@shumai-one/shumai 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{chunk-qysf4mpk.js → chunk-07jszkhj.js} +61 -61
- package/bin/chunk-0c67210c.js +1 -0
- package/bin/{chunk-7t1r3sj3.js → chunk-0wvhahzh.js} +2 -2
- package/bin/chunk-161rxeq2.js +2 -0
- package/bin/{chunk-ncqhp76x.js → chunk-1bgsphyz.js} +2 -2
- package/bin/{chunk-nzggcbgk.js → chunk-1dqsf5qj.js} +6 -6
- package/bin/{chunk-psk38vp4.js → chunk-1jybg56e.js} +1 -1
- package/bin/chunk-1kt5dzjv.js +2 -0
- package/bin/{chunk-m5z5mzan.js → chunk-1t51fp6n.js} +1 -1
- package/bin/{chunk-w3jmahea.js → chunk-2jrjwaqr.js} +2 -2
- package/bin/chunk-2qjfpmcf.js +2 -0
- package/bin/{chunk-k2aqztk1.js → chunk-2vzzd0q6.js} +1 -1
- package/bin/chunk-2yr5k567.js +2 -0
- package/bin/chunk-2z1pnt7h.js +2 -0
- package/bin/{chunk-wnpjz2kw.js → chunk-3d5rm1d1.js} +1 -1
- package/bin/{chunk-gdg0tkbk.js → chunk-3d9tfxp4.js} +1 -1
- package/bin/{chunk-42ygnm34.js → chunk-3dgahs95.js} +1 -1
- package/bin/{chunk-3mfdp2nh.js → chunk-3j5njrpr.js} +2 -2
- package/bin/{chunk-h4s1fgf1.js → chunk-3n4224c0.js} +1 -1
- package/bin/{chunk-wmkbkad1.js → chunk-3tg39jx7.js} +3 -3
- package/bin/chunk-3vmapyk9.js +1 -0
- package/bin/{chunk-c5dr9m1d.js → chunk-47tn3vtg.js} +1 -1
- package/bin/{chunk-c51tvhra.js → chunk-4syt6rn0.js} +3 -3
- package/bin/chunk-5kvc1gp2.js +1 -0
- package/bin/{chunk-7v7mypc6.js → chunk-5vvvgjvz.js} +2 -2
- package/bin/{chunk-1b7gg0nx.js → chunk-6vxzkrsj.js} +11 -11
- package/bin/{chunk-cwfjvynz.js → chunk-6y4xkcte.js} +2 -2
- package/bin/{chunk-3x3sf7rp.js → chunk-7e5z637e.js} +2 -2
- package/bin/chunk-7nvk7waw.js +1 -0
- package/bin/{chunk-rq0n0vcc.js → chunk-80qz30dc.js} +2 -2
- package/bin/chunk-886pnknh.js +3 -0
- package/bin/{chunk-zg7a107s.js → chunk-8cn7fx40.js} +1 -1
- package/bin/chunk-908pypkr.js +1 -0
- package/bin/chunk-952qwf17.js +2 -0
- package/bin/chunk-988casfy.js +1 -0
- package/bin/chunk-9a2tf0mh.js +2 -0
- package/bin/{chunk-73evafrq.js → chunk-9d0thqcy.js} +1 -1
- package/bin/{chunk-ss0mcgbd.js → chunk-9nvymwqj.js} +2 -2
- package/bin/{chunk-s0caa0zm.js → chunk-9trnkbtr.js} +4 -4
- package/bin/{chunk-xcwjsav0.js → chunk-a4056d0r.js} +1 -1
- package/bin/{chunk-qg1f1z3t.js → chunk-a796sgcw.js} +4 -4
- package/bin/{chunk-zrxe6p0q.js → chunk-afnzb9ne.js} +2 -2
- package/bin/chunk-apfrw0wd.js +3 -0
- package/bin/{chunk-kfpfqxb3.js → chunk-axmd242s.js} +1 -1
- package/bin/{chunk-v0201sn5.js → chunk-b3aqmcps.js} +2 -2
- package/bin/chunk-b6q287d1.js +2 -0
- package/bin/{chunk-1hnpvtvf.js → chunk-b9hyc0a1.js} +2 -2
- package/bin/chunk-ba33nf0q.js +4 -0
- package/bin/chunk-batadmvr.js +2 -0
- package/bin/{chunk-2y6teq4s.js → chunk-brwbhbmc.js} +7 -7
- package/bin/chunk-bvdvp192.js +1 -0
- package/bin/{chunk-1yv06e0q.js → chunk-crja7whq.js} +2 -2
- package/bin/{chunk-4k2bej3c.js → chunk-d7fwggt6.js} +2 -2
- package/bin/chunk-db1msmdh.js +2 -0
- package/bin/{chunk-ncp007yb.js → chunk-dbw8c1jj.js} +5 -5
- package/bin/{chunk-b5a77dzv.js → chunk-dj5a6kkh.js} +1 -1
- package/bin/chunk-dkx3pmdz.js +1 -0
- package/bin/{chunk-20ee2pqp.js → chunk-dmvvt8va.js} +2 -2
- package/bin/{chunk-f3pb9mh9.js → chunk-dpc11hpd.js} +9 -9
- package/bin/{chunk-y8a3hans.js → chunk-dscq4a4k.js} +2 -2
- package/bin/{chunk-cbpgrg5j.js → chunk-dz076sh7.js} +1 -1
- package/bin/chunk-edqd8evk.js +2 -0
- package/bin/{chunk-a3j3hyx2.js → chunk-ehpfg3km.js} +2 -2
- package/bin/{chunk-j3kjscfj.js → chunk-ey3h4sct.js} +2 -2
- package/bin/{chunk-z422yh6b.js → chunk-ga3pahzf.js} +1 -1
- package/bin/chunk-gc6m7agb.js +3 -0
- package/bin/{chunk-y78v01te.js → chunk-gcjsw9yp.js} +1 -1
- package/bin/chunk-gqr5hxhj.js +2 -0
- package/bin/{chunk-0z8tgn67.js → chunk-gsfcpcye.js} +1 -1
- package/bin/chunk-h9mka9br.js +2 -0
- package/bin/chunk-hacyjx1s.js +1 -0
- package/bin/chunk-hd6dnnyg.js +2 -0
- package/bin/chunk-he5nvmqw.js +1 -0
- package/bin/{chunk-af1mcn9p.js → chunk-hnhdq2wd.js} +1 -1
- package/bin/{chunk-xgy6ppww.js → chunk-hs2r9qaw.js} +2 -2
- package/bin/{chunk-23bg4h8n.js → chunk-hxyg5q2a.js} +2 -2
- package/bin/chunk-hyr1vtfp.js +1 -0
- package/bin/{chunk-jbt3e1ac.js → chunk-j9ks8bd7.js} +2 -2
- package/bin/{chunk-w9160hxz.js → chunk-jg2v25d2.js} +3 -3
- package/bin/chunk-jh8q3885.js +211 -0
- package/bin/chunk-jzbrt2vk.js +1 -0
- package/bin/{chunk-v2xt5p3x.js → chunk-k6avge95.js} +4 -4
- package/bin/{chunk-zp1sv030.js → chunk-kg8eg9z3.js} +2 -2
- package/bin/chunk-kk42xhgz.js +1 -0
- package/bin/{chunk-qqqarj5v.js → chunk-kmbjp5kp.js} +2 -2
- package/bin/{chunk-zcfehv0w.js → chunk-md5pcq46.js} +8 -8
- package/bin/{chunk-3x80f4jk.js → chunk-mtb9fpj2.js} +1 -1
- package/bin/chunk-n3xjwszr.js +2 -0
- package/bin/chunk-nqym3zbs.js +1 -0
- package/bin/{chunk-pdrmbxrt.js → chunk-p75f5pgq.js} +2 -2
- package/bin/{chunk-21e4gjvw.js → chunk-pdh9bnyj.js} +2 -2
- package/bin/{chunk-7sc73pfr.js → chunk-pgj2kjnn.js} +2 -2
- package/bin/{chunk-dqxh6dwz.js → chunk-pvg3msgw.js} +8 -8
- package/bin/{chunk-gjp851vj.js → chunk-pwkby9h7.js} +6 -6
- package/bin/{chunk-njswnpaq.js → chunk-qbqym9m6.js} +2 -2
- package/bin/{chunk-18qzk2mm.js → chunk-qgkbxw1k.js} +2 -2
- package/bin/{chunk-p4yrnr37.js → chunk-qs7855cz.js} +2 -2
- package/bin/{chunk-7jtmwt5a.js → chunk-radcwage.js} +2 -2
- package/bin/{chunk-azafjrm4.js → chunk-rmzcarv9.js} +2 -2
- package/bin/{chunk-erharpzt.js → chunk-rp4pc6kz.js} +1 -1
- package/bin/{chunk-dchtr0ap.js → chunk-rsd164d9.js} +2 -2
- package/bin/{chunk-g6xgghnq.js → chunk-s05cdax2.js} +1 -1
- package/bin/{chunk-tgee88jq.js → chunk-sab7tjxw.js} +5 -5
- package/bin/chunk-sebbjvgv.css +1 -0
- package/bin/{chunk-1n1h09e9.js → chunk-t350k3s1.js} +1 -1
- package/bin/{chunk-y13s3641.js → chunk-t7bvde99.js} +3 -3
- package/bin/chunk-t8gv2ekj.js +14 -0
- package/bin/chunk-teqprbd8.js +2 -0
- package/bin/chunk-tgr86ac4.js +2 -0
- package/bin/{chunk-48rbc18e.js → chunk-v8v8vdf7.js} +9 -9
- package/bin/chunk-vm5tn0zm.js +2 -0
- package/bin/chunk-vzj2j11x.js +2 -0
- package/bin/chunk-w1wxzqqb.js +2 -0
- package/bin/chunk-wmjp8dcm.js +1 -0
- package/bin/chunk-wy8dkyxj.js +1 -0
- package/bin/{chunk-3c0tcbga.js → chunk-y1b3ck7m.js} +1 -1
- package/bin/{chunk-nkmr6gqc.js → chunk-y20sbaz5.js} +2 -2
- package/bin/{chunk-5trfc3xh.js → chunk-y56yvezn.js} +1 -1
- package/bin/{chunk-ty71fdw9.js → chunk-yfr0hzb7.js} +2 -2
- package/bin/chunk-ysv80zyb.js +5 -0
- package/bin/chunk-z08bqvkc.js +42 -0
- package/bin/{chunk-brxwrh0b.js → chunk-z6jpt0h6.js} +4 -4
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +404 -383
- package/package.json +7 -7
- package/prisma/migrations/20260914024424_add_asset_comment_reactions/migration.sql +22 -0
- package/prisma/migrations/20260914064432_limit_reaction_code_length/migration.sql +8 -0
- package/prisma/migrations/20260914092940_add_jpeg_preview_flags/migration.sql +5 -0
- package/prisma/schema.prisma +21 -0
- package/bin/chunk-20yset6k.js +0 -1
- package/bin/chunk-2swjkvxv.js +0 -211
- package/bin/chunk-3115qtvj.js +0 -2
- package/bin/chunk-3rwx54z7.js +0 -2
- package/bin/chunk-5xcjnbm9.js +0 -1
- package/bin/chunk-685gzbdg.js +0 -14
- package/bin/chunk-6kzm51c7.js +0 -2
- package/bin/chunk-813885jm.js +0 -1
- package/bin/chunk-8yg9zy53.js +0 -2
- package/bin/chunk-923agf2d.js +0 -1
- package/bin/chunk-942ksfnj.js +0 -2
- package/bin/chunk-99yzvkq5.js +0 -2
- package/bin/chunk-9by727gr.js +0 -2
- package/bin/chunk-9sr1z8kv.js +0 -42
- package/bin/chunk-a0fggks8.js +0 -2
- package/bin/chunk-a8x0dmec.js +0 -2
- package/bin/chunk-b80fgsdf.js +0 -1
- package/bin/chunk-bg6kp843.js +0 -1
- package/bin/chunk-da2w7c80.js +0 -2
- package/bin/chunk-e1s1zgv0.js +0 -2
- package/bin/chunk-fp8x63vs.js +0 -2
- package/bin/chunk-ft11rrhz.js +0 -1
- package/bin/chunk-fyszcddw.js +0 -2
- package/bin/chunk-g6hq18q1.js +0 -1
- package/bin/chunk-gy68h3x5.js +0 -2
- package/bin/chunk-hsv4v7na.js +0 -1
- package/bin/chunk-jrf90z42.js +0 -3
- package/bin/chunk-kyxramkk.js +0 -1
- package/bin/chunk-n48548fs.js +0 -4
- package/bin/chunk-ncnr223m.js +0 -2
- package/bin/chunk-nngp6fhe.js +0 -1
- package/bin/chunk-p1nb8wk8.js +0 -3
- package/bin/chunk-pc2dnpkh.js +0 -2
- package/bin/chunk-pmj9b8qt.js +0 -3
- package/bin/chunk-pve3zpta.js +0 -2
- package/bin/chunk-q3q0brsn.js +0 -2
- package/bin/chunk-qk7me5ra.js +0 -2
- package/bin/chunk-r0j962y1.js +0 -1
- package/bin/chunk-r5dxd4sx.js +0 -1
- package/bin/chunk-sa6k5ye7.js +0 -1
- package/bin/chunk-sz6cnm4q.css +0 -1
- package/bin/chunk-w88h5wtf.js +0 -1
- package/bin/chunk-wrbas9cg.js +0 -1
- package/bin/chunk-z5t4yxzb.js +0 -2
- package/bin/chunk-zwenq5zy.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,Ue}from"./chunk-jh8q3885.js";import"./chunk-t8gv2ekj.js";import"./chunk-07jszkhj.js";import"./chunk-w1wxzqqb.js";import"./chunk-ey3h4sct.js";import"./chunk-vzj2j11x.js";import"./chunk-h9mka9br.js";import"./chunk-3tg39jx7.js";import"./chunk-ysv80zyb.js";import"./chunk-k6avge95.js";import"./chunk-161rxeq2.js";import"./chunk-ehpfg3km.js";import{ba}from"./chunk-1kt5dzjv.js";import"./chunk-d7fwggt6.js";import"./chunk-tgr86ac4.js";import"./chunk-2jrjwaqr.js";import"./chunk-rmzcarv9.js";import"./chunk-yfr0hzb7.js";import"./chunk-6y4xkcte.js";import"./chunk-3d5rm1d1.js";function p(){let{shareId:a,fileId:s}=e.useParams(),{start:n,version:o,compare:r,cmpLeft:i,cmpRight:l,cmpActive:c}=e.useSearch();return t(ba,{shareId:a,initialFileId:s,startTime:n,versionId:o,compare:r,compareLeftId:i,compareRightId:l,compareActiveSide:c})}var e=Ue("/share/$shareId/files/$fileId")({component:p});export{e as Route};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{I}from"./chunk-jh8q3885.js";var a=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Pl=I("external-link",a);
|
|
2
|
+
export{Pl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{P,h,D,b,u,S,Z,t,o,K,L,B,ft,A,I,wr,F,Do,ke,ve,rn,bt,vt,Xt,we,Re,C,E,he,Ja,ge,Ae,W,Vr,Vt,ds,fs,ps,Af,Ne,id,it,Fc,Lc,pr,ud,pb,kb,Ri,zf,Qf,$h,Gh,xl,ag,ip,Oo,Fo,Pd,Je,Xe,et,tt,rt,nt,ot,st,ue,ie,me,Ge,le,H,ce,Pt,Nt,k,xo,So,Qr,kn,be,Ur,Vd}from"./chunk-jh8q3885.js";import{Sa,Ea,Or,iu,lu,Xo,es,_s,bs}from"./chunk-07jszkhj.js";import{Ui,su}from"./chunk-ysv80zyb.js";import{js}from"./chunk-k6avge95.js";var ct=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ze=I("pencil",ct);S();S();function Qe({teamId:d,projectId:s,file:r,onSaveField:l,members:z,onCommentSelect:f,hideAnnotationControl:V=!1,readOnly:w=!1,publicFields:y,isPublic:m=!1,shareId:N,currentTime:q,onTyping:te,selectedCommentId:p,heightPercent:j,onHeightPercentChange:Q}){let{canEdit:O}=Pt(s),{fields:c,setFields:J}=Or(),se=K(),{ref:re,inView:fe}=Nt(),[a,M]=u(null),[U,ne]=u(!1),[Te,ze]=u(null),G=b(!1),Ve=b(0),Y=b(j),je=(e)=>{G.current=!0,Ve.current=e.clientY,Y.current=j,e.target.setPointerCapture?.(e.pointerId)},Me=P((e)=>{if(!G.current)return;let v=(Ve.current-e.clientY)/window.innerHeight*100,oe=Math.min(85,Math.max(10,Y.current+v));Q(oe)},[Q]),De=(e)=>{G.current=!1;try{e.target.releasePointerCapture?.(e.pointerId)}catch{}},{data:ee}=L({queryKey:["fields",s],queryFn:async()=>{let e=await A.api.projects[":projectId"].fields.$get({param:{projectId:s}});if(!e.ok)throw Error("Failed to fetch fields");return await e.json()},enabled:!!s&&!y}),T=Xo(r);h(()=>{if(y)J(y,s);else if(ee)J(ee,s)},[ee,y,s,J]);let{data:xe,fetchNextPage:X,hasNextPage:Ie}=ft({queryKey:m?["shares",N,"files",r?.id,"comments"]:["files",r?.id,"comments"],queryFn:async({pageParam:e})=>{if(m){let i=localStorage.getItem(`share_pwd_${N}`)||"",v=await A.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:N,fileId:r.id},query:{after:e}},{headers:{"x-share-password":i}});if(!v.ok)throw Error("Failed to fetch comments");return await v.json()}else{let i=await A.api.files[":fileId"].comments.$get({param:{fileId:r.id},query:{after:e}});if(!i.ok)throw Error("Failed to fetch comments");return await i.json()}},enabled:!!r?.id&&(!m||!!N),initialPageParam:"",refetchInterval:2000,getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),{mutate:Pe}=B({mutationFn:async({text:e,attachmentIds:i,annotations:v,replyToId:oe,guestUserId:ye,second:Ce})=>{if(m){let de=localStorage.getItem(`share_pwd_${N}`)||"",Be=await A.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:N,fileId:r.id},json:{message:e,attachmentIds:i,replyToId:oe??void 0,annotations:v,second:Ce??void 0}},{headers:{"x-share-password":de,...ye?{"x-guest-user-id":ye}:{}}});if(!Be.ok)throw Error("Failed to create comment");return await Be.json()}else{let de=await A.api.files[":fileId"].comments.$post({param:{fileId:r.id},json:{message:e,attachmentIds:i,replyToId:oe??void 0,annotations:v,second:Ce??void 0}});if(!de.ok)throw Error("Failed to create comment");return await de.json()}},onSuccess:()=>{se.invalidateQueries({queryKey:m?["shares",N,"files",r?.id,"comments"]:["files",r?.id,"comments"]})},onError:()=>{k.error(kb?.()||"Failed to post comment")}}),Se=xe?.pages?.[0]?.pageInfo?.total??xe?.pages.reduce((e,i)=>e+(i.data?.length||0),0)??0;h(()=>{if(fe&&Ie)X()},[fe,X,Ie]);let _=D(()=>(r?.fieldValues||[]).reduce((e,i)=>(e[i.fieldId]=i,e),{}),[r?.fieldValues]),ae=D(()=>[...c].sort((e,i)=>{let v=e.config?.name?.toLowerCase()||"",oe=i.config?.name?.toLowerCase()||"";if(v<oe)return-1;if(v>oe)return 1;return 0}),[c]),Ee=xe?.pages.flatMap((e)=>e.data??[])??[],_e=(e,i,v=[],oe,ye)=>{if(!e.trim()&&i.length===0&&v.length===0)return;let Ce=oe||a?.id||null;if(m){let de=localStorage.getItem(`guest_user_id_${N}`);if(!de)ze({text:e,attachmentIds:i,annotations:v,replyToId:Ce,second:ye}),ne(!0);else Pe({text:e,attachmentIds:i,annotations:v,replyToId:Ce,guestUserId:de,second:ye})}else Pe({text:e,attachmentIds:i,annotations:v,replyToId:Ce,second:ye});M(null)},Oe=(e)=>{if(Te)Pe({...Te,guestUserId:e}),ze(null),M(null)},Fe=(e)=>{let i=z.find((v)=>v.id===e);if(i)return i;return{id:"unknown",name:"Unknown",role:"unknown"}},Le=j<=15;return o("div",{style:{height:`${j}dvh`},className:"shrink-0 flex flex-col bg-background border-t border-border shadow-2xl rounded-t-2xl overflow-hidden select-none z-20","data-testid":"mobile-bottom-sheet",children:[t("div",{onPointerDown:je,onPointerMove:Me,onPointerUp:De,onPointerCancel:De,className:"w-full pt-2 pb-1.5 flex flex-col items-center justify-center cursor-grab active:cursor-grabbing touch-none shrink-0","aria-label":"Drag to resize bottom sheet",children:t("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30 hover:bg-muted-foreground/50 transition-colors"})}),o(xo,{defaultValue:"comments",className:"flex-1 flex flex-col min-h-0 px-2 pb-1 overflow-hidden",children:[o(So,{className:"w-full shrink-0 h-9 bg-muted/60 p-1",children:[o(Qr,{value:"comments",className:"flex-1 text-xs font-semibold py-1",children:[id()," ",Se>0&&`(${Se})`]}),t(Qr,{value:"fields",className:"flex-1 text-xs font-semibold py-1",children:Ri()})]}),o(kn,{value:"comments",className:C("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",Le&&"hidden"),children:[t("div",{className:"flex items-center justify-between px-2 pb-1.5 shrink-0 border-b border-border/50",children:o("span",{className:"text-xs font-bold text-foreground",children:[Af?.()||"All comments",Se>0?` (${Se})`:""]})}),t(ce,{className:"flex-1 min-h-0 px-2 py-2 [&>div>div]:block!",children:Ee.length===0?t("div",{className:"py-8 text-center text-xs text-muted-foreground",children:Gh()}):o("div",{className:"space-y-3",children:[Ee.map((e)=>o("div",{children:[t(Ui,{teamId:d,message:e,getUser:Fe,onReply:M,hasReplies:!!e.replies?.length,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,isSelected:p===e.id,onSelect:()=>{f?.(e)},readOnly:w,isPublic:m}),e.replies?.map((i,v)=>t("div",{children:t(Ui,{teamId:d,isReply:!0,message:i,getUser:Fe,onReply:M,hasReplies:!1,isLastReply:v===(e.replies?.length??0)-1,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,isSelected:p===i.id,onSelect:()=>{f?.(i)},readOnly:w,isPublic:m})},i.id))]},e.id)),t("div",{ref:re})]})}),(!w||m)&&t("div",{className:"mt-auto shrink-0 bg-background border-t border-border pt-1",children:t(su,{isOpen:U,onClose:()=>ne(!1),onSuccess:Oe,children:t(js,{projectId:s,onSendMessage:_e,replyingTo:a,onCancelReply:()=>M(null),hideAnnotationControl:V,disableMentions:m,currentTime:T?.commentsConfig?.hasTimestamp?q:void 0,formatTimestamp:T?.commentsConfig?.formatTimestamp,frameRate:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:T?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,onTyping:te})})})]}),t(kn,{value:"fields",className:C("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",Le&&"hidden"),children:t(ce,{className:"flex-1 px-3 py-2 min-h-0 [&>div>div]:block!",children:ae&&ae.length>0?t("div",{className:"space-y-4 pb-6",children:ae.map((e)=>o("div",{className:"space-y-1.5",children:[t("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:e.config?.name}),t("div",{className:"min-h-[32px]",children:t(bs,{fieldId:e.id,config:e.config,value:_[e.id]?.value,onSave:O?(i)=>l(e.id,i):void 0,readOnly:w||e.readOnly||!O})})]},e.id))}):t("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"No custom fields defined"})})})]})]})}function Ye({fileName:d,folderName:s,version:r,versions:l,activeFileId:z,isPublic:f=!1,shareId:V,allowDownload:w=!0,downloadInfo:y,canEdit:m=!1,onBack:N,onPrevFile:q,onNextFile:te,hasPrevFile:p=!1,hasNextFile:j=!1,onSelectVersion:Q,onRename:O,onDelete:c,onLinkedTasks:J,linkedTaskCount:se=0}){let re=async(a)=>{try{let M=f&&V?await A.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:V,fileId:z},json:{key:a}}):await A.api.files["download-url"].$post({json:{key:a,assetId:z}});if(!M.ok)return;let{url:U}=await M.json(),ne=document.createElement("a");ne.href=U,ne.download="",document.body.appendChild(ne),ne.click(),document.body.removeChild(ne)}catch{}},fe=(y?.videoTranscodes?.length??0)>0;return o("header",{className:"flex h-12 w-full items-center justify-between border-b border-border bg-card px-2 py-1.5 shrink-0 select-none z-30",children:[t("div",{className:"flex items-center",children:t(E,{variant:"ghost",size:"icon",onClick:N,className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":ip(),children:t(rn,{className:"h-5 w-5"})})}),o("div",{className:"flex flex-1 items-center justify-center gap-1 min-w-0 px-1",children:[o("div",{className:"flex items-center min-w-0 max-w-[65vw]",children:[s&&o(Z,{children:[t("span",{className:"truncate text-xs font-medium text-muted-foreground max-w-[80px]",children:s}),t("span",{className:"text-muted-foreground mx-1 text-xs",children:"/"})]}),l&&l.length>1?o(he,{modal:!1,children:[t(ge,{asChild:!0,children:o("button",{className:"flex items-center gap-1 min-w-0 truncate text-xs font-medium text-foreground hover:bg-accent rounded px-1 py-0.5 transition-colors cursor-pointer",children:[t("span",{className:"truncate max-w-[120px] font-semibold",children:d}),r!==void 0&&o(be,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",r]}),t(ve,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]})}),o(Ae,{align:"center",className:"w-48 z-40",children:[t(Vr,{className:"text-xs",children:Pd()}),l.map((a)=>o(W,{onClick:()=>Q?.(a.id),className:C("flex items-center justify-between text-xs cursor-pointer",a.id===z?"bg-accent font-semibold text-accent-foreground":""),children:[o("span",{children:["v",a.version]}),t("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px]",children:a.name||d})]},a.id))]})]}):o("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t("span",{className:"truncate text-xs font-semibold text-foreground max-w-[140px]",children:d}),r!==void 0&&o(be,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",r]})]})]}),(p||j)&&o("div",{className:"flex items-center gap-0.5 shrink-0 bg-muted/60 rounded p-0.5 ml-1",children:[t(E,{variant:"ghost",size:"icon",disabled:!p,onClick:q,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:ag(),"aria-label":ag(),children:t(rn,{className:"h-3.5 w-3.5"})}),t(E,{variant:"ghost",size:"icon",disabled:!j,onClick:te,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:$h(),"aria-label":$h(),children:t(bt,{className:"h-3.5 w-3.5"})})]})]}),t("div",{className:"flex items-center gap-1",children:o(he,{modal:!1,children:[t(ge,{asChild:!0,children:t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":Qf(),children:t(wr,{className:"h-4 w-4"})})}),o(Ae,{align:"end",className:"w-52 z-40",children:[w&&(fe?o(ds,{children:[o(fs,{className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(vt,{className:"h-3.5 w-3.5"}),t("span",{children:pr()})]}),t(Ja,{children:o(ps,{className:"w-48 z-50",children:[t(Vr,{className:"text-xs",children:pr()}),y?.videoTranscodes?.map((a)=>{let M=Math.max(a.width,a.height),U=`${a.height}p`;if(M>=3840)U="2160p";else if(M>=1920)U="1080p";else if(M>=1280)U="720p";else if(M>=960)U="540p";else if(M>=640)U="360p";else if(M>=320)U="180p";return o(W,{onClick:()=>re(a.key),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{children:U}),t("span",{className:"text-[10px] text-muted-foreground",children:"MP4"})]},U)}),y?.originalKey&&o(Z,{children:[t(Vt,{}),o(W,{onClick:()=>re(y.originalKey),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{children:xl?.()||"Original"}),t("span",{className:"text-[10px] text-muted-foreground",children:d.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})})]}):o(W,{onClick:()=>y?.originalKey&&re(y.originalKey),disabled:!y?.originalKey,className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(vt,{className:"h-3.5 w-3.5"}),t("span",{children:pr()})]})),l&&l.length>1&&Q&&o(ds,{children:[t(fs,{className:"flex items-center gap-2 text-xs cursor-pointer",children:t("span",{children:Pd?.()||"Switch version"})}),t(Ja,{children:o(ps,{className:"w-48 z-50",children:[t(Vr,{className:"text-xs",children:Pd?.()||"Switch version"}),l.map((a)=>o(W,{onClick:()=>Q(a.id),className:C("flex items-center justify-between text-xs cursor-pointer",a.id===z?"bg-accent font-semibold text-accent-foreground":""),children:[o("span",{children:["v",a.version]}),t("span",{className:"text-[10px] text-muted-foreground truncate max-w-[120px]",children:a.name||d})]},a.id))]})})]}),J&&o(W,{onClick:J,className:"flex items-center justify-between text-xs cursor-pointer",children:[o("span",{className:"flex items-center gap-2",children:[t(Do,{className:"h-3.5 w-3.5"}),t("span",{children:zf?.()||"Linked Tasks"})]}),se>0&&t("span",{className:"inline-flex items-center justify-center px-1.5 py-0.2 text-[10px] font-semibold rounded-full bg-muted-foreground/15 text-foreground",children:se})]}),m&&O&&o(W,{onClick:O,className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(Ze,{className:"h-3.5 w-3.5"}),t("span",{children:Oo()})]}),m&&c&&o(Z,{children:[t(Vt,{}),o(W,{onClick:c,className:"flex items-center gap-2 text-xs text-destructive focus:text-destructive cursor-pointer",children:[t(we,{className:"h-3.5 w-3.5"}),t("span",{children:it()})]})]})]})]})})]})}function Fl({projectId:d,teamId:s="",fileId:r,file:l,projectInfo:z,ancestorFolders:f=[],versions:V,activeFileId:w,startTime:y,isPublic:m=!1,shareId:N,allowDownload:q=!0,publicFields:te,siblingFiles:p=[],onNavigateToFile:j,onNavigateBack:Q,onRenameFile:O,onDeleteFile:c,onSaveField:J,onSelectVersion:se}){let{canEdit:re}=Pt(d),{members:fe}=Ur(),a=b(null),[M,U]=u(50),[ne,Te]=u([]),[ze,G]=u(0),[Ve,Y]=u(null),[je,Me]=u(!1),[De,ee]=u(""),T=b(null),[xe,X]=u(!1),[Ie,Pe]=u(!1),[Se,_]=u(!1),[ae,Ee]=u(!1),{data:_e}=L({queryKey:["teams",s,"kanban","assets",w,"tasks"],queryFn:async()=>{if(!s||!w||m)return{data:[],total:0};let x=await A.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:s,assetId:w}});if(!x.ok)return{data:[],total:0};return await x.json()},enabled:!!s&&!!w&&!m}),Oe=_e?.total??_e?.data?.length??0,{prevFile:Fe,nextFile:Le}=D(()=>{if(!p||p.length===0)return{prevFile:null,nextFile:null};let x=p.findIndex((pe)=>pe.id===r||pe.id===w);if(x===-1)return{prevFile:null,nextFile:null};return{prevFile:x>0?p[x-1]:null,nextFile:x<p.length-1?p[x+1]:null}},[p,r,w]),e=f.length>0?f[0]?.name:z?.name,v=V?.find((x)=>x.id===w)?.version??(V&&V.length>0?V.length:void 0),oe=D(()=>({originalKey:l.media?.original?.key,videoTranscodes:l.media?.videoTranscodes?.map((x)=>({key:x.key,width:x.width,height:x.height}))}),[l.media]),ye=()=>{Te([]),Y(null)},Ce=(x)=>{Y(x.id||null);let pe=x.annotations;if(pe&&pe.length>0)Te(pe);else Te([]);if(x.second!==null&&x.second!==void 0)a.current?.seekTo(x.second),a.current?.pause();else if(pe&&pe.length>0)a.current?.pause()},de=async(x)=>{if(x?.preventDefault(),!De.trim()||!O)return;try{Pe(!0),await O(De.trim()),Me(!1)}finally{Pe(!1)}},Be=async()=>{if(!c)return;try{X(!0),await c(),_(!1)}finally{X(!1)}};return h(()=>{G(0),Y(null),Te([])},[l?.id]),o("div",{className:"flex h-[100dvh] w-full flex-col bg-background overflow-hidden relative",children:[t(Ye,{fileName:l.name,folderName:e,version:v,versions:V,activeFileId:w,isPublic:m,shareId:N,allowDownload:q,downloadInfo:oe,canEdit:re,onBack:Q,hasPrevFile:!!Fe,hasNextFile:!!Le,onPrevFile:()=>Fe&&j(Fe.id),onNextFile:()=>Le&&j(Le.id),onSelectVersion:se,onRename:()=>{ee(l.name),Me(!0)},onDelete:()=>_(!0),onLinkedTasks:!m?()=>Ee(!0):void 0,linkedTaskCount:Oe}),t("div",{className:"relative flex-1 min-h-0 bg-background overflow-hidden flex flex-col",children:t(es,{file:l,mediaControllerRef:a,onPlay:ye,onTimeUpdate:G,annotations:ne,startTime:y,shareId:N,allowDownload:q})}),t(Qe,{teamId:s,projectId:d,file:l,onSaveField:J,members:fe,onCommentSelect:Ce,hideAnnotationControl:l.proxyType==="audio",readOnly:m||!re,publicFields:te,isPublic:m,shareId:N,currentTime:ze,onTyping:()=>a.current?.pause(),selectedCommentId:Ve,heightPercent:M,onHeightPercentChange:U}),!m&&ae&&t(Vd,{teamId:s,assetId:w,assetName:l.name,isOpen:ae,onClose:()=>Ee(!1)}),!m&&t(ue,{open:je,onOpenChange:Me,children:t(ie,{children:o("form",{onSubmit:de,children:[t(me,{children:t(le,{children:Oo()})}),t("div",{className:"py-4",children:t(H,{ref:T,value:De,onChange:(x)=>ee(x.target.value),placeholder:ud?.()||"Enter new name",onFocus:()=>{setTimeout(()=>{if(T.current)_s(T.current)},0)},autoFocus:!0})}),o(Ge,{children:[t(E,{type:"button",variant:"outline",onClick:()=>Me(!1),children:Ne()}),o(E,{type:"submit",disabled:Ie||!De.trim(),children:[Ie&&t(F,{className:"mr-2 h-4 w-4 animate-spin"}),Fo()]})]})]})})}),!m&&t(Je,{open:Se,onOpenChange:_,children:o(Xe,{children:[o(et,{children:[t(rt,{children:Lc?.()||"Delete Asset?"}),t(nt,{children:Fc?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),o(tt,{children:[t(st,{children:Ne()}),o(ot,{onClick:Be,disabled:xe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[xe&&t(F,{className:"mr-2 h-4 w-4 animate-spin"}),it()]})]})]})})]})}S();function We({activeState:d,activeAsset:s,previewUrl:r,isFullScreen:l,onTogglePlay:z,onToggleLoop:f,onSeek:V,onVolumeChange:w,onToggleMute:y,onChangePlaybackRate:m,onChangeResolution:N,onZoomIn:q,onZoomOut:te,onFit:p,onDownload:j,onToggleFullScreen:Q,allowDownload:O=!0}){if(d?.kind==="video"&&d.video&&s){let c=d.video,J=c.totalFrames/c.frameRate,se=c.currentFrame/c.frameRate,re={isPlaying:c.isPlaying,progress:J>0?se/J*100:0,currentTime:se,duration:J,volume:c.volume,isMuted:c.isMuted,isLooping:c.isLooping,playbackRate:c.playbackRate,isFullScreen:l,showFrames:!1,currentResolution:c.currentResolution},fe=r&&!s.media?.videoPreview?{...s,media:{...s.media,videoPreview:{url:r}}}:s;return t(iu,{state:re,zoom:d.zoom,isControlsVisible:!0,floatOverlayInFullScreen:!1,buffered:c.buffered,data:fe,resolutions:c.resolutions,togglePlay:z,toggleLoop:f,toggleMute:y,handleVolumeChange:w,changePlaybackRate:m,changeResolution:(a)=>N(a.resolution),handleDownload:(a)=>j(a),toggleFullScreen:Q,onZoomChange:(a)=>a>=d.zoom?q():te(),onZoomReset:p,frameRate:c.frameRate,totalFrames:c.totalFrames,currentFrame:c.currentFrame,seekToFrame:V,allowDownload:O})}if(d?.kind==="image")return t(lu,{zoom:d.zoom,onZoomIn:q,onZoomOut:te,onFit:p,onDownload:()=>j(),canDownload:!!s?.media?.original?.key,fullscreen:{isFullScreen:l,onToggle:Q},allowDownload:O});return t("div",{className:"relative z-10 flex items-center justify-end gap-2 border-t border-border bg-card px-4 py-3",children:t("button",{onClick:Q,className:"text-foreground transition-colors hover:text-primary",title:"Fullscreen",children:l?t(Ea,{className:"h-5 w-5"}):t(Sa,{className:"h-5 w-5"})})})}function qe({side:d,fileName:s,version:r,activeVersionId:l,versions:z,isActive:f,onActivate:V,onSwitchVersion:w,onExit:y}){let m=C("flex-shrink-0 rounded p-1 transition-colors hover:bg-muted",f?"text-foreground":"text-muted-foreground hover:text-foreground"),N=t("button",{onClick:y,title:pb(),className:m,children:t(Re,{className:"h-4 w-4"})}),q=o("button",{onClick:V,className:C("flex min-w-0 items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-muted",f?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[t("span",{className:"truncate",children:s}),r!==void 0&&o("span",{className:C("flex-shrink-0 rounded border px-1 py-0 text-xs",f?"border-foreground/40":"border-border"),children:["v",r]})]}),te=o(he,{children:[t(ge,{onClick:V,title:Pd(),className:m,children:t(ve,{className:"h-4 w-4"})}),t(Ae,{align:d==="left"?"start":"end",className:"w-80 p-1",children:t("div",{className:"flex max-h-96 flex-col gap-1 overflow-y-auto",children:z.map((p)=>{let j=p.id===l;return o(W,{onClick:()=>w(p.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",p.version]}),t("div",{className:"flex h-10 w-16 flex-shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:p.previewUrl?t("img",{src:p.previewUrl,alt:p.name||void 0,className:"h-full w-full object-cover"}):t(Xt,{className:"h-4 w-4 text-muted-foreground"})}),o("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t("span",{className:"truncate text-sm font-semibold text-foreground",children:p.name}),t("span",{className:"truncate text-xs text-muted-foreground",children:p.creator?.name||"Unknown"})]}),j&&t(ke,{className:"ml-auto h-4 w-4 flex-shrink-0 text-primary"})]},p.id)})})})]});return t("div",{onMouseDown:V,className:C("dark flex h-10 flex-shrink-0 items-center gap-1 border-b bg-background px-2 transition-colors",f?"border-b-2 border-primary":"border-border"),children:d==="left"?o(Z,{children:[N,q,te]}):o(Z,{children:[q,te,t("div",{className:"ml-auto"}),N]})})}function at(d,s,r){return L({queryKey:s?["public-share-file",r,d,localStorage.getItem(`share_pwd_${r}`)||""]:["files",d],queryFn:async()=>{if(s){let z=localStorage.getItem(`share_pwd_${r}`)||"",f=await A.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:d}},{headers:{"x-share-password":z}});if(!f.ok)throw Error("Failed to fetch version asset");return await f.json()}let l=await A.api.files[":fileId"].$get({param:{fileId:d}});if(!l.ok)throw Error("Failed to fetch version asset");return await l.json()},enabled:!!d&&(!s||!!r)})}function Ll({isPublic:d=!1,shareId:s,versions:r,leftId:l,rightId:z,activeSide:f,annotations:V,seekRequest:w,onActiveSideChange:y,onSwitchVersion:m,onExit:N,onActiveAssetChange:q,onPlay:te,onTimeUpdate:p,allowDownload:j=!0}){let Q=b(null),O=b(null),c=b(null),[J,se]=u(null),[re,fe]=u(null),[a,M]=u(1),[U,ne]=u(!1),[Te,ze]=u(!1),{data:G,isLoading:Ve}=at(l,d,s),{data:Y,isLoading:je}=at(z,d,s),Me=Xo(G),De=Xo(Y),ee=!!G&&!!Y&&Me.id===De.id,T=f==="left"?G:Y,xe=f==="left"?J:re,X=P(()=>f==="left"?O.current:c.current,[f]),Ie=P(()=>f==="left"?c.current:O.current,[f]);h(()=>{q(T??null)},[T,q]),h(()=>{if(!w)return;let n=X();if(n?.seekToSecond(w.second),n?.pause(),ee){let g=Ie();g?.seekToSecond(w.second),g?.pause()}},[w?.nonce]),h(()=>{let n=()=>ze(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]);let Pe=P((n)=>se(n),[]),Se=P((n)=>fe(n),[]),_=P((n)=>{let g=X();if(g)n(g);if(ee){let R=Ie();if(R)n(R)}},[X,Ie,ee]),ae=P(()=>{let n=!xe?.video?.isPlaying;_((g)=>n?g.play():g.pause())},[xe?.video?.isPlaying,_]);h(()=>{let n=(g)=>{let R=document.activeElement;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R instanceof HTMLElement&&R.isContentEditable))return;let He=g.key===" ",Ue=R&&(R.tagName==="BUTTON"||R.tagName==="A"||R.tagName==="SELECT"||R.tagName==="OPTION"||R.getAttribute("role")==="button"||R.getAttribute("role")==="link"||R.getAttribute("role")==="checkbox"||R.getAttribute("role")==="radio"||R.getAttribute("role")==="menuitem");if(He&&Ue)return;if(g.key===" "||g.key.toLowerCase()==="k")g.preventDefault(),ae()};return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[ae]);let Ee=P((n)=>_((g)=>g.seekToFrame(n)),[_]),_e=P(()=>X()?.toggleLoop(),[X]),Oe=P((n)=>{M(n),ne(n===0)},[]),Fe=P(()=>ne((n)=>!n),[]),Le=P((n)=>_((g)=>g.setPlaybackRate(n)),[_]),e=P((n)=>X()?.changeResolution(n),[X]),i=P(()=>_((n)=>n.zoomBy(1.2)),[_]),v=P(()=>_((n)=>n.zoomBy(0.8)),[_]),oe=P(()=>_((n)=>n.fit()),[_]),ye=P((n)=>{X()?.download(n)},[X]),Ce=P(()=>{let n=Q.current;if(!n||typeof n.requestFullscreen!=="function")return;if(!document.fullscreenElement)n.requestFullscreen().catch(()=>{});else if(document.exitFullscreen)document.exitFullscreen().catch(()=>{})},[]),de=P((n,g)=>{if(ee)c.current?.panBy(n,g)},[ee]),Be=P((n,g)=>{if(ee)O.current?.panBy(n,g)},[ee]),x=P(()=>ae(),[ae]),pe=P((n)=>r.find((g)=>g.id===n)?.version,[r]),lt=D(()=>T?.media?.videoPreview?.url,[T?.media?.videoPreview?.url]),Ke=(n,g)=>{let He=Xo(g)?.comparePane;if(!He)return t("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:t("p",{className:"text-muted-foreground",children:"Preview unavailable"})});let Ue=f===n;return t(He,{ref:n==="left"?O:c,file:g,shareId:s,isActive:Ue,annotations:Ue?V:[],onStateChange:n==="left"?Pe:Se,onUserPan:n==="left"?de:Be,onActivate:()=>y(n),muted:Ue?U:!0,volume:a,onPlay:te,onTimeUpdate:p,onRequestTogglePlay:x},g.id)},dt=!!G&&!!Y,mt=Ve||je;return o("div",{ref:Q,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:[G&&t(qe,{side:"left",fileName:G.name,version:pe(l),activeVersionId:l,versions:r,isActive:f==="left",onActivate:()=>y("left"),onSwitchVersion:(n)=>m("left",n),onExit:N}),t("div",{className:"relative flex min-h-0 flex-1",children:G?Ke("left",G):t("div",{className:"flex flex-1 items-center justify-center",children:t(F,{className:"h-6 w-6 animate-spin text-foreground"})})})]}),o("div",{className:"flex min-w-0 flex-1 flex-col",children:[Y&&t(qe,{side:"right",fileName:Y.name,version:pe(z),activeVersionId:z,versions:r,isActive:f==="right",onActivate:()=>y("right"),onSwitchVersion:(n)=>m("right",n),onExit:N}),t("div",{className:"relative flex min-h-0 flex-1",children:Y?Ke("right",Y):t("div",{className:"flex flex-1 items-center justify-center",children:t(F,{className:"h-6 w-6 animate-spin text-foreground"})})})]})]}),mt&&!dt&&t("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/30",children:t(F,{className:"h-8 w-8 animate-spin text-foreground"})}),t(We,{activeState:xe,activeAsset:T??null,previewUrl:lt,isFullScreen:Te,onTogglePlay:ae,onToggleLoop:_e,onSeek:Ee,onVolumeChange:Oe,onToggleMute:Fe,onChangePlaybackRate:Le,onChangeResolution:e,onZoomIn:i,onZoomOut:v,onFit:oe,onDownload:ye,onToggleFullScreen:Ce,allowDownload:j})]})}
|
|
2
|
+
export{Fl,Ll};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{za,Yt}from"./chunk-v0201sn5.js";function C(e,t){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function P(e){return typeof e.result==="function"}async function S(e,t){for await(let r of t)e.push(r);e.end(P(t)?await t.result():void 0)}function y(e,t){let r=new Yt;return t().then((n)=>S(r,n)).catch((n)=>{let a=C(e,n);r.push({type:"error",reason:"error",error:a}),r.end(a)}),r}function jr(e){return{stream:(t,r,n)=>y(t,async()=>(await e()).stream(t,r,n)),streamSimple:(t,r,n)=>y(t,async()=>(await e()).streamSimple(t,r,n))}}var K=function(e,t){if(typeof e==="string"&&/^\.\.?\//.test(e))return e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,a,s,i){return n?t?".jsx":".js":a&&(!s||!i)?r:a+s+"."+i.toLowerCase()+"js"});return e},x=(e)=>import(K(e));function b(){return globalThis.process?.env}function A(){return{async env(e){let t=b()?.[e];return typeof t==="string"&&t.trim().length>0?t:void 0},async fileExists(e){try{let t=await x("node:fs/promises"),r=e;if(r.startsWith("~"))r=(await x("node:os")).homedir()+r.slice(1);return await t.access(r),!0}catch{return!1}}}}class mc{credentials=new Map;chains=new Map;enqueue(e,t){let r=this.chains.get(e)??Promise.resolve(),n=(async()=>(await r.catch(()=>{}),t()))();return this.chains.set(e,n.catch(()=>{})),n}async read(e){return this.credentials.get(e)}async list(){return[...this.credentials].map(([e,t])=>({providerId:e,type:t.type}))}modify(e,t){return this.enqueue(e,async()=>{let r=this.credentials.get(e),n=await t(r);if(n!==void 0)this.credentials.set(e,n);return n??r})}delete(e){return this.enqueue(e,async()=>{this.credentials.delete(e)})}}class u extends Error{code;constructor(e,t,r){super(q(t,r?.cause),r);this.name="ModelsError",this.code=e}}function q(e,t){if(t===void 0||t===null)return e;let r=za(t).trim();if(!r||e.includes(r))return e;return`${e}: ${r}`}async function v(e,t,r,n){let a=n?.env?E(r,n.env):r;if(n?.apiKey!==void 0&&e.auth.apiKey)return m(a,e.auth.apiKey,e.id,{type:"api_key",key:n.apiKey,env:n.env});let s=await _(t,e.id);if(s){if(s.type==="oauth"&&e.auth.oauth)return R(t,e.id,e.auth.oauth,s);if(s.type==="api_key"&&e.auth.apiKey){let i=n?.env?{...s,env:{...s.env,...n.env}}:s;return m(a,e.auth.apiKey,e.id,i)}return}return e.auth.apiKey?m(a,e.auth.apiKey,e.id,void 0):void 0}function E(e,t){return{env:async(r)=>t[r]||await e.env(r),fileExists:(r)=>e.fileExists(r)}}async function R(e,t,r,n){let a=n;if(Date.now()>=a.expires){let s;try{s=await e.modify(t,async(i)=>{if(i?.type!=="oauth")return;if(Date.now()<i.expires)return;try{return await r.refresh(i)}catch(c){throw new u("oauth",`OAuth refresh failed for ${t}`,{cause:c})}})}catch(i){if(i instanceof u)throw i;throw new u("auth",`Credential store modify failed for ${t}`,{cause:i})}if(s?.type!=="oauth")return;a=s}try{return{auth:await r.toAuth(a),source:"OAuth"}}catch(s){throw new u("oauth",`OAuth auth derivation failed for ${t}`,{cause:s})}}async function m(e,t,r,n){try{return await t.resolve({ctx:e,credential:n})}catch(a){throw new u("auth",`API key auth failed for provider ${r}`,{cause:a})}}async function _(e,t){try{return await e.read(t)}catch(r){throw new u("auth",`Credential store read failed for ${t}`,{cause:r})}}class g{entries=new Map;async read(e){let t=this.entries.get(e);return t?structuredClone(t):void 0}async write(e,t){this.entries.set(e,structuredClone(t))}async delete(e){this.entries.delete(e)}}function k(e,t){if(!e&&!t)return;let r={...e};for(let[n,a]of Object.entries(t??{})){let s=n.toLowerCase();for(let i of Object.keys(r))if(i.toLowerCase()===s)delete r[i];r[n]=a}return r}class M{providers=new Map;credentials;modelsStore;authContext;constructor(e){this.credentials=e?.credentials??new mc,this.modelsStore=e?.modelsStore??new g,this.authContext=e?.authContext??A()}setProvider(e){this.providers.set(e.id,e)}deleteProvider(e){this.providers.delete(e)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(e){return this.providers.get(e)}getModels(e){if(e!==void 0){let r=this.providers.get(e);if(!r)return[];try{return r.getModels()}catch{return[]}}let t=[];for(let r of this.providers.values())try{t.push(...r.getModels())}catch{}return t}getModel(e,t){return this.getModels(e).find((r)=>r.id===t)}async refresh(e={}){let t=e.allowNetwork??!0,r=new Map,n=Array.from(this.providers.values()).filter((a)=>a.refreshModels!==void 0);return await Promise.all(n.map(async(a)=>{if(e.signal?.aborted)return;let s={read:()=>this.modelsStore.read(a.id),write:(c)=>this.modelsStore.write(a.id,c),delete:()=>this.modelsStore.delete(a.id)},i;try{i=await this.readCredential(a.id);let c=await this.resolveRefreshCredential(a,i,t,e.signal);if(!c)return;await a.refreshModels({credential:c,store:s,allowNetwork:t,force:e.force,signal:e.signal})}catch(c){if(!e.signal?.aborted)r.set(a.id,c instanceof Error?c:new u("model_source",`Model refresh failed for ${a.id}`,{cause:c}));try{await a.refreshModels({credential:i,store:s,allowNetwork:!1,signal:e.signal})}catch{}}})),{aborted:e.signal?.aborted??!1,errors:r}}async resolveRefreshCredential(e,t,r,n){if(t?.type==="oauth"){let c=e.auth.oauth;if(!c)return;if(!r||Date.now()<t.expires)return t;if(n?.aborted)return;let p=await this.credentials.modify(e.id,async(l)=>{if(l?.type!=="oauth"||Date.now()<l.expires)return;return c.refresh(l,n)});return p?.type==="oauth"?p:void 0}let a=e.auth.apiKey;if(!a)return;let s=t?.type==="api_key"?t:void 0,i=await a.resolve({ctx:this.authContext,credential:s});if(!i)return;return{type:"api_key",key:i.auth.apiKey,env:i.env}}async readCredential(e){try{return await this.credentials.read(e)}catch(t){throw new u("auth",`Credential store read failed for ${e}`,{cause:t})}}async checkProviderAuth(e,t){if(t?.type==="oauth")return e.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;let r=e.auth.apiKey;if(!r)return;if(r.check)try{return await r.check({ctx:this.authContext,credential:t?.type==="api_key"?t:void 0})}catch(a){throw new u("auth",`API key auth check failed for provider ${e.id}`,{cause:a})}let n=await v(e,this.credentials,this.authContext);return n?{source:n.source,type:"api_key"}:void 0}async checkAuth(e){let t=this.providers.get(e);if(!t)return;return this.checkProviderAuth(t,await this.readCredential(e))}async getAvailable(e){let t=e?[this.providers.get(e)].filter((n)=>n!==void 0):this.getProviders();return(await Promise.all(t.map(async(n)=>{let a=await this.readCredential(n.id);return{provider:n,credential:a,auth:await this.checkProviderAuth(n,a)}}))).flatMap(({provider:n,credential:a,auth:s})=>{if(!s)return[];let i=n.getModels();return n.filterModels?.(i,a)??i})}async getAuth(e,t){let r=typeof e==="string"?e:e.provider,n=this.providers.get(r);if(!n)return;let a=await v(n,this.credentials,this.authContext,t);if(!a||typeof e==="string"||!e.headers)return a;return{...a,auth:{...a.auth,headers:k(a.auth.headers,e.headers)}}}async login(e,t,r){let n=this.providers.get(e);if(!n)throw new u("provider",`Unknown provider: ${e}`);let a=t==="oauth"?n.auth.oauth:n.auth.apiKey;if(!a?.login)throw new u("auth",`${n.name} does not support ${t} login`);let s=await a.login(r);try{await this.credentials.modify(e,async()=>s)}catch(i){throw new u("auth",`Credential store modify failed for ${e}`,{cause:i})}return s}async logout(e){try{await this.credentials.delete(e)}catch(t){throw new u("auth",`Credential store delete failed for ${e}`,{cause:t})}}requireProvider(e){let t=this.providers.get(e.provider);if(!t)throw new u("provider",`Unknown provider: ${e.provider}`);return t}async applyAuth(e,t){this.requireProvider(e);let r=await this.getAuth(e,{apiKey:t?.apiKey,env:t?.env});if(!r)throw new u("auth",`Provider is not configured: ${e.provider}`);let n=r.auth,a=t?.apiKey??n.apiKey,s=k(n.headers,t?.headers);if(t?.transformHeaders)s=await t.transformHeaders(s??{});let i=r.env||t?.env?{...r.env??{},...t?.env??{}}:void 0,c=n.baseUrl?{...e,baseUrl:n.baseUrl}:e,{transformHeaders:p,...l}=t??{},o={...l,apiKey:a,headers:s,env:i};return{requestModel:c,requestOptions:o}}stream(e,t,r){return y(e,async()=>{let n=this.requireProvider(e),{requestModel:a,requestOptions:s}=await this.applyAuth(e,r);return n.stream(a,t,s)})}async complete(e,t,r){return this.stream(e,t,r).result()}streamSimple(e,t,r){return y(e,async()=>{let n=this.requireProvider(e),{requestModel:a,requestOptions:s}=await this.applyAuth(e,r);return n.streamSimple(a,t,s)})}async completeSimple(e,t,r){return this.streamSimple(e,t,r).result()}}function lm(e){return new M(e)}function _e(e){let t=e.models,r=[],n,a=e.fetchModels,s=()=>{let o=[...t];for(let h of r){let d=o.findIndex((f)=>f.id===h.id);if(d>=0)o[d]=h;else o.push(h)}return o},i=typeof e.api.stream==="function"?e.api:void 0,c=i?void 0:e.api,p=(o)=>i??c?.[o.api],l=(o,h)=>{let d=p(o);if(!d)return y(o,async()=>{throw new u("stream",`Provider ${e.id} has no API implementation for "${o.api}"`)});return h(d)};return{id:e.id,name:e.name??e.id,baseUrl:e.baseUrl,headers:e.headers,auth:e.auth,getModels:s,refreshModels:a?(o)=>(n??=(async()=>{try{let h=await o.store.read();if(h)r=h.models.filter((f)=>f.provider===e.id).map((f)=>f);if(!o.allowNetwork||o.signal?.aborted)return;let d=await a(o);if(o.signal?.aborted)return;r=d,await o.store.write({models:d,checkedAt:Date.now()})}finally{n=void 0}})(),n):void 0,filterModels:e.filterModels,stream:(o,h,d)=>l(o,(f)=>f.stream(o,h,d)),streamSimple:(o,h,d)=>l(o,(f)=>f.streamSimple(o,h,d))}}function sn(e,t){let r=t.input+t.cacheRead+t.cacheWrite,n=e.cost,a=-1;for(let c of e.cost.tiers??[])if(r>c.inputTokensAbove&&c.inputTokensAbove>a)n=c,a=c.inputTokensAbove;let s=t.cacheWrite1h??0,i=t.cacheWrite-s;return t.cost.input=n.input/1e6*t.input,t.cost.output=n.output/1e6*t.output,t.cost.cacheRead=n.cacheRead/1e6*t.cacheRead,t.cost.cacheWrite=(n.cacheWrite*i+n.input*2*s)/1e6,t.cost.total=t.cost.input+t.cost.output+t.cost.cacheRead+t.cost.cacheWrite,t.cost}var w=["off","minimal","low","medium","high","xhigh","max"];function T(e){if(!e.reasoning)return["off"];return w.filter((t)=>{let r=e.thinkingLevelMap?.[t];if(r===null)return!1;if(t==="xhigh"||t==="max")return r!==void 0;return!0})}function qr(e,t){let r=T(e);if(r.includes(t))return t;let n=w.indexOf(t);if(n===-1)return r[0]??"off";for(let a=n;a<w.length;a++){let s=w[a];if(r.includes(s))return s}for(let a=n-1;a>=0;a--){let s=w[a];if(r.includes(s))return s}return r[0]??"off"}
|
|
3
|
-
export{
|
|
2
|
+
import{qa,Yt}from"./chunk-b3aqmcps.js";function C(e,t){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function P(e){return typeof e.result==="function"}async function S(e,t){for await(let r of t)e.push(r);e.end(P(t)?await t.result():void 0)}function y(e,t){let r=new Yt;return t().then((n)=>S(r,n)).catch((n)=>{let a=C(e,n);r.push({type:"error",reason:"error",error:a}),r.end(a)}),r}function qr(e){return{stream:(t,r,n)=>y(t,async()=>(await e()).stream(t,r,n)),streamSimple:(t,r,n)=>y(t,async()=>(await e()).streamSimple(t,r,n))}}var K=function(e,t){if(typeof e==="string"&&/^\.\.?\//.test(e))return e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,n,a,s,i){return n?t?".jsx":".js":a&&(!s||!i)?r:a+s+"."+i.toLowerCase()+"js"});return e},x=(e)=>import(K(e));function b(){return globalThis.process?.env}function A(){return{async env(e){let t=b()?.[e];return typeof t==="string"&&t.trim().length>0?t:void 0},async fileExists(e){try{let t=await x("node:fs/promises"),r=e;if(r.startsWith("~"))r=(await x("node:os")).homedir()+r.slice(1);return await t.access(r),!0}catch{return!1}}}}class _c{credentials=new Map;chains=new Map;enqueue(e,t){let r=this.chains.get(e)??Promise.resolve(),n=(async()=>(await r.catch(()=>{}),t()))();return this.chains.set(e,n.catch(()=>{})),n}async read(e){return this.credentials.get(e)}async list(){return[...this.credentials].map(([e,t])=>({providerId:e,type:t.type}))}modify(e,t){return this.enqueue(e,async()=>{let r=this.credentials.get(e),n=await t(r);if(n!==void 0)this.credentials.set(e,n);return n??r})}delete(e){return this.enqueue(e,async()=>{this.credentials.delete(e)})}}class u extends Error{code;constructor(e,t,r){super(q(t,r?.cause),r);this.name="ModelsError",this.code=e}}function q(e,t){if(t===void 0||t===null)return e;let r=qa(t).trim();if(!r||e.includes(r))return e;return`${e}: ${r}`}async function v(e,t,r,n){let a=n?.env?E(r,n.env):r;if(n?.apiKey!==void 0&&e.auth.apiKey)return m(a,e.auth.apiKey,e.id,{type:"api_key",key:n.apiKey,env:n.env});let s=await _(t,e.id);if(s){if(s.type==="oauth"&&e.auth.oauth)return R(t,e.id,e.auth.oauth,s);if(s.type==="api_key"&&e.auth.apiKey){let i=n?.env?{...s,env:{...s.env,...n.env}}:s;return m(a,e.auth.apiKey,e.id,i)}return}return e.auth.apiKey?m(a,e.auth.apiKey,e.id,void 0):void 0}function E(e,t){return{env:async(r)=>t[r]||await e.env(r),fileExists:(r)=>e.fileExists(r)}}async function R(e,t,r,n){let a=n;if(Date.now()>=a.expires){let s;try{s=await e.modify(t,async(i)=>{if(i?.type!=="oauth")return;if(Date.now()<i.expires)return;try{return await r.refresh(i)}catch(c){throw new u("oauth",`OAuth refresh failed for ${t}`,{cause:c})}})}catch(i){if(i instanceof u)throw i;throw new u("auth",`Credential store modify failed for ${t}`,{cause:i})}if(s?.type!=="oauth")return;a=s}try{return{auth:await r.toAuth(a),source:"OAuth"}}catch(s){throw new u("oauth",`OAuth auth derivation failed for ${t}`,{cause:s})}}async function m(e,t,r,n){try{return await t.resolve({ctx:e,credential:n})}catch(a){throw new u("auth",`API key auth failed for provider ${r}`,{cause:a})}}async function _(e,t){try{return await e.read(t)}catch(r){throw new u("auth",`Credential store read failed for ${t}`,{cause:r})}}class g{entries=new Map;async read(e){let t=this.entries.get(e);return t?structuredClone(t):void 0}async write(e,t){this.entries.set(e,structuredClone(t))}async delete(e){this.entries.delete(e)}}function k(e,t){if(!e&&!t)return;let r={...e};for(let[n,a]of Object.entries(t??{})){let s=n.toLowerCase();for(let i of Object.keys(r))if(i.toLowerCase()===s)delete r[i];r[n]=a}return r}class M{providers=new Map;credentials;modelsStore;authContext;constructor(e){this.credentials=e?.credentials??new _c,this.modelsStore=e?.modelsStore??new g,this.authContext=e?.authContext??A()}setProvider(e){this.providers.set(e.id,e)}deleteProvider(e){this.providers.delete(e)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(e){return this.providers.get(e)}getModels(e){if(e!==void 0){let r=this.providers.get(e);if(!r)return[];try{return r.getModels()}catch{return[]}}let t=[];for(let r of this.providers.values())try{t.push(...r.getModels())}catch{}return t}getModel(e,t){return this.getModels(e).find((r)=>r.id===t)}async refresh(e={}){let t=e.allowNetwork??!0,r=new Map,n=Array.from(this.providers.values()).filter((a)=>a.refreshModels!==void 0);return await Promise.all(n.map(async(a)=>{if(e.signal?.aborted)return;let s={read:()=>this.modelsStore.read(a.id),write:(c)=>this.modelsStore.write(a.id,c),delete:()=>this.modelsStore.delete(a.id)},i;try{i=await this.readCredential(a.id);let c=await this.resolveRefreshCredential(a,i,t,e.signal);if(!c)return;await a.refreshModels({credential:c,store:s,allowNetwork:t,force:e.force,signal:e.signal})}catch(c){if(!e.signal?.aborted)r.set(a.id,c instanceof Error?c:new u("model_source",`Model refresh failed for ${a.id}`,{cause:c}));try{await a.refreshModels({credential:i,store:s,allowNetwork:!1,signal:e.signal})}catch{}}})),{aborted:e.signal?.aborted??!1,errors:r}}async resolveRefreshCredential(e,t,r,n){if(t?.type==="oauth"){let c=e.auth.oauth;if(!c)return;if(!r||Date.now()<t.expires)return t;if(n?.aborted)return;let p=await this.credentials.modify(e.id,async(l)=>{if(l?.type!=="oauth"||Date.now()<l.expires)return;return c.refresh(l,n)});return p?.type==="oauth"?p:void 0}let a=e.auth.apiKey;if(!a)return;let s=t?.type==="api_key"?t:void 0,i=await a.resolve({ctx:this.authContext,credential:s});if(!i)return;return{type:"api_key",key:i.auth.apiKey,env:i.env}}async readCredential(e){try{return await this.credentials.read(e)}catch(t){throw new u("auth",`Credential store read failed for ${e}`,{cause:t})}}async checkProviderAuth(e,t){if(t?.type==="oauth")return e.auth.oauth?{source:"OAuth",type:"oauth"}:void 0;let r=e.auth.apiKey;if(!r)return;if(r.check)try{return await r.check({ctx:this.authContext,credential:t?.type==="api_key"?t:void 0})}catch(a){throw new u("auth",`API key auth check failed for provider ${e.id}`,{cause:a})}let n=await v(e,this.credentials,this.authContext);return n?{source:n.source,type:"api_key"}:void 0}async checkAuth(e){let t=this.providers.get(e);if(!t)return;return this.checkProviderAuth(t,await this.readCredential(e))}async getAvailable(e){let t=e?[this.providers.get(e)].filter((n)=>n!==void 0):this.getProviders();return(await Promise.all(t.map(async(n)=>{let a=await this.readCredential(n.id);return{provider:n,credential:a,auth:await this.checkProviderAuth(n,a)}}))).flatMap(({provider:n,credential:a,auth:s})=>{if(!s)return[];let i=n.getModels();return n.filterModels?.(i,a)??i})}async getAuth(e,t){let r=typeof e==="string"?e:e.provider,n=this.providers.get(r);if(!n)return;let a=await v(n,this.credentials,this.authContext,t);if(!a||typeof e==="string"||!e.headers)return a;return{...a,auth:{...a.auth,headers:k(a.auth.headers,e.headers)}}}async login(e,t,r){let n=this.providers.get(e);if(!n)throw new u("provider",`Unknown provider: ${e}`);let a=t==="oauth"?n.auth.oauth:n.auth.apiKey;if(!a?.login)throw new u("auth",`${n.name} does not support ${t} login`);let s=await a.login(r);try{await this.credentials.modify(e,async()=>s)}catch(i){throw new u("auth",`Credential store modify failed for ${e}`,{cause:i})}return s}async logout(e){try{await this.credentials.delete(e)}catch(t){throw new u("auth",`Credential store delete failed for ${e}`,{cause:t})}}requireProvider(e){let t=this.providers.get(e.provider);if(!t)throw new u("provider",`Unknown provider: ${e.provider}`);return t}async applyAuth(e,t){this.requireProvider(e);let r=await this.getAuth(e,{apiKey:t?.apiKey,env:t?.env});if(!r)throw new u("auth",`Provider is not configured: ${e.provider}`);let n=r.auth,a=t?.apiKey??n.apiKey,s=k(n.headers,t?.headers);if(t?.transformHeaders)s=await t.transformHeaders(s??{});let i=r.env||t?.env?{...r.env??{},...t?.env??{}}:void 0,c=n.baseUrl?{...e,baseUrl:n.baseUrl}:e,{transformHeaders:p,...l}=t??{},o={...l,apiKey:a,headers:s,env:i};return{requestModel:c,requestOptions:o}}stream(e,t,r){return y(e,async()=>{let n=this.requireProvider(e),{requestModel:a,requestOptions:s}=await this.applyAuth(e,r);return n.stream(a,t,s)})}async complete(e,t,r){return this.stream(e,t,r).result()}streamSimple(e,t,r){return y(e,async()=>{let n=this.requireProvider(e),{requestModel:a,requestOptions:s}=await this.applyAuth(e,r);return n.streamSimple(a,t,s)})}async completeSimple(e,t,r){return this.streamSimple(e,t,r).result()}}function fm(e){return new M(e)}function ye(e){let t=e.models,r=[],n,a=e.fetchModels,s=()=>{let o=[...t];for(let h of r){let d=o.findIndex((f)=>f.id===h.id);if(d>=0)o[d]=h;else o.push(h)}return o},i=typeof e.api.stream==="function"?e.api:void 0,c=i?void 0:e.api,p=(o)=>i??c?.[o.api],l=(o,h)=>{let d=p(o);if(!d)return y(o,async()=>{throw new u("stream",`Provider ${e.id} has no API implementation for "${o.api}"`)});return h(d)};return{id:e.id,name:e.name??e.id,baseUrl:e.baseUrl,headers:e.headers,auth:e.auth,getModels:s,refreshModels:a?(o)=>(n??=(async()=>{try{let h=await o.store.read();if(h)r=h.models.filter((f)=>f.provider===e.id).map((f)=>f);if(!o.allowNetwork||o.signal?.aborted)return;let d=await a(o);if(o.signal?.aborted)return;r=d,await o.store.write({models:d,checkedAt:Date.now()})}finally{n=void 0}})(),n):void 0,filterModels:e.filterModels,stream:(o,h,d)=>l(o,(f)=>f.stream(o,h,d)),streamSimple:(o,h,d)=>l(o,(f)=>f.streamSimple(o,h,d))}}function cn(e,t){let r=t.input+t.cacheRead+t.cacheWrite,n=e.cost,a=-1;for(let c of e.cost.tiers??[])if(r>c.inputTokensAbove&&c.inputTokensAbove>a)n=c,a=c.inputTokensAbove;let s=t.cacheWrite1h??0,i=t.cacheWrite-s;return t.cost.input=n.input/1e6*t.input,t.cost.output=n.output/1e6*t.output,t.cost.cacheRead=n.cacheRead/1e6*t.cacheRead,t.cost.cacheWrite=(n.cacheWrite*i+n.input*2*s)/1e6,t.cost.total=t.cost.input+t.cost.output+t.cost.cacheRead+t.cost.cacheWrite,t.cost}var w=["off","minimal","low","medium","high","xhigh","max"];function T(e){if(!e.reasoning)return["off"];return w.filter((t)=>{let r=e.thinkingLevelMap?.[t];if(r===null)return!1;if(t==="xhigh"||t==="max")return r!==void 0;return!0})}function Hr(e,t){let r=T(e);if(r.includes(t))return t;let n=w.indexOf(t);if(n===-1)return r[0]??"off";for(let a=n;a<w.length;a++){let s=w[a];if(r.includes(s))return s}for(let a=n-1;a>=0;a--){let s=w[a];if(r.includes(s))return s}return r[0]??"off"}
|
|
3
|
+
export{_c,qr,fm,ye,cn,Hr};
|