@shumai-one/shumai 0.4.6 → 0.4.7

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.
Files changed (143) hide show
  1. package/bin/{chunk-1bgsphyz.js → chunk-05tnmf8h.js} +2 -2
  2. package/bin/chunk-0xsgx9ep.js +1 -0
  3. package/bin/{chunk-3d5rm1d1.js → chunk-0ygtayqf.js} +1 -1
  4. package/bin/{chunk-crja7whq.js → chunk-11c93g1m.js} +2 -2
  5. package/bin/chunk-1ajgdv26.js +1 -0
  6. package/bin/{chunk-ba33nf0q.js → chunk-1ntn42d2.js} +3 -3
  7. package/bin/chunk-2kxhdnma.js +3 -0
  8. package/bin/chunk-30dsxm8s.js +1 -0
  9. package/bin/chunk-3b6h719s.js +3 -0
  10. package/bin/{chunk-pdh9bnyj.js → chunk-3g5pyw2e.js} +2 -2
  11. package/bin/{chunk-p75f5pgq.js → chunk-3h9c5ak3.js} +2 -2
  12. package/bin/{chunk-2qjfpmcf.js → chunk-3m5kwcj7.js} +1 -1
  13. package/bin/{chunk-w1wxzqqb.js → chunk-3p1bb08a.js} +2 -2
  14. package/bin/{chunk-6vxzkrsj.js → chunk-3r5yc5wm.js} +4 -4
  15. package/bin/{chunk-sab7tjxw.js → chunk-3tyk9xgf.js} +3 -3
  16. package/bin/{chunk-h9mka9br.js → chunk-4a88wwg2.js} +1 -1
  17. package/bin/{chunk-z08bqvkc.js → chunk-4f5pnnah.js} +14 -14
  18. package/bin/{chunk-dpc11hpd.js → chunk-4jgq9m51.js} +7 -7
  19. package/bin/{chunk-d7fwggt6.js → chunk-4m8gk79m.js} +1 -1
  20. package/bin/{chunk-b9hyc0a1.js → chunk-53vtc74g.js} +2 -2
  21. package/bin/{chunk-1kt5dzjv.js → chunk-58e1a3re.js} +2 -2
  22. package/bin/{chunk-dmvvt8va.js → chunk-5qkwpy8c.js} +2 -2
  23. package/bin/{chunk-07jszkhj.js → chunk-5rk7dyx9.js} +58 -58
  24. package/bin/{chunk-ga3pahzf.js → chunk-5v4s2kp4.js} +1 -1
  25. package/bin/{chunk-v8v8vdf7.js → chunk-5wp37g6w.js} +4 -4
  26. package/bin/{chunk-hs2r9qaw.js → chunk-628k58ek.js} +2 -2
  27. package/bin/{chunk-rp4pc6kz.js → chunk-6kdf411z.js} +1 -1
  28. package/bin/chunk-6ksrrayx.css +1 -0
  29. package/bin/chunk-6rjkbwz6.js +14 -0
  30. package/bin/{chunk-md5pcq46.js → chunk-781990k7.js} +4 -4
  31. package/bin/{chunk-ey3h4sct.js → chunk-887pj9xd.js} +2 -2
  32. package/bin/{chunk-1jybg56e.js → chunk-8b1w6bj9.js} +1 -1
  33. package/bin/{chunk-0wvhahzh.js → chunk-8gna37dd.js} +1 -1
  34. package/bin/{chunk-rmzcarv9.js → chunk-8sf106rq.js} +1 -1
  35. package/bin/{chunk-2jrjwaqr.js → chunk-8ystwvdt.js} +1 -1
  36. package/bin/{chunk-3j5njrpr.js → chunk-9v6eqa3n.js} +2 -2
  37. package/bin/{chunk-rsd164d9.js → chunk-9va1mzeq.js} +1 -1
  38. package/bin/{chunk-kmbjp5kp.js → chunk-an6nsq1t.js} +1 -1
  39. package/bin/{chunk-vzj2j11x.js → chunk-ayq8dskd.js} +1 -1
  40. package/bin/{chunk-y20sbaz5.js → chunk-b0rjvx5g.js} +1 -1
  41. package/bin/chunk-bgm76rzj.js +1 -0
  42. package/bin/chunk-btmxr226.js +1 -0
  43. package/bin/chunk-camzbwqh.js +2 -0
  44. package/bin/{chunk-t350k3s1.js → chunk-ccvjwhqq.js} +1 -1
  45. package/bin/{chunk-pgj2kjnn.js → chunk-dkzyv61a.js} +2 -2
  46. package/bin/{chunk-y56yvezn.js → chunk-dyq6h9ha.js} +1 -1
  47. package/bin/{chunk-teqprbd8.js → chunk-e17daz1x.js} +1 -1
  48. package/bin/{chunk-dbw8c1jj.js → chunk-ebf1r872.js} +4 -4
  49. package/bin/{chunk-2vzzd0q6.js → chunk-ebx3bd4c.js} +1 -1
  50. package/bin/{chunk-161rxeq2.js → chunk-ee3mrvqp.js} +1 -1
  51. package/bin/chunk-fg6zf2gb.js +2 -0
  52. package/bin/{chunk-6y4xkcte.js → chunk-fhazy8f9.js} +1 -1
  53. package/bin/{chunk-gqr5hxhj.js → chunk-fk712d68.js} +1 -1
  54. package/bin/{chunk-afnzb9ne.js → chunk-fvgb6rps.js} +2 -2
  55. package/bin/chunk-g9gmht89.js +2 -0
  56. package/bin/{chunk-1t51fp6n.js → chunk-gf4n4ahk.js} +1 -1
  57. package/bin/{chunk-gcjsw9yp.js → chunk-h3wr8nnk.js} +1 -1
  58. package/bin/chunk-htpjtarr.js +2 -0
  59. package/bin/{chunk-kg8eg9z3.js → chunk-hye75kp0.js} +2 -2
  60. package/bin/{chunk-3tg39jx7.js → chunk-j41mya13.js} +2 -2
  61. package/bin/chunk-j547gtag.js +2 -0
  62. package/bin/{chunk-a4056d0r.js → chunk-jde9r5mj.js} +1 -1
  63. package/bin/chunk-jf4kcad0.js +1 -0
  64. package/bin/{chunk-tgr86ac4.js → chunk-jt04mf5s.js} +1 -1
  65. package/bin/{chunk-hnhdq2wd.js → chunk-k3qypq3x.js} +1 -1
  66. package/bin/chunk-k5hnrtrt.js +1 -0
  67. package/bin/{chunk-mtb9fpj2.js → chunk-k810fstm.js} +1 -1
  68. package/bin/{chunk-3n4224c0.js → chunk-kg2c445x.js} +1 -1
  69. package/bin/{chunk-edqd8evk.js → chunk-kq2qbwx1.js} +1 -1
  70. package/bin/{chunk-7nvk7waw.js → chunk-m2h7a172.js} +1 -1
  71. package/bin/{chunk-brwbhbmc.js → chunk-m638fg4n.js} +5 -5
  72. package/bin/{chunk-3dgahs95.js → chunk-mm1a0zja.js} +1 -1
  73. package/bin/{chunk-hxyg5q2a.js → chunk-njabdtvb.js} +2 -2
  74. package/bin/{chunk-b6q287d1.js → chunk-njqf50vw.js} +1 -1
  75. package/bin/{chunk-47tn3vtg.js → chunk-nn5hyf6f.js} +1 -1
  76. package/bin/{chunk-t7bvde99.js → chunk-nnq8g9yy.js} +3 -3
  77. package/bin/{chunk-8cn7fx40.js → chunk-ny7qjn6s.js} +1 -1
  78. package/bin/{chunk-3d9tfxp4.js → chunk-p5fwjk5c.js} +1 -1
  79. package/bin/{chunk-s05cdax2.js → chunk-pa1fmskf.js} +1 -1
  80. package/bin/{chunk-a796sgcw.js → chunk-pcspeqwq.js} +2 -2
  81. package/bin/{chunk-yfr0hzb7.js → chunk-q1d7x1cc.js} +1 -1
  82. package/bin/{chunk-y1b3ck7m.js → chunk-q45n02fs.js} +1 -1
  83. package/bin/chunk-q6jsw0rr.js +211 -0
  84. package/bin/chunk-qjzyze00.js +1 -0
  85. package/bin/{chunk-2yr5k567.js → chunk-r55htzxr.js} +1 -1
  86. package/bin/{chunk-46wfxyd7.js → chunk-r7e2fmmx.js} +2 -2
  87. package/bin/{chunk-5kvc1gp2.js → chunk-rbagbd0e.js} +1 -1
  88. package/bin/{chunk-dz076sh7.js → chunk-rdscv38p.js} +1 -1
  89. package/bin/chunk-rfhmk32e.js +1 -0
  90. package/bin/{chunk-qs7855cz.js → chunk-rkafv27g.js} +2 -2
  91. package/bin/{chunk-hd6dnnyg.js → chunk-rkqpnyzx.js} +1 -1
  92. package/bin/{chunk-z6jpt0h6.js → chunk-s30fjvzs.js} +3 -3
  93. package/bin/{chunk-dj5a6kkh.js → chunk-s41mgkse.js} +1 -1
  94. package/bin/{chunk-988casfy.js → chunk-s63vj79f.js} +1 -1
  95. package/bin/{chunk-9d0thqcy.js → chunk-t3t7dcfq.js} +1 -1
  96. package/bin/{chunk-gsfcpcye.js → chunk-twyxs4z2.js} +1 -1
  97. package/bin/{chunk-1dqsf5qj.js → chunk-typ46eqd.js} +5 -5
  98. package/bin/chunk-v1sgrg0r.js +1 -0
  99. package/bin/{chunk-j9ks8bd7.js → chunk-vdnmq163.js} +1 -1
  100. package/bin/{chunk-jg2v25d2.js → chunk-vx66rms0.js} +2 -2
  101. package/bin/{chunk-9nvymwqj.js → chunk-wvq717b5.js} +2 -2
  102. package/bin/chunk-xbge27m4.js +1 -0
  103. package/bin/{chunk-ysv80zyb.js → chunk-xca338dw.js} +3 -3
  104. package/bin/chunk-xcsz1wp7.js +1 -0
  105. package/bin/{chunk-ehpfg3km.js → chunk-xznabrt2.js} +1 -1
  106. package/bin/{chunk-pvg3msgw.js → chunk-xzyfnfck.js} +3 -3
  107. package/bin/{chunk-9trnkbtr.js → chunk-ycw3rwhx.js} +3 -3
  108. package/bin/{chunk-qbqym9m6.js → chunk-yqvhgtez.js} +2 -2
  109. package/bin/{chunk-4syt6rn0.js → chunk-yr03tf5r.js} +2 -2
  110. package/bin/{chunk-n3xjwszr.js → chunk-z9jpgxf1.js} +1 -1
  111. package/bin/chunk-zb0az2tq.js +2 -0
  112. package/bin/{chunk-pwkby9h7.js → chunk-zbt4h7n0.js} +1 -1
  113. package/bin/{chunk-kk42xhgz.js → chunk-zcdqsp1e.js} +1 -1
  114. package/bin/chunk-zej27b5c.js +2 -0
  115. package/bin/{chunk-axmd242s.js → chunk-zmjtv19e.js} +1 -1
  116. package/bin/{chunk-7e5z637e.js → chunk-zr11zfwc.js} +1 -1
  117. package/bin/{chunk-k6avge95.js → chunk-zz0522zr.js} +4 -4
  118. package/bin/shumai-app.html +1 -1
  119. package/bin/shumai-app.js +294 -293
  120. package/package.json +7 -7
  121. package/bin/chunk-0c67210c.js +0 -1
  122. package/bin/chunk-2z1pnt7h.js +0 -2
  123. package/bin/chunk-3vmapyk9.js +0 -1
  124. package/bin/chunk-886pnknh.js +0 -3
  125. package/bin/chunk-908pypkr.js +0 -1
  126. package/bin/chunk-952qwf17.js +0 -2
  127. package/bin/chunk-9a2tf0mh.js +0 -2
  128. package/bin/chunk-apfrw0wd.js +0 -3
  129. package/bin/chunk-batadmvr.js +0 -2
  130. package/bin/chunk-bvdvp192.js +0 -1
  131. package/bin/chunk-db1msmdh.js +0 -2
  132. package/bin/chunk-dkx3pmdz.js +0 -1
  133. package/bin/chunk-hacyjx1s.js +0 -1
  134. package/bin/chunk-he5nvmqw.js +0 -1
  135. package/bin/chunk-hyr1vtfp.js +0 -1
  136. package/bin/chunk-jh8q3885.js +0 -211
  137. package/bin/chunk-jzbrt2vk.js +0 -1
  138. package/bin/chunk-nqym3zbs.js +0 -1
  139. package/bin/chunk-sebbjvgv.css +0 -1
  140. package/bin/chunk-t8gv2ekj.js +0 -14
  141. package/bin/chunk-vm5tn0zm.js +0 -2
  142. package/bin/chunk-wmjp8dcm.js +0 -1
  143. package/bin/chunk-wy8dkyxj.js +0 -1
@@ -0,0 +1,3 @@
1
+ import{V,P,h,He,D,b,u,Ns,S,L,t,o,K,Z,B,Ic,Ue,A,I,vr,zn,wr,F,St,ke,ve,bt,Xt,eo,Wo,vo,fe,Bt,we,Re,C,ds,E,Ce,Ie,Te,he,ge,Ae,W,Vt,n,Mi,xA,gf,MA,kA,Af,RA,rd,PA,OA,wm,xm,LA,ZA,jA,qA,HA,$A,VA,QA,KA,WA,JA,XA,e0,t0,r0,Cm,n0,Im,o0,Tm,s0,Mm,a0,km,i0,Rm,l0,Nm,c0,Dm,u0,Pm,d0,f0,p0,Om,m0,h0,g0,Fm,Lm,Zm,Bm,A0,_0,S0,E0,C0,k0,R0,N0,F0,od,sd,jm,L0,Z0,qm,B0,U0,Hm,z0,bf,$m,Gm,j0,H0,ad,Q0,K0,W0,e_,l_,c_,u_,d_,Qm,p_,m_,h_,g_,A_,__,Ne,b_,w_,x_,S_,C_,R_,N_,D_,P_,Ym,F_,L_,j_,H_,th,Pc,X_,oy,sy,ay,ly,cy,fy,my,xy,Sy,it,Ey,Cy,ky,Ry,Ny,Oy,Mf,lh,Zy,hl,qy,Hy,Rf,Gy,Vy,dh,Yy,fh,Jy,Xy,Nf,rb,nb,ib,Df,cb,db,ph,mb,hb,Bs,Yo,Tb,kb,gh,ki,pd,Db,Pb,Zb,yh,gl,Ub,md,bh,vh,jb,qb,Hb,Vb,Qb,nv,ov,pv,mv,Ih,hv,gv,_v,yv,Th,Mv,kv,Rv,Nv,Dv,Pv,Ov,Lv,kh,Bv,Uv,zv,Gv,Vv,Qv,Kv,Wv,Yv,nw,aw,fw,pw,mw,hw,Vf,gw,Aw,Dh,_w,yw,bw,vw,ww,Ph,Oh,xw,Sw,Ew,Cw,Fh,Iw,Lh,Tw,Mw,Zh,Bc,_d,kw,Rw,Bh,Nw,Dw,Pw,Ow,Fw,Lw,Zw,Bw,Uw,Uh,zw,jw,Qf,Kf,Qw,Kw,Ww,zh,Yw,Jw,Xw,ex,tx,yd,rx,sx,_l,ax,lx,cx,ux,dx,fx,yx,bx,Sx,Yh,Ex,Xh,eg,vd,Rx,Nx,Dx,tp,rp,Lx,Zx,zx,Hx,$x,rg,Gx,Qx,fS,pS,mS,hS,og,gS,AS,_S,bS,ES,CS,Ni,Di,Pi,IS,TS,MS,RS,OS,FS,ZS,dg,YS,JS,XS,eE,pg,mg,hg,gg,tE,Ag,_g,yg,bg,rE,nE,aE,lE,xg,dp,uE,fE,pE,hE,fp,pp,mp,hp,yE,Sd,Ed,Cd,Id,Td,vE,wE,Md,xE,kd,SE,Rd,EE,gp,Sl,Ap,CE,IE,NE,DE,Nd,_p,El,Rg,Ng,eC,tC,Fo,zs,Og,Sp,Zg,Bg,vC,Ug,zg,wC,EC,CC,qg,TC,kC,Ip,Gg,GC,VC,Vg,QC,t1,r1,n1,o1,s1,a1,i1,l1,c1,u1,d1,f1,p1,m1,h1,g1,A1,_1,y1,b1,C1,P1,O1,F1,L1,Z1,rA,U1,G1,V1,Q1,nA,K1,sA,W1,Y1,X1,iA,aI,pI,mI,hI,wI,xI,SI,EI,CI,II,TI,MI,kI,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,Tt,H,ce,Pt,k,p,te,R,Ve,ro,Wc,Yc,uA,Jc,ri,dA,ga,Fi,Xc,xo,So,Qr,kn,be,mt,ht,gt,ya,Q,je,Fe,Le,Ze,Be,ne,Pr,lr,gr,Et,kt,Rt,Ut,Mt}from"./chunk-q6jsw0rr.js";import{Uo}from"./chunk-camzbwqh.js";import{To,Ar}from"./chunk-3p1bb08a.js";import{Hl,$l}from"./chunk-z9jpgxf1.js";import{$s,ao,ui,Bo,bn,Gl,di,Hi,Ra,Vl}from"./chunk-9v6eqa3n.js";import{Ql}from"./chunk-fk712d68.js";import{Rn,Nn,Dn,br,xt,_t}from"./chunk-njqf50vw.js";import{fi}from"./chunk-e17daz1x.js";import{Co}from"./chunk-9va1mzeq.js";import{Io}from"./chunk-jt04mf5s.js";import{Vn,io}from"./chunk-8ystwvdt.js";import{vn}from"./chunk-8sf106rq.js";import{lo}from"./chunk-q1d7x1cc.js";import{sn}from"./chunk-fhazy8f9.js";import{co}from"./chunk-80qz30dc.js";import{Rr}from"./chunk-0ygtayqf.js";var js=[["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"}]],Ua=I("at-sign",js);var Os=[["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"}]],Ga=I("film",Os);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=I("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=I("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=I("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"}]],Ha=I("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"}]],Wa=I("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"}]],Za=I("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"}]],wt=I("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=I("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"}]],Xa=I("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=I("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"}]],jt=I("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=I("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=I("zoom-out",ar);S();S();var sr=ds("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 Oe({className:e,orientation:r="vertical",...a}){return t("div",{role:"group","data-slot":"field","data-orientation":r,className:C(sr({orientation:r}),e),...a})}function $e({className:e,...r}){return t(Q,{"data-slot":"field-label",className:C("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",e),...r})}function sa({className:e,...r}){return t("p",{"data-slot":"field-description",className:C("text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...r})}function Ke({className:e,children:r,errors:a,...l}){let s=D(()=>{if(r)return r;if(!a?.length)return null;let d=[...new Map(a.map((c)=>[c?.message,c])).values()];if(d?.length==1)return d[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:d.map((c,f)=>c?.message&&t("li",{children:c.message},f))})},[r,a]);if(!s)return null;return t("div",{role:"alert","data-slot":"field-error",className:C("text-sm font-normal text-destructive",e),...l,children:s})}function es({update:e,notify:r,unwatched:a}){return{link:l,unlink:s,propagate:d,checkDirty:c,shallowPropagate:f};function l(g,y,x){let m=y.depsTail;if(m!==void 0&&m.dep===g)return;let i=m!==void 0?m.nextDep:y.deps;if(i!==void 0&&i.dep===g){i.version=x,y.depsTail=i;return}let v=g.subsTail;if(v!==void 0&&v.version===x&&v.sub===y)return;let w=y.depsTail=g.subsTail={version:x,dep:g,sub:y,prevDep:m,nextDep:i,prevSub:v,nextSub:void 0};if(i!==void 0)i.prevDep=w;if(m!==void 0)m.nextDep=w;else y.deps=w;if(v!==void 0)v.nextSub=w;else g.subs=w}function s(g,y=g.sub){let{dep:x,prevDep:m,nextDep:i,nextSub:v,prevSub:w}=g;if(i!==void 0)i.prevDep=m;else y.depsTail=m;if(m!==void 0)m.nextDep=i;else y.deps=i;if(v!==void 0)v.prevSub=w;else x.subsTail=w;if(w!==void 0)w.nextSub=v;else if((x.subs=v)===void 0)a(x);return i}function d(g){let y=g.nextSub,x;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)r(m);if(i&1){let v=m.subs;if(v!==void 0){let w=(g=v).nextSub;if(w!==void 0)x={value:y,prev:x},y=w;continue}}if((g=y)!==void 0){y=g.nextSub;continue}while(x!==void 0)if(g=x.value,x=x.prev,g!==void 0){y=g.nextSub;continue e}break}while(!0)}function c(g,y){let x,m=0,i=!1;e:do{let v=g.dep,w=v.flags;if(y.flags&16)i=!0;else if((w&17)===17){if(e(v)){let M=v.subs;if(M.nextSub!==void 0)f(M);i=!0}}else if((w&33)===33){if(g.nextSub!==void 0||g.prevSub!==void 0)x={value:g,prev:x};g=v.deps,y=v,++m;continue}if(!i){let M=g.nextDep;if(M!==void 0){g=M;continue}}while(m--){let M=y.subs,O=M.nextSub!==void 0;if(O)g=x.value,x=x.prev;else g=M;if(i){if(e(y)){if(O)f(M);y=g.sub;continue}i=!1}else y.flags&=-33;y=g.sub;let Y=g.nextDep;if(Y!==void 0){g=Y;continue e}}return i}while(!0)}function f(g){do{let y=g.sub,x=y.flags;if((x&48)===32){if(y.flags=x|16,(x&6)===2)r(y)}}while((g=g.nextSub)!==void 0)}function _(g,y){let x=y.depsTail;while(x!==void 0){if(x===g)return!0;x=x.prevDep}return!1}}function ra(e,r,a){let l=typeof e==="object",s=l?e:void 0;return{next:(l?e.next:e)?.bind(s),error:(l?e.error:r)?.bind(s),complete:(l?e.complete:a)?.bind(s)}}var Ma=[],fa=0,{link:ts,unlink:rr,propagate:or,checkDirty:ss,shallowPropagate:as}=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)}}),pa=0,Fa=0,Nt,Da=0;function ze(e){try{++Da,e()}finally{if(!--Da)Aa()}}function ha(e){let r=e.depsTail,a=r!==void 0?r.nextDep:e.deps;while(a!==void 0)a=rr(a,e)}function Aa(){if(Da>0)return;while(pa<Fa){let e=Ma[pa];Ma[pa++]=void 0,e.notify()}pa=0,Fa=0}function va(e,r){let a=typeof e==="function",l=e,s={_snapshot:a?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:a?0:1,get(){if(Nt!==void 0)ts(s,Nt,fa);return s._snapshot},subscribe(d){let c=ra(d),f={current:!1},_=ir(()=>{if(s.get(),!f.current)f.current=!0;else c.next?.(s._snapshot)});return{unsubscribe:()=>{_.stop()}}},_update(d){let c=Nt,f=r?.compare??Object.is;if(a)Nt=s,++fa,s.depsTail=void 0;else if(d===void 0)return!1;if(a)s.flags=5;try{let _=s._snapshot,g=typeof d==="function"?d(_):d===void 0&&a?l(_):d;if(_===void 0||!f(_,g))return s._snapshot=g,!0;return!1}finally{if(Nt=c,a)s.flags&=-5;ha(s)}}};if(a)s.flags=17,s.get=function(){let d=s.flags;if(d&16||d&32&&ss(s.deps,s)){if(s._update()){let c=s.subs;if(c!==void 0)as(c)}}else if(d&32)s.flags=d&-33;if(Nt!==void 0)ts(s,Nt,fa);return s._snapshot};else s.set=function(d){if(s._update(d)){let c=s.subs;if(c!==void 0)or(c),as(c),Aa()}};return s}function ir(e){let r=()=>{let l=Nt;Nt=a,++fa,a.depsTail=void 0,a.flags=6;try{return e()}finally{Nt=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&&ss(this.deps,this))r();else this.flags=2},stop(){this.flags=0,this.depsTail=void 0,ha(this)}};return r(),a}var Ia=class{constructor(e,r){if(this.atom=va(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),r)this.actions=r(this)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ra(e))}},rs=class{constructor(e){this.atom=va(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(ra(e))}};function Ct(e,r){if(typeof e==="function")return new rs(e);if(r)return new Ia(e,r);return new Ia(e)}var os=class{constructor(e,r){if(this.fn=e,this.options=r,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...a)=>{let l=Date.now()-this.lastExecutionTime;if(this.options.leading&&l>=this.options.wait)this.execute(...a);else if(this.lastArgs=a,!this.timeoutId&&this.options.trailing){let s=this.options.wait-l;this.isPending=!0,this.timeoutId=setTimeout(()=>{if(this.lastArgs!==void 0)this.execute(...this.lastArgs)},s)}},this.execute=(...a)=>{this.fn(...a),this.options.onExecute?.(a,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{if(this.isPending&&this.lastArgs)this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{if(this.timeoutId)clearTimeout(this.timeoutId),this.timeoutId=void 0},this.options.leading===void 0&&this.options.trailing===void 0)this.options.leading=!0,this.options.trailing=!0}};function Ta(e,r){return new os(e,r).maybeExecute}var Ea=class{#o=!0;#t;#e;#m;#a;#n;#s;#l;#u=0;#f=5;#i=!1;#d=!1;#r=null;#p=()=>{this.debugLog("Connected to event bus"),this.#n=!0,this.#i=!1,this.debugLog("Emitting queued events",this.#a),this.#a.forEach((e)=>this.emitEventToBus(e)),this.#a=[],this.stopConnectLoop(),this.#e().removeEventListener("tanstack-connect-success",this.#p)};#c=()=>{if(this.#u<this.#f){this.#u++,this.dispatchCustomEvent("tanstack-connect",{});return}this.#e().removeEventListener("tanstack-connect",this.#c),this.#d=!0,this.debugLog("Max retries reached, giving up on connection"),this.stopConnectLoop()};#g=()=>{if(this.#i)return;this.#i=!0,this.#e().addEventListener("tanstack-connect-success",this.#p),this.#c()};constructor({pluginId:e,debug:r=!1,enabled:a=!0,reconnectEveryMs:l=300}){this.#t=e,this.#o=a,this.#e=this.getGlobalTarget,this.#m=r,this.debugLog(" Initializing event subscription for plugin",this.#t),this.#a=[],this.#n=!1,this.#d=!1,this.#s=null,this.#l=l}startConnectLoop(){if(this.#s!==null||this.#n)return;this.debugLog(`Starting connect loop (every ${this.#l}ms)`),this.#s=setInterval(this.#c,this.#l)}stopConnectLoop(){if(this.#i=!1,this.#s===null)return;clearInterval(this.#s),this.#s=null,this.#a=[],this.debugLog("Stopped connect loop")}debugLog(...e){if(this.#m)console.log(`\uD83C\uDF34 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<"u"&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog("Using global event target"),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<"u"&&typeof window.addEventListener<"u")return this.debugLog("Using window as event target"),window;let e=typeof EventTarget<"u"?new EventTarget:void 0;if(typeof e>"u"||typeof e.addEventListener>"u")return this.debugLog("No event mechanism available, running in non-web environment"),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1};return this.debugLog("Using new EventTarget as fallback"),e}getPluginId(){return this.#t}dispatchCustomEventShim(e,r){try{let a=new Event(e,{detail:r});this.#e().dispatchEvent(a)}catch(a){this.debugLog("Failed to dispatch shim event")}}dispatchCustomEvent(e,r){try{this.#e().dispatchEvent(new CustomEvent(e,{detail:r}))}catch(a){this.dispatchCustomEventShim(e,r)}}emitEventToBus(e){this.debugLog("Emitting event to client bus",e),this.dispatchCustomEvent("tanstack-dispatch-event",e)}createEventPayload(e,r){return{type:`${this.#t}:${e}`,payload:r,pluginId:this.#t}}emit(e,r){if(!this.#o){this.debugLog("Event bus client is disabled, not emitting event",e,r);return}if(this.#r)this.debugLog("Emitting event to internal event target",e,r),this.#r.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,r)}));if(this.#d){this.debugLog("Previously failed to connect, not emitting to bus");return}if(!this.#n){if(this.debugLog("Bus not available, will be pushed as soon as connected"),this.#a.push(this.createEventPayload(e,r)),typeof CustomEvent<"u"&&!this.#i)this.#g(),this.startConnectLoop();return}return this.emitEventToBus(this.createEventPayload(e,r))}on(e,r,a){let l=a?.withEventTarget??!1,s=`${this.#t}:${e}`;if(l){if(!this.#r)this.#r=new EventTarget;this.#r.addEventListener(s,(c)=>{r(c.detail)})}if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event",s),()=>{};let d=(c)=>{this.debugLog("Received event from bus",c.detail),r(c.detail)};return this.#e().addEventListener(s,d),this.debugLog("Registered event to bus",s),()=>{if(l)this.#r?.removeEventListener(s,d);this.#e().removeEventListener(s,d)}}onAll(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}onAllPluginEvents(e){if(!this.#o)return this.debugLog("Event bus client is disabled, not registering event"),()=>{};let r=(a)=>{let l=a.detail;if(this.#t&&l.pluginId!==this.#t)return;e(l)};return this.#e().addEventListener("tanstack-devtools-global",r),()=>this.#e().removeEventListener("tanstack-devtools-global",r)}};class is extends Ea{constructor(){super({pluginId:"form-devtools",reconnectEveryMs:1000})}}var ut=new is;function Ft(e,r){return typeof e==="function"?e(r):e}function Yt(e,r){return _a(r).reduce((l,s)=>{if(l===null)return null;if(typeof l<"u")return l[s];return},e)}function Kt(e,r,a){let l=_a(r);function s(d){if(!l.length)return Ft(a,d);let c=l.shift();if(typeof c==="string"||typeof c==="number"&&!Array.isArray(d)){if(typeof d==="object"){if(d===null)d={};return{...d,[c]:s(d[c])}}return{[c]:s()}}if(Array.isArray(d)&&typeof c==="number"){let f=d.slice(0,c);return[...f.length?f:Array(c),s(d[c]),...d.slice(c+1)]}return[...Array(c),s()]}return s(e)}function Pa(e,r){let a=_a(r);function l(s){if(!s)return;if(a.length===1){let c=a[0];if(Array.isArray(s)&&typeof c==="number")return s.filter((g,y)=>y!==c);let{[c]:f,..._}=s;return _}let d=a.shift();if(typeof d==="string"||typeof d==="number"&&!Array.isArray(s)){if(typeof s==="object")return{...s,[d]:l(s[d])}}if(typeof d==="number"){if(Array.isArray(s)){if(d>=s.length)return s;let c=s.slice(0,d);return[...c.length?c:Array(d),l(s[d]),...s.slice(d+1)]}}throw Error("It seems we have created an infinite loop in deleteBy. ")}return l(e)}var ns=46,Va=91,La=93,ls=48,nr=57;function _a(e){if(Array.isArray(e))return[...e];if(typeof e!=="string")throw Error("Path must be a string.");let r=e.length,a=[],l=r>0&&e.charCodeAt(0)===Va?1:0,s=!0,d=-1;for(let c=l;c<=r;c++){let f=c<r?e.charCodeAt(c):-1;if(c===r||f===ns||f===Va||f===La){let _=c-l;if(_>0){let g=s&&(_===1||e.charCodeAt(l)!==ls),y=e.slice(l,c);if(g){let x=parseInt(y,10);if(_<=15||String(x)===y)a.push(x);else a.push(y)}else a.push(y)}else if(d!==La&&!(d===-1&&f===La)&&!(d===f&&(f===ns||f===Va)))a.push("");l=c+1,s=!0}else if(f<ls||f>nr)s=!1;d=f}if(!a.length)a.push("");return a}function Ba(e){return!(Array.isArray(e)&&e.length===0)}function It(e,r){let a=(l)=>l.validators.filter(Boolean).map((s)=>({cause:s.cause,validate:s.fn}));return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!1},runValidation:a})}function Lt(e,r){let{asyncDebounceMs:a}=r,{onBlurAsyncDebounceMs:l,onChangeAsyncDebounceMs:s,onDynamicAsyncDebounceMs:d}=r.validators||{},c=a??0,f=(_)=>_.validators.filter(Boolean).map((g)=>{let y=g?.cause||e,x=c;switch(y){case"change":x=s??c;break;case"blur":x=l??c;break;case"dynamic":x=d??c;break;case"submit":x=0;break}if(e==="submit")x=0;return{cause:y,validate:g.fn,debounceMs:x}});return r.validationLogic({form:r.form,group:r.group,validators:r.validators,event:{type:e,fieldName:r.fieldName,async:!0},runValidation:f})}var Jt=(e)=>!!e&&typeof e==="object"&&("fields"in e);function pt(e,r){if(Object.is(e,r))return!0;if(typeof e!=="object"||e===null||typeof r!=="object"||r===null)return!1;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(let[s,d]of e)if(!r.has(s)||!Object.is(d,r.get(s)))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(let s of e)if(!r.has(s))return!1;return!0}let a=Object.keys(e),l=Object.keys(r);if(a.length!==l.length)return!1;if(a.length===0&&!Array.isArray(e)&&!Array.isArray(r)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(r)!==Object.prototype))return!1;for(let s of a)if(!l.includes(s)||!pt(e[s],r[s]))return!1;return!0}var ea=({newFormValidatorError:e,isPreviousErrorFromFormValidator:r,previousErrorValue:a})=>{if(e)return{newErrorValue:e,newSource:"form"};if(r)return{newErrorValue:void 0,newSource:void 0};if(a)return{newErrorValue:a,newSource:"field"};return{newErrorValue:void 0,newSource:void 0}},Gt=({formLevelError:e,fieldLevelError:r})=>{if(r)return{newErrorValue:r,newSource:"field"};if(e)return{newErrorValue:e,newSource:"form"};return{newErrorValue:void 0,newSource:void 0}};function Ye(e,r){if(e===void 0||e===null)return r;return{...e,...r}}var zt=256,xa=[],ba;while(zt--)xa[zt]=(zt+256).toString(16).substring(1);function oa(){let e=0,r,a="";if(!ba||zt+16>256){ba=Array(256),e=256;while(e--)ba[e]=256*Math.random()|0;e=0,zt=0}for(;e<16;e++){if(r=ba[zt+e],e===6)a+=xa[r&15|64];else if(e===8)a+=xa[r&63|128];else a+=xa[r];if(e&1&&e>1&&e<11)a+="-"}return zt++,a}var qa=Ta((e)=>ut.emit("form-state",{id:e.formId,state:e.store.state}),{wait:300});function Qt(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]=Qt(e[l]);return a}if(e instanceof Map){let a=new Map;return e.forEach((l,s)=>{a.set(s,Qt(l))}),a}if(e instanceof Set){let a=new Set;return e.forEach((l)=>{a.add(Qt(l))}),a}let r={};for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a))r[a]=Qt(e[a]);return r}function vt(e,r){return r===e||r.startsWith(`${e}.`)||r.startsWith(`${e}[`)}var ft=(e)=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let r=e.event.async,a=r?void 0:{fn:e.validators.onMount,cause:"mount"},l={fn:r?e.validators.onChangeAsync:e.validators.onChange,cause:"change"},s={fn:r?e.validators.onBlurAsync:e.validators.onBlur,cause:"blur"},d={fn:r?e.validators.onSubmitAsync:e.validators.onSubmit,cause:"submit"},c=r?void 0:{fn:()=>{return},cause:"server"};switch(e.event.type){case"mount":return e.runValidation({validators:[a],form:e.form});case"submit":return e.runValidation({validators:[l,s,d,c],form:e.form});case"server":return e.runValidation({validators:[],form:e.form});case"blur":return e.runValidation({validators:[s,c],form:e.form});case"change":return e.runValidation({validators:[l,c],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function dr(e,r){let a=new Map;for(let l of e){let s=l.path??[],d=r,c="";for(let f=0;f<s.length;f++){let _=s[f];if(_===void 0)continue;let g=typeof _==="object"?_.key:_,y=Number(g);if(Array.isArray(d)&&!Number.isNaN(y))c+=`[${y}]`;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 cs=(e,r)=>{let a=dr(e,r);return{form:a,fields:a}},Dt={validate({value:e,validationSource:r},a){let l=a["~standard"].validate(e);if(l instanceof Promise)throw Error("async function passed to sync validator");if(!l.issues)return;if(r==="field")return l.issues;return cs(l.issues,e)},async validateAsync({value:e,validationSource:r},a){let l=await a["~standard"].validate(e);if(!l.issues)return;if(r==="field")return l.issues;return cs(l.issues,e)}},ta=(e)=>!!e&&("~standard"in e);var at={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function qt(e){function r(x){let m=e.getFieldMeta(x)??at;e.setFieldMeta(x,{...m,_arrayVersion:(m._arrayVersion||0)+1})}function a(x,m,i){r(x);let v=f(x,m,"move",i),w=Math.min(m,i),M=Math.max(m,i);for(let Y=w;Y<=M;Y++)v.push(c(x,Y));let O=Object.keys(e.fieldInfo).reduce((Y,z)=>{if(z.startsWith(c(x,m)))Y.set(z,e.getFieldMeta(z));return Y},new Map);g(v,m<i?"up":"down"),Object.keys(e.fieldInfo).filter((Y)=>Y.startsWith(c(x,i))).forEach((Y)=>{let z=Y.replace(c(x,i),c(x,m)),de=O.get(z);if(de)e.setFieldMeta(Y,de)})}function l(x,m){r(x);let i=f(x,m,"remove");g(i,"up")}function s(x,m,i){r(x),f(x,m,"swap",i).forEach((w)=>{if(!w.toString().startsWith(c(x,m)))return;let M=w.toString().replace(c(x,m),c(x,i)),[O,Y]=[e.getFieldMeta(w),e.getFieldMeta(M)];if(O)e.setFieldMeta(M,O);if(Y)e.setFieldMeta(w,Y)})}function d(x,m){r(x);let i=f(x,m,"insert");g(i,"down"),i.forEach((v)=>{if(v.toString().startsWith(c(x,m)))e.setFieldMeta(v,y())})}function c(x,m){return`${x}[${m}]`}function f(x,m,i,v){let w=[c(x,m)];switch(i){case"swap":w.push(c(x,v));break;case"move":{let[M,O]=[Math.min(m,v),Math.max(m,v)];for(let Y=M;Y<=O;Y++)w.push(c(x,Y));break}default:{let M=e.getFieldValue(x),O=Array.isArray(M)?M.length:0;for(let Y=m+1;Y<O;Y++)w.push(c(x,Y));break}}return Object.keys(e.fieldInfo).filter((M)=>w.some((O)=>M.startsWith(O)))}function _(x,m){return x.replace(/\[(\d+)\]/,(i,v)=>{let w=parseInt(v,10);return`[${m==="up"?w+1:Math.max(0,w-1)}]`})}function g(x,m){(m==="up"?x:[...x].reverse()).forEach((v)=>{let w=_(v.toString(),m),M=e.getFieldMeta(w);if(M)e.setFieldMeta(v,M);else e.setFieldMeta(v,y())})}let y=()=>at;return{bumpArrayVersion:r,handleArrayMove:a,handleArrayRemove:l,handleArraySwap:s,handleArrayInsert:d}}function ja(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}class na{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let s=this.store.subscribe(()=>{qa(this)}),d=ut.on("request-form-state",(y)=>{if(y.payload.id===this._formId)ut.emit("form-api",{id:this._formId,state:this.store.state,options:this.options})}),c=ut.on("request-form-reset",(y)=>{if(y.payload.id===this._formId)this.reset()}),f=ut.on("request-form-force-submit",(y)=>{if(y.payload.id===this._formId)this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1}),_=()=>{f(),c(),d(),s.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=(s)=>{if(!s)return;let d=this.options;this.options=s;let c=s.defaultValues&&!pt(s.defaultValues,d.defaultValues)&&!this.state.isTouched,f=!pt(s.defaultState,d.defaultState)&&!this.state.isTouched;if(!c&&!f)return;if(ze(()=>{this.baseStore.setState(()=>ja(Object.assign({},this.state,f?s.defaultState:{},c?{values:s.defaultValues}:{})))}),c){let _=qt(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=(s,d)=>{let{fieldMeta:c}=this.state,f=this.resetFieldMeta(c);if(s&&!d?.keepDefaultValues)this.options={...this.options,defaultValues:s};this.baseStore.setState(()=>{let _=s??this.options.defaultValues??this.options.defaultState?.values;if(!s)Object.values(this.fieldInfo).forEach((g)=>{if(g.instance&&g.instance.options.defaultValue!==void 0)_=Kt(_,g.instance.name,g.instance.options.defaultValue)});return ja({...this.options.defaultState,values:_,fieldMetaBase:f})})},this.validateAllFields=async(s)=>{let d=[];return ze(()=>{Object.values(this.fieldInfo).forEach((f)=>{if(!f.instance)return;let _=f.instance;if(d.push(Promise.resolve().then(()=>_.validate(s,{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(s,d,c)=>{let f=this.getFieldValue(s),_=Array.isArray(f)?Math.max(f.length-1,0):null,g=[`${s}[${d}]`];for(let i=d+1;i<=(_??0);i++)g.push(`${s}[${i}]`);let y=Object.keys(this.fieldInfo).filter((i)=>g.some((v)=>i.startsWith(v))),x=[];return ze(()=>{y.forEach((i)=>{x.push(Promise.resolve().then(()=>this.validateField(i,c)))})}),(await Promise.all(x)).flat()},this.validateField=(s,d)=>{let c=this.fieldInfo[s]?.instance;if(!c){let{hasErrored:f}=this.validateSync(d);if(f&&!this.options.asyncAlways)return this.getFieldMeta(s)?.errors??[];return this.validateAsync(d).then(()=>this.getFieldMeta(s)?.errors??[])}if(!c.store.state.meta.isTouched)c.setMeta((f)=>({...f,isTouched:!0}));return c.validate(d)},this.validateSync=(s,d)=>{let c=It(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ft}),f=!1,_={};return ze(()=>{for(let x of c){if(!x.validate)continue;let m=this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form"},type:"validate"}),{formError:i,fieldErrors:v}=wa(m),w=ia(x.cause),M=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(v||{})]);if(d?.filterFieldNames)M=new Set([...M].filter(d.filterFieldNames));for(let O of M){if(this.baseStore.state.fieldMetaBase[O]===void 0&&!v?.[O])continue;let Y=this.getFieldMeta(O)??at,{errorMap:z,errorSourceMap:de}=Y,oe=v?.[O],{newErrorValue:T,newSource:q}=ea({newFormValidatorError:oe,isPreviousErrorFromFormValidator:de?.[w]==="form",previousErrorValue:z?.[w]});if(q==="form")_[O]={..._[O],[w]:oe};if(z?.[w]!==T)this.setFieldMeta(O,(j=at)=>({...j,errorMap:{...j.errorMap,[w]:T},errorSourceMap:{...j.errorSourceMap,[w]:q}}))}if(!d?.dontUpdateFormErrorMap){if(this.state.errorMap?.[w]!==i)this.baseStore.setState((O)=>({...O,errorMap:{...O.errorMap,[w]:i}}))}if(i||v)f=!0}if(d?.dontUpdateFormErrorMap)return;let g=ia("submit");if(this.state.errorMap?.[g]&&s!=="submit"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[g]:void 0}}));let y=ia("server");if(this.state.errorMap?.[y]&&s!=="server"&&!f)this.baseStore.setState((x)=>({...x,errorMap:{...x.errorMap,[y]:void 0}}))}),{hasErrored:f,fieldsErrorMap:_}},this.validateAsync=async(s,d)=>{let c=Lt(s,{...this.options,form:this,group:d?.group,validationLogic:this.options.validationLogic||ft});if(!this.state.isFormValidating)this.baseStore.setState((x)=>({...x,isFormValidating:!0}));let f=[],_;for(let x of c){if(!x.validate)continue;let m=ia(x.cause);this.state.validationMetaMap[m]?.lastAbortController.abort();let v=new AbortController;this.state.validationMetaMap[m]={lastAbortController:v},f.push(new Promise(async(w)=>{let M;try{M=await new Promise((T,q)=>{setTimeout(async()=>{if(v.signal.aborted)return T(void 0);try{T(await this.runValidator({validate:x.validate,value:{value:this.state.values,formApi:this,validationSource:"form",signal:v.signal},type:"validateAsync"}))}catch(j){q(j)}},x.debounceMs)})}catch(T){M=T}let{formError:O,fieldErrors:Y}=wa(M);if(Y)_=_?{..._,...Y}:Y;let z=ia(x.cause),de=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(_||{})]),oe=Array.from(de);if(d?.filterFieldNames)oe=oe.filter(d.filterFieldNames);for(let T of oe){if(this.baseStore.state.fieldMetaBase[T]===void 0&&!_?.[T])continue;let q=this.getFieldMeta(T)??at,{errorMap:j,errorSourceMap:G}=q,N=_?.[T],{newErrorValue:X,newSource:xe}=ea({newFormValidatorError:N,isPreviousErrorFromFormValidator:G?.[z]==="form",previousErrorValue:j?.[z]});if(j?.[z]!==X)this.setFieldMeta(T,(ye=at)=>({...ye,errorMap:{...ye.errorMap,[z]:X},errorSourceMap:{...ye.errorSourceMap,[z]:xe}}))}if(!d?.dontUpdateFormErrorMap)this.baseStore.setState((T)=>({...T,errorMap:{...T.errorMap,[z]:O}}));w(_?{fieldErrors:_,errorMapKey:z}:void 0)}))}let g=[],y={};if(f.length){g=await Promise.all(f);for(let x of g)if(x?.fieldErrors){let{errorMapKey:m}=x;for(let[i,v]of Object.entries(x.fieldErrors)){let M={...y[i]||{},[m]:v};y[i]=M}}}return this.baseStore.setState((x)=>({...x,isFormValidating:!1})),y},this.validate=(s,d)=>{let{hasErrored:c,fieldsErrorMap:f}=this.validateSync(s,d);if(c&&!this.options.asyncAlways)return f;return this.validateAsync(s,d)},this._handleSubmit=async(s)=>{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=s??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride){if(this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:d});return}}this.baseStore.setState((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=(s)=>Yt(this.state.values,s),this.getFieldMeta=(s)=>this.state.fieldMeta[s],this.getFormGroupMeta=(s)=>this.formGroupMetaDerived.state[s],this.getFieldInfo=(s)=>this.fieldInfo[s]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(s,d)=>{this.baseStore.setState((c)=>({...c,fieldMetaBase:{...c.fieldMetaBase,[s]:Ft(d,c.fieldMetaBase[s])}}))},this.resetFieldMeta=(s)=>Object.keys(s).reduce((d,c)=>{let f=c;return d[f]=at,d},{}),this.setFieldValue=(s,d,c)=>{let f=c?.dontUpdateMeta??!1,_=c?.dontRunListeners??!1,g=c?.dontValidate??!1;if(ze(()=>{if(!f)this.setFieldMeta(s,(y)=>({...y,isTouched:!0,isDirty:!0,errorMap:{...y?.errorMap,onMount:void 0}}));this.baseStore.setState((y)=>({...y,values:Kt(y.values,s,d)}))}),!_)this.getFieldInfo(s).instance?.triggerOnChangeListener();if(!g)this.validateField(s,"change")},this.deleteField=(s)=>{let c=[...Object.keys(this.fieldInfo).filter((f)=>{let _=s.toString();return f.startsWith(`${_}.`)||f.startsWith(`${_}[`)}),s];this.baseStore.setState((f)=>{let _={...f};return c.forEach((g)=>{_.values=Pa(_.values,g),delete this.fieldInfo[g],delete _.fieldMetaBase[g]}),_})},this.pushFieldValue=(s,d,c)=>{this.setFieldValue(s,(f)=>[...Array.isArray(f)?f:[],d],c),qt(this).bumpArrayVersion(s)},this.insertFieldValue=async(s,d,c,f)=>{this.setFieldValue(s,(g)=>[...g.slice(0,d),c,...g.slice(d)],Ye(f,{dontValidate:!0}));let _=f?.dontValidate??!1;if(!_)await this.validateField(s,"change");if(qt(this).handleArrayInsert(s,d),!_)await this.validateArrayFieldsStartingFrom(s,d,"change")},this.replaceFieldValue=async(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>g.map((y,x)=>x===d?c:y),Ye(f,{dontValidate:!0})),qt(this).bumpArrayVersion(s),!(f?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.removeFieldValue=async(s,d,c)=>{let f=this.getFieldValue(s),_=Array.isArray(f)?Math.max(f.length-1,0):null;if(this.setFieldValue(s,(y)=>y.filter((x,m)=>m!==d),Ye(c,{dontValidate:!0})),qt(this).handleArrayRemove(s,d),_!==null){let y=`${s}[${_}]`;this.deleteField(y)}if(!(c?.dontValidate??!1))await this.validateField(s,"change"),await this.validateArrayFieldsStartingFrom(s,d,"change")},this.swapFieldValues=(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>{let y=g[d],x=g[c];return Kt(Kt(g,`${d}`,x),`${c}`,y)},Ye(f,{dontValidate:!0})),qt(this).handleArraySwap(s,d,c),!(f?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.moveFieldValues=(s,d,c,f)=>{if(this.setFieldValue(s,(g)=>{let y=[...g];return y.splice(c,0,y.splice(d,1)[0]),y},Ye(f,{dontValidate:!0})),qt(this).handleArrayMove(s,d,c),!(f?.dontValidate??!1))this.validateField(s,"change"),this.validateField(`${s}[${d}]`,"change"),this.validateField(`${s}[${c}]`,"change")},this.clearFieldValues=(s,d)=>{let c=this.getFieldValue(s),f=Array.isArray(c)?Math.max(c.length-1,0):null;if(this.setFieldValue(s,[],Ye(d,{dontValidate:!0})),qt(this).bumpArrayVersion(s),f!==null)for(let g=0;g<=f;g++){let y=`${s}[${g}]`;this.deleteField(y)}if(!(d?.dontValidate??!1))this.validateField(s,"change")},this.resetField=(s)=>{this.baseStore.setState((d)=>{let c=this.getFieldInfo(s).instance?.options.defaultValue,f=Yt(this.options.defaultValues,s),_=c??f;return{...d,fieldMetaBase:{...d.fieldMetaBase,[s]:at},values:_!==void 0?Kt(d.values,s,_):d.values}})},this.setErrorMap=(s)=>{ze(()=>{Object.entries(s).forEach(([d,c])=>{let f=d;if(Jt(c)){let{formError:_,fieldErrors:g}=wa(c);for(let y of Object.keys(this.fieldInfo)){if(!this.getFieldMeta(y))continue;this.setFieldMeta(y,(m)=>({...m,errorMap:{...m.errorMap,[f]:g?.[y]},errorSourceMap:{...m.errorSourceMap,[f]:"form"}}))}this.baseStore.setState((y)=>({...y,errorMap:{...y.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((s,[d,c])=>{if(Object.keys(c).length&&c.errors.length)s[d]={errors:c.errors,errorMap:c.errorMap};return s},{})}),this.parseValuesWithSchema=(s)=>Dt.validate({value:this.state.values,validationSource:"form"},s),this.parseValuesWithSchemaAsync=(s)=>Dt.validateAsync({value:this.state.values,validationSource:"form"},s),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??oa(),this._devtoolsSubmissionOverride=!1;let r=ja({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){r=e.transform({state:r}).state;for(let s of Object.keys(r.errorMap)){let d=r.errorMap[s];if(d===void 0||!Jt(d))continue;for(let c of Object.keys(d.fields)){let f=d.fields[c];if(f===void 0)continue;let _=r.fieldMetaBase[c];r.fieldMetaBase[c]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,..._??{},errorSourceMap:{..._?.errorSourceMap??{},onChange:"form"},errorMap:{..._?.errorMap??{},[s]:f}}}}}this.baseStore=Ct(r);let a=void 0;this.fieldMetaDerived=Ct((s)=>{let d=this.baseStore.get(),c=0,f={};for(let _ of Object.keys(d.fieldMetaBase)){let g=d.fieldMetaBase[_],y=a?.fieldMetaBase[_],x=s?.[_],m=Yt(d.values,_),i=x?.errors;if(!y||g.errorMap!==y.errorMap){i=Object.values(g.errorMap??{}).filter((Y)=>Y!==void 0);let O=this.getFieldInfo(_)?.instance;if(!O||!O.options.disableErrorFlat)i=i.flat(1)}let v=!Ba(i),w=!g.isDirty,M=pt(m,this.getFieldInfo(_)?.instance?.options.defaultValue??Yt(this.options.defaultValues,_));if(x&&x.isPristine===w&&x.isValid===v&&x.isDefaultValue===M&&x.errors===i&&g===y){f[_]=x,c++;continue}f[_]={...g,errors:i??[],isPristine:w,isValid:v,isDefaultValue:M}}if(!Object.keys(d.fieldMetaBase).length)return f;if(s&&c===Object.keys(d.fieldMetaBase).length)return s;return a=this.baseStore.get(),f}),this.formGroupMetaDerived=Ct((s)=>{let d=this.baseStore.get(),c=this.fieldMetaDerived.get(),f={};for(let _ of this.formGroupApis){let g=_.name,y=d.formGroupStateBase[g]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},x=c[g],m=!1,i=!0,v=!1,w=!1,M=!0,O=!1;for(let Me in c){if(Me===g)continue;if(!vt(g,Me))continue;let Se=c[Me];if(!Se)continue;if(Se.isValidating)m=!0;if(!Se.isValid)i=!1;if(Se.isTouched)v=!0;if(Se.isBlurred)w=!0;if(!Se.isDefaultValue)M=!1;if(Se.isDirty)O=!0}let Y=!O,z=!!m||y.isValidating,de=x?.errorMap??{},oe=x?.errorSourceMap??{},T=Boolean(de.onMount||Object.entries(c).some(([Me,Se])=>Se&&Me!==g&&vt(g,Me)&&Se.errorMap.onMount)),q=s?.[g],j=q?.errors??[];if(!q||q.__srcErrorMap!==de)j=Object.values(de).reduce((Me,Se)=>{if(Se===void 0)return Me;if(Se&&typeof Se==="object"&&"fields"in Se){let ae=Se.group;if(ae!==void 0)Me.push(ae);return Me}return Me.push(Se),Me},[]);let G=j.length===0,N=i&&G,X=_.options.canSubmitWhenInvalid??!1,xe=y.submissionAttempts===0&&!v&&!T||!z&&!y.isSubmitting&&N||X;if(q&&q.errorMap===de&&q.errorSourceMap===oe&&q.errors===j&&q.isFieldsValidating===m&&q.isFieldsValid===i&&q.isGroupValid===G&&q.isValid===N&&q.canSubmit===xe&&q.isTouched===v&&q.isBlurred===w&&q.isPristine===Y&&q.isDefaultValue===M&&q.isDirty===O&&q.isValidating===z&&q.isSubmitting===y.isSubmitting&&q.isSubmitted===y.isSubmitted&&q.submissionAttempts===y.submissionAttempts&&q.isSubmitSuccessful===y.isSubmitSuccessful){f[g]=q;continue}let ye={...y,errorMap:de,errorSourceMap:oe,_arrayVersion:x?._arrayVersion??0,isTouched:v,isBlurred:w,isDirty:O,isPristine:Y,isDefaultValue:M,isValid:N,errors:j,isValidating:z,isFieldsValidating:m,isFieldsValid:i,isGroupValid:G,canSubmit:xe};Object.defineProperty(ye,"__srcErrorMap",{value:de,enumerable:!1,configurable:!0}),f[g]=ye}return f});let l=void 0;this.store=Ct((s)=>{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),y=f.some((G)=>G.isTouched),x=f.some((G)=>G.isBlurred),m=f.every((G)=>G.isDefaultValue),i=y&&d.errorMap?.onMount,v=f.some((G)=>G.isDirty),w=!v,M=Boolean(d.errorMap?.onMount||f.some((G)=>G?.errorMap?.onMount)),O=!!_,Y=s?.errors??[];if(!l||d.errorMap!==l.errorMap)Y=Object.values(d.errorMap).reduce((G,N)=>{if(N===void 0)return G;if(N&&Jt(N))return G.push(N.form),G;return G.push(N),G},[]);let z=Y.length===0,de=g&&z,oe=this.options.canSubmitWhenInvalid??!1,T=d.submissionAttempts===0&&!y&&!M||!O&&!d.isSubmitting&&de||oe,q=d.errorMap;if(i)Y=Y.filter((G)=>G!==d.errorMap.onMount),q=Object.assign(q,{onMount:void 0});if(s&&l&&s.errorMap===q&&s.fieldMeta===this.fieldMetaDerived.state&&s.errors===Y&&s.isFieldsValidating===_&&s.isFieldsValid===g&&s.isFormValid===z&&s.isValid===de&&s.canSubmit===T&&s.isTouched===y&&s.isBlurred===x&&s.isPristine===w&&s.isDefaultValue===m&&s.isDirty===v&&pt(l,d))return s;let j={...d,errorMap:q,fieldMeta:this.fieldMetaDerived.state,errors:Y,isFieldsValidating:_,isFieldsValid:g,isFormValid:z,isValid:de,canSubmit:T,isTouched:y,isBlurred:x,isPristine:w,isDefaultValue:m,isDirty:v};return l=this.baseStore.get(),j}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){if(ta(e.validate))return Dt[e.type](e.value,e.validate);return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function wa(e){if(e){if(Jt(e)){let r=wa(e.form).formError,a=e.fields;return{formError:r,fieldErrors:a}}return{formError:e}}return{formError:void 0}}function ia(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 Ot{constructor(e){this.options={},this.mount=()=>{if(this.options.defaultValue!==void 0&&!this.getMeta().isTouched)this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let r=this.getInfo();r.instance=this,this.update(this.options);let{onMount:a}=this.options.validators||{};if(a){let l=this.runValidator({validate:a,value:{value:this.state.value,fieldApi:this,validationSource:"field"},type:"validate"});if(l)this.setMeta((s)=>({...s,errorMap:{...s?.errorMap,onMount:l},errorSourceMap:{...s?.errorSourceMap,onMount:"field"}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[s,d]of Object.entries(this.timeoutIds.validations))if(d)clearTimeout(d),this.timeoutIds.validations[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.listeners))if(d)clearTimeout(d),this.timeoutIds.listeners[s]=null;for(let[s,d]of Object.entries(this.timeoutIds.formListeners))if(d)clearTimeout(d),this.timeoutIds.formListeners[s]=null;let l=this.form.fieldInfo[this.name];if(!l)return;if(l.instance!==this)return;for(let[s,d]of Object.entries(l.validationMetaMap))d?.lastAbortController.abort(),l.validationMetaMap[s]=void 0;this.form.baseStore.setState((s)=>({...s,fieldMetaBase:{...s.fieldMetaBase,[this.name]:{...at,isTouched:s.fieldMetaBase[this.name]?.isTouched??at.isTouched,isBlurred:s.fieldMetaBase[this.name]?.isBlurred??at.isBlurred,isDirty:s.fieldMetaBase[this.name]?.isDirty??at.isDirty}}})),l.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!pt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,Ye(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(r,a)=>{if(this.form.pushFieldValue(this.name,r,Ye(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.insertValue=(r,a,l)=>{if(this.form.insertFieldValue(this.name,r,a,Ye(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.replaceValue=(r,a,l)=>{if(this.form.replaceFieldValue(this.name,r,a,Ye(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.removeValue=(r,a)=>{if(this.form.removeFieldValue(this.name,r,Ye(a,{dontRunListeners:!0})),!a?.dontRunListeners)this.triggerOnChangeListener()},this.swapValues=(r,a,l)=>{if(this.form.swapFieldValues(this.name,r,a,Ye(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.moveValue=(r,a,l)=>{if(this.form.moveFieldValues(this.name,r,a,Ye(l,{dontRunListeners:!0})),!l?.dontRunListeners)this.triggerOnChangeListener()},this.clearValues=(r)=>{if(this.form.clearFieldValues(this.name,Ye(r,{dontRunListeners:!0})),!r?.dontRunListeners)this.triggerOnChangeListener()},this.getLinkedFields=(r)=>{let a=Object.values(this.form.fieldInfo),l=[];for(let s of a){if(!s.instance)continue;if(!(s.instance instanceof Ot))continue;let{onChangeListenTo:d,onBlurListenTo:c}=s.instance.options.validators||{};if(r==="change"&&d?.includes(this.name))l.push(s.instance);if(r==="blur"&&c?.includes(this.name))l.push(s.instance)}return l},this.validateSync=(r,a)=>{let l=It(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ft}),d=this.getLinkedFields(r).reduce((_,g)=>{let y=It(r,{...g.options,form:g.form,fieldName:g.name,validationLogic:g.form.options.validationLogic||ft});return y.forEach((x)=>{x.field=g}),_.concat(y)},[]),c=!1;ze(()=>{let _=(g,y)=>{let x=la(y.cause),m=y.validate?ms(g.runValidator({validate:y.validate,value:{value:g.store.state.value,validationSource:"field",fieldApi:g},type:"validate"})):void 0,i=a[x],{newErrorValue:v,newSource:w}=Gt({formLevelError:i,fieldLevelError:m});if(g.state.meta.errorMap?.[x]!==v)g.setMeta((M)=>({...M,errorMap:{...M.errorMap,[x]:v},errorSourceMap:{...M.errorSourceMap,[x]:w}}));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=la("submit");if(this.state.meta.errorMap?.[f]&&r!=="submit"&&!c)this.setMeta((_)=>({..._,errorMap:{..._.errorMap,[f]:void 0},errorSourceMap:{..._.errorSourceMap,[f]:void 0}}));return{hasErrored:c}},this.validateAsync=async(r,a)=>{let l=Lt(r,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||ft}),s=await a,c=this.getLinkedFields(r).reduce((i,v)=>{let w=Lt(r,{...v.options,form:v.form,fieldName:v.name,validationLogic:v.form.options.validationLogic||ft});return w.forEach((M)=>{M.field=v}),i.concat(w)},[]),f=[],_=[],g=l.some((i)=>i.validate),y=Array.from(new Set(c.filter((i)=>i.validate).map((i)=>i.field)));ze(()=>{if(g)this.startValidation();for(let i of y)i.startValidation()});let x=(i,v,w)=>{let M=la(v.cause),O=i.getInfo();O.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;O.validationMetaMap[M]={lastAbortController:z},w.push(new Promise(async(de)=>{let oe;try{oe=await new Promise((N,X)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]),i.endValidation();i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(z.signal.aborted)return N(void 0);try{N(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,fieldApi:i,signal:z.signal,validationSource:"field"},type:"validateAsync"}))}catch(xe){X(xe)}},v.debounceMs)})}catch(N){oe=N}if(z.signal.aborted)return de(void 0);let T=ms(oe),q=s[i.name]?.[M],{newErrorValue:j,newSource:G}=Gt({formLevelError:q,fieldLevelError:T});if(i.getInfo().instance!==i)return de(void 0);i.setMeta((N)=>({...N,errorMap:{...N?.errorMap,[M]:j},errorSourceMap:{...N.errorSourceMap,[M]:G}})),de(j)}))};for(let i of l){if(!i.validate)continue;x(this,i,f)}for(let i of c){if(!i.validate)continue;x(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 y)i.endValidation()}),m.filter(Boolean)},this.validate=(r,a)=>{if(!this.state.meta.isTouched)return[];let l=a?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter((x)=>this.name.startsWith(x.name)),d=((a?.skipFormValidation)?{fieldsErrorMap:{}}:this.form.validateSync(r)).fieldsErrorMap[this.name]??{};if(!a?.skipFormValidation)for(let x of l){if(x.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:m}=this.form.validateSync(r,{group:x,dontUpdateFormErrorMap:!0,filterFieldNames:(i)=>vt(x.name,i)});d={...d,...m[this.name]??{}}}let{hasErrored:c}=this.validateSync(r,d),f=new WeakMap;for(let x of l){let{hasErrored:m}=x.validateSync(r,{},{skipRelatedFieldValidation:!0});f.set(x,m)}if(c&&!this.options.asyncAlways){this.getInfo().validationMetaMap[la(r)]?.lastAbortController.abort();let x=[];for(let m of l)m.getInfo().validationMetaMap[la(r)]?.lastAbortController.abort(),x.push(m.state.meta.errors);return[...this.state.meta.errors,...x.flat()]}let _=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r),g=this.validateAsync(r,_),y=[];for(let x of l){if(f.get(x)&&!x.options.asyncAlways)continue;y.push(x.validateAsync(r,_,{skipRelatedFieldValidation:!0}))}if(y.length===0)return g;return Promise.all([g,...y]).then((x)=>x.flat())},this.handleChange=(r)=>{this.setValue(r)},this.handleBlur=()=>{if(!this.state.meta.isTouched)this.setMeta((a)=>({...a,isTouched:!0}));if(!this.state.meta.isBlurred)this.setMeta((a)=>({...a,isBlurred:!0}));this.validate("blur"),this.triggerOnBlurListener()},this.setErrorMap=(r)=>{this.setMeta((a)=>({...a,errorMap:{...a.errorMap,...r}}))},this.parseValueWithSchema=(r)=>Dt.validate({value:this.state.value,validationSource:"field"},r),this.parseValueWithSchemaAsync=(r)=>Dt.validateAsync({value:this.state.value,validationSource:"field"},r),this.triggerOnBlurListener=()=>{let r=this.form.options.listeners?.onBlurDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.blur)clearTimeout(this.timeoutIds.formListeners.blur);this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onBlurDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.blur)clearTimeout(this.timeoutIds.listeners.blur);this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},r)}else this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let l of this.form.formGroupApis)if(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=Ct((r)=>{this.form.store.get();let a=this.form.getFieldMeta(this.name)??{...at,...e.defaultMeta},l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!pt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}})}get state(){return this.store.state}runValidator(e){if(ta(e.validate))return Dt[e.type](e.value,e.validate);return e.validate(e.value)}startValidation(){this.setMeta((e)=>{let r=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:r,isValidating:r>0&&!e.isValidating?!0:e.isValidating}})}endValidation(){this.setMeta((e)=>{let r=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:r,isValidating:r===0&&e.isValidating?!1:e.isValidating}})}}function ms(e){if(e)return e;return}function la(e){switch(e){case"submit":return"onSubmit";case"blur":return"onBlur";case"mount":return"onMount";case"server":return"onServer";case"dynamic":return"onDynamic";case"change":default:return"onChange"}}function Oa(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function ps(e){return{...at,...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 Ht{constructor(e){this.options={},this.setFormGroupState=(r)=>{this.form.baseStore.setState((a)=>{let l=a.formGroupStateBase[this.name]??Oa({});return{...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:r(l)}}})},this._lastDistributedFieldNames={},this.update=(r)=>{if(this.options=r,this.name=r.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0){let a=this.form.getFieldValue(this.name);if(!pt(a,r.defaultValue))this.form.setFieldValue(this.name,r.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})}if(!this.form.getFieldMeta(this.name))this.form.setFieldMeta(this.name,{...at,...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]??Oa({...this.options.defaultState})}}));let{onMount:r}=this.options.validators||{};if(r){let a=this.runValidator({validate:r,value:{value:this.state.value,groupApi:this,validationSource:"form"},type:"validate"}),l=a,s=void 0;if(za(a))l=a.group,s=a.fields;let d=$a(l);if(d)this.setMeta((c)=>({...c,errorMap:{...c.errorMap,onMount:d},errorSourceMap:{...c.errorSourceMap,onMount:"field"}}));this.distributeFieldErrors("onMount",s)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[a,l]of Object.entries(this.timeoutIds.validations))if(l)clearTimeout(l),this.timeoutIds.validations[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.listeners))if(l)clearTimeout(l),this.timeoutIds.listeners[a]=null;for(let[a,l]of Object.entries(this.timeoutIds.formListeners))if(l)clearTimeout(l),this.timeoutIds.formListeners[a]=null;if(this.fieldInfo.instance!==this)return;for(let[a,l]of Object.entries(this.fieldInfo.validationMetaMap))l?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[a]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState((a)=>({...a,formGroupStateBase:{...a.formGroupStateBase,[this.name]:Oa({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}},this.setValue=(r,a)=>{if(this.form.setFieldValue(this.name,r,Ye(a,{dontRunListeners:!0,dontValidate:!0})),!a?.dontRunListeners)this.triggerOnChangeListener();if(!a?.dontValidate)this.validate("change")},this.getMeta=()=>this.store.state.meta,this.setMeta=(r)=>this.form.setFieldMeta(this.name,r),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let r=Object.values(this.form.fieldInfo),a=[];for(let l of r){if(!l.instance)continue;if(!(l.instance instanceof Ot))continue;if(l.instance.name.startsWith(this.name))a.push(l.instance)}return a},this.getRelatedFieldMetasDerived=()=>{let r=Object.entries(this.form.fieldMetaDerived.state),a=[];for(let[l,s]of r){if(l===this.name)continue;if(vt(this.name,l))a.push({...s,name:l})}return a},this.buildChildFieldName=(r)=>{if(r==="")return this.name;if(r.startsWith("["))return`${this.name}${r}`;return`${this.name}.${r}`},this.distributeFieldErrors=(r,a)=>{let l=this._lastDistributedFieldNames[r]??new Set,s=new Set;if(a)for(let[f,_]of Object.entries(a)){if(_===void 0||_===null||_===!1)continue;s.add(this.buildChildFieldName(f))}let d=new Set([...l,...s]),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?.[_],y=this.form.getFieldMeta(f);if(!y&&!g)continue;let x=y?.errorMap[r],m=y?.errorSourceMap[r]==="form",{newErrorValue:i,newSource:v}=ea({newFormValidatorError:g,isPreviousErrorFromFormValidator:m,previousErrorValue:x});if(i)c=!0;if(x===i&&y?.errorSourceMap[r]===v)continue;this.form.setFieldMeta(f,(w=at)=>({...w,errorMap:{...w.errorMap,[r]:i},errorSourceMap:{...w.errorSourceMap,[r]:v}}))}return this._lastDistributedFieldNames[r]=s,c},this.validateSync=(r,a,l={})=>{let s=It(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ft}),c=(l.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((g,y)=>{let x=It(r,{...y.options,form:y.form,validationLogic:y.form.options.validationLogic||ft});return x.forEach((m)=>{m.field=y}),g.concat(x)},[]),f=!1;ze(()=>{let g=(y,x)=>{let m=Na(x.cause),i=y===this,v=void 0;if(x.validate)v=y.runValidator({validate:x.validate,value:{value:y.store.state.value,validationSource:i?"form":"field",...y instanceof Ht?{groupApi:y}:{fieldApi:y}},type:"validate"});let w=v,M=void 0;if(i&&za(v))w=v.group,M=v.fields;let O=$a(w),Y=a[m],{newErrorValue:z,newSource:de}=Gt({formLevelError:Y,fieldLevelError:O});if(y.state.meta.errorMap?.[m]!==z)y.setMeta((oe)=>({...oe,errorMap:{...oe.errorMap,[m]:z},errorSourceMap:{...oe.errorSourceMap,[m]:de}}));if(z)f=!0;if(i){if(this.distributeFieldErrors(m,M))f=!0}};for(let y of s)g(this,y);for(let y of c){if(!y.validate)continue;g(y.field,y)}});let _=Na("submit");if(this.state.meta.errorMap?.[_]&&r!=="submit"&&!f)this.setMeta((g)=>({...g,errorMap:{...g.errorMap,[_]:void 0},errorSourceMap:{...g.errorSourceMap,[_]:void 0}}));return{hasErrored:f}},this.validateAsync=async(r,a,l={})=>{let s=Lt(r,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||ft}),d=await a,c=l.skipRelatedFieldValidation?[]:this.getRelatedFields(),f=c.reduce((i,v)=>{let w=Lt(r,{...v.options,form:v.form,validationLogic:v.form.options.validationLogic||ft});return w.forEach((M)=>{M.field=v}),i.concat(w)},[]),_=[],g=[],y=s.some((i)=>i.validate)||f.some((i)=>i.validate);if(y){if(!this.state.meta.isValidating)this.setMeta((i)=>({...i,isValidating:!0}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!0}))}let x=(i,v,w)=>{let M=Na(v.cause),O=i.getInfo();O.validationMetaMap[M]?.lastAbortController.abort();let z=new AbortController;O.validationMetaMap[M]={lastAbortController:z};let de=i===this;w.push(new Promise(async(oe)=>{let T;try{T=await new Promise((ye,Me)=>{if(i.timeoutIds.validations[v.cause])clearTimeout(i.timeoutIds.validations[v.cause]);i.timeoutIds.validations[v.cause]=setTimeout(async()=>{if(z.signal.aborted)return ye(void 0);try{ye(await this.runValidator({validate:v.validate,value:{value:i.store.state.value,signal:z.signal,validationSource:de?"form":"field",...i instanceof Ht?{groupApi:i}:{fieldApi:i}},type:"validateAsync"}))}catch(Se){Me(Se)}},v.debounceMs)})}catch(ye){T=ye}if(z.signal.aborted)return oe(void 0);let q=T,j=void 0;if(de&&za(T))q=T.group,j=T.fields;let G=$a(q),N=d[i.name]?.[M],{newErrorValue:X,newSource:xe}=Gt({formLevelError:N,fieldLevelError:G});if(i.getInfo().instance!==i)return oe(void 0);if(i.setMeta((ye)=>({...ye,errorMap:{...ye?.errorMap,[M]:X},errorSourceMap:{...ye.errorSourceMap,[M]:xe}})),de)this.distributeFieldErrors(M,j);oe(X)}))};for(let i of s){if(!i.validate)continue;x(this,i,_)}for(let i of f){if(!i.validate)continue;x(i.field,i,g)}let m=[];if(_.length||g.length)m=await Promise.all(_),await Promise.all(g);if(y){this.setMeta((i)=>({...i,isValidating:!1}));for(let i of c)i.setMeta((v)=>({...v,isValidating:!1}))}return m.filter(Boolean)},this.validateAllFields=async(r)=>{let a=[];return ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(a.push(Promise.resolve().then(()=>s.validate(r,{skipFormValidation:!0,skipGroupValidation:!0}))),!s.store.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})}),(await Promise.all(a)).flat()},this.validateArrayFieldsStartingFrom=(r,a,l)=>this.form.validateArrayFieldsStartingFrom(r,a,l),this.validateField=(r,a)=>this.form.validateField(r,a),this.getFieldValue=(r)=>this.form.getFieldValue(r),this.getFieldMeta=(r)=>this.form.getFieldMeta(r),this.setFieldMeta=(r,a)=>this.form.setFieldMeta(r,a),this.setFieldValue=(r,a)=>this.form.setFieldValue(r,a),this.deleteField=(r)=>this.form.deleteField(r),this.pushFieldValue=(r,a)=>this.form.pushFieldValue(r,a),this.insertFieldValue=(r,a,l)=>this.form.insertFieldValue(r,a,l),this.replaceFieldValue=(r,a,l)=>this.form.replaceFieldValue(r,a,l),this.swapFieldValues=(r,a,l)=>this.form.swapFieldValues(r,a,l),this.moveFieldValues=(r,a,l)=>this.form.moveFieldValues(r,a,l),this.clearFieldValues=(r)=>this.form.clearFieldValues(r),this.resetField=(r)=>this.form.resetField(r),this.removeFieldValue=(r,a)=>this.form.removeFieldValue(r,a),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every((r)=>r.state.meta.isValid),this.validate=(r,a)=>{let{fieldsErrorMap:l}=a?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)}),{hasErrored:s}=this.validateSync(r,l[this.name]??{},{skipRelatedFieldValidation:a?.skipRelatedFieldValidation});if(s&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[Na(r)]?.lastAbortController.abort(),this.state.meta.errors;let d=a?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(r,{dontUpdateFormErrorMap:!0,filterFieldNames:(c)=>vt(this.name,c)});return this.validateAsync(r,d,{skipRelatedFieldValidation:a?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let r=this.form.options.listeners?.onChangeGroupDebounceMs;if(r&&r>0){if(this.timeoutIds.formListeners.change)clearTimeout(this.timeoutIds.formListeners.change);this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},r)}else this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let a=this.options.listeners?.onChangeDebounceMs;if(a&&a>0){if(this.timeoutIds.listeners.change)clearTimeout(this.timeoutIds.listeners.change);this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},a)}else this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async(r)=>{this.setFormGroupState((s)=>({...s,isSubmitted:!1,submissionAttempts:s.submissionAttempts+1,isSubmitSuccessful:!1})),ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{if(!s.state.meta.isTouched)s.setMeta((d)=>({...d,isTouched:!0}))})});let a=r??this.options.onSubmitMeta;this.setFormGroupState((s)=>({...s,isSubmitting:!0}));let l=()=>{this.setFormGroupState((s)=>({...s,isSubmitting:!1}))};if(await this.validateAllFields("submit"),!this.areRelatedFieldsValid()){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}if(await this.validate("submit",{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){l(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:a});return}ze(()=>{Object.values(this.getRelatedFields()).forEach((s)=>{s.options.listeners?.onGroupSubmit?.({value:s.state.value,fieldApi:s})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:a}),ze(()=>{this.setFormGroupState((s)=>({...s,isSubmitted:!0,isSubmitSuccessful:!0})),l()})}catch(s){throw this.setFormGroupState((d)=>({...d,isSubmitSuccessful:!1})),l(),s}},this.form=e.form,this.name=e.name,this.options=e,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=Ct((r)=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let a=this.form.getFormGroupMeta(this.name)??ps(e.defaultMeta),l=this.form.getFieldValue(this.name);if(!a.isTouched&&l===void 0&&this.options.defaultValue!==void 0&&!pt(l,this.options.defaultValue))l=this.options.defaultValue;if(r&&r.value===l&&r.meta===a)return r;return{value:l,meta:a}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(ta(e.validate)){let r=Dt[e.type](e.value,e.validate);if(e.type==="validate")return us(r);return r.then(us)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}}function $a(e){if(e)return e;return}function za(e){return!!e&&typeof e==="object"&&"fields"in e}function us(e){if(!e||typeof e!=="object")return e;if(!("form"in e)&&!("fields"in e))return e;let{form:r,fields:a,...l}=e;return{...l,group:r,fields:a}}function 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 Qa(e,r){if(!r)return;let a=Object.assign({},e,{state:Qt(e.state)});if(r(a),a.fieldInfo!==e.fieldInfo)e.fieldInfo=a.fieldInfo;if(a.options!==e.options)e.options=a.options;let s=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((d,c)=>{if(e.state[c]!==a.state[c])d[c]=a.state[c];return d},{});return ze(()=>{if(Object.keys(s).length)e.baseStore.setState((d)=>({...d,...s}));if(a.state.errorMap!==e.state.errorMap)e.setErrorMap(a.state.errorMap)}),a}S();function cr(e,r){return e===r}function De(e,r=(l)=>l,a){let l=a?.compare??cr,s=P((c)=>{let{unsubscribe:f}=e.subscribe(c);return f},[e]),d=P(()=>e.get(),[e]);return Ic(s,d,d,r,l)}var da=(e,r=(l)=>l,a)=>De(e,r,{compare:a});S();S();S();var yt=typeof window<"u"?He:h;function mr(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new Ot({...e})),d=l;if(r.form!==e.form||r.name!==e.name)d=new Ot({...e}),s(d),a({form:e.form,name:e.name});let c=De(d.store,e.mode==="array"?(v)=>v.meta._arrayVersion||0:(v)=>v.value),f=De(d.store,(v)=>v.meta.isTouched),_=De(d.store,(v)=>v.meta.isBlurred),g=De(d.store,(v)=>v.meta.isDirty),y=De(d.store,(v)=>v.meta.errorMap),x=De(d.store,(v)=>v.meta.errorSourceMap),m=De(d.store,(v)=>v.meta.isValidating),i=D(()=>({...d,get state(){return{value:e.mode==="array"?d.state.value:c,get meta(){return{...d.state.meta,isTouched:f,isBlurred:_,isDirty:g,errorMap:y,errorSourceMap:x,isValidating:m}}}}}),[d,e.mode,c,f,_,g,y,x,m]);return yt(d.mount,[d]),yt(()=>{d.update(e)}),i}var fs=({children:e,...r})=>{let a=mr(r),l=D(()=>Ft(e,a),[e,a]);return t(L,{children:l})};S();S();function gs(){return u(()=>oa())[0]}var ur=V,hs=Ns.split(".")[0]==="17"?gs:ur.useId;S();function pr(e){let[r,a]=u(()=>({form:e.form,name:e.name})),[l,s]=u(()=>new Ht({...e}));if(r.form!==e.form||r.name!==e.name)s(new Ht({...e})),a({form:e.form,name:e.name});let d=De(l.store,(T)=>T.value),c=De(l.store,(T)=>T.meta.isTouched),f=De(l.store,(T)=>T.meta.isBlurred),_=De(l.store,(T)=>T.meta.isDirty),g=De(l.store,(T)=>T.meta.errorMap),y=De(l.store,(T)=>T.meta.errorSourceMap),x=De(l.store,(T)=>T.meta.isValidating),m=De(l.store,(T)=>T.meta.isSubmitting),i=De(l.store,(T)=>T.meta.isSubmitted),v=De(l.store,(T)=>T.meta.submissionAttempts),w=De(l.store,(T)=>T.meta.isSubmitSuccessful),M=De(l.store,(T)=>T.meta.canSubmit),O=De(l.store,(T)=>T.meta.isValid),Y=De(l.store,(T)=>T.meta.isFieldsValid),z=De(l.store,(T)=>T.meta.isFieldsValidating),de=De(l.store,(T)=>T.meta.isGroupValid),oe=D(()=>({...l,handleSubmit:(...j)=>l._handleSubmit(...j),get state(){return{...l.state,value:d,get meta(){return{...l.state.meta,isTouched:c,isBlurred:f,isDirty:_,errorMap:g,errorSourceMap:y,isValidating:x,isSubmitting:m,isSubmitted:i,submissionAttempts:v,isSubmitSuccessful:w,canSubmit:M,isValid:O,isFieldsValid:Y,isFieldsValidating:z,isGroupValid:de}}}}}),[l,d,c,f,_,g,y,x,m,i,v,w,M,O,Y,z,de]);return yt(l.mount,[l]),yt(()=>{l.update(e)}),oe}var vs=({children:e,...r})=>{let a=pr(r),l=D(()=>Ft(e,a),[e,a]);return t(L,{children:l})};function fr({form:e,selector:r=(l)=>l,children:a}){let l=De(e.store,r);return t(L,{children:Ft(a,l)})}function $t(e){let r=hs(),[a,l]=u(e?.formId),[s,d]=u(()=>new na({...e,formId:e?.formId??r}));if(a!==e?.formId){let _=e?.formId??r;d(new na({...e,formId:_})),l(_)}let c=D(()=>{let _={...s,handleSubmit:(...g)=>s._handleSubmit(...g),get formId(){return s._formId},get state(){return s.store.state}};return _.Field=function(y){return t(fs,{...y,form:s})},_.FormGroup=function(y){return t(vs,{...y,form:s})},_.Subscribe=function(y){return t(fr,{form:s,selector:y.selector,children:y.children})},_},[s]);yt(s.mount,[]),yt(()=>{s.update(e)});let f=b(!1);return yt(()=>{if(!f.current)return;if(!e?.transform)return;Qa(s,e.transform)},[s,e?.transform]),yt(()=>{f.current=!0}),c}S();var hr=R({name:p().min(1,ax()),type:Ve(["chat","autofill","embedding"]),permission:Ve(["owner","editor","reviewer"]),avatar:p().optional(),providerId:p().optional(),modelId:p().optional(),soul:p().optional(),thinkingLevel:Yc.optional(),systemPrompt:p().optional(),skills:te(p()).optional(),mcpServerIds:te(p()).optional(),deniedTools:te(p()).optional()}),yr=[{id:"bash",name:()=>t0(),description:()=>e0()},{id:"read_skill",name:()=>f0(),description:()=>d0()},{id:"read_asset",name:()=>Pm(),description:()=>u0()},{id:"list_assets",name:()=>Nm(),description:()=>l0()},{id:"create_folder",name:()=>Im(),description:()=>n0()},{id:"create_file",name:()=>Cm(),description:()=>r0()},{id:"create_version",name:()=>Tm(),description:()=>o0()},{id:"generate_image",name:()=>km(),description:()=>a0()},{id:"generate_video",name:()=>Rm(),description:()=>i0()},{id:"rename_asset",name:()=>Om(),description:()=>p0()},{id:"move_assets",name:()=>Dm(),description:()=>c0()},{id:"delete_asset",name:()=>Mm(),description:()=>s0()}];function ys({isOpen:e,onClose:r,teamId:a,type:l,initialValues:s,title:d}){let c=K(),{canAdmin:f}=Pt(),{data:_}=Z({queryKey:["teams",a,"providers"],queryFn:async()=>{let U=await A.api.teams[":teamId"].providers.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch providers");return await U.json()},enabled:e}),{data:g}=Z({queryKey:["teams",a,"skills"],queryFn:async()=>{let U=await A.api.teams[":teamId"].skills.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch skills");return await U.json()},enabled:e}),y=g?.skills||[],{data:x}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let U=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!U.ok)throw Error("Failed to fetch MCP servers");return await U.json()},enabled:e}),m=x?.servers||[],i=D(()=>hr.superRefine((U,J)=>{if(U.type==="chat"||U.type==="autofill"){if(!U.providerId)J.addIssue({code:ro.custom,message:eE(),path:["providerId"]});if(!U.modelId)J.addIssue({code:ro.custom,message:Xw(),path:["modelId"]})}}),[]),v=$t({defaultValues:{name:s?.name||"",type:s?.type||l||"chat",permission:s?.permission||"reviewer",avatar:s?.avatarPreset||s?.avatar||Wc[0].id,providerId:s?.providerId||"",modelId:s?.modelId||"",soul:s?.soul||"",thinkingLevel:s?.thinkingLevel||"off",systemPrompt:s?.systemPrompt||"",skills:s?.skills?.map((U)=>U.skillId)||[],mcpServerIds:s?.mcpServerIds||[],deniedTools:s?.deniedTools??[...uA]},validators:{onChange:i},onSubmit:async({value:U})=>{try{if(s?.id)await Se.mutateAsync({id:s.id,values:U});else await Me.mutateAsync(U)}catch{}}}),w=da(v.store,(U)=>U.values.providerId),{data:M,isLoading:O}=Z({queryKey:["teams",a,"providers",w,"models"],queryFn:async()=>{let U=await A.api.providers[":id"].models.$get({param:{id:w}});if(!U.ok)throw Error("Failed to fetch models");return await U.json()},enabled:!!w&&e}),[Y,z]=u(""),[de,oe]=u(!1),T=D(()=>{if(!_)return[];return[..._].sort((U,J)=>U.name.toLowerCase().localeCompare(J.name.toLowerCase()))},[_]),q=D(()=>{if(!Y.trim())return T;let U=Y.toLowerCase();return T.filter((J)=>J.name.toLowerCase().includes(U))},[T,Y]),[j,G]=u(""),[N,X]=u(!1),xe=D(()=>{if(!M)return[];return[...M].sort((U,J)=>{let ee=(U.name||U.modelId).toLowerCase(),se=(J.name||J.modelId).toLowerCase();return ee.localeCompare(se)})},[M]),ye=D(()=>{if(!j.trim())return xe;let U=j.toLowerCase();return xe.filter((J)=>J.modelId.toLowerCase().includes(U)||J.name&&J.name.toLowerCase().includes(U))},[xe,j]),Me=B({mutationFn:async(U)=>{let J=await A.api.teams[":teamId"].agents.$post({param:{teamId:a},json:U});if(!J.ok)throw Error("Failed to create agent");return await J.json()},onSuccess:()=>{r(),c.invalidateQueries({queryKey:["agents",a]}),k.success(HA())},onError:(U)=>{k.error(Bs({message:U.message}))}}),Se=B({mutationFn:async({id:U,values:J})=>{let ee=await A.api.agents[":agentId"].$put({param:{agentId:U},json:J});if(!ee.ok)throw Error("Failed to update agent");return await ee.json()},onSuccess:()=>{r(),c.invalidateQueries({queryKey:["agents",a]}),k.success(Bm())},onError:(U)=>{k.error(Bs({message:U.message}))}});h(()=>{if(e)v.reset(),z(""),oe(!1),G(""),X(!1)},[e,s,l]);let ae=da(v.store,(U)=>U.values.type),_e=ae==="chat"||ae==="autofill",Ee=ae==="chat",Pe=(U)=>U.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(ue,{open:e,onOpenChange:r,children:o(ie,{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(le,{children:d}),t(Tt,{children:P_()})]}),o("form",{onSubmit:(U)=>{U.preventDefault(),U.stopPropagation(),v.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ce,{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:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched;return o(Oe,{"data-invalid":J,children:[t($e,{children:VA()}),t(H,{value:U.state.value,onBlur:U.handleBlur,onChange:(ee)=>U.handleChange(ee.target.value),placeholder:QA(),"aria-invalid":J}),J&&t(Ke,{errors:Pe(U.state.meta.errors)})]})}}),t(v.Field,{name:"type",children:(U)=>o(Oe,{children:[t($e,{children:g0()}),o(Fe,{value:U.state.value,onValueChange:(J)=>U.handleChange(J),disabled:!0,children:[t(Ze,{className:"bg-muted/50",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"chat",children:Lm()}),t(ne,{value:"autofill",children:Fm()}),t(ne,{value:"embedding",children:Zm()})]})]})]})}),Ee&&t(v.Field,{name:"permission",children:(U)=>o(Oe,{children:[t($e,{children:Ip()}),o(Fe,{value:U.state.value||"reviewer",onValueChange:(J)=>U.handleChange(J),disabled:!f,children:[t(Ze,{children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})]})}),t(v.Field,{name:"avatar",children:(U)=>o(Oe,{className:"md:col-span-2",children:[t($e,{children:qA()}),o("div",{className:"flex flex-wrap gap-4 mt-2",children:[Wc.map((J)=>{let ee=U.state.value===J.id;return t("button",{type:"button",onClick:()=>U.handleChange(J.id),className:C("relative w-14 h-14 rounded-full overflow-hidden border-2 transition-all hover:scale-105",ee?"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:OS()})},J.id)}),U.state.value&&!Wc.some((J)=>J.id===U.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:U.state.value,className:"w-full h-full object-cover",alt:fy()})})]})]})})]}),_e&&o(L,{children:[o("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 p-4 bg-muted/50 rounded-xl border border-border",children:[t(v.Field,{name:"providerId",children:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched,ee=_?.find((se)=>se.id===U.state.value);return o(Oe,{"data-invalid":J,children:[t($e,{children:YS()}),o(mt,{open:de,onOpenChange:(se)=>{if(oe(se),!se)z("")},modal:!0,children:[t(ht,{asChild:!0,children:o(E,{type:"button",variant:"outline",role:"combobox","aria-expanded":de,"aria-invalid":J,className:C("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:ee?t("span",{className:"font-medium text-foreground truncate",children:ee.name}):t("span",{className:"text-muted-foreground",children:CC()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(gt,{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:(se)=>se.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Bt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(H,{placeholder:Zg(),value:Y,onChange:(se)=>z(se.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ce,{className:"w-full p-1",style:{height:q.length===0?"96px":`${Math.min(q.length*38+8,256)}px`},onWheel:(se)=>se.stopPropagation(),children:q.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:Dx()}):t("div",{className:"space-y-0.5 pr-2",children:q.map((se)=>{let Qe=U.state.value===se.id;return o("div",{onClick:()=>{U.handleChange(se.id),v.setFieldValue("modelId",""),G(""),oe(!1),z("")},className:C("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",Qe?"bg-accent text-accent-foreground font-medium":"hover:bg-muted/60 text-foreground"),children:[t("span",{className:"truncate flex-1 pr-2",children:se.name}),Qe&&t(ke,{className:"w-4 h-4 text-primary shrink-0"})]},se.id)})})})]})]}),J&&t(Ke,{errors:Pe(U.state.meta.errors)})]})}}),t(v.Field,{name:"modelId",children:(U)=>{let J=!!U.state.meta.errors.length&&U.state.meta.isTouched,ee=M?.find((se)=>se.id===U.state.value);return o(Oe,{"data-invalid":J,children:[o($e,{className:"flex items-center gap-2",children:[Qw(),O&&t(F,{className:"w-3 h-3 animate-spin"})]}),o(mt,{open:N,onOpenChange:(se)=>{if(X(se),!se)G("")},modal:!0,children:[t(ht,{asChild:!0,children:o(E,{type:"button",variant:"outline",role:"combobox","aria-expanded":N,"aria-invalid":J,disabled:!w||O,className:C("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:ee?o(L,{children:[t("span",{className:"truncate font-medium text-foreground",children:ee.name||ee.modelId}),ee.name&&ee.name!==ee.modelId&&t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0 shrink-0",children:ee.modelId})]}):t("span",{className:"text-muted-foreground",children:wC()})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o(gt,{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:(se)=>se.stopPropagation(),children:[o("div",{className:"relative p-2 pb-1.5 border-b border-border shrink-0",children:[t(Bt,{className:"absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t(H,{placeholder:Sp(),value:j,onChange:(se)=>G(se.target.value),className:"pl-8 h-8 text-xs bg-muted/40",autoFocus:!0})]}),t(ce,{className:"w-full p-1",style:{height:ye.length===0?"96px":`${Math.min(ye.length*38+8,256)}px`},onWheel:(se)=>se.stopPropagation(),children:ye.length===0?t("div",{className:"flex items-center justify-center h-full py-6 text-xs text-muted-foreground",children:vd()}):t("div",{className:"space-y-0.5 pr-2",children:ye.map((se)=>{let Qe=U.state.value===se.id;return o("div",{onClick:()=>{U.handleChange(se.id),X(!1),G("")},className:C("flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors",Qe?"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:se.name||se.modelId}),se.name&&se.name!==se.modelId&&o("span",{className:"font-mono text-[10px] text-muted-foreground truncate",children:["(",se.modelId,")"]}),se.config?.reasoning&&t(be,{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(jt,{className:"w-2.5 h-2.5"})})]})}),Qe&&t(ke,{className:"w-4 h-4 text-primary shrink-0"})]},se.id)})})})]})]}),J&&t(Ke,{errors:Pe(U.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(v.Field,{name:"thinkingLevel",children:(U)=>{let J={off:P1(),low:L1(),medium:Z1(),high:O1()};return o(Oe,{children:[t($e,{children:F1()}),o(Fe,{value:U.state.value,onValueChange:(ee)=>U.handleChange(ee),children:[t(Ze,{children:t(Le,{})}),t(Be,{children:Yc.options.map((ee)=>t(ne,{value:ee,children:J[ee]||ee},ee))})]})]})}})})]}),t(v.Field,{name:"soul",children:(U)=>o(Oe,{children:[t($e,{children:JA()}),t(ya,{value:U.state.value,onBlur:U.handleBlur,onChange:(J)=>U.handleChange(J.target.value),placeholder:XA(),className:"min-h-[120px]"})]})}),o("div",{className:"space-y-4",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(wt,{className:"w-5 h-5 text-primary"}),Gg()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"skills",children:(U)=>o(L,{children:[y.map((J)=>{let ee=U.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(wt,{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:ee?Df():Rf()}),t(je,{checked:ee,onCheckedChange:(se)=>{if(se)U.handleChange([...U.state.value||[],J.id]);else U.handleChange((U.state.value||[]).filter((Qe)=>Qe!==J.id))}})]})]},J.id)}),y.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:Lx()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(bn,{className:"w-5 h-5 text-primary"}),Bc()]}),t("div",{className:"space-y-2",children:t(v.Field,{name:"mcpServerIds",children:(U)=>o(L,{children:[m.map((J)=>{let ee=U.state.value?.includes(J.id)||!1,se=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(bn,{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(be,{variant:"outline",className:"text-[10px]",children:[J.toolCount??0," tools"]}),se&&t(be,{variant:"secondary",className:"text-[10px] bg-amber-500/10 text-amber-600 border-amber-500/20",children:Bh()})]}),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:ee?Df():Rf()}),t(je,{checked:ee,onCheckedChange:(Qe)=>{if(Qe)U.handleChange([...U.state.value||[],J.id]);else U.handleChange((U.state.value||[]).filter((At)=>At!==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:eg()})})]})})})]}),o("div",{className:"space-y-4 border-t border-border pt-6",children:[o(Q,{className:"text-base font-bold flex items-center gap-2",children:[t(Io,{className:"w-5 h-5 text-primary"}),m0()]}),t("p",{className:"text-xs text-muted-foreground",children:h0()}),t("div",{className:"space-y-2",children:t(v.Field,{name:"deniedTools",children:(U)=>{let J=U.state.value||[];return t(L,{children:yr.map((ee)=>{let se=!J.includes(ee.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(Io,{className:"w-4 h-4 text-muted-foreground"}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:ee.name()}),t("span",{className:"text-[10px] text-muted-foreground line-clamp-1",children:ee.description()})]})]}),o("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-xs text-muted-foreground",children:se?Df():Rf()}),t(je,{checked:se,disabled:!f,onCheckedChange:(Qe)=>{if(Qe)U.handleChange(J.filter((At)=>At!==ee.id));else U.handleChange([...J,ee.id])}})]})]},ee.id)})})}})})]})]})]})}),o(Ge,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[t(E,{variant:"outline",onClick:r,type:"button",children:Ne()}),t(v.Subscribe,{selector:(U)=>[U.canSubmit,U.isSubmitting],children:([U,J])=>o(E,{type:"submit",className:"bg-primary hover:bg-primary/90 text-primary-foreground min-w-[120px]",disabled:!U||J||Me.isPending||Se.isPending,children:[(J||Me.isPending||Se.isPending)&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),s?zs():X_()]})})]})]})]})})}var xr=[{type:"chat",label:"Chat",icon:vo},{type:"autofill",label:"Autofill",icon:jt},{type:"embedding",label:"Embedding",icon:ao}];function xs({teamId:e}){let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u("chat"),[f,_]=u(null),[g,y]=u(null),[x,m]=u(!1),[i,v]=u({chat:!0,autofill:!0,embedding:!0}),w=(T)=>{if(T==="chat")return Lm();if(T==="autofill")return Fm();return Zm()},{data:M=[],isLoading:O}=Z({queryKey:["agents",e],queryFn:async()=>{let T=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!T.ok)throw Error("failed to fetch agents");return[...await T.json()].sort((j,G)=>G.id.localeCompare(j.id))}}),Y=B({mutationFn:async(T)=>{if(!(await A.api.agents[":agentId"].$delete({param:{agentId:T}})).ok)throw Error("failed to delete agent")},onSuccess:()=>{m(!1),r.invalidateQueries({queryKey:["agents",e]}),k.success($A())},onError:(T)=>{k.error(T.message)}}),z=B({mutationFn:async({agentId:T,permission:q})=>{let j=await A.api.agents[":agentId"].permission.$patch({param:{agentId:T},json:{permission:q}});if(!j.ok)throw Error(gl());return j.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]})},onError:(T)=>{k.error(T.message||gl())}}),de=B({mutationFn:async(T)=>{let q=await A.api.agents[":agentId"].$put({param:{agentId:T.agentId},json:{name:T.name,type:T.type,enabled:T.enabled,avatar:T.avatar,providerId:T.providerId,modelId:T.modelId,thinkingLevel:T.thinkingLevel,systemPrompt:T.systemPrompt,soul:T.soul,skills:T.skills,deniedTools:T.deniedTools}});if(!q.ok)throw Error("failed to update agent");return q.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["agents",e]}),k.success(Bm())},onError:(T)=>{k.error(T.message)}}),oe=(T)=>{v((q)=>({...q,[T]:!q[T]}))};return o(L,{children:[(l||f)&&t(ys,{isOpen:!0,title:f?dh({name:f.name}):ly({type:w(d)}),onClose:()=>{s(!1),_(null)},teamId:e,type:d,initialValues:f||void 0}),t(Je,{open:x,onOpenChange:m,children:o(Xe,{children:[o(et,{children:[t(rt,{children:ad()}),t(nt,{children:Cy({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:Ne()}),t(ot,{className:"bg-destructive hover:bg-destructive/90 text-white",onClick:(T)=>{if(Y.isPending){T.preventDefault();return}if(g)Y.mutate(g.id)},children:Y.isPending?t(F,{className:"w-4 h-4 animate-spin"}):Ey()})]})]})}),O&&M.length===0?t("div",{className:"flex items-center justify-center p-12",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):o("div",{className:"space-y-6 max-w-5xl mx-auto relative",children:[O&&t("div",{className:"absolute top-0 right-0 p-2",children:t(F,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),xr.map((T)=>{let q=M.filter((N)=>N.type===T.type),j=T.icon,G=T.type==="autofill"||T.type==="embedding";return o("div",{className:"bg-card rounded-xl border border-border overflow-hidden",children:[o("div",{className:C("px-6 py-4 flex items-center justify-between",!G&&"cursor-pointer hover:bg-muted/50 transition-colors"),onClick:!G?()=>oe(T.type):void 0,children:[o("div",{className:"flex items-center gap-2",children:[t("h3",{className:"font-semibold text-foreground",children:T.type==="chat"?w_():T.type==="autofill"?e_():nb()}),!G&&t(be,{variant:"secondary",className:"h-5 px-1.5 min-w-[1.25rem] text-[10px]",children:q.length})]}),o("div",{className:"flex items-center gap-2",children:[!(G&&q.length>0)&&t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full bg-primary/10 text-primary hover:bg-primary/20",onClick:(N)=>{N.stopPropagation(),c(T.type),s(!0)},children:t(fe,{className:"w-4 h-4"})}),!G&&t(ve,{className:C("w-5 h-5 text-muted-foreground transition-transform duration-200",i[T.type]?"rotate-180":"")})]})]}),(G||i[T.type])&&t("div",{className:"px-6 pb-6 pt-2 space-y-3",children:o("div",{className:"grid grid-cols-1 gap-4",children:[q.map((N)=>t(Et,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all duration-200 cursor-pointer pb-1 pt-1",onClick:()=>_(N),children:o(Mt,{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:N.avatar?t("img",{src:N.avatar,className:"w-full h-full object-cover",alt:""}):t(St,{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:N.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(wt,{className:"w-3 h-3"}),GC({count:N.skills?.length||0})]})})]})]}),o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(X)=>X.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{onClick:(X)=>{X.stopPropagation(),y(N),m(!0)},className:"text-red-500 focus:text-red-500 gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",it()]})})]})]}),o("div",{className:"flex items-center justify-between gap-2 pt-2 border-t border-border/50",children:[t("div",{children:N.type==="chat"?t("div",{onClick:(X)=>X.stopPropagation(),children:o(Fe,{value:N.permission||"reviewer",onValueChange:(X)=>{z.mutate({agentId:N.id,permission:X})},disabled:!a,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{children:N.permission==="reviewer"?Ni():N.permission==="editor"?Di():Pi()})}),o(Be,{align:"start",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})}):t("div",{})}),t("div",{onClick:(X)=>X.stopPropagation(),children:t(je,{checked:N.enabled,onCheckedChange:(X)=>{de.mutate({teamId:e,agentId:N.id,name:N.name,type:N.type,enabled:X,avatar:N.avatar,providerId:N.providerId,modelId:N.modelId,thinkingLevel:N.thinkingLevel,systemPrompt:N.systemPrompt,soul:N.soul,skills:N.skills?.map((xe)=>xe.skillId),deniedTools:N.deniedTools})}})})]})]})},N.id)),q.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(j,{className:"w-5 h-5 text-muted-foreground"})}),t("p",{className:"text-sm text-muted-foreground",children:yx({type:w(T.type)})}),t(E,{variant:"link",size:"sm",className:"text-primary font-medium h-auto p-0 mt-1",onClick:()=>{c(T.type),s(!0)},children:oy()})]})]})})]},T.type)})]})]})}S();S();function Sa({isOpen:e,onClose:r,onSubmit:a,initialValues:l,title:s,isLoading:d=!1,defaultApi:c,existingModelIds:f=[]}){let _=D(()=>dA.extend({modelId:p().min(1,zh()).refine((m)=>{if(l?.modelId===m)return!0;return!f.includes(m)},{message:Yw()})}),[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}}},y=$t({defaultValues:g(),validators:{onSubmit:_},onSubmit:async({value:m})=>{a(m)}});h(()=>{if(e)y.reset(g())},[e,l,c,y]);let x=(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(ue,{open:e,onOpenChange:r,children:o(ie,{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(le,{className:"text-xl",children:s})}),o("form",{onSubmit:(m)=>{m.preventDefault(),m.stopPropagation(),y.handleSubmit()},className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t("div",{className:"flex-1 min-h-0",children:t(ce,{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(y.Field,{name:"modelId",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:zh()}),t(H,{id:m.name,name:m.name,value:m.state.value,onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:Jw(),"aria-invalid":i}),i&&t(Ke,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"name",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,children:Gy()}),t(H,{id:m.name,name:m.name,value:m.state.value||"",onBlur:m.handleBlur,onChange:(v)=>m.handleChange(v.target.value),placeholder:ex(),"aria-invalid":i}),i&&t(Ke,{errors:x(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:bS()}),t(y.Field,{name:"config.reasoning",children:(m)=>o(Oe,{orientation:"horizontal",className:"rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center",children:[t($e,{htmlFor:m.name,className:"cursor-pointer",children:_p()}),t(je,{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(y.Field,{name:"config.contextWindow",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:j_()}),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(Ke,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.maxTokens",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:fw()}),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(Ke,{errors:x(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(ui,{className:"w-4 h-4 text-primary"}),FS()]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t(y.Field,{name:"config.cost.input",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:Uv()}),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(Ke,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.output",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:hS()}),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(Ke,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheRead",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:A_()}),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(Ke,{errors:x(m.state.meta.errors)})]})}}),t(y.Field,{name:"config.cost.cacheWrite",children:(m)=>{let i=!!m.state.meta.errors.length&&m.state.meta.isTouched;return o(Oe,{"data-invalid":i,children:[t($e,{htmlFor:m.name,className:"text-xs",children:__()}),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(Ke,{errors:x(m.state.meta.errors)})]})}})]})]})]})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:d,children:Ne()}),t(y.Subscribe,{selector:(m)=>[m.canSubmit,m.isSubmitting],children:([m,i])=>t(E,{type:"submit",className:"min-w-[100px]",disabled:!m||i||d,children:i||d?t(F,{className:"w-4 h-4 animate-spin"}):zs()})})]})]})]})})}S();function _s({isOpen:e,onClose:r,teamId:a,syncData:l,onSuccess:s}){let[d,c]=u(""),[f,_]=u(()=>new Set(l?.providers.map((q)=>q.name)||[])),[g,y]=u(()=>{let q=new Set;return l?.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),q});h(()=>{if(l){_(new Set(l.providers.map((j)=>j.name)));let q=new Set;l.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),y(q)}},[l]);let x=D(()=>{if(!l)return[];let q=d.trim().toLowerCase();if(!q)return l.providers;return l.providers.map((j)=>{let G=j.name.toLowerCase().includes(q),N=j.models.filter((X)=>G||X.modelId.toLowerCase().includes(q)||X.name.toLowerCase().includes(q));if(N.length>0)return{...j,models:N};return null}).filter((j)=>j!==null)},[l,d]),m=g.size,i=D(()=>{if(!l)return 0;let q=0;for(let j of l.providers)if(j.models.some((N)=>g.has(`${j.name}:${N.modelId}`)))q++;return q},[l,g]),v=(q)=>{_((j)=>{let G=new Set(j);if(G.has(q))G.delete(q);else G.add(q);return G})},w=()=>{if(!l)return;_(new Set(l.providers.map((q)=>q.name)))},M=()=>{_(new Set)},O=(q,j)=>{let G=`${q}:${j}`;y((N)=>{let X=new Set(N);if(X.has(G))X.delete(G);else X.add(G);return X})},Y=(q)=>{let j=l?.providers.find((N)=>N.name===q);if(!j||j.models.length===0)return;let G=j.models.every((N)=>g.has(`${q}:${N.modelId}`));y((N)=>{let X=new Set(N);return j.models.forEach((xe)=>{let ye=`${q}:${xe.modelId}`;if(G)X.delete(ye);else X.add(ye)}),X})},z=()=>{if(!l)return;let q=new Set;l.providers.forEach((j)=>{j.models.forEach((G)=>{q.add(`${j.name}:${G.modelId}`)})}),y(q)},de=()=>{y(new Set)},oe=B({mutationFn:async(q)=>{let j=await A.api.teams[":teamId"].providers["sync-apply"].$post({param:{teamId:a},json:q});if(!j.ok){let G=await j.json().catch(()=>({message:"Failed to apply sync"}));throw Error(G.message||"Failed to apply sync")}return await j.json()},onSuccess:(q)=>{k.success(y1({modelCount:q.addedModels,providerCount:q.addedProviders})),s(),r()},onError:(q)=>{k.error(q.message)}}),T=async()=>{if(!l||m===0)return;let q=[];for(let j of l.providers){let G=j.models.filter((N)=>g.has(`${j.name}:${N.modelId}`));if(G.length>0)q.push({name:j.name,isNewProvider:j.isNewProvider,config:j.config,models:G})}if(q.length===0)return;await oe.mutateAsync({providers:q})};return t(ue,{open:e,onOpenChange:(q)=>!q&&r(),children:o(ie,{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(le,{className:"flex items-center gap-2 text-xl font-semibold",children:[t(sn,{className:"w-5 h-5 text-primary"}),u1()]}),t(Tt,{className:"text-xs text-muted-foreground leading-relaxed mt-1.5",children:c1()})]}),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(Bt,{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:(q)=>c(q.target.value),placeholder:g1(),className:"pl-8 h-8 text-xs bg-background"})]}),o("div",{className:"flex items-center gap-1.5",children:[t(E,{type:"button",variant:"outline",size:"sm",onClick:w,className:"h-8 text-xs px-2.5",children:f1()}),t(E,{type:"button",variant:"outline",size:"sm",onClick:M,className:"h-8 text-xs px-2.5",children:a1()}),t("div",{className:"w-px h-4 bg-border mx-1"}),t(E,{type:"button",variant:"outline",size:"sm",onClick:z,className:"h-8 text-xs px-2.5",children:A1()}),t(E,{type:"button",variant:"outline",size:"sm",onClick:de,className:"h-8 text-xs px-2.5",children:l1()})]})]})}),t("div",{className:"flex-1 min-h-0 px-6 overflow-hidden",children:t(ce,{className:"h-full border border-border/60 rounded-md bg-muted/20",children:t("div",{className:"p-3 space-y-3",children:x.length===0?t("div",{className:"py-8 text-center text-sm text-muted-foreground",children:Xh()}):x.map((q)=>{let j=f.has(q.name),G=q.isNewProvider,N=q.models.filter((ye)=>g.has(`${q.name}:${ye.modelId}`)).length,X=N===q.models.length,xe=N>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(q.name),className:"p-0.5 text-muted-foreground hover:text-foreground rounded transition-colors",children:j?t(ve,{className:"w-4 h-4"}):t(bt,{className:"w-4 h-4"})}),t(Pr,{checked:X?!0:xe?"indeterminate":!1,onCheckedChange:()=>Y(q.name),id:`provider-check-${q.name}`}),o("label",{htmlFor:`provider-check-${q.name}`,className:"font-medium text-sm text-foreground flex items-center gap-2 cursor-pointer select-none",children:[t(ao,{className:"w-4 h-4 text-muted-foreground"}),t("span",{children:q.name})]})]}),o("div",{className:"flex items-center gap-2",children:[G?t(be,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:m1()}):t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 text-muted-foreground",children:d1()}),t("span",{className:"text-xs text-muted-foreground",children:p1({count:q.models.length})})]})]}),j&&t("div",{className:"border-t border-border/40 divide-y divide-border/30 bg-muted/10",children:q.models.map((ye)=>{let Me=g.has(`${q.name}:${ye.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(Pr,{checked:Me,onCheckedChange:()=>O(q.name,ye.modelId),id:`model-check-${q.name}-${ye.modelId}`}),o("label",{htmlFor:`model-check-${q.name}-${ye.modelId}`,className:"text-xs font-medium text-foreground cursor-pointer select-none truncate",children:[ye.name||ye.modelId,t("span",{className:"ml-1.5 text-[11px] text-muted-foreground font-mono font-normal",children:ye.modelId})]})]}),o("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[ye.config.reasoning&&t(be,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal border-amber-500/30 text-amber-600 dark:text-amber-400",children:h1()}),t("span",{className:"text-[11px] text-muted-foreground font-mono",children:i1({count:Math.round(ye.config.contextWindow/1000)})})]})]},ye.modelId)})})]},q.name)})})})}),o(Ge,{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:_1({modelCount:m,providerCount:i})}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:oe.isPending,children:Ne()}),t(E,{type:"button",onClick:T,disabled:m===0||oe.isPending,className:"gap-2",children:oe.isPending?o(L,{children:[t(F,{className:"w-4 h-4 animate-spin"}),o1()]}):n1({count:m})})]})]})]})})}var ws={"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 Ss({teamId:e}){let r=K(),[a,l]=u(null),[s,d]=u(!1),[c,f]=u(""),[_,g]=u(!1),[y,x]=u(null),[m,i]=u(!1),[v,w]=u(null),M=B({mutationFn:async()=>{let j=await A.api.teams[":teamId"].providers["sync-check"].$post({param:{teamId:e}});if(!j.ok){let G=await j.json().catch(()=>({message:"Failed to check updates"}));throw Error(G.message||"Failed to check updates")}return await j.json()},onSuccess:(j)=>{if(j.totalNewModels===0&&j.totalNewProviders===0){k.info(b1());return}w(j),i(!0)},onError:(j)=>{k.error(j.message)}}),{data:O,isLoading:Y}=Z({queryKey:["teams",e,"providers"],queryFn:async()=>{let j=await A.api.teams[":teamId"].providers.$get({param:{teamId:e}});if(!j.ok)throw Error("Failed to fetch providers");return await j.json()}}),z=D(()=>O?.find((j)=>j.id===a)||null,[O,a]),de=D(()=>O?.map((j)=>j.name)||[],[O]),oe=D(()=>{if(!O)return[];if(!c.trim())return O;let j=c.toLowerCase();return O.filter((G)=>G.name.toLowerCase().includes(j))},[O,c]),T=B({mutationFn:async(j)=>{let G=await A.api.teams[":teamId"].providers.$post({param:{teamId:e},json:{name:j.name,config:j.config,models:j.models}});if(!G.ok)throw Error("Failed to create provider");return await G.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),d(!1),k.success(JS())},onError:(j)=>{k.error(Bs({message:j.message}))}}),q=B({mutationFn:async(j)=>{let G=await A.api.providers[":id"].$delete({param:{id:j}});if(!G.ok)throw Error("Failed to delete provider");return await G.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]}),l(null),g(!1),x(null),k.success(XS())},onError:(j)=>{k.error(Bs({message:j.message}))}});if(Y)return t("div",{className:"flex h-64 items-center justify-center",children:t(F,{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(ao,{className:"w-5 h-5 text-primary"}),L_()]}),o("div",{className:"flex items-center gap-2",children:[t(E,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"gap-2",children:M.isPending?o(L,{children:[t(F,{className:"w-4 h-4 animate-spin"}),s1()]}):o(L,{children:[t(ma,{className:"w-4 h-4"}),r1()]})}),o(E,{onClick:()=>d(!0),className:"bg-primary hover:bg-primary/90 text-primary-foreground gap-2",children:[t(fe,{className:"w-4 h-4"}),wm()]})]})]}),o("div",{className:"relative px-0.5",children:[t(Bt,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{placeholder:Zg(),value:c,onChange:(j)=>f(j.target.value),className:"pl-10 bg-card border-border focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-0"})]})]}),t(ce,{className:"flex-1 min-h-0",children:o("div",{className:"pr-4 py-2 grid grid-cols-1 gap-4",children:[oe.map((j)=>t(Et,{className:"group cursor-pointer hover:border-primary/50 transition-all hover:shadow-md overflow-hidden",onClick:()=>l(j.id),children:o(Mt,{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:j.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(jt,{className:"w-3 h-3"}),j.config.api]}),j.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(Wo,{className:"w-3 h-3 flex-none"}),t("span",{className:"truncate max-w-[200px] md:max-w-[300px]",children:j.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(Ha,{className:"w-3 h-3"}),sx({count:j.modelsCount})]})]})]})]}),o("div",{className:"flex items-center gap-1",children:[o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(G)=>G.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-foreground",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{align:"end",className:"w-32",children:o(W,{onClick:(G)=>{G.stopPropagation(),x(j),g(!0)},className:"text-destructive focus:text-destructive gap-2 cursor-pointer",children:[t(we,{className:"w-4 h-4"})," ",it()]})})]}),t(bt,{className:"flex-none w-5 h-5 text-muted-foreground/50 group-hover:text-primary transition-colors"})]})]})},j.id)),O?.length===0&&o("div",{className:"text-center py-12 bg-muted/30 rounded-2xl border-2 border-dashed border-border",children:[t(ao,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:Nx()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:kA()})]}),O&&O.length>0&&oe.length===0&&o("div",{className:"text-center py-12",children:[t(Bt,{className:"w-12 h-12 text-muted-foreground/50 mx-auto mb-4"}),t("h4",{className:"text-foreground font-medium",children:Xh()}),t("p",{className:"text-sm text-muted-foreground mt-1",children:X1({query:c})}),t(E,{variant:"ghost",size:"sm",onClick:()=>f(""),className:"mt-4 text-primary hover:text-primary/90 hover:bg-primary/10",children:C_()})]})]})}),t(_r,{isOpen:s,onClose:()=>d(!1),onSubmit:(j)=>T.mutate(j),isLoading:T.isPending,existingProviderNames:de}),z&&t(Nr,{isOpen:!!z,onClose:()=>l(null),provider:z,teamId:e,existingProviderNames:de}),t(Je,{open:_,onOpenChange:g,children:o(Xe,{children:[o(et,{children:[t(rt,{children:ad()}),t(nt,{children:Oy({name:y?.name??""})})]}),o(tt,{children:[t(st,{onClick:()=>x(null),children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(y)q.mutate(y.id)},children:[q.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})}),t(_s,{isOpen:m,onClose:()=>i(!1),teamId:e,syncData:v,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"providers"]})}})]})}function _r({isOpen:e,onClose:r,onSubmit:a,isLoading:l,existingProviderNames:s}){let[d,c]=u([]),[f,_]=u(!1),[g,y]=u(null),x=D(()=>R({name:p().min(1,mg()).refine((w)=>!s.includes(w),{message:hg()}),config:ri}),[s]),m=$t({defaultValues:{name:"",config:{api:"openai-completions",baseUrl:"",apiKey:""}},validators:{onSubmit:x},onSubmit:async({value:w})=>{a({name:w.name,config:w.config,models:d})}});h(()=>{if(e)m.reset(),c([]),_(!1),y(null)},[e,m]);let i=(w)=>w.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=(w)=>{if(g!==null)c((M)=>M.map((O,Y)=>Y===g?w:O)),y(null);else c((M)=>[w,...M]),_(!1)};return t(ue,{open:e,onOpenChange:r,children:o(ie,{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(le,{className:"text-xl",children:PA()}),t(Tt,{children:Ym()})]}),o("form",{onSubmit:(w)=>{w.preventDefault(),w.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(ce,{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:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:pg()}),t(H,{id:w.name,name:w.name,value:w.state.value,onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:gg(),"aria-invalid":M}),M&&t(Ke,{errors:i(w.state.meta.errors)})]})}}),t(m.Field,{name:"config.api",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:Th()}),o(Fe,{onValueChange:w.handleChange,value:w.state.value,children:[t(Ze,{id:w.name,"aria-invalid":M,children:t(Le,{placeholder:Bg()})}),t(Be,{children:Jc.map((O)=>t(ne,{value:O,children:ws[O]},O))})]}),M&&t(Ke,{errors:i(w.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.baseUrl",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:Qm()}),t(H,{id:w.name,name:w.name,value:w.state.value||"",onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":M}),t(sa,{children:og()}),M&&t(Ke,{errors:i(w.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(m.Field,{name:"config.apiKey",children:(w)=>{let M=!!w.state.meta.errors.length&&w.state.meta.isTouched;return o(Oe,{"data-invalid":M,children:[t($e,{htmlFor:w.name,children:sd()}),t(H,{id:w.name,name:w.name,type:"text",value:w.state.value||"",onBlur:w.handleBlur,onChange:(O)=>w.handleChange(O.target.value),placeholder:qm(),"aria-invalid":M}),t(sa,{className:"text-xs mt-1",children:jm()}),M&&t(Ke,{errors:i(w.state.meta.errors)})]})}})})]}),o("div",{className:"space-y-3",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t(Q,{className:"text-base font-semibold",children:yd()}),t("p",{className:"text-xs text-muted-foreground mt-0.5",children:rx()})]}),o(E,{type:"button",variant:"outline",size:"sm",onClick:()=>_(!0),className:"gap-1.5",children:[t(fe,{className:"w-4 h-4"}),rd()]})]}),d.length===0?t("div",{className:"text-center py-8 rounded-xl border border-dashed text-muted-foreground text-sm",children:vd()}):t("div",{className:"space-y-2",children:d.map((w,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:()=>y(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:w.name||w.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px]",children:w.modelId}),w.config.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20",children:[t(jt,{className:"w-2.5 h-2.5"})," ",_p()]})]}),o("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[o("span",{children:[w.config.contextWindow?.toLocaleString()," ",nA()]}),t("span",{children:"·"}),t("span",{children:th({input:w.config.cost?.input??0,output:w.config.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 ml-2",children:t(E,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(O)=>{O.stopPropagation(),c((Y)=>Y.filter((z,de)=>de!==M))},children:t(we,{className:"w-3.5 h-3.5"})})})]},w.modelId+M))})]})]})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,disabled:l,children:Ne()}),t(m.Subscribe,{selector:(w)=>[w.canSubmit,w.isSubmitting],children:([w,M])=>t(E,{type:"submit",className:"min-w-[120px]",disabled:!w||M||l,children:M||l?t(F,{className:"w-4 h-4 animate-spin"}):wm()})})]})]}),(f||g!==null)&&t(Sa,{isOpen:!0,onClose:()=>{_(!1),y(null)},onSubmit:v,title:g!==null?fh():rd(),initialValues:g!==null?d[g]:null,defaultApi:m.getFieldValue("config.api"),existingModelIds:d.filter((w,M)=>M!==g).map((w)=>w.modelId)},g!==null?`edit-${g}-${d[g]?.modelId}`:"add")]})})}function Nr({isOpen:e,onClose:r,provider:a,teamId:l,existingProviderNames:s}){let d=K(),[c,f]=u("general"),[_,g]=u(""),[y,x]=u(!1),[m,i]=u(null),[v,w]=u(null),{data:M=[],isLoading:O}=Z({queryKey:["teams",l,"providers",a.id,"models"],queryFn:async()=>{let N=await A.api.providers[":id"].models.$get({param:{id:a.id}});if(!N.ok)throw Error("Failed to fetch models");return await N.json()},enabled:e}),Y=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].$put({param:{id:a.id},json:{name:N.name,config:N.config}});if(!X.ok)throw Error("Failed to update provider");return await X.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",l,"providers"]}),k.success(bg())},onError:(N)=>{k.error(Bs({message:N.message}))}}),z=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].models.$post({param:{id:a.id},json:N});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"]}),x(!1),k.success(Kw())},onError:(N)=>{k.error(Bs({message:N.message}))}}),de=B({mutationFn:async({modelDbId:N,values:X})=>{let xe=await A.api.providers[":id"].models[":modelDbId"].$put({param:{id:a.id,modelDbId:N},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),k.success(tx())},onError:(N)=>{k.error(Bs({message:N.message}))}}),oe=B({mutationFn:async(N)=>{let X=await A.api.providers[":id"].models[":modelDbId"].$delete({param:{id:a.id,modelDbId:N}});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"]}),w(null),k.success(Ww())},onError:(N)=>{k.error(Bs({message:N.message}))}}),T=D(()=>R({name:p().min(1,mg()).refine((N)=>{if(a.name===N)return!0;return!s.includes(N)},{message:hg()}),config:ri}),[s,a.name]),q=$t({defaultValues:{name:a.name,config:a.config},validators:{onSubmit:T},onSubmit:async({value:N})=>{Y.mutate({name:N.name,config:N.config})}});h(()=>{if(e)q.reset(),f("general"),g("")},[e,q]);let j=(N)=>N.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=D(()=>{if(!_.trim())return M;let N=_.toLowerCase();return M.filter((X)=>X.modelId.toLowerCase().includes(N)||X.name?.toLowerCase().includes(N))},[M,_]);return t(ue,{open:e,onOpenChange:r,children:o(ie,{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(le,{className:"text-xl",children:dh({name:a.name})}),t(Tt,{children:Ym()})]}),o(xo,{value:c,onValueChange:(N)=>f(N),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(So,{className:"grid w-full grid-cols-2",children:[t(Qr,{value:"general",children:Ih()}),o(Qr,{value:"models",className:"gap-2",children:[yd(),t(be,{variant:"secondary",className:"h-5 px-1.5 text-[11px]",children:M.length})]})]})}),t(kn,{value:"general",className:"flex-1 flex flex-col min-h-0 m-0",children:o("form",{onSubmit:(N)=>{N.preventDefault(),N.stopPropagation(),q.handleSubmit()},className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"flex-1 min-h-0",children:t(ce,{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(q.Field,{name:"name",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:pg()}),t(H,{id:N.name,name:N.name,value:N.state.value,onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:gg(),"aria-invalid":X}),X&&t(Ke,{errors:j(N.state.meta.errors)})]})}}),t(q.Field,{name:"config.api",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:Th()}),o(Fe,{onValueChange:N.handleChange,value:N.state.value,children:[t(Ze,{id:N.name,"aria-invalid":X,children:t(Le,{placeholder:Bg()})}),t(Be,{children:Jc.map((xe)=>t(ne,{value:xe,children:ws[xe]},xe))})]}),X&&t(Ke,{errors:j(N.state.meta.errors)})]})}}),t("div",{className:"md:col-span-2",children:t(q.Field,{name:"config.baseUrl",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:Qm()}),t(H,{id:N.name,name:N.name,value:N.state.value||"",onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:"https://api.openai.com/v1","aria-invalid":X}),t(sa,{children:og()}),X&&t(Ke,{errors:j(N.state.meta.errors)})]})}})}),t("div",{className:"md:col-span-2",children:t(q.Field,{name:"config.apiKey",children:(N)=>{let X=!!N.state.meta.errors.length&&N.state.meta.isTouched;return o(Oe,{"data-invalid":X,children:[t($e,{htmlFor:N.name,children:sd()}),t(H,{id:N.name,name:N.name,type:"text",value:N.state.value||"",onBlur:N.handleBlur,onChange:(xe)=>N.handleChange(xe.target.value),placeholder:qm(),"aria-invalid":X}),t(sa,{className:"text-xs mt-1",children:jm()}),X&&t(Ke,{errors:j(N.state.meta.errors)})]})}})})]})})})}),o(Ge,{className:"p-6 pt-4 border-t border-border gap-2 shrink-0",children:[t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),t(q.Subscribe,{selector:(N)=>[N.canSubmit,N.isSubmitting],children:([N,X])=>t(E,{type:"submit",className:"min-w-[120px]",disabled:!N||X||Y.isPending,children:X||Y.isPending?t(F,{className:"w-4 h-4 animate-spin"}):zs()})})]})]})}),o(kn,{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(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{placeholder:Sp(),value:_,onChange:(N)=>g(N.target.value),className:"pl-9 h-9"})]}),o(E,{size:"sm",onClick:()=>x(!0),className:"gap-1.5 shrink-0",children:[t(fe,{className:"w-4 h-4"}),rd()]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ce,{className:"h-full pr-4",children:O?t("div",{className:"flex h-48 items-center justify-center",children:t(F,{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:vd()}):t("div",{className:"space-y-2 pb-4",children:G.map((N)=>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(N),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:N.name||N.modelId}),t(be,{variant:"secondary",className:"font-mono text-[10px] px-1.5 py-0.5",children:N.modelId}),N.config?.reasoning&&o(be,{variant:"outline",className:"text-[10px] gap-1 bg-primary/10 text-primary border-primary/20 h-5",children:[t(jt,{className:"w-2.5 h-2.5"})," ",_p()]})]}),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:[N.config?.contextWindow?.toLocaleString()," ",nA()]}),t("span",{children:"·"}),t("span",{children:pw({count:N.config?.maxTokens?.toLocaleString()??"0"})}),t("span",{children:"·"}),t("span",{children:th({input:N.config?.cost?.input??0,output:N.config?.cost?.output??0})})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:(X)=>{X.stopPropagation(),w(N)},children:t(we,{className:"w-3.5 h-3.5"})})})]},N.id))})})})]})]}),y&&t(Sa,{isOpen:y,onClose:()=>x(!1),onSubmit:(N)=>z.mutate(N),title:rd(),isLoading:z.isPending,defaultApi:a.config.api,existingModelIds:M.map((N)=>N.modelId)}),m&&t(Sa,{isOpen:!!m,onClose:()=>i(null),onSubmit:(N)=>de.mutate({modelDbId:m.id,values:N}),title:fh(),isLoading:de.isPending,initialValues:{modelId:m.modelId,name:m.name,config:m.config},defaultApi:a.config.api,existingModelIds:M.filter((N)=>N.id!==m.id).map((N)=>N.modelId)}),t(Je,{open:!!v,onOpenChange:(N)=>!N&&w(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:ad()}),t(nt,{children:Ny({name:v?.name||v?.modelId||""})})]}),o(tt,{children:[t(st,{onClick:()=>w(null),children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(v)oe.mutate(v.id)},children:[oe.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})})]})})}S();function Cs({teamId:e}){let r=K(),[a,l]=u(""),{data:s,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(Yo());return await v.json()}}),{mutate:c,isPending:f}=B({mutationFn:async(v)=>{let w=await A.api.teams[":teamId"].sandbox.$put({param:{teamId:e},json:v});if(!w.ok)throw Error(bh());return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"sandbox"]}),k.success(tC())},onError:(v)=>{k.error(v instanceof Error?v.message:bh())}}),_=(v)=>{c({networkSandboxEnabled:v})},g=(v)=>{if(v.preventDefault(),!a.trim())return;if(s?.allowedDomains.includes(a.trim())){k.error(Vy());return}let w=[...s?.allowedDomains||[],a.trim()],M=s?.pendingDomains||[];c({allowedDomains:w,pendingDomains:M}),l("")},y=(v)=>{let w=(s?.allowedDomains||[]).filter((O)=>O!==v),M=s?.pendingDomains||[];c({allowedDomains:w,pendingDomains:M})},x=(v)=>{let w=[...s?.allowedDomains||[],v],M=(s?.pendingDomains||[]).filter((O)=>O!==v);c({allowedDomains:w,pendingDomains:M})},m=(v)=>{let w=(s?.pendingDomains||[]).filter((M)=>M!==v);c({allowedDomains:s?.allowedDomains||[],pendingDomains:w})};if(d)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});let i=!!s?.networkSandboxEnabled;return t(ce,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Et,{children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(ca,{className:"w-5 h-5 text-primary"}),t(Rt,{children:cx()})]}),t(Ut,{children:ux()})]}),o(Mt,{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:ib()}),t("p",{className:"text-xs text-muted-foreground",children:fx()})]}),t(je,{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(Wo,{className:"w-4 h-4 mt-0.5 shrink-0"}),t("span",{children:dx()})]}),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(E,{type:"submit",disabled:f||!i,children:[f?t(F,{className:"w-4 h-4 animate-spin"}):t(fe,{className:"w-4 h-4 mr-2"}),MA()]})]}),o("div",{className:"space-y-2",children:[t("h4",{className:"text-sm font-medium text-muted-foreground mb-3",children:F0()}),o("div",{className:"flex flex-wrap gap-2",children:[s?.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:()=>y(v),className:"ml-1 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50 disabled:cursor-not-allowed",disabled:f||!i,children:t(Re,{className:"w-3.5 h-3.5"})})]},v)),s?.allowedDomains.length===0&&t("div",{className:"text-sm text-muted-foreground italic",children:Sx()})]})]})]})]}),o(Et,{className:"border-orange-500/20 bg-orange-500/5",children:[o(kt,{children:[o("div",{className:"flex items-center gap-2",children:[t(Gl,{className:"w-5 h-5 text-orange-500"}),t(Rt,{children:ES()})]}),t(Ut,{children:CS()})]}),t(Mt,{children:t("div",{className:"space-y-3",children:s?.pendingDomains&&s.pendingDomains.length>0?t("div",{className:"divide-y divide-border",children:s.pendingDomains.map((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(E,{size:"sm",variant:"outline",className:"h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20",onClick:()=>x(v),disabled:f||!i,children:[t(ke,{className:"w-4 h-4 mr-1.5"}),H0()]}),o(E,{size:"sm",variant:"outline",className:"h-8 border-destructive/20 text-destructive hover:bg-destructive/10",onClick:()=>m(v),disabled:f||!i,children:[t(we,{className:"w-4 h-4 mr-1.5"}),it()]})]})]},v))}):t("div",{className:"text-sm text-muted-foreground italic py-2",children:Rx()})})})]}),t(Et,{children:o(kt,{children:[t(Rt,{children:nv()}),t(Ut,{children:ov()})]})})]})})}S();var Sr=(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"})]}),ks=({teamId:e})=>{let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u(!1),[f,_]=u(!1),[g,y]=u(null),{data:x,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(Yo());return await M.json()}}),i=B({mutationFn:async(M)=>{if(!(await A.api.skills[":id"].$delete({param:{id:M}})).ok)throw Error(ki())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]}),_(!1)}}),v=B({mutationFn:async({id:M,permission:O})=>{if(!(await A.api.skills[":id"].permission.$patch({param:{id:M},json:{permission:O}})).ok)throw Error(gl())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"skills"]})},onError:(M)=>{alert(M.message||gl())}}),w=x?.skills||[];return o(Et,{children:[o(kt,{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(wt,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:Vg()}),t(Ut,{children:QC()})]})]}),o(E,{onClick:()=>s(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",LA()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(F,{className:"w-8 h-8 animate-spin text-primary"})}):w.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(wt,{className:"w-6 h-6"})}),t("h3",{className:"text-lg font-medium text-foreground",children:Zx()}),t("p",{className:"text-muted-foreground mt-1 max-w-xs mx-auto",children:ZA()})]}):t("div",{className:"space-y-4",children:w.map((M)=>t(Cr,{skill:M,canAdmin:a,onDelete:()=>{y(M),_(!0)},onConfigure:()=>{y(M),c(!0)},onPermissionChange:(O)=>v.mutate({id:M.id,permission:O})},M.id))})}),t(kr,{open:l,onOpenChange:s,teamId:e}),g&&t(Mr,{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:ad()}),t(nt,{children:Zy({name:g?.name??""})})]}),o(tt,{children:[t(st,{children:Ne()}),o(ot,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",onClick:()=>{if(g)i.mutate(g.id)},children:[i.isPending?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})})]})},Cr=({skill:e,canAdmin:r,onDelete:a,onConfigure:l,onPermissionChange:s})=>o("div",{className:"p-4 bg-card rounded-xl border border-border flex flex-col justify-between hover:shadow-md transition-all group cursor-pointer",onClick:l,children:[o("div",{children:[o("div",{className:"flex items-start justify-between mb-2",children:[t("h4",{className:"font-bold text-foreground flex items-center gap-2",children:e.name}),o(he,{children:[t(ge,{asChild:!0,onClick:(d)=>d.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t(wr,{className:"w-4 h-4"})})}),t(Ae,{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(we,{className:"w-4 h-4"})," ",it()]})})]})]}),t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.description||Yh()})]}),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:[iA()," ",new Date(e.updatedAt).toLocaleDateString()]}),t("div",{className:"flex items-center gap-2",onClick:(d)=>d.stopPropagation(),children:o(Fe,{value:e.permission||"reviewer",onValueChange:(d)=>s(d),disabled:!r,children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[140px]",children:t(Le,{placeholder:Ip()})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})})]})]}),kr=({open:e,onOpenChange:r,teamId:a})=>{let l=K(),[s,d]=u(""),[c,f]=u(!1),_=b(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}),y=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
+ ${gS()}`)){await y({...m,override:!0});return}}else if(!i.ok){let v=await i.json().catch(()=>({}));throw Error(v.error||Pb())}else l.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1),d("")}catch(i){if(i instanceof Error)alert(i.message);else alert(od())}finally{f(!1)}},x=async(m)=>{if(!m||m.length===0)return;let i=g?.data?.[0]?.id;if(!i){alert(lx());return}let v=m[0];if(!v.name.toLowerCase().endsWith(".zip")){alert(Qx());return}f(!0);try{let w=v.name,M=v.type||"application/zip",O=await A.api.projects[":projectId"].attachments.$post({param:{projectId:i},json:{fileName:w,size:v.size,contentType:M}});if(!O.ok)throw Error("Failed to get upload URL");let{id:Y,uploadUrl:z}=await O.json();if(!(await fetch(z,{method:"PUT",body:v,headers:{"Content-Type":M}})).ok)throw Error("Failed to upload file to storage");await y({assetId:Y})}catch(w){if(w instanceof Error)alert(w.message);else alert(od())}finally{f(!1)}};return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-[450px]",children:[o(me,{children:[t(le,{children:OA()}),t(Tt,{children:Bv()})]}),o("div",{className:"space-y-6 pt-4",children:[o("div",{className:"space-y-3",children:[t(Q,{children:AS()}),o("div",{onClick:()=>!c&&_.current?.click(),className:C("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)=>x(m.target.files)}),t("div",{className:"p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors",children:t(lo,{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:kC()}),t("p",{className:"text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold",children:_S()})]})]}),c&&!s&&o("div",{className:"flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse",children:[t(F,{className:"w-4 h-4 animate-spin"}),ZS()]})]}),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:pS()})})]}),t("div",{className:"space-y-4",children:o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"githubUrl",children:_v()}),o("div",{className:"flex gap-2",children:[o("div",{className:"relative flex-1",children:[t(Sr,{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:s,onChange:(m)=>d(m.target.value),disabled:c,className:"pl-9"})]}),t(E,{onClick:()=>y({githubUrl:s}),disabled:!s||c,className:"px-6",children:c&&s?t(F,{className:"w-4 h-4 animate-spin"}):zv()})]}),t("p",{className:"text-[10px] text-muted-foreground italic",children:yv()})]})})]})]})})},Mr=({open:e,onOpenChange:r,teamId:a,skill:l})=>{let s=K(),[d,c]=u({...l.config||{},environmentVariables:l.config?.environmentVariables||[]}),[f,_]=u(!1),g=(w,M)=>{let O=[...d.environmentVariables];O[w]={...O[w],default:M},c({...d,environmentVariables:O})},y=(w,M)=>{let O=[...d.environmentVariables];O[w]={...O[w],name:M},c({...d,environmentVariables:O})},x=()=>{c({...d,environmentVariables:[...d.environmentVariables,{name:"",default:""}]})},m=(w)=>{let M=[...d.environmentVariables];M.splice(w,1),c({...d,environmentVariables:M})},i=async()=>{let w=d.environmentVariables.filter((O)=>O.name.trim()!==""),M={...d,environmentVariables:w};_(!0);try{let O=await A.api.skills[":id"].config.$patch({param:{id:l.id},json:{config:M}});if(!O.ok){let Y=await O.json().catch(()=>({}));throw Error(Y.error||"Failed to update config")}s.invalidateQueries({queryKey:["teams",a,"skills"]}),r(!1)}catch(O){if(O instanceof Error)alert(O.message);else alert(od())}finally{_(!1)}},v=d?.environmentVariables||[];return t(ue,{open:e,onOpenChange:r,children:o(ie,{className:"sm:max-w-[500px]",children:[o(me,{children:[t("div",{className:"flex items-center justify-between",children:o(le,{className:"flex items-center gap-2",children:[t(Ql,{className:"w-5 h-5 text-primary"}),F_({name:l.name})]})}),t(Tt,{children:aw()})]}),t(ce,{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:Ex()})}):v.map((w,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(Re,{className:"w-4 h-4"})}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:pI()}),t(H,{value:w.name,onChange:(O)=>y(M,O.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(Q,{className:"text-[10px] uppercase tracking-wider font-bold text-muted-foreground",children:Sy()}),t(H,{value:w.default||"",onChange:(O)=>g(M,O.target.value),placeholder:fS(),className:"h-8 bg-background border-border text-sm"}),t("p",{className:"text-[10px] text-muted-foreground italic",children:hb()})]})]},M))})}),o(Ge,{className:"flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border",children:[o(E,{variant:"ghost",size:"sm",onClick:x,className:"h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10",children:[t(fe,{className:"w-3.5 h-3.5"})," ",jA()]}),o("div",{className:"flex gap-2",children:[t(E,{variant:"ghost",onClick:()=>r(!1),children:Ne()}),o(E,{onClick:i,disabled:f,className:"px-8",children:[f?t(F,{className:"w-4 h-4 animate-spin mr-2"}):null,zs()]})]})]})]})})};S();S();var Ms=({isOpen:e,onClose:r,teamId:a,server:l})=>{let s=K(),d=!!l,[c,f]=u(""),[_,g]=u("streamable_http"),[y,x]=u("reviewer"),[m,i]=u("auto"),[v,w]=u(""),[M,O]=u(""),[Y,z]=u(""),[de,oe]=u(""),[T,q]=u("authorization_code"),[j,G]=u([]),[N,X]=u([]),[xe,ye]=u({}),[Me,Se]=u(!1);h(()=>{if(l)f(l.url),g(l.transport||"streamable_http"),x(l.permission||"reviewer"),i(l.authType||"auto"),G(Array.isArray(l.config?.directTools)?l.config.directTools:[]),X(l.config?.excludeTools??[]),ye({}),Se(!1);else f(""),g("streamable_http"),x("reviewer"),i("auto"),w(""),O(""),z(""),oe(""),q("authorization_code"),G([]),X([]),ye({}),Se(!1)},[l,e]);let ae=()=>{if(m==="none")return{type:"none"};if(m==="bearer")return{type:"bearer",bearerToken:v||void 0};if(m==="oauth")return{type:"oauth",oauth:{grantType:T,clientId:M||void 0,clientSecret:Y||void 0,scope:de||void 0}};return},{data:_e,isLoading:Ee,refetch:Pe}=Z({queryKey:["mcp","servers",l?.id,"tools"],queryFn:async()=>{if(!l?.id)return{tools:[]};let pe=await A.api.mcp.servers[":id"].tools.$get({param:{id:l.id}});if(!pe.ok)throw Error("Failed to fetch tools");return await pe.json()},enabled:e&&d&&!!l?.id}),U=B({mutationFn:async()=>{if(!l?.id)return;let pe=await A.api.mcp.servers[":id"].refresh.$post({param:{id:l.id}});if(!pe.ok){let lt=await pe.json().catch(()=>({}));throw Error(lt.error||"Failed to refresh server")}return await pe.json()},onSuccess:()=>{k.success(Iw()),Pe(),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]})},onError:(pe)=>{k.error(pe.message)}}),J=B({mutationFn:async()=>{let pe={directTools:j.length>0?j:void 0,excludeTools:N.length>0?N:void 0};if(d&&l){let lt={transport:_,permission:y,authConfig:ae(),config:pe},qe=await A.api.mcp.servers[":id"].$patch({param:{id:l.id},json:lt});if(!qe.ok){let ct=await qe.json().catch(()=>({}));throw Error(ct.error||gl())}return await qe.json()}else{let lt={url:c.trim()},qe=await A.api.teams[":teamId"].mcp.servers.$post({param:{teamId:a},json:lt});if(!qe.ok){let aa=await qe.json().catch(()=>({}));throw Error(aa.error||od())}return await qe.json()}},onSuccess:()=>{k.success(d?dg():Bc()),s.invalidateQueries({queryKey:["teams",a,"mcp","servers"]}),r()},onError:(pe)=>{k.error(pe.message)}}),ee=(pe)=>{if(pe.preventDefault(),!c.trim())return;J.mutate()},se=_e?.tools??[],Qe=(pe)=>{if(N.includes(pe))return"off";if(j.includes(pe))return"direct";return"on"},At=(pe,lt)=>{if(lt==="off")X((qe)=>qe.includes(pe)?qe:[...qe,pe]),G((qe)=>qe.filter((ct)=>ct!==pe));else if(lt==="on")X((qe)=>qe.filter((ct)=>ct!==pe)),G((qe)=>qe.filter((ct)=>ct!==pe));else if(lt==="direct")X((qe)=>qe.filter((ct)=>ct!==pe)),G((qe)=>qe.includes(pe)?qe:[...qe,pe])},re=(pe)=>{let lt=se.map((qe)=>qe.name);if(pe==="off")X(lt),G([]);else if(pe==="on")X([]),G([]);else if(pe==="direct")X([]),G(lt)},We=(pe)=>{ye((lt)=>({...lt,[pe]:!lt[pe]}))};return t(ue,{open:e,onOpenChange:(pe)=>!pe&&r(),children:d&&l?o(ie,{className:"sm:max-w-2xl h-[85vh] flex flex-col p-0 overflow-hidden",children:[U.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(F,{className:"w-8 h-8 animate-spin text-primary mb-2"}),o("span",{className:"text-xs font-medium text-muted-foreground",children:[Fh(),"..."]})]}),o(me,{className:"p-6 pb-4 border-b border-border flex-shrink-0",children:[o(le,{className:"flex items-center gap-2 text-xl font-bold",children:[t(bn,{className:"w-5 h-5 text-primary"}),Yy()]}),t(Tt,{children:_d()})]}),o("form",{onSubmit:ee,className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[t(ce,{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:Mw()}),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:Zh()}),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:hl()}),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(Wo,{className:"w-3 h-3"}),Lh()]})]}),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:Tw()}),t("p",{onClick:()=>Se((pe)=>!pe),className:`text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed cursor-pointer transition-all ${Me?"":"line-clamp-2"}`,title:Me?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(Q,{className:"text-xs",children:Bw()}),o(Fe,{value:_,onValueChange:(pe)=>g(pe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"streamable_http",children:"Streamable HTTP"}),t(ne,{value:"sse",children:"Server-Sent Events (SSE)"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:Ip()}),o(Fe,{value:y,onValueChange:(pe)=>x(pe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]})]})]}),o("div",{className:"space-y-3 pt-3 border-t border-border",children:[o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:_w()}),o(Fe,{value:m,onValueChange:(pe)=>i(pe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"auto",children:mw()}),t(ne,{value:"none",children:gw()}),t(ne,{value:"bearer",children:hw()}),t(ne,{value:"oauth",children:Aw()})]})]})]}),m==="bearer"&&o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:yw()}),t(H,{className:"h-9 text-xs font-mono",type:"password",value:v,onChange:(pe)=>w(pe.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(Q,{className:"text-xs",children:Ew()}),o(Fe,{value:T,onValueChange:(pe)=>q(pe),children:[t(Ze,{className:"h-9 text-xs",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"authorization_code",children:"Authorization Code"}),t(ne,{value:"client_credentials",children:"Client Credentials"})]})]})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:xw()}),t(H,{className:"h-9 text-xs",value:M,onChange:(pe)=>O(pe.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(Q,{className:"text-xs",children:Sw()}),t(H,{className:"h-9 text-xs",type:"password",value:Y,onChange:(pe)=>z(pe.target.value),placeholder:"Optional Secret"})]}),o("div",{className:"space-y-1.5",children:[t(Q,{className:"text-xs",children:Cw()}),t(H,{className:"h-9 text-xs",value:de,onChange:(pe)=>oe(pe.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(Q,{className:"text-xs font-semibold flex items-center gap-1.5",children:[t(Co,{className:"w-3.5 h-3.5"}),Fw()," (",se.length,")"]}),t("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:Zw()}),se.length>0&&o("div",{className:"flex items-center gap-1.5 pt-0.5",children:[t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>re("off"),disabled:U.isPending||Ee,children:vw()}),t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>re("on"),disabled:U.isPending||Ee,children:ww()}),t(E,{type:"button",variant:"outline",size:"sm",className:"h-7 text-[11px] px-2.5",onClick:()=>re("direct"),disabled:U.isPending||Ee,children:bw()})]})]}),t("div",{className:"space-y-2",children:Ee?t("div",{className:"flex justify-center py-8",children:t(F,{className:"w-6 h-6 animate-spin text-primary"})}):se.length===0?t("div",{className:"text-center py-6 text-muted-foreground text-xs",children:zx()}):se.map((pe)=>{let lt=Qe(pe.name),qe=!!xe[pe.name],ct=pe.inputSchema,aa=ct?.properties&&Object.keys(ct.properties).length>0;return o("div",{className:`border border-border rounded-lg p-3 transition-colors ${lt!=="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:()=>aa&&We(pe.name),children:[aa?qe?t(ve,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}):t(bt,{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:pe.name}),pe.title&&t(be,{variant:"outline",className:"text-[10px]",children:pe.title})]}),pe.description&&t("p",{className:"text-xs text-muted-foreground mt-1 break-words line-clamp-3",children:pe.description})]})]}),t("div",{className:"flex items-center gap-2 shrink-0",children:o(To,{type:"single",value:lt,onValueChange:(Wt)=>{if(Wt)At(pe.name,Wt)},size:"sm",variant:"outline",disabled:U.isPending||Ee,children:[t(Ar,{value:"off",className:"text-[11px] px-2 h-7",children:Pw()}),t(Ar,{value:"on",className:"text-[11px] px-2 h-7",children:Ow()}),t(Ar,{value:"direct",className:"text-[11px] px-2 h-7",children:Dw()})]})})]}),qe&&aa&&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:K1()}),t("div",{className:"grid grid-cols-1 gap-1.5",children:Object.entries(ct.properties).map(([Wt,Ca])=>{let qs=ct.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}),qs&&t("span",{className:"text-[10px] text-red-500 font-bold",children:"*"}),t(be,{variant:"secondary",className:"text-[9px] px-1 py-0",children:Ca.type||"any"})]}),Ca.description&&t("span",{className:"text-[11px] text-muted-foreground break-words sm:max-w-[320px]",children:Ca.description})]},Wt)})})]})]},pe.name)})})]})]})}),o(Ge,{className:"p-6 pt-4 border-t border-border flex-shrink-0",children:[o(E,{type:"button",variant:"outline",onClick:()=>U.mutate(),disabled:U.isPending||Ee||J.isPending,className:"gap-1.5 mr-auto",children:[t(ma,{className:`w-4 h-4 ${U.isPending?"animate-spin":""}`}),Fh()]}),t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(E,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),zs()]})]})]})]}):o(ie,{className:"sm:max-w-md",children:[o(me,{children:[o(le,{className:"flex items-center gap-2 text-xl font-bold",children:[t(bn,{className:"w-5 h-5 text-primary"}),Af()]}),t(Tt,{children:_d()})]}),o("form",{onSubmit:ee,className:"space-y-4",children:[o("div",{className:"space-y-2",children:[t(Q,{className:"text-xs font-semibold",children:Zh()}),t(H,{value:c,onChange:(pe)=>f(pe.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(Wo,{className:"w-3.5 h-3.5"}),Lh()]})]}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:r,children:Ne()}),o(E,{type:"submit",disabled:J.isPending||!c,children:[J.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),Pc()]})]})]})]})})};var Fs=({teamId:e})=>{let r=K(),{canAdmin:a}=Pt(),[l,s]=u(!1),[d,c]=u(null),[f,_]=u(null),[g,y]=u(null),{data:x,isLoading:m}=Z({queryKey:["teams",e,"mcp","servers"],queryFn:async()=>{let z=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:e}});if(!z.ok)throw Error(Yo());return await z.json()}}),i=B({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].$delete({param:{id:z}})).ok)throw Error(ki())},onSuccess:()=>{k.success(it()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),_(null)},onError:(z)=>{k.error(z.message)}}),v=B({mutationFn:async({id:z,permission:de})=>{if(!(await A.api.mcp.servers[":id"].permission.$patch({param:{id:z},json:{permission:de}})).ok)throw Error(gl())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{k.error(z.message)}}),w=B({mutationFn:async(z)=>{if(!(await A.api.mcp.servers[":id"].auth.$delete({param:{id:z}})).ok)throw Error("Failed to disconnect auth")},onSuccess:()=>{k.success(Oh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},onError:(z)=>{k.error(z.message)}}),M=async(z)=>{y(z);try{let de=await A.api.mcp.servers[":id"].auth.start.$post({param:{id:z}});if(!de.ok){let T=await de.json().catch(()=>({}));throw Error(T.error||Vf())}let oe=await de.json();if(oe.status==="authenticated"){k.success(Dh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]}),y(null);return}if(oe.authorizationUrl){let j=window.screenX+(window.outerWidth-600)/2,G=window.screenY+(window.outerHeight-700)/2,N=window.open(oe.authorizationUrl,"mcp_oauth_popup",`width=600,height=700,left=${j},top=${G},scrollbars=yes`),X=(ye)=>{if(ye.data?.type==="mcp-oauth-callback")if(window.removeEventListener("message",X),y(null),ye.data.ok)k.success(Dh()),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]});else k.error(ye.data.message||Vf())};window.addEventListener("message",X);let xe=setInterval(()=>{if(!N||N.closed)clearInterval(xe),window.removeEventListener("message",X),y(null),r.invalidateQueries({queryKey:["teams",e,"mcp","servers"]})},1000)}}catch(de){k.error(de instanceof Error?de.message:Vf()),y(null)}},O=x?.servers||[],Y=(z)=>{switch(z.status){case"connected":return o(be,{variant:"secondary",className:"gap-1 bg-emerald-500/10 text-emerald-600 border-emerald-500/20 text-[10px]",children:[t(vr,{className:"w-3 h-3"}),kw()]});case"needs_auth":return o(be,{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"}),Bh()]});case"failed":return o(be,{variant:"secondary",className:"gap-1 bg-red-500/10 text-red-600 border-red-500/20 text-[10px]",children:[t(vn,{className:"w-3 h-3"}),Rw()]});default:return o(be,{variant:"outline",className:"gap-1 text-[10px]",children:[t(Xt,{className:"w-3 h-3 text-muted-foreground"}),Nw()]})}};return o(Et,{children:[o(kt,{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(bn,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:Bc()}),t(Ut,{children:_d()})]})]}),a&&o(E,{onClick:()=>s(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",Af()]})]}),t(Mt,{children:m?t("div",{className:"flex justify-center py-10",children:t(F,{className:"w-8 h-8 animate-spin text-primary"})}):O.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(bn,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold",children:eg()}),t("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm mx-auto",children:RA()}),a&&o(E,{onClick:()=>s(!0),className:"mt-4 gap-2",variant:"outline",children:[t(fe,{className:"w-4 h-4"})," ",Af()]})]}):t("div",{className:"space-y-4",children:O.map((z)=>{let de=g===z.id,oe=z.status==="needs_auth"||!z.hasCredential&&z.authType!=="none";return o("div",{onClick:()=>a&&c(z),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(bn,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t("span",{className:"truncate",children:z.name}),t(be,{variant:"outline",className:"text-[10px] uppercase shrink-0",children:z.transport})]}),a&&o(he,{modal:!1,children:[t(ge,{asChild:!0,onClick:(T)=>T.stopPropagation(),children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:t(wr,{className:"w-4 h-4"})})}),o(Ae,{align:"end",children:[z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)?o(W,{onClick:(T)=>{T.stopPropagation(),M(z.id)},children:[t(Zt,{className:"w-4 h-4 mr-2"}),Ph()]}):null,z.hasCredential&&o(W,{onClick:(T)=>{T.stopPropagation(),w.mutate(z.id)},className:"text-amber-600",children:[t(Xa,{className:"w-4 h-4 mr-2"}),Oh()]}),(z.status!=="connected"&&(z.authType!=="none"||z.hasCredential)||z.hasCredential)&&t(Vt,{}),o(W,{onClick:(T)=>{T.stopPropagation(),_(z)},className:"text-red-600",children:[t(we,{className:"w-4 h-4 mr-2"}),it()]})]})]})]}),o("div",{className:"space-y-1",children:[t("p",{className:"text-sm text-muted-foreground line-clamp-2",children:z.description||Yh()}),t("p",{className:"font-mono text-[10px] text-muted-foreground/70 truncate",children:z.url}),z.lastError&&t("p",{className:"text-[10px] text-red-500/90 truncate font-mono",children:z.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(z),o(be,{variant:"outline",className:"text-[10px] gap-1 shrink-0",children:[t(Co,{className:"w-3 h-3 text-muted-foreground"}),Lw({count:z.toolCount})]}),o("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider font-semibold whitespace-nowrap",children:[iA()," ",new Date(z.updatedAt).toLocaleDateString()]})]}),o("div",{className:"flex items-center gap-2 shrink-0",onClick:(T)=>T.stopPropagation(),children:[a?o(Fe,{value:z.permission,onValueChange:(T)=>v.mutate({id:z.id,permission:T}),children:[t(Ze,{className:"h-7 text-xs px-2 bg-background border-border w-[130px]",children:t(Le,{})}),o(Be,{align:"end",children:[t(ne,{value:"reviewer",children:Ni()}),t(ne,{value:"editor",children:Di()}),t(ne,{value:"owner",children:Pi()})]})]}):t(be,{variant:"outline",className:"text-[10px]",children:z.permission==="reviewer"?Ni():z.permission==="editor"?Di():Pi()}),oe&&a&&o(E,{size:"sm",variant:"default",onClick:(T)=>{T.stopPropagation(),M(z.id)},disabled:de,className:"gap-1.5 bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[de?t(F,{className:"w-3.5 h-3.5 animate-spin"}):t(Zt,{className:"w-3.5 h-3.5"}),Ph()]})]})]})]},z.id)})})}),t(Ms,{isOpen:l||!!d,onClose:()=>{s(!1),c(null)},teamId:e,server:d}),t(Je,{open:!!f,onOpenChange:(z)=>!z&&_(null),children:o(Xe,{children:[o(et,{children:[t(rt,{children:ky()}),t(nt,{children:Ry({name:f?.name||""})})]}),o(tt,{children:[t(st,{children:Ne()}),o(ot,{onClick:()=>f&&i.mutate(f.id),className:"bg-red-600 hover:bg-red-700 text-white",children:[i.isPending&&t(F,{className:"w-4 h-4 mr-2 animate-spin"}),it()]})]})]})})]})};function Ds({teamId:e}){let r=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(Yo());return await f.json()}}),{mutate:s,isPending:d}=B({mutationFn:async(f)=>{let _=await A.api.teams[":teamId"].notifications.settings.$post({param:{teamId:e},json:f});if(!_.ok)throw Error(yh());return await _.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"notification-settings"]}),r.invalidateQueries({queryKey:["teams",e,"notifications"]}),k.success($x())},onError:(f)=>{k.error(f instanceof Error?f.message:yh())}}),c=(f)=>{if(!a)return;let _={...a,[f]:!a[f]};s(_)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});return t(ce,{className:"h-full",children:o("div",{className:"space-y-6 pr-4 pb-8",children:[o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(vo,{className:"w-5 h-5 text-primary"}),t(Rt,{className:"text-lg",children:N_()})]}),t(Ut,{children:D_()})]}),o(Mt,{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(vo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:mv()}),t("p",{className:"text-sm text-muted-foreground",children:CI()})]})]}),t(je,{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(Wa,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:R_()}),t("p",{className:"text-sm text-muted-foreground",children:TI()})]})]}),t(je,{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(Ua,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:W0()}),t("p",{className:"text-sm text-muted-foreground",children:II()})]})]}),t(je,{checked:a?.mentions??!0,onCheckedChange:()=>c("mentions"),disabled:d})]})]})]}),o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{className:"border-b border-border bg-muted/30 py-5",children:[o("div",{className:"flex items-center gap-2",children:[t(zn,{className:"w-5 h-5 text-primary"}),t(Rt,{className:"text-lg",children:Q0()})]}),t(Ut,{children:K0()})]}),o(Mt,{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(fi,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:kI()}),t("p",{className:"text-sm text-muted-foreground",children:MI()})]})]}),t(je,{checked:a?.yourUploads??!1,onCheckedChange:()=>c("yourUploads"),disabled:d})]}),o("div",{className:"flex items-center justify-between p-6",children:[o("div",{className:"flex gap-4",children:[t("div",{className:"mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-muted text-foreground",children:t(zn,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:mS()}),t("p",{className:"text-sm text-muted-foreground",children:SI()})]})]}),t(je,{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($s,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:t1()}),t("p",{className:"text-sm text-muted-foreground",children:EI()})]})]}),t(je,{checked:a?.statusUpdates??!0,onCheckedChange:()=>c("statusUpdates"),disabled:d})]})]})]}),o(Et,{className:"overflow-hidden gap-0 py-0",children:[o(kt,{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(Rt,{className:"text-lg",children:Qv()})]}),t(Ut,{children:Vv()})]}),o(Mt,{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:Kv()}),t("p",{className:"text-sm text-muted-foreground",children:xI()})]})]}),t(je,{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(vo,{className:"w-4 h-4"})}),o("div",{className:"space-y-0.5",children:[t("h4",{className:"text-sm font-semibold text-foreground",children:Gv()}),t("p",{className:"text-sm text-muted-foreground",children:wI()})]})]}),t(je,{checked:a?.kanbanComments??!0,onCheckedChange:()=>c("kanbanComments"),disabled:d})]})]})]})]})})}S();function As({teamId:e}){let r=K(),[a,l]=u(""),[s,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}=B({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:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),l(""),k.success(B0())},onError:(i)=>{k.error(i instanceof Error?i.message:Db())}}),{mutate:y}=B({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:()=>{r.invalidateQueries({queryKey:["teams",e,"api-tokens"]}),k.success(U0())},onError:(i)=>{k.error(i instanceof Error?i.message:Zb())}}),x=(i)=>{if(i.preventDefault(),!a.trim())return;_(a.trim())},m=async(i,v)=>{await co(v),d(i),k.success(H_()),setTimeout(()=>d(null),2000)};if(f)return t("div",{className:"flex justify-center items-center p-8",children:t(F,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return t("div",{className:"space-y-6",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:Hm()}),t(Ut,{children:z0()})]}),o(Mt,{className:"space-y-6",children:[o("form",{onSubmit:x,className:"flex gap-4 items-end max-w-md",children:[o("div",{className:"flex-1 space-y-2",children:[t("label",{htmlFor:"tokenName",className:"text-sm font-medium text-muted-foreground",children:V1()}),t(H,{id:"tokenName",value:a,onChange:(i)=>l(i.target.value),placeholder:Q1(),required:!0})]}),o(E,{type:"submit",disabled:g||!a.trim(),children:[g?t(F,{className:"w-4 h-4 animate-spin mr-2"}):t(fe,{className:"w-4 h-4 mr-2"}),gv()]})]}),t("div",{className:"border rounded-lg overflow-hidden",children:o(Rn,{children:[t(Nn,{children:o(br,{children:[t(xt,{children:_l()}),t(xt,{children:G1()}),t(xt,{children:cy()}),t(xt,{className:"w-[100px] text-right",children:xA()})]})}),t(Dn,{children:!c||c.length===0?t(br,{children:t(_t,{colSpan:4,className:"text-center py-6 text-muted-foreground text-sm",children:bx()})}):c.map((i)=>o(br,{children:[t(_t,{className:"font-medium",children:i.name}),t(_t,{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(E,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(i.id,i.token),children:s===i.id?t(ke,{className:"h-3.5 w-3.5 text-green-500"}):t(Rr,{className:"h-3.5 w-3.5"})})]})}),t(_t,{className:"text-muted-foreground",children:new Date(i.createdAt).toLocaleDateString()}),t(_t,{className:"text-right",children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-500 hover:text-red-600 hover:bg-red-50",onClick:()=>y(i.id),children:t(we,{className:"h-4 w-4"})})})]},i.id))})]})})]})]})})}S();S();var Fr=[{value:"read_asset",label:()=>Pm()},{value:"list_assets",label:()=>Nm()},{value:"create_folder",label:()=>Im()},{value:"create_file",label:()=>Cm()},{value:"create_version",label:()=>Tm()},{value:"generate_image",label:()=>km()},{value:"generate_video",label:()=>Rm()},{value:"rename_asset",label:()=>Om()},{value:"move_assets",label:()=>Dm()},{value:"delete_asset",label:()=>Mm()}],Ka={agent_total_tokens:{label:()=>Td(),icon:ao,unit:"tokens",defaultLimit:1e5},agent_cost:{label:()=>Ed(),icon:ui,unit:"$",defaultLimit:10},agent_mcp_call_count:{label:()=>Cd(),icon:bn,unit:"calls",defaultLimit:100},agent_bash_call_count:{label:()=>Sd(),icon:Io,unit:"calls",defaultLimit:50},agent_tool_call_count:{label:()=>Id(),icon:Co,unit:"calls",defaultLimit:100}},Is=({open:e,onOpenChange:r,teamId:a,rule:l,onSuccess:s})=>{let d=K(),c=!!l,[f,_]=u("each_member"),[g,y]=u("team"),[x,m]=u([]),[i,v]=u("agent_total_tokens"),[w,M]=u(""),[O,Y]=u("*"),[z,de]=u("read_asset"),[oe,T]=u(1e5),[q,j]=u("1day"),[G,N]=u(!0),[X,xe]=u(!1),[ye,Me]=u(""),{data:Se=[]}=Z({queryKey:["teams",a,"members"],queryFn:async()=>{let re=await A.api.teams[":teamId"].members.$get({param:{teamId:a},query:{}});if(!re.ok)return[];return await re.json()},enabled:e}),{data:ae}=Z({queryKey:["teams",a,"mcp","servers"],queryFn:async()=>{let re=await A.api.teams[":teamId"].mcp.servers.$get({param:{teamId:a}});if(!re.ok)return{servers:[]};return await re.json()},enabled:e&&i==="agent_mcp_call_count"}),_e=ae?.servers||[];h(()=>{if(l){_(l.scopeMode),y(l.role||"team"),m(l.userIds||[]),v(l.resource);let re=l.resourceData||{};M(typeof re.id==="string"?re.id:""),Y(typeof re.match==="string"?re.match:"*"),de(typeof re.name==="string"?re.name:typeof re.toolName==="string"?re.toolName:"read_asset"),T(l.limit),j(Xc(l.period)),N(l.enabled)}else _("each_member"),y("team"),m([]),v("agent_total_tokens"),M(""),Y("*"),de("read_asset"),T(Ka.agent_total_tokens.defaultLimit),j("1day"),N(!0)},[l,e]);let Ee=(re)=>{if(v(re),!c)T(Ka[re]?.defaultLimit||100)},Pe=B({mutationFn:async()=>{let re={};if(i==="agent_mcp_call_count")re.id=w;else if(i==="agent_bash_call_count")re.match=O.trim()||"*";else if(i==="agent_tool_call_count")re.name=z||"read_asset";let We=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"?x:null,resource:i,resourceData:Object.keys(re).length>0?re:null,limit:Number(oe),period:q,enabled:G}});if(!We.ok){let pe=await We.json().catch(()=>({}));throw Error(pe?.message||gh())}return await We.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(lE()),r(!1),s?.()},onError:(re)=>{console.error("CREATE MUTATION ERROR:",re),k.error(re instanceof Error?re.message:gh())}}),U=B({mutationFn:async()=>{if(!l)return;let re={};if(i==="agent_mcp_call_count")re.id=w;else if(i==="agent_bash_call_count")re.match=O.trim()||"*";else if(i==="agent_tool_call_count")re.name=z||"read_asset";let We=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"?x:null,resource:i,resourceData:Object.keys(re).length>0?re:null,limit:Number(oe),period:q,enabled:G}});if(!We.ok){let pe=await We.json().catch(()=>({}));throw Error(pe?.message||md())}return await We.json()},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(DE()),r(!1),s?.()},onError:(re)=>{k.error(re instanceof Error?re.message:md())}}),J=B({mutationFn:async()=>{if(!l)return;if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:a,id:l.id}})).ok)throw Error(pd())},onSuccess:()=>{d.invalidateQueries({queryKey:["teams",a,"quotas"]}),k.success(xg()),xe(!1),r(!1),s?.()},onError:(re)=>{k.error(re instanceof Error?re.message:pd())}}),ee=(re)=>{if(re.preventDefault(),f==="selected_members"&&x.length===0){k.error(TC());return}if(i==="agent_mcp_call_count"&&!w.trim()){k.error(ph());return}if(oe<=0){k.error("Limit must be greater than 0");return}if(c)U.mutate();else Pe.mutate()},se=Pe.isPending||U.isPending||J.isPending,Qe=Se.filter((re)=>{if(!ye.trim())return!0;let We=ye.toLowerCase();return re.name.toLowerCase().includes(We)||re.email&&re.email.toLowerCase().includes(We)}),At=(re)=>{m((We)=>We.includes(re)?We.filter((pe)=>pe!==re):[...We,re])};return o(L,{children:[t(ue,{open:e,onOpenChange:r,children:o(ie,{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(le,{className:"text-xl font-bold",children:c?Jy():sy()}),t(Tt,{className:"text-sm text-muted-foreground",children:c?Xy():ay()})]}),o("form",{onSubmit:ee,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(Q,{className:"text-sm font-semibold",children:wE()}),o("div",{className:"grid grid-cols-3 gap-2",children:[o(E,{type:"button",variant:f==="each_member"?"default":"outline",size:"sm",disabled:c||se,onClick:()=>_("each_member"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(Vn,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:kd()})]}),o(E,{type:"button",variant:f==="all_members"?"default":"outline",size:"sm",disabled:c||se,onClick:()=>_("all_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(io,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Md()})]}),o(E,{type:"button",variant:f==="selected_members"?"default":"outline",size:"sm",disabled:c||se,onClick:()=>_("selected_members"),className:"flex flex-col h-auto py-2.5 px-2 gap-1 items-center justify-center text-xs",children:[t(di,{className:"w-4 h-4"}),t("span",{className:"font-semibold",children:Rd()})]})]}),o("p",{className:"text-xs text-muted-foreground pt-0.5",children:[f==="each_member"&&SE(),f==="all_members"&&xE(),f==="selected_members"&&EE()]})]}),f!=="selected_members"?o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-role-scope",className:"text-sm font-semibold",children:vE()}),o(Fe,{value:g,onValueChange:y,disabled:c||se,children:[t(Ze,{id:"quota-role-scope",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"team",children:Sl()}),o(ne,{value:"owner",children:[gp(),": Owner"]}),o(ne,{value:"editor",children:[gp(),": Editor"]}),o(ne,{value:"reviewer",children:[gp(),": Reviewer"]})]})]})]}):o("div",{className:"space-y-2",children:[t(Q,{className:"text-sm font-semibold",children:zg()}),o(mt,{children:[t(ht,{asChild:!0,children:o(E,{variant:"outline",role:"combobox",disabled:se,className:"w-full justify-between text-left font-normal h-10",children:[t("span",{className:"truncate",children:x.length===0?zg():CE({count:x.length})}),t(ve,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t(gt,{className:"w-[320px] p-2",align:"start",children:o("div",{className:"space-y-2",children:[o("div",{className:"relative",children:[t(Bt,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),t(H,{placeholder:Ap(),value:ye,onChange:(re)=>Me(re.target.value),className:"h-8 pl-8 text-xs"})]}),t(ce,{className:"h-48",children:t("div",{className:"space-y-1 pr-2",children:Qe.map((re)=>{let We=x.includes(re.id);return o("div",{onClick:()=>At(re.id),className:"flex items-center gap-2 p-1.5 rounded-lg hover:bg-muted/60 cursor-pointer text-xs",children:[t(Pr,{checked:We,onCheckedChange:()=>At(re.id)}),o(Ce,{className:"w-5 h-5",children:[t(Ie,{src:re.image||void 0}),t(Te,{className:"text-[10px]",children:re.name?.[0]?.toUpperCase()||"U"})]}),o("div",{className:"truncate flex-1",children:[t("span",{className:"font-medium text-foreground block truncate",children:re.name}),re.email&&t("span",{className:"text-[10px] text-muted-foreground block truncate",children:re.email})]})]},re.id)})})})]})})]})]}),o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-resource",className:"text-sm font-semibold",children:yE()}),o(Fe,{value:i,onValueChange:(re)=>Ee(re),disabled:c||se,children:[t(Ze,{id:"quota-resource",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"agent_total_tokens",children:o("div",{className:"flex items-center gap-2",children:[t(ao,{className:"w-4 h-4 text-primary"}),t("span",{children:Td()})]})}),t(ne,{value:"agent_cost",children:o("div",{className:"flex items-center gap-2",children:[t(ui,{className:"w-4 h-4 text-emerald-500"}),t("span",{children:Ed()})]})}),t(ne,{value:"agent_mcp_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(bn,{className:"w-4 h-4 text-blue-500"}),t("span",{children:Cd()})]})}),t(ne,{value:"agent_bash_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Io,{className:"w-4 h-4 text-purple-500"}),t("span",{children:Sd()})]})}),t(ne,{value:"agent_tool_call_count",children:o("div",{className:"flex items-center gap-2",children:[t(Co,{className:"w-4 h-4 text-cyan-500"}),t("span",{children:Id()})]})})]})]})]}),i==="agent_mcp_call_count"&&o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-mcp",className:"text-sm font-semibold",children:Ug()}),_e.length>0?o(Fe,{value:w,onValueChange:M,disabled:c||se,children:[t(Ze,{id:"quota-mcp",className:"w-full",children:t(Le,{placeholder:Ug()})}),t(Be,{children:_e.map((re)=>o(ne,{value:re.id,children:[re.name," (",re.id,")"]},re.id))})]}):t(H,{id:"quota-mcp",value:w,onChange:(re)=>M(re.target.value),placeholder:ph(),disabled:c||se})]}),i==="agent_bash_call_count"&&o("div",{className:"space-y-1.5",children:[t(Q,{htmlFor:"quota-bash",className:"text-sm font-semibold",children:p_()}),t(H,{id:"quota-bash",value:O,onChange:(re)=>Y(re.target.value),placeholder:m_(),disabled:se}),t("p",{className:"text-xs text-muted-foreground",children:aE()})]}),i==="agent_tool_call_count"&&o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-tool",className:"text-sm font-semibold",children:qg()}),o(Fe,{value:z,onValueChange:de,disabled:c||se,children:[t(Ze,{id:"quota-tool",className:"w-full",children:t(Le,{placeholder:qg()})}),t(Be,{children:Fr.map((re)=>t(ne,{value:re.value,children:re.label()},re.value))})]}),t("p",{className:"text-xs text-muted-foreground",children:NE()})]}),o("div",{className:"grid grid-cols-2 gap-4",children:[o("div",{className:"space-y-2",children:[o(Q,{htmlFor:"quota-limit",className:"text-sm font-semibold",children:[fE()," (",Ka[i]?.unit||"",")"]}),t(H,{id:"quota-limit",type:"number",min:"0.01",step:i==="agent_cost"?"0.01":"1",value:oe,onChange:(re)=>T(Number(re.target.value)),placeholder:pE(),disabled:se,required:!0})]}),o("div",{className:"space-y-2",children:[t(Q,{htmlFor:"quota-period",className:"text-sm font-semibold",children:hE()}),o(Fe,{value:q,onValueChange:(re)=>j(re),disabled:se,children:[t(Ze,{id:"quota-period",className:"w-full",children:t(Le,{})}),o(Be,{children:[t(ne,{value:"1hour",children:o("div",{className:"flex items-center gap-2",children:[t(Xt,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:pp()})]})}),t(ne,{value:"5hour",children:o("div",{className:"flex items-center gap-2",children:[t(Xt,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:mp()})]})}),t(ne,{value:"1day",children:o("div",{className:"flex items-center gap-2",children:[t(Xt,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:fp()})]})}),t(ne,{value:"7day",children:o("div",{className:"flex items-center gap-2",children:[t(Xt,{className:"w-3.5 h-3.5 text-muted-foreground"}),t("span",{children:hp()})]})})]})]})]})]}),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(Q,{htmlFor:"quota-enabled",className:"text-sm font-medium cursor-pointer",children:G?uE():dp()}),t("p",{className:"text-xs text-muted-foreground",children:G?"Active and enforcing limits":"Inactive, requests will bypass this quota"})]}),t(je,{id:"quota-enabled",checked:G,onCheckedChange:N,disabled:se})]}),o(Ge,{className:"pt-4 flex items-center justify-between gap-2 sm:justify-between border-t border-border/60",children:[c?o(E,{type:"button",variant:"destructive",size:"sm",onClick:()=>xe(!0),disabled:se,className:"gap-1.5",children:[t(we,{className:"w-4 h-4"}),t("span",{children:Mf()})]}):t("div",{}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:se,children:Ne()}),o(E,{type:"submit",disabled:se,className:"gap-2",children:[se&&t(F,{className:"w-4 h-4 animate-spin"}),c?Fo():Pc()]})]})]})]})]})}),t(Je,{open:X,onOpenChange:xe,children:o(Xe,{children:[o(et,{children:[t(rt,{children:Mf()}),t(nt,{children:lh()})]}),o(tt,{children:[t(st,{disabled:se,children:Ne()}),o(ot,{onClick:(re)=>{re.preventDefault(),J.mutate()},disabled:se,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[se&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),it()]})]})]})})]})};var Ts=({teamId:e})=>{let r=K(),[a,l]=u(!1),[s,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(Yo());return await i.json()}}),y=B({mutationFn:async({id:i,enabled:v})=>{let w=await A.api.teams[":teamId"].quotas[":id"].$put({param:{teamId:e,id:i},json:{enabled:v}});if(!w.ok)throw Error(md());return await w.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),k.success(IE())},onError:(i)=>{k.error(i instanceof Error?i.message:md())}}),x=B({mutationFn:async(i)=>{if(!(await A.api.teams[":teamId"].quotas[":id"].$delete({param:{teamId:e,id:i}})).ok)throw Error(pd())},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"quotas"]}),k.success(xg()),f(null)},onError:(i)=>{k.error(i instanceof Error?i.message:pd())}}),m=_?.rules||[];return o(ce,{className:"h-full",children:[t("div",{className:"space-y-6 pr-4 pb-10",children:o(Et,{children:[o(kt,{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(Bo,{className:"w-6 h-6"})}),o("div",{children:[t(Rt,{className:"text-xl font-bold",children:Rg()}),t(Ut,{children:Ng()})]})]}),o(E,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",xm()]})]}),t(Mt,{children:g?t("div",{className:"flex justify-center py-12",children:t(F,{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(Bo,{className:"w-6 h-6"})}),t("h3",{className:"text-base font-semibold text-foreground mb-1",children:rp()}),t("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-6",children:tp()}),o(E,{onClick:()=>l(!0),className:"gap-2",children:[t(fe,{className:"w-4 h-4"})," ",xm()]})]}):t("div",{className:"flex flex-col gap-4",children:m.map((i)=>{let v=Hi[i.resource],w=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(w.id||"")]}),i.resource==="agent_bash_call_count"&&o("span",{children:["Match: ",String(w.match||"*")]}),i.resource==="agent_tool_call_count"&&o("span",{children:["Tool: ",String(w.name||w.toolName||"*")]})]})]}),o("div",{className:"flex items-center gap-2",onClick:(M)=>M.stopPropagation(),children:[t(je,{checked:i.enabled,onCheckedChange:(M)=>y.mutate({id:i.id,enabled:M}),disabled:y.isPending}),o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{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(Ae,{align:"end",children:o(W,{onClick:()=>f(i),className:"text-destructive focus:text-destructive",children:[t(we,{className:"w-4 h-4 mr-2"}),it()]})})]})]})]}),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(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(io,{className:"w-3 h-3"}),o("span",{children:[Md(),i.role?` (${i.role})`:` (${Sl()})`]})]}),i.scopeMode==="each_member"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(Vn,{className:"w-3 h-3"}),o("span",{children:[kd(),i.role?` (${i.role})`:` (${Sl()})`]})]}),i.scopeMode==="selected_members"&&o(be,{variant:"secondary",className:"gap-1 text-xs",children:[t(di,{className:"w-3 h-3"}),o("span",{children:[Rd()," (",i.userIds?.length||0,")"]})]}),o(be,{variant:"outline",className:"gap-1 text-xs",children:[t(Xt,{className:"w-3 h-3"}),o("span",{children:[Ra(i.resource,i.limit)," ",v?.unit," /"," ",Vl(i.period)]})]})]})})]})},i.id)})})})]})}),(a||!!s)&&t(Is,{open:a||!!s,onOpenChange:(i)=>{if(!i)l(!1),d(null)},teamId:e,rule:s}),t(Je,{open:!!c,onOpenChange:(i)=>{if(!i)f(null)},children:o(Xe,{children:[o(et,{children:[t(rt,{children:Mf()}),t(nt,{children:lh()})]}),o(tt,{children:[t(st,{disabled:x.isPending,children:Ne()}),o(ot,{onClick:(i)=>{if(i.preventDefault(),c)x.mutate(c.id)},disabled:x.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[x.isPending&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),it()]})]})]})})]})};function Es({teamId:e}){let r=K(),{data:a,isLoading:l}=Z({queryKey:["teams",e,"settings"],queryFn:async()=>{let _=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!_.ok)throw Error(Yo());return await _.json()},enabled:!!e}),{mutate:s,isPending:d}=B({mutationFn:async(_)=>{let g=await A.api.teams[":teamId"].settings.$patch({param:{teamId:e},json:{key:"appearance.hideAgent",value:_}});if(!g.ok)throw Error(vh());return await g.json()},onSuccess:async(_,g)=>{if(r.invalidateQueries({queryKey:["teams",e,"settings"]}),await gr.getState().fetchMetadata(e),g)lr.getState().setIsChatbotOpen(!1);k.success(j0())},onError:(_)=>{k.error(_ instanceof Error?_.message:vh())}}),c=Boolean(a?.appearance?.hideAgent),f=(_)=>{s(_)};if(l)return t("div",{className:"flex items-center justify-center p-8",children:t(F,{className:"h-6 w-6 animate-spin text-muted-foreground"})});return t("div",{className:"h-full overflow-y-auto pr-1",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:$m()}),t(Ut,{children:Gm()})]}),t(Mt,{className:"space-y-6",children:o("div",{className:"flex items-center justify-between space-x-4 rounded-lg border border-border p-4",children:[o("div",{className:"space-y-1",children:[t("label",{htmlFor:"hide-agent-switch",className:"text-sm font-medium leading-none cursor-pointer",children:Pv()}),t("p",{className:"text-xs text-muted-foreground",children:Ov()})]}),t(je,{id:"hide-agent-switch",checked:c,onCheckedChange:f,disabled:d})]})})]})})}S();var Vs={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 Ls({teamId:e}){let r=K(),[a,l]=u(null),{data:s,isLoading:d}=Z({queryKey:["teams",e,"media-generation"],queryFn:async()=>{let g=await A.api.teams[":teamId"]["media-generation"].$get({param:{teamId:e}});if(!g.ok)throw Error("Failed to fetch media generation settings");return await g.json()}}),c=s?.providers||[],f=s?.enabledModels||[],_=D(()=>{if(!a)return null;return c.find((g)=>g.provider===a.provider)||a},[a,c]);if(d)return t("div",{className:"flex h-64 items-center justify-center",children:t(F,{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(ce,{className:"h-full pr-1 [&>div>div]:block!",children:t("div",{className:"pb-12 min-w-0 w-full",children:o(Et,{className:"border-border min-w-0 w-full",children:[o(kt,{children:[t(Rt,{className:"text-base font-semibold",children:zw()}),t(Ut,{children:jw()})]}),t(Mt,{className:"min-w-0",children:t("div",{className:"space-y-2.5 min-w-0",children:c.map((g)=>{let y=Vs[g.provider]||g.provider,x=g.status==="configured_custom",m=g.status==="configured_env",i=f.filter((w)=>w.provider===g.provider&&w.type==="image").length,v=f.filter((w)=>w.provider===g.provider&&w.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:y}),t("span",{className:"text-xs text-muted-foreground font-mono opacity-60 truncate",title:g.customApiKeyOrEnv||g.defaultEnvKey,children:g.customApiKeyOrEnv||g.defaultEnvKey})]}),o("div",{className:"flex flex-wrap items-center gap-2 min-w-0",children:[x&&o(be,{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(vr,{className:"w-3 h-3"}),Ag()]}),m&&o(be,{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(vr,{className:"w-3 h-3"}),_g()]}),!x&&!m&&t(be,{variant:"outline",className:"bg-muted text-muted-foreground border-border text-[10px] shrink-0 font-normal",children:yg()}),g.supportedTypes.includes("image")&&o("span",{className:C("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(eo,{className:"w-3 h-3"}),Lv({count:i})]}),g.supportedTypes.includes("video")&&o("span",{className:C("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"}),mI({count:v})]})]})]}),t(bt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors shrink-0"})]},g.provider)})})})]})})}),_&&t(Dr,{isOpen:!!_,onClose:()=>l(null),provider:_,teamId:e,enabledModels:f,onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"media-generation"]})}})]})}function Dr({isOpen:e,onClose:r,provider:a,teamId:l,enabledModels:s,onSuccess:d}){let[c,f]=u(()=>a.apiKeyConfigured?"models":"api-key"),[_,g]=u(a.customApiKeyOrEnv||""),[y,x]=u(()=>s.filter((ae)=>ae.provider===a.provider).map((ae)=>({type:ae.type,modelId:ae.modelId,name:ae.name}))),[m,i]=u(""),[v,w]=u("all"),[M,O]=u(""),[Y,z]=u(a.supportedTypes[0]||"image");h(()=>{f(a.apiKeyConfigured?"models":"api-key"),g(a.customApiKeyOrEnv||""),x(s.filter((ae)=>ae.provider===a.provider).map((ae)=>({type:ae.type,modelId:ae.modelId,name:ae.name}))),i(""),w("all"),O(""),z(a.supportedTypes[0]||"image")},[a.provider,a.customApiKeyOrEnv,a.apiKeyConfigured,s]);let{data:de=[],isLoading:oe}=Z({queryKey:["teams",l,"media-generation","curated",a.provider],queryFn:async()=>{let ae=await A.api.teams[":teamId"]["media-generation"].models.curated.$get({param:{teamId:l},query:{provider:a.provider}});if(!ae.ok)return[];return await ae.json()},enabled:e}),{mutate:T,isPending:q}=B({mutationFn:async()=>{let ae=await A.api.teams[":teamId"]["media-generation"].providers[":provider"].$put({param:{teamId:l,provider:a.provider},json:{apiKey:_.trim(),models:y.map((_e)=>({type:_e.type,modelId:_e.modelId,name:_e.name||_e.modelId}))}});if(!ae.ok){let _e=await ae.json().catch(()=>({}));throw Error(_e?.message||"Failed to update provider")}return await ae.json()},onSuccess:()=>{k.success(bg()),d(),r()},onError:(ae)=>{k.error(ae instanceof Error?ae.message:Ub())}}),j=D(()=>new Set(de.map((ae)=>ae.modelId)),[de]),G=D(()=>y.filter((ae)=>!j.has(ae.modelId)),[y,j]),N=D(()=>{let ae=[];for(let _e of de){let Ee=y.some((Pe)=>Pe.modelId===_e.modelId&&Pe.type===_e.type);ae.push({type:_e.type,modelId:_e.modelId,name:_e.name,isCustom:!1,isToggledOn:Ee})}for(let _e of G)ae.push({type:_e.type,modelId:_e.modelId,name:_e.name||_e.modelId,isCustom:!0,isToggledOn:!0});return ae},[de,y,G]),X=D(()=>N.filter((ae)=>{if(v!=="all"&&ae.type!==v)return!1;if(m.trim()){let _e=m.toLowerCase(),Ee=ae.name.toLowerCase().includes(_e),Pe=ae.modelId.toLowerCase().includes(_e);if(!Ee&&!Pe)return!1}return!0}),[N,v,m]),xe=(ae,_e)=>{if(_e)x((Ee)=>[...Ee,{type:ae.type,modelId:ae.modelId,name:ae.name,isCustom:ae.isCustom}]);else x((Ee)=>Ee.filter((Pe)=>!(Pe.modelId===ae.modelId&&Pe.type===ae.type)))},ye=(ae,_e)=>{x((Ee)=>Ee.filter((Pe)=>!(Pe.modelId===ae&&Pe.type===_e)))},Me=()=>{let ae=M.trim();if(!ae)return;if(y.some((Ee)=>Ee.modelId===ae&&Ee.type===Y)){k.error(kb());return}x((Ee)=>[...Ee,{type:Y,modelId:ae,name:ae,isCustom:!0}]),O("")},Se=Vs[a.provider]||a.provider;return t(ue,{open:e,onOpenChange:(ae)=>!ae&&r(),children:o(ie,{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(le,{className:"flex items-center gap-2 text-xl",children:[t("span",{children:Se}),a.status==="configured_custom"&&t(be,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-[10px] font-normal",children:Ag()}),a.status==="configured_env"&&t(be,{variant:"outline",className:"bg-sky-500/10 text-sky-600 dark:text-sky-400 border-sky-500/20 text-[10px] font-normal",children:_g()})]}),t(Tt,{children:xy({envKey:a.defaultEnvKey})})]}),o(xo,{value:c,onValueChange:(ae)=>f(ae),className:"flex-1 flex flex-col min-h-0",children:[t("div",{className:"px-6 pb-2 shrink-0",children:o(So,{className:"grid w-full grid-cols-2",children:[t(Qr,{value:"api-key",onClick:()=>f("api-key"),children:sd()}),o(Qr,{value:"models",onClick:()=>f("models"),children:[yd()," (",y.length,")"]})]})}),t(kn,{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(ce,{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:sd()}),_&&o(E,{type:"button",variant:"ghost",size:"sm",className:"text-xs h-7 text-destructive hover:bg-destructive/10 hover:text-destructive gap-1 px-2",onClick:()=>g(""),children:[t(we,{className:"w-3.5 h-3.5"}),S_()]})]}),t(H,{id:"provider-api-key",type:"text",value:_,onChange:(ae)=>g(ae.target.value),placeholder:Z0({envKey:a.defaultEnvKey}),className:"font-mono text-sm"}),t("p",{className:"text-xs text-muted-foreground mt-1",children:L0({envKey:a.defaultEnvKey})})]})})})})}),o(kn,{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(vn,{className:"w-4 h-4 shrink-0 mt-0.5"}),o("div",{children:[t("p",{className:"font-medium",children:yg()}),t("p",{className:"text-[11px] opacity-90 mt-0.5",children:tE()})]})]})}),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(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t(H,{type:"text",placeholder:Sp(),value:m,onChange:(ae)=>i(ae.target.value),className:"pl-9 h-9 text-xs"})]}),a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-9",children:[t("button",{type:"button",onClick:()=>w("all"),className:C("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:k0()}),o("button",{type:"button",onClick:()=>w("image"),className:C("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(eo,{className:"w-3.5 h-3.5"}),Qf()]}),o("button",{type:"button",onClick:()=>w("video"),className:C("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"}),Kf()]})]})]}),t("div",{className:"flex-1 min-h-0 px-6",children:t(ce,{className:"h-full pr-4",children:oe?o("div",{className:"flex h-48 items-center justify-center gap-2 text-muted-foreground",children:[t(F,{className:"h-5 w-5 animate-spin"}),t("span",{className:"text-xs",children:nw()})]}):X.length===0?t("div",{className:"text-center py-12 border border-dashed rounded-xl text-muted-foreground text-sm",children:vd()}):t("div",{className:"space-y-2 pb-4",children:X.map((ae)=>o("div",{className:C("flex items-center justify-between p-3 rounded-xl border transition-all text-xs",ae.isToggledOn?"border-primary/40 bg-primary/5":"border-border bg-card hover:border-primary/30"),children:[o("div",{className:"flex items-center gap-2.5 min-w-0 flex-1 mr-3",children:[o(be,{variant:"outline",className:C("text-[10px] px-1.5 py-0.5 gap-1 shrink-0 font-normal",ae.type==="image"?"bg-primary/10 text-primary border-primary/20":"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20"),children:[ae.type==="image"?t(eo,{className:"w-3 h-3"}):t(ua,{className:"w-3 h-3"}),ae.type==="image"?Qf():Kf()]}),o("div",{className:"min-w-0 flex-1",children:[o("div",{className:"font-semibold text-foreground text-sm truncate flex items-center gap-1.5",children:[t("span",{className:"truncate",children:ae.name}),ae.isCustom&&t(be,{variant:"secondary",className:"text-[10px] h-4 px-1 font-normal shrink-0",children:my().replace("...","")})]}),t("p",{className:"font-mono text-[11px] text-muted-foreground truncate mt-0.5",children:ae.modelId})]})]}),o("div",{className:"flex items-center gap-2 shrink-0",children:[ae.isCustom&&t(E,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>ye(ae.modelId,ae.type),title:it(),children:t(we,{className:"w-3.5 h-3.5"})}),t(je,{checked:ae.isToggledOn,onCheckedChange:(_e)=>xe(ae,_e),"aria-label":`Toggle ${ae.name}`})]})]},`${ae.type}-${ae.modelId}`))})})}),t("div",{className:"px-6 py-3 border-t border-border shrink-0 bg-muted/10",children:o("div",{className:"flex items-center gap-2",children:[a.supportedTypes.length>1&&o("div",{className:"flex rounded-md border border-border overflow-hidden shrink-0 h-8",children:[t("button",{type:"button",onClick:()=>z("image"),className:C("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:Qf()}),t("button",{type:"button",onClick:()=>z("video"),className:C("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:Kf()})]}),t(H,{type:"text",value:M,onChange:(ae)=>O(ae.target.value),placeholder:db(),className:"font-mono text-xs h-8 flex-1",onKeyDown:(ae)=>{if(ae.key==="Enter")ae.preventDefault(),Me()}}),o(E,{type:"button",size:"sm",variant:"outline",className:"h-8 text-xs shrink-0 gap-1",onClick:Me,disabled:!M.trim(),children:[t(fe,{className:"w-3.5 h-3.5"}),gf()]})]})})]})]}),o(Ge,{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:[y.length," ",yd().toLowerCase()]}),o("div",{className:"flex items-center gap-2",children:[t(E,{type:"button",variant:"outline",size:"sm",onClick:r,disabled:q,children:Ne()}),o(E,{type:"button",size:"sm",onClick:()=>T(),disabled:q,children:[q&&t(F,{className:"w-4 h-4 mr-1.5 animate-spin"}),Fo()]})]})]})]})})}S();S();function Ps({isOpen:e,onClose:r,imageSrc:a,onConfirm:l}){let[s,d]=u(1),[c,f]=u({x:0,y:0}),[_,g]=u(!1),[y,x]=u(!1),m=b({x:0,y:0}),i=b(null),v=b(null),w=250;h(()=>{if(e)d(1),f({x:0,y:0}),x(!1)},[e,a]);let M=(T)=>{T.preventDefault(),g(!0),m.current={x:T.clientX-c.x,y:T.clientY-c.y}},O=(T)=>{if(!_)return;f({x:T.clientX-m.current.x,y:T.clientY-m.current.y})},Y=()=>{g(!1)},z=(T)=>{if(T.touches.length!==1)return;g(!0);let q=T.touches[0];m.current={x:q.clientX-c.x,y:q.clientY-c.y}},de=(T)=>{if(!_||T.touches.length!==1)return;let q=T.touches[0];f({x:q.clientX-m.current.x,y:q.clientY-m.current.y})},oe=async()=>{let T=i.current,q=v.current;if(!T||!q)return;x(!0);try{let j=T.getBoundingClientRect(),G=512,N=document.createElement("canvas");N.width=512,N.height=512;let X=N.getContext("2d");if(X){X.clearRect(0,0,512,512);let xe=2.048,ye=j.width/s,Me=j.height/s,Se=256+c.x*xe,ae=256+c.y*xe;X.translate(Se,ae),X.scale(s*xe,s*xe),X.drawImage(T,-ye/2,-Me/2,ye,Me);let _e=await new Promise((Ee)=>{N.toBlob((Pe)=>Ee(Pe),"image/jpeg",0.9)});if(_e)await l(_e)}}catch(j){console.error("Failed to crop image",j)}finally{x(!1)}};return t(ue,{open:e,onOpenChange:(T)=>!T&&r(),children:o(ie,{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(le,{className:"text-xl font-bold flex items-center gap-2",children:[t(Za,{className:"w-5 h-5 text-primary"}),RS()]})}),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:O,onMouseUp:Y,onMouseLeave:Y,onTouchStart:z,onTouchMove:de,onTouchEnd:Y,children:[a&&t("img",{ref:i,src:a,alt:u_(),crossOrigin:"anonymous",className:"absolute origin-center max-w-none pointer-events-none transition-transform duration-75 select-none",style:{top:"50%",left:"50%",transform:`translate(-50%, -50%) translate(${c.x}px, ${c.y}px) scale(${s})`,maxHeight:"100%"}}),t("div",{className:"absolute inset-0 pointer-events-none border-[3px] border-primary/90 rounded-full"}),t("div",{className:"absolute inset-0 pointer-events-none bg-black/40",style:{clipPath:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",maskImage:"radial-gradient(circle, transparent 122px, black 123px)",WebkitMaskImage:"radial-gradient(circle, transparent 122px, black 123px)"}})]}),o("div",{className:"w-full flex items-center gap-3 px-2",children:[t(Ja,{className:"w-4 h-4 text-muted-foreground"}),t("input",{type:"range",min:"1.0",max:"3.0",step:"0.01",value:s,onChange:(T)=>d(parseFloat(T.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(Ge,{className:"p-6 border-t border-border/40 bg-muted/20 flex flex-row justify-end gap-3",children:[t(E,{variant:"outline",onClick:r,disabled:y,children:Ne()}),t(E,{onClick:oe,disabled:y||!a,className:"min-w-[80px]",children:y?o(L,{children:[t(F,{className:"w-4 h-4 animate-spin mr-2"}),Og()]}):Fo()})]})]})})}var Ir=["general","transcode","quotas","appearance","skills","mcp","providers","image-video","agents","sandbox","notifications","developer"];function Rs(){if(typeof window>"u")return"general";let e=window.location.hash.replace(/^#/,"");return Ir.includes(e)?e:"general"}function Tr(){let{teamId:e}=Er.useParams(),r=K(),[a,l]=u(Rs),s=(ee)=>{l(ee);let se=ee==="general"?"":`#${ee}`;if(window.location.hash!==se)window.history.replaceState(null,"",window.location.pathname+window.location.search+se)};h(()=>{let ee=()=>{l(Rs())};return window.addEventListener("hashchange",ee),()=>window.removeEventListener("hashchange",ee)},[]);let[d,c]=u(""),[f,_]=u(!1),[g,y]=u(null),x=b(null),[m,i]=u(!1),{setMetadata:v,getMetadata:w}=gr(),M=w("locale")||n(),O=async(ee)=>{if(ee==="en"||ee==="zh")try{await v(e,"locale",ee),Mi(ee),k.success(Yv())}catch(se){console.error(se),k.error(qb())}},{data:Y,isLoading:z,error:de}=Z({queryKey:["teams",e,"settings"],queryFn:async()=>{let ee=await A.api.teams[":teamId"].settings.$get({param:{teamId:e}});if(!ee.ok)throw Error("Failed to fetch settings");return await ee.json()}}),{data:oe,isLoading:T}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let ee=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!ee.ok)throw Error("Failed to fetch me");return await ee.json()},enabled:!!e});h(()=>{if(oe?.name)c(oe.name)},[oe]),h(()=>{let ee=["transcode","quotas","appearance","providers","image-video","skills","mcp","agents","sandbox"];if(oe&&oe.role!=="owner"&&ee.includes(a))s("general")},[oe,a]);let q=(ee)=>{if(!ee)return"U";let se=ee.split(" ");if(se.length>1)return`${se[0][0]}${se[se.length-1][0]}`.toUpperCase();return ee.substring(0,2).toUpperCase()},j=(ee)=>{let se=ee.target.files?.[0];if(se){let Qe=new FileReader;Qe.onload=()=>{y(Qe.result),_(!0)},Qe.readAsDataURL(se),ee.target.value=""}},G=async(ee)=>{i(!0);try{let se=new File([ee],"avatar.jpg",{type:"image/jpeg"}),Qe=await A.api.teams[":teamId"].files.$post({param:{teamId:e},form:{file:se}});if(!Qe.ok)throw Error("Failed to upload avatar");let re=(await Qe.json()).key;if(!(await A.api.teams[":teamId"].me.$patch({param:{teamId:e},json:{imageKey:re}})).ok)throw Error("Failed to save profile");k.success(d_()),r.invalidateQueries({queryKey:["teams",e,"me"]}),_(!1)}catch(se){console.error(se),k.error(jb())}finally{i(!1)}},N=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");k.success(c_()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(ee){console.error(ee),k.error(Tb())}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");k.success(dg()),r.invalidateQueries({queryKey:["teams",e,"me"]})}catch(ee){console.error(ee),k.error(Hb())}finally{i(!1)}},{mutate:xe}=B({mutationFn:async(ee)=>{let se=await A.api.teams[":teamId"].settings.$patch({param:{teamId:ee.teamId},json:ee.data});if(!se.ok)throw Error("Failed to update settings");return await se.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["teams",e,"settings"]})}}),ye=(ee)=>{xe({teamId:e,data:{key:"transcode.videoStrategy",value:ee}})},Me=(ee)=>{xe({teamId:e,data:{key:"transcode.hardwareAcceleration",value:ee}})},[Se,ae]=u(null),_e=Y?.transcode?.threads??0;h(()=>{ae(null)},[_e]);let Ee=(ee)=>{xe({teamId:e,data:{key:"transcode.threads",value:ee}})};if(z||T)return t("div",{className:"flex h-screen items-center justify-center",children:t(F,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(de)return t("div",{className:"p-8 text-center text-red-500",children:Yo()});let Pe=Y?.transcode?.videoStrategy||ga.best_match;if(Pe==="single"||Pe==="disable")Pe=ga.best_match;else if(Pe==="full")Pe=ga.all;let U=Y?.transcode?.hardwareAcceleration||Fi.off,J=Se??_e;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:MS()}),o("button",{onClick:()=>s("general"),className:C("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(Vn,{className:"w-5 h-5"}),pv(),a==="general"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("notifications"),className:C("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(fi,{className:"w-5 h-5"}),rg(),a==="notifications"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("developer"),className:C("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"}),Hm(),a==="developer"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),oe?.role==="owner"&&o(L,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:C1()}),o("button",{onClick:()=>s("transcode"),className:C("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(Ga,{className:"w-5 h-5"}),Uh(),a==="transcode"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("quotas"),className:C("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(Bo,{className:"w-5 h-5"}),Nd(),a==="quotas"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("appearance"),className:C("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",a==="appearance"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[t(Hl,{className:"w-5 h-5"}),bf(),a==="appearance"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]}),oe?.role==="owner"&&o(L,{children:[t("div",{className:"mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:C0()}),o("button",{onClick:()=>s("providers"),className:C("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(ao,{className:"w-5 h-5"}),rE(),a==="providers"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("image-video"),className:C("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(sn,{className:"w-5 h-5"}),kh(),a==="image-video"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("skills"),className:C("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(wt,{className:"w-5 h-5"}),Gg(),a==="skills"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("mcp"),className:C("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(bn,{className:"w-5 h-5"}),Bc(),a==="mcp"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("agents"),className:C("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(St,{className:"w-5 h-5"}),A0(),a==="agents"&&t("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),o("button",{onClick:()=>s("sandbox"),className:C("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($l,{className:"w-5 h-5"}),KA(),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"&&Ih(),a==="transcode"&&Uh(),a==="quotas"&&Rg(),a==="appearance"&&$m(),a==="skills"&&Vg(),a==="mcp"&&Bc(),a==="providers"&&E0(),a==="image-video"&&kh(),a==="agents"&&S0(),a==="sandbox"&&WA(),a==="notifications"&&Hx(),a==="developer"&&Hy()]}),o("p",{className:"text-sm text-muted-foreground mt-1",children:[a==="general"&&hv(),a==="transcode"&&sA(),a==="quotas"&&Ng(),a==="appearance"&&Gm(),a==="skills"&&VC(),a==="mcp"&&_d(),a==="providers"&&nE(),a==="image-video"&&Uw(),a==="agents"&&_0(),a==="sandbox"&&eC(),a==="notifications"&&Gx(),a==="developer"&&qy()]})]})}),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(Et,{children:[o(kt,{children:[t(Rt,{children:IS()}),t(Ut,{children:TS()})]}),t(Mt,{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:l_()}),o("div",{className:"group relative cursor-pointer overflow-hidden rounded-full w-24 h-24 border border-border/60 shadow-md transition-all hover:opacity-90",onClick:()=>x.current?.click(),children:[o(Ce,{className:"w-24 h-24",children:[oe?.image&&t(Ie,{src:oe.image,alt:oe.name,className:"object-cover w-24 h-24"}),t(Te,{className:"text-2xl bg-primary/40 text-foreground",children:q(oe?.name)})]}),t("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:t("span",{className:"text-white text-xs font-semibold",children:b_()})})]}),o("div",{className:"flex gap-2",children:[t(E,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:aI()}),oe?.image&&t(E,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:N,children:El()})]}),t("input",{type:"file",ref:x,className:"hidden",accept:"image/*",onChange:j})]}),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:_l()}),t(H,{value:d,onChange:(ee)=>c(ee.target.value),placeholder:mb(),className:"max-w-md"})]}),o("div",{className:"space-y-2",children:[t("label",{className:"text-sm font-medium text-muted-foreground",children:Nf()}),t(H,{value:oe?.email||"",disabled:!0,className:"max-w-md bg-muted/50 cursor-not-allowed"}),t("p",{className:"text-xs text-muted-foreground",children:rb()})]}),o(E,{onClick:X,disabled:m||!d.trim(),className:"mt-2",children:[m&&t(F,{className:"w-4 h-4 animate-spin mr-2"}),zs()]})]})]})})]}),o(Et,{className:"border border-slate-200 dark:border-slate-800 mt-6",children:[o(kt,{children:[t(Rt,{children:Wv()}),t(Ut,{children:EC()})]}),t(Mt,{className:"space-y-4",children:t("div",{className:"max-w-xs",children:o(Fe,{value:M,onValueChange:O,children:[t(Ze,{children:t(Le,{placeholder:vC()})}),o(Be,{children:[t(ne,{value:"en",children:cb()}),t(ne,{value:"zh",children:x_()})]})]})})})]}),t(Ps,{isOpen:f,onClose:()=>_(!1),imageSrc:g,onConfirm:G})]}),a==="transcode"&&t("div",{className:"h-full overflow-y-auto pr-1 pb-8",children:o(Et,{children:[o(kt,{children:[t(Rt,{children:W1()}),o(Ut,{children:[t("span",{className:"block mb-2",children:sA()}),t("span",{className:"block",children:Y1()})]})]}),o(Mt,{className:"space-y-6",children:[o("div",{className:"space-y-3",children:[t("h3",{className:"text-lg font-medium",children:hI()}),o("div",{className:"space-y-3",children:[o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Pe===ga.best_match?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(ga.best_match),children:[t("div",{className:"font-semibold",children:h_()}),t("div",{className:"text-sm text-muted-foreground",children:g_()})]}),o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",Pe===ga.all?"border-primary bg-primary/5":"border-border"),onClick:()=>ye(ga.all),children:[t("div",{className:"font-semibold",children:R0()}),t("div",{className:"text-sm text-muted-foreground",children:N0()})]})]})]}),o("div",{className:"space-y-3 pt-6 border-t border-border",children:[t("h3",{className:"text-lg font-medium",children:Mv()}),o("div",{className:"space-y-3",children:[o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",U===Fi.off?"border-primary bg-primary/5":"border-border"),onClick:()=>Me(Fi.off),children:[t("div",{className:"font-semibold",children:Nv()}),t("div",{className:"text-sm text-muted-foreground",children:Dv()})]}),o("div",{className:C("cursor-pointer rounded-lg border p-4 transition-all hover:border-primary",U===Fi.auto?"border-primary bg-primary/5":"border-border"),onClick:()=>Me(Fi.auto),children:[t("div",{className:"font-semibold",children:kv()}),t("div",{className:"text-sm text-muted-foreground",children:Rv()})]})]})]}),o("div",{className:"space-y-4 pt-6 border-t border-border",children:[o("div",{className:"flex items-center justify-between",children:[o("div",{children:[t("h3",{className:"text-lg font-medium",children:Vb()}),t("p",{className:"text-sm text-muted-foreground",children:Qb()})]}),t("span",{className:"font-mono text-sm font-semibold px-2.5 py-1 rounded bg-muted text-foreground border border-border",children:J===0?rA():U1({count:J})})]}),o("div",{className:"pt-2 px-1",children:[t(Uo,{value:[J],min:0,max:32,step:1,onValueChange:([ee])=>ae(ee),onValueCommit:([ee])=>{ae(ee),Ee(ee)}}),o("div",{className:"flex justify-between text-xs text-muted-foreground mt-2",children:[o("span",{children:[rA()," (0)"]}),t("span",{children:"16"}),t("span",{children:"32"})]})]})]})]})]})}),a==="skills"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(ks,{teamId:e})}),a==="mcp"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Fs,{teamId:e})}),a==="providers"&&t(Ss,{teamId:e}),a==="image-video"&&t(Ls,{teamId:e}),a==="agents"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(xs,{teamId:e})}),a==="sandbox"&&t("div",{className:"h-full overflow-y-auto pr-1",children:t(Cs,{teamId:e})}),a==="notifications"&&t(Ds,{teamId:e}),a==="developer"&&t(As,{teamId:e}),a==="quotas"&&t(Ts,{teamId:e}),a==="appearance"&&t(Es,{teamId:e})]})]})})]})})}var Er=Ue("/teams/$teamId/settings")({component:Tr});export{Er as Route};