import{_ as B}from"./B4vThZpn.js";import{u as N,a4 as T,q as D,c as o,a as d,t as v,e as V,F as S,r as w,n as x,i as U,d as F,m as L,l as m,o as t,I as M,g as y,h as C}from"./BKiFavna.js";import{u as q}from"./BZ7f31ti.js";import{u as z}from"./DKzHUNYh.js";import{_ as A}from"./DlAUqK2U.js";const E={class:"page-hdr"},G={class:"tabs"},K=["onClick"],$={class:"settings-card"},H=["onUpdate:modelValue"],J=["onUpdate:modelValue"],P=["disabled"],Q={key:0,class:"fas fa-spinner fa-spin"},R={__name:"settings",setup(W){const{lang:p}=N(),{api:f}=q(),b=z(),a=m({}),c=m(!1),u=m(""),_=m("success"),n=m("general"),j=L(()=>Object.keys(a.value)),h=T("siteSettings",()=>({})),I=l=>{const s=l.toLowerCase();return s.includes("logo")||s.includes("favicon")||s.includes("og_image")||s.includes("banner")},O=async()=>{try{const l=await f.get("/admin/settings");a.value=l.data.settings;const s={};for(const g of Object.values(a.value))Object.assign(s,g);h.value=s}catch{}},k=async()=>{c.value=!0,u.value="";const l={};for(const s of Object.values(a.value))Object.assign(l,s);try{await f.put("/admin/settings",{settings:l}),u.value=p.value==="bn"?"সেটিংস সেভ হয়েছে!":"Settings saved!",_.value="success",b.success(u.value),h.value={...l}}catch(s){u.value=s.message,_.value="error",b.error(s.message)}finally{c.value=!1}};return D(O),(l,s)=>{const g=B;return t(),o("div",null,[d("h1",E,v(V(p)==="bn"?"সাইট সেটিংস":"Site Settings"),1),d("div",G,[(t(!0),o(S,null,w(j.value,i=>(t(),o("button",{key:i,class:x(["tab",{active:n.value===i}]),onClick:e=>n.value=i},v(i),11,K))),128))]),d("div",$,[(t(!0),o(S,null,w(a.value[n.value],(i,e)=>(t(),o("div",{key:e,class:"form-group"},[d("label",null,v(e),1),I(e)?(t(),M(g,{key:0,modelValue:a.value[n.value][e],"onUpdate:modelValue":r=>a.value[n.value][e]=r,endpoint:"/admin/upload/image"},null,8,["modelValue","onUpdate:modelValue"])):e.includes("description")||e.includes("address")||e.includes("keywords")||e.includes("about")?y((t(),o("textarea",{key:1,"onUpdate:modelValue":r=>a.value[n.value][e]=r,rows:"2"},null,8,H)),[[C,a.value[n.value][e]]]):y((t(),o("input",{key:2,"onUpdate:modelValue":r=>a.value[n.value][e]=r},null,8,J)),[[C,a.value[n.value][e]]])]))),128)),u.value?(t(),o("p",{key:0,class:x(["msg",_.value])},v(u.value),3)):U("",!0),d("button",{onClick:k,disabled:c.value,class:"btn-primary"},[c.value?(t(),o("i",Q)):U("",!0),F(" "+v(c.value?"Saving...":V(p)==="bn"?"সেভ করুন":"Save Settings"),1)],8,P)])])}}},ae=A(R,[["__scopeId","data-v-a6deeb04"]]);export{ae as default};
