@shumai-one/shumai 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/bin/{chunk-qmtvy2j4.js → chunk-03pw611p.js} +2 -2
  2. package/bin/{chunk-1nh6xgek.js → chunk-05m8w09t.js} +1 -1
  3. package/bin/chunk-0ark0qrm.js +1 -0
  4. package/bin/{chunk-arpna31w.js → chunk-1apsnd7e.js} +1 -1
  5. package/bin/{chunk-g2dk56e7.js → chunk-1bfrnc6b.js} +1 -1
  6. package/bin/chunk-21h9kgp5.js +1 -0
  7. package/bin/{chunk-na2nympm.js → chunk-2967rnmn.js} +1 -1
  8. package/bin/chunk-2errtbmb.js +2 -0
  9. package/bin/{chunk-hrzm70wg.js → chunk-2jnyk045.js} +1 -1
  10. package/bin/{chunk-etces6ff.js → chunk-2mr99scd.js} +2 -2
  11. package/bin/chunk-2pxev94x.js +2 -0
  12. package/bin/chunk-2y9t0qxp.js +45 -0
  13. package/bin/{chunk-s7qpj715.js → chunk-2ydhnafa.js} +2 -2
  14. package/bin/chunk-38hp9gfh.js +2 -0
  15. package/bin/chunk-3t7v2de9.js +307 -0
  16. package/bin/{chunk-20y3wte3.js → chunk-3vbx3x11.js} +2 -2
  17. package/bin/{chunk-d3s00sn0.js → chunk-3xfhbvar.js} +2 -2
  18. package/bin/chunk-4153rke8.js +12 -0
  19. package/bin/{chunk-7jjc175m.js → chunk-4a185tez.js} +3 -3
  20. package/bin/{chunk-zxpef55w.js → chunk-4rexdetz.js} +3 -3
  21. package/bin/{chunk-1dawjfk8.js → chunk-58y9bagr.js} +2 -2
  22. package/bin/chunk-5dqn7egd.js +11 -0
  23. package/bin/{chunk-9p2d0mk1.js → chunk-5e48saab.js} +1 -1
  24. package/bin/{chunk-vnfmh5ke.js → chunk-5qwzveck.js} +2 -2
  25. package/bin/chunk-61hfhfce.js +2 -0
  26. package/bin/chunk-6ab9eftx.js +3 -0
  27. package/bin/chunk-6b0f3d07.js +2 -0
  28. package/bin/chunk-6gjn8trh.js +3 -0
  29. package/bin/{chunk-gn8snrnk.js → chunk-75x3w5hx.js} +1 -1
  30. package/bin/chunk-7e39zmss.js +1 -0
  31. package/bin/chunk-7h1m1e0b.js +1 -0
  32. package/bin/chunk-7kdz1eng.js +3 -0
  33. package/bin/chunk-7pcba64w.js +1 -0
  34. package/bin/{chunk-s05f0v9t.js → chunk-7xfx7741.js} +1 -1
  35. package/bin/chunk-898hrxwq.js +2 -0
  36. package/bin/{chunk-ph3e1bpp.js → chunk-89chaa11.js} +2 -2
  37. package/bin/chunk-8btfb5g6.js +2 -0
  38. package/bin/{chunk-gvn079hy.js → chunk-8pa1n500.js} +2 -2
  39. package/bin/{chunk-vy24ncn2.js → chunk-8qe7cpbr.js} +1 -1
  40. package/bin/{chunk-ws07a9kv.js → chunk-8tnq43k9.js} +1 -1
  41. package/bin/{chunk-1d22tysv.js → chunk-8wzepzp3.js} +2 -2
  42. package/bin/chunk-9deae0n7.js +3 -0
  43. package/bin/{chunk-3rcc5s99.js → chunk-ankkm2wz.js} +2 -2
  44. package/bin/chunk-ardp3pze.js +2 -0
  45. package/bin/chunk-axe5rq99.js +7 -0
  46. package/bin/chunk-bagxeg82.js +2 -0
  47. package/bin/{chunk-ss45w8ks.js → chunk-bhqrqt97.js} +2 -2
  48. package/bin/chunk-bn1sts8x.js +3 -0
  49. package/bin/{chunk-31mjcykb.js → chunk-bpb0szs5.js} +2 -2
  50. package/bin/{chunk-tsncwscz.js → chunk-c1j58ekb.js} +2 -2
  51. package/bin/chunk-c4nenmry.js +2 -0
  52. package/bin/chunk-c9f6n4sf.js +3 -0
  53. package/bin/chunk-cwh21vfb.js +2 -0
  54. package/bin/chunk-cwpmf8tx.js +2 -0
  55. package/bin/{chunk-ejfmxjw6.js → chunk-d2xrh0vv.js} +2 -2
  56. package/bin/chunk-d4sg0z3y.js +2 -0
  57. package/bin/chunk-d4sjezbk.js +8 -0
  58. package/bin/{chunk-vgb8bzcg.js → chunk-ddfx823h.js} +2 -2
  59. package/bin/chunk-dtjx1097.js +2 -0
  60. package/bin/chunk-e32bzfza.js +1 -0
  61. package/bin/chunk-e6rmqgzv.js +2 -0
  62. package/bin/chunk-ersxsrz8.js +62 -0
  63. package/bin/chunk-gg1wfpm8.js +3 -0
  64. package/bin/{chunk-qc6dmzn0.js → chunk-gg8dmkwd.js} +2 -2
  65. package/bin/chunk-gnx9g8px.js +2 -0
  66. package/bin/{chunk-xawwxdq9.js → chunk-h0k9zw29.js} +2 -2
  67. package/bin/chunk-htrzgs2a.css +1 -0
  68. package/bin/chunk-j2jdrmaa.js +2 -0
  69. package/bin/{chunk-v2kfr8fx.js → chunk-j5dejr3e.js} +2 -2
  70. package/bin/{chunk-wap08p4j.js → chunk-j5q3t199.js} +2 -2
  71. package/bin/chunk-jgxhv36z.js +3 -0
  72. package/bin/{chunk-dwswqq3g.js → chunk-jnx8p6kj.js} +1 -1
  73. package/bin/chunk-k41vt2gq.js +1 -0
  74. package/bin/chunk-k78m3rar.js +2 -0
  75. package/bin/chunk-kfbztymc.js +4 -0
  76. package/bin/chunk-kgr3ytpb.js +5 -0
  77. package/bin/chunk-khc3dydj.js +2 -0
  78. package/bin/chunk-krpr6g8a.js +1 -0
  79. package/bin/chunk-m8tnsds1.js +2 -0
  80. package/bin/chunk-mfmcsdd7.js +1 -0
  81. package/bin/chunk-msjv1ykh.js +2 -0
  82. package/bin/chunk-n73dbqps.js +1 -0
  83. package/bin/{chunk-5vqan9c4.js → chunk-n7cmya8k.js} +2 -2
  84. package/bin/{chunk-hfp4hpca.js → chunk-nabagpah.js} +2 -2
  85. package/bin/chunk-nn5qpr0q.js +1 -0
  86. package/bin/{chunk-ve7v8wtv.js → chunk-pew69nxg.js} +2 -2
  87. package/bin/{chunk-7eycsyk6.js → chunk-q2shr586.js} +1 -1
  88. package/bin/chunk-q7v8sj72.js +1 -0
  89. package/bin/chunk-q9tm2d21.js +8 -0
  90. package/bin/{chunk-mcxsk75h.js → chunk-qw5yjhab.js} +3 -3
  91. package/bin/{chunk-j0p1peav.js → chunk-r9thyg31.js} +2 -2
  92. package/bin/{chunk-h2wsm7h3.js → chunk-s584wxzj.js} +2 -2
  93. package/bin/{chunk-wr5byz6r.js → chunk-s5s1rk4n.js} +1 -1
  94. package/bin/{chunk-zs9b0f3z.js → chunk-scfbmsy7.js} +2 -2
  95. package/bin/{chunk-k20bhxed.js → chunk-sddrv3ep.js} +1 -1
  96. package/bin/{chunk-amsb41z5.js → chunk-sfmhbk59.js} +1 -1
  97. package/bin/chunk-tbdgkpgw.js +2 -0
  98. package/bin/chunk-twhj7h73.js +1 -0
  99. package/bin/{chunk-mahxw48e.js → chunk-v5zdafv4.js} +2 -2
  100. package/bin/{chunk-3t7mjvdv.js → chunk-vzx1r87y.js} +2 -2
  101. package/bin/{chunk-a76c5r3c.js → chunk-w3xzd86e.js} +2 -2
  102. package/bin/{chunk-nzy3pjjm.js → chunk-xkh6b42h.js} +2 -2
  103. package/bin/chunk-yn7mxpmb.js +7 -0
  104. package/bin/{chunk-yahb7wan.js → chunk-z544s59c.js} +2 -2
  105. package/bin/{chunk-f8cn9m28.js → chunk-zned6mj8.js} +1 -1
  106. package/bin/{chunk-08mxv0sm.js → chunk-zpq34g0w.js} +2 -2
  107. package/bin/shumai-app.html +1 -1
  108. package/bin/shumai-app.js +495 -372
  109. package/package.json +7 -7
  110. package/prisma/migrations/20260801065040_add_audit_log/migration.sql +33 -0
  111. package/prisma/migrations/20260805021613_add_asset_autofill_context/migration.sql +2 -0
  112. package/prisma/migrations/20260806082136_add_sharelink_watermark/migration.sql +69 -0
  113. package/prisma/migrations/20260806085643_add_watermark_file_status/migration.sql +7 -0
  114. package/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql +86 -0
  115. package/prisma/migrations/20260808014542_add_sharelink_allow_download/migration.sql +2 -0
  116. package/prisma/schema.prisma +93 -0
  117. package/bin/chunk-08dr94gp.js +0 -2
  118. package/bin/chunk-0t4z17qr.js +0 -2
  119. package/bin/chunk-2ynx0den.js +0 -8
  120. package/bin/chunk-31a3k77j.js +0 -2
  121. package/bin/chunk-3jdef7n4.js +0 -6
  122. package/bin/chunk-4ahve1nf.js +0 -2
  123. package/bin/chunk-4hdnrwh1.js +0 -1
  124. package/bin/chunk-4hdx2tv0.js +0 -2
  125. package/bin/chunk-4htdb0xp.js +0 -1
  126. package/bin/chunk-4p7xpfey.js +0 -2
  127. package/bin/chunk-5f81c951.js +0 -1
  128. package/bin/chunk-5zntjzxw.js +0 -3
  129. package/bin/chunk-6a2eb3b5.js +0 -3
  130. package/bin/chunk-6t3gdd7e.js +0 -2
  131. package/bin/chunk-7d5kep8c.js +0 -2
  132. package/bin/chunk-7kzqkp5z.js +0 -1
  133. package/bin/chunk-7sh6409h.js +0 -1
  134. package/bin/chunk-7y8dng8t.js +0 -2
  135. package/bin/chunk-8e5zvy88.js +0 -307
  136. package/bin/chunk-8m6zg15c.js +0 -4
  137. package/bin/chunk-8qyke29r.js +0 -7
  138. package/bin/chunk-90et6bwm.js +0 -3
  139. package/bin/chunk-9c7fxjej.js +0 -2
  140. package/bin/chunk-a10tf0d8.js +0 -3
  141. package/bin/chunk-b10meywb.js +0 -2
  142. package/bin/chunk-b1e3tec3.js +0 -62
  143. package/bin/chunk-bdjhb77e.js +0 -2
  144. package/bin/chunk-beay9amy.js +0 -1
  145. package/bin/chunk-c3fvs0bv.js +0 -4
  146. package/bin/chunk-c5my1b3k.js +0 -7
  147. package/bin/chunk-dhekxndw.js +0 -3
  148. package/bin/chunk-dwaj1yn4.js +0 -2
  149. package/bin/chunk-er1rb6yj.js +0 -1
  150. package/bin/chunk-etqpzc9e.js +0 -3
  151. package/bin/chunk-fdpjw17x.js +0 -7
  152. package/bin/chunk-gqh4ttjh.js +0 -3
  153. package/bin/chunk-hz31j0hk.js +0 -4
  154. package/bin/chunk-jm6bxtzt.js +0 -41
  155. package/bin/chunk-jstc7pka.js +0 -2
  156. package/bin/chunk-k0a35mg9.js +0 -2
  157. package/bin/chunk-k9w6mk9d.js +0 -3
  158. package/bin/chunk-kgb16ggd.css +0 -1
  159. package/bin/chunk-m4py21f3.js +0 -2
  160. package/bin/chunk-mm1j72a8.js +0 -7
  161. package/bin/chunk-nr89225z.js +0 -2
  162. package/bin/chunk-nrf5r23d.js +0 -1
  163. package/bin/chunk-nt9tfjx6.js +0 -12
  164. package/bin/chunk-p396vw9h.js +0 -8
  165. package/bin/chunk-p9xfyqh1.js +0 -2
  166. package/bin/chunk-pj0fgb2x.js +0 -6
  167. package/bin/chunk-pp072ksj.js +0 -2
  168. package/bin/chunk-q5cdjzbv.js +0 -3
  169. package/bin/chunk-qn96vbke.js +0 -2
  170. package/bin/chunk-qvgc9e08.js +0 -3
  171. package/bin/chunk-rrxjvewm.js +0 -2
  172. package/bin/chunk-s5rfya1p.js +0 -1
  173. package/bin/chunk-scsy69bp.js +0 -1
  174. package/bin/chunk-sf6fwvrs.js +0 -8
  175. package/bin/chunk-t2txvzkp.js +0 -3
  176. package/bin/chunk-td54rdfj.js +0 -8
  177. package/bin/chunk-vb9m47z9.js +0 -1
  178. package/bin/chunk-vf066xwh.js +0 -3
  179. package/bin/chunk-w3a50kz8.js +0 -3
  180. package/bin/chunk-w9w5301f.js +0 -4
  181. package/bin/chunk-wny0qagx.js +0 -3
  182. package/bin/chunk-wqhk76de.js +0 -14
  183. package/bin/chunk-wrz9e73c.js +0 -2
  184. package/bin/chunk-x5dcgk62.js +0 -6
  185. package/bin/chunk-xwmsxg5x.js +0 -1
  186. package/bin/chunk-y2nw8rbx.js +0 -4
  187. package/bin/chunk-y9ttm07y.js +0 -3
  188. package/bin/chunk-z0ej44ak.js +0 -3
  189. package/bin/chunk-zemgtnk0.js +0 -1
  190. package/bin/chunk-zg0vm233.js +0 -2
  191. package/bin/chunk-zhd2mkbr.js +0 -1
@@ -1,2 +0,0 @@
1
- import{Ta as BK,Va as gJ}from"./chunk-31mjcykb.js";import{Xa as ZJ}from"./chunk-hfp4hpca.js";import{ab as ZK,bb as _K,cb as $K,db as GK,eb as zK,fb as QK,gb as HK,hb as UK}from"./chunk-20y3wte3.js";import{rg as $J}from"./chunk-yahb7wan.js";import{Rg as QJ,Tg as HJ,Ug as UJ,Vg as w,Zg as KK,ch as WK,dh as XK}from"./chunk-nr89225z.js";import{Di as DJ,Ji as eJ,Kh as z,Mh as U,Qi as kJ,Vh as zJ,Wh as p,_h as nJ,ai as aJ,ak as O,ck as N,gh as NK,hh as iJ,ih as J,ik as W,jh as X,ji as rJ,jj as wJ,jk as TJ,kh as lJ,kk as RJ,lk as SJ,mk as fJ,nk as hJ,ok as YK,ph as v,pj as JK,qh as _J,qi as oJ,si as sJ,th as dJ,uh as h,ui as XJ,vh as GJ,vi as YJ,xi as tJ,xj as uJ}from"./chunk-b1e3tec3.js";import{Xk as vK}from"./chunk-ws07a9kv.js";var _=vK(NK(),1);function cK({teamId:B,projectId:Z,projectName:$,rootFolderId:P,dragState:b,onSelect:M,selectedFolderId:A,hideCollections:m,hideShares:C,ancestorFolders:D}){let q=GJ(),Q=lJ(),{canEdit:V}=WK(Z),j=dJ({from:"/projects/$projectId/recently-deleted",shouldThrow:!1}),[L,r]=_.useState(!0),[T,BJ]=_.useState(!0),[u,bJ]=_.useState(!0),{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R}=_J({queryKey:["shares",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].shares.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_share_links());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{data:l,fetchNextPage:o,hasNextPage:d,isFetchingNextPage:n}=_J({queryKey:["collections",Z],queryFn:async({pageParam:K})=>{let Y=await U.api.projects[":projectId"].collections.$get({param:{projectId:Z},query:{first:"20",after:K}});if(!Y.ok)throw Error(W.failed_fetch_collections());return await Y.json()},initialPageParam:"",getNextPageParam:(K)=>K.pageInfo?.cursor||void 0,enabled:!!Z}),{ref:qJ,inView:s}=$J(),{ref:VJ,inView:t}=$J();_.useEffect(()=>{if(s&&d&&!n)o()},[s,d,n,o]),_.useEffect(()=>{if(t&&g&&!R)i()},[t,g,R,i]);let AJ=_.useMemo(()=>l?.pages.flatMap((K)=>K.data)||[],[l]),OJ=_.useMemo(()=>c?.pages.flatMap((K)=>K.data)||[],[c]),{mutate:PJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].collections.$post({param:{projectId:Z},json:{name:W.untitled_collection(),filter:{sourceFolderId:P,searchFilter:{conditions:[],recursively:!0}}}});if(!K.ok)throw Error(W.failed_create_collection());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_created()),q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:MJ}=v({mutationFn:async()=>{let K=await U.api.projects[":projectId"].shares.$post({param:{projectId:Z},json:{name:new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}});if(!K.ok)throw Error(W.failed_create_share_link());return await K.json()},onSuccess:(K)=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_created()),q({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:K.id}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),e=h({from:"/projects/$projectId/collections/$collectionId",shouldThrow:!1}),LJ=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1}),G=h({from:"/projects/$projectId/folders/$folderId",shouldThrow:!1}),[y,yJ]=_.useState(null),[F,EJ]=_.useState("collection"),[E,JJ]=_.useState(""),[qK,k]=_.useState(!1),[vJ,NJ]=_.useState(null),[S,CJ]=_.useState("collection"),[VK,f]=_.useState(!1),{mutate:IJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.folders[":folderId"].$put({param:{folderId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_folder());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:AK}=v({mutationFn:async(K)=>{if(!(await U.api.folders.$delete({json:{ids:[K]}})).ok)throw Error(W.failed_delete_folder());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["search",B]}),Q.invalidateQueries({queryKey:["folders"]}),z.success(W.folder_deleted()),f(!1),G?.folderId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),[OK,a]=_.useState(!1),[KJ,xJ]=_.useState(!1),[FJ,pJ]=_.useState([]),PK=async(K)=>{a(!0),xJ(!0),pJ([]);try{let Y=await U.api.files["download-links"].$post({json:{ids:[K]}});if(!Y.ok)throw Error(W.failed_to_prepare_download_links());let H=await Y.json();pJ(H.files)}catch(Y){z.error(W.failed_to_prepare_download_links()),a(!1),console.error(Y)}finally{xJ(!1)}},MK=()=>{let K=[...FJ];if(a(!1),K.length===0)return;z.info(W.starting_download_files({count:K.length}),{duration:5000});let Y=(WJ)=>new Promise((I)=>setTimeout(I,WJ));(async()=>{for(let I=0;I<K.length;I+=5){let EK=K.slice(I,I+5);for(let cJ of EK){let x=document.createElement("a");x.href=cJ.url,x.download=cJ.name,x.target="_blank",document.body.appendChild(x),x.click(),x.remove()}await Y(1000)}})().catch((WJ)=>{console.error("Background downloads failed:",WJ),z.error(W.some_downloads_failed())})},{mutate:mJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.collections[":collectionId"].$patch({param:{collectionId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_collection());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:LK}=v({mutationFn:async(K)=>{let Y=await U.api.collections[":collectionId"].$delete({param:{collectionId:K}});if(!Y.ok)throw Error(W.failed_delete_collection());return await Y.json()},onSuccess:(K,Y)=>{if(Q.invalidateQueries({queryKey:["collections",Z]}),z.success(W.collection_deleted()),f(!1),e?.collectionId===Y)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:jJ}=v({mutationFn:async({id:K,name:Y})=>{let H=await U.api.shares[":shareId"].$put({param:{shareId:K},json:{name:Y}});if(!H.ok)throw Error(W.failed_rename_share_link());return await H.json()},onSuccess:()=>{Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_renamed()),k(!1)},onError:(K)=>{z.error(`Error: ${K.message}`)}}),{mutate:yK}=v({mutationFn:async(K)=>{if(!(await U.api.shares[":shareId"].$delete({param:{shareId:K}})).ok)throw Error(W.failed_delete_share_link());return K},onSuccess:(K)=>{if(Q.invalidateQueries({queryKey:["shares",Z]}),z.success(W.share_link_deleted()),f(!1),LJ?.shareId===K)q({to:"/projects/$projectId",params:{projectId:Z}})},onError:(K)=>{z.error(`Error: ${K.message}`)}});return X("div",{className:"flex flex-col h-full overflow-hidden p-3 gap-4 bg-background",children:[X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",L?"flex-1 min-h-[50%] h-full":"flex-none h-[44px] max-h-[44px]"),children:[J("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>r(!L),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.folder_tree_assets()}),L?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",L?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[J(bK,{teamId:B,projectId:Z,folder:{id:P,name:$,type:"folder",sizeByte:0,fileCount:0,status:"processed",createdAt:"",updatedAt:""},level:0,isRoot:!0,dragState:b,onSelect:M,selectedFolderId:A,canEdit:V,onRenameTrigger:(K,Y)=>{yJ(K),EJ("folder"),JJ(Y),k(!0)},onDeleteTrigger:(K)=>{NJ(K),CJ("folder"),f(!0)},onDownloadTrigger:(K)=>{PK(K)},ancestorFolders:D},P),V&&X("div",{className:O("group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",j&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/recently-deleted",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(uJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.recently_deleted()})]})]})})]}),!m&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4",T?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>BJ(!T),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.collections()}),T?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("button",{onClick:()=>PJ(),className:"text-muted-foreground hover:text-foreground flex-none",children:J(wJ,{className:"h-3.5 w-3.5"})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",T?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/collections",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_collections_count({count:l?.pages[0]?.pageInfo?.total||0})})]}),AJ.map((K)=>{let Y=e?.collectionId===K.id;return X("div",{className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",Y&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium"),onClick:()=>q({to:"/projects/$projectId/collections/$collectionId",params:{projectId:Z,collectionId:K.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(rJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:K.name})]}),V&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(H)=>H.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{yJ(K.id),EJ("collection"),JJ(K.name),k(!0)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{NJ(K.id),CJ("collection"),f(!0)},children:W.delete()})]})]})})]},K.id)}),J("div",{ref:qJ,className:"h-1"}),n&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),!C&&X("div",{className:O("flex flex-col overflow-hidden transition-all duration-300 ease-in-out",u?"flex-1 min-h-0 h-full":"flex-none h-[44px] max-h-[44px]"),children:[X("header",{className:"group flex items-center justify-between px-2 mb-1 flex-none",children:[X("div",{className:"flex-1 flex items-center gap-1.5 cursor-pointer select-none text-muted-foreground hover:text-foreground transition-colors",onClick:()=>bJ(!u),children:[J("h3",{className:"text-xs font-semibold uppercase tracking-wider",children:W.share_links()}),u?J(XJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"}):J(YJ,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]}),V&&J("div",{className:"flex items-center gap-1 flex-none",children:J("button",{onClick:()=>MJ(),className:"text-muted-foreground hover:text-foreground",children:J(wJ,{className:"h-3.5 w-3.5"})})})]}),J(ZJ,{className:O("flex-1 min-h-0 transition-all duration-300 ease-in-out [&>div>div]:block!",u?"opacity-100 visible pointer-events-auto":"opacity-0 invisible pointer-events-none h-0"),children:X("div",{className:"space-y-0.5 pr-3",children:[X("div",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>q({to:"/projects/$projectId/shares",params:{projectId:Z}}),children:[J("div",{className:"flex h-4 w-4 items-center justify-center",children:J(kJ,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:W.all_share_links_count({count:c?.pages[0]?.pageInfo?.total||0})})]}),OJ.map((K)=>J(CK,{link:K,projectId:Z,dragState:b,canEdit:V,onRenameTrigger:(Y,H)=>{yJ(Y),EJ("share"),JJ(H),k(!0)},onDeleteTrigger:(Y)=>{NJ(Y),CJ("share"),f(!0)}},K.id)),J("div",{ref:VJ,className:"h-1"}),R&&J("div",{className:"flex justify-center p-2",children:J(p,{className:"h-4 w-4 animate-spin text-muted-foreground"})})]})})]}),J(TJ,{open:qK,onOpenChange:k,children:X(RJ,{onClick:(K)=>K.stopPropagation(),children:[J(SJ,{children:J(hJ,{children:F==="collection"?W.rename_collection():F==="share"?W.rename_share_link():W.rename_folder()})}),J("div",{className:"py-4",children:J(XK,{value:E,onChange:(K)=>JJ(K.target.value),placeholder:W.enter_new_name(),onKeyDown:(K)=>{if(K.key==="Enter"&&E.trim()){if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})}}})}),X(fJ,{children:[J(N,{variant:"ghost",onClick:()=>k(!1),children:W.cancel()}),J(N,{disabled:!E.trim(),onClick:()=>{if(F==="collection")mJ({id:y,name:E});else if(F==="share")jJ({id:y,name:E});else if(F==="folder")IJ({id:y,name:E})},children:W.rename()})]})]})}),J(ZK,{open:VK,onOpenChange:f,children:X(_K,{onClick:(K)=>K.stopPropagation(),children:[X($K,{children:[J(zK,{children:S==="collection"?W.delete_collection_confirm():S==="share"?W.delete_share_link_confirm():W.delete_folder_confirm()}),J(QK,{children:W.delete_confirm_description({type:S==="collection"?W.collection():S==="share"?W.share_link():W.folder().toLowerCase()})})]}),X(GK,{children:[J(UK,{children:W.cancel()}),J(HK,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{if(S==="collection")LK(vJ);else if(S==="share")yK(vJ);else if(S==="folder")AK(vJ)},children:W.delete()})]})]})}),J(TJ,{open:OK,onOpenChange:a,children:X(RJ,{className:"sm:max-w-md",children:[X(SJ,{children:[J(hJ,{children:KJ?W.preparing_download():W.confirm_download()}),J(YK,{children:KJ?W.resolving_files_wait():W.folder_files_download_description()})]}),KJ?X("div",{className:"space-y-4 py-6 flex flex-col items-center justify-center",children:[J(p,{className:"h-8 w-8 animate-spin text-primary"}),J("span",{className:"text-sm font-medium text-muted-foreground mt-2",children:W.preparing_download_links()})]}):X("div",{className:"space-y-4 py-2",children:[J("div",{className:"text-sm text-muted-foreground",children:W.download_includes_files({count:FJ.length})}),X("div",{className:"flex items-start gap-3 p-3 text-sm rounded-lg bg-amber-50 dark:bg-amber-950/30 text-amber-800 dark:text-amber-300 border border-amber-200 dark:border-amber-900/30",children:[J(aJ,{className:"h-5 w-5 shrink-0 mt-0.5"}),X("div",{children:[J("p",{className:"font-semibold",children:W.no_folder_structure()}),J("p",{className:"mt-0.5 text-xs text-amber-700/90 dark:text-amber-400/90",children:W.folder_structure_warning()})]})]})]}),J(fJ,{children:!KJ?X(iJ,{children:[J(N,{variant:"outline",onClick:()=>a(!1),children:W.cancel()}),X(N,{onClick:MK,className:"gap-2",disabled:FJ.length===0,children:[J(DJ,{className:"h-4 w-4"}),W.start_download()]})]}):J(N,{disabled:!0,variant:"outline",children:W.cancel()})})]})})]})}function CK({link:B,projectId:Z,dragState:$,canEdit:P,onRenameTrigger:b,onDeleteTrigger:M}){let A=GJ(),C=h({from:"/projects/$projectId/shares/$shareId",shouldThrow:!1})?.shareId===B.id,{ref:D,isDropTarget:q}=gJ({id:`share:${B.id}`,data:{type:"share-link",id:B.id}}),Q=!!$?.isActive;return X("div",{ref:D,className:O("group flex cursor-pointer items-center justify-between rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",C&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",q&&Q&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),onClick:()=>A({to:"/projects/$projectId/shares/$shareId",params:{projectId:Z,shareId:B.id}}),children:[X("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[J("div",{className:"flex h-4 w-4 items-center justify-center shrink-0",children:J(JK,{className:"h-4 w-4 text-sidebar-primary"})}),J("span",{className:"truncate text-sidebar-foreground flex-1",children:B.name})]}),P&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(V)=>V.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[J(w,{onClick:()=>{b(B.id,B.name)},children:W.rename()}),J(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{M(B.id)},children:W.delete()})]})]})})]})}function bK({teamId:B,projectId:Z,folder:$,level:P,isRoot:b,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V}){let j=_.useMemo(()=>{return V?.some((G)=>G.id===$.id)??!1},[V,$.id]),[L,r]=_.useState(b||j);_.useEffect(()=>{if(j)r(!0)},[j]);let T=GJ(),BJ=h({from:"/projects/$projectId/folders/$folderId",select:(G)=>({folderId:G.folderId}),shouldThrow:!1}),u=h({from:"/projects/$projectId/",shouldThrow:!1}),bJ=b?!!u:BJ?.folderId===$.id,{data:c,fetchNextPage:i,hasNextPage:g,isFetchingNextPage:R,isLoading:l}=_J({queryKey:["folders",$.id,"children",{assetType:"folder"}],queryFn:async({pageParam:G})=>{let y=await U.api.folders[":folderId"].children.$get({param:{folderId:$.id},query:{assetType:"folder",after:G,first:"20"}});if(!y.ok)throw Error(W.failed_to_fetch_folder_children());return await y.json()},initialPageParam:"",getNextPageParam:(G)=>{return G.pageInfo?.cursor||void 0},enabled:L||!!b}),{ref:o,inView:d}=$J();_.useEffect(()=>{if(d&&g&&!R)i()},[d,g,R,i]);let n=c?.pages.flatMap((G)=>G.data??[])??[],qJ=(G)=>{G.stopPropagation(),r(!L)},s=()=>{if(A){A($);return}if(b)T({to:"/projects/$projectId",params:{projectId:Z}});else T({to:"/projects/$projectId/folders/$folderId",params:{projectId:Z,folderId:$.id}})},{ref:VJ,isDragging:t}=BK({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:!!b||!!A||!C}),{ref:AJ,isDropTarget:OJ}=gJ({id:`tree:${$.id}`,data:{type:"folder",item:$},disabled:M?.draggedIds.has($.id)||!!A||!C}),PJ=(G)=>{VJ(G),AJ(G)},MJ=_.useMemo(()=>{if(A)return!1;if(!M?.isActive)return!1;if(M.draggedIds.has($.id))return!1;return!0},[M,$.id,A]),e=OJ&&MJ,LJ=m===$.id;return X("div",{children:[X("div",{ref:PJ,className:O("group flex cursor-pointer items-center gap-1 rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground min-w-0",(bJ||LJ)&&"bg-sidebar-accent text-sidebar-accent-foreground font-medium",t&&"opacity-50",e&&"bg-sidebar-accent ring-2 ring-primary ring-inset"),style:{...b?{}:{paddingLeft:`${P*12+8}px`}},onClick:s,children:[!b&&J("button",{onClick:qJ,className:"flex h-4 w-4 items-center justify-center shrink-0",children:L?J(oJ,{className:"h-3 w-3"}):J(sJ,{className:"h-3 w-3"})}),b?J(tJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}):J(eJ,{className:"h-4 w-4 text-sidebar-primary shrink-0"}),J("span",{className:"flex-1 truncate text-sidebar-foreground",children:$.name}),C&&!b&&J("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:(G)=>G.stopPropagation(),children:X(QJ,{modal:!1,children:[J(HJ,{asChild:!0,children:J(N,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 hover:bg-muted hover:text-muted-foreground p-0",children:J(zJ,{className:"h-3.5 w-3.5"})})}),X(UJ,{align:"end",className:"w-32",children:[X(w,{onClick:()=>{D($.id,$.name)},children:[J(nJ,{className:"mr-2 h-4 w-4"}),W.rename()]}),X(w,{onClick:()=>{Q($.id)},children:[J(DJ,{className:"mr-2 h-4 w-4"}),W.download()]}),J(KK,{}),X(w,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q($.id)},children:[J(uJ,{className:"mr-2 h-4 w-4"}),W.delete()]})]})]})})]}),L&&X("div",{children:[l&&J("div",{className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:J(p,{className:"h-4 w-4 animate-spin"})}),n.map((G)=>J(bK,{teamId:B,projectId:Z,folder:G,level:P+1,dragState:M,onSelect:A,selectedFolderId:m,canEdit:C,onRenameTrigger:D,onDeleteTrigger:q,onDownloadTrigger:Q,ancestorFolders:V},G.id)),g&&J("div",{ref:o,className:"flex items-center justify-center p-2",style:{paddingLeft:`${(P+1)*12+8}px`},children:R&&J(p,{className:"h-4 w-4 animate-spin"})})]})]})}
2
- export{cK as ga};
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{Tb as S}from"./chunk-s05f0v9t.js";import{Ub as h,Vb as x}from"./chunk-hrzm70wg.js";import{$b as T}from"./chunk-ss45w8ks.js";import{ic as g,jc as v,kc as b,lc as k}from"./chunk-6a2eb3b5.js";import{mc as E}from"./chunk-amsb41z5.js";import{nc as C}from"./chunk-gn8snrnk.js";import{Ye as f,Ze as y}from"./chunk-w9w5301f.js";import{bf as O}from"./chunk-k9w6mk9d.js";import{df as I}from"./chunk-wny0qagx.js";import{tk as L}from"./chunk-jm6bxtzt.js";import"./chunk-hz31j0hk.js";import"./chunk-ws07a9kv.js";function u(Q,_){if(Q)return Q;if(T("PI_CACHE_RETENTION",_)==="long")return"long";return"short"}function m(Q,_,Z){let $=u(_,Z);if($==="none")return{retention:$};let X=$==="long"&&K(Q).supportsLongCacheRetention?"1h":void 0;return{retention:$,cacheControl:{type:"ephemeral",...X&&{ttl:X}}}}var r="2.1.75",i=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],l=new Map(i.map((Q)=>[Q.toLowerCase(),Q])),H=(Q)=>l.get(Q.toLowerCase())??Q,a=(Q,_)=>{if(_&&_.length>0){let Z=Q.toLowerCase(),$=_.find((X)=>X.name.toLowerCase()===Z);if($)return $.name}return Q};function n(Q){if(!Q.some((X)=>X.type==="image"))return E(Q.map((X)=>X.text).join(`
3
- `));let Z=Q.map((X)=>{if(X.type==="text")return{type:"text",text:E(X.text)};return{type:"image",source:{type:"base64",media_type:X.mimeType,data:X.data}}});if(!Z.some((X)=>X.type==="text"))Z.unshift({type:"text",text:"(see attached image)"});return Z}var s="fine-grained-tool-streaming-2025-05-14",t="interleaved-thinking-2025-05-14";function K(Q){return{supportsEagerToolInputStreaming:Q.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:Q.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:Q.compat?.sendSessionAffinityHeaders??!1,supportsCacheControlOnTools:Q.compat?.supportsCacheControlOnTools??!0,supportsTemperature:Q.compat?.supportsTemperature??!0,allowEmptySignature:Q.compat?.allowEmptySignature??!1,supportsToolReferences:Q.compat?.supportsToolReferences??o(Q)}}function o(Q){if(Q.provider!=="anthropic"||Q.id.includes("haiku"))return!1;let _=Q.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);if(!_)return!1;let Z=Number(_[1]),$=_[2]&&_[2].length<8?Number(_[2]):0;return Z>4||Z===4&&$>=5}function B(...Q){let _={};for(let Z of Q)if(Z)Object.assign(_,Z);return _}function z(Q,_){if(!Q)return!1;let Z=_.toLowerCase();for(let[$,X]of Object.entries(Q))if($.toLowerCase()===Z&&X!==null&&X.trim().length>0)return!0;return!1}function c(Q,_,Z){if(_)return;if(z(Z,"authorization")||z(Z,"x-api-key")||z(Z,"cf-aig-authorization"))return;throw Error(`No API key for provider: ${Q}`)}var e=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function p(Q){if(!Q.event&&Q.data.length===0)return null;let _={event:Q.event,data:Q.data.join(`
4
- `),raw:[...Q.raw]};return Q.event=null,Q.data=[],Q.raw=[],_}function R(Q,_){if(Q==="")return p(_);if(_.raw.push(Q),Q.startsWith(":"))return null;let Z=Q.indexOf(":"),$=Z===-1?Q:Q.slice(0,Z),X=Z===-1?"":Q.slice(Z+1);if(X.startsWith(" "))X=X.slice(1);if($==="event")_.event=X;else if($==="data")_.data.push(X);return null}function QQ(Q){let _=Q.indexOf("\r"),Z=Q.indexOf(`
5
- `);if(_===-1)return Z;if(Z===-1)return _;return Math.min(_,Z)}function F(Q){let _=QQ(Q);if(_===-1)return null;let Z=_+1;if(Q[_]==="\r"&&Q[Z]===`
6
- `)Z+=1;return{line:Q.slice(0,_),rest:Q.slice(Z)}}async function*XQ(Q,_){let Z=Q.getReader(),$=new TextDecoder,X={event:null,data:[],raw:[]},U="";try{while(!0){if(_?.aborted)throw Error("Request was aborted");let{value:q,done:P}=await Z.read();if(P)break;U+=$.decode(q,{stream:!0});let D=F(U);while(D){U=D.rest;let G=R(D.line,X);if(G)yield G;D=F(U)}}U+=$.decode();let V=F(U);while(V){U=V.rest;let q=R(V.line,X);if(q)yield q;V=F(U)}if(U.length>0){let q=R(U,X);if(q)yield q}let j=p(X);if(j)yield j}finally{Z.releaseLock()}}async function*YQ(Q,_){if(!Q.body)throw Error("Attempted to iterate over an Anthropic response with no body");let Z=!1,$=!1;for await(let X of XQ(Q.body,_)){if(X.event==="error")throw Error(X.data);if(!e.has(X.event??""))continue;try{let U=f(X.data);if(U.type==="message_start")Z=!0;else if(U.type==="message_stop")$=!0;yield U}catch(U){let V=U instanceof Error?U.message:String(U);throw Error(`Could not parse Anthropic SSE event ${X.event}: ${V}; data=${X.data}; raw=${X.raw.join("\\n")}`)}}if(Z&&!$)throw Error("Anthropic stream ended before message_stop")}var N=(Q,_,Z)=>{let $=new I;return(async()=>{let X={role:"assistant",content:[],api:Q.api,provider:Q.provider,model:Q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let U,V;if(Z?.client)U=Z.client,V=!1;else{let Y=Z?.apiKey;c(Q.provider,Y,Z?.headers);let W;if(Q.provider==="github-copilot"){let d=h(_.messages);W=x({messages:_.messages,hasImages:d})}let w=u(Z?.cacheRetention,Z?.env)==="none"?void 0:Z?.sessionId,M=$Q(Q,Y,Z?.interleavedThinking??!0,GQ(Q,_),Z?.headers,W,w);U=M.client,V=M.isOAuthToken}let j=UQ(Q,_,V,Z),q=await Z?.onPayload?.(j,Q);if(q!==void 0)j=q;let P={...Z?.signal?{signal:Z.signal}:{},...Z?.timeoutMs!==void 0?{timeout:Z.timeoutMs}:{},maxRetries:Z?.maxRetries??0},D=await U.messages.create({...j,stream:!0},P).asResponse();await Z?.onResponse?.({status:D.status,headers:C(D.headers)},Q),$.push({type:"start",partial:X});let G=X.content;for await(let Y of YQ(D,Z?.signal))if(Y.type==="message_start")X.responseId=Y.message.id,X.usage.input=Y.message.usage.input_tokens||0,X.usage.output=Y.message.usage.output_tokens||0,X.usage.cacheRead=Y.message.usage.cache_read_input_tokens||0,X.usage.cacheWrite=Y.message.usage.cache_creation_input_tokens||0,X.usage.cacheWrite1h=Y.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,X.usage.totalTokens=X.usage.input+X.usage.output+X.usage.cacheRead+X.usage.cacheWrite,O(Q,X.usage);else if(Y.type==="content_block_start"){if(Y.content_block.type==="text"){let W={type:"text",text:"",index:Y.index};X.content.push(W),$.push({type:"text_start",contentIndex:X.content.length-1,partial:X})}else if(Y.content_block.type==="thinking"){let W={type:"thinking",thinking:"",thinkingSignature:"",index:Y.index};X.content.push(W),$.push({type:"thinking_start",contentIndex:X.content.length-1,partial:X})}else if(Y.content_block.type==="redacted_thinking"){let W={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:Y.content_block.data,redacted:!0,index:Y.index};X.content.push(W),$.push({type:"thinking_start",contentIndex:X.content.length-1,partial:X})}else if(Y.content_block.type==="tool_use"){let W={type:"toolCall",id:Y.content_block.id,name:V?a(Y.content_block.name,_.tools):Y.content_block.name,arguments:Y.content_block.input??{},partialJson:"",index:Y.index};X.content.push(W),$.push({type:"toolcall_start",contentIndex:X.content.length-1,partial:X})}}else if(Y.type==="content_block_delta"){if(Y.delta.type==="text_delta"){let W=G.findIndex((w)=>w.index===Y.index),J=G[W];if(J&&J.type==="text")J.text+=Y.delta.text,$.push({type:"text_delta",contentIndex:W,delta:Y.delta.text,partial:X})}else if(Y.delta.type==="thinking_delta"){let W=G.findIndex((w)=>w.index===Y.index),J=G[W];if(J&&J.type==="thinking")J.thinking+=Y.delta.thinking,$.push({type:"thinking_delta",contentIndex:W,delta:Y.delta.thinking,partial:X})}else if(Y.delta.type==="input_json_delta"){let W=G.findIndex((w)=>w.index===Y.index),J=G[W];if(J&&J.type==="toolCall")J.partialJson+=Y.delta.partial_json,J.arguments=y(J.partialJson),$.push({type:"toolcall_delta",contentIndex:W,delta:Y.delta.partial_json,partial:X})}else if(Y.delta.type==="signature_delta"){let W=G.findIndex((w)=>w.index===Y.index),J=G[W];if(J&&J.type==="thinking")J.thinkingSignature=J.thinkingSignature||"",J.thinkingSignature+=Y.delta.signature}}else if(Y.type==="content_block_stop"){let W=G.findIndex((w)=>w.index===Y.index),J=G[W];if(J){if(delete J.index,J.type==="text")$.push({type:"text_end",contentIndex:W,content:J.text,partial:X});else if(J.type==="thinking")$.push({type:"thinking_end",contentIndex:W,content:J.thinking,partial:X});else if(J.type==="toolCall")J.arguments=y(J.partialJson),delete J.partialJson,$.push({type:"toolcall_end",contentIndex:W,toolCall:J,partial:X})}}else if(Y.type==="message_delta"){if(Y.delta.stop_reason){let W=JQ(Y.delta.stop_reason,Y.delta.stop_details);if(X.stopReason=W.stopReason,W.errorMessage)X.errorMessage=W.errorMessage}if(Y.usage){if(Y.usage.input_tokens!=null)X.usage.input=Y.usage.input_tokens;if(Y.usage.output_tokens!=null)X.usage.output=Y.usage.output_tokens;if(Y.usage.cache_read_input_tokens!=null)X.usage.cacheRead=Y.usage.cache_read_input_tokens;if(Y.usage.cache_creation_input_tokens!=null)X.usage.cacheWrite=Y.usage.cache_creation_input_tokens;let W=Y.usage.output_tokens_details?.thinking_tokens;if(W!=null)X.usage.reasoning=W}X.usage.totalTokens=X.usage.input+X.usage.output+X.usage.cacheRead+X.usage.cacheWrite,O(Q,X.usage)}if(Z?.signal?.aborted)throw Error("Request was aborted");if(X.stopReason==="aborted"||X.stopReason==="error")throw Error(X.errorMessage||"An unknown error occurred");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(U){for(let V of X.content)delete V.index,delete V.partialJson;X.stopReason=Z?.signal?.aborted?"aborted":"error",X.errorMessage=U instanceof Error?U.message:JSON.stringify(U),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$};function ZQ(Q,_){let Z=_?Q.thinkingLevelMap?.[_]:void 0;if(typeof Z==="string")return Z;switch(_){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var RQ=(Q,_,Z)=>{c(Q.provider,Z?.apiKey,Z?.headers);let $=v(Q,_,Z,Z?.apiKey);if(!Z?.reasoning)return N(Q,_,{...$,thinkingEnabled:!1});if(Q.compat?.forceAdaptiveThinking===!0){let V=ZQ(Q,Z.reasoning);return N(Q,_,{...$,thinkingEnabled:!0,effort:V})}let X=b($.maxTokens,Q.maxTokens,Z.reasoning,Z.thinkingBudgets),U=g(Q,_,X.maxTokens);return N(Q,_,{...$,maxTokens:U,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(X.thinkingBudget,Math.max(0,U-1024))})};function _Q(Q){return Q.includes("sk-ant-oat")}function $Q(Q,_,Z,$,X,U,V){let j=Z&&Q.compat?.forceAdaptiveThinking!==!0,q=[];if($)q.push(s);if(j)q.push(t);if(Q.provider==="github-copilot")return{client:new L({apiKey:null,authToken:_??null,baseURL:Q.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:B({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...q.length>0?{"anthropic-beta":q.join(",")}:{}},Q.headers,U,X)}),isOAuthToken:!1};if(_&&_Q(_))return{client:new L({apiKey:null,authToken:_,baseURL:Q.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:B({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...q].join(","),"user-agent":`claude-cli/${r}`,"x-app":"cli"},Q.headers,X)}),isOAuthToken:!0};let P=V&&K(Q).sendSessionAffinityHeaders?{"x-session-affinity":V}:{},D=B({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...q.length>0?{"anthropic-beta":q.join(",")}:{}},P,Q.headers,X);return{client:new L({apiKey:_??null,authToken:null,baseURL:Q.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:D}),isOAuthToken:!1}}function UQ(Q,_,Z,$){let{cacheControl:X}=m(Q,$?.cacheRetention,$?.env),U=K(Q),V=k(_.messages,Q,WQ),j=Z?H:(W)=>W,q=S({..._,messages:V},U.supportsToolReferences,j),P=q.immediate,D=[...q.deferred.values()];if(P.length===0&&D.length>0)P=D,D=[];let G=new Set(D.map((W)=>j(W.name))),Y={model:Q.id,messages:qQ(V,Z,X,U.allowEmptySignature,G,j),max_tokens:$?.maxTokens??Q.maxTokens,stream:!0};if(Z){if(Y.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...X?{cache_control:X}:{}}],_.systemPrompt)Y.system.push({type:"text",text:E(_.systemPrompt),...X?{cache_control:X}:{}})}else if(_.systemPrompt)Y.system=[{type:"text",text:E(_.systemPrompt),...X?{cache_control:X}:{}}];if($?.temperature!==void 0&&!$?.thinkingEnabled&&U.supportsTemperature)Y.temperature=$.temperature;if(P.length>0||D.length>0)Y.tools=[...A(P,Z,U.supportsEagerToolInputStreaming,U.supportsCacheControlOnTools?X:void 0),...A(D,Z,U.supportsEagerToolInputStreaming,void 0,!0)];if(Q.reasoning){if($?.thinkingEnabled){let W=$.thinkingDisplay??"summarized";if(Q.compat?.forceAdaptiveThinking===!0){if(Y.thinking={type:"adaptive",display:W},$.effort)Y.output_config=$.effort==="xhigh"?{effort:$.effort}:{effort:$.effort}}else Y.thinking={type:"enabled",budget_tokens:$.thinkingBudgetTokens||1024,display:W}}else if($?.thinkingEnabled===!1&&Q.thinkingLevelMap?.off!==null)Y.thinking={type:"disabled"}}if($?.metadata){let W=$.metadata.user_id;if(typeof W==="string")Y.metadata={user_id:W}}if($?.toolChoice)if(typeof $.toolChoice==="string")Y.tool_choice={type:$.toolChoice};else Y.tool_choice=$.toolChoice;return Y}function WQ(Q){return Q.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function VQ(Q,_,Z,$,X){let U=[];for(let j of Q.addedToolNames??[]){let q=X(j);if(!Z.has(q)||$.has(q))continue;$.add(q),U.push({type:"tool_reference",tool_name:_?H(j):j})}let V=n(Q.content);return{toolResult:{type:"tool_result",tool_use_id:Q.toolCallId,content:U.length>0?U:V,is_error:Q.isError},siblingContent:U.length===0?[]:typeof V==="string"?[{type:"text",text:V}]:V}}function qQ(Q,_,Z,$=!1,X=new Set,U=(V)=>V){let V=[],j=new Set;for(let q=0;q<Q.length;q++){let P=Q[q];if(P.role==="user")if(typeof P.content==="string"){if(P.content.trim().length>0)V.push({role:"user",content:E(P.content)})}else{let G=P.content.map((Y)=>{if(Y.type==="text")return{type:"text",text:E(Y.text)};else return{type:"image",source:{type:"base64",media_type:Y.mimeType,data:Y.data}}}).filter((Y)=>{if(Y.type==="text")return Y.text.trim().length>0;return!0});if(G.length===0)continue;V.push({role:"user",content:G})}else if(P.role==="assistant"){let D=[];for(let G of P.content)if(G.type==="text"){if(G.text.trim().length===0)continue;D.push({type:"text",text:E(G.text)})}else if(G.type==="thinking"){if(G.redacted){D.push({type:"redacted_thinking",data:G.thinkingSignature});continue}let Y=G.thinkingSignature,W=!!Y&&Y.trim().length>0;if(G.thinking.trim().length===0&&!W)continue;if(!W)D.push($?{type:"thinking",thinking:E(G.thinking),signature:""}:{type:"text",text:E(G.thinking)});else D.push({type:"thinking",thinking:E(G.thinking),signature:Y})}else if(G.type==="toolCall")D.push({type:"tool_use",id:G.id,name:_?H(G.name):G.name,input:G.arguments??{}});if(D.length===0)continue;V.push({role:"assistant",content:D})}else if(P.role==="toolResult"){let D=[],G=[],Y=q;while(Y<Q.length&&Q[Y].role==="toolResult"){let W=VQ(Q[Y],_,X,j,U);D.push(W.toolResult),G.push(...W.siblingContent),Y++}q=Y-1,V.push({role:"user",content:[...D,...G]})}}if(Z&&V.length>0){let q=V[V.length-1];if(q.role==="user"){if(Array.isArray(q.content)){let P=q.content[q.content.length-1];if(P&&(P.type==="text"||P.type==="image"||P.type==="tool_result"))P.cache_control=Z}else if(typeof q.content==="string")q.content=[{type:"text",text:q.content,cache_control:Z}]}}return V}function GQ(Q,_){return!!_.tools?.length&&!K(Q).supportsEagerToolInputStreaming}function A(Q,_,Z,$,X=!1){if(!Q)return[];return Q.map((U,V)=>{let j=U.parameters;return{name:_?H(U.name):U.name,description:U.description,...Z?{eager_input_streaming:!0}:{},input_schema:{type:"object",properties:j.properties??{},required:j.required??[]},...X?{defer_loading:!0}:{},...$&&V===Q.length-1?{cache_control:$}:{}}})}function JQ(Q,_){switch(Q){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:_?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error"};default:throw Error(`Unhandled stop reason: ${Q}`)}}export{RQ as streamSimple,N as stream};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{pk as V,qk as k,rk as _,sk as E}from"./chunk-y9ttm07y.js";import{uk as b,vk as f,wk as A}from"./chunk-wqhk76de.js";import"./chunk-dhekxndw.js";import{yk as L}from"./chunk-etqpzc9e.js";import{zk as N}from"./chunk-k20bhxed.js";import"./chunk-c3fvs0bv.js";import"./chunk-hz31j0hk.js";import{Ek as B}from"./chunk-90et6bwm.js";import{Qk as M}from"./chunk-5zntjzxw.js";import{Uk as D,Vk as U}from"./chunk-vf066xwh.js";import"./chunk-qvgc9e08.js";import"./chunk-ws07a9kv.js";var y=new Set(["openai","openai-codex","opencode"]);function H(w){if(w)return w;if(typeof process<"u"&&process.env.PI_CACHE_RETENTION==="long")return"long";return"short"}function S(w){return{sendSessionIdHeader:w.compat?.sendSessionIdHeader??!0,supportsLongCacheRetention:w.compat?.supportsLongCacheRetention??!0}}function T(w,F){return F==="long"&&w.supportsLongCacheRetention?"24h":void 0}function C(w){if(w instanceof Error){let F=w.status,z=typeof F==="number"?F:void 0;if(z!==void 0)return`OpenAI API error (${z}): ${w.message}`;return w.message}try{return JSON.stringify(w)}catch{return String(w)}}var I=(w,F,z)=>{let G=new U;return(async()=>{let Q={role:"assistant",content:[],api:w.api,provider:w.provider,model:w.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let W=z?.apiKey;if(!W)throw Error(`No API key for provider: ${w.provider}`);let X=H(z?.cacheRetention)==="none"?void 0:z?.sessionId,Z=v(w,F,W,z?.headers,X),Y=x(w,F,z),$=await z?.onPayload?.(Y,w);if($!==void 0)Y=$;let j={...z?.signal?{signal:z.signal}:{},...z?.timeoutMs!==void 0?{timeout:z.timeoutMs}:{},maxRetries:z?.maxRetries??0},{data:K,response:q}=await Z.responses.create(Y,j).withResponse();if(await z?.onResponse?.({status:q.status,headers:B(q.headers)},w),G.push({type:"start",partial:Q}),await A(K,Q,G,w,{serviceTier:z?.serviceTier,applyServiceTierPricing:(P,O)=>h(P,O,w)}),z?.signal?.aborted)throw Error("Request was aborted");if(Q.stopReason==="aborted"||Q.stopReason==="error")throw Error("An unknown error occurred");G.push({type:"done",reason:Q.stopReason,message:Q}),G.end()}catch(W){for(let J of Q.content)delete J.index,delete J.partialJson;Q.stopReason=z?.signal?.aborted?"aborted":"error",Q.errorMessage=C(W),G.push({type:"error",reason:Q.stopReason,error:Q}),G.end()}})(),G},i=(w,F,z)=>{let G=z?.apiKey;if(!G)throw Error(`No API key for provider: ${w.provider}`);let Q=M(w,z,G),W=z?.reasoning?D(w,z.reasoning):void 0;return I(w,F,{...Q,reasoningEffort:W==="off"?void 0:W})};function v(w,F,z,G,Q){let W=S(w),J={...w.headers};if(w.provider==="github-copilot"){let Z=_(F.messages),Y=E({messages:F.messages,hasImages:Z});Object.assign(J,Y)}if(Q){if(W.sendSessionIdHeader)J.session_id=Q;J["x-client-request-id"]=Q}if(G)Object.assign(J,G);let X=w.provider==="cloudflare-ai-gateway"?{...J,Authorization:J.Authorization??null,"cf-aig-authorization":`Bearer ${z}`}:J;return new N({apiKey:z,baseURL:V(w.provider)?k(w):w.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:X})}function x(w,F,z){let G=b(w,F,y),Q=H(z?.cacheRetention),W=S(w),J={model:w.id,input:G,stream:!0,prompt_cache_key:Q==="none"?void 0:L(z?.sessionId),prompt_cache_retention:T(W,Q),store:!1};if(z?.maxTokens)J.max_output_tokens=z?.maxTokens;if(z?.temperature!==void 0)J.temperature=z?.temperature;if(z?.serviceTier!==void 0)J.service_tier=z.serviceTier;if(F.tools&&F.tools.length>0)J.tools=f(F.tools);if(w.reasoning){if(z?.reasoningEffort||z?.reasoningSummary){let X=z?.reasoningEffort?w.thinkingLevelMap?.[z.reasoningEffort]??z.reasoningEffort:"medium";J.reasoning={effort:X,summary:z?.reasoningSummary||"auto"},J.include=["reasoning.encrypted_content"]}else if(w.provider!=="github-copilot"&&w.thinkingLevelMap?.off!==null)J.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return J}function R(w,F){switch(F){case"flex":return 0.5;case"priority":return w.id==="gpt-5.5"?2.5:2;default:return 1}}function h(w,F,z){let G=R(z,F);if(G===1)return;w.cost.input*=G,w.cost.output*=G,w.cost.cacheRead*=G,w.cost.cacheWrite*=G,w.cost.total=w.cost.input+w.cost.output+w.cost.cacheRead+w.cost.cacheWrite}export{i as streamSimpleOpenAIResponses,I as streamOpenAIResponses};
@@ -1,3 +0,0 @@
1
- // @bun
2
- var q=new Set;function F(b){return q.add(b),()=>{q.delete(b)}}function A(b){if(b instanceof Error)return b.message||b.name;if(typeof b==="string")return b;return String(b)}function B(b){if(!(b instanceof Error))return{name:"ThrownValue",message:A(b)};let k=b.code;return{name:b.name||void 0,message:b.message||b.name,stack:b.stack,code:typeof k==="string"||typeof k==="number"?k:void 0}}function H(b,k,z){return{type:b,timestamp:Date.now(),error:B(k),details:z}}function J(b,k){b.diagnostics=[...b.diagnostics??[],k]}
3
- export{F as Ue,A as Ve,H as We,J as Xe};
@@ -1,2 +0,0 @@
1
- import{s as p}from"./chunk-nzy3pjjm.js";import{W as Yz,X as Zz,Y as _z,Z as $z,_ as Kz}from"./chunk-zhd2mkbr.js";import{Va as Uz}from"./chunk-31mjcykb.js";import{Xa as A}from"./chunk-hfp4hpca.js";import{kg as v}from"./chunk-z0ej44ak.js";import{Pg as Jz}from"./chunk-wap08p4j.js";import{bh as Xz}from"./chunk-nr89225z.js";import{Gj as Gz,Mh as r,Ni as h,Wh as o,ak as T,di as t,fi as e,gh as Bz,hh as B,ih as z,ik as Y,jh as J,jj as zz,kh as a,ki as M,li as s,nh as n,qi as b,xj as S}from"./chunk-b1e3tec3.js";import{Xk as Rz}from"./chunk-ws07a9kv.js";var _=Rz(Bz(),1);function uz({projectId:O,contextAssetId:R}){let{isHistoryMode:W,setIsHistoryMode:I,currentSessionId:Vz,chatAssets:u,removeAsset:Wz,messages:E,historySessions:g,isStreaming:D,fetchHistorySessions:m,loadSession:Lz,deleteSession:Nz,startNewSession:Qz,sendMessage:Pz,abortActiveSession:Oz,selectedAgentId:H,setSelectedAgentId:w,inputText:C,setInputText:l}=v(),{teamId:Z,ensureTeamIdForProject:j}=Xz();_.useEffect(()=>{if(O)j(O)},[O,j]);let{data:Dz=[]}=n({queryKey:["agents",Z],queryFn:async()=>{if(!Z)return[];let G=await r.api.teams[":teamId"].agents.$get({param:{teamId:Z}});if(!G.ok)throw Error("failed to fetch agents");return G.json()},enabled:!!Z}),F=Dz.filter((G)=>G.type==="chat"&&G.enabled);_.useEffect(()=>{if(F.length>0){if(!F.some((X)=>X.id===H))w(F[0].id)}},[F,H,w]);let d=_.useRef(null),y=_.useRef(null),k=_.useRef(!0),f=_.useRef(!0);_.useEffect(()=>{f.current=!0,k.current=!0},[O,R,W]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let{scrollTop:X,isAtBottom:$}=v.getState(),V=setTimeout(()=>{if($)G.scrollTop=G.scrollHeight;else G.scrollTop=X;let Q=setTimeout(()=>{f.current=!1},50);return()=>clearTimeout(Q)},0);return()=>clearTimeout(V)},[O,R,W]),_.useEffect(()=>{let G=y.current?.querySelector('[data-slot="scroll-area-viewport"]');if(!G)return;let X=()=>{if(f.current)return;let $=G.scrollTop,V=G.scrollHeight-$-G.clientHeight<10;v.getState().setScrollState($,V)};return G.addEventListener("scroll",X),()=>{G.removeEventListener("scroll",X)}},[O,R,W]);let{ref:qz,isDropTarget:Ez}=Uz({id:"chatbot-sidebar",data:{type:"chatbot-sidebar"}});_.useEffect(()=>{if(!W){let{isAtBottom:G}=v.getState();if(G||D){let X=k.current?"auto":"smooth";d.current?.scrollIntoView({behavior:X})}k.current=!1}},[E,D,W]),_.useEffect(()=>{if(W&&Z)m(Z)},[W,m,Z]);let q=a(),Fz=_.useCallback(()=>{q.invalidateQueries({queryKey:["search"]}),q.invalidateQueries({queryKey:["folders"]}),q.invalidateQueries({queryKey:["files"]}),q.invalidateQueries({queryKey:["file"]}),q.invalidateQueries({queryKey:["version_stacks"]}),q.invalidateQueries({queryKey:["projects"]})},[q]),x=()=>{if(!C.trim()||D||!Z)return;Pz(Z,C,O,R,Fz),l("")},Hz=(G)=>{if(G.nativeEvent.isComposing)return;if(G.key==="Enter"&&!G.shiftKey)G.preventDefault(),x()},c=(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""},i=(G)=>{return G.replace(/<@([a-zA-Z0-9_-]+)>/g,"@$1").replace(/^\[([^\]]+)\]:/gm,"\\[$1\\]:")},Cz=(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:c(G.content)})},G.id);case"assistant":{let $=G.content;if(!$)return null;let V=[];if($.forEach((K,L)=>{if(!K||typeof K!=="object")return;let N=K;switch(N.type){case"text":{let U=N.text;if(typeof U!=="string"||!U.trim())return;V.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:P,...vz})=>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",...vz})},children:i(U)})},`txt-${L}`));break}case"thinking":{let U=N.thinking;if(typeof U!=="string"||!U.trim())return;V.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(s,{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:i(U)})})]},`think-${L}`));break}case"toolCall":{let U=String(N.name||N.toolName||Y.unknown()),P=N.arguments||N.args;V.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(Gz,{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:U}),z(b,{className:"h-3 w-3 ml-auto transition-transform group-open:rotate-180"})]}),!!P&&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(P,null,2)})]})]},`tool-${L}`));break}case"image":{let U=String(N.mimeType||"image/png"),P=String(N.data||"");V.push(z("div",{className:"my-2 max-w-full",children:P?z("img",{src:P.startsWith("data:")?P:`data:${U};base64,${P}`,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-${L}`));break}default:{let U=JSON.stringify(K,null,2);if(U==="{}")return;V.push(z("pre",{className:"text-xs text-foreground/80 font-mono whitespace-pre-wrap break-words bg-muted/20 p-2 rounded",children:U},`other-${L}`))}}}),V.length===0)return null;let Q=!1;if($.length>0){let K=$[$.length-1];if(typeof K==="string"&&K.trim().length>0)Q=!0;else if(K&&typeof K==="object"){let L=K;if(L.type==="text"&&typeof L.text==="string"&&L.text.trim().length>0)Q=!0}}return J("div",{className:"flex flex-col w-full space-y-1",children:[z("div",{className:"space-y-2 w-full",children:V}),Q&&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==="context_display_info"){let Q=X.details?.assets||[];if(Q.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:Q.map((K)=>J("li",{className:"truncate",children:[K.name," ",J("span",{className:"text-muted-foreground/70",children:["(",K.type,")"]})]},K.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:c($)},G.id)}default:return null}};return J("div",{ref:qz,className:T("relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0"),children:[Ez&&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(M,{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:W?J(B,{children:[z("div",{className:"flex items-center gap-2 font-semibold",children:z("span",{children:Y.history()})}),z("button",{onClick:()=>I(!1),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:"Close History",children:z(t,{className:"h-4 w-4"})})]}):J(B,{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:Qz,className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.new_chat(),children:z(zz,{className:"h-4 w-4"})}),z("button",{onClick:()=>I(!0),className:"p-1.5 hover:bg-accent rounded-md text-muted-foreground hover:text-foreground transition-colors",title:Y.history(),children:z(h,{className:"h-4 w-4"})})]})]})}),W?z(A,{className:"flex-1 p-4 min-h-0",children:g.length===0?J("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground p-4 text-center",children:[z(h,{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:g.map((G)=>{let X=G.id===Vz;return J("div",{className:T("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:()=>Z&&Lz(Z,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:Jz(G.createdAt)})]}),z("button",{onClick:($)=>{if($.stopPropagation(),Z&&confirm(Y.delete_session_confirm()))Nz(Z,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(S,{className:"h-4 w-4"})})]},G.id)})})}):J(B,{children:[z(A,{ref:y,className:"flex-1 p-4 min-h-0 [&>div>div]:!block",children:E.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(M,{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:[E.map(Cz),D&&E.length>0&&E[E.length-1].role==="user"&&J("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground italic",children:[z(o,{className:"h-3 w-3 animate-spin text-primary"}),z("span",{children:"Thinking..."})]}),z("div",{ref:d})]})}),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:[u.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:u.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:()=>Wz(G.id),className:"text-muted-foreground hover:text-destructive transition-colors p-0.5",title:Y.remove_from_context(),children:z(S,{className:"h-3.5 w-3.5"})})]},G.id))}),z("textarea",{value:C,onChange:(G)=>l(G.target.value),onKeyDown:Hz,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:D}),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:F.length>0?J(Yz,{value:H||"",onValueChange:(G)=>w(G),disabled:D,children:[z(_z,{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(Zz,{placeholder:Y.select_agent()})}),z($z,{children:F.map((G)=>z(Kz,{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(M,{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()})})}),D?z("button",{onClick:()=>{if(Z)Oz(Z)},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:x,disabled:!C.trim()||!H,className:T("p-2 rounded-full transition-all duration-200 flex items-center justify-center shrink-0 shadow-sm",C.trim()&&H?"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(e,{className:"h-4 w-4"})})]})]})})]})]})}
2
- export{uz as k};
@@ -1,3 +0,0 @@
1
- // @bun
2
- function f(b){return b.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"")}
3
- export{f as Wk};
@@ -1,2 +0,0 @@
1
- import{n as s,p as t,q as b}from"./chunk-8e5zvy88.js";import{Rg as YG,Tg as _G,Ug as $G,Vg as QG}from"./chunk-nr89225z.js";import{Gi as JG,Hj as WG,Mh as c,Wh as A,Zi as i,ak as C,cj as a,gh as SG,hh as d,ih as H,ik as r,jh as O,nh as KG,pi as GG,qi as HG}from"./chunk-b1e3tec3.js";import{Xk as AG}from"./chunk-ws07a9kv.js";function vG({file:Y,mediaControllerRef:X,onPlay:K,onPause:N,onTimeUpdate:V,annotations:_,startTime:M,shareId:Z,children:U}){let L=b(Y).viewer;return H(L,{ref:X,file:Y,onPlay:K,onPause:N,onTimeUpdate:V,annotations:_,startTime:M,shareId:Z,children:U},Y.id)}var J=AG(SG(),1);function e({activeState:Y,activeAsset:X,previewUrl:K,isFullScreen:N,onTogglePlay:V,onToggleLoop:_,onSeek:M,onVolumeChange:Z,onToggleMute:U,onChangePlaybackRate:B,onChangeResolution:L,onZoomIn:w,onZoomOut:T,onFit:z,onDownload:F,onToggleFullScreen:E}){if(Y?.kind==="video"&&Y.video&&X){let $=Y.video,y=$.totalFrames/$.frameRate,p=$.currentFrame/$.frameRate,S={isPlaying:$.isPlaying,progress:y>0?p/y*100:0,currentTime:p,duration:y,volume:$.volume,isMuted:$.isMuted,isLooping:$.isLooping,playbackRate:$.playbackRate,isFullScreen:N,showFrames:!1,currentResolution:$.currentResolution},g=K&&!X.media?.videoPreview?{...X,media:{...X.media,videoPreview:{url:K}}}:X;return H(s,{state:S,zoom:Y.zoom,isControlsVisible:!0,floatOverlayInFullScreen:!1,buffered:$.buffered,data:g,resolutions:$.resolutions,togglePlay:V,toggleLoop:_,toggleMute:U,handleVolumeChange:Z,changePlaybackRate:B,changeResolution:(k)=>L(k.resolution),handleDownload:(k)=>F(k),toggleFullScreen:E,onZoomChange:(k)=>k>=Y.zoom?w():T(),onZoomReset:z,frameRate:$.frameRate,totalFrames:$.totalFrames,currentFrame:$.currentFrame,seekToFrame:M})}if(Y?.kind==="image")return H(t,{zoom:Y.zoom,onZoomIn:w,onZoomOut:T,onFit:z,onDownload:()=>F(),canDownload:!!X?.media?.original?.key,fullscreen:{isFullScreen:N,onToggle:E}});return H("div",{className:"relative z-10 flex items-center justify-end gap-2 border-t border-border bg-card px-4 py-3",children:H("button",{onClick:E,className:"text-foreground transition-colors hover:text-primary",title:"Fullscreen",children:N?H(a,{className:"h-5 w-5"}):H(i,{className:"h-5 w-5"})})})}function v({side:Y,fileName:X,version:K,activeVersionId:N,versions:V,isActive:_,onActivate:M,onSwitchVersion:Z,onExit:U}){let B=C("flex-shrink-0 rounded p-1 transition-colors hover:bg-muted",_?"text-foreground":"text-muted-foreground hover:text-foreground"),L=H("button",{onClick:U,title:r.exit_compare(),className:B,children:H(WG,{className:"h-4 w-4"})}),w=O("button",{onClick:M,className:C("flex min-w-0 items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-muted",_?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[H("span",{className:"truncate",children:X}),K!==void 0&&O("span",{className:C("flex-shrink-0 rounded border px-1 py-0 text-xs",_?"border-foreground/40":"border-border"),children:["v",K]})]}),T=O(YG,{children:[H(_G,{onClick:M,title:r.switch_version(),className:B,children:H(HG,{className:"h-4 w-4"})}),H($G,{align:Y==="left"?"start":"end",className:"w-80 p-1",children:H("div",{className:"flex max-h-96 flex-col gap-1 overflow-y-auto",children:V.map((z)=>{let F=z.id===N;return O(QG,{onClick:()=>Z(z.id),className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2",children:[O("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",z.version]}),H("div",{className:"flex h-10 w-16 flex-shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:z.previewUrl?H("img",{src:z.previewUrl,alt:z.name||void 0,className:"h-full w-full object-cover"}):H(JG,{className:"h-4 w-4 text-muted-foreground"})}),O("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[H("span",{className:"truncate text-sm font-semibold text-foreground",children:z.name}),H("span",{className:"truncate text-xs text-muted-foreground",children:z.creator?.name||"Unknown"})]}),F&&H(GG,{className:"ml-auto h-4 w-4 flex-shrink-0 text-primary"})]},z.id)})})})]});return H("div",{onMouseDown:M,className:C("dark flex h-10 flex-shrink-0 items-center gap-1 border-b bg-background px-2 transition-colors",_?"border-b-2 border-primary":"border-border"),children:Y==="left"?O(d,{children:[L,w,T]}):O(d,{children:[w,T,H("div",{className:"ml-auto"}),L]})})}function XG(Y,X,K){return KG({queryKey:X?["public-share-file",K,Y,localStorage.getItem(`share_pwd_${K}`)||""]:["files",Y],queryFn:async()=>{if(X){let V=localStorage.getItem(`share_pwd_${K}`)||"",_=await c.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:K,fileId:Y}},{headers:{"x-share-password":V}});if(!_.ok)throw Error("Failed to fetch version asset");return await _.json()}let N=await c.api.files[":fileId"].$get({param:{fileId:Y}});if(!N.ok)throw Error("Failed to fetch version asset");return await N.json()},enabled:!!Y&&(!X||!!K)})}function NH({isPublic:Y=!1,shareId:X,versions:K,leftId:N,rightId:V,activeSide:_,annotations:M,seekRequest:Z,onActiveSideChange:U,onSwitchVersion:B,onExit:L,onActiveAssetChange:w,onPlay:T,onTimeUpdate:z}){let F=J.useRef(null),E=J.useRef(null),$=J.useRef(null),[y,p]=J.useState(null),[S,g]=J.useState(null),[k,NG]=J.useState(1),[zG,l]=J.useState(!1),[OG,qG]=J.useState(!1),{data:P,isLoading:VG}=XG(N,Y,X),{data:R,isLoading:ZG}=XG(V,Y,X),MG=b(P),UG=b(R),I=!!P&&!!R&&MG.id===UG.id,f=_==="left"?P:R,u=_==="left"?y:S,D=J.useCallback(()=>_==="left"?E.current:$.current,[_]),h=J.useCallback(()=>_==="left"?$.current:E.current,[_]);J.useEffect(()=>{w(f??null)},[f,w]),J.useEffect(()=>{if(!Z)return;let G=D();if(G?.seekToSecond(Z.second),G?.pause(),I){let W=h();W?.seekToSecond(Z.second),W?.pause()}},[Z?.nonce]),J.useEffect(()=>{let G=()=>qG(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",G),()=>document.removeEventListener("fullscreenchange",G)},[]);let LG=J.useCallback((G)=>p(G),[]),DG=J.useCallback((G)=>g(G),[]),q=J.useCallback((G)=>{let W=D();if(W)G(W);if(I){let Q=h();if(Q)G(Q)}},[D,h,I]),m=J.useCallback(()=>{let G=!u?.video?.isPlaying;q((W)=>G?W.play():W.pause())},[u?.video?.isPlaying,q]);J.useEffect(()=>{let G=(W)=>{let Q=document.activeElement;if(Q&&(Q.tagName==="INPUT"||Q.tagName==="TEXTAREA"||Q instanceof HTMLElement&&Q.isContentEditable))return;let x=W.key===" ",j=Q&&(Q.tagName==="BUTTON"||Q.tagName==="A"||Q.tagName==="SELECT"||Q.tagName==="OPTION"||Q.getAttribute("role")==="button"||Q.getAttribute("role")==="link"||Q.getAttribute("role")==="checkbox"||Q.getAttribute("role")==="radio"||Q.getAttribute("role")==="menuitem");if(x&&j)return;if(W.key===" "||W.key.toLowerCase()==="k")W.preventDefault(),m()};return window.addEventListener("keydown",G),()=>{window.removeEventListener("keydown",G)}},[m]);let BG=J.useCallback((G)=>q((W)=>W.seekToFrame(G)),[q]),wG=J.useCallback(()=>D()?.toggleLoop(),[D]),FG=J.useCallback((G)=>{NG(G),l(G===0)},[]),EG=J.useCallback(()=>l((G)=>!G),[]),PG=J.useCallback((G)=>q((W)=>W.setPlaybackRate(G)),[q]),RG=J.useCallback((G)=>D()?.changeResolution(G),[D]),TG=J.useCallback(()=>q((G)=>G.zoomBy(1.2)),[q]),kG=J.useCallback(()=>q((G)=>G.zoomBy(0.8)),[q]),IG=J.useCallback(()=>q((G)=>G.fit()),[q]),bG=J.useCallback((G)=>{D()?.download(G)},[D]),yG=J.useCallback(()=>{if(!F.current)return;if(!document.fullscreenElement)F.current.requestFullscreen();else document.exitFullscreen()},[]),fG=J.useCallback((G,W)=>{if(I)$.current?.panBy(G,W)},[I]),mG=J.useCallback((G,W)=>{if(I)E.current?.panBy(G,W)},[I]),jG=J.useCallback(()=>m(),[m]),n=J.useCallback((G)=>K.find((W)=>W.id===G)?.version,[K]),CG=J.useMemo(()=>f?.media?.videoPreview?.url,[f?.media?.videoPreview?.url]),o=(G,W)=>{let x=b(W)?.comparePane;if(!x)return H("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:H("p",{className:"text-muted-foreground",children:"Preview unavailable"})});let j=_===G;return H(x,{ref:G==="left"?E:$,file:W,shareId:X,isActive:j,annotations:j?M:[],onStateChange:G==="left"?LG:DG,onUserPan:G==="left"?fG:mG,onActivate:()=>U(G),muted:j?zG:!0,volume:k,onPlay:T,onTimeUpdate:z,onRequestTogglePlay:jG},W.id)},pG=!!P&&!!R,xG=VG||ZG;return O("div",{ref:F,className:"flex h-full flex-1 flex-col bg-background",children:[O("div",{className:"flex min-h-0 flex-1",children:[O("div",{className:"flex min-w-0 flex-1 flex-col border-r border-zinc-800",children:[P&&H(v,{side:"left",fileName:P.name,version:n(N),activeVersionId:N,versions:K,isActive:_==="left",onActivate:()=>U("left"),onSwitchVersion:(G)=>B("left",G),onExit:L}),H("div",{className:"relative flex min-h-0 flex-1",children:P?o("left",P):H("div",{className:"flex flex-1 items-center justify-center",children:H(A,{className:"h-6 w-6 animate-spin text-foreground"})})})]}),O("div",{className:"flex min-w-0 flex-1 flex-col",children:[R&&H(v,{side:"right",fileName:R.name,version:n(V),activeVersionId:V,versions:K,isActive:_==="right",onActivate:()=>U("right"),onSwitchVersion:(G)=>B("right",G),onExit:L}),H("div",{className:"relative flex min-h-0 flex-1",children:R?o("right",R):H("div",{className:"flex flex-1 items-center justify-center",children:H(A,{className:"h-6 w-6 animate-spin text-foreground"})})})]})]}),xG&&!pG&&H("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/30",children:H(A,{className:"h-8 w-8 animate-spin text-foreground"})}),H(e,{activeState:u,activeAsset:f??null,previewUrl:CG,isFullScreen:OG,onTogglePlay:m,onToggleLoop:wG,onSeek:BG,onVolumeChange:FG,onToggleMute:EG,onChangePlaybackRate:PG,onChangeResolution:RG,onZoomIn:TG,onZoomOut:kG,onFit:IG,onDownload:bG,onToggleFullScreen:yG})]})}
2
- export{vG as h,NH as i};
@@ -1 +0,0 @@
1
- import{j as _}from"./chunk-k0a35mg9.js";import"./chunk-qn96vbke.js";import"./chunk-d3s00sn0.js";import"./chunk-8e5zvy88.js";import"./chunk-nzy3pjjm.js";import"./chunk-mm1j72a8.js";import"./chunk-9c7fxjej.js";import"./chunk-zhd2mkbr.js";import"./chunk-bdjhb77e.js";import"./chunk-p9xfyqh1.js";import"./chunk-31mjcykb.js";import"./chunk-hfp4hpca.js";import"./chunk-wrz9e73c.js";import"./chunk-1nh6xgek.js";import"./chunk-3rcc5s99.js";import"./chunk-20y3wte3.js";import{gf as Y,hf as Z}from"./chunk-a76c5r3c.js";import"./chunk-qc6dmzn0.js";import"./chunk-7y8dng8t.js";import"./chunk-3t7mjvdv.js";import"./chunk-z0ej44ak.js";import"./chunk-tsncwscz.js";import"./chunk-h2wsm7h3.js";import"./chunk-etces6ff.js";import"./chunk-yahb7wan.js";import"./chunk-mahxw48e.js";import"./chunk-wap08p4j.js";import{bh as X}from"./chunk-nr89225z.js";import{Ah as V,Mh as B,gh as O,ih as w,ik as W,nh as A,oh as N,ph as U}from"./chunk-b1e3tec3.js";import{Xk as M}from"./chunk-ws07a9kv.js";var h=M(O(),1);function R(){let{projectId:k,collectionId:D}=P.useParams(),{teamId:G,ensureTeamIdForProject:H}=X();h.useEffect(()=>{H(k)},[k,H]);let{data:J}=N(Y(k)),{data:v,refetch:z}=A({...Z(D)}),{mutate:E}=U({mutationFn:async(q)=>{let K=await B.api.collections[":collectionId"].$patch({param:{collectionId:D},json:q});if(!K.ok)throw Error("Failed to update collection");return await K.json()},onSuccess:()=>{z()}}),b=J?.rootFolder,{data:L}=A({queryKey:["folders",b],queryFn:async()=>{let q=await B.api.folders[":folderId"].$get({param:{folderId:b}});if(!q.ok)throw Error("Failed to fetch folder");return await q.json()},enabled:!!b});if(!G||!b||!L||!v)return w("div",{children:W.loading_collection()});let $=v.filter.sourceFolderId||b;return w(_,{teamId:G,projectId:k,projectName:J.name??"",assetId:$,rootFolderId:b,collection:v,onUpdateCollection:E})}var P=V("/projects/$projectId/collections/$collectionId")({component:R});export{P as Route};
@@ -1 +0,0 @@
1
- import{g as v}from"./chunk-jstc7pka.js";import"./chunk-rrxjvewm.js";import"./chunk-8e5zvy88.js";import"./chunk-nzy3pjjm.js";import"./chunk-mm1j72a8.js";import"./chunk-9c7fxjej.js";import"./chunk-zhd2mkbr.js";import"./chunk-bdjhb77e.js";import"./chunk-p9xfyqh1.js";import"./chunk-31mjcykb.js";import"./chunk-hfp4hpca.js";import"./chunk-wrz9e73c.js";import"./chunk-1nh6xgek.js";import"./chunk-3rcc5s99.js";import"./chunk-20y3wte3.js";import"./chunk-6t3gdd7e.js";import"./chunk-ejfmxjw6.js";import"./chunk-7y8dng8t.js";import"./chunk-3t7mjvdv.js";import"./chunk-z0ej44ak.js";import"./chunk-tsncwscz.js";import"./chunk-h2wsm7h3.js";import"./chunk-etces6ff.js";import"./chunk-yahb7wan.js";import"./chunk-mahxw48e.js";import"./chunk-wap08p4j.js";import"./chunk-nr89225z.js";import{Ah as q,ih as k}from"./chunk-b1e3tec3.js";import"./chunk-ws07a9kv.js";function B(){let{shareId:w,folderId:A}=C.useParams();return k(v,{shareId:w,initialFolderId:A})}var C=q("/share/$shareId/folders/$folderId")({component:B});export{C as Route};
@@ -1,8 +0,0 @@
1
- // @bun
2
- import{Ue as QN,Ve as h,We as VN,Xe as ZN}from"./chunk-q5cdjzbv.js";import{uk as g,vk as NN,wk as v}from"./chunk-wqhk76de.js";import"./chunk-dhekxndw.js";import{yk as e}from"./chunk-etqpzc9e.js";import"./chunk-c3fvs0bv.js";import"./chunk-hz31j0hk.js";import{Ek as b}from"./chunk-90et6bwm.js";import{Qk as s}from"./chunk-5zntjzxw.js";import{Uk as t,Vk as o}from"./chunk-vf066xwh.js";import"./chunk-qvgc9e08.js";import"./chunk-ws07a9kv.js";function c(N){let Q=N.filter((Z)=>Z!==void 0);if(Q.length===0)return{cleanup:()=>{}};if(Q.length===1)return{signal:Q[0],cleanup:()=>{}};let V=new AbortController,$=[],X=(Z)=>{if(!V.signal.aborted)V.abort(Z.reason)};for(let Z of Q){if(Z.aborted){X(Z);break}let G=()=>X(Z);Z.addEventListener("abort",G,{once:!0}),$.push({signal:Z,listener:G})}return{signal:V.signal,cleanup:()=>{for(let{signal:Z,listener:G}of $)Z.removeEventListener("abort",G)}}}var jN=function(N,Q){if(typeof N==="string"&&/^\.\.?\//.test(N))return N.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(V,$,X,Z,G){return $?Q?".jsx":".js":X&&(!Z||!G)?V:X+Z+"."+G.toLowerCase()+"js"});return N},C=null,$N=(N)=>import(jN(N)),UN="node:os";if(typeof process<"u"&&(process.versions?.node||process.versions?.bun))$N(UN).then((N)=>{C=N});var _N="https://chatgpt.com/backend-api",BN="https://api.openai.com/auth",WN=0,p=1000,HN=60000,l=1e4,RN=15000,XN=new Set(["openai","openai-codex","opencode"]),qN=1009,AN=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function wN(N){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(N)}function CN(N,Q){if(N===429&&wN(Q))return!1;if(N===429||N===500||N===502||N===503||N===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(Q)}function EN(N){let Q=N.get("retry-after-ms");if(Q!==null){let Z=Number(Q);if(Number.isFinite(Z))return Math.max(0,Z)}let V=N.get("retry-after");if(!V)return;let $=Number(V);if(Number.isFinite($))return Math.max(0,$*1000);let X=Date.parse(V);if(!Number.isNaN(X))return Math.max(0,X-Date.now());return}function fN(N,Q){let V=Q?.maxRetryDelayMs??HN;return V>0?Math.min(N,V):N}function d(N,Q){return new Promise((V,$)=>{if(Q?.aborted){$(Error("Request was aborted"));return}let X=setTimeout(V,N);Q?.addEventListener("abort",()=>{clearTimeout(X),$(Error("Request was aborted"))})})}function a(N){if(N===void 0)return;if(!Number.isFinite(N)||N<0)throw Error(`Invalid timeoutMs: ${String(N)}`);return Math.floor(N)}function MN(){let N=new AbortController,Q,V=setTimeout(()=>{Q=Error(`Codex SSE response headers timed out after ${l}ms`),N.abort(Q)},l);return{signal:N.signal,clear:()=>clearTimeout(V),error:()=>Q}}var SN=(N,Q,V)=>{let $=new o;return(async()=>{let X={role:"assistant",content:[],api:"openai-codex-responses",provider:N.provider,model:N.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let Z=V?.apiKey;if(!Z)throw Error(`No API key for provider: ${N.provider}`);let G=NQ(Z),J=xN(N,Q,V),Y=await V?.onPayload?.(J,N);if(Y!==void 0)J=Y;let P=V?.sessionId||QQ(),O=VQ(N.headers,V?.headers,G,Z,V?.sessionId),z=ZQ(N.headers,V?.headers,G,Z,P),B=JSON.stringify(J),L=a(V?.timeoutMs),W=a(V?.websocketConnectTimeoutMs),D=V?.transport||"auto",j=D!=="sse"&&PN(V?.sessionId);if(j)i(V?.sessionId);if(D!=="sse"&&!j){let U=!1;try{if(await sN(hN(N.baseUrl),J,z,X,$,N,()=>{U=!0},L,W,V),V?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end();return}catch(_){if(V?.signal?.aborted||kN(_))throw _;if(ZN(X,VN("provider_transport_failure",_,{configuredTransport:D,fallbackTransport:U?void 0:"sse",eventsEmitted:U,phase:U?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(B).byteLength})),uN(V?.sessionId,_),U)throw _;i(V?.sessionId)}}let F,K,R=V?.maxRetries??WN;for(let U=0;U<=R;U++){if(V?.signal?.aborted)throw Error("Request was aborted");try{let _=MN(),A=c([V?.signal,_.signal]);try{F=await fetch(FN(N.baseUrl),{method:"POST",headers:O,body:B,signal:A.signal})}catch(w){let f=_.error();throw f&&!V?.signal?.aborted?f:w}finally{A.cleanup(),_.clear()}if(await V?.onResponse?.({status:F.status,headers:b(F.headers)},N),F.ok)break;let m=await F.text();if(U<R&&CN(F.status,m)){let w=EN(F.headers),f=w===void 0?p*2**U:F.status===429?fN(w,V):w;await d(f,V?.signal);continue}let DN=new Response(m,{status:F.status,statusText:F.statusText}),u=await eN(DN);throw Error(u.friendlyMessage||u.message)}catch(_){if(_ instanceof Error){if(_.name==="AbortError"||_.message==="Request was aborted")throw Error("Request was aborted")}if(K=_ instanceof Error?_:Error(String(_)),U<R&&!K.message.includes("usage limit")){let A=p*2**U;await d(A,V?.signal);continue}throw K}}if(!F?.ok)throw K??Error("Failed after retries");if(!F.body)throw Error("No response body");if($.push({type:"start",partial:X}),await IN(F,X,$,N,V),V?.signal?.aborted)throw Error("Request was aborted");$.push({type:"done",reason:X.stopReason,message:X}),$.end()}catch(Z){for(let G of X.content)delete G.partialJson;X.stopReason=V?.signal?.aborted?"aborted":"error",X.errorMessage=Z instanceof Error?Z.message:String(Z),$.push({type:"error",reason:X.stopReason,error:X}),$.end()}})(),$},OQ=(N,Q,V)=>{let $=V?.apiKey;if(!$)throw Error(`No API key for provider: ${N.provider}`);let X=s(N,V,$),Z=V?.reasoning?t(N,V.reasoning):void 0;return SN(N,Q,{...X,reasoningEffort:Z==="off"?void 0:Z})};function xN(N,Q,V){let $=g(N,Q,XN,{includeSystemPrompt:!1}),X={model:N.id,store:!1,stream:!0,instructions:Q.systemPrompt||"You are a helpful assistant.",input:$,text:{verbosity:V?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:e(V?.sessionId),tool_choice:"auto",parallel_tool_calls:!0};if(V?.temperature!==void 0)X.temperature=V.temperature;if(V?.serviceTier!==void 0)X.service_tier=V.serviceTier;if(Q.tools&&Q.tools.length>0)X.tools=NN(Q.tools,{strict:null});if(V?.reasoningEffort!==void 0){let Z=V.reasoningEffort==="none"?N.thinkingLevelMap?.off??"none":N.thinkingLevelMap?.[V.reasoningEffort]??V.reasoningEffort;if(Z!==null)X.reasoning={effort:Z,summary:V.reasoningSummary??"auto"}}return X}function TN(N,Q){switch(Q){case"flex":return 0.5;case"priority":return N.id==="gpt-5.5"?2.5:2;default:return 1}}function GN(N,Q,V){let $=TN(V,Q);if($===1)return;N.cost.input*=$,N.cost.output*=$,N.cost.cacheRead*=$,N.cost.cacheWrite*=$,N.cost.total=N.cost.input+N.cost.output+N.cost.cacheRead+N.cost.cacheWrite}function YN(N,Q){if(N==="default"&&(Q==="flex"||Q==="priority"))return Q;return N??Q}function FN(N){let V=(N&&N.trim().length>0?N:_N).replace(/\/+$/,"");if(V.endsWith("/codex/responses"))return V;if(V.endsWith("/codex"))return`${V}/responses`;return`${V}/codex/responses`}function hN(N){let Q=new URL(FN(N));if(Q.protocol==="https:")Q.protocol="wss:";if(Q.protocol==="http:")Q.protocol="ws:";return Q.toString()}async function IN(N,Q,V,$,X){await v(JN(gN(N,X?.signal)),Q,V,$,{serviceTier:X?.serviceTier,resolveServiceTier:YN,applyServiceTierPricing:(Z,G)=>GN(Z,G,$)})}class x extends Error{code;payload;constructor(N,Q){super(N);this.name="CodexApiError",this.code=Q?.code,this.payload=Q?.payload,this.cause=Q?.cause}}class I extends Error{payload;constructor(N,Q){super(N);this.name="CodexProtocolError",this.payload=Q?.payload,this.cause=Q?.cause}}function kN(N){return N instanceof x||N instanceof I}async function*JN(N){for await(let Q of N){let V=typeof Q.type==="string"?Q.type:void 0;if(!V)continue;if(V==="error"){let $=Q.code||"",X=Q.message||"";throw new x(`Codex error: ${X||$||JSON.stringify(Q)}`,{code:$||void 0,payload:Q})}if(V==="response.failed"){let $=Q.response,X=$?.error?.code,Z=$?.error?.message;throw new x(Z||"Codex response failed",{code:X,payload:Q})}if(V==="response.done"||V==="response.completed"||V==="response.incomplete"){let $=Q.response,X=$?{...$,status:bN($.status)}:$;yield{...Q,type:"response.completed",response:X};return}yield Q}}function bN(N){if(typeof N!=="string")return;return AN.has(N)?N:void 0}async function*gN(N,Q){if(!N.body)return;let V=N.body.getReader(),$=new TextDecoder,X="",Z=()=>{V.cancel().catch(()=>{})};Q?.addEventListener("abort",Z,{once:!0});try{while(!0){if(Q?.aborted)throw Error("Request was aborted");let{done:G,value:J}=await V.read();if(Q?.aborted)throw Error("Request was aborted");if(G)break;X+=$.decode(J,{stream:!0});let Y=X.indexOf(`
3
-
4
- `);while(Y!==-1){let P=X.slice(0,Y);X=X.slice(Y+2);let O=P.split(`
5
- `).filter((z)=>z.startsWith("data:")).map((z)=>z.slice(5).trim());if(O.length>0){let z=O.join(`
6
- `).trim();if(z&&z!=="[DONE]")try{yield JSON.parse(z)}catch(B){throw new I(`Invalid Codex SSE JSON: ${h(B)}`,{cause:B,payload:z})}}Y=X.indexOf(`
7
-
8
- `)}}}finally{Q?.removeEventListener("abort",Z);try{await V.cancel()}catch{}try{V.releaseLock()}catch{}}}var vN="responses_websockets=2026-02-06",yN=300000,H=new Map,E=new Map,T=new Set;function y(N){let Q=E.get(N);if(!Q)Q={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0},E.set(N,Q);return Q}function DQ(N){let Q=E.get(N);return Q?{...Q}:void 0}function jQ(N){if(N){E.delete(N),T.delete(N);return}E.clear(),T.clear()}function mN(N){let Q=(V)=>{if(V.idleTimer)clearTimeout(V.idleTimer);q(V.socket,1000,"debug_close")};if(N){let V=H.get(N);if(V)Q(V);H.delete(N);return}for(let V of H.values())Q(V);H.clear()}QN(mN);function PN(N){return N?T.has(N):!1}function i(N){if(!N)return;let Q=y(N);Q.sseFallbacks++,Q.websocketFallbackActive=PN(N)}function uN(N,Q){if(!N)return;T.add(N);let V=y(N);V.websocketFailures++,V.lastWebSocketError=h(Q),V.websocketFallbackActive=!0}var M=null;async function cN(){if(M)return M;if(process?.versions?.bun&&(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)){let V=(await $N("proxy-from-env")).getProxyForUrl;return M=class extends WebSocket{constructor($,X){let Z={};if(Array.isArray(X)||typeof X==="string")Z={protocols:X};else Z={...X};let G=V($.toString().replace(/^wss:/,"https:").replace(/^ws:/,"http:"));super($,{...Z,...G?{proxy:G}:{}})}},M}let N=globalThis.WebSocket;if(typeof N!=="function")return null;return N}class zN extends Error{code;reason;wasClean;constructor(N,Q){super(N);this.name="WebSocketCloseError",this.code=Q?.code,this.reason=Q?.reason,this.wasClean=Q?.wasClean}}function pN(N){let Q=N.readyState;return typeof Q==="number"?Q:void 0}function S(N){let Q=pN(N);return Q===void 0||Q===1}function q(N,Q=1000,V="done"){try{N.close(Q,V)}catch{}}function r(N,Q){if(Q.idleTimer)clearTimeout(Q.idleTimer);Q.idleTimer=setTimeout(()=>{if(Q.busy)return;q(Q.socket,1000,"idle_timeout"),H.delete(N)},yN)}async function k(N,Q,V,$=RN){let X=await cN();if(!X)throw Error("WebSocket transport is not available in this runtime");let Z=b(Q);return delete Z["OpenAI-Beta"],new Promise((G,J)=>{let Y=!1,P,O;try{O=new X(N,{headers:Z})}catch(F){J(F instanceof Error?F:Error(String(F)));return}let z=()=>{if(P)clearTimeout(P),P=void 0;O.removeEventListener("open",L),O.removeEventListener("error",W),O.removeEventListener("close",D),V?.removeEventListener("abort",j)},B=(F,K)=>{if(Y)return;if(Y=!0,z(),K)q(O,1000,K);J(F)},L=()=>{if(Y)return;Y=!0,z(),G(O)},W=(F)=>{B(LN(F))},D=(F)=>{B(KN(F))},j=()=>{B(Error("Request was aborted"),"aborted")};if(O.addEventListener("open",L),O.addEventListener("error",W),O.addEventListener("close",D),V?.addEventListener("abort",j),$>0)P=setTimeout(()=>{B(Error(`WebSocket connect timeout after ${$}ms`),"connect_timeout")},$);if(V?.aborted)j()})}async function lN(N,Q,V,$,X){if(!V){let Y=await k(N,Q,$,X);return{socket:Y,reused:!1,release:()=>q(Y)}}let Z=H.get(V);if(Z){if(Z.idleTimer)clearTimeout(Z.idleTimer),Z.idleTimer=void 0;if(!Z.busy&&S(Z.socket))return Z.busy=!0,{socket:Z.socket,entry:Z,reused:!0,release:({keep:Y}={})=>{if(!Y||!S(Z.socket)){q(Z.socket),H.delete(V);return}Z.busy=!1,r(V,Z)}};if(Z.busy){let Y=await k(N,Q,$,X);return{socket:Y,reused:!1,release:()=>{q(Y)}}}if(!S(Z.socket))q(Z.socket),H.delete(V)}let G=await k(N,Q,$,X),J={socket:G,busy:!0};return H.set(V,J),{socket:G,entry:J,reused:!1,release:({keep:Y}={})=>{if(!Y||!S(J.socket)){if(q(J.socket),J.idleTimer)clearTimeout(J.idleTimer);if(H.get(V)===J)H.delete(V);return}J.busy=!1,r(V,J)}}}function LN(N){if(N&&typeof N==="object"){let Q="message"in N?N.message:void 0;if(typeof Q==="string"&&Q.length>0)return Error(Q);let V="error"in N?N.error:void 0;if(V instanceof Error&&V.message.length>0)return V;if(V&&typeof V==="object"&&"message"in V){let $=V.message;if(typeof $==="string"&&$.length>0)return Error($)}}return Error("WebSocket error")}function KN(N){if(N&&typeof N==="object"){let Q="code"in N?N.code:void 0,V="reason"in N?N.reason:void 0,$="wasClean"in N?N.wasClean:void 0,X=typeof Q==="number"?` ${Q}`:"",Z=typeof V==="string"&&V.length>0?` ${V}`:"";if(!Z&&Q===qN)Z=" message too big";return new zN(`WebSocket closed${X}${Z}`.trim(),{code:typeof Q==="number"?Q:void 0,reason:typeof V==="string"&&V.length>0?V:void 0,wasClean:typeof $==="boolean"?$:void 0})}return Error("WebSocket closed")}async function dN(N){if(typeof N==="string")return N;if(N instanceof ArrayBuffer)return new TextDecoder().decode(new Uint8Array(N));if(ArrayBuffer.isView(N)){let Q=N;return new TextDecoder().decode(new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength))}if(N&&typeof N==="object"&&"arrayBuffer"in N){let V=await N.arrayBuffer();return new TextDecoder().decode(new Uint8Array(V))}return null}async function*aN(N,Q,V){let $=[],X=null,Z=!1,G=null,J=!1,Y=()=>{if(!X)return;let L=X;X=null,L()},P=(L)=>{(async()=>{let W=null;try{if(!L||typeof L!=="object"||!("data"in L))return;if(W=await dN(L.data),!W)return;let D=JSON.parse(W),j=typeof D.type==="string"?D.type:"";if(j==="response.completed"||j==="response.done"||j==="response.incomplete")J=!0,Z=!0;$.push(D),Y()}catch(D){G=new I(`Invalid Codex WebSocket JSON: ${h(D)}`,{cause:D,payload:W}),Z=!0,Y()}})()},O=(L)=>{G=LN(L),Z=!0,Y()},z=(L)=>{if(J){Z=!0,Y();return}if(!G)G=KN(L);Z=!0,Y()},B=()=>{G=Error("Request was aborted"),Z=!0,Y()};N.addEventListener("message",P),N.addEventListener("error",O),N.addEventListener("close",z),Q?.addEventListener("abort",B);try{while(!0){if(Q?.aborted)throw Error("Request was aborted");if($.length>0){yield $.shift();continue}if(Z)break;let L;await new Promise((W,D)=>{if(X=W,V!==void 0&&V>0)L=setTimeout(()=>{let j=Error(`WebSocket idle timeout after ${V}ms`);G=j,Z=!0,X=null,q(N,1000,"idle_timeout"),D(j)},V)}).finally(()=>{if(L)clearTimeout(L)})}if(G)throw G;if(!J)throw Error("WebSocket stream closed before response.completed")}finally{N.removeEventListener("message",P),N.removeEventListener("error",O),N.removeEventListener("close",z),Q?.removeEventListener("abort",B)}}function n(N){let{input:Q,previous_response_id:V,...$}=N;return $}function iN(N,Q){return JSON.stringify(N??[])===JSON.stringify(Q??[])}function rN(N,Q){return JSON.stringify(n(N))===JSON.stringify(n(Q))}function nN(N,Q){if(!rN(N,Q.lastRequestBody))return;let V=N.input??[],$=[...Q.lastRequestBody.input??[],...Q.lastResponseItems];if(V.length<$.length)return;let X=V.slice(0,$.length);if(!iN(X,$))return;return V.slice($.length)}function tN(N,Q){let V=N.continuation;if(!V)return Q;let $=nN(Q,V);if(!$||!V.lastResponseId)return N.continuation=void 0,Q;return{...Q,previous_response_id:V.lastResponseId,input:$}}async function*oN(N,Q,V,$){let X=!1;for await(let Z of N){if(!X)X=!0,$(),V.push({type:"start",partial:Q});yield Z}}async function sN(N,Q,V,$,X,Z,G,J,Y,P){let{socket:O,entry:z,reused:B,release:L}=await lN(N,V,P?.sessionId,P?.signal,Y),W=!0,D=P?.transport==="websocket-cached"||P?.transport==="auto",j=Q,F=D&&z?tN(z,j):j,K=P?.sessionId?y(P.sessionId):void 0;if(K){if(K.requests++,B)K.connectionsReused++;else K.connectionsCreated++;if(D)K.cachedContextRequests++;if(F.store===!0)K.storeTrueRequests++;if(K.lastInputItems=F.input?.length??0,F.previous_response_id)K.deltaRequests++,K.lastDeltaInputItems=F.input?.length??0,K.lastPreviousResponseId=F.previous_response_id;else K.fullContextRequests++,K.lastDeltaInputItems=void 0,K.lastPreviousResponseId=void 0}try{if(O.send(JSON.stringify({type:"response.create",...F})),await v(oN(JN(aN(O,P?.signal,J)),$,X,G),$,X,Z,{serviceTier:P?.serviceTier,resolveServiceTier:YN,applyServiceTierPricing:(R,U)=>GN(R,U,Z)}),P?.signal?.aborted)W=!1;else if(D&&z&&$.responseId){let R=g(Z,{messages:[$]},XN,{includeSystemPrompt:!1}).filter((U)=>U.type!=="function_call_output");z.continuation={lastRequestBody:j,lastResponseId:$.responseId,lastResponseItems:R}}}catch(R){if(z)z.continuation=void 0;throw W=!1,R}finally{L({keep:W})}}async function eN(N){let Q=await N.text(),V=Q||N.statusText||"Request failed",$;try{let Z=JSON.parse(Q)?.error;if(Z){let G=Z.code||Z.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(G)||N.status===429){let J=Z.plan_type?` (${Z.plan_type.toLowerCase()} plan)`:"",Y=Z.resets_at?Math.max(0,Math.round((Z.resets_at*1000-Date.now())/60000)):void 0,P=Y!==void 0?` Try again in ~${Y} min.`:"";$=`You have hit your ChatGPT usage limit${J}.${P}`.trim()}V=Z.message||$||V}}catch{}return{message:V,friendlyMessage:$}}function NQ(N){try{let Q=N.split(".");if(Q.length!==3)throw Error("Invalid token");let $=JSON.parse(atob(Q[1]))?.[BN]?.chatgpt_account_id;if(!$)throw Error("No account ID in token");return $}catch{throw Error("Failed to extract accountId from token")}}function QQ(){if(typeof globalThis.crypto?.randomUUID==="function")return globalThis.crypto.randomUUID();return`codex_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function ON(N,Q,V,$){let X=new Headers(N);for(let[G,J]of Object.entries(Q||{}))X.set(G,J);X.set("Authorization",`Bearer ${$}`),X.set("chatgpt-account-id",V),X.set("originator","pi");let Z=C?`pi (${C.platform()} ${C.release()}; ${C.arch()})`:"pi (browser)";return X.set("User-Agent",Z),X}function VQ(N,Q,V,$,X){let Z=ON(N,Q,V,$);if(Z.set("OpenAI-Beta","responses=experimental"),Z.set("accept","text/event-stream"),Z.set("content-type","application/json"),X)Z.set("session-id",X),Z.set("x-client-request-id",X);return Z}function ZQ(N,Q,V,$,X){let Z=ON(N,Q,V,$);return Z.delete("accept"),Z.delete("content-type"),Z.delete("OpenAI-Beta"),Z.delete("openai-beta"),Z.set("OpenAI-Beta",vN),Z.set("x-client-request-id",X),Z.set("session-id",X),Z}export{OQ as streamSimpleOpenAICodexResponses,SN as streamOpenAICodexResponses,jQ as resetOpenAICodexWebSocketDebugStats,DQ as getOpenAICodexWebSocketDebugStats,mN as closeOpenAICodexWebSocketSessions};
@@ -1,3 +0,0 @@
1
- // @bun
2
- var f=new Set;function h(b){return f.add(b),()=>{f.delete(b)}}
3
- export{h as me};