import{_ as S}from"./Ds_Hg87V.js";import{_ as k}from"./BuyjqtaR.js";import{e as $,i as I,k as N,r as v,l as V,x as R,m as B,o as p,w as r,b as l,a as t,t as o,n as s,c as h,F as L,y as M,p as T,d,_ as y,z as g}from"./BoB2h2qv.js";import{_ as U}from"./Bj6F-phl.js";import{_ as P,a as D}from"./CzJS0Rvs.js";import{_ as E}from"./llbY0rJB.js";import{_ as F,a as A,b as z}from"./flZqRd3D.js";import{_ as j}from"./BipjDKWG.js";import"./DlAUqK2U.js";const q={class:"text-2xl font-bold"},G={class:"flex flex-col gap-6"},J={class:"space-y-4"},K={class:"text-lg font-semibold"},O={class:"grid grid-cols-1 gap-3 md:grid-cols-2"},Q={class:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},W={class:"mt-1 text-sm"},X={class:"space-y-4"},Y={class:"text-lg font-semibold"},Z={class:"flex flex-wrap items-center gap-2"},ee={class:"list-disc list-inside space-y-1 text-sm"},de=$({__name:"settings",setup(se){const{t:e}=I(),i=N(),c=v({serverHost:"",api:{baseURL:""},s3:{endpoint:"",region:""}}),n=v({serverHost:""}),f=v(!1),x=async()=>{try{const a=await g.loadConfig();c.value=a,n.value.serverHost=a.serverHost}catch{i.error(e("Failed to load current configuration"))}},b=async()=>{if(!n.value.serverHost){i.error(e("Please enter server address"));return}f.value=!0;try{let a=n.value.serverHost.trim();/^https?:\/\//.test(a)||(a="https://"+a);const _=new URL(a),m=/^https?:\/\//.test(n.value.serverHost)?n.value.serverHost:a;localStorage.setItem("rustfs-server-host",m),/^https?:\/\//.test(n.value.serverHost)||(n.value.serverHost=a),g.clearCache(),i.success(e("Configuration saved successfully")),setTimeout(()=>{window.location.reload()},200)}catch{i.error(e("Invalid server address format"))}finally{f.value=!1}},C=async()=>{localStorage.removeItem("rustfs-server-host"),g.clearCache(),i.success(e("Configuration reset successfully")),setTimeout(()=>{window.location.reload()},200)};V(()=>{x()});const w=R(()=>[{label:e("Server Host"),value:c.value.serverHost||e("Not configured")},{label:e("API Base URL"),value:c.value.api.baseURL||e("Not configured")},{label:e("S3 Endpoint"),value:c.value.s3.endpoint||e("Not configured")},{label:e("S3 Region"),value:c.value.s3.region||e("Not configured")}]);return(a,_)=>{const m=S,H=k;return p(),B(H,null,{default:r(()=>[l(m,null,{default:r(()=>[t("h1",q,o(s(e)("Settings")),1)]),_:1}),t("div",G,[t("div",J,[t("h2",K,o(s(e)("Current Configuration")),1),t("dl",O,[(p(!0),h(L,null,M(s(w),u=>(p(),h("div",{key:u.label,class:"rounded-md border p-3"},[t("dt",Q,o(u.label),1),t("dd",W,o(u.value),1)]))),128))])]),t("div",X,[t("h2",Y,o(s(e)("Server Configuration")),1),t("form",{class:"space-y-4",onSubmit:T(b,["prevent"])},[l(s(F),null,{default:r(()=>[l(s(A),null,{default:r(()=>[d(o(s(e)("Server Address")),1)]),_:1}),l(s(z),null,{default:r(()=>[l(s(U),{modelValue:n.value.serverHost,"onUpdate:modelValue":_[0]||(_[0]=u=>n.value.serverHost=u),placeholder:s(e)("Please enter server address (e.g., http://localhost:9000)"),autocomplete:"off"},null,8,["modelValue","placeholder"])]),_:1}),l(s(j),null,{default:r(()=>[d(o(s(e)("Example: http://localhost:9000 or https://your-domain.com")),1)]),_:1})]),_:1}),t("div",Z,[l(s(y),{type:"submit",variant:"default",loading:f.value},{default:r(()=>[d(o(s(e)("Save Configuration")),1)]),_:1},8,["loading"]),l(s(y),{type:"button",variant:"outline",onClick:C},{default:r(()=>[d(o(s(e)("Reset to Default")),1)]),_:1})])],32),l(s(P),null,{default:r(()=>[l(s(E),null,{default:r(()=>[d(o(s(e)("Configuration Information")),1)]),_:1}),l(s(D),null,{default:r(()=>[t("ul",ee,[t("li",null,o(s(e)("Configuration is saved locally in your browser")),1),t("li",null,o(s(e)("Page will refresh automatically after saving configuration")),1),t("li",null,o(s(e)("Make sure the server address is accessible from your network")),1)])]),_:1})]),_:1})])])]),_:1})}}});export{de as default};
