import{f as g,a as o,c as m}from"../chunks/bmn8XlW7.js";import{o as H}from"../chunks/CJbqisBi.js";import{p as J,a as K,d as N,e as y,c as d,s as v,g as e,h as O,r as b,f as c,t as Q}from"../chunks/DpkolLiq.js";import{s as R}from"../chunks/pfhwnV1O.js";import{i as u,a as T,b as U}from"../chunks/TXeUdaq1.js";import{k as V}from"../chunks/B3p6J_mX.js";import{g as w}from"../chunks/C2ETuzsT.js";import{r as k}from"../chunks/CiPTfhJW.js";import{p as W}from"../chunks/CNEWdp3h.js";import{c as X,p as Y}from"../chunks/DxBGAPM1.js";import{a as Z}from"../chunks/MqDOSMkA.js";var aa=g('<div class="text-center py-12 text-muted-foreground">Loading profile...</div>'),ea=g('<div class="text-center py-12 text-red-500 dark:text-red-400"> </div>'),ra=g('<div class="max-w-2xl mx-auto"><h1 class="text-2xl font-bold mb-6">Edit Server Profile</h1> <!></div>');function ca(S,C){J(C,!0);const E=()=>U(W,"$page",F),[F,I]=T();let s=v(null),_=v(!0),l=v(null);const x=O(()=>parseInt(E().params.id??"0",10));H(async()=>{try{d(s,await X.get(e(x)),!0)}catch(a){d(l,a instanceof Error?a.message:"Failed to load profile",!0)}finally{d(_,!1)}});async function P(a){await Y.update(e(x),a),await w(k("/profiles"))}async function $(){await w(k("/profiles"))}var f=ra(),L=N(y(f),2);{var M=a=>{var i=aa();o(a,i)},j=a=>{var i=m(),q=c(i);{var z=r=>{var t=ea(),n=y(t,!0);b(t),Q(()=>R(n,e(l))),o(r,t)},A=r=>{var t=m(),n=c(t);{var B=p=>{var h=m(),D=c(h);V(D,()=>e(s).id,G=>{Z(G,{get profile(){return e(s)},onSubmit:P,onCancel:$})}),o(p,h)};u(n,p=>{e(s)&&p(B)},!0)}o(r,t)};u(q,r=>{e(l)?r(z):r(A,!1)},!0)}o(a,i)};u(L,a=>{e(_)?a(M):a(j,!1)})}b(f),o(S,f),K(),I()}export{ca as component};
