@shumai-one/shumai 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{chunk-qxscgcn9.js → chunk-01ym2agz.js} +1 -1
- package/bin/{chunk-ae6zgjhd.js → chunk-047n9gfs.js} +2 -2
- package/bin/chunk-0a4ahz7r.js +2 -0
- package/bin/{chunk-v5hz09a1.js → chunk-0awcpx0a.js} +2 -2
- package/bin/{chunk-19q13a80.js → chunk-0fbgfgxv.js} +5 -5
- package/bin/{chunk-jt6v15wx.js → chunk-0nnqha4f.js} +1 -1
- package/bin/chunk-0tvggyy4.js +1 -0
- package/bin/{chunk-zckxc8m6.js → chunk-113baw0m.js} +2 -2
- package/bin/{chunk-mneeg71d.js → chunk-1dbjyarc.js} +2 -2
- package/bin/{chunk-951r2rx1.js → chunk-1qre79kf.js} +1 -1
- package/bin/chunk-27v3yepb.js +1 -0
- package/bin/{chunk-5vqbzsjv.js → chunk-2rq3w8sg.js} +1 -1
- package/bin/{chunk-v034sfw8.js → chunk-3020am4q.js} +2 -2
- package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
- package/bin/chunk-3pwwg1xm.js +1 -0
- package/bin/{chunk-19jpn3r6.js → chunk-3sfb63fp.js} +1 -1
- package/bin/{chunk-wwkhskce.js → chunk-3tg10kwz.js} +2 -2
- package/bin/{chunk-0y4zq3y4.js → chunk-4g4pxmef.js} +1 -1
- package/bin/{chunk-2pw7xcrn.js → chunk-4jj92zwa.js} +1 -1
- package/bin/{chunk-bpxw19ez.js → chunk-4yhvexzk.js} +1 -1
- package/bin/chunk-58cbk6e8.js +1 -0
- package/bin/{chunk-eqr0znmc.js → chunk-59t9s2jh.js} +1 -1
- package/bin/{chunk-n76w2wcr.js → chunk-5e7r7a9d.js} +1 -1
- package/bin/{chunk-8tzfcqtb.js → chunk-5m51b7af.js} +1 -1
- package/bin/{chunk-m6v8vt2b.js → chunk-65t6rm5d.js} +2 -2
- package/bin/chunk-6bed0rz4.js +1 -0
- package/bin/{chunk-1nvj833s.js → chunk-6smn0q1n.js} +5 -5
- package/bin/{chunk-r249n1xe.js → chunk-6zerk0em.js} +2 -2
- package/bin/{chunk-gvas3xkp.js → chunk-7bbsv8g0.js} +1 -1
- package/bin/chunk-83bdgs2c.js +1 -0
- package/bin/{chunk-93p27bbm.js → chunk-86qtjd30.js} +5 -5
- package/bin/{chunk-b5r0be06.js → chunk-8rekh4h9.js} +1 -1
- package/bin/{chunk-d2dgazjj.js → chunk-8s9fehda.js} +1 -1
- package/bin/{chunk-r776bhsg.js → chunk-8sf2hf31.js} +1 -1
- package/bin/{chunk-mn108p93.js → chunk-9d3w678j.js} +1 -1
- package/bin/{chunk-xr2v0d6y.js → chunk-9gftd4f7.js} +4 -4
- package/bin/{chunk-n9vp9nbg.js → chunk-9rcg8zgs.js} +32 -32
- package/bin/{chunk-6jkjx0n2.js → chunk-a23q1kc4.js} +3 -3
- package/bin/{chunk-81dawvn4.js → chunk-a6cdt85k.js} +2 -2
- package/bin/chunk-a76h3ehe.js +1 -0
- package/bin/{chunk-rmvhyqyb.js → chunk-b1bkd2p4.js} +8 -8
- package/bin/{chunk-wnqxyqrg.js → chunk-bf5m8f6t.js} +2 -2
- package/bin/chunk-cf57fk11.js +2 -0
- package/bin/{chunk-0v9srsdz.js → chunk-cv5xx81e.js} +1 -1
- package/bin/{chunk-3q5qkfkc.js → chunk-czybv3vy.js} +1 -1
- package/bin/{chunk-ggfx2b0f.js → chunk-d4sbcvpa.js} +1 -1
- package/bin/{chunk-9ggwc289.js → chunk-d6xezgrg.js} +1 -1
- package/bin/{chunk-bbcmhcvc.js → chunk-da86fpjt.js} +2 -2
- package/bin/chunk-dzjmwat0.js +14 -0
- package/bin/{chunk-rza95y4z.js → chunk-eex8sjfs.js} +2 -2
- package/bin/{chunk-9zgqjdx1.js → chunk-emgyjhmx.js} +2 -2
- package/bin/{chunk-k3prp6c6.js → chunk-exmwerag.js} +5 -5
- package/bin/{chunk-kzr6ecke.js → chunk-f38xyahm.js} +1 -1
- package/bin/{chunk-ffj9cq9y.js → chunk-fb1bes2h.js} +1 -1
- package/bin/chunk-fbvak7q2.js +1 -0
- package/bin/{chunk-15w79661.js → chunk-fg9sr6r9.js} +1 -1
- package/bin/{chunk-dppfek34.js → chunk-fyb6t7ct.js} +2 -2
- package/bin/chunk-g2ptqqm3.js +3 -0
- package/bin/{chunk-t1yamxgk.js → chunk-ggwqxn95.js} +1 -1
- package/bin/chunk-ghk54h71.js +13 -0
- package/bin/{chunk-kvwec0p3.js → chunk-h1fbev9c.js} +2 -2
- package/bin/{chunk-f5z3096k.js → chunk-h9akn41s.js} +2 -2
- package/bin/{chunk-asy868kq.js → chunk-hdansxny.js} +1 -1
- package/bin/{chunk-grjek810.js → chunk-hjwpd09v.js} +2 -2
- package/bin/{chunk-zf5cyxnt.js → chunk-hjzbw975.js} +1 -1
- package/bin/{chunk-jgfye6nf.js → chunk-j4p3eqtd.js} +1 -1
- package/bin/chunk-jtkxeat4.js +2 -0
- package/bin/{chunk-8zgq5sav.js → chunk-jw4g9628.js} +3 -3
- package/bin/{chunk-0ge2mm8j.js → chunk-jxebakyq.js} +1 -1
- package/bin/{chunk-0asthrjf.js → chunk-kfewyax2.js} +2 -2
- package/bin/chunk-kk3m4za5.js +1 -0
- package/bin/{chunk-vzdgsfkf.js → chunk-m7tnj47b.js} +1 -1
- package/bin/{chunk-w73v578p.js → chunk-maw5ah8t.js} +2 -2
- package/bin/{chunk-8ny7wvzb.js → chunk-n0wwtjwv.js} +1 -1
- package/bin/{chunk-e439kt05.js → chunk-nahdd2t9.js} +1 -1
- package/bin/{chunk-04avc4fn.js → chunk-nv7tztvh.js} +32 -32
- package/bin/{chunk-mn208vrv.js → chunk-nyjwdxyj.js} +2 -2
- package/bin/{chunk-qmrg2jhs.js → chunk-p0yfxt5e.js} +5 -5
- package/bin/{chunk-p0j4wpa5.js → chunk-q27qn367.js} +2 -2
- package/bin/{chunk-j53sjkxt.js → chunk-q36sdt2w.js} +1 -1
- package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
- package/bin/{chunk-cpj562n6.js → chunk-qbj5pe8t.js} +1 -1
- package/bin/chunk-qj0bxb1m.js +2 -0
- package/bin/{chunk-9bakwac0.js → chunk-qk5hsn6e.js} +4 -4
- package/bin/{chunk-6rn094yj.js → chunk-qnyqtaf0.js} +1 -1
- package/bin/{chunk-ypkkfwfb.js → chunk-qqkr6h07.js} +2 -2
- package/bin/chunk-qyqc5j3a.css +1 -0
- package/bin/chunk-qzaf6bre.js +2 -0
- package/bin/{chunk-cx32wsa1.js → chunk-r1e59gf0.js} +1 -1
- package/bin/chunk-ra5csbkr.js +2 -0
- package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
- package/bin/{chunk-ryepy5er.js → chunk-rx9g95wk.js} +4 -4
- package/bin/{chunk-2w6gve12.js → chunk-rxyy37wa.js} +3 -3
- package/bin/{chunk-7qvvf0yd.js → chunk-scez7ppq.js} +2 -2
- package/bin/{chunk-twpc640e.js → chunk-t2a1vq34.js} +1 -1
- package/bin/chunk-t879v3b7.js +1 -0
- package/bin/{chunk-a8bymrv1.js → chunk-tjavzarz.js} +2 -2
- package/bin/{chunk-ce0bhc72.js → chunk-treyx8em.js} +1 -1
- package/bin/{chunk-dche0gy0.js → chunk-v3z4z04s.js} +1 -1
- package/bin/{chunk-5bk16qdp.js → chunk-v3z63tpw.js} +2 -2
- package/bin/{chunk-5rzxekn4.js → chunk-v9bes1fv.js} +1 -1
- package/bin/{chunk-d5hbzp7t.js → chunk-vjyget8s.js} +1 -1
- package/bin/{chunk-4zksqvwj.js → chunk-vmm9m3nv.js} +2 -2
- package/bin/chunk-vvr8tnse.js +211 -0
- package/bin/{chunk-tvkekn4z.js → chunk-w3stry4v.js} +1 -1
- package/bin/{chunk-3pm6q6kg.js → chunk-w89czwjj.js} +1 -1
- package/bin/{chunk-rw5h0n0s.js → chunk-wk0hk00z.js} +1 -1
- package/bin/{chunk-15vsw36h.js → chunk-ww9qq8yq.js} +5 -5
- package/bin/chunk-x4q082e6.js +2 -0
- package/bin/{chunk-98mg3dpd.js → chunk-x6rf77jm.js} +4 -4
- package/bin/chunk-x7dyj53k.js +2 -0
- package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
- package/bin/{chunk-5nqvqvqp.js → chunk-xcrd0y8v.js} +3 -3
- package/bin/{chunk-0j22699g.js → chunk-z0z0jn5h.js} +2 -2
- package/bin/{chunk-w9z27p0m.js → chunk-zasjhrwc.js} +1 -1
- package/bin/chunk-zefds5gg.js +1 -0
- package/bin/{chunk-8ayz61rc.js → chunk-zzzgk1d5.js} +3 -3
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +390 -373
- package/package.json +8 -11
- package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
- package/prisma/schema.prisma +10 -8
- package/bin/chunk-2gf95tj0.js +0 -1
- package/bin/chunk-2tk5w3jc.js +0 -1
- package/bin/chunk-301e7g3z.js +0 -2
- package/bin/chunk-3kmjbc3m.js +0 -2
- package/bin/chunk-3td60k1m.js +0 -2
- package/bin/chunk-42hrvk6k.js +0 -211
- package/bin/chunk-8abhmarc.js +0 -2
- package/bin/chunk-965102pf.js +0 -3
- package/bin/chunk-acn3r2m2.js +0 -1
- package/bin/chunk-ce75dw3k.css +0 -1
- package/bin/chunk-d9qpgkek.js +0 -2
- package/bin/chunk-dv6p6n5e.js +0 -1
- package/bin/chunk-gnt9gewm.js +0 -2
- package/bin/chunk-k97axrc4.js +0 -13
- package/bin/chunk-qb178ntp.js +0 -2
- package/bin/chunk-s4r6e6ms.js +0 -1
- package/bin/chunk-syjjke3f.js +0 -1
- package/bin/chunk-tgfxe0sb.js +0 -1
- package/bin/chunk-tjretpx8.js +0 -1
- package/bin/chunk-w4yjgez6.js +0 -14
- package/bin/chunk-wjcebkpb.js +0 -1
- package/bin/chunk-ws71fg50.js +0 -2
- package/bin/chunk-yfp3q4da.js +0 -1
- package/bin/chunk-z8e4wc59.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Q,P,m,$e,D,_,u,Zs,S,L,t,o,G,Z,B,Fc,Ue,A,I,ir,zn,Sr,O,Tt,Re,ve,Et,er,ro,Hn,hi,xo,fe,Ut,we,Jo,Pe,E,ps,C,Ce,Ie,Te,ge,Ae,_e,K,Vt,n,Na,$A,Cf,YA,JA,If,XA,ld,r0,n0,Om,Fm,s0,i0,u0,d0,f0,p0,h0,g0,A0,_0,y0,b0,w0,x0,S0,E0,C0,Bm,I0,Um,T0,zm,M0,jm,k0,qm,R0,Hm,P0,$m,N0,Gm,D0,Vm,O0,F0,L0,Qm,Z0,B0,U0,Km,Wm,Ym,Jm,z0,j0,Q0,K0,X0,n_,ud,dd,th,o_,s_,rh,i_,a_,nh,l_,kf,oh,sh,c_,d_,fd,h_,g_,A_,v_,M_,k_,R_,P_,ah,D_,O_,F_,L_,Z_,B_,Ne,z_,q_,H_,$_,V_,Da,J_,X_,ey,ty,uh,ny,oy,cy,dy,mh,jc,by,Ey,Cy,Iy,My,ky,Ny,Oy,Hy,$y,ct,Gy,Vy,Yy,Jy,Xy,rb,Bf,vh,sb,Sl,ub,db,zf,pb,mb,Sh,_b,Eh,yb,bb,jf,xb,Ch,Sb,Ih,Eb,Tb,Mb,Rb,qf,Nb,Ob,Th,Zb,Bb,$s,Xo,Jb,ev,Rh,Oa,yd,nv,ov,Ph,lv,$f,Oh,Fh,El,uv,bd,Lh,Zh,pv,mv,hv,vd,_v,yv,Tv,Mv,Zv,Bv,Uv,qh,zv,jv,Hv,$v,Hh,Sd,$h,Xv,ew,tw,rw,nw,ow,sw,iw,aw,lw,dw,fw,pw,mw,hw,gw,Aw,_w,yw,bw,vw,ww,Sw,Vh,Cw,Iw,Tw,Kh,Mw,Dw,Ow,Fw,Lw,Zw,Bw,$w,Qw,Xw,ex,tx,rx,op,nx,ox,Yh,sx,ix,ax,lx,cx,Jh,Xh,ux,dx,fx,px,eg,mx,tg,hx,gx,rg,Qc,Cd,Ax,_x,ng,yx,bx,vx,wx,xx,Sx,Ex,Cx,Ix,Mx,kx,sp,ip,Fx,Lx,Zx,ig,Bx,Ux,zx,jx,qx,Id,Hx,Gx,Vx,Qx,Kx,Yx,Il,Jx,eS,tS,rS,nS,oS,dS,fS,gS,gg,AS,_g,yg,Md,xS,SS,ES,fp,pp,MS,kS,NS,FS,LS,vg,ZS,US,oE,wg,sE,iE,Sg,aE,lE,cE,dE,gE,AE,Za,Ba,Ua,_E,yE,bE,wE,CE,IE,kE,Pg,qE,HE,$E,GE,Dg,Og,Fg,Lg,VE,Zg,Bg,Ug,zg,QE,KE,JE,eC,Hg,wp,rC,oC,sC,aC,xp,Sp,Ep,Cp,dC,Pd,Nd,Dd,Od,Fd,pC,mC,Ld,hC,Zd,gC,Bd,AC,Ip,Nl,Tp,_C,yC,SC,EC,Ud,Mp,Dl,Jg,Xg,GC,VC,Gn,QC,Vs,rA,Op,sA,iA,mI,aA,lA,hI,_I,yI,uA,vI,xI,dA,TI,fA,MI,kI,RI,PI,za,Zp,mA,qI,HI,hA,$I,GI,VI,QI,KI,WI,YI,JI,XI,eT,tT,rT,nT,oT,sT,fT,pT,mT,hT,gT,AT,_T,yT,bT,vT,wT,xT,ST,ET,CT,IT,TT,MT,kT,RT,DT,ZT,$T,VT,QT,KT,WT,YT,SA,XT,s1,i1,a1,EA,l1,c1,u1,p1,Gd,IA,h1,g1,A1,_1,y1,b1,v1,w1,x1,S1,MA,k1,L1,Z1,B1,U1,kA,z1,Q1,K1,W1,Y1,J1,X1,eM,tM,rM,Xe,et,tt,rt,nt,ot,st,it,de,le,me,qe,ce,Mt,z,ue,Ot,M,f,te,R,Ve,oo,su,iu,NA,au,ia,DA,Qs,OA,qa,FA,lu,Eo,Co,Yr,Rn,he,At,_t,yt,Ei,W,Me,Fe,Le,Ze,Be,ne,wr,ur,_r,Ke,vt,wt,kt,at,ca}from"./chunk-vvr8tnse.js";import{jo}from"./chunk-zasjhrwc.js";import{Ro,yr}from"./chunk-fb1bes2h.js";import{Xl,ec}from"./chunk-da86fpjt.js";import{Ys,lo,ha,zo,wn,tc,Xa,Oi,rc}from"./chunk-a6cdt85k.js";import{nc}from"./chunk-x4q082e6.js";import{Pn,Nn,Dn,xr,It,xt}from"./chunk-ggwqxn95.js";import{ga}from"./chunk-q36sdt2w.js";import{Mo}from"./chunk-fg9sr6r9.js";import{ko}from"./chunk-hjzbw975.js";import{Kn,co}from"./chunk-5m51b7af.js";import{nr}from"./chunk-emgyjhmx.js";import{uo}from"./chunk-01ym2agz.js";import{dn}from"./chunk-hjwpd09v.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-8s9fehda.js";var dr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ma=I("circle-x",dr);var cr=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],as=I("at-sign",cr);var mr=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],ss=I("blocks",mr);var pr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],rs=I("film",pr);var fr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ua=I("globe",fr);var gr=[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]],Xt=I("key",gr);var hr=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Aa=I("layout-dashboard",hr);var vr=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],os=I("maximize-2",vr);var br=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],is=I("message-circle",br);var Cr=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],ns=I("move",Cr);var kr=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],Ct=I("puzzle",kr);var Mr=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],pa=I("refresh-cw",Mr);var Fr=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ls=I("send",Fr);var Dr=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ds=I("shield-check",Dr);var Ar=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],fa=I("video",Ar);var Ir=[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]],qt=I("zap",Ir);var Tr=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],cs=I("zoom-in",Tr);var Er=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],ms=I("zoom-out",Er);S();S();var Vr=ps("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}});function Qe({className:e,orientation:r="vertical",...a}){return t("div",{role:"group","data-slot":"field","data-orientation":r,className:E(Vr({orientation:r}),e),...a})}function ze({className:e,...r}){return t(W,{"data-slot":"field-label",className:E("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",e),...r})}function aa({className:e,...r}){return t("p",{"data-slot":"field-description",className:E("text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...r})}function Ge({className:e,children:r,errors:a,...l}){let s=D(()=>{if(r)return r;if(!a?.length)return null;let d=[...new Map(a.map((c)=>[c?.message,c])).values()];if(d?.length==1)return d[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:d.map((c,h)=>c?.message&&t("li",{children:c.message},h))})},[r,a]);if(!s)return null;return t("div",{role:"alert","data-slot":"field-error",className:E("text-sm font-normal text-destructive",e),...l,children:s})}function us({update:e,notify:r,unwatched:a}){return{link:l,unlink:s,propagate:d,checkDirty:c,shallowPropagate:h};function l(g,v,x){let p=v.depsTail;if(p!==void 0&&p.dep===g)return;let i=p!==void 0?p.nextDep:v.deps;if(i!==void 0&&i.dep===g){i.version=x,v.depsTail=i;return}let w=g.subsTail;if(w!==void 0&&w.version===x&&w.sub===v)return;let b=v.depsTail=g.subsTail={version:x,dep:g,sub:v,prevDep:p,nextDep:i,prevSub:w,nextSub:void 0};if(i!==void 0)i.prevDep=b;if(p!==void 0)p.nextDep=b;else v.deps=b;if(w!==void 0)w.nextSub=b;else g.subs=b}function s(g,v=g.sub){let{dep:x,prevDep:p,nextDep:i,nextSub:w,prevSub:b}=g;if(i!==void 0)i.prevDep=p;else v.depsTail=p;if(p!==void 0)p.nextDep=i;else v.deps=i;if(w!==void 0)w.prevSub=b;else x.subsTail=b;if(b!==void 0)b.nextSub=w;else if((x.subs=w)===void 0)a(x);return i}function d(g){let v=g.nextSub,x;e:do{let p=g.sub,i=p.flags;if(!(i&60))p.flags=i|32;else if(!(i&12))i=0;else if(!(i&4))p.flags=i&-9|32;else if(!(i&48)&&y(g,p))p.flags=i|40,i&=1;else i=0;if(i&2)r(p);if(i&1){let w=p.subs;if(w!==void 0){let b=(g=w).nextSub;if(b!==void 0)x={value:v,prev:x},v=b;continue}}if((g=v)!==void 0){v=g.nextSub;continue}while(x!==void 0)if(g=x.value,x=x.prev,g!==void 0){v=g.nextSub;continue e}break}while(!0)}function c(g,v){let x,p=0,i=!1;e:do{let w=g.dep,b=w.flags;if(v.flags&16)i=!0;else if((b&17)===17){if(e(w)){let N=w.subs;if(N.nextSub!==void 0)h(N);i=!0}}else if((b&33)===33){if(g.nextSub!==void 0||g.prevSub!==void 0)x={value:g,prev:x};g=w.deps,v=w,++p;continue}if(!i){let N=g.nextDep;if(N!==void 0){g=N;continue}}while(p--){let N=v.subs,V=N.nextSub!==void 0;if(V)g=x.value,x=x.prev;else g=N;if(i){if(e(v)){if(V)h(N);v=g.sub;continue}i=!1}else v.flags&=-33;v=g.sub;let q=g.nextDep;if(q!==void 0){g=q;continue e}}return i}while(!0)}function h(g){do{let v=g.sub,x=v.flags;if((x&48)===32){if(v.flags=x|16,(x&6)===2)r(v)}}while((g=g.nextSub)!==void 0)}function y(g,v){let x=v.depsTail;while(x!==void 0){if(x===g)return!0;x=x.prevDep}return!1}}function sa(e,r,a){let l=typeof e==="object",s=l?e:void 0;return{next:(l?e.next:e)?.bind(s),error:(l?e.error:r)?.bind(s),complete:(l?e.complete:a)?.bind(s)}}var Ia=[],ba=0,{link:fs,unlink:Lr,propagate:Pr,checkDirty:hs,shallowPropagate:gs}=us({update(e){return e._update()},notify(e){Ia[Ta++]=e,e.flags&=-3},unwatched(e){if(e.depsTail!==void 0)e.depsTail=void 0,e.flags=17,ya(e)}}),va=0,Ta=0,St,Ea=0;function He(e){try{++Ea,e()}finally{if(!--Ea)Va()}}function ya(e){let r=e.depsTail,a=r!==void 0?r.nextDep:e.deps;while(a!==void 0)a=Lr(a,e)}function Va(){if(Ea>0)return;while(va<Ta){let e=Ia[va];Ia[va++]=void 0,e.notify()}va=0,Ta=0}function xa(e,r){let a=typeof e==="function",l=e,s={_snapshot:a?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:a?0:1,get(){if(St!==void 0)fs(s,St,ba);return s._snapshot},subscribe(d){let c=sa(d),h={current:!1},y=Rr(()=>{if(s.get(),!h.current)h.current=!0;else c.next?.(s._snapshot)});return{unsubscribe:()=>{y.stop()}}},_update(d){let c=St,h=r?.compare??Object.is;if(a)St=s,++ba,s.depsTail=void 0;else if(d===void 0)return!1;if(a)s.flags=5;try{let y=s._snapshot,g=typeof d==="function"?d(y):d===void 0&&a?l(y):d;if(y===void 0||!h(y,g))return s._snapshot=g,!0;return!1}finally{if(St=c,a)s.flags&=-5;ya(s)}}};if(a)s.flags=17,s.get=function(){let d=s.flags;if(d&16||d&32&&hs(s.deps,s)){if(s._update()){let c=s.subs;if(c!==void 0)gs(c)}}else if(d&32)s.flags=d&-33;if(St!==void 0)fs(s,St,ba);return s._snapshot};else s.set=function(d){if(s._update(d)){let c=s.subs;if(c!==void 0)Pr(c),gs(c),Va()}};return s}function Rr(e){let r=()=>{let l=St;St=a,++ba,a.depsTail=void 0,a.flags=6;try{return e()}finally{St=l,a.flags&=-5,ya(a)}},a={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let l=this.flags;if(l&16||l&32&&hs(this.deps,this))r();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ya(this)}};return r(),a}var La=class{constructor(e,r){if(this.atom=xa(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),r)this.actions=r(this)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}},vs=class{constructor(e){this.atom=xa(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}};function Ft(e,r){if(typeof e==="function")return new vs(e);if(r)return new La(e,r);return new La(e)}var bs=class{constructor(e,r){if(this.fn=e,this.options=r,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...a)=>{let l=Date.now()-this.lastExecutionTime;if(this.options.leading&&l>=this.options.wait)this.execute(...a);else if(this.lastArgs=a,!this.timeoutId&&this.options.trailing){let s=this.options.wait-l;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},s)}},this.execute=(...a)=>{this.fn(...a),this.options.onExecute?.(a,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{if(this.isPending&&this.lastArgs)this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{if(this.timeoutId)clearTimeout(this.timeoutId),this.timeoutId=void 0},this.options.leading===void 0&&this.options.trailing===void 0)this.options.leading=!0,this.options.trailing=!0}};function Pa(e,r){return new bs(e,r).maybeExecute}var Ra=class{#o=!0;#t;#e;#m;#a;#n;#s;#l;#u=0;#f=5;#i=!1;#d=!1;#r=null;#p=()=>{this.debugLog("Connected to event bus"),this.#n=!0,this.#i=!1,this.debugLog("Emitting queued events",this.#a),this.#a.forEach((e)=>this.emitEventToBus(e)),this.#a=[],this.stopConnectLoop(),this.#e().removeEventListener("tanstack-connect-success",this.#p)};#c=()=>{if(this.#u<this.#f){this.#u++,this.dispatchCustomEvent("tanstack-connect",{});return}this.#e().removeEventListener("tanstack-connect",this.#c),this.#d=!0,this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};#g=()=>{if(this.#i)return;this.#i=!0,this.#e().addEventListener("tanstack-connect-success",this.#p),this.#c()};constructor({pluginId:e,debug:r=!1,enabled:a=!0,reconnectEveryMs:l=300}){this.#t=e,this.#o=a,this.#e=this.getGlobalTarget,this.#m=r,this.debugLog(" Initializing event subscription for plugin",this.#t),this.#a=[],this.#n=!1,this.#d=!1,this.#s=null,this.#l=l}startConnectLoop(){if(this.#s!==null||this.#n)return;this.debugLog(`Starting connect loop (every ${this.#l}ms)`),this.#s=setInterval(this.#c,this.#l)}stopConnectLoop(){if(this.#i=!1,this.#s===null)return;clearInterval(this.#s),this.#s=null,this.#a=[],this.debugLog("Stopped connect loop")}debugLog(...e){if(this.#m)console.log(`\uD83C\uDF34 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;let e=typeof EventTarget<"u"?new EventTarget:void 0;if(typeof e>"u"||typeof e.addEventListener>"u")return this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1};return this.debugLog("Using new EventTarget as fallback"),e}getPluginId(){return this.#t}dispatchCustomEventShim(e,r){try{let a=new Event(e,{detail:r});this.#e().dispatchEvent(a)}catch(a){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,r){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:r}))}catch(a){this.dispatchCustomEventShim(e,r)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,r){return{type:`${this.#t}:${e}`,payload:r,pluginId:this.#t}}emit(e,r){if(!this.#o){this.debugLog("Event bus client is disabled, not emitting event",e,r);return}if(this.#r)this.debugLog("Emitting event to internal event target",e,r),this.#r.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,r)}));if(this.#d){this.debugLog("Previously failed to connect, not emitting to bus");return}if(!this.#n){if(this.debugLog("Bus not available, will be pushed as soon as connected"),this.#a.push(this.createEventPayload(e,r)),typeof CustomEvent<"u"&&!this.#i)this.#g(),this.startConnectLoop();return}return this.emitEventToBus(this.createEventPayload(e,r))}on(e,r,a){let l=a?.withEventTarget??!1,s=`${this.#t}:${e}`;if(l){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(s,(c)=>{r(c.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",s),()=>{};let d=(c)=>{this.debugLog("Received event from bus",c.detail),r(c.detail)};return this.#e().addEventListener(s,d),this.debugLog("Registered event to bus",s),()=>{if(l)this.#r?.removeEventListener(s,d);this.#e().removeEventListener(s,d)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}onAllPluginEvents(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;if(this.#t&&l.pluginId!==this.#t)return;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}};class ys extends Ra{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var ft=new ys;function Dt(e,r){return typeof e==="function"?e(r):e}function Yt(e,r){return Ca(r).reduce((l,s)=>{if(l===null)return null;if(typeof l<"u")return l[s];return},e)}function Gt(e,r,a){let l=Ca(r);function s(d){if(!l.length)return Dt(a,d);let c=l.shift();if(typeof c==="string"||typeof c==="number"&&!Array.isArray(d)){if(typeof d==="object"){if(d===null)d={};return{...d,[c]:s(d[c])}}return{[c]:s()}}if(Array.isArray(d)&&typeof c==="number"){let h=d.slice(0,c);return[...h.length?h:Array(c),s(d[c]),...d.slice(c+1)]}return[...Array(c),s()]}return s(e)}function Qa(e,r){let a=Ca(r);function l(s){if(!s)return;if(a.length===1){let c=a[0];if(Array.isArray(s)&&typeof c==="number")return s.filter((g,v)=>v!==c);let{[c]:h,...y}=s;return y}let d=a.shift();if(typeof d==="string"||typeof d==="number"&&!Array.isArray(s)){if(typeof s==="object")return{...s,[d]:l(s[d])}}if(typeof d==="number"){if(Array.isArray(s)){if(d>=s.length)return s;let c=s.slice(0,d);return[...c.length?c:Array(d),l(s[d]),...s.slice(d+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return l(e)}var xs=46,ja=91,$a=93,_s=48,Br=57;function Ca(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let r=e.length,a=[],l=r>0&&e.charCodeAt(0)===ja?1:0,s=!0,d=-1;for(let c=l;c<=r;c++){let h=c<r?e.charCodeAt(c):-1;if(c===r||h===xs||h===ja||h===$a){let y=c-l;if(y>0){let g=s&&(y===1||e.charCodeAt(l)!==_s),v=e.slice(l,c);if(g){let x=parseInt(v,10);if(y<=15||String(x)===v)a.push(x);else a.push(v)}else a.push(v)}else if(d!==$a&&!(d===-1&&h===$a)&&!(d===h&&(h===xs||h===ja)))a.push("");l=c+1,s=!0}else if(h<_s||h>Br)s=!1;d=h}if(!a.length)a.push("");return a}function Ka(e){return!(Array.isArray(e)&&e.length===0)}function Pt(e,r){let a=(l)=>l.validators.filter(Boolean).map((s)=>({cause:s.cause,validate:s.fn}));return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!1},runValidation:a})}function Rt(e,r){let{asyncDebounceMs:a}=r,{onBlurAsyncDebounceMs:l,onChangeAsyncDebounceMs:s,onDynamicAsyncDebounceMs:d}=r.validators||{},c=a??0,h=(y)=>y.validators.filter(Boolean).map((g)=>{let v=g?.cause||e,x=c;switch(v){case"change":x=s??c;break;case"blur":x=l??c;break;case"dynamic":x=d??c;break;case"submit":x=0;break}if(e==="submit")x=0;return{cause:v,validate:g.fn,debounceMs:x}});return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!0},runValidation:h})}var Jt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function gt(e,r){if(Object.is(e,r))return!0;if(typeof e!=="object"||e===null||typeof r!=="object"||r===null)return!1;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(let[s,d]of e)if(!r.has(s)||!Object.is(d,r.get(s)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(let s of e)if(!r.has(s))return!1;return!0}let a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;if(a.length===0&&!Array.isArray(e)&&!Array.isArray(r)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(r)!==Object.prototype))return!1;for(let s of a)if(!l.includes(s)||!gt(e[s],r[s]))return!1;return!0}var ea=({newFormValidatorError:e,isPreviousErrorFromFormValidator:r,previousErrorValue:a})=>{if(e)return{newErrorValue:e,newSource:"form"};if(r)return{newErrorValue:void 0,newSource:void 0};if(a)return{newErrorValue:a,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Wt=({formLevelError:e,fieldLevelError:r})=>{if(r)return{newErrorValue:r,newSource:"field"};if(e)return{newErrorValue:e,newSource:"form"};return{newErrorValue:void 0,newSource:void 0}};function mt(e,r){if(e===void 0||e===null)return r;return{...e,...r}}var zt=256,wa=[],_a;while(zt--)wa[zt]=(zt+256).toString(16).substring(1);function ra(){let e=0,r,a="";if(!_a||zt+16>256){_a=Array(256),e=256;while(e--)_a[e]=256*Math.random()|0;e=0,zt=0}for(;e<16;e++){if(r=_a[zt+e],e===6)a+=wa[r&15|64];else if(e===8)a+=wa[r&63|128];else a+=wa[r];if(e&1&&e>1&&e<11)a+="-"}return zt++,a}var Ha=Pa((e)=>ft.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function Ht(e){if(e===null||typeof e!=="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let a=[];for(let l=0;l<e.length;l++)a[l]=Ht(e[l]);return a}if(e instanceof Map){let a=new Map;return e.forEach((l,s)=>{a.set(s,Ht(l))}),a}if(e instanceof Set){let a=new Set;return e.forEach((l)=>{a.add(Ht(l))}),a}let r={};for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a))r[a]=Ht(e[a]);return r}function bt(e,r){return r===e||r.startsWith(`${e}.`)||r.startsWith(`${e}[`)}var ht=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let r=e.event.async,a=r?void 0:{fn:e.validators.onMount,cause:"mount"},l={fn:r?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},s={fn:r?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},d={fn:r?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},c=r?void 0:{fn:()=>{return},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[a],form:e.form});case"submit":return e.runValidation({validators:[l,s,d,c],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[s,c],form:e.form});case"change":return e.runValidation({validators:[l,c],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function qr(e,r){let a=new Map;for(let l of e){let s=l.path??[],d=r,c="";for(let h=0;h<s.length;h++){let y=s[h];if(y===void 0)continue;let g=typeof y==="object"?y.key:y,v=Number(g);if(Array.isArray(d)&&!Number.isNaN(v))c+=`[${v}]`;else c+=(h>0?".":"")+String(g);if(typeof d==="object"&&d!==null)d=d[g];else d=void 0}a.set(c,(a.get(c)??[]).concat(l))}return Object.fromEntries(a)}var ws=(e,r)=>{let a=qr(e,r);return{form:a,fields:a}},Lt={validate({value:e,validationSource:r},a){let l=a["~standard"].validate(e);if(l instanceof Promise)throw Error("async function passed to sync validator");if(!l.issues)return;if(r==="field")return l.issues;return ws(l.issues,e)},async validateAsync({value:e,validationSource:r},a){let l=await a["~standard"].validate(e);if(!l.issues)return;if(r==="field")return l.issues;return ws(l.issues,e)}},ta=(e)=>!!e&&("~standard"in e);var ut={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Bt(e){function r(x){let p=e.getFieldMeta(x)??ut;e.setFieldMeta(x,{...p,_arrayVersion:(p._arrayVersion||0)+1})}function a(x,p,i){r(x);let w=h(x,p,"move",i),b=Math.min(p,i),N=Math.max(p,i);for(let q=b;q<=N;q++)w.push(c(x,q));let V=Object.keys(e.fieldInfo).reduce((q,j)=>{if(j.startsWith(c(x,p)))q.set(j,e.getFieldMeta(j));return q},new Map);g(w,p<i?"up":"down"),Object.keys(e.fieldInfo).filter((q)=>q.startsWith(c(x,i))).forEach((q)=>{let j=q.replace(c(x,i),c(x,p)),re=V.get(j);if(re)e.setFieldMeta(q,re)})}function l(x,p){r(x);let i=h(x,p,"remove");g(i,"up")}function s(x,p,i){r(x),h(x,p,"swap",i).forEach((b)=>{if(!b.toString().startsWith(c(x,p)))return;let N=b.toString().replace(c(x,p),c(x,i)),[V,q]=[e.getFieldMeta(b),e.getFieldMeta(N)];if(V)e.setFieldMeta(N,V);if(q)e.setFieldMeta(b,q)})}function d(x,p){r(x);let i=h(x,p,"insert");g(i,"down"),i.forEach((w)=>{if(w.toString().startsWith(c(x,p)))e.setFieldMeta(w,v())})}function c(x,p){return`${x}[${p}]`}function h(x,p,i,w){let b=[c(x,p)];switch(i){case"swap":b.push(c(x,w));break;case"move":{let[N,V]=[Math.min(p,w),Math.max(p,w)];for(let q=N;q<=V;q++)b.push(c(x,q));break}default:{let N=e.getFieldValue(x),V=Array.isArray(N)?N.length:0;for(let q=p+1;q<V;q++)b.push(c(x,q));break}}return Object.keys(e.fieldInfo).filter((N)=>b.some((V)=>N.startsWith(V)))}function y(x,p){return x.replace(/\[(\d+)\]/,(i,w)=>{let b=parseInt(w,10);return`[${p==="up"?b+1:Math.max(0,b-1)}]`})}function g(x,p){(p==="up"?x:[...x].reverse()).forEach((w)=>{let b=y(w.toString(),p),N=e.getFieldMeta(b);if(N)e.setFieldMeta(w,N);else e.setFieldMeta(w,v())})}let v=()=>ut;return{bumpArrayVersion:r,handleArrayMove:a,handleArrayRemove:l,handleArraySwap:s,handleArrayInsert:d}}function Ga(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}class na{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let s=this.store.subscribe(()=>{Ha(this)}),d=ft.on("request-form-state",(v)=>{if(v.payload.id===this._formId)ft.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),c=ft.on("request-form-reset",(v)=>{if(v.payload.id===this._formId)this.reset()}),h=ft.on("request-form-force-submit",(v)=>{if(v.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),y=()=>{h(),c(),d(),s.unsubscribe(),ft.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:g}=this.options.validators||{};if(ft.emit("form-api",{id:this._formId,state:this.store.state,options:this.options}),!g)return y;return this.validateSync("mount"),y},this.update=(s)=>{if(!s)return;let d=this.options;this.options=s;let c=s.defaultValues&&!gt(s.defaultValues,d.defaultValues)&&!this.state.isTouched,h=!gt(s.defaultState,d.defaultState)&&!this.state.isTouched;if(!c&&!h)return;if(He(()=>{this.baseStore.setState(()=>Ga(Object.assign({},this.state,h?s.defaultState:{},c?{values:s.defaultValues}:{})))}),c){let y=Bt(this);for(let g of Object.keys(this.fieldInfo))if(Array.isArray(this.getFieldValue(g)))y.bumpArrayVersion(g)}ft.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})},this.reset=(s,d)=>{let{fieldMeta:c}=this.state,h=this.resetFieldMeta(c);if(s&&!d?.keepDefaultValues)this.options={...this.options,defaultValues:s};this.baseStore.setState(()=>{let y=s??this.options.defaultValues??this.options.defaultState?.values;if(!s)Object.values(this.fieldInfo).forEach((g)=>{if(g.instance&&g.instance.options.defaultValue!==void 0)y=Gt(y,g.instance.name,g.instance.options.defaultValue)});return Ga({...this.options.defaultState,values:y,fieldMetaBase:h})})},this.validateAllFields=async(s)=>{let d=[];return He(()=>{Object.values(this.fieldInfo).forEach((h)=>{if(!h.instance)return;let y=h.instance;if(d.push(Promise.resolve().then(()=>y.validate(s,{skipFormValidation:!0,skipGroupValidation:!0}))),!h.instance.store.state.meta.isTouched)h.instance.setMeta((g)=>({...g,isTouched:!0}))})}),(await Promise.all(d)).flat()},this.validateArrayFieldsStartingFrom=async(s,d,c)=>{let h=this.getFieldValue(s),y=Array.isArray(h)?Math.max(h.length-1,0):null,g=[`${s}[${d}]`];for(let i=d+1;i<=(y??0);i++)g.push(`${s}[${i}]`);let v=Object.keys(this.fieldInfo).filter((i)=>g.some((w)=>i.startsWith(w))),x=[];return He(()=>{v.forEach((i)=>{x.push(Promise.resolve().then(()=>this.validateField(i,c)))})}),(await Promise.all(x)).flat()},this.validateField=(s,d)=>{let c=this.fieldInfo[s]?.instance;if(!c){let{hasErrored:h}=this.validateSync(d);if(h&&!this.options.asyncAlways)return this.getFieldMeta(s)?.errors??[];return this.validateAsync(d).then(()=>this.getFieldMeta(s)?.errors??[])}if(!c.store.state.meta.isTouched)c.setMeta((h)=>({...h,isTouched:!0}));return c.validate(d)},this.validateSync=(s,d)=>{let c=Pt(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ht}),h=!1,y={};return He(()=>{for(let x of c){if(!x.validate)continue;let p=this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:i,fieldErrors:w}=Sa(p),b=oa(x.cause),N=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(w||{})]);if(d?.filterFieldNames)N=new Set([...N].filter(d.filterFieldNames));for(let V of N){if(this.baseStore.state.fieldMetaBase[V]===void 0&&!w?.[V])continue;let q=this.getFieldMeta(V)??ut,{errorMap:j,errorSourceMap:re}=q,oe=w?.[V],{newErrorValue:F,newSource:T}=ea({newFormValidatorError:oe,isPreviousErrorFromFormValidator:re?.[b]==="form",previousErrorValue:j?.[b]});if(T==="form")y[V]={...y[V],[b]:oe};if(j?.[b]!==F)this.setFieldMeta(V,(U=ut)=>({...U,errorMap:{...U.errorMap,[b]:F},errorSourceMap:{...U.errorSourceMap,[b]:T}}))}if(!d?.dontUpdateFormErrorMap){if(this.state.errorMap?.[b]!==i)this.baseStore.setState((V)=>({...V,errorMap:{...V.errorMap,[b]:i}}))}if(i||w)h=!0}if(d?.dontUpdateFormErrorMap)return;let g=oa("submit");if(this.state.errorMap?.[g]&&s!=="submit"&&!h)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[g]:void 0}}));let v=oa("server");if(this.state.errorMap?.[v]&&s!=="server"&&!h)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[v]:void 0}}))}),{hasErrored:h,fieldsErrorMap:y}},this.validateAsync=async(s,d)=>{let c=Rt(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ht});if(!this.state.isFormValidating)this.baseStore.setState((x)=>({...x,isFormValidating:!0}));let h=[],y;for(let x of c){if(!x.validate)continue;let p=oa(x.cause);this.state.validationMetaMap[p]?.lastAbortController.abort();let w=new AbortController;this.state.validationMetaMap[p]={lastAbortController:w},h.push(new Promise(async(b)=>{let N;try{N=await new Promise((F,T)=>{setTimeout(async()=>{if(w.signal.aborted)return F(void 0);try{F(await this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:w.signal},type:"validateAsync"}))}catch(U){T(U)}},x.debounceMs)})}catch(F){N=F}let{formError:V,fieldErrors:q}=Sa(N);if(q)y=y?{...y,...q}:q;let j=oa(x.cause),re=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(y||{})]),oe=Array.from(re);if(d?.filterFieldNames)oe=oe.filter(d.filterFieldNames);for(let F of oe){if(this.baseStore.state.fieldMetaBase[F]===void 0&&!y?.[F])continue;let T=this.getFieldMeta(F)??ut,{errorMap:U,errorSourceMap:Y}=T,k=y?.[F],{newErrorValue:J,newSource:ye}=ea({newFormValidatorError:k,isPreviousErrorFromFormValidator:Y?.[j]==="form",previousErrorValue:U?.[j]});if(U?.[j]!==J)this.setFieldMeta(F,(be=ut)=>({...be,errorMap:{...be.errorMap,[j]:J},errorSourceMap:{...be.errorSourceMap,[j]:ye}}))}if(!d?.dontUpdateFormErrorMap)this.baseStore.setState((F)=>({...F,errorMap:{...F.errorMap,[j]:V}}));b(y?{fieldErrors:y,errorMapKey:j}:void 0)}))}let g=[],v={};if(h.length){g=await Promise.all(h);for(let x of g)if(x?.fieldErrors){let{errorMapKey:p}=x;for(let[i,w]of Object.entries(x.fieldErrors)){let N={...v[i]||{},[p]:w};v[i]=N}}}return this.baseStore.setState((x)=>({...x,isFormValidating:!1})),v},this.validate=(s,d)=>{let{hasErrored:c,fieldsErrorMap:h}=this.validateSync(s,d);if(c&&!this.options.asyncAlways)return h;return this.validateAsync(s,d)},this._handleSubmit=async(s)=>{this.baseStore.setState((h)=>({...h,isSubmitted:!1,submissionAttempts:h.submissionAttempts+1,isSubmitSuccessful:!1})),He(()=>{Object.values(this.fieldInfo).forEach((h)=>{if(!h.instance)return;if(!h.instance.store.state.meta.isTouched)h.instance.setMeta((y)=>({...y,isTouched:!0}))})});let d=s??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){if(this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d});return}}this.baseStore.setState((h)=>({...h,isSubmitting:!0}));let c=()=>{this.baseStore.setState((h)=>({...h,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ft.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map((h)=>h.errors).flat()});return}if(await this.validate("submit"),!this.state.isValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ft.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});return}He(()=>{Object.values(this.fieldInfo).forEach((h)=>{h.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:d});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:d}),He(()=>{this.baseStore.setState((h)=>({...h,isSubmitted:!0,isSubmitSuccessful:!0})),ft.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),c()})}catch(h){throw this.baseStore.setState((y)=>({...y,isSubmitSuccessful:!1})),ft.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:h}),c(),h}},this.getFieldValue=(s)=>Yt(this.state.values,s),this.getFieldMeta=(s)=>this.state.fieldMeta[s],this.getFormGroupMeta=(s)=>this.formGroupMetaDerived.state[s],this.getFieldInfo=(s)=>this.fieldInfo[s]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(s,d)=>{this.baseStore.setState((c)=>({...c,fieldMetaBase:{...c.fieldMetaBase,[s]:Dt(d,c.fieldMetaBase[s])}}))},this.resetFieldMeta=(s)=>Object.keys(s).reduce((d,c)=>{let h=c;return d[h]=ut,d},{}),this.setFieldValue=(s,d,c)=>{let h=c?.dontUpdateMeta??!1,y=c?.dontRunListeners??!1,g=c?.dontValidate??!1;if(He(()=>{if(!h)this.setFieldMeta(s,(v)=>({...v,isTouched:!0,isDirty:!0,errorMap:{...v?.errorMap,onMount:void 0}}));this.baseStore.setState((v)=>({...v,values:Gt(v.values,s,d)}))}),!y)this.getFieldInfo(s).instance?.triggerOnChangeListener();if(!g)this.validateField(s,"change")},this.deleteField=(s)=>{let c=[...Object.keys(this.fieldInfo).filter((h)=>{let y=s.toString();return h.startsWith(`${y}.`)||h.startsWith(`${y}[`)}),s];this.baseStore.setState((h)=>{let y={...h};return c.forEach((g)=>{y.values=Qa(y.values,g),delete this.fieldInfo[g],delete y.fieldMetaBase[g]}),y})},this.pushFieldValue=(s,d,c)=>{this.setFieldValue(s,(h)=>[...Array.isArray(h)?h:[],d],c),Bt(this).bumpArrayVersion(s)},this.insertFieldValue=async(s,d,c,h)=>{this.setFieldValue(s,(g)=>[...g.slice(0,d),c,...g.slice(d)],mt(h,{dontValidate:!0}));let y=h?.dontValidate??!1;if(!y)await this.validateField(s,"change");if(Bt(this).handleArrayInsert(s,d),!y)await this.validateArrayFieldsStartingFrom(s,d,"change")},this.replaceFieldValue=async(s,d,c,h)=>{if(this.setFieldValue(s,(g)=>g.map((v,x)=>x===d?c:v),mt(h,{dontValidate:!0})),Bt(this).bumpArrayVersion(s),!(h?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.removeFieldValue=async(s,d,c)=>{let h=this.getFieldValue(s),y=Array.isArray(h)?Math.max(h.length-1,0):null;if(this.setFieldValue(s,(v)=>v.filter((x,p)=>p!==d),mt(c,{dontValidate:!0})),Bt(this).handleArrayRemove(s,d),y!==null){let v=`${s}[${y}]`;this.deleteField(v)}if(!(c?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.swapFieldValues=(s,d,c,h)=>{if(this.setFieldValue(s,(g)=>{let v=g[d],x=g[c];return Gt(Gt(g,`${d}`,x),`${c}`,v)},mt(h,{dontValidate:!0})),Bt(this).handleArraySwap(s,d,c),!(h?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.moveFieldValues=(s,d,c,h)=>{if(this.setFieldValue(s,(g)=>{let v=[...g];return v.splice(c,0,v.splice(d,1)[0]),v},mt(h,{dontValidate:!0})),Bt(this).handleArrayMove(s,d,c),!(h?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.clearFieldValues=(s,d)=>{let c=this.getFieldValue(s),h=Array.isArray(c)?Math.max(c.length-1,0):null;if(this.setFieldValue(s,[],mt(d,{dontValidate:!0})),Bt(this).bumpArrayVersion(s),h!==null)for(let g=0;g<=h;g++){let v=`${s}[${g}]`;this.deleteField(v)}if(!(d?.dontValidate??!1))this.validateField(s,"change")},this.resetField=(s)=>{this.baseStore.setState((d)=>{let c=this.getFieldInfo(s).instance?.options.defaultValue,h=Yt(this.options.defaultValues,s),y=c??h;return{...d,fieldMetaBase:{...d.fieldMetaBase,[s]:ut},values:y!==void 0?Gt(d.values,s,y):d.values}})},this.setErrorMap=(s)=>{He(()=>{Object.entries(s).forEach(([d,c])=>{let h=d;if(Jt(c)){let{formError:y,fieldErrors:g}=Sa(c);for(let v of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(v))continue;this.setFieldMeta(v,(p)=>({...p,errorMap:{...p.errorMap,[h]:g?.[v]},errorSourceMap:{...p.errorSourceMap,[h]:"form"}}))}this.baseStore.setState((v)=>({...v,errorMap:{...v.errorMap,[h]:y}}))}else this.baseStore.setState((y)=>({...y,errorMap:{...y.errorMap,[h]:c}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((s,[d,c])=>{if(Object.keys(c).length&&c.errors.length)s[d]={errors:c.errors,errorMap:c.errorMap};return s},{})}),this.parseValuesWithSchema=(s)=>Lt.validate({value:this.state.values,validationSource:"form"},s),this.parseValuesWithSchemaAsync=(s)=>Lt.validateAsync({value:this.state.values,validationSource:"form"},s),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ra(),this._devtoolsSubmissionOverride=!1;let r=Ga({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){r=e.transform({state:r}).state;for(let s of Object.keys(r.errorMap)){let d=r.errorMap[s];if(d===void 0||!Jt(d))continue;for(let c of Object.keys(d.fields)){let h=d.fields[c];if(h===void 0)continue;let y=r.fieldMetaBase[c];r.fieldMetaBase[c]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...y??{},errorSourceMap:{...y?.errorSourceMap??{},onChange:"form"},errorMap:{...y?.errorMap??{},[s]:h}}}}}this.baseStore=Ft(r);let a=void 0;this.fieldMetaDerived=Ft((s)=>{let d=this.baseStore.get(),c=0,h={};for(let y of Object.keys(d.fieldMetaBase)){let g=d.fieldMetaBase[y],v=a?.fieldMetaBase[y],x=s?.[y],p=Yt(d.values,y),i=x?.errors;if(!v||g.errorMap!==v.errorMap){i=Object.values(g.errorMap??{}).filter((q)=>q!==void 0);let V=this.getFieldInfo(y)?.instance;if(!V||!V.options.disableErrorFlat)i=i.flat(1)}let w=!Ka(i),b=!g.isDirty,N=gt(p,this.getFieldInfo(y)?.instance?.options.defaultValue??Yt(this.options.defaultValues,y));if(x&&x.isPristine===b&&x.isValid===w&&x.isDefaultValue===N&&x.errors===i&&g===v){h[y]=x,c++;continue}h[y]={...g,errors:i??[],isPristine:b,isValid:w,isDefaultValue:N}}if(!Object.keys(d.fieldMetaBase).length)return h;if(s&&c===Object.keys(d.fieldMetaBase).length)return s;return a=this.baseStore.get(),h}),this.formGroupMetaDerived=Ft((s)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),h={};for(let y of this.formGroupApis){let g=y.name,v=d.formGroupStateBase[g]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},x=c[g],p=!1,i=!0,w=!1,b=!1,N=!0,V=!1;for(let De in c){if(De===g)continue;if(!bt(g,De))continue;let Ee=c[De];if(!Ee)continue;if(Ee.isValidating)p=!0;if(!Ee.isValid)i=!1;if(Ee.isTouched)w=!0;if(Ee.isBlurred)b=!0;if(!Ee.isDefaultValue)N=!1;if(Ee.isDirty)V=!0}let q=!V,j=!!p||v.isValidating,re=x?.errorMap??{},oe=x?.errorSourceMap??{},F=Boolean(re.onMount||Object.entries(c).some(([De,Ee])=>Ee&&De!==g&&bt(g,De)&&Ee.errorMap.onMount)),T=s?.[g],U=T?.errors??[];if(!T||T.__srcErrorMap!==re)U=Object.values(re).reduce((De,Ee)=>{if(Ee===void 0)return De;if(Ee&&typeof Ee==="object"&&"fields"in Ee){let ae=Ee.group;if(ae!==void 0)De.push(ae);return De}return De.push(Ee),De},[]);let Y=U.length===0,k=i&&Y,J=y.options.canSubmitWhenInvalid??!1,ye=v.submissionAttempts===0&&!w&&!F||!j&&!v.isSubmitting&&k||J;if(T&&T.errorMap===re&&T.errorSourceMap===oe&&T.errors===U&&T.isFieldsValidating===p&&T.isFieldsValid===i&&T.isGroupValid===Y&&T.isValid===k&&T.canSubmit===ye&&T.isTouched===w&&T.isBlurred===b&&T.isPristine===q&&T.isDefaultValue===N&&T.isDirty===V&&T.isValidating===j&&T.isSubmitting===v.isSubmitting&&T.isSubmitted===v.isSubmitted&&T.submissionAttempts===v.submissionAttempts&&T.isSubmitSuccessful===v.isSubmitSuccessful){h[g]=T;continue}let be={...v,errorMap:re,errorSourceMap:oe,_arrayVersion:x?._arrayVersion??0,isTouched:w,isBlurred:b,isDirty:V,isPristine:q,isDefaultValue:N,isValid:k,errors:U,isValidating:j,isFieldsValidating:p,isFieldsValid:i,isGroupValid:Y,canSubmit:ye};Object.defineProperty(be,"__srcErrorMap",{value:re,enumerable:!1,configurable:!0}),h[g]=be}return h});let l=void 0;this.store=Ft((s)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),h=Object.values(c).filter(Boolean),y=h.some((Y)=>Y.isValidating),g=h.every((Y)=>Y.isValid),v=h.some((Y)=>Y.isTouched),x=h.some((Y)=>Y.isBlurred),p=h.every((Y)=>Y.isDefaultValue),i=v&&d.errorMap?.onMount,w=h.some((Y)=>Y.isDirty),b=!w,N=Boolean(d.errorMap?.onMount||h.some((Y)=>Y?.errorMap?.onMount)),V=!!y,q=s?.errors??[];if(!l||d.errorMap!==l.errorMap)q=Object.values(d.errorMap).reduce((Y,k)=>{if(k===void 0)return Y;if(k&&Jt(k))return Y.push(k.form),Y;return Y.push(k),Y},[]);let j=q.length===0,re=g&&j,oe=this.options.canSubmitWhenInvalid??!1,F=d.submissionAttempts===0&&!v&&!N||!V&&!d.isSubmitting&&re||oe,T=d.errorMap;if(i)q=q.filter((Y)=>Y!==d.errorMap.onMount),T=Object.assign(T,{onMount:void 0});if(s&&l&&s.errorMap===T&&s.fieldMeta===this.fieldMetaDerived.state&&s.errors===q&&s.isFieldsValidating===y&&s.isFieldsValid===g&&s.isFormValid===j&&s.isValid===re&&s.canSubmit===F&&s.isTouched===v&&s.isBlurred===x&&s.isPristine===b&&s.isDefaultValue===p&&s.isDirty===w&>(l,d))return s;let U={...d,errorMap:T,fieldMeta:this.fieldMetaDerived.state,errors:q,isFieldsValidating:y,isFieldsValid:g,isFormValid:j,isValid:re,canSubmit:F,isTouched:v,isBlurred:x,isPristine:b,isDefaultValue:p,isDirty:w};return l=this.baseStore.get(),U}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){if(ta(e.validate))return Lt[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function Sa(e){if(e){if(Jt(e)){let r=Sa(e.form).formError,a=e.fields;return{formError:r,fieldErrors:a}}return{formError:e}}return{formError:void 0}}function oa(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}class jt{constructor(e){this.options={},this.mount=()=>{if(this.options.defaultValue!==void 0&&!this.getMeta().isTouched)this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let r=this.getInfo();r.instance=this,this.update(this.options);let{onMount:a}=this.options.validators||{};if(a){let l=this.runValidator({validate:a,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});if(l)this.setMeta((s)=>({...s,errorMap:{...s?.errorMap,onMount:l},errorSourceMap:{...s?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[s,d]of Object.entries(this.timeoutIds.validations))if(d)clearTimeout(d),this.timeoutIds.validations[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.listeners))if(d)clearTimeout(d),this.timeoutIds.listeners[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.formListeners))if(d)clearTimeout(d),this.timeoutIds.formListeners[s]=null;let l=this.form.fieldInfo[this.name];if(!l)return;if(l.instance!==this)return;for(let[s,d]of Object.entries(l.validationMetaMap))d?.lastAbortController.abort(),l.validationMetaMap[s]=void 0;this.form.baseStore.setState((s)=>({...s,fieldMetaBase:{...s.fieldMetaBase,[this.name]:{...ut,isTouched:s.fieldMetaBase[this.name]?.isTouched??ut.isTouched,isBlurred:s.fieldMetaBase[this.name]?.isBlurred??ut.isBlurred,isDirty:s.fieldMetaBase[this.name]?.isDirty??ut.isDirty}}})),l.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!gt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,mt(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(r,a)=>{if(this.form.pushFieldValue(this.name,r,mt(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(r,a,l)=>{if(this.form.insertFieldValue(this.name,r,a,mt(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(r,a,l)=>{if(this.form.replaceFieldValue(this.name,r,a,mt(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(r,a)=>{if(this.form.removeFieldValue(this.name,r,mt(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(r,a,l)=>{if(this.form.swapFieldValues(this.name,r,a,mt(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(r,a,l)=>{if(this.form.moveFieldValues(this.name,r,a,mt(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(r)=>{if(this.form.clearFieldValues(this.name,mt(r,{dontRunListeners:!0})),!r?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(r)=>{let a=Object.values(this.form.fieldInfo),l=[];for(let s of a){if(!s.instance)continue;if(!(s.instance instanceof jt))continue;let{onChangeListenTo:d,onBlurListenTo:c}=s.instance.options.validators||{};if(r==="change"&&d?.includes(this.name))l.push(s.instance);if(r==="blur"&&c?.includes(this.name))l.push(s.instance)}return l},this.validateSync=(r,a)=>{let l=Pt(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ht}),d=this.getLinkedFields(r).reduce((y,g)=>{let v=Pt(r,{...g.options,form:g.form,fieldName:g.name,validationLogic:g.form.options.validationLogic||ht});return v.forEach((x)=>{x.field=g}),y.concat(v)},[]),c=!1;He(()=>{let y=(g,v)=>{let x=la(v.cause),p=v.validate?Ns(g.runValidator({validate:v.validate,value:{value:g.store.state.value,validationSource:"field",fieldApi:g},type:"validate"})):void 0,i=a[x],{newErrorValue:w,newSource:b}=Wt({formLevelError:i,fieldLevelError:p});if(g.state.meta.errorMap?.[x]!==w)g.setMeta((N)=>({...N,errorMap:{...N.errorMap,[x]:w},errorSourceMap:{...N.errorSourceMap,[x]:b}}));if(w)c=!0};for(let g of l)y(this,g);for(let g of d){if(!g.validate)continue;y(g.field,g)}});let h=la("submit");if(this.state.meta.errorMap?.[h]&&r!=="submit"&&!c)this.setMeta((y)=>({...y,errorMap:{...y.errorMap,[h]:void 0},errorSourceMap:{...y.errorSourceMap,[h]:void 0}}));return{hasErrored:c}},this.validateAsync=async(r,a)=>{let l=Rt(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ht}),s=await a,c=this.getLinkedFields(r).reduce((i,w)=>{let b=Rt(r,{...w.options,form:w.form,fieldName:w.name,validationLogic:w.form.options.validationLogic||ht});return b.forEach((N)=>{N.field=w}),i.concat(b)},[]),h=[],y=[],g=l.some((i)=>i.validate),v=Array.from(new Set(c.filter((i)=>i.validate).map((i)=>i.field)));He(()=>{if(g)this.startValidation();for(let i of v)i.startValidation()});let x=(i,w,b)=>{let N=la(w.cause),V=i.getInfo();V.validationMetaMap[N]?.lastAbortController.abort();let j=new AbortController;V.validationMetaMap[N]={lastAbortController:j},b.push(new Promise(async(re)=>{let oe;try{oe=await new Promise((k,J)=>{if(i.timeoutIds.validations[w.cause])clearTimeout(i.timeoutIds.validations[w.cause]),i.endValidation();i.timeoutIds.validations[w.cause]=setTimeout(async()=>{if(j.signal.aborted)return k(void 0);try{k(await this.runValidator({validate:w.validate,value:{value:i.store.state.value,fieldApi:i,signal:j.signal,validationSource:"field"},type:"validateAsync"}))}catch(ye){J(ye)}},w.debounceMs)})}catch(k){oe=k}if(j.signal.aborted)return re(void 0);let F=Ns(oe),T=s[i.name]?.[N],{newErrorValue:U,newSource:Y}=Wt({formLevelError:T,fieldLevelError:F});if(i.getInfo().instance!==i)return re(void 0);i.setMeta((k)=>({...k,errorMap:{...k?.errorMap,[N]:U},errorSourceMap:{...k.errorSourceMap,[N]:Y}})),re(U)}))};for(let i of l){if(!i.validate)continue;x(this,i,h)}for(let i of c){if(!i.validate)continue;x(i.field,i,y)}let p=[];if(h.length||y.length)p=await Promise.all(h),await Promise.all(y);return He(()=>{if(g)this.endValidation();for(let i of v)i.endValidation()}),p.filter(Boolean)},this.validate=(r,a)=>{if(!this.state.meta.isTouched)return[];let l=a?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((x)=>this.name.startsWith(x.name)),d=((a?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(r)).fieldsErrorMap[this.name]??{};if(!a?.skipFormValidation)for(let x of l){if(x.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:p}=this.form.validateSync(r,{group:x,dontUpdateFormErrorMap:!0,filterFieldNames:(i)=>bt(x.name,i)});d={...d,...p[this.name]??{}}}let{hasErrored:c}=this.validateSync(r,d),h=new WeakMap;for(let x of l){let{hasErrored:p}=x.validateSync(r,{},{skipRelatedFieldValidation:!0});h.set(x,p)}if(c&&!this.options.asyncAlways){this.getInfo().validationMetaMap[la(r)]?.lastAbortController.abort();let x=[];for(let p of l)p.getInfo().validationMetaMap[la(r)]?.lastAbortController.abort(),x.push(p.state.meta.errors);return[...this.state.meta.errors,...x.flat()]}let y=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r),g=this.validateAsync(r,y),v=[];for(let x of l){if(h.get(x)&&!x.options.asyncAlways)continue;v.push(x.validateAsync(r,y,{skipRelatedFieldValidation:!0}))}if(v.length===0)return g;return Promise.all([g,...v]).then((x)=>x.flat())},this.handleChange=(r)=>{this.setValue(r)},this.handleBlur=()=>{if(!this.state.meta.isTouched)this.setMeta((a)=>({...a,isTouched:!0}));if(!this.state.meta.isBlurred)this.setMeta((a)=>({...a,isBlurred:!0}));this.validate("blur"),this.triggerOnBlurListener()},this.setErrorMap=(r)=>{this.setMeta((a)=>({...a,errorMap:{...a.errorMap,...r}}))},this.parseValueWithSchema=(r)=>Lt.validate({value:this.state.value,validationSource:"field"},r),this.parseValueWithSchemaAsync=(r)=>Lt.validateAsync({value:this.state.value,validationSource:"field"},r),this.triggerOnBlurListener=()=>{let r=this.form.options.listeners?.onBlurDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.blur)clearTimeout(this.timeoutIds.formListeners.blur);this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onBlurDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.blur)clearTimeout(this.timeoutIds.listeners.blur);this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let l of this.form.formGroupApis)if(bt(l.name,this.name))l.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=Ft((r)=>{this.form.store.get();let a=this.form.getFieldMeta(this.name)??{...ut,...e.defaultMeta},l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!gt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}})}get state(){return this.store.state}runValidator(e){if(ta(e.validate))return Lt[e.type](e.value,e.validate);return e.validate(e.value)}startValidation(){this.setMeta((e)=>{let r=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:r,isValidating:r>0&&!e.isValidating?!0:e.isValidating}})}endValidation(){this.setMeta((e)=>{let r=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:r,isValidating:r===0&&e.isValidating?!1:e.isValidating}})}}function Ns(e){if(e)return e;return}function la(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function Wa(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function Ss(e){return{...ut,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}class Zt{constructor(e){this.options={},this.setFormGroupState=(r)=>{this.form.baseStore.setState((a)=>{let l=a.formGroupStateBase[this.name]??Wa({});return{...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:r(l)}}})},this._lastDistributedFieldNames={},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!gt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,{...ut,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:a.formGroupStateBase[this.name]??Wa({...this.options.defaultState})}}));let{onMount:r}=this.options.validators||{};if(r){let a=this.runValidator({validate:r,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),l=a,s=void 0;if(Ja(a))l=a.group,s=a.fields;let d=Ya(l);if(d)this.setMeta((c)=>({...c,errorMap:{...c.errorMap,onMount:d},errorSourceMap:{...c.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",s)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[a,l]of Object.entries(this.timeoutIds.validations))if(l)clearTimeout(l),this.timeoutIds.validations[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.listeners))if(l)clearTimeout(l),this.timeoutIds.listeners[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.formListeners))if(l)clearTimeout(l),this.timeoutIds.formListeners[a]=null;if(this.fieldInfo.instance!==this)return;for(let[a,l]of Object.entries(this.fieldInfo.validationMetaMap))l?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[a]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:Wa({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,mt(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let r=Object.values(this.form.fieldInfo),a=[];for(let l of r){if(!l.instance)continue;if(!(l.instance instanceof jt))continue;if(l.instance.name.startsWith(this.name))a.push(l.instance)}return a},this.getRelatedFieldMetasDerived=()=>{let r=Object.entries(this.form.fieldMetaDerived.state),a=[];for(let[l,s]of r){if(l===this.name)continue;if(bt(this.name,l))a.push({...s,name:l})}return a},this.buildChildFieldName=(r)=>{if(r==="")return this.name;if(r.startsWith("["))return`${this.name}${r}`;return`${this.name}.${r}`},this.distributeFieldErrors=(r,a)=>{let l=this._lastDistributedFieldNames[r]??new Set,s=new Set;if(a)for(let[h,y]of Object.entries(a)){if(y===void 0||y===null||y===!1)continue;s.add(this.buildChildFieldName(h))}let d=new Set([...l,...s]),c=!1;for(let h of d){let y=h.startsWith(this.name+"[")?h.slice(this.name.length):h.slice(this.name.length+1),g=a?.[y],v=this.form.getFieldMeta(h);if(!v&&!g)continue;let x=v?.errorMap[r],p=v?.errorSourceMap[r]==="form",{newErrorValue:i,newSource:w}=ea({newFormValidatorError:g,isPreviousErrorFromFormValidator:p,previousErrorValue:x});if(i)c=!0;if(x===i&&v?.errorSourceMap[r]===w)continue;this.form.setFieldMeta(h,(b=ut)=>({...b,errorMap:{...b.errorMap,[r]:i},errorSourceMap:{...b.errorSourceMap,[r]:w}}))}return this._lastDistributedFieldNames[r]=s,c},this.validateSync=(r,a,l={})=>{let s=Pt(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ht}),c=(l.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((g,v)=>{let x=Pt(r,{...v.options,form:v.form,validationLogic:v.form.options.validationLogic||ht});return x.forEach((p)=>{p.field=v}),g.concat(x)},[]),h=!1;He(()=>{let g=(v,x)=>{let p=ka(x.cause),i=v===this,w=void 0;if(x.validate)w=v.runValidator({validate:x.validate,value:{value:v.store.state.value,validationSource:i?"form":"field",...v instanceof Zt?{groupApi:v}:{fieldApi:v}},type:"validate"});let b=w,N=void 0;if(i&&Ja(w))b=w.group,N=w.fields;let V=Ya(b),q=a[p],{newErrorValue:j,newSource:re}=Wt({formLevelError:q,fieldLevelError:V});if(v.state.meta.errorMap?.[p]!==j)v.setMeta((oe)=>({...oe,errorMap:{...oe.errorMap,[p]:j},errorSourceMap:{...oe.errorSourceMap,[p]:re}}));if(j)h=!0;if(i){if(this.distributeFieldErrors(p,N))h=!0}};for(let v of s)g(this,v);for(let v of c){if(!v.validate)continue;g(v.field,v)}});let y=ka("submit");if(this.state.meta.errorMap?.[y]&&r!=="submit"&&!h)this.setMeta((g)=>({...g,errorMap:{...g.errorMap,[y]:void 0},errorSourceMap:{...g.errorSourceMap,[y]:void 0}}));return{hasErrored:h}},this.validateAsync=async(r,a,l={})=>{let s=Rt(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ht}),d=await a,c=l.skipRelatedFieldValidation?[]:this.getRelatedFields(),h=c.reduce((i,w)=>{let b=Rt(r,{...w.options,form:w.form,validationLogic:w.form.options.validationLogic||ht});return b.forEach((N)=>{N.field=w}),i.concat(b)},[]),y=[],g=[],v=s.some((i)=>i.validate)||h.some((i)=>i.validate);if(v){if(!this.state.meta.isValidating)this.setMeta((i)=>({...i,isValidating:!0}));for(let i of c)i.setMeta((w)=>({...w,isValidating:!0}))}let x=(i,w,b)=>{let N=ka(w.cause),V=i.getInfo();V.validationMetaMap[N]?.lastAbortController.abort();let j=new AbortController;V.validationMetaMap[N]={lastAbortController:j};let re=i===this;b.push(new Promise(async(oe)=>{let F;try{F=await new Promise((be,De)=>{if(i.timeoutIds.validations[w.cause])clearTimeout(i.timeoutIds.validations[w.cause]);i.timeoutIds.validations[w.cause]=setTimeout(async()=>{if(j.signal.aborted)return be(void 0);try{be(await this.runValidator({validate:w.validate,value:{value:i.store.state.value,signal:j.signal,validationSource:re?"form":"field",...i instanceof Zt?{groupApi:i}:{fieldApi:i}},type:"validateAsync"}))}catch(Ee){De(Ee)}},w.debounceMs)})}catch(be){F=be}if(j.signal.aborted)return oe(void 0);let T=F,U=void 0;if(re&&Ja(F))T=F.group,U=F.fields;let Y=Ya(T),k=d[i.name]?.[N],{newErrorValue:J,newSource:ye}=Wt({formLevelError:k,fieldLevelError:Y});if(i.getInfo().instance!==i)return oe(void 0);if(i.setMeta((be)=>({...be,errorMap:{...be?.errorMap,[N]:J},errorSourceMap:{...be.errorSourceMap,[N]:ye}})),re)this.distributeFieldErrors(N,U);oe(J)}))};for(let i of s){if(!i.validate)continue;x(this,i,y)}for(let i of h){if(!i.validate)continue;x(i.field,i,g)}let p=[];if(y.length||g.length)p=await Promise.all(y),await Promise.all(g);if(v){this.setMeta((i)=>({...i,isValidating:!1}));for(let i of c)i.setMeta((w)=>({...w,isValidating:!1}))}return p.filter(Boolean)},this.validateAllFields=async(r)=>{let a=[];return He(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(a.push(Promise.resolve().then(()=>s.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!s.store.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})}),(await Promise.all(a)).flat()},this.validateArrayFieldsStartingFrom=(r,a,l)=>this.form.validateArrayFieldsStartingFrom(r,a,l),this.validateField=(r,a)=>this.form.validateField(r,a),this.getFieldValue=(r)=>this.form.getFieldValue(r),this.getFieldMeta=(r)=>this.form.getFieldMeta(r),this.setFieldMeta=(r,a)=>this.form.setFieldMeta(r,a),this.setFieldValue=(r,a)=>this.form.setFieldValue(r,a),this.deleteField=(r)=>this.form.deleteField(r),this.pushFieldValue=(r,a)=>this.form.pushFieldValue(r,a),this.insertFieldValue=(r,a,l)=>this.form.insertFieldValue(r,a,l),this.replaceFieldValue=(r,a,l)=>this.form.replaceFieldValue(r,a,l),this.swapFieldValues=(r,a,l)=>this.form.swapFieldValues(r,a,l),this.moveFieldValues=(r,a,l)=>this.form.moveFieldValues(r,a,l),this.clearFieldValues=(r)=>this.form.clearFieldValues(r),this.resetField=(r)=>this.form.resetField(r),this.removeFieldValue=(r,a)=>this.form.removeFieldValue(r,a),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((r)=>r.state.meta.isValid),this.validate=(r,a)=>{let{fieldsErrorMap:l}=a?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>bt(this.name,c)}),{hasErrored:s}=this.validateSync(r,l[this.name]??{},{skipRelatedFieldValidation:a?.skipRelatedFieldValidation});if(s&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[ka(r)]?.lastAbortController.abort(),this.state.meta.errors;let d=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>bt(this.name,c)});return this.validateAsync(r,d,{skipRelatedFieldValidation:a?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeGroupDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},r)}else this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async(r)=>{this.setFormGroupState((s)=>({...s,isSubmitted:!1,submissionAttempts:s.submissionAttempts+1,isSubmitSuccessful:!1})),He(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(!s.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})});let a=r??this.options.onSubmitMeta;this.setFormGroupState((s)=>({...s,isSubmitting:!0}));let l=()=>{this.setFormGroupState((s)=>({...s,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.areRelatedFieldsValid()){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}if(await this.validate("submit",{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}He(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{s.options.listeners?.onGroupSubmit?.({value:s.state.value,fieldApi:s})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:a}),He(()=>{this.setFormGroupState((s)=>({...s,isSubmitted:!0,isSubmitSuccessful:!0})),l()})}catch(s){throw this.setFormGroupState((d)=>({...d,isSubmitSuccessful:!1})),l(),s}},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=Ft((r)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let a=this.form.getFormGroupMeta(this.name)??Ss(e.defaultMeta),l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!gt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ta(e.validate)){let r=Lt[e.type](e.value,e.validate);if(e.type==="validate")return Cs(r);return r.then(Cs)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function Ya(e){if(e)return e;return}function Ja(e){return!!e&&typeof e==="object"&&"fields"in e}function Cs(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:r,fields:a,...l}=e;return{...l,group:r,fields:a}}function ka(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function es(e,r){if(!r)return;let a=Object.assign({},e,{state:Ht(e.state)});if(r(a),a.fieldInfo!==e.fieldInfo)e.fieldInfo=a.fieldInfo;if(a.options!==e.options)e.options=a.options;let s=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((d,c)=>{if(e.state[c]!==a.state[c])d[c]=a.state[c];return d},{});return He(()=>{if(Object.keys(s).length)e.baseStore.setState((d)=>({...d,...s}));if(a.state.errorMap!==e.state.errorMap)e.setErrorMap(a.state.errorMap)}),a}S();function jr(e,r){return e===r}function je(e,r=(l)=>l,a){let l=a?.compare??jr,s=P((c)=>{let{unsubscribe:h}=e.subscribe(c);return h},[e]),d=P(()=>e.get(),[e]);return Fc(s,d,d,r,l)}var da=(e,r=(l)=>l,a)=>je(e,r,{compare:a});S();S();S();var Nt=typeof window<"u"?$e:m;function Or(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new jt({...e})),d=l;if(r.form!==e.form||r.name!==e.name)d=new jt({...e}),s(d),a({form:e.form,name:e.name});let c=je(d.store,e.mode==="array"?(w)=>w.meta._arrayVersion||0:(w)=>w.value),h=je(d.store,(w)=>w.meta.isTouched),y=je(d.store,(w)=>w.meta.isBlurred),g=je(d.store,(w)=>w.meta.isDirty),v=je(d.store,(w)=>w.meta.errorMap),x=je(d.store,(w)=>w.meta.errorSourceMap),p=je(d.store,(w)=>w.meta.isValidating),i=D(()=>({...d,get state(){return{value:e.mode==="array"?d.state.value:c,get meta(){return{...d.state.meta,isTouched:h,isBlurred:y,isDirty:g,errorMap:v,errorSourceMap:x,isValidating:p}}}}}),[d,e.mode,c,h,y,g,v,x,p]);return Nt(d.mount,[d]),Nt(()=>{d.update(e)}),i}var ks=({children:e,...r})=>{let a=Or(r),l=D(()=>Dt(e,a),[e,a]);return t(L,{children:l})};S();S();function Ms(){return u(()=>ra())[0]}var $r=Q,Fs=Zs.split(".")[0]==="17"?Ms:$r.useId;S();function Qr(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new Zt({...e}));if(r.form!==e.form||r.name!==e.name)s(new Zt({...e})),a({form:e.form,name:e.name});let d=je(l.store,(F)=>F.value),c=je(l.store,(F)=>F.meta.isTouched),h=je(l.store,(F)=>F.meta.isBlurred),y=je(l.store,(F)=>F.meta.isDirty),g=je(l.store,(F)=>F.meta.errorMap),v=je(l.store,(F)=>F.meta.errorSourceMap),x=je(l.store,(F)=>F.meta.isValidating),p=je(l.store,(F)=>F.meta.isSubmitting),i=je(l.store,(F)=>F.meta.isSubmitted),w=je(l.store,(F)=>F.meta.submissionAttempts),b=je(l.store,(F)=>F.meta.isSubmitSuccessful),N=je(l.store,(F)=>F.meta.canSubmit),V=je(l.store,(F)=>F.meta.isValid),q=je(l.store,(F)=>F.meta.isFieldsValid),j=je(l.store,(F)=>F.meta.isFieldsValidating),re=je(l.store,(F)=>F.meta.isGroupValid),oe=D(()=>({...l,handleSubmit:(...U)=>l._handleSubmit(...U),get state(){return{...l.state,value:d,get meta(){return{...l.state.meta,isTouched:c,isBlurred:h,isDirty:y,errorMap:g,errorSourceMap:v,isValidating:x,isSubmitting:p,isSubmitted:i,submissionAttempts:w,isSubmitSuccessful:b,canSubmit:N,isValid:V,isFieldsValid:q,isFieldsValidating:j,isGroupValid:re}}}}}),[l,d,c,h,y,g,v,x,p,i,w,b,N,V,q,j,re]);return Nt(l.mount,[l]),Nt(()=>{l.update(e)}),oe}var Ds=({children:e,...r})=>{let a=Qr(r),l=D(()=>Dt(e,a),[e,a]);return t(L,{children:l})};function Kr({form:e,selector:r=(l)=>l,children:a}){let l=je(e.store,r);return t(L,{children:Dt(a,l)})}function $t(e){let r=Fs(),[a,l]=u(e?.formId),[s,d]=u(()=>new na({...e,formId:e?.formId??r}));if(a!==e?.formId){let y=e?.formId??r;d(new na({...e,formId:y})),l(y)}let c=D(()=>{let y={...s,handleSubmit:(...g)=>s._handleSubmit(...g),get formId(){return s._formId},get state(){return s.store.state}};return y.Field=function(v){return t(ks,{...v,form:s})},y.FormGroup=function(v){return t(Ds,{...v,form:s})},y.Subscribe=function(v){return t(Kr,{form:s,selector:v.selector,children:v.children})},y},[s]);Nt(s.mount,[]),Nt(()=>{s.update(e)});let h=_(!1);return Nt(()=>{if(!h.current)return;if(!e?.transform)return;es(s,e.transform)},[s,e?.transform]),Nt(()=>{h.current=!0}),c}S();var zr=R({name:f().min(1,Jx()),type:Ve(["chat","autofill","embedding"]),permission:Ve(["owner","editor","reviewer"]),avatar:f().optional(),providerId:f().optional(),modelId:f().optional(),soul:f().optional(),thinkingLevel:iu.optional(),systemPrompt:f().optional(),skills:te(f()).optional(),mcpServerIds:te(f()).optional(),deniedTools:te(f()).optional()}),Ur=[{id:"bash",name:()=>E0(),description:()=>S0()},{id:"read_skill",name:()=>F0(),description:()=>O0()},{id:"read_asset",name:()=>Vm(),description:()=>D0()},{id:"list_assets",name:()=>$m(),description:()=>P0()},{id:"create_folder",name:()=>Um(),description:()=>I0()},{id:"create_file",name:()=>Bm(),description:()=>C0()},{id:"create_version",name:()=>zm(),description:()=>T0()},{id:"generate_image",name:()=>qm(),description:()=>k0()},{id:"generate_video",name:()=>Hm(),description:()=>R0()},{id:"rename_asset",name:()=>Qm(),description:()=>L0()},{id:"move_assets",name:()=>Gm(),description:()=>N0()},{id:"delete_asset",name:()=>jm(),description:()=>M0()}];function Is({isOpen:e,onClose:r,teamId:a,type:l,initialValues:s,title:d,readOnly:c=!1}){let h=G(),{canAdmin:y}=Ot(),{data:g}=Z({queryKey:["teams",a,"providers"],queryFn:async()=>{let X=await A.api.teams[":teamId"].providers.$get({param:{teamId:a}});if(!X.ok)throw Error("Failed to fetch providers");return await X.json()},enabled:e}),{data:v}=Z({queryKey:["teams",a,"skills"],queryFn:async()=>{let X=await A.api.teams[":teamId"].skills.$get({param:{teamId:a}});if(!X.ok)throw Error("Failed to fetch skills");return await X.json()},enabled:e}),x=v?.skills||[],{data:p}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let X=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!X.ok)throw Error("Failed to fetch MCP servers");return await X.json()},enabled:e}),i=p?.servers||[],w=D(()=>zr.superRefine((X,se)=>{if(X.type==="chat"||X.type==="autofill"){if(!X.providerId)se.addIssue({code:oo.custom,message:GE(),path:["providerId"]});if(!X.modelId)se.addIssue({code:oo.custom,message:zx(),path:["modelId"]})}}),[]),b=$t({defaultValues:{name:s?.name||"",type:s?.type||l||"chat",permission:s?.permission||"reviewer",avatar:s?.avatarPreset||s?.avatar||su[0].id,providerId:s?.providerId||"",modelId:s?.modelId||"",soul:s?.soul||"",thinkingLevel:s?.thinkingLevel||"off",systemPrompt:s?.systemPrompt||"",skills:s?.skills?.map((X)=>X.skillId)||[],mcpServerIds:s?.mcpServerIds||[],deniedTools:s?.deniedTools??[...NA]},validators:{onChange:w},onSubmit:async({value:X})=>{try{if(s?.id)await ae.mutateAsync({id:s.id,values:X});else await Ee.mutateAsync(X)}catch{}}}),N=da(b.store,(X)=>X.values.providerId),{data:V,isLoading:q}=Z({queryKey:["teams",a,"providers",N,"models"],queryFn:async()=>{let X=await A.api.providers[":id"].models.$get({param:{id:N}});if(!X.ok)throw Error("Failed to fetch models");return await X.json()},enabled:!!N&&e}),[j,re]=u(""),[oe,F]=u(!1),T=D(()=>{if(!g)return[];return[...g].sort((X,se)=>X.name.toLowerCase().localeCompare(se.name.toLowerCase()))},[g]),U=D(()=>{if(!j.trim())return T;let X=j.toLowerCase();return T.filter((se)=>se.name.toLowerCase().includes(X))},[T,j]),[Y,k]=u(""),[J,ye]=u(!1),be=D(()=>{if(!V)return[];return[...V].sort((X,se)=>{let ie=(X.name||X.modelId).toLowerCase(),pe=(se.name||se.modelId).toLowerCase();return ie.localeCompare(pe)})},[V]),De=D(()=>{if(!Y.trim())return be;let X=Y.toLowerCase();return be.filter((se)=>se.modelId.toLowerCase().includes(X)||se.name&&se.name.toLowerCase().includes(X))},[be,Y]),Ee=B({mutationFn:async(X)=>{let se=await A.api.teams[":teamId"].agents.$post({param:{teamId:a},json:X});if(!se.ok)throw Error("Failed to create agent");return await se.json()},onSuccess:()=>{r(),h.invalidateQueries({queryKey:["agents",a]}),M.success(f0())},onError:(X)=>{M.error($s({message:X.message}))}}),ae=B({mutationFn:async({id:X,values:se})=>{let ie=await A.api.agents[":agentId"].$put({param:{agentId:X},json:se});if(!ie.ok)throw Error("Failed to update agent");return await ie.json()},onSuccess:()=>{r(),h.invalidateQueries({queryKey:["agents",a]}),M.success(Jm())},onError:(X)=>{M.error($s({message:X.message}))}});m(()=>{if(e)b.reset(),re(""),F(!1),k(""),ye(!1)},[e,s,l]);let Se=da(b.store,(X)=>X.values.type),Oe=Se==="chat"||Se==="autofill",We=Se==="chat",lt=(X)=>X.map((se)=>{if(typeof se==="string")return{message:se};if(se&&typeof se==="object"&&"message"in se)return{message:String(se.message)};return{message:String(se||"")}});return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-3xl h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 flex-shrink-0",children:[t(ce,{children:d}),t(Mt,{children:ty()})]}),o("form",{onSubmit:(X)=>{X.preventDefault(),X.stopPropagation(),b.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ue,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 pt-2 space-y-6",children:[c&&t("div",{className:"p-3 bg-muted text-muted-foreground text-sm rounded-lg border border-border",children:h0()}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t(b.Field,{name:"name",children:(X)=>{let se=!!X.state.meta.errors.length&&X.state.meta.isTouched;return o(Qe,{"data-invalid":se,children:[t(ze,{children:g0()}),t(z,{value:X.state.value,onBlur:X.handleBlur,onChange:(ie)=>X.handleChange(ie.target.value),placeholder:A0(),"aria-invalid":se,disabled:c}),se&&t(Ge,{errors:lt(X.state.meta.errors)})]})}}),t(b.Field,{name:"type",children:(X)=>o(Qe,{children:[t(ze,{children:U0()}),o(Fe,{value:X.state.value,onValueChange:(se)=>X.handleChange(se),disabled:!0,children:[t(Ze,{className:"bg-muted/50",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"chat",children:Wm()}),t(ne,{value:"autofill",children:Km()}),t(ne,{value:"embedding",children:Ym()})]})]})]})}),We&&t(b.Field,{name:"permission",children:(X)=>o(Qe,{children:[t(ze,{children:Zp()}),o(Fe,{value:X.state.value||"reviewer",onValueChange:(se)=>X.handleChange(se),disabled:c||!y,children:[t(Ze,{children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Za()}),t(ne,{value:"editor",children:Ba()}),t(ne,{value:"owner",children:Ua()})]})]})]})}),t(b.Field,{name:"avatar",children:(X)=>o(Qe,{className:"md:col-span-2",children:[t(ze,{children:d0()}),o("div",{className:"flex flex-wrap gap-4 mt-2",children:[su.map((se)=>{let ie=X.state.value===se.id;return t("button",{type:"button",disabled:c,onClick:()=>!c&&X.handleChange(se.id),className:E("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all",!c&&"hover:scale-105",ie?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-muted-foreground",c&&"cursor-default opacity-80"),children:t("img",{src:se.preview,className:"w-full h-full object-cover",alt:CE()})},se.id)}),X.state.value&&!su.some((se)=>se.id===X.state.value)&&t("button",{type:"button",disabled:!0,className:"relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105 cursor-default",children:t("img",{src:X.state.value,className:"w-full h-full object-cover",alt:Ny()})})]})]})})]}),Oe&&o(L,{children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-4 bg-muted/50 rounded-xl border border-border",children:[t(b.Field,{name:"providerId",children:(X)=>{let se=!!X.state.meta.errors.length&&X.state.meta.isTouched,ie=g?.find((pe)=>pe.id===X.state.value);return o(Qe,{"data-invalid":se,children:[t(ze,{children:qE()}),o(At,{open:oe,onOpenChange:(pe)=>{if(F(pe),!pe)re("")},modal:!0,children:[t(_t,{asChild:!0,children:o(C,{type:"button",variant:"outline",role:"combobox","aria-expanded":oe,"aria-invalid":se,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",se&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate",children:ie?t("span",{className:"font-medium text-foreground truncate",children:ie.name}):t("span",{className:"text-muted-foreground",children:yI()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(yt,{className:"w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden",align:"start",side:"bottom",sideOffset:4,onWheel:(pe)=>pe.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Ut,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(z,{placeholder:sA(),value:j,onChange:(pe)=>re(pe.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ue,{className:"w-full p-1",style:{height:U.length===0?"96px":`${Math.min(U.length*38+8,256)}px`},onWheel:(pe)=>pe.stopPropagation(),children:U.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:ES()}):t("div",{className:"space-y-0.5 pr-2",children:U.map((pe)=>{let dt=X.state.value===pe.id;return o("div",{onClick:()=>{X.handleChange(pe.id),b.setFieldValue("modelId",""),k(""),F(!1),re("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",dt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("span",{className:"truncate flex-1 pr-2",children:pe.name}),dt&&t(Re,{className:"w-4 h-4 text-primary shrink-0"})]},pe.id)})})})]})]}),se&&t(Ge,{errors:lt(X.state.meta.errors)})]})}}),t(b.Field,{name:"modelId",children:(X)=>{let se=!!X.state.meta.errors.length&&X.state.meta.isTouched,ie=V?.find((pe)=>pe.id===X.state.value);return o(Qe,{"data-invalid":se,children:[o(ze,{className:"flex items-center gap-2",children:[Fx(),q&&t(O,{className:"w-3 h-3 animate-spin"})]}),o(At,{open:J,onOpenChange:(pe)=>{if(ye(pe),!pe)k("")},modal:!0,children:[t(_t,{asChild:!0,children:o(C,{type:"button",variant:"outline",role:"combobox","aria-expanded":J,"aria-invalid":se,disabled:!N||q,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",se&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate flex items-center gap-2",children:ie?o(L,{children:[t("span",{className:"truncate font-medium text-foreground",children:ie.name||ie.modelId}),ie.name&&ie.name!==ie.modelId&&t(he,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:ie.modelId})]}):t("span",{className:"text-muted-foreground",children:hI()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(yt,{className:"w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden",align:"start",side:"bottom",sideOffset:4,onWheel:(pe)=>pe.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Ut,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(z,{placeholder:Op(),value:Y,onChange:(pe)=>k(pe.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ue,{className:"w-full p-1",style:{height:De.length===0?"96px":`${Math.min(De.length*38+8,256)}px`},onWheel:(pe)=>pe.stopPropagation(),children:De.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Md()}):t("div",{className:"space-y-0.5 pr-2",children:De.map((pe)=>{let dt=X.state.value===pe.id;return o("div",{onClick:()=>{X.handleChange(pe.id),ye(!1),k("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",dt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("div",{className:"min-w-0 flex-1 pr-2",children:o("div",{className:"flex items-center gap-2",children:[t("span",{className:"truncate",children:pe.name||pe.modelId}),pe.name&&pe.name!==pe.modelId&&o("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",pe.modelId,")"]}),pe.config?.reasoning&&t(he,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 gap-0.5 bg-primary/10 text-primary border-primary/20 shrink-0",children:t(qt,{className:"w-2.5 h-2.5"})})]})}),dt&&t(Re,{className:"w-4 h-4 text-primary shrink-0"})]},pe.id)})})})]})]}),se&&t(Ge,{errors:lt(X.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(b.Field,{name:"thinkingLevel",children:(X)=>{let se={off:VT(),low:WT(),medium:YT(),high:QT()};return o(Qe,{children:[t(ze,{children:KT()}),o(Fe,{value:X.state.value,onValueChange:(ie)=>X.handleChange(ie),children:[t(Ze,{children:t(Le,{})}),t(Be,{children:iu.options.map((ie)=>t(ne,{value:ie,children:se[ie]||ie},ie))})]})]})}})})]}),t(b.Field,{name:"soul",children:(X)=>o(Qe,{children:[t(ze,{children:w0()}),t(Ei,{value:X.state.value,onBlur:X.handleBlur,onChange:(se)=>X.handleChange(se.target.value),placeholder:x0(),className:"min-h-[120px]"})]})}),o("div",{className:"space-y-4",children:[o(W,{className:"text-base font-bold flex items-center gap-2",children:[t(Ct,{className:"w-5 h-5 text-primary"}),mA()]}),t("div",{className:"space-y-2",children:t(b.Field,{name:"skills",children:(X)=>o(L,{children:[x.map((se)=>{let ie=X.state.value?.includes(se.id)||!1;return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(Ct,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:se.name}),se.description&&t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:se.description})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:ie?qf():zf()}),t(Me,{checked:ie,onCheckedChange:(pe)=>{if(pe)X.handleChange([...X.state.value||[],se.id]);else X.handleChange((X.state.value||[]).filter((dt)=>dt!==se.id))}})]})]},se.id)}),x.length===0&&t("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-sm text-muted-foreground",children:MS()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(W,{className:"text-base font-bold flex items-center gap-2",children:[t(wn,{className:"w-5 h-5 text-primary"}),Qc()]}),t("div",{className:"space-y-2",children:t(b.Field,{name:"mcpServerIds",children:(X)=>o(L,{children:[i.map((se)=>{let ie=X.state.value?.includes(se.id)||!1,pe=se.status==="needs_auth"||!se.hasCredential&&se.authType==="oauth";return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(wn,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-sm font-medium",children:se.name}),o(he,{variant:"outline",className:"text-[10px]",children:[se.toolCount??0," tools"]}),pe&&t(he,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:ng()})]}),t("span",{className:"text-[10px] font-mono text-muted-foreground line-clamp-1",children:se.url})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:ie?qf():zf()}),t(Me,{checked:ie,onCheckedChange:(dt)=>{if(dt)X.handleChange([...X.state.value||[],se.id]);else X.handleChange((X.state.value||[]).filter((ee)=>ee!==se.id))}})]})]},se.id)}),i.length===0&&t("div",{className:"text-center py-6 border-2 border-dashed border-border rounded-xl",children:t("p",{className:"text-xs text-muted-foreground",children:yg()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(W,{className:"text-base font-bold flex items-center gap-2",children:[t(ko,{className:"w-5 h-5 text-primary"}),Z0()]}),t("p",{className:"text-xs text-muted-foreground",children:B0()}),t("div",{className:"space-y-2",children:t(b.Field,{name:"deniedTools",children:(X)=>{let se=X.state.value||[];return t(L,{children:Ur.map((ie)=>{let pe=!se.includes(ie.id);return o("div",{className:"flex items-center justify-between p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex items-center gap-3",children:[t(ko,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:ie.name()}),t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:ie.description()})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:pe?qf():zf()}),t(Me,{checked:pe,disabled:!y,onCheckedChange:(dt)=>{if(dt)X.handleChange(se.filter((ee)=>ee!==ie.id));else X.handleChange([...se,ie.id])}})]})]},ie.id)})})}})})]})]})]})}),t(qe,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:c?t(C,{variant:"outline",onClick:r,type:"button",children:Da()}):o(L,{children:[t(C,{variant:"outline",onClick:r,type:"button",children:Ne()}),t(b.Subscribe,{selector:(X)=>[X.canSubmit,X.isSubmitting],children:([X,se])=>o(C,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!X||se||Ee.isPending||ae.isPending,children:[(se||Ee.isPending||ae.isPending)&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),s?Vs():by()]})})]})})]})]})})}var Hr=[{type:"chat",label:"Chat",icon:xo},{type:"autofill",label:"Autofill",icon:qt},{type:"embedding",label:"Embedding",icon:lo}];function Ts({teamId:e}){let r=G(),{canAdmin:a}=Ot(),[l,s]=u(!1),[d,c]=u("chat"),[h,y]=u(null),[g,v]=u(null),[x,p]=u(!1),[i,w]=u({chat:!0,autofill:!0,embedding:!0}),b=(F)=>{if(F==="chat")return Wm();if(F==="autofill")return Km();return Ym()},{data:N=[],isLoading:V}=Z({queryKey:["agents",e],queryFn:async()=>{let F=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!F.ok)throw Error("failed to fetch agents");return[...await F.json()].sort((U,Y)=>Y.id.localeCompare(U.id))}}),q=B({mutationFn:async(F)=>{if(!(await A.api.agents[":agentId"].$delete({param:{agentId:F}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{p(!1),r.invalidateQueries({queryKey:["agents",e]}),M.success(p0())},onError:(F)=>{M.error(F.message)}}),j=B({mutationFn:async({agentId:F,permission:T})=>{let U=await A.api.agents[":agentId"].permission.$patch({param:{agentId:F},json:{permission:T}});if(!U.ok)throw Error(El());return U.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]})},onError:(F)=>{M.error(F.message||El())}}),re=B({mutationFn:async(F)=>{let T=await A.api.agents[":agentId"].$put({param:{agentId:F.agentId},json:{name:F.name,type:F.type,enabled:F.enabled,avatar:F.avatar,providerId:F.providerId,modelId:F.modelId,thinkingLevel:F.thinkingLevel,systemPrompt:F.systemPrompt,soul:F.soul,skills:F.skills,deniedTools:F.deniedTools}});if(!T.ok)throw Error("failed to update agent");return T.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]}),M.success(Jm())},onError:(F)=>{M.error(F.message)}}),oe=(F)=>{w((T)=>({...T,[F]:!T[F]}))};return o(L,{children:[(l||h)&&t(Is,{isOpen:!0,readOnly:h?.readOnly,title:h?Sh({name:h.name}):My({type:b(d)}),onClose:()=>{s(!1),y(null)},teamId:e,type:d,initialValues:h||void 0}),t(Xe,{open:x,onOpenChange:p,children:o(et,{children:[o(tt,{children:[t(nt,{children:fd()}),t(ot,{children:Vy({name:g?.name??""})})]}),o(rt,{children:[t(it,{children:Ne()}),t(st,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(F)=>{if(q.isPending){F.preventDefault();return}if(g)q.mutate(g.id)},children:q.isPending?t(O,{className:"w-4 h-4 animate-spin"}):Gy()})]})]})}),V&&N.length===0?t("div",{className:"flex items-center justify-center p-12",children:t(O,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[V&&t("div",{className:"absolute top-0 right-0 p-2",children:t(O,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),Hr.map((F)=>{let T=N.filter((k)=>k.type===F.type),U=F.icon,Y=F.type==="autofill"||F.type==="embedding";return o("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[o("div",{className:E("px-6 py-4 flex items-center justify-between",!Y&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!Y?()=>oe(F.type):void 0,children:[o("div",{className:"flex items-center gap-2",children:[t("h3",{className:"font-semibold text-foreground",children:F.type==="chat"?q_():F.type==="autofill"?v_():Eb()}),!Y&&t(he,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:T.length})]}),o("div",{className:"flex items-center gap-2",children:[!(Y&&T.length>0)&&t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20",onClick:(k)=>{k.stopPropagation(),c(F.type),s(!0)},children:t(fe,{className:"w-4 h-4"})}),!Y&&t(ve,{className:E("w-5 h-5 text-muted-foreground transition-transform duration-200",i[F.type]?"rotate-180":"")})]})]}),(Y||i[F.type])&&t("div",{className:"px-6 pb-6 pt-2 space-y-3",children:o("div",{className:"grid grid-cols-1 gap-4",children:[T.map((k)=>t(Ke,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>y(k),children:o(at,{className:"p-4 flex flex-col gap-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[t("div",{className:"w-10 h-10 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:k.avatar?t("img",{src:k.avatar,className:"w-full h-full object-cover",alt:""}):t(Tt,{className:"w-6 h-6 text-muted-foreground"})}),o("div",{className:"min-w-0 flex-1",children:[t("span",{className:"font-bold text-foreground block truncate",children:k.name}),t("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:o("span",{className:"flex items-center gap-1",children:[t(Ct,{className:"w-3 h-3"}),qI({count:k.skills?.length||0})]})})]})]}),k.readOnly?t(he,{variant:"outline",className:"text-xs text-muted-foreground border-border",children:_0()}):o(ge,{modal:!1,children:[t(Ae,{asChild:!0,onClick:(J)=>J.stopPropagation(),children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Sr,{className:"w-4 h-4"})})}),t(_e,{align:"end",className:"w-32",children:o(K,{onClick:(J)=>{J.stopPropagation(),v(k),p(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",ct()]})})]})]}),o("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[t("div",{children:k.type==="chat"?t("div",{onClick:(J)=>J.stopPropagation(),children:o(Fe,{value:k.permission||"reviewer",onValueChange:(J)=>{j.mutate({agentId:k.id,permission:J})},disabled:!a,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{children:k.permission==="reviewer"?Za():k.permission==="editor"?Ba():Ua()})}),o(Be,{align:"start",children:[t(ne,{value:"reviewer",children:Za()}),t(ne,{value:"editor",children:Ba()}),t(ne,{value:"owner",children:Ua()})]})]})}):t("div",{})}),t("div",{onClick:(J)=>J.stopPropagation(),children:t(Me,{checked:k.enabled,disabled:k.readOnly,onCheckedChange:(J)=>{re.mutate({teamId:e,agentId:k.id,name:k.name,type:k.type,enabled:J,avatar:k.avatar,providerId:k.providerId,modelId:k.modelId,thinkingLevel:k.thinkingLevel,systemPrompt:k.systemPrompt,soul:k.soul,skills:k.skills?.map((ye)=>ye.skillId),deniedTools:k.deniedTools})}})})]})]})},k.id)),T.length===0&&o("div",{className:"col-span-full py-8 flex flex-col items-center justify-center border-2 border-dashed border-border rounded-xl bg-muted/30",children:[t("div",{className:"w-10 h-10 rounded-full bg-card flex items-center justify-center shadow-sm mb-3",children:t(U,{className:"w-5 h-5 text-muted-foreground"})}),t("p",{className:"text-sm text-muted-foreground",children:dS({type:b(F.type)})}),t(C,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{c(F.type),s(!0)},children:Ey()})]})]})})]},F.type)})]})]})}S();S();function Ma({isOpen:e,onClose:r,onSubmit:a,initialValues:l,title:s,isLoading:d=!1,defaultApi:c,existingModelIds:h=[]}){let y=D(()=>DA.extend({modelId:f().min(1,ig()).refine((p)=>{if(l?.modelId===p)return!0;return!h.includes(p)},{message:Bx()})}),[h,l]),g=()=>l||{modelId:"",name:"",config:{api:c,reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},v=$t({defaultValues:g(),validators:{onSubmit:y},onSubmit:async({value:p})=>{a(p)}});m(()=>{if(e)v.reset(g())},[e,l,c,v]);let x=(p)=>p.map((i)=>{if(typeof i==="string")return{message:i};if(i&&typeof i==="object"&&"message"in i)return{message:String(i.message)};return{message:String(i||"")}});return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-xl h-[85vh] max-h-[700px] flex flex-col p-0 overflow-hidden",children:[t(me,{className:"p-6 pb-2 shrink-0",children:t(ce,{className:"text-xl",children:s})}),o("form",{onSubmit:(p)=>{p.preventDefault(),p.stopPropagation(),v.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ue,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"space-y-4",children:[t(v.Field,{name:"modelId",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,children:ig()}),t(z,{id:p.name,name:p.name,value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(w.target.value),placeholder:Ux(),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}}),t(v.Field,{name:"name",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,children:pb()}),t(z,{id:p.name,name:p.name,value:p.state.value||"",onBlur:p.handleBlur,onChange:(w)=>p.handleChange(w.target.value),placeholder:jx(),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:dE()}),t(v.Field,{name:"config.reasoning",children:(p)=>o(Qe,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[t(ze,{htmlFor:p.name,className:"cursor-pointer",children:Mp()}),t(Me,{id:p.name,checked:p.state.value,onCheckedChange:p.handleChange})]})}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(v.Field,{name:"config.contextWindow",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:cy()}),t(z,{id:p.name,name:p.name,type:"number",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseInt(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}}),t(v.Field,{name:"config.maxTokens",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:Xw()}),t(z,{id:p.name,name:p.name,type:"number",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseInt(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}})]})]}),o("div",{className:"space-y-4 pt-2 border-t border-border",children:[o("h4",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:[t(ha,{className:"w-4 h-4 text-primary"}),IE()]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(v.Field,{name:"config.cost.input",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:Iw()}),t(z,{id:p.name,name:p.name,type:"number",step:"0.0001",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseFloat(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}}),t(v.Field,{name:"config.cost.output",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:iE()}),t(z,{id:p.name,name:p.name,type:"number",step:"0.0001",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseFloat(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}}),t(v.Field,{name:"config.cost.cacheRead",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:Z_()}),t(z,{id:p.name,name:p.name,type:"number",step:"0.0001",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseFloat(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}}),t(v.Field,{name:"config.cost.cacheWrite",children:(p)=>{let i=!!p.state.meta.errors.length&&p.state.meta.isTouched;return o(Qe,{"data-invalid":i,children:[t(ze,{htmlFor:p.name,className:"text-xs",children:B_()}),t(z,{id:p.name,name:p.name,type:"number",step:"0.0001",value:p.state.value,onBlur:p.handleBlur,onChange:(w)=>p.handleChange(parseFloat(w.target.value)||0),"aria-invalid":i}),i&&t(Ge,{errors:x(p.state.meta.errors)})]})}})]})]})]})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(C,{type:"button",variant:"outline",onClick:r,disabled:d,children:Ne()}),t(v.Subscribe,{selector:(p)=>[p.canSubmit,p.isSubmitting],children:([p,i])=>t(C,{type:"submit",className:"min-w-[100px]",disabled:!p||i||d,children:i||d?t(O,{className:"w-4 h-4 animate-spin"}):Vs()})})]})]})]})})}S();function Es({isOpen:e,onClose:r,teamId:a,syncData:l,onSuccess:s}){let[d,c]=u(""),[h,y]=u(()=>new Set(l?.providers.map((T)=>T.name)||[])),[g,v]=u(()=>{let T=new Set;return l?.providers.forEach((U)=>{U.models.forEach((Y)=>{T.add(`${U.name}:${Y.modelId}`)})}),T});m(()=>{if(l){y(new Set(l.providers.map((U)=>U.name)));let T=new Set;l.providers.forEach((U)=>{U.models.forEach((Y)=>{T.add(`${U.name}:${Y.modelId}`)})}),v(T)}},[l]);let x=D(()=>{if(!l)return[];let T=d.trim().toLowerCase();if(!T)return l.providers;return l.providers.map((U)=>{let Y=U.name.toLowerCase().includes(T),k=U.models.filter((J)=>Y||J.modelId.toLowerCase().includes(T)||J.name.toLowerCase().includes(T));if(k.length>0)return{...U,models:k};return null}).filter((U)=>U!==null)},[l,d]),p=g.size,i=D(()=>{if(!l)return 0;let T=0;for(let U of l.providers)if(U.models.some((k)=>g.has(`${U.name}:${k.modelId}`)))T++;return T},[l,g]),w=(T)=>{y((U)=>{let Y=new Set(U);if(Y.has(T))Y.delete(T);else Y.add(T);return Y})},b=()=>{if(!l)return;y(new Set(l.providers.map((T)=>T.name)))},N=()=>{y(new Set)},V=(T,U)=>{let Y=`${T}:${U}`;v((k)=>{let J=new Set(k);if(J.has(Y))J.delete(Y);else J.add(Y);return J})},q=(T)=>{let U=l?.providers.find((k)=>k.name===T);if(!U||U.models.length===0)return;let Y=U.models.every((k)=>g.has(`${T}:${k.modelId}`));v((k)=>{let J=new Set(k);return U.models.forEach((ye)=>{let be=`${T}:${ye.modelId}`;if(Y)J.delete(be);else J.add(be)}),J})},j=()=>{if(!l)return;let T=new Set;l.providers.forEach((U)=>{U.models.forEach((Y)=>{T.add(`${U.name}:${Y.modelId}`)})}),v(T)},re=()=>{v(new Set)},oe=B({mutationFn:async(T)=>{let U=await A.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:a},json:T});if(!U.ok){let Y=await U.json().catch(()=>({message:"Failed to apply sync"}));throw Error(Y.message||"Failed to apply sync")}return await U.json()},onSuccess:(T)=>{M.success(kT({modelCount:T.addedModels,providerCount:T.addedProviders})),s(),r()},onError:(T)=>{M.error(T.message)}}),F=async()=>{if(!l||p===0)return;let T=[];for(let U of l.providers){let Y=U.models.filter((k)=>g.has(`${U.name}:${k.modelId}`));if(Y.length>0)T.push({name:U.name,isNewProvider:U.isNewProvider,config:U.config,models:Y})}if(T.length===0)return;await oe.mutateAsync({providers:T})};return t(de,{open:e,onOpenChange:(T)=>!T&&r(),children:o(le,{className:"sm:max-w-3xl md:max-w-4xl w-full h-[85vh] max-h-[85vh] flex flex-col p-0 overflow-hidden gap-0",children:[o(me,{className:"p-6 pb-4 shrink-0",children:[o(ce,{className:"flex items-center gap-2 text-xl font-semibold",children:[t(dn,{className:"w-5 h-5 text-primary"}),vT()]}),t(Mt,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:bT()})]}),t("div",{className:"px-6 pb-3 shrink-0",children:o("div",{className:"flex items-center justify-between gap-3",children:[o("div",{className:"relative flex-1",children:[t(Ut,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(z,{value:d,onChange:(T)=>c(T.target.value),placeholder:IT(),className:"pl-8 h-8 text-xs bg-background"})]}),o("div",{className:"flex items-center gap-1.5",children:[t(C,{type:"button",variant:"outline",size:"sm",onClick:b,className:"h-8 text-xs px-2.5",children:xT()}),t(C,{type:"button",variant:"outline",size:"sm",onClick:N,className:"h-8 text-xs px-2.5",children:AT()}),t("div",{className:"w-px h-4 bg-border mx-1"}),t(C,{type:"button",variant:"outline",size:"sm",onClick:j,className:"h-8 text-xs px-2.5",children:TT()}),t(C,{type:"button",variant:"outline",size:"sm",onClick:re,className:"h-8 text-xs px-2.5",children:yT()})]})]})}),t("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:t(ue,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:t("div",{className:"p-3 space-y-3",children:x.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:_g()}):x.map((T)=>{let U=h.has(T.name),Y=T.isNewProvider,k=T.models.filter((be)=>g.has(`${T.name}:${be.modelId}`)).length,J=k===T.models.length,ye=k>0&&!J;return o("div",{className:"border border-border/50 rounded-lg bg-background overflow-hidden",children:[o("div",{className:"flex items-center justify-between px-3 py-2 bg-card hover:bg-muted/40 transition-colors",children:[o("div",{className:"flex items-center gap-2.5",children:[t("button",{type:"button",onClick:()=>w(T.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:U?t(ve,{className:"w-4 h-4"}):t(Et,{className:"w-4 h-4"})}),t(wr,{checked:J?!0:ye?"indeterminate":!1,onCheckedChange:()=>q(T.name),id:`provider-check-${T.name}`}),o("label",{htmlFor:`provider-check-${T.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[t(lo,{className:"w-4 h-4 text-muted-foreground"}),t("span",{children:T.name})]})]}),o("div",{className:"flex items-center gap-2",children:[Y?t(he,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:ET()}):t(he,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:wT()}),t("span",{className:"text-xs text-muted-foreground",children:ST({count:T.models.length})})]})]}),U&&t("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:T.models.map((be)=>{let De=g.has(`${T.name}:${be.modelId}`);return o("div",{className:"flex items-center justify-between pl-9 pr-3 py-2 hover:bg-muted/30 transition-colors",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t(wr,{checked:De,onCheckedChange:()=>V(T.name,be.modelId),id:`model-check-${T.name}-${be.modelId}`}),o("label",{htmlFor:`model-check-${T.name}-${be.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[be.name||be.modelId,t("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:be.modelId})]})]}),o("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[be.config.reasoning&&t(he,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:CT()}),t("span",{className:"text-[11px] text-muted-foreground font-mono",children:_T({count:Math.round(be.config.contextWindow/1000)})})]})]},be.modelId)})})]},T.name)})})})}),o(qe,{className:"p-6 pt-3 shrink-0 border-t border-border flex items-center justify-between sm:justify-between w-full",children:[t("div",{className:"text-xs text-muted-foreground",children:MT({modelCount:p,providerCount:i})}),o("div",{className:"flex items-center gap-2",children:[t(C,{type:"button",variant:"outline",onClick:r,disabled:oe.isPending,children:Ne()}),t(C,{type:"button",onClick:F,disabled:p===0||oe.isPending,className:"gap-2",children:oe.isPending?o(L,{children:[t(O,{className:"w-4 h-4 animate-spin"}),hT()]}):mT({count:p})})]})]})]})})}var Ls={"openai-completions":"OpenAI Completions","mistral-conversations":"Mistral Conversations","openai-responses":"OpenAI Responses","azure-openai-responses":"Azure OpenAI Responses","openai-codex-responses":"OpenAI Codex Responses","anthropic-messages":"Anthropic Messages","bedrock-converse-stream":"AWS Bedrock","google-generative-ai":"Google Generative AI","google-vertex":"Google Vertex"};function Ps({teamId:e}){let r=G(),[a,l]=u(null),[s,d]=u(!1),[c,h]=u(""),[y,g]=u(!1),[v,x]=u(null),[p,i]=u(!1),[w,b]=u(null),N=B({mutationFn:async()=>{let U=await A.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!U.ok){let Y=await U.json().catch(()=>({message:"Failed to check updates"}));throw Error(Y.message||"Failed to check updates")}return await U.json()},onSuccess:(U)=>{if(U.totalNewModels===0&&U.totalNewProviders===0){M.info(RT());return}b(U),i(!0)},onError:(U)=>{M.error(U.message)}}),{data:V,isLoading:q}=Z({queryKey:["teams",e,"providers"],queryFn:async()=>{let U=await A.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!U.ok)throw Error("Failed to fetch providers");return await U.json()}}),j=D(()=>V?.find((U)=>U.id===a)||null,[V,a]),re=D(()=>V?.map((U)=>U.name)||[],[V]),oe=D(()=>{if(!V)return[];if(!c.trim())return V;let U=c.toLowerCase();return V.filter((Y)=>Y.name.toLowerCase().includes(U))},[V,c]),F=B({mutationFn:async(U)=>{let Y=await A.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:U.name,config:U.config,models:U.models}});if(!Y.ok)throw Error("Failed to create provider");return await Y.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),d(!1),M.success(HE())},onError:(U)=>{M.error($s({message:U.message}))}}),T=B({mutationFn:async(U)=>{let Y=await A.api.providers[":id"].$delete({param:{id:U}});if(!Y.ok)throw Error("Failed to delete provider");return await Y.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),l(null),g(!1),x(null),M.success($E())},onError:(U)=>{M.error($s({message:U.message}))}});if(q)return t("div",{className:"flex h-64 items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-primary"})});return o("div",{className:"h-full flex flex-col space-y-0",children:[o("div",{className:"flex-none space-y-4 pb-4",children:[o("div",{className:"flex items-center justify-between",children:[o("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[t(lo,{className:"w-5 h-5 text-primary"}),oy()]}),o("div",{className:"flex items-center gap-2",children:[t(C,{variant:"outline",onClick:()=>N.mutate(),disabled:N.isPending,className:"gap-2",children:N.isPending?o(L,{children:[t(O,{className:"w-4 h-4 animate-spin"}),gT()]}):o(L,{children:[t(pa,{className:"w-4 h-4"}),pT()]})}),o(C,{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[t(fe,{className:"w-4 h-4"}),Om()]})]})]}),o("div",{className:"relative px-0.5",children:[t(Ut,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(z,{placeholder:sA(),value:c,onChange:(U)=>h(U.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),t(ue,{className:"flex-1 min-h-0",children:o("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[oe.map((U)=>t(Ke,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>l(U.id),children:o(at,{className:"p-5 flex items-center justify-between gap-4",children:[o("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[t("div",{className:"flex-none p-3 bg-muted rounded-xl group-hover:bg-primary/10 transition-colors",children:t(ua,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"min-w-0 flex-1",children:[t("div",{className:"flex items-center gap-2",children:t("span",{className:"font-bold text-foreground truncate",children:U.name})}),o("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-xs text-muted-foreground mt-1",children:[o("span",{className:"flex items-center gap-1 flex-none",children:[t(qt,{className:"w-3 h-3"}),U.config.api]}),U.config.baseUrl&&o("span",{className:"flex items-center gap-1 min-w-0",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(Hn,{className:"w-3 h-3 flex-none"}),t("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:U.config.baseUrl})]}),o("span",{className:"flex items-center gap-1 flex-none",children:[t("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/30 flex-none"}),t(os,{className:"w-3 h-3"}),Yx({count:U.modelsCount})]})]})]})]}),o("div",{className:"flex items-center gap-1",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,onClick:(Y)=>Y.stopPropagation(),children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Sr,{className:"w-4 h-4"})})}),t(_e,{align:"end",className:"w-32",children:o(K,{onClick:(Y)=>{Y.stopPropagation(),x(U),g(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",ct()]})})]}),t(Et,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},U.id)),V?.length===0&&o("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[t(lo,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:SS()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:JA()})]}),V&&V.length>0&&oe.length===0&&o("div",{className:"text-center py-12",children:[t(Ut,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:_g()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:p1({query:c})}),t(C,{variant:"ghost",size:"sm",onClick:()=>h(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:V_()})]})]})}),t(Gr,{isOpen:s,onClose:()=>d(!1),onSubmit:(U)=>F.mutate(U),isLoading:F.isPending,existingProviderNames:re}),j&&t(Wr,{isOpen:!!j,onClose:()=>l(null),provider:j,teamId:e,existingProviderNames:re}),t(Xe,{open:y,onOpenChange:g,children:o(et,{children:[o(tt,{children:[t(nt,{children:fd()}),t(ot,{children:rb({name:v?.name??""})})]}),o(rt,{children:[t(it,{onClick:()=>x(null),children:Ne()}),o(st,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(v)T.mutate(v.id)},children:[T.isPending?t(O,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),ct()]})]})]})}),t(Es,{isOpen:p,onClose:()=>i(!1),teamId:e,syncData:w,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function Gr({isOpen:e,onClose:r,onSubmit:a,isLoading:l,existingProviderNames:s}){let[d,c]=u([]),[h,y]=u(!1),[g,v]=u(null),x=D(()=>R({name:f().min(1,Og()).refine((b)=>!s.includes(b),{message:Fg()}),config:ia}),[s]),p=$t({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:x},onSubmit:async({value:b})=>{a({name:b.name,config:b.config,models:d})}});m(()=>{if(e)p.reset(),c([]),y(!1),v(null)},[e,p]);let i=(b)=>b.map((N)=>{if(typeof N==="string")return{message:N};if(N&&typeof N==="object"&&"message"in N)return{message:String(N.message)};return{message:String(N||"")}}),w=(b)=>{if(g!==null)c((N)=>N.map((V,q)=>q===g?b:V)),v(null);else c((N)=>[b,...N]),y(!1)};return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[t(ce,{className:"text-xl",children:r0()}),t(Mt,{children:uh()})]}),o("form",{onSubmit:(b)=>{b.preventDefault(),b.stopPropagation(),p.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ue,{className:"h-full",children:o("div",{className:"p-6 pt-2 space-y-6 pr-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 p-5 rounded-2xl border bg-muted/20",children:[t(p.Field,{name:"name",children:(b)=>{let N=!!b.state.meta.errors.length&&b.state.meta.isTouched;return o(Qe,{"data-invalid":N,children:[t(ze,{htmlFor:b.name,children:Dg()}),t(z,{id:b.name,name:b.name,value:b.state.value,onBlur:b.handleBlur,onChange:(V)=>b.handleChange(V.target.value),placeholder:Lg(),"aria-invalid":N}),N&&t(Ge,{errors:i(b.state.meta.errors)})]})}}),t(p.Field,{name:"config.api",children:(b)=>{let N=!!b.state.meta.errors.length&&b.state.meta.isTouched;return o(Qe,{"data-invalid":N,children:[t(ze,{htmlFor:b.name,children:Hh()}),o(Fe,{onValueChange:b.handleChange,value:b.state.value,children:[t(Ze,{id:b.name,"aria-invalid":N,children:t(Le,{placeholder:iA()})}),t(Be,{children:au.map((V)=>t(ne,{value:V,children:Ls[V]},V))})]}),N&&t(Ge,{errors:i(b.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(p.Field,{name:"config.baseUrl",children:(b)=>{let N=!!b.state.meta.errors.length&&b.state.meta.isTouched;return o(Qe,{"data-invalid":N,children:[t(ze,{htmlFor:b.name,children:ah()}),t(z,{id:b.name,name:b.name,value:b.state.value||"",onBlur:b.handleBlur,onChange:(V)=>b.handleChange(V.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":N}),t(aa,{children:Sg()}),N&&t(Ge,{errors:i(b.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(p.Field,{name:"config.apiKey",children:(b)=>{let N=!!b.state.meta.errors.length&&b.state.meta.isTouched;return o(Qe,{"data-invalid":N,children:[t(ze,{htmlFor:b.name,children:dd()}),t(z,{id:b.name,name:b.name,type:"text",value:b.state.value||"",onBlur:b.handleBlur,onChange:(V)=>b.handleChange(V.target.value),placeholder:rh(),"aria-invalid":N}),t(aa,{className:"text-xs mt-1",children:th()}),N&&t(Ge,{errors:i(b.state.meta.errors)})]})}})})]}),o("div",{className:"space-y-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(W,{className:"text-base font-semibold",children:Id()}),t("p",{className:"text-xs text-muted-foreground mt-0.5",children:Hx()})]}),o(C,{type:"button",variant:"outline",size:"sm",onClick:()=>y(!0),className:"gap-1.5",children:[t(fe,{className:"w-4 h-4"}),ld()]})]}),d.length===0?t("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:Md()}):t("div",{className:"space-y-2",children:d.map((b,N)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>v(N),children:[o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2",children:[t("span",{className:"font-semibold text-foreground truncate",children:b.name||b.modelId}),t(he,{variant:"secondary",className:"font-mono text-[10px]",children:b.modelId}),b.config.reasoning&&o(he,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[t(qt,{className:"w-2.5 h-2.5"})," ",Mp()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[b.config.contextWindow?.toLocaleString()," ",EA()]}),t("span",{children:"·"}),t("span",{children:mh({input:b.config.cost?.input??0,output:b.config.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 ml-2",children:t(C,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(V)=>{V.stopPropagation(),c((q)=>q.filter((j,re)=>re!==N))},children:t(we,{className:"w-3.5 h-3.5"})})})]},b.modelId+N))})]})]})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(C,{type:"button",variant:"outline",onClick:r,disabled:l,children:Ne()}),t(p.Subscribe,{selector:(b)=>[b.canSubmit,b.isSubmitting],children:([b,N])=>t(C,{type:"submit",className:"min-w-[120px]",disabled:!b||N||l,children:N||l?t(O,{className:"w-4 h-4 animate-spin"}):Om()})})]})]}),(h||g!==null)&&t(Ma,{isOpen:!0,onClose:()=>{y(!1),v(null)},onSubmit:w,title:g!==null?Eh():ld(),initialValues:g!==null?d[g]:null,defaultApi:p.getFieldValue("config.api"),existingModelIds:d.filter((b,N)=>N!==g).map((b)=>b.modelId)},g!==null?`edit-${g}-${d[g]?.modelId}`:"add")]})})}function Wr({isOpen:e,onClose:r,provider:a,teamId:l,existingProviderNames:s}){let d=G(),[c,h]=u("general"),[y,g]=u(""),[v,x]=u(!1),[p,i]=u(null),[w,b]=u(null),{data:N=[],isLoading:V}=Z({queryKey:["teams",l,"providers",a.id,"models"],queryFn:async()=>{let k=await A.api.providers[":id"].models.$get({param:{id:a.id}});if(!k.ok)throw Error("Failed to fetch models");return await k.json()},enabled:e}),q=B({mutationFn:async(k)=>{let J=await A.api.providers[":id"].$put({param:{id:a.id},json:{name:k.name,config:k.config}});if(!J.ok)throw Error("Failed to update provider");return await J.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers"]}),M.success(zg())},onError:(k)=>{M.error($s({message:k.message}))}}),j=B({mutationFn:async(k)=>{let J=await A.api.providers[":id"].models.$post({param:{id:a.id},json:k});if(!J.ok)throw Error("Failed to create model");return await J.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),x(!1),M.success(Lx())},onError:(k)=>{M.error($s({message:k.message}))}}),re=B({mutationFn:async({modelDbId:k,values:J})=>{let ye=await A.api.providers[":id"].models[":modelDbId"].$put({param:{id:a.id,modelDbId:k},json:J});if(!ye.ok)throw Error("Failed to update model");return await ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),i(null),M.success(qx())},onError:(k)=>{M.error($s({message:k.message}))}}),oe=B({mutationFn:async(k)=>{let J=await A.api.providers[":id"].models[":modelDbId"].$delete({param:{id:a.id,modelDbId:k}});if(!J.ok)throw Error("Failed to delete model");return await J.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),b(null),M.success(Zx())},onError:(k)=>{M.error($s({message:k.message}))}}),F=D(()=>R({name:f().min(1,Og()).refine((k)=>{if(a.name===k)return!0;return!s.includes(k)},{message:Fg()}),config:ia}),[s,a.name]),T=$t({defaultValues:{name:a.name,config:a.config},validators:{onSubmit:F},onSubmit:async({value:k})=>{q.mutate({name:k.name,config:k.config})}});m(()=>{if(e)T.reset(),h("general"),g("")},[e,T]);let U=(k)=>k.map((J)=>{if(typeof J==="string")return{message:J};if(J&&typeof J==="object"&&"message"in J)return{message:String(J.message)};return{message:String(J||"")}}),Y=D(()=>{if(!y.trim())return N;let k=y.toLowerCase();return N.filter((J)=>J.modelId.toLowerCase().includes(k)||J.name?.toLowerCase().includes(k))},[N,y]);return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[t(ce,{className:"text-xl",children:Sh({name:a.name})}),t(Mt,{children:uh()})]}),o(Eo,{value:c,onValueChange:(k)=>h(k),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(Co,{className:"grid w-full grid-cols-2",children:[t(Yr,{value:"general",children:qh()}),o(Yr,{value:"models",className:"gap-2",children:[Id(),t(he,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:N.length})]})]})}),t(Rn,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:o("form",{onSubmit:(k)=>{k.preventDefault(),k.stopPropagation(),T.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"flex-1 min-h-0",children:t(ue,{className:"h-full",children:t("div",{className:"p-6 space-y-6 pr-6",children:o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5 p-5 rounded-2xl border bg-muted/10",children:[t(T.Field,{name:"name",children:(k)=>{let J=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Qe,{"data-invalid":J,children:[t(ze,{htmlFor:k.name,children:Dg()}),t(z,{id:k.name,name:k.name,value:k.state.value,onBlur:k.handleBlur,onChange:(ye)=>k.handleChange(ye.target.value),placeholder:Lg(),"aria-invalid":J}),J&&t(Ge,{errors:U(k.state.meta.errors)})]})}}),t(T.Field,{name:"config.api",children:(k)=>{let J=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Qe,{"data-invalid":J,children:[t(ze,{htmlFor:k.name,children:Hh()}),o(Fe,{onValueChange:k.handleChange,value:k.state.value,children:[t(Ze,{id:k.name,"aria-invalid":J,children:t(Le,{placeholder:iA()})}),t(Be,{children:au.map((ye)=>t(ne,{value:ye,children:Ls[ye]},ye))})]}),J&&t(Ge,{errors:U(k.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(T.Field,{name:"config.baseUrl",children:(k)=>{let J=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Qe,{"data-invalid":J,children:[t(ze,{htmlFor:k.name,children:ah()}),t(z,{id:k.name,name:k.name,value:k.state.value||"",onBlur:k.handleBlur,onChange:(ye)=>k.handleChange(ye.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":J}),t(aa,{children:Sg()}),J&&t(Ge,{errors:U(k.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(T.Field,{name:"config.apiKey",children:(k)=>{let J=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(Qe,{"data-invalid":J,children:[t(ze,{htmlFor:k.name,children:dd()}),t(z,{id:k.name,name:k.name,type:"text",value:k.state.value||"",onBlur:k.handleBlur,onChange:(ye)=>k.handleChange(ye.target.value),placeholder:rh(),"aria-invalid":J}),t(aa,{className:"text-xs mt-1",children:th()}),J&&t(Ge,{errors:U(k.state.meta.errors)})]})}})})]})})})}),o(qe,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(C,{type:"button",variant:"outline",onClick:r,children:Ne()}),t(T.Subscribe,{selector:(k)=>[k.canSubmit,k.isSubmitting],children:([k,J])=>t(C,{type:"submit",className:"min-w-[120px]",disabled:!k||J||q.isPending,children:J||q.isPending?t(O,{className:"w-4 h-4 animate-spin"}):Vs()})})]})]})}),o(Rn,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[o("div",{className:"p-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1 max-w-sm",children:[t(Ut,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(z,{placeholder:Op(),value:y,onChange:(k)=>g(k.target.value),className:"pl-9 h-9"})]}),o(C,{size:"sm",onClick:()=>x(!0),className:"gap-1.5 shrink-0",children:[t(fe,{className:"w-4 h-4"}),ld()]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ue,{className:"h-full pr-4",children:V?t("div",{className:"flex h-48 items-center justify-center",children:t(O,{className:"h-6 w-6 animate-spin text-primary"})}):Y.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Md()}):t("div",{className:"space-y-2 pb-4",children:Y.map((k)=>o("div",{className:"group cursor-pointer flex items-center justify-between p-3.5 rounded-xl border bg-card hover:border-primary/50 transition-all shadow-none hover:shadow-sm",onClick:()=>i(k),children:[o("div",{className:"min-w-0 flex-1 pr-3",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-semibold text-foreground text-sm",children:k.name||k.modelId}),t(he,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:k.modelId}),k.config?.reasoning&&o(he,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[t(qt,{className:"w-2.5 h-2.5"})," ",Mp()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1",children:[o("span",{children:[k.config?.contextWindow?.toLocaleString()," ",EA()]}),t("span",{children:"·"}),t("span",{children:ex({count:k.config?.maxTokens?.toLocaleString()??"0"})}),t("span",{children:"·"}),t("span",{children:mh({input:k.config?.cost?.input??0,output:k.config?.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(J)=>{J.stopPropagation(),b(k)},children:t(we,{className:"w-3.5 h-3.5"})})})]},k.id))})})})]})]}),v&&t(Ma,{isOpen:v,onClose:()=>x(!1),onSubmit:(k)=>j.mutate(k),title:ld(),isLoading:j.isPending,defaultApi:a.config.api,existingModelIds:N.map((k)=>k.modelId)}),p&&t(Ma,{isOpen:!!p,onClose:()=>i(null),onSubmit:(k)=>re.mutate({modelDbId:p.id,values:k}),title:Eh(),isLoading:re.isPending,initialValues:{modelId:p.modelId,name:p.name,config:p.config},defaultApi:a.config.api,existingModelIds:N.filter((k)=>k.id!==p.id).map((k)=>k.modelId)}),t(Xe,{open:!!w,onOpenChange:(k)=>!k&&b(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:fd()}),t(ot,{children:Xy({name:w?.name||w?.modelId||""})})]}),o(rt,{children:[t(it,{onClick:()=>b(null),children:Ne()}),o(st,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(w)oe.mutate(w.id)},children:[oe.isPending?t(O,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),ct()]})]})]})})]})})}S();function Rs({teamId:e}){let r=G(),[a,l]=u(""),{data:s,isLoading:d}=Z({queryKey:["teams",e,"sandbox"],queryFn:async()=>{let w=await A.api.teams[":teamId"].sandbox.$get({param:{teamId:e}});if(!w.ok)throw Error(Xo());return await w.json()}}),{mutate:c,isPending:h}=B({mutationFn:async(w)=>{let b=await A.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:w});if(!b.ok)throw Error(Lh());return await b.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"sandbox"]}),M.success(VC())},onError:(w)=>{M.error(w instanceof Error?w.message:Lh())}}),y=(w)=>{c({networkSandboxEnabled:w})},g=(w)=>{if(w.preventDefault(),!a.trim())return;if(s?.allowedDomains.includes(a.trim())){M.error(mb());return}let b=[...s?.allowedDomains||[],a.trim()],N=s?.pendingDomains||[];c({allowedDomains:b,pendingDomains:N}),l("")},v=(w)=>{let b=(s?.allowedDomains||[]).filter((V)=>V!==w),N=s?.pendingDomains||[];c({allowedDomains:b,pendingDomains:N})},x=(w)=>{let b=[...s?.allowedDomains||[],w],N=(s?.pendingDomains||[]).filter((V)=>V!==w);c({allowedDomains:b,pendingDomains:N})},p=(w)=>{let b=(s?.pendingDomains||[]).filter((N)=>N!==w);c({allowedDomains:s?.allowedDomains||[],pendingDomains:b})};if(d)return t("div",{className:"flex items-center justify-center p-8",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let i=!!s?.networkSandboxEnabled;return t(ue,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Ke,{children:[o(vt,{children:[o("div",{className:"flex items-center gap-2",children:[t(ua,{className:"w-5 h-5 text-primary"}),t(wt,{children:tS()})]}),t(kt,{children:rS()})]}),o(at,{children:[o("div",{className:"flex items-center justify-between p-4 mb-6 rounded-lg border border-border bg-muted/30",children:[o("div",{className:"space-y-0.5 pr-4",children:[t("label",{htmlFor:"network-sandbox-switch",className:"text-sm font-medium text-foreground cursor-pointer",children:Rb()}),t("p",{className:"text-xs text-muted-foreground",children:oS()})]}),t(Me,{id:"network-sandbox-switch",checked:i,onCheckedChange:y,disabled:h})]}),!i&&o("div",{className:"flex items-start gap-2.5 p-3.5 mb-6 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-700 dark:text-amber-300 text-sm",children:[t(Hn,{className:"w-4 h-4 mt-0.5 shrink-0"}),t("span",{children:nS()})]}),o("form",{onSubmit:g,className:"flex gap-2 mb-6",children:[t(z,{placeholder:"e.g. api.openai.com",value:a,onChange:(w)=>l(w.target.value),disabled:h||!i}),o(C,{type:"submit",disabled:h||!i,children:[h?t(O,{className:"w-4 h-4 animate-spin"}):t(fe,{className:"w-4 h-4 mr-2"}),YA()]})]}),o("div",{className:"space-y-2",children:[t("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:n_()}),o("div",{className:"flex flex-wrap gap-2",children:[s?.allowedDomains.map((w)=>o("div",{className:"flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50",children:[t("span",{className:"font-medium text-foreground",children:w}),t("button",{onClick:()=>v(w),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:h||!i,children:t(Pe,{className:"w-3.5 h-3.5"})})]},w)),s?.allowedDomains.length===0&&t("div",{className:"text-sm text-muted-foreground italic",children:gS()})]})]})]})]}),o(Ke,{className:"border-orange-500/20 bg-orange-500/5",children:[o(vt,{children:[o("div",{className:"flex items-center gap-2",children:[t(tc,{className:"w-5 h-5 text-orange-500"}),t(wt,{children:gE()})]}),t(kt,{children:AE()})]}),t(at,{children:t("div",{className:"space-y-3",children:s?.pendingDomains&&s.pendingDomains.length>0?t("div",{className:"divide-y divide-border",children:s.pendingDomains.map((w)=>o("div",{className:"flex items-center justify-between py-2.5 first:pt-0 last:pb-0",children:[t("span",{className:"font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all",children:w}),o("div",{className:"flex items-center gap-2",children:[o(C,{size:"sm",variant:"outline",className:"h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20",onClick:()=>x(w),disabled:h||!i,children:[t(Re,{className:"w-4 h-4 mr-1.5"}),d_()]}),o(C,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>p(w),disabled:h||!i,children:[t(we,{className:"w-4 h-4 mr-1.5"}),ct()]})]})]},w))}):t("div",{className:"text-sm text-muted-foreground italic py-2",children:xS()})})})]}),t(Ke,{children:o(vt,{children:[t(wt,{children:Tv()}),t(kt,{children:Mv()})]})})]})})}S();var Zr=(e)=>o("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[t("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),t("path",{d:"M9 18c-4.51 2-5-2-7-2"})]}),Bs=({teamId:e})=>{let r=G(),{canAdmin:a}=Ot(),[l,s]=u(!1),[d,c]=u(!1),[h,y]=u(!1),[g,v]=u(null),{data:x,isLoading:p}=Z({queryKey:["teams",e,"skills"],queryFn:async()=>{let N=await A.api.teams[":teamId"].skills.$get({param:{teamId:e}});if(!N.ok)throw Error(Xo());return await N.json()}}),i=B({mutationFn:async(N)=>{if(!(await A.api.skills[":id"].$delete({param:{id:N}})).ok)throw Error(Oa())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]}),y(!1)}}),w=B({mutationFn:async({id:N,permission:V})=>{if(!(await A.api.skills[":id"].permission.$patch({param:{id:N},json:{permission:V}})).ok)throw Error(El())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(N)=>{alert(N.message||El())}}),b=x?.skills||[];return o(Ke,{children:[o(vt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(Ct,{className:"w-6 h-6"})}),o("div",{children:[t(wt,{className:"text-xl font-bold",children:hA()}),t(kt,{children:$I()})]})]}),o(C,{onClick:()=>s(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",s0()]})]}),t(at,{children:p?t("div",{className:"flex justify-center py-10",children:t(O,{className:"w-8 h-8 animate-spin text-primary"})}):b.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(Ct,{className:"w-6 h-6"})}),t("h3",{className:"text-lg font-medium text-foreground",children:kS()}),t("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:i0()})]}):t("div",{className:"space-y-4",children:b.map((N)=>t(Xr,{skill:N,canAdmin:a,onDelete:()=>{v(N),y(!0)},onConfigure:()=>{v(N),c(!0)},onPermissionChange:(V)=>w.mutate({id:N.id,permission:V})},N.id))})}),t(Jr,{open:l,onOpenChange:s,teamId:e}),g&&t(eo,{open:d,onOpenChange:(N)=>{if(c(N),!N)setTimeout(()=>{document.body.style.pointerEvents="auto"},100)},teamId:e,skill:g}),t(Xe,{open:h,onOpenChange:y,children:o(et,{children:[o(tt,{children:[t(nt,{children:fd()}),t(ot,{children:sb({name:g?.name??""})})]}),o(rt,{children:[t(it,{children:Ne()}),o(st,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(g)i.mutate(g.id)},children:[i.isPending?t(O,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),ct()]})]})]})})]})},Xr=({skill:e,canAdmin:r,onDelete:a,onConfigure:l,onPermissionChange:s})=>o("div",{className:"p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group cursor-pointer",onClick:l,children:[o("div",{children:[o("div",{className:"flex items-start justify-between mb-2",children:[t("h4",{className:"font-bold text-foreground flex items-center gap-2",children:e.name}),o(ge,{children:[t(Ae,{asChild:!0,onClick:(d)=>d.stopPropagation(),children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t(Sr,{className:"w-4 h-4"})})}),t(_e,{align:"end",className:"w-32",children:o(K,{onClick:(d)=>{d.stopPropagation(),a()},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",ct()]})})]})]}),t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||gg()})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold",children:[MA()," ",new Date(e.updatedAt).toLocaleDateString()]}),t("div",{className:"flex items-center gap-2",onClick:(d)=>d.stopPropagation(),children:o(Fe,{value:e.permission||"reviewer",onValueChange:(d)=>s(d),disabled:!r,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{placeholder:Zp()})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Za()}),t(ne,{value:"editor",children:Ba()}),t(ne,{value:"owner",children:Ua()})]})]})})]})]}),Jr=({open:e,onOpenChange:r,teamId:a})=>{let l=G(),[s,d]=u(""),[c,h]=u(!1),y=_(null),{data:g}=Z({queryKey:["teams",a,"projects"],queryFn:async()=>{let p=await A.api.teams[":teamId"].projects.$get({param:{teamId:a},query:{first:"1"}});if(!p.ok)throw Error("Failed to fetch projects");return await p.json()},enabled:e}),v=async(p)=>{h(!0);try{let i=await A.api.teams[":teamId"].skills.$post({param:{teamId:a},json:p});if(i.status===409){let w=await i.json();if(window.confirm(`${w.error}
|
|
2
|
+
|
|
3
|
+
${aE()}`)){await v({...p,override:!0});return}}else if(!i.ok){let w=await i.json().catch(()=>({}));throw Error(w.error||ov())}else l.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1),d("")}catch(i){if(i instanceof Error)alert(i.message);else alert(ud())}finally{h(!1)}},x=async(p)=>{if(!p||p.length===0)return;let i=g?.data?.[0]?.id;if(!i){alert(eS());return}let w=p[0];if(!w.name.toLowerCase().endsWith(".zip")){alert(US());return}h(!0);try{let b=w.name,N=w.type||"application/zip",V=await A.api.projects[":projectId"].attachments.$post({param:{projectId:i},json:{fileName:b,size:w.size,contentType:N}});if(!V.ok)throw Error("Failed to get upload URL");let{id:q,uploadUrl:j}=await V.json();if(!(await fetch(j,{method:"PUT",body:w,headers:{"Content-Type":N}})).ok)throw Error("Failed to upload file to storage");await v({assetId:q})}catch(b){if(b instanceof Error)alert(b.message);else alert(ud())}finally{h(!1)}};return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-[450px]",children:[o(me,{children:[t(ce,{children:n0()}),t(Mt,{children:Cw()})]}),o("div",{className:"space-y-6 pt-4",children:[o("div",{className:"space-y-3",children:[t(W,{children:lE()}),o("div",{onClick:()=>!c&&y.current?.click(),className:E("group relative h-32 border-2 border-dashed rounded-xl flex flex-col items-center justify-center transition-all cursor-pointer",c?"opacity-50 cursor-not-allowed bg-muted/50 border-border":"hover:bg-primary/5 hover:border-primary/50 border-border"),children:[t("input",{type:"file",ref:y,className:"hidden",accept:".zip",onChange:(p)=>x(p.target.files)}),t("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:t(uo,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary"})}),o("div",{className:"mt-3 text-center",children:[t("p",{className:"text-sm font-medium text-foreground",children:xI()}),t("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:cE()})]})]}),c&&!s&&o("div",{className:"flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse",children:[t(O,{className:"w-4 h-4 animate-spin"}),kE()]})]}),o("div",{className:"relative",children:[t("div",{className:"absolute inset-0 flex items-center",children:t("span",{className:"w-full border-t border-border"})}),t("div",{className:"relative flex justify-center text-xs uppercase",children:t("span",{className:"bg-background px-2 text-muted-foreground font-bold",children:wg()})})]}),t("div",{className:"space-y-4",children:o("div",{className:"space-y-2",children:[t(W,{htmlFor:"githubUrl",children:Hv()}),o("div",{className:"flex gap-2",children:[o("div",{className:"relative flex-1",children:[t(Zr,{className:"absolute left-3 top-2.5 w-4 h-4 text-muted-foreground"}),t(z,{id:"githubUrl",placeholder:"https://github.com/owner/repo",value:s,onChange:(p)=>d(p.target.value),disabled:c,className:"pl-9"})]}),t(C,{onClick:()=>v({githubUrl:s}),disabled:!s||c,className:"px-6",children:c&&s?t(O,{className:"w-4 h-4 animate-spin"}):Tw()})]}),t("p",{className:"text-[10px] text-muted-foreground italic",children:$v()})]})})]})]})})},eo=({open:e,onOpenChange:r,teamId:a,skill:l})=>{let s=G(),[d,c]=u({...l.config||{},environmentVariables:l.config?.environmentVariables||[]}),[h,y]=u(!1),g=(b,N)=>{let V=[...d.environmentVariables];V[b]={...V[b],default:N},c({...d,environmentVariables:V})},v=(b,N)=>{let V=[...d.environmentVariables];V[b]={...V[b],name:N},c({...d,environmentVariables:V})},x=()=>{c({...d,environmentVariables:[...d.environmentVariables,{name:"",default:""}]})},p=(b)=>{let N=[...d.environmentVariables];N.splice(b,1),c({...d,environmentVariables:N})},i=async()=>{let b=d.environmentVariables.filter((V)=>V.name.trim()!==""),N={...d,environmentVariables:b};y(!0);try{let V=await A.api.skills[":id"].config.$patch({param:{id:l.id},json:{config:N}});if(!V.ok){let q=await V.json().catch(()=>({}));throw Error(q.error||"Failed to update config")}s.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1)}catch(V){if(V instanceof Error)alert(V.message);else alert(ud())}finally{y(!1)}},w=d?.environmentVariables||[];return t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-[500px]",children:[o(me,{children:[t("div",{className:"flex items-center justify-between",children:o(ce,{className:"flex items-center gap-2",children:[t(nc,{className:"w-5 h-5 text-primary"}),ny({name:l.name})]})}),t(Mt,{children:Qw()})]}),t(ue,{className:"max-h-[60vh]",children:t("div",{className:"py-4 space-y-4 pr-4",children:w.length===0?t("div",{className:"text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border",children:t("p",{className:"text-muted-foreground text-sm italic",children:AS()})}):w.map((b,N)=>o("div",{className:"p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group",children:[t("button",{onClick:()=>p(N),className:"absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100",children:t(Pe,{className:"w-4 h-4"})}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:L1()}),t(z,{value:b.name,onChange:(V)=>v(N,V.target.value),placeholder:"e.g. API_KEY",className:"h-8 bg-background border-border text-sm font-mono"})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:$y()}),t(z,{value:b.default||"",onChange:(V)=>g(N,V.target.value),placeholder:oE(),className:"h-8 bg-background border-border text-sm"}),t("p",{className:"text-[10px] text-muted-foreground italic",children:Bb()})]})]},N))})}),o(qe,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[o(C,{variant:"ghost",size:"sm",onClick:x,className:"h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[t(fe,{className:"w-3.5 h-3.5"})," ",u0()]}),o("div",{className:"flex gap-2",children:[t(C,{variant:"ghost",onClick:()=>r(!1),children:Ne()}),o(C,{onClick:i,disabled:h,className:"px-8",children:[h?t(O,{className:"w-4 h-4 animate-spin mr-2"}):null,Vs()]})]})]})]})})};S();S();var qs=({isOpen:e,onClose:r,teamId:a,server:l})=>{let s=G(),d=!!l,[c,h]=u(""),[y,g]=u("streamable_http"),[v,x]=u("reviewer"),[p,i]=u("auto"),[w,b]=u(""),[N,V]=u(""),[q,j]=u(""),[re,oe]=u(""),[F,T]=u("authorization_code"),[U,Y]=u([]),[k,J]=u([]),[ye,be]=u({}),[De,Ee]=u(!1);m(()=>{if(l)h(l.url),g(l.transport||"streamable_http"),x(l.permission||"reviewer"),i(l.authType||"auto"),Y(Array.isArray(l.config?.directTools)?l.config.directTools:[]),J(l.config?.excludeTools??[]),be({}),Ee(!1);else h(""),g("streamable_http"),x("reviewer"),i("auto"),b(""),V(""),j(""),oe(""),T("authorization_code"),Y([]),J([]),be({}),Ee(!1)},[l,e]);let ae=()=>{if(p==="none")return{type:"none"};if(p==="bearer")return{type:"bearer",bearerToken:w||void 0};if(p==="oauth")return{type:"oauth",oauth:{grantType:F,clientId:N||void 0,clientSecret:q||void 0,scope:re||void 0}};return},{data:Se,isLoading:Oe,refetch:We}=Z({queryKey:["mcp","servers",l?.id,"tools"],queryFn:async()=>{if(!l?.id)return{tools:[]};let H=await A.api.mcp.servers[":id"].tools.$get({param:{id:l.id}});if(!H.ok)throw Error("Failed to fetch tools");return await H.json()},enabled:e&&d&&!!l?.id}),lt=B({mutationFn:async()=>{if(!l?.id)return;let H=await A.api.mcp.servers[":id"].refresh.$post({param:{id:l.id}});if(!H.ok){let xe=await H.json().catch(()=>({}));throw Error(xe.error||"Failed to refresh server")}return await H.json()},onSuccess:()=>{M.success(mx()),We(),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]})},onError:(H)=>{M.error(H.message)}}),X=B({mutationFn:async()=>{let H={directTools:U.length>0?U:void 0,excludeTools:k.length>0?k:void 0};if(d&&l){let xe={transport:y,permission:v,authConfig:ae(),config:H},ke=await A.api.mcp.servers[":id"].$patch({param:{id:l.id},json:xe});if(!ke.ok){let pt=await ke.json().catch(()=>({}));throw Error(pt.error||El())}return await ke.json()}else{let xe={url:c.trim()},ke=await A.api.teams[":teamId"].mcp.servers.$post({param:{teamId:a},json:xe});if(!ke.ok){let Qt=await ke.json().catch(()=>({}));throw Error(Qt.error||ud())}return await ke.json()}},onSuccess:()=>{M.success(d?Pg():Qc()),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]}),r()},onError:(H)=>{M.error(H.message)}}),se=(H)=>{if(H.preventDefault(),!c.trim())return;X.mutate()},ie=Se?.tools??[],pe=(H)=>{if(k.includes(H))return"off";if(U.includes(H))return"direct";return"on"},dt=(H,xe)=>{if(xe==="off")J((ke)=>ke.includes(H)?ke:[...ke,H]),Y((ke)=>ke.filter((pt)=>pt!==H));else if(xe==="on")J((ke)=>ke.filter((pt)=>pt!==H)),Y((ke)=>ke.filter((pt)=>pt!==H));else if(xe==="direct")J((ke)=>ke.filter((pt)=>pt!==H)),Y((ke)=>ke.includes(H)?ke:[...ke,H])},ee=(H)=>{let xe=ie.map((ke)=>ke.name);if(H==="off")J(xe),Y([]);else if(H==="on")J([]),Y([]);else if(H==="direct")J([]),Y(xe)},Ye=(H)=>{be((xe)=>({...xe,[H]:!xe[H]}))};return t(de,{open:e,onOpenChange:(H)=>!H&&r(),children:d&&l?o(le,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[lt.isPending&&o("div",{className:"absolute inset-0 bg-background/60 backdrop-blur-[1px] flex flex-col items-center justify-center z-50 rounded-lg",children:[t(O,{className:"w-8 h-8 animate-spin text-primary mb-2"}),o("span",{className:"text-xs font-medium text-muted-foreground",children:[eg(),"..."]})]}),o(me,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[o(ce,{className:"flex items-center gap-2 text-xl font-bold",children:[t(wn,{className:"w-5 h-5 text-primary"}),_b()]}),t(Mt,{children:Cd()})]}),o("form",{onSubmit:se,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ue,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 space-y-5",children:[o("div",{className:"grid grid-cols-1 gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:gx()}),t("span",{className:"text-sm font-medium",children:l.name})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:rg()}),t("span",{className:"text-sm font-mono text-foreground break-all",children:l.url})]}),l.description&&o("div",{className:"flex flex-col",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:Sl()}),t("span",{className:"text-sm text-foreground",children:l.description})]}),o("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:[t(Hn,{className:"w-3 h-3"}),tg()]})]}),l.instructions&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-1",children:[t("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold block",children:hx()}),t("p",{onClick:()=>Ee((H)=>!H),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${De?"":"line-clamp-2"}`,title:De?void 0:"Click to expand instructions",children:l.instructions})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:Cx()}),o(Fe,{value:y,onValueChange:(H)=>g(H),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"streamable_http",children:"Streamable HTTP"}),t(ne,{value:"sse",children:"Server-Sent Events (SSE)"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:Zp()}),o(Fe,{value:v,onValueChange:(H)=>x(H),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Za()}),t(ne,{value:"editor",children:Ba()}),t(ne,{value:"owner",children:Ua()})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:sx()}),o(Fe,{value:p,onValueChange:(H)=>i(H),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"auto",children:tx()}),t(ne,{value:"none",children:nx()}),t(ne,{value:"bearer",children:rx()}),t(ne,{value:"oauth",children:ox()})]})]})]}),p==="bearer"&&o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:ix()}),t(z,{className:"h-9 text-xs font-mono",type:"password",value:w,onChange:(H)=>b(H.target.value),placeholder:"Enter token string"})]}),p==="oauth"&&o("div",{className:"p-3 bg-muted/20 border border-border rounded-lg space-y-3",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:fx()}),o(Fe,{value:F,onValueChange:(H)=>T(H),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"authorization_code",children:"Authorization Code"}),t(ne,{value:"client_credentials",children:"Client Credentials"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:ux()}),t(z,{className:"h-9 text-xs",value:N,onChange:(H)=>V(H.target.value),placeholder:"Optional Client ID"})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:dx()}),t(z,{className:"h-9 text-xs",type:"password",value:q,onChange:(H)=>j(H.target.value),placeholder:"Optional Secret"})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs",children:px()}),t(z,{className:"h-9 text-xs",value:re,onChange:(H)=>oe(H.target.value),placeholder:"Optional scope"})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-2.5",children:[o(W,{className:"text-xs font-semibold flex items-center gap-1.5",children:[t(Mo,{className:"w-3.5 h-3.5"}),xx()," (",ie.length,")"]}),t("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:Ex()}),ie.length>0&&o("div",{className:"flex items-center gap-1.5 pt-0.5",children:[t(C,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ee("off"),disabled:lt.isPending||Oe,children:lx()}),t(C,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ee("on"),disabled:lt.isPending||Oe,children:cx()}),t(C,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>ee("direct"),disabled:lt.isPending||Oe,children:ax()})]})]}),t("div",{className:"space-y-2",children:Oe?t("div",{className:"flex justify-center py-8",children:t(O,{className:"w-6 h-6 animate-spin text-primary"})}):ie.length===0?t("div",{className:"text-center py-6 text-muted-foreground text-xs",children:NS()}):ie.map((H)=>{let xe=pe(H.name),ke=!!ye[H.name],pt=H.inputSchema,Qt=pt?.properties&&Object.keys(pt.properties).length>0;return o("div",{className:`border border-border rounded-lg p-3 transition-colors ${xe!=="off"?"bg-card":"bg-muted/30 opacity-70"}`,children:[o("div",{className:"flex items-start justify-between gap-3",children:[o("div",{className:"flex items-start gap-2 flex-1 min-w-0 cursor-pointer",onClick:()=>Qt&&Ye(H.name),children:[Qt?ke?t(ve,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t(Et,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t("div",{className:"w-4 h-4 shrink-0"}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-mono text-xs font-bold text-foreground break-all",children:H.name}),H.title&&t(he,{variant:"outline",className:"text-[10px]",children:H.title})]}),H.description&&t("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:H.description})]})]}),t("div",{className:"flex items-center gap-2 shrink-0",children:o(Ro,{type:"single",value:xe,onValueChange:(Kt)=>{if(Kt)dt(H.name,Kt)},size:"sm",variant:"outline",disabled:lt.isPending||Oe,children:[t(yr,{value:"off",className:"text-[11px] px-2 h-7",children:vx()}),t(yr,{value:"on",className:"text-[11px] px-2 h-7",children:wx()}),t(yr,{value:"direct",className:"text-[11px] px-2 h-7",children:bx()})]})})]}),ke&&Qt&&o("div",{className:"mt-3 pt-3 border-t border-border/60 pl-6 space-y-2",children:[t("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:l1()}),t("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(pt.properties).map(([Kt,Fa])=>{let lr=pt.required?.includes(Kt);return o("div",{className:"flex flex-col sm:flex-row sm:items-baseline justify-between gap-1 sm:gap-2 p-2 bg-muted/20 rounded text-xs min-w-0",children:[o("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[t("span",{className:"font-mono font-semibold break-all",children:Kt}),lr&&t("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),t(he,{variant:"secondary",className:"text-[9px] px-1 py-0",children:Fa.type||"any"})]}),Fa.description&&t("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:Fa.description})]},Kt)})})]})]},H.name)})})]})]})}),o(qe,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[o(C,{type:"button",variant:"outline",onClick:()=>lt.mutate(),disabled:lt.isPending||Oe||X.isPending,className:"gap-1.5 mr-auto",children:[t(pa,{className:`w-4 h-4 ${lt.isPending?"animate-spin":""}`}),eg()]}),t(C,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(C,{type:"submit",disabled:X.isPending||!c,children:[X.isPending&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),Vs()]})]})]})]}):o(le,{className:"sm:max-w-md",children:[o(me,{children:[o(ce,{className:"flex items-center gap-2 text-xl font-bold",children:[t(wn,{className:"w-5 h-5 text-primary"}),If()]}),t(Mt,{children:Cd()})]}),o("form",{onSubmit:se,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs font-semibold",children:rg()}),t(z,{value:c,onChange:(H)=>h(H.target.value),placeholder:"https://mcp.example.com/mcp",type:"url",required:!0}),o("p",{className:"text-[11px] text-muted-foreground flex items-center gap-1.5",children:[t(Hn,{className:"w-3.5 h-3.5"}),tg()]})]}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(C,{type:"submit",disabled:X.isPending||!c,children:[X.isPending&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),jc()]})]})]})]})})};var js=({teamId:e})=>{let r=G(),{canAdmin:a}=Ot(),[l,s]=u(!1),[d,c]=u(null),[h,y]=u(null),[g,v]=u(null),{data:x,isLoading:p}=Z({queryKey:["teams",e,"mcp","servers"],queryFn:async()=>{let j=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:e}});if(!j.ok)throw Error(Xo());return await j.json()}}),i=B({mutationFn:async(j)=>{if(!(await A.api.mcp.servers[":id"].$delete({param:{id:j}})).ok)throw Error(Oa())},onSuccess:()=>{M.success(ct()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),y(null)},onError:(j)=>{M.error(j.message)}}),w=B({mutationFn:async({id:j,permission:re})=>{if(!(await A.api.mcp.servers[":id"].permission.$patch({param:{id:j},json:{permission:re}})).ok)throw Error(El())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(j)=>{M.error(j.message)}}),b=B({mutationFn:async(j)=>{if(!(await A.api.mcp.servers[":id"].auth.$delete({param:{id:j}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{M.success(Xh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(j)=>{M.error(j.message)}}),N=async(j)=>{v(j);try{let re=await A.api.mcp.servers[":id"].auth.start.$post({param:{id:j}});if(!re.ok){let F=await re.json().catch(()=>({}));throw Error(F.error||op())}let oe=await re.json();if(oe.status==="authenticated"){M.success(Yh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),v(null);return}if(oe.authorizationUrl){let U=window.screenX+(window.outerWidth-600)/2,Y=window.screenY+(window.outerHeight-700)/2,k=window.open(oe.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${U},top=${Y},scrollbars=yes`),J=(be)=>{if(be.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",J),v(null),be.data.ok)M.success(Yh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else M.error(be.data.message||op())};window.addEventListener("message",J);let ye=setInterval(()=>{if(!k||k.closed)clearInterval(ye),window.removeEventListener("message",J),v(null),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(re){M.error(re instanceof Error?re.message:op()),v(null)}},V=x?.servers||[],q=(j)=>{switch(j.status){case"connected":return o(he,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[t(ir,{className:"w-3 h-3"}),Ax()]});case"needs_auth":return o(he,{variant:"secondary",className:"gap-1 bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:[t(Xt,{className:"w-3 h-3"}),ng()]});case"failed":return o(he,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[t(nr,{className:"w-3 h-3"}),_x()]});default:return o(he,{variant:"outline",className:"gap-1 text-[10px]",children:[t(er,{className:"w-3 h-3 text-muted-foreground"}),yx()]})}};return o(Ke,{children:[o(vt,{className:"flex flex-row items-center justify-between space-y-0 pb-7",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(wn,{className:"w-6 h-6"})}),o("div",{children:[t(wt,{className:"text-xl font-bold",children:Qc()}),t(kt,{children:Cd()})]})]}),a&&o(C,{onClick:()=>s(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",If()]})]}),t(at,{children:p?t("div",{className:"flex justify-center py-10",children:t(O,{className:"w-8 h-8 animate-spin text-primary"})}):V.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(wn,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold",children:yg()}),t("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:XA()}),a&&o(C,{onClick:()=>s(!0),className:"mt-4 gap-2",variant:"outline",children:[t(fe,{className:"w-4 h-4"})," ",If()]})]}):t("div",{className:"space-y-4",children:V.map((j)=>{let re=g===j.id,oe=j.status==="needs_auth"||!j.hasCredential&&j.authType!=="none";return o("div",{onClick:()=>a&&c(j),className:`p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group ${a?"cursor-pointer":""}`,children:[o("div",{className:"flex items-start justify-between gap-2 mb-2",children:[o("h4",{className:"font-bold text-foreground flex items-center gap-2 min-w-0",children:[t(wn,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t("span",{className:"truncate",children:j.name}),t(he,{variant:"outline",className:"text-[10px] uppercase shrink-0",children:j.transport})]}),a&&o(ge,{modal:!1,children:[t(Ae,{asChild:!0,onClick:(F)=>F.stopPropagation(),children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:t(Sr,{className:"w-4 h-4"})})}),o(_e,{align:"end",children:[j.status!=="connected"&&(j.authType!=="none"||j.hasCredential)?o(K,{onClick:(F)=>{F.stopPropagation(),N(j.id)},children:[t(Xt,{className:"w-4 h-4 mr-2"}),Jh()]}):null,j.hasCredential&&o(K,{onClick:(F)=>{F.stopPropagation(),b.mutate(j.id)},className:"text-amber-600",children:[t(ds,{className:"w-4 h-4 mr-2"}),Xh()]}),(j.status!=="connected"&&(j.authType!=="none"||j.hasCredential)||j.hasCredential)&&t(Vt,{}),o(K,{onClick:(F)=>{F.stopPropagation(),y(j)},className:"text-red-600",children:[t(we,{className:"w-4 h-4 mr-2"}),ct()]})]})]})]}),o("div",{className:"space-y-1",children:[t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:j.description||gg()}),t("p",{className:"font-mono text-[10px] text-muted-foreground/70 truncate",children:j.url}),j.lastError&&t("p",{className:"text-[10px] text-red-500/90 truncate font-mono",children:j.lastError})]}),o("div",{className:"mt-4 flex items-center justify-between gap-2 pt-2 border-t border-border/50 text-xs",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[q(j),o(he,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[t(Mo,{className:"w-3 h-3 text-muted-foreground"}),Sx({count:j.toolCount})]}),o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[MA()," ",new Date(j.updatedAt).toLocaleDateString()]})]}),o("div",{className:"flex items-center gap-2 shrink-0",onClick:(F)=>F.stopPropagation(),children:[a?o(Fe,{value:j.permission,onValueChange:(F)=>w.mutate({id:j.id,permission:F}),children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:t(Le,{})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Za()}),t(ne,{value:"editor",children:Ba()}),t(ne,{value:"owner",children:Ua()})]})]}):t(he,{variant:"outline",className:"text-[10px]",children:j.permission==="reviewer"?Za():j.permission==="editor"?Ba():Ua()}),oe&&a&&o(C,{size:"sm",variant:"default",onClick:(F)=>{F.stopPropagation(),N(j.id)},disabled:re,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[re?t(O,{className:"w-3.5 h-3.5 animate-spin"}):t(Xt,{className:"w-3.5 h-3.5"}),Jh()]})]})]})]},j.id)})})}),t(qs,{isOpen:l||!!d,onClose:()=>{s(!1),c(null)},teamId:e,server:d}),t(Xe,{open:!!h,onOpenChange:(j)=>!j&&y(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:Yy()}),t(ot,{children:Jy({name:h?.name||""})})]}),o(rt,{children:[t(it,{children:Ne()}),o(st,{onClick:()=>h&&i.mutate(h.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[i.isPending&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),ct()]})]})]})})]})};function Os({teamId:e}){let r=G(),{data:a,isLoading:l}=Z({queryKey:["teams",e,"notification-settings"],queryFn:async()=>{let h=await A.api.teams[":teamId"].notifications.settings.$get({param:{teamId:e}});if(!h.ok)throw Error(Xo());return await h.json()}}),{mutate:s,isPending:d}=B({mutationFn:async(h)=>{let y=await A.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:h});if(!y.ok)throw Error(Fh());return await y.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),r.invalidateQueries({queryKey:["teams",e,"notifications"]}),M.success(LS())},onError:(h)=>{M.error(h instanceof Error?h.message:Fh())}}),c=(h)=>{if(!a)return;let y={...a,[h]:!a[h]};s(y)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return t(ue,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Ke,{className:"overflow-hidden gap-0 py-0",children:[o(vt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(xo,{className:"w-5 h-5 text-primary"}),t(wt,{className:"text-lg",children:X_()})]}),t(kt,{children:ey()})]}),o(at,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(xo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Uv()}),t("p",{className:"text-sm text-muted-foreground",children:J1()})]})]}),t(Me,{checked:a?.comments??!0,onCheckedChange:()=>c("comments"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(is,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:J_()}),t("p",{className:"text-sm text-muted-foreground",children:eM()})]})]}),t(Me,{checked:a?.replies??!0,onCheckedChange:()=>c("replies"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(as,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:A_()}),t("p",{className:"text-sm text-muted-foreground",children:X1()})]})]}),t(Me,{checked:a?.mentions??!0,onCheckedChange:()=>c("mentions"),disabled:d})]})]})]}),o(Ke,{className:"overflow-hidden gap-0 py-0",children:[o(vt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(zn,{className:"w-5 h-5 text-primary"}),t(wt,{className:"text-lg",children:h_()})]}),t(kt,{children:g_()})]}),o(at,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(ga,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:rM()}),t("p",{className:"text-sm text-muted-foreground",children:tM()})]})]}),t(Me,{checked:a?.yourUploads??!1,onCheckedChange:()=>c("yourUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(zn,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:sE()}),t("p",{className:"text-sm text-muted-foreground",children:W1()})]})]}),t(Me,{checked:a?.otherUploads??!0,onCheckedChange:()=>c("otherUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Ys,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:fT()}),t("p",{className:"text-sm text-muted-foreground",children:Y1()})]})]}),t(Me,{checked:a?.statusUpdates??!0,onCheckedChange:()=>c("statusUpdates"),disabled:d})]})]})]}),o(Ke,{className:"overflow-hidden gap-0 py-0",children:[o(vt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(Aa,{className:"w-5 h-5 text-primary"}),t(wt,{className:"text-lg",children:Fw()})]}),t(kt,{children:Ow()})]}),o(at,{className:"divide-y divide-border p-0",children:[o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(Aa,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Lw()}),t("p",{className:"text-sm text-muted-foreground",children:K1()})]})]}),t(Me,{checked:a?.kanbanTasks??!0,onCheckedChange:()=>c("kanbanTasks"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(xo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Dw()}),t("p",{className:"text-sm text-muted-foreground",children:Q1()})]})]}),t(Me,{checked:a?.kanbanComments??!0,onCheckedChange:()=>c("kanbanComments"),disabled:d})]})]})]})]})})}S();function Ks({teamId:e}){let r=G(),[a,l]=u(""),[s,d]=u(null),{data:c,isLoading:h}=Z({queryKey:["teams",e,"api-tokens"],queryFn:async()=>{let i=await A.api.teams[":teamId"]["api-tokens"].$get({param:{teamId:e}});if(!i.ok)throw Error("Failed to fetch API tokens");return await i.json()}}),{mutate:y,isPending:g}=B({mutationFn:async(i)=>{let w=await A.api.teams[":teamId"]["api-tokens"].$post({param:{teamId:e},json:{name:i}});if(!w.ok)throw Error("Failed to create API token");return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),l(""),M.success(i_())},onError:(i)=>{M.error(i instanceof Error?i.message:nv())}}),{mutate:v}=B({mutationFn:async(i)=>{let w=await A.api.teams[":teamId"]["api-tokens"][":tokenId"].$delete({param:{teamId:e,tokenId:i}});if(!w.ok)throw Error("Failed to delete API token");return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),M.success(a_())},onError:(i)=>{M.error(i instanceof Error?i.message:lv())}}),x=(i)=>{if(i.preventDefault(),!a.trim())return;y(a.trim())},p=async(i,w)=>{await fo(w),d(i),M.success(dy()),setTimeout(()=>d(null),2000)};if(h)return t("div",{className:"flex justify-center items-center p-8",children:t(O,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return t("div",{className:"space-y-6",children:o(Ke,{children:[o(vt,{children:[t(wt,{children:nh()}),t(kt,{children:l_()})]}),o(at,{className:"space-y-6",children:[o("form",{onSubmit:x,className:"flex gap-4 items-end max-w-md",children:[o("div",{className:"flex-1 space-y-2",children:[t("label",{htmlFor:"tokenName",className:"text-sm font-medium text-muted-foreground",children:i1()}),t(z,{id:"tokenName",value:a,onChange:(i)=>l(i.target.value),placeholder:a1(),required:!0})]}),o(C,{type:"submit",disabled:g||!a.trim(),children:[g?t(O,{className:"w-4 h-4 animate-spin mr-2"}):t(fe,{className:"w-4 h-4 mr-2"}),jv()]})]}),t("div",{className:"border rounded-lg overflow-hidden",children:o(Pn,{children:[t(Nn,{children:o(xr,{children:[t(It,{children:Il()}),t(It,{children:s1()}),t(It,{children:ky()}),t(It,{className:"w-[100px] text-right",children:$A()})]})}),t(Dn,{children:!c||c.length===0?t(xr,{children:t(xt,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:fS()})}):c.map((i)=>o(xr,{children:[t(xt,{className:"font-medium",children:i.name}),t(xt,{className:"font-mono text-sm max-w-[200px] truncate",children:o("div",{className:"flex items-center gap-2",children:[o("span",{children:[i.token.substring(0,8),"..."]}),t(C,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>p(i.id,i.token),children:s===i.id?t(Re,{className:"h-3.5 w-3.5 text-green-500"}):t(Nr,{className:"h-3.5 w-3.5"})})]})}),t(xt,{className:"text-muted-foreground",children:new Date(i.createdAt).toLocaleDateString()}),t(xt,{className:"text-right",children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>v(i.id),children:t(we,{className:"h-4 w-4"})})})]},i.id))})]})})]})]})})}S();S();var to=[{value:"read_asset",label:()=>Vm()},{value:"list_assets",label:()=>$m()},{value:"create_folder",label:()=>Um()},{value:"create_file",label:()=>Bm()},{value:"create_version",label:()=>zm()},{value:"generate_image",label:()=>qm()},{value:"generate_video",label:()=>Hm()},{value:"rename_asset",label:()=>Qm()},{value:"move_assets",label:()=>Gm()},{value:"delete_asset",label:()=>jm()}],ts={agent_total_tokens:{label:()=>Fd(),icon:lo,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>Nd(),icon:ha,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>Dd(),icon:wn,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>Pd(),icon:ko,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>Od(),icon:Mo,unit:"calls",defaultLimit:100}},zs=({open:e,onOpenChange:r,teamId:a,rule:l,onSuccess:s})=>{let d=G(),c=!!l,[h,y]=u("each_member"),[g,v]=u("team"),[x,p]=u([]),[i,w]=u("agent_total_tokens"),[b,N]=u(""),[V,q]=u("*"),[j,re]=u("read_asset"),[oe,F]=u(1e5),[T,U]=u("1day"),[Y,k]=u(!0),[J,ye]=u(!1),[be,De]=u(""),{data:Ee=[]}=Z({queryKey:["teams",a,"members"],queryFn:async()=>{let ee=await A.api.teams[":teamId"].members.$get({param:{teamId:a},query:{}});if(!ee.ok)return[];return await ee.json()},enabled:e}),{data:ae}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let ee=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!ee.ok)return{servers:[]};return await ee.json()},enabled:e&&i==="agent_mcp_call_count"}),Se=ae?.servers||[];m(()=>{if(l){y(l.scopeMode),v(l.role||"team"),p(l.userIds||[]),w(l.resource);let ee=l.resourceData||{};N(typeof ee.id==="string"?ee.id:""),q(typeof ee.match==="string"?ee.match:"*"),re(typeof ee.name==="string"?ee.name:typeof ee.toolName==="string"?ee.toolName:"read_asset"),F(l.limit),U(lu(l.period)),k(l.enabled)}else y("each_member"),v("team"),p([]),w("agent_total_tokens"),N(""),q("*"),re("read_asset"),F(ts.agent_total_tokens.defaultLimit),U("1day"),k(!0)},[l,e]);let Oe=(ee)=>{if(w(ee),!c)F(ts[ee]?.defaultLimit||100)},We=B({mutationFn:async()=>{let ee={};if(i==="agent_mcp_call_count")ee.id=b;else if(i==="agent_bash_call_count")ee.match=V.trim()||"*";else if(i==="agent_tool_call_count")ee.name=j||"read_asset";let Ye=await A.api.teams[":teamId"].quotas.$post({param:{teamId:a},json:{scopeMode:h,role:h!=="selected_members"&&g!=="team"?g:null,userIds:h==="selected_members"?x:null,resource:i,resourceData:Object.keys(ee).length>0?ee:null,limit:Number(oe),period:T,enabled:Y}});if(!Ye.ok){let H=await Ye.json().catch(()=>({}));throw Error(H?.message||Rh())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),M.success(eC()),r(!1),s?.()},onError:(ee)=>{console.error("CREATE MUTATION ERROR:",ee),M.error(ee instanceof Error?ee.message:Rh())}}),lt=B({mutationFn:async()=>{if(!l)return;let ee={};if(i==="agent_mcp_call_count")ee.id=b;else if(i==="agent_bash_call_count")ee.match=V.trim()||"*";else if(i==="agent_tool_call_count")ee.name=j||"read_asset";let Ye=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:a,id:l.id},json:{scopeMode:h,role:h!=="selected_members"&&g!=="team"?g:null,userIds:h==="selected_members"?x:null,resource:i,resourceData:Object.keys(ee).length>0?ee:null,limit:Number(oe),period:T,enabled:Y}});if(!Ye.ok){let H=await Ye.json().catch(()=>({}));throw Error(H?.message||bd())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),M.success(EC()),r(!1),s?.()},onError:(ee)=>{M.error(ee instanceof Error?ee.message:bd())}}),X=B({mutationFn:async()=>{if(!l)return;if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:a,id:l.id}})).ok)throw Error(yd())},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),M.success(Hg()),ye(!1),r(!1),s?.()},onError:(ee)=>{M.error(ee instanceof Error?ee.message:yd())}}),se=(ee)=>{if(ee.preventDefault(),h==="selected_members"&&x.length===0){M.error(vI());return}if(i==="agent_mcp_call_count"&&!b.trim()){M.error(Th());return}if(oe<=0){M.error("Limit must be greater than 0");return}if(c)lt.mutate();else We.mutate()},ie=We.isPending||lt.isPending||X.isPending,pe=Ee.filter((ee)=>{if(!be.trim())return!0;let Ye=be.toLowerCase();return ee.name.toLowerCase().includes(Ye)||ee.email&&ee.email.toLowerCase().includes(Ye)}),dt=(ee)=>{p((Ye)=>Ye.includes(ee)?Ye.filter((H)=>H!==ee):[...Ye,ee])};return o(L,{children:[t(de,{open:e,onOpenChange:r,children:o(le,{className:"sm:max-w-[540px] max-h-[90vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-4 border-b border-border/60 shrink-0",children:[t(ce,{className:"text-xl font-bold",children:c?yb():Cy()}),t(Mt,{className:"text-sm text-muted-foreground",children:c?bb():Iy()})]}),o("form",{onSubmit:se,noValidate:!0,className:"flex-1 overflow-y-auto min-h-0 p-6 space-y-5",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-sm font-semibold",children:mC()}),o("div",{className:"grid grid-cols-3 gap-2",children:[o(C,{type:"button",variant:h==="each_member"?"default":"outline",size:"sm",disabled:c||ie,onClick:()=>y("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Kn,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Zd()})]}),o(C,{type:"button",variant:h==="all_members"?"default":"outline",size:"sm",disabled:c||ie,onClick:()=>y("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(co,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Ld()})]}),o(C,{type:"button",variant:h==="selected_members"?"default":"outline",size:"sm",disabled:c||ie,onClick:()=>y("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Jo,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Bd()})]})]}),o("p",{className:"text-xs text-muted-foreground pt-0.5",children:[h==="each_member"&&gC(),h==="all_members"&&hC(),h==="selected_members"&&AC()]})]}),h!=="selected_members"?o("div",{className:"space-y-2",children:[t(W,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:pC()}),o(Fe,{value:g,onValueChange:v,disabled:c||ie,children:[t(Ze,{id:"quota-role-scope",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"team",children:Nl()}),o(ne,{value:"owner",children:[Ip(),": Owner"]}),o(ne,{value:"editor",children:[Ip(),": Editor"]}),o(ne,{value:"reviewer",children:[Ip(),": Reviewer"]})]})]})]}):o("div",{className:"space-y-2",children:[t(W,{className:"text-sm font-semibold",children:lA()}),o(At,{children:[t(_t,{asChild:!0,children:o(C,{variant:"outline",role:"combobox",disabled:ie,className:"w-full justify-between text-left font-normal h-10",children:[t("span",{className:"truncate",children:x.length===0?lA():_C({count:x.length})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t(yt,{className:"w-[320px] p-2",align:"start",children:o("div",{className:"space-y-2",children:[o("div",{className:"relative",children:[t(Ut,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),t(z,{placeholder:Tp(),value:be,onChange:(ee)=>De(ee.target.value),className:"h-8 pl-8 text-xs"})]}),t(ue,{className:"h-48",children:t("div",{className:"space-y-1 pr-2",children:pe.map((ee)=>{let Ye=x.includes(ee.id);return o("div",{onClick:()=>dt(ee.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[t(wr,{checked:Ye,onCheckedChange:()=>dt(ee.id)}),o(Ce,{className:"w-5 h-5",children:[t(Ie,{src:ee.image||void 0}),t(Te,{className:"text-[10px]",children:ee.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"truncate flex-1",children:[t("span",{className:"font-medium text-foreground block truncate",children:ee.name}),ee.email&&t("span",{className:"text-[10px] text-muted-foreground block truncate",children:ee.email})]})]},ee.id)})})})]})})]})]}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:dC()}),o(Fe,{value:i,onValueChange:(ee)=>Oe(ee),disabled:c||ie,children:[t(Ze,{id:"quota-resource",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"agent_total_tokens",children:o("div",{className:"flex items-center gap-2",children:[t(lo,{className:"w-4 h-4 text-primary"}),t("span",{children:Fd()})]})}),t(ne,{value:"agent_cost",children:o("div",{className:"flex items-center gap-2",children:[t(ha,{className:"w-4 h-4 text-emerald-500"}),t("span",{children:Nd()})]})}),t(ne,{value:"agent_mcp_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(wn,{className:"w-4 h-4 text-blue-500"}),t("span",{children:Dd()})]})}),t(ne,{value:"agent_bash_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(ko,{className:"w-4 h-4 text-purple-500"}),t("span",{children:Pd()})]})}),t(ne,{value:"agent_tool_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Mo,{className:"w-4 h-4 text-cyan-500"}),t("span",{children:Od()})]})})]})]})]}),i==="agent_mcp_call_count"&&o("div",{className:"space-y-2",children:[t(W,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:aA()}),Se.length>0?o(Fe,{value:b,onValueChange:N,disabled:c||ie,children:[t(Ze,{id:"quota-mcp",className:"w-full",children:t(Le,{placeholder:aA()})}),t(Be,{children:Se.map((ee)=>o(ne,{value:ee.id,children:[ee.name," (",ee.id,")"]},ee.id))})]}):t(z,{id:"quota-mcp",value:b,onChange:(ee)=>N(ee.target.value),placeholder:Th(),disabled:c||ie})]}),i==="agent_bash_call_count"&&o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:D_()}),t(z,{id:"quota-bash",value:V,onChange:(ee)=>q(ee.target.value),placeholder:O_(),disabled:ie}),t("p",{className:"text-xs text-muted-foreground",children:JE()})]}),i==="agent_tool_call_count"&&o("div",{className:"space-y-2",children:[t(W,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:uA()}),o(Fe,{value:j,onValueChange:re,disabled:c||ie,children:[t(Ze,{id:"quota-tool",className:"w-full",children:t(Le,{placeholder:uA()})}),t(Be,{children:to.map((ee)=>t(ne,{value:ee.value,children:ee.label()},ee.value))})]}),t("p",{className:"text-xs text-muted-foreground",children:SC()})]}),o("div",{className:"grid grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[o(W,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[oC()," (",ts[i]?.unit||"",")"]}),t(z,{id:"quota-limit",type:"number",min:"0.01",step:i==="agent_cost"?"0.01":"1",value:oe,onChange:(ee)=>F(Number(ee.target.value)),placeholder:sC(),disabled:ie,required:!0})]}),o("div",{className:"space-y-2",children:[t(W,{htmlFor:"quota-period",className:"text-sm font-semibold",children:aC()}),o(Fe,{value:T,onValueChange:(ee)=>U(ee),disabled:ie,children:[t(Ze,{id:"quota-period",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"1hour",children:o("div",{className:"flex items-center gap-2",children:[t(er,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Sp()})]})}),t(ne,{value:"5hour",children:o("div",{className:"flex items-center gap-2",children:[t(er,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Ep()})]})}),t(ne,{value:"1day",children:o("div",{className:"flex items-center gap-2",children:[t(er,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:xp()})]})}),t(ne,{value:"7day",children:o("div",{className:"flex items-center gap-2",children:[t(er,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:Cp()})]})})]})]})]})]}),o("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[o("div",{className:"space-y-0.5",children:[t(W,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:Y?rC():wp()}),t("p",{className:"text-xs text-muted-foreground",children:Y?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),t(Me,{id:"quota-enabled",checked:Y,onCheckedChange:k,disabled:ie})]}),o(qe,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[c?o(C,{type:"button",variant:"destructive",size:"sm",onClick:()=>ye(!0),disabled:ie,className:"gap-1.5",children:[t(we,{className:"w-4 h-4"}),t("span",{children:Bf()})]}):t("div",{}),o("div",{className:"flex items-center gap-2",children:[t(C,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:ie,children:Ne()}),o(C,{type:"submit",disabled:ie,className:"gap-2",children:[ie&&t(O,{className:"w-4 h-4 animate-spin"}),c?Gn():jc()]})]})]})]})]})}),t(Xe,{open:J,onOpenChange:ye,children:o(et,{children:[o(tt,{children:[t(nt,{children:Bf()}),t(ot,{children:vh()})]}),o(rt,{children:[t(it,{disabled:ie,children:Ne()}),o(st,{onClick:(ee)=>{ee.preventDefault(),X.mutate()},disabled:ie,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[ie&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),ct()]})]})]})})]})};var Us=({teamId:e})=>{let r=G(),[a,l]=u(!1),[s,d]=u(null),[c,h]=u(null),{data:y,isLoading:g}=Z({queryKey:["teams",e,"quotas"],queryFn:async()=>{let i=await A.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!i.ok)throw Error(Xo());return await i.json()}}),v=B({mutationFn:async({id:i,enabled:w})=>{let b=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:i},json:{enabled:w}});if(!b.ok)throw Error(bd());return await b.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),M.success(yC())},onError:(i)=>{M.error(i instanceof Error?i.message:bd())}}),x=B({mutationFn:async(i)=>{if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:i}})).ok)throw Error(yd())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),M.success(Hg()),h(null)},onError:(i)=>{M.error(i instanceof Error?i.message:yd())}}),p=y?.rules||[];return o(ue,{className:"h-full",children:[t("div",{className:"space-y-6 pr-4 pb-10",children:o(Ke,{children:[o(vt,{className:"flex flex-row items-center justify-between space-y-0 pb-6",children:[o("div",{className:"flex items-center gap-3",children:[t("div",{className:"p-2 bg-primary/10 text-primary rounded-lg",children:t(zo,{className:"w-6 h-6"})}),o("div",{children:[t(wt,{className:"text-xl font-bold",children:Jg()}),t(kt,{children:Xg()})]})]}),o(C,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",Fm()]})]}),t(at,{children:g?t("div",{className:"flex justify-center py-12",children:t(O,{className:"w-8 h-8 animate-spin text-primary"})}):p.length===0?o("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-xl",children:[t("div",{className:"mx-auto w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4 text-muted-foreground",children:t(zo,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold text-foreground mb-1",children:pp()}),t("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:fp()}),o(C,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",Fm()]})]}):t("div",{className:"flex flex-col gap-4",children:p.map((i)=>{let w=Xa[i.resource],b=i.resourceData||{};return t("div",{onClick:()=>d(i),className:`group relative flex flex-col justify-between p-5 rounded-xl border bg-card text-card-foreground shadow-2xs transition-all hover:border-primary/40 hover:shadow-xs cursor-pointer ${!i.enabled?"opacity-60 bg-muted/20":""}`,children:o("div",{className:"space-y-3",children:[o("div",{className:"flex items-start justify-between gap-2",children:[o("div",{children:[t("div",{className:"font-semibold text-base text-foreground group-hover:text-primary transition-colors flex items-center gap-2",children:t("span",{children:w?.label?w.label():i.resource})}),o("div",{className:"text-xs text-muted-foreground line-clamp-1",children:[i.resource==="agent_mcp_call_count"&&o("span",{children:["Server: ",String(b.id||"")]}),i.resource==="agent_bash_call_count"&&o("span",{children:["Match: ",String(b.match||"*")]}),i.resource==="agent_tool_call_count"&&o("span",{children:["Tool: ",String(b.name||b.toolName||"*")]})]})]}),o("div",{className:"flex items-center gap-2",onClick:(N)=>N.stopPropagation(),children:[t(Me,{checked:i.enabled,onCheckedChange:(N)=>v.mutate({id:i.id,enabled:N}),disabled:v.isPending}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"icon","aria-label":"Quota actions",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(Sr,{className:"w-4 h-4"})})}),t(_e,{align:"end",children:o(K,{onClick:()=>h(i),className:"text-destructive focus:text-destructive",children:[t(we,{className:"w-4 h-4 mr-2"}),ct()]})})]})]})]}),t("div",{className:"flex flex-wrap items-center gap-2 pt-2 border-t border-border/50",children:o("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.scopeMode==="all_members"&&o(he,{variant:"secondary",className:"gap-1 text-xs",children:[t(co,{className:"w-3 h-3"}),o("span",{children:[Ld(),i.role?` (${i.role})`:` (${Nl()})`]})]}),i.scopeMode==="each_member"&&o(he,{variant:"secondary",className:"gap-1 text-xs",children:[t(Kn,{className:"w-3 h-3"}),o("span",{children:[Zd(),i.role?` (${i.role})`:` (${Nl()})`]})]}),i.scopeMode==="selected_members"&&o(he,{variant:"secondary",className:"gap-1 text-xs",children:[t(Jo,{className:"w-3 h-3"}),o("span",{children:[Bd()," (",i.userIds?.length||0,")"]})]}),o(he,{variant:"outline",className:"gap-1 text-xs",children:[t(er,{className:"w-3 h-3"}),o("span",{children:[Oi(i.resource,i.limit)," ",w?.unit," /"," ",rc(i.period)]})]})]})})]})},i.id)})})})]})}),(a||!!s)&&t(zs,{open:a||!!s,onOpenChange:(i)=>{if(!i)l(!1),d(null)},teamId:e,rule:s}),t(Xe,{open:!!c,onOpenChange:(i)=>{if(!i)h(null)},children:o(et,{children:[o(tt,{children:[t(nt,{children:Bf()}),t(ot,{children:vh()})]}),o(rt,{children:[t(it,{disabled:x.isPending,children:Ne()}),o(st,{onClick:(i)=>{if(i.preventDefault(),c)x.mutate(c.id)},disabled:x.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[x.isPending&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),ct()]})]})]})})]})};function Hs({teamId:e}){let r=G(),{data:a,isLoading:l}=Z({queryKey:["teams",e,"settings"],queryFn:async()=>{let y=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!y.ok)throw Error(Xo());return await y.json()},enabled:!!e}),{mutate:s,isPending:d}=B({mutationFn:async(y)=>{let g=await A.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:"appearance.hideAgent",value:y}});if(!g.ok)throw Error(Zh());return await g.json()},onSuccess:async(y,g)=>{if(r.invalidateQueries({queryKey:["teams",e,"settings"]}),await _r.getState().fetchMetadata(e),g)ur.getState().setIsChatbotOpen(!1);M.success(c_())},onError:(y)=>{M.error(y instanceof Error?y.message:Zh())}}),c=Boolean(a?.appearance?.hideAgent),h=(y)=>{s(y)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})});return t("div",{className:"h-full overflow-y-auto pr-1",children:o(Ke,{children:[o(vt,{children:[t(wt,{children:oh()}),t(kt,{children:sh()})]}),t(at,{className:"space-y-6",children:o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"hide-agent-switch",className:"text-sm font-medium leading-none cursor-pointer",children:Aw()}),t("p",{className:"text-xs text-muted-foreground",children:_w()})]}),t(Me,{id:"hide-agent-switch",checked:c,onCheckedChange:h,disabled:d})]})})]})})}S();S();function Gs({isOpen:e,onClose:r,teamId:a,defaultFrom:l=""}){let[s,d]=u(l);m(()=>{if(e)d(l)},[l,e]);let{mutateAsync:c,isPending:h}=B({mutationFn:async(g)=>{let v=await A.api.teams[":teamId"].notifications.email.test.$post({param:{teamId:a},json:{from:g}});if(!v.ok){let x=await v.json().catch(()=>null);throw Error(x?.message||Oh())}return await v.json()}}),y=async()=>{if(!s.trim()){M.error(Zv());return}try{await c(s.trim()),M.success($T()),r()}catch(g){M.error(g instanceof Error?g.message:Oh())}};return t(de,{open:e,onOpenChange:(g)=>!g&&r(),children:o(le,{className:"sm:max-w-md",children:[o(me,{children:[o("div",{className:"flex items-center gap-2",children:[t(ls,{className:"w-5 h-5 text-primary"}),t(ce,{children:dA()})]}),t(Mt,{children:TI()})]}),t("div",{className:"space-y-4 py-2",children:o("div",{className:"space-y-2",children:[t("label",{htmlFor:"test-dialog-from-input",className:"text-sm font-medium text-foreground",children:fA()}),t(z,{id:"test-dialog-from-input",value:s,onChange:(g)=>d(g.target.value),placeholder:"Shumai <noreply@example.com>",disabled:h,autoFocus:!0})]})}),o(qe,{className:"gap-2 sm:gap-0",children:[t(C,{variant:"outline",onClick:r,disabled:h,children:Ne()}),o(C,{onClick:y,disabled:h,children:[h&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),dA()]})]})]})})}function Ws({teamId:e}){let r=G(),[a,l]=u({enabled:!1,host:"",port:587,username:"",password:"",smtps:!1,ignoreCert:!1,from:"",replyTo:""}),[s,d]=u(!1),{data:c,isLoading:h,error:y}=Z({queryKey:["teams",e,"email-settings"],queryFn:async()=>{let i=await A.api.teams[":teamId"].notifications.email.$get({param:{teamId:e}});if(!i.ok)throw Error(Ph());return await i.json()},enabled:!!e});m(()=>{if(c)l({enabled:c.enabled??!1,host:c.host??"",port:c.port??587,username:c.username??"",password:"",smtps:c.smtps??!1,ignoreCert:c.ignoreCert??!1,from:c.from??"",replyTo:c.replyTo??""})},[c]);let{mutateAsync:g,isPending:v}=B({mutationFn:async(i)=>{let w=await A.api.teams[":teamId"].notifications.email.$put({param:{teamId:e},json:{enabled:i.enabled,host:i.host,port:i.port,username:i.username||"",password:i.password||"",smtps:i.smtps,ignoreCert:i.ignoreCert,from:i.from,replyTo:i.replyTo||""}});if(!w.ok){let b=await w.json().catch(()=>null);throw Error(b?.message||$f())}return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"email-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]})}}),x=async()=>{try{await g(a),M.success(Ih())}catch(i){M.error(i instanceof Error?i.message:$f())}},p=async()=>{if(!a.host.trim()){M.error(QI());return}try{await g(a),M.success(Ih()),d(!0)}catch(i){M.error(i instanceof Error?i.message:$f())}};if(h)return t("div",{className:"flex items-center justify-center p-8",children:t(O,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(y)return t("div",{className:"p-8 text-center text-destructive",children:y instanceof Error?y.message:Ph()});return o(L,{children:[t(ue,{className:"h-full",children:t("div",{className:"space-y-6 pr-4 pb-8",children:o(Ke,{children:[o(at,{className:"space-y-6 pt-6",children:[o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"enable-email-switch",className:"text-sm font-medium leading-none cursor-pointer",children:Tb()}),t("p",{className:"text-xs text-muted-foreground",children:Mb()})]}),t(Me,{id:"enable-email-switch",checked:a.enabled,onCheckedChange:(i)=>l({...a,enabled:i})})]}),o("div",{className:"space-y-4 pt-2",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:nT()}),o("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o("div",{className:"space-y-2 md:col-span-2",children:[t("label",{htmlFor:"smtp-host-input",className:"text-sm font-medium text-foreground",children:GI()}),t(z,{id:"smtp-host-input",value:a.host,onChange:(i)=>l({...a,host:i.target.value}),placeholder:VI(),disabled:!a.enabled})]}),o("div",{className:"space-y-2",children:[t("label",{htmlFor:"smtp-port-input",className:"text-sm font-medium text-foreground",children:eT()}),t(z,{id:"smtp-port-input",type:"number",value:a.port,onChange:(i)=>l({...a,port:parseInt(i.target.value,10)||587}),disabled:!a.enabled})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[t("label",{htmlFor:"smtp-username-input",className:"text-sm font-medium text-foreground",children:oT()}),t(z,{id:"smtp-username-input",value:a.username||"",onChange:(i)=>l({...a,username:i.target.value}),placeholder:sT(),disabled:!a.enabled,autoComplete:"off"})]}),o("div",{className:"space-y-2",children:[t("label",{htmlFor:"smtp-password-input",className:"text-sm font-medium text-foreground",children:YI()}),t(z,{id:"smtp-password-input",type:"password",value:a.password||"",onChange:(i)=>l({...a,password:i.target.value}),placeholder:c?.password?JI():XI(),disabled:!a.enabled,autoComplete:"new-password"})]})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-2",children:[o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"smtps-switch",className:"text-sm font-medium leading-none cursor-pointer",children:tT()}),t("p",{className:"text-xs text-muted-foreground",children:rT()})]}),t(Me,{id:"smtps-switch",checked:a.smtps,onCheckedChange:(i)=>l({...a,smtps:i}),disabled:!a.enabled})]}),o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"ignore-cert-switch",className:"text-sm font-medium leading-none cursor-pointer",children:KI()}),t("p",{className:"text-xs text-muted-foreground",children:WI()})]}),t(Me,{id:"ignore-cert-switch",checked:a.ignoreCert,onCheckedChange:(i)=>l({...a,ignoreCert:i}),disabled:!a.enabled})]})]})]}),o("div",{className:"space-y-4 pt-4 border-t border-border",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:PI()}),o("div",{className:"space-y-2",children:[t("label",{htmlFor:"sender-from-input",className:"text-sm font-medium text-foreground",children:fA()}),t(z,{id:"sender-from-input",value:a.from,onChange:(i)=>l({...a,from:i.target.value}),placeholder:"Shumai <noreply@example.com>",disabled:!a.enabled}),t("p",{className:"text-xs text-muted-foreground",children:MI()})]}),o("div",{className:"space-y-2",children:[t("label",{htmlFor:"sender-reply-to-input",className:"text-sm font-medium text-foreground",children:kI()}),t(z,{id:"sender-reply-to-input",value:a.replyTo||"",onChange:(i)=>l({...a,replyTo:i.target.value}),placeholder:"noreply@example.com",disabled:!a.enabled}),t("p",{className:"text-xs text-muted-foreground",children:RI()})]})]})]}),o(ca,{className:"flex flex-col sm:flex-row items-center justify-end gap-3 border-t border-border p-6 bg-muted/20",children:[o(C,{variant:"outline",onClick:x,disabled:v,children:[v&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),Gn()]}),o(C,{onClick:p,disabled:v||!a.enabled,children:[v&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),QC()]})]})]})})}),t(Gs,{isOpen:s,onClose:()=>d(!1),teamId:e,defaultFrom:a.from})]})}S();var Xs={openai:"OpenAI",google:"Google","google-vertex":"Google Vertex AI",xai:"xAI",fal:"Fal",replicate:"Replicate","black-forest-labs":"Black Forest Labs",klingai:"Kling AI",togetherai:"Together AI",fireworks:"Fireworks AI",deepinfra:"DeepInfra",luma:"Luma","amazon-bedrock":"Amazon Bedrock",alibaba:"Alibaba",bytedance:"ByteDance",minimax:"MiniMax",prodia:"Prodia",azure:"Azure OpenAI"};function Js({teamId:e}){let r=G(),[a,l]=u(null),{data:s,isLoading:d}=Z({queryKey:["teams",e,"media-generation"],queryFn:async()=>{let g=await A.api.teams[":teamId"]["media-generation"].$get({param:{teamId:e}});if(!g.ok)throw Error("Failed to fetch media generation settings");return await g.json()}}),c=s?.providers||[],h=s?.enabledModels||[],y=D(()=>{if(!a)return null;return c.find((g)=>g.provider===a.provider)||a},[a,c]);if(d)return t("div",{className:"flex h-64 items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-col h-full min-w-0 w-full",children:[t(ue,{className:"h-full pr-1 [&>div>div]:block!",children:t("div",{className:"pb-12 min-w-0 w-full",children:o(Ke,{className:"border-border min-w-0 w-full",children:[o(vt,{children:[t(wt,{className:"text-base font-semibold",children:Mx()}),t(kt,{children:kx()})]}),t(at,{className:"min-w-0",children:t("div",{className:"space-y-2.5 min-w-0",children:c.map((g)=>{let v=Xs[g.provider]||g.provider,x=g.status==="configured_custom",p=g.status==="configured_env",i=h.filter((b)=>b.provider===g.provider&&b.type==="image").length,w=h.filter((b)=>b.provider===g.provider&&b.type==="video").length;return o("div",{onClick:()=>l(g),className:"group cursor-pointer flex items-center justify-between gap-4 p-3.5 rounded-xl border border-border bg-card/50 hover:bg-card/80 hover:border-primary/50 transition-all shadow-none hover:shadow-xs min-w-0",children:[o("div",{className:"flex flex-col gap-1.5 min-w-0 flex-1",children:[o("div",{className:"flex items-center gap-2.5 min-w-0",children:[t("span",{className:"font-semibold text-sm text-foreground truncate",children:v}),t("span",{className:"text-xs text-muted-foreground font-mono opacity-60 truncate",title:g.customApiKeyOrEnv||g.defaultEnvKey,children:g.customApiKeyOrEnv||g.defaultEnvKey})]}),o("div",{className:"flex flex-wrap items-center gap-2 min-w-0",children:[x&&o(he,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(ir,{className:"w-3 h-3"}),Zg()]}),p&&o(he,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] shrink-0 font-normal gap-1",children:[t(ir,{className:"w-3 h-3"}),Bg()]}),!x&&!p&&t(he,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:Ug()}),g.supportedTypes.includes("image")&&o("span",{className:E("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",i>0?"bg-primary/10 text-primary border-primary/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[t(ro,{className:"w-3 h-3"}),Sw({count:i})]}),g.supportedTypes.includes("video")&&o("span",{className:E("inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border shrink-0 font-normal transition-colors",w>0?"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20":"bg-muted/50 text-muted-foreground border-border/60"),children:[t(fa,{className:"w-3 h-3"}),Z1({count:w})]})]})]}),t(Et,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},g.provider)})})})]})})}),y&&t(ao,{isOpen:!!y,onClose:()=>l(null),provider:y,teamId:e,enabledModels:h,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function ao({isOpen:e,onClose:r,provider:a,teamId:l,enabledModels:s,onSuccess:d}){let[c,h]=u(()=>a.apiKeyConfigured?"models":"api-key"),[y,g]=u(a.customApiKeyOrEnv||""),[v,x]=u(()=>s.filter((ae)=>ae.provider===a.provider).map((ae)=>({type:ae.type,modelId:ae.modelId,name:ae.name}))),[p,i]=u(""),[w,b]=u("all"),[N,V]=u(""),[q,j]=u(a.supportedTypes[0]||"image");m(()=>{h(a.apiKeyConfigured?"models":"api-key"),g(a.customApiKeyOrEnv||""),x(s.filter((ae)=>ae.provider===a.provider).map((ae)=>({type:ae.type,modelId:ae.modelId,name:ae.name}))),i(""),b("all"),V(""),j(a.supportedTypes[0]||"image")},[a.provider,a.customApiKeyOrEnv,a.apiKeyConfigured,s]);let{data:re=[],isLoading:oe}=Z({queryKey:["teams",l,"media-generation","curated",a.provider],queryFn:async()=>{let ae=await A.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:l},query:{provider:a.provider}});if(!ae.ok)return[];return await ae.json()},enabled:e}),{mutate:F,isPending:T}=B({mutationFn:async()=>{let ae=await A.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:l,provider:a.provider},json:{apiKey:y.trim(),models:v.map((Se)=>({type:Se.type,modelId:Se.modelId,name:Se.name||Se.modelId}))}});if(!ae.ok){let Se=await ae.json().catch(()=>({}));throw Error(Se?.message||"Failed to update provider")}return await ae.json()},onSuccess:()=>{M.success(zg()),d(),r()},onError:(ae)=>{M.error(ae instanceof Error?ae.message:uv())}}),U=D(()=>new Set(re.map((ae)=>ae.modelId)),[re]),Y=D(()=>v.filter((ae)=>!U.has(ae.modelId)),[v,U]),k=D(()=>{let ae=[];for(let Se of re){let Oe=v.some((We)=>We.modelId===Se.modelId&&We.type===Se.type);ae.push({type:Se.type,modelId:Se.modelId,name:Se.name,isCustom:!1,isToggledOn:Oe})}for(let Se of Y)ae.push({type:Se.type,modelId:Se.modelId,name:Se.name||Se.modelId,isCustom:!0,isToggledOn:!0});return ae},[re,v,Y]),J=D(()=>k.filter((ae)=>{if(w!=="all"&&ae.type!==w)return!1;if(p.trim()){let Se=p.toLowerCase(),Oe=ae.name.toLowerCase().includes(Se),We=ae.modelId.toLowerCase().includes(Se);if(!Oe&&!We)return!1}return!0}),[k,w,p]),ye=(ae,Se)=>{if(Se)x((Oe)=>[...Oe,{type:ae.type,modelId:ae.modelId,name:ae.name,isCustom:ae.isCustom}]);else x((Oe)=>Oe.filter((We)=>!(We.modelId===ae.modelId&&We.type===ae.type)))},be=(ae,Se)=>{x((Oe)=>Oe.filter((We)=>!(We.modelId===ae&&We.type===Se)))},De=()=>{let ae=N.trim();if(!ae)return;if(v.some((Oe)=>Oe.modelId===ae&&Oe.type===q)){M.error(ev());return}x((Oe)=>[...Oe,{type:q,modelId:ae,name:ae,isCustom:!0}]),V("")},Ee=Xs[a.provider]||a.provider;return t(de,{open:e,onOpenChange:(ae)=>!ae&&r(),children:o(le,{className:"sm:max-w-2xl md:max-w-3xl h-[88vh] flex flex-col p-0 overflow-hidden",children:[o(me,{className:"p-6 pb-2 shrink-0",children:[o(ce,{className:"flex items-center gap-2 text-xl",children:[t("span",{children:Ee}),a.status==="configured_custom"&&t(he,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:Zg()}),a.status==="configured_env"&&t(he,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:Bg()})]}),t(Mt,{children:Hy({envKey:a.defaultEnvKey})})]}),o(Eo,{value:c,onValueChange:(ae)=>h(ae),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(Co,{className:"grid w-full grid-cols-2",children:[t(Yr,{value:"api-key",onClick:()=>h("api-key"),children:dd()}),o(Yr,{value:"models",onClick:()=>h("models"),children:[Id()," (",v.length,")"]})]})}),t(Rn,{value:"api-key",className:"flex-1 flex flex-col min-h-0 m-0",children:t("div",{className:"flex-1 min-h-0",children:t(ue,{className:"h-full",children:t("div",{className:"p-6 space-y-4 pr-6",children:o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t("label",{htmlFor:"provider-api-key",className:"text-xs font-medium text-foreground",children:dd()}),y&&o(C,{type:"button",variant:"ghost",size:"sm",className:"text-xs h-7 text-destructive hover:bg-destructive/10 hover:text-destructive gap-1 px-2",onClick:()=>g(""),children:[t(we,{className:"w-3.5 h-3.5"}),$_()]})]}),t(z,{id:"provider-api-key",type:"text",value:y,onChange:(ae)=>g(ae.target.value),placeholder:s_({envKey:a.defaultEnvKey}),className:"font-mono text-sm"}),t("p",{className:"text-xs text-muted-foreground mt-1",children:o_({envKey:a.defaultEnvKey})})]})})})})}),o(Rn,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[!a.apiKeyConfigured&&!y&&t("div",{className:"px-6 pb-2 shrink-0",children:o("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-600 dark:text-amber-400 text-xs",children:[t(nr,{className:"w-4 h-4 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-medium",children:Ug()}),t("p",{className:"text-[11px] opacity-90 mt-0.5",children:VE()})]})]})}),o("div",{className:"px-6 pb-3 flex items-center justify-between gap-3 shrink-0",children:[o("div",{className:"relative flex-1",children:[t(Ut,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(z,{type:"text",placeholder:Op(),value:p,onChange:(ae)=>i(ae.target.value),className:"pl-9 h-9 text-xs"})]}),a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-9",children:[t("button",{type:"button",onClick:()=>b("all"),className:E("px-3 text-xs transition-colors",w==="all"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:X0()}),o("button",{type:"button",onClick:()=>b("image"),className:E("px-3 text-xs transition-colors flex items-center gap-1.5",w==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(ro,{className:"w-3.5 h-3.5"}),sp()]}),o("button",{type:"button",onClick:()=>b("video"),className:E("px-3 text-xs transition-colors flex items-center gap-1.5",w==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(fa,{className:"w-3.5 h-3.5"}),ip()]})]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ue,{className:"h-full pr-4",children:oe?o("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[t(O,{className:"h-5 w-5 animate-spin"}),t("span",{className:"text-xs",children:$w()})]}):J.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Md()}):t("div",{className:"space-y-2 pb-4",children:J.map((ae)=>o("div",{className:E("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",ae.isToggledOn?"border-primary/40 bg-primary/5":"border-border bg-card hover:border-primary/30"),children:[o("div",{className:"flex items-center gap-2.5 min-w-0 flex-1 mr-3",children:[o(he,{variant:"outline",className:E("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",ae.type==="image"?"bg-primary/10 text-primary border-primary/20":"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20"),children:[ae.type==="image"?t(ro,{className:"w-3 h-3"}):t(fa,{className:"w-3 h-3"}),ae.type==="image"?sp():ip()]}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"font-semibold text-foreground text-sm truncate flex items-center gap-1.5",children:[t("span",{className:"truncate",children:ae.name}),ae.isCustom&&t(he,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:Oy().replace("...","")})]}),t("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:ae.modelId})]})]}),o("div",{className:"flex items-center gap-2 shrink-0",children:[ae.isCustom&&t(C,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>be(ae.modelId,ae.type),title:ct(),children:t(we,{className:"w-3.5 h-3.5"})}),t(Me,{checked:ae.isToggledOn,onCheckedChange:(Se)=>ye(ae,Se),"aria-label":`Toggle ${ae.name}`})]})]},`${ae.type}-${ae.modelId}`))})})}),t("div",{className:"px-6 py-3 border-t border-border shrink-0 bg-muted/10",children:o("div",{className:"flex items-center gap-2",children:[a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-8",children:[t("button",{type:"button",onClick:()=>j("image"),className:E("px-2.5 py-1 text-xs transition-colors",q==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:sp()}),t("button",{type:"button",onClick:()=>j("video"),className:E("px-2.5 py-1 text-xs transition-colors",q==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:ip()})]}),t(z,{type:"text",value:N,onChange:(ae)=>V(ae.target.value),placeholder:Ob(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(ae)=>{if(ae.key==="Enter")ae.preventDefault(),De()}}),o(C,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:De,disabled:!N.trim(),children:[t(fe,{className:"w-3.5 h-3.5"}),Cf()]})]})})]})]}),o(qe,{className:"px-6 py-4 border-t border-border shrink-0 flex items-center justify-between sm:justify-between w-full m-0 bg-card",children:[o("div",{className:"text-xs text-muted-foreground",children:[v.length," ",Id().toLowerCase()]}),o("div",{className:"flex items-center gap-2",children:[t(C,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:T,children:Ne()}),o(C,{type:"button",size:"sm",onClick:()=>F(),disabled:T,children:[T&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),Gn()]})]})]})]})})}S();var tr=({teamId:e})=>{let r=G(),[a,l]=u(""),[s,d]=u(""),[c,h]=u(""),[y,g]=u(null),[v,x]=u(!1),{data:p,isLoading:i}=Z({queryKey:["teams",e,"turntable-settings"],queryFn:async()=>{let q=await A.api.teams[":teamId"]["turntable-settings"].$get({param:{teamId:e}});if(!q.ok)throw Error("Failed to load turntable settings");return await q.json()},enabled:!!e});m(()=>{if(p)l(p.url||""),d(p.username||""),h(""),g(null)},[p]);let{mutateAsync:w,isPending:b}=B({mutationFn:async()=>{let q=await A.api.teams[":teamId"]["turntable-settings"].$put({param:{teamId:e},json:{url:a.trim(),username:s.trim()||void 0,password:c||void 0}});if(!q.ok){let j=await q.json().catch(()=>({}));throw Error(j.message||"Failed to update turntable settings")}return await q.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"turntable-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]}),M.success(za())},onError:(q)=>{M.error(q.message||vd())}}),N=async()=>{x(!0),g(null);try{let q=await A.api.teams[":teamId"]["turntable-settings"].test.$post({param:{teamId:e},json:{url:a||void 0,username:s||void 0,password:c||void 0}});if(!q.ok){let oe=(await q.json().catch(()=>({}))).message||"Request failed";g({ok:!1,error:oe}),M.error(Gd());return}let j=await q.json();if(g(j),j.ok)M.success(IA());else M.error(j.error||Gd())}catch(q){let j=q instanceof Error?q.message:String(q);g({ok:!1,error:j}),M.error(Gd())}finally{x(!1)}},V=Boolean(p?.isEnvConfigured);return o(Ke,{children:[o(vt,{children:[o("div",{className:"flex items-center justify-between",children:[t(wt,{children:b1()}),V&&o(he,{variant:"secondary",className:"gap-1",children:[t(Hn,{className:"w-3 h-3"}),h1()]})]}),t(kt,{children:v1()})]}),t(at,{className:"space-y-4",children:i?t("div",{className:"flex items-center justify-center py-6",children:t(O,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):o(L,{children:[o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"turntable-url",className:"text-sm font-medium",children:_1()}),t(z,{id:"turntable-url",value:a,onChange:(q)=>l(q.target.value),placeholder:y1(),disabled:V||b})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"turntable-username",className:"text-sm font-medium",children:S1()}),t(z,{id:"turntable-username",value:s,onChange:(q)=>d(q.target.value),placeholder:"admin",disabled:V||b})]}),o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"turntable-password",className:"text-sm font-medium",children:g1()}),t(z,{id:"turntable-password",type:"password",value:c,onChange:(q)=>h(q.target.value),placeholder:p?.hasPassword?A1():"••••••••",disabled:V||b})]})]}),y&&t("div",{className:`flex items-center gap-2 p-3 rounded-lg border text-sm ${y.ok?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-destructive/30 bg-destructive/10 text-destructive"}`,children:y.ok?o(L,{children:[t(ir,{className:"w-4 h-4 shrink-0"}),o("span",{children:[IA()," (v",y.version||"unknown",y.blender?`, Blender ${y.blender}`:"",")"]})]}):o(L,{children:[t(ma,{className:"w-4 h-4 shrink-0"}),o("span",{children:[Gd(),": ",y.error]})]})})]})}),o(ca,{className:"flex justify-between border-t border-border pt-4",children:[o(C,{type:"button",variant:"outline",onClick:N,disabled:i||v||!a.trim(),children:[v&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),v?x1():w1()]}),o(C,{type:"button",onClick:()=>w(),disabled:V||b||i,children:[b&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),Gn()]})]})]})};S();var ar=({teamId:e})=>{let r=G(),[a,l]=u(""),[s,d]=u(""),[c,h]=u(""),[y,g]=u(null),[v,x]=u(!1),{data:p,isLoading:i}=Z({queryKey:["teams",e,"gotenberg-settings"],queryFn:async()=>{let q=await A.api.teams[":teamId"]["gotenberg-settings"].$get({param:{teamId:e}});if(!q.ok)throw Error("Failed to load gotenberg settings");return await q.json()},enabled:!!e});m(()=>{if(p)l(p.url||""),d(p.username||""),h(""),g(null)},[p]);let{mutateAsync:w,isPending:b}=B({mutationFn:async()=>{let q=await A.api.teams[":teamId"]["gotenberg-settings"].$put({param:{teamId:e},json:{url:a.trim(),username:s.trim()||void 0,password:c||void 0}});if(!q.ok){let j=await q.json().catch(()=>({}));throw Error(j.message||"Failed to update gotenberg settings")}return await q.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"gotenberg-settings"]}),r.invalidateQueries({queryKey:["teams",e,"settings"]}),M.success(za())},onError:(q)=>{M.error(q.message||vd())}}),N=async()=>{x(!0),g(null);try{let q=await A.api.teams[":teamId"]["gotenberg-settings"].test.$post({param:{teamId:e},json:{url:a.trim()||void 0,username:s.trim()||void 0,password:c||void 0}});if(!q.ok){let oe=(await q.json().catch(()=>({}))).message||"Request failed";g({ok:!1,error:oe}),M.error(Sd());return}let j=await q.json();if(g(j),j.ok)M.success($h());else M.error(j.error||Sd())}catch(q){let j=q instanceof Error?q.message:String(q);g({ok:!1,error:j}),M.error(Sd())}finally{x(!1)}},V=Boolean(p?.isEnvConfigured);return o(Ke,{children:[o(vt,{children:[o("div",{className:"flex items-center justify-between",children:[t(wt,{children:ow()}),V&&o(he,{variant:"secondary",className:"gap-1",children:[t(Hn,{className:"w-3 h-3"}),Xv()]})]}),t(kt,{children:sw()})]}),t(at,{className:"space-y-4",children:i?t("div",{className:"flex items-center justify-center py-6",children:t(O,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):o(L,{children:[o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"gotenberg-url",className:"text-sm font-medium",children:rw()}),t(z,{id:"gotenberg-url",value:a,onChange:(q)=>l(q.target.value),placeholder:nw(),disabled:V||b})]}),o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"gotenberg-username",className:"text-sm font-medium",children:lw()}),t(z,{id:"gotenberg-username",value:s,onChange:(q)=>d(q.target.value),placeholder:"admin",disabled:V||b})]}),o("div",{className:"space-y-1.5",children:[t("label",{htmlFor:"gotenberg-password",className:"text-sm font-medium",children:ew()}),t(z,{id:"gotenberg-password",type:"password",value:c,onChange:(q)=>h(q.target.value),placeholder:p?.hasPassword?tw():"••••••••",disabled:V||b})]})]}),y&&t("div",{className:`flex items-center gap-2 p-3 rounded-lg border text-sm ${y.ok?"border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"border-destructive/30 bg-destructive/10 text-destructive"}`,children:y.ok?o(L,{children:[t(ir,{className:"w-4 h-4 shrink-0"}),o("span",{children:[$h(),y.version?` (v${y.version})`:""]})]}):o(L,{children:[t(ma,{className:"w-4 h-4 shrink-0"}),o("span",{children:[Sd(),": ",y.error]})]})})]})}),o(ca,{className:"flex justify-between border-t border-border pt-4",children:[o(C,{type:"button",variant:"outline",onClick:N,disabled:i||v||!a.trim(),children:[v&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),v?aw():iw()]}),o(C,{type:"button",onClick:()=>w(),disabled:V||b||i,children:[b&&t(O,{className:"w-4 h-4 mr-2 animate-spin"}),Gn()]})]})]})};S();S();function sr({isOpen:e,onClose:r,imageSrc:a,onConfirm:l}){let[s,d]=u(1),[c,h]=u({x:0,y:0}),[y,g]=u(!1),[v,x]=u(!1),p=_({x:0,y:0}),i=_(null),w=_(null),b=250;m(()=>{if(e)d(1),h({x:0,y:0}),x(!1)},[e,a]);let N=(F)=>{F.preventDefault(),g(!0),p.current={x:F.clientX-c.x,y:F.clientY-c.y}},V=(F)=>{if(!y)return;h({x:F.clientX-p.current.x,y:F.clientY-p.current.y})},q=()=>{g(!1)},j=(F)=>{if(F.touches.length!==1)return;g(!0);let T=F.touches[0];p.current={x:T.clientX-c.x,y:T.clientY-c.y}},re=(F)=>{if(!y||F.touches.length!==1)return;let T=F.touches[0];h({x:T.clientX-p.current.x,y:T.clientY-p.current.y})},oe=async()=>{let F=i.current,T=w.current;if(!F||!T)return;x(!0);try{let U=F.getBoundingClientRect(),Y=512,k=document.createElement("canvas");k.width=512,k.height=512;let J=k.getContext("2d");if(J){J.clearRect(0,0,512,512);let ye=2.048,be=U.width/s,De=U.height/s,Ee=256+c.x*ye,ae=256+c.y*ye;J.translate(Ee,ae),J.scale(s*ye,s*ye),J.drawImage(F,-be/2,-De/2,be,De);let Se=await new Promise((Oe)=>{k.toBlob((We)=>Oe(We),"image/jpeg",0.9)});if(Se)await l(Se)}}catch(U){console.error("Failed to crop image",U)}finally{x(!1)}};return t(de,{open:e,onOpenChange:(F)=>!F&&r(),children:o(le,{className:"sm:max-w-[420px] rounded-2xl border border-border bg-background/95 backdrop-blur-md shadow-2xl p-0 overflow-hidden gap-0",children:[t(me,{className:"p-6 border-b border-border/40 bg-gradient-to-br from-primary/5 to-transparent",children:o(ce,{className:"text-xl font-bold flex items-center gap-2",children:[t(ns,{className:"w-5 h-5 text-primary"}),wE()]})}),o("div",{className:"p-6 flex flex-col items-center gap-6",children:[o("div",{ref:w,className:"relative overflow-hidden bg-muted select-none border border-border/40 rounded-xl cursor-move shadow-inner",style:{width:250,height:250},onMouseDown:N,onMouseMove:V,onMouseUp:q,onMouseLeave:q,onTouchStart:j,onTouchMove:re,onTouchEnd:q,children:[a&&t("img",{ref:i,src:a,alt:R_(),crossOrigin:"anonymous",className:"absolute origin-center max-w-none pointer-events-none transition-transform duration-75 select-none",style:{top:"50%",left:"50%",transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${s})`,maxHeight:"100%"}}),t("div",{className:"absolute inset-0 pointer-events-none border-[3px] border-primary/90 rounded-full"}),t("div",{className:"absolute inset-0 pointer-events-none bg-black/40",style:{clipPath:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",maskImage:"radial-gradient(circle, transparent 122px, black 123px)",WebkitMaskImage:"radial-gradient(circle, transparent 122px, black 123px)"}})]}),o("div",{className:"w-full flex items-center gap-3 px-2",children:[t(ms,{className:"w-4 h-4 text-muted-foreground"}),t("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:s,onChange:(F)=>d(parseFloat(F.target.value)),className:"flex-1 h-1.5 bg-muted rounded-lg appearance-none cursor-pointer accent-primary focus:outline-none"}),t(cs,{className:"w-4 h-4 text-muted-foreground"})]})]}),o(qe,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[t(C,{variant:"outline",onClick:r,disabled:v,children:Ne()}),t(C,{onClick:oe,disabled:v||!a,className:"min-w-[80px]",children:v?o(L,{children:[t(O,{className:"w-4 h-4 animate-spin mr-2"}),rA()]}):Gn()})]})]})})}var so=["general","transcode","quotas","appearance","email","integrations","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"],io=["480p","720p","1080p","1440p","2160p"],no=["480p","720p","1080p","1440p","2160p"];function rr({teamId:e,settingKey:r,field:a,serverResolutions:l,defaultResolutions:s}){let d=G(),c=_(null),[h,y]=u(null),g=_(Promise.resolve()),v=_(!1);return m(()=>{if(!v.current)c.current=null,y(null)},[l]),{currentResolutions:h??l??s,handleToggle:(i)=>{let w=c.current??h??l??s;if(w.includes(i)&&w.length===1)return;let b=w.includes(i)?w.filter((N)=>N!==i):[...w,i];if(b.length===0)return;c.current=b,y(b),d.setQueryData(["teams",e,"settings"],(N)=>{if(!N)return N;return{...N,transcode:{...N.transcode,[a]:b}}}),v.current=!0,g.current=g.current.then(async()=>{let N=c.current;if(!N)return;let V=await A.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:r,value:N}});if(!V.ok)throw Error("Failed to update settings");if(await V.json(),c.current===N)c.current=null,v.current=!1,y(null),await d.invalidateQueries({queryKey:["teams",e,"settings"]}),M.success(za())}).catch((N)=>{console.error(N),c.current=null,v.current=!1,y(null),d.invalidateQueries({queryKey:["teams",e,"settings"]}),M.error(vd())})}}}function or(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return so.includes(e)?e:"general"}function mo(){let{teamId:e}=po.useParams(),r=G(),[a,l]=u(or),s=(H)=>{l(H);let xe=H==="general"?"":`#${H}`;if(window.location.hash!==xe)window.history.replaceState(null,"",window.location.pathname+window.location.search+xe)};m(()=>{let H=()=>{l(or())};return window.addEventListener("hashchange",H),()=>window.removeEventListener("hashchange",H)},[]);let[d,c]=u(""),[h,y]=u(!1),[g,v]=u(null),x=_(null),[p,i]=u(!1),{setMetadata:w,getMetadata:b}=_r(),N=b("locale")||n(),V=async(H)=>{if(H==="en"||H==="zh")try{await w(e,"locale",H),Na(H),M.success(Bw())}catch(xe){console.error(xe),M.error(mv())}},{data:q,isLoading:j,error:re}=Z({queryKey:["teams",e,"settings"],queryFn:async()=>{let H=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!H.ok)throw Error("Failed to fetch settings");return await H.json()}}),{data:oe,isLoading:F}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let H=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!H.ok)throw Error("Failed to fetch me");return await H.json()},enabled:!!e});m(()=>{if(oe?.name)c(oe.name)},[oe]),m(()=>{let H=["transcode","quotas","appearance","email","providers","image-video","skills","mcp","agents","sandbox"];if(oe&&oe.role!=="owner"&&H.includes(a))s("general")},[oe,a]);let T=(H)=>{if(!H)return"U";let xe=H.split(" ");if(xe.length>1)return`${xe[0][0]}${xe[xe.length-1][0]}`.toUpperCase();return H.substring(0,2).toUpperCase()},U=(H)=>{let xe=H.target.files?.[0];if(xe){let ke=new FileReader;ke.onload=()=>{v(ke.result),y(!0)},ke.readAsDataURL(xe),H.target.value=""}},Y=async(H)=>{i(!0);try{let xe=new File([H],"avatar.jpg",{type:"image/jpeg"}),ke=await A.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:xe}});if(!ke.ok)throw Error("Failed to upload avatar");let Qt=(await ke.json()).key;if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:Qt}})).ok)throw Error("Failed to save profile");M.success(P_()),r.invalidateQueries({queryKey:["teams",e,"me"]}),y(!1)}catch(xe){console.error(xe),M.error(pv())}finally{i(!1)}},k=async()=>{i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:null}})).ok)throw Error("Failed to remove avatar");M.success(k_()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(H){console.error(H),M.error(Jb())}finally{i(!1)}},J=async()=>{if(!d.trim())return;i(!0);try{if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{name:d.trim()}})).ok)throw Error("Failed to update name");M.success(Pg()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(H){console.error(H),M.error(hv())}finally{i(!1)}},{mutate:ye}=B({mutationFn:async(H)=>{let xe=await A.api.teams[":teamId"].settings.$patch({param:{teamId:H.teamId},json:H.data});if(!xe.ok)throw Error("Failed to update settings");return await xe.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"settings"]}),M.success(za())},onError:()=>{M.error(vd())}}),be=(H)=>{ye({teamId:e,data:{key:"transcode.videoStrategy",value:H}})},{currentResolutions:De,handleToggle:Ee}=rr({teamId:e,settingKey:"transcode.videoResolutions",field:"videoResolutions",serverResolutions:q?.transcode?.videoResolutions,defaultResolutions:OA}),{currentResolutions:ae,handleToggle:Se}=rr({teamId:e,settingKey:"transcode.hlsResolutions",field:"hlsResolutions",serverResolutions:q?.transcode?.hlsResolutions,defaultResolutions:FA}),Oe=(H)=>{ye({teamId:e,data:{key:"transcode.hardwareAcceleration",value:H}})},[We,lt]=u(null),X=q?.transcode?.threads??0;m(()=>{lt(null)},[X]);let se=(H)=>{ye({teamId:e,data:{key:"transcode.threads",value:H}})},ie=(H)=>{ye({teamId:e,data:{key:"transcode.hlsEnabled",value:H}})};if(j||F)return t("div",{className:"flex h-screen items-center justify-center",children:t(O,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(re)return t("div",{className:"p-8 text-center text-red-500",children:Xo()});let pe=q?.transcode?.videoStrategy||Qs.best_match;if(pe==="single"||pe==="disable")pe=Qs.best_match;else if(pe==="full"||pe==="all"||pe==="multi")pe=Qs.multi;let dt=q?.transcode?.hardwareAcceleration||qa.off,ee=We??X,Ye=q?.transcode?.hlsEnabled??!1;return t("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:o("div",{className:"flex flex-col md:flex-row h-full",children:[t("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:o("nav",{className:"p-4 space-y-1 mt-4",children:[t("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:bE()}),o("button",{onClick:()=>s("general"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="general"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Kn,{className:"w-5 h-5"}),Bv(),a==="general"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("notifications"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="notifications"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(ga,{className:"w-5 h-5"}),vg(),a==="notifications"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("developer"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="developer"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Xt,{className:"w-5 h-5"}),nh(),a==="developer"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),oe?.role==="owner"&&o(L,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:ZT()}),o("button",{onClick:()=>s("transcode"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="transcode"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(rs,{className:"w-5 h-5"}),kA(),a==="transcode"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("quotas"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(zo,{className:"w-5 h-5"}),Ud(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("appearance"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="appearance"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Xl,{className:"w-5 h-5"}),kf(),a==="appearance"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("email"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="email"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(hi,{className:"w-5 h-5"}),Ch(),a==="email"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("integrations"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="integrations"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(ss,{className:"w-5 h-5"}),Kh(),a==="integrations"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),oe?.role==="owner"&&o(L,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:DT()}),o("button",{onClick:()=>s("providers"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="providers"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(lo,{className:"w-5 h-5"}),QE(),a==="providers"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("image-video"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="image-video"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(dn,{className:"w-5 h-5"}),Vh(),a==="image-video"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("skills"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="skills"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Ct,{className:"w-5 h-5"}),mA(),a==="skills"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("mcp"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(wn,{className:"w-5 h-5"}),Qc(),a==="mcp"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("agents"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="agents"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Tt,{className:"w-5 h-5"}),z0(),a==="agents"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("sandbox"),className:E("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="sandbox"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(ec,{className:"w-5 h-5"}),y0(),a==="sandbox"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})]})}),t("main",{className:"flex-1 bg-background/50 h-full flex flex-col transition-colors duration-300 overflow-y-hidden",children:o("div",{className:"flex-1 flex flex-col max-w-4xl w-full mx-auto p-6 md:p-10 overflow-hidden",children:[t("div",{className:"flex-none flex items-center justify-between mb-6",children:o("div",{children:[o("h2",{className:"text-2xl font-bold text-foreground",children:[a==="general"&&qh(),a==="transcode"&&kA(),a==="quotas"&&Jg(),a==="appearance"&&oh(),a==="email"&&Ch(),a==="integrations"&&Kh(),a==="skills"&&hA(),a==="mcp"&&Qc(),a==="providers"&&K0(),a==="image-video"&&Vh(),a==="agents"&&Q0(),a==="sandbox"&&b0(),a==="notifications"&&FS(),a==="developer"&&db()]}),o("p",{className:"text-sm text-muted-foreground mt-1",children:[a==="general"&&zv(),a==="transcode"&&z1(),a==="quotas"&&Xg(),a==="appearance"&&sh(),a==="email"&&Sb(),a==="integrations"&&Mw(),a==="skills"&&HI(),a==="mcp"&&Cd(),a==="providers"&&KE(),a==="image-video"&&Ix(),a==="agents"&&j0(),a==="sandbox"&&GC(),a==="notifications"&&ZS(),a==="developer"&&ub()]})]})}),o("div",{className:"flex-1 overflow-hidden animate-in fade-in slide-in-from-bottom-4 duration-500",children:[a==="general"&&o("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[o(Ke,{children:[o(vt,{children:[t(wt,{children:_E()}),t(kt,{children:yE()})]}),t(at,{className:"space-y-6",children:o("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[o("div",{className:"flex flex-col items-center gap-3",children:[t("span",{className:"text-sm font-medium text-muted-foreground",children:M_()}),o("div",{className:"group relative cursor-pointer overflow-hidden rounded-full w-24 h-24 border border-border/60 shadow-md transition-all hover:opacity-90",onClick:()=>x.current?.click(),children:[o(Ce,{className:"w-24 h-24",children:[oe?.image&&t(Ie,{src:oe.image,alt:oe.name,className:"object-cover w-24 h-24"}),t(Te,{className:"text-2xl bg-primary/40 text-foreground",children:T(oe?.name)})]}),t("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:t("span",{className:"text-white text-xs font-semibold",children:z_()})})]}),o("div",{className:"flex gap-2",children:[t(C,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:k1()}),oe?.image&&t(C,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:k,children:Dl()})]}),t("input",{type:"file",ref:x,className:"hidden",accept:"image/*",onChange:U})]}),o("div",{className:"flex-1 space-y-4 w-full",children:[o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:Il()}),t(z,{value:d,onChange:(H)=>c(H.target.value),placeholder:Zb(),className:"max-w-md"})]}),o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:jf()}),t(z,{value:oe?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),t("p",{className:"text-xs text-muted-foreground",children:xb()})]}),o(C,{onClick:J,disabled:p||!d.trim(),className:"mt-2",children:[p&&t(O,{className:"w-4 h-4 animate-spin mr-2"}),Vs()]})]})]})})]}),o(Ke,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[o(vt,{children:[t(wt,{children:Zw()}),t(kt,{children:_I()})]}),t(at,{className:"space-y-4",children:t("div",{className:"max-w-xs",children:o(Fe,{value:N,onValueChange:V,children:[t(Ze,{children:t(Le,{placeholder:mI()})}),o(Be,{children:[t(ne,{value:"en",children:Nb()}),t(ne,{value:"zh",children:H_()})]})]})})})]}),t(sr,{isOpen:h,onClose:()=>y(!1),imageSrc:g,onConfirm:Y})]}),a==="transcode"&&o("div",{className:"h-full overflow-y-auto space-y-6 pr-1 pb-8",children:[o(Ke,{children:[o(vt,{children:[t(wt,{children:c1()}),t(kt,{children:u1()})]}),o(at,{className:"space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"space-y-0.5",children:[t("h3",{className:"text-lg font-medium",children:Gx()}),t("p",{className:"text-sm text-muted-foreground",children:Vx()})]}),o("div",{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",pe===Qs.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>be(Qs.best_match),children:[t("div",{className:"font-semibold",children:F_()}),t("div",{className:"text-sm text-muted-foreground",children:L_()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",pe===Qs.multi?"border-primary bg-primary/5":"border-border"),onClick:()=>be(Qs.multi),children:[t("div",{className:"font-semibold",children:Qx()}),t("div",{className:"text-sm text-muted-foreground",children:Kx()})]}),pe===Qs.multi&&o("div",{className:"space-y-3 pt-2 pl-1",children:[o("div",{className:"space-y-1",children:[t("h4",{className:"text-sm font-medium",children:B1()}),t("p",{className:"text-xs text-muted-foreground",children:U1()})]}),t("div",{className:"flex flex-wrap gap-4 pt-1",children:io.map((H)=>{let xe=De.includes(H),ke=xe&&De.length===1;return o("label",{className:E("flex items-center space-x-2 text-sm",ke?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[t(wr,{checked:xe,disabled:ke,onCheckedChange:()=>Ee(H)}),t("span",{children:H})]},H)})})]})]})]}),o("div",{className:"space-y-4 pt-6 border-t border-border",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{className:"space-y-0.5",children:[t("h3",{className:"text-lg font-medium",children:vw()}),t("p",{className:"text-sm text-muted-foreground",children:ww()})]}),t(Me,{checked:Ye,onCheckedChange:ie})]}),Ye&&o("div",{className:"space-y-3 pt-2 pl-1",children:[o("div",{className:"space-y-1",children:[t("h4",{className:"text-sm font-medium",children:yw()}),t("p",{className:"text-xs text-muted-foreground",children:bw()})]}),t("div",{className:"flex flex-wrap gap-4 pt-1",children:no.map((H)=>{let xe=ae.includes(H),ke=xe&&ae.length===1;return o("label",{className:E("flex items-center space-x-2 text-sm",ke?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[t(wr,{checked:xe,disabled:ke,onCheckedChange:()=>Se(H)}),t("span",{children:H})]},H)})})]})]})]})]}),o(Ke,{children:[o(vt,{children:[t(wt,{children:dw()}),t(kt,{children:gw()})]}),o(at,{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",dt===qa.off?"border-primary bg-primary/5":"border-border"),onClick:()=>Oe(qa.off),children:[t("div",{className:"font-semibold",children:mw()}),t("div",{className:"text-sm text-muted-foreground",children:hw()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",dt===qa.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>Oe(qa.auto),children:[t("div",{className:"font-semibold",children:fw()}),t("div",{className:"text-sm text-muted-foreground",children:pw()})]})]})]}),o(Ke,{children:[t(vt,{children:o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(wt,{children:_v()}),t(kt,{className:"mt-1.5",children:yv()})]}),t("span",{className:"font-mono text-sm font-semibold px-2.5 py-1 rounded bg-muted text-foreground border border-border",children:ee===0?SA():XT({count:ee})})]})}),t(at,{children:o("div",{className:"pt-2 px-1",children:[t(jo,{value:[ee],min:0,max:32,step:1,onValueChange:([H])=>lt(H),onValueCommit:([H])=>{lt(H),se(H)}}),o("div",{className:"flex justify-between text-xs text-muted-foreground mt-2",children:[o("span",{children:[SA()," (0)"]}),t("span",{children:"16"}),t("span",{children:"32"})]})]})})]})]}),a==="skills"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Bs,{teamId:e})}),a==="mcp"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(js,{teamId:e})}),a==="providers"&&t(Ps,{teamId:e}),a==="image-video"&&t(Js,{teamId:e}),a==="agents"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ts,{teamId:e})}),a==="sandbox"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Rs,{teamId:e})}),a==="notifications"&&t(Os,{teamId:e}),a==="developer"&&t(Ks,{teamId:e}),a==="quotas"&&t(Us,{teamId:e}),a==="appearance"&&t(Hs,{teamId:e}),a==="email"&&t(Ws,{teamId:e}),a==="integrations"&&o("div",{className:"h-full overflow-y-auto space-y-6 pr-1",children:[t(tr,{teamId:e}),t(ar,{teamId:e})]})]})]})})]})})}var po=Ue("/teams/$teamId/settings")({component:mo});export{po as Route};
|