@shumai-one/shumai 0.4.2 → 0.4.4
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-071x515q.js +4 -0
- package/bin/{chunk-adekdctx.css → chunk-0ccg9ddn.css} +1 -1
- package/bin/chunk-0cmx7k4c.js +1 -0
- package/bin/chunk-0qaq0sp8.js +5 -0
- package/bin/chunk-0qjfahk9.js +2 -0
- package/bin/chunk-0zv3bks2.js +2 -0
- package/bin/chunk-16xax8kk.js +1 -0
- package/bin/chunk-1gvscz88.js +5 -0
- package/bin/chunk-1j27fzy1.js +2 -0
- package/bin/chunk-1t167cvj.js +11 -0
- package/bin/chunk-1xh34aew.js +2 -0
- package/bin/chunk-1zwajpwf.js +8 -0
- package/bin/chunk-2w5xqhjm.js +1 -0
- package/bin/chunk-3tedzb2j.js +54 -0
- package/bin/chunk-3ttrhqy3.js +2 -0
- package/bin/chunk-3zkasqb8.js +1 -0
- package/bin/chunk-453ykvaw.js +2 -0
- package/bin/chunk-4991gz3y.js +13 -0
- package/bin/chunk-4hkkdm2q.js +2 -0
- package/bin/chunk-4mjywsj8.js +3 -0
- package/bin/chunk-4v41a1r9.js +6 -0
- package/bin/chunk-4wy87hwd.js +3 -0
- package/bin/chunk-579e4wv4.js +3 -0
- package/bin/chunk-5adsx8x4.js +2 -0
- package/bin/chunk-5hg6kcfz.js +45 -0
- package/bin/chunk-5nm2jvg5.js +32 -0
- package/bin/chunk-5tcdwep5.js +11 -0
- package/bin/chunk-5vzrpz50.js +2 -0
- package/bin/chunk-6ghcj4a9.js +3 -0
- package/bin/chunk-77fmkpdz.js +10 -0
- package/bin/chunk-7bcxj1jd.js +2 -0
- package/bin/chunk-7gmdnsdg.js +2 -0
- package/bin/chunk-7jtmwt5a.js +3 -0
- package/bin/chunk-7kjgvxqa.js +2 -0
- package/bin/chunk-7pw1550a.js +2 -0
- package/bin/chunk-7rhz2gze.js +211 -0
- package/bin/chunk-837fky18.js +3 -0
- package/bin/chunk-84as6x83.js +1 -0
- package/bin/chunk-8e28hcny.js +2 -0
- package/bin/chunk-914bp49r.js +4 -0
- package/bin/chunk-97f2af6d.js +12 -0
- package/bin/chunk-98715kc3.js +2 -0
- package/bin/chunk-9ccw540k.js +2 -0
- package/bin/chunk-9t8n2des.js +2 -0
- package/bin/chunk-9ybt6vbm.js +1 -0
- package/bin/chunk-a6gx7f5q.js +1 -0
- package/bin/chunk-avwgktxb.js +2 -0
- package/bin/chunk-bkr5zm4h.js +2 -0
- package/bin/chunk-cbgq517y.js +2 -0
- package/bin/chunk-d27mm390.js +1 -0
- package/bin/chunk-dj92fss9.js +2 -0
- package/bin/chunk-dqxeztfa.js +2 -0
- package/bin/chunk-drepsbb4.js +2 -0
- package/bin/chunk-f6svp4dp.js +2 -0
- package/bin/chunk-fahk9h62.js +8 -0
- package/bin/chunk-fb40xxz3.js +3 -0
- package/bin/chunk-fnmwksnb.js +3 -0
- package/bin/chunk-fpc4p0j8.js +3 -0
- package/bin/chunk-fsyzs0tf.js +1 -0
- package/bin/chunk-fxecgp5k.js +1 -0
- package/bin/chunk-g3fpmyyn.js +3 -0
- package/bin/chunk-gc5sbfa5.js +2 -0
- package/bin/chunk-gdm6yfqq.js +2 -0
- package/bin/chunk-gk2q9a3f.js +2 -0
- package/bin/chunk-gt4csat6.js +3 -0
- package/bin/chunk-gye8gabk.js +2 -0
- package/bin/chunk-hk5rc6cd.js +24 -0
- package/bin/chunk-hm0dkzed.js +3 -0
- package/bin/chunk-hmpwg5za.js +16 -0
- package/bin/chunk-j1tkmcae.js +3 -0
- package/bin/chunk-j2bvj2yn.js +2 -0
- package/bin/chunk-jffktpqg.js +1 -0
- package/bin/chunk-jgs8an3h.js +18 -0
- package/bin/chunk-jmpb5633.js +2 -0
- package/bin/chunk-jrjnqx78.js +2 -0
- package/bin/chunk-k2k9vjq6.js +1 -0
- package/bin/chunk-kpgfqkp0.js +3 -0
- package/bin/chunk-ks8xzc95.js +3 -0
- package/bin/chunk-kswvyqq1.js +2 -0
- package/bin/chunk-m9pr03kn.js +2 -0
- package/bin/chunk-mfn9qjm4.js +2 -0
- package/bin/chunk-msfw3jmc.js +3 -0
- package/bin/chunk-mz0yjra0.js +5 -0
- package/bin/chunk-nbdw8fen.js +1 -0
- package/bin/chunk-nkdk229f.js +2 -0
- package/bin/chunk-nr20tvnw.js +3 -0
- package/bin/chunk-pazjhrnf.js +12 -0
- package/bin/chunk-q806pqeh.js +1 -0
- package/bin/chunk-qka4mkmj.js +2 -0
- package/bin/chunk-qsr1a0rp.js +2 -0
- package/bin/chunk-rchsme43.js +3 -0
- package/bin/chunk-reyxk4bw.js +2 -0
- package/bin/chunk-rhvv1vvk.js +3 -0
- package/bin/chunk-rq0n0vcc.js +2 -0
- package/bin/chunk-rqf7999q.js +42 -0
- package/bin/chunk-rssgmj7x.js +2 -0
- package/bin/chunk-ryzz5fht.js +2 -0
- package/bin/chunk-s2fnfyn9.js +2 -0
- package/bin/chunk-s2k4qntr.js +3 -0
- package/bin/chunk-snhsjs4x.js +299 -0
- package/bin/chunk-t2hy6tj9.js +2 -0
- package/bin/chunk-t7nsgg5k.js +4 -0
- package/bin/chunk-tm7f32c7.js +14 -0
- package/bin/chunk-trveq4wg.js +3 -0
- package/bin/chunk-vap4k11j.js +20 -0
- package/bin/chunk-vm5fx7td.js +3 -0
- package/bin/chunk-vy8gntez.js +1 -0
- package/bin/chunk-vyzptrea.js +2 -0
- package/bin/chunk-w4ghe71n.js +2 -0
- package/bin/chunk-wdsf44hs.js +2 -0
- package/bin/chunk-wjyaezs7.js +2 -0
- package/bin/chunk-wndm3px3.js +1 -0
- package/bin/chunk-x5jwwvs0.js +1 -0
- package/bin/chunk-x92cq59c.js +1 -0
- package/bin/chunk-xa18z1py.js +3 -0
- package/bin/chunk-xarsrs08.js +2 -0
- package/bin/chunk-xtf3c29c.css +1 -0
- package/bin/chunk-xx337zcw.js +2 -0
- package/bin/chunk-xz6713tj.js +2 -0
- package/bin/chunk-yfnem6se.js +2 -0
- package/bin/chunk-ytdwk2fq.js +2 -0
- package/bin/chunk-ze20rm02.js +7 -0
- package/bin/chunk-zw86wnwe.js +7 -0
- package/bin/chunk-zxk7q0zk.js +2 -0
- package/bin/{pdf.worker.min-szxdj13d.mjs → pdf.worker.min-vf48er29.mjs} +14423 -13889
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +841 -678
- package/package.json +18 -18
- package/prisma/migrations/20260904022457_add_agent_id_to_assets_and_audit_logs/migration.sql +17 -0
- package/prisma/migrations/20260906081230_default_denied_tools_delete_asset/migration.sql +15 -0
- package/prisma/migrations/20260907021754_add_asset_upload_id/migration.sql +2 -0
- package/prisma/schema.prisma +10 -0
- package/bin/chunk-07h4b77v.js +0 -2
- package/bin/chunk-0t4n4d5w.js +0 -4
- package/bin/chunk-1611z9jg.js +0 -2
- package/bin/chunk-1phqxp6z.js +0 -3
- package/bin/chunk-23hckrrz.js +0 -2
- package/bin/chunk-30z44j1g.js +0 -2
- package/bin/chunk-3j463k1g.js +0 -1
- package/bin/chunk-4181tdds.js +0 -14
- package/bin/chunk-480jtqng.js +0 -4
- package/bin/chunk-4c3g146q.js +0 -2
- package/bin/chunk-4ca0zt5e.js +0 -1
- package/bin/chunk-4d9bgmf2.js +0 -2
- package/bin/chunk-4ev56fss.js +0 -9
- package/bin/chunk-4gk52tjq.js +0 -45
- package/bin/chunk-4mdqkj4d.js +0 -1
- package/bin/chunk-4r91fggc.js +0 -2
- package/bin/chunk-50fb1x3w.js +0 -1
- package/bin/chunk-59gj1njz.js +0 -1
- package/bin/chunk-5pr0t7fb.js +0 -2
- package/bin/chunk-5vewxmz7.js +0 -3
- package/bin/chunk-62zx96pe.js +0 -2
- package/bin/chunk-63y0eb07.js +0 -2
- package/bin/chunk-6d5xrgfx.js +0 -2
- package/bin/chunk-6gbtz5bf.js +0 -67
- package/bin/chunk-6gjg5egq.js +0 -3
- package/bin/chunk-6m4jz9s1.js +0 -44
- package/bin/chunk-6s4x525w.js +0 -2
- package/bin/chunk-6w2wmvqs.js +0 -3
- package/bin/chunk-77d23vcn.js +0 -2
- package/bin/chunk-77m5p188.js +0 -2
- package/bin/chunk-7bvx087f.js +0 -1
- package/bin/chunk-7pfjfrjg.js +0 -5
- package/bin/chunk-7q10s127.js +0 -4
- package/bin/chunk-7thx8ctx.js +0 -3
- package/bin/chunk-8t4s91gh.js +0 -2
- package/bin/chunk-98ey5p2e.js +0 -3
- package/bin/chunk-9amndcyh.js +0 -6
- package/bin/chunk-9bk23g9x.js +0 -1
- package/bin/chunk-9mkcfy43.js +0 -1
- package/bin/chunk-9t3nsq5n.js +0 -2
- package/bin/chunk-9tjq99ds.js +0 -2
- package/bin/chunk-9wm9rwh1.js +0 -2
- package/bin/chunk-ab16fyg4.js +0 -4
- package/bin/chunk-arv0g2av.js +0 -1
- package/bin/chunk-aytj4zxg.js +0 -3
- package/bin/chunk-b1ypjqgp.js +0 -2
- package/bin/chunk-bdjv0ykq.js +0 -2
- package/bin/chunk-c1k86mfa.js +0 -10
- package/bin/chunk-caa96dgd.js +0 -2
- package/bin/chunk-ce4v2yjy.js +0 -1
- package/bin/chunk-cqh60y54.js +0 -3
- package/bin/chunk-cvq7zgw7.js +0 -1
- package/bin/chunk-d9mjbtp2.js +0 -2
- package/bin/chunk-dn7sbjws.js +0 -3
- package/bin/chunk-dxyq9h8n.js +0 -3
- package/bin/chunk-e3cabksx.js +0 -3
- package/bin/chunk-egcrbj94.js +0 -2
- package/bin/chunk-ev17v1mv.js +0 -2
- package/bin/chunk-evtpwg71.js +0 -2
- package/bin/chunk-f3e0nsv2.js +0 -2
- package/bin/chunk-f40gjqpq.js +0 -2
- package/bin/chunk-fe7822ak.js +0 -299
- package/bin/chunk-g8tkhw9j.js +0 -2
- package/bin/chunk-g9r0p4t8.js +0 -2
- package/bin/chunk-gbjyh9ms.js +0 -1
- package/bin/chunk-gtbsb39v.js +0 -3
- package/bin/chunk-gytz1q13.js +0 -13
- package/bin/chunk-h0fxysxs.js +0 -7
- package/bin/chunk-h8bdvsqt.js +0 -2
- package/bin/chunk-hag024w8.js +0 -2
- package/bin/chunk-hc6w5nw4.js +0 -7
- package/bin/chunk-j69dqc48.js +0 -2
- package/bin/chunk-jbtw1zym.js +0 -8
- package/bin/chunk-jc1vb7rj.js +0 -5
- package/bin/chunk-jdv78w9r.js +0 -2
- package/bin/chunk-jjs70y9v.js +0 -3
- package/bin/chunk-jmdar2gz.js +0 -2
- package/bin/chunk-jvwz10n4.js +0 -2
- package/bin/chunk-k47md1g4.js +0 -2
- package/bin/chunk-k4v0brcb.js +0 -2
- package/bin/chunk-k6n7c07e.js +0 -1
- package/bin/chunk-kk2cstsg.js +0 -2
- package/bin/chunk-knz4h56q.js +0 -12
- package/bin/chunk-kqqtt6bd.js +0 -3
- package/bin/chunk-kvyp1t4j.js +0 -7
- package/bin/chunk-kxskpgsq.js +0 -5
- package/bin/chunk-m6srbjcs.js +0 -2
- package/bin/chunk-mcc1scxs.js +0 -12
- package/bin/chunk-mq83a0kk.js +0 -2
- package/bin/chunk-mxm8g4q0.js +0 -1
- package/bin/chunk-nhpgdqq5.js +0 -2
- package/bin/chunk-nne496aa.js +0 -2
- package/bin/chunk-nqpb0r9h.js +0 -11
- package/bin/chunk-ns0zww9g.js +0 -2
- package/bin/chunk-ps4xfp23.js +0 -2
- package/bin/chunk-pz2ec6xt.js +0 -2
- package/bin/chunk-q163k309.js +0 -2
- package/bin/chunk-q1da61ps.js +0 -1
- package/bin/chunk-qrf0ady6.js +0 -68
- package/bin/chunk-qy28f25e.js +0 -2
- package/bin/chunk-r7s4ypw1.js +0 -2
- package/bin/chunk-ran23vm9.js +0 -1
- package/bin/chunk-rfvdc4n0.js +0 -2
- package/bin/chunk-rgthkvgx.js +0 -3
- package/bin/chunk-s39n3yw3.js +0 -2
- package/bin/chunk-s7wdd0g7.js +0 -8
- package/bin/chunk-s88ha5kx.js +0 -3
- package/bin/chunk-sf91bt9m.js +0 -2
- package/bin/chunk-sjwbjf9j.js +0 -2
- package/bin/chunk-t62076pv.js +0 -1
- package/bin/chunk-tbbwss3v.js +0 -3
- package/bin/chunk-tjcc7a6y.js +0 -24
- package/bin/chunk-tp6ab26e.js +0 -2
- package/bin/chunk-v2wxk9p5.js +0 -4
- package/bin/chunk-vbk6y4hk.js +0 -2
- package/bin/chunk-vfgfg5fk.js +0 -2
- package/bin/chunk-vm6c3xx9.js +0 -2
- package/bin/chunk-vsx96mt6.js +0 -3
- package/bin/chunk-wbyw1shz.js +0 -6
- package/bin/chunk-whh2vh50.css +0 -1
- package/bin/chunk-wjkcq65s.js +0 -2
- package/bin/chunk-wkefwkfp.js +0 -41
- package/bin/chunk-x7bsnk1e.js +0 -2
- package/bin/chunk-xbhw6bpz.js +0 -3
- package/bin/chunk-xg5yrcj5.js +0 -2
- package/bin/chunk-xg9xscqz.js +0 -1
- package/bin/chunk-xw2gpcsh.js +0 -3
- package/bin/chunk-ycq8ank7.js +0 -2
- package/bin/chunk-yp9hvkc5.js +0 -73
- package/bin/chunk-ytypyfkc.js +0 -65
- package/bin/chunk-z1kjmf60.js +0 -2
- package/bin/chunk-z36bx86r.js +0 -2
- package/bin/chunk-z7hdnecp.js +0 -3
- package/bin/chunk-zeby1cq7.js +0 -2
- package/bin/chunk-zs5e8z1w.js +0 -1
- package/bin/chunk-zxnyefg5.js +0 -2
- /package/bin/{chunk-24ke0th1.css → chunk-kegybs91.css} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Q,N,h,Ge,O,w,u,Es,C,B,t,o,K,Z,U,Sc,Fe,A,T,br,Bn,wr,L,wt,Me,be,pt,hr,Yn,Ko,_o,fe,Ut,ve,De,E,as,S,Ee,Ie,Te,ge,Ae,ye,W,Gt,n,Ei,iA,df,pA,mA,ff,hA,Ju,yA,_A,hm,gm,bA,wA,CA,EA,IA,TA,RA,kA,PA,NA,DA,LA,ZA,BA,UA,_m,FA,bm,zA,wm,jA,vm,qA,xm,HA,Sm,$A,Cm,GA,Em,QA,Im,VA,KA,WA,Tm,YA,JA,XA,Mm,Rm,km,Pm,ey,ty,iy,ly,cy,my,hy,gy,by,ed,td,Dm,wy,vy,Lm,xy,Sy,Zm,Cy,Ty,rd,Py,Ny,Oy,By,Gy,Qy,Vy,Ky,Um,Yy,Jy,Xy,e0,t0,r0,ke,o0,a0,i0,l0,u0,h0,g0,A0,y0,jm,b0,w0,E0,T0,Gm,kc,Z0,j0,q0,H0,G0,Q0,W0,J0,i_,l_,at,c_,u_,m_,h_,g_,__,vf,Jm,v_,fl,I_,T_,Sf,R_,k_,th,D_,rh,L_,Z_,Cf,F_,z_,$_,Ef,Q_,K_,nh,J_,X_,Ns,ls,db,pb,ah,Ii,cd,hb,gb,bb,ch,pl,vb,ud,uh,xb,Sb,Cb,Lb,Zb,Gb,Qb,gh,Vb,Kb,Yb,Jb,Ah,lw,cw,uw,dw,fw,mw,_h,gw,Aw,yw,xw,Sw,Cw,Ew,Iw,Tw,Ow,Zw,qw,Hw,$w,Gw,Ff,Qw,Vw,vh,Kw,Ww,Yw,Jw,Xw,xh,Sh,ev,tv,rv,nv,Ch,ov,Eh,sv,av,Ih,Lc,md,iv,lv,Th,cv,uv,dv,fv,pv,mv,hv,gv,Av,Mh,yv,_v,zf,jf,Cv,Ev,Iv,Rh,Tv,Mv,Rv,kv,Pv,hd,Nv,Uv,hl,Fv,jv,qv,Hv,$v,Gv,Xv,ex,ox,Lh,sx,Bh,Uh,Ad,dx,fx,px,Qf,Vf,Ax,yx,wx,Sx,Cx,zh,Ex,Tx,Gx,Qx,Vx,Kx,qh,Wx,Yx,Jx,eS,sS,aS,Mi,Ri,ki,iS,lS,cS,dS,mS,hS,AS,Wh,RS,kS,PS,NS,Jh,Xh,eg,tg,OS,rg,ng,og,sg,DS,LS,US,zS,lg,np,qS,$S,GS,VS,op,sp,ap,ip,JS,bd,wd,vd,xd,Sd,eC,tC,Cd,rC,Ed,nC,Id,oC,lp,wl,cp,sC,aC,dC,fC,Td,up,vl,gg,Ag,RC,kC,Oo,Ds,bg,gp,xg,Sg,WC,Cg,Eg,YC,eE,tE,Tg,nE,sE,_p,kg,wE,vE,Pg,xE,RE,kE,PE,NE,OE,DE,LE,ZE,BE,UE,FE,zE,jE,qE,HE,$E,GE,QE,VE,KE,tI,cI,uI,dI,fI,pI,bI,wI,vI,zg,xI,qg,SI,CI,II,$g,OI,zI,jI,qI,WI,YI,JI,XI,eT,tT,rT,nT,oT,Je,Xe,et,tt,rt,nt,ot,st,pe,ue,me,$e,de,Tt,H,ie,Pt,R,wo,vo,Vr,En,we,gt,At,yt,p,re,P,We,eo,Gc,Qc,Kg,Vc,Xa,Wg,da,Oi,Kc,pa,V,qe,Le,Ze,Be,Ue,ne,Nr,Lo,Ct,Nt,Ot,Ht,Rt}from"./chunk-7rhz2gze.js";import{Eo,pr}from"./chunk-gc5sbfa5.js";import{zl}from"./chunk-yfnem6se.js";import{Fs,no,li,Uo,fn,jl,ci,zi,Ca,ql}from"./chunk-dqxeztfa.js";import{Hl}from"./chunk-avwgktxb.js";import{Tn,Mn,Rn,_r,bt,mt}from"./chunk-xx337zcw.js";import{ui}from"./chunk-qka4mkmj.js";import{So}from"./chunk-5adsx8x4.js";import{Co}from"./chunk-j2bvj2yn.js";import{Hn,oo}from"./chunk-cbgq517y.js";import{pn}from"./chunk-gk2q9a3f.js";import{so}from"./chunk-9t8n2des.js";import{rn}from"./chunk-ytdwk2fq.js";import{ao}from"./chunk-rq0n0vcc.js";import{Rr}from"./chunk-0zv3bks2.js";var $s=[["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"}]],Ka=T("at-sign",$s);var zs=[["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"}]],Ua=T("film",zs);var Qs=[["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"}]],ca=T("globe",Qs);var Ks=[["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"}]],Zt=T("key",Ks);var Us=[["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"}]],ka=T("layout-dashboard",Us);var Gs=[["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"}]],Ga=T("maximize-2",Gs);var Hs=[["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"}]],Ha=T("message-circle",Hs);var Ws=[["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"}]],Wa=T("move",Ws);var Zs=[["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"}]],_t=T("puzzle",Zs);var Xs=[["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"}]],ma=T("refresh-cw",Xs);var Ys=[["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"}]],Za=T("shield-check",Ys);var Js=[["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"}]],ua=T("video",Js);var er=[["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"}]],Lt=T("zap",er);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"}]],Ya=T("zoom-in",tr);var ar=[["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"}]],Ja=T("zoom-out",ar);C();C();var sr=as("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 je({className:e,orientation:s="vertical",...a}){return t("div",{role:"group","data-slot":"field","data-orientation":s,className:E(sr({orientation:s}),e),...a})}function Oe({className:e,...s}){return t(V,{"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),...s})}function aa({className:e,...s}){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),...s})}function Qe({className:e,children:s,errors:a,...l}){let r=O(()=>{if(s)return s;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,f)=>c?.message&&t("li",{children:c.message},f))})},[s,a]);if(!r)return null;return t("div",{role:"alert","data-slot":"field-error",className:E("text-sm font-normal text-destructive",e),...l,children:r})}function es({update:e,notify:s,unwatched:a}){return{link:l,unlink:r,propagate:d,checkDirty:c,shallowPropagate:f};function l(g,b,y){let m=b.depsTail;if(m!==void 0&&m.dep===g)return;let i=m!==void 0?m.nextDep:b.deps;if(i!==void 0&&i.dep===g){i.version=y,b.depsTail=i;return}let v=g.subsTail;if(v!==void 0&&v.version===y&&v.sub===b)return;let x=b.depsTail=g.subsTail={version:y,dep:g,sub:b,prevDep:m,nextDep:i,prevSub:v,nextSub:void 0};if(i!==void 0)i.prevDep=x;if(m!==void 0)m.nextDep=x;else b.deps=x;if(v!==void 0)v.nextSub=x;else g.subs=x}function r(g,b=g.sub){let{dep:y,prevDep:m,nextDep:i,nextSub:v,prevSub:x}=g;if(i!==void 0)i.prevDep=m;else b.depsTail=m;if(m!==void 0)m.nextDep=i;else b.deps=i;if(v!==void 0)v.prevSub=x;else y.subsTail=x;if(x!==void 0)x.nextSub=v;else if((y.subs=v)===void 0)a(y);return i}function d(g){let b=g.nextSub,y;e:do{let m=g.sub,i=m.flags;if(!(i&60))m.flags=i|32;else if(!(i&12))i=0;else if(!(i&4))m.flags=i&-9|32;else if(!(i&48)&&_(g,m))m.flags=i|40,i&=1;else i=0;if(i&2)s(m);if(i&1){let v=m.subs;if(v!==void 0){let x=(g=v).nextSub;if(x!==void 0)y={value:b,prev:y},b=x;continue}}if((g=b)!==void 0){b=g.nextSub;continue}while(y!==void 0)if(g=y.value,y=y.prev,g!==void 0){b=g.nextSub;continue e}break}while(!0)}function c(g,b){let y,m=0,i=!1;e:do{let v=g.dep,x=v.flags;if(b.flags&16)i=!0;else if((x&17)===17){if(e(v)){let M=v.subs;if(M.nextSub!==void 0)f(M);i=!0}}else if((x&33)===33){if(g.nextSub!==void 0||g.prevSub!==void 0)y={value:g,prev:y};g=v.deps,b=v,++m;continue}if(!i){let M=g.nextDep;if(M!==void 0){g=M;continue}}while(m--){let M=b.subs,q=M.nextSub!==void 0;if(q)g=y.value,y=y.prev;else g=M;if(i){if(e(b)){if(q)f(M);b=g.sub;continue}i=!1}else b.flags&=-33;b=g.sub;let Y=g.nextDep;if(Y!==void 0){g=Y;continue e}}return i}while(!0)}function f(g){do{let b=g.sub,y=b.flags;if((y&48)===32){if(b.flags=y|16,(y&6)===2)s(b)}}while((g=g.nextSub)!==void 0)}function _(g,b){let y=b.depsTail;while(y!==void 0){if(y===g)return!0;y=y.prevDep}return!1}}function sa(e,s,a){let l=typeof e==="object",r=l?e:void 0;return{next:(l?e.next:e)?.bind(r),error:(l?e.error:s)?.bind(r),complete:(l?e.complete:a)?.bind(r)}}var Ma=[],ga=0,{link:ts,unlink:rr,propagate:or,checkDirty:rs,shallowPropagate:ss}=es({update(e){return e._update()},notify(e){Ma[Fa++]=e,e.flags&=-3},unwatched(e){if(e.depsTail!==void 0)e.depsTail=void 0,e.flags=17,ha(e)}}),fa=0,Fa=0,St,Da=0;function ze(e){try{++Da,e()}finally{if(!--Da)Aa()}}function ha(e){let s=e.depsTail,a=s!==void 0?s.nextDep:e.deps;while(a!==void 0)a=rr(a,e)}function Aa(){if(Da>0)return;while(fa<Fa){let e=Ma[fa];Ma[fa++]=void 0,e.notify()}fa=0,Fa=0}function va(e,s){let a=typeof e==="function",l=e,r={_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)ts(r,St,ga);return r._snapshot},subscribe(d){let c=sa(d),f={current:!1},_=ir(()=>{if(r.get(),!f.current)f.current=!0;else c.next?.(r._snapshot)});return{unsubscribe:()=>{_.stop()}}},_update(d){let c=St,f=s?.compare??Object.is;if(a)St=r,++ga,r.depsTail=void 0;else if(d===void 0)return!1;if(a)r.flags=5;try{let _=r._snapshot,g=typeof d==="function"?d(_):d===void 0&&a?l(_):d;if(_===void 0||!f(_,g))return r._snapshot=g,!0;return!1}finally{if(St=c,a)r.flags&=-5;ha(r)}}};if(a)r.flags=17,r.get=function(){let d=r.flags;if(d&16||d&32&&rs(r.deps,r)){if(r._update()){let c=r.subs;if(c!==void 0)ss(c)}}else if(d&32)r.flags=d&-33;if(St!==void 0)ts(r,St,ga);return r._snapshot};else r.set=function(d){if(r._update(d)){let c=r.subs;if(c!==void 0)or(c),ss(c),Aa()}};return r}function ir(e){let s=()=>{let l=St;St=a,++ga,a.depsTail=void 0,a.flags=6;try{return e()}finally{St=l,a.flags&=-5,ha(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&&rs(this.deps,this))s();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ha(this)}};return s(),a}var Ia=class{constructor(e,s){if(this.atom=va(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),s)this.actions=s(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))}},os=class{constructor(e){this.atom=va(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(sa(e))}};function kt(e,s){if(typeof e==="function")return new os(e);if(s)return new Ia(e,s);return new Ia(e)}var is=class{constructor(e,s){if(this.fn=e,this.options=s,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 r=this.options.wait-l;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},r)}},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 Ea(e,s){return new is(e,s).maybeExecute}var Ta=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:s=!1,enabled:a=!0,reconnectEveryMs:l=300}){this.#t=e,this.#o=a,this.#e=this.getGlobalTarget,this.#m=s,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,s){try{let a=new Event(e,{detail:s});this.#e().dispatchEvent(a)}catch(a){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,s){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:s}))}catch(a){this.dispatchCustomEventShim(e,s)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,s){return{type:`${this.#t}:${e}`,payload:s,pluginId:this.#t}}emit(e,s){if(!this.#o){this.debugLog("Event bus client is disabled, not emitting event",e,s);return}if(this.#r)this.debugLog("Emitting event to internal event target",e,s),this.#r.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,s)}));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,s)),typeof CustomEvent<"u"&&!this.#i)this.#g(),this.startConnectLoop();return}return this.emitEventToBus(this.createEventPayload(e,s))}on(e,s,a){let l=a?.withEventTarget??!1,r=`${this.#t}:${e}`;if(l){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(r,(c)=>{s(c.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",r),()=>{};let d=(c)=>{this.debugLog("Received event from bus",c.detail),s(c.detail)};return this.#e().addEventListener(r,d),this.debugLog("Registered event to bus",r),()=>{if(l)this.#r?.removeEventListener(r,d);this.#e().removeEventListener(r,d)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let s=(a)=>{let l=a.detail;e(l)};return this.#e().addEventListener("tanstack-devtools-global",s),()=>this.#e().removeEventListener("tanstack-devtools-global",s)}onAllPluginEvents(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let s=(a)=>{let l=a.detail;if(this.#t&&l.pluginId!==this.#t)return;e(l)};return this.#e().addEventListener("tanstack-devtools-global",s),()=>this.#e().removeEventListener("tanstack-devtools-global",s)}};class ns extends Ta{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var ut=new ns;function Mt(e,s){return typeof e==="function"?e(s):e}function Xt(e,s){return xa(s).reduce((l,r)=>{if(l===null)return null;if(typeof l<"u")return l[r];return},e)}function zt(e,s,a){let l=xa(s);function r(d){if(!l.length)return Mt(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]:r(d[c])}}return{[c]:r()}}if(Array.isArray(d)&&typeof c==="number"){let f=d.slice(0,c);return[...f.length?f:Array(c),r(d[c]),...d.slice(c+1)]}return[...Array(c),r()]}return r(e)}function Pa(e,s){let a=xa(s);function l(r){if(!r)return;if(a.length===1){let c=a[0];if(Array.isArray(r)&&typeof c==="number")return r.filter((g,b)=>b!==c);let{[c]:f,..._}=r;return _}let d=a.shift();if(typeof d==="string"||typeof d==="number"&&!Array.isArray(r)){if(typeof r==="object")return{...r,[d]:l(r[d])}}if(typeof d==="number"){if(Array.isArray(r)){if(d>=r.length)return r;let c=r.slice(0,d);return[...c.length?c:Array(d),l(r[d]),...r.slice(d+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return l(e)}var ds=46,Va=91,La=93,cs=48,nr=57;function xa(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let s=e.length,a=[],l=s>0&&e.charCodeAt(0)===Va?1:0,r=!0,d=-1;for(let c=l;c<=s;c++){let f=c<s?e.charCodeAt(c):-1;if(c===s||f===ds||f===Va||f===La){let _=c-l;if(_>0){let g=r&&(_===1||e.charCodeAt(l)!==cs),b=e.slice(l,c);if(g){let y=parseInt(b,10);if(_<=15||String(y)===b)a.push(y);else a.push(b)}else a.push(b)}else if(d!==La&&!(d===-1&&f===La)&&!(d===f&&(f===ds||f===Va)))a.push("");l=c+1,r=!0}else if(f<cs||f>nr)r=!1;d=f}if(!a.length)a.push("");return a}function Ba(e){return!(Array.isArray(e)&&e.length===0)}function Dt(e,s){let a=(l)=>l.validators.filter(Boolean).map((r)=>({cause:r.cause,validate:r.fn}));return s.validationLogic({form:s.form,group:s.group,validators:s.validators,event:{type:e,fieldName:s.fieldName,async:!1},runValidation:a})}function It(e,s){let{asyncDebounceMs:a}=s,{onBlurAsyncDebounceMs:l,onChangeAsyncDebounceMs:r,onDynamicAsyncDebounceMs:d}=s.validators||{},c=a??0,f=(_)=>_.validators.filter(Boolean).map((g)=>{let b=g?.cause||e,y=c;switch(b){case"change":y=r??c;break;case"blur":y=l??c;break;case"dynamic":y=d??c;break;case"submit":y=0;break}if(e==="submit")y=0;return{cause:b,validate:g.fn,debounceMs:y}});return s.validationLogic({form:s.form,group:s.group,validators:s.validators,event:{type:e,fieldName:s.fieldName,async:!0},runValidation:f})}var Yt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function ft(e,s){if(Object.is(e,s))return!0;if(typeof e!=="object"||e===null||typeof s!=="object"||s===null)return!1;if(e instanceof Date&&s instanceof Date)return e.getTime()===s.getTime();if(e instanceof Map&&s instanceof Map){if(e.size!==s.size)return!1;for(let[r,d]of e)if(!s.has(r)||!Object.is(d,s.get(r)))return!1;return!0}if(e instanceof Set&&s instanceof Set){if(e.size!==s.size)return!1;for(let r of e)if(!s.has(r))return!1;return!0}let a=Object.keys(e),l=Object.keys(s);if(a.length!==l.length)return!1;if(a.length===0&&!Array.isArray(e)&&!Array.isArray(s)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(s)!==Object.prototype))return!1;for(let r of a)if(!l.includes(r)||!ft(e[r],s[r]))return!1;return!0}var Jt=({newFormValidatorError:e,isPreviousErrorFromFormValidator:s,previousErrorValue:a})=>{if(e)return{newErrorValue:e,newSource:"form"};if(s)return{newErrorValue:void 0,newSource:void 0};if(a)return{newErrorValue:a,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Qt=({formLevelError:e,fieldLevelError:s})=>{if(s)return{newErrorValue:s,newSource:"field"};if(e)return{newErrorValue:e,newSource:"form"};return{newErrorValue:void 0,newSource:void 0}};function Ke(e,s){if(e===void 0||e===null)return s;return{...e,...s}}var jt=256,ya=[],ba;while(jt--)ya[jt]=(jt+256).toString(16).substring(1);function ra(){let e=0,s,a="";if(!ba||jt+16>256){ba=Array(256),e=256;while(e--)ba[e]=256*Math.random()|0;e=0,jt=0}for(;e<16;e++){if(s=ba[jt+e],e===6)a+=ya[s&15|64];else if(e===8)a+=ya[s&63|128];else a+=ya[s];if(e&1&&e>1&&e<11)a+="-"}return jt++,a}var Ra=Ea((e)=>ut.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function $t(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]=$t(e[l]);return a}if(e instanceof Map){let a=new Map;return e.forEach((l,r)=>{a.set(r,$t(l))}),a}if(e instanceof Set){let a=new Set;return e.forEach((l)=>{a.add($t(l))}),a}let s={};for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a))s[a]=$t(e[a]);return s}function vt(e,s){return s===e||s.startsWith(`${e}.`)||s.startsWith(`${e}[`)}var ht=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let s=e.event.async,a=s?void 0:{fn:e.validators.onMount,cause:"mount"},l={fn:s?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},r={fn:s?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},d={fn:s?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},c=s?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,r,d,c],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[r,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 lr(e,s){let a=new Map;for(let l of e){let r=l.path??[],d=s,c="";for(let f=0;f<r.length;f++){let _=r[f];if(_===void 0)continue;let g=typeof _==="object"?_.key:_,b=Number(g);if(Array.isArray(d)&&!Number.isNaN(b))c+=`[${b}]`;else c+=(f>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 ms=(e,s)=>{let a=lr(e,s);return{form:a,fields:a}},Ft={validate({value:e,validationSource:s},a){let l=a["~standard"].validate(e);if(l instanceof Promise)throw Error("async function passed to sync validator");if(!l.issues)return;if(s==="field")return l.issues;return ms(l.issues,e)},async validateAsync({value:e,validationSource:s},a){let l=await a["~standard"].validate(e);if(!l.issues)return;if(s==="field")return l.issues;return ms(l.issues,e)}},ea=(e)=>!!e&&("~standard"in e);var He={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Et(e){function s(y){let m=e.getFieldMeta(y)??He;e.setFieldMeta(y,{...m,_arrayVersion:(m._arrayVersion||0)+1})}function a(y,m,i){s(y);let v=f(y,m,"move",i),x=Math.min(m,i),M=Math.max(m,i);for(let Y=x;Y<=M;Y++)v.push(c(y,Y));let q=Object.keys(e.fieldInfo).reduce((Y,j)=>{if(j.startsWith(c(y,m)))Y.set(j,e.getFieldMeta(j));return Y},new Map);g(v,m<i?"up":"down"),Object.keys(e.fieldInfo).filter((Y)=>Y.startsWith(c(y,i))).forEach((Y)=>{let j=Y.replace(c(y,i),c(y,m)),oe=q.get(j);if(oe)e.setFieldMeta(Y,oe)})}function l(y,m){s(y);let i=f(y,m,"remove");g(i,"up")}function r(y,m,i){s(y),f(y,m,"swap",i).forEach((x)=>{if(!x.toString().startsWith(c(y,m)))return;let M=x.toString().replace(c(y,m),c(y,i)),[q,Y]=[e.getFieldMeta(x),e.getFieldMeta(M)];if(q)e.setFieldMeta(M,q);if(Y)e.setFieldMeta(x,Y)})}function d(y,m){s(y);let i=f(y,m,"insert");g(i,"down"),i.forEach((v)=>{if(v.toString().startsWith(c(y,m)))e.setFieldMeta(v,b())})}function c(y,m){return`${y}[${m}]`}function f(y,m,i,v){let x=[c(y,m)];switch(i){case"swap":x.push(c(y,v));break;case"move":{let[M,q]=[Math.min(m,v),Math.max(m,v)];for(let Y=M;Y<=q;Y++)x.push(c(y,Y));break}default:{let M=e.getFieldValue(y),q=Array.isArray(M)?M.length:0;for(let Y=m+1;Y<q;Y++)x.push(c(y,Y));break}}return Object.keys(e.fieldInfo).filter((M)=>x.some((q)=>M.startsWith(q)))}function _(y,m){return y.replace(/\[(\d+)\]/,(i,v)=>{let x=parseInt(v,10);return`[${m==="up"?x+1:Math.max(0,x-1)}]`})}function g(y,m){(m==="up"?y:[...y].reverse()).forEach((v)=>{let x=_(v.toString(),m),M=e.getFieldMeta(x);if(M)e.setFieldMeta(v,M);else e.setFieldMeta(v,b())})}let b=()=>He;return{bumpArrayVersion:s,handleArrayMove:a,handleArrayRemove:l,handleArraySwap:r,handleArrayInsert:d}}function qa(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 ia{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let r=this.store.subscribe(()=>{Ra(this)}),d=ut.on("request-form-state",(b)=>{if(b.payload.id===this._formId)ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),c=ut.on("request-form-reset",(b)=>{if(b.payload.id===this._formId)this.reset()}),f=ut.on("request-form-force-submit",(b)=>{if(b.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),_=()=>{f(),c(),d(),r.unsubscribe(),ut.emit("form-unmounted",{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:g}=this.options.validators||{};if(ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options}),!g)return _;return this.validateSync("mount"),_},this.update=(r)=>{if(!r)return;let d=this.options;this.options=r;let c=r.defaultValues&&!ft(r.defaultValues,d.defaultValues)&&!this.state.isTouched,f=!ft(r.defaultState,d.defaultState)&&!this.state.isTouched;if(!c&&!f)return;if(ze(()=>{this.baseStore.setState(()=>qa(Object.assign({},this.state,f?r.defaultState:{},c?{values:r.defaultValues}:{})))}),c){let _=Et(this);for(let g of Object.keys(this.fieldInfo))if(Array.isArray(this.getFieldValue(g)))_.bumpArrayVersion(g)}ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})},this.reset=(r,d)=>{let{fieldMeta:c}=this.state,f=this.resetFieldMeta(c);if(r&&!d?.keepDefaultValues)this.options={...this.options,defaultValues:r};this.baseStore.setState(()=>{let _=r??this.options.defaultValues??this.options.defaultState?.values;if(!r)Object.values(this.fieldInfo).forEach((g)=>{if(g.instance&&g.instance.options.defaultValue!==void 0)_=zt(_,g.instance.name,g.instance.options.defaultValue)});return qa({...this.options.defaultState,values:_,fieldMetaBase:f})})},this.validateAllFields=async(r)=>{let d=[];return ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;let _=f.instance;if(d.push(Promise.resolve().then(()=>_.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!f.instance.store.state.meta.isTouched)f.instance.setMeta((g)=>({...g,isTouched:!0}))})}),(await Promise.all(d)).flat()},this.validateArrayFieldsStartingFrom=async(r,d,c)=>{let f=this.getFieldValue(r),_=Array.isArray(f)?Math.max(f.length-1,0):null,g=[`${r}[${d}]`];for(let i=d+1;i<=(_??0);i++)g.push(`${r}[${i}]`);let b=Object.keys(this.fieldInfo).filter((i)=>g.some((v)=>i.startsWith(v))),y=[];return ze(()=>{b.forEach((i)=>{y.push(Promise.resolve().then(()=>this.validateField(i,c)))})}),(await Promise.all(y)).flat()},this.validateField=(r,d)=>{let c=this.fieldInfo[r]?.instance;if(!c){let{hasErrored:f}=this.validateSync(d);if(f&&!this.options.asyncAlways)return this.getFieldMeta(r)?.errors??[];return this.validateAsync(d).then(()=>this.getFieldMeta(r)?.errors??[])}if(!c.store.state.meta.isTouched)c.setMeta((f)=>({...f,isTouched:!0}));return c.validate(d)},this.validateSync=(r,d)=>{let c=Dt(r,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ht}),f=!1,_={};return ze(()=>{for(let y of c){if(!y.validate)continue;let m=this.runValidator({validate:y.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:i,fieldErrors:v}=_a(m),x=oa(y.cause),M=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(v||{})]);if(d?.filterFieldNames)M=new Set([...M].filter(d.filterFieldNames));for(let q of M){if(this.baseStore.state.fieldMetaBase[q]===void 0&&!v?.[q])continue;let Y=this.getFieldMeta(q)??He,{errorMap:j,errorSourceMap:oe}=Y,se=v?.[q],{newErrorValue:F,newSource:D}=Jt({newFormValidatorError:se,isPreviousErrorFromFormValidator:oe?.[x]==="form",previousErrorValue:j?.[x]});if(D==="form")_[q]={..._[q],[x]:se};if(j?.[x]!==F)this.setFieldMeta(q,(I=He)=>({...I,errorMap:{...I.errorMap,[x]:F},errorSourceMap:{...I.errorSourceMap,[x]:D}}))}if(!d?.dontUpdateFormErrorMap){if(this.state.errorMap?.[x]!==i)this.baseStore.setState((q)=>({...q,errorMap:{...q.errorMap,[x]:i}}))}if(i||v)f=!0}if(d?.dontUpdateFormErrorMap)return;let g=oa("submit");if(this.state.errorMap?.[g]&&r!=="submit"&&!f)this.baseStore.setState((y)=>({...y,errorMap:{...y.errorMap,[g]:void 0}}));let b=oa("server");if(this.state.errorMap?.[b]&&r!=="server"&&!f)this.baseStore.setState((y)=>({...y,errorMap:{...y.errorMap,[b]:void 0}}))}),{hasErrored:f,fieldsErrorMap:_}},this.validateAsync=async(r,d)=>{let c=It(r,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ht});if(!this.state.isFormValidating)this.baseStore.setState((y)=>({...y,isFormValidating:!0}));let f=[],_;for(let y of c){if(!y.validate)continue;let m=oa(y.cause);this.state.validationMetaMap[m]?.lastAbortController.abort();let v=new AbortController;this.state.validationMetaMap[m]={lastAbortController:v},f.push(new Promise(async(x)=>{let M;try{M=await new Promise((F,D)=>{setTimeout(async()=>{if(v.signal.aborted)return F(void 0);try{F(await this.runValidator({validate:y.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:v.signal},type:"validateAsync"}))}catch(I){D(I)}},y.debounceMs)})}catch(F){M=F}let{formError:q,fieldErrors:Y}=_a(M);if(Y)_=_?{..._,...Y}:Y;let j=oa(y.cause),oe=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(_||{})]),se=Array.from(oe);if(d?.filterFieldNames)se=se.filter(d.filterFieldNames);for(let F of se){if(this.baseStore.state.fieldMetaBase[F]===void 0&&!_?.[F])continue;let D=this.getFieldMeta(F)??He,{errorMap:I,errorSourceMap:G}=D,k=_?.[F],{newErrorValue:X,newSource:xe}=Jt({newFormValidatorError:k,isPreviousErrorFromFormValidator:G?.[j]==="form",previousErrorValue:I?.[j]});if(I?.[j]!==X)this.setFieldMeta(F,(he=He)=>({...he,errorMap:{...he.errorMap,[j]:X},errorSourceMap:{...he.errorSourceMap,[j]:xe}}))}if(!d?.dontUpdateFormErrorMap)this.baseStore.setState((F)=>({...F,errorMap:{...F.errorMap,[j]:q}}));x(_?{fieldErrors:_,errorMapKey:j}:void 0)}))}let g=[],b={};if(f.length){g=await Promise.all(f);for(let y of g)if(y?.fieldErrors){let{errorMapKey:m}=y;for(let[i,v]of Object.entries(y.fieldErrors)){let M={...b[i]||{},[m]:v};b[i]=M}}}return this.baseStore.setState((y)=>({...y,isFormValidating:!1})),b},this.validate=(r,d)=>{let{hasErrored:c,fieldsErrorMap:f}=this.validateSync(r,d);if(c&&!this.options.asyncAlways)return f;return this.validateAsync(r,d)},this._handleSubmit=async(r)=>{this.baseStore.setState((f)=>({...f,isSubmitted:!1,submissionAttempts:f.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;if(!f.instance.store.state.meta.isTouched)f.instance.setMeta((_)=>({..._,isTouched:!0}))})});let d=r??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((f)=>({...f,isSubmitting:!0}));let c=()=>{this.baseStore.setState((f)=>({...f,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.state.isFieldsValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validateAllFields",errors:Object.values(this.state.fieldMeta).map((f)=>f.errors).flat()});return}if(await this.validate("submit"),!this.state.isValid){c(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d}),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"validate",errors:this.state.errors});return}ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{f.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:d});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:d}),ze(()=>{this.baseStore.setState((f)=>({...f,isSubmitted:!0,isSubmitSuccessful:!0})),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),c()})}catch(f){throw this.baseStore.setState((_)=>({..._,isSubmitSuccessful:!1})),ut.emit("form-submission",{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:"inflight",onError:f}),c(),f}},this.getFieldValue=(r)=>Xt(this.state.values,r),this.getFieldMeta=(r)=>this.state.fieldMeta[r],this.getFormGroupMeta=(r)=>this.formGroupMetaDerived.state[r],this.getFieldInfo=(r)=>this.fieldInfo[r]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(r,d)=>{this.baseStore.setState((c)=>({...c,fieldMetaBase:{...c.fieldMetaBase,[r]:Mt(d,c.fieldMetaBase[r])}}))},this.resetFieldMeta=(r)=>Object.keys(r).reduce((d,c)=>{let f=c;return d[f]=He,d},{}),this.setFieldValue=(r,d,c)=>{let f=c?.dontUpdateMeta??!1,_=c?.dontRunListeners??!1,g=c?.dontValidate??!1;if(ze(()=>{if(!f)this.setFieldMeta(r,(b)=>({...b,isTouched:!0,isDirty:!0,errorMap:{...b?.errorMap,onMount:void 0}}));this.baseStore.setState((b)=>({...b,values:zt(b.values,r,d)}))}),!_)this.getFieldInfo(r).instance?.triggerOnChangeListener();if(!g)this.validateField(r,"change")},this.deleteField=(r)=>{let c=[...Object.keys(this.fieldInfo).filter((f)=>{let _=r.toString();return f.startsWith(`${_}.`)||f.startsWith(`${_}[`)}),r];this.baseStore.setState((f)=>{let _={...f};return c.forEach((g)=>{_.values=Pa(_.values,g),delete this.fieldInfo[g],delete _.fieldMetaBase[g]}),_})},this.pushFieldValue=(r,d,c)=>{this.setFieldValue(r,(f)=>[...Array.isArray(f)?f:[],d],c),Et(this).bumpArrayVersion(r)},this.insertFieldValue=async(r,d,c,f)=>{this.setFieldValue(r,(g)=>[...g.slice(0,d),c,...g.slice(d)],Ke(f,{dontValidate:!0}));let _=f?.dontValidate??!1;if(!_)await this.validateField(r,"change");if(Et(this).handleArrayInsert(r,d),!_)await this.validateArrayFieldsStartingFrom(r,d,"change")},this.replaceFieldValue=async(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>g.map((b,y)=>y===d?c:b),Ke(f,{dontValidate:!0})),Et(this).bumpArrayVersion(r),!(f?.dontValidate??!1))await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,d,"change")},this.removeFieldValue=async(r,d,c)=>{let f=this.getFieldValue(r),_=Array.isArray(f)?Math.max(f.length-1,0):null;if(this.setFieldValue(r,(b)=>b.filter((y,m)=>m!==d),Ke(c,{dontValidate:!0})),Et(this).handleArrayRemove(r,d),_!==null){let b=`${r}[${_}]`;this.deleteField(b)}if(!(c?.dontValidate??!1))await this.validateField(r,"change"),await this.validateArrayFieldsStartingFrom(r,d,"change")},this.swapFieldValues=(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>{let b=g[d],y=g[c];return zt(zt(g,`${d}`,y),`${c}`,b)},Ke(f,{dontValidate:!0})),Et(this).handleArraySwap(r,d,c),!(f?.dontValidate??!1))this.validateField(r,"change"),this.validateField(`${r}[${d}]`,"change"),this.validateField(`${r}[${c}]`,"change")},this.moveFieldValues=(r,d,c,f)=>{if(this.setFieldValue(r,(g)=>{let b=[...g];return b.splice(c,0,b.splice(d,1)[0]),b},Ke(f,{dontValidate:!0})),Et(this).handleArrayMove(r,d,c),!(f?.dontValidate??!1))this.validateField(r,"change"),this.validateField(`${r}[${d}]`,"change"),this.validateField(`${r}[${c}]`,"change")},this.clearFieldValues=(r,d)=>{let c=this.getFieldValue(r),f=Array.isArray(c)?Math.max(c.length-1,0):null;if(this.setFieldValue(r,[],Ke(d,{dontValidate:!0})),Et(this).bumpArrayVersion(r),f!==null)for(let g=0;g<=f;g++){let b=`${r}[${g}]`;this.deleteField(b)}if(!(d?.dontValidate??!1))this.validateField(r,"change")},this.resetField=(r)=>{this.baseStore.setState((d)=>{let c=this.getFieldInfo(r).instance?.options.defaultValue,f=Xt(this.options.defaultValues,r),_=c??f;return{...d,fieldMetaBase:{...d.fieldMetaBase,[r]:He},values:_!==void 0?zt(d.values,r,_):d.values}})},this.setErrorMap=(r)=>{ze(()=>{Object.entries(r).forEach(([d,c])=>{let f=d;if(Yt(c)){let{formError:_,fieldErrors:g}=_a(c);for(let b of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(b))continue;this.setFieldMeta(b,(m)=>({...m,errorMap:{...m.errorMap,[f]:g?.[b]},errorSourceMap:{...m.errorSourceMap,[f]:"form"}}))}this.baseStore.setState((b)=>({...b,errorMap:{...b.errorMap,[f]:_}}))}else this.baseStore.setState((_)=>({..._,errorMap:{..._.errorMap,[f]:c}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((r,[d,c])=>{if(Object.keys(c).length&&c.errors.length)r[d]={errors:c.errors,errorMap:c.errorMap};return r},{})}),this.parseValuesWithSchema=(r)=>Ft.validate({value:this.state.values,validationSource:"form"},r),this.parseValuesWithSchemaAsync=(r)=>Ft.validateAsync({value:this.state.values,validationSource:"form"},r),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??ra(),this._devtoolsSubmissionOverride=!1;let s=qa({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){s=e.transform({state:s}).state;for(let r of Object.keys(s.errorMap)){let d=s.errorMap[r];if(d===void 0||!Yt(d))continue;for(let c of Object.keys(d.fields)){let f=d.fields[c];if(f===void 0)continue;let _=s.fieldMetaBase[c];s.fieldMetaBase[c]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,..._??{},errorSourceMap:{..._?.errorSourceMap??{},onChange:"form"},errorMap:{..._?.errorMap??{},[r]:f}}}}}this.baseStore=kt(s);let a=void 0;this.fieldMetaDerived=kt((r)=>{let d=this.baseStore.get(),c=0,f={};for(let _ of Object.keys(d.fieldMetaBase)){let g=d.fieldMetaBase[_],b=a?.fieldMetaBase[_],y=r?.[_],m=Xt(d.values,_),i=y?.errors;if(!b||g.errorMap!==b.errorMap){i=Object.values(g.errorMap??{}).filter((Y)=>Y!==void 0);let q=this.getFieldInfo(_)?.instance;if(!q||!q.options.disableErrorFlat)i=i.flat(1)}let v=!Ba(i),x=!g.isDirty,M=ft(m,this.getFieldInfo(_)?.instance?.options.defaultValue??Xt(this.options.defaultValues,_));if(y&&y.isPristine===x&&y.isValid===v&&y.isDefaultValue===M&&y.errors===i&&g===b){f[_]=y,c++;continue}f[_]={...g,errors:i??[],isPristine:x,isValid:v,isDefaultValue:M}}if(!Object.keys(d.fieldMetaBase).length)return f;if(r&&c===Object.keys(d.fieldMetaBase).length)return r;return a=this.baseStore.get(),f}),this.formGroupMetaDerived=kt((r)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f={};for(let _ of this.formGroupApis){let g=_.name,b=d.formGroupStateBase[g]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},y=c[g],m=!1,i=!0,v=!1,x=!1,M=!0,q=!1;for(let Ce in c){if(Ce===g)continue;if(!vt(g,Ce))continue;let Se=c[Ce];if(!Se)continue;if(Se.isValidating)m=!0;if(!Se.isValid)i=!1;if(Se.isTouched)v=!0;if(Se.isBlurred)x=!0;if(!Se.isDefaultValue)M=!1;if(Se.isDirty)q=!0}let Y=!q,j=!!m||b.isValidating,oe=y?.errorMap??{},se=y?.errorSourceMap??{},F=Boolean(oe.onMount||Object.entries(c).some(([Ce,Se])=>Se&&Ce!==g&&vt(g,Ce)&&Se.errorMap.onMount)),D=r?.[g],I=D?.errors??[];if(!D||D.__srcErrorMap!==oe)I=Object.values(oe).reduce((Ce,Se)=>{if(Se===void 0)return Ce;if(Se&&typeof Se==="object"&&"fields"in Se){let ee=Se.group;if(ee!==void 0)Ce.push(ee);return Ce}return Ce.push(Se),Ce},[]);let G=I.length===0,k=i&&G,X=_.options.canSubmitWhenInvalid??!1,xe=b.submissionAttempts===0&&!v&&!F||!j&&!b.isSubmitting&&k||X;if(D&&D.errorMap===oe&&D.errorSourceMap===se&&D.errors===I&&D.isFieldsValidating===m&&D.isFieldsValid===i&&D.isGroupValid===G&&D.isValid===k&&D.canSubmit===xe&&D.isTouched===v&&D.isBlurred===x&&D.isPristine===Y&&D.isDefaultValue===M&&D.isDirty===q&&D.isValidating===j&&D.isSubmitting===b.isSubmitting&&D.isSubmitted===b.isSubmitted&&D.submissionAttempts===b.submissionAttempts&&D.isSubmitSuccessful===b.isSubmitSuccessful){f[g]=D;continue}let he={...b,errorMap:oe,errorSourceMap:se,_arrayVersion:y?._arrayVersion??0,isTouched:v,isBlurred:x,isDirty:q,isPristine:Y,isDefaultValue:M,isValid:k,errors:I,isValidating:j,isFieldsValidating:m,isFieldsValid:i,isGroupValid:G,canSubmit:xe};Object.defineProperty(he,"__srcErrorMap",{value:oe,enumerable:!1,configurable:!0}),f[g]=he}return f});let l=void 0;this.store=kt((r)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f=Object.values(c).filter(Boolean),_=f.some((G)=>G.isValidating),g=f.every((G)=>G.isValid),b=f.some((G)=>G.isTouched),y=f.some((G)=>G.isBlurred),m=f.every((G)=>G.isDefaultValue),i=b&&d.errorMap?.onMount,v=f.some((G)=>G.isDirty),x=!v,M=Boolean(d.errorMap?.onMount||f.some((G)=>G?.errorMap?.onMount)),q=!!_,Y=r?.errors??[];if(!l||d.errorMap!==l.errorMap)Y=Object.values(d.errorMap).reduce((G,k)=>{if(k===void 0)return G;if(k&&Yt(k))return G.push(k.form),G;return G.push(k),G},[]);let j=Y.length===0,oe=g&&j,se=this.options.canSubmitWhenInvalid??!1,F=d.submissionAttempts===0&&!b&&!M||!q&&!d.isSubmitting&&oe||se,D=d.errorMap;if(i)Y=Y.filter((G)=>G!==d.errorMap.onMount),D=Object.assign(D,{onMount:void 0});if(r&&l&&r.errorMap===D&&r.fieldMeta===this.fieldMetaDerived.state&&r.errors===Y&&r.isFieldsValidating===_&&r.isFieldsValid===g&&r.isFormValid===j&&r.isValid===oe&&r.canSubmit===F&&r.isTouched===b&&r.isBlurred===y&&r.isPristine===x&&r.isDefaultValue===m&&r.isDirty===v&&ft(l,d))return r;let I={...d,errorMap:D,fieldMeta:this.fieldMetaDerived.state,errors:Y,isFieldsValidating:_,isFieldsValid:g,isFormValid:j,isValid:oe,canSubmit:F,isTouched:b,isBlurred:y,isPristine:x,isDefaultValue:m,isDirty:v};return l=this.baseStore.get(),I}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){if(ea(e.validate))return Ft[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function _a(e){if(e){if(Yt(e)){let s=_a(e.form).formError,a=e.fields;return{formError:s,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 Bt{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 s=this.getInfo();s.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((r)=>({...r,errorMap:{...r?.errorMap,onMount:l},errorSourceMap:{...r?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[r,d]of Object.entries(this.timeoutIds.validations))if(d)clearTimeout(d),this.timeoutIds.validations[r]=null;for(let[r,d]of Object.entries(this.timeoutIds.listeners))if(d)clearTimeout(d),this.timeoutIds.listeners[r]=null;for(let[r,d]of Object.entries(this.timeoutIds.formListeners))if(d)clearTimeout(d),this.timeoutIds.formListeners[r]=null;let l=this.form.fieldInfo[this.name];if(!l)return;if(l.instance!==this)return;for(let[r,d]of Object.entries(l.validationMetaMap))d?.lastAbortController.abort(),l.validationMetaMap[r]=void 0;this.form.baseStore.setState((r)=>({...r,fieldMetaBase:{...r.fieldMetaBase,[this.name]:{...He,isTouched:r.fieldMetaBase[this.name]?.isTouched??He.isTouched,isBlurred:r.fieldMetaBase[this.name]?.isBlurred??He.isBlurred,isDirty:r.fieldMetaBase[this.name]?.isDirty??He.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=(s)=>{if(this.options=s,this.name=s.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!ft(a,s.defaultValue))this.form.setFieldValue(this.name,s.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=(s,a)=>{if(this.form.setFieldValue(this.name,s,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(s)=>this.form.setFieldMeta(this.name,s),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(s,a)=>{if(this.form.pushFieldValue(this.name,s,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(s,a,l)=>{if(this.form.insertFieldValue(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(s,a,l)=>{if(this.form.replaceFieldValue(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(s,a)=>{if(this.form.removeFieldValue(this.name,s,Ke(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(s,a,l)=>{if(this.form.swapFieldValues(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(s,a,l)=>{if(this.form.moveFieldValues(this.name,s,a,Ke(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(s)=>{if(this.form.clearFieldValues(this.name,Ke(s,{dontRunListeners:!0})),!s?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(s)=>{let a=Object.values(this.form.fieldInfo),l=[];for(let r of a){if(!r.instance)continue;if(!(r.instance instanceof Bt))continue;let{onChangeListenTo:d,onBlurListenTo:c}=r.instance.options.validators||{};if(s==="change"&&d?.includes(this.name))l.push(r.instance);if(s==="blur"&&c?.includes(this.name))l.push(r.instance)}return l},this.validateSync=(s,a)=>{let l=Dt(s,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ht}),d=this.getLinkedFields(s).reduce((_,g)=>{let b=Dt(s,{...g.options,form:g.form,fieldName:g.name,validationLogic:g.form.options.validationLogic||ht});return b.forEach((y)=>{y.field=g}),_.concat(b)},[]),c=!1;ze(()=>{let _=(g,b)=>{let y=na(b.cause),m=b.validate?us(g.runValidator({validate:b.validate,value:{value:g.store.state.value,validationSource:"field",fieldApi:g},type:"validate"})):void 0,i=a[y],{newErrorValue:v,newSource:x}=Qt({formLevelError:i,fieldLevelError:m});if(g.state.meta.errorMap?.[y]!==v)g.setMeta((M)=>({...M,errorMap:{...M.errorMap,[y]:v},errorSourceMap:{...M.errorSourceMap,[y]:x}}));if(v)c=!0};for(let g of l)_(this,g);for(let g of d){if(!g.validate)continue;_(g.field,g)}});let f=na("submit");if(this.state.meta.errorMap?.[f]&&s!=="submit"&&!c)this.setMeta((_)=>({..._,errorMap:{..._.errorMap,[f]:void 0},errorSourceMap:{..._.errorSourceMap,[f]:void 0}}));return{hasErrored:c}},this.validateAsync=async(s,a)=>{let l=It(s,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ht}),r=await a,c=this.getLinkedFields(s).reduce((i,v)=>{let x=It(s,{...v.options,form:v.form,fieldName:v.name,validationLogic:v.form.options.validationLogic||ht});return x.forEach((M)=>{M.field=v}),i.concat(x)},[]),f=[],_=[],g=l.some((i)=>i.validate),b=Array.from(new Set(c.filter((i)=>i.validate).map((i)=>i.field)));ze(()=>{if(g)this.startValidation();for(let i of b)i.startValidation()});let y=(i,v,x)=>{let M=na(v.cause),q=i.getInfo();q.validationMetaMap[M]?.lastAbortController.abort();let j=new AbortController;q.validationMetaMap[M]={lastAbortController:j},x.push(new Promise(async(oe)=>{let se;try{se=await new Promise((k,X)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]),i.endValidation();i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(j.signal.aborted)return k(void 0);try{k(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,fieldApi:i,signal:j.signal,validationSource:"field"},type:"validateAsync"}))}catch(xe){X(xe)}},v.debounceMs)})}catch(k){se=k}if(j.signal.aborted)return oe(void 0);let F=us(se),D=r[i.name]?.[M],{newErrorValue:I,newSource:G}=Qt({formLevelError:D,fieldLevelError:F});if(i.getInfo().instance!==i)return oe(void 0);i.setMeta((k)=>({...k,errorMap:{...k?.errorMap,[M]:I},errorSourceMap:{...k.errorSourceMap,[M]:G}})),oe(I)}))};for(let i of l){if(!i.validate)continue;y(this,i,f)}for(let i of c){if(!i.validate)continue;y(i.field,i,_)}let m=[];if(f.length||_.length)m=await Promise.all(f),await Promise.all(_);return ze(()=>{if(g)this.endValidation();for(let i of b)i.endValidation()}),m.filter(Boolean)},this.validate=(s,a)=>{if(!this.state.meta.isTouched)return[];let l=a?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((y)=>this.name.startsWith(y.name)),d=((a?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(s)).fieldsErrorMap[this.name]??{};if(!a?.skipFormValidation)for(let y of l){if(y.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:m}=this.form.validateSync(s,{group:y,dontUpdateFormErrorMap:!0,filterFieldNames:(i)=>vt(y.name,i)});d={...d,...m[this.name]??{}}}let{hasErrored:c}=this.validateSync(s,d),f=new WeakMap;for(let y of l){let{hasErrored:m}=y.validateSync(s,{},{skipRelatedFieldValidation:!0});f.set(y,m)}if(c&&!this.options.asyncAlways){this.getInfo().validationMetaMap[na(s)]?.lastAbortController.abort();let y=[];for(let m of l)m.getInfo().validationMetaMap[na(s)]?.lastAbortController.abort(),y.push(m.state.meta.errors);return[...this.state.meta.errors,...y.flat()]}let _=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(s),g=this.validateAsync(s,_),b=[];for(let y of l){if(f.get(y)&&!y.options.asyncAlways)continue;b.push(y.validateAsync(s,_,{skipRelatedFieldValidation:!0}))}if(b.length===0)return g;return Promise.all([g,...b]).then((y)=>y.flat())},this.handleChange=(s)=>{this.setValue(s)},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=(s)=>{this.setMeta((a)=>({...a,errorMap:{...a.errorMap,...s}}))},this.parseValueWithSchema=(s)=>Ft.validate({value:this.state.value,validationSource:"field"},s),this.parseValueWithSchemaAsync=(s)=>Ft.validateAsync({value:this.state.value,validationSource:"field"},s),this.triggerOnBlurListener=()=>{let s=this.form.options.listeners?.onBlurDebounceMs;if(s&&s>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})},s)}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 s=this.form.options.listeners?.onChangeDebounceMs;if(s&&s>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})},s)}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(vt(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=kt((s)=>{this.form.store.get();let a=this.form.getFieldMeta(this.name)??{...He,...e.defaultMeta},l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!ft(l,this.options.defaultValue))l=this.options.defaultValue;if(s&&s.value===l&&s.meta===a)return s;return{value:l,meta:a}})}get state(){return this.store.state}runValidator(e){if(ea(e.validate))return Ft[e.type](e.value,e.validate);return e.validate(e.value)}startValidation(){this.setMeta((e)=>{let s=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:s,isValidating:s>0&&!e.isValidating?!0:e.isValidating}})}endValidation(){this.setMeta((e)=>{let s=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:s,isValidating:s===0&&e.isValidating?!1:e.isValidating}})}}function us(e){if(e)return e;return}function na(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 ja(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function fs(e){return{...He,...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 Kt{constructor(e){this.options={},this.setFormGroupState=(s)=>{this.form.baseStore.setState((a)=>{let l=a.formGroupStateBase[this.name]??ja({});return{...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:s(l)}}})},this._lastDistributedFieldNames={},this.update=(s)=>{if(this.options=s,this.name=s.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!ft(a,s.defaultValue))this.form.setFieldValue(this.name,s.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,{...He,...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]??ja({...this.options.defaultState})}}));let{onMount:s}=this.options.validators||{};if(s){let a=this.runValidator({validate:s,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),l=a,r=void 0;if($a(a))l=a.group,r=a.fields;let d=Oa(l);if(d)this.setMeta((c)=>({...c,errorMap:{...c.errorMap,onMount:d},errorSourceMap:{...c.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",r)}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]:ja({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(s,a)=>{if(this.form.setFieldValue(this.name,s,Ke(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(s)=>this.form.setFieldMeta(this.name,s),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let s=Object.values(this.form.fieldInfo),a=[];for(let l of s){if(!l.instance)continue;if(!(l.instance instanceof Bt))continue;if(l.instance.name.startsWith(this.name))a.push(l.instance)}return a},this.getRelatedFieldMetasDerived=()=>{let s=Object.entries(this.form.fieldMetaDerived.state),a=[];for(let[l,r]of s){if(l===this.name)continue;if(vt(this.name,l))a.push({...r,name:l})}return a},this.buildChildFieldName=(s)=>{if(s==="")return this.name;if(s.startsWith("["))return`${this.name}${s}`;return`${this.name}.${s}`},this.distributeFieldErrors=(s,a)=>{let l=this._lastDistributedFieldNames[s]??new Set,r=new Set;if(a)for(let[f,_]of Object.entries(a)){if(_===void 0||_===null||_===!1)continue;r.add(this.buildChildFieldName(f))}let d=new Set([...l,...r]),c=!1;for(let f of d){let _=f.startsWith(this.name+"[")?f.slice(this.name.length):f.slice(this.name.length+1),g=a?.[_],b=this.form.getFieldMeta(f);if(!b&&!g)continue;let y=b?.errorMap[s],m=b?.errorSourceMap[s]==="form",{newErrorValue:i,newSource:v}=Jt({newFormValidatorError:g,isPreviousErrorFromFormValidator:m,previousErrorValue:y});if(i)c=!0;if(y===i&&b?.errorSourceMap[s]===v)continue;this.form.setFieldMeta(f,(x=He)=>({...x,errorMap:{...x.errorMap,[s]:i},errorSourceMap:{...x.errorSourceMap,[s]:v}}))}return this._lastDistributedFieldNames[s]=r,c},this.validateSync=(s,a,l={})=>{let r=Dt(s,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ht}),c=(l.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((g,b)=>{let y=Dt(s,{...b.options,form:b.form,validationLogic:b.form.options.validationLogic||ht});return y.forEach((m)=>{m.field=b}),g.concat(y)},[]),f=!1;ze(()=>{let g=(b,y)=>{let m=wa(y.cause),i=b===this,v=void 0;if(y.validate)v=b.runValidator({validate:y.validate,value:{value:b.store.state.value,validationSource:i?"form":"field",...b instanceof Kt?{groupApi:b}:{fieldApi:b}},type:"validate"});let x=v,M=void 0;if(i&&$a(v))x=v.group,M=v.fields;let q=Oa(x),Y=a[m],{newErrorValue:j,newSource:oe}=Qt({formLevelError:Y,fieldLevelError:q});if(b.state.meta.errorMap?.[m]!==j)b.setMeta((se)=>({...se,errorMap:{...se.errorMap,[m]:j},errorSourceMap:{...se.errorSourceMap,[m]:oe}}));if(j)f=!0;if(i){if(this.distributeFieldErrors(m,M))f=!0}};for(let b of r)g(this,b);for(let b of c){if(!b.validate)continue;g(b.field,b)}});let _=wa("submit");if(this.state.meta.errorMap?.[_]&&s!=="submit"&&!f)this.setMeta((g)=>({...g,errorMap:{...g.errorMap,[_]:void 0},errorSourceMap:{...g.errorSourceMap,[_]:void 0}}));return{hasErrored:f}},this.validateAsync=async(s,a,l={})=>{let r=It(s,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ht}),d=await a,c=l.skipRelatedFieldValidation?[]:this.getRelatedFields(),f=c.reduce((i,v)=>{let x=It(s,{...v.options,form:v.form,validationLogic:v.form.options.validationLogic||ht});return x.forEach((M)=>{M.field=v}),i.concat(x)},[]),_=[],g=[],b=r.some((i)=>i.validate)||f.some((i)=>i.validate);if(b){if(!this.state.meta.isValidating)this.setMeta((i)=>({...i,isValidating:!0}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!0}))}let y=(i,v,x)=>{let M=wa(v.cause),q=i.getInfo();q.validationMetaMap[M]?.lastAbortController.abort();let j=new AbortController;q.validationMetaMap[M]={lastAbortController:j};let oe=i===this;x.push(new Promise(async(se)=>{let F;try{F=await new Promise((he,Ce)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]);i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(j.signal.aborted)return he(void 0);try{he(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,signal:j.signal,validationSource:oe?"form":"field",...i instanceof Kt?{groupApi:i}:{fieldApi:i}},type:"validateAsync"}))}catch(Se){Ce(Se)}},v.debounceMs)})}catch(he){F=he}if(j.signal.aborted)return se(void 0);let D=F,I=void 0;if(oe&&$a(F))D=F.group,I=F.fields;let G=Oa(D),k=d[i.name]?.[M],{newErrorValue:X,newSource:xe}=Qt({formLevelError:k,fieldLevelError:G});if(i.getInfo().instance!==i)return se(void 0);if(i.setMeta((he)=>({...he,errorMap:{...he?.errorMap,[M]:X},errorSourceMap:{...he.errorSourceMap,[M]:xe}})),oe)this.distributeFieldErrors(M,I);se(X)}))};for(let i of r){if(!i.validate)continue;y(this,i,_)}for(let i of f){if(!i.validate)continue;y(i.field,i,g)}let m=[];if(_.length||g.length)m=await Promise.all(_),await Promise.all(g);if(b){this.setMeta((i)=>({...i,isValidating:!1}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!1}))}return m.filter(Boolean)},this.validateAllFields=async(s)=>{let a=[];return ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{if(a.push(Promise.resolve().then(()=>r.validate(s,{skipFormValidation:!0,skipGroupValidation:!0}))),!r.store.state.meta.isTouched)r.setMeta((d)=>({...d,isTouched:!0}))})}),(await Promise.all(a)).flat()},this.validateArrayFieldsStartingFrom=(s,a,l)=>this.form.validateArrayFieldsStartingFrom(s,a,l),this.validateField=(s,a)=>this.form.validateField(s,a),this.getFieldValue=(s)=>this.form.getFieldValue(s),this.getFieldMeta=(s)=>this.form.getFieldMeta(s),this.setFieldMeta=(s,a)=>this.form.setFieldMeta(s,a),this.setFieldValue=(s,a)=>this.form.setFieldValue(s,a),this.deleteField=(s)=>this.form.deleteField(s),this.pushFieldValue=(s,a)=>this.form.pushFieldValue(s,a),this.insertFieldValue=(s,a,l)=>this.form.insertFieldValue(s,a,l),this.replaceFieldValue=(s,a,l)=>this.form.replaceFieldValue(s,a,l),this.swapFieldValues=(s,a,l)=>this.form.swapFieldValues(s,a,l),this.moveFieldValues=(s,a,l)=>this.form.moveFieldValues(s,a,l),this.clearFieldValues=(s)=>this.form.clearFieldValues(s),this.resetField=(s)=>this.form.resetField(s),this.removeFieldValue=(s,a)=>this.form.removeFieldValue(s,a),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((s)=>s.state.meta.isValid),this.validate=(s,a)=>{let{fieldsErrorMap:l}=a?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(s,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)}),{hasErrored:r}=this.validateSync(s,l[this.name]??{},{skipRelatedFieldValidation:a?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[wa(s)]?.lastAbortController.abort(),this.state.meta.errors;let d=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(s,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)});return this.validateAsync(s,d,{skipRelatedFieldValidation:a?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let s=this.form.options.listeners?.onChangeGroupDebounceMs;if(s&&s>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})},s)}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(s)=>{this.setFormGroupState((r)=>({...r,isSubmitted:!1,submissionAttempts:r.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{if(!r.state.meta.isTouched)r.setMeta((d)=>({...d,isTouched:!0}))})});let a=s??this.options.onSubmitMeta;this.setFormGroupState((r)=>({...r,isSubmitting:!0}));let l=()=>{this.setFormGroupState((r)=>({...r,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}ze(()=>{Object.values(this.getRelatedFields()).forEach((r)=>{r.options.listeners?.onGroupSubmit?.({value:r.state.value,fieldApi:r})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:a}),ze(()=>{this.setFormGroupState((r)=>({...r,isSubmitted:!0,isSubmitSuccessful:!0})),l()})}catch(r){throw this.setFormGroupState((d)=>({...d,isSubmitSuccessful:!1})),l(),r}},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=kt((s)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let a=this.form.getFormGroupMeta(this.name)??fs(e.defaultMeta),l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!ft(l,this.options.defaultValue))l=this.options.defaultValue;if(s&&s.value===l&&s.meta===a)return s;return{value:l,meta:a}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ea(e.validate)){let s=Ft[e.type](e.value,e.validate);if(e.type==="validate")return ps(s);return s.then(ps)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function Oa(e){if(e)return e;return}function $a(e){return!!e&&typeof e==="object"&&"fields"in e}function ps(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:s,fields:a,...l}=e;return{...l,group:s,fields:a}}function wa(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 za(e,s){if(!s)return;let a=Object.assign({},e,{state:$t(e.state)});if(s(a),a.fieldInfo!==e.fieldInfo)e.fieldInfo=a.fieldInfo;if(a.options!==e.options)e.options=a.options;let r=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 ze(()=>{if(Object.keys(r).length)e.baseStore.setState((d)=>({...d,...r}));if(a.state.errorMap!==e.state.errorMap)e.setErrorMap(a.state.errorMap)}),a}C();function dr(e,s){return e===s}function Ve(e,s=(l)=>l,a){let l=a?.compare??dr,r=N((c)=>{let{unsubscribe:f}=e.subscribe(c);return f},[e]),d=N(()=>e.get(),[e]);return Sc(r,d,d,s,l)}var la=(e,s=(l)=>l,a)=>Ve(e,s,{compare:a});C();C();C();var xt=typeof window<"u"?Ge:h;function cr(e){let[s,a]=u(()=>({form:e.form,name:e.name})),[l,r]=u(()=>new Bt({...e})),d=l;if(s.form!==e.form||s.name!==e.name)d=new Bt({...e}),r(d),a({form:e.form,name:e.name});let c=Ve(d.store,e.mode==="array"?(v)=>v.meta._arrayVersion||0:(v)=>v.value),f=Ve(d.store,(v)=>v.meta.isTouched),_=Ve(d.store,(v)=>v.meta.isBlurred),g=Ve(d.store,(v)=>v.meta.isDirty),b=Ve(d.store,(v)=>v.meta.errorMap),y=Ve(d.store,(v)=>v.meta.errorSourceMap),m=Ve(d.store,(v)=>v.meta.isValidating),i=O(()=>({...d,get state(){return{value:e.mode==="array"?d.state.value:c,get meta(){return{...d.state.meta,isTouched:f,isBlurred:_,isDirty:g,errorMap:b,errorSourceMap:y,isValidating:m}}}}}),[d,e.mode,c,f,_,g,b,y,m]);return xt(d.mount,[d]),xt(()=>{d.update(e)}),i}var gs=({children:e,...s})=>{let a=cr(s),l=O(()=>Mt(e,a),[e,a]);return t(B,{children:l})};C();C();function hs(){return u(()=>ra())[0]}var mr=Q,vs=Es.split(".")[0]==="17"?hs:mr.useId;C();function ur(e){let[s,a]=u(()=>({form:e.form,name:e.name})),[l,r]=u(()=>new Kt({...e}));if(s.form!==e.form||s.name!==e.name)r(new Kt({...e})),a({form:e.form,name:e.name});let d=Ve(l.store,(F)=>F.value),c=Ve(l.store,(F)=>F.meta.isTouched),f=Ve(l.store,(F)=>F.meta.isBlurred),_=Ve(l.store,(F)=>F.meta.isDirty),g=Ve(l.store,(F)=>F.meta.errorMap),b=Ve(l.store,(F)=>F.meta.errorSourceMap),y=Ve(l.store,(F)=>F.meta.isValidating),m=Ve(l.store,(F)=>F.meta.isSubmitting),i=Ve(l.store,(F)=>F.meta.isSubmitted),v=Ve(l.store,(F)=>F.meta.submissionAttempts),x=Ve(l.store,(F)=>F.meta.isSubmitSuccessful),M=Ve(l.store,(F)=>F.meta.canSubmit),q=Ve(l.store,(F)=>F.meta.isValid),Y=Ve(l.store,(F)=>F.meta.isFieldsValid),j=Ve(l.store,(F)=>F.meta.isFieldsValidating),oe=Ve(l.store,(F)=>F.meta.isGroupValid),se=O(()=>({...l,handleSubmit:(...I)=>l._handleSubmit(...I),get state(){return{...l.state,value:d,get meta(){return{...l.state.meta,isTouched:c,isBlurred:f,isDirty:_,errorMap:g,errorSourceMap:b,isValidating:y,isSubmitting:m,isSubmitted:i,submissionAttempts:v,isSubmitSuccessful:x,canSubmit:M,isValid:q,isFieldsValid:Y,isFieldsValidating:j,isGroupValid:oe}}}}}),[l,d,c,f,_,g,b,y,m,i,v,x,M,q,Y,j,oe]);return xt(l.mount,[l]),xt(()=>{l.update(e)}),se}var bs=({children:e,...s})=>{let a=ur(s),l=O(()=>Mt(e,a),[e,a]);return t(B,{children:l})};function fr({form:e,selector:s=(l)=>l,children:a}){let l=Ve(e.store,s);return t(B,{children:Mt(a,l)})}function qt(e){let s=vs(),[a,l]=u(e?.formId),[r,d]=u(()=>new ia({...e,formId:e?.formId??s}));if(a!==e?.formId){let _=e?.formId??s;d(new ia({...e,formId:_})),l(_)}let c=O(()=>{let _={...r,handleSubmit:(...g)=>r._handleSubmit(...g),get formId(){return r._formId},get state(){return r.store.state}};return _.Field=function(b){return t(gs,{...b,form:r})},_.FormGroup=function(b){return t(bs,{...b,form:r})},_.Subscribe=function(b){return t(fr,{form:r,selector:b.selector,children:b.children})},_},[r]);xt(r.mount,[]),xt(()=>{r.update(e)});let f=w(!1);return xt(()=>{if(!f.current)return;if(!e?.transform)return;za(r,e.transform)},[r,e?.transform]),xt(()=>{f.current=!0}),c}C();var gr=P({name:p().min(1,Fv()),type:We(["chat","autofill","embedding"]),permission:We(["owner","editor","reviewer"]),avatar:p().optional(),providerId:p().optional(),modelId:p().optional(),soul:p().optional(),thinkingLevel:Qc.optional(),systemPrompt:p().optional(),skills:re(p()).optional(),mcpServerIds:re(p()).optional(),deniedTools:re(p()).optional()}),vr=[{id:"bash",name:()=>BA(),description:()=>ZA()},{id:"read_skill",name:()=>KA(),description:()=>VA()},{id:"read_asset",name:()=>Im(),description:()=>QA()},{id:"list_assets",name:()=>Cm(),description:()=>$A()},{id:"create_folder",name:()=>bm(),description:()=>FA()},{id:"create_file",name:()=>_m(),description:()=>UA()},{id:"create_version",name:()=>wm(),description:()=>zA()},{id:"generate_image",name:()=>xm(),description:()=>qA()},{id:"generate_video",name:()=>Sm(),description:()=>HA()},{id:"rename_asset",name:()=>Tm(),description:()=>WA()},{id:"move_assets",name:()=>Em(),description:()=>GA()},{id:"delete_asset",name:()=>vm(),description:()=>jA()}];function xs({isOpen:e,onClose:s,teamId:a,type:l,initialValues:r,title:d}){let c=K(),{canAdmin:f}=Pt(),{data:_}=Z({queryKey:["teams",a,"providers"],queryFn:async()=>{let z=await A.api.teams[":teamId"].providers.$get({param:{teamId:a}});if(!z.ok)throw Error("Failed to fetch providers");return await z.json()},enabled:e}),{data:g}=Z({queryKey:["teams",a,"skills"],queryFn:async()=>{let z=await A.api.teams[":teamId"].skills.$get({param:{teamId:a}});if(!z.ok)throw Error("Failed to fetch skills");return await z.json()},enabled:e}),b=g?.skills||[],{data:y}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let z=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!z.ok)throw Error("Failed to fetch MCP servers");return await z.json()},enabled:e}),m=y?.servers||[],i=O(()=>gr.superRefine((z,J)=>{if(z.type==="chat"||z.type==="autofill"){if(!z.providerId)J.addIssue({code:eo.custom,message:NS(),path:["providerId"]});if(!z.modelId)J.addIssue({code:eo.custom,message:Rv(),path:["modelId"]})}}),[]),v=qt({defaultValues:{name:r?.name||"",type:r?.type||l||"chat",permission:r?.permission||"reviewer",avatar:r?.avatarPreset||r?.avatar||Gc[0].id,providerId:r?.providerId||"",modelId:r?.modelId||"",soul:r?.soul||"",thinkingLevel:r?.thinkingLevel||"off",systemPrompt:r?.systemPrompt||"",skills:r?.skills?.map((z)=>z.skillId)||[],mcpServerIds:r?.mcpServerIds||[],deniedTools:r?.deniedTools??[...Kg]},validators:{onChange:i},onSubmit:async({value:z})=>{try{if(r?.id)await Se.mutateAsync({id:r.id,values:z});else await Ce.mutateAsync(z)}catch{}}}),x=la(v.store,(z)=>z.values.providerId),{data:M,isLoading:q}=Z({queryKey:["teams",a,"providers",x,"models"],queryFn:async()=>{let z=await A.api.providers[":id"].models.$get({param:{id:x}});if(!z.ok)throw Error("Failed to fetch models");return await z.json()},enabled:!!x&&e}),[Y,j]=u(""),[oe,se]=u(!1),F=O(()=>{if(!_)return[];return[..._].sort((z,J)=>z.name.toLowerCase().localeCompare(J.name.toLowerCase()))},[_]),D=O(()=>{if(!Y.trim())return F;let z=Y.toLowerCase();return F.filter((J)=>J.name.toLowerCase().includes(z))},[F,Y]),[I,G]=u(""),[k,X]=u(!1),xe=O(()=>{if(!M)return[];return[...M].sort((z,J)=>{let Ne=(z.name||z.modelId).toLowerCase(),le=(J.name||J.modelId).toLowerCase();return Ne.localeCompare(le)})},[M]),he=O(()=>{if(!I.trim())return xe;let z=I.toLowerCase();return xe.filter((J)=>J.modelId.toLowerCase().includes(z)||J.name&&J.name.toLowerCase().includes(z))},[xe,I]),Ce=U({mutationFn:async(z)=>{let J=await A.api.teams[":teamId"].agents.$post({param:{teamId:a},json:z});if(!J.ok)throw Error("Failed to create agent");return await J.json()},onSuccess:()=>{s(),c.invalidateQueries({queryKey:["agents",a]}),R.success(IA())},onError:(z)=>{R.error(Ns({message:z.message}))}}),Se=U({mutationFn:async({id:z,values:J})=>{let Ne=await A.api.agents[":agentId"].$put({param:{agentId:z},json:J});if(!Ne.ok)throw Error("Failed to update agent");return await Ne.json()},onSuccess:()=>{s(),c.invalidateQueries({queryKey:["agents",a]}),R.success(Pm())},onError:(z)=>{R.error(Ns({message:z.message}))}});h(()=>{if(e)v.reset(),j(""),se(!1),G(""),X(!1)},[e,r,l]);let ee=la(v.store,(z)=>z.values.type),ae=ee==="chat"||ee==="autofill",_e=ee==="chat",Pe=(z)=>z.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||"")}});return t(pe,{open:e,onOpenChange:s,children:o(ue,{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(de,{children:d}),t(Tt,{children:y0()})]}),o("form",{onSubmit:(z)=>{z.preventDefault(),z.stopPropagation(),v.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ie,{className:"flex-1 min-h-0",children:o("div",{className:"p-6 pt-2 space-y-6",children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[t(v.Field,{name:"name",children:(z)=>{let J=!!z.state.meta.errors.length&&z.state.meta.isTouched;return o(je,{"data-invalid":J,children:[t(Oe,{children:RA()}),t(H,{value:z.state.value,onBlur:z.handleBlur,onChange:(Ne)=>z.handleChange(Ne.target.value),placeholder:kA(),"aria-invalid":J}),J&&t(Qe,{errors:Pe(z.state.meta.errors)})]})}}),t(v.Field,{name:"type",children:(z)=>o(je,{children:[t(Oe,{children:XA()}),o(Le,{value:z.state.value,onValueChange:(J)=>z.handleChange(J),disabled:!0,children:[t(Be,{className:"bg-muted/50",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"chat",children:Rm()}),t(ne,{value:"autofill",children:Mm()}),t(ne,{value:"embedding",children:km()})]})]})]})}),_e&&t(v.Field,{name:"permission",children:(z)=>o(je,{children:[t(Oe,{children:_p()}),o(Le,{value:z.state.value||"reviewer",onValueChange:(J)=>z.handleChange(J),disabled:!f,children:[t(Be,{children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"reviewer",children:Mi()}),t(ne,{value:"editor",children:Ri()}),t(ne,{value:"owner",children:ki()})]})]})]})}),t(v.Field,{name:"avatar",children:(z)=>o(je,{className:"md:col-span-2",children:[t(Oe,{children:EA()}),o("div",{className:"flex flex-wrap gap-4 mt-2",children:[Gc.map((J)=>{let Ne=z.state.value===J.id;return t("button",{type:"button",onClick:()=>z.handleChange(J.id),className:E("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all hover:scale-105",Ne?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-muted-foreground"),children:t("img",{src:J.preview,className:"w-full h-full object-cover",alt:mS()})},J.id)}),z.state.value&&!Gc.some((J)=>J.id===z.state.value)&&t("button",{type:"button",className:"relative w-14 h-14 rounded-full overflow-hidden border-2 border-primary ring-2 ring-primary ring-offset-2 scale-105",children:t("img",{src:z.state.value,className:"w-full h-full object-cover",alt:W0()})})]})]})})]}),ae&&o(B,{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(v.Field,{name:"providerId",children:(z)=>{let J=!!z.state.meta.errors.length&&z.state.meta.isTouched,Ne=_?.find((le)=>le.id===z.state.value);return o(je,{"data-invalid":J,children:[t(Oe,{children:RS()}),o(gt,{open:oe,onOpenChange:(le)=>{if(se(le),!le)j("")},modal:!0,children:[t(At,{asChild:!0,children:o(S,{type:"button",variant:"outline",role:"combobox","aria-expanded":oe,"aria-invalid":J,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate",children:Ne?t("span",{className:"font-medium text-foreground truncate",children:Ne.name}):t("span",{className:"text-muted-foreground",children:tE()})}),t(be,{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:(le)=>le.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(H,{placeholder:xg(),value:Y,onChange:(le)=>j(le.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ie,{className:"w-full p-1",style:{height:D.length===0?"96px":`${Math.min(D.length*38+8,256)}px`},onWheel:(le)=>le.stopPropagation(),children:D.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:px()}):t("div",{className:"space-y-0.5 pr-2",children:D.map((le)=>{let lt=z.state.value===le.id;return o("div",{onClick:()=>{z.handleChange(le.id),v.setFieldValue("modelId",""),G(""),se(!1),j("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",lt?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("span",{className:"truncate flex-1 pr-2",children:le.name}),lt&&t(Me,{className:"w-4 h-4 text-primary shrink-0"})]},le.id)})})})]})]}),J&&t(Qe,{errors:Pe(z.state.meta.errors)})]})}}),t(v.Field,{name:"modelId",children:(z)=>{let J=!!z.state.meta.errors.length&&z.state.meta.isTouched,Ne=M?.find((le)=>le.id===z.state.value);return o(je,{"data-invalid":J,children:[o(Oe,{className:"flex items-center gap-2",children:[Cv(),q&&t(L,{className:"w-3 h-3 animate-spin"})]}),o(gt,{open:k,onOpenChange:(le)=>{if(X(le),!le)G("")},modal:!0,children:[t(At,{asChild:!0,children:o(S,{type:"button",variant:"outline",role:"combobox","aria-expanded":k,"aria-invalid":J,disabled:!x||q,className:E("w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50",J&&"border-destructive ring-destructive"),children:[t("span",{className:"truncate flex items-center gap-2",children:Ne?o(B,{children:[t("span",{className:"truncate font-medium text-foreground",children:Ne.name||Ne.modelId}),Ne.name&&Ne.name!==Ne.modelId&&t(we,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:Ne.modelId})]}):t("span",{className:"text-muted-foreground",children:YC()})}),t(be,{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:(le)=>le.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(H,{placeholder:gp(),value:I,onChange:(le)=>G(le.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ie,{className:"w-full p-1",style:{height:he.length===0?"96px":`${Math.min(he.length*38+8,256)}px`},onWheel:(le)=>le.stopPropagation(),children:he.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Ad()}):t("div",{className:"space-y-0.5 pr-2",children:he.map((le)=>{let lt=z.state.value===le.id;return o("div",{onClick:()=>{z.handleChange(le.id),X(!1),G("")},className:E("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",lt?"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:le.name||le.modelId}),le.name&&le.name!==le.modelId&&o("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",le.modelId,")"]}),le.config?.reasoning&&t(we,{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(Lt,{className:"w-2.5 h-2.5"})})]})}),lt&&t(Me,{className:"w-4 h-4 text-primary shrink-0"})]},le.id)})})})]})]}),J&&t(Qe,{errors:Pe(z.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(v.Field,{name:"thinkingLevel",children:(z)=>{let J={off:cI(),low:fI(),medium:pI(),high:uI()};return o(je,{children:[t(Oe,{children:dI()}),o(Le,{value:z.state.value,onValueChange:(Ne)=>z.handleChange(Ne),children:[t(Be,{children:t(Ze,{})}),t(Ue,{children:Qc.options.map((Ne)=>t(ne,{value:Ne,children:J[Ne]||Ne},Ne))})]})]})}})})]}),t(v.Field,{name:"soul",children:(z)=>o(je,{children:[t(Oe,{children:DA()}),t(pa,{value:z.state.value,onBlur:z.handleBlur,onChange:(J)=>z.handleChange(J.target.value),placeholder:LA(),className:"min-h-[120px]"})]})}),o("div",{className:"space-y-4",children:[o(V,{className:"text-base font-bold flex items-center gap-2",children:[t(_t,{className:"w-5 h-5 text-primary"}),kg()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"skills",children:(z)=>o(B,{children:[b.map((J)=>{let Ne=z.state.value?.includes(J.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(_t,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:J.name}),J.description&&t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:J.description})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Ne?Ef():Sf()}),t(qe,{checked:Ne,onCheckedChange:(le)=>{if(le)z.handleChange([...z.state.value||[],J.id]);else z.handleChange((z.state.value||[]).filter((lt)=>lt!==J.id))}})]})]},J.id)}),b.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:Ax()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(V,{className:"text-base font-bold flex items-center gap-2",children:[t(fn,{className:"w-5 h-5 text-primary"}),Lc()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"mcpServerIds",children:(z)=>o(B,{children:[m.map((J)=>{let Ne=z.state.value?.includes(J.id)||!1,le=J.status==="needs_auth"||!J.hasCredential&&J.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(fn,{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:J.name}),o(we,{variant:"outline",className:"text-[10px]",children:[J.toolCount??0," tools"]}),le&&t(we,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:Th()})]}),t("span",{className:"text-[10px] font-mono text-muted-foreground line-clamp-1",children:J.url})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:Ne?Ef():Sf()}),t(qe,{checked:Ne,onCheckedChange:(lt)=>{if(lt)z.handleChange([...z.state.value||[],J.id]);else z.handleChange((z.state.value||[]).filter((Vt)=>Vt!==J.id))}})]})]},J.id)}),m.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:Uh()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(V,{className:"text-base font-bold flex items-center gap-2",children:[t(Co,{className:"w-5 h-5 text-primary"}),YA()]}),t("p",{className:"text-xs text-muted-foreground",children:JA()}),t("div",{className:"space-y-2",children:t(v.Field,{name:"deniedTools",children:(z)=>{let J=z.state.value||[];return t(B,{children:vr.map((Ne)=>{let le=!J.includes(Ne.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(Co,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:Ne.name()}),t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:Ne.description()})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:le?Ef():Sf()}),t(qe,{checked:le,disabled:!f,onCheckedChange:(lt)=>{if(lt)z.handleChange(J.filter((Vt)=>Vt!==Ne.id));else z.handleChange([...J,Ne.id])}})]})]},Ne.id)})})}})})]})]})]})}),o($e,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[t(S,{variant:"outline",onClick:s,type:"button",children:ke()}),t(v.Subscribe,{selector:(z)=>[z.canSubmit,z.isSubmitting],children:([z,J])=>o(S,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!z||J||Ce.isPending||Se.isPending,children:[(J||Ce.isPending||Se.isPending)&&t(L,{className:"w-4 h-4 animate-spin mr-2"}),r?Ds():Z0()]})})]})]})]})})}var yr=[{type:"chat",label:"Chat",icon:_o},{type:"autofill",label:"Autofill",icon:Lt},{type:"embedding",label:"Embedding",icon:no}];function _s({teamId:e}){let s=K(),{canAdmin:a}=Pt(),[l,r]=u(!1),[d,c]=u("chat"),[f,_]=u(null),[g,b]=u(null),[y,m]=u(!1),[i,v]=u({chat:!0,autofill:!0,embedding:!0}),x=(F)=>{if(F==="chat")return Rm();if(F==="autofill")return Mm();return km()},{data:M=[],isLoading:q}=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((I,G)=>G.id.localeCompare(I.id))}}),Y=U({mutationFn:async(F)=>{if(!(await A.api.agents[":agentId"].$delete({param:{agentId:F}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{m(!1),s.invalidateQueries({queryKey:["agents",e]}),R.success(TA())},onError:(F)=>{R.error(F.message)}}),j=U({mutationFn:async({agentId:F,permission:D})=>{let I=await A.api.agents[":agentId"].permission.$patch({param:{agentId:F},json:{permission:D}});if(!I.ok)throw Error(pl());return I.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["agents",e]})},onError:(F)=>{R.error(F.message||pl())}}),oe=U({mutationFn:async(F)=>{let D=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(!D.ok)throw Error("failed to update agent");return D.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["agents",e]}),R.success(Pm())},onError:(F)=>{R.error(F.message)}}),se=(F)=>{v((D)=>({...D,[F]:!D[F]}))};return o(B,{children:[(l||f)&&t(xs,{isOpen:!0,title:f?th({name:f.name}):G0({type:x(d)}),onClose:()=>{r(!1),_(null)},teamId:e,type:d,initialValues:f||void 0}),t(Je,{open:y,onOpenChange:m,children:o(Xe,{children:[o(et,{children:[t(rt,{children:rd()}),t(nt,{children:u_({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:ke()}),t(ot,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(F)=>{if(Y.isPending){F.preventDefault();return}if(g)Y.mutate(g.id)},children:Y.isPending?t(L,{className:"w-4 h-4 animate-spin"}):c_()})]})]})}),q&&M.length===0?t("div",{className:"flex items-center justify-center p-12",children:t(L,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[q&&t("div",{className:"absolute top-0 right-0 p-2",children:t(L,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),yr.map((F)=>{let D=M.filter((k)=>k.type===F.type),I=F.icon,G=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",!G&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!G?()=>se(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"?a0():F.type==="autofill"?By():z_()}),!G&&t(we,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:D.length})]}),o("div",{className:"flex items-center gap-2",children:[!(G&&D.length>0)&&t(S,{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),r(!0)},children:t(fe,{className:"w-4 h-4"})}),!G&&t(be,{className:E("w-5 h-5 text-muted-foreground transition-transform duration-200",i[F.type]?"rotate-180":"")})]})]}),(G||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:[D.map((k)=>t(Ct,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>_(k),children:o(Rt,{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(wt,{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(_t,{className:"w-3 h-3"}),wE({count:k.skills?.length||0})]})})]})]}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,onClick:(X)=>X.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(ye,{align:"end",className:"w-32",children:o(W,{onClick:(X)=>{X.stopPropagation(),b(k),m(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]})]}),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:(X)=>X.stopPropagation(),children:o(Le,{value:k.permission||"reviewer",onValueChange:(X)=>{j.mutate({agentId:k.id,permission:X})},disabled:!a,children:[t(Be,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Ze,{children:k.permission==="reviewer"?Mi():k.permission==="editor"?Ri():ki()})}),o(Ue,{align:"start",children:[t(ne,{value:"reviewer",children:Mi()}),t(ne,{value:"editor",children:Ri()}),t(ne,{value:"owner",children:ki()})]})]})}):t("div",{})}),t("div",{onClick:(X)=>X.stopPropagation(),children:t(qe,{checked:k.enabled,onCheckedChange:(X)=>{oe.mutate({teamId:e,agentId:k.id,name:k.name,type:k.type,enabled:X,avatar:k.avatar,providerId:k.providerId,modelId:k.modelId,thinkingLevel:k.thinkingLevel,systemPrompt:k.systemPrompt,soul:k.soul,skills:k.skills?.map((xe)=>xe.skillId),deniedTools:k.deniedTools})}})})]})]})},k.id)),D.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(I,{className:"w-5 h-5 text-muted-foreground"})}),t("p",{className:"text-sm text-muted-foreground",children:Xv({type:x(F.type)})}),t(S,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{c(F.type),r(!0)},children:j0()})]})]})})]},F.type)})]})]})}C();C();function Na({isOpen:e,onClose:s,onSubmit:a,initialValues:l,title:r,isLoading:d=!1,defaultApi:c,existingModelIds:f=[]}){let _=O(()=>Wg.extend({modelId:p().min(1,Rh()).refine((m)=>{if(l?.modelId===m)return!0;return!f.includes(m)},{message:Tv()})}),[f,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}}},b=qt({defaultValues:g(),validators:{onSubmit:_},onSubmit:async({value:m})=>{a(m)}});h(()=>{if(e)b.reset(g())},[e,l,c,b]);let y=(m)=>m.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(pe,{open:e,onOpenChange:s,children:o(ue,{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(de,{className:"text-xl",children:r})}),o("form",{onSubmit:(m)=>{m.preventDefault(),m.stopPropagation(),b.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ie,{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(b.Field,{name:"modelId",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,children:Rh()}),t(H,{id:m.name,name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:Mv(),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}}),t(b.Field,{name:"name",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,children:R_()}),t(H,{id:m.name,name:m.name,value:m.state.value||"",onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:kv(),"aria-invalid":i}),i&&t(Qe,{errors:y(m.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:eS()}),t(b.Field,{name:"config.reasoning",children:(m)=>o(je,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[t(Oe,{htmlFor:m.name,className:"cursor-pointer",children:up()}),t(qe,{id:m.name,checked:m.state.value,onCheckedChange:m.handleChange})]})}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(b.Field,{name:"config.contextWindow",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:E0()}),t(H,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseInt(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}}),t(b.Field,{name:"config.maxTokens",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:qw()}),t(H,{id:m.name,name:m.name,type:"number",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseInt(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.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(li,{className:"w-4 h-4 text-primary"}),hS()]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(b.Field,{name:"config.cost.input",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:Aw()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}}),t(b.Field,{name:"config.cost.output",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:Kx()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}}),t(b.Field,{name:"config.cost.cacheRead",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:t0()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}}),t(b.Field,{name:"config.cost.cacheWrite",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(je,{"data-invalid":i,children:[t(Oe,{htmlFor:m.name,className:"text-xs",children:r0()}),t(H,{id:m.name,name:m.name,type:"number",step:"0.0001",value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(parseFloat(v.target.value)||0),"aria-invalid":i}),i&&t(Qe,{errors:y(m.state.meta.errors)})]})}})]})]})]})})}),o($e,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:d,children:ke()}),t(b.Subscribe,{selector:(m)=>[m.canSubmit,m.isSubmitting],children:([m,i])=>t(S,{type:"submit",className:"min-w-[100px]",disabled:!m||i||d,children:i||d?t(L,{className:"w-4 h-4 animate-spin"}):Ds()})})]})]})]})})}C();function ws({isOpen:e,onClose:s,teamId:a,syncData:l,onSuccess:r}){let[d,c]=u(""),[f,_]=u(()=>new Set(l?.providers.map((D)=>D.name)||[])),[g,b]=u(()=>{let D=new Set;return l?.providers.forEach((I)=>{I.models.forEach((G)=>{D.add(`${I.name}:${G.modelId}`)})}),D});h(()=>{if(l){_(new Set(l.providers.map((I)=>I.name)));let D=new Set;l.providers.forEach((I)=>{I.models.forEach((G)=>{D.add(`${I.name}:${G.modelId}`)})}),b(D)}},[l]);let y=O(()=>{if(!l)return[];let D=d.trim().toLowerCase();if(!D)return l.providers;return l.providers.map((I)=>{let G=I.name.toLowerCase().includes(D),k=I.models.filter((X)=>G||X.modelId.toLowerCase().includes(D)||X.name.toLowerCase().includes(D));if(k.length>0)return{...I,models:k};return null}).filter((I)=>I!==null)},[l,d]),m=g.size,i=O(()=>{if(!l)return 0;let D=0;for(let I of l.providers)if(I.models.some((k)=>g.has(`${I.name}:${k.modelId}`)))D++;return D},[l,g]),v=(D)=>{_((I)=>{let G=new Set(I);if(G.has(D))G.delete(D);else G.add(D);return G})},x=()=>{if(!l)return;_(new Set(l.providers.map((D)=>D.name)))},M=()=>{_(new Set)},q=(D,I)=>{let G=`${D}:${I}`;b((k)=>{let X=new Set(k);if(X.has(G))X.delete(G);else X.add(G);return X})},Y=(D)=>{let I=l?.providers.find((k)=>k.name===D);if(!I||I.models.length===0)return;let G=I.models.every((k)=>g.has(`${D}:${k.modelId}`));b((k)=>{let X=new Set(k);return I.models.forEach((xe)=>{let he=`${D}:${xe.modelId}`;if(G)X.delete(he);else X.add(he)}),X})},j=()=>{if(!l)return;let D=new Set;l.providers.forEach((I)=>{I.models.forEach((G)=>{D.add(`${I.name}:${G.modelId}`)})}),b(D)},oe=()=>{b(new Set)},se=U({mutationFn:async(D)=>{let I=await A.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:a},json:D});if(!I.ok){let G=await I.json().catch(()=>({message:"Failed to apply sync"}));throw Error(G.message||"Failed to apply sync")}return await I.json()},onSuccess:(D)=>{R.success(VE({modelCount:D.addedModels,providerCount:D.addedProviders})),r(),s()},onError:(D)=>{R.error(D.message)}}),F=async()=>{if(!l||m===0)return;let D=[];for(let I of l.providers){let G=I.models.filter((k)=>g.has(`${I.name}:${k.modelId}`));if(G.length>0)D.push({name:I.name,isNewProvider:I.isNewProvider,config:I.config,models:G})}if(D.length===0)return;await se.mutateAsync({providers:D})};return t(pe,{open:e,onOpenChange:(D)=>!D&&s(),children:o(ue,{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(de,{className:"flex items-center gap-2 text-xl font-semibold",children:[t(rn,{className:"w-5 h-5 text-primary"}),UE()]}),t(Tt,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:BE()})]}),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(H,{value:d,onChange:(D)=>c(D.target.value),placeholder:$E(),className:"pl-8 h-8 text-xs bg-background"})]}),o("div",{className:"flex items-center gap-1.5",children:[t(S,{type:"button",variant:"outline",size:"sm",onClick:x,className:"h-8 text-xs px-2.5",children:zE()}),t(S,{type:"button",variant:"outline",size:"sm",onClick:M,className:"h-8 text-xs px-2.5",children:DE()}),t("div",{className:"w-px h-4 bg-border mx-1"}),t(S,{type:"button",variant:"outline",size:"sm",onClick:j,className:"h-8 text-xs px-2.5",children:GE()}),t(S,{type:"button",variant:"outline",size:"sm",onClick:oe,className:"h-8 text-xs px-2.5",children:ZE()})]})]})}),t("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:t(ie,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:t("div",{className:"p-3 space-y-3",children:y.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:Bh()}):y.map((D)=>{let I=f.has(D.name),G=D.isNewProvider,k=D.models.filter((he)=>g.has(`${D.name}:${he.modelId}`)).length,X=k===D.models.length,xe=k>0&&!X;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:()=>v(D.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:I?t(be,{className:"w-4 h-4"}):t(pt,{className:"w-4 h-4"})}),t(Nr,{checked:X?!0:xe?"indeterminate":!1,onCheckedChange:()=>Y(D.name),id:`provider-check-${D.name}`}),o("label",{htmlFor:`provider-check-${D.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[t(no,{className:"w-4 h-4 text-muted-foreground"}),t("span",{children:D.name})]})]}),o("div",{className:"flex items-center gap-2",children:[G?t(we,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:qE()}):t(we,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:FE()}),t("span",{className:"text-xs text-muted-foreground",children:jE({count:D.models.length})})]})]}),I&&t("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:D.models.map((he)=>{let Ce=g.has(`${D.name}:${he.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(Nr,{checked:Ce,onCheckedChange:()=>q(D.name,he.modelId),id:`model-check-${D.name}-${he.modelId}`}),o("label",{htmlFor:`model-check-${D.name}-${he.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[he.name||he.modelId,t("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:he.modelId})]})]}),o("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[he.config.reasoning&&t(we,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:HE()}),t("span",{className:"text-[11px] text-muted-foreground font-mono",children:LE({count:Math.round(he.config.contextWindow/1000)})})]})]},he.modelId)})})]},D.name)})})})}),o($e,{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:QE({modelCount:m,providerCount:i})}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:se.isPending,children:ke()}),t(S,{type:"button",onClick:F,disabled:m===0||se.isPending,className:"gap-2",children:se.isPending?o(B,{children:[t(L,{className:"w-4 h-4 animate-spin"}),NE()]}):PE({count:m})})]})]})]})})}var Ss={"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 Cs({teamId:e}){let s=K(),[a,l]=u(null),[r,d]=u(!1),[c,f]=u(""),[_,g]=u(!1),[b,y]=u(null),[m,i]=u(!1),[v,x]=u(null),M=U({mutationFn:async()=>{let I=await A.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!I.ok){let G=await I.json().catch(()=>({message:"Failed to check updates"}));throw Error(G.message||"Failed to check updates")}return await I.json()},onSuccess:(I)=>{if(I.totalNewModels===0&&I.totalNewProviders===0){R.info(KE());return}x(I),i(!0)},onError:(I)=>{R.error(I.message)}}),{data:q,isLoading:Y}=Z({queryKey:["teams",e,"providers"],queryFn:async()=>{let I=await A.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!I.ok)throw Error("Failed to fetch providers");return await I.json()}}),j=O(()=>q?.find((I)=>I.id===a)||null,[q,a]),oe=O(()=>q?.map((I)=>I.name)||[],[q]),se=O(()=>{if(!q)return[];if(!c.trim())return q;let I=c.toLowerCase();return q.filter((G)=>G.name.toLowerCase().includes(I))},[q,c]),F=U({mutationFn:async(I)=>{let G=await A.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:I.name,config:I.config,models:I.models}});if(!G.ok)throw Error("Failed to create provider");return await G.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]}),d(!1),R.success(kS())},onError:(I)=>{R.error(Ns({message:I.message}))}}),D=U({mutationFn:async(I)=>{let G=await A.api.providers[":id"].$delete({param:{id:I}});if(!G.ok)throw Error("Failed to delete provider");return await G.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]}),l(null),g(!1),y(null),R.success(PS())},onError:(I)=>{R.error(Ns({message:I.message}))}});if(Y)return t("div",{className:"flex h-64 items-center justify-center",children:t(L,{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(no,{className:"w-5 h-5 text-primary"}),w0()]}),o("div",{className:"flex items-center gap-2",children:[t(S,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"gap-2",children:M.isPending?o(B,{children:[t(L,{className:"w-4 h-4 animate-spin"}),OE()]}):o(B,{children:[t(ma,{className:"w-4 h-4"}),kE()]})}),o(S,{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[t(fe,{className:"w-4 h-4"}),hm()]})]})]}),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(H,{placeholder:xg(),value:c,onChange:(I)=>f(I.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),t(ie,{className:"flex-1 min-h-0",children:o("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[se.map((I)=>t(Ct,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>l(I.id),children:o(Rt,{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(ca,{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:I.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(Lt,{className:"w-3 h-3"}),I.config.api]}),I.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(Ko,{className:"w-3 h-3 flex-none"}),t("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:I.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(Ga,{className:"w-3 h-3"}),Uv({count:I.modelsCount})]})]})]})]}),o("div",{className:"flex items-center gap-1",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,onClick:(G)=>G.stopPropagation(),children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(ye,{align:"end",className:"w-32",children:o(W,{onClick:(G)=>{G.stopPropagation(),y(I),g(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]}),t(pt,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},I.id)),q?.length===0&&o("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[t(no,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:fx()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:mA()})]}),q&&q.length>0&&se.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:Bh()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:II({query:c})}),t(S,{variant:"ghost",size:"sm",onClick:()=>f(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:u0()})]})]})}),t(xr,{isOpen:r,onClose:()=>d(!1),onSubmit:(I)=>F.mutate(I),isLoading:F.isPending,existingProviderNames:oe}),j&&t(Sr,{isOpen:!!j,onClose:()=>l(null),provider:j,teamId:e,existingProviderNames:oe}),t(Je,{open:_,onOpenChange:g,children:o(Xe,{children:[o(et,{children:[t(rt,{children:rd()}),t(nt,{children:__({name:b?.name??""})})]}),o(tt,{children:[t(st,{onClick:()=>y(null),children:ke()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(b)D.mutate(b.id)},children:[D.isPending?t(L,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})}),t(ws,{isOpen:m,onClose:()=>i(!1),teamId:e,syncData:v,onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function xr({isOpen:e,onClose:s,onSubmit:a,isLoading:l,existingProviderNames:r}){let[d,c]=u([]),[f,_]=u(!1),[g,b]=u(null),y=O(()=>P({name:p().min(1,Xh()).refine((x)=>!r.includes(x),{message:eg()}),config:Xa}),[r]),m=qt({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:y},onSubmit:async({value:x})=>{a({name:x.name,config:x.config,models:d})}});h(()=>{if(e)m.reset(),c([]),_(!1),b(null)},[e,m]);let i=(x)=>x.map((M)=>{if(typeof M==="string")return{message:M};if(M&&typeof M==="object"&&"message"in M)return{message:String(M.message)};return{message:String(M||"")}}),v=(x)=>{if(g!==null)c((M)=>M.map((q,Y)=>Y===g?x:q)),b(null);else c((M)=>[x,...M]),_(!1)};return t(pe,{open:e,onOpenChange:s,children:o(ue,{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(de,{className:"text-xl",children:yA()}),t(Tt,{children:jm()})]}),o("form",{onSubmit:(x)=>{x.preventDefault(),x.stopPropagation(),m.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ie,{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(m.Field,{name:"name",children:(x)=>{let M=!!x.state.meta.errors.length&&x.state.meta.isTouched;return o(je,{"data-invalid":M,children:[t(Oe,{htmlFor:x.name,children:Jh()}),t(H,{id:x.name,name:x.name,value:x.state.value,onBlur:x.handleBlur,onChange:(q)=>x.handleChange(q.target.value),placeholder:tg(),"aria-invalid":M}),M&&t(Qe,{errors:i(x.state.meta.errors)})]})}}),t(m.Field,{name:"config.api",children:(x)=>{let M=!!x.state.meta.errors.length&&x.state.meta.isTouched;return o(je,{"data-invalid":M,children:[t(Oe,{htmlFor:x.name,children:Ah()}),o(Le,{onValueChange:x.handleChange,value:x.state.value,children:[t(Be,{id:x.name,"aria-invalid":M,children:t(Ze,{placeholder:Sg()})}),t(Ue,{children:Vc.map((q)=>t(ne,{value:q,children:Ss[q]},q))})]}),M&&t(Qe,{errors:i(x.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.baseUrl",children:(x)=>{let M=!!x.state.meta.errors.length&&x.state.meta.isTouched;return o(je,{"data-invalid":M,children:[t(Oe,{htmlFor:x.name,children:Um()}),t(H,{id:x.name,name:x.name,value:x.state.value||"",onBlur:x.handleBlur,onChange:(q)=>x.handleChange(q.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":M}),t(aa,{children:qh()}),M&&t(Qe,{errors:i(x.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.apiKey",children:(x)=>{let M=!!x.state.meta.errors.length&&x.state.meta.isTouched;return o(je,{"data-invalid":M,children:[t(Oe,{htmlFor:x.name,children:td()}),t(H,{id:x.name,name:x.name,type:"text",value:x.state.value||"",onBlur:x.handleBlur,onChange:(q)=>x.handleChange(q.target.value),placeholder:Lm(),"aria-invalid":M}),t(aa,{className:"text-xs mt-1",children:Dm()}),M&&t(Qe,{errors:i(x.state.meta.errors)})]})}})})]}),o("div",{className:"space-y-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(V,{className:"text-base font-semibold",children:hd()}),t("p",{className:"text-xs text-muted-foreground mt-0.5",children:Nv()})]}),o(S,{type:"button",variant:"outline",size:"sm",onClick:()=>_(!0),className:"gap-1.5",children:[t(fe,{className:"w-4 h-4"}),Ju()]})]}),d.length===0?t("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:Ad()}):t("div",{className:"space-y-2",children:d.map((x,M)=>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:()=>b(M),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:x.name||x.modelId}),t(we,{variant:"secondary",className:"font-mono text-[10px]",children:x.modelId}),x.config.reasoning&&o(we,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[t(Lt,{className:"w-2.5 h-2.5"})," ",up()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[x.config.contextWindow?.toLocaleString()," ",zg()]}),t("span",{children:"·"}),t("span",{children:Gm({input:x.config.cost?.input??0,output:x.config.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 ml-2",children:t(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(q)=>{q.stopPropagation(),c((Y)=>Y.filter((j,oe)=>oe!==M))},children:t(ve,{className:"w-3.5 h-3.5"})})})]},x.modelId+M))})]})]})})}),o($e,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,disabled:l,children:ke()}),t(m.Subscribe,{selector:(x)=>[x.canSubmit,x.isSubmitting],children:([x,M])=>t(S,{type:"submit",className:"min-w-[120px]",disabled:!x||M||l,children:M||l?t(L,{className:"w-4 h-4 animate-spin"}):hm()})})]})]}),(f||g!==null)&&t(Na,{isOpen:!0,onClose:()=>{_(!1),b(null)},onSubmit:v,title:g!==null?rh():Ju(),initialValues:g!==null?d[g]:null,defaultApi:m.getFieldValue("config.api"),existingModelIds:d.filter((x,M)=>M!==g).map((x)=>x.modelId)},g!==null?`edit-${g}-${d[g]?.modelId}`:"add")]})})}function Sr({isOpen:e,onClose:s,provider:a,teamId:l,existingProviderNames:r}){let d=K(),[c,f]=u("general"),[_,g]=u(""),[b,y]=u(!1),[m,i]=u(null),[v,x]=u(null),{data:M=[],isLoading:q}=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}),Y=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].$put({param:{id:a.id},json:{name:k.name,config:k.config}});if(!X.ok)throw Error("Failed to update provider");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers"]}),R.success(sg())},onError:(k)=>{R.error(Ns({message:k.message}))}}),j=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].models.$post({param:{id:a.id},json:k});if(!X.ok)throw Error("Failed to create model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),y(!1),R.success(Ev())},onError:(k)=>{R.error(Ns({message:k.message}))}}),oe=U({mutationFn:async({modelDbId:k,values:X})=>{let xe=await A.api.providers[":id"].models[":modelDbId"].$put({param:{id:a.id,modelDbId:k},json:X});if(!xe.ok)throw Error("Failed to update model");return await xe.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),i(null),R.success(Pv())},onError:(k)=>{R.error(Ns({message:k.message}))}}),se=U({mutationFn:async(k)=>{let X=await A.api.providers[":id"].models[":modelDbId"].$delete({param:{id:a.id,modelDbId:k}});if(!X.ok)throw Error("Failed to delete model");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers",a.id,"models"]}),d.invalidateQueries({queryKey:["teams",l,"providers"]}),x(null),R.success(Iv())},onError:(k)=>{R.error(Ns({message:k.message}))}}),F=O(()=>P({name:p().min(1,Xh()).refine((k)=>{if(a.name===k)return!0;return!r.includes(k)},{message:eg()}),config:Xa}),[r,a.name]),D=qt({defaultValues:{name:a.name,config:a.config},validators:{onSubmit:F},onSubmit:async({value:k})=>{Y.mutate({name:k.name,config:k.config})}});h(()=>{if(e)D.reset(),f("general"),g("")},[e,D]);let I=(k)=>k.map((X)=>{if(typeof X==="string")return{message:X};if(X&&typeof X==="object"&&"message"in X)return{message:String(X.message)};return{message:String(X||"")}}),G=O(()=>{if(!_.trim())return M;let k=_.toLowerCase();return M.filter((X)=>X.modelId.toLowerCase().includes(k)||X.name?.toLowerCase().includes(k))},[M,_]);return t(pe,{open:e,onOpenChange:s,children:o(ue,{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(de,{className:"text-xl",children:th({name:a.name})}),t(Tt,{children:jm()})]}),o(wo,{value:c,onValueChange:(k)=>f(k),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(vo,{className:"grid w-full grid-cols-2",children:[t(Vr,{value:"general",children:gh()}),o(Vr,{value:"models",className:"gap-2",children:[hd(),t(we,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:M.length})]})]})}),t(En,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:o("form",{onSubmit:(k)=>{k.preventDefault(),k.stopPropagation(),D.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"flex-1 min-h-0",children:t(ie,{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(D.Field,{name:"name",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(je,{"data-invalid":X,children:[t(Oe,{htmlFor:k.name,children:Jh()}),t(H,{id:k.name,name:k.name,value:k.state.value,onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:tg(),"aria-invalid":X}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}}),t(D.Field,{name:"config.api",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(je,{"data-invalid":X,children:[t(Oe,{htmlFor:k.name,children:Ah()}),o(Le,{onValueChange:k.handleChange,value:k.state.value,children:[t(Be,{id:k.name,"aria-invalid":X,children:t(Ze,{placeholder:Sg()})}),t(Ue,{children:Vc.map((xe)=>t(ne,{value:xe,children:Ss[xe]},xe))})]}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(D.Field,{name:"config.baseUrl",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(je,{"data-invalid":X,children:[t(Oe,{htmlFor:k.name,children:Um()}),t(H,{id:k.name,name:k.name,value:k.state.value||"",onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":X}),t(aa,{children:qh()}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(D.Field,{name:"config.apiKey",children:(k)=>{let X=!!k.state.meta.errors.length&&k.state.meta.isTouched;return o(je,{"data-invalid":X,children:[t(Oe,{htmlFor:k.name,children:td()}),t(H,{id:k.name,name:k.name,type:"text",value:k.state.value||"",onBlur:k.handleBlur,onChange:(xe)=>k.handleChange(xe.target.value),placeholder:Lm(),"aria-invalid":X}),t(aa,{className:"text-xs mt-1",children:Dm()}),X&&t(Qe,{errors:I(k.state.meta.errors)})]})}})})]})})})}),o($e,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(S,{type:"button",variant:"outline",onClick:s,children:ke()}),t(D.Subscribe,{selector:(k)=>[k.canSubmit,k.isSubmitting],children:([k,X])=>t(S,{type:"submit",className:"min-w-[120px]",disabled:!k||X||Y.isPending,children:X||Y.isPending?t(L,{className:"w-4 h-4 animate-spin"}):Ds()})})]})]})}),o(En,{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(H,{placeholder:gp(),value:_,onChange:(k)=>g(k.target.value),className:"pl-9 h-9"})]}),o(S,{size:"sm",onClick:()=>y(!0),className:"gap-1.5 shrink-0",children:[t(fe,{className:"w-4 h-4"}),Ju()]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ie,{className:"h-full pr-4",children:q?t("div",{className:"flex h-48 items-center justify-center",children:t(L,{className:"h-6 w-6 animate-spin text-primary"})}):G.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Ad()}):t("div",{className:"space-y-2 pb-4",children:G.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(we,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:k.modelId}),k.config?.reasoning&&o(we,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[t(Lt,{className:"w-2.5 h-2.5"})," ",up()]})]}),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()," ",zg()]}),t("span",{children:"·"}),t("span",{children:Hw({count:k.config?.maxTokens?.toLocaleString()??"0"})}),t("span",{children:"·"}),t("span",{children:Gm({input:k.config?.cost?.input??0,output:k.config?.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(X)=>{X.stopPropagation(),x(k)},children:t(ve,{className:"w-3.5 h-3.5"})})})]},k.id))})})})]})]}),b&&t(Na,{isOpen:b,onClose:()=>y(!1),onSubmit:(k)=>j.mutate(k),title:Ju(),isLoading:j.isPending,defaultApi:a.config.api,existingModelIds:M.map((k)=>k.modelId)}),m&&t(Na,{isOpen:!!m,onClose:()=>i(null),onSubmit:(k)=>oe.mutate({modelDbId:m.id,values:k}),title:rh(),isLoading:oe.isPending,initialValues:{modelId:m.modelId,name:m.name,config:m.config},defaultApi:a.config.api,existingModelIds:M.filter((k)=>k.id!==m.id).map((k)=>k.modelId)}),t(Je,{open:!!v,onOpenChange:(k)=>!k&&x(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:rd()}),t(nt,{children:g_({name:v?.name||v?.modelId||""})})]}),o(tt,{children:[t(st,{onClick:()=>x(null),children:ke()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(v)se.mutate(v.id)},children:[se.isPending?t(L,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})})]})})}C();function ks({teamId:e}){let s=K(),[a,l]=u(""),{data:r,isLoading:d}=Z({queryKey:["teams",e,"sandbox"],queryFn:async()=>{let v=await A.api.teams[":teamId"].sandbox.$get({param:{teamId:e}});if(!v.ok)throw Error(ls());return await v.json()}}),{mutate:c,isPending:f}=U({mutationFn:async(v)=>{let x=await A.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:v});if(!x.ok)throw Error(uh());return await x.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"sandbox"]}),R.success(kC())},onError:(v)=>{R.error(v instanceof Error?v.message:uh())}}),_=(v)=>{c({networkSandboxEnabled:v})},g=(v)=>{if(v.preventDefault(),!a.trim())return;if(r?.allowedDomains.includes(a.trim())){R.error(k_());return}let x=[...r?.allowedDomains||[],a.trim()],M=r?.pendingDomains||[];c({allowedDomains:x,pendingDomains:M}),l("")},b=(v)=>{let x=(r?.allowedDomains||[]).filter((q)=>q!==v),M=r?.pendingDomains||[];c({allowedDomains:x,pendingDomains:M})},y=(v)=>{let x=[...r?.allowedDomains||[],v],M=(r?.pendingDomains||[]).filter((q)=>q!==v);c({allowedDomains:x,pendingDomains:M})},m=(v)=>{let x=(r?.pendingDomains||[]).filter((M)=>M!==v);c({allowedDomains:r?.allowedDomains||[],pendingDomains:x})};if(d)return t("div",{className:"flex items-center justify-center p-8",children:t(L,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let i=!!r?.networkSandboxEnabled;return t(ie,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Ct,{children:[o(Nt,{children:[o("div",{className:"flex items-center gap-2",children:[t(ca,{className:"w-5 h-5 text-primary"}),t(Ot,{children:qv()})]}),t(Ht,{children:Hv()})]}),o(Rt,{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:$_()}),t("p",{className:"text-xs text-muted-foreground",children:Gv()})]}),t(qe,{id:"network-sandbox-switch",checked:i,onCheckedChange:_,disabled:f})]}),!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(Ko,{className:"w-4 h-4 mt-0.5 shrink-0"}),t("span",{children:$v()})]}),o("form",{onSubmit:g,className:"flex gap-2 mb-6",children:[t(H,{placeholder:"e.g. api.openai.com",value:a,onChange:(v)=>l(v.target.value),disabled:f||!i}),o(S,{type:"submit",disabled:f||!i,children:[f?t(L,{className:"w-4 h-4 animate-spin"}):t(fe,{className:"w-4 h-4 mr-2"}),pA()]})]}),o("div",{className:"space-y-2",children:[t("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:by()}),o("div",{className:"flex flex-wrap gap-2",children:[r?.allowedDomains.map((v)=>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:v}),t("button",{onClick:()=>b(v),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:f||!i,children:t(De,{className:"w-3.5 h-3.5"})})]},v)),r?.allowedDomains.length===0&&t("div",{className:"text-sm text-muted-foreground italic",children:ox()})]})]})]})]}),o(Ct,{className:"border-orange-500/20 bg-orange-500/5",children:[o(Nt,{children:[o("div",{className:"flex items-center gap-2",children:[t(jl,{className:"w-5 h-5 text-orange-500"}),t(Ot,{children:sS()})]}),t(Ht,{children:aS()})]}),t(Rt,{children:t("div",{className:"space-y-3",children:r?.pendingDomains&&r.pendingDomains.length>0?t("div",{className:"divide-y divide-border",children:r.pendingDomains.map((v)=>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:v}),o("div",{className:"flex items-center gap-2",children:[o(S,{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:()=>y(v),disabled:f||!i,children:[t(Me,{className:"w-4 h-4 mr-1.5"}),Ty()]}),o(S,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>m(v),disabled:f||!i,children:[t(ve,{className:"w-4 h-4 mr-1.5"}),at()]})]})]},v))}):t("div",{className:"text-sm text-muted-foreground italic py-2",children:dx()})})})]}),t(Ct,{children:o(Nt,{children:[t(Ot,{children:Lb()}),t(Ht,{children:Zb()})]})})]})})}C();var Cr=(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"})]}),Ms=({teamId:e})=>{let s=K(),{canAdmin:a}=Pt(),[l,r]=u(!1),[d,c]=u(!1),[f,_]=u(!1),[g,b]=u(null),{data:y,isLoading:m}=Z({queryKey:["teams",e,"skills"],queryFn:async()=>{let M=await A.api.teams[":teamId"].skills.$get({param:{teamId:e}});if(!M.ok)throw Error(ls());return await M.json()}}),i=U({mutationFn:async(M)=>{if(!(await A.api.skills[":id"].$delete({param:{id:M}})).ok)throw Error(Ii())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"skills"]}),_(!1)}}),v=U({mutationFn:async({id:M,permission:q})=>{if(!(await A.api.skills[":id"].permission.$patch({param:{id:M},json:{permission:q}})).ok)throw Error(pl())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(M)=>{alert(M.message||pl())}}),x=y?.skills||[];return o(Ct,{children:[o(Nt,{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(_t,{className:"w-6 h-6"})}),o("div",{children:[t(Ot,{className:"text-xl font-bold",children:Pg()}),t(Ht,{children:xE()})]})]}),o(S,{onClick:()=>r(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",bA()]})]}),t(Rt,{children:m?t("div",{className:"flex justify-center py-10",children:t(L,{className:"w-8 h-8 animate-spin text-primary"})}):x.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(_t,{className:"w-6 h-6"})}),t("h3",{className:"text-lg font-medium text-foreground",children:yx()}),t("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:wA()})]}):t("div",{className:"space-y-4",children:x.map((M)=>t(kr,{skill:M,canAdmin:a,onDelete:()=>{b(M),_(!0)},onConfigure:()=>{b(M),c(!0)},onPermissionChange:(q)=>v.mutate({id:M.id,permission:q})},M.id))})}),t(Mr,{open:l,onOpenChange:r,teamId:e}),g&&t(Fr,{open:d,onOpenChange:(M)=>{if(c(M),!M)setTimeout(()=>{document.body.style.pointerEvents="auto"},100)},teamId:e,skill:g}),t(Je,{open:f,onOpenChange:_,children:o(Xe,{children:[o(et,{children:[t(rt,{children:rd()}),t(nt,{children:v_({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:ke()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(g)i.mutate(g.id)},children:[i.isPending?t(L,{className:"w-4 h-4 animate-spin mr-2"}):t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})})]})},kr=({skill:e,canAdmin:s,onDelete:a,onConfigure:l,onPermissionChange:r})=>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(S,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t(wr,{className:"w-4 h-4"})})}),t(ye,{align:"end",className:"w-32",children:o(W,{onClick:(d)=>{d.stopPropagation(),a()},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(ve,{className:"w-4 h-4"})," ",at()]})})]})]}),t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||Lh()})]}),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:[$g()," ",new Date(e.updatedAt).toLocaleDateString()]}),t("div",{className:"flex items-center gap-2",onClick:(d)=>d.stopPropagation(),children:o(Le,{value:e.permission||"reviewer",onValueChange:(d)=>r(d),disabled:!s,children:[t(Be,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Ze,{placeholder:_p()})}),o(Ue,{align:"end",children:[t(ne,{value:"reviewer",children:Mi()}),t(ne,{value:"editor",children:Ri()}),t(ne,{value:"owner",children:ki()})]})]})})]})]}),Mr=({open:e,onOpenChange:s,teamId:a})=>{let l=K(),[r,d]=u(""),[c,f]=u(!1),_=w(null),{data:g}=Z({queryKey:["teams",a,"projects"],queryFn:async()=>{let m=await A.api.teams[":teamId"].projects.$get({param:{teamId:a},query:{first:"1"}});if(!m.ok)throw Error("Failed to fetch projects");return await m.json()},enabled:e}),b=async(m)=>{f(!0);try{let i=await A.api.teams[":teamId"].skills.$post({param:{teamId:a},json:m});if(i.status===409){let v=await i.json();if(window.confirm(`${v.error}
|
|
2
|
+
|
|
3
|
+
${Wx()}`)){await b({...m,override:!0});return}}else if(!i.ok){let v=await i.json().catch(()=>({}));throw Error(v.error||gb())}else l.invalidateQueries({queryKey:["teams",a,"skills"]}),s(!1),d("")}catch(i){if(i instanceof Error)alert(i.message);else alert(ed())}finally{f(!1)}},y=async(m)=>{if(!m||m.length===0)return;let i=g?.data?.[0]?.id;if(!i){alert(jv());return}let v=m[0];if(!v.name.toLowerCase().endsWith(".zip")){alert(Tx());return}f(!0);try{let x=v.name,M=v.type||"application/zip",q=await A.api.projects[":projectId"].attachments.$post({param:{projectId:i},json:{fileName:x,size:v.size,contentType:M}});if(!q.ok)throw Error("Failed to get upload URL");let{id:Y,uploadUrl:j}=await q.json();if(!(await fetch(j,{method:"PUT",body:v,headers:{"Content-Type":M}})).ok)throw Error("Failed to upload file to storage");await b({assetId:Y})}catch(x){if(x instanceof Error)alert(x.message);else alert(ed())}finally{f(!1)}};return t(pe,{open:e,onOpenChange:s,children:o(ue,{className:"sm:max-w-[450px]",children:[o(me,{children:[t(de,{children:_A()}),t(Tt,{children:gw()})]}),o("div",{className:"space-y-6 pt-4",children:[o("div",{className:"space-y-3",children:[t(V,{children:Yx()}),o("div",{onClick:()=>!c&&_.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:_,className:"hidden",accept:".zip",onChange:(m)=>y(m.target.files)}),t("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:t(so,{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:sE()}),t("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:Jx()})]})]}),c&&!r&&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(L,{className:"w-4 h-4 animate-spin"}),AS()]})]}),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:Qx()})})]}),t("div",{className:"space-y-4",children:o("div",{className:"space-y-2",children:[t(V,{htmlFor:"githubUrl",children:Yb()}),o("div",{className:"flex gap-2",children:[o("div",{className:"relative flex-1",children:[t(Cr,{className:"absolute left-3 top-2.5 w-4 h-4 text-muted-foreground"}),t(H,{id:"githubUrl",placeholder:"https://github.com/owner/repo",value:r,onChange:(m)=>d(m.target.value),disabled:c,className:"pl-9"})]}),t(S,{onClick:()=>b({githubUrl:r}),disabled:!r||c,className:"px-6",children:c&&r?t(L,{className:"w-4 h-4 animate-spin"}):yw()})]}),t("p",{className:"text-[10px] text-muted-foreground italic",children:Jb()})]})})]})]})})},Fr=({open:e,onOpenChange:s,teamId:a,skill:l})=>{let r=K(),[d,c]=u({...l.config||{},environmentVariables:l.config?.environmentVariables||[]}),[f,_]=u(!1),g=(x,M)=>{let q=[...d.environmentVariables];q[x]={...q[x],default:M},c({...d,environmentVariables:q})},b=(x,M)=>{let q=[...d.environmentVariables];q[x]={...q[x],name:M},c({...d,environmentVariables:q})},y=()=>{c({...d,environmentVariables:[...d.environmentVariables,{name:"",default:""}]})},m=(x)=>{let M=[...d.environmentVariables];M.splice(x,1),c({...d,environmentVariables:M})},i=async()=>{let x=d.environmentVariables.filter((q)=>q.name.trim()!==""),M={...d,environmentVariables:x};_(!0);try{let q=await A.api.skills[":id"].config.$patch({param:{id:l.id},json:{config:M}});if(!q.ok){let Y=await q.json().catch(()=>({}));throw Error(Y.error||"Failed to update config")}r.invalidateQueries({queryKey:["teams",a,"skills"]}),s(!1)}catch(q){if(q instanceof Error)alert(q.message);else alert(ed())}finally{_(!1)}},v=d?.environmentVariables||[];return t(pe,{open:e,onOpenChange:s,children:o(ue,{className:"sm:max-w-[500px]",children:[o(me,{children:[t("div",{className:"flex items-center justify-between",children:o(de,{className:"flex items-center gap-2",children:[t(Hl,{className:"w-5 h-5 text-primary"}),b0({name:l.name})]})}),t(Tt,{children:Zw()})]}),t(ie,{className:"max-h-[60vh]",children:t("div",{className:"py-4 space-y-4 pr-4",children:v.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:sx()})}):v.map((x,M)=>o("div",{className:"p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group",children:[t("button",{onClick:()=>m(M),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(De,{className:"w-4 h-4"})}),o("div",{className:"space-y-1.5",children:[t(V,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:zI()}),t(H,{value:x.name,onChange:(q)=>b(M,q.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(V,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:l_()}),t(H,{value:x.default||"",onChange:(q)=>g(M,q.target.value),placeholder:Gx(),className:"h-8 bg-background border-border text-sm"}),t("p",{className:"text-[10px] text-muted-foreground italic",children:X_()})]})]},M))})}),o($e,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[o(S,{variant:"ghost",size:"sm",onClick:y,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"})," ",CA()]}),o("div",{className:"flex gap-2",children:[t(S,{variant:"ghost",onClick:()=>s(!1),children:ke()}),o(S,{onClick:i,disabled:f,className:"px-8",children:[f?t(L,{className:"w-4 h-4 animate-spin mr-2"}):null,Ds()]})]})]})]})})};C();C();var As=({isOpen:e,onClose:s,teamId:a,server:l})=>{let r=K(),d=!!l,[c,f]=u(""),[_,g]=u("streamable_http"),[b,y]=u("reviewer"),[m,i]=u("auto"),[v,x]=u(""),[M,q]=u(""),[Y,j]=u(""),[oe,se]=u(""),[F,D]=u("authorization_code"),[I,G]=u([]),[k,X]=u([]),[xe,he]=u({}),[Ce,Se]=u(!1);h(()=>{if(l)f(l.url),g(l.transport||"streamable_http"),y(l.permission||"reviewer"),i(l.authType||"auto"),G(Array.isArray(l.config?.directTools)?l.config.directTools:[]),X(l.config?.excludeTools??[]),he({}),Se(!1);else f(""),g("streamable_http"),y("reviewer"),i("auto"),x(""),q(""),j(""),se(""),D("authorization_code"),G([]),X([]),he({}),Se(!1)},[l,e]);let ee=()=>{if(m==="none")return{type:"none"};if(m==="bearer")return{type:"bearer",bearerToken:v||void 0};if(m==="oauth")return{type:"oauth",oauth:{grantType:F,clientId:M||void 0,clientSecret:Y||void 0,scope:oe||void 0}};return},{data:ae,isLoading:_e,refetch:Pe}=Z({queryKey:["mcp","servers",l?.id,"tools"],queryFn:async()=>{if(!l?.id)return{tools:[]};let ce=await A.api.mcp.servers[":id"].tools.$get({param:{id:l.id}});if(!ce.ok)throw Error("Failed to fetch tools");return await ce.json()},enabled:e&&d&&!!l?.id}),z=U({mutationFn:async()=>{if(!l?.id)return;let ce=await A.api.mcp.servers[":id"].refresh.$post({param:{id:l.id}});if(!ce.ok){let it=await ce.json().catch(()=>({}));throw Error(it.error||"Failed to refresh server")}return await ce.json()},onSuccess:()=>{R.success(ov()),Pe(),r.invalidateQueries({queryKey:["teams",a,"mcp","servers"]})},onError:(ce)=>{R.error(ce.message)}}),J=U({mutationFn:async()=>{let ce={directTools:I.length>0?I:void 0,excludeTools:k.length>0?k:void 0};if(d&&l){let it={transport:_,permission:b,authConfig:ee(),config:ce},Re=await A.api.mcp.servers[":id"].$patch({param:{id:l.id},json:it});if(!Re.ok){let dt=await Re.json().catch(()=>({}));throw Error(dt.error||pl())}return await Re.json()}else{let it={url:c.trim()},Re=await A.api.teams[":teamId"].mcp.servers.$post({param:{teamId:a},json:it});if(!Re.ok){let ta=await Re.json().catch(()=>({}));throw Error(ta.error||ed())}return await Re.json()}},onSuccess:()=>{R.success(d?Wh():Lc()),r.invalidateQueries({queryKey:["teams",a,"mcp","servers"]}),s()},onError:(ce)=>{R.error(ce.message)}}),Ne=(ce)=>{if(ce.preventDefault(),!c.trim())return;J.mutate()},le=ae?.tools??[],lt=(ce)=>{if(k.includes(ce))return"off";if(I.includes(ce))return"direct";return"on"},Vt=(ce,it)=>{if(it==="off")X((Re)=>Re.includes(ce)?Re:[...Re,ce]),G((Re)=>Re.filter((dt)=>dt!==ce));else if(it==="on")X((Re)=>Re.filter((dt)=>dt!==ce)),G((Re)=>Re.filter((dt)=>dt!==ce));else if(it==="direct")X((Re)=>Re.filter((dt)=>dt!==ce)),G((Re)=>Re.includes(ce)?Re:[...Re,ce])},te=(ce)=>{let it=le.map((Re)=>Re.name);if(ce==="off")X(it),G([]);else if(ce==="on")X([]),G([]);else if(ce==="direct")X([]),G(it)},Ye=(ce)=>{he((it)=>({...it,[ce]:!it[ce]}))};return t(pe,{open:e,onOpenChange:(ce)=>!ce&&s(),children:d&&l?o(ue,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[z.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(L,{className:"w-8 h-8 animate-spin text-primary mb-2"}),o("span",{className:"text-xs font-medium text-muted-foreground",children:[Ch(),"..."]})]}),o(me,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[o(de,{className:"flex items-center gap-2 text-xl font-bold",children:[t(fn,{className:"w-5 h-5 text-primary"}),D_()]}),t(Tt,{children:md()})]}),o("form",{onSubmit:Ne,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ie,{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:av()}),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:Ih()}),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:fl()}),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(Ko,{className:"w-3 h-3"}),Eh()]})]}),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:sv()}),t("p",{onClick:()=>Se((ce)=>!ce),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${Ce?"":"line-clamp-2"}`,title:Ce?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(V,{className:"text-xs",children:gv()}),o(Le,{value:_,onValueChange:(ce)=>g(ce),children:[t(Be,{className:"h-9 text-xs",children:t(Ze,{})}),o(Ue,{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(V,{className:"text-xs",children:_p()}),o(Le,{value:b,onValueChange:(ce)=>y(ce),children:[t(Be,{className:"h-9 text-xs",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"reviewer",children:Mi()}),t(ne,{value:"editor",children:Ri()}),t(ne,{value:"owner",children:ki()})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(V,{className:"text-xs",children:Kw()}),o(Le,{value:m,onValueChange:(ce)=>i(ce),children:[t(Be,{className:"h-9 text-xs",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"auto",children:$w()}),t(ne,{value:"none",children:Qw()}),t(ne,{value:"bearer",children:Gw()}),t(ne,{value:"oauth",children:Vw()})]})]})]}),m==="bearer"&&o("div",{className:"space-y-1.5",children:[t(V,{className:"text-xs",children:Ww()}),t(H,{className:"h-9 text-xs font-mono",type:"password",value:v,onChange:(ce)=>x(ce.target.value),placeholder:"Enter token string"})]}),m==="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(V,{className:"text-xs",children:rv()}),o(Le,{value:F,onValueChange:(ce)=>D(ce),children:[t(Be,{className:"h-9 text-xs",children:t(Ze,{})}),o(Ue,{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(V,{className:"text-xs",children:ev()}),t(H,{className:"h-9 text-xs",value:M,onChange:(ce)=>q(ce.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(V,{className:"text-xs",children:tv()}),t(H,{className:"h-9 text-xs",type:"password",value:Y,onChange:(ce)=>j(ce.target.value),placeholder:"Optional Secret"})]}),o("div",{className:"space-y-1.5",children:[t(V,{className:"text-xs",children:nv()}),t(H,{className:"h-9 text-xs",value:oe,onChange:(ce)=>se(ce.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(V,{className:"text-xs font-semibold flex items-center gap-1.5",children:[t(So,{className:"w-3.5 h-3.5"}),pv()," (",le.length,")"]}),t("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:hv()}),le.length>0&&o("div",{className:"flex items-center gap-1.5 pt-0.5",children:[t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>te("off"),disabled:z.isPending||_e,children:Jw()}),t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>te("on"),disabled:z.isPending||_e,children:Xw()}),t(S,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>te("direct"),disabled:z.isPending||_e,children:Yw()})]})]}),t("div",{className:"space-y-2",children:_e?t("div",{className:"flex justify-center py-8",children:t(L,{className:"w-6 h-6 animate-spin text-primary"})}):le.length===0?t("div",{className:"text-center py-6 text-muted-foreground text-xs",children:wx()}):le.map((ce)=>{let it=lt(ce.name),Re=!!xe[ce.name],dt=ce.inputSchema,ta=dt?.properties&&Object.keys(dt.properties).length>0;return o("div",{className:`border border-border rounded-lg p-3 transition-colors ${it!=="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:()=>ta&&Ye(ce.name),children:[ta?Re?t(be,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t(pt,{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:ce.name}),ce.title&&t(we,{variant:"outline",className:"text-[10px]",children:ce.title})]}),ce.description&&t("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:ce.description})]})]}),t("div",{className:"flex items-center gap-2 shrink-0",children:o(Eo,{type:"single",value:it,onValueChange:(Wt)=>{if(Wt)Vt(ce.name,Wt)},size:"sm",variant:"outline",disabled:z.isPending||_e,children:[t(pr,{value:"off",className:"text-[11px] px-2 h-7",children:dv()}),t(pr,{value:"on",className:"text-[11px] px-2 h-7",children:fv()}),t(pr,{value:"direct",className:"text-[11px] px-2 h-7",children:uv()})]})})]}),Re&&ta&&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:xI()}),t("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(dt.properties).map(([Wt,Sa])=>{let Os=dt.required?.includes(Wt);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:Wt}),Os&&t("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),t(we,{variant:"secondary",className:"text-[9px] px-1 py-0",children:Sa.type||"any"})]}),Sa.description&&t("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:Sa.description})]},Wt)})})]})]},ce.name)})})]})]})}),o($e,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[o(S,{type:"button",variant:"outline",onClick:()=>z.mutate(),disabled:z.isPending||_e||J.isPending,className:"gap-1.5 mr-auto",children:[t(ma,{className:`w-4 h-4 ${z.isPending?"animate-spin":""}`}),Ch()]}),t(S,{type:"button",variant:"outline",onClick:s,children:ke()}),o(S,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(L,{className:"w-4 h-4 mr-2 animate-spin"}),Ds()]})]})]})]}):o(ue,{className:"sm:max-w-md",children:[o(me,{children:[o(de,{className:"flex items-center gap-2 text-xl font-bold",children:[t(fn,{className:"w-5 h-5 text-primary"}),ff()]}),t(Tt,{children:md()})]}),o("form",{onSubmit:Ne,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(V,{className:"text-xs font-semibold",children:Ih()}),t(H,{value:c,onChange:(ce)=>f(ce.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(Ko,{className:"w-3.5 h-3.5"}),Eh()]})]}),o($e,{children:[t(S,{type:"button",variant:"outline",onClick:s,children:ke()}),o(S,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(L,{className:"w-4 h-4 mr-2 animate-spin"}),kc()]})]})]})]})})};var Is=({teamId:e})=>{let s=K(),{canAdmin:a}=Pt(),[l,r]=u(!1),[d,c]=u(null),[f,_]=u(null),[g,b]=u(null),{data:y,isLoading:m}=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(ls());return await j.json()}}),i=U({mutationFn:async(j)=>{if(!(await A.api.mcp.servers[":id"].$delete({param:{id:j}})).ok)throw Error(Ii())},onSuccess:()=>{R.success(at()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),_(null)},onError:(j)=>{R.error(j.message)}}),v=U({mutationFn:async({id:j,permission:oe})=>{if(!(await A.api.mcp.servers[":id"].permission.$patch({param:{id:j},json:{permission:oe}})).ok)throw Error(pl())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(j)=>{R.error(j.message)}}),x=U({mutationFn:async(j)=>{if(!(await A.api.mcp.servers[":id"].auth.$delete({param:{id:j}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{R.success(Sh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(j)=>{R.error(j.message)}}),M=async(j)=>{b(j);try{let oe=await A.api.mcp.servers[":id"].auth.start.$post({param:{id:j}});if(!oe.ok){let F=await oe.json().catch(()=>({}));throw Error(F.error||Ff())}let se=await oe.json();if(se.status==="authenticated"){R.success(vh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),b(null);return}if(se.authorizationUrl){let I=window.screenX+(window.outerWidth-600)/2,G=window.screenY+(window.outerHeight-700)/2,k=window.open(se.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${I},top=${G},scrollbars=yes`),X=(he)=>{if(he.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",X),b(null),he.data.ok)R.success(vh()),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else R.error(he.data.message||Ff())};window.addEventListener("message",X);let xe=setInterval(()=>{if(!k||k.closed)clearInterval(xe),window.removeEventListener("message",X),b(null),s.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(oe){R.error(oe instanceof Error?oe.message:Ff()),b(null)}},q=y?.servers||[],Y=(j)=>{switch(j.status){case"connected":return o(we,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[t(br,{className:"w-3 h-3"}),iv()]});case"needs_auth":return o(we,{variant:"secondary",className:"gap-1 bg-amber-500/10 text-amber-600 border-amber-500/20 text-[10px]",children:[t(Zt,{className:"w-3 h-3"}),Th()]});case"failed":return o(we,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[t(pn,{className:"w-3 h-3"}),lv()]});default:return o(we,{variant:"outline",className:"gap-1 text-[10px]",children:[t(hr,{className:"w-3 h-3 text-muted-foreground"}),cv()]})}};return o(Ct,{children:[o(Nt,{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(fn,{className:"w-6 h-6"})}),o("div",{children:[t(Ot,{className:"text-xl font-bold",children:Lc()}),t(Ht,{children:md()})]})]}),a&&o(S,{onClick:()=>r(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",ff()]})]}),t(Rt,{children:m?t("div",{className:"flex justify-center py-10",children:t(L,{className:"w-8 h-8 animate-spin text-primary"})}):q.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(fn,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold",children:Uh()}),t("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:hA()}),a&&o(S,{onClick:()=>r(!0),className:"mt-4 gap-2",variant:"outline",children:[t(fe,{className:"w-4 h-4"})," ",ff()]})]}):t("div",{className:"space-y-4",children:q.map((j)=>{let oe=g===j.id,se=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(fn,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t("span",{className:"truncate",children:j.name}),t(we,{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(S,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:t(wr,{className:"w-4 h-4"})})}),o(ye,{align:"end",children:[j.status!=="connected"&&(j.authType!=="none"||j.hasCredential)?o(W,{onClick:(F)=>{F.stopPropagation(),M(j.id)},children:[t(Zt,{className:"w-4 h-4 mr-2"}),xh()]}):null,j.hasCredential&&o(W,{onClick:(F)=>{F.stopPropagation(),x.mutate(j.id)},className:"text-amber-600",children:[t(Za,{className:"w-4 h-4 mr-2"}),Sh()]}),(j.status!=="connected"&&(j.authType!=="none"||j.hasCredential)||j.hasCredential)&&t(Gt,{}),o(W,{onClick:(F)=>{F.stopPropagation(),_(j)},className:"text-red-600",children:[t(ve,{className:"w-4 h-4 mr-2"}),at()]})]})]})]}),o("div",{className:"space-y-1",children:[t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:j.description||Lh()}),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:[Y(j),o(we,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[t(So,{className:"w-3 h-3 text-muted-foreground"}),mv({count:j.toolCount})]}),o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[$g()," ",new Date(j.updatedAt).toLocaleDateString()]})]}),o("div",{className:"flex items-center gap-2 shrink-0",onClick:(F)=>F.stopPropagation(),children:[a?o(Le,{value:j.permission,onValueChange:(F)=>v.mutate({id:j.id,permission:F}),children:[t(Be,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:t(Ze,{})}),o(Ue,{align:"end",children:[t(ne,{value:"reviewer",children:Mi()}),t(ne,{value:"editor",children:Ri()}),t(ne,{value:"owner",children:ki()})]})]}):t(we,{variant:"outline",className:"text-[10px]",children:j.permission==="reviewer"?Mi():j.permission==="editor"?Ri():ki()}),se&&a&&o(S,{size:"sm",variant:"default",onClick:(F)=>{F.stopPropagation(),M(j.id)},disabled:oe,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[oe?t(L,{className:"w-3.5 h-3.5 animate-spin"}):t(Zt,{className:"w-3.5 h-3.5"}),xh()]})]})]})]},j.id)})})}),t(As,{isOpen:l||!!d,onClose:()=>{r(!1),c(null)},teamId:e,server:d}),t(Je,{open:!!f,onOpenChange:(j)=>!j&&_(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:m_()}),t(nt,{children:h_({name:f?.name||""})})]}),o(tt,{children:[t(st,{children:ke()}),o(ot,{onClick:()=>f&&i.mutate(f.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[i.isPending&&t(L,{className:"w-4 h-4 mr-2 animate-spin"}),at()]})]})]})})]})};function Ts({teamId:e}){let s=K(),{data:a,isLoading:l}=Z({queryKey:["teams",e,"notification-settings"],queryFn:async()=>{let f=await A.api.teams[":teamId"].notifications.settings.$get({param:{teamId:e}});if(!f.ok)throw Error(ls());return await f.json()}}),{mutate:r,isPending:d}=U({mutationFn:async(f)=>{let _=await A.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:f});if(!_.ok)throw Error(ch());return await _.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),s.invalidateQueries({queryKey:["teams",e,"notifications"]}),R.success(Cx())},onError:(f)=>{R.error(f instanceof Error?f.message:ch())}}),c=(f)=>{if(!a)return;let _={...a,[f]:!a[f]};r(_)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(L,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return t(ie,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Ct,{className:"overflow-hidden gap-0 py-0",children:[o(Nt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(_o,{className:"w-5 h-5 text-primary"}),t(Ot,{className:"text-lg",children:g0()})]}),t(Ht,{children:A0()})]}),o(Rt,{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(_o,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Qb()}),t("p",{className:"text-sm text-muted-foreground",children:eT()})]})]}),t(qe,{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(Ha,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:h0()}),t("p",{className:"text-sm text-muted-foreground",children:rT()})]})]}),t(qe,{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(Ka,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Oy()}),t("p",{className:"text-sm text-muted-foreground",children:tT()})]})]}),t(qe,{checked:a?.mentions??!0,onCheckedChange:()=>c("mentions"),disabled:d})]})]})]}),o(Ct,{className:"overflow-hidden gap-0 py-0",children:[o(Nt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(Bn,{className:"w-5 h-5 text-primary"}),t(Ot,{className:"text-lg",children:Py()})]}),t(Ht,{children:Ny()})]}),o(Rt,{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(ui,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:oT()}),t("p",{className:"text-sm text-muted-foreground",children:nT()})]})]}),t(qe,{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(Bn,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Vx()}),t("p",{className:"text-sm text-muted-foreground",children:JI()})]})]}),t(qe,{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(Fs,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:RE()}),t("p",{className:"text-sm text-muted-foreground",children:XI()})]})]}),t(qe,{checked:a?.statusUpdates??!0,onCheckedChange:()=>c("statusUpdates"),disabled:d})]})]})]}),o(Ct,{className:"overflow-hidden gap-0 py-0",children:[o(Nt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(ka,{className:"w-5 h-5 text-primary"}),t(Ot,{className:"text-lg",children:Cw()})]}),t(Ht,{children:Sw()})]}),o(Rt,{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(ka,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Ew()}),t("p",{className:"text-sm text-muted-foreground",children:YI()})]})]}),t(qe,{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(_o,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:xw()}),t("p",{className:"text-sm text-muted-foreground",children:WI()})]})]}),t(qe,{checked:a?.kanbanComments??!0,onCheckedChange:()=>c("kanbanComments"),disabled:d})]})]})]})]})})}C();function Vs({teamId:e}){let s=K(),[a,l]=u(""),[r,d]=u(null),{data:c,isLoading:f}=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:_,isPending:g}=U({mutationFn:async(i)=>{let v=await A.api.teams[":teamId"]["api-tokens"].$post({param:{teamId:e},json:{name:i}});if(!v.ok)throw Error("Failed to create API token");return await v.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),l(""),R.success(xy())},onError:(i)=>{R.error(i instanceof Error?i.message:hb())}}),{mutate:b}=U({mutationFn:async(i)=>{let v=await A.api.teams[":teamId"]["api-tokens"][":tokenId"].$delete({param:{teamId:e,tokenId:i}});if(!v.ok)throw Error("Failed to delete API token");return await v.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),R.success(Sy())},onError:(i)=>{R.error(i instanceof Error?i.message:bb())}}),y=(i)=>{if(i.preventDefault(),!a.trim())return;_(a.trim())},m=async(i,v)=>{await ao(v),d(i),R.success(T0()),setTimeout(()=>d(null),2000)};if(f)return t("div",{className:"flex justify-center items-center p-8",children:t(L,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return t("div",{className:"space-y-6",children:o(Ct,{children:[o(Nt,{children:[t(Ot,{children:Zm()}),t(Ht,{children:Cy()})]}),o(Rt,{className:"space-y-6",children:[o("form",{onSubmit:y,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:wI()}),t(H,{id:"tokenName",value:a,onChange:(i)=>l(i.target.value),placeholder:vI(),required:!0})]}),o(S,{type:"submit",disabled:g||!a.trim(),children:[g?t(L,{className:"w-4 h-4 animate-spin mr-2"}):t(fe,{className:"w-4 h-4 mr-2"}),Kb()]})]}),t("div",{className:"border rounded-lg overflow-hidden",children:o(Tn,{children:[t(Mn,{children:o(_r,{children:[t(bt,{children:hl()}),t(bt,{children:bI()}),t(bt,{children:Q0()}),t(bt,{className:"w-[100px] text-right",children:iA()})]})}),t(Rn,{children:!c||c.length===0?t(_r,{children:t(mt,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:ex()})}):c.map((i)=>o(_r,{children:[t(mt,{className:"font-medium",children:i.name}),t(mt,{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(S,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(i.id,i.token),children:r===i.id?t(Me,{className:"h-3.5 w-3.5 text-green-500"}):t(Rr,{className:"h-3.5 w-3.5"})})]})}),t(mt,{className:"text-muted-foreground",children:new Date(i.createdAt).toLocaleDateString()}),t(mt,{className:"text-right",children:t(S,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>b(i.id),children:t(ve,{className:"h-4 w-4"})})})]},i.id))})]})})]})]})})}C();C();var Dr=[{value:"read_asset",label:()=>Im()},{value:"list_assets",label:()=>Cm()},{value:"create_folder",label:()=>bm()},{value:"create_file",label:()=>_m()},{value:"create_version",label:()=>wm()},{value:"generate_image",label:()=>xm()},{value:"generate_video",label:()=>Sm()},{value:"rename_asset",label:()=>Tm()},{value:"move_assets",label:()=>Em()},{value:"delete_asset",label:()=>vm()}],Qa={agent_total_tokens:{label:()=>Sd(),icon:no,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>wd(),icon:li,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>vd(),icon:fn,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>bd(),icon:Co,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>xd(),icon:So,unit:"calls",defaultLimit:100}},Ls=({open:e,onOpenChange:s,teamId:a,rule:l,onSuccess:r})=>{let d=K(),c=!!l,[f,_]=u("each_member"),[g,b]=u("team"),[y,m]=u([]),[i,v]=u("agent_total_tokens"),[x,M]=u(""),[q,Y]=u("*"),[j,oe]=u("read_asset"),[se,F]=u(1e5),[D,I]=u("1day"),[G,k]=u(!0),[X,xe]=u(!1),[he,Ce]=u(""),{data:Se=[]}=Z({queryKey:["teams",a,"members"],queryFn:async()=>{let te=await A.api.teams[":teamId"].members.$get({param:{teamId:a},query:{}});if(!te.ok)return[];return await te.json()},enabled:e}),{data:ee}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let te=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!te.ok)return{servers:[]};return await te.json()},enabled:e&&i==="agent_mcp_call_count"}),ae=ee?.servers||[];h(()=>{if(l){_(l.scopeMode),b(l.role||"team"),m(l.userIds||[]),v(l.resource);let te=l.resourceData||{};M(typeof te.id==="string"?te.id:""),Y(typeof te.match==="string"?te.match:"*"),oe(typeof te.name==="string"?te.name:typeof te.toolName==="string"?te.toolName:"read_asset"),F(l.limit),I(Kc(l.period)),k(l.enabled)}else _("each_member"),b("team"),m([]),v("agent_total_tokens"),M(""),Y("*"),oe("read_asset"),F(Qa.agent_total_tokens.defaultLimit),I("1day"),k(!0)},[l,e]);let _e=(te)=>{if(v(te),!c)F(Qa[te]?.defaultLimit||100)},Pe=U({mutationFn:async()=>{let te={};if(i==="agent_mcp_call_count")te.id=x;else if(i==="agent_bash_call_count")te.match=q.trim()||"*";else if(i==="agent_tool_call_count")te.name=j||"read_asset";let Ye=await A.api.teams[":teamId"].quotas.$post({param:{teamId:a},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?y:null,resource:i,resourceData:Object.keys(te).length>0?te:null,limit:Number(se),period:D,enabled:G}});if(!Ye.ok){let ce=await Ye.json().catch(()=>({}));throw Error(ce?.message||ah())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(zS()),s(!1),r?.()},onError:(te)=>{console.error("CREATE MUTATION ERROR:",te),R.error(te instanceof Error?te.message:ah())}}),z=U({mutationFn:async()=>{if(!l)return;let te={};if(i==="agent_mcp_call_count")te.id=x;else if(i==="agent_bash_call_count")te.match=q.trim()||"*";else if(i==="agent_tool_call_count")te.name=j||"read_asset";let Ye=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:a,id:l.id},json:{scopeMode:f,role:f!=="selected_members"&&g!=="team"?g:null,userIds:f==="selected_members"?y:null,resource:i,resourceData:Object.keys(te).length>0?te:null,limit:Number(se),period:D,enabled:G}});if(!Ye.ok){let ce=await Ye.json().catch(()=>({}));throw Error(ce?.message||ud())}return await Ye.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(fC()),s(!1),r?.()},onError:(te)=>{R.error(te instanceof Error?te.message:ud())}}),J=U({mutationFn:async()=>{if(!l)return;if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:a,id:l.id}})).ok)throw Error(cd())},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),R.success(lg()),xe(!1),s(!1),r?.()},onError:(te)=>{R.error(te instanceof Error?te.message:cd())}}),Ne=(te)=>{if(te.preventDefault(),f==="selected_members"&&y.length===0){R.error(nE());return}if(i==="agent_mcp_call_count"&&!x.trim()){R.error(nh());return}if(se<=0){R.error("Limit must be greater than 0");return}if(c)z.mutate();else Pe.mutate()},le=Pe.isPending||z.isPending||J.isPending,lt=Se.filter((te)=>{if(!he.trim())return!0;let Ye=he.toLowerCase();return te.name.toLowerCase().includes(Ye)||te.email&&te.email.toLowerCase().includes(Ye)}),Vt=(te)=>{m((Ye)=>Ye.includes(te)?Ye.filter((ce)=>ce!==te):[...Ye,te])};return o(B,{children:[t(pe,{open:e,onOpenChange:s,children:o(ue,{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(de,{className:"text-xl font-bold",children:c?L_():q0()}),t(Tt,{className:"text-sm text-muted-foreground",children:c?Z_():H0()})]}),o("form",{onSubmit:Ne,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(V,{className:"text-sm font-semibold",children:tC()}),o("div",{className:"grid grid-cols-3 gap-2",children:[o(S,{type:"button",variant:f==="each_member"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>_("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Hn,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Ed()})]}),o(S,{type:"button",variant:f==="all_members"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>_("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(oo,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Cd()})]}),o(S,{type:"button",variant:f==="selected_members"?"default":"outline",size:"sm",disabled:c||le,onClick:()=>_("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(ci,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Id()})]})]}),o("p",{className:"text-xs text-muted-foreground pt-0.5",children:[f==="each_member"&&nC(),f==="all_members"&&rC(),f==="selected_members"&&oC()]})]}),f!=="selected_members"?o("div",{className:"space-y-2",children:[t(V,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:eC()}),o(Le,{value:g,onValueChange:b,disabled:c||le,children:[t(Be,{id:"quota-role-scope",className:"w-full",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"team",children:wl()}),o(ne,{value:"owner",children:[lp(),": Owner"]}),o(ne,{value:"editor",children:[lp(),": Editor"]}),o(ne,{value:"reviewer",children:[lp(),": Reviewer"]})]})]})]}):o("div",{className:"space-y-2",children:[t(V,{className:"text-sm font-semibold",children:Eg()}),o(gt,{children:[t(At,{asChild:!0,children:o(S,{variant:"outline",role:"combobox",disabled:le,className:"w-full justify-between text-left font-normal h-10",children:[t("span",{className:"truncate",children:y.length===0?Eg():sC({count:y.length})}),t(be,{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(H,{placeholder:cp(),value:he,onChange:(te)=>Ce(te.target.value),className:"h-8 pl-8 text-xs"})]}),t(ie,{className:"h-48",children:t("div",{className:"space-y-1 pr-2",children:lt.map((te)=>{let Ye=y.includes(te.id);return o("div",{onClick:()=>Vt(te.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[t(Nr,{checked:Ye,onCheckedChange:()=>Vt(te.id)}),o(Ee,{className:"w-5 h-5",children:[t(Ie,{src:te.image||void 0}),t(Te,{className:"text-[10px]",children:te.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"truncate flex-1",children:[t("span",{className:"font-medium text-foreground block truncate",children:te.name}),te.email&&t("span",{className:"text-[10px] text-muted-foreground block truncate",children:te.email})]})]},te.id)})})})]})})]})]}),o("div",{className:"space-y-2",children:[t(V,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:JS()}),o(Le,{value:i,onValueChange:(te)=>_e(te),disabled:c||le,children:[t(Be,{id:"quota-resource",className:"w-full",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"agent_total_tokens",children:o("div",{className:"flex items-center gap-2",children:[t(no,{className:"w-4 h-4 text-primary"}),t("span",{children:Sd()})]})}),t(ne,{value:"agent_cost",children:o("div",{className:"flex items-center gap-2",children:[t(li,{className:"w-4 h-4 text-emerald-500"}),t("span",{children:wd()})]})}),t(ne,{value:"agent_mcp_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(fn,{className:"w-4 h-4 text-blue-500"}),t("span",{children:vd()})]})}),t(ne,{value:"agent_bash_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Co,{className:"w-4 h-4 text-purple-500"}),t("span",{children:bd()})]})}),t(ne,{value:"agent_tool_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(So,{className:"w-4 h-4 text-cyan-500"}),t("span",{children:xd()})]})})]})]})]}),i==="agent_mcp_call_count"&&o("div",{className:"space-y-2",children:[t(V,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:Cg()}),ae.length>0?o(Le,{value:x,onValueChange:M,disabled:c||le,children:[t(Be,{id:"quota-mcp",className:"w-full",children:t(Ze,{placeholder:Cg()})}),t(Ue,{children:ae.map((te)=>o(ne,{value:te.id,children:[te.name," (",te.id,")"]},te.id))})]}):t(H,{id:"quota-mcp",value:x,onChange:(te)=>M(te.target.value),placeholder:nh(),disabled:c||le})]}),i==="agent_bash_call_count"&&o("div",{className:"space-y-1.5",children:[t(V,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:Yy()}),t(H,{id:"quota-bash",value:q,onChange:(te)=>Y(te.target.value),placeholder:Jy(),disabled:le}),t("p",{className:"text-xs text-muted-foreground",children:US()})]}),i==="agent_tool_call_count"&&o("div",{className:"space-y-2",children:[t(V,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:Tg()}),o(Le,{value:j,onValueChange:oe,disabled:c||le,children:[t(Be,{id:"quota-tool",className:"w-full",children:t(Ze,{placeholder:Tg()})}),t(Ue,{children:Dr.map((te)=>t(ne,{value:te.value,children:te.label()},te.value))})]}),t("p",{className:"text-xs text-muted-foreground",children:dC()})]}),o("div",{className:"grid grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[o(V,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[$S()," (",Qa[i]?.unit||"",")"]}),t(H,{id:"quota-limit",type:"number",min:"0.01",step:i==="agent_cost"?"0.01":"1",value:se,onChange:(te)=>F(Number(te.target.value)),placeholder:GS(),disabled:le,required:!0})]}),o("div",{className:"space-y-2",children:[t(V,{htmlFor:"quota-period",className:"text-sm font-semibold",children:VS()}),o(Le,{value:D,onValueChange:(te)=>I(te),disabled:le,children:[t(Be,{id:"quota-period",className:"w-full",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"1hour",children:o("div",{className:"flex items-center gap-2",children:[t(hr,{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(hr,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:ap()})]})}),t(ne,{value:"1day",children:o("div",{className:"flex items-center gap-2",children:[t(hr,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:op()})]})}),t(ne,{value:"7day",children:o("div",{className:"flex items-center gap-2",children:[t(hr,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:ip()})]})})]})]})]})]}),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(V,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:G?qS():np()}),t("p",{className:"text-xs text-muted-foreground",children:G?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),t(qe,{id:"quota-enabled",checked:G,onCheckedChange:k,disabled:le})]}),o($e,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[c?o(S,{type:"button",variant:"destructive",size:"sm",onClick:()=>xe(!0),disabled:le,className:"gap-1.5",children:[t(ve,{className:"w-4 h-4"}),t("span",{children:vf()})]}):t("div",{}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",onClick:()=>s(!1),disabled:le,children:ke()}),o(S,{type:"submit",disabled:le,className:"gap-2",children:[le&&t(L,{className:"w-4 h-4 animate-spin"}),c?Oo():kc()]})]})]})]})]})}),t(Je,{open:X,onOpenChange:xe,children:o(Xe,{children:[o(et,{children:[t(rt,{children:vf()}),t(nt,{children:Jm()})]}),o(tt,{children:[t(st,{disabled:le,children:ke()}),o(ot,{onClick:(te)=>{te.preventDefault(),J.mutate()},disabled:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[le&&t(L,{className:"w-4 h-4 animate-spin mr-2"}),at()]})]})]})})]})};var Ps=({teamId:e})=>{let s=K(),[a,l]=u(!1),[r,d]=u(null),[c,f]=u(null),{data:_,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(ls());return await i.json()}}),b=U({mutationFn:async({id:i,enabled:v})=>{let x=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:i},json:{enabled:v}});if(!x.ok)throw Error(ud());return await x.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"quotas"]}),R.success(aC())},onError:(i)=>{R.error(i instanceof Error?i.message:ud())}}),y=U({mutationFn:async(i)=>{if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:i}})).ok)throw Error(cd())},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"quotas"]}),R.success(lg()),f(null)},onError:(i)=>{R.error(i instanceof Error?i.message:cd())}}),m=_?.rules||[];return o(ie,{className:"h-full",children:[t("div",{className:"space-y-6 pr-4 pb-10",children:o(Ct,{children:[o(Nt,{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(Uo,{className:"w-6 h-6"})}),o("div",{children:[t(Ot,{className:"text-xl font-bold",children:gg()}),t(Ht,{children:Ag()})]})]}),o(S,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",gm()]})]}),t(Rt,{children:g?t("div",{className:"flex justify-center py-12",children:t(L,{className:"w-8 h-8 animate-spin text-primary"})}):m.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(Uo,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold text-foreground mb-1",children:Vf()}),t("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:Qf()}),o(S,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",gm()]})]}):t("div",{className:"flex flex-col gap-4",children:m.map((i)=>{let v=zi[i.resource],x=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:v?.label?v.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(x.id||"")]}),i.resource==="agent_bash_call_count"&&o("span",{children:["Match: ",String(x.match||"*")]}),i.resource==="agent_tool_call_count"&&o("span",{children:["Tool: ",String(x.name||x.toolName||"*")]})]})]}),o("div",{className:"flex items-center gap-2",onClick:(M)=>M.stopPropagation(),children:[t(qe,{checked:i.enabled,onCheckedChange:(M)=>b.mutate({id:i.id,enabled:M}),disabled:b.isPending}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(S,{variant:"ghost",size:"icon","aria-label":"Quota actions",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(ye,{align:"end",children:o(W,{onClick:()=>f(i),className:"text-destructive focus:text-destructive",children:[t(ve,{className:"w-4 h-4 mr-2"}),at()]})})]})]})]}),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(we,{variant:"secondary",className:"gap-1 text-xs",children:[t(oo,{className:"w-3 h-3"}),o("span",{children:[Cd(),i.role?` (${i.role})`:` (${wl()})`]})]}),i.scopeMode==="each_member"&&o(we,{variant:"secondary",className:"gap-1 text-xs",children:[t(Hn,{className:"w-3 h-3"}),o("span",{children:[Ed(),i.role?` (${i.role})`:` (${wl()})`]})]}),i.scopeMode==="selected_members"&&o(we,{variant:"secondary",className:"gap-1 text-xs",children:[t(ci,{className:"w-3 h-3"}),o("span",{children:[Id()," (",i.userIds?.length||0,")"]})]}),o(we,{variant:"outline",className:"gap-1 text-xs",children:[t(hr,{className:"w-3 h-3"}),o("span",{children:[Ca(i.resource,i.limit)," ",v?.unit," /"," ",ql(i.period)]})]})]})})]})},i.id)})})})]})}),(a||!!r)&&t(Ls,{open:a||!!r,onOpenChange:(i)=>{if(!i)l(!1),d(null)},teamId:e,rule:r}),t(Je,{open:!!c,onOpenChange:(i)=>{if(!i)f(null)},children:o(Xe,{children:[o(et,{children:[t(rt,{children:vf()}),t(nt,{children:Jm()})]}),o(tt,{children:[t(st,{disabled:y.isPending,children:ke()}),o(ot,{onClick:(i)=>{if(i.preventDefault(),c)y.mutate(c.id)},disabled:y.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[y.isPending&&t(L,{className:"w-4 h-4 animate-spin mr-2"}),at()]})]})]})})]})};C();var Bs={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 Rs({teamId:e}){let s=K(),[a,l]=u(null),{data:r,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=r?.providers||[],f=r?.enabledModels||[],_=O(()=>{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(L,{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(ie,{className:"h-full pr-1 [&>div>div]:block!",children:t("div",{className:"pb-12 min-w-0 w-full",children:o(Ct,{className:"border-border min-w-0 w-full",children:[o(Nt,{children:[t(Ot,{className:"text-base font-semibold",children:yv()}),t(Ht,{children:_v()})]}),t(Rt,{className:"min-w-0",children:t("div",{className:"space-y-2.5 min-w-0",children:c.map((g)=>{let b=Bs[g.provider]||g.provider,y=g.status==="configured_custom",m=g.status==="configured_env",i=f.filter((x)=>x.provider===g.provider&&x.type==="image").length,v=f.filter((x)=>x.provider===g.provider&&x.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:b}),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:[y&&o(we,{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(br,{className:"w-3 h-3"}),rg()]}),m&&o(we,{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(br,{className:"w-3 h-3"}),ng()]}),!y&&!m&&t(we,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:og()}),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(Yn,{className:"w-3 h-3"}),mw({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",v>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(ua,{className:"w-3 h-3"}),jI({count:v})]})]})]}),t(pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},g.provider)})})})]})})}),_&&t(Ar,{isOpen:!!_,onClose:()=>l(null),provider:_,teamId:e,enabledModels:f,onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function Ar({isOpen:e,onClose:s,provider:a,teamId:l,enabledModels:r,onSuccess:d}){let[c,f]=u(()=>a.apiKeyConfigured?"models":"api-key"),[_,g]=u(a.customApiKeyOrEnv||""),[b,y]=u(()=>r.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),[m,i]=u(""),[v,x]=u("all"),[M,q]=u(""),[Y,j]=u(a.supportedTypes[0]||"image");h(()=>{f(a.apiKeyConfigured?"models":"api-key"),g(a.customApiKeyOrEnv||""),y(r.filter((ee)=>ee.provider===a.provider).map((ee)=>({type:ee.type,modelId:ee.modelId,name:ee.name}))),i(""),x("all"),q(""),j(a.supportedTypes[0]||"image")},[a.provider,a.customApiKeyOrEnv,a.apiKeyConfigured,r]);let{data:oe=[],isLoading:se}=Z({queryKey:["teams",l,"media-generation","curated",a.provider],queryFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:l},query:{provider:a.provider}});if(!ee.ok)return[];return await ee.json()},enabled:e}),{mutate:F,isPending:D}=U({mutationFn:async()=>{let ee=await A.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:l,provider:a.provider},json:{apiKey:_.trim(),models:b.map((ae)=>({type:ae.type,modelId:ae.modelId,name:ae.name||ae.modelId}))}});if(!ee.ok){let ae=await ee.json().catch(()=>({}));throw Error(ae?.message||"Failed to update provider")}return await ee.json()},onSuccess:()=>{R.success(sg()),d(),s()},onError:(ee)=>{R.error(ee instanceof Error?ee.message:vb())}}),I=O(()=>new Set(oe.map((ee)=>ee.modelId)),[oe]),G=O(()=>b.filter((ee)=>!I.has(ee.modelId)),[b,I]),k=O(()=>{let ee=[];for(let ae of oe){let _e=b.some((Pe)=>Pe.modelId===ae.modelId&&Pe.type===ae.type);ee.push({type:ae.type,modelId:ae.modelId,name:ae.name,isCustom:!1,isToggledOn:_e})}for(let ae of G)ee.push({type:ae.type,modelId:ae.modelId,name:ae.name||ae.modelId,isCustom:!0,isToggledOn:!0});return ee},[oe,b,G]),X=O(()=>k.filter((ee)=>{if(v!=="all"&&ee.type!==v)return!1;if(m.trim()){let ae=m.toLowerCase(),_e=ee.name.toLowerCase().includes(ae),Pe=ee.modelId.toLowerCase().includes(ae);if(!_e&&!Pe)return!1}return!0}),[k,v,m]),xe=(ee,ae)=>{if(ae)y((_e)=>[..._e,{type:ee.type,modelId:ee.modelId,name:ee.name,isCustom:ee.isCustom}]);else y((_e)=>_e.filter((Pe)=>!(Pe.modelId===ee.modelId&&Pe.type===ee.type)))},he=(ee,ae)=>{y((_e)=>_e.filter((Pe)=>!(Pe.modelId===ee&&Pe.type===ae)))},Ce=()=>{let ee=M.trim();if(!ee)return;if(b.some((_e)=>_e.modelId===ee&&_e.type===Y)){R.error(pb());return}y((_e)=>[..._e,{type:Y,modelId:ee,name:ee,isCustom:!0}]),q("")},Se=Bs[a.provider]||a.provider;return t(pe,{open:e,onOpenChange:(ee)=>!ee&&s(),children:o(ue,{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(de,{className:"flex items-center gap-2 text-xl",children:[t("span",{children:Se}),a.status==="configured_custom"&&t(we,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:rg()}),a.status==="configured_env"&&t(we,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:ng()})]}),t(Tt,{children:i_({envKey:a.defaultEnvKey})})]}),o(wo,{value:c,onValueChange:(ee)=>f(ee),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(vo,{className:"grid w-full grid-cols-2",children:[t(Vr,{value:"api-key",onClick:()=>f("api-key"),children:td()}),o(Vr,{value:"models",onClick:()=>f("models"),children:[hd()," (",b.length,")"]})]})}),t(En,{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(ie,{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:td()}),_&&o(S,{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(ve,{className:"w-3.5 h-3.5"}),l0()]})]}),t(H,{id:"provider-api-key",type:"text",value:_,onChange:(ee)=>g(ee.target.value),placeholder:vy({envKey:a.defaultEnvKey}),className:"font-mono text-sm"}),t("p",{className:"text-xs text-muted-foreground mt-1",children:wy({envKey:a.defaultEnvKey})})]})})})})}),o(En,{value:"models",className:"flex-1 flex flex-col min-h-0 m-0",children:[!a.apiKeyConfigured&&!_&&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(pn,{className:"w-4 h-4 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-medium",children:og()}),t("p",{className:"text-[11px] opacity-90 mt-0.5",children:OS()})]})]})}),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(H,{type:"text",placeholder:gp(),value:m,onChange:(ee)=>i(ee.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:()=>x("all"),className:E("px-3 text-xs transition-colors",v==="all"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:my()}),o("button",{type:"button",onClick:()=>x("image"),className:E("px-3 text-xs transition-colors flex items-center gap-1.5",v==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(Yn,{className:"w-3.5 h-3.5"}),zf()]}),o("button",{type:"button",onClick:()=>x("video"),className:E("px-3 text-xs transition-colors flex items-center gap-1.5",v==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:[t(ua,{className:"w-3.5 h-3.5"}),jf()]})]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ie,{className:"h-full pr-4",children:se?o("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[t(L,{className:"h-5 w-5 animate-spin"}),t("span",{className:"text-xs",children:Ow()})]}):X.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:Ad()}):t("div",{className:"space-y-2 pb-4",children:X.map((ee)=>o("div",{className:E("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",ee.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(we,{variant:"outline",className:E("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",ee.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:[ee.type==="image"?t(Yn,{className:"w-3 h-3"}):t(ua,{className:"w-3 h-3"}),ee.type==="image"?zf():jf()]}),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:ee.name}),ee.isCustom&&t(we,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:J0().replace("...","")})]}),t("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:ee.modelId})]})]}),o("div",{className:"flex items-center gap-2 shrink-0",children:[ee.isCustom&&t(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>he(ee.modelId,ee.type),title:at(),children:t(ve,{className:"w-3.5 h-3.5"})}),t(qe,{checked:ee.isToggledOn,onCheckedChange:(ae)=>xe(ee,ae),"aria-label":`Toggle ${ee.name}`})]})]},`${ee.type}-${ee.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",Y==="image"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:zf()}),t("button",{type:"button",onClick:()=>j("video"),className:E("px-2.5 py-1 text-xs transition-colors",Y==="video"?"bg-primary text-primary-foreground font-medium":"bg-muted/40 hover:bg-muted text-muted-foreground"),children:jf()})]}),t(H,{type:"text",value:M,onChange:(ee)=>q(ee.target.value),placeholder:K_(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(ee)=>{if(ee.key==="Enter")ee.preventDefault(),Ce()}}),o(S,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:Ce,disabled:!M.trim(),children:[t(fe,{className:"w-3.5 h-3.5"}),df()]})]})})]})]}),o($e,{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:[b.length," ",hd().toLowerCase()]}),o("div",{className:"flex items-center gap-2",children:[t(S,{type:"button",variant:"outline",size:"sm",onClick:s,disabled:D,children:ke()}),o(S,{type:"button",size:"sm",onClick:()=>F(),disabled:D,children:[D&&t(L,{className:"w-4 h-4 mr-1.5 animate-spin"}),Oo()]})]})]})]})})}C();C();function qs({isOpen:e,onClose:s,imageSrc:a,onConfirm:l}){let[r,d]=u(1),[c,f]=u({x:0,y:0}),[_,g]=u(!1),[b,y]=u(!1),m=w({x:0,y:0}),i=w(null),v=w(null),x=250;h(()=>{if(e)d(1),f({x:0,y:0}),y(!1)},[e,a]);let M=(F)=>{F.preventDefault(),g(!0),m.current={x:F.clientX-c.x,y:F.clientY-c.y}},q=(F)=>{if(!_)return;f({x:F.clientX-m.current.x,y:F.clientY-m.current.y})},Y=()=>{g(!1)},j=(F)=>{if(F.touches.length!==1)return;g(!0);let D=F.touches[0];m.current={x:D.clientX-c.x,y:D.clientY-c.y}},oe=(F)=>{if(!_||F.touches.length!==1)return;let D=F.touches[0];f({x:D.clientX-m.current.x,y:D.clientY-m.current.y})},se=async()=>{let F=i.current,D=v.current;if(!F||!D)return;y(!0);try{let I=F.getBoundingClientRect(),G=512,k=document.createElement("canvas");k.width=512,k.height=512;let X=k.getContext("2d");if(X){X.clearRect(0,0,512,512);let xe=2.048,he=I.width/r,Ce=I.height/r,Se=256+c.x*xe,ee=256+c.y*xe;X.translate(Se,ee),X.scale(r*xe,r*xe),X.drawImage(F,-he/2,-Ce/2,he,Ce);let ae=await new Promise((_e)=>{k.toBlob((Pe)=>_e(Pe),"image/jpeg",0.9)});if(ae)await l(ae)}}catch(I){console.error("Failed to crop image",I)}finally{y(!1)}};return t(pe,{open:e,onOpenChange:(F)=>!F&&s(),children:o(ue,{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(de,{className:"text-xl font-bold flex items-center gap-2",children:[t(Wa,{className:"w-5 h-5 text-primary"}),dS()]})}),o("div",{className:"p-6 flex flex-col items-center gap-6",children:[o("div",{ref:v,className:"relative overflow-hidden bg-muted select-none border border-border/40 rounded-xl cursor-move shadow-inner",style:{width:250,height:250},onMouseDown:M,onMouseMove:q,onMouseUp:Y,onMouseLeave:Y,onTouchStart:j,onTouchMove:oe,onTouchEnd:Y,children:[a&&t("img",{ref:i,src:a,alt:Vy(),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(${r})`,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(Ja,{className:"w-4 h-4 text-muted-foreground"}),t("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:r,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(Ya,{className:"w-4 h-4 text-muted-foreground"})]})]}),o($e,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[t(S,{variant:"outline",onClick:s,disabled:b,children:ke()}),t(S,{onClick:se,disabled:b||!a,className:"min-w-[80px]",children:b?o(B,{children:[t(L,{className:"w-4 h-4 animate-spin mr-2"}),bg()]}):Oo()})]})]})})}var Ir=["general","transcode","quotas","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"];function js(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return Ir.includes(e)?e:"general"}function Er(){let{teamId:e}=Tr.useParams(),s=K(),[a,l]=u(js),r=(ae)=>{l(ae);let _e=ae==="general"?"":`#${ae}`;if(window.location.hash!==_e)window.history.replaceState(null,"",window.location.pathname+window.location.search+_e)};h(()=>{let ae=()=>{l(js())};return window.addEventListener("hashchange",ae),()=>window.removeEventListener("hashchange",ae)},[]);let[d,c]=u(""),[f,_]=u(!1),[g,b]=u(null),y=w(null),[m,i]=u(!1),{setMetadata:v,getMetadata:x}=Lo(),M=x("locale")||n(),q=async(ae)=>{if(ae==="en"||ae==="zh")try{await v(e,"locale",ae),Ei(ae),R.success(Tw())}catch(_e){console.error(_e),R.error(Sb())}},{data:Y,isLoading:j,error:oe}=Z({queryKey:["teams",e,"settings"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!ae.ok)throw Error("Failed to fetch settings");return await ae.json()}}),{data:se,isLoading:F}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let ae=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!ae.ok)throw Error("Failed to fetch me");return await ae.json()},enabled:!!e});h(()=>{if(se?.name)c(se.name)},[se]),h(()=>{let ae=["transcode","quotas","providers","image-video","skills","mcp","agents","sandbox"];if(se&&se.role!=="owner"&&ae.includes(a))r("general")},[se,a]);let D=(ae)=>{if(!ae)return"U";let _e=ae.split(" ");if(_e.length>1)return`${_e[0][0]}${_e[_e.length-1][0]}`.toUpperCase();return ae.substring(0,2).toUpperCase()},I=(ae)=>{let _e=ae.target.files?.[0];if(_e){let Pe=new FileReader;Pe.onload=()=>{b(Pe.result),_(!0)},Pe.readAsDataURL(_e),ae.target.value=""}},G=async(ae)=>{i(!0);try{let _e=new File([ae],"avatar.jpg",{type:"image/jpeg"}),Pe=await A.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:_e}});if(!Pe.ok)throw Error("Failed to upload avatar");let J=(await Pe.json()).key;if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:J}})).ok)throw Error("Failed to save profile");R.success(Ky()),s.invalidateQueries({queryKey:["teams",e,"me"]}),_(!1)}catch(_e){console.error(_e),R.error(xb())}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");R.success(Qy()),s.invalidateQueries({queryKey:["teams",e,"me"]})}catch(ae){console.error(ae),R.error(db())}finally{i(!1)}},X=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");R.success(Wh()),s.invalidateQueries({queryKey:["teams",e,"me"]})}catch(ae){console.error(ae),R.error(Cb())}finally{i(!1)}},{mutate:xe}=U({mutationFn:async(ae)=>{let _e=await A.api.teams[":teamId"].settings.$patch({param:{teamId:ae.teamId},json:ae.data});if(!_e.ok)throw Error("Failed to update settings");return await _e.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["teams",e,"settings"]})}}),he=(ae)=>{xe({teamId:e,data:{key:"transcode.videoStrategy",value:ae}})},Ce=(ae)=>{xe({teamId:e,data:{key:"transcode.hardwareAcceleration",value:ae}})};if(j||F)return t("div",{className:"flex h-screen items-center justify-center",children:t(L,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(oe)return t("div",{className:"p-8 text-center text-red-500",children:ls()});let Se=Y?.transcode?.videoStrategy||da.best_match;if(Se==="single"||Se==="disable")Se=da.best_match;else if(Se==="full")Se=da.all;let ee=Y?.transcode?.hardwareAcceleration||Oi.off;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:cS()}),o("button",{onClick:()=>r("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(Hn,{className:"w-5 h-5"}),Gb(),a==="general"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(ui,{className:"w-5 h-5"}),zh(),a==="notifications"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(Zt,{className:"w-5 h-5"}),Zm(),a==="developer"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),se?.role==="owner"&&o(B,{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:tI()}),o("button",{onClick:()=>r("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(Ua,{className:"w-5 h-5"}),Mh(),a==="transcode"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(Uo,{className:"w-5 h-5"}),Td(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),se?.role==="owner"&&o(B,{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:cy()}),o("button",{onClick:()=>r("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(no,{className:"w-5 h-5"}),DS(),a==="providers"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(rn,{className:"w-5 h-5"}),_h(),a==="image-video"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(_t,{className:"w-5 h-5"}),kg(),a==="skills"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(fn,{className:"w-5 h-5"}),Lc(),a==="mcp"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(wt,{className:"w-5 h-5"}),ey(),a==="agents"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>r("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(zl,{className:"w-5 h-5"}),PA(),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"&&gh(),a==="transcode"&&Mh(),a==="quotas"&&gg(),a==="skills"&&Pg(),a==="mcp"&&Lc(),a==="providers"&&ly(),a==="image-video"&&_h(),a==="agents"&&iy(),a==="sandbox"&&NA(),a==="notifications"&&Sx(),a==="developer"&&T_()]}),o("p",{className:"text-sm text-muted-foreground mt-1",children:[a==="general"&&Vb(),a==="transcode"&&qg(),a==="quotas"&&Ag(),a==="skills"&&vE(),a==="mcp"&&md(),a==="providers"&&LS(),a==="image-video"&&Av(),a==="agents"&&ty(),a==="sandbox"&&RC(),a==="notifications"&&Ex(),a==="developer"&&I_()]})]})}),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(Ct,{children:[o(Nt,{children:[t(Ot,{children:iS()}),t(Ht,{children:lS()})]}),t(Rt,{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:Gy()}),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:()=>y.current?.click(),children:[o(Ee,{className:"w-24 h-24",children:[se?.image&&t(Ie,{src:se.image,alt:se.name,className:"object-cover w-24 h-24"}),t(Te,{className:"text-2xl bg-primary/40 text-foreground",children:D(se?.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:o0()})})]}),o("div",{className:"flex gap-2",children:[t(S,{variant:"outline",size:"sm",onClick:()=>y.current?.click(),children:OI()}),se?.image&&t(S,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:k,children:vl()})]}),t("input",{type:"file",ref:y,className:"hidden",accept:"image/*",onChange:I})]}),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:hl()}),t(H,{value:d,onChange:(ae)=>c(ae.target.value),placeholder:J_(),className:"max-w-md"})]}),o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:Cf()}),t(H,{value:se?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),t("p",{className:"text-xs text-muted-foreground",children:F_()})]}),o(S,{onClick:X,disabled:m||!d.trim(),className:"mt-2",children:[m&&t(L,{className:"w-4 h-4 animate-spin mr-2"}),Ds()]})]})]})})]}),o(Ct,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[o(Nt,{children:[t(Ot,{children:Iw()}),t(Ht,{children:eE()})]}),t(Rt,{className:"space-y-4",children:t("div",{className:"max-w-xs",children:o(Le,{value:M,onValueChange:q,children:[t(Be,{children:t(Ze,{placeholder:WC()})}),o(Ue,{children:[t(ne,{value:"en",children:Q_()}),t(ne,{value:"zh",children:i0()})]})]})})})]}),t(qs,{isOpen:f,onClose:()=>_(!1),imageSrc:g,onConfirm:G})]}),a==="transcode"&&t("div",{className:"h-full overflow-y-auto pr-1",children:o(Ct,{children:[o(Nt,{children:[t(Ot,{children:SI()}),o(Ht,{children:[t("span",{className:"block mb-2",children:qg()}),t("span",{className:"block",children:CI()})]})]}),o(Rt,{className:"space-y-6",children:[o("div",{className:"space-y-3",children:[t("h3",{className:"text-lg font-medium",children:qI()}),o("div",{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Se===da.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>he(da.best_match),children:[t("div",{className:"font-semibold",children:Xy()}),t("div",{className:"text-sm text-muted-foreground",children:e0()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Se===da.all?"border-primary bg-primary/5":"border-border"),onClick:()=>he(da.all),children:[t("div",{className:"font-semibold",children:hy()}),t("div",{className:"text-sm text-muted-foreground",children:gy()})]})]})]}),o("div",{className:"space-y-3 pt-6 border-t border-border",children:[t("h3",{className:"text-lg font-medium",children:lw()}),o("div",{className:"space-y-3",children:[o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===Oi.off?"border-primary bg-primary/5":"border-border"),onClick:()=>Ce(Oi.off),children:[t("div",{className:"font-semibold",children:dw()}),t("div",{className:"text-sm text-muted-foreground",children:fw()})]}),o("div",{className:E("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",ee===Oi.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>Ce(Oi.auto),children:[t("div",{className:"font-semibold",children:cw()}),t("div",{className:"text-sm text-muted-foreground",children:uw()})]})]})]})]})]})}),a==="skills"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Ms,{teamId:e})}),a==="mcp"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Is,{teamId:e})}),a==="providers"&&t(Cs,{teamId:e}),a==="image-video"&&t(Rs,{teamId:e}),a==="agents"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(_s,{teamId:e})}),a==="sandbox"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ks,{teamId:e})}),a==="notifications"&&t(Ts,{teamId:e}),a==="developer"&&t(Vs,{teamId:e}),a==="quotas"&&t(Ps,{teamId:e})]})]})})]})})}var Tr=Fe("/teams/$teamId/settings")({component:Er});export{Tr as Route};
|