@shumai-one/shumai 0.4.0 → 0.4.1

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 (166) hide show
  1. package/bin/chunk-082zg4nr.js +307 -0
  2. package/bin/chunk-09pe07g6.js +7 -0
  3. package/bin/chunk-0qdzjcny.js +2 -0
  4. package/bin/chunk-0z1p2pvf.js +1 -0
  5. package/bin/{chunk-xkhwj8mw.js → chunk-116p639c.js} +2 -2
  6. package/bin/{chunk-yfqz6f72.js → chunk-13ypr8v0.js} +1 -1
  7. package/bin/{chunk-tcm57j8r.js → chunk-16txy3r1.js} +2 -2
  8. package/bin/{chunk-vhcqazqf.js → chunk-1vs91e4q.js} +2 -2
  9. package/bin/{chunk-br7d2qwc.js → chunk-29e0mb43.js} +1 -1
  10. package/bin/chunk-2a0egvsg.js +1 -0
  11. package/bin/{chunk-kxr8fjsq.js → chunk-2f35h4fn.js} +2 -2
  12. package/bin/{chunk-pdjar480.js → chunk-2jsjrqw4.js} +1 -1
  13. package/bin/{chunk-ns804tmv.js → chunk-2q7ew7yz.js} +2 -2
  14. package/bin/{chunk-9cmvymm5.js → chunk-2sc2jxd3.js} +1 -1
  15. package/bin/chunk-2vc6pw8q.js +2 -0
  16. package/bin/{chunk-8956rryj.js → chunk-3gqdepkd.js} +2 -2
  17. package/bin/chunk-44370df5.js +4 -0
  18. package/bin/{chunk-mha3rsh7.js → chunk-44xtwvd7.js} +1 -1
  19. package/bin/{chunk-5yhn31rd.js → chunk-47r5b77s.js} +1 -1
  20. package/bin/chunk-4azttb3w.js +1 -0
  21. package/bin/{chunk-j04sztp3.js → chunk-4ee336e3.js} +1 -1
  22. package/bin/{chunk-02afmyqy.js → chunk-4k2d8w9w.js} +2 -2
  23. package/bin/{chunk-djx2r4nj.js → chunk-4yhd7bmp.js} +1 -1
  24. package/bin/chunk-4yybby29.js +2 -0
  25. package/bin/{chunk-md12a1sf.js → chunk-5395g4kq.js} +1 -1
  26. package/bin/{chunk-34kaja59.js → chunk-5bkj2n94.js} +2 -2
  27. package/bin/{chunk-gjnrd32m.js → chunk-5c4h0t33.js} +1 -1
  28. package/bin/{chunk-ex2ym5pz.js → chunk-6nrynqdw.js} +2 -2
  29. package/bin/{chunk-ysvhtgve.js → chunk-6tv7rm3x.js} +2 -2
  30. package/bin/{chunk-7x1vkftb.js → chunk-785kxysj.js} +2 -2
  31. package/bin/{chunk-1qr0ajc8.js → chunk-78cxvbjd.js} +1 -1
  32. package/bin/{chunk-dk8vk17v.js → chunk-7g2k89gq.js} +2 -2
  33. package/bin/chunk-7psq38hv.js +1 -0
  34. package/bin/{chunk-xzag8w1v.js → chunk-7qzt5nhz.js} +1 -1
  35. package/bin/{chunk-gcc6pte2.js → chunk-7sf0gbbm.js} +1 -1
  36. package/bin/{chunk-9k76s3y6.js → chunk-7wvw67f3.js} +2 -2
  37. package/bin/chunk-7xcyn1ba.js +2 -0
  38. package/bin/{chunk-wehhpcm1.js → chunk-7zgvmn5q.js} +1 -1
  39. package/bin/{chunk-nz2v1jmd.js → chunk-8pfgh13x.js} +2 -2
  40. package/bin/{chunk-0h8rjeyj.js → chunk-8yt4m2pb.js} +1 -1
  41. package/bin/{chunk-0bfqrx5q.js → chunk-90tbc5f4.js} +2 -2
  42. package/bin/{chunk-41d9gkx7.js → chunk-92yvt66q.js} +1 -1
  43. package/bin/chunk-93v3tm93.js +1 -0
  44. package/bin/{chunk-aw5zkdma.js → chunk-9f83pnfc.js} +1 -1
  45. package/bin/chunk-a5b3aevg.js +2 -0
  46. package/bin/{chunk-kjjhvrk1.js → chunk-af6m9p1d.js} +1 -1
  47. package/bin/chunk-ajryg2e2.js +1 -0
  48. package/bin/{chunk-62ebss6h.js → chunk-axb1f1ae.js} +2 -2
  49. package/bin/{chunk-fvbd5dk7.js → chunk-b0cqsrse.js} +2 -2
  50. package/bin/chunk-b27jgdsf.css +1 -0
  51. package/bin/{chunk-k3r97v7j.js → chunk-bbar8rsh.js} +1 -1
  52. package/bin/{chunk-x9akgj7w.js → chunk-be9a7kc6.js} +2 -2
  53. package/bin/{chunk-dkjkn8t3.js → chunk-bkbqvxfv.js} +2 -2
  54. package/bin/chunk-bwyph9a0.js +1 -0
  55. package/bin/{chunk-2x46963w.js → chunk-c43nmcfq.js} +1 -1
  56. package/bin/{chunk-4q782s34.js → chunk-c97vh5wb.js} +3 -3
  57. package/bin/{chunk-s73c0brj.js → chunk-cerjktz2.js} +1 -1
  58. package/bin/chunk-cyvx7gcx.js +2 -0
  59. package/bin/{chunk-zye42cfp.js → chunk-d6d1j7qq.js} +2 -2
  60. package/bin/{chunk-zh752hw8.js → chunk-d9sh922y.js} +1 -1
  61. package/bin/chunk-dbjc1vxt.js +1 -0
  62. package/bin/{chunk-06spnkta.js → chunk-djkajvn7.js} +1 -1
  63. package/bin/{chunk-vcf2qk9h.js → chunk-dyvmwafa.js} +1 -1
  64. package/bin/{chunk-wzmpvadf.js → chunk-ewge52nq.js} +1 -1
  65. package/bin/{chunk-6m1k317a.js → chunk-f32kxe6c.js} +2 -2
  66. package/bin/{chunk-mhps85dd.js → chunk-f4d3v0nc.js} +2 -2
  67. package/bin/{chunk-52dr035y.js → chunk-f8ysqfyv.js} +1 -1
  68. package/bin/{chunk-xjnghr99.js → chunk-fcsar7p0.js} +1 -1
  69. package/bin/{chunk-44edgqvy.js → chunk-gfdfkqrc.js} +2 -2
  70. package/bin/chunk-gr30nssh.js +1 -0
  71. package/bin/{chunk-t6qdrw24.js → chunk-gtwhwdbs.js} +1 -1
  72. package/bin/{chunk-dag45evp.js → chunk-gyaem1t4.js} +1 -1
  73. package/bin/chunk-hk6tvf7b.js +1 -0
  74. package/bin/{chunk-yyjx8nbq.js → chunk-hmmzbyy1.js} +2 -2
  75. package/bin/chunk-hzz4hsss.js +1 -0
  76. package/bin/{chunk-ymr5ybxk.js → chunk-j10gz94w.js} +2 -2
  77. package/bin/{chunk-gazp5662.js → chunk-j9q9rjvd.js} +2 -2
  78. package/bin/{chunk-etprs58p.js → chunk-jw00fmkp.js} +1 -1
  79. package/bin/chunk-k1f3gj25.js +3 -0
  80. package/bin/{chunk-he1ywtxx.js → chunk-k20w9eaz.js} +1 -1
  81. package/bin/{chunk-r2shjtte.js → chunk-kejt7kcr.js} +2 -2
  82. package/bin/{chunk-d7en47eh.js → chunk-kkveddbn.js} +1 -1
  83. package/bin/chunk-ktvmxqfg.js +5 -0
  84. package/bin/{chunk-792t2653.js → chunk-m49g5tf4.js} +1 -1
  85. package/bin/{chunk-wy2f6mby.js → chunk-me3xj7na.js} +1 -1
  86. package/bin/{chunk-3twtxs5m.js → chunk-mgytr7nc.js} +1 -1
  87. package/bin/{chunk-y3dy4pdt.js → chunk-mkb4dycy.js} +1 -1
  88. package/bin/chunk-n21a21vx.js +2 -0
  89. package/bin/{chunk-qac5hr5h.js → chunk-nndzhn3n.js} +1 -1
  90. package/bin/{chunk-m8z8jvdq.js → chunk-pcxjm1re.js} +1 -1
  91. package/bin/{chunk-m2tbft2c.js → chunk-pg00gkr4.js} +1 -1
  92. package/bin/{chunk-thbfw1ed.js → chunk-pn94h6x7.js} +1 -1
  93. package/bin/{chunk-93ecxcy4.js → chunk-pt51m9h1.js} +2 -2
  94. package/bin/{chunk-vkgxrn1h.js → chunk-px2cvc1n.js} +1 -1
  95. package/bin/{chunk-3gjn4pyp.js → chunk-q059y3wx.js} +1 -1
  96. package/bin/{chunk-kvnfgr29.js → chunk-q46rc697.js} +1 -1
  97. package/bin/{chunk-wrgwjg2g.js → chunk-r6g1srb3.js} +1 -1
  98. package/bin/chunk-r88vwaxc.js +1 -0
  99. package/bin/chunk-r9pzpqst.js +2 -0
  100. package/bin/{chunk-tn67sjb2.js → chunk-rar0gk7s.js} +2 -2
  101. package/bin/chunk-rfrpb986.js +1 -0
  102. package/bin/{chunk-2xgvs3as.js → chunk-rfsbzd39.js} +2 -2
  103. package/bin/{chunk-8nyve0cr.js → chunk-s503pcvb.js} +2 -2
  104. package/bin/{chunk-vvhs586e.js → chunk-s9sgkkjp.js} +1 -1
  105. package/bin/{chunk-4b7jcpgv.js → chunk-srs9jq8f.js} +1 -1
  106. package/bin/chunk-t77dwtcc.js +2 -0
  107. package/bin/{chunk-zmyawgth.js → chunk-tcqw0q8x.js} +1 -1
  108. package/bin/{chunk-fcsfssar.js → chunk-thd9zasr.js} +1 -1
  109. package/bin/chunk-tkgpc6c9.js +2 -0
  110. package/bin/{chunk-76433x4d.js → chunk-ts10cfmc.js} +2 -2
  111. package/bin/{chunk-p49h5fxs.js → chunk-txkmks1h.js} +1 -1
  112. package/bin/{chunk-jwgfkpek.js → chunk-v9hbssqd.js} +1 -1
  113. package/bin/{chunk-31y5j4hr.js → chunk-v9zc56qr.js} +1 -1
  114. package/bin/{chunk-et0cewj7.js → chunk-vh7eb7tp.js} +1 -1
  115. package/bin/chunk-w9p59ahz.js +73 -0
  116. package/bin/{chunk-3r33kewe.js → chunk-wfee9d83.js} +2 -2
  117. package/bin/{chunk-agabtxrc.js → chunk-wxsq9zmf.js} +1 -1
  118. package/bin/chunk-wzdnsgwq.js +2 -0
  119. package/bin/chunk-x2nnv4j8.js +1 -0
  120. package/bin/chunk-xxtcmzcv.js +2 -0
  121. package/bin/{chunk-sx6y697s.js → chunk-xyzmew7g.js} +1 -1
  122. package/bin/{chunk-ck6msfch.js → chunk-ygsbmfcy.js} +2 -2
  123. package/bin/{chunk-ez6veng7.js → chunk-ym9xavj0.js} +1 -1
  124. package/bin/{chunk-xv5h4dv1.js → chunk-z340qkez.js} +1 -1
  125. package/bin/{chunk-c3msq02x.js → chunk-za7ga4bf.js} +1 -1
  126. package/bin/{chunk-j536e9nx.js → chunk-zqvavykq.js} +2 -2
  127. package/bin/{chunk-2rbexbv0.js → chunk-zt15ht52.js} +1 -1
  128. package/bin/shumai-app.html +1 -1
  129. package/bin/shumai-app.js +269 -311
  130. package/package.json +7 -7
  131. package/prisma/schema.prisma +1 -1
  132. package/bin/chunk-045f1bw7.js +0 -2
  133. package/bin/chunk-0n1wfwcm.js +0 -2
  134. package/bin/chunk-1fwzepfn.js +0 -2
  135. package/bin/chunk-2xevs82j.js +0 -2
  136. package/bin/chunk-34adtqqh.js +0 -1
  137. package/bin/chunk-4j8fbckp.js +0 -1
  138. package/bin/chunk-57s7yj35.js +0 -1
  139. package/bin/chunk-6tse78c7.js +0 -2
  140. package/bin/chunk-ajndx51c.js +0 -2
  141. package/bin/chunk-bbyc2jfq.js +0 -1
  142. package/bin/chunk-by6g0vye.js +0 -2
  143. package/bin/chunk-c24fvhm6.js +0 -1
  144. package/bin/chunk-c6aszz6p.js +0 -1
  145. package/bin/chunk-csqvmx1m.js +0 -2
  146. package/bin/chunk-dg8c91j5.js +0 -1
  147. package/bin/chunk-f2zbsrc9.js +0 -2
  148. package/bin/chunk-gcpr2a24.js +0 -7
  149. package/bin/chunk-gpjkegdp.js +0 -1
  150. package/bin/chunk-jt6d0zb1.js +0 -2
  151. package/bin/chunk-k2065y29.js +0 -2
  152. package/bin/chunk-k514bttd.js +0 -1
  153. package/bin/chunk-k7chm9a9.js +0 -2
  154. package/bin/chunk-kjgejwjp.css +0 -1
  155. package/bin/chunk-kqpzx5az.js +0 -73
  156. package/bin/chunk-nn0px81k.js +0 -307
  157. package/bin/chunk-p1temt1j.js +0 -1
  158. package/bin/chunk-rkz6x3r0.js +0 -2
  159. package/bin/chunk-svz0ds0g.js +0 -1
  160. package/bin/chunk-t31basc5.js +0 -1
  161. package/bin/chunk-wvwqgff4.js +0 -1
  162. package/bin/chunk-ww1cy08p.js +0 -1
  163. package/bin/chunk-xfp27ya9.js +0 -2
  164. package/bin/chunk-y0f4bc9f.js +0 -2
  165. package/bin/chunk-y2s0tjaa.js +0 -3
  166. /package/bin/{chunk-xg9xscqz.js → chunk-kryt6pg3.js} +0 -0
@@ -0,0 +1 @@
1
+ import{e as kZ,f as uZ}from"./chunk-a5b3aevg.js";import{w as pZ}from"./chunk-09pe07g6.js";import{Z as $J}from"./chunk-44xtwvd7.js";import"./chunk-srs9jq8f.js";import{ba as ZZ}from"./chunk-4yhd7bmp.js";import"./chunk-mkb4dycy.js";import{da as vZ}from"./chunk-mgnxa0vy.js";import{ke as iZ}from"./chunk-8yt4m2pb.js";import{Le as IZ}from"./chunk-zqvavykq.js";import{Ze as CZ}from"./chunk-6nrynqdw.js";import"./chunk-xxtcmzcv.js";import"./chunk-f4d3v0nc.js";import"./chunk-2q7ew7yz.js";import"./chunk-j10gz94w.js";import"./chunk-ktvmxqfg.js";import{eg as JZ}from"./chunk-k1f3gj25.js";import{gg as OZ,hg as wZ,ig as FZ,jg as TZ,kg as EJ}from"./chunk-hmmzbyy1.js";import"./chunk-7g2k89gq.js";import{ng as hZ,og as mZ}from"./chunk-7xcyn1ba.js";import{Sg as fZ,Tg as BZ,ah as bZ,dh as gZ,gh as SZ}from"./chunk-785kxysj.js";import{hh as AZ}from"./chunk-ygsbmfcy.js";import"./chunk-1vs91e4q.js";import"./chunk-16txy3r1.js";import"./chunk-bkbqvxfv.js";import"./chunk-ts10cfmc.js";import"./chunk-rfsbzd39.js";import"./chunk-2sc2jxd3.js";import{ci as KJ}from"./chunk-f32kxe6c.js";import"./chunk-2f35h4fn.js";import{gi as wJ,ii as FJ,ji as TJ,ki as GJ,ni as QZ,oi as zZ,si as bJ}from"./chunk-4k2d8w9w.js";import{Ai as jZ,Bi as u,Ci as eJ,Ii as U,Ri as oJ,Ti as rJ,Ui as WZ,Vi as qZ,Wi as aJ,Yi as N,wi as zJ,zi as a}from"./chunk-s503pcvb.js";import{_i as P}from"./chunk-axb1f1ae.js";import{$i as vJ,Dj as LJ,Fl as dJ,Gk as NJ,Gl as OJ,Kl as lJ,Mk as BJ,Nj as UZ,Pk as PZ,Sk as yZ,Sl as $Z,aj as QJ,ak as HZ,bj as J,cj as Y,ck as VZ,dk as fJ,dl as MZ,il as DJ,lk as sJ,mj as xZ,pk as RZ,ql as nJ,qm as A,sj as EZ,tm as X,um as JJ,vk as _Z,xl as DZ}from"./chunk-w9p59ahz.js";import{rn as CJ}from"./chunk-txkmks1h.js";var S=CJ(vJ(),1);var W=CJ(vJ(),1);function eZ({ratio:G}){switch(G){case"16:9":return J("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return J("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return J("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return J("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return J("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return J("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function tJ(){return Math.random().toString(36).substring(2,9)}function KZ(){return{id:tJ(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function J0(){return{id:tJ(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var cJ=[{id:"dark",label:"Dark Slate",bg:"#1e293b",dot:"#475569"},{id:"black",label:"Black",bg:"#000000",dot:"#404040"},{id:"gray",label:"Slate Gray",bg:"#64748b",dot:"#cbd5e1"},{id:"white",label:"White",bg:"#ffffff",dot:"#94a3b8"},{id:"green",label:"Chroma Green",bg:"#059669",dot:"#047857"}],Z0={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function NZ({open:G,onOpenChange:w,initialConfig:y,shareId:E,teamId:F,onSaveSuccess:M}){let B=zJ(),[Q,D]=W.useState([]),[z,R]=W.useState(null),[b,h]=W.useState(null),[T,ZJ]=W.useState("16:9"),[HJ,VJ]=W.useState("grid"),[WJ,j]=W.useState(!1),[YJ,o]=W.useState("new"),[s,x]=W.useState(""),[m,i]=W.useState(null),C=W.useRef(null),c=W.useRef(null),[n,qJ]=W.useState({w:0,h:0}),[v,I]=W.useState(!1),H=W.useCallback((Z)=>{if(c.current=Z,!Z)return;let $=()=>{let{clientWidth:f,clientHeight:O}=Z;if(f<=0||O<=0)return;let g=Z0[T],iJ=f,yJ=iJ/g;if(yJ>O)yJ=O,iJ=yJ*g;qJ({w:Math.round(iJ),h:Math.round(yJ)})};$();let V=new ResizeObserver($);return V.observe(Z),()=>{V.disconnect(),c.current=null}},[T]),k=bJ((Z)=>Z.teamId),_J=F||k,[SJ,UJ]=W.useState(!1),[d,RJ]=W.useState({}),r=W.useRef(null),AJ=U.api.teams[":teamId"].files.$post,e=async(Z,$)=>{let V=Z.target.files?.[0];if(!V)return;if(V.size>1048576){if(N.error(X.file_exceeds_1mb_limit()),r.current)r.current.value="";return}if(!_J){N.error(X.failed_upload_file());return}UJ(!0);let f=URL.createObjectURL(V);RJ((O)=>({...O,[$]:f}));try{let O=await AJ({param:{teamId:_J},form:{file:V}});if(!O.ok)throw Error(X.failed_upload_file());let g=await O.json();L($,{imageAssetKey:g.key,imageAssetUrl:g.url})}catch(O){let g=O instanceof Error?O.message:X.failed_upload_file();N.error(g)}finally{if(UJ(!1),r.current)r.current.value=""}};W.useEffect(()=>{if(G){if(y?.blocks&&y.blocks.length>0)D(y.blocks),R(y.blocks[0].id);else{let Z=KZ();D([Z]),R(Z.id)}h(null)}},[G,y]);let{data:l=[]}=a({queryKey:["watermark-templates",F],queryFn:async()=>{let Z=await U.api["watermark-templates"].$get({query:F?{teamId:F}:{}});if(!Z.ok)return[];return await Z.json()},enabled:G}),hJ=U.api.shares[":shareId"].watermark.$put,{mutate:IJ,isPending:pJ}=u({mutationFn:async(Z)=>{let $=await hJ({param:{shareId:E},json:{enabled:!0,config:Z}});if(!$.ok){let V=await $.json().catch(()=>null);throw Error(V?.error||X.failed_update())}return await $.json()},onSuccess:()=>{B.invalidateQueries({queryKey:["share",E]}),B.invalidateQueries({queryKey:["shares"]}),N.success(X.watermark_updated()),w(!1),M?.()},onError:(Z)=>{N.error(Z.message||X.failed_update())}}),kJ=U.api["watermark-templates"].$post,{mutate:uJ,isPending:PJ}=u({mutationFn:async({name:Z,config:$})=>{let V=await kJ({json:{name:Z,teamId:F||void 0,config:$}});if(!V.ok)throw Error(X.failed_update());return await V.json()},onSuccess:(Z)=>{B.invalidateQueries({queryKey:["watermark-templates"]}),h(Z.id),j(!1),N.success(X.template_saved())},onError:()=>{N.error(X.failed_update())}}),jJ=U.api["watermark-templates"][":templateId"].$put,{mutate:K,isPending:q}=u({mutationFn:async({templateId:Z,config:$})=>{let V=await jJ({param:{templateId:Z},json:{config:$}});if(!V.ok)throw Error(X.failed_update());return await V.json()},onSuccess:()=>{B.invalidateQueries({queryKey:["watermark-templates"]}),j(!1),N.success(X.template_updated())},onError:()=>{N.error(X.failed_update())}}),p=U.api["watermark-templates"][":templateId"].$delete,{mutate:nZ}=u({mutationFn:async(Z)=>{if(!(await p({param:{templateId:Z}})).ok)throw Error(X.failed_to_delete())},onSuccess:(Z,$)=>{if(B.invalidateQueries({queryKey:["watermark-templates"]}),b===$)h(null);N.success(X.template_deleted())},onError:()=>{N.error(X.failed_to_delete())}}),XJ=Q.findIndex((Z)=>Z.id===z),_=XJ>=0?Q[XJ]:null,XZ=()=>{let Z=KZ();D(($)=>[...$,Z]),R(Z.id)},dZ=()=>{let Z=J0();D(($)=>[...$,Z]),R(Z.id)},GZ=(Z)=>{if(!Z)return;D(($)=>{let V=$.filter((f)=>f.id!==Z);if(z===Z)R(V.length>0?V[Math.max(0,XJ-1)].id:null);return V})},L=(Z,$)=>{D((V)=>V.map((f)=>f.id===Z?{...f,...$}:f))},lZ=()=>{if(Q.length===0)return;let Z=(XJ-1+Q.length)%Q.length;R(Q[Z].id)},oZ=()=>{if(Q.length===0)return;let Z=(XJ+1)%Q.length;R(Q[Z].id)},rZ=(Z,$)=>{Z.stopPropagation(),R($),I(!0)},xJ=W.useCallback((Z)=>{if(!v||!z||!C.current)return;let $=C.current.getBoundingClientRect(),V=(Z.clientX-$.left)/$.width,f=(Z.clientY-$.top)/$.height,O=Math.max(0,Math.min(1,Math.round(V*100)/100)),g=Math.max(0,Math.min(1,Math.round(f*100)/100));L(z,{x:O,y:g})},[v,z]),mJ=W.useCallback(()=>{I(!1)},[]);W.useEffect(()=>{if(v)window.addEventListener("mousemove",xJ),window.addEventListener("mouseup",mJ);return()=>{window.removeEventListener("mousemove",xJ),window.removeEventListener("mouseup",mJ)}},[v,xJ,mJ]),W.useEffect(()=>{let Z=($)=>{if(!G||!z)return;let V=$.target?.tagName?.toLowerCase();if(V==="input"||V==="textarea"||V==="select")return;if($.key==="Delete"||$.key==="Backspace")$.preventDefault(),GZ(z)};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[G,z,XJ]);let aZ=(Z)=>{if(Z.config?.blocks&&Z.config.blocks.length>0){let $=Z.config.blocks.map((V)=>({...V,id:tJ()}));D($),R($[0].id),h(Z.id)}},tZ=()=>{if(Q.length===0){N.error(X.no_watermark_blocks());return}IJ({blocks:Q})},sZ=()=>{if(YJ==="new"){if(!s.trim()){N.error(X.enter_template_name());return}uJ({name:s.trim(),config:{blocks:Q}})}else{let Z=m||b;if(!Z){N.error(X.select_template_to_overwrite());return}K({templateId:Z,config:{blocks:Q}})}};return Y(QJ,{children:[J(oJ,{open:G,onOpenChange:w,children:Y(rJ,{showCloseButton:!1,className:"sm:max-w-[1400px] max-w-[95vw] w-[95vw] h-[88vh] flex flex-col p-0 gap-0 overflow-hidden",onPointerDownOutside:(Z)=>Z.preventDefault(),children:[Y("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[J("div",{className:"flex items-center gap-3",children:J(aJ,{className:"text-base font-semibold",children:X.watermark_editor()})}),Y("div",{className:"flex items-center gap-2",children:[Y(wJ,{modal:!1,children:[J(FJ,{asChild:!0,children:Y(A,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[J(_Z,{className:"h-4 w-4 text-muted-foreground"}),X.watermark_templates()]})}),Y(TJ,{align:"end",className:"w-56",children:[J(QZ,{className:"text-xs font-semibold text-muted-foreground",children:X.load_template()}),l.length===0?J("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:X.no_templates_found()}):l.map((Z)=>Y(GJ,{onClick:()=>aZ(Z),className:"flex items-center justify-between text-xs cursor-pointer",children:[J("span",{className:"truncate flex-1",children:Z.name}),b===Z.id&&J(HZ,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),J(A,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:($)=>{$.stopPropagation(),nZ(Z.id)},children:J(dJ,{className:"h-3 w-3"})})]},Z.id)),J(zZ,{}),Y(GJ,{onClick:()=>{o("new"),x(""),j(!0)},className:"text-xs gap-2 cursor-pointer",children:[J(DJ,{className:"h-3.5 w-3.5 text-primary"}),X.create_new_template()]}),l.length>0&&Y(GJ,{onClick:()=>{o("overwrite"),i(b||l[0].id),j(!0)},className:"text-xs gap-2 cursor-pointer",children:[J(nJ,{className:"h-3.5 w-3.5 text-muted-foreground"}),X.overwrite_existing_template()]})]})]}),J(A,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>w(!1),children:X.cancel()}),Y(A,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:pJ,onClick:tZ,children:[J(nJ,{className:"h-3.5 w-3.5"}),X.save_watermark()]})]})]}),Y("div",{className:"flex-1 flex overflow-hidden",children:[Y("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[Y("div",{className:"flex items-center justify-between mb-3",children:[J("div",{className:"flex items-center gap-1 bg-muted/60 p-1 rounded-md border border-border/60",children:["16:9","9:16","4:3","3:4","1:1"].map((Z)=>Y(A,{variant:T===Z?"secondary":"ghost",size:"sm",className:MJ("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",T===Z?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>ZJ(Z),children:[J(eZ,{ratio:Z}),J("span",{children:Z})]},Z))}),J("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:cJ.map((Z)=>J("button",{type:"button",onClick:()=>VJ(Z.id),style:{backgroundColor:Z.bg},className:MJ("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",HJ===Z.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:Z.label},Z.id))})]}),J("div",{ref:H,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let Z=cJ.find((V)=>V.id===HJ)||cJ[0],$=n.w>0&&n.h>0;return J("div",{ref:C,onClick:()=>R(null),style:{backgroundColor:Z.bg,backgroundImage:`radial-gradient(${Z.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...$?{width:n.w,height:n.h}:{}},className:MJ("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",T==="16:9"&&"aspect-[16/9] w-full max-h-full",T==="9:16"&&"aspect-[9/16] h-full max-w-full",T==="4:3"&&"aspect-[4/3] w-full max-h-full",T==="3:4"&&"aspect-[3/4] h-full max-w-full",T==="1:1"&&"aspect-square h-full max-w-full"),children:Q.map((V)=>{let f=V.id===z,O=V.size*(n.w||640);return J("div",{onMouseDown:(g)=>rZ(g,V.id),onClick:(g)=>{g.stopPropagation(),R(V.id)},style:{left:`${V.x*100}%`,top:`${V.y*100}%`,transform:`translate(-50%, -50%) rotate(${V.rotation}deg)`,opacity:V.opacity},className:MJ("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",f?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:V.type==="text"?J("span",{style:{fontSize:`${O}px`,color:V.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:V.text||"Text"}):J("div",{style:{width:`${O}px`,height:`${O}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:d[V.id]||V.imageAssetUrl?J("img",{src:d[V.id]||V.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):J(NJ,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},V.id)})})})()})]}),Y("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[J("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:Y("div",{className:"flex items-center gap-2",children:[J(BJ,{className:"h-4 w-4 text-muted-foreground"}),J("span",{className:"text-xs font-semibold",children:X.watermark()})]})}),Y("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[Y("div",{className:"flex items-center gap-1",children:[J(A,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:Q.length<=1,onClick:lZ,children:J(VZ,{className:"h-4 w-4"})}),Y(wJ,{modal:!1,children:[J(FJ,{asChild:!0,children:J(A,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:Q.length===0?"0 / 0":`${XJ+1} / ${Q.length}`})}),J(TJ,{align:"start",className:"w-48",children:Q.map((Z,$)=>Y(GJ,{onClick:()=>R(Z.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[Y("span",{className:"flex items-center gap-2 truncate",children:[Z.type==="text"?J(OJ,{className:"h-3.5 w-3.5 text-muted-foreground"}):J(NJ,{className:"h-3.5 w-3.5 text-muted-foreground"}),Z.type==="text"?Z.text||"Text":Z.imageAssetKey||"Image"]}),Y("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",$+1]})]},Z.id))})]}),J(A,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:Q.length<=1,onClick:oZ,children:J(fJ,{className:"h-4 w-4"})})]}),Y("div",{className:"flex items-center gap-1",children:[_&&J(A,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:X.delete(),onClick:()=>GZ(_.id),children:J(dJ,{className:"h-4 w-4"})}),Y(wJ,{modal:!1,children:[J(FJ,{asChild:!0,children:Y(A,{size:"sm",className:"h-7 text-xs gap-1",children:[J(DJ,{className:"h-3.5 w-3.5"}),X.add()]})}),Y(TJ,{align:"end",children:[Y(GJ,{onClick:XZ,className:"text-xs gap-2 cursor-pointer",children:[J(OJ,{className:"h-3.5 w-3.5"}),X.add_text_block()]}),Y(GJ,{onClick:dZ,className:"text-xs gap-2 cursor-pointer",children:[J(NJ,{className:"h-3.5 w-3.5"}),X.add_image_block()]})]})]})]})]}),J(AZ,{className:"flex-1 min-h-0 p-4",children:_?Y("div",{className:"space-y-5 text-xs",children:[Y("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[Y("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[_.type==="text"?J(OJ,{className:"h-4 w-4 text-primary"}):J(NJ,{className:"h-4 w-4 text-primary"}),_.type==="text"?X.add_text_block():X.add_image_block()]}),Y("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",_.id.slice(0,6)]})]}),_.type==="text"&&Y("div",{className:"space-y-2",children:[J(P,{className:"text-xs",children:X.text_content()}),J(JJ,{type:"text",value:_.text,onChange:(Z)=>L(_.id,{text:Z.target.value}),className:"text-xs h-8"})]}),_.type==="image"&&Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.image_asset_key()}),_.imageAssetKey&&Y("button",{type:"button",onClick:()=>L(_.id,{imageAssetKey:"",imageAssetUrl:void 0}),className:"text-xs text-muted-foreground hover:text-destructive flex items-center gap-1 font-medium transition-colors cursor-pointer",children:[J($Z,{className:"w-3.5 h-3.5"}),X.remove?X.remove():"Remove"]})]}),J("input",{type:"file",ref:r,className:"hidden",accept:"image/*",onChange:(Z)=>e(Z,_.id)}),Y("div",{onClick:()=>r.current?.click(),className:"relative aspect-square w-full rounded-xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 hover:border-primary/50 hover:bg-muted/40 transition-all p-2",children:[SJ&&J("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:Y("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[J(LJ,{className:"w-4 h-4 animate-spin text-primary"}),J("span",{className:"text-xs font-semibold",children:X.uploading()})]})}),d[_.id]||_.imageAssetUrl?Y(QJ,{children:[J("img",{src:d[_.id]||_.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),Y("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1 text-white z-10",children:[J(lJ,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),J("span",{className:"text-xs font-semibold",children:X.upload_image()})]})]}):Y("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[J("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:J(lJ,{className:"w-4 h-4 text-muted-foreground"})}),Y("div",{children:[J("p",{className:"text-xs font-medium text-foreground",children:X.upload_watermark_image()}),J("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:X.upload_watermark_image_hint()})]})]})]})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:_.type==="text"?X.font_size():X.image_size()}),Y("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(_.size*100),"%"]})]}),Y("div",{className:"flex items-center gap-3",children:[J($J,{min:_.type==="text"?0.01:0.02,max:_.type==="text"?0.12:0.5,step:0.005,value:[_.size],onValueChange:([Z])=>L(_.id,{size:Z}),className:"flex-1"}),J(JJ,{type:"number",min:1,max:100,value:Math.round(_.size*100),onChange:(Z)=>L(_.id,{size:Math.min(1,Math.max(0.001,Number(Z.target.value)/100))}),className:"w-16 h-7 text-xs font-mono text-right"})]})]}),_.type==="text"&&Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.color()}),J("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:_.color})]}),Y("div",{className:"flex items-center gap-2",children:[J("input",{type:"color",value:_.color,onChange:(Z)=>L(_.id,{color:Z.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),J(JJ,{type:"text",value:_.color,onChange:(Z)=>L(_.id,{color:Z.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),J("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((Z)=>J("button",{type:"button",onClick:()=>L(_.id,{color:Z}),style:{backgroundColor:Z},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},Z))})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.opacity()}),Y("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(_.opacity*100),"%"]})]}),J($J,{min:0,max:1,step:0.01,value:[_.opacity],onValueChange:([Z])=>L(_.id,{opacity:Z})})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.rotation()}),Y("span",{className:"font-mono text-[11px] text-muted-foreground",children:[_.rotation,"°"]})]}),J($J,{min:-180,max:180,step:1,value:[_.rotation],onValueChange:([Z])=>L(_.id,{rotation:Z})}),J("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((Z)=>Y(A,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>L(_.id,{rotation:Z}),children:[Z,"°"]},Z))})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.position_x()}),Y("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(_.x*100),"%"]})]}),J($J,{min:0,max:1,step:0.01,value:[_.x],onValueChange:([Z])=>L(_.id,{x:Z})})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.position_y()}),Y("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(_.y*100),"%"]})]}),J($J,{min:0,max:1,step:0.01,value:[_.y],onValueChange:([Z])=>L(_.id,{y:Z})})]})]}):Y("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[J("p",{children:X.select_block_to_edit()}),Y(A,{size:"sm",variant:"outline",onClick:XZ,children:[J(DJ,{className:"h-3.5 w-3.5 mr-1"}),X.add_text_block()]})]})})]})]})]})}),J(oJ,{open:WJ,onOpenChange:j,children:Y(rJ,{className:"max-w-md",children:[J(WZ,{children:J(aJ,{className:"text-sm font-semibold",children:YJ==="new"?X.create_new_template():X.overwrite_existing_template()})}),J("div",{className:"py-3 space-y-4 text-xs",children:YJ==="new"?Y("div",{className:"space-y-2",children:[J(P,{children:X.template_name()}),J(JJ,{type:"text",value:s,onChange:(Z)=>x(Z.target.value),placeholder:X.enter_template_name(),className:"text-xs"})]}):Y("div",{className:"space-y-2",children:[J(P,{children:X.select_template_to_overwrite()}),J("select",{value:m||"",onChange:(Z)=>i(Z.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:l.map((Z)=>J("option",{value:Z.id,children:Z.name},Z.id))})]})}),Y(qZ,{children:[J(A,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>j(!1),children:X.cancel()}),J(A,{size:"sm",className:"text-xs",disabled:PJ||q,onClick:sZ,children:X.confirm()})]})]})})]})}function MJ(...G){return G.filter(Boolean).join(" ")}var t=CJ(vJ(),1);function LZ({shareLink:G,viewMode:w,onViewModeChange:y,defaultSortOrder:E,onSortOrderChange:F}){let M=zJ(),[B,Q]=t.useState(G.password||""),[D,z]=t.useState(G.expireAt?new Date(G.expireAt):void 0),[R,b]=t.useState(!1);t.default.useEffect(()=>{Q(G.password||"")},[G.password]);let[h,T]=t.useState(G.hasPassword),[ZJ,HJ]=t.useState(!!G.expireAt),{data:VJ,refetch:WJ}=a({queryKey:["share-watermark",G.id],queryFn:async()=>{let H=await U.api.shares[":shareId"].watermark.$get({param:{shareId:G.id}});if(!H.ok)return null;return await H.json()},refetchInterval:(H)=>{return(H.state.data?.watermarkStatus||G.watermarkStatus)==="processing"?3000:!1}}),j=U.api.shares[":shareId"].watermark.$put,{mutate:YJ}=u({mutationFn:async()=>{let H=await j({param:{shareId:G.id},json:{enabled:!1}});if(!H.ok)throw Error(X.failed_update());return await H.json()},onSuccess:()=>{M.invalidateQueries({queryKey:["shares",G.projectId]}),M.invalidateQueries({queryKey:["share",G.id]}),M.invalidateQueries({queryKey:["share-watermark",G.id]}),N.success(X.watermark_disabled_msg())}}),o=VJ?.watermarkStatus??G.watermarkStatus??(G.watermarkConfigId?"ready":"disabled"),s=VJ?.watermarkConfig?.config??G.watermarkConfig?.config??null,x=s!==null&&o!=="disabled",{data:m}=a({queryKey:["fields",G.projectId],queryFn:async()=>{let H=await U.api.projects[":projectId"].fields.$get({param:{projectId:G.projectId}});if(!H.ok)throw Error(X.failed_fetch_fields());return await H.json()},enabled:!!G.projectId}),i=U.api.shares[":shareId"].$put,{mutate:C}=u({mutationFn:async(H)=>{let k=await i({param:{shareId:G.id},json:H});if(!k.ok)throw Error(X.failed_update());return await k.json()},onSuccess:()=>{M.invalidateQueries({queryKey:["shares",G.projectId]}),M.invalidateQueries({queryKey:["share",G.id]}),N.success(X.settings_updated())}}),c=`${window.location.origin}/share/${G.id}`,n=async(H)=>{if(await vZ(H))N.success(X.copied_to_clipboard())},qJ=(H)=>{let k=G.fieldVisibility||{},_J={...k,[H]:!k[H]};C({fieldVisibility:_J})},v="index",I="asc";if(E){let H=E.split(":");v=H[0],I=H[1]||"asc"}return Y("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[J("div",{className:"flex-1 overflow-y-auto",children:Y("div",{className:"p-4 space-y-6",children:[Y("div",{className:"space-y-4",children:[Y("div",{className:"flex items-center justify-between",children:[J("h3",{className:"text-sm font-medium",children:X.link_visibility()}),J(KJ,{checked:!G.isDisabled,onCheckedChange:(H)=>C({isDisabled:!H})})]}),Y("div",{className:"relative w-full",children:[J(JJ,{value:c,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),J(A,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>n(c),children:J(sJ,{className:"h-4 w-4"})})]})]}),Y("div",{className:"space-y-1",children:[J(gJ,{title:X.security(),icon:J(DZ,{className:"h-4 w-4"}),children:Y("div",{className:"p-3 space-y-4 pt-2",children:[Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.password()}),J(KJ,{checked:h,onCheckedChange:(H)=>{if(T(H),!H)C({password:null})}})]}),h&&Y("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[J(JJ,{type:"text",value:B,onChange:(H)=>Q(H.target.value),placeholder:X.enter_password(),className:"text-xs"}),J(A,{size:"sm",onClick:()=>C({password:B}),children:X.save()})]})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.expiration_date()}),J(KJ,{checked:ZJ,onCheckedChange:(H)=>{if(HJ(H),!H)z(void 0),C({expireAt:null})}})]}),ZJ&&J("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:J(CZ,{value:D,onChange:(H)=>{z(H),C({expireAt:H?H.toISOString():null})},className:"text-xs"})})]}),Y("div",{className:"space-y-2",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.allow_download()}),J(KJ,{checked:G.allowDownload,onCheckedChange:(H)=>C({allowDownload:H})})]}),J("p",{className:"text-xs text-muted-foreground",children:X.allow_download_description()})]}),Y("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:X.watermark()}),J(KJ,{checked:x,disabled:o==="processing",onCheckedChange:(H)=>{if(!H)YJ();else b(!0)}})]}),x&&o==="processing"&&Y("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[J(LJ,{className:"h-3.5 w-3.5 animate-spin"}),J("span",{children:X.watermark_transcoding_processing()})]}),x&&o!=="processing"&&J(A,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>b(!0),children:X.edit_watermark()})]})]})}),J(gJ,{title:X.appearance(),icon:J(MZ,{className:"h-4 w-4"}),children:Y("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[Y(A,{variant:w==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>y("card"),children:[J(BJ,{className:"h-4 w-4"}),X.grid()]}),Y(A,{variant:w==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>y("list"),children:[J(yZ,{className:"h-4 w-4"}),X.list()]})]})}),J(gJ,{title:X.fields(),icon:J(PZ,{className:"h-4 w-4"}),children:J("div",{className:"p-3 space-y-3 pt-2",children:m?.map((H)=>Y("div",{className:"flex items-center justify-between",children:[J(P,{className:"text-xs",children:H.config?.name}),J(KJ,{checked:G.fieldVisibility?.[H.id]??!1,onCheckedChange:()=>qJ(H.id)})]},H.id))})}),J(gJ,{title:X.sort_by(),icon:J(EZ,{className:"h-4 w-4"}),children:Y("div",{className:"p-3 space-y-4 pt-2",children:[Y("div",{className:"space-y-2",children:[J(P,{className:"text-xs text-muted-foreground",children:X.field()}),Y(OZ,{value:v,onValueChange:(H)=>{if(H==="index")F(null);else F(`${H}:${I}`)},children:[J(FZ,{className:"w-full text-xs h-9",children:J(wZ,{})}),Y(TZ,{children:[J(EJ,{value:"index",children:X.sort_custom()}),J(EJ,{value:"name",children:X.sort_name()}),J(EJ,{value:"createdAt",children:X.sort_date_created()}),J(EJ,{value:"size",children:X.sort_size()})]})]})]}),Y("div",{className:"space-y-2",children:[J(P,{className:"text-xs text-muted-foreground",children:X.order()}),Y(A,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:v==="index",onClick:()=>{F(`${v}:${I==="asc"?"desc":"asc"}`)},children:[J("span",{children:v==="name"?I==="asc"?X.sort_a_to_z():X.sort_z_to_a():v==="createdAt"?I==="asc"?X.sort_oldest_to_newest():X.sort_newest_to_oldest():v==="size"?I==="asc"?X.sort_smallest_to_largest():X.sort_largest_to_smallest():I==="asc"?X.ascending():X.descending()}),J(UZ,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),Y("div",{className:"p-4 border-t border-border space-y-2",children:[Y(A,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(c,"_blank"),children:[J(RZ,{className:"h-4 w-4 mr-2"}),X.open_share_link()]}),Y(A,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>n(c),children:[J(sJ,{className:"h-4 w-4 mr-2"}),X.copy_link()]})]}),J(NZ,{open:R,onOpenChange:b,initialConfig:s,shareId:G.id,onSaveSuccess:()=>{WJ(),M.invalidateQueries({queryKey:["share",G.id]}),M.invalidateQueries({queryKey:["shares",G.projectId]})}})]})}function gJ({title:G,icon:w,children:y}){let[E,F]=t.useState(!1);return Y("div",{className:"border-b border-border last:border-0",children:[Y("button",{onClick:()=>F(!E),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[Y("div",{className:"flex items-center gap-3",children:[w,J("span",{className:"text-sm font-medium",children:G})]}),J(fJ,{className:Y0("h-4 w-4 transition-transform",E&&"rotate-90")})]}),E&&y&&J("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:y})]})}function Y0(...G){return G.filter(Boolean).join(" ")}function YZ({teamId:G,projectId:w,projectName:y,shareId:E,rootFolderId:F}){let M=zJ(),{fetchMetadata:B}=IZ();S.useEffect(()=>{if(G)B(G)},[G,B]);let{data:Q}=a({queryKey:["share",E],queryFn:async()=>{let K=await U.api.shares[":shareId"].$get({param:{shareId:E}});if(!K.ok)throw Error(X.failed_fetch_share_link());return await K.json()}}),D=Q?.rootFolderId,[z,R]=S.useState(null),[b,h]=S.useState([]);S.useEffect(()=>{if(D)R(D),h([]),e(new Set)},[D,E]);let T=JZ((K)=>K.setProjectState),ZJ=JZ((K)=>K.clearProjectState),HJ=(K)=>{if(K===z)return;if(K===D)R(D),h([]);else{let q=b.findIndex((p)=>p.id===K);if(q!==-1)R(K),h(b.slice(q+1))}e(new Set)},[VJ,WJ]=S.useState(240),[j,YJ]=S.useState(360),{shareConfigLeftSidebarCollapsed:o,shareConfigRightSidebarCollapsed:s}=hZ(),x=Q?.defaultSortOrder||null,m,i;if(x){let K=x.split(":");m=K[0],i=K[1]}let C=Q?.viewMode??"card",{data:c,fetchNextPage:n,hasNextPage:qJ,isFetchingNextPage:v,isLoading:I}=eJ({queryKey:["folder-children",G,z,"folder",m,i],queryFn:async({pageParam:K})=>{let q=await U.api.folders[":folderId"].children.$get({param:{folderId:z},query:{assetType:"folder",after:K,sort:m,order:i}});if(!q.ok)throw Error(X.failed_fetch_folders());return await q.json()},enabled:!!z,initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0}),{data:H,fetchNextPage:k,hasNextPage:_J,isFetchingNextPage:SJ,isLoading:UJ}=eJ({queryKey:["folder-children",G,z,"file",m,i],queryFn:async({pageParam:K})=>{let q=await U.api.folders[":folderId"].children.$get({param:{folderId:z},query:{assetType:"file",after:K,sort:m,order:i}});if(!q.ok)throw Error(X.failed_fetch_files());return await q.json()},enabled:!!z,initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0}),d=S.useMemo(()=>c?.pages.flatMap((K)=>K.data??[])??[],[c]),RJ=S.useMemo(()=>H?.pages.flatMap((K)=>K.data??[])??[],[H]);S.useEffect(()=>{if(Q)T({teamId:G,projectId:w,projectName:y,ancestorFolders:b,currentAsset:{name:z===D?Q.name:d.find((K)=>K.id===z)?.name||Q.name,type:"folder"},isRootFolder:!1,shareId:E,onFolderClick:HJ});return()=>ZJ()},[G,w,y,b,z,D,Q,E,d,T,ZJ]);let r=()=>{e(new Set)},[AJ,e]=S.useState(new Set),{dragState:l,handleDragStart:hJ,handleDragEnd:IJ}=uZ({teamId:G,projectId:w,assetId:z||"",folders:d,files:RJ,selectedIds:AJ,onClearSelection:r}),pJ=U.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:kJ}=u({mutationFn:async(K)=>{if(!(await pJ({param:{shareId:E,assetId:K}})).ok)throw Error(X.failed_remove())},onSuccess:()=>{M.invalidateQueries({queryKey:["folder-children",G,z]}),N.success(X.removed_from_share())}}),uJ=U.api.shares[":shareId"].$put,{mutate:PJ}=u({mutationFn:async(K)=>{let q=await uJ({param:{shareId:E},json:K});if(!q.ok)throw Error(X.failed_update());return await q.json()},onSuccess:()=>{M.invalidateQueries({queryKey:["share",E]}),N.success(X.settings_updated())}}),jJ=(K)=>{if(K.type==="folder"||K.targetType==="folder"){let q=z===D?Q?.name||"":d.find((p)=>p.id===z)?.name||X.unknown();h((p)=>[{id:z,name:q},...p]),R(K.id),e(new Set)}};if(!Q)return J("div",{children:X.loading()});return Y(bZ,{modifiers:[kZ.configure({anchor:{x:0,y:0}})],sensors:[BZ.configure({activationConstraints:[new fZ.Distance({value:10})]})],onDragStart:hJ,onDragEnd:IJ,children:[J("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:Y("div",{className:"flex flex-1 overflow-hidden relative",children:[!o&&Y(QJ,{children:[J("div",{className:"bg-background",style:{width:VJ},children:J(SZ,{teamId:G,projectId:w,projectName:y,rootFolderId:F,dragState:l})}),J(ZZ,{onResize:(K)=>WJ((q)=>Math.max(180,Math.min(400,q+K)))})]}),J(pZ,{teamId:G,projectId:w,assetId:z||"",folders:d,files:RJ,selectedItem:null,selectedIds:AJ,onItemSelect:(K,q)=>{if(q.metaKey||q.ctrlKey){let p=new Set(AJ);if(p.has(K.id))p.delete(K.id);else p.add(K.id);e(p)}else e(new Set([K.id]))},onItemDoubleClick:jJ,onSaveField:()=>{},displayStyle:C,onClearSelection:r,fetchNextFoldersPage:n,hasNextFoldersPage:qJ,isFetchingNextFoldersPage:v,fetchNextFilesPage:k,hasNextFilesPage:_J,isFetchingNextFilesPage:SJ,isLoading:I||UJ,filterConditions:[],onFilterChange:()=>{},dragState:l,isShareView:!0,onRemoveFromShare:(K)=>{K.forEach((q)=>kJ(q.id))},fieldVisibility:Q.fieldVisibility}),!s&&Y(QJ,{children:[J(ZZ,{onResize:(K)=>YJ((q)=>Math.max(240,Math.min(600,q-K)))}),J("div",{style:{width:j},className:"flex-shrink-0 h-full",children:J(LZ,{shareLink:Q,viewMode:C,onViewModeChange:(K)=>PJ({viewMode:K}),defaultSortOrder:x,onSortOrderChange:(K)=>PJ({defaultSortOrder:K})})})]})]})}),J(gZ,{children:l?.isActive?J("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:X.moving_items({count:l.itemCount})}):null})]})}var cZ=CJ(vJ(),1);function X0(){let{projectId:G,shareId:w}=G0.useParams(),{teamId:y,ensureTeamIdForProject:E}=bJ();cZ.useEffect(()=>{E(G)},[G,E]);let{data:F}=jZ(iZ(G)),M=F?.rootFolder,{data:B}=a({queryKey:["folders",M],queryFn:async()=>{let Q=await U.api.folders[":folderId"].$get({param:{folderId:M}});if(!Q.ok)throw Error("Failed to fetch folder");return await Q.json()},enabled:!!M});if(!y||!M||!B)return J(mZ,{});return J(YZ,{teamId:y,projectId:G,projectName:F.name??"",shareId:w,rootFolderId:M})}var G0=xZ("/projects/$projectId/shares/$shareId")({component:X0});export{G0 as Route};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{gn as w,hn as T}from"./chunk-kvnfgr29.js";function S(B,Q){return{role:"assistant",content:[],api:B.api,provider:B.provider,model:B.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function f(B){return typeof B.result==="function"}async function L(B,Q){for await(let Y of Q)B.push(Y);B.end(f(Q)?await Q.result():void 0)}function H(B,Q){let Y=new w;return Q().then((Z)=>L(Y,Z)).catch((Z)=>{let $=S(B,Z);Y.push({type:"error",reason:"error",error:$}),Y.end($)}),Y}function g(B){return{stream:(Q,Y,Z)=>H(Q,async()=>(await B()).stream(Q,Y,Z)),streamSimple:(Q,Y,Z)=>H(Q,async()=>(await B()).streamSimple(Q,Y,Z))}}var b=function(B,Q){if(typeof B==="string"&&/^\.\.?\//.test(B))return B.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(Y,Z,$,F,J){return Z?Q?".jsx":".js":$&&(!F||!J)?Y:$+F+"."+J.toLowerCase()+"js"});return B},A=(B)=>import(b(B));function N(){return globalThis.process?.env}function C(){return{async env(B){let Q=N()?.[B];return typeof Q==="string"&&Q.trim().length>0?Q:void 0},async fileExists(B){try{let Q=await A("node:fs/promises"),Y=B;if(Y.startsWith("~"))Y=(await A("node:os")).homedir()+Y.slice(1);return await Q.access(Y),!0}catch{return!1}}}}class D{credentials=new Map;chains=new Map;enqueue(B,Q){let Y=this.chains.get(B)??Promise.resolve(),Z=(async()=>{return await Y.catch(()=>{}),Q()})();return this.chains.set(B,Z.catch(()=>{})),Z}async read(B){return this.credentials.get(B)}async list(){return[...this.credentials].map(([B,Q])=>({providerId:B,type:Q.type}))}modify(B,Q){return this.enqueue(B,async()=>{let Y=this.credentials.get(B),Z=await Q(Y);if(Z!==void 0)this.credentials.set(B,Z);return Z??Y})}delete(B){return this.enqueue(B,async()=>{this.credentials.delete(B)})}}class G extends Error{code;constructor(B,Q,Y){super(y(Q,Y?.cause),Y);this.name="ModelsError",this.code=B}}function y(B,Q){if(Q===void 0||Q===null)return B;let Y=T(Q).trim();if(!Y||B.includes(Y))return B;return`${B}: ${Y}`}async function _(B,Q,Y,Z){let $=Z?.env?E(Y,Z.env):Y;if(Z?.apiKey!==void 0&&B.auth.apiKey)return q($,B.auth.apiKey,B.id,{type:"api_key",key:Z.apiKey,env:Z.env});let F=await x(Q,B.id);if(F){if(F.type==="oauth"&&B.auth.oauth)return M(Q,B.id,B.auth.oauth,F);if(F.type==="api_key"&&B.auth.apiKey){let J=Z?.env?{...F,env:{...F.env,...Z.env}}:F;return q($,B.auth.apiKey,B.id,J)}return}return B.auth.apiKey?q($,B.auth.apiKey,B.id,void 0):void 0}function E(B,Q){return{env:async(Y)=>Q[Y]||await B.env(Y),fileExists:(Y)=>B.fileExists(Y)}}async function M(B,Q,Y,Z){let $=Z;if(Date.now()>=$.expires){let F;try{F=await B.modify(Q,async(J)=>{if(J?.type!=="oauth")return;if(Date.now()<J.expires)return;try{return await Y.refresh(J)}catch(W){throw new G("oauth",`OAuth refresh failed for ${Q}`,{cause:W})}})}catch(J){if(J instanceof G)throw J;throw new G("auth",`Credential store modify failed for ${Q}`,{cause:J})}if(F?.type!=="oauth")return;$=F}try{return{auth:await Y.toAuth($),source:"OAuth"}}catch(F){throw new G("oauth",`OAuth auth derivation failed for ${Q}`,{cause:F})}}async function q(B,Q,Y,Z){try{return await Q.resolve({ctx:B,credential:Z})}catch($){throw new G("auth",`API key auth failed for provider ${Y}`,{cause:$})}}async function x(B,Q){try{return await B.read(Q)}catch(Y){throw new G("auth",`Credential store read failed for ${Q}`,{cause:Y})}}class j{entries=new Map;async read(B){let Q=this.entries.get(B);return Q?structuredClone(Q):void 0}async write(B,Q){this.entries.set(B,structuredClone(Q))}async delete(B){this.entries.delete(B)}}function K(B,Q){if(!B&&!Q)return;let Y={...B};for(let[Z,$]of Object.entries(Q??{})){let F=Z.toLowerCase();for(let J of Object.keys(Y))if(J.toLowerCase()===F)delete Y[J];Y[Z]=$}return Y}class O{providers=new Map;credentials;modelsStore;authContext;constructor(B){this.credentials=B?.credentials??new D,this.modelsStore=B?.modelsStore??new j,this.authContext=B?.authContext??C()}setProvider(B){this.providers.set(B.id,B)}deleteProvider(B){this.providers.delete(B)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(B){return this.providers.get(B)}getModels(B){if(B!==void 0){let Y=this.providers.get(B);if(!Y)return[];try{return Y.getModels()}catch{return[]}}let Q=[];for(let Y of this.providers.values())try{Q.push(...Y.getModels())}catch{}return Q}getModel(B,Q){return this.getModels(B).find((Y)=>Y.id===Q)}async refresh(B={}){let Q=B.allowNetwork??!0,Y=new Map,Z=Array.from(this.providers.values()).filter(($)=>$.refreshModels!==void 0);return await Promise.all(Z.map(async($)=>{if(B.signal?.aborted)return;let F={read:()=>this.modelsStore.read($.id),write:(W)=>this.modelsStore.write($.id,W),delete:()=>this.modelsStore.delete($.id)},J;try{J=await this.readCredential($.id);let W=await this.resolveRefreshCredential($,J,Q,B.signal);if(!W)return;await $.refreshModels({credential:W,store:F,allowNetwork:Q,force:B.force,signal:B.signal})}catch(W){if(!B.signal?.aborted)Y.set($.id,W instanceof Error?W:new G("model_source",`Model refresh failed for ${$.id}`,{cause:W}));try{await $.refreshModels({credential:J,store:F,allowNetwork:!1,signal:B.signal})}catch{}}})),{aborted:B.signal?.aborted??!1,errors:Y}}async resolveRefreshCredential(B,Q,Y,Z){if(Q?.type==="oauth"){let W=B.auth.oauth;if(!W)return;if(!Y||Date.now()<Q.expires)return Q;if(Z?.aborted)return;let k=await this.credentials.modify(B.id,async(z)=>{if(z?.type!=="oauth"||Date.now()<z.expires)return;return W.refresh(z,Z)});return k?.type==="oauth"?k:void 0}let $=B.auth.apiKey;if(!$)return;let F=Q?.type==="api_key"?Q:void 0,J=await $.resolve({ctx:this.authContext,credential:F});if(!J)return;return{type:"api_key",key:J.auth.apiKey,env:J.env}}async readCredential(B){try{return await this.credentials.read(B)}catch(Q){throw new G("auth",`Credential store read failed for ${B}`,{cause:Q})}}async checkProviderAuth(B,Q){if(Q?.type==="oauth")return B.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;let Y=B.auth.apiKey;if(!Y)return;if(Y.check)try{return await Y.check({ctx:this.authContext,credential:Q?.type==="api_key"?Q:void 0})}catch($){throw new G("auth",`API key auth check failed for provider ${B.id}`,{cause:$})}let Z=await _(B,this.credentials,this.authContext);return Z?{source:Z.source,type:"api_key"}:void 0}async checkAuth(B){let Q=this.providers.get(B);if(!Q)return;return this.checkProviderAuth(Q,await this.readCredential(B))}async getAvailable(B){let Q=B?[this.providers.get(B)].filter((Z)=>Z!==void 0):this.getProviders();return(await Promise.all(Q.map(async(Z)=>{let $=await this.readCredential(Z.id);return{provider:Z,credential:$,auth:await this.checkProviderAuth(Z,$)}}))).flatMap(({provider:Z,credential:$,auth:F})=>{if(!F)return[];let J=Z.getModels();return Z.filterModels?.(J,$)??J})}async getAuth(B,Q){let Y=typeof B==="string"?B:B.provider,Z=this.providers.get(Y);if(!Z)return;let $=await _(Z,this.credentials,this.authContext,Q);if(!$||typeof B==="string"||!B.headers)return $;return{...$,auth:{...$.auth,headers:K($.auth.headers,B.headers)}}}async login(B,Q,Y){let Z=this.providers.get(B);if(!Z)throw new G("provider",`Unknown provider: ${B}`);let $=Q==="oauth"?Z.auth.oauth:Z.auth.apiKey;if(!$?.login)throw new G("auth",`${Z.name} does not support ${Q} login`);let F=await $.login(Y);try{await this.credentials.modify(B,async()=>F)}catch(J){throw new G("auth",`Credential store modify failed for ${B}`,{cause:J})}return F}async logout(B){try{await this.credentials.delete(B)}catch(Q){throw new G("auth",`Credential store delete failed for ${B}`,{cause:Q})}}requireProvider(B){let Q=this.providers.get(B.provider);if(!Q)throw new G("provider",`Unknown provider: ${B.provider}`);return Q}async applyAuth(B,Q){this.requireProvider(B);let Y=await this.getAuth(B,{apiKey:Q?.apiKey,env:Q?.env});if(!Y)throw new G("auth",`Provider is not configured: ${B.provider}`);let Z=Y.auth,$=Q?.apiKey??Z.apiKey,F=K(Z.headers,Q?.headers);if(Q?.transformHeaders)F=await Q.transformHeaders(F??{});let J=Y.env||Q?.env?{...Y.env??{},...Q?.env??{}}:void 0,W=Z.baseUrl?{...B,baseUrl:Z.baseUrl}:B,{transformHeaders:k,...z}=Q??{},P={...z,apiKey:$,headers:F,env:J};return{requestModel:W,requestOptions:P}}stream(B,Q,Y){return H(B,async()=>{let Z=this.requireProvider(B),{requestModel:$,requestOptions:F}=await this.applyAuth(B,Y);return Z.stream($,Q,F)})}async complete(B,Q,Y){return this.stream(B,Q,Y).result()}streamSimple(B,Q,Y){return H(B,async()=>{let Z=this.requireProvider(B),{requestModel:$,requestOptions:F}=await this.applyAuth(B,Y);return Z.streamSimple($,Q,F)})}async completeSimple(B,Q,Y){return this.streamSimple(B,Q,Y).result()}}function d(B){return new O(B)}function o(B){let Q=B.models,Y=[],Z,$=B.fetchModels,F=()=>{let P=[...Q];for(let U of Y){let X=P.findIndex((V)=>V.id===U.id);if(X>=0)P[X]=U;else P.push(U)}return P},J=typeof B.api.stream==="function"?B.api:void 0,W=J?void 0:B.api,k=(P)=>J??W?.[P.api],z=(P,U)=>{let X=k(P);if(!X)return H(P,async()=>{throw new G("stream",`Provider ${B.id} has no API implementation for "${P.api}"`)});return U(X)};return{id:B.id,name:B.name??B.id,baseUrl:B.baseUrl,headers:B.headers,auth:B.auth,getModels:F,refreshModels:$?(P)=>{return Z??=(async()=>{try{let U=await P.store.read();if(U)Y=U.models.filter((V)=>V.provider===B.id).map((V)=>V);if(!P.allowNetwork||P.signal?.aborted)return;let X=await $(P);if(P.signal?.aborted)return;Y=X,await P.store.write({models:X,checkedAt:Date.now()})}finally{Z=void 0}})(),Z}:void 0,filterModels:B.filterModels,stream:(P,U,X)=>z(P,(V)=>V.stream(P,U,X)),streamSimple:(P,U,X)=>z(P,(V)=>V.streamSimple(P,U,X))}}function r(B,Q){let Y=Q.input+Q.cacheRead+Q.cacheWrite,Z=B.cost,$=-1;for(let W of B.cost.tiers??[])if(Y>W.inputTokensAbove&&W.inputTokensAbove>$)Z=W,$=W.inputTokensAbove;let F=Q.cacheWrite1h??0,J=Q.cacheWrite-F;return Q.cost.input=Z.input/1e6*Q.input,Q.cost.output=Z.output/1e6*Q.output,Q.cost.cacheRead=Z.cacheRead/1e6*Q.cacheRead,Q.cost.cacheWrite=(Z.cacheWrite*J+Z.input*2*F)/1e6,Q.cost.total=Q.cost.input+Q.cost.output+Q.cost.cacheRead+Q.cost.cacheWrite,Q.cost}var R=["off","minimal","low","medium","high","xhigh","max"];function h(B){if(!B.reasoning)return["off"];return R.filter((Q)=>{let Y=B.thinkingLevelMap?.[Q];if(Y===null)return!1;if(Q==="xhigh"||Q==="max")return Y!==void 0;return!0})}function e(B,Q){let Y=h(B);if(Y.includes(Q))return Q;let Z=R.indexOf(Q);if(Z===-1)return Y[0]??"off";for(let $=Z;$<R.length;$++){let F=R[$];if(Y.includes(F))return F}for(let $=Z-1;$>=0;$--){let F=R[$];if(Y.includes(F))return F}return Y[0]??"off"}
3
- export{g as an,D as bn,d as cn,o as dn,r as en,e as fn};
2
+ import{nn as w,on as T}from"./chunk-q46rc697.js";function S(B,Q){return{role:"assistant",content:[],api:B.api,provider:B.provider,model:B.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function f(B){return typeof B.result==="function"}async function L(B,Q){for await(let Y of Q)B.push(Y);B.end(f(Q)?await Q.result():void 0)}function H(B,Q){let Y=new w;return Q().then((Z)=>L(Y,Z)).catch((Z)=>{let $=S(B,Z);Y.push({type:"error",reason:"error",error:$}),Y.end($)}),Y}function g(B){return{stream:(Q,Y,Z)=>H(Q,async()=>(await B()).stream(Q,Y,Z)),streamSimple:(Q,Y,Z)=>H(Q,async()=>(await B()).streamSimple(Q,Y,Z))}}var b=function(B,Q){if(typeof B==="string"&&/^\.\.?\//.test(B))return B.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(Y,Z,$,F,J){return Z?Q?".jsx":".js":$&&(!F||!J)?Y:$+F+"."+J.toLowerCase()+"js"});return B},A=(B)=>import(b(B));function N(){return globalThis.process?.env}function C(){return{async env(B){let Q=N()?.[B];return typeof Q==="string"&&Q.trim().length>0?Q:void 0},async fileExists(B){try{let Q=await A("node:fs/promises"),Y=B;if(Y.startsWith("~"))Y=(await A("node:os")).homedir()+Y.slice(1);return await Q.access(Y),!0}catch{return!1}}}}class D{credentials=new Map;chains=new Map;enqueue(B,Q){let Y=this.chains.get(B)??Promise.resolve(),Z=(async()=>{return await Y.catch(()=>{}),Q()})();return this.chains.set(B,Z.catch(()=>{})),Z}async read(B){return this.credentials.get(B)}async list(){return[...this.credentials].map(([B,Q])=>({providerId:B,type:Q.type}))}modify(B,Q){return this.enqueue(B,async()=>{let Y=this.credentials.get(B),Z=await Q(Y);if(Z!==void 0)this.credentials.set(B,Z);return Z??Y})}delete(B){return this.enqueue(B,async()=>{this.credentials.delete(B)})}}class G extends Error{code;constructor(B,Q,Y){super(y(Q,Y?.cause),Y);this.name="ModelsError",this.code=B}}function y(B,Q){if(Q===void 0||Q===null)return B;let Y=T(Q).trim();if(!Y||B.includes(Y))return B;return`${B}: ${Y}`}async function _(B,Q,Y,Z){let $=Z?.env?E(Y,Z.env):Y;if(Z?.apiKey!==void 0&&B.auth.apiKey)return q($,B.auth.apiKey,B.id,{type:"api_key",key:Z.apiKey,env:Z.env});let F=await x(Q,B.id);if(F){if(F.type==="oauth"&&B.auth.oauth)return M(Q,B.id,B.auth.oauth,F);if(F.type==="api_key"&&B.auth.apiKey){let J=Z?.env?{...F,env:{...F.env,...Z.env}}:F;return q($,B.auth.apiKey,B.id,J)}return}return B.auth.apiKey?q($,B.auth.apiKey,B.id,void 0):void 0}function E(B,Q){return{env:async(Y)=>Q[Y]||await B.env(Y),fileExists:(Y)=>B.fileExists(Y)}}async function M(B,Q,Y,Z){let $=Z;if(Date.now()>=$.expires){let F;try{F=await B.modify(Q,async(J)=>{if(J?.type!=="oauth")return;if(Date.now()<J.expires)return;try{return await Y.refresh(J)}catch(W){throw new G("oauth",`OAuth refresh failed for ${Q}`,{cause:W})}})}catch(J){if(J instanceof G)throw J;throw new G("auth",`Credential store modify failed for ${Q}`,{cause:J})}if(F?.type!=="oauth")return;$=F}try{return{auth:await Y.toAuth($),source:"OAuth"}}catch(F){throw new G("oauth",`OAuth auth derivation failed for ${Q}`,{cause:F})}}async function q(B,Q,Y,Z){try{return await Q.resolve({ctx:B,credential:Z})}catch($){throw new G("auth",`API key auth failed for provider ${Y}`,{cause:$})}}async function x(B,Q){try{return await B.read(Q)}catch(Y){throw new G("auth",`Credential store read failed for ${Q}`,{cause:Y})}}class j{entries=new Map;async read(B){let Q=this.entries.get(B);return Q?structuredClone(Q):void 0}async write(B,Q){this.entries.set(B,structuredClone(Q))}async delete(B){this.entries.delete(B)}}function K(B,Q){if(!B&&!Q)return;let Y={...B};for(let[Z,$]of Object.entries(Q??{})){let F=Z.toLowerCase();for(let J of Object.keys(Y))if(J.toLowerCase()===F)delete Y[J];Y[Z]=$}return Y}class O{providers=new Map;credentials;modelsStore;authContext;constructor(B){this.credentials=B?.credentials??new D,this.modelsStore=B?.modelsStore??new j,this.authContext=B?.authContext??C()}setProvider(B){this.providers.set(B.id,B)}deleteProvider(B){this.providers.delete(B)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(B){return this.providers.get(B)}getModels(B){if(B!==void 0){let Y=this.providers.get(B);if(!Y)return[];try{return Y.getModels()}catch{return[]}}let Q=[];for(let Y of this.providers.values())try{Q.push(...Y.getModels())}catch{}return Q}getModel(B,Q){return this.getModels(B).find((Y)=>Y.id===Q)}async refresh(B={}){let Q=B.allowNetwork??!0,Y=new Map,Z=Array.from(this.providers.values()).filter(($)=>$.refreshModels!==void 0);return await Promise.all(Z.map(async($)=>{if(B.signal?.aborted)return;let F={read:()=>this.modelsStore.read($.id),write:(W)=>this.modelsStore.write($.id,W),delete:()=>this.modelsStore.delete($.id)},J;try{J=await this.readCredential($.id);let W=await this.resolveRefreshCredential($,J,Q,B.signal);if(!W)return;await $.refreshModels({credential:W,store:F,allowNetwork:Q,force:B.force,signal:B.signal})}catch(W){if(!B.signal?.aborted)Y.set($.id,W instanceof Error?W:new G("model_source",`Model refresh failed for ${$.id}`,{cause:W}));try{await $.refreshModels({credential:J,store:F,allowNetwork:!1,signal:B.signal})}catch{}}})),{aborted:B.signal?.aborted??!1,errors:Y}}async resolveRefreshCredential(B,Q,Y,Z){if(Q?.type==="oauth"){let W=B.auth.oauth;if(!W)return;if(!Y||Date.now()<Q.expires)return Q;if(Z?.aborted)return;let k=await this.credentials.modify(B.id,async(z)=>{if(z?.type!=="oauth"||Date.now()<z.expires)return;return W.refresh(z,Z)});return k?.type==="oauth"?k:void 0}let $=B.auth.apiKey;if(!$)return;let F=Q?.type==="api_key"?Q:void 0,J=await $.resolve({ctx:this.authContext,credential:F});if(!J)return;return{type:"api_key",key:J.auth.apiKey,env:J.env}}async readCredential(B){try{return await this.credentials.read(B)}catch(Q){throw new G("auth",`Credential store read failed for ${B}`,{cause:Q})}}async checkProviderAuth(B,Q){if(Q?.type==="oauth")return B.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;let Y=B.auth.apiKey;if(!Y)return;if(Y.check)try{return await Y.check({ctx:this.authContext,credential:Q?.type==="api_key"?Q:void 0})}catch($){throw new G("auth",`API key auth check failed for provider ${B.id}`,{cause:$})}let Z=await _(B,this.credentials,this.authContext);return Z?{source:Z.source,type:"api_key"}:void 0}async checkAuth(B){let Q=this.providers.get(B);if(!Q)return;return this.checkProviderAuth(Q,await this.readCredential(B))}async getAvailable(B){let Q=B?[this.providers.get(B)].filter((Z)=>Z!==void 0):this.getProviders();return(await Promise.all(Q.map(async(Z)=>{let $=await this.readCredential(Z.id);return{provider:Z,credential:$,auth:await this.checkProviderAuth(Z,$)}}))).flatMap(({provider:Z,credential:$,auth:F})=>{if(!F)return[];let J=Z.getModels();return Z.filterModels?.(J,$)??J})}async getAuth(B,Q){let Y=typeof B==="string"?B:B.provider,Z=this.providers.get(Y);if(!Z)return;let $=await _(Z,this.credentials,this.authContext,Q);if(!$||typeof B==="string"||!B.headers)return $;return{...$,auth:{...$.auth,headers:K($.auth.headers,B.headers)}}}async login(B,Q,Y){let Z=this.providers.get(B);if(!Z)throw new G("provider",`Unknown provider: ${B}`);let $=Q==="oauth"?Z.auth.oauth:Z.auth.apiKey;if(!$?.login)throw new G("auth",`${Z.name} does not support ${Q} login`);let F=await $.login(Y);try{await this.credentials.modify(B,async()=>F)}catch(J){throw new G("auth",`Credential store modify failed for ${B}`,{cause:J})}return F}async logout(B){try{await this.credentials.delete(B)}catch(Q){throw new G("auth",`Credential store delete failed for ${B}`,{cause:Q})}}requireProvider(B){let Q=this.providers.get(B.provider);if(!Q)throw new G("provider",`Unknown provider: ${B.provider}`);return Q}async applyAuth(B,Q){this.requireProvider(B);let Y=await this.getAuth(B,{apiKey:Q?.apiKey,env:Q?.env});if(!Y)throw new G("auth",`Provider is not configured: ${B.provider}`);let Z=Y.auth,$=Q?.apiKey??Z.apiKey,F=K(Z.headers,Q?.headers);if(Q?.transformHeaders)F=await Q.transformHeaders(F??{});let J=Y.env||Q?.env?{...Y.env??{},...Q?.env??{}}:void 0,W=Z.baseUrl?{...B,baseUrl:Z.baseUrl}:B,{transformHeaders:k,...z}=Q??{},P={...z,apiKey:$,headers:F,env:J};return{requestModel:W,requestOptions:P}}stream(B,Q,Y){return H(B,async()=>{let Z=this.requireProvider(B),{requestModel:$,requestOptions:F}=await this.applyAuth(B,Y);return Z.stream($,Q,F)})}async complete(B,Q,Y){return this.stream(B,Q,Y).result()}streamSimple(B,Q,Y){return H(B,async()=>{let Z=this.requireProvider(B),{requestModel:$,requestOptions:F}=await this.applyAuth(B,Y);return Z.streamSimple($,Q,F)})}async completeSimple(B,Q,Y){return this.streamSimple(B,Q,Y).result()}}function d(B){return new O(B)}function o(B){let Q=B.models,Y=[],Z,$=B.fetchModels,F=()=>{let P=[...Q];for(let U of Y){let X=P.findIndex((V)=>V.id===U.id);if(X>=0)P[X]=U;else P.push(U)}return P},J=typeof B.api.stream==="function"?B.api:void 0,W=J?void 0:B.api,k=(P)=>J??W?.[P.api],z=(P,U)=>{let X=k(P);if(!X)return H(P,async()=>{throw new G("stream",`Provider ${B.id} has no API implementation for "${P.api}"`)});return U(X)};return{id:B.id,name:B.name??B.id,baseUrl:B.baseUrl,headers:B.headers,auth:B.auth,getModels:F,refreshModels:$?(P)=>{return Z??=(async()=>{try{let U=await P.store.read();if(U)Y=U.models.filter((V)=>V.provider===B.id).map((V)=>V);if(!P.allowNetwork||P.signal?.aborted)return;let X=await $(P);if(P.signal?.aborted)return;Y=X,await P.store.write({models:X,checkedAt:Date.now()})}finally{Z=void 0}})(),Z}:void 0,filterModels:B.filterModels,stream:(P,U,X)=>z(P,(V)=>V.stream(P,U,X)),streamSimple:(P,U,X)=>z(P,(V)=>V.streamSimple(P,U,X))}}function r(B,Q){let Y=Q.input+Q.cacheRead+Q.cacheWrite,Z=B.cost,$=-1;for(let W of B.cost.tiers??[])if(Y>W.inputTokensAbove&&W.inputTokensAbove>$)Z=W,$=W.inputTokensAbove;let F=Q.cacheWrite1h??0,J=Q.cacheWrite-F;return Q.cost.input=Z.input/1e6*Q.input,Q.cost.output=Z.output/1e6*Q.output,Q.cost.cacheRead=Z.cacheRead/1e6*Q.cacheRead,Q.cost.cacheWrite=(Z.cacheWrite*J+Z.input*2*F)/1e6,Q.cost.total=Q.cost.input+Q.cost.output+Q.cost.cacheRead+Q.cost.cacheWrite,Q.cost}var R=["off","minimal","low","medium","high","xhigh","max"];function h(B){if(!B.reasoning)return["off"];return R.filter((Q)=>{let Y=B.thinkingLevelMap?.[Q];if(Y===null)return!1;if(Q==="xhigh"||Q==="max")return Y!==void 0;return!0})}function e(B,Q){let Y=h(B);if(Y.includes(Q))return Q;let Z=R.indexOf(Q);if(Z===-1)return Y[0]??"off";for(let $=Z;$<R.length;$++){let F=R[$];if(Y.includes(F))return F}for(let $=Z-1;$>=0;$--){let F=R[$];if(Y.includes(F))return F}return Y[0]??"off"}
3
+ export{g as hn,D as in,d as jn,o as kn,r as ln,e as mn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{vd as GJ,wd as zJ}from"./chunk-j5rx3x1q.js";import{om as OJ}from"./chunk-wrgwjg2g.js";import{rm as n,sm as WJ,tm as r}from"./chunk-8956rryj.js";import{um as jJ}from"./chunk-k3r97v7j.js";import"./chunk-wzmpvadf.js";import{zm as p}from"./chunk-tn67sjb2.js";import"./chunk-9k76s3y6.js";import{Om as KJ,Pm as _J}from"./chunk-thbfw1ed.js";import{Um as a,Wm as LJ}from"./chunk-agabtxrc.js";import"./chunk-he1ywtxx.js";import{_m as i}from"./chunk-xzag8w1v.js";import{fn as DJ}from"./chunk-xkhwj8mw.js";import{gn as YJ,hn as y,in as NJ,jn as VJ}from"./chunk-kvnfgr29.js";import"./chunk-p49h5fxs.js";function o(J){let Q=J.filter((F)=>F!==void 0);if(Q.length===0)return{cleanup:()=>{}};if(Q.length===1)return{signal:Q[0],cleanup:()=>{}};let Z=new AbortController,$=[],X=(F)=>{if(!Z.signal.aborted)Z.abort(F.reason)};for(let F of Q){if(F.aborted){X(F);break}let Y=()=>X(F);F.addEventListener("abort",Y,{once:!0}),$.push({signal:F,listener:Y})}return{signal:Z.signal,cleanup:()=>{for(let{signal:F,listener:Y}of $)F.removeEventListener("abort",Y)}}}var fJ={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function c(J,Q){let Z=J.toLowerCase(),$=J.toUpperCase();return Q?.[Z]||Q?.[$]||p(Z)||p($)||""}function SJ(J){if(J instanceof URL)return J;try{return new URL(J)}catch{return}}function TJ(J,Q,Z){let $=c("no_proxy",Z).toLowerCase();if(!$)return!0;if($==="*")return!1;return $.split(/[,\s]/).every((X)=>{if(!X)return!0;let F=X.match(/^(.+):(\d+)$/),Y=F?F[1]:X,G=F?Number.parseInt(F[2],10):0;if(G&&G!==Q)return!0;if(!/^[.*]/.test(Y))return J!==Y;if(Y.startsWith("*"))Y=Y.slice(1);return!J.endsWith(Y)})}function hJ(J,Q){let Z=SJ(J);if(!Z?.protocol||!Z.host)return"";let $=Z.protocol.split(":",1)[0],X=Z.host.replace(/:\d*$/,""),F=Number.parseInt(Z.port,10)||fJ[$]||0;if(!TJ(X,F,Q))return"";let Y=c(`${$}_proxy`,Q)||c("all_proxy",Q);if(Y&&!Y.includes("://"))Y=`${$}://${Y}`;return Y}var xJ="Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.";function e(J,Q){let Z=hJ(J,Q);if(!Z)return;let $;try{$=new URL(Z)}catch(X){throw Error(`Invalid proxy URL ${JSON.stringify(Z)}: ${X instanceof Error?X.message:String(X)}`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw Error(`${xJ} Got ${$.protocol}`);return $}function bJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:os")??null}var I=bJ(),kJ="https://chatgpt.com/backend-api",IJ="https://api.openai.com/auth",gJ=0,JJ=1000,vJ=60000,yJ=15000,mJ=3,BJ=new Set(["openai","openai-codex","opencode"]),uJ=1009,pJ="websocket_connection_limit_reached",cJ="previous_response_not_found",lJ=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function dJ(J){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(J)}function iJ(J,Q){if(J===429&&dJ(Q))return!1;if(J===429||J===500||J===502||J===503||J===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function aJ(J){let Q=J.get("retry-after-ms");if(Q!==null){let F=Number(Q);if(Number.isFinite(F))return Math.max(0,F)}let Z=J.get("retry-after");if(!Z)return;let $=Number(Z);if(Number.isFinite($))return Math.max(0,$*1000);let X=Date.parse(Z);if(!Number.isNaN(X))return Math.max(0,X-Date.now());return}class t extends Error{}function nJ(J,Q){let Z=Q?.maxRetryDelayMs??vJ;if(Z>0&&J>Z)throw new t(`Server requested ${Math.ceil(J/1000)}s retry delay (max: ${Math.ceil(Z/1000)}s)`);return J}function QJ(J,Q){return new Promise((Z,$)=>{if(Q?.aborted){$(Error("Request was aborted"));return}let X=setTimeout(Z,J);Q?.addEventListener("abort",()=>{clearTimeout(X),$(Error("Request was aborted"))})})}function ZJ(J){if(J===void 0)return;if(!Number.isFinite(J)||J<0)throw Error(`Invalid timeoutMs: ${String(J)}`);return Math.floor(J)}function rJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:zlib")??null}function tJ(J){let Q=rJ();if(!Q||typeof Q.zstdCompressSync!=="function")return null;try{let Z=Q.zstdCompressSync(J,{params:{[Q.constants.ZSTD_c_compressionLevel]:mJ}});return new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength)}catch{return null}}var sJ=(J,Q,Z)=>{let $=new YJ;return(async()=>{let X={role:"assistant",content:[],api:"openai-codex-responses",provider:J.provider,model:J.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let F=Z?.apiKey;if(!F)throw Error(`No API key for provider: ${J.provider}`);let Y=UQ(F),G=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1),N=Z?.cacheRetention==="none"?void 0:Z?.sessionId,V=jJ(N),K=oJ(J,Q,Z,V,G),D=await Z?.onPayload?.(K,J);if(D!==void 0)K=D;let R=V||zJ(),z=CQ(J.headers,Z?.headers,Y,F,V),A=MQ(J.headers,Z?.headers,Y,F,R),j=JSON.stringify(K),_=ZJ(Z?.timeoutMs),U=ZJ(Z?.websocketConnectTimeoutMs),L=Z?.transport||"auto",W=!1,O=L!=="sse"&&EJ(N);if(O)$J(N);if(L!=="sse"&&!O){let B=!1,H=!1,M=!1;while(!0){B=!1;try{if(await wQ(JQ(J.baseUrl),K,A,X,$,J,()=>{if(B=!0,!W)W=!0,$.push({type:"start",partial:X})},_,U,N,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end();return}catch(w){let x=Z?.signal?.aborted,b=!B&&$Q(w),S=FQ(w);if(!x&&S&&!M){M=!0;continue}if(!x&&b&&!H){H=!0;continue}if(x||ZQ(w)&&!b)throw w;if(VJ(X,NJ("provider_transport_failure",w,{configuredTransport:L,fallbackTransport:B?void 0:"sse",eventsEmitted:B,phase:B?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(j).byteLength})),KQ(N,w),B)throw w;$J(N);break}}}let C=tJ(j);if(C)z.set("content-encoding","zstd");let f=C??j,q,h,u=Z?.maxRetries??gJ;for(let B=0;B<=u;B++){if(Z?.signal?.aborted)throw Error("Request was aborted");try{let H=_!==void 0&&_>0?AbortSignal.timeout(_):void 0,M=o([Z?.signal,H]);try{q=await fetch(qJ(J.baseUrl),{method:"POST",headers:z,body:f,signal:M.signal})}catch(S){if(H?.aborted&&!Z?.signal?.aborted)throw Error(`Codex SSE response headers timed out after ${_}ms`);throw S}finally{M.cleanup()}if(await Z?.onResponse?.({status:q.status,headers:i(q.headers)},J),q.ok)break;let w=await q.text();if(B<u&&iJ(q.status,w)){let S=aJ(q.headers),MJ=S===void 0?JJ*2**B:nJ(S,Z);await QJ(MJ,Z?.signal);continue}let x=new Response(w,{status:q.status,statusText:q.statusText}),b=await PQ(x);throw Error(b.friendlyMessage||b.message)}catch(H){if(H instanceof Error){if(H.name==="AbortError"||H.message==="Request was aborted")throw Error("Request was aborted")}if(h=H instanceof Error?H:Error(String(H)),B<u&&!(h instanceof t)&&!h.message.includes("usage limit")){let M=JJ*2**B;await QJ(M,Z?.signal);continue}throw h}}if(!q?.ok)throw h??Error("Failed after retries");if(!q.body)throw Error("No response body");if(!W)W=!0,$.push({type:"start",partial:X});if(await QQ(q,X,$,J,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(F){for(let Y of X.content)delete Y.partialJson,delete Y.customInput;X.stopReason=Z?.signal?.aborted?"aborted":"error",X.errorMessage=_J(KJ(F)),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$},iQ=(J,Q,Z)=>{let $=Z?.apiKey;if(!$)throw Error(`No API key for provider: ${J.provider}`);let X=LJ(J,Q,Z,$),F=Z?.reasoning?DJ(J,Z.reasoning):void 0;return sJ(J,Q,{...X,reasoningEffort:F==="off"?void 0:F})};function oJ(J,Q,Z,$,X=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1)){let F=J.compat?.supportsStrictMode??!0,Y=J.compat?.supportsOpenAIGrammarTools??!1,G=OJ(Q,J.compat?.supportsToolSearch??!1),N=n(J,Q,BJ,{includeSystemPrompt:!1,grammarToolInputProperties:X,deferredTools:G.deferred,toolOptions:{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y}}),V={model:J.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:N,text:{verbosity:Z?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:$,tool_choice:Z?.toolChoice??"auto",parallel_tool_calls:!0};if(Z?.temperature!==void 0)V.temperature=Z.temperature;if(Z?.serviceTier!==void 0)V.service_tier=Z.serviceTier;if(G.immediate.length>0)V.tools=WJ(G.immediate,{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y});if(Z?.reasoningEffort!==void 0){let K=Z.reasoningEffort==="none"?J.thinkingLevelMap?.off??"none":J.thinkingLevelMap?.[Z.reasoningEffort]??Z.reasoningEffort;if(K!==null)V.reasoning={effort:K,summary:Z.reasoningSummary??"auto"}}return V}function eJ(J,Q){switch(Q){case"flex":return 0.5;case"priority":return J.id==="gpt-5.5"?2.5:2;default:return 1}}function RJ(J,Q,Z){let $=eJ(Z,Q);if($===1)return;J.cost.input*=$,J.cost.output*=$,J.cost.cacheRead*=$,J.cost.cacheWrite*=$,J.cost.total=J.cost.input+J.cost.output+J.cost.cacheRead+J.cost.cacheWrite}function AJ(J,Q){if(J==="default"&&(Q==="flex"||Q==="priority"))return Q;return J??Q}function qJ(J){let Z=(J&&J.trim().length>0?J:kJ).replace(/\/+$/,"");if(Z.endsWith("/codex/responses"))return Z;if(Z.endsWith("/codex"))return`${Z}/responses`;return`${Z}/codex/responses`}function JQ(J){let Q=new URL(qJ(J));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function QQ(J,Q,Z,$,X,F){await r(HJ(NQ(J,F?.signal)),Q,Z,$,{serviceTier:F?.serviceTier,grammarToolInputProperties:X,resolveServiceTier:AJ,applyServiceTierPricing:(Y,G)=>RJ(Y,G,$)})}class T extends Error{code;payload;constructor(J,Q){super(J);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class m extends Error{payload;constructor(J,Q){super(J);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function ZQ(J){return J instanceof T||J instanceof m}function $Q(J){return J instanceof T&&J.code===pJ}function FQ(J){return J instanceof T&&J.code===cJ}function XQ(J){let Q=J.error&&typeof J.error==="object"?J.error:void 0;return{code:typeof J.code==="string"?J.code:typeof Q?.code==="string"?Q.code:void 0,message:typeof J.message==="string"?J.message:typeof Q?.message==="string"?Q.message:void 0}}async function*HJ(J){for await(let Q of J){let Z=typeof Q.type==="string"?Q.type:void 0;if(!Z)continue;if(Z==="error"){let{code:$,message:X}=XQ(Q);throw new T(`Codex error: ${X||$||JSON.stringify(Q)}`,{code:$,payload:Q})}if(Z==="response.failed"){let $=Q.response,X=$?.error?.code,F=$?.error?.message;throw new T(F||"Codex response failed",{code:X,payload:Q})}if(Z==="response.done"||Z==="response.completed"||Z==="response.incomplete"){let $=Q.response,X=$?{...$,status:YQ($.status)}:$;yield{...Q,type:"response.completed",response:X};return}yield Q}}function YQ(J){if(typeof J!=="string")return;return lJ.has(J)?J:void 0}async function*NQ(J,Q){if(!J.body)return;let Z=J.body.getReader(),$=new TextDecoder,X="",F=()=>{Z.cancel().catch(()=>{})};Q?.addEventListener("abort",F,{once:!0});try{while(!0){if(Q?.aborted)throw Error("Request was aborted");let{done:Y,value:G}=await Z.read();if(Q?.aborted)throw Error("Request was aborted");if(Y)break;X+=$.decode(G,{stream:!0});let N=X.indexOf(`
2
+ import{vd as GJ,wd as zJ}from"./chunk-j5rx3x1q.js";import{vm as OJ}from"./chunk-r6g1srb3.js";import{Am as r,ym as n,zm as WJ}from"./chunk-3gqdepkd.js";import{Bm as jJ}from"./chunk-bbar8rsh.js";import"./chunk-ewge52nq.js";import{Gm as p}from"./chunk-rar0gk7s.js";import"./chunk-7wvw67f3.js";import{Vm as KJ,Wm as _J}from"./chunk-pn94h6x7.js";import{$m as a,bn as LJ}from"./chunk-wxsq9zmf.js";import"./chunk-k20w9eaz.js";import{fn as i}from"./chunk-7qzt5nhz.js";import{mn as DJ}from"./chunk-116p639c.js";import{nn as YJ,on as y,pn as NJ,qn as VJ}from"./chunk-q46rc697.js";import"./chunk-txkmks1h.js";function o(J){let Q=J.filter((F)=>F!==void 0);if(Q.length===0)return{cleanup:()=>{}};if(Q.length===1)return{signal:Q[0],cleanup:()=>{}};let Z=new AbortController,$=[],X=(F)=>{if(!Z.signal.aborted)Z.abort(F.reason)};for(let F of Q){if(F.aborted){X(F);break}let Y=()=>X(F);F.addEventListener("abort",Y,{once:!0}),$.push({signal:F,listener:Y})}return{signal:Z.signal,cleanup:()=>{for(let{signal:F,listener:Y}of $)F.removeEventListener("abort",Y)}}}var fJ={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443};function c(J,Q){let Z=J.toLowerCase(),$=J.toUpperCase();return Q?.[Z]||Q?.[$]||p(Z)||p($)||""}function SJ(J){if(J instanceof URL)return J;try{return new URL(J)}catch{return}}function TJ(J,Q,Z){let $=c("no_proxy",Z).toLowerCase();if(!$)return!0;if($==="*")return!1;return $.split(/[,\s]/).every((X)=>{if(!X)return!0;let F=X.match(/^(.+):(\d+)$/),Y=F?F[1]:X,G=F?Number.parseInt(F[2],10):0;if(G&&G!==Q)return!0;if(!/^[.*]/.test(Y))return J!==Y;if(Y.startsWith("*"))Y=Y.slice(1);return!J.endsWith(Y)})}function hJ(J,Q){let Z=SJ(J);if(!Z?.protocol||!Z.host)return"";let $=Z.protocol.split(":",1)[0],X=Z.host.replace(/:\d*$/,""),F=Number.parseInt(Z.port,10)||fJ[$]||0;if(!TJ(X,F,Q))return"";let Y=c(`${$}_proxy`,Q)||c("all_proxy",Q);if(Y&&!Y.includes("://"))Y=`${$}://${Y}`;return Y}var xJ="Unsupported proxy protocol. SOCKS and PAC proxy URLs are not supported; use an HTTP or HTTPS proxy URL.";function e(J,Q){let Z=hJ(J,Q);if(!Z)return;let $;try{$=new URL(Z)}catch(X){throw Error(`Invalid proxy URL ${JSON.stringify(Z)}: ${X instanceof Error?X.message:String(X)}`)}if($.protocol!=="http:"&&$.protocol!=="https:")throw Error(`${xJ} Got ${$.protocol}`);return $}function bJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:os")??null}var I=bJ(),kJ="https://chatgpt.com/backend-api",IJ="https://api.openai.com/auth",gJ=0,JJ=1000,vJ=60000,yJ=15000,mJ=3,BJ=new Set(["openai","openai-codex","opencode"]),uJ=1009,pJ="websocket_connection_limit_reached",cJ="previous_response_not_found",lJ=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function dJ(J){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(J)}function iJ(J,Q){if(J===429&&dJ(Q))return!1;if(J===429||J===500||J===502||J===503||J===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function aJ(J){let Q=J.get("retry-after-ms");if(Q!==null){let F=Number(Q);if(Number.isFinite(F))return Math.max(0,F)}let Z=J.get("retry-after");if(!Z)return;let $=Number(Z);if(Number.isFinite($))return Math.max(0,$*1000);let X=Date.parse(Z);if(!Number.isNaN(X))return Math.max(0,X-Date.now());return}class t extends Error{}function nJ(J,Q){let Z=Q?.maxRetryDelayMs??vJ;if(Z>0&&J>Z)throw new t(`Server requested ${Math.ceil(J/1000)}s retry delay (max: ${Math.ceil(Z/1000)}s)`);return J}function QJ(J,Q){return new Promise((Z,$)=>{if(Q?.aborted){$(Error("Request was aborted"));return}let X=setTimeout(Z,J);Q?.addEventListener("abort",()=>{clearTimeout(X),$(Error("Request was aborted"))})})}function ZJ(J){if(J===void 0)return;if(!Number.isFinite(J)||J<0)throw Error(`Invalid timeoutMs: ${String(J)}`);return Math.floor(J)}function rJ(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:zlib")??null}function tJ(J){let Q=rJ();if(!Q||typeof Q.zstdCompressSync!=="function")return null;try{let Z=Q.zstdCompressSync(J,{params:{[Q.constants.ZSTD_c_compressionLevel]:mJ}});return new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength)}catch{return null}}var sJ=(J,Q,Z)=>{let $=new YJ;return(async()=>{let X={role:"assistant",content:[],api:"openai-codex-responses",provider:J.provider,model:J.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let F=Z?.apiKey;if(!F)throw Error(`No API key for provider: ${J.provider}`);let Y=UQ(F),G=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1),N=Z?.cacheRetention==="none"?void 0:Z?.sessionId,V=jJ(N),K=oJ(J,Q,Z,V,G),D=await Z?.onPayload?.(K,J);if(D!==void 0)K=D;let R=V||zJ(),z=CQ(J.headers,Z?.headers,Y,F,V),A=MQ(J.headers,Z?.headers,Y,F,R),j=JSON.stringify(K),_=ZJ(Z?.timeoutMs),U=ZJ(Z?.websocketConnectTimeoutMs),L=Z?.transport||"auto",W=!1,O=L!=="sse"&&EJ(N);if(O)$J(N);if(L!=="sse"&&!O){let B=!1,H=!1,M=!1;while(!0){B=!1;try{if(await wQ(JQ(J.baseUrl),K,A,X,$,J,()=>{if(B=!0,!W)W=!0,$.push({type:"start",partial:X})},_,U,N,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end();return}catch(w){let x=Z?.signal?.aborted,b=!B&&$Q(w),S=FQ(w);if(!x&&S&&!M){M=!0;continue}if(!x&&b&&!H){H=!0;continue}if(x||ZQ(w)&&!b)throw w;if(VJ(X,NJ("provider_transport_failure",w,{configuredTransport:L,fallbackTransport:B?void 0:"sse",eventsEmitted:B,phase:B?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(j).byteLength})),KQ(N,w),B)throw w;$J(N);break}}}let C=tJ(j);if(C)z.set("content-encoding","zstd");let f=C??j,q,h,u=Z?.maxRetries??gJ;for(let B=0;B<=u;B++){if(Z?.signal?.aborted)throw Error("Request was aborted");try{let H=_!==void 0&&_>0?AbortSignal.timeout(_):void 0,M=o([Z?.signal,H]);try{q=await fetch(qJ(J.baseUrl),{method:"POST",headers:z,body:f,signal:M.signal})}catch(S){if(H?.aborted&&!Z?.signal?.aborted)throw Error(`Codex SSE response headers timed out after ${_}ms`);throw S}finally{M.cleanup()}if(await Z?.onResponse?.({status:q.status,headers:i(q.headers)},J),q.ok)break;let w=await q.text();if(B<u&&iJ(q.status,w)){let S=aJ(q.headers),MJ=S===void 0?JJ*2**B:nJ(S,Z);await QJ(MJ,Z?.signal);continue}let x=new Response(w,{status:q.status,statusText:q.statusText}),b=await PQ(x);throw Error(b.friendlyMessage||b.message)}catch(H){if(H instanceof Error){if(H.name==="AbortError"||H.message==="Request was aborted")throw Error("Request was aborted")}if(h=H instanceof Error?H:Error(String(H)),B<u&&!(h instanceof t)&&!h.message.includes("usage limit")){let M=JJ*2**B;await QJ(M,Z?.signal);continue}throw h}}if(!q?.ok)throw h??Error("Failed after retries");if(!q.body)throw Error("No response body");if(!W)W=!0,$.push({type:"start",partial:X});if(await QQ(q,X,$,J,G,Z),Z?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(F){for(let Y of X.content)delete Y.partialJson,delete Y.customInput;X.stopReason=Z?.signal?.aborted?"aborted":"error",X.errorMessage=_J(KJ(F)),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$},iQ=(J,Q,Z)=>{let $=Z?.apiKey;if(!$)throw Error(`No API key for provider: ${J.provider}`);let X=LJ(J,Q,Z,$),F=Z?.reasoning?DJ(J,Z.reasoning):void 0;return sJ(J,Q,{...X,reasoningEffort:F==="off"?void 0:F})};function oJ(J,Q,Z,$,X=a(Q.tools,J.compat?.supportsOpenAIGrammarTools??!1)){let F=J.compat?.supportsStrictMode??!0,Y=J.compat?.supportsOpenAIGrammarTools??!1,G=OJ(Q,J.compat?.supportsToolSearch??!1),N=n(J,Q,BJ,{includeSystemPrompt:!1,grammarToolInputProperties:X,deferredTools:G.deferred,toolOptions:{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y}}),V={model:J.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:N,text:{verbosity:Z?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:$,tool_choice:Z?.toolChoice??"auto",parallel_tool_calls:!0};if(Z?.temperature!==void 0)V.temperature=Z.temperature;if(Z?.serviceTier!==void 0)V.service_tier=Z.serviceTier;if(G.immediate.length>0)V.tools=WJ(G.immediate,{strict:null,supportsStrictMode:F,supportsOpenAIGrammarTools:Y});if(Z?.reasoningEffort!==void 0){let K=Z.reasoningEffort==="none"?J.thinkingLevelMap?.off??"none":J.thinkingLevelMap?.[Z.reasoningEffort]??Z.reasoningEffort;if(K!==null)V.reasoning={effort:K,summary:Z.reasoningSummary??"auto"}}return V}function eJ(J,Q){switch(Q){case"flex":return 0.5;case"priority":return J.id==="gpt-5.5"?2.5:2;default:return 1}}function RJ(J,Q,Z){let $=eJ(Z,Q);if($===1)return;J.cost.input*=$,J.cost.output*=$,J.cost.cacheRead*=$,J.cost.cacheWrite*=$,J.cost.total=J.cost.input+J.cost.output+J.cost.cacheRead+J.cost.cacheWrite}function AJ(J,Q){if(J==="default"&&(Q==="flex"||Q==="priority"))return Q;return J??Q}function qJ(J){let Z=(J&&J.trim().length>0?J:kJ).replace(/\/+$/,"");if(Z.endsWith("/codex/responses"))return Z;if(Z.endsWith("/codex"))return`${Z}/responses`;return`${Z}/codex/responses`}function JQ(J){let Q=new URL(qJ(J));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function QQ(J,Q,Z,$,X,F){await r(HJ(NQ(J,F?.signal)),Q,Z,$,{serviceTier:F?.serviceTier,grammarToolInputProperties:X,resolveServiceTier:AJ,applyServiceTierPricing:(Y,G)=>RJ(Y,G,$)})}class T extends Error{code;payload;constructor(J,Q){super(J);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class m extends Error{payload;constructor(J,Q){super(J);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function ZQ(J){return J instanceof T||J instanceof m}function $Q(J){return J instanceof T&&J.code===pJ}function FQ(J){return J instanceof T&&J.code===cJ}function XQ(J){let Q=J.error&&typeof J.error==="object"?J.error:void 0;return{code:typeof J.code==="string"?J.code:typeof Q?.code==="string"?Q.code:void 0,message:typeof J.message==="string"?J.message:typeof Q?.message==="string"?Q.message:void 0}}async function*HJ(J){for await(let Q of J){let Z=typeof Q.type==="string"?Q.type:void 0;if(!Z)continue;if(Z==="error"){let{code:$,message:X}=XQ(Q);throw new T(`Codex error: ${X||$||JSON.stringify(Q)}`,{code:$,payload:Q})}if(Z==="response.failed"){let $=Q.response,X=$?.error?.code,F=$?.error?.message;throw new T(F||"Codex response failed",{code:X,payload:Q})}if(Z==="response.done"||Z==="response.completed"||Z==="response.incomplete"){let $=Q.response,X=$?{...$,status:YQ($.status)}:$;yield{...Q,type:"response.completed",response:X};return}yield Q}}function YQ(J){if(typeof J!=="string")return;return lJ.has(J)?J:void 0}async function*NQ(J,Q){if(!J.body)return;let Z=J.body.getReader(),$=new TextDecoder,X="",F=()=>{Z.cancel().catch(()=>{})};Q?.addEventListener("abort",F,{once:!0});try{while(!0){if(Q?.aborted)throw Error("Request was aborted");let{done:Y,value:G}=await Z.read();if(Q?.aborted)throw Error("Request was aborted");if(Y)break;X+=$.decode(G,{stream:!0});let N=X.indexOf(`
3
3
 
4
4
  `);while(N!==-1){let V=X.slice(0,N);X=X.slice(N+2);let K=V.split(`
5
5
  `).filter((D)=>D.startsWith("data:")).map((D)=>D.slice(5).trim());if(K.length>0){let D=K.join(`
@@ -1,2 +1,2 @@
1
- import{Vi as O}from"./chunk-kqpzx5az.js";import{kn as M}from"./chunk-p49h5fxs.js";var f=M(O(),1),K=M(O(),1),Q=M(O(),1);var E=new Map,x=new WeakMap,_=0,I;function v(q){if(!q)return"0";if(x.has(q))return x.get(q);return _+=1,x.set(q,_.toString()),x.get(q)}function h(q){return Object.keys(q).sort().filter((A)=>q[A]!==void 0).map((A)=>{return`${A}_${A==="root"?v(q.root):q[A]}`}).toString()}function k(q){let A=h(q),B=E.get(A);if(!B){let J=new Map,W,G=new IntersectionObserver((D)=>{D.forEach((z)=>{var H;let $=z.isIntersecting&&W.some((Y)=>z.intersectionRatio>=Y);if(q.trackVisibility&&typeof z.isVisible>"u")z.isVisible=$;[...(H=J.get(z.target))!=null?H:[]].forEach((Y)=>{Y($,z)})})},q);W=G.thresholds||(Array.isArray(q.threshold)?q.threshold:[q.threshold||0]),B={id:A,observer:G,elements:J},E.set(A,B)}return B}function w(q,A,B={},J=I){if(typeof window.IntersectionObserver>"u"&&J!==void 0){let H=q.getBoundingClientRect();return A(J,{isIntersecting:J,target:q,intersectionRatio:typeof B.threshold==="number"?B.threshold:0,time:0,boundingClientRect:H,intersectionRect:H,rootBounds:H}),()=>{}}let{id:W,observer:G,elements:D}=k(B),z=D.get(q)||[];if(!D.has(q))D.set(q,z);return z.push(A),G.observe(q),function(){if(z.splice(z.indexOf(A),1),z.length===0)D.delete(q),G.unobserve(q);if(D.size===0)G.disconnect(),E.delete(W)}}function y({threshold:q,delay:A,trackVisibility:B,rootMargin:J,root:W,triggerOnce:G,skip:D,initialInView:z,fallbackInView:H,onChange:$}={}){var Y;let[N,g]=K.useState(null),S=K.useRef($),L=K.useRef(z),[F,P]=K.useState({inView:!!z,entry:void 0});S.current=$,K.useEffect(()=>{if(L.current===void 0)L.current=z;if(D||!N)return;let Z;return Z=w(N,(U,j)=>{let u=L.current;if(L.current=U,u===void 0&&!U)return;if(P({inView:U,entry:j}),S.current)S.current(U,j);if(j.isIntersecting&&G&&Z)Z(),Z=void 0},{root:W,rootMargin:J,threshold:q,trackVisibility:B,delay:A},H),()=>{if(Z)Z()}},[Array.isArray(q)?q.toString():q,N,W,J,G,D,B,H,A]);let T=(Y=F.entry)==null?void 0:Y.target,C=K.useRef(void 0);if(!N&&T&&!G&&!D&&C.current!==T)C.current=T,P({inView:!!z,entry:void 0}),L.current=z;let X=[g,F.inView,F.entry];return X.ref=X[0],X.inView=X[1],X.entry=X[2],X}var R,m,d=(m=(R=("useInsertionEffect"in Q)?Q.useInsertionEffect:void 0)!=null?R:Q.useLayoutEffect)!=null?m:Q.useEffect;
2
- export{y as eh};
1
+ import{$i as O}from"./chunk-w9p59ahz.js";import{rn as M}from"./chunk-txkmks1h.js";var f=M(O(),1),K=M(O(),1),Q=M(O(),1);var E=new Map,x=new WeakMap,_=0,I;function v(q){if(!q)return"0";if(x.has(q))return x.get(q);return _+=1,x.set(q,_.toString()),x.get(q)}function h(q){return Object.keys(q).sort().filter((A)=>q[A]!==void 0).map((A)=>{return`${A}_${A==="root"?v(q.root):q[A]}`}).toString()}function k(q){let A=h(q),B=E.get(A);if(!B){let J=new Map,W,G=new IntersectionObserver((D)=>{D.forEach((z)=>{var H;let $=z.isIntersecting&&W.some((Y)=>z.intersectionRatio>=Y);if(q.trackVisibility&&typeof z.isVisible>"u")z.isVisible=$;[...(H=J.get(z.target))!=null?H:[]].forEach((Y)=>{Y($,z)})})},q);W=G.thresholds||(Array.isArray(q.threshold)?q.threshold:[q.threshold||0]),B={id:A,observer:G,elements:J},E.set(A,B)}return B}function w(q,A,B={},J=I){if(typeof window.IntersectionObserver>"u"&&J!==void 0){let H=q.getBoundingClientRect();return A(J,{isIntersecting:J,target:q,intersectionRatio:typeof B.threshold==="number"?B.threshold:0,time:0,boundingClientRect:H,intersectionRect:H,rootBounds:H}),()=>{}}let{id:W,observer:G,elements:D}=k(B),z=D.get(q)||[];if(!D.has(q))D.set(q,z);return z.push(A),G.observe(q),function(){if(z.splice(z.indexOf(A),1),z.length===0)D.delete(q),G.unobserve(q);if(D.size===0)G.disconnect(),E.delete(W)}}function y({threshold:q,delay:A,trackVisibility:B,rootMargin:J,root:W,triggerOnce:G,skip:D,initialInView:z,fallbackInView:H,onChange:$}={}){var Y;let[N,g]=K.useState(null),S=K.useRef($),L=K.useRef(z),[F,P]=K.useState({inView:!!z,entry:void 0});S.current=$,K.useEffect(()=>{if(L.current===void 0)L.current=z;if(D||!N)return;let Z;return Z=w(N,(U,j)=>{let u=L.current;if(L.current=U,u===void 0&&!U)return;if(P({inView:U,entry:j}),S.current)S.current(U,j);if(j.isIntersecting&&G&&Z)Z(),Z=void 0},{root:W,rootMargin:J,threshold:q,trackVisibility:B,delay:A},H),()=>{if(Z)Z()}},[Array.isArray(q)?q.toString():q,N,W,J,G,D,B,H,A]);let T=(Y=F.entry)==null?void 0:Y.target,C=K.useRef(void 0);if(!N&&T&&!G&&!D&&C.current!==T)C.current=T,P({inView:!!z,entry:void 0}),L.current=z;let X=[g,F.inView,F.entry];return X.ref=X[0],X.inView=X[1],X.entry=X[2],X}var R,m,d=(m=(R=("useInsertionEffect"in Q)?Q.useInsertionEffect:void 0)!=null?R:Q.useLayoutEffect)!=null?m:Q.useEffect;
2
+ export{y as kh};
@@ -1,2 +1,2 @@
1
- import{Pl as o,Xi as e}from"./chunk-kqpzx5az.js";function d({className:n,...t}){return e("div",{"data-slot":"skeleton",className:o("animate-pulse rounded-md bg-accent",n),...t})}
2
- export{d as dh};
1
+ import{Wl as o,bj as e}from"./chunk-w9p59ahz.js";function d({className:n,...t}){return e("div",{"data-slot":"skeleton",className:o("animate-pulse rounded-md bg-accent",n),...t})}
2
+ export{d as jh};
@@ -1 +1 @@
1
- import{a as QJ,b as a,c as dJ}from"./chunk-vvhs586e.js";import{i as c,j as i,k as j,l as R,m as q,n as E}from"./chunk-sx6y697s.js";import{_ as LJ}from"./chunk-jt6d0zb1.js";import{$ as _J,aa as u}from"./chunk-4b7jcpgv.js";import{ve as jJ}from"./chunk-gcc6pte2.js";import{bf as v,cf as T,df as I,ef as b,ff as g}from"./chunk-x9akgj7w.js";import{Lf as O}from"./chunk-ymr5ybxk.js";import{Mf as kJ,Nf as FJ,Of as MJ,_f as mJ,bg as HJ}from"./chunk-2xevs82j.js";import"./chunk-zye42cfp.js";import"./chunk-dk8vk17v.js";import"./chunk-vhcqazqf.js";import{eh as JJ}from"./chunk-tcm57j8r.js";import"./chunk-dkjkn8t3.js";import{Ch as KJ,Eh as EJ}from"./chunk-2xgvs3as.js";import"./chunk-9cmvymm5.js";import{$h as A,Zh as S,_h as C}from"./chunk-kxr8fjsq.js";import{Ci as M,Di as TJ,Ei as IJ,Fi as bJ,Gi as gJ,Hi as nJ,Ii as uJ,Ji as cJ,Ki as iJ,Si as qJ,qi as SJ,si as BJ,ti as D,vi as CJ,wi as e}from"./chunk-8nyve0cr.js";import{El as pJ,Fj as l,Gl as vJ,Hl as NJ,Ll as lJ,Pl as s,Uk as r,Vi as t,Wi as hJ,Wj as AJ,Wl as YJ,Xi as J,Yi as K,ck as ZJ,gj as tJ,jm as n,kl as $J,mm as W,nj as rJ,nm as XJ,ol as aJ,pj as GJ,rk as x,vj as wJ,wj as k}from"./chunk-kqpzx5az.js";import{kn as o}from"./chunk-p49h5fxs.js";var sJ=o(t(),1);var VJ=o(t(),1);function UJ({teamId:Y}){let[Z,z]=VJ.useState("team"),[G,Q]=VJ.useState("1h"),{data:V,isLoading:H}=D({queryKey:["teams",Y,"ai-usage",G,"team"],queryFn:async()=>{let _=await M.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:Y},query:{timeframe:G}});if(!_.ok)throw Error("Failed to fetch team AI usage");return await _.json()},enabled:!!Y&&Z==="team"}),{data:f,isLoading:y}=D({queryKey:["teams",Y,"members"],queryFn:async()=>{let _=await M.api.teams[":teamId"].members.$get({param:{teamId:Y},query:{}});if(!_.ok)throw Error("Failed to fetch team members");return await _.json()},enabled:!!Y&&Z==="members"}),P=BJ({queries:(f||[]).map((_)=>({queryKey:["teams",Y,"ai-usage",G,_.id],queryFn:async()=>{let L=await M.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:Y},query:{timeframe:G,userId:_.id}});if(!L.ok)throw Error(`Failed to fetch AI usage for member ${_.id}`);return await L.json()},enabled:!!Y&&Z==="members"}))}),B=y||P.some((_)=>_.isLoading),U=(_)=>{if(!_)return"U";let L=_.split(" ");if(L.length>1)return`${L[0][0]}${L[L.length-1][0]}`.toUpperCase();return _.substring(0,2).toUpperCase()},F=(_)=>{if(!_)return"";switch(_.toLowerCase()){case"owner":return W.owner();case"editor":return W.editor();case"reviewer":return W.reviewer();default:return _}},X=(_)=>(_??0).toLocaleString(),w=(_)=>`$${(_??0).toFixed(6)}`;return K(v,{className:"border-border/60 shadow-sm",children:[K(T,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[K("div",{children:[J(I,{className:"text-xl font-semibold tracking-tight",children:W.ai_usage()}),J(b,{className:"text-sm text-muted-foreground mt-1",children:W.ai_usage_description()})]}),K("div",{className:"flex flex-wrap items-center gap-3",children:[K(_J,{type:"single",value:Z,onValueChange:(_)=>{if(_)z(_)},className:"border rounded-lg p-1 bg-muted/30",children:[J(u,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:W.team_view()}),J(u,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:W.members_view()})]}),K(_J,{type:"single",value:G,onValueChange:(_)=>{if(_)Q(_)},className:"border rounded-lg p-1 bg-muted/30",children:[J(u,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),J(u,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),J(u,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),J(u,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),J(g,{children:Z==="team"?H?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J("div",{className:"rounded-md border",children:K(c,{children:[J(i,{children:K(R,{children:[J(q,{children:W.team()}),J(q,{className:"text-right",children:W.input_tokens()}),J(q,{className:"text-right",children:W.output_tokens()}),J(q,{className:"text-right",children:W.cache_read_tokens()}),J(q,{className:"text-right",children:W.total_tokens()}),J(q,{className:"text-right",children:W.cost()})]})}),J(j,{children:K(R,{children:[J(E,{className:"font-medium",children:W.team()}),J(E,{className:"text-right",children:X(V?.team?.inputTokens)}),J(E,{className:"text-right",children:X(V?.team?.outputTokens)}),J(E,{className:"text-right",children:X(V?.team?.cacheReadTokens)}),J(E,{className:"text-right font-medium",children:X(V?.team?.totalTokens)}),J(E,{className:"text-right font-medium",children:w(V?.team?.cost)})]})})]})}):B?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J("div",{className:"rounded-md border",children:K(c,{children:[J(i,{children:K(R,{children:[J(q,{children:W.members()}),J(q,{children:W.role()}),J(q,{className:"text-right",children:W.input_tokens()}),J(q,{className:"text-right",children:W.output_tokens()}),J(q,{className:"text-right",children:W.cache_read_tokens()}),J(q,{className:"text-right",children:W.total_tokens()}),J(q,{className:"text-right",children:W.cost()})]})}),J(j,{children:(f||[]).map((_,L)=>{let p=P[L]?.data?.member;return K(R,{children:[J(E,{children:K("div",{className:"flex items-center gap-3",children:[K(S,{className:"h-8 w-8 rounded-full",children:[_.image&&J(C,{src:_.image,alt:_.name,className:"object-cover"}),J(A,{className:"bg-primary/20 text-xs",children:U(_.name)})]}),K("div",{className:"flex flex-col",children:[J("span",{className:"text-sm font-medium leading-none",children:_.name}),J("span",{className:"text-xs text-muted-foreground mt-0.5",children:_.email})]})]})}),J(E,{className:"text-xs text-muted-foreground",children:F(_.role)}),J(E,{className:"text-right",children:X(p?.inputTokens)}),J(E,{className:"text-right",children:X(p?.outputTokens)}),J(E,{className:"text-right",children:X(p?.cacheReadTokens)}),J(E,{className:"text-right font-medium",children:X(p?.totalTokens)}),J(E,{className:"text-right font-medium",children:w(p?.cost)})]},_.id)})})]})})})]})}var WJ=o(t(),1);function yJ({teamId:Y}){let[Z,z]=WJ.useState(null),{ref:G,inView:Q}=JJ(),{data:V,isLoading:H,isError:f,fetchNextPage:y,hasNextPage:P,isFetchingNextPage:B}=e({queryKey:["teams",Y,"agent-sessions"],queryFn:async({pageParam:X})=>{let w=await M.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:Y},query:{first:"20",after:X?String(X):void 0}});if(!w.ok)throw Error("Failed to fetch agent sessions");return await w.json()},initialPageParam:"",getNextPageParam:(X)=>X.pageInfo.cursor||void 0,enabled:!!Y});WJ.useEffect(()=>{if(Q&&P&&!B)y()},[Q,P,B,y]);let U=V?.pages.flatMap((X)=>X.data).filter((X)=>X.id!=="pending")||[],F=(X)=>{switch(X){case"comment":return J(O,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:W.session_type_comment()});case"chat":return J(O,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:W.session_type_chat()});case"naming":return J(O,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:W.session_type_naming()});default:return J(O,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:X})}};return K("div",{className:"space-y-6",children:[K(v,{className:"border border-border/50 shadow-xs",children:[J(T,{className:"pb-4",children:J("div",{className:"flex items-center justify-between",children:K("div",{children:[K(I,{className:"text-xl font-bold flex items-center gap-2",children:[J(r,{className:"w-5 h-5 text-violet-500"}),W.sessions()]}),J(b,{className:"mt-1 text-sm text-muted-foreground",children:W.sessions_description()})]})})}),J(g,{children:H?J("div",{className:"flex h-64 items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):f?J("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):U.length===0?K("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[J(r,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),J("p",{className:"text-base font-medium",children:W.no_sessions_found()})]}):K("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[K(c,{children:[J(i,{className:"bg-muted/40",children:K(R,{children:[J(q,{children:W.session_name()}),J(q,{children:W.creator()}),J(q,{children:W.session_type()}),J(q,{className:"text-right",children:W.create_time()})]})}),J(j,{children:U.map((X)=>K(R,{onClick:()=>z(X.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[J(E,{className:"font-medium",children:K("div",{className:"flex flex-col",children:[J("span",{className:"text-sm font-semibold text-foreground",children:X.name||W.untitled_session()}),J("span",{className:"text-xs font-mono text-muted-foreground/70",children:X.id})]})}),J(E,{children:K("div",{className:"flex items-center gap-2",children:[K(S,{className:"h-6 w-6",children:[J(C,{src:X.creator?.image||void 0}),J(A,{className:"text-[10px]",children:X.creator?.name?.[0]?.toUpperCase()||"?"})]}),J("span",{className:"text-sm text-foreground/90",children:X.creator?.name||"System / Agent"})]})}),J(E,{children:F(X.type)}),J(E,{className:"text-right text-xs text-muted-foreground",children:KJ(X.createdAt)})]},X.id))})]}),J("div",{ref:G,className:"py-4 flex justify-center",children:B&&J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),J(LJ,{sessionId:Z,open:!!Z,onOpenChange:(X)=>{if(!X)z(null)}})]})}var d=o(t(),1);function RJ({...Y}){return J(YJ.Root,{"data-slot":"collapsible",...Y})}function fJ({...Y}){return J(YJ.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...Y})}function DJ({...Y}){return J(YJ.CollapsibleContent,{"data-slot":"collapsible-content",...Y})}function OJ(Y){switch(Y.toLowerCase()){case"owner":return W.owner();case"editor":return W.editor();case"reviewer":return W.reviewer();default:return Y}}function YK(Y,Z){if(typeof Y==="object"&&Y!==null&&"message"in Y){let z=Y.message;if(typeof z==="string")return z}return Z}function ZK({rule:Y}){let Z=Y.resourceData??{};if(Y.resource==="agent_mcp_call_count")return J("span",{children:W.quota_target_server({value:String(Z.id??"")})});if(Y.resource==="agent_bash_call_count")return J("span",{children:W.quota_target_match({value:String(Z.match??"*")})});if(Y.resource==="agent_tool_call_count")return J("span",{children:W.quota_target_tool({value:String(Z.name??Z.toolName??"*")})});return null}function $K({rule:Y}){if(Y.scopeMode==="all_members")return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(NJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_all_members(),Y.role?` (${OJ(Y.role)})`:` (${W.quota_scope_team()})`]})]});if(Y.scopeMode==="each_member")return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(vJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_each_member(),Y.role?` (${OJ(Y.role)})`:` (${W.quota_scope_team()})`]})]});return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(pJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_selected_members()," (",Y.userIds?.length||0,")"]})]})}function XK({teamId:Y,rule:Z,record:z}){let G=SJ(),[Q,V]=d.useState(!1),[H,f]=d.useState(()=>new Date),y=QJ[Z.resource],P=Z.scopeMode==="all_members",B=z.percent>=100,U=P?Z.role?`${W.quota_role_shared_pool()}: ${OJ(Z.role)}`:W.quota_team_shared_pool():z.user?.name||z.userId||W.unknown();d.useEffect(()=>{if(!z.isWindowActive||!z.periodEnd)return;let X=window.setInterval(()=>f(new Date),60000);return()=>window.clearInterval(X)},[z.isWindowActive,z.periodEnd]);let F=CJ({mutationFn:async()=>{let X=await M.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:Y,id:Z.id},json:{userId:z.userId??null}});if(!X.ok){let w=await X.json().catch(()=>null);throw Error(YK(w,W.failed_to_reset_quota()))}return await X.json()},onSuccess:()=>{G.invalidateQueries({queryKey:["teams",Y,"quotas",Z.id,"records"]}),G.invalidateQueries({queryKey:["teams",Y,"quotas"]}),V(!1),qJ.success(W.quota_reset_successfully())},onError:(X)=>{let w=X instanceof Error?X.message:W.failed_to_reset_quota();V(!1),qJ.error(w)}});return K(hJ,{children:[K("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[K("div",{className:"flex items-center justify-between gap-3",children:[K("div",{className:"flex min-w-0 items-center gap-3",children:[P?J("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:J(NJ,{className:"h-5 w-5"})}):K(S,{className:"h-9 w-9 shrink-0 border border-border/50",children:[J(C,{src:z.user?.image||void 0}),J(A,{className:"text-xs font-semibold",children:z.user?.name?.[0]?.toUpperCase()||"U"})]}),K("div",{className:"min-w-0",children:[J("div",{className:"truncate text-sm font-semibold text-foreground",children:U}),!P&&z.user?.email&&J("div",{className:"truncate text-xs text-muted-foreground",children:z.user.email})]})]}),K("div",{className:"flex shrink-0 items-center gap-2",children:[z.isWindowActive&&z.periodEnd?K(O,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[J(ZJ,{className:"h-3 w-3"}),J("span",{children:W.quota_refreshes_in({time:EJ(z.periodEnd,H)})})]}):K(O,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[J(GJ,{className:"h-3 w-3 text-primary"}),J("span",{children:W.quota_available()})]}),K(n,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>V(!0),disabled:F.isPending,children:[F.isPending?J(k,{className:"h-3.5 w-3.5 animate-spin"}):J(l,{className:"h-3.5 w-3.5"}),W.quota_reset_usage()]})]})]}),K("div",{className:"space-y-1.5 pt-1",children:[J(jJ,{value:Math.min(100,Math.max(0,z.percent)),className:"h-2"}),K("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[K("span",{className:B?"font-bold text-destructive":"text-foreground",children:[a(Z.resource,z.consumed)," /"," ",a(Z.resource,Z.limit)," ",y?.unit]}),K("span",{className:B?"font-bold text-destructive":"text-muted-foreground",children:[z.percent,"%"]})]})]}),K("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[z.isWindowActive&&z.periodEnd?K("span",{className:"flex items-center gap-1 text-primary",children:[J(ZJ,{className:"h-3 w-3"}),W.quota_refreshes_in({time:EJ(z.periodEnd,H)})]}):K("span",{className:"flex items-center gap-1",children:[J(GJ,{className:"h-3 w-3 text-primary"}),W.quota_available()]}),K("span",{children:[W.quota_remaining(),": ",a(Z.resource,z.remaining)," ",y?.unit]})]})]}),J(TJ,{open:Q,onOpenChange:V,children:K(IJ,{children:[K(bJ,{children:[J(nJ,{children:W.quota_reset_usage()}),J(uJ,{children:W.quota_reset_usage_confirm({target:U})})]}),K(gJ,{children:[J(iJ,{disabled:F.isPending,children:W.cancel()}),K(cJ,{onClick:(X)=>{X.preventDefault(),F.mutate()},disabled:F.isPending,children:[F.isPending&&J(k,{className:"mr-2 h-4 w-4 animate-spin"}),W.confirm()]})]})]})})]})}function zK({teamId:Y,rule:Z}){let[z,G]=d.useState(!1),[Q,V]=d.useState(""),H=QJ[Z.resource],f=H?.icon||x,{data:y,isLoading:P,isError:B}=D({queryKey:["teams",Y,"quotas",Z.id,"records"],queryFn:async()=>{let X=await M.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:Y,id:Z.id}});if(!X.ok)throw Error(W.failed_to_load_quota_usage());return await X.json()},enabled:z,refetchInterval:z?1e4:!1}),U=y?.records??[],F=U.filter((X)=>{if(!Q.trim())return!0;let w=Q.toLowerCase();return X.user?.name.toLowerCase().includes(w)||X.user?.email.toLowerCase().includes(w)});return K(RJ,{open:z,onOpenChange:G,className:"rounded-xl border border-border/70",children:[J(fJ,{asChild:!0,children:K("button",{type:"button","aria-label":z?W.quota_collapse_rule():W.quota_expand_rule(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[K("div",{className:"flex min-w-0 items-start gap-3",children:[J("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:J(f,{className:"h-5 w-5"})}),K("div",{className:"min-w-0",children:[K("div",{className:"flex flex-wrap items-center gap-2",children:[J("span",{className:"font-semibold text-foreground",children:H?.label()||Z.resource}),!Z.enabled&&J(O,{variant:"secondary",children:W.quota_disabled()})]}),K("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[J($K,{rule:Z}),K(O,{variant:"outline",className:"gap-1 text-xs",children:[J(ZJ,{className:"h-3 w-3"}),a(Z.resource,Z.limit)," ",H?.unit," /"," ",dJ(Z.period)]}),J(ZK,{rule:Z})]})]})]}),J(AJ,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${z?"rotate-180":""}`})]})}),J(DJ,{children:K("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[Z.scopeMode!=="all_members"&&U.length>3&&K("div",{className:"relative",children:[J($J,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),J(XJ,{value:Q,onChange:(X)=>V(X.target.value),placeholder:W.quota_search_members(),className:"h-9 pl-9 text-sm"})]}),P?J("div",{className:"flex justify-center py-10",children:J(k,{className:"h-7 w-7 animate-spin text-primary"})}):B?J("div",{className:"py-8 text-center text-sm text-destructive",children:W.failed_to_load_quota_usage()}):F.length===0?J("div",{className:"py-8 text-center text-sm text-muted-foreground",children:W.quota_no_usage_records()}):F.map((X,w)=>J(XK,{teamId:Y,rule:Z,record:X},X.id||X.userId||`record-${w}`))]})})]})}function xJ({teamId:Y}){let{data:Z,isLoading:z,isError:G}=D({queryKey:["teams",Y,"quotas"],queryFn:async()=>{let V=await M.api.teams[":teamId"].quotas.$get({param:{teamId:Y}});if(!V.ok)throw Error(W.failed_load_settings());return await V.json()},enabled:!!Y}),Q=Z?.rules??[];return K(v,{className:"border-border/60 shadow-sm",children:[K(T,{children:[K(I,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[J(x,{className:"h-5 w-5 text-primary"}),W.quotas()]}),J(b,{children:W.quota_dashboard_description()})]}),J(g,{children:z?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):G?J("div",{className:"py-10 text-center text-sm text-destructive",children:W.failed_load_settings()}):Q.length===0?K("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[J(x,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),J("p",{className:"text-base font-medium text-foreground",children:W.no_quotas_title()}),J("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:W.no_quotas_description()})]}):J("div",{className:"space-y-3",children:Q.map((V)=>J(zK,{teamId:Y,rule:V},V.id))})})]})}var m=o(t(),1);var _K=Object.values(mJ);function oJ({teamId:Y}){let[Z,z]=m.useState([]),[G,Q]=m.useState([]),[V,H]=m.useState(""),{ref:f,inView:y}=JJ(),{data:P}=D({queryKey:["teams",Y,"members"],queryFn:async()=>{let $=await M.api.teams[":teamId"].members.$get({param:{teamId:Y},query:{}});if(!$.ok)return[];return await $.json()},enabled:!!Y}),B=P||[],{data:U,isLoading:F,isError:X,fetchNextPage:w,hasNextPage:_,isFetchingNextPage:L}=e({queryKey:["teams",Y,"audit-logs",Z,G,V],queryFn:async({pageParam:$})=>{let N=await M.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:Y},query:{first:"20",after:$?String($):void 0,actions:Z.length>0?Z:void 0,userIds:G.length>0?G:void 0,itemId:V.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:($)=>$.pageInfo.endCursor||void 0,enabled:!!Y});m.useEffect(()=>{if(y&&_&&!L)w()},[y,_,L,w]);let p=U?.pages.flatMap(($)=>$.nodes)||[],PJ=U?.pages[0]?.total??0,eJ=($)=>{z((N)=>N.includes($)?N.filter((h)=>h!==$):[...N,$])},JK=($)=>{Q((N)=>N.includes($)?N.filter((h)=>h!==$):[...N,$])},KK=($)=>{if($.includes("delete")||$.includes("remove")||$.includes("revoke"))return J(O,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:$});if($.includes("create")||$.includes("add"))return J(O,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:$});if($.includes("update")||$.includes("reparent")||$.includes("copy"))return J(O,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:$});return J(O,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:$})},WK=new Map(B.map(($)=>[$.userId||$.id,$]));return J("div",{className:"space-y-6",children:K(v,{className:"border border-border/50 shadow-xs",children:[K(T,{className:"pb-4",children:[K("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[K("div",{children:[K(I,{className:"text-xl font-bold flex items-center gap-2",children:[J(l,{className:"h-5 w-5 text-primary"}),W.audit_logs()]}),J(b,{className:"mt-1",children:W.audit_logs_description()})]}),PJ>0&&K(O,{variant:"secondary",className:"w-fit text-xs font-normal",children:[PJ," ",W.audit_logs()]})]}),K("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[K(kJ,{children:[J(FJ,{asChild:!0,children:K(n,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[J(wJ,{className:"h-3.5 w-3.5"}),W.filter_by_action(),Z.length>0&&J(O,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:Z.length})]})}),K(MJ,{className:"w-64 p-2",align:"start",children:[J("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:W.select_actions()}),J("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:_K.map(($)=>K("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[J(HJ,{checked:Z.includes($),onCheckedChange:()=>eJ($)}),J("span",{className:"font-mono",children:$})]},$))}),Z.length>0&&J(n,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>z([]),children:"Clear Actions"})]})]}),K(kJ,{children:[J(FJ,{asChild:!0,children:K(n,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[J(wJ,{className:"h-3.5 w-3.5"}),W.filter_by_user(),G.length>0&&J(O,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:G.length})]})}),K(MJ,{className:"w-64 p-2",align:"start",children:[J("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:W.select_users()}),J("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:B.map(($)=>{let N=$.userId||$.user?.id||$.id,h=$.user?.name||$.name||N,zJ=$.user?.image||$.image;return K("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[J(HJ,{checked:G.includes(N),onCheckedChange:()=>JK(N)}),K(S,{className:"h-5 w-5",children:[J(C,{src:zJ||void 0}),J(A,{className:"text-[10px]",children:h.slice(0,2).toUpperCase()})]}),J("span",{className:"truncate",children:h})]},N)})}),G.length>0&&J(n,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>Q([]),children:"Clear Users"})]})]}),K("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[J($J,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),J(XJ,{type:"text",placeholder:W.search_item_id(),value:V,onChange:($)=>H($.target.value),className:"pl-8 pr-8 h-9 text-xs"}),V&&J("button",{onClick:()=>H(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:J(lJ,{className:"h-4 w-4"})})]}),(Z.length>0||G.length>0||V)&&J(n,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{z([]),Q([]),H("")},children:"Clear all"})]})]}),K(g,{className:"p-0",children:[F?J("div",{className:"flex h-64 items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):X?J("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):p.length===0?J("div",{className:"p-12 text-center text-sm text-muted-foreground",children:W.no_audit_logs()}):K(c,{children:[J(i,{children:K(R,{className:"hover:bg-transparent border-b border-border/50",children:[J(q,{className:"w-[180px] text-xs font-semibold",children:W.action()}),J(q,{className:"w-[200px] text-xs font-semibold",children:W.user()}),J(q,{className:"text-xs font-semibold",children:W.item_id()}),J(q,{className:"text-xs font-semibold",children:W.project_id()}),J(q,{className:"w-[160px] text-right text-xs font-semibold",children:W.timestamp()})]})}),J(j,{children:p.map(($)=>{let N=$.userId?WK.get($.userId):null,h=N?.user?.name||N?.name||$.userId||"System",zJ=N?.user?.image||N?.image;return K(R,{className:"hover:bg-muted/40 transition-colors",children:[J(E,{className:"py-3 font-medium",children:KK($.action)}),J(E,{className:"py-3",children:K("div",{className:"flex items-center gap-2",children:[K(S,{className:"h-6 w-6",children:[J(C,{src:zJ||void 0}),J(A,{className:"text-[10px]",children:h.slice(0,2).toUpperCase()})]}),J("span",{className:"text-xs font-medium text-foreground truncate max-w-[140px]",children:h})]})}),J(E,{className:"py-3 text-xs font-mono text-muted-foreground",children:$.itemId||"-"}),J(E,{className:"py-3 text-xs font-mono text-muted-foreground",children:$.projectId||"-"}),J(E,{className:"py-3 text-right text-xs text-muted-foreground",children:KJ($.createdAt)})]},$.id)})})]}),J("div",{ref:f,className:"py-4 flex justify-center",children:L&&J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}function VK(){let{teamId:Y}=GK.useParams(),[Z,z]=sJ.useState("audit-logs"),{data:G,isLoading:Q}=D({queryKey:["teams",Y,"me"],queryFn:async()=>{let V=await M.api.teams[":teamId"].me.$get({param:{teamId:Y}});if(!V.ok)throw Error("Failed to fetch me");return await V.json()},enabled:!!Y});if(Q)return J("div",{className:"flex h-screen items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(G?.role?.toLowerCase()!=="owner")return K("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[J(aJ,{className:"h-12 w-12 text-destructive mb-4"}),J("h2",{className:"text-xl font-bold tracking-tight mb-2",children:W.access_denied()}),J("p",{className:"text-sm text-muted-foreground max-w-md",children:W.only_owner_dashboard()})]});return J("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:K("div",{className:"flex flex-col md:flex-row h-full",children:[J("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:K("nav",{className:"p-4 space-y-1 mt-4",children:[J("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:W.dashboard()}),J("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:W.team_category()}),K("button",{onClick:()=>z("audit-logs"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="audit-logs"?"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:[J(l,{className:"w-5 h-5"}),W.audit_logs(),Z==="audit-logs"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),K("button",{onClick:()=>z("quotas"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="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:[J(x,{className:"w-5 h-5"}),W.quotas(),Z==="quotas"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),J("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:W.ai()}),K("button",{onClick:()=>z("ai-usage"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="ai-usage"?"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:[J(rJ,{className:"w-5 h-5"}),W.usage(),Z==="ai-usage"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),K("button",{onClick:()=>z("ai-sessions"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="ai-sessions"?"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:[J(r,{className:"w-5 h-5"}),W.sessions(),Z==="ai-sessions"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),J("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:K("div",{className:"max-w-6xl mx-auto space-y-8",children:[Z==="audit-logs"&&J(oJ,{teamId:Y}),Z==="ai-usage"&&J(UJ,{teamId:Y}),Z==="ai-sessions"&&J(yJ,{teamId:Y}),Z==="quotas"&&J(xJ,{teamId:Y})]})})]})})}var GK=tJ("/teams/$teamId/dashboard")({component:VK});export{GK as Route};
1
+ import{a as QJ,b as a,c as dJ}from"./chunk-s9sgkkjp.js";import{i as c,j as i,k as j,l as R,m as q,n as E}from"./chunk-xyzmew7g.js";import{_ as LJ}from"./chunk-44370df5.js";import{$ as _J,aa as u}from"./chunk-srs9jq8f.js";import{ve as jJ}from"./chunk-7sf0gbbm.js";import{$e as v,af as T,bf as I,cf as b,df as g}from"./chunk-be9a7kc6.js";import{Mf as O}from"./chunk-j10gz94w.js";import{$f as mJ,Nf as kJ,Of as FJ,Pf as MJ,dg as HJ}from"./chunk-ktvmxqfg.js";import"./chunk-d6d1j7qq.js";import"./chunk-7g2k89gq.js";import"./chunk-1vs91e4q.js";import{kh as JJ}from"./chunk-16txy3r1.js";import"./chunk-bkbqvxfv.js";import{Ih as KJ,Kh as EJ}from"./chunk-rfsbzd39.js";import"./chunk-2sc2jxd3.js";import{di as S,ei as C,fi as A}from"./chunk-2f35h4fn.js";import{Bi as CJ,Ci as e,Ii as M,Ji as TJ,Ki as IJ,Li as bJ,Mi as gJ,Ni as nJ,Oi as uJ,Pi as cJ,Qi as iJ,Yi as qJ,wi as SJ,yi as BJ,zi as D}from"./chunk-s503pcvb.js";import{$i as t,$k as r,Bj as wJ,Dj as k,Ll as pJ,Mj as l,Nl as vJ,Ol as NJ,Sl as lJ,Wl as s,aj as hJ,bj as J,bk as AJ,bm as YJ,cj as K,jk as ZJ,mj as tJ,qm as n,rl as $J,tj as rJ,tm as W,um as XJ,vj as GJ,vl as aJ,yk as x}from"./chunk-w9p59ahz.js";import{rn as o}from"./chunk-txkmks1h.js";var sJ=o(t(),1);var VJ=o(t(),1);function UJ({teamId:Y}){let[Z,z]=VJ.useState("team"),[G,Q]=VJ.useState("1h"),{data:V,isLoading:H}=D({queryKey:["teams",Y,"ai-usage",G,"team"],queryFn:async()=>{let _=await M.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:Y},query:{timeframe:G}});if(!_.ok)throw Error("Failed to fetch team AI usage");return await _.json()},enabled:!!Y&&Z==="team"}),{data:f,isLoading:y}=D({queryKey:["teams",Y,"members"],queryFn:async()=>{let _=await M.api.teams[":teamId"].members.$get({param:{teamId:Y},query:{}});if(!_.ok)throw Error("Failed to fetch team members");return await _.json()},enabled:!!Y&&Z==="members"}),P=BJ({queries:(f||[]).map((_)=>({queryKey:["teams",Y,"ai-usage",G,_.id],queryFn:async()=>{let L=await M.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:Y},query:{timeframe:G,userId:_.id}});if(!L.ok)throw Error(`Failed to fetch AI usage for member ${_.id}`);return await L.json()},enabled:!!Y&&Z==="members"}))}),B=y||P.some((_)=>_.isLoading),U=(_)=>{if(!_)return"U";let L=_.split(" ");if(L.length>1)return`${L[0][0]}${L[L.length-1][0]}`.toUpperCase();return _.substring(0,2).toUpperCase()},F=(_)=>{if(!_)return"";switch(_.toLowerCase()){case"owner":return W.owner();case"editor":return W.editor();case"reviewer":return W.reviewer();default:return _}},X=(_)=>(_??0).toLocaleString(),w=(_)=>`$${(_??0).toFixed(6)}`;return K(v,{className:"border-border/60 shadow-sm",children:[K(T,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[K("div",{children:[J(I,{className:"text-xl font-semibold tracking-tight",children:W.ai_usage()}),J(b,{className:"text-sm text-muted-foreground mt-1",children:W.ai_usage_description()})]}),K("div",{className:"flex flex-wrap items-center gap-3",children:[K(_J,{type:"single",value:Z,onValueChange:(_)=>{if(_)z(_)},className:"border rounded-lg p-1 bg-muted/30",children:[J(u,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:W.team_view()}),J(u,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:W.members_view()})]}),K(_J,{type:"single",value:G,onValueChange:(_)=>{if(_)Q(_)},className:"border rounded-lg p-1 bg-muted/30",children:[J(u,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),J(u,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),J(u,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),J(u,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),J(g,{children:Z==="team"?H?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J("div",{className:"rounded-md border",children:K(c,{children:[J(i,{children:K(R,{children:[J(q,{children:W.team()}),J(q,{className:"text-right",children:W.input_tokens()}),J(q,{className:"text-right",children:W.output_tokens()}),J(q,{className:"text-right",children:W.cache_read_tokens()}),J(q,{className:"text-right",children:W.total_tokens()}),J(q,{className:"text-right",children:W.cost()})]})}),J(j,{children:K(R,{children:[J(E,{className:"font-medium",children:W.team()}),J(E,{className:"text-right",children:X(V?.team?.inputTokens)}),J(E,{className:"text-right",children:X(V?.team?.outputTokens)}),J(E,{className:"text-right",children:X(V?.team?.cacheReadTokens)}),J(E,{className:"text-right font-medium",children:X(V?.team?.totalTokens)}),J(E,{className:"text-right font-medium",children:w(V?.team?.cost)})]})})]})}):B?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J("div",{className:"rounded-md border",children:K(c,{children:[J(i,{children:K(R,{children:[J(q,{children:W.members()}),J(q,{children:W.role()}),J(q,{className:"text-right",children:W.input_tokens()}),J(q,{className:"text-right",children:W.output_tokens()}),J(q,{className:"text-right",children:W.cache_read_tokens()}),J(q,{className:"text-right",children:W.total_tokens()}),J(q,{className:"text-right",children:W.cost()})]})}),J(j,{children:(f||[]).map((_,L)=>{let p=P[L]?.data?.member;return K(R,{children:[J(E,{children:K("div",{className:"flex items-center gap-3",children:[K(S,{className:"h-8 w-8 rounded-full",children:[_.image&&J(C,{src:_.image,alt:_.name,className:"object-cover"}),J(A,{className:"bg-primary/20 text-xs",children:U(_.name)})]}),K("div",{className:"flex flex-col",children:[J("span",{className:"text-sm font-medium leading-none",children:_.name}),J("span",{className:"text-xs text-muted-foreground mt-0.5",children:_.email})]})]})}),J(E,{className:"text-xs text-muted-foreground",children:F(_.role)}),J(E,{className:"text-right",children:X(p?.inputTokens)}),J(E,{className:"text-right",children:X(p?.outputTokens)}),J(E,{className:"text-right",children:X(p?.cacheReadTokens)}),J(E,{className:"text-right font-medium",children:X(p?.totalTokens)}),J(E,{className:"text-right font-medium",children:w(p?.cost)})]},_.id)})})]})})})]})}var WJ=o(t(),1);function yJ({teamId:Y}){let[Z,z]=WJ.useState(null),{ref:G,inView:Q}=JJ(),{data:V,isLoading:H,isError:f,fetchNextPage:y,hasNextPage:P,isFetchingNextPage:B}=e({queryKey:["teams",Y,"agent-sessions"],queryFn:async({pageParam:X})=>{let w=await M.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:Y},query:{first:"20",after:X?String(X):void 0}});if(!w.ok)throw Error("Failed to fetch agent sessions");return await w.json()},initialPageParam:"",getNextPageParam:(X)=>X.pageInfo.cursor||void 0,enabled:!!Y});WJ.useEffect(()=>{if(Q&&P&&!B)y()},[Q,P,B,y]);let U=V?.pages.flatMap((X)=>X.data).filter((X)=>X.id!=="pending")||[],F=(X)=>{switch(X){case"comment":return J(O,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:W.session_type_comment()});case"chat":return J(O,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:W.session_type_chat()});case"naming":return J(O,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:W.session_type_naming()});default:return J(O,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:X})}};return K("div",{className:"space-y-6",children:[K(v,{className:"border border-border/50 shadow-xs",children:[J(T,{className:"pb-4",children:J("div",{className:"flex items-center justify-between",children:K("div",{children:[K(I,{className:"text-xl font-bold flex items-center gap-2",children:[J(r,{className:"w-5 h-5 text-violet-500"}),W.sessions()]}),J(b,{className:"mt-1 text-sm text-muted-foreground",children:W.sessions_description()})]})})}),J(g,{children:H?J("div",{className:"flex h-64 items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):f?J("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):U.length===0?K("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[J(r,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),J("p",{className:"text-base font-medium",children:W.no_sessions_found()})]}):K("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[K(c,{children:[J(i,{className:"bg-muted/40",children:K(R,{children:[J(q,{children:W.session_name()}),J(q,{children:W.creator()}),J(q,{children:W.session_type()}),J(q,{className:"text-right",children:W.create_time()})]})}),J(j,{children:U.map((X)=>K(R,{onClick:()=>z(X.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[J(E,{className:"font-medium",children:K("div",{className:"flex flex-col",children:[J("span",{className:"text-sm font-semibold text-foreground",children:X.name||W.untitled_session()}),J("span",{className:"text-xs font-mono text-muted-foreground/70",children:X.id})]})}),J(E,{children:K("div",{className:"flex items-center gap-2",children:[K(S,{className:"h-6 w-6",children:[J(C,{src:X.creator?.image||void 0}),J(A,{className:"text-[10px]",children:X.creator?.name?.[0]?.toUpperCase()||"?"})]}),J("span",{className:"text-sm text-foreground/90",children:X.creator?.name||"System / Agent"})]})}),J(E,{children:F(X.type)}),J(E,{className:"text-right text-xs text-muted-foreground",children:KJ(X.createdAt)})]},X.id))})]}),J("div",{ref:G,className:"py-4 flex justify-center",children:B&&J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),J(LJ,{sessionId:Z,open:!!Z,onOpenChange:(X)=>{if(!X)z(null)}})]})}var d=o(t(),1);function RJ({...Y}){return J(YJ.Root,{"data-slot":"collapsible",...Y})}function fJ({...Y}){return J(YJ.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...Y})}function DJ({...Y}){return J(YJ.CollapsibleContent,{"data-slot":"collapsible-content",...Y})}function OJ(Y){switch(Y.toLowerCase()){case"owner":return W.owner();case"editor":return W.editor();case"reviewer":return W.reviewer();default:return Y}}function YK(Y,Z){if(typeof Y==="object"&&Y!==null&&"message"in Y){let z=Y.message;if(typeof z==="string")return z}return Z}function ZK({rule:Y}){let Z=Y.resourceData??{};if(Y.resource==="agent_mcp_call_count")return J("span",{children:W.quota_target_server({value:String(Z.id??"")})});if(Y.resource==="agent_bash_call_count")return J("span",{children:W.quota_target_match({value:String(Z.match??"*")})});if(Y.resource==="agent_tool_call_count")return J("span",{children:W.quota_target_tool({value:String(Z.name??Z.toolName??"*")})});return null}function $K({rule:Y}){if(Y.scopeMode==="all_members")return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(NJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_all_members(),Y.role?` (${OJ(Y.role)})`:` (${W.quota_scope_team()})`]})]});if(Y.scopeMode==="each_member")return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(vJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_each_member(),Y.role?` (${OJ(Y.role)})`:` (${W.quota_scope_team()})`]})]});return K(O,{variant:"secondary",className:"gap-1 text-xs",children:[J(pJ,{className:"h-3 w-3"}),K("span",{children:[W.quota_scope_mode_selected_members()," (",Y.userIds?.length||0,")"]})]})}function XK({teamId:Y,rule:Z,record:z}){let G=SJ(),[Q,V]=d.useState(!1),[H,f]=d.useState(()=>new Date),y=QJ[Z.resource],P=Z.scopeMode==="all_members",B=z.percent>=100,U=P?Z.role?`${W.quota_role_shared_pool()}: ${OJ(Z.role)}`:W.quota_team_shared_pool():z.user?.name||z.userId||W.unknown();d.useEffect(()=>{if(!z.isWindowActive||!z.periodEnd)return;let X=window.setInterval(()=>f(new Date),60000);return()=>window.clearInterval(X)},[z.isWindowActive,z.periodEnd]);let F=CJ({mutationFn:async()=>{let X=await M.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:Y,id:Z.id},json:{userId:z.userId??null}});if(!X.ok){let w=await X.json().catch(()=>null);throw Error(YK(w,W.failed_to_reset_quota()))}return await X.json()},onSuccess:()=>{G.invalidateQueries({queryKey:["teams",Y,"quotas",Z.id,"records"]}),G.invalidateQueries({queryKey:["teams",Y,"quotas"]}),V(!1),qJ.success(W.quota_reset_successfully())},onError:(X)=>{let w=X instanceof Error?X.message:W.failed_to_reset_quota();V(!1),qJ.error(w)}});return K(hJ,{children:[K("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[K("div",{className:"flex items-center justify-between gap-3",children:[K("div",{className:"flex min-w-0 items-center gap-3",children:[P?J("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:J(NJ,{className:"h-5 w-5"})}):K(S,{className:"h-9 w-9 shrink-0 border border-border/50",children:[J(C,{src:z.user?.image||void 0}),J(A,{className:"text-xs font-semibold",children:z.user?.name?.[0]?.toUpperCase()||"U"})]}),K("div",{className:"min-w-0",children:[J("div",{className:"truncate text-sm font-semibold text-foreground",children:U}),!P&&z.user?.email&&J("div",{className:"truncate text-xs text-muted-foreground",children:z.user.email})]})]}),K("div",{className:"flex shrink-0 items-center gap-2",children:[z.isWindowActive&&z.periodEnd?K(O,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[J(ZJ,{className:"h-3 w-3"}),J("span",{children:W.quota_refreshes_in({time:EJ(z.periodEnd,H)})})]}):K(O,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[J(GJ,{className:"h-3 w-3 text-primary"}),J("span",{children:W.quota_available()})]}),K(n,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>V(!0),disabled:F.isPending,children:[F.isPending?J(k,{className:"h-3.5 w-3.5 animate-spin"}):J(l,{className:"h-3.5 w-3.5"}),W.quota_reset_usage()]})]})]}),K("div",{className:"space-y-1.5 pt-1",children:[J(jJ,{value:Math.min(100,Math.max(0,z.percent)),className:"h-2"}),K("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[K("span",{className:B?"font-bold text-destructive":"text-foreground",children:[a(Z.resource,z.consumed)," /"," ",a(Z.resource,Z.limit)," ",y?.unit]}),K("span",{className:B?"font-bold text-destructive":"text-muted-foreground",children:[z.percent,"%"]})]})]}),K("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[z.isWindowActive&&z.periodEnd?K("span",{className:"flex items-center gap-1 text-primary",children:[J(ZJ,{className:"h-3 w-3"}),W.quota_refreshes_in({time:EJ(z.periodEnd,H)})]}):K("span",{className:"flex items-center gap-1",children:[J(GJ,{className:"h-3 w-3 text-primary"}),W.quota_available()]}),K("span",{children:[W.quota_remaining(),": ",a(Z.resource,z.remaining)," ",y?.unit]})]})]}),J(TJ,{open:Q,onOpenChange:V,children:K(IJ,{children:[K(bJ,{children:[J(nJ,{children:W.quota_reset_usage()}),J(uJ,{children:W.quota_reset_usage_confirm({target:U})})]}),K(gJ,{children:[J(iJ,{disabled:F.isPending,children:W.cancel()}),K(cJ,{onClick:(X)=>{X.preventDefault(),F.mutate()},disabled:F.isPending,children:[F.isPending&&J(k,{className:"mr-2 h-4 w-4 animate-spin"}),W.confirm()]})]})]})})]})}function zK({teamId:Y,rule:Z}){let[z,G]=d.useState(!1),[Q,V]=d.useState(""),H=QJ[Z.resource],f=H?.icon||x,{data:y,isLoading:P,isError:B}=D({queryKey:["teams",Y,"quotas",Z.id,"records"],queryFn:async()=>{let X=await M.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:Y,id:Z.id}});if(!X.ok)throw Error(W.failed_to_load_quota_usage());return await X.json()},enabled:z,refetchInterval:z?1e4:!1}),U=y?.records??[],F=U.filter((X)=>{if(!Q.trim())return!0;let w=Q.toLowerCase();return X.user?.name.toLowerCase().includes(w)||X.user?.email.toLowerCase().includes(w)});return K(RJ,{open:z,onOpenChange:G,className:"rounded-xl border border-border/70",children:[J(fJ,{asChild:!0,children:K("button",{type:"button","aria-label":z?W.quota_collapse_rule():W.quota_expand_rule(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[K("div",{className:"flex min-w-0 items-start gap-3",children:[J("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:J(f,{className:"h-5 w-5"})}),K("div",{className:"min-w-0",children:[K("div",{className:"flex flex-wrap items-center gap-2",children:[J("span",{className:"font-semibold text-foreground",children:H?.label()||Z.resource}),!Z.enabled&&J(O,{variant:"secondary",children:W.quota_disabled()})]}),K("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[J($K,{rule:Z}),K(O,{variant:"outline",className:"gap-1 text-xs",children:[J(ZJ,{className:"h-3 w-3"}),a(Z.resource,Z.limit)," ",H?.unit," /"," ",dJ(Z.period)]}),J(ZK,{rule:Z})]})]})]}),J(AJ,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${z?"rotate-180":""}`})]})}),J(DJ,{children:K("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[Z.scopeMode!=="all_members"&&U.length>3&&K("div",{className:"relative",children:[J($J,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),J(XJ,{value:Q,onChange:(X)=>V(X.target.value),placeholder:W.quota_search_members(),className:"h-9 pl-9 text-sm"})]}),P?J("div",{className:"flex justify-center py-10",children:J(k,{className:"h-7 w-7 animate-spin text-primary"})}):B?J("div",{className:"py-8 text-center text-sm text-destructive",children:W.failed_to_load_quota_usage()}):F.length===0?J("div",{className:"py-8 text-center text-sm text-muted-foreground",children:W.quota_no_usage_records()}):F.map((X,w)=>J(XK,{teamId:Y,rule:Z,record:X},X.id||X.userId||`record-${w}`))]})})]})}function xJ({teamId:Y}){let{data:Z,isLoading:z,isError:G}=D({queryKey:["teams",Y,"quotas"],queryFn:async()=>{let V=await M.api.teams[":teamId"].quotas.$get({param:{teamId:Y}});if(!V.ok)throw Error(W.failed_load_settings());return await V.json()},enabled:!!Y}),Q=Z?.rules??[];return K(v,{className:"border-border/60 shadow-sm",children:[K(T,{children:[K(I,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[J(x,{className:"h-5 w-5 text-primary"}),W.quotas()]}),J(b,{children:W.quota_dashboard_description()})]}),J(g,{children:z?J("div",{className:"flex h-48 items-center justify-center",children:J(k,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):G?J("div",{className:"py-10 text-center text-sm text-destructive",children:W.failed_load_settings()}):Q.length===0?K("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[J(x,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),J("p",{className:"text-base font-medium text-foreground",children:W.no_quotas_title()}),J("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:W.no_quotas_description()})]}):J("div",{className:"space-y-3",children:Q.map((V)=>J(zK,{teamId:Y,rule:V},V.id))})})]})}var m=o(t(),1);var _K=Object.values(mJ);function oJ({teamId:Y}){let[Z,z]=m.useState([]),[G,Q]=m.useState([]),[V,H]=m.useState(""),{ref:f,inView:y}=JJ(),{data:P}=D({queryKey:["teams",Y,"members"],queryFn:async()=>{let $=await M.api.teams[":teamId"].members.$get({param:{teamId:Y},query:{}});if(!$.ok)return[];return await $.json()},enabled:!!Y}),B=P||[],{data:U,isLoading:F,isError:X,fetchNextPage:w,hasNextPage:_,isFetchingNextPage:L}=e({queryKey:["teams",Y,"audit-logs",Z,G,V],queryFn:async({pageParam:$})=>{let N=await M.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:Y},query:{first:"20",after:$?String($):void 0,actions:Z.length>0?Z:void 0,userIds:G.length>0?G:void 0,itemId:V.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:($)=>$.pageInfo.endCursor||void 0,enabled:!!Y});m.useEffect(()=>{if(y&&_&&!L)w()},[y,_,L,w]);let p=U?.pages.flatMap(($)=>$.nodes)||[],PJ=U?.pages[0]?.total??0,eJ=($)=>{z((N)=>N.includes($)?N.filter((h)=>h!==$):[...N,$])},JK=($)=>{Q((N)=>N.includes($)?N.filter((h)=>h!==$):[...N,$])},KK=($)=>{if($.includes("delete")||$.includes("remove")||$.includes("revoke"))return J(O,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:$});if($.includes("create")||$.includes("add"))return J(O,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:$});if($.includes("update")||$.includes("reparent")||$.includes("copy"))return J(O,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:$});return J(O,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:$})},WK=new Map(B.map(($)=>[$.userId||$.id,$]));return J("div",{className:"space-y-6",children:K(v,{className:"border border-border/50 shadow-xs",children:[K(T,{className:"pb-4",children:[K("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[K("div",{children:[K(I,{className:"text-xl font-bold flex items-center gap-2",children:[J(l,{className:"h-5 w-5 text-primary"}),W.audit_logs()]}),J(b,{className:"mt-1",children:W.audit_logs_description()})]}),PJ>0&&K(O,{variant:"secondary",className:"w-fit text-xs font-normal",children:[PJ," ",W.audit_logs()]})]}),K("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[K(kJ,{children:[J(FJ,{asChild:!0,children:K(n,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[J(wJ,{className:"h-3.5 w-3.5"}),W.filter_by_action(),Z.length>0&&J(O,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:Z.length})]})}),K(MJ,{className:"w-64 p-2",align:"start",children:[J("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:W.select_actions()}),J("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:_K.map(($)=>K("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[J(HJ,{checked:Z.includes($),onCheckedChange:()=>eJ($)}),J("span",{className:"font-mono",children:$})]},$))}),Z.length>0&&J(n,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>z([]),children:"Clear Actions"})]})]}),K(kJ,{children:[J(FJ,{asChild:!0,children:K(n,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[J(wJ,{className:"h-3.5 w-3.5"}),W.filter_by_user(),G.length>0&&J(O,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:G.length})]})}),K(MJ,{className:"w-64 p-2",align:"start",children:[J("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:W.select_users()}),J("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:B.map(($)=>{let N=$.userId||$.user?.id||$.id,h=$.user?.name||$.name||N,zJ=$.user?.image||$.image;return K("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[J(HJ,{checked:G.includes(N),onCheckedChange:()=>JK(N)}),K(S,{className:"h-5 w-5",children:[J(C,{src:zJ||void 0}),J(A,{className:"text-[10px]",children:h.slice(0,2).toUpperCase()})]}),J("span",{className:"truncate",children:h})]},N)})}),G.length>0&&J(n,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>Q([]),children:"Clear Users"})]})]}),K("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[J($J,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),J(XJ,{type:"text",placeholder:W.search_item_id(),value:V,onChange:($)=>H($.target.value),className:"pl-8 pr-8 h-9 text-xs"}),V&&J("button",{onClick:()=>H(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:J(lJ,{className:"h-4 w-4"})})]}),(Z.length>0||G.length>0||V)&&J(n,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{z([]),Q([]),H("")},children:"Clear all"})]})]}),K(g,{className:"p-0",children:[F?J("div",{className:"flex h-64 items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):X?J("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):p.length===0?J("div",{className:"p-12 text-center text-sm text-muted-foreground",children:W.no_audit_logs()}):K(c,{children:[J(i,{children:K(R,{className:"hover:bg-transparent border-b border-border/50",children:[J(q,{className:"w-[180px] text-xs font-semibold",children:W.action()}),J(q,{className:"w-[200px] text-xs font-semibold",children:W.user()}),J(q,{className:"text-xs font-semibold",children:W.item_id()}),J(q,{className:"text-xs font-semibold",children:W.project_id()}),J(q,{className:"w-[160px] text-right text-xs font-semibold",children:W.timestamp()})]})}),J(j,{children:p.map(($)=>{let N=$.userId?WK.get($.userId):null,h=N?.user?.name||N?.name||$.userId||"System",zJ=N?.user?.image||N?.image;return K(R,{className:"hover:bg-muted/40 transition-colors",children:[J(E,{className:"py-3 font-medium",children:KK($.action)}),J(E,{className:"py-3",children:K("div",{className:"flex items-center gap-2",children:[K(S,{className:"h-6 w-6",children:[J(C,{src:zJ||void 0}),J(A,{className:"text-[10px]",children:h.slice(0,2).toUpperCase()})]}),J("span",{className:"text-xs font-medium text-foreground truncate max-w-[140px]",children:h})]})}),J(E,{className:"py-3 text-xs font-mono text-muted-foreground",children:$.itemId||"-"}),J(E,{className:"py-3 text-xs font-mono text-muted-foreground",children:$.projectId||"-"}),J(E,{className:"py-3 text-right text-xs text-muted-foreground",children:KJ($.createdAt)})]},$.id)})})]}),J("div",{ref:f,className:"py-4 flex justify-center",children:L&&J(k,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}function VK(){let{teamId:Y}=GK.useParams(),[Z,z]=sJ.useState("audit-logs"),{data:G,isLoading:Q}=D({queryKey:["teams",Y,"me"],queryFn:async()=>{let V=await M.api.teams[":teamId"].me.$get({param:{teamId:Y}});if(!V.ok)throw Error("Failed to fetch me");return await V.json()},enabled:!!Y});if(Q)return J("div",{className:"flex h-screen items-center justify-center",children:J(k,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(G?.role?.toLowerCase()!=="owner")return K("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[J(aJ,{className:"h-12 w-12 text-destructive mb-4"}),J("h2",{className:"text-xl font-bold tracking-tight mb-2",children:W.access_denied()}),J("p",{className:"text-sm text-muted-foreground max-w-md",children:W.only_owner_dashboard()})]});return J("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:K("div",{className:"flex flex-col md:flex-row h-full",children:[J("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:K("nav",{className:"p-4 space-y-1 mt-4",children:[J("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:W.dashboard()}),J("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:W.team_category()}),K("button",{onClick:()=>z("audit-logs"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="audit-logs"?"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:[J(l,{className:"w-5 h-5"}),W.audit_logs(),Z==="audit-logs"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),K("button",{onClick:()=>z("quotas"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="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:[J(x,{className:"w-5 h-5"}),W.quotas(),Z==="quotas"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),J("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:W.ai()}),K("button",{onClick:()=>z("ai-usage"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="ai-usage"?"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:[J(rJ,{className:"w-5 h-5"}),W.usage(),Z==="ai-usage"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),K("button",{onClick:()=>z("ai-sessions"),className:s("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",Z==="ai-sessions"?"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:[J(r,{className:"w-5 h-5"}),W.sessions(),Z==="ai-sessions"&&J("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),J("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:K("div",{className:"max-w-6xl mx-auto space-y-8",children:[Z==="audit-logs"&&J(oJ,{teamId:Y}),Z==="ai-usage"&&J(UJ,{teamId:Y}),Z==="ai-sessions"&&J(yJ,{teamId:Y}),Z==="quotas"&&J(xJ,{teamId:Y})]})})]})})}var GK=tJ("/teams/$teamId/dashboard")({component:VK});export{GK as Route};
@@ -0,0 +1 @@
1
+ import{d as x}from"./chunk-cyvx7gcx.js";import"./chunk-a5b3aevg.js";import"./chunk-0qdzjcny.js";import"./chunk-2vc6pw8q.js";import"./chunk-09pe07g6.js";import"./chunk-082zg4nr.js";import"./chunk-44xtwvd7.js";import"./chunk-44370df5.js";import"./chunk-srs9jq8f.js";import"./chunk-4yhd7bmp.js";import"./chunk-mkb4dycy.js";import"./chunk-mgnxa0vy.js";import{ye as f}from"./chunk-q059y3wx.js";import"./chunk-zqvavykq.js";import"./chunk-xxtcmzcv.js";import"./chunk-pt51m9h1.js";import"./chunk-f4d3v0nc.js";import"./chunk-kejt7kcr.js";import"./chunk-2q7ew7yz.js";import"./chunk-j10gz94w.js";import"./chunk-ktvmxqfg.js";import"./chunk-k1f3gj25.js";import"./chunk-hmmzbyy1.js";import"./chunk-d6d1j7qq.js";import"./chunk-7g2k89gq.js";import{og as p}from"./chunk-7xcyn1ba.js";import"./chunk-785kxysj.js";import"./chunk-ygsbmfcy.js";import"./chunk-1vs91e4q.js";import"./chunk-16txy3r1.js";import"./chunk-90tbc5f4.js";import"./chunk-bkbqvxfv.js";import"./chunk-ts10cfmc.js";import"./chunk-rfsbzd39.js";import"./chunk-2sc2jxd3.js";import"./chunk-f32kxe6c.js";import"./chunk-2f35h4fn.js";import{si as h}from"./chunk-4k2d8w9w.js";import{Ai as r,Ii as c,zi as l}from"./chunk-s503pcvb.js";import"./chunk-axb1f1ae.js";import{$i as w,bj as a,mj as o}from"./chunk-w9p59ahz.js";import{rn as m}from"./chunk-txkmks1h.js";var g=m(w(),1);function v(){let{projectId:e}=d.useParams(),{teamId:s,ensureTeamIdForProject:n}=h();g.useEffect(()=>{n(e)},[e,n]);let{data:i}=r(f(e)),t=i?.rootFolder,{data:b}=l({queryKey:["folders",t],queryFn:()=>(async()=>{return await(await c.api.folders[":folderId"].$get({param:{folderId:t}})).json()})(),enabled:!!t});if(!s||!t||!b)return a(p,{});return a(x,{teamId:s,projectId:e,projectName:i.name??"",assetId:"recently-deleted",rootFolderId:t})}var d=o("/projects/$projectId/recently-deleted")({component:v});export{d as Route};
@@ -1,2 +1,2 @@
1
- import{Pl as r,Ul as o,Xi as e}from"./chunk-kqpzx5az.js";function u({className:a,size:t="default",...s}){return e(o.Root,{"data-slot":"avatar","data-size":t,className:r("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",a),...s})}function l({className:a,...t}){return e(o.Image,{"data-slot":"avatar-image",className:r("aspect-square size-full",a),...t})}function d({className:a,...t}){return e(o.Fallback,{"data-slot":"avatar-fallback",className:r("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",a),...t})}
2
- export{u as Zh,l as _h,d as $h};
1
+ import{$l as o,Wl as r,bj as e}from"./chunk-w9p59ahz.js";function u({className:a,size:t="default",...s}){return e(o.Root,{"data-slot":"avatar","data-size":t,className:r("group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6",a),...s})}function l({className:a,...t}){return e(o.Image,{"data-slot":"avatar-image",className:r("aspect-square size-full",a),...t})}function d({className:a,...t}){return e(o.Fallback,{"data-slot":"avatar-fallback",className:r("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",a),...t})}
2
+ export{u as di,l as ei,d as fi};
@@ -1,2 +1,2 @@
1
- import{Ee as A}from"./chunk-y0f4bc9f.js";import{Ci as z}from"./chunk-8nyve0cr.js";import{Xi as v,fj as w}from"./chunk-kqpzx5az.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/agentsmd")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
1
+ import{og as A}from"./chunk-7xcyn1ba.js";import{Ii as z}from"./chunk-s503pcvb.js";import{bj as v,lj as w}from"./chunk-w9p59ahz.js";var B=(b)=>({queryKey:["projects",b],queryFn:async()=>{let h=await z.api.projects[":projectId"].$get({param:{projectId:b}});if(!h.ok)throw Error("failed to fetch project");return await h.json()}}),H=w("/projects/$projectId/agentsmd")({loader:({context:{queryClient:b},params:{projectId:h}})=>b.ensureQueryData(B(h)),pendingComponent:()=>v(A,{})});
2
2
  export{B as Ae,H as Be};
@@ -1,2 +1,2 @@
1
- import{Hh as b,Ih as G,Nh as B0}from"./chunk-9cmvymm5.js";import{Ci as y,xi as $0,yi as w0}from"./chunk-8nyve0cr.js";var c=Symbol.for("immer-nothing"),v=Symbol.for("immer-draftable"),X=Symbol.for("immer-state");function Y($,...w){throw Error(`[Immer] minified error nr: ${$}. Full error at: https://bit.ly/3cXEKWf`)}var z=Object.getPrototypeOf;function x($){return!!$&&!!$[X]}function U($){if(!$)return!1;return o($)||Array.isArray($)||!!$[v]||!!$.constructor?.[v]||L($)||R($)}var q0=Object.prototype.constructor.toString(),n=new WeakMap;function o($){if(!$||typeof $!=="object")return!1;let w=Object.getPrototypeOf($);if(w===null||w===Object.prototype)return!0;let B=Object.hasOwnProperty.call(w,"constructor")&&w.constructor;if(B===Object)return!0;if(typeof B!=="function")return!1;let W=n.get(B);if(W===void 0)W=Function.toString.call(B),n.set(B,W);return W===q0}function C($,w,B=!0){if(F($)===0)(B?Reflect.ownKeys($):Object.keys($)).forEach((q)=>{w(q,$[q],$)});else $.forEach((W,q)=>w(q,W,$))}function F($){let w=$[X];return w?w.type_:Array.isArray($)?1:L($)?2:R($)?3:0}function D($,w){return F($)===2?$.has(w):Object.prototype.hasOwnProperty.call($,w)}function r($,w,B){let W=F($);if(W===2)$.set(w,B);else if(W===3)$.add(B);else $[w]=B}function Z0($,w){if($===w)return $!==0||1/$===1/w;else return $!==$&&w!==w}function L($){return $ instanceof Map}function R($){return $ instanceof Set}function K($){return $.copy_||$.base_}function P($,w){if(L($))return new Map($);if(R($))return new Set($);if(Array.isArray($))return Array.prototype.slice.call($);let B=o($);if(w===!0||w==="class_only"&&!B){let W=Object.getOwnPropertyDescriptors($);delete W[X];let q=Reflect.ownKeys(W);for(let Z=0;Z<q.length;Z++){let J=q[Z],Q=W[J];if(Q.writable===!1)Q.writable=!0,Q.configurable=!0;if(Q.get||Q.set)W[J]={configurable:!0,writable:!0,enumerable:Q.enumerable,value:$[J]}}return Object.create(z($),W)}else{let W=z($);if(W!==null&&B)return{...$};let q=Object.create(W);return Object.assign(q,$)}}function g($,w=!1){if(E($)||x($)||!U($))return $;if(F($)>1)Object.defineProperties($,{set:O,add:O,clear:O,delete:O});if(Object.freeze($),w)Object.values($).forEach((B)=>g(B,!0));return $}function J0(){Y(2)}var O={value:J0};function E($){if($===null||typeof $!=="object")return!0;return Object.isFrozen($)}var Q0={};function I($){let w=Q0[$];if(!w)Y(0,$);return w}var M;function p(){return M}function X0($,w){return{drafts_:[],parent_:$,immer_:w,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function h($,w){if(w)I("Patches"),$.patches_=[],$.inversePatches_=[],$.patchListener_=w}function k($){A($),$.drafts_.forEach(Y0),$.drafts_=null}function A($){if($===M)M=$.parent_}function i($){return M=X0(M,$)}function Y0($){let w=$[X];if(w.type_===0||w.type_===1)w.revoke_();else w.revoked_=!0}function u($,w){w.unfinalizedDrafts_=w.drafts_.length;let B=w.drafts_[0];if($!==void 0&&$!==B){if(B[X].modified_)k(w),Y(4);if(U($)){if($=V(w,$),!w.parent_)f(w,$)}if(w.patches_)I("Patches").generateReplacementPatches_(B[X].base_,$,w.patches_,w.inversePatches_)}else $=V(w,B,[]);if(k(w),w.patches_)w.patchListener_(w.patches_,w.inversePatches_);return $!==c?$:void 0}function V($,w,B){if(E(w))return w;let W=$.immer_.shouldUseStrictIteration(),q=w[X];if(!q)return C(w,(Z,J)=>l($,q,w,Z,J,B),W),w;if(q.scope_!==$)return w;if(!q.modified_)return f($,q.base_,!0),q.base_;if(!q.finalized_){q.finalized_=!0,q.scope_.unfinalizedDrafts_--;let Z=q.copy_,J=Z,Q=!1;if(q.type_===3)J=new Set(Z),Z.clear(),Q=!0;if(C(J,(H,N)=>l($,q,Z,H,N,B,Q),W),f($,Z,!1),B&&$.patches_)I("Patches").generatePatches_(q,B,$.patches_,$.inversePatches_)}return q.copy_}function l($,w,B,W,q,Z,J){if(q==null)return;if(typeof q!=="object"&&!J)return;let Q=E(q);if(Q&&!J)return;if(x(q)){let H=Z&&w&&w.type_!==3&&!D(w.assigned_,W)?Z.concat(W):void 0,N=V($,q,H);if(r(B,W,N),x(N))$.canAutoFreeze_=!1;else return}else if(J)B.add(q);if(U(q)&&!Q){if(!$.immer_.autoFreeze_&&$.unfinalizedDrafts_<1)return;if(w&&w.base_&&w.base_[W]===q&&Q)return;if(V($,q),(!w||!w.scope_.parent_)&&typeof W!=="symbol"&&(L(B)?B.has(W):Object.prototype.propertyIsEnumerable.call(B,W)))f($,q)}}function f($,w,B=!1){if(!$.parent_&&$.immer_.autoFreeze_&&$.canAutoFreeze_)g(w,B)}function G0($,w){let B=Array.isArray($),W={type_:B?1:0,scope_:w?w.scope_:p(),modified_:!1,finalized_:!1,assigned_:{},parent_:w,base_:$,draft_:null,copy_:null,revoke_:null,isManual_:!1},q=W,Z=d;if(B)q=[W],Z=m;let{revoke:J,proxy:Q}=Proxy.revocable(q,Z);return W.draft_=Q,W.revoke_=J,Q}var d={get($,w){if(w===X)return $;let B=K($);if(!D(B,w))return H0($,B,w);let W=B[w];if($.finalized_||!U(W))return W;if(W===_($.base_,w))return j($),$.copy_[w]=S(W,$);return W},has($,w){return w in K($)},ownKeys($){return Reflect.ownKeys(K($))},set($,w,B){let W=s(K($),w);if(W?.set)return W.set.call($.draft_,B),!0;if(!$.modified_){let q=_(K($),w),Z=q?.[X];if(Z&&Z.base_===B)return $.copy_[w]=B,$.assigned_[w]=!1,!0;if(Z0(B,q)&&(B!==void 0||D($.base_,w)))return!0;j($),T($)}if($.copy_[w]===B&&(B!==void 0||(w in $.copy_))||Number.isNaN(B)&&Number.isNaN($.copy_[w]))return!0;return $.copy_[w]=B,$.assigned_[w]=!0,!0},deleteProperty($,w){if(_($.base_,w)!==void 0||w in $.base_)$.assigned_[w]=!1,j($),T($);else delete $.assigned_[w];if($.copy_)delete $.copy_[w];return!0},getOwnPropertyDescriptor($,w){let B=K($),W=Reflect.getOwnPropertyDescriptor(B,w);if(!W)return W;return{writable:!0,configurable:$.type_!==1||w!=="length",enumerable:W.enumerable,value:B[w]}},defineProperty(){Y(11)},getPrototypeOf($){return z($.base_)},setPrototypeOf(){Y(12)}},m={};C(d,($,w)=>{m[$]=function(){return arguments[0]=arguments[0][0],w.apply(this,arguments)}});m.deleteProperty=function($,w){return m.set.call(this,$,w,void 0)};m.set=function($,w,B){return d.set.call(this,$[0],w,B,$[0])};function _($,w){let B=$[X];return(B?K(B):$)[w]}function H0($,w,B){let W=s(w,B);return W?"value"in W?W.value:W.get?.call($.draft_):void 0}function s($,w){if(!(w in $))return;let B=z($);while(B){let W=Object.getOwnPropertyDescriptor(B,w);if(W)return W;B=z(B)}return}function T($){if(!$.modified_){if($.modified_=!0,$.parent_)T($.parent_)}}function j($){if(!$.copy_)$.copy_=P($.base_,$.scope_.immer_.useStrictShallowCopy_)}var K0=class{constructor($){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(w,B,W)=>{if(typeof w==="function"&&typeof B!=="function"){let Z=B;B=w;let J=this;return function(H=Z,...N){return J.produce(H,(W0)=>B.call(this,W0,...N))}}if(typeof B!=="function")Y(6);if(W!==void 0&&typeof W!=="function")Y(7);let q;if(U(w)){let Z=i(this),J=S(w,void 0),Q=!0;try{q=B(J),Q=!1}finally{if(Q)k(Z);else A(Z)}return h(Z,W),u(q,Z)}else if(!w||typeof w!=="object"){if(q=B(w),q===void 0)q=w;if(q===c)q=void 0;if(this.autoFreeze_)g(q,!0);if(W){let Z=[],J=[];I("Patches").generateReplacementPatches_(w,q,Z,J),W(Z,J)}return q}else Y(1,w)},this.produceWithPatches=(w,B)=>{if(typeof w==="function")return(J,...Q)=>this.produceWithPatches(J,(H)=>w(H,...Q));let W,q;return[this.produce(w,B,(J,Q)=>{W=J,q=Q}),W,q]},typeof $?.autoFreeze==="boolean")this.setAutoFreeze($.autoFreeze);if(typeof $?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy($.useStrictShallowCopy);if(typeof $?.useStrictIteration==="boolean")this.setUseStrictIteration($.useStrictIteration)}createDraft($){if(!U($))Y(8);if(x($))$=U0($);let w=i(this),B=S($,void 0);return B[X].isManual_=!0,A(w),B}finishDraft($,w){let B=$&&$[X];if(!B||!B.isManual_)Y(9);let{scope_:W}=B;return h(W,w),u(void 0,W)}setAutoFreeze($){this.autoFreeze_=$}setUseStrictShallowCopy($){this.useStrictShallowCopy_=$}setUseStrictIteration($){this.useStrictIteration_=$}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches($,w){let B;for(B=w.length-1;B>=0;B--){let q=w[B];if(q.path.length===0&&q.op==="replace"){$=q.value;break}}if(B>-1)w=w.slice(B+1);let W=I("Patches").applyPatches_;if(x($))return W($,w);return this.produce($,(q)=>W(q,w))}};function S($,w){let B=L($)?I("MapSet").proxyMap_($,w):R($)?I("MapSet").proxySet_($,w):G0($,w);return(w?w.scope_:p()).drafts_.push(B),B}function U0($){if(!x($))Y(10,$);return a($)}function a($){if(!U($)||E($))return $;let w=$[X],B,W=!0;if(w){if(!w.modified_)return w.base_;w.finalized_=!0,B=P($,w.scope_.immer_.useStrictShallowCopy_),W=w.scope_.immer_.shouldUseStrictIteration()}else B=P($,!0);if(C(B,(q,Z)=>{r(B,q,a(Z))},W),w)w.finalized_=!1;return B}var I0=new K0,t=I0.produce;var N0=($)=>(w,B,W)=>{return W.setState=(q,Z,...J)=>{let Q=typeof q==="function"?t(q):q;return w(Q,Z,...J)},$(W.setState,B,W)},e=N0;var f0=$0()(w0(e(($,w)=>({members:[],loading:!1,fetchMembers:async(B,W,q)=>{if(!q&&w().loadedTeamId===B&&w().loadedWithAgents===W)return;$({loading:!0});try{let Z=await y.api.teams[":teamId"].members.$get({param:{teamId:B},query:{includeAgents:W?"true":"false"}});if(!Z.ok)throw Error("failed to fetch members");let J=await Z.json();$({members:J||[],loadedTeamId:B,loadedProjectId:void 0,loadedWithAgents:W,loading:!1})}catch{$({loading:!1})}},fetchProjectMembers:async(B,W,q)=>{if(!q&&w().loadedProjectId===B&&w().loadedWithAgents===W)return;$({loading:!0});try{let Z=await y.api.projects[":projectId"].members.$get({param:{projectId:B},query:{includeAgents:W?"true":"false"}});if(!Z.ok)throw Error("failed to fetch project members");let J=await Z.json();$({members:J||[],loadedProjectId:B,loadedTeamId:void 0,loadedWithAgents:W,loading:!1})}catch{$({loading:!1})}}}))));function R0($){if(!$||$<=0)return"0 B";let w=1000,B=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],W=Math.floor(Math.log($)/Math.log(w));if(W<0)W=0;if(W>=B.length)W=B.length-1;let q=$/Math.pow(w,W);if(W===0)return`${Math.round(q)} B`;let Z=parseFloat(q.toFixed(2));if(Z>=1000&&W<B.length-1)return parseFloat(($/Math.pow(w,W+1)).toFixed(2))+" "+B[W+1];return`${Z} ${B[W]}`}function D0($,w,B){let W=G($,B?.in);if(isNaN(w))return b(B?.in||$,NaN);if(!w)return W;let q=W.getDate(),Z=b(B?.in||$,W.getTime());Z.setMonth(W.getMonth()+w+1,0);let J=Z.getDate();if(q>=J)return Z;else return W.setFullYear(Z.getFullYear(),Z.getMonth(),q),W}function A0($,w){let B=G($,w?.in),W=B.getMonth();return B.setFullYear(B.getFullYear(),W+1,0),B.setHours(23,59,59,999),B}function g0($,w){return G($,w?.in).getMonth()}function b0($,w){return G($,w?.in).getFullYear()}function h0($,w){let[B,W]=B0($,w.start,w.end);return{start:B,end:W}}
2
- export{D0 as Ef,A0 as Ff,h0 as Gf,g0 as Hf,b0 as If,R0 as Jf,f0 as Kf};
1
+ import{Nh as b,Oh as G,Th as B0}from"./chunk-2sc2jxd3.js";import{Di as $0,Ei as w0,Ii as y}from"./chunk-s503pcvb.js";var c=Symbol.for("immer-nothing"),v=Symbol.for("immer-draftable"),X=Symbol.for("immer-state");function Y($,...w){throw Error(`[Immer] minified error nr: ${$}. Full error at: https://bit.ly/3cXEKWf`)}var z=Object.getPrototypeOf;function x($){return!!$&&!!$[X]}function U($){if(!$)return!1;return o($)||Array.isArray($)||!!$[v]||!!$.constructor?.[v]||L($)||R($)}var q0=Object.prototype.constructor.toString(),n=new WeakMap;function o($){if(!$||typeof $!=="object")return!1;let w=Object.getPrototypeOf($);if(w===null||w===Object.prototype)return!0;let B=Object.hasOwnProperty.call(w,"constructor")&&w.constructor;if(B===Object)return!0;if(typeof B!=="function")return!1;let W=n.get(B);if(W===void 0)W=Function.toString.call(B),n.set(B,W);return W===q0}function C($,w,B=!0){if(F($)===0)(B?Reflect.ownKeys($):Object.keys($)).forEach((q)=>{w(q,$[q],$)});else $.forEach((W,q)=>w(q,W,$))}function F($){let w=$[X];return w?w.type_:Array.isArray($)?1:L($)?2:R($)?3:0}function D($,w){return F($)===2?$.has(w):Object.prototype.hasOwnProperty.call($,w)}function r($,w,B){let W=F($);if(W===2)$.set(w,B);else if(W===3)$.add(B);else $[w]=B}function Z0($,w){if($===w)return $!==0||1/$===1/w;else return $!==$&&w!==w}function L($){return $ instanceof Map}function R($){return $ instanceof Set}function K($){return $.copy_||$.base_}function P($,w){if(L($))return new Map($);if(R($))return new Set($);if(Array.isArray($))return Array.prototype.slice.call($);let B=o($);if(w===!0||w==="class_only"&&!B){let W=Object.getOwnPropertyDescriptors($);delete W[X];let q=Reflect.ownKeys(W);for(let Z=0;Z<q.length;Z++){let J=q[Z],Q=W[J];if(Q.writable===!1)Q.writable=!0,Q.configurable=!0;if(Q.get||Q.set)W[J]={configurable:!0,writable:!0,enumerable:Q.enumerable,value:$[J]}}return Object.create(z($),W)}else{let W=z($);if(W!==null&&B)return{...$};let q=Object.create(W);return Object.assign(q,$)}}function g($,w=!1){if(E($)||x($)||!U($))return $;if(F($)>1)Object.defineProperties($,{set:O,add:O,clear:O,delete:O});if(Object.freeze($),w)Object.values($).forEach((B)=>g(B,!0));return $}function J0(){Y(2)}var O={value:J0};function E($){if($===null||typeof $!=="object")return!0;return Object.isFrozen($)}var Q0={};function I($){let w=Q0[$];if(!w)Y(0,$);return w}var M;function p(){return M}function X0($,w){return{drafts_:[],parent_:$,immer_:w,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function h($,w){if(w)I("Patches"),$.patches_=[],$.inversePatches_=[],$.patchListener_=w}function k($){A($),$.drafts_.forEach(Y0),$.drafts_=null}function A($){if($===M)M=$.parent_}function i($){return M=X0(M,$)}function Y0($){let w=$[X];if(w.type_===0||w.type_===1)w.revoke_();else w.revoked_=!0}function u($,w){w.unfinalizedDrafts_=w.drafts_.length;let B=w.drafts_[0];if($!==void 0&&$!==B){if(B[X].modified_)k(w),Y(4);if(U($)){if($=V(w,$),!w.parent_)f(w,$)}if(w.patches_)I("Patches").generateReplacementPatches_(B[X].base_,$,w.patches_,w.inversePatches_)}else $=V(w,B,[]);if(k(w),w.patches_)w.patchListener_(w.patches_,w.inversePatches_);return $!==c?$:void 0}function V($,w,B){if(E(w))return w;let W=$.immer_.shouldUseStrictIteration(),q=w[X];if(!q)return C(w,(Z,J)=>l($,q,w,Z,J,B),W),w;if(q.scope_!==$)return w;if(!q.modified_)return f($,q.base_,!0),q.base_;if(!q.finalized_){q.finalized_=!0,q.scope_.unfinalizedDrafts_--;let Z=q.copy_,J=Z,Q=!1;if(q.type_===3)J=new Set(Z),Z.clear(),Q=!0;if(C(J,(H,N)=>l($,q,Z,H,N,B,Q),W),f($,Z,!1),B&&$.patches_)I("Patches").generatePatches_(q,B,$.patches_,$.inversePatches_)}return q.copy_}function l($,w,B,W,q,Z,J){if(q==null)return;if(typeof q!=="object"&&!J)return;let Q=E(q);if(Q&&!J)return;if(x(q)){let H=Z&&w&&w.type_!==3&&!D(w.assigned_,W)?Z.concat(W):void 0,N=V($,q,H);if(r(B,W,N),x(N))$.canAutoFreeze_=!1;else return}else if(J)B.add(q);if(U(q)&&!Q){if(!$.immer_.autoFreeze_&&$.unfinalizedDrafts_<1)return;if(w&&w.base_&&w.base_[W]===q&&Q)return;if(V($,q),(!w||!w.scope_.parent_)&&typeof W!=="symbol"&&(L(B)?B.has(W):Object.prototype.propertyIsEnumerable.call(B,W)))f($,q)}}function f($,w,B=!1){if(!$.parent_&&$.immer_.autoFreeze_&&$.canAutoFreeze_)g(w,B)}function G0($,w){let B=Array.isArray($),W={type_:B?1:0,scope_:w?w.scope_:p(),modified_:!1,finalized_:!1,assigned_:{},parent_:w,base_:$,draft_:null,copy_:null,revoke_:null,isManual_:!1},q=W,Z=d;if(B)q=[W],Z=m;let{revoke:J,proxy:Q}=Proxy.revocable(q,Z);return W.draft_=Q,W.revoke_=J,Q}var d={get($,w){if(w===X)return $;let B=K($);if(!D(B,w))return H0($,B,w);let W=B[w];if($.finalized_||!U(W))return W;if(W===_($.base_,w))return j($),$.copy_[w]=S(W,$);return W},has($,w){return w in K($)},ownKeys($){return Reflect.ownKeys(K($))},set($,w,B){let W=s(K($),w);if(W?.set)return W.set.call($.draft_,B),!0;if(!$.modified_){let q=_(K($),w),Z=q?.[X];if(Z&&Z.base_===B)return $.copy_[w]=B,$.assigned_[w]=!1,!0;if(Z0(B,q)&&(B!==void 0||D($.base_,w)))return!0;j($),T($)}if($.copy_[w]===B&&(B!==void 0||(w in $.copy_))||Number.isNaN(B)&&Number.isNaN($.copy_[w]))return!0;return $.copy_[w]=B,$.assigned_[w]=!0,!0},deleteProperty($,w){if(_($.base_,w)!==void 0||w in $.base_)$.assigned_[w]=!1,j($),T($);else delete $.assigned_[w];if($.copy_)delete $.copy_[w];return!0},getOwnPropertyDescriptor($,w){let B=K($),W=Reflect.getOwnPropertyDescriptor(B,w);if(!W)return W;return{writable:!0,configurable:$.type_!==1||w!=="length",enumerable:W.enumerable,value:B[w]}},defineProperty(){Y(11)},getPrototypeOf($){return z($.base_)},setPrototypeOf(){Y(12)}},m={};C(d,($,w)=>{m[$]=function(){return arguments[0]=arguments[0][0],w.apply(this,arguments)}});m.deleteProperty=function($,w){return m.set.call(this,$,w,void 0)};m.set=function($,w,B){return d.set.call(this,$[0],w,B,$[0])};function _($,w){let B=$[X];return(B?K(B):$)[w]}function H0($,w,B){let W=s(w,B);return W?"value"in W?W.value:W.get?.call($.draft_):void 0}function s($,w){if(!(w in $))return;let B=z($);while(B){let W=Object.getOwnPropertyDescriptor(B,w);if(W)return W;B=z(B)}return}function T($){if(!$.modified_){if($.modified_=!0,$.parent_)T($.parent_)}}function j($){if(!$.copy_)$.copy_=P($.base_,$.scope_.immer_.useStrictShallowCopy_)}var K0=class{constructor($){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(w,B,W)=>{if(typeof w==="function"&&typeof B!=="function"){let Z=B;B=w;let J=this;return function(H=Z,...N){return J.produce(H,(W0)=>B.call(this,W0,...N))}}if(typeof B!=="function")Y(6);if(W!==void 0&&typeof W!=="function")Y(7);let q;if(U(w)){let Z=i(this),J=S(w,void 0),Q=!0;try{q=B(J),Q=!1}finally{if(Q)k(Z);else A(Z)}return h(Z,W),u(q,Z)}else if(!w||typeof w!=="object"){if(q=B(w),q===void 0)q=w;if(q===c)q=void 0;if(this.autoFreeze_)g(q,!0);if(W){let Z=[],J=[];I("Patches").generateReplacementPatches_(w,q,Z,J),W(Z,J)}return q}else Y(1,w)},this.produceWithPatches=(w,B)=>{if(typeof w==="function")return(J,...Q)=>this.produceWithPatches(J,(H)=>w(H,...Q));let W,q;return[this.produce(w,B,(J,Q)=>{W=J,q=Q}),W,q]},typeof $?.autoFreeze==="boolean")this.setAutoFreeze($.autoFreeze);if(typeof $?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy($.useStrictShallowCopy);if(typeof $?.useStrictIteration==="boolean")this.setUseStrictIteration($.useStrictIteration)}createDraft($){if(!U($))Y(8);if(x($))$=U0($);let w=i(this),B=S($,void 0);return B[X].isManual_=!0,A(w),B}finishDraft($,w){let B=$&&$[X];if(!B||!B.isManual_)Y(9);let{scope_:W}=B;return h(W,w),u(void 0,W)}setAutoFreeze($){this.autoFreeze_=$}setUseStrictShallowCopy($){this.useStrictShallowCopy_=$}setUseStrictIteration($){this.useStrictIteration_=$}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches($,w){let B;for(B=w.length-1;B>=0;B--){let q=w[B];if(q.path.length===0&&q.op==="replace"){$=q.value;break}}if(B>-1)w=w.slice(B+1);let W=I("Patches").applyPatches_;if(x($))return W($,w);return this.produce($,(q)=>W(q,w))}};function S($,w){let B=L($)?I("MapSet").proxyMap_($,w):R($)?I("MapSet").proxySet_($,w):G0($,w);return(w?w.scope_:p()).drafts_.push(B),B}function U0($){if(!x($))Y(10,$);return a($)}function a($){if(!U($)||E($))return $;let w=$[X],B,W=!0;if(w){if(!w.modified_)return w.base_;w.finalized_=!0,B=P($,w.scope_.immer_.useStrictShallowCopy_),W=w.scope_.immer_.shouldUseStrictIteration()}else B=P($,!0);if(C(B,(q,Z)=>{r(B,q,a(Z))},W),w)w.finalized_=!1;return B}var I0=new K0,t=I0.produce;var N0=($)=>(w,B,W)=>{return W.setState=(q,Z,...J)=>{let Q=typeof q==="function"?t(q):q;return w(Q,Z,...J)},$(W.setState,B,W)},e=N0;var f0=$0()(w0(e(($,w)=>({members:[],loading:!1,fetchMembers:async(B,W,q)=>{if(!q&&w().loadedTeamId===B&&w().loadedWithAgents===W)return;$({loading:!0});try{let Z=await y.api.teams[":teamId"].members.$get({param:{teamId:B},query:{includeAgents:W?"true":"false"}});if(!Z.ok)throw Error("failed to fetch members");let J=await Z.json();$({members:J||[],loadedTeamId:B,loadedProjectId:void 0,loadedWithAgents:W,loading:!1})}catch{$({loading:!1})}},fetchProjectMembers:async(B,W,q)=>{if(!q&&w().loadedProjectId===B&&w().loadedWithAgents===W)return;$({loading:!0});try{let Z=await y.api.projects[":projectId"].members.$get({param:{projectId:B},query:{includeAgents:W?"true":"false"}});if(!Z.ok)throw Error("failed to fetch project members");let J=await Z.json();$({members:J||[],loadedProjectId:B,loadedTeamId:void 0,loadedWithAgents:W,loading:!1})}catch{$({loading:!1})}}}))));function R0($){if(!$||$<=0)return"0 B";let w=1000,B=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],W=Math.floor(Math.log($)/Math.log(w));if(W<0)W=0;if(W>=B.length)W=B.length-1;let q=$/Math.pow(w,W);if(W===0)return`${Math.round(q)} B`;let Z=parseFloat(q.toFixed(2));if(Z>=1000&&W<B.length-1)return parseFloat(($/Math.pow(w,W+1)).toFixed(2))+" "+B[W+1];return`${Z} ${B[W]}`}function D0($,w,B){let W=G($,B?.in);if(isNaN(w))return b(B?.in||$,NaN);if(!w)return W;let q=W.getDate(),Z=b(B?.in||$,W.getTime());Z.setMonth(W.getMonth()+w+1,0);let J=Z.getDate();if(q>=J)return Z;else return W.setFullYear(Z.getFullYear(),Z.getMonth(),q),W}function A0($,w){let B=G($,w?.in),W=B.getMonth();return B.setFullYear(B.getFullYear(),W+1,0),B.setHours(23,59,59,999),B}function g0($,w){return G($,w?.in).getMonth()}function b0($,w){return G($,w?.in).getFullYear()}function h0($,w){let[B,W]=B0($,w.start,w.end);return{start:B,end:W}}
2
+ export{D0 as Ff,A0 as Gf,h0 as Hf,g0 as If,b0 as Jf,R0 as Kf,f0 as Lf};
@@ -1,2 +1,2 @@
1
1
  var BX={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},y=(X,$,w)=>{let H,B=BX[X];if(typeof B==="string")H=B;else if($===1)H=B.one;else H=B.other.replace("{{count}}",$.toString());if(w?.addSuffix)if(w.comparison&&w.comparison>0)return"in "+H;else return H+" ago";return H};function Y(X){return($={})=>{let w=$.width?String($.width):X.defaultWidth;return X.formats[w]||X.formats[X.defaultWidth]}}var KX={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},MX={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},AX={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},O={date:Y({formats:KX,defaultWidth:"full"}),time:Y({formats:MX,defaultWidth:"full"}),dateTime:Y({formats:AX,defaultWidth:"full"})};var GX={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},p=(X,$,w,H)=>GX[X];function V(X){return($,w)=>{let H=w?.context?String(w.context):"standalone",B;if(H==="formatting"&&X.formattingValues){let M=X.defaultFormattingWidth||X.defaultWidth,Q=w?.width?String(w.width):M;B=X.formattingValues[Q]||X.formattingValues[M]}else{let M=X.defaultWidth,Q=w?.width?String(w.width):X.defaultWidth;B=X.values[Q]||X.values[M]}let K=X.argumentCallback?X.argumentCallback($):$;return B[K]}}var QX={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},UX={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},xX={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},JX={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},RX={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},NX={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},qX=(X,$)=>{let w=Number(X),H=w%100;if(H>20||H<10)switch(H%10){case 1:return w+"st";case 2:return w+"nd";case 3:return w+"rd"}return w+"th"},m={ordinalNumber:qX,era:V({values:QX,defaultWidth:"wide"}),quarter:V({values:UX,defaultWidth:"wide",argumentCallback:(X)=>X-1}),month:V({values:xX,defaultWidth:"wide"}),day:V({values:JX,defaultWidth:"wide"}),dayPeriod:V({values:RX,defaultWidth:"wide",formattingValues:NX,defaultFormattingWidth:"wide"})};function Z(X){return($,w={})=>{let H=w.width,B=H&&X.matchPatterns[H]||X.matchPatterns[X.defaultMatchWidth],K=$.match(B);if(!K)return null;let M=K[0],Q=H&&X.parsePatterns[H]||X.parsePatterns[X.defaultParseWidth],R=Array.isArray(Q)?CX(Q,(U)=>U.test(M)):TX(Q,(U)=>U.test(M)),N;N=X.valueCallback?X.valueCallback(R):R,N=w.valueCallback?w.valueCallback(N):N;let J=$.slice(M.length);return{value:N,rest:J}}}function TX(X,$){for(let w in X)if(Object.prototype.hasOwnProperty.call(X,w)&&$(X[w]))return w;return}function CX(X,$){for(let w=0;w<X.length;w++)if($(X[w]))return w;return}function z(X){return($,w={})=>{let H=$.match(X.matchPattern);if(!H)return null;let B=H[0],K=$.match(X.parsePattern);if(!K)return null;let M=X.valueCallback?X.valueCallback(K[0]):K[0];M=w.valueCallback?w.valueCallback(M):M;let Q=$.slice(B.length);return{value:M,rest:Q}}}var PX=/^(\d+)(th|st|nd|rd)?/i,EX=/\d+/i,VX={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ZX={any:[/^b/i,/^(a|c)/i]},IX={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},vX={any:[/1/i,/2/i,/3/i,/4/i]},YX={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},SX={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},LX={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},FX={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},_X={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},jX={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},g={ordinalNumber:z({matchPattern:PX,parsePattern:EX,valueCallback:(X)=>parseInt(X,10)}),era:Z({matchPatterns:VX,defaultMatchWidth:"wide",parsePatterns:ZX,defaultParseWidth:"any"}),quarter:Z({matchPatterns:IX,defaultMatchWidth:"wide",parsePatterns:vX,defaultParseWidth:"any",valueCallback:(X)=>X+1}),month:Z({matchPatterns:YX,defaultMatchWidth:"wide",parsePatterns:SX,defaultParseWidth:"any"}),day:Z({matchPatterns:LX,defaultMatchWidth:"wide",parsePatterns:FX,defaultParseWidth:"any"}),dayPeriod:Z({matchPatterns:_X,defaultMatchWidth:"any",parsePatterns:jX,defaultParseWidth:"any"})};var h={code:"en-US",formatDistance:y,formatLong:O,formatRelative:p,localize:m,match:g,options:{weekStartsOn:0,firstWeekContainsDate:1}};var hX={};function C(){return hX}var bX=Math.pow(10,8)*24*60*60*1000,x$=-bX,S=604800000,u=86400000,J$=60000,R$=3600000;var b=Symbol.for("constructDateFrom");function x(X,$){if(typeof X==="function")return X($);if(X&&typeof X==="object"&&b in X)return X[b]($);if(X instanceof Date)return new X.constructor($);return new Date($)}function G(X,$){return x($||X,X)}function W(X){let $=G(X),w=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate(),$.getHours(),$.getMinutes(),$.getSeconds(),$.getMilliseconds()));return w.setUTCFullYear($.getFullYear()),+X-+w}function L(X,...$){let w=x.bind(null,X||$.find((H)=>typeof H==="object"));return $.map(w)}function I(X,$){let w=G(X,$?.in);return w.setHours(0,0,0,0),w}function c(X,$,w){let[H,B]=L(w?.in,X,$),K=I(H),M=I(B),Q=+K-W(K),R=+M-W(M);return Math.round((Q-R)/u)}function k(X,$){let w=G(X,$?.in);return w.setFullYear(w.getFullYear(),0,1),w.setHours(0,0,0,0),w}function f(X,$){let w=G(X,$?.in);return c(w,k(w))+1}function q(X,$){let w=C(),H=$?.weekStartsOn??$?.locale?.options?.weekStartsOn??w.weekStartsOn??w.locale?.options?.weekStartsOn??0,B=G(X,$?.in),K=B.getDay(),M=(K<H?7:0)+K-H;return B.setDate(B.getDate()-M),B.setHours(0,0,0,0),B}function P(X,$){return q(X,{...$,weekStartsOn:1})}function F(X,$){let w=G(X,$?.in),H=w.getFullYear(),B=x(w,0);B.setFullYear(H+1,0,4),B.setHours(0,0,0,0);let K=P(B),M=x(w,0);M.setFullYear(H,0,4),M.setHours(0,0,0,0);let Q=P(M);if(w.getTime()>=K.getTime())return H+1;else if(w.getTime()>=Q.getTime())return H;else return H-1}function d(X,$){let w=F(X,$),H=x($?.in||X,0);return H.setFullYear(w,0,4),H.setHours(0,0,0,0),P(H)}function n(X,$){let w=G(X,$?.in),H=+P(w)-+d(w);return Math.round(H/S)+1}function _(X,$){let w=G(X,$?.in),H=w.getFullYear(),B=C(),K=$?.firstWeekContainsDate??$?.locale?.options?.firstWeekContainsDate??B.firstWeekContainsDate??B.locale?.options?.firstWeekContainsDate??1,M=x($?.in||X,0);M.setFullYear(H+1,0,K),M.setHours(0,0,0,0);let Q=q(M,$),R=x($?.in||X,0);R.setFullYear(H,0,K),R.setHours(0,0,0,0);let N=q(R,$);if(+w>=+Q)return H+1;else if(+w>=+N)return H;else return H-1}function l(X,$){let w=C(),H=$?.firstWeekContainsDate??$?.locale?.options?.firstWeekContainsDate??w.firstWeekContainsDate??w.locale?.options?.firstWeekContainsDate??1,B=_(X,$),K=x($?.in||X,0);return K.setFullYear(B,0,H),K.setHours(0,0,0,0),q(K,$)}function s(X,$){let w=G(X,$?.in),H=+q(w,$)-+l(w,$);return Math.round(H/S)+1}function A(X,$){let w=X<0?"-":"",H=Math.abs(X).toString().padStart($,"0");return w+H}var T={y(X,$){let w=X.getFullYear(),H=w>0?w:1-w;return A($==="yy"?H%100:H,$.length)},M(X,$){let w=X.getMonth();return $==="M"?String(w+1):A(w+1,2)},d(X,$){return A(X.getDate(),$.length)},a(X,$){let w=X.getHours()/12>=1?"pm":"am";switch($){case"a":case"aa":return w.toUpperCase();case"aaa":return w;case"aaaaa":return w[0];case"aaaa":default:return w==="am"?"a.m.":"p.m."}},h(X,$){return A(X.getHours()%12||12,$.length)},H(X,$){return A(X.getHours(),$.length)},m(X,$){return A(X.getMinutes(),$.length)},s(X,$){return A(X.getSeconds(),$.length)},S(X,$){let w=$.length,H=X.getMilliseconds(),B=Math.trunc(H*Math.pow(10,w-3));return A(B,$.length)}};var v={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},D={G:function(X,$,w){let H=X.getFullYear()>0?1:0;switch($){case"G":case"GG":case"GGG":return w.era(H,{width:"abbreviated"});case"GGGGG":return w.era(H,{width:"narrow"});case"GGGG":default:return w.era(H,{width:"wide"})}},y:function(X,$,w){if($==="yo"){let H=X.getFullYear(),B=H>0?H:1-H;return w.ordinalNumber(B,{unit:"year"})}return T.y(X,$)},Y:function(X,$,w,H){let B=_(X,H),K=B>0?B:1-B;if($==="YY"){let M=K%100;return A(M,2)}if($==="Yo")return w.ordinalNumber(K,{unit:"year"});return A(K,$.length)},R:function(X,$){let w=F(X);return A(w,$.length)},u:function(X,$){let w=X.getFullYear();return A(w,$.length)},Q:function(X,$,w){let H=Math.ceil((X.getMonth()+1)/3);switch($){case"Q":return String(H);case"QQ":return A(H,2);case"Qo":return w.ordinalNumber(H,{unit:"quarter"});case"QQQ":return w.quarter(H,{width:"abbreviated",context:"formatting"});case"QQQQQ":return w.quarter(H,{width:"narrow",context:"formatting"});case"QQQQ":default:return w.quarter(H,{width:"wide",context:"formatting"})}},q:function(X,$,w){let H=Math.ceil((X.getMonth()+1)/3);switch($){case"q":return String(H);case"qq":return A(H,2);case"qo":return w.ordinalNumber(H,{unit:"quarter"});case"qqq":return w.quarter(H,{width:"abbreviated",context:"standalone"});case"qqqqq":return w.quarter(H,{width:"narrow",context:"standalone"});case"qqqq":default:return w.quarter(H,{width:"wide",context:"standalone"})}},M:function(X,$,w){let H=X.getMonth();switch($){case"M":case"MM":return T.M(X,$);case"Mo":return w.ordinalNumber(H+1,{unit:"month"});case"MMM":return w.month(H,{width:"abbreviated",context:"formatting"});case"MMMMM":return w.month(H,{width:"narrow",context:"formatting"});case"MMMM":default:return w.month(H,{width:"wide",context:"formatting"})}},L:function(X,$,w){let H=X.getMonth();switch($){case"L":return String(H+1);case"LL":return A(H+1,2);case"Lo":return w.ordinalNumber(H+1,{unit:"month"});case"LLL":return w.month(H,{width:"abbreviated",context:"standalone"});case"LLLLL":return w.month(H,{width:"narrow",context:"standalone"});case"LLLL":default:return w.month(H,{width:"wide",context:"standalone"})}},w:function(X,$,w,H){let B=s(X,H);if($==="wo")return w.ordinalNumber(B,{unit:"week"});return A(B,$.length)},I:function(X,$,w){let H=n(X);if($==="Io")return w.ordinalNumber(H,{unit:"week"});return A(H,$.length)},d:function(X,$,w){if($==="do")return w.ordinalNumber(X.getDate(),{unit:"date"});return T.d(X,$)},D:function(X,$,w){let H=f(X);if($==="Do")return w.ordinalNumber(H,{unit:"dayOfYear"});return A(H,$.length)},E:function(X,$,w){let H=X.getDay();switch($){case"E":case"EE":case"EEE":return w.day(H,{width:"abbreviated",context:"formatting"});case"EEEEE":return w.day(H,{width:"narrow",context:"formatting"});case"EEEEEE":return w.day(H,{width:"short",context:"formatting"});case"EEEE":default:return w.day(H,{width:"wide",context:"formatting"})}},e:function(X,$,w,H){let B=X.getDay(),K=(B-H.weekStartsOn+8)%7||7;switch($){case"e":return String(K);case"ee":return A(K,2);case"eo":return w.ordinalNumber(K,{unit:"day"});case"eee":return w.day(B,{width:"abbreviated",context:"formatting"});case"eeeee":return w.day(B,{width:"narrow",context:"formatting"});case"eeeeee":return w.day(B,{width:"short",context:"formatting"});case"eeee":default:return w.day(B,{width:"wide",context:"formatting"})}},c:function(X,$,w,H){let B=X.getDay(),K=(B-H.weekStartsOn+8)%7||7;switch($){case"c":return String(K);case"cc":return A(K,$.length);case"co":return w.ordinalNumber(K,{unit:"day"});case"ccc":return w.day(B,{width:"abbreviated",context:"standalone"});case"ccccc":return w.day(B,{width:"narrow",context:"standalone"});case"cccccc":return w.day(B,{width:"short",context:"standalone"});case"cccc":default:return w.day(B,{width:"wide",context:"standalone"})}},i:function(X,$,w){let H=X.getDay(),B=H===0?7:H;switch($){case"i":return String(B);case"ii":return A(B,$.length);case"io":return w.ordinalNumber(B,{unit:"day"});case"iii":return w.day(H,{width:"abbreviated",context:"formatting"});case"iiiii":return w.day(H,{width:"narrow",context:"formatting"});case"iiiiii":return w.day(H,{width:"short",context:"formatting"});case"iiii":default:return w.day(H,{width:"wide",context:"formatting"})}},a:function(X,$,w){let B=X.getHours()/12>=1?"pm":"am";switch($){case"a":case"aa":return w.dayPeriod(B,{width:"abbreviated",context:"formatting"});case"aaa":return w.dayPeriod(B,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return w.dayPeriod(B,{width:"narrow",context:"formatting"});case"aaaa":default:return w.dayPeriod(B,{width:"wide",context:"formatting"})}},b:function(X,$,w){let H=X.getHours(),B;if(H===12)B=v.noon;else if(H===0)B=v.midnight;else B=H/12>=1?"pm":"am";switch($){case"b":case"bb":return w.dayPeriod(B,{width:"abbreviated",context:"formatting"});case"bbb":return w.dayPeriod(B,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return w.dayPeriod(B,{width:"narrow",context:"formatting"});case"bbbb":default:return w.dayPeriod(B,{width:"wide",context:"formatting"})}},B:function(X,$,w){let H=X.getHours(),B;if(H>=17)B=v.evening;else if(H>=12)B=v.afternoon;else if(H>=4)B=v.morning;else B=v.night;switch($){case"B":case"BB":case"BBB":return w.dayPeriod(B,{width:"abbreviated",context:"formatting"});case"BBBBB":return w.dayPeriod(B,{width:"narrow",context:"formatting"});case"BBBB":default:return w.dayPeriod(B,{width:"wide",context:"formatting"})}},h:function(X,$,w){if($==="ho"){let H=X.getHours()%12;if(H===0)H=12;return w.ordinalNumber(H,{unit:"hour"})}return T.h(X,$)},H:function(X,$,w){if($==="Ho")return w.ordinalNumber(X.getHours(),{unit:"hour"});return T.H(X,$)},K:function(X,$,w){let H=X.getHours()%12;if($==="Ko")return w.ordinalNumber(H,{unit:"hour"});return A(H,$.length)},k:function(X,$,w){let H=X.getHours();if(H===0)H=24;if($==="ko")return w.ordinalNumber(H,{unit:"hour"});return A(H,$.length)},m:function(X,$,w){if($==="mo")return w.ordinalNumber(X.getMinutes(),{unit:"minute"});return T.m(X,$)},s:function(X,$,w){if($==="so")return w.ordinalNumber(X.getSeconds(),{unit:"second"});return T.s(X,$)},S:function(X,$){return T.S(X,$)},X:function(X,$,w){let H=X.getTimezoneOffset();if(H===0)return"Z";switch($){case"X":return r(H);case"XXXX":case"XX":return E(H);case"XXXXX":case"XXX":default:return E(H,":")}},x:function(X,$,w){let H=X.getTimezoneOffset();switch($){case"x":return r(H);case"xxxx":case"xx":return E(H);case"xxxxx":case"xxx":default:return E(H,":")}},O:function(X,$,w){let H=X.getTimezoneOffset();switch($){case"O":case"OO":case"OOO":return"GMT"+i(H,":");case"OOOO":default:return"GMT"+E(H,":")}},z:function(X,$,w){let H=X.getTimezoneOffset();switch($){case"z":case"zz":case"zzz":return"GMT"+i(H,":");case"zzzz":default:return"GMT"+E(H,":")}},t:function(X,$,w){let H=Math.trunc(+X/1000);return A(H,$.length)},T:function(X,$,w){return A(+X,$.length)}};function i(X,$=""){let w=X>0?"-":"+",H=Math.abs(X),B=Math.trunc(H/60),K=H%60;if(K===0)return w+String(B);return w+String(B)+$+A(K,2)}function r(X,$){if(X%60===0)return(X>0?"-":"+")+A(Math.abs(X)/60,2);return E(X,$)}function E(X,$=""){let w=X>0?"-":"+",H=Math.abs(X),B=A(Math.trunc(H/60),2),K=A(H%60,2);return w+B+$+K}var o=(X,$)=>{switch(X){case"P":return $.date({width:"short"});case"PP":return $.date({width:"medium"});case"PPP":return $.date({width:"long"});case"PPPP":default:return $.date({width:"full"})}},t=(X,$)=>{switch(X){case"p":return $.time({width:"short"});case"pp":return $.time({width:"medium"});case"ppp":return $.time({width:"long"});case"pppp":default:return $.time({width:"full"})}},WX=(X,$)=>{let w=X.match(/(P+)(p+)?/)||[],H=w[1],B=w[2];if(!B)return o(X,$);let K;switch(H){case"P":K=$.dateTime({width:"short"});break;case"PP":K=$.dateTime({width:"medium"});break;case"PPP":K=$.dateTime({width:"long"});break;case"PPPP":default:K=$.dateTime({width:"full"});break}return K.replace("{{date}}",o(H,$)).replace("{{time}}",t(B,$))},a={p:t,P:WX};var DX=/^D+$/,yX=/^Y+$/,OX=["D","DD","YY","YYYY"];function e(X){return DX.test(X)}function XX(X){return yX.test(X)}function $X(X,$,w){let H=pX(X,$,w);if(console.warn(H),OX.includes(X))throw RangeError(H)}function pX(X,$,w){let H=X[0]==="Y"?"years":"days of the month";return`Use \`${X.toLowerCase()}\` instead of \`${X}\` (in \`${$}\`) for formatting ${H} to the input \`${w}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}function wX(X){return X instanceof Date||typeof X==="object"&&Object.prototype.toString.call(X)==="[object Date]"}function HX(X){return!(!wX(X)&&typeof X!=="number"||isNaN(+G(X)))}var mX=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zX=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gX=/^'([^]*?)'?$/,uX=/''/g,cX=/[a-zA-Z]/;function gw(X,$,w){let H=C(),B=w?.locale??H.locale??h,K=w?.firstWeekContainsDate??w?.locale?.options?.firstWeekContainsDate??H.firstWeekContainsDate??H.locale?.options?.firstWeekContainsDate??1,M=w?.weekStartsOn??w?.locale?.options?.weekStartsOn??H.weekStartsOn??H.locale?.options?.weekStartsOn??0,Q=G(X,w?.in);if(!HX(Q))throw RangeError("Invalid time value");let R=$.match(zX).map((J)=>{let U=J[0];if(U==="p"||U==="P"){let j=a[U];return j(J,B.formatLong)}return J}).join("").match(mX).map((J)=>{if(J==="''")return{isToken:!1,value:"'"};let U=J[0];if(U==="'")return{isToken:!1,value:kX(J)};if(D[U])return{isToken:!0,value:J};if(U.match(cX))throw RangeError("Format string contains an unescaped latin alphabet character `"+U+"`");return{isToken:!1,value:J}});if(B.localize.preprocessor)R=B.localize.preprocessor(Q,R);let N={firstWeekContainsDate:K,weekStartsOn:M,locale:B};return R.map((J)=>{if(!J.isToken)return J.value;let U=J.value;if(!w?.useAdditionalWeekYearTokens&&XX(U)||!w?.useAdditionalDayOfYearTokens&&e(U))$X(U,$,String(X));let j=D[U[0]];return j(Q,U,B.localize,N)}).join("")}function kX(X){let $=X.match(gX);if(!$)return X;return $[1].replace(uX,"'")}function fw(X,$,w){let[H,B]=L(w?.in,X,$);return+I(H)===+I(B)}function sw(X,$,w){let H=G(X,w?.in);if(isNaN($))return x(w?.in||X,NaN);if(!$)return H;return H.setDate(H.getDate()+$),H}
2
- export{J$ as Fh,R$ as Gh,x as Hh,G as Ih,sw as Jh,C as Kh,q as Lh,P as Mh,L as Nh,I as Oh,c as Ph,fw as Qh,wX as Rh,HX as Sh,k as Th,h as Uh,n as Vh,s as Wh,gw as Xh};
2
+ export{J$ as Lh,R$ as Mh,x as Nh,G as Oh,sw as Ph,C as Qh,q as Rh,P as Sh,L as Th,I as Uh,c as Vh,fw as Wh,wX as Xh,HX as Yh,k as Zh,h as _h,n as $h,s as ai,gw as bi};