import{_ as S,a as t,b as o,d as l,t as c,F as h,j as g,q as p,f as x,s as U,v as f,x as V,r as v,o as C,k}from"./app-kAt5lVqd.js";const F={setup(){const i=v({}),r=v(!0),u=v(""),n=async()=>{var a,e;try{r.value=!0,u.value="";const{data:s}=await k.get("/super-admin/settings");console.log("Settings loaded:",s),i.value=s.data}catch(s){console.error("Failed to load settings:",s),u.value=((e=(a=s.response)==null?void 0:a.data)==null?void 0:e.message)||"Failed to load settings"}finally{r.value=!1}},m=async()=>{var a,e;try{const s=[];Object.values(i.value).forEach(b=>{b.forEach(y=>{s.push({id:y.id,value:y.value})})}),await k.post("/super-admin/settings/bulk-update",{settings:s}),alert("Settings saved successfully")}catch(s){console.error("Failed to save settings:",s),alert(((e=(a=s.response)==null?void 0:a.data)==null?void 0:e.message)||"Failed to save settings")}},_=a=>a.charAt(0).toUpperCase()+a.slice(1).replace(/_/g," "),d=a=>a.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");return C(()=>{n()}),{settings:i,loading:r,error:u,saveSettings:m,formatGroupName:_,formatKey:d}}},D={class:"settings-management"},E={class:"settings-header"},M={key:0,class:"loading"},N={key:1,class:"error"},j={key:2,class:"settings-groups"},w={class:"group-title"},B={class:"settings-card"},A={class:"setting-label"},G={class:"setting-key"},K={class:"setting-input"},L=["onUpdate:modelValue","type"],q=["onUpdate:modelValue"],I={key:2,class:"checkbox-label"},O=["onUpdate:modelValue"],T=["onUpdate:modelValue"];function z(i,r,u,n,m,_){return o(),t("div",D,[l("div",E,[r[1]||(r[1]=l("h2",null,"System Settings",-1)),l("button",{onClick:r[0]||(r[0]=(...d)=>n.saveSettings&&n.saveSettings(...d)),class:"btn-primary"},"💾 Save Changes")]),n.loading?(o(),t("div",M,"Loading settings...")):n.error?(o(),t("div",N,c(n.error),1)):(o(),t("div",j,[(o(!0),t(h,null,g(n.settings,(d,a)=>(o(),t("div",{key:a,class:"settings-group"},[l("h3",w,c(n.formatGroupName(a)),1),l("div",B,[(o(!0),t(h,null,g(d,e=>(o(),t("div",{key:e.id,class:"setting-item"},[l("div",A,[l("label",null,c(n.formatKey(e.key)),1),l("span",G,c(e.key),1)]),l("div",K,[e.type==="text"||e.type==="email"?p((o(),t("input",{key:0,"onUpdate:modelValue":s=>e.value=s,type:e.type,class:"form-input"},null,8,L)),[[U,e.value]]):e.type==="number"?p((o(),t("input",{key:1,"onUpdate:modelValue":s=>e.value=s,type:"number",step:"any",class:"form-input"},null,8,q)),[[f,e.value,void 0,{number:!0}]]):e.type==="boolean"?(o(),t("label",I,[p(l("input",{"onUpdate:modelValue":s=>e.value=s,type:"checkbox",class:"form-checkbox","true-value":"1","false-value":"0"},null,8,O),[[V,e.value]]),l("span",null,c(e.value==="1"?"Enabled":"Disabled"),1)])):e.type==="textarea"?p((o(),t("textarea",{key:3,"onUpdate:modelValue":s=>e.value=s,rows:"3",class:"form-input"},null,8,T)),[[f,e.value]]):x("",!0)])]))),128))])]))),128))]))])}const J=S(F,[["render",z],["__scopeId","data-v-1c0c756d"]]);export{J as default};
