2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
import"../chunks/DsnmJJEf.js";import{o as _t}from"../chunks/DukJHxi2.js";import{p as pt,i as p,m as H,e as gt,f as J,a as h,b as Nt,k as ht,o as At,$ as xt,g as e,j as r,h as y,d as f,s as I,r as d,c as C,t as w}from"../chunks/krC2xWPP.js";import{e as Ct,s as G}from"../chunks/CddAxf8c.js";import{i as X}from"../chunks/DjsWWzyL.js";import{h as Et,s as $}from"../chunks/j_DJpx8B.js";import{i as g,c as Tt}from"../chunks/Cu5ilWky.js";import"../chunks/BSopV7IU.js";import{g as yt,s as It}from"../chunks/CMqN2HxG.js";import{c as Ot}from"../chunks/Lyt-zgeV.js";import{a as z,c as St,s as Dt,h as bt,B as Ft,v as kt}from"../chunks/D7PIEGLR.js";import{A as W}from"../chunks/CsG_FdPZ.js";import{t as D,B as Mt}from"../chunks/Lvd_r9sp.js";import{S as jt}from"../chunks/K87jKp17.js";import{U as Lt}from"../chunks/Bf-u42YS.js";import{S as Ut}from"../chunks/h5AuRbZl.js";import{L as Q}from"../chunks/C_E2vM9U.js";import{S as wt}from"../chunks/CV_JZMCk.js";var Gt=C("<!> ",1),Xt=C('<div><div><div class="flex items-center gap-2"><!> <h1> </h1></div> <!></div></div>'),$t=C('<div class="flex flex-1 items-center justify-center"><!></div>'),zt=C('<div class="flex-1 overflow-y-auto"><div class="px-6 py-6"><!></div></div>'),Bt=C('<div class="flex flex-1 items-center justify-center text-sm text-muted-foreground"> </div>'),qt=C('<div class="flex h-full flex-col"><!> <!> <!></div>');function ce(Y,Z){pt(Z,!0);const tt=y(()=>Tt.isSuperAdmin);let c=p(null),a=p(H({})),u=p(H({})),b=p("{}"),F=p(""),k=p(!0),E=p(!1),M=p(!1);const B=y(()=>z(e(a))!==e(b));let et=y(()=>!e(c)||!bt(e(c).fields,e(a)));async function rt(){r(k,!0);try{const[t,o]=await Promise.all([yt("accounts"),Ot().catch(()=>null)]);r(a,t.data??{},!0),r(b,z(e(a)),!0),r(F,t.etag,!0),r(c,o,!0)}catch(t){(t&&typeof t=="object"&&"status"in t?t.status:0)===403?r(M,!0):D.error(g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.FAILED_TO_LOAD"))}finally{r(k,!1)}}function st(t,o){const N=t.split("."),A={...e(a)};let i=A;for(let x=0;x<N.length-1;x++){const n=N[x];typeof i[n]!="object"||i[n]===null?i[n]={}:i[n]={...i[n]},i=i[n]}i[N[N.length-1]]=o,r(a,A,!0);const O=e(c)?kt(e(c).fields,t,A):null;if(O)r(u,{...e(u),[t]:O},!0);else if(e(u)[t]){const{[t]:x,...n}=e(u);r(u,n,!0)}}async function q(){if(r(u,e(c)?St(e(c).fields,e(a)):{},!0),Object.keys(e(u)).length>0){Dt();return}r(E,!0);try{const t=await It("accounts",e(a),e(F));r(a,t.data??e(a),!0),r(b,z(e(a)),!0),r(F,t.etag,!0),D.success(g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.SAVED"))}catch(t){(t&&typeof t=="object"&&"status"in t?t.status:0)===409?D.error(g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.MODIFIED_ELSEWHERE")):D.error(g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.FAILED_TO_SAVE"))}finally{r(E,!1)}}function at(t){(t.metaKey||t.ctrlKey)&&t.key==="s"&&(t.preventDefault(),e(B)&&!e(E)&&q())}_t(()=>{rt()});var K=gt();Et("l0fj7g",t=>{ht(o=>{xt.title=o??""},[()=>g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.PAGE_TITLE")])}),Ct("keydown",At,at);var ot=J(K);{var it=t=>{W(t,{})},nt=t=>{W(t,{})},lt=t=>{var o=qt(),N=f(o);jt(N,{noBorder:!0,children:(s,v)=>{let m=()=>v?.().scrolled;var S=Xt(),j=f(S),L=f(j),P=f(L);{let T=y(()=>m()?16:20);Ut(P,{get size(){return e(T)},class:"text-muted-foreground"})}var U=I(P,2),ct=f(U,!0);d(U),d(L);var ft=I(L,2);{let T=y(()=>!e(B)||e(E)||!e(et));Mt(ft,{size:"sm",get disabled(){return e(T)},onclick:q,children:(dt,Kt)=>{var R=Gt(),V=J(R);{var ut=_=>{Q(_,{size:14,class:"animate-spin"})},vt=_=>{wt(_,{size:14})};X(V,_=>{e(E)?_(ut):_(vt,-1)})}var mt=I(V);w(_=>G(mt,` ${_??""}`),[()=>g.t("ADMIN_NEXT.SAVE")]),h(dt,R)},$$slots:{default:!0}})}d(j),d(S),w(T=>{$(S,1,`px-6 transition-[padding] duration-200 ${m()?"py-2":"pt-6 pb-3"}`),$(j,1,`flex items-center justify-between ${m()?"min-h-6":"min-h-8"}`),$(U,1,`font-semibold tracking-tight text-foreground transition-[font-size] duration-200 ${m()?"text-sm":"text-xl"}`),G(ct,T)},[()=>g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.TITLE")]),h(s,S)},$$slots:{default:!0}});var A=I(N,2);Lt(A,{});var i=I(A,2);{var O=l=>{var s=$t(),v=f(s);Q(v,{size:24,class:"animate-spin text-muted-foreground"}),d(s),h(l,s)},x=l=>{var s=zt(),v=f(s),m=f(v);Ft(m,{get fields(){return e(c).fields},get data(){return e(a)},onchange:st,get errors(){return e(u)}}),d(v),d(s),h(l,s)},n=l=>{var s=Bt(),v=f(s,!0);d(s),w(m=>G(v,m),[()=>g.t("ADMIN_NEXT.ACCOUNTS_CONFIG.NO_FIELDS")]),h(l,s)};X(i,l=>{e(k)?l(O):e(c)?l(x,1):l(n,-1)})}d(o),h(t,o)};X(ot,t=>{!e(tt)&&!e(M)?t(it):e(M)?t(nt,1):t(lt,-1)})}h(Y,K),Nt()}export{ce as component};
|