@shumai-one/shumai 0.4.1 → 0.4.2

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 (173) hide show
  1. package/bin/{chunk-rfsbzd39.js → chunk-07h4b77v.js} +2 -2
  2. package/bin/{chunk-j9q9rjvd.js → chunk-0t4n4d5w.js} +2 -2
  3. package/bin/{chunk-be9a7kc6.js → chunk-1611z9jg.js} +2 -2
  4. package/bin/{chunk-q46rc697.js → chunk-1phqxp6z.js} +1 -1
  5. package/bin/{chunk-xxtcmzcv.js → chunk-23hckrrz.js} +2 -2
  6. package/bin/{chunk-j10gz94w.js → chunk-30z44j1g.js} +2 -2
  7. package/bin/{chunk-thd9zasr.js → chunk-3j463k1g.js} +1 -1
  8. package/bin/{chunk-d6d1j7qq.js → chunk-4181tdds.js} +2 -2
  9. package/bin/{chunk-44370df5.js → chunk-480jtqng.js} +2 -2
  10. package/bin/{chunk-pcxjm1re.js → chunk-4c3g146q.js} +2 -2
  11. package/bin/chunk-4ca0zt5e.js +1 -0
  12. package/bin/chunk-4d9bgmf2.js +2 -0
  13. package/bin/{chunk-b0cqsrse.js → chunk-4ev56fss.js} +5 -5
  14. package/bin/{chunk-tcqw0q8x.js → chunk-4gk52tjq.js} +1 -1
  15. package/bin/chunk-4mdqkj4d.js +1 -0
  16. package/bin/{chunk-f4d3v0nc.js → chunk-4r91fggc.js} +2 -2
  17. package/bin/chunk-50fb1x3w.js +1 -0
  18. package/bin/chunk-59gj1njz.js +1 -0
  19. package/bin/{chunk-4ee336e3.js → chunk-5pr0t7fb.js} +1 -1
  20. package/bin/chunk-5vewxmz7.js +3 -0
  21. package/bin/chunk-62zx96pe.js +2 -0
  22. package/bin/{chunk-7xcyn1ba.js → chunk-63y0eb07.js} +2 -2
  23. package/bin/chunk-6d5xrgfx.js +2 -0
  24. package/bin/{chunk-jw00fmkp.js → chunk-6gbtz5bf.js} +2 -2
  25. package/bin/{chunk-r6g1srb3.js → chunk-6gjg5egq.js} +1 -1
  26. package/bin/{chunk-c97vh5wb.js → chunk-6m4jz9s1.js} +3 -3
  27. package/bin/{chunk-7zgvmn5q.js → chunk-6s4x525w.js} +1 -1
  28. package/bin/{chunk-7qzt5nhz.js → chunk-6w2wmvqs.js} +1 -1
  29. package/bin/{chunk-kejt7kcr.js → chunk-77d23vcn.js} +2 -2
  30. package/bin/{chunk-1vs91e4q.js → chunk-77m5p188.js} +2 -2
  31. package/bin/chunk-7bvx087f.js +1 -0
  32. package/bin/chunk-7pfjfrjg.js +5 -0
  33. package/bin/{chunk-78cxvbjd.js → chunk-7q10s127.js} +1 -1
  34. package/bin/{chunk-za7ga4bf.js → chunk-7thx8ctx.js} +2 -2
  35. package/bin/{chunk-s9sgkkjp.js → chunk-8t4s91gh.js} +1 -1
  36. package/bin/{chunk-bbar8rsh.js → chunk-98ey5p2e.js} +1 -1
  37. package/bin/{chunk-gfdfkqrc.js → chunk-9amndcyh.js} +3 -3
  38. package/bin/chunk-9bk23g9x.js +1 -0
  39. package/bin/chunk-9mkcfy43.js +1 -0
  40. package/bin/{chunk-8yt4m2pb.js → chunk-9t3nsq5n.js} +2 -2
  41. package/bin/{chunk-zqvavykq.js → chunk-9tjq99ds.js} +2 -2
  42. package/bin/chunk-9wm9rwh1.js +2 -0
  43. package/bin/{chunk-8pfgh13x.js → chunk-ab16fyg4.js} +2 -2
  44. package/bin/chunk-arv0g2av.js +1 -0
  45. package/bin/{chunk-hx2mvd20.js → chunk-aytj4zxg.js} +2 -2
  46. package/bin/{chunk-4k2d8w9w.js → chunk-b1ypjqgp.js} +2 -2
  47. package/bin/{chunk-pt51m9h1.js → chunk-bdjv0ykq.js} +2 -2
  48. package/bin/chunk-c1k86mfa.js +10 -0
  49. package/bin/{chunk-me3xj7na.js → chunk-caa96dgd.js} +1 -1
  50. package/bin/chunk-ce4v2yjy.js +1 -0
  51. package/bin/{chunk-pg00gkr4.js → chunk-cqh60y54.js} +2 -2
  52. package/bin/chunk-cvq7zgw7.js +1 -0
  53. package/bin/{chunk-16txy3r1.js → chunk-d9mjbtp2.js} +2 -2
  54. package/bin/{chunk-116p639c.js → chunk-dn7sbjws.js} +2 -2
  55. package/bin/{chunk-txkmks1h.js → chunk-dxyq9h8n.js} +1 -1
  56. package/bin/{chunk-mgytr7nc.js → chunk-e3cabksx.js} +1 -1
  57. package/bin/{chunk-f8ysqfyv.js → chunk-egcrbj94.js} +2 -2
  58. package/bin/chunk-ev17v1mv.js +2 -0
  59. package/bin/{chunk-a5b3aevg.js → chunk-evtpwg71.js} +1 -1
  60. package/bin/{chunk-zt15ht52.js → chunk-f3e0nsv2.js} +1 -1
  61. package/bin/{chunk-r9pzpqst.js → chunk-f40gjqpq.js} +1 -1
  62. package/bin/chunk-fe7822ak.js +299 -0
  63. package/bin/{chunk-srs9jq8f.js → chunk-g8tkhw9j.js} +2 -2
  64. package/bin/{chunk-mgnxa0vy.js → chunk-g9r0p4t8.js} +1 -1
  65. package/bin/chunk-gbjyh9ms.js +1 -0
  66. package/bin/{chunk-pn94h6x7.js → chunk-gtbsb39v.js} +1 -1
  67. package/bin/{chunk-d9sh922y.js → chunk-gytz1q13.js} +1 -1
  68. package/bin/chunk-h0fxysxs.js +7 -0
  69. package/bin/{chunk-9f83pnfc.js → chunk-h8bdvsqt.js} +2 -2
  70. package/bin/{chunk-ts10cfmc.js → chunk-hag024w8.js} +2 -2
  71. package/bin/{chunk-09pe07g6.js → chunk-hc6w5nw4.js} +1 -1
  72. package/bin/chunk-j69dqc48.js +2 -0
  73. package/bin/{chunk-13ypr8v0.js → chunk-jbtw1zym.js} +1 -1
  74. package/bin/{chunk-7wvw67f3.js → chunk-jc1vb7rj.js} +2 -2
  75. package/bin/{chunk-92yvt66q.js → chunk-jdv78w9r.js} +1 -1
  76. package/bin/{chunk-gyaem1t4.js → chunk-jjs70y9v.js} +1 -1
  77. package/bin/{chunk-6tv7rm3x.js → chunk-jmdar2gz.js} +2 -2
  78. package/bin/{chunk-cyvx7gcx.js → chunk-jvwz10n4.js} +1 -1
  79. package/bin/{chunk-ygsbmfcy.js → chunk-k47md1g4.js} +2 -2
  80. package/bin/{chunk-hmmzbyy1.js → chunk-k4v0brcb.js} +2 -2
  81. package/bin/chunk-k6n7c07e.js +1 -0
  82. package/bin/{chunk-af6m9p1d.js → chunk-kk2cstsg.js} +1 -1
  83. package/bin/{chunk-wfee9d83.js → chunk-knz4h56q.js} +3 -3
  84. package/bin/{chunk-j5rx3x1q.js → chunk-kqqtt6bd.js} +1 -1
  85. package/bin/{chunk-ym9xavj0.js → chunk-kvyp1t4j.js} +1 -1
  86. package/bin/{chunk-4yhd7bmp.js → chunk-kxskpgsq.js} +2 -2
  87. package/bin/{chunk-q059y3wx.js → chunk-m6srbjcs.js} +2 -2
  88. package/bin/{chunk-3gqdepkd.js → chunk-mcc1scxs.js} +2 -2
  89. package/bin/{chunk-90tbc5f4.js → chunk-mq83a0kk.js} +2 -2
  90. package/bin/chunk-mxm8g4q0.js +1 -0
  91. package/bin/{chunk-f32kxe6c.js → chunk-nhpgdqq5.js} +2 -2
  92. package/bin/{chunk-2jsjrqw4.js → chunk-nne496aa.js} +2 -2
  93. package/bin/{chunk-cerjktz2.js → chunk-nqpb0r9h.js} +1 -1
  94. package/bin/chunk-ns0zww9g.js +2 -0
  95. package/bin/{chunk-2sc2jxd3.js → chunk-ps4xfp23.js} +1 -1
  96. package/bin/chunk-pz2ec6xt.js +2 -0
  97. package/bin/{chunk-px2cvc1n.js → chunk-q163k309.js} +2 -2
  98. package/bin/chunk-q1da61ps.js +1 -0
  99. package/bin/{chunk-785kxysj.js → chunk-qrf0ady6.js} +2 -2
  100. package/bin/{chunk-kkveddbn.js → chunk-qy28f25e.js} +1 -1
  101. package/bin/{chunk-fcsar7p0.js → chunk-r7s4ypw1.js} +1 -1
  102. package/bin/chunk-ran23vm9.js +1 -0
  103. package/bin/chunk-rfvdc4n0.js +2 -0
  104. package/bin/{chunk-8rcfhfq5.js → chunk-rgthkvgx.js} +1 -1
  105. package/bin/chunk-s39n3yw3.js +2 -0
  106. package/bin/{chunk-z340qkez.js → chunk-s7wdd0g7.js} +1 -1
  107. package/bin/{chunk-n8gsjwht.js → chunk-s88ha5kx.js} +2 -2
  108. package/bin/chunk-sf91bt9m.js +2 -0
  109. package/bin/{chunk-c43nmcfq.js → chunk-sjwbjf9j.js} +1 -1
  110. package/bin/chunk-t62076pv.js +1 -0
  111. package/bin/{chunk-k20w9eaz.js → chunk-tbbwss3v.js} +1 -1
  112. package/bin/{chunk-djkajvn7.js → chunk-tjcc7a6y.js} +1 -1
  113. package/bin/{chunk-nndzhn3n.js → chunk-tp6ab26e.js} +1 -1
  114. package/bin/{chunk-5395g4kq.js → chunk-v2wxk9p5.js} +2 -2
  115. package/bin/{chunk-wzdnsgwq.js → chunk-vbk6y4hk.js} +2 -2
  116. package/bin/{chunk-dyvmwafa.js → chunk-vfgfg5fk.js} +2 -2
  117. package/bin/{chunk-5c4h0t33.js → chunk-vm6c3xx9.js} +2 -2
  118. package/bin/{chunk-wxsq9zmf.js → chunk-vsx96mt6.js} +1 -1
  119. package/bin/{chunk-vh7eb7tp.js → chunk-wbyw1shz.js} +2 -2
  120. package/bin/chunk-whh2vh50.css +1 -0
  121. package/bin/{chunk-m49g5tf4.js → chunk-wjkcq65s.js} +2 -2
  122. package/bin/{chunk-47r5b77s.js → chunk-wkefwkfp.js} +1 -1
  123. package/bin/{chunk-7sf0gbbm.js → chunk-x7bsnk1e.js} +2 -2
  124. package/bin/{chunk-rar0gk7s.js → chunk-xbhw6bpz.js} +2 -2
  125. package/bin/{chunk-5bkj2n94.js → chunk-xg5yrcj5.js} +2 -2
  126. package/bin/{chunk-ewge52nq.js → chunk-xw2gpcsh.js} +1 -1
  127. package/bin/{chunk-xyzmew7g.js → chunk-ycq8ank7.js} +1 -1
  128. package/bin/{chunk-w9p59ahz.js → chunk-yp9hvkc5.js} +9 -9
  129. package/bin/{chunk-bkbqvxfv.js → chunk-ytypyfkc.js} +2 -2
  130. package/bin/{chunk-axb1f1ae.js → chunk-z1kjmf60.js} +2 -2
  131. package/bin/chunk-z36bx86r.js +2 -0
  132. package/bin/chunk-z7hdnecp.js +3 -0
  133. package/bin/{chunk-2vc6pw8q.js → chunk-zeby1cq7.js} +1 -1
  134. package/bin/chunk-zs5e8z1w.js +1 -0
  135. package/bin/chunk-zxnyefg5.js +2 -0
  136. package/bin/shumai-app.html +1 -1
  137. package/bin/shumai-app.js +297 -285
  138. package/package.json +7 -7
  139. package/bin/chunk-082zg4nr.js +0 -307
  140. package/bin/chunk-0qdzjcny.js +0 -2
  141. package/bin/chunk-0z1p2pvf.js +0 -1
  142. package/bin/chunk-29e0mb43.js +0 -1
  143. package/bin/chunk-2a0egvsg.js +0 -1
  144. package/bin/chunk-2f35h4fn.js +0 -2
  145. package/bin/chunk-2q7ew7yz.js +0 -2
  146. package/bin/chunk-44xtwvd7.js +0 -2
  147. package/bin/chunk-4azttb3w.js +0 -1
  148. package/bin/chunk-4yybby29.js +0 -2
  149. package/bin/chunk-6nrynqdw.js +0 -2
  150. package/bin/chunk-7g2k89gq.js +0 -2
  151. package/bin/chunk-7psq38hv.js +0 -1
  152. package/bin/chunk-93v3tm93.js +0 -1
  153. package/bin/chunk-ajryg2e2.js +0 -1
  154. package/bin/chunk-b27jgdsf.css +0 -1
  155. package/bin/chunk-bwyph9a0.js +0 -1
  156. package/bin/chunk-dbjc1vxt.js +0 -1
  157. package/bin/chunk-gr30nssh.js +0 -1
  158. package/bin/chunk-gtwhwdbs.js +0 -1
  159. package/bin/chunk-hk6tvf7b.js +0 -1
  160. package/bin/chunk-hzz4hsss.js +0 -1
  161. package/bin/chunk-k1f3gj25.js +0 -3
  162. package/bin/chunk-ktvmxqfg.js +0 -5
  163. package/bin/chunk-mkb4dycy.js +0 -2
  164. package/bin/chunk-n21a21vx.js +0 -2
  165. package/bin/chunk-r88vwaxc.js +0 -1
  166. package/bin/chunk-rfrpb986.js +0 -1
  167. package/bin/chunk-s503pcvb.js +0 -7
  168. package/bin/chunk-t77dwtcc.js +0 -2
  169. package/bin/chunk-tkgpc6c9.js +0 -2
  170. package/bin/chunk-v9hbssqd.js +0 -3
  171. package/bin/chunk-v9zc56qr.js +0 -1
  172. package/bin/chunk-x2nnv4j8.js +0 -1
  173. /package/bin/{chunk-kryt6pg3.js → chunk-xg9xscqz.js} +0 -0
@@ -1,2 +0,0 @@
1
- import{fg as v}from"./chunk-k1f3gj25.js";import{gg as _z,hg as $z,ig as Kz,jg as Uz,kg as Vz}from"./chunk-hmmzbyy1.js";import{lg as p}from"./chunk-d6d1j7qq.js";import{eh as Yz}from"./chunk-785kxysj.js";import{hh as I}from"./chunk-ygsbmfcy.js";import{Ih as Zz}from"./chunk-rfsbzd39.js";import{si as Xz}from"./chunk-4k2d8w9w.js";import{Ii as o,wi as n,zi as r}from"./chunk-s503pcvb.js";import{$i as Mz,Dj as t,Fk as S,Fl as A,Oj as e,Qj as s,Rl as Jz,Wl as w,Xj as T,Yj as zz,aj as M,bj as z,bk as b,cj as J,il as Gz,tm as Y}from"./chunk-w9p59ahz.js";import{rn as Bz}from"./chunk-txkmks1h.js";var _=Bz(Mz(),1);function gz({projectId:V,contextAssetId:R}){let{isHistoryMode:N,setIsHistoryMode:u,currentSessionId:Wz,chatAssets:g,removeAsset:Lz,messages:D,historySessions:m,isStreaming:q,fetchHistorySessions:l,loadSession:Nz,deleteSession:Qz,startNewSession:Pz,sendMessage:Dz,abortActiveSession:Oz,selectedAgentId:F,setSelectedAgentId:B,inputText:C,setInputText:d}=v(),{teamId:W,ensureTeamIdForProject:j}=Xz();_.useEffect(()=>{if(V)j(V)},[V,j]);let{data:qz=[],isSuccess:i}=r({queryKey:["chat-agents",V],queryFn:async()=>{if(!V)return[];let G=await o.api.projects[":projectId"]["chat-agents"].$get({param:{projectId:V}});if(!G.ok)throw Error("failed to fetch agents");return G.json()},enabled:!!V}),H=qz.filter((G)=>G.type==="chat"&&G.enabled);_.useEffect(()=>{if(!i)return;if(H.length>0){if(!H.some((X)=>X.id===F))B(H[0].id)}else if(F!==null)B(null)},[i,H,F,B]);let x=_.useRef(null),y=_.useRef(null),k=_.useRef(!0),f=_.useRef(!0);_.useEffect(()=>{f.current=!0,k.current=!0},[V,R,N]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let{scrollTop:X,isAtBottom:$}=v.getState(),U=setTimeout(()=>{if($)G.scrollTop=G.scrollHeight;else G.scrollTop=X;let L=setTimeout(()=>{f.current=!1},50);return()=>clearTimeout(L)},0);return()=>clearTimeout(U)},[V,R,N]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let X=()=>{if(f.current)return;let $=G.scrollTop,U=G.scrollHeight-$-G.clientHeight<10;v.getState().setScrollState($,U)};return G.addEventListener("scroll",X),()=>{G.removeEventListener("scroll",X)}},[V,R,N]);let{ref:Ez,isDropTarget:Fz}=Yz({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});_.useEffect(()=>{if(!N){let{isAtBottom:G}=v.getState();if(G||q){let X=k.current?"auto":"smooth";x.current?.scrollIntoView({behavior:X})}k.current=!1}},[D,q,N]),_.useEffect(()=>{if(N&&W)l(W)},[N,l,W]);let E=n(),Hz=_.useCallback(()=>{E.invalidateQueries({queryKey:["search"]}),E.invalidateQueries({queryKey:["folders"]}),E.invalidateQueries({queryKey:["files"]}),E.invalidateQueries({queryKey:["file"]}),E.invalidateQueries({queryKey:["version_stacks"]}),E.invalidateQueries({queryKey:["projects"]})},[E]),a=()=>{if(!C.trim()||q||!W)return;Dz(W,C,V,R,Hz),d("")},Cz=(G)=>{if(G.nativeEvent.isComposing)return;if(G.key==="Enter"&&!G.shiftKey)G.preventDefault(),a()},h=(G)=>{if(typeof G==="string")return G;if(Array.isArray(G))return G.map((X)=>{if(typeof X==="string")return X;if(X&&typeof X==="object"&&"type"in X&&X.type==="text"&&"text"in X)return String(X.text);return""}).join("");return""},c=(G)=>{return G.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},vz=(G)=>{switch(G.role){case"user":return z("div",{className:"flex justify-end w-full",children:z("div",{className:"bg-primary text-primary-foreground rounded-lg px-3 py-2 max-w-[85%] text-sm whitespace-pre-wrap shadow-xs break-words",children:h(G.content)})},G.id);case"assistant":{let $=G.content;if(!$)return null;let U=[];if($.forEach((Z,Q)=>{if(!Z||typeof Z!=="object")return;let P=Z;switch(P.type){case"text":{let K=P.text;if(typeof K!=="string"||!K.trim())return;U.push(z("div",{className:"text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words",children:z(p,{components:{pre:({node:O,...Rz})=>z("pre",{className:"whitespace-pre-wrap break-all break-words bg-muted text-foreground p-4 rounded-md border border-border/50 font-mono text-sm",...Rz})},children:c(K)})},`txt-${Q}`));break}case"thinking":{let K=P.thinking;if(typeof K!=="string"||!K.trim())return;U.push(J("details",{className:"group border border-border/50 rounded-lg bg-muted/20 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-medium text-muted-foreground select-none cursor-pointer hover:bg-muted/40 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(zz,{className:"h-3.5 w-3.5 text-primary/70 animate-pulse"}),z("span",{children:Y.role_thinking()||"Thinking"}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),z("div",{className:"p-3 pt-0 text-xs text-muted-foreground/90 border-t border-border/40 bg-muted/10 leading-relaxed prose prose-sm dark:prose-invert max-w-none whitespace-pre-wrap font-sans",children:z(p,{children:c(K)})})]},`think-${Q}`));break}case"toolCall":{let K=String(P.name||P.toolName||Y.unknown()),O=P.arguments||P.args;U.push(J("details",{className:"group border border-border/50 rounded-lg bg-violet-500/5 my-2 overflow-hidden",children:[J("summary",{className:"flex items-center gap-2 p-2.5 text-xs font-semibold text-violet-600 dark:text-violet-400 select-none cursor-pointer hover:bg-violet-500/10 transition-colors list-none [&::-webkit-details-marker]:hidden",children:[z(Jz,{className:"h-3.5 w-3.5"}),z("span",{children:Y.calling_tool()}),z("span",{className:"font-mono bg-violet-500/10 px-1.5 py-0.5 rounded text-[11px] text-violet-700 dark:text-violet-300",children:K}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!O&&J("div",{className:"p-3 pt-0 text-[10px] text-muted-foreground/90 border-t border-border/40 bg-violet-500/5 font-sans",children:[z("div",{className:"text-[9px] text-muted-foreground/60 uppercase font-bold tracking-wider mb-1.5",children:Y.tool_arguments()||"Arguments"}),z("pre",{className:"font-mono bg-muted/30 p-2 rounded border border-border/30 overflow-x-auto max-h-32",children:JSON.stringify(O,null,2)})]})]},`tool-${Q}`));break}case"image":{let K=String(P.mimeType||"image/png"),O=String(P.data||"");U.push(z("div",{className:"my-2 max-w-full",children:O?z("img",{src:O.startsWith("data:")?O:`data:${K};base64,${O}`,alt:"Attached asset",className:"max-h-60 rounded border border-border/50 object-contain shadow-xs"}):z("div",{className:"text-xs text-muted-foreground italic flex items-center gap-1.5 py-1",children:Y.image_object()})},`img-${Q}`));break}default:{let K=JSON.stringify(Z,null,2);if(K==="{}")return;U.push(z("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:K},`other-${Q}`))}}}),U.length===0)return null;let L=!1;if($.length>0){let Z=$[$.length-1];if(typeof Z==="string"&&Z.trim().length>0)L=!0;else if(Z&&typeof Z==="object"){let Q=Z;if(Q.type==="text"&&typeof Q.text==="string"&&Q.text.trim().length>0)L=!0}}return J("div",{className:"flex flex-col w-full space-y-1",children:[z("div",{className:"space-y-2 w-full",children:U}),L&&z("div",{className:"text-[10px] text-muted-foreground self-start italic pt-1",children:Y.created_by_agent()})]},G.id)}case"toolResult":return z("div",{className:"flex items-center gap-2 text-xs text-muted-foreground bg-muted/40 p-2 rounded-md border border-border/50",children:z("span",{className:"font-semibold",children:Y.tool_result_with_name({name:G.toolName||"tool"})})},G.id);case"thinking_level_change":case"custom":{let X=G;if(X.customType==="shumai_message"){let L=X.details?.referencedAssets||[];return J("div",{className:"flex flex-col items-end w-full space-y-1",children:[L.length>0&&J("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1 w-full",children:[z("div",{className:"font-semibold",children:Y.assets_added_to_context()}),z("ul",{className:"list-disc list-inside space-y-0.5",children:L.map((Z)=>J("li",{className:"truncate",children:[Z.name," ",J("span",{className:"text-muted-foreground/70",children:["(",Z.type,")"]})]},Z.id))})]}),z("div",{className:"bg-primary text-primary-foreground rounded-lg px-3 py-2 max-w-[85%] text-sm whitespace-pre-wrap shadow-xs break-words",children:h(X.content)})]},G.id)}if(X.customType==="context_display_info"){let L=X.details?.assets||[];if(L.length===0)return null;return J("div",{className:"text-xs text-muted-foreground bg-muted/40 p-2.5 rounded-lg border border-border/50 space-y-1 my-1",children:[z("div",{className:"font-semibold",children:Y.assets_added_to_context()}),z("ul",{className:"list-disc list-inside space-y-0.5",children:L.map((Z)=>J("li",{className:"truncate",children:[Z.name," ",J("span",{className:"text-muted-foreground/70",children:["(",Z.type,")"]})]},Z.id))})]},G.id)}let $=X.content||"";return z("div",{className:"text-center text-xs text-muted-foreground italic bg-muted/20 py-1.5 rounded",children:h($)},G.id)}default:return null}};return J("div",{ref:Ez,className:w("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Fz&&z("div",{className:"absolute inset-0 bg-accent/30 border-2 border-primary z-50 pointer-events-none flex items-center justify-center p-6 text-center animate-in fade-in duration-150",children:J("div",{className:"bg-background/95 text-foreground px-4 py-3 rounded-xl border border-border/80 flex flex-col items-center gap-2 shadow-lg max-w-[80%] animate-in zoom-in-95 duration-150",children:[z(T,{className:"h-6 w-6 text-primary animate-bounce"}),z("span",{className:"text-sm font-semibold text-foreground",children:Y.chatbot_drag_drop_hint()||"Drop assets here"})]})}),z("div",{className:"flex items-center justify-between p-4 pt-[0.7rem] flex-shrink-0",children:N?J(M,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.history()})}),z("button",{onClick:()=>u(!1),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:"Close History",children:z(e,{className:"h-4 w-4"})})]}):J(M,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.shumai_agent()})}),J("div",{className:"flex items-center gap-1",children:[z("button",{onClick:Pz,className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.new_chat(),children:z(Gz,{className:"h-4 w-4"})}),z("button",{onClick:()=>u(!0),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.history(),children:z(S,{className:"h-4 w-4"})})]})]})}),N?z(I,{className:"flex-1 p-4 min-h-0",children:m.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground p-4 text-center",children:[z(S,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.no_history_sessions()})]}):z("div",{className:"space-y-2 pb-4",children:m.map((G)=>{let X=G.id===Wz;return J("div",{className:w("group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card",X?"border-primary":"border-border hover:bg-accent/30"),children:[J("div",{onClick:()=>W&&Nz(W,G.id),className:"flex-1 min-w-0 pr-6",children:[z("div",{className:"text-sm font-semibold text-foreground truncate",children:G.name||Y.new_chat()}),z("div",{className:"text-xs text-muted-foreground mt-0.5",children:Zz(G.createdAt)})]}),z("button",{onClick:($)=>{if($.stopPropagation(),W&&confirm(Y.delete_session_confirm()))Qz(W,G.id)},className:"absolute right-3 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity text-muted-foreground hover:text-destructive p-1 rounded hover:bg-muted",title:"Delete Session",children:z(A,{className:"h-4 w-4"})})]},G.id)})})}):J(M,{children:[z(I,{ref:y,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:D.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center",children:[z(T,{className:"h-8 w-8 mb-2 opacity-50 text-muted-foreground"}),z("p",{className:"text-sm",children:Y.chatbot_drag_drop_hint()})]}):J("div",{className:"space-y-4 pb-4",children:[D.map(vz),q&&D.length>0&&(D[D.length-1].role==="user"||D[D.length-1].customType==="shumai_message")&&J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[z(t,{className:"h-3 w-3 animate-spin text-primary"}),z("span",{children:"Thinking..."})]}),z("div",{ref:x})]})}),z("div",{className:"p-2 flex-shrink-0 bg-background",children:J("div",{className:"relative flex flex-col w-full border border-foreground/20 rounded-2xl shadow-xs transition-all duration-200 focus-within:ring-2 focus-within:ring-primary focus-within:border-transparent bg-background overflow-hidden",children:[g.length>0&&z("div",{className:"flex flex-col gap-1.5 min-h-0 max-h-[160px] overflow-y-auto border-b border-border bg-muted/5 p-3 divide-y divide-border/50",children:g.map((G)=>J("div",{className:"flex items-center justify-between py-1.5 text-xs group",children:[J("div",{className:"flex items-baseline gap-1.5 min-w-0 pr-2",children:[z("span",{className:"truncate font-medium text-foreground",children:G.name}),z("span",{className:"text-[9px] text-muted-foreground uppercase flex-shrink-0",children:G.type})]}),z("button",{onClick:()=>Lz(G.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5",title:Y.remove_from_context(),children:z(A,{className:"h-3.5 w-3.5"})})]},G.id))}),z("textarea",{value:C,onChange:(G)=>d(G.target.value),onKeyDown:Cz,placeholder:"Type a message...",rows:2,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-hidden resize-none min-h-[44px] max-h-[120px] px-3 py-2 text-sm focus-visible:outline-hidden focus:ring-transparent focus:border-transparent focus-visible:ring-0",disabled:q}),J("div",{className:"flex justify-between items-center px-3 pb-2 pt-1",children:[z("div",{className:"flex items-center gap-1.5 min-w-0 max-w-[70%]",children:H.length>0?J(_z,{value:F||"",onValueChange:(G)=>B(G),disabled:q,children:[z(Kz,{className:"h-8 border-none bg-transparent hover:bg-muted text-muted-foreground hover:text-foreground focus:ring-0 focus:ring-offset-0 px-2 py-0 gap-1.5 text-xs shrink-0 select-none shadow-none max-w-full",children:z($z,{placeholder:Y.select_agent()})}),z(Uz,{children:H.map((G)=>z(Vz,{value:G.id,children:J("div",{className:"flex items-center gap-2",children:[G.avatar?z("img",{src:G.avatar,alt:G.name,className:"w-4 h-4 rounded-full object-cover"}):z(T,{className:"w-4 h-4 text-muted-foreground"}),z("span",{className:"text-xs",children:G.name})]})},G.id))})]}):z("div",{className:"flex items-center gap-1.5 px-2 py-1 text-[11px] text-muted-foreground/60 italic select-none",children:z("span",{children:Y.no_chat_agents_warning()})})}),q?z("button",{onClick:()=>{if(W)Oz(W)},className:"p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm bg-destructive text-destructive-foreground hover:bg-destructive/90 transform hover:-translate-y-0.5",title:"Stop generation",children:z("div",{className:"h-4 w-4 flex items-center justify-center",children:z("div",{className:"h-3 w-3 bg-current rounded-[2px] bg-white"})})}):z("button",{onClick:a,disabled:!C.trim()||!F,className:w("p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm",C.trim()&&F?"bg-primary text-primary-foreground hover:bg-primary/95 transform hover:-translate-y-0.5":"bg-muted text-muted-foreground cursor-not-allowed opacity-50"),children:z(s,{className:"h-4 w-4"})})]})]})})]})]})}
2
- export{gz as h};
@@ -1 +0,0 @@
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 +0,0 @@
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};
@@ -1 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
1
- import{$ as O2,aa as F0}from"./chunk-srs9jq8f.js";import{wf as w0,xf as U2,yf as y2}from"./chunk-f4d3v0nc.js";import{Ff as y0,Gf as r0,Hf as x0,If as h0,Jf as L0,Lf as T0}from"./chunk-2q7ew7yz.js";import{Nf as o,Of as u,Pf as j,Uf as h,Vf as t}from"./chunk-ktvmxqfg.js";import{Rg as w2,Sg as T2,Tg as C2,ah as R2}from"./chunk-785kxysj.js";import{Nh as l0,Oh as r,Yh as K0,bi as O0}from"./chunk-2sc2jxd3.js";import{ci as S0}from"./chunk-f32kxe6c.js";import{di as Q0,ei as q0,fi as b0}from"./chunk-2f35h4fn.js";import{gi as F2,ii as V2,ji as S2,ki as m2}from"./chunk-4k2d8w9w.js";import{Bi as E0,Di as D0,Ii as $0,Ri as k2,Si as K2,Ti as J2,Ui as Z2,Wi as X2,Xi as Y2,Yi as H0,wi as H2}from"./chunk-s503pcvb.js";import{_i as Z0}from"./chunk-axb1f1ae.js";import{$i as I,Ak as b2,Bk as B2,Bl as A2,El as g2,Gl as W2,Hj as v0,Kj as Q2,Nl as v2,Ol as c2,Sk as G2,Sl as _0,Tj as $2,Wl as B0,Xj as c0,_j as q2,ak as m0,bj as P,bk as X0,cj as J,ck as j0,dk as n0,il as k0,jk as i0,km as A0,qm as x,rl as Y0,tl as M2,tm as G,um as G0,wj as f0,zl as W0}from"./chunk-w9p59ahz.js";import{rn as E}from"./chunk-txkmks1h.js";function l2(N){let $=N.lastIndexOf(".");if($>0)return[0,$];return[0,N.length]}function z5(N){N.focus();let[$,k]=l2(N.value);if(typeof N.setSelectionRange==="function")N.setSelectionRange($,k);else N.select()}var i=D0((N)=>({fields:[],loadedProjectId:null,setFields:($,k)=>N({fields:$,loadedProjectId:k}),updateFields:($)=>N({fields:$})}));function o0(N,$){let{start:k,end:K}=x0($?.in,N),X=+k>+K,M=X?+k:+K,z=X?K:k;z.setHours(0,0,0,0);let Y=$?.step??1;if(!Y)return[];if(Y<0)Y=-Y,X=!X;let H=[];while(+z<=M)H.push(l0(k,z)),z.setDate(z.getDate()+Y),z.setHours(0,0,0,0);return X?H.reverse():H}function g0(N,$){return r(N,$?.in).getDate()}function u0(N,$){return r(N,$?.in).getDay()}function R0(N,$){return r(N,$?.in).getHours()}function U0(N,$){return r(N,$?.in).getMinutes()}var a=E(I(),1);var x2=({value:N,config:$,onSave:k,readOnly:K})=>{let X=$?.date,[M,z]=a.useState(!1),Y=a.useRef(null),H=N?new Date(N):new Date,Q=K0(H)?H:new Date,[q,b]=a.useState(Q);a.useEffect(()=>{if(M&&N){let g=new Date(N);if(K0(g))b(g)}},[M,N]),a.useEffect(()=>{let g=(_)=>{if(Y.current&&!Y.current.contains(_.target)){if(M)z(!1)}};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[M]);let v=()=>{if(!K)z(!0)},S=(g)=>{if(!g)return"";let _=new Date(g);if(!K0(_))return"Invalid Date";let c="PPP";if(X?.displayFormat==="usa")c="MM/dd/yyyy";else if(X?.displayFormat==="euro")c="dd/MM/yyyy";else if(X?.displayFormat==="iso")c="yyyy-MM-dd";if(X?.includeTime)if(X?.timeFormat==="twenty_four_hour")c+=" HH:mm";else c+=" p";let C=O0(_,c);if(X?.displayTimezone)C+=` (${Intl.DateTimeFormat().resolvedOptions().timeZone})`;return C},Z=new Date(q.getFullYear(),q.getMonth(),1),F=r0(q),w=o0({start:Z,end:F}),y=u0(Z),A=(g)=>{let _=new Date(g);if(X?.includeTime)_.setHours(R0(Q)),_.setMinutes(U0(Q));let c=_.toISOString();if(k(c),!X?.includeTime)z(!1)},T=(g,_)=>{let c=N?new Date(N):new Date;if(!K0(c))c.setTime(new Date().getTime());if(g==="hour")c.setHours(_);if(g==="minute")c.setMinutes(_);let C=c.toISOString();k(C)},W=Array.from({length:24},(g,_)=>_),O=Array.from({length:12},(g,_)=>_*5);if(M)return J("div",{className:"relative w-full",ref:Y,children:[P("div",{className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm shadow-sm min-h-[28px] flex items-center",children:N?S(N):P("span",{className:"text-muted-foreground",children:"Select date..."})}),J("div",{className:"absolute z-50 top-full left-0 mt-1 bg-popover border border-border rounded-lg shadow-xl flex flex-col md:flex-row overflow-hidden min-w-[280px]",children:[J("div",{className:"p-4 w-64",children:[J("div",{className:"flex justify-between items-center mb-4",children:[P("button",{onClick:()=>b(y0(q,-1)),className:"p-1 hover:bg-accent rounded",children:P(j0,{className:"w-4 h-4"})}),P("span",{className:"font-semibold text-sm",children:O0(q,"MMMM yyyy")}),P("button",{onClick:()=>b(y0(q,1)),className:"p-1 hover:bg-accent rounded",children:P(n0,{className:"w-4 h-4"})})]}),P("div",{className:"grid grid-cols-7 gap-1 text-center text-xs mb-2 text-muted-foreground",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map((g)=>P("div",{children:g},g))}),J("div",{className:"grid grid-cols-7 gap-1 text-center text-sm",children:[Array.from({length:y}).map((g,_)=>P("div",{},`empty-${_}`)),w.map((g)=>{let _=N?new Date(N):null,c=_&&K0(_)&&g0(_)===g0(g)&&h0(_)===h0(g)&&L0(_)===L0(g);return P("button",{onClick:()=>A(g),className:`w-8 h-8 rounded-full flex items-center justify-center hover:bg-accent transition-colors ${c?"bg-primary text-primary-foreground hover:bg-primary/90":"text-foreground"}`,children:g0(g)},g.toString())})]})]}),X?.includeTime&&J("div",{className:"border-l border-border bg-muted w-32 flex flex-col",children:[J("div",{className:"p-2 border-b border-border text-xs font-semibold text-muted-foreground flex items-center justify-center gap-1",children:[P(i0,{className:"w-3 h-3"})," Time"]}),J("div",{className:"flex flex-1 h-64",children:[P("div",{className:"flex-1 overflow-y-auto scrollbar-hide border-r border-border",children:W.map((g)=>P("div",{onClick:()=>T("hour",g),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${R0(Q)===g?"bg-primary/10 font-medium text-primary":""}`,children:g.toString().padStart(2,"0")},g))}),P("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:O.map((g)=>P("div",{onClick:()=>T("minute",g),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${U0(Q)===g?"bg-primary/10 font-medium text-primary":""}`,children:g.toString().padStart(2,"0")},g))})]})]})]})]});return P("div",{onClick:v,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors ${!K?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:N?S(N):P("span",{className:"text-muted-foreground italic",children:"Empty"})})},a0=x2;var l=E(I(),1);var o2=({value:N,onSave:$,readOnly:k})=>{let[K,X]=l.useState(!1),[M,z]=l.useState(N||""),Y=l.useRef(null),H=l.useRef(null),[Q,q]=l.useState(!1);l.useEffect(()=>{z(N||"")},[N]),l.useEffect(()=>{if(K&&Y.current)Y.current.focus(),q(!1)},[K]),l.useEffect(()=>{let Z=(F)=>{if(Q&&H.current&&!H.current.contains(F.target))q(!1)};if(Q)document.addEventListener("mousedown",Z);return()=>{document.removeEventListener("mousedown",Z)}},[Q]);let b=()=>{X(!1),$(M)},v=(Z)=>{Z.stopPropagation(),q(!0)},S=(Z)=>{if(Z.stopPropagation(),!k)X(!0)};if(K)return P("textarea",{ref:Y,value:M,onChange:(Z)=>z(Z.target.value),onBlur:b,className:"w-full min-h-[80px] p-2 border border-ring rounded bg-background text-sm outline-none shadow-sm resize-none"});return J("div",{ref:H,className:"relative w-full text-sm",children:[P("div",{onClick:v,className:`w-full text-foreground rounded border border-transparent transition-all px-2 py-1 h-[48px] line-clamp-2 whitespace-pre-wrap overflow-hidden ${!k?"cursor-pointer hover:bg-accent hover:border-border":"cursor-pointer"}`,title:"Click to expand",children:N?N:P("span",{className:"text-muted-foreground italic",children:"Empty"})}),Q&&P("div",{onClick:S,className:`absolute top-0 left-0 w-full min-h-full h-auto z-50 bg-background border border-ring rounded shadow-lg px-2 py-1 whitespace-pre-wrap ${!k?"cursor-text":""}`,children:N?N:P("span",{className:"text-muted-foreground italic",children:"Empty"})})]})},d0=o2;var d=E(I(),1);var u2=({value:N,config:$,onSave:k,readOnly:K})=>{let X=$?.number,[M,z]=d.useState(!1),[Y,H]=d.useState(""),Q=d.useRef(null);d.useEffect(()=>{H(N!==void 0&&N!==null?N.toString():"")},[N]),d.useEffect(()=>{if(M&&Q.current)Q.current.focus()},[M]);let q=()=>{if(!K)z(!0)},b=()=>{if(z(!1),Y==="")k(void 0);else{let Z=parseFloat(Y);k(isNaN(Z)?void 0:Z)}},v=(Z)=>{if(Z.key==="Enter")Z.stopPropagation(),Q.current?.blur()},S=(Z)=>{if(Z===void 0||Z===null||isNaN(Z))return"";return Z.toFixed(X?.scale)};if(M)return P("input",{ref:Q,type:"number",step:1/Math.pow(10,X?.scale||0),value:Y,onChange:(Z)=>H(Z.target.value),onBlur:b,onKeyDown:v,onDoubleClick:(Z)=>Z.stopPropagation(),className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm text-left font-mono"});return P("div",{onClick:q,onDoubleClick:(Z)=>Z.stopPropagation(),className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors text-left font-mono ${!K?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:N!==void 0&&N!==null?S(N):P("span",{className:"text-muted-foreground italic font-sans text-left block",children:"Empty"})})},t0=u2;var s0=E(I(),1);var j2=({value:N,config:$,onSave:k,readOnly:K})=>{let X=$?.rating,M=Math.max(2,Math.min(6,X?.maxValue||5)),[z,Y]=s0.useState(null),H=(q,b)=>{if(q.stopPropagation(),K)return;let v;if(N===b)v=0;else v=b;k(v)},Q=Array.from({length:M},(q,b)=>b+1);return P("div",{className:"flex items-center gap-1 h-[28px]",onMouseLeave:()=>!K&&Y(null),onDoubleClick:(q)=>q.stopPropagation(),children:Q.map((q)=>{let b=z!==null?q<=z:q<=(N||0);return P("button",{onClick:(v)=>H(v,q),onMouseEnter:()=>!K&&Y(q),className:`focus:outline-none transition-transform ${!K?"cursor-pointer hover:scale-110":"cursor-default"}`,type:"button",disabled:K,children:P(W0,{className:`w-5 h-5 transition-colors ${b?"fill-yellow-400 text-yellow-400":"fill-muted text-muted-foreground/30"}`})},q)})})},e0=j2;var p0=E(I(),1);var P0;(function(N){N.Base32IncorrectEncoding="B32_ENC_INVALID",N.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",N.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",N.EncodeTimeNegative="ENC_TIME_NEG",N.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",N.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",N.PRNGDetectFailure="PRNG_DETECT",N.ULIDInvalid="ULID_INVALID",N.Unexpected="UNEXPECTED",N.UUIDInvalid="UUID_INVALID"})(P0||(P0={}));class J0 extends Error{constructor(N,$){super(`${$} (${N})`);this.name="ULIDError",this.code=N}}function n2(N){let $=Math.floor(N()*32)%32;return"0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt($)}function i2(N){let $=r2(),k=$&&($.crypto||$.msCrypto)||null;if(typeof k?.getRandomValues==="function")return()=>{let K=new Uint8Array(1);return k.getRandomValues(K),K[0]/256};else if(typeof k?.randomBytes==="function")return()=>k.randomBytes(1).readUInt8()/256;throw new J0(P0.PRNGDetectFailure,"Failed to find a reliable PRNG")}function r2(){if(t2())return self;if(typeof window<"u")return window;if(typeof global<"u")return global;if(typeof globalThis<"u")return globalThis;return null}function a2(N,$){let k="";for(;N>0;N--)k=n2($)+k;return k}function d2(N,$=10){if(isNaN(N))throw new J0(P0.EncodeTimeValueMalformed,`Time must be a number: ${N}`);else if(N>281474976710655)throw new J0(P0.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${N}`);else if(N<0)throw new J0(P0.EncodeTimeNegative,`Time must be positive: ${N}`);else if(Number.isInteger(N)===!1)throw new J0(P0.EncodeTimeValueMalformed,`Time must be an integer: ${N}`);let k,K="";for(let X=$;X>0;X--)k=N%32,K="0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt(k)+K,N=(N-k)/32;return K}function t2(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function N2(N,$){let k=$||i2(),K=!N||isNaN(N)?Date.now():N;return d2(K,10)+a2(16,k)}function s2(N,$,k){let K=N.slice();return K.splice(k,0,K.splice($,1)[0]),K}function P2(N,$,k,K){if(k===K)return N;let X=s2($,k,K),M=new Set($.map((Y)=>Y.id)),z=0;return N.map((Y)=>M.has(Y.id)?X[z++]:Y)}async function l5(N){let $=[],k=[],K=N.items;if(K)for(let z=0;z<K.length;z++){let Y=K[z];if(Y.kind==="file"){let H=Y.webkitGetAsEntry?.();if(H)k.push({entry:H,path:""})}}else return Array.from(N.files);let X=(z)=>{return new Promise((Y)=>{z.readEntries((H)=>Y(H),()=>Y([]))})},M=(z)=>{return new Promise((Y,H)=>{z.file((Q)=>Y(Q),(Q)=>H(Q))})};while(k.length>0){let z=k.shift();if(!z)continue;let{entry:Y,path:H}=z;if(Y.isFile)try{let Q=await M(Y),q=H?`${H}/${Q.name}`:Q.name;Object.defineProperty(Q,"webkitRelativePath",{value:q,writable:!1,configurable:!0}),$.push(Q)}catch(Q){console.error("Error reading file entry:",Q)}else if(Y.isDirectory){let Q=Y.createReader(),q=[],b=await X(Q);while(b.length>0)q=q.concat(b),b=await X(Q);let v=H?`${H}/${Y.name}`:Y.name;for(let S of q)k.push({entry:S,path:v})}}return $}var p=E(I(),1);var _2=E(I(),1);function z2(){let[N,$]=_2.useState(!1);return J(k2,{open:N,onOpenChange:$,children:[P(K2,{asChild:!0,children:J(x,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 p-0 hover:bg-transparent text-muted-foreground hover:text-foreground inline-flex items-center justify-center shrink-0 ml-1",title:G.autofill_source_help_title(),children:[P(f0,{className:"h-3.5 w-3.5"}),P("span",{className:"sr-only",children:G.autofill_source_help_title()})]})}),J(J2,{className:"sm:max-w-[500px]",children:[J(Z2,{children:[J(X2,{className:"flex items-center gap-2",children:[P(f0,{className:"h-5 w-5 text-muted-foreground"}),G.autofill_source_help_title()]}),P(Y2,{children:G.autofill_source_help_desc()})]}),J("div",{className:"space-y-4 py-2",children:[J("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[J("div",{className:"flex items-center gap-2 font-medium text-sm",children:[P($2,{className:"h-4 w-4 text-muted-foreground shrink-0"}),P("span",{children:G.autofill_source_none()})]}),P("p",{className:"text-xs text-muted-foreground leading-relaxed",children:G.autofill_source_none_desc()}),P("p",{className:"text-xs italic text-muted-foreground/80",children:G.autofill_source_none_example()})]}),J("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[J("div",{className:"flex items-center gap-2 font-medium text-sm",children:[P(v0,{className:"h-4 w-4 text-amber-500 shrink-0"}),P("span",{children:G.autofill_source_content()})]}),P("p",{className:"text-xs text-muted-foreground leading-relaxed",children:G.autofill_source_content_desc()}),P("p",{className:"text-xs italic text-muted-foreground/80",children:G.autofill_source_content_example()})]}),J("div",{className:"rounded-lg border p-3.5 space-y-1.5 bg-muted/30",children:[J("div",{className:"flex items-center gap-2 font-medium text-sm",children:[P(c0,{className:"h-4 w-4 text-blue-500 shrink-0"}),P("span",{children:G.autofill_source_creation_context()})]}),P("p",{className:"text-xs text-muted-foreground leading-relaxed",children:G.autofill_source_creation_context_desc()}),P("p",{className:"text-xs italic text-muted-foreground/80",children:G.autofill_source_creation_context_example()})]})]})]})]})}var V0=["red","orange","yellow","green","blue","purple","gray"],I0={red:{bg:"rgba(239, 68, 68, 0.15)",text:"#ef4444",hex:"#ef4444"},orange:{bg:"rgba(249, 115, 22, 0.15)",text:"#f97316",hex:"#f97316"},yellow:{bg:"rgba(234, 179, 8, 0.15)",text:"#ca8a04",hex:"#eab308"},green:{bg:"rgba(34, 197, 94, 0.15)",text:"#16a34a",hex:"#22c55e"},blue:{bg:"rgba(59, 130, 246, 0.15)",text:"#2563eb",hex:"#3b82f6"},purple:{bg:"rgba(168, 85, 247, 0.15)",text:"#9333ea",hex:"#a855f7"},gray:{bg:"rgba(128, 128, 128, 0.15)",text:"#4b5563",hex:"#808080"},system:{bg:"rgba(128, 128, 128, 0.1)",text:"#6b7280",hex:"#808080"}};function z0(N){if(!N)return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:"#6b7280"};let $=N.toLowerCase(),k=I0[$];if(k)return{backgroundColor:k.bg,color:k.text};if(N.startsWith("#"))return{backgroundColor:`${N}33`,color:N};return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:N}}function M0(N=[]){let $=new Set(N.map((K)=>K.color?.toLowerCase()).filter(Boolean)),k=V0.filter((K)=>!$.has(K.toLowerCase()));if(k.length>0)return k[Math.floor(Math.random()*k.length)];return V0[Math.floor(Math.random()*V0.length)]}var e2={[h.text]:W2,[h.longText]:Q2,[h.select]:G2,[h.selectMulti]:A2,[h.rating]:W0,[h.number]:B2,[h.toggle]:g2,[h.date]:q2,[h.user]:v2,[h.userMulti]:c2};function N5({field:N,index:$,onVisibilityChange:k}){let{ref:K,handleRef:X}=y2({id:N.id,index:$}),M=N.config?.type?e2[N.config.type]:null;return J("div",{ref:K,className:"flex items-center justify-between p-2 rounded-md hover:bg-muted",children:[J("div",{className:"flex items-center gap-2",children:[P("div",{ref:X,className:"cursor-grab",children:P(b2,{className:"h-4 w-4 text-muted-foreground"})}),M&&P(M,{className:"h-4 w-4 text-muted-foreground shrink-0"}),N.config?.autofillSource===t.CONTENT&&P(v0,{className:"h-4 w-4 text-muted-foreground shrink-0"}),N.config?.autofillSource===t.CREATION_CONTEXT&&P(c0,{className:"h-4 w-4 text-muted-foreground shrink-0"}),P("span",{className:"text-sm truncate",children:N.config?.name})]}),P(S0,{checked:N.visible,onCheckedChange:(z)=>k(N.id,z)})]})}function b1({projectId:N,onManageFields:$,onSave:k}){let{fields:K,updateFields:X}=i(),[M,z]=p.useState(""),[Y,H]=p.useState("list"),[Q,q]=p.useState(""),[b,v]=p.useState(""),[S,Z]=p.useState(t.NONE),[F,w]=p.useState(""),[y,A]=p.useState([]),T=H2();p.useEffect(()=>{T.invalidateQueries({queryKey:["fields",N]})},[N,T]);let W=$0.api.projects[":projectId"].fields.order.$patch,{mutate:O}=E0({mutationFn:async(B)=>{if(!(await W(B)).ok)throw Error(G.failed_update_fields_order());return null}}),g=$0.api.projects[":projectId"].fields.$post,{mutate:_}=E0({mutationFn:async(B)=>{let m=await g(B);if(!m.ok)throw Error(G.failed_create_field());return await m.json()},onSuccess:(B)=>{let m={...B,visible:!0},U=[...K,m];X(U),q(""),A([]),O({param:{projectId:N},json:U.map((V)=>({fieldId:V.id,visible:V.visible||!1}))}),k?.()}}),c=p.useMemo(()=>K.filter((B)=>B.config?.name?.toLowerCase().includes(M.toLowerCase())),[K,M]),C=(B)=>{if(B.canceled)return;let{source:m}=B.operation;if(!U2(m))return;let{initialIndex:U,index:V}=m;if(U===V)return;let D=P2(K,c,U,V);X(D),O({param:{projectId:N},json:D.map((N0)=>({fieldId:N0.id,visible:N0.visible||!1}))})},L=(B,m)=>{let U=K.map((V)=>V.id===B?{...V,visible:m}:V);X(U),O({param:{projectId:N},json:U.map((V)=>({fieldId:V.id,visible:V.visible||!1}))})},R=()=>{if(!Q||!b)return;let B=b===h.select?{select:{options:y}}:b===h.selectMulti?{selectMulti:{options:y}}:{};_({param:{projectId:N},json:{config:{name:Q,type:b,autofillSource:S,...B},label:Q,description:F}})},f=K.filter((B)=>B.visible).length;if(Y==="create")return P("div",{className:"w-80 p-4",children:J("div",{className:"space-y-4",children:[J("div",{className:"space-y-2",children:[P(Z0,{htmlFor:"field-name",children:G.field_name()}),P(G0,{id:"field-name",placeholder:G.new_field_placeholder(),value:Q,onChange:(B)=>q(B.target.value),autoFocus:!0})]}),J("div",{className:"space-y-2",children:[P(Z0,{children:G.field_type()}),J(F2,{children:[P(V2,{asChild:!0,children:J(x,{variant:"outline",className:"w-full justify-between font-normal",children:[b?P("span",{className:"capitalize",children:b.replace(/_/g," ")}):P("span",{className:"text-muted-foreground border-dashed",children:G.select_field_type()}),P(X0,{className:"ml-2 h-4 w-4 opacity-50"})]})}),P(S2,{className:"w-[--radix-dropdown-menu-trigger-width]",children:Object.values(h).map((B)=>P(m2,{onClick:()=>{v(B),A([])},className:"capitalize",children:B.replace(/_/g," ")},B))})]})]}),J("div",{className:"space-y-2",children:[P(Z0,{htmlFor:"field-desc",children:G.description()}),P(G0,{id:"field-desc",placeholder:G.description_optional_placeholder(),value:F,onChange:(B)=>w(B.target.value)})]}),J("div",{className:"space-y-2",children:[J("div",{className:"flex items-center gap-1",children:[P(Z0,{children:G.autofill_source()}),P(z2,{})]}),J(O2,{type:"single",value:S,onValueChange:(B)=>{if(B)Z(B)},className:"w-full grid grid-cols-3 border rounded-md p-1 gap-1",children:[P(F0,{value:t.NONE,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:G.autofill_source_none()}),P(F0,{value:t.CONTENT,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:G.autofill_source_content()}),P(F0,{value:t.CREATION_CONTEXT,className:"text-[11px] leading-tight py-1 px-1 h-auto min-h-[32px] w-full text-center justify-center whitespace-normal font-medium",children:G.autofill_source_creation_context()})]})]}),(b===h.select||b===h.selectMulti)&&J("div",{className:"space-y-2",children:[J("div",{className:"flex items-center justify-between",children:[P(Z0,{className:"text-sm font-medium",children:G.options()}),J(x,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{let B={id:N2(),displayName:G.new_option(),color:M0(y)};A([...y,B])},children:[P(k0,{className:"h-4 w-4 mr-1"})," ",G.add_option()]})]}),P("div",{className:"space-y-2 max-h-40 overflow-y-auto pr-1",children:y.map((B,m)=>J("div",{className:"flex items-center gap-2",children:[P(G0,{value:B.displayName,onChange:(U)=>{let V=[...y];V[m]={...B,displayName:U.target.value},A(V)},placeholder:G.option_name_placeholder(),className:"h-8 flex-1"}),J(o,{children:[P(u,{asChild:!0,children:P("button",{type:"button",className:"w-6 h-6 rounded-full border shrink-0 cursor-pointer focus:outline-none hover:scale-105 transition-transform",style:{backgroundColor:I0[B.color||""]?.hex||B.color||"#808080"}})}),P(j,{className:"p-2 w-auto",align:"end",children:P("div",{className:"flex gap-1",children:V0.map((U)=>P("button",{type:"button",className:"w-5 h-5 rounded-full border cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:I0[U]?.hex||U},onClick:()=>{let V=[...y];V[m]={...B,color:U},A(V)}},U))})})]}),P(x,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{A(y.filter((U,V)=>V!==m))},children:P(_0,{className:"h-4 w-4"})})]},B.id))})]}),J("div",{className:"flex gap-2 pt-2",children:[P(x,{variant:"secondary",className:"flex-1",onClick:()=>{H("list"),q(""),v(""),Z(t.NONE),w(""),A([])},children:G.cancel()}),P(x,{className:"flex-1",onClick:R,disabled:!Q||!b,children:G.save()})]})]})});return J("div",{className:"w-80 p-4",children:[P("div",{className:"flex items-center justify-between mb-4",children:J("h3",{className:"font-semibold",children:[G.fields()," ",P("span",{className:"text-muted-foreground text-sm font-normal",children:G.visible_count({count:f})})]})}),J("div",{className:"relative mb-4",children:[P(Y0,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),P(G0,{placeholder:G.search_fields_placeholder(),value:M,onChange:(B)=>z(B.target.value),className:"pl-8"})]}),P("div",{className:"max-h-60 overflow-y-auto pr-2",children:P(R2,{sensors:[C2.configure({activationConstraints:[new T2.Distance({value:8})]}),w2],onDragEnd:C,children:c.map((B,m)=>P(N5,{field:B,index:m,onVisibilityChange:L},B.id))})}),$&&J("div",{className:"mt-4 space-y-2",children:[J(x,{variant:"secondary",className:"w-full",onClick:$,children:[P(M2,{className:"h-4 w-4 mr-2"}),G.manage_fields()]}),J(x,{className:"w-full",onClick:()=>H("create"),children:[P(k0,{className:"h-4 w-4 mr-2"}),G.new_field()]})]})]})}var P5=({value:N,config:$,onSave:k,readOnly:K,fieldId:X})=>{let M=$?.select,z=M?.options||[],[Y,H]=p0.useState(!1),[Q,q]=p0.useState(""),b=z.find((W)=>W.id===N),v=Q.trim(),S=z.filter((W)=>W.displayName.toLowerCase().includes(v.toLowerCase())),Z=z.some((W)=>W.displayName.trim().toLowerCase()===v.toLowerCase()||W.id.toLowerCase()===v.toLowerCase()),F=()=>{if(!K)H(!0)},w=(W)=>{k(W),H(!1),q("")},y=(W)=>{if(K)return;if(H(W),!W)q("")},A=async()=>{if(!v)return;let W={id:v.toLowerCase().replace(/\s+/g,"-"),displayName:v,color:M0(z)},O=[...z,W],g={...$,select:{...M,options:O}};if(X)try{let _=await $0.api.fields[":fieldId"].$put({param:{fieldId:X},json:{config:g}});if(!_.ok){H0.error(G.failed_update_field());return}let c=await _.json(),L=i.getState().fields.map((R)=>R.id===c.id?{...R,...c,visible:R.visible}:R);i.getState().updateFields(L)}catch{H0.error(G.failed_update_field());return}k(W.id),q(""),H(!1)};return P("div",{className:"relative w-full",onClick:(W)=>W.stopPropagation(),children:J(o,{open:!K&&Y,onOpenChange:y,children:[P(u,{asChild:!0,children:J("div",{onClick:F,className:`flex items-center justify-between w-full h-[28px] px-2 rounded border border-transparent transition-colors ${!K?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((W)=>{if(!W)return P("span",{className:"text-muted-foreground italic text-sm",children:"Select an option"});return P("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium h-[22px]",style:z0(W.color),children:W.displayName})})(b),!K&&P(X0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),J(j,{side:"bottom",align:"start",sideOffset:4,className:"p-1.5 w-64 max-h-72 flex flex-col bg-popover border border-border rounded-lg shadow-lg",children:[J("div",{className:"relative pb-1.5 border-b border-border mb-1",onClick:(W)=>W.stopPropagation(),children:[P(Y0,{className:"w-3.5 h-3.5 absolute left-2 top-2 text-muted-foreground"}),P("input",{type:"text",className:"w-full pl-7 pr-2 py-1 text-xs bg-muted/50 border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-ring text-foreground",placeholder:G.search_options_placeholder(),value:Q,onChange:(W)=>q(W.target.value),autoFocus:!0})]}),J("div",{className:"overflow-y-auto max-h-48 min-h-[120px] space-y-0.5",children:[Q===""&&J("div",{onClick:()=>w(""),className:"px-2.5 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded cursor-pointer flex items-center gap-2",children:[P(_0,{className:"w-3.5 h-3.5"})," Clear"]}),S.map((W)=>P("div",{onClick:()=>w(W.id),className:`px-2.5 py-1.5 text-xs hover:bg-accent rounded cursor-pointer flex items-center justify-between ${N===W.id?"bg-accent/50 font-medium":""}`,children:P("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:z0(W.color),children:W.displayName})},W.id)),S.length===0&&!v&&P("div",{className:"px-2.5 py-2 text-xs text-muted-foreground italic text-center",children:G.no_options_found()}),v!==""&&!Z&&J("div",{onClick:A,className:"px-2.5 py-1.5 text-xs text-primary hover:bg-accent rounded cursor-pointer flex items-center gap-1.5 font-medium border-t border-border mt-1 pt-1.5",children:[P(k0,{className:"w-3.5 h-3.5 shrink-0"}),P("span",{className:"truncate",children:G.add_option_with_name({name:v})})]})]})]})]})})},h2=P5;var s=E(I(),1);var $5=({value:N=[],config:$,onSave:k,readOnly:K,fieldId:X})=>{let M=$?.selectMulti,z=M?.options||[],Y=s.useRef(null),[H,Q]=s.useState(!1),[q,b]=s.useState(N.length),[v,S]=s.useState(""),Z=z.filter((_)=>(N||[]).includes(_.id))||[],F=v.trim(),w=z.filter((_)=>_.displayName.toLowerCase().includes(F.toLowerCase())),y=z.some((_)=>_.displayName.trim().toLowerCase()===F.toLowerCase()||_.id.toLowerCase()===F.toLowerCase());s.useLayoutEffect(()=>{if(H){b(Z.length);return}if(Y.current){let _=Y.current.clientWidth-8,C=document.createElement("canvas").getContext("2d");if(C&&_>0){C.font="500 12px ui-sans-serif, system-ui, sans-serif";let L=4,R=Z.map((D)=>Math.ceil(C.measureText(D.displayName).width)+18);if(R.reduce((D,N0)=>D+N0,0)+Math.max(0,R.length-1)*L<=_){b(Z.length);return}let m=_-32-L,U=0,V=0;for(let D=0;D<R.length;D++){let N0=V>0?U+L+R[D]:R[D];if(N0>m)break;U=N0,V++}b(V)}}},[Z,H,N]);let A=(_)=>{let c=N||[],C;if(c.includes(_))C=c.filter((L)=>L!==_);else C=[...c,_];k(C)},T=async()=>{if(!F)return;let _={id:F.toLowerCase().replace(/\s+/g,"-"),displayName:F,color:M0(z)},c=[...z,_],C={...$,selectMulti:{...M,options:c}};if(X)try{let L=await $0.api.fields[":fieldId"].$put({param:{fieldId:X},json:{config:C}});if(!L.ok){H0.error(G.failed_update_field());return}let R=await L.json(),B=i.getState().fields.map((m)=>m.id===R.id?{...m,...R,visible:m.visible}:m);i.getState().updateFields(B)}catch{H0.error(G.failed_update_field());return}k([...N||[],_.id]),S("")},W=(_)=>{if(_.stopPropagation(),!K)Q(!0)},O=Z.length-q;return P("div",{className:"relative w-full",onClick:(_)=>_.stopPropagation(),children:J(o,{open:!K&&H,onOpenChange:(_)=>{if(K)return;if(Q(_),!_)S("")},children:[P(u,{asChild:!0,children:J("div",{ref:Y,onClick:W,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!K||O>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[Z.length===0&&P("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),Z.slice(0,q).map((_)=>P("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border border-transparent whitespace-nowrap h-[22px]",style:z0(_.color),children:_.displayName},_.id)),O>0&&J("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",O]})]})}),J(j,{side:"bottom",align:"start",sideOffset:4,className:"p-1.5 w-64 max-h-72 flex flex-col bg-popover border border-border rounded-lg shadow-lg",children:[J("div",{className:"relative pb-1.5 border-b border-border mb-1",onClick:(_)=>_.stopPropagation(),children:[P(Y0,{className:"w-3.5 h-3.5 absolute left-2 top-2 text-muted-foreground"}),P("input",{type:"text",className:"w-full pl-7 pr-2 py-1 text-xs bg-muted/50 border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-ring text-foreground",placeholder:G.search_options_placeholder(),value:v,onChange:(_)=>S(_.target.value),autoFocus:!0})]}),J("div",{className:"overflow-y-auto max-h-48 min-h-[120px] space-y-0.5",children:[w.map((_)=>{let c=(N||[]).includes(_.id);return J("div",{onClick:()=>A(_.id),className:`px-2.5 py-1.5 hover:bg-accent rounded cursor-pointer flex items-center justify-between text-xs ${c?"bg-accent/30 font-medium":""}`,children:[P("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:z0(_.color),children:_.displayName}),c&&P(m0,{className:"w-3.5 h-3.5 text-primary"})]},_.id)}),w.length===0&&!F&&P("div",{className:"px-2.5 py-2 text-xs text-muted-foreground italic text-center",children:G.no_options_found()}),F!==""&&!y&&J("div",{onClick:T,className:"px-2.5 py-1.5 text-xs text-primary hover:bg-accent rounded cursor-pointer flex items-center gap-1.5 font-medium border-t border-border mt-1 pt-1.5",children:[P(k0,{className:"w-3.5 h-3.5 shrink-0"}),P("span",{className:"truncate",children:G.add_option_with_name({name:F})})]})]})]})]})})},L2=$5;var e=E(I(),1);var k5=({value:N,onSave:$,readOnly:k})=>{let[K,X]=e.useState(!1),[M,z]=e.useState(N||""),Y=e.useRef(null);e.useEffect(()=>{z(N||"")},[N]),e.useEffect(()=>{if(K&&Y.current)Y.current.focus()},[K]);let H=()=>{if(!k)X(!0)},Q=()=>{X(!1),$(M)},q=(b)=>{if(b.key==="Enter")Y.current?.blur()};if(K)return P("input",{ref:Y,type:"text",value:M,onChange:(b)=>z(b.target.value),onBlur:Q,onKeyDown:q,className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm"});return P("div",{onClick:H,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded truncate border border-transparent transition-colors ${!k?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:N||P("span",{className:"text-muted-foreground italic",children:"Empty"})})},f2=k5;var K5=({value:N,onSave:$,readOnly:k})=>{return P("div",{className:"flex items-center h-[28px] w-full",onClick:(X)=>X.stopPropagation(),children:P(S0,{checked:N,onCheckedChange:(X)=>{if(!k)$(X)},disabled:k,className:"cursor-pointer"})})},E2=K5;var C0=E(I(),1);var J5=({value:N,onSave:$,readOnly:k})=>{let K=w0(),{members:X,fetchMembers:M}=T0(),[z,Y]=C0.useState(!1);C0.useEffect(()=>{if(K)M(K)},[K,M]);let H=X.find((Z)=>Z.id===N),Q=()=>{if(!k)Y(!0)},q=(Z)=>{$(Z),Y(!1)},b=(Z)=>{if(k)return;Y(Z)},v=(Z)=>{return Z.split(" ").map((F)=>F[0]).slice(0,2).join("").toUpperCase()};return P("div",{className:"relative w-full",onClick:(Z)=>Z.stopPropagation(),children:J(o,{open:!k&&z,onOpenChange:b,children:[P(u,{asChild:!0,children:J("div",{onClick:Q,className:`flex items-center justify-between w-full h-[28px] px-2 rounded border border-transparent transition-colors ${!k?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((Z)=>{if(!Z)return P("span",{className:"text-muted-foreground italic text-sm",children:"Select user"});return J("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border h-[22px]",children:[J(Q0,{className:"w-4 h-4",children:[P(q0,{src:Z.image,alt:Z.name,className:"object-cover"}),P(b0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:v(Z.name)})]}),P("span",{className:"truncate max-w-[120px]",children:Z.name})]})})(H),!k&&P(X0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),J(j,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[200px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:[J("div",{onClick:()=>q(""),className:"px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[P(_0,{className:"w-3 h-3"})," Clear"]}),X.map((Z)=>J("div",{onClick:()=>q(Z.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[J(Q0,{className:"w-5 h-5",children:[P(q0,{src:Z.image,alt:Z.name,className:"object-cover"}),P(b0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:v(Z.name)})]}),P("span",{className:"text-sm font-medium text-foreground",children:Z.name})]},Z.id))]})]})})},I2=J5;var n=E(I(),1);var Z5=({value:N=[],onSave:$,readOnly:k})=>{let K=w0(),{members:X,fetchMembers:M}=T0(),z=n.useRef(null),[Y,H]=n.useState(!1),[Q,q]=n.useState(N.length);n.useEffect(()=>{if(K)M(K)},[K,M]);let b=X.filter((A)=>(N||[]).includes(A.id)),v=(A)=>{return A.split(" ").map((T)=>T[0]).slice(0,2).join("").toUpperCase()};n.useLayoutEffect(()=>{if(Y){q(b.length);return}if(z.current){let A=z.current.clientWidth-8,W=document.createElement("canvas").getContext("2d");if(W&&A>0){W.font="500 12px ui-sans-serif, system-ui, sans-serif";let O=4,g=b.map((f)=>{return Math.min(100,Math.ceil(W.measureText(f.name).width))+40});if(g.reduce((f,B)=>f+B,0)+Math.max(0,g.length-1)*O<=A){q(b.length);return}let C=A-32-O,L=0,R=0;for(let f=0;f<g.length;f++){let B=R>0?L+O+g[f]:g[f];if(B>C)break;L=B,R++}q(R)}}},[b,Y,N]);let S=(A)=>{let T=N||[],W;if(T.includes(A))W=T.filter((O)=>O!==A);else W=[...T,A];$(W)},Z=(A)=>{if(A.stopPropagation(),!k)H(!0)},F=b.length-Q,w=(A)=>{if(k)return;H(A)},y=(A)=>{return J("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border whitespace-nowrap h-[22px]",children:[J(Q0,{className:"w-4 h-4",children:[P(q0,{src:A.image,alt:A.name,className:"object-cover"}),P(b0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:v(A.name)})]}),P("span",{className:"truncate max-w-[100px]",children:A.name})]},A.id)};return P("div",{className:"relative w-full",onClick:(A)=>A.stopPropagation(),children:J(o,{open:!k&&Y,onOpenChange:w,children:[P(u,{asChild:!0,children:J("div",{ref:z,onClick:Z,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!k||F>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[b.length===0&&P("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),b.slice(0,Q).map(y),F>0&&J("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",F]})]})}),P(j,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[200px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:X.map((A)=>{let T=(N||[]).includes(A.id);return J("div",{onClick:()=>S(A.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between rounded-sm",children:[J("div",{className:"flex items-center gap-2",children:[J(Q0,{className:"w-5 h-5",children:[P(q0,{src:A.image,alt:A.name,className:"object-cover"}),P(b0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:v(A.name)})]}),P("span",{className:"text-sm font-medium text-foreground",children:A.name})]}),T&&P(m0,{className:"w-4 h-4 text-primary"})]},A.id)})})]})})},p2=Z5;var X5=(N)=>{if(!N.config)return P("div",{children:"Unknown Field Type"});switch(N.config.type){case"text":return P(f2,{...N,value:N.value,onSave:N.onSave});case"longText":return P(d0,{...N,value:N.value,onSave:N.onSave});case"select":return P(h2,{...N,value:N.value,onSave:N.onSave});case"selectMulti":return P(L2,{...N,value:N.value,onSave:N.onSave});case"rating":return P(e0,{...N,value:N.value,onSave:N.onSave});case"number":return P(t0,{...N,value:N.value,onSave:N.onSave});case"toggle":return P(E2,{...N,value:N.value,onSave:N.onSave});case"date":return P(a0,{...N,value:N.value,onSave:N.onSave});case"user":return P(I2,{...N,value:N.value,onSave:N.onSave});case"userMulti":return P(p2,{...N,value:N.value,onSave:N.onSave});default:return P("div",{children:"Unknown Field Type"})}},GN=X5;var gN=({progress:N,className:$})=>{let K=2*Math.PI*20,X=K-Math.min(100,Math.max(0,N))/100*K;return J("svg",{viewBox:"0 0 50 50",className:B0("w-12 h-12",$),children:[P("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),P("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:K,strokeDashoffset:X,transform:"rotate(-90 25 25)"}),P("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round(N)}%`})]})};var Y5=(N)=>{if(isNaN(N))return"00:00";let $=new Date(N*1000),k=$.getUTCHours(),K=$.getUTCMinutes().toString().padStart(2,"0"),X=$.getUTCSeconds().toString().padStart(2,"0");if(k)return`${k}:${K}:${X}`;return`${K}:${X}`},cN=(N,$,k,K)=>{if(k==="frames")return`${N} fr`;if(k==="standard")return Y5(N/$);let X=Math.round($),M=$!==X,z=!1;if(M&&(X===30||X===60))z=!0;let Y=0;if(K){let Z=K.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(Z){let F=parseInt(Z[1],10),w=parseInt(Z[2],10),y=parseInt(Z[3],10),A=parseInt(Z[5],10);if(z=Z[4]!==":",Y=(F*3600+w*60+y)*X+A,z){let T=F*60+w,W=$<30?2:4;Y-=W*(T-Math.floor(T/10))}}}let H=N+Y;if(z){let Z=$<30?2:4,F=Math.floor(H/(17982*Z/2)),w=H%(17982*Z/2);if(w<Z)w=w+Z;H+=9*Z*F+Z*Math.floor((w-Z)/(1798*Z/2))}let Q=H%X,q=Math.floor(H/X)%60,b=Math.floor(H/(X*60))%60,v=Math.floor(H/(X*3600))%24,S=z?";":":";return`${v.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}${S}${Q.toString().padStart(2,"0")}`};var FN=(N,$)=>{if(!$)return 0;let k=1/$;return N*k+k/2},_5=(N)=>Math.max(100,3000/(N||30)),VN=({dbTotalFrames:N,containerDuration:$,frameRate:k})=>{let K=k||30,X=Math.round($*K);if(N<=0)return X;let M=N/K,z=$-M,Y=_5(K)/1000;return z>Y?X:N};var D2=E(I(),1);function TN({className:N,defaultValue:$,value:k,min:K=0,max:X=100,...M}){let z=D2.useMemo(()=>Array.isArray(k)?k:Array.isArray($)?$:[K,X],[k,$,K,X]);return J(A0.Root,{"data-slot":"slider",defaultValue:$,value:k,min:K,max:X,className:B0("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",N),...M,children:[P(A0.Track,{"data-slot":"slider-track",className:B0("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:P(A0.Range,{"data-slot":"slider-range",className:B0("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:z.length},(Y,H)=>P(A0.Thumb,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},H))]})}
2
- export{P2 as F,l5 as G,i as H,N2 as I,gN as J,z5 as K,e0 as L,z2 as M,V0 as N,I0 as O,z0 as P,M0 as Q,e2 as R,b1 as S,GN as T,Y5 as U,cN as V,FN as W,_5 as X,VN as Y,TN as Z};
@@ -1 +0,0 @@
1
- import{h as Y1}from"./chunk-0qdzjcny.js";import{p as w1,q as K1,r as J1}from"./chunk-4yybby29.js";import{E as X1,y as y1}from"./chunk-082zg4nr.js";import{K as z1}from"./chunk-44xtwvd7.js";import"./chunk-44370df5.js";import"./chunk-srs9jq8f.js";import{ba as G1}from"./chunk-4yhd7bmp.js";import"./chunk-6tv7rm3x.js";import"./chunk-t77dwtcc.js";import"./chunk-6nrynqdw.js";import"./chunk-5bkj2n94.js";import{vf as tz}from"./chunk-pt51m9h1.js";import"./chunk-f4d3v0nc.js";import"./chunk-kejt7kcr.js";import{Lf as rz}from"./chunk-2q7ew7yz.js";import"./chunk-j10gz94w.js";import"./chunk-ktvmxqfg.js";import{eg as az,fg as iz}from"./chunk-k1f3gj25.js";import"./chunk-hmmzbyy1.js";import"./chunk-d6d1j7qq.js";import"./chunk-7g2k89gq.js";import{ng as sz,pg as ez}from"./chunk-7xcyn1ba.js";import"./chunk-785kxysj.js";import"./chunk-ygsbmfcy.js";import"./chunk-1vs91e4q.js";import{kh as Lz}from"./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 oz}from"./chunk-4k2d8w9w.js";import{Bi as l,Ii as H,Ji as Sz,Ki as vz,Li as Dz,Mi as fz,Ni as Fz,Oi as jz,Pi as pz,Qi as mz,Ri as cz,Ti as uz,Ui as Iz,Vi as dz,Wi as lz,Yi as j,ui as Kz,wi as Az,zi as F}from"./chunk-s503pcvb.js";import"./chunk-axb1f1ae.js";import{$i as Pz,Dj as C,Sj as hz,Wl as Nz,aj as xz,bj as y,cj as _,hj as Rz,jj as bz,mj as Cz,qm as Xz,rk as Ez,tm as U,um as nz}from"./chunk-w9p59ahz.js";import{rn as qz}from"./chunk-txkmks1h.js";var Q=qz(Pz(),1);var p1=({item:w})=>{if(w.preview?.thumbnailUrl)return y("img",{src:w.preview.thumbnailUrl,alt:"Preview",className:"w-full h-full object-cover"});if(w.preview?.proxyType==="audio"||w.proxyType==="audio")return y("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:y(hz,{className:"w-5 h-5 text-muted-foreground"})});return y("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:y(Ez,{className:"w-5 h-5 text-muted-foreground"})})},Mz=({projectId:w,currentAssetId:G,parentFolderId:V,initialFiles:W,initialNextCursor:b})=>{let{ref:J,inView:L}=Lz({threshold:0,rootMargin:"200px"}),q=Q.useRef(null),M=Q.useRef(!0),[B,h]=Q.useState(W),[$,S]=Q.useState(b),[v,p]=Q.useState(!!b),[g,E]=Q.useState(!1);return Q.useEffect(()=>{h(W),S(b),p(!!b),M.current=!0},[W,b]),Q.useEffect(()=>{(async()=>{if(!$||g||!L||!v)return;E(!0);try{let k=await H.api.folders[":folderId"].search.$post({param:{folderId:V},json:{assetType:"file",after:$,first:200,recursively:!1,conditions:[]}});if(!k.ok)throw Error("Failed to fetch next page");let D=await k.json(),x=D.data||[];h((n)=>[...n,...x]),S(D.pageInfo?.cursor||void 0),p(!!D.pageInfo?.cursor&&x.length>0)}catch(k){console.error("Error fetching next page:",k)}finally{E(!1)}})()},[L,$,v,g,V]),Q.useEffect(()=>{if(B.some((k)=>k?.id===G)&&q.current)if(M.current)q.current.scrollIntoView({block:"center",inline:"center",behavior:"auto"}),M.current=!1;else q.current.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})},[B,G]),y("div",{className:"h-24 md:h-full w-full md:w-24 bg-gray-100 dark:bg-gray-950 flex flex-row md:flex-col flex-shrink-0 select-none",children:_("div",{className:"flex-1 overflow-x-auto overflow-y-hidden md:overflow-y-auto md:overflow-x-hidden px-4 md:px-0 py-2 md:py-4 flex flex-row md:flex-col items-center gap-3 no-scrollbar",children:[B.map((T)=>{if(!T)return null;let k=T.id===G;return y("div",{ref:T.id===G?q:null,className:"flex-shrink-0",children:y(bz,{to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:T.id},search:{version:void 0},className:Nz("rounded-lg border overflow-hidden flex items-center justify-center transition-all bg-muted/30 block",k?"w-[62px] h-[62px] opacity-100":"w-[52px] h-[52px] opacity-60 hover:opacity-100"),children:y(p1,{item:T})})},T.id)}),v&&y("div",{ref:J,className:"px-2 md:px-0 py-2 md:py-4 flex justify-center items-center h-full md:w-full flex-shrink-0",children:g&&y(C,{className:"h-5 w-5 animate-spin text-muted-foreground"})})]})})};var X=qz(Pz(),1);function m1(){let{projectId:w,fileId:G}=gz.useParams(),V=gz.useSearch(),W=V.version,b=V.start,J=W||G,L=V.cmpLeft,q=V.cmpRight,M=V.cmpActive??"left",B=!!V.compare&&!!L&&!!q,h=X.useRef(null),{teamId:$,ensureTeamIdForProject:S}=oz(),[v,p]=X.useState(360),[g,E]=X.useState([]),{fileViewRightSidebarCollapsed:T}=sz(),{isChatbotOpen:k}=iz(),[D,x]=X.useState(0),[n,m]=X.useState(null),[Gz,Z1]=X.useState(null),[_1,U1]=X.useState(void 0),[A,o]=X.useState({show:!1,files:[],nextCursor:void 0,folderId:void 0}),W1=H.api.files[":fileId"].metadata.$patch,{mutate:B1}=l({mutationFn:async(z)=>{let K=await W1(z);if(!K.ok)throw Error("Failed to patch metadata");return await K.json()}}),f=Az(),{members:$1,fetchProjectMembers:Jz}=rz(),H1=tz();X.useEffect(()=>{S(w)},[w,S]),X.useEffect(()=>{if(w)Jz(w,!0)},[w,Jz]),X.useEffect(()=>{if(w&&G)H.api.projects[":projectId"].recents.view.$post({param:{projectId:w},json:{assetId:G}}).catch(()=>{})},[w,G]);let{data:Yz,isLoading:Q1,isError:k1,isFetching:T1}=F({queryKey:["files",G],queryFn:async()=>{let z=await H.api.files[":fileId"].$get({param:{fileId:G}});if(!z.ok)throw Error("Failed to fetch stack");return await z.json()},enabled:!!$,placeholderData:Kz}),{data:O1,isLoading:V1,isError:q1,isFetching:P1}=F({queryKey:["files",W],queryFn:async()=>{let z=await H.api.files[":fileId"].$get({param:{fileId:W}});if(!z.ok)throw Error("Failed to fetch version");return await z.json()},enabled:!!$&&!!W,placeholderData:Kz}),{data:b1}=F({queryKey:["version_stacks",G,"versions"],queryFn:async()=>{let z=await H.api.version_stacks[":stackId"].versions.$get({param:{stackId:G}});if(!z.ok)throw Error("Failed to fetch versions");return await z.json()},enabled:!!w&&!!G&&(!!W||B)}),{data:N}=F({queryKey:["projects",w],queryFn:async()=>{let z=await H.api.projects[":projectId"].$get({param:{projectId:w}});if(!z.ok)throw Error("Failed to fetch project");return await z.json()}}),O=Rz(),{setProjectState:Zz,clearProjectState:_z}=az(),h1=Q1||!!W&&V1,E1=k1||!!W&&q1,N1=T1||!!W&&P1,Y=O1||Yz,P=W?b1:Yz?.versionStack?.versions,Z=Y?.ancestorFolders?.[0]?.id??N?.rootFolder??"",[a,c]=X.useState(!1),[u,Uz]=X.useState(""),r=X.useRef(null),s=X.useRef(!1),[L1,i]=X.useState(!1),M1=H.api.files[":fileId"].$put,{mutate:g1,mutateAsync:x1,isPending:Wz}=l({mutationFn:async(z)=>{let K=await M1(z);if(!K.ok)throw Error("Failed to rename file");return await K.json()},onSuccess:()=>{f.invalidateQueries({queryKey:["files"]}),f.invalidateQueries({queryKey:["version_stacks"]}),j.success(U.renamed_successfully?.()||"Renamed successfully"),c(!1)},onError:()=>{j.error(U.failed_to_rename?.()||"Failed to rename")}}),A1=H.api.files.$delete,{mutate:R1,mutateAsync:C1,isPending:Bz}=l({mutationFn:async(z)=>{if(!(await A1(z)).ok)throw Error("Failed to delete file")},onSuccess:()=>{if(f.invalidateQueries({queryKey:["files"]}),f.invalidateQueries({queryKey:["version_stacks"]}),j.success(U.deleted?.()||"Deleted"),i(!1),Z&&Z!==N?.rootFolder)O({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:Z}});else O({to:"/projects/$projectId",params:{projectId:w}})},onError:()=>{j.error(U.failed_to_delete?.()||"Failed to delete")}}),S1=(z)=>{if(z?.preventDefault(),!u.trim()||!J)return;g1({param:{fileId:J},json:{name:u.trim()}})},v1=()=>{if(!J)return;R1({json:{ids:[J]}})};X.useEffect(()=>{if(Y&&N&&$)Zz({teamId:$,projectId:w,projectName:N.name??"",ancestorFolders:Y.ancestorFolders??[],currentAsset:{id:J||G,name:Y.name,type:"file",version:P?P.find((z)=>z.id===J)?.version??P.length:void 0,proxyType:Y.proxyType},isRootFolder:!1,fileId:G,downloadInfo:{originalKey:Y.media?.original?.key,videoTranscodes:Y.media?.videoTranscodes?.map((z)=>({key:z.key,width:z.width,height:z.height}))},versions:P,compareMode:B,canCompareVersions:(P?.length??0)>=2,onCompareVersions:()=>{let z=y1(P);if(!z)return;O({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:G},search:(K)=>({...K,version:void 0,compare:!0,cmpLeft:z.left.id,cmpRight:z.right.id,cmpActive:"left"})})},onFolderClick:(z)=>{O({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:z}})},onRename:()=>{s.current=!1,Uz(Y?.name??""),c(!0)},onDelete:()=>{i(!0)}});return()=>_z()},[$,w,N,Y,P,J,G,B,Zz,_z,O]),X.useEffect(()=>{if(!a)return;let z=setTimeout(()=>{s.current=!0},1000);return()=>clearTimeout(z)},[a]);let D1=()=>{if(s.current)return;setTimeout(()=>{if(r.current)z1(r.current)},0)};if(X.useEffect(()=>{if(!Z||!J)return;if(A.folderId===Z)return;let z=!0;return(async()=>{try{let I="",kz=!1,zz=[],yz=void 0;for(let Tz=0;Tz<5;Tz++){let Oz=await H.api.folders[":folderId"].search.$post({param:{folderId:Z},json:{assetType:"file",after:I,first:200,recursively:!1,conditions:[]}});if(!Oz.ok)throw Error("Failed to search parent folder for carousel");let R=await Oz.json(),wz=R.data||[];if(zz.push(...wz),wz.some((d)=>d.id===J)){if(kz=!0,yz=R.pageInfo?.cursor||void 0,R.pageInfo?.cursor)try{let d=await H.api.folders[":folderId"].search.$post({param:{folderId:Z},json:{assetType:"file",after:R.pageInfo.cursor,first:200,recursively:!1,conditions:[]}});if(d.ok){let Vz=await d.json(),j1=Vz.data||[];zz.push(...j1),yz=Vz.pageInfo?.cursor||void 0}}catch{}break}if(!R.pageInfo?.cursor||wz.length<200)break;I=R.pageInfo.cursor}if(z)if(kz)o({show:!0,files:zz,nextCursor:yz,folderId:Z});else o({show:!1,files:[],nextCursor:void 0,folderId:Z})}catch(I){if(console.error(I),z)o({show:!1,files:[],nextCursor:void 0,folderId:Z})}})(),()=>{z=!1}},[Z,J,A.folderId]),X.useEffect(()=>{x(0),m(null),E([])},[Y?.id]),X.useEffect(()=>{m(null),E([])},[Gz?.id]),h1&&!Y)return y(ez,{});if(E1||!Y||!N||!$)return y("div",{children:U.file_not_found()});let t=B?Gz:Y,$z=t?.id??J,Hz=(z,K)=>{if(!$)return;B1({param:{fileId:$z},json:[{key:z,value:K}]},{onSuccess:()=>{f.invalidateQueries({queryKey:["files",$z]})}})},e=(z)=>{O({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:G},search:(K)=>({...K,...z})})},f1=()=>{e({compare:void 0,cmpLeft:void 0,cmpRight:void 0,cmpActive:void 0,version:M==="left"?L:q})},F1=(z)=>{m(z.id||null);let K=z.annotations;if(K&&K.length>0)E(K);else E([]);if(B){if(z.second!==null&&z.second!==void 0)U1({second:z.second,nonce:Date.now()});return}if(z.second!==null&&z.second!==void 0)h.current?.seekTo(z.second),h.current?.pause();else if(K&&K.length>0)h.current?.pause()},Qz=()=>{E([]),m(null)};if(H1&&!B)return y(K1,{projectId:w,teamId:$,fileId:G,file:Y,projectInfo:N,ancestorFolders:Y.ancestorFolders??[],parentFolderId:Z,versions:P,activeFileId:J,startTime:b,siblingFiles:A.files,onNavigateToFile:(z)=>{O({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:z}})},onNavigateBack:()=>{if(Z&&Z!==N?.rootFolder)O({to:"/projects/$projectId/folders/$folderId",params:{projectId:w,folderId:Z}});else O({to:"/projects/$projectId",params:{projectId:w}})},onSelectVersion:(z)=>{O({to:"/projects/$projectId/files/$fileId",params:{projectId:w,fileId:G},search:(K)=>({...K,version:z})})},onRenameFile:async(z)=>{await x1({param:{fileId:J},json:{name:z}})},onDeleteFile:async()=>{await C1({json:{ids:[J]}})},onSaveField:Hz});return _("div",{className:"h-full flex flex-1 flex-col bg-background",children:[_("div",{className:"h-full flex flex-1 overflow-hidden",children:[_("div",{className:"flex-1 relative",children:[N1&&!B&&y("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/50",children:y(C,{className:"h-8 w-8 animate-spin text-foreground"})}),B&&L&&q?y(J1,{versions:P??[],leftId:L,rightId:q,activeSide:M,annotations:g,seekRequest:_1,onActiveSideChange:(z)=>e({cmpActive:z}),onSwitchVersion:(z,K)=>e(z==="left"?{cmpLeft:K}:{cmpRight:K}),onExit:f1,onActiveAssetChange:Z1,onPlay:Qz,onTimeUpdate:x}):y(w1,{file:Y,mediaControllerRef:h,onPlay:Qz,onTimeUpdate:x,annotations:g,startTime:b,children:A.show&&y(Mz,{projectId:w,currentAssetId:J,parentFolderId:Z,initialFiles:A.files,initialNextCursor:A.nextCursor})})]}),(!T||k)&&_(xz,{children:[y(G1,{onResize:(z)=>{p((K)=>Math.max(300,Math.min(600,K-z)))},className:"hidden md:block"}),y("div",{style:{width:v},className:"flex-shrink-0 bg-background flex flex-col",children:k?y(Y1,{projectId:w,contextAssetId:J}):y(X1,{teamId:$,projectId:w,file:t,onSaveField:Hz,members:$1,onCommentSelect:F1,currentTime:D,onTyping:()=>{if(B)return;h.current?.pause()},selectedCommentId:n,hideAnnotationControl:t?.proxyType==="audio"})})]})]}),y(cz,{open:a,onOpenChange:c,children:y(uz,{children:_("form",{onSubmit:S1,children:[y(Iz,{children:y(lz,{children:U.rename()})}),y("div",{className:"py-4",children:y(nz,{ref:r,value:u,onChange:(z)=>Uz(z.target.value),placeholder:U.enter_new_name?.()||"Enter new name",onFocus:D1,autoFocus:!0})}),_(dz,{children:[y(Xz,{type:"button",variant:"outline",onClick:()=>c(!1),children:U.cancel()}),_(Xz,{type:"submit",disabled:Wz||!u.trim(),children:[Wz&&y(C,{className:"mr-2 h-4 w-4 animate-spin"}),U.save()]})]})]})})}),y(Sz,{open:L1,onOpenChange:i,children:_(vz,{children:[_(Dz,{children:[y(Fz,{children:U.delete_asset_title?.()||"Delete Asset?"}),y(jz,{children:U.delete_asset_description?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),_(fz,{children:[y(mz,{children:U.cancel()}),_(pz,{onClick:v1,disabled:Bz,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[Bz&&y(C,{className:"mr-2 h-4 w-4 animate-spin"}),U.delete()]})]})]})})]})}var gz=Cz("/projects/$projectId/files/$fileId")({component:m1});export{gz as Route};
@@ -1,2 +0,0 @@
1
- import{A as Q1,B as S1,C as Wz,D as Jz,x as bz,z as Dz}from"./chunk-082zg4nr.js";import{H as e1,K as Az,T as zz}from"./chunk-44xtwvd7.js";import{Oe as wz}from"./chunk-6tv7rm3x.js";import{Af as s1,Bf as D1,Cf as F1,zf as i1}from"./chunk-kejt7kcr.js";import{Lf as Tz}from"./chunk-2q7ew7yz.js";import{Mf as u1}from"./chunk-j10gz94w.js";import{hh as b1}from"./chunk-ygsbmfcy.js";import{kh as n1}from"./chunk-16txy3r1.js";import{gi as R1,hi as j1,ii as k1,ji as T1,ki as t,ni as C1,oi as I1,pi as g1,qi as v1,ri as m1,ti as A1}from"./chunk-4k2d8w9w.js";import{Bi as a1,Ci as o1,Ii as v,Ji as Zz,Ki as qz,Li as Hz,Mi as Uz,Ni as Oz,Oi as Vz,Pi as Lz,Qi as Bz,Ri as Nz,Ti as Ez,Ui as Mz,Vi as yz,Wi as Rz,Yi as t1,wi as l1,zi as N1}from"./chunk-s503pcvb.js";import{$i as p1,Dj as U1,Fl as Gz,Ij as $z,Sl as pz,Wl as n,Xk as Cz,aj as H1,ak as Sz,al as Pz,bj as z,bk as P1,cj as W,ck as h1,dk as Kz,gl as Yz,ok as x1,qm as Z1,rk as fz,tm as G,um as kz,zj as _z}from"./chunk-w9p59ahz.js";import{rn as f1}from"./chunk-txkmks1h.js";function d1({file:Q,mediaControllerRef:K,onPlay:_,onPause:Z,onTimeUpdate:R,annotations:U,startTime:k,shareId:N,allowDownload:M,children:H}){let E=Q1(Q),b=E.viewer;return z(b,{ref:K,file:Q,onPlay:_,onPause:Z,onTimeUpdate:R,annotations:U,startTime:k,shareId:N,allowDownload:M,children:H},E.id)}var C=f1(p1(),1);var f=f1(p1(),1);function Xz({teamId:Q,projectId:K,file:_,onSaveField:Z,members:R,onCommentSelect:U,hideAnnotationControl:k=!1,readOnly:N=!1,publicFields:M,isPublic:H=!1,shareId:E,currentTime:b,onTyping:m,selectedCommentId:V,heightPercent:D,onHeightPercentChange:p}){let{canEdit:F}=A1(K),{fields:O,setFields:I}=e1(),l=l1(),{ref:r,inView:i}=n1(),[Y,w]=f.useState(null),[S,u]=f.useState(!1),[W1,O1]=f.useState(null),h=f.useRef(!1),V1=f.useRef(0),x=f.useRef(D),E1=(J)=>{h.current=!0,V1.current=J.clientY,x.current=D,J.target.setPointerCapture?.(J.pointerId)},_1=f.useCallback((J)=>{if(!h.current)return;let y=(V1.current-J.clientY)/window.innerHeight*100,c=Math.min(85,Math.max(10,x.current+y));p(c)},[p]),J1=(J)=>{h.current=!1;try{J.target.releasePointerCapture?.(J.pointerId)}catch{}},{data:g}=N1({queryKey:["fields",K],queryFn:async()=>{let J=await v.api.projects[":projectId"].fields.$get({param:{projectId:K}});if(!J.ok)throw Error("Failed to fetch fields");return await J.json()},enabled:!!K&&!M}),T=Q1(_);f.useEffect(()=>{if(M)I(M,K);else if(g)I(g,K)},[g,M,K,I]);let{data:s,fetchNextPage:j,hasNextPage:X1}=o1({queryKey:H?["shares",E,"files",_?.id,"comments"]:["files",_?.id,"comments"],queryFn:async({pageParam:J})=>{if(H){let q=localStorage.getItem(`share_pwd_${E}`)||"",y=await v.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:E,fileId:_.id},query:{after:J}},{headers:{"x-share-password":q}});if(!y.ok)throw Error("Failed to fetch comments");return await y.json()}else{let q=await v.api.files[":fileId"].comments.$get({param:{fileId:_.id},query:{after:J}});if(!q.ok)throw Error("Failed to fetch comments");return await q.json()}},enabled:!!_?.id&&(!H||!!E),initialPageParam:"",refetchInterval:2000,getNextPageParam:(J)=>J.pageInfo?.cursor||void 0}),{mutate:$1}=a1({mutationFn:async({text:J,attachmentIds:q,annotations:y,replyToId:c,guestUserId:e,second:z1})=>{if(H){let a=localStorage.getItem(`share_pwd_${E}`)||"",B1=await v.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:E,fileId:_.id},json:{message:J,attachmentIds:q,replyToId:c??void 0,annotations:y,second:z1??void 0}},{headers:{"x-share-password":a,...e?{"x-guest-user-id":e}:{}}});if(!B1.ok)throw Error("Failed to create comment");return await B1.json()}else{let a=await v.api.files[":fileId"].comments.$post({param:{fileId:_.id},json:{message:J,attachmentIds:q,replyToId:c??void 0,annotations:y,second:z1??void 0}});if(!a.ok)throw Error("Failed to create comment");return await a.json()}},onSuccess:()=>{l.invalidateQueries({queryKey:H?["shares",E,"files",_?.id,"comments"]:["files",_?.id,"comments"]})},onError:()=>{t1.error(G.failed_to_post_comment?.()||"Failed to post comment")}}),K1=s?.pages?.[0]?.pageInfo?.total??s?.pages.reduce((J,q)=>J+(q.data?.length||0),0)??0;f.useEffect(()=>{if(i&&X1)j()},[i,j,X1]);let P=f.useMemo(()=>{return(_?.fieldValues||[]).reduce((J,q)=>{return J[q.fieldId]=q,J},{})},[_?.fieldValues]),d=f.useMemo(()=>{return[...O].sort((J,q)=>{let y=J.config?.name?.toLowerCase()||"",c=q.config?.name?.toLowerCase()||"";if(y<c)return-1;if(y>c)return 1;return 0})},[O]),q1=s?.pages.flatMap((J)=>J.data??[])??[],L1=(J,q,y=[],c,e)=>{if(!J.trim()&&q.length===0&&y.length===0)return;let z1=c||Y?.id||null;if(H){let a=localStorage.getItem(`guest_user_id_${E}`);if(!a)O1({text:J,attachmentIds:q,annotations:y,replyToId:z1,second:e}),u(!0);else $1({text:J,attachmentIds:q,annotations:y,replyToId:z1,guestUserId:a,second:e})}else $1({text:J,attachmentIds:q,annotations:y,replyToId:z1,second:e});w(null)},M1=(J)=>{if(W1)$1({...W1,guestUserId:J}),O1(null),w(null)},Y1=(J)=>{let q=R.find((y)=>y.id===J);if(q)return q;return{id:"unknown",name:"Unknown",role:"unknown"}},G1=D<=15;return W("div",{style:{height:`${D}dvh`},className:"shrink-0 flex flex-col bg-background border-t border-border shadow-2xl rounded-t-2xl overflow-hidden select-none z-20","data-testid":"mobile-bottom-sheet",children:[z("div",{onPointerDown:E1,onPointerMove:_1,onPointerUp:J1,onPointerCancel:J1,className:"w-full pt-2 pb-1.5 flex flex-col items-center justify-center cursor-grab active:cursor-grabbing touch-none shrink-0","aria-label":"Drag to resize bottom sheet",children:z("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30 hover:bg-muted-foreground/50 transition-colors"})}),W(i1,{defaultValue:"comments",className:"flex-1 flex flex-col min-h-0 px-2 pb-1 overflow-hidden",children:[W(s1,{className:"w-full shrink-0 h-9 bg-muted/60 p-1",children:[W(D1,{value:"comments",className:"flex-1 text-xs font-semibold py-1",children:[G.comments()," ",K1>0&&`(${K1})`]}),z(D1,{value:"fields",className:"flex-1 text-xs font-semibold py-1",children:G.fields()})]}),W(F1,{value:"comments",className:n("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",G1&&"hidden"),children:[z("div",{className:"flex items-center justify-between px-2 pb-1.5 shrink-0 border-b border-border/50",children:W("span",{className:"text-xs font-bold text-foreground",children:[G.all_comments?.()||"All comments",K1>0?` (${K1})`:""]})}),z(b1,{className:"flex-1 min-h-0 px-2 py-2 [&>div>div]:block!",children:q1.length===0?z("div",{className:"py-8 text-center text-xs text-muted-foreground",children:G.no_comments_yet()}):W("div",{className:"space-y-3",children:[q1.map((J)=>W("div",{children:[z(S1,{teamId:Q,message:J,getUser:Y1,onReply:w,hasReplies:!!J.replies?.length,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.startTimecode:void 0,isSelected:V===J.id,onSelect:()=>{U?.(J)}}),J.replies?.map((q,y)=>z("div",{children:z(S1,{teamId:Q,isReply:!0,message:q,getUser:Y1,onReply:w,hasReplies:!1,isLastReply:y===(J.replies?.length??0)-1,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.startTimecode:void 0,isSelected:V===q.id,onSelect:()=>{U?.(q)}})},q.id))]},J.id)),z("div",{ref:r})]})}),(!N||H)&&z("div",{className:"mt-auto shrink-0 bg-background border-t border-border pt-1",children:z(Jz,{isOpen:S,onClose:()=>u(!1),onSuccess:M1,children:z(Wz,{projectId:K,onSendMessage:L1,replyingTo:Y,onCancelReply:()=>w(null),hideAnnotationControl:k,disableMentions:H,currentTime:T?.commentsConfig?.hasTimestamp?b:void 0,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?_?.media?.metadata?.startTimecode:void 0,onTyping:m})})})]}),z(F1,{value:"fields",className:n("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",G1&&"hidden"),children:z(b1,{className:"flex-1 px-3 py-2 min-h-0 [&>div>div]:block!",children:d&&d.length>0?z("div",{className:"space-y-4 pb-6",children:d.map((J)=>W("div",{className:"space-y-1.5",children:[z("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:J.config?.name}),z("div",{className:"min-h-[32px]",children:z(zz,{fieldId:J.id,config:J.config,value:P[J.id]?.value,onSave:F?(q)=>Z(J.id,q):void 0,readOnly:N||J.readOnly||!F})})]},J.id))}):z("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"No custom fields defined"})})})]})]})}function Qz({fileName:Q,folderName:K,version:_,versions:Z,activeFileId:R,isPublic:U=!1,shareId:k,allowDownload:N=!0,downloadInfo:M,canEdit:H=!1,onBack:E,onPrevFile:b,onNextFile:m,hasPrevFile:V=!1,hasNextFile:D=!1,onSelectVersion:p,onRename:F,onDelete:O,onLinkedTasks:I,linkedTaskCount:l=0}){let r=async(Y)=>{try{let w=U&&k?await v.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:k,fileId:R},json:{key:Y}}):await v.api.files["download-url"].$post({json:{key:Y,assetId:R}});if(!w.ok)return;let{url:S}=await w.json(),u=document.createElement("a");u.href=S,u.download="",document.body.appendChild(u),u.click(),document.body.removeChild(u)}catch{}},i=(M?.videoTranscodes?.length??0)>0;return W("header",{className:"flex h-12 w-full items-center justify-between border-b border-border bg-card px-2 py-1.5 shrink-0 select-none z-30",children:[z("div",{className:"flex items-center",children:z(Z1,{variant:"ghost",size:"icon",onClick:E,className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":G.previous_page(),children:z(h1,{className:"h-5 w-5"})})}),W("div",{className:"flex flex-1 items-center justify-center gap-1 min-w-0 px-1",children:[W("div",{className:"flex items-center min-w-0 max-w-[65vw]",children:[K&&W(H1,{children:[z("span",{className:"truncate text-xs font-medium text-muted-foreground max-w-[80px]",children:K}),z("span",{className:"text-muted-foreground mx-1 text-xs",children:"/"})]}),Z&&Z.length>1?W(R1,{modal:!1,children:[z(k1,{asChild:!0,children:W("button",{className:"flex items-center gap-1 min-w-0 truncate text-xs font-medium text-foreground hover:bg-accent rounded px-1 py-0.5 transition-colors cursor-pointer",children:[z("span",{className:"truncate max-w-[120px] font-semibold",children:Q}),_!==void 0&&W(u1,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",_]}),z(P1,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]})}),W(T1,{align:"center",className:"w-48 z-40",children:[z(C1,{className:"text-xs",children:G.switch_version()}),Z.map((Y)=>W(t,{onClick:()=>p?.(Y.id),className:n("flex items-center justify-between text-xs cursor-pointer",Y.id===R?"bg-accent font-semibold text-accent-foreground":""),children:[W("span",{children:["v",Y.version]}),z("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px]",children:Y.name||Q})]},Y.id))]})]}):W("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[z("span",{className:"truncate text-xs font-semibold text-foreground max-w-[140px]",children:Q}),_!==void 0&&W(u1,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",_]})]})]}),(V||D)&&W("div",{className:"flex items-center gap-0.5 shrink-0 bg-muted/60 rounded p-0.5 ml-1",children:[z(Z1,{variant:"ghost",size:"icon",disabled:!V,onClick:b,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:G.previous_file(),"aria-label":G.previous_file(),children:z(h1,{className:"h-3.5 w-3.5"})}),z(Z1,{variant:"ghost",size:"icon",disabled:!D,onClick:m,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:G.next_file(),"aria-label":G.next_file(),children:z(Kz,{className:"h-3.5 w-3.5"})})]})]}),z("div",{className:"flex items-center gap-1",children:W(R1,{modal:!1,children:[z(k1,{asChild:!0,children:z(Z1,{variant:"ghost",size:"icon",className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":G.more_options(),children:z(_z,{className:"h-4 w-4"})})}),W(T1,{align:"end",className:"w-52 z-40",children:[N&&(i?W(g1,{children:[W(v1,{className:"flex items-center gap-2 text-xs cursor-pointer",children:[z(x1,{className:"h-3.5 w-3.5"}),z("span",{children:G.download()})]}),z(j1,{children:W(m1,{className:"w-48 z-50",children:[z(C1,{className:"text-xs",children:G.download()}),M?.videoTranscodes?.map((Y)=>{let w=Math.max(Y.width,Y.height),S=`${Y.height}p`;if(w>=3840)S="2160p";else if(w>=1920)S="1080p";else if(w>=1280)S="720p";else if(w>=960)S="540p";else if(w>=640)S="360p";else if(w>=320)S="180p";return W(t,{onClick:()=>r(Y.key),className:"flex items-center justify-between text-xs cursor-pointer",children:[z("span",{children:S}),z("span",{className:"text-[10px] text-muted-foreground",children:"MP4"})]},S)}),M?.originalKey&&W(H1,{children:[z(I1,{}),W(t,{onClick:()=>r(M.originalKey),className:"flex items-center justify-between text-xs cursor-pointer",children:[z("span",{children:G.original?.()||"Original"}),z("span",{className:"text-[10px] text-muted-foreground",children:Q.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})})]}):W(t,{onClick:()=>M?.originalKey&&r(M.originalKey),disabled:!M?.originalKey,className:"flex items-center gap-2 text-xs cursor-pointer",children:[z(x1,{className:"h-3.5 w-3.5"}),z("span",{children:G.download()})]})),Z&&Z.length>1&&p&&W(g1,{children:[z(v1,{className:"flex items-center gap-2 text-xs cursor-pointer",children:z("span",{children:G.switch_version?.()||"Switch version"})}),z(j1,{children:W(m1,{className:"w-48 z-50",children:[z(C1,{className:"text-xs",children:G.switch_version?.()||"Switch version"}),Z.map((Y)=>W(t,{onClick:()=>p(Y.id),className:n("flex items-center justify-between text-xs cursor-pointer",Y.id===R?"bg-accent font-semibold text-accent-foreground":""),children:[W("span",{children:["v",Y.version]}),z("span",{className:"text-[10px] text-muted-foreground truncate max-w-[120px]",children:Y.name||Q})]},Y.id))]})})]}),I&&W(t,{onClick:I,className:"flex items-center justify-between text-xs cursor-pointer",children:[W("span",{className:"flex items-center gap-2",children:[z($z,{className:"h-3.5 w-3.5"}),z("span",{children:G.linked_tasks?.()||"Linked Tasks"})]}),l>0&&z("span",{className:"inline-flex items-center justify-center px-1.5 py-0.2 text-[10px] font-semibold rounded-full bg-muted-foreground/15 text-foreground",children:l})]}),H&&F&&W(t,{onClick:F,className:"flex items-center gap-2 text-xs cursor-pointer",children:[z(Yz,{className:"h-3.5 w-3.5"}),z("span",{children:G.rename()})]}),H&&O&&W(H1,{children:[z(I1,{}),W(t,{onClick:O,className:"flex items-center gap-2 text-xs text-destructive focus:text-destructive cursor-pointer",children:[z(Gz,{className:"h-3.5 w-3.5"}),z("span",{children:G.delete()})]})]})]})]})})]})}function j0({projectId:Q,teamId:K="",fileId:_,file:Z,projectInfo:R,ancestorFolders:U=[],versions:k,activeFileId:N,startTime:M,isPublic:H=!1,shareId:E,allowDownload:b=!0,publicFields:m,siblingFiles:V=[],onNavigateToFile:D,onNavigateBack:p,onRenameFile:F,onDeleteFile:O,onSaveField:I,onSelectVersion:l}){let{canEdit:r}=A1(Q),{members:i}=Tz(),Y=C.useRef(null),[w,S]=C.useState(50),[u,W1]=C.useState([]),[O1,h]=C.useState(0),[V1,x]=C.useState(null),[E1,_1]=C.useState(!1),[J1,g]=C.useState(""),T=C.useRef(null),[s,j]=C.useState(!1),[X1,$1]=C.useState(!1),[K1,P]=C.useState(!1),[d,q1]=C.useState(!1),{data:L1}=N1({queryKey:["teams",K,"kanban","assets",N,"tasks"],queryFn:async()=>{if(!K||!N||H)return{data:[],total:0};let B=await v.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:K,assetId:N}});if(!B.ok)return{data:[],total:0};return await B.json()},enabled:!!K&&!!N&&!H}),M1=L1?.total??L1?.data?.length??0,{prevFile:Y1,nextFile:G1}=C.useMemo(()=>{if(!V||V.length===0)return{prevFile:null,nextFile:null};let B=V.findIndex((o)=>o.id===_||o.id===N);if(B===-1)return{prevFile:null,nextFile:null};return{prevFile:B>0?V[B-1]:null,nextFile:B<V.length-1?V[B+1]:null}},[V,_,N]),J=U.length>0?U[0]?.name:R?.name,y=k?.find((B)=>B.id===N)?.version??(k&&k.length>0?k.length:void 0),c=C.useMemo(()=>{return{originalKey:Z.media?.original?.key,videoTranscodes:Z.media?.videoTranscodes?.map((B)=>({key:B.key,width:B.width,height:B.height}))}},[Z.media]),e=()=>{W1([]),x(null)},z1=(B)=>{x(B.id||null);let o=B.annotations;if(o&&o.length>0)W1(o);else W1([]);if(B.second!==null&&B.second!==void 0)Y.current?.seekTo(B.second),Y.current?.pause();else if(o&&o.length>0)Y.current?.pause()},a=async(B)=>{if(B?.preventDefault(),!J1.trim()||!F)return;try{$1(!0),await F(J1.trim()),_1(!1)}finally{$1(!1)}},B1=async()=>{if(!O)return;try{j(!0),await O(),P(!1)}finally{j(!1)}};return C.useEffect(()=>{h(0),x(null),W1([])},[Z?.id]),W("div",{className:"flex h-[100dvh] w-full flex-col bg-background overflow-hidden relative",children:[z(Qz,{fileName:Z.name,folderName:J,version:y,versions:k,activeFileId:N,isPublic:H,shareId:E,allowDownload:b,downloadInfo:c,canEdit:r,onBack:p,hasPrevFile:!!Y1,hasNextFile:!!G1,onPrevFile:()=>Y1&&D(Y1.id),onNextFile:()=>G1&&D(G1.id),onSelectVersion:l,onRename:()=>{g(Z.name),_1(!0)},onDelete:()=>P(!0),onLinkedTasks:!H?()=>q1(!0):void 0,linkedTaskCount:M1}),z("div",{className:"relative flex-1 min-h-0 bg-background overflow-hidden flex flex-col",children:z(d1,{file:Z,mediaControllerRef:Y,onPlay:e,onTimeUpdate:h,annotations:u,startTime:M,shareId:E,allowDownload:b})}),z(Xz,{teamId:K,projectId:Q,file:Z,onSaveField:I,members:i,onCommentSelect:z1,hideAnnotationControl:Z.proxyType==="audio",readOnly:H||!r,publicFields:m,isPublic:H,shareId:E,currentTime:O1,onTyping:()=>Y.current?.pause(),selectedCommentId:V1,heightPercent:w,onHeightPercentChange:S}),!H&&d&&z(wz,{teamId:K,assetId:N,assetName:Z.name,isOpen:d,onClose:()=>q1(!1)}),!H&&z(Nz,{open:E1,onOpenChange:_1,children:z(Ez,{children:W("form",{onSubmit:a,children:[z(Mz,{children:z(Rz,{children:G.rename()})}),z("div",{className:"py-4",children:z(kz,{ref:T,value:J1,onChange:(B)=>g(B.target.value),placeholder:G.enter_new_name?.()||"Enter new name",onFocus:()=>{setTimeout(()=>{if(T.current)Az(T.current)},0)},autoFocus:!0})}),W(yz,{children:[z(Z1,{type:"button",variant:"outline",onClick:()=>_1(!1),children:G.cancel()}),W(Z1,{type:"submit",disabled:X1||!J1.trim(),children:[X1&&z(U1,{className:"mr-2 h-4 w-4 animate-spin"}),G.save()]})]})]})})}),!H&&z(Zz,{open:K1,onOpenChange:P,children:W(qz,{children:[W(Hz,{children:[z(Oz,{children:G.delete_asset_title?.()||"Delete Asset?"}),z(Vz,{children:G.delete_asset_description?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),W(Uz,{children:[z(Bz,{children:G.cancel()}),W(Lz,{onClick:B1,disabled:s,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[s&&z(U1,{className:"mr-2 h-4 w-4 animate-spin"}),G.delete()]})]})]})})]})}var $=f1(p1(),1);function Fz({activeState:Q,activeAsset:K,previewUrl:_,isFullScreen:Z,onTogglePlay:R,onToggleLoop:U,onSeek:k,onVolumeChange:N,onToggleMute:M,onChangePlaybackRate:H,onChangeResolution:E,onZoomIn:b,onZoomOut:m,onFit:V,onDownload:D,onToggleFullScreen:p,allowDownload:F=!0}){if(Q?.kind==="video"&&Q.video&&K){let O=Q.video,I=O.totalFrames/O.frameRate,l=O.currentFrame/O.frameRate,r={isPlaying:O.isPlaying,progress:I>0?l/I*100:0,currentTime:l,duration:I,volume:O.volume,isMuted:O.isMuted,isLooping:O.isLooping,playbackRate:O.playbackRate,isFullScreen:Z,showFrames:!1,currentResolution:O.currentResolution},i=_&&!K.media?.videoPreview?{...K,media:{...K.media,videoPreview:{url:_}}}:K;return z(bz,{state:r,zoom:Q.zoom,isControlsVisible:!0,floatOverlayInFullScreen:!1,buffered:O.buffered,data:i,resolutions:O.resolutions,togglePlay:R,toggleLoop:U,toggleMute:M,handleVolumeChange:N,changePlaybackRate:H,changeResolution:(Y)=>E(Y.resolution),handleDownload:(Y)=>D(Y),toggleFullScreen:p,onZoomChange:(Y)=>Y>=Q.zoom?b():m(),onZoomReset:V,frameRate:O.frameRate,totalFrames:O.totalFrames,currentFrame:O.currentFrame,seekToFrame:k,allowDownload:F})}if(Q?.kind==="image")return z(Dz,{zoom:Q.zoom,onZoomIn:b,onZoomOut:m,onFit:V,onDownload:()=>D(),canDownload:!!K?.media?.original?.key,fullscreen:{isFullScreen:Z,onToggle:p},allowDownload:F});return z("div",{className:"relative z-10 flex items-center justify-end gap-2 border-t border-border bg-card px-4 py-3",children:z("button",{onClick:p,className:"text-foreground transition-colors hover:text-primary",title:"Fullscreen",children:Z?z(Pz,{className:"h-5 w-5"}):z(Cz,{className:"h-5 w-5"})})})}function c1({side:Q,fileName:K,version:_,activeVersionId:Z,versions:R,isActive:U,onActivate:k,onSwitchVersion:N,onExit:M}){let H=n("flex-shrink-0 rounded p-1 transition-colors hover:bg-muted",U?"text-foreground":"text-muted-foreground hover:text-foreground"),E=z("button",{onClick:M,title:G.exit_compare(),className:H,children:z(pz,{className:"h-4 w-4"})}),b=W("button",{onClick:k,className:n("flex min-w-0 items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-muted",U?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[z("span",{className:"truncate",children:K}),_!==void 0&&W("span",{className:n("flex-shrink-0 rounded border px-1 py-0 text-xs",U?"border-foreground/40":"border-border"),children:["v",_]})]}),m=W(R1,{children:[z(k1,{onClick:k,title:G.switch_version(),className:H,children:z(P1,{className:"h-4 w-4"})}),z(T1,{align:Q==="left"?"start":"end",className:"w-80 p-1",children:z("div",{className:"flex max-h-96 flex-col gap-1 overflow-y-auto",children:R.map((V)=>{let D=V.id===Z;return W(t,{onClick:()=>N(V.id),className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2",children:[W("div",{className:"flex min-w-[2rem] flex-shrink-0 items-center justify-center rounded-full bg-muted px-2 py-0.5 text-xs font-semibold text-muted-foreground select-none",children:["v",V.version]}),z("div",{className:"flex h-10 w-16 flex-shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:V.previewUrl?z("img",{src:V.previewUrl,alt:V.name||void 0,className:"h-full w-full object-cover"}):z(fz,{className:"h-4 w-4 text-muted-foreground"})}),W("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[z("span",{className:"truncate text-sm font-semibold text-foreground",children:V.name}),z("span",{className:"truncate text-xs text-muted-foreground",children:V.creator?.name||"Unknown"})]}),D&&z(Sz,{className:"ml-auto h-4 w-4 flex-shrink-0 text-primary"})]},V.id)})})})]});return z("div",{onMouseDown:k,className:n("dark flex h-10 flex-shrink-0 items-center gap-1 border-b bg-background px-2 transition-colors",U?"border-b-2 border-primary":"border-border"),children:Q==="left"?W(H1,{children:[E,b,m]}):W(H1,{children:[b,m,z("div",{className:"ml-auto"}),E]})})}function hz(Q,K,_){return N1({queryKey:K?["public-share-file",_,Q,localStorage.getItem(`share_pwd_${_}`)||""]:["files",Q],queryFn:async()=>{if(K){let R=localStorage.getItem(`share_pwd_${_}`)||"",U=await v.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:_,fileId:Q}},{headers:{"x-share-password":R}});if(!U.ok)throw Error("Failed to fetch version asset");return await U.json()}let Z=await v.api.files[":fileId"].$get({param:{fileId:Q}});if(!Z.ok)throw Error("Failed to fetch version asset");return await Z.json()},enabled:!!Q&&(!K||!!_)})}function XW({isPublic:Q=!1,shareId:K,versions:_,leftId:Z,rightId:R,activeSide:U,annotations:k,seekRequest:N,onActiveSideChange:M,onSwitchVersion:H,onExit:E,onActiveAssetChange:b,onPlay:m,onTimeUpdate:V,allowDownload:D=!0}){let p=$.useRef(null),F=$.useRef(null),O=$.useRef(null),[I,l]=$.useState(null),[r,i]=$.useState(null),[Y,w]=$.useState(1),[S,u]=$.useState(!1),[W1,O1]=$.useState(!1),{data:h,isLoading:V1}=hz(Z,Q,K),{data:x,isLoading:E1}=hz(R,Q,K),_1=Q1(h),J1=Q1(x),g=!!h&&!!x&&_1.id===J1.id,T=U==="left"?h:x,s=U==="left"?I:r,j=$.useCallback(()=>U==="left"?F.current:O.current,[U]),X1=$.useCallback(()=>U==="left"?O.current:F.current,[U]);$.useEffect(()=>{b(T??null)},[T,b]),$.useEffect(()=>{if(!N)return;let X=j();if(X?.seekToSecond(N.second),X?.pause(),g){let L=X1();L?.seekToSecond(N.second),L?.pause()}},[N?.nonce]),$.useEffect(()=>{let X=()=>O1(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",X),()=>document.removeEventListener("fullscreenchange",X)},[]);let $1=$.useCallback((X)=>l(X),[]),K1=$.useCallback((X)=>i(X),[]),P=$.useCallback((X)=>{let L=j();if(L)X(L);if(g){let A=X1();if(A)X(A)}},[j,X1,g]),d=$.useCallback(()=>{let X=!s?.video?.isPlaying;P((L)=>X?L.play():L.pause())},[s?.video?.isPlaying,P]);$.useEffect(()=>{let X=(L)=>{let A=document.activeElement;if(A&&(A.tagName==="INPUT"||A.tagName==="TEXTAREA"||A instanceof HTMLElement&&A.isContentEditable))return;let w1=L.key===" ",y1=A&&(A.tagName==="BUTTON"||A.tagName==="A"||A.tagName==="SELECT"||A.tagName==="OPTION"||A.getAttribute("role")==="button"||A.getAttribute("role")==="link"||A.getAttribute("role")==="checkbox"||A.getAttribute("role")==="radio"||A.getAttribute("role")==="menuitem");if(w1&&y1)return;if(L.key===" "||L.key.toLowerCase()==="k")L.preventDefault(),d()};return window.addEventListener("keydown",X),()=>{window.removeEventListener("keydown",X)}},[d]);let q1=$.useCallback((X)=>P((L)=>L.seekToFrame(X)),[P]),L1=$.useCallback(()=>j()?.toggleLoop(),[j]),M1=$.useCallback((X)=>{w(X),u(X===0)},[]),Y1=$.useCallback(()=>u((X)=>!X),[]),G1=$.useCallback((X)=>P((L)=>L.setPlaybackRate(X)),[P]),J=$.useCallback((X)=>j()?.changeResolution(X),[j]),q=$.useCallback(()=>P((X)=>X.zoomBy(1.2)),[P]),y=$.useCallback(()=>P((X)=>X.zoomBy(0.8)),[P]),c=$.useCallback(()=>P((X)=>X.fit()),[P]),e=$.useCallback((X)=>{j()?.download(X)},[j]),z1=$.useCallback(()=>{let X=p.current;if(!X||typeof X.requestFullscreen!=="function")return;if(!document.fullscreenElement)X.requestFullscreen().catch(()=>{});else if(document.exitFullscreen)document.exitFullscreen().catch(()=>{})},[]),a=$.useCallback((X,L)=>{if(g)O.current?.panBy(X,L)},[g]),B1=$.useCallback((X,L)=>{if(g)F.current?.panBy(X,L)},[g]),B=$.useCallback(()=>d(),[d]),o=$.useCallback((X)=>_.find((L)=>L.id===X)?.version,[_]),xz=$.useMemo(()=>T?.media?.videoPreview?.url,[T?.media?.videoPreview?.url]),r1=(X,L)=>{let w1=Q1(L)?.comparePane;if(!w1)return z("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:z("p",{className:"text-muted-foreground",children:"Preview unavailable"})});let y1=U===X;return z(w1,{ref:X==="left"?F:O,file:L,shareId:K,isActive:y1,annotations:y1?k:[],onStateChange:X==="left"?$1:K1,onUserPan:X==="left"?a:B1,onActivate:()=>M(X),muted:y1?S:!0,volume:Y,onPlay:m,onTimeUpdate:V,onRequestTogglePlay:B},L.id)},jz=!!h&&!!x,Iz=V1||E1;return W("div",{ref:p,className:"flex h-full flex-1 flex-col bg-background",children:[W("div",{className:"flex min-h-0 flex-1",children:[W("div",{className:"flex min-w-0 flex-1 flex-col border-r border-zinc-800",children:[h&&z(c1,{side:"left",fileName:h.name,version:o(Z),activeVersionId:Z,versions:_,isActive:U==="left",onActivate:()=>M("left"),onSwitchVersion:(X)=>H("left",X),onExit:E}),z("div",{className:"relative flex min-h-0 flex-1",children:h?r1("left",h):z("div",{className:"flex flex-1 items-center justify-center",children:z(U1,{className:"h-6 w-6 animate-spin text-foreground"})})})]}),W("div",{className:"flex min-w-0 flex-1 flex-col",children:[x&&z(c1,{side:"right",fileName:x.name,version:o(R),activeVersionId:R,versions:_,isActive:U==="right",onActivate:()=>M("right"),onSwitchVersion:(X)=>H("right",X),onExit:E}),z("div",{className:"relative flex min-h-0 flex-1",children:x?r1("right",x):z("div",{className:"flex flex-1 items-center justify-center",children:z(U1,{className:"h-6 w-6 animate-spin text-foreground"})})})]})]}),Iz&&!jz&&z("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/30",children:z(U1,{className:"h-8 w-8 animate-spin text-foreground"})}),z(Fz,{activeState:s,activeAsset:T??null,previewUrl:xz,isFullScreen:W1,onTogglePlay:d,onToggleLoop:L1,onSeek:q1,onVolumeChange:M1,onToggleMute:Y1,onChangePlaybackRate:G1,onChangeResolution:J,onZoomIn:q,onZoomOut:y,onFit:c,onDownload:e,onToggleFullScreen:z1,allowDownload:D})]})}
2
- export{d1 as p,j0 as q,XW as r};