@shumai-one/shumai 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/chunk-01052ssf.js +32 -0
- package/bin/{chunk-cdk8vqeg.js → chunk-02fvcrej.js} +4 -4
- package/bin/chunk-0bj887zm.js +2 -0
- package/bin/chunk-167z646e.js +2 -0
- package/bin/chunk-1ktk6764.js +10 -0
- package/bin/{chunk-4jj92zwa.js → chunk-1nvd90g2.js} +1 -1
- package/bin/{chunk-ww9qq8yq.js → chunk-1wfg56z3.js} +5 -5
- package/bin/{chunk-3tg10kwz.js → chunk-257dcd2f.js} +2 -2
- package/bin/chunk-26qn7fek.js +2 -0
- package/bin/chunk-2cdxm1cp.js +55 -0
- package/bin/chunk-2jj4j8cn.js +3 -0
- package/bin/chunk-2ne2b54t.js +2 -0
- package/bin/{chunk-h1fbev9c.js → chunk-2nhgdqdg.js} +2 -2
- package/bin/chunk-2vbeqczj.js +1 -0
- package/bin/chunk-37p6bcx2.js +1 -0
- package/bin/chunk-3ckkwdjx.js +13 -0
- package/bin/chunk-3knfx6dm.js +1 -0
- package/bin/chunk-3z85zxkn.js +1 -0
- package/bin/chunk-4mws03es.js +5 -0
- package/bin/chunk-54tbfvya.js +2 -0
- package/bin/chunk-55h9ze53.js +2 -0
- package/bin/chunk-56kh5fxc.js +1 -0
- package/bin/chunk-576nj64j.js +2 -0
- package/bin/{chunk-9gftd4f7.js → chunk-5wapd171.js} +13 -13
- package/bin/chunk-6cnqjngz.js +1 -0
- package/bin/chunk-73yncv54.js +2 -0
- package/bin/chunk-7g46e1wy.js +3 -0
- package/bin/{chunk-3020am4q.js → chunk-7naa7tpn.js} +2 -2
- package/bin/{chunk-6zerk0em.js → chunk-7sgrtxbt.js} +2 -2
- package/bin/{chunk-5bpvwv66.js → chunk-7v7mypc6.js} +2 -2
- package/bin/chunk-82tps5n1.js +2 -0
- package/bin/chunk-84x8p7v5.js +1 -0
- package/bin/{chunk-fxg81vtx.js → chunk-88jg9dq5.js} +2 -2
- package/bin/chunk-8cjet7pp.js +12 -0
- package/bin/chunk-8fyg9dy4.js +2 -0
- package/bin/chunk-8gtfgkrn.js +2 -0
- package/bin/chunk-8mqbztj8.js +2 -0
- package/bin/chunk-8qdtvfx3.css +1 -0
- package/bin/chunk-8xb6yz11.js +2 -0
- package/bin/chunk-8yjsmr7g.js +2 -0
- package/bin/chunk-91rb0jpb.js +2 -0
- package/bin/chunk-96qpjght.js +2 -0
- package/bin/chunk-9f1xk1nt.js +1 -0
- package/bin/chunk-9mk9cvbk.js +1 -0
- package/bin/{chunk-65t6rm5d.js → chunk-9n1w5dw1.js} +3 -3
- package/bin/chunk-9nw5w8vh.js +1 -0
- package/bin/{chunk-cv5xx81e.js → chunk-9t3p4xp6.js} +1 -1
- package/bin/chunk-9xhjy897.js +11 -0
- package/bin/chunk-9zsv6d2f.js +1 -0
- package/bin/chunk-a411xhmm.js +7 -0
- package/bin/{chunk-xbw7ffrz.js → chunk-a74g6h8a.js} +2 -2
- package/bin/chunk-ah8fjb6f.js +2 -0
- package/bin/chunk-atfz7g7e.js +2 -0
- package/bin/{chunk-j4p3eqtd.js → chunk-b5rhvzv9.js} +2 -2
- package/bin/{chunk-rq2h2bwt.js → chunk-b7bnp021.js} +2 -2
- package/bin/chunk-cf5axr8c.js +1 -0
- package/bin/chunk-cgmebxx6.js +2 -0
- package/bin/chunk-cwat1jwx.js +3 -0
- package/bin/chunk-cz13a82m.js +3 -0
- package/bin/chunk-dk42gf7v.js +2 -0
- package/bin/chunk-e4f56spj.js +4 -0
- package/bin/chunk-e4yscwen.js +18 -0
- package/bin/chunk-eb7mzbfm.js +1 -0
- package/bin/chunk-er14d498.js +3 -0
- package/bin/{chunk-sbyyn9yw.js → chunk-eyjfhdp9.js} +2 -2
- package/bin/chunk-f25fe9th.js +393 -0
- package/bin/chunk-f6avg5qe.js +129 -0
- package/bin/{chunk-vjyget8s.js → chunk-fatmqnp1.js} +1 -1
- package/bin/chunk-fvx9k1dc.js +2 -0
- package/bin/chunk-g22wmpk1.js +3 -0
- package/bin/chunk-g6sdezec.js +2 -0
- package/bin/chunk-gtf19jc1.js +2 -0
- package/bin/chunk-gxepkvt2.js +2 -0
- package/bin/chunk-h1n7jqnw.js +1 -0
- package/bin/chunk-hfm82066.js +2 -0
- package/bin/chunk-hnkcgvcj.js +3 -0
- package/bin/{chunk-fg9sr6r9.js → chunk-hpbn0k9n.js} +2 -2
- package/bin/{chunk-qk5hsn6e.js → chunk-hpwv4am3.js} +4 -4
- package/bin/{chunk-d6xezgrg.js → chunk-hw6czrya.js} +1 -1
- package/bin/{chunk-59t9s2jh.js → chunk-hzkjgcre.js} +1 -1
- package/bin/chunk-j2s311yc.js +3 -0
- package/bin/{chunk-6hzktewz.js → chunk-jt02kpfc.js} +2 -2
- package/bin/{chunk-qnyqtaf0.js → chunk-jt0ykktx.js} +1 -1
- package/bin/{chunk-047n9gfs.js → chunk-jzgbxqdg.js} +2 -2
- package/bin/chunk-kj6h5j5a.js +4 -0
- package/bin/chunk-km4gn6b6.js +1 -0
- package/bin/chunk-knj2s8mg.js +16 -0
- package/bin/{chunk-01ym2agz.js → chunk-kvhf12b4.js} +2 -2
- package/bin/chunk-m0q2cgfg.js +2 -0
- package/bin/chunk-m82tkhaa.js +11 -0
- package/bin/chunk-m9adtgzk.js +2 -0
- package/bin/{chunk-rh8dy99a.js → chunk-mcj1xpcc.js} +2 -2
- package/bin/chunk-mcw198kg.js +13 -0
- package/bin/{chunk-5e7r7a9d.js → chunk-mwktrwtx.js} +1 -1
- package/bin/chunk-mzsw9var.js +3 -0
- package/bin/chunk-ns33grgx.js +2 -0
- package/bin/{chunk-emgyjhmx.js → chunk-ny1kbmxt.js} +2 -2
- package/bin/{chunk-czybv3vy.js → chunk-p3f5aevs.js} +1 -1
- package/bin/chunk-p3j6ydk1.js +1 -0
- package/bin/chunk-p4s95471.js +2 -0
- package/bin/chunk-pk406dgy.js +2 -0
- package/bin/chunk-q2bew2vc.js +2 -0
- package/bin/chunk-q5vkxee3.js +5 -0
- package/bin/{chunk-n0wwtjwv.js → chunk-q83h0hkx.js} +2 -2
- package/bin/chunk-q8w4mbw4.js +2 -0
- package/bin/{chunk-hjwpd09v.js → chunk-qwpkcp8d.js} +2 -2
- package/bin/chunk-r1xer8gn.js +5 -0
- package/bin/chunk-s1e4qy3q.js +14 -0
- package/bin/{chunk-w89czwjj.js → chunk-s9ksftq2.js} +1 -1
- package/bin/chunk-srxp5jav.js +42 -0
- package/bin/chunk-swtwaaqe.js +1 -0
- package/bin/chunk-tagdrg7p.js +1 -0
- package/bin/{chunk-da86fpjt.js → chunk-tekwpkjf.js} +2 -2
- package/bin/chunk-twtxnzbv.js +2 -0
- package/bin/{chunk-q7t5zs7n.js → chunk-v05rrxp5.js} +2 -2
- package/bin/{chunk-8s9fehda.js → chunk-v5cn90cf.js} +2 -2
- package/bin/chunk-v5mcjwxy.js +2 -0
- package/bin/{chunk-fyb6t7ct.js → chunk-vcrmjtcz.js} +2 -2
- package/bin/chunk-vkzasgxw.js +2 -0
- package/bin/chunk-vp3czaeh.js +7 -0
- package/bin/chunk-x03jwaga.js +8 -0
- package/bin/chunk-x342vzdx.js +2 -0
- package/bin/chunk-x8mjh387.js +5 -0
- package/bin/chunk-xc54vhfz.js +2 -0
- package/bin/chunk-xvkwbczx.js +3 -0
- package/bin/chunk-y241cxff.js +1 -0
- package/bin/chunk-yk12hydf.js +7 -0
- package/bin/chunk-ympbfzz4.js +2 -0
- package/bin/chunk-yq32evnn.js +20 -0
- package/bin/chunk-z1p13dnc.js +2 -0
- package/bin/chunk-zarz3sqn.js +211 -0
- package/bin/chunk-zezje74z.js +4 -0
- package/bin/chunk-zrszykjf.js +3 -0
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +947 -1012
- package/package.json +7 -7
- package/prisma/migrations/20261026024507_hash_api_tokens/migration.sql +28 -0
- package/prisma/migrations/20261026031904_add_audit_log_via/migration.sql +2 -0
- package/prisma/migrations/20261029024626_add_oauth_and_jwks/migration.sql +205 -0
- package/prisma/migrations/20261029030321_default_empty_arrays_oauth/migration.sql +25 -0
- package/prisma/schema.prisma +186 -1
- package/bin/chunk-0a4ahz7r.js +0 -2
- package/bin/chunk-0awcpx0a.js +0 -3
- package/bin/chunk-0fbgfgxv.js +0 -12
- package/bin/chunk-0nnqha4f.js +0 -3
- package/bin/chunk-0tvggyy4.js +0 -1
- package/bin/chunk-113baw0m.js +0 -2
- package/bin/chunk-1dbjyarc.js +0 -2
- package/bin/chunk-1qre79kf.js +0 -1
- package/bin/chunk-23780yj6.js +0 -3
- package/bin/chunk-27v3yepb.js +0 -1
- package/bin/chunk-2rq3w8sg.js +0 -2
- package/bin/chunk-3fjgf7eb.js +0 -3
- package/bin/chunk-3pwwg1xm.js +0 -1
- package/bin/chunk-3sfb63fp.js +0 -2
- package/bin/chunk-4g4pxmef.js +0 -3
- package/bin/chunk-4yhvexzk.js +0 -5
- package/bin/chunk-58cbk6e8.js +0 -1
- package/bin/chunk-5m51b7af.js +0 -2
- package/bin/chunk-6bed0rz4.js +0 -1
- package/bin/chunk-6smn0q1n.js +0 -20
- package/bin/chunk-7bbsv8g0.js +0 -2
- package/bin/chunk-83bdgs2c.js +0 -1
- package/bin/chunk-86qtjd30.js +0 -11
- package/bin/chunk-8rekh4h9.js +0 -3
- package/bin/chunk-8sf2hf31.js +0 -2
- package/bin/chunk-9d3w678j.js +0 -1
- package/bin/chunk-9rcg8zgs.js +0 -42
- package/bin/chunk-a23q1kc4.js +0 -5
- package/bin/chunk-a6cdt85k.js +0 -2
- package/bin/chunk-a76h3ehe.js +0 -1
- package/bin/chunk-b1bkd2p4.js +0 -32
- package/bin/chunk-bf5m8f6t.js +0 -2
- package/bin/chunk-cf57fk11.js +0 -2
- package/bin/chunk-d4sbcvpa.js +0 -2
- package/bin/chunk-dzjmwat0.js +0 -14
- package/bin/chunk-eex8sjfs.js +0 -2
- package/bin/chunk-exmwerag.js +0 -18
- package/bin/chunk-f38xyahm.js +0 -1
- package/bin/chunk-fb1bes2h.js +0 -2
- package/bin/chunk-fbvak7q2.js +0 -1
- package/bin/chunk-g2ptqqm3.js +0 -3
- package/bin/chunk-ggwqxn95.js +0 -2
- package/bin/chunk-ghk54h71.js +0 -13
- package/bin/chunk-h9akn41s.js +0 -3
- package/bin/chunk-hdansxny.js +0 -2
- package/bin/chunk-hjzbw975.js +0 -2
- package/bin/chunk-jtkxeat4.js +0 -2
- package/bin/chunk-jw4g9628.js +0 -5
- package/bin/chunk-jxebakyq.js +0 -1
- package/bin/chunk-kfewyax2.js +0 -2
- package/bin/chunk-kk3m4za5.js +0 -1
- package/bin/chunk-m7tnj47b.js +0 -3
- package/bin/chunk-maw5ah8t.js +0 -3
- package/bin/chunk-nahdd2t9.js +0 -2
- package/bin/chunk-nv7tztvh.js +0 -129
- package/bin/chunk-nyjwdxyj.js +0 -3
- package/bin/chunk-p0yfxt5e.js +0 -54
- package/bin/chunk-q27qn367.js +0 -5
- package/bin/chunk-q36sdt2w.js +0 -2
- package/bin/chunk-qbj5pe8t.js +0 -1
- package/bin/chunk-qj0bxb1m.js +0 -2
- package/bin/chunk-qqkr6h07.js +0 -11
- package/bin/chunk-qyqc5j3a.css +0 -1
- package/bin/chunk-qzaf6bre.js +0 -2
- package/bin/chunk-r1e59gf0.js +0 -2
- package/bin/chunk-ra5csbkr.js +0 -2
- package/bin/chunk-rx9g95wk.js +0 -10
- package/bin/chunk-rxyy37wa.js +0 -4
- package/bin/chunk-scez7ppq.js +0 -3
- package/bin/chunk-t2a1vq34.js +0 -7
- package/bin/chunk-t879v3b7.js +0 -1
- package/bin/chunk-tjavzarz.js +0 -3
- package/bin/chunk-treyx8em.js +0 -2
- package/bin/chunk-v3z4z04s.js +0 -2
- package/bin/chunk-v3z63tpw.js +0 -2
- package/bin/chunk-v9bes1fv.js +0 -2
- package/bin/chunk-vmm9m3nv.js +0 -2
- package/bin/chunk-vvr8tnse.js +0 -211
- package/bin/chunk-w3stry4v.js +0 -1
- package/bin/chunk-wk0hk00z.js +0 -1
- package/bin/chunk-x4q082e6.js +0 -2
- package/bin/chunk-x6rf77jm.js +0 -16
- package/bin/chunk-x7dyj53k.js +0 -2
- package/bin/chunk-xcrd0y8v.js +0 -6
- package/bin/chunk-z0z0jn5h.js +0 -4
- package/bin/chunk-zasjhrwc.js +0 -2
- package/bin/chunk-zefds5gg.js +0 -1
- package/bin/chunk-zzzgk1d5.js +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Q,S,G,M,w,Z,Y,a,g,ie,X,ee,Tt,Je,R,z,K,qe,Mn,jt,Do,No,ps,Re,Ue,Ge,F,De,Ne,Fe,de,En,ur,Um,vA,jm,Cb,Sb,$m,Hm,Ke,Pw,Ya,Kw,Jw,a_,Mt,th,nx,_x,w_,Cx,kx,Rx,Mx,Ox,Px,Fl,pa,bd,lh,Ll,uC,vC,VC,cS,dS,IS,kS,RS,vp,OI,yT,bT,kT,MT,Dh,_0,Nh,p1,m1,Wc,xk,Nk,wo,Uk,Wk,Xk,ny,jl,Cd,Jc,ng,og,sg,Yc,Sd,Id,ig,ag,Td,LM,ZM,BM,UM,jM,Jn,gg,RO,MO,kd,My,zO,jO,qO,$O,HO,Se,xe,ke,ot,Ce,re,Ie,Pt,an,Yn,Eo,Md,j,qr,Zn,fe,Ve,Xe,et,tt,rt,be,Aa,ar,Fr,qt,Rg}from"./chunk-zarz3sqn.js";import{ec}from"./chunk-f6avg5qe.js";import{Zd,wa}from"./chunk-s1e4qy3q.js";import{_s}from"./chunk-ns33grgx.js";import"./chunk-q2bew2vc.js";import"./chunk-55h9ze53.js";import"./chunk-8mqbztj8.js";import{Jr}from"./chunk-q5vkxee3.js";import{il,lu}from"./chunk-96qpjght.js";import{ou,su}from"./chunk-tekwpkjf.js";import{al}from"./chunk-b5rhvzv9.js";import{uu}from"./chunk-7naa7tpn.js";import{gr}from"./chunk-pk406dgy.js";import{fu}from"./chunk-8fyg9dy4.js";import"./chunk-atfz7g7e.js";import"./chunk-257dcd2f.js";import"./chunk-ny1kbmxt.js";import"./chunk-fvx9k1dc.js";import{zo}from"./chunk-kvhf12b4.js";import"./chunk-qwpkcp8d.js";import{jo}from"./chunk-88jg9dq5.js";import{Zr}from"./chunk-v5cn90cf.js";Z();var bt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],it=z("folder-open",bt);var yt=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=z("list-filter",yt);Z();function Nt({ratio:t}){switch(t){case"16:9":return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return a("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return a("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return a("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return a("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return a("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function at(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:at(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function kt(){return{id:at(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var Ze=[{id:"dark",label:"Dark Slate",bg:"#1e293b",dot:"#475569"},{id:"black",label:"Black",bg:"#000000",dot:"#404040"},{id:"gray",label:"Slate Gray",bg:"#64748b",dot:"#cbd5e1"},{id:"white",label:"White",bg:"#ffffff",dot:"#94a3b8"},{id:"green",label:"Chroma Green",bg:"#059669",dot:"#047857"}],St={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function mt({open:t,onOpenChange:b,initialConfig:f,shareId:m,teamId:y,onSaveSuccess:x}){let D=ie(),[l,v]=w([]),[d,p]=w(null),[B,E]=w(null),[N,oe]=w("16:9"),[le,ce]=w("grid"),[ge,q]=w(!1),[ne,te]=w("new"),[se,O]=w(""),[U,V]=w(null),k=M(null),H=M(null),[J,ve]=w({w:0,h:0}),[_,A]=w(!1),s=Q((e)=>{if(H.current=e,!e)return;let i=()=>{let{clientWidth:C,clientHeight:h}=e;if(C<=0||h<=0)return;let P=St[N],Ye=C,Te=Ye/P;if(Te>h)Te=h,Ye=Te*P;ve({w:Math.round(Ye),h:Math.round(Te)})};i();let o=new ResizeObserver(i);return o.observe(e),()=>{o.disconnect(),H.current=null}},[N]),W=Pt((e)=>e.teamId),me=y||W,[Ee,ye]=w(!1),[L,he]=w({}),ae=M(null),ue=R.api.teams[":teamId"].files.$post,we=async(e,i)=>{let o=e.target.files?.[0];if(!o)return;if(o.size>1048576){if(j.error(uC()),ae.current)ae.current.value="";return}if(!me){j.error(bd());return}ye(!0);let C=URL.createObjectURL(o);he((h)=>({...h,[i]:C}));try{let h=await ue({param:{teamId:me},form:{file:o}});if(!h.ok)throw Error(bd());let P=await h.json();I(i,{imageAssetKey:P.key,imageAssetUrl:P.url})}catch(h){let P=h instanceof Error?h.message:bd();j.error(P)}finally{if(ye(!1),ae.current)ae.current.value=""}};S(()=>{if(t){if(f?.blocks&&f.blocks.length>0)v(f.blocks),p(f.blocks[0].id);else{let e=dt();v([e]),p(e.id)}E(null)}},[t,f]);let{data:T=[]}=X({queryKey:["watermark-templates",y],queryFn:async()=>{let e=await R.api["watermark-templates"].$get({query:y?{teamId:y}:{}});if(!e.ok)return[];return await e.json()},enabled:t}),_e=R.api.shares[":shareId"].watermark.$put,{mutate:pe,isPending:Ae}=ee({mutationFn:async(e)=>{let i=await _e({param:{shareId:m},json:{enabled:!0,config:e}});if(!i.ok){let o=await i.json().catch(()=>null);throw Error(o?.error||pa())}return await i.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["share",m]}),D.invalidateQueries({queryKey:["shares"]}),j.success(HO()),b(!1),x?.()},onError:(e)=>{j.error(e.message||pa())}}),We=R.api["watermark-templates"].$post,{mutate:ze,isPending:Le}=ee({mutationFn:async({name:e,config:i})=>{let o=await We({json:{name:e,teamId:y||void 0,config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:(e)=>{D.invalidateQueries({queryKey:["watermark-templates"]}),E(e.id),q(!1),j.success(BM())},onError:()=>{j.error(pa())}}),$e=R.api["watermark-templates"][":templateId"].$put,{mutate:Me,isPending:Oe}=ee({mutationFn:async({templateId:e,config:i})=>{let o=await $e({param:{templateId:e},json:{config:i}});if(!o.ok)throw Error(pa());return await o.json()},onSuccess:()=>{D.invalidateQueries({queryKey:["watermark-templates"]}),q(!1),j.success(UM())},onError:()=>{j.error(pa())}}),r=R.api["watermark-templates"][":templateId"].$delete,{mutate:c}=ee({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Fl())},onSuccess:(e,i)=>{if(D.invalidateQueries({queryKey:["watermark-templates"]}),B===i)E(null);j.success(LM())},onError:()=>{j.error(Fl())}}),u=l.findIndex((e)=>e.id===d),n=u>=0?l[u]:null,Be=()=>{let e=dt();v((i)=>[...i,e]),p(e.id)},pt=()=>{let e=kt();v((i)=>[...i,e]),p(e.id)},nt=(e)=>{if(!e)return;v((i)=>{let o=i.filter((C)=>C.id!==e);if(d===e)p(o.length>0?o[Math.max(0,u-1)].id:null);return o})},I=(e,i)=>{v((o)=>o.map((C)=>C.id===e?{...C,...i}:C))},ft=()=>{if(l.length===0)return;let e=(u-1+l.length)%l.length;p(l[e].id)},gt=()=>{if(l.length===0)return;let e=(u+1)%l.length;p(l[e].id)},xt=(e,i)=>{e.stopPropagation(),p(i),A(!0)},Qe=Q((e)=>{if(!_||!d||!k.current)return;let i=k.current.getBoundingClientRect(),o=(e.clientX-i.left)/i.width,C=(e.clientY-i.top)/i.height,h=Math.max(0,Math.min(1,Math.round(o*100)/100)),P=Math.max(0,Math.min(1,Math.round(C*100)/100));I(d,{x:h,y:P})},[_,d]),He=Q(()=>{A(!1)},[]);S(()=>{if(_)window.addEventListener("mousemove",Qe),window.addEventListener("mouseup",He);return()=>{window.removeEventListener("mousemove",Qe),window.removeEventListener("mouseup",He)}},[_,Qe,He]),S(()=>{let e=(i)=>{if(!t||!d)return;let o=i.target?.tagName?.toLowerCase();if(o==="input"||o==="textarea"||o==="select")return;if(i.key==="Delete"||i.key==="Backspace")i.preventDefault(),nt(d)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,d,u]);let vt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let i=e.config.blocks.map((o)=>({...o,id:at()}));v(i),p(i[0].id),E(e.id)}},ht=()=>{if(l.length===0){j.error(bT());return}pe({blocks:l})},wt=()=>{if(ne==="new"){if(!se.trim()){j.error(w_());return}ze({name:se.trim(),config:{blocks:l}})}else{let e=U||B;if(!e){j.error(ny());return}Me({templateId:e,config:{blocks:l}})}};return g(Y,{children:[a(Se,{open:t,onOpenChange:b,children:g(xe,{showCloseButton:!1,className:"sm:max-w-[1400px] max-w-[95vw] w-[95vw] h-[88vh] flex flex-col p-0 gap-0 overflow-hidden",onPointerDownOutside:(e)=>e.preventDefault(),children:[g("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[a("div",{className:"flex items-center gap-3",children:a(Ce,{className:"text-base font-semibold",children:jO()})}),g("div",{className:"flex items-center gap-2",children:[g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[a(it,{className:"h-4 w-4 text-muted-foreground"}),qO()]})}),g(Fe,{align:"end",className:"w-56",children:[a(En,{className:"text-xs font-semibold text-muted-foreground",children:RS()}),T.length===0?a("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:yT()}):T.map((e)=>g(de,{onClick:()=>vt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[a("span",{className:"truncate flex-1",children:e.name}),B===e.id&&a(qe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(i)=>{i.stopPropagation(),c(e.id)},children:a(Ue,{className:"h-3 w-3"})})]},e.id)),a(ur,{}),g(de,{onClick:()=>{te("new"),O(""),q(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(Re,{className:"h-3.5 w-3.5 text-primary"}),a_()]}),T.length>0&&g(de,{onClick:()=>{te("overwrite"),V(B||T[0].id),q(!0)},className:"text-xs gap-2 cursor-pointer",children:[a(al,{className:"h-3.5 w-3.5 text-muted-foreground"}),_0()]})]})]}),a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>b(!1),children:Ke()}),g(F,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ae,onClick:ht,children:[a(al,{className:"h-3.5 w-3.5"}),Uk()]})]})]}),g("div",{className:"flex-1 flex overflow-hidden",children:[g("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[g("div",{className:"flex items-center justify-between mb-3",children:[a("div",{className:"flex items-center gap-1 bg-muted/60 p-1 rounded-md border border-border/60",children:["16:9","9:16","4:3","3:4","1:1"].map((e)=>g(F,{variant:N===e?"secondary":"ghost",size:"sm",className:Pe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",N===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>oe(e),children:[a(Nt,{ratio:e}),a("span",{children:e})]},e))}),a("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:Ze.map((e)=>a("button",{type:"button",onClick:()=>ce(e.id),style:{backgroundColor:e.bg},className:Pe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",le===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),a("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=Ze.find((o)=>o.id===le)||Ze[0],i=J.w>0&&J.h>0;return a("div",{ref:k,onClick:()=>p(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...i?{width:J.w,height:J.h}:{}},className:Pe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",N==="16:9"&&"aspect-[16/9] w-full max-h-full",N==="9:16"&&"aspect-[9/16] h-full max-w-full",N==="4:3"&&"aspect-[4/3] w-full max-h-full",N==="3:4"&&"aspect-[3/4] h-full max-w-full",N==="1:1"&&"aspect-square h-full max-w-full"),children:l.map((o)=>{let C=o.id===d,h=o.size*(J.w||640);return a("div",{onMouseDown:(P)=>xt(P,o.id),onClick:(P)=>{P.stopPropagation(),p(o.id)},style:{left:`${o.x*100}%`,top:`${o.y*100}%`,transform:`translate(-50%, -50%) rotate(${o.rotation}deg)`,opacity:o.opacity},className:Pe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",C?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:o.type==="text"?a("span",{style:{fontSize:`${h}px`,color:o.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:o.text||"Text"}):a("div",{style:{width:`${h}px`,height:`${h}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:L[o.id]||o.imageAssetUrl?a("img",{src:L[o.id]||o.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):a(Do,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},o.id)})})})()})]}),g("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[a("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:g("div",{className:"flex items-center gap-2",children:[a(No,{className:"h-4 w-4 text-muted-foreground"}),a("span",{className:"text-xs font-semibold",children:My()})]})}),g("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[g("div",{className:"flex items-center gap-1",children:[a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:ft,children:a(Mn,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:a(F,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:l.length===0?"0 / 0":`${u+1} / ${l.length}`})}),a(Fe,{align:"start",className:"w-48",children:l.map((e,i)=>g(de,{onClick:()=>p(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[g("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?a(ec,{className:"h-3.5 w-3.5 text-muted-foreground"}):a(Do,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),g("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",i+1]})]},e.id))})]}),a(F,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:l.length<=1,onClick:gt,children:a(jt,{className:"h-4 w-4"})})]}),g("div",{className:"flex items-center gap-1",children:[n&&a(F,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:Mt(),onClick:()=>nt(n.id),children:a(Ue,{className:"h-4 w-4"})}),g(De,{modal:!1,children:[a(Ne,{asChild:!0,children:g(F,{size:"sm",className:"h-7 text-xs gap-1",children:[a(Re,{className:"h-3.5 w-3.5"}),Um()]})}),g(Fe,{align:"end",children:[g(de,{onClick:Be,className:"text-xs gap-2 cursor-pointer",children:[a(ec,{className:"h-3.5 w-3.5"}),jm()]}),g(de,{onClick:pt,className:"text-xs gap-2 cursor-pointer",children:[a(Do,{className:"h-3.5 w-3.5"}),vA()]})]})]})]})]}),a(Ie,{className:"flex-1 min-h-0 p-4",children:n?g("div",{className:"space-y-5 text-xs",children:[g("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[g("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[n.type==="text"?a(ec,{className:"h-4 w-4 text-primary"}):a(Do,{className:"h-4 w-4 text-primary"}),n.type==="text"?jm():vA()]}),g("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",n.id.slice(0,6)]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs",children:jM()}),a(re,{type:"text",value:n.text,onChange:(e)=>I(n.id,{text:e.target.value}),className:"text-xs h-8"})]}),n.type==="image"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:cS()}),n.imageAssetKey&&g("button",{type:"button",onClick:()=>I(n.id,{imageAssetKey:"",imageAssetUrl:void 0}),className:"text-xs text-muted-foreground hover:text-destructive flex items-center gap-1 font-medium transition-colors cursor-pointer",children:[a(Ge,{className:"w-3.5 h-3.5"}),Wc?Wc():"Remove"]})]}),a("input",{type:"file",ref:ae,className:"hidden",accept:"image/*",onChange:(e)=>we(e,n.id)}),g("div",{onClick:()=>ae.current?.click(),className:"relative aspect-square w-full rounded-xl border border-dashed border-border flex items-center justify-center cursor-pointer overflow-hidden group shadow-inner bg-muted/20 hover:border-primary/50 hover:bg-muted/40 transition-all p-2",children:[Ee&&a("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:g("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[a(K,{className:"w-4 h-4 animate-spin text-primary"}),a("span",{className:"text-xs font-semibold",children:kd()})]})}),L[n.id]||n.imageAssetUrl?g(Y,{children:[a("img",{src:L[n.id]||n.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),g("div",{className:"absolute inset-0 bg-black/45 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center gap-1 text-white z-10",children:[a(zo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),a("span",{className:"text-xs font-semibold",children:gg()})]})]}):g("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[a("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:a(zo,{className:"w-4 h-4 text-muted-foreground"})}),g("div",{children:[a("p",{className:"text-xs font-medium text-foreground",children:RO()}),a("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:MO()})]})]})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:n.type==="text"?vC():dS()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.size*100),"%"]})]}),g("div",{className:"flex items-center gap-3",children:[a(_s,{min:n.type==="text"?0.01:0.02,max:n.type==="text"?0.12:0.5,step:0.005,value:[n.size],onValueChange:([e])=>I(n.id,{size:e}),className:"flex-1"}),a(re,{type:"number",min:1,max:100,value:Math.round(n.size*100),onChange:(e)=>I(n.id,{size:Math.min(1,Math.max(0.001,Number(e.target.value)/100))}),className:"w-16 h-7 text-xs font-mono text-right"})]})]}),n.type==="text"&&g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Pw()}),a("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:n.color})]}),g("div",{className:"flex items-center gap-2",children:[a("input",{type:"color",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),a(re,{type:"text",value:n.color,onChange:(e)=>I(n.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),a("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>a("button",{type:"button",onClick:()=>I(n.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:kT()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.opacity*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.opacity],onValueChange:([e])=>I(n.id,{opacity:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Nk()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[n.rotation,"°"]})]}),a(_s,{min:-180,max:180,step:1,value:[n.rotation],onValueChange:([e])=>I(n.id,{rotation:e})}),a("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>g(F,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>I(n.id,{rotation:e}),children:[e,"°"]},e))})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:p1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.x*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.x],onValueChange:([e])=>I(n.id,{x:e})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:m1()}),g("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(n.y*100),"%"]})]}),a(_s,{min:0,max:1,step:0.01,value:[n.y],onValueChange:([e])=>I(n.id,{y:e})})]})]}):g("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[a("p",{children:Xk()}),g(F,{size:"sm",variant:"outline",onClick:Be,children:[a(Re,{className:"h-3.5 w-3.5 mr-1"}),jm()]})]})})]})]})]})}),a(Se,{open:ge,onOpenChange:q,children:g(xe,{className:"max-w-md",children:[a(ke,{children:a(Ce,{className:"text-sm font-semibold",children:ne==="new"?a_():_0()})}),a("div",{className:"py-3 space-y-4 text-xs",children:ne==="new"?g("div",{className:"space-y-2",children:[a(fe,{children:ZM()}),a(re,{type:"text",value:se,onChange:(e)=>O(e.target.value),placeholder:w_(),className:"text-xs"})]}):g("div",{className:"space-y-2",children:[a(fe,{children:ny()}),a("select",{value:U||"",onChange:(e)=>V(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:T.map((e)=>a("option",{value:e.id,children:e.name},e.id))})]})}),g(ot,{children:[a(F,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>q(!1),children:Ke()}),a(F,{size:"sm",className:"text-xs",disabled:Le||Oe,onClick:wt,children:Ya()})]})]})})]})}function Pe(...t){return t.filter(Boolean).join(" ")}Z();function ut({shareLink:t,viewMode:b,onViewModeChange:f,defaultSortOrder:m,onSortOrderChange:y}){let x=ie(),[D,l]=w(t.password||""),[v,d]=w(t.expireAt?new Date(t.expireAt):void 0),[p,B]=w(!1);S(()=>{l(t.password||"")},[t.password]);let[E,N]=w(t.hasPassword),[oe,le]=w(!!t.expireAt),{data:ce,refetch:ge}=X({queryKey:["share-watermark",t.id],queryFn:async()=>{let s=await R.api.shares[":shareId"].watermark.$get({param:{shareId:t.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||t.watermarkStatus)==="processing"?3000:!1}),q=R.api.shares[":shareId"].watermark.$put,{mutate:ne}=ee({mutationFn:async()=>{let s=await q({param:{shareId:t.id},json:{enabled:!1}});if(!s.ok)throw Error(pa());return await s.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["share-watermark",t.id]}),j.success(zO())}}),te=ce?.watermarkStatus??t.watermarkStatus??(t.watermarkConfigId?"ready":"disabled"),se=ce?.watermarkConfig?.config??t.watermarkConfig?.config??null,O=se!==null&&te!=="disabled",{data:U}=X({queryKey:["fields",t.projectId],queryFn:async()=>{let s=await R.api.projects[":projectId"].fields.$get({param:{projectId:t.projectId}});if(!s.ok)throw Error(kx());return await s.json()},enabled:!!t.projectId}),V=R.api.shares[":shareId"].$put,{mutate:k}=ee({mutationFn:async(s)=>{let W=await V({param:{shareId:t.id},json:s});if(!W.ok)throw Error(pa());return await W.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["shares",t.projectId]}),x.invalidateQueries({queryKey:["share",t.id]}),j.success(jl())}}),H=`${window.location.origin}/share/${t.id}`,J=async(s)=>{if(await jo(s))j.success(Kw())},ve=(s)=>{let W=t.fieldVisibility||{},me={...W,[s]:!W[s]};k({fieldVisibility:me})},_="index",A="asc";if(m){let s=m.split(":");_=s[0],A=s[1]||"asc"}return g("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[a("div",{className:"flex-1 overflow-y-auto",children:g("div",{className:"p-4 space-y-6",children:[g("div",{className:"space-y-4",children:[g("div",{className:"flex items-center justify-between",children:[a("h3",{className:"text-sm font-medium",children:IS()}),a(Ve,{checked:!t.isDisabled,onCheckedChange:(s)=>k({isDisabled:!s})})]}),g("div",{className:"relative w-full",children:[a(re,{value:H,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),a(F,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>J(H),children:a(Zr,{className:"h-4 w-4"})})]})]}),g("div",{className:"space-y-1",children:[a(je,{title:Wk(),icon:a(su,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Nh()}),a(Ve,{checked:E,onCheckedChange:(s)=>{if(N(s),!s)k({password:null})}})]}),E&&g("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[a(re,{type:"text",value:D,onChange:(s)=>l(s.target.value),placeholder:_x(),className:"text-xs"}),a(F,{size:"sm",onClick:()=>k({password:D}),children:wo()})]})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Cx()}),a(Ve,{checked:oe,onCheckedChange:(s)=>{if(le(s),!s)d(void 0),k({expireAt:null})}})]}),oe&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:a(Aa,{value:v,onChange:(s)=>{d(s),k({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),g("div",{className:"space-y-2",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:Cb()}),a(Ve,{checked:t.allowDownload,onCheckedChange:(s)=>k({allowDownload:s})})]}),a("p",{className:"text-xs text-muted-foreground",children:Sb()})]}),g("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:My()}),a(Ve,{checked:O,disabled:te==="processing",onCheckedChange:(s)=>{if(!s)ne();else B(!0)}})]}),O&&te==="processing"&&g("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[a(K,{className:"h-3.5 w-3.5 animate-spin"}),a("span",{children:$O()})]}),O&&te!=="processing"&&a(F,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>B(!0),children:nx()})]})]})}),a(je,{title:$m(),icon:a(ou,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[g(F,{variant:b==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("card"),children:[a(No,{className:"h-4 w-4"}),VC()]}),g(F,{variant:b==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>f("list"),children:[a(ps,{className:"h-4 w-4"}),kS()]})]})}),a(je,{title:Ll(),icon:a(lt,{className:"h-4 w-4"}),children:a("div",{className:"p-3 space-y-3 pt-2",children:U?.map((s)=>g("div",{className:"flex items-center justify-between",children:[a(fe,{className:"text-xs",children:s.config?.name}),a(Ve,{checked:t.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>ve(s.id)})]},s.id))})}),a(je,{title:Jc(),icon:a(fu,{className:"h-4 w-4"}),children:g("div",{className:"p-3 space-y-4 pt-2",children:[g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:lh()}),g(Xe,{value:_,onValueChange:(s)=>{if(s==="index")y(null);else y(`${s}:${A}`)},children:[a(tt,{className:"w-full text-xs h-9",children:a(et,{})}),g(rt,{children:[a(be,{value:"index",children:ng()}),a(be,{value:"name",children:Yc()}),a(be,{value:"createdAt",children:og()}),a(be,{value:"size",children:ig()})]})]})]}),g("div",{className:"space-y-2",children:[a(fe,{className:"text-xs text-muted-foreground",children:Dh()}),g(F,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:_==="index",onClick:()=>{y(`${_}:${A==="asc"?"desc":"asc"}`)},children:[a("span",{children:_==="name"?A==="asc"?Cd():Td():_==="createdAt"?A==="asc"?Id():Sd():_==="size"?A==="asc"?ag():sg():A==="asc"?Hm():th()}),a(Zd,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),g("div",{className:"p-4 border-t border-border space-y-2",children:[g(F,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(H,"_blank"),children:[a(uu,{className:"h-4 w-4 mr-2"}),MT()]}),g(F,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>J(H),children:[a(Zr,{className:"h-4 w-4 mr-2"}),Jw()]})]}),a(mt,{open:p,onOpenChange:B,initialConfig:se,shareId:t.id,onSaveSuccess:()=>{ge(),x.invalidateQueries({queryKey:["share",t.id]}),x.invalidateQueries({queryKey:["shares",t.projectId]})}})]})}function je({title:t,icon:b,children:f}){let[m,y]=w(!1);return g("div",{className:"border-b border-border last:border-0",children:[g("button",{onClick:()=>y(!m),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[g("div",{className:"flex items-center gap-3",children:[b,a("span",{className:"text-sm font-medium",children:t})]}),a(jt,{className:_t("h-4 w-4 transition-transform",m&&"rotate-90")})]}),m&&f&&a("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:f})]})}function _t(...t){return t.filter(Boolean).join(" ")}function st({teamId:t,projectId:b,projectName:f,shareId:m,rootFolderId:y}){let x=ie(),{fetchMetadata:D}=Fr();S(()=>{if(t)D(t)},[t,D]);let{data:l}=X({queryKey:["share",m],queryFn:async()=>{let r=await R.api.shares[":shareId"].$get({param:{shareId:m}});if(!r.ok)throw Error(Ox());return await r.json()}}),v=l?.rootFolderId,[d,p]=w(null),[B,E]=w([]);S(()=>{if(v)p(v),E([]),T(new Set)},[v,m]);let N=Zn((r)=>r.setProjectState),oe=Zn((r)=>r.clearProjectState),le=(r)=>{if(r===d)return;if(r===v)p(v),E([]);else{let c=B.findIndex((u)=>u.id===r);if(c!==-1)p(r),E(B.slice(c+1))}T(new Set)},[ce,ge]=w(240),[q,ne]=w(360),{shareConfigLeftSidebarCollapsed:te,shareConfigRightSidebarCollapsed:se}=ar(),O=l?.defaultSortOrder||null,U,V;if(O){let r=O.split(":");U=r[0],V=r[1]}let k=l?.viewMode??"card",{data:H,fetchNextPage:J,hasNextPage:ve,isFetchingNextPage:_,isLoading:A}=Tt({queryKey:["folder-children",t,d,"folder",U,V],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"folder",after:r,sort:U,order:V}});if(!c.ok)throw Error(Mx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:W,hasNextPage:me,isFetchingNextPage:Ee,isLoading:ye}=Tt({queryKey:["folder-children",t,d,"file",U,V],queryFn:async({pageParam:r})=>{let c=await R.api.folders[":folderId"].children.$get({param:{folderId:d},query:{assetType:"file",after:r,sort:U,order:V}});if(!c.ok)throw Error(Rx());return await c.json()},enabled:!!d,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),L=G(()=>H?.pages.flatMap((r)=>r.data??[])??[],[H]),he=G(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);S(()=>{if(l)N({teamId:t,projectId:b,projectName:f,ancestorFolders:B,currentAsset:{name:d===v?l.name:L.find((r)=>r.id===d)?.name||l.name,type:"folder"},isRootFolder:!1,shareId:m,onFolderClick:le});return()=>oe()},[t,b,f,B,d,v,l,m,L,N,oe]);let[ae,ue]=w(null),[we,T]=w(new Set),_e=()=>{T(new Set),ue(null)},{dragState:pe,handleDragStart:Ae,handleDragEnd:We}=lu({teamId:t,projectId:b,assetId:d||"",folders:L,files:he,selectedIds:we,onClearSelection:_e}),ze=R.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Le}=ee({mutationFn:async(r)=>{if(!(await ze({param:{shareId:m,assetId:r}})).ok)throw Error(Px())},onSuccess:()=>{x.invalidateQueries({queryKey:["folder-children",t,d]}),j.success(xk())}}),$e=R.api.shares[":shareId"].$put,{mutate:Me}=ee({mutationFn:async(r)=>{let c=await $e({param:{shareId:m},json:r});if(!c.ok)throw Error(pa());return await c.json()},onSuccess:()=>{x.invalidateQueries({queryKey:["share",m]}),j.success(jl())}}),Oe=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let c=d===v?l?.name||"":L.find((u)=>u.id===d)?.name||Jn();E((u)=>[{id:d,name:c},...u]),p(r.id),T(new Set)}};if(!l)return a("div",{children:vp()});return g(Eo,{modifiers:[il.configure({anchor:{x:0,y:0}})],sensors:[Yn.configure({activationConstraints:[new an.Distance({value:10})]})],onDragStart:Ae,onDragEnd:We,children:[a("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:g("div",{className:"flex flex-1 overflow-hidden relative",children:[!te&&g(Y,{children:[a("div",{className:"bg-background",style:{width:ce},children:a(qr,{teamId:t,projectId:b,projectName:f,rootFolderId:y,dragState:pe})}),a(Jr,{onResize:(r)=>ge((c)=>Math.max(180,Math.min(400,c+r)))})]}),a(wa,{teamId:t,projectId:b,assetId:d||"",folders:L,files:he,selectedItem:ae,selectedIds:we,onItemSelect:(r,c)=>{if(c.metaKey||c.ctrlKey){let u=new Set(we);if(u.has(r.id)){if(u.delete(r.id),T(u),ae?.id===r.id){let n=[...L,...he].find((Be)=>u.has(Be.id));ue(n||null)}}else u.add(r.id),T(u),ue(r)}else T(new Set([r.id])),ue(r)},onItemDoubleClick:Oe,onSaveField:()=>{},displayStyle:k,onClearSelection:_e,fetchNextFoldersPage:J,hasNextFoldersPage:ve,isFetchingNextFoldersPage:_,fetchNextFilesPage:W,hasNextFilesPage:me,isFetchingNextFilesPage:Ee,isLoading:A||ye,filterConditions:[],onFilterChange:()=>{},dragState:pe,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((c)=>Le(c.id))},fieldVisibility:l.fieldVisibility}),!se&&g(Y,{children:[a(Jr,{onResize:(r)=>ne((c)=>Math.max(240,Math.min(600,c-r)))}),a("div",{style:{width:q},className:"flex-shrink-0 h-full",children:a(ut,{shareLink:l,viewMode:k,onViewModeChange:(r)=>Me({viewMode:r}),defaultSortOrder:O,onSortOrderChange:(r)=>Me({defaultSortOrder:r})})})]})]})}),a(Md,{children:pe?.isActive?a("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:OI({count:pe.itemCount})}):null})]})}Z();function It(){let{projectId:t,shareId:b}=Ct.useParams(),{teamId:f,ensureTeamIdForProject:m}=Pt();S(()=>{m(t)},[t,m]);let{data:y}=gr(Rg(t)),x=y?.rootFolder,{data:D}=X({queryKey:["folders",x],queryFn:async()=>{let l=await R.api.folders[":folderId"].$get({param:{folderId:x}});if(!l.ok)throw Error("Failed to fetch folder");return await l.json()},enabled:!!x});if(!f||!x||!D)return a(qt,{});return a(st,{teamId:f,projectId:t,projectName:y.name??"",shareId:b,rootFolderId:x})}var Ct=Je("/projects/$projectId/shares/$shareId")({component:It});export{Ct as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{J,Q,S,G,M,w,Mo,Z,Y,a,g,ie,Lf,Zf,jr,cd,Ga,Yo,ir,ks,Bf,Uf,zf,jf,ud,qf,X,ee,Tt,Je,R,z,wr,K,tn,$t,qe,Be,cr,On,rr,Rs,Ge,B,Ut,Le,pe,Gt,Vr,er,we,Cr,F,$e,He,Qe,$y,Hy,Bm,Ab,vb,bb,zb,Qm,Kb,XA,Ke,xw,Tw,kw,Ya,s_,cE,cp,_d,c_,Mi,Ms,S_,zx,I_,dh,mC,hC,gC,AC,rS,z_,yS,bI,wI,Eh,eT,kh,Rh,mT,wT,IT,VT,g0,xd,s1,S0,Ip,L0,z1,q1,Bh,H1,V1,B0,W1,J1,U0,Y1,ek,Pp,Dp,Np,Kc,Hh,lk,ck,uk,dk,Fp,yk,Pi,Pk,Vk,Jk,uR,eg,fR,ER,xR,SR,IR,TR,kR,ay,RR,ly,py,oM,sM,iM,TM,gy,_y,kM,by,zp,OM,FM,JM,nO,Sy,Jn,pg,SO,OO,PO,Rd,BO,Ag,eP,_t,yt,vt,bt,wt,Et,xt,Ct,Se,xe,ke,Ce,Ot,re,Ie,Vt,j,$l,Hl,tu,nn,vg,co,uo,Wr,gn,ve,pt,mt,ht,Sr,on,rm,lt,Nt,Ft,Ht,St}from"./chunk-zarz3sqn.js";import{os,Lr}from"./chunk-q2bew2vc.js";import{_u}from"./chunk-zezje74z.js";import{Li,eo,gs,iu,Vl,ya,au}from"./chunk-q8w4mbw4.js";import"./chunk-hpbn0k9n.js";import{Bn,Un,zn,Tr,ft,ct}from"./chunk-576nj64j.js";import"./chunk-8yjsmr7g.js";import{Uo}from"./chunk-atfz7g7e.js";import{yu}from"./chunk-91rb0jpb.js";import{jn}from"./chunk-fvx9k1dc.js";import{Zr}from"./chunk-v5cn90cf.js";Z();function de(e,t){let s=new Set(t);return e.filter((i)=>!s.has(i))}var me=class extends Yo{#r;#e;#o;#a;#t;#s;#i;#n;#l;#d=[];constructor(e,t,s){super();this.#r=e,this.#a=s,this.#o=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){if(this.listeners.size===1)this.#t.forEach((e)=>{e.subscribe((t)=>{this.#p(e,t)})})}onUnsubscribe(){if(!this.listeners.size)this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach((e)=>{e.destroy()})}setQueries(e,t){this.#o=e,this.#a=t,ir.batch(()=>{let s=this.#t,i=this.#u(this.#o);i.forEach((p)=>p.observer.setOptions(p.defaultedQueryOptions));let n=i.map((p)=>p.observer),r=n.map((p)=>p.getCurrentResult()),c=s.length!==n.length,u=n.some((p,b)=>p!==s[b]),f=c||u,v=f?!0:r.some((p,b)=>{let h=this.#e[b];return!h||!Ga(p,h)});if(!f&&!v)return;if(f)this.#d=i,this.#t=n;if(this.#e=r,!this.hasListeners())return;if(f)de(s,n).forEach((p)=>{p.destroy()}),de(n,s).forEach((p)=>{p.subscribe((b)=>{this.#p(p,b)})});this.#f()})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map((e)=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){let s=this.#u(e),i=s.map((r)=>r.observer.getOptimisticResult(r.defaultedQueryOptions)),n=s.map((r)=>r.defaultedQueryOptions.queryHash);return[i,(r)=>this.#c(r??i,t,n),()=>this.#m(i,s)]}#m(e,t){let s=new Set;return t.map((i,n)=>{let r=e[n];return!i.defaultedQueryOptions.notifyOnChangeProps?i.observer.trackResult(r,(c)=>{if(!s.has(c))s.add(c),t.forEach((u)=>{u.observer.trackProp(c)})}):r})}#c(e,t,s){if(t){let i=this.#l,n=s!==void 0&&i!==void 0&&(i.length!==s.length||s.some((r,c)=>r!==i[c]));if(this.#e!==this.#n||n||t!==this.#i){if(this.#i=t,this.#n=this.#e,s!==void 0)this.#l=s;this.#s=cd(this.#s,t(e))}return this.#s}return e}#g(){return!this.#a?.combine||this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#u(e){let t=new Map;this.#t.forEach((i)=>{let n=i.options.queryHash;if(!n)return;let r=t.get(n);if(r)r.push(i);else t.set(n,[i])});let s=[];return e.forEach((i)=>{let n=this.#r.defaultQueryOptions(i),r=t.get(n.queryHash)?.shift()??new ks(this.#r,n);s.push({defaultedQueryOptions:n,observer:r})}),s}#p(e,t){let s=this.#t.indexOf(e);if(s!==-1)this.#e=this.#e.slice(),this.#e[s]=t,this.#f()}#f(){if(this.hasListeners()){let e=this.#g(),t=this.#s,s=e?t:this.#c(this.#m(this.#e,this.#d),this.#a?.combine);if(e||t!==s)ir.batch(()=>{this.listeners.forEach((i)=>{i(this.#e)})})}}};Z();function ce({queries:e,...t},s){let i=ie(s),n=Lf(),r=Zf(),c=t.subscribed!==!1,u=G(()=>e.map((m)=>{let x=i.defaultQueryOptions(m);return x._optimisticResults=n?"isRestoring":c?"optimistic":void 0,x}),[e,i,n,c]);u.forEach((m)=>{jf(m);let x=i.getQueryCache().get(m.queryHash);Bf(m,r,x)}),Uf(r);let[f]=w(()=>new me(i,u,t)),[v,p,b]=f.getOptimisticResult(u,t.combine),h=!n&&c;Mo(Q((m)=>h?f.subscribe(ir.batchCalls(m)):jr,[f,h]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),S(()=>{f.setQueries(u,t)},[u,t,f]);let l=v.some((m,x)=>ud(u[x],m))?v.flatMap((m,x)=>{let T=u[x];if(T&&ud(T,m)){let k=new ks(i,T);return qf(T,k,r)}return[]}):[];if(l.length>0)throw Promise.all(l);let C=v.find((m,x)=>{let T=u[x];return T&&zf({result:m,errorResetBoundary:r,throwOnError:T.throwOnError,query:i.getQueryCache().get(T.queryHash),suspense:T.suspense})});if(C)throw C.error;return p(b())}Z();Z();var je=Object.defineProperty,O=(e,t)=>je(e,"name",{value:t,configurable:!0}),se="Collapsible",[Fe,da]=Ut(se),[We,oe]=Fe(se),ze=J(O(function(t,s){let{__scopeCollapsible:i,open:n,defaultOpen:r,disabled:c,onOpenChange:u,...f}=t,[v,p]=er({prop:n,defaultProp:r??!1,onChange:u,caller:se});return a(We,{scope:i,disabled:c,contentId:Vr(),open:v,onOpenToggle:Q(()=>p((b)=>!b),[p]),children:a(we.div,{"data-state":te(v),"data-disabled":c?"":void 0,...f,ref:s})})},"Collapsible")),Ue="CollapsibleTrigger",Ve=J(O(function(t,s){let{__scopeCollapsible:i,...n}=t,r=oe(Ue,i);return a(we.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":te(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...n,ref:s,onClick:pe(t.onClick,r.onOpenToggle)})},"CollapsibleTrigger")),ue="CollapsibleContent",Xe=J(O(function(t,s){let{forceMount:i,...n}=t,r=oe(ue,t.__scopeCollapsible);return a(Cr,{present:i||r.open,children:({present:c})=>a(Ye,{...n,ref:s,present:c})})},"CollapsibleContent")),Ye=J(O(function(t,s){let{__scopeCollapsible:i,present:n,children:r,...c}=t,u=oe(ue,i),[f,v]=w(n),p=M(null),b=Le(s,p),h=M(0),l=h.current,C=M(0),m=C.current,x=u.open||f,T=M(x),k=M(void 0);return S(()=>{let _=requestAnimationFrame(()=>T.current=!1);return()=>cancelAnimationFrame(_)},[]),Gt(()=>{let _=p.current;if(_){k.current=k.current||{transitionDuration:_.style.transitionDuration,animationName:_.style.animationName},_.style.transitionDuration="0s",_.style.animationName="none";let q=_.getBoundingClientRect();if(h.current=q.height,C.current=q.width,!T.current)_.style.transitionDuration=k.current.transitionDuration,_.style.animationName=k.current.animationName;v(n)}},[u.open,n]),a(we.div,{"data-state":te(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!x,...c,ref:b,style:{["--radix-collapsible-content-height"]:l?`${l}px`:void 0,["--radix-collapsible-content-width"]:m?`${m}px`:void 0,...t.style},children:x&&r})},"CollapsibleContentImpl"));function te(e){return e?"open":"closed"}O(te,"getState");var Ze=ze;var tt=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],fe=z("chart-no-axes-column",tt);var at=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],P=z("funnel",at);var st=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ge=z("eye",st);var rt=[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]],W=z("messages-square",rt);var ot=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],be=z("rotate-cw",ot);var it=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ae=z("workflow",it);function he({teamId:e}){let[t,s]=w("team"),[i,n]=w("1h"),{data:r,isLoading:c}=X({queryKey:["teams",e,"ai-usage",i,"team"],queryFn:async()=>{let m=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i}});if(!m.ok)throw Error("Failed to fetch team AI usage");return await m.json()},enabled:!!e&&t==="team"}),{data:u,isLoading:f}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let m=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!m.ok)throw Error("Failed to fetch team members");return await m.json()},enabled:!!e&&t==="members"}),v=ce({queries:(u||[]).map((m)=>({queryKey:["teams",e,"ai-usage",i,m.id],queryFn:async()=>{let x=await R.api.teams[":teamId"]["ai-usage"].$get({param:{teamId:e},query:{timeframe:i,userId:m.id}});if(!x.ok)throw Error(`Failed to fetch AI usage for member ${m.id}`);return await x.json()},enabled:!!e&&t==="members"}))}),p=f||v.some((m)=>m.isLoading),b=(m)=>{if(!m)return"U";let x=m.split(" ");if(x.length>1)return`${x[0][0]}${x[x.length-1][0]}`.toUpperCase();return m.substring(0,2).toUpperCase()},h=(m)=>{if(!m)return"";switch(m.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return m}},l=(m)=>(m??0).toLocaleString(),C=(m)=>`$${(m??0).toFixed(6)}`;return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6",children:[g("div",{children:[a(Ft,{className:"text-xl font-semibold tracking-tight",children:vb()}),a(Ht,{className:"text-sm text-muted-foreground mt-1",children:bb()})]}),g("div",{className:"flex flex-wrap items-center gap-3",children:[g(os,{type:"single",value:t,onValueChange:(m)=>{if(m)s(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"team",className:"px-3 py-1.5 text-xs font-medium",children:FM()}),a(Lr,{value:"members",className:"px-3 py-1.5 text-xs font-medium",children:wI()})]}),g(os,{type:"single",value:i,onValueChange:(m)=>{if(m)n(m)},className:"border rounded-lg p-1 bg-muted/30",children:[a(Lr,{value:"1h",className:"px-2.5 py-1.5 text-xs font-medium",children:"1h"}),a(Lr,{value:"24h",className:"px-2.5 py-1.5 text-xs font-medium",children:"24h"}),a(Lr,{value:"7d",className:"px-2.5 py-1.5 text-xs font-medium",children:"7d"}),a(Lr,{value:"30d",className:"px-2.5 py-1.5 text-xs font-medium",children:"30d"})]})]})]}),a(St,{children:t==="team"?c?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:zp()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:g(Tr,{children:[a(ct,{className:"font-medium",children:zp()}),a(ct,{className:"text-right",children:l(r?.team?.inputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.outputTokens)}),a(ct,{className:"text-right",children:l(r?.team?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(r?.team?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(r?.team?.cost)})]})})]})}):p?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):a("div",{className:"rounded-md border",children:g(Bn,{children:[a(Un,{children:g(Tr,{children:[a(ft,{children:bI()}),a(ft,{children:Pk()}),a(ft,{className:"text-right",children:z_()}),a(ft,{className:"text-right",children:g0()}),a(ft,{className:"text-right",children:XA()}),a(ft,{className:"text-right",children:Sy()}),a(ft,{className:"text-right",children:s_()})]})}),a(zn,{children:(u||[]).map((m,x)=>{let T=v[x]?.data?.member;return g(Tr,{children:[a(ct,{children:g("div",{className:"flex items-center gap-3",children:[g($e,{className:"h-8 w-8 rounded-full",children:[m.image&&a(He,{src:m.image,alt:m.name,className:"object-cover"}),a(Qe,{className:"bg-primary/20 text-xs",children:b(m.name)})]}),g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-medium leading-none",children:m.name}),a("span",{className:"text-xs text-muted-foreground mt-0.5",children:m.email})]})]})}),a(ct,{className:"text-xs text-muted-foreground",children:h(m.role)}),a(ct,{className:"text-right",children:l(T?.inputTokens)}),a(ct,{className:"text-right",children:l(T?.outputTokens)}),a(ct,{className:"text-right",children:l(T?.cacheReadTokens)}),a(ct,{className:"text-right font-medium",children:l(T?.totalTokens)}),a(ct,{className:"text-right font-medium",children:C(T?.cost)})]},m.id)})})]})})})]})}Z();function Ne({teamId:e}){let[t,s]=w(null),{ref:i,inView:n}=Vt(),{data:r,isLoading:c,isError:u,fetchNextPage:f,hasNextPage:v,isFetchingNextPage:p}=Tt({queryKey:["teams",e,"agent-sessions"],queryFn:async({pageParam:l})=>{let C=await R.api.teams[":teamId"]["agent-sessions"].$get({param:{teamId:e},query:{first:"20",after:l?String(l):void 0}});if(!C.ok)throw Error("Failed to fetch agent sessions");return await C.json()},initialPageParam:"",getNextPageParam:(l)=>l.pageInfo.cursor||void 0,enabled:!!e});S(()=>{if(n&&v&&!p)f()},[n,v,p,f]);let b=r?.pages.flatMap((l)=>l.data).filter((l)=>l.id!=="pending")||[],h=(l)=>{switch(l){case"comment":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20",children:TR()});case"chat":return a(ve,{variant:"outline",className:"bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",children:IR()});case"naming":return a(ve,{variant:"outline",className:"bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",children:kR()});default:return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border",children:l})}};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[a(Nt,{className:"pb-4",children:a("div",{className:"flex items-center justify-between",children:g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(W,{className:"w-5 h-5 text-violet-500"}),ay()]}),a(Ht,{className:"mt-1 text-sm text-muted-foreground",children:RR()})]})})}),a(St,{children:c?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u?a("div",{className:"flex h-64 items-center justify-center text-destructive",children:"Failed to load agent sessions."}):b.length===0?g("div",{className:"flex flex-col items-center justify-center py-12 text-center text-muted-foreground",children:[a(W,{className:"w-10 h-10 text-muted-foreground/40 mb-3"}),a("p",{className:"text-base font-medium",children:mT()})]}):g("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[g(Bn,{children:[a(Un,{className:"bg-muted/40",children:g(Tr,{children:[a(ft,{children:xR()}),a(ft,{children:_d()}),a(ft,{children:SR()}),a(ft,{className:"text-right",children:cE()})]})}),a(zn,{children:b.map((l)=>g(Tr,{onClick:()=>s(l.id),className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[a(ct,{className:"font-medium",children:g("div",{className:"flex flex-col",children:[a("span",{className:"text-sm font-semibold text-foreground",children:l.name||pg()}),a("span",{className:"text-xs font-mono text-muted-foreground/70",children:l.id})]})}),a(ct,{children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:l.creator?.image||void 0}),a(Qe,{className:"text-[10px]",children:l.creator?.name?.[0]?.toUpperCase()||"?"})]}),a("span",{className:"text-sm text-foreground/90",children:l.creator?.name||"System / Agent"})]})}),a(ct,{children:h(l.type)}),a(ct,{className:"text-right text-xs text-muted-foreground",children:nn(l.createdAt)})]},l.id))})]}),a("div",{ref:i,className:"py-4 flex justify-center",children:p&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})})]}),a(_u,{sessionId:t,open:!!t,onOpenChange:(l)=>{if(!l)s(null)}})]})}Z();function ye({...e}){return a(Ze,{"data-slot":"collapsible",...e})}function Te({...e}){return a(Ve,{"data-slot":"collapsible-trigger",...e})}function _e({...e}){return a(Xe,{"data-slot":"collapsible-content",...e})}function ne(e){switch(e.toLowerCase()){case"owner":return xd();case"editor":return Mi();case"reviewer":return Pi();default:return e}}function nt(e,t){if(typeof e==="object"&&e!==null&&"message"in e){let s=e.message;if(typeof s==="string")return s}return t}function dt({rule:e}){let t=e.resourceData??{};if(e.resource==="agent_mcp_call_count")return a("span",{children:ck({value:String(t.id??"")})});if(e.resource==="agent_bash_call_count")return a("span",{children:lk({value:String(t.match??"*")})});if(e.resource==="agent_tool_call_count")return a("span",{children:uk({value:String(t.name??t.toolName??"*")})});return null}function ut({rule:e}){if(e.scopeMode==="all_members")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Uo,{className:"h-3 w-3"}),g("span",{children:[Pp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});if(e.scopeMode==="each_member")return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(jn,{className:"h-3 w-3"}),g("span",{children:[Dp(),e.role?` (${ne(e.role)})`:` (${Kc()})`]})]});return g(ve,{variant:"secondary",className:"gap-1 text-xs",children:[a(Rs,{className:"h-3 w-3"}),g("span",{children:[Np()," (",e.userIds?.length||0,")"]})]})}function gt({teamId:e,rule:t,record:s}){let i=ie(),[n,r]=w(!1),[c,u]=w(()=>new Date),f=Vl[t.resource],v=t.scopeMode==="all_members",p=s.percent>=100,b=v?t.role?`${ek()}: ${ne(t.role)}`:dk():s.user?.name||s.userId||Jn();S(()=>{if(!s.isWindowActive||!s.periodEnd)return;let l=window.setInterval(()=>u(new Date),60000);return()=>window.clearInterval(l)},[s.isWindowActive,s.periodEnd]);let h=ee({mutationFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.reset.$post({param:{teamId:e,id:t.id},json:{userId:s.userId??null}});if(!l.ok){let C=await l.json().catch(()=>null);throw Error(nt(C,I_()))}return await l.json()},onSuccess:()=>{i.invalidateQueries({queryKey:["teams",e,"quotas",t.id,"records"]}),i.invalidateQueries({queryKey:["teams",e,"quotas"]}),r(!1),j.success(J1())},onError:(l)=>{let C=l instanceof Error?l.message:I_();r(!1),j.error(C)}});return g(Y,{children:[g("div",{className:"space-y-3 rounded-xl border border-border/70 bg-card p-4 text-card-foreground shadow-2xs",children:[g("div",{className:"flex items-center justify-between gap-3",children:[g("div",{className:"flex min-w-0 items-center gap-3",children:[v?a("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:a(Uo,{className:"h-5 w-5"})}):g($e,{className:"h-9 w-9 shrink-0 border border-border/50",children:[a(He,{src:s.user?.image||void 0}),a(Qe,{className:"text-xs font-semibold",children:s.user?.name?.[0]?.toUpperCase()||"U"})]}),g("div",{className:"min-w-0",children:[a("div",{className:"truncate text-sm font-semibold text-foreground",children:b}),!v&&s.user?.email&&a("div",{className:"truncate text-xs text-muted-foreground",children:s.user.email})]})]}),g("div",{className:"flex shrink-0 items-center gap-2",children:[s.isWindowActive&&s.periodEnd?g(ve,{variant:"outline",className:"hidden gap-1 border-primary/30 bg-primary/5 text-xs text-primary sm:flex",children:[a(cr,{className:"h-3 w-3"}),a("span",{children:B0({time:vg(s.periodEnd,c)})})]}):g(ve,{variant:"secondary",className:"hidden gap-1 text-xs text-muted-foreground sm:flex",children:[a(wr,{className:"h-3 w-3 text-primary"}),a("span",{children:L0()})]}),g(F,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>r(!0),disabled:h.isPending,children:[h.isPending?a(K,{className:"h-3.5 w-3.5 animate-spin"}):a(Li,{className:"h-3.5 w-3.5"}),U0()]})]})]}),g("div",{className:"space-y-1.5 pt-1",children:[a(rm,{value:Math.min(100,Math.max(0,s.percent)),className:"h-2"}),g("div",{className:"flex items-center justify-between gap-2 text-xs font-medium",children:[g("span",{className:p?"font-bold text-destructive":"text-foreground",children:[ya(t.resource,s.consumed)," /"," ",ya(t.resource,t.limit)," ",f?.unit]}),g("span",{className:p?"font-bold text-destructive":"text-muted-foreground",children:[s.percent,"%"]})]})]}),g("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground sm:hidden",children:[s.isWindowActive&&s.periodEnd?g("span",{className:"flex items-center gap-1 text-primary",children:[a(cr,{className:"h-3 w-3"}),B0({time:vg(s.periodEnd,c)})]}):g("span",{className:"flex items-center gap-1",children:[a(wr,{className:"h-3 w-3 text-primary"}),L0()]}),g("span",{children:[W1(),": ",ya(t.resource,s.remaining)," ",f?.unit]})]})]}),a(_t,{open:n,onOpenChange:r,children:g(yt,{children:[g(vt,{children:[a(wt,{children:U0()}),a(Et,{children:Y1({target:b})})]}),g(bt,{children:[a(Ct,{disabled:h.isPending,children:Ke()}),g(xt,{onClick:(l)=>{l.preventDefault(),h.mutate()},disabled:h.isPending,children:[h.isPending&&a(K,{className:"mr-2 h-4 w-4 animate-spin"}),Ya()]})]})]})})]})}function kt({teamId:e,rule:t}){let[s,i]=w(!1),[n,r]=w(""),c=Vl[t.resource],u=c?.icon||gs,{data:f,isLoading:v,isError:p}=X({queryKey:["teams",e,"quotas",t.id,"records"],queryFn:async()=>{let l=await R.api.teams[":teamId"].quotas[":id"].records.$get({param:{teamId:e,id:t.id}});if(!l.ok)throw Error(S_());return await l.json()},enabled:s,refetchInterval:s?1e4:!1}),b=f?.records??[],h=b.filter((l)=>{if(!n.trim())return!0;let C=n.toLowerCase();return l.user?.name.toLowerCase().includes(C)||l.user?.email.toLowerCase().includes(C)});return g(ye,{open:s,onOpenChange:i,className:"rounded-xl border border-border/70",children:[a(Te,{asChild:!0,children:g("button",{type:"button","aria-label":s?z1():H1(),className:"flex w-full items-center justify-between gap-4 p-4 text-left transition-colors hover:bg-muted/40",children:[g("div",{className:"flex min-w-0 items-start gap-3",children:[a("div",{className:"mt-0.5 rounded-lg bg-primary/10 p-2 text-primary",children:a(u,{className:"h-5 w-5"})}),g("div",{className:"min-w-0",children:[g("div",{className:"flex flex-wrap items-center gap-2",children:[a("span",{className:"font-semibold text-foreground",children:c?.label()||t.resource}),!t.enabled&&a(ve,{variant:"secondary",children:Bh()})]}),g("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[a(ut,{rule:t}),g(ve,{variant:"outline",className:"gap-1 text-xs",children:[a(cr,{className:"h-3 w-3"}),ya(t.resource,t.limit)," ",c?.unit," /"," ",au(t.period)]}),a(dt,{rule:t})]})]})]}),a(Be,{className:`h-5 w-5 shrink-0 text-muted-foreground transition-transform ${s?"rotate-180":""}`})]})}),a(_e,{children:g("div",{className:"space-y-3 border-t border-border/60 bg-muted/10 p-4",children:[t.scopeMode!=="all_members"&&b.length>3&&g("div",{className:"relative",children:[a(rr,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),a(re,{value:n,onChange:(l)=>r(l.target.value),placeholder:Hh(),className:"h-9 pl-9 text-sm"})]}),v?a("div",{className:"flex justify-center py-10",children:a(K,{className:"h-7 w-7 animate-spin text-primary"})}):p?a("div",{className:"py-8 text-center text-sm text-destructive",children:S_()}):h.length===0?a("div",{className:"py-8 text-center text-sm text-muted-foreground",children:V1()}):h.map((l,C)=>a(gt,{teamId:e,rule:t,record:l},l.id||l.userId||`record-${C}`))]})})]})}function Ae({teamId:e}){let{data:t,isLoading:s,isError:i}=X({queryKey:["teams",e,"quotas"],queryFn:async()=>{let r=await R.api.teams[":teamId"].quotas.$get({param:{teamId:e}});if(!r.ok)throw Error(Ms());return await r.json()},enabled:!!e}),n=t?.rules??[];return g(lt,{className:"border-border/60 shadow-sm",children:[g(Nt,{children:[g(Ft,{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[a(gs,{className:"h-5 w-5 text-primary"}),Fp()]}),a(Ht,{children:q1()})]}),a(St,{children:s?a("div",{className:"flex h-48 items-center justify-center",children:a(K,{className:"h-7 w-7 animate-spin text-muted-foreground"})}):i?a("div",{className:"py-10 text-center text-sm text-destructive",children:Ms()}):n.length===0?g("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border py-12 text-center",children:[a(gs,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),a("p",{className:"text-base font-medium text-foreground",children:Rh()}),a("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:kh()})]}):a("div",{className:"space-y-3",children:n.map((r)=>a(kt,{teamId:e,rule:r},r.id))})})]})}Z();var At=Object.values(tu);function Re({teamId:e}){let[t,s]=w([]),[i,n]=w([]),[r,c]=w(""),{ref:u,inView:f}=Vt(),{data:v}=X({queryKey:["teams",e,"members"],queryFn:async()=>{let d=await R.api.teams[":teamId"].members.$get({param:{teamId:e},query:{}});if(!d.ok)return[];return await d.json()},enabled:!!e}),p=v||[],{data:b,isLoading:h,isError:l,fetchNextPage:C,hasNextPage:m,isFetchingNextPage:x}=Tt({queryKey:["teams",e,"audit-logs",t,i,r],queryFn:async({pageParam:d})=>{let N=await R.api.teams[":teamId"]["audit-logs"].$get({param:{teamId:e},query:{first:"20",after:d?String(d):void 0,actions:t.length>0?t:void 0,userIds:i.length>0?i:void 0,itemId:r.trim()||void 0}});if(!N.ok)throw Error("Failed to fetch audit logs");return await N.json()},initialPageParam:"",getNextPageParam:(d)=>d.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(f&&m&&!x)C()},[f,m,x,C]);let T=b?.pages.flatMap((d)=>d.nodes)||[],k=b?.pages[0]?.total??0,_=(d)=>{s((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},q=(d)=>{n((N)=>N.includes(d)?N.filter((D)=>D!==d):[...N,d])},I=(d)=>{if(d.includes("delete")||d.includes("remove")||d.includes("revoke"))return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:d});if(d.includes("create")||d.includes("add"))return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:d});if(d.includes("update")||d.includes("reparent")||d.includes("copy"))return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs",children:d});return a(ve,{variant:"outline",className:"bg-muted text-muted-foreground border-border font-mono text-xs",children:d})},U=new Map(p.map((d)=>[d.userId||d.id,d]));return a("div",{className:"space-y-6",children:g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(Li,{className:"h-5 w-5 text-primary"}),Qm()]}),a(Ht,{className:"mt-1",children:Kb()})]}),k>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[k," ",Qm()]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),mC(),t.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:t.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:Jk()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:At.map((d)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:t.includes(d),onCheckedChange:()=>_(d)}),a("span",{className:"font-mono",children:d})]},d))}),t.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>s([]),children:"Clear Actions"})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),AC(),i.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:i.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:fR()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:p.map((d)=>{let N=d.userId||d.user?.id||d.id,D=d.user?.name||d.name||N,E=d.user?.image||d.image;return g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:i.includes(N),onCheckedChange:()=>q(N)}),g($e,{className:"h-5 w-5",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"truncate",children:D})]},N)})}),i.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>n([]),children:"Clear Users"})]})]}),g("div",{className:"relative flex-1 min-w-[200px] max-w-xs",children:[a(rr,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a(re,{type:"text",placeholder:Vk(),value:r,onChange:(d)=>c(d.target.value),className:"pl-8 pr-8 h-9 text-xs"}),r&&a("button",{onClick:()=>c(""),className:"absolute right-2.5 top-2.5 text-muted-foreground hover:text-foreground",children:a(Ge,{className:"h-4 w-4"})})]}),(t.length>0||i.length>0||r)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{s([]),n([]),c("")},children:"Clear all"})]})]}),g(St,{className:"p-0",children:[h?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?a("div",{className:"p-8 text-center text-sm text-destructive",children:"Failed to load audit logs."}):T.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:eT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[180px] pl-6 text-xs font-semibold",children:Hy()}),a(ft,{className:"w-[200px] px-4 text-xs font-semibold",children:PO()}),a(ft,{className:"px-4 text-xs font-semibold",children:yS()}),a(ft,{className:"px-4 text-xs font-semibold",children:S0()}),a(ft,{className:"w-[160px] pr-6 text-right text-xs font-semibold",children:JM()})]})}),a(zn,{children:T.map((d)=>{let N=d.userId?U.get(d.userId):null,D=N?.user?.name||N?.name||d.userId||"System",E=N?.user?.image||N?.image;return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:I(d.action)}),a(ct,{className:"py-3 px-4",children:g("div",{className:"flex items-center gap-2",children:[g($e,{className:"h-6 w-6",children:[a(He,{src:E||void 0}),a(Qe,{className:"text-[10px]",children:D.slice(0,2).toUpperCase()})]}),a("span",{className:"text-xs font-medium text-foreground truncate max-w-[160px]",children:d.agent?Rd({user:D,agent:d.agent.name}):D}),d.agent&&a($t,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.itemId||"-"}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:d.projectId||"-"}),a(ct,{className:"py-3 pr-6 text-right text-xs text-muted-foreground",children:nn(d.createdAt)})]},d.id)})})]}),a("div",{ref:u,className:"py-4 flex justify-center",children:x&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]})})}Z();Z();function De({task:e,open:t,onOpenChange:s}){let[i,n]=w(null);if(!e)return null;let r=(u,f)=>{navigator.clipboard.writeText(u),n(f),setTimeout(()=>{n(null)},2000)},c=(u)=>{switch(u){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 text-xs font-mono",children:"completed"});case"processing":return a(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 text-xs font-mono",children:"processing"});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 text-xs font-mono",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 text-xs font-mono",children:"failed"});default:return a(ve,{variant:"outline",className:"text-xs font-mono",children:u||"unknown"})}};return a(Se,{open:t,onOpenChange:s,children:g(xe,{className:"max-w-2xl max-h-[90vh] flex flex-col p-6",children:[g(ke,{className:"pb-2 border-b border-border/50",children:[g("div",{className:"flex items-center justify-between gap-2 pr-6",children:[g("div",{className:"flex items-center gap-2",children:[a(On,{className:"h-5 w-5 text-primary"}),a(Ce,{className:"text-lg font-bold",children:TM()})]}),g("div",{className:"flex items-center gap-2",children:[c(e.status),e.type&&a(ve,{variant:"secondary",className:"font-mono text-xs",children:e.type})]})]}),g(Ot,{className:"text-xs text-muted-foreground mt-1 flex items-center gap-2",children:[g("span",{children:[gy(),": ",a("span",{className:"font-mono text-foreground",children:e.id})]}),a(F,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",onClick:()=>r(e.id,"task_id"),children:i==="task_id"?a(qe,{className:"h-3 w-3 text-emerald-500"}):a(Zr,{className:"h-3 w-3"})})]})]}),g("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 py-3 text-xs border-b border-border/40",children:[g("div",{children:[a("div",{className:"text-muted-foreground",children:dh()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.fileName||"-",children:e.fileName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:ly()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.fileSize!==null&&e.fileSize!==void 0?on(e.fileSize):"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:Ip()}),a("div",{className:"truncate font-medium text-foreground mt-0.5",title:e.projectName||"-",children:e.projectName||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:zb()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.assetId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:S0()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.projectId||"-"})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:cp()}),g("div",{className:"font-medium text-foreground mt-0.5 flex items-center gap-1",children:[a(cr,{className:"h-3 w-3 text-muted-foreground"}),nn(e.createdAt)]})]}),g("div",{children:[a("div",{className:"text-muted-foreground",children:SO()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.updatedAt)})]}),e.heartbeat&&g("div",{children:[a("div",{className:"text-muted-foreground",children:rS()}),a("div",{className:"font-medium text-foreground mt-0.5",children:nn(e.heartbeat)})]}),e.model&&g("div",{children:[a("div",{className:"text-muted-foreground",children:Eh()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.model})]}),(e.inputTokens>0||e.outputTokens>0)&&g("div",{children:[g("div",{className:"text-muted-foreground flex items-center gap-1",children:[a(eo,{className:"h-3 w-3"})," ",nO()]}),g("div",{className:"font-medium text-foreground mt-0.5 font-mono",children:[e.inputTokens.toLocaleString()," in / ",e.outputTokens.toLocaleString()," out"]})]}),e.sessionId&&g("div",{className:"col-span-2",children:[a("div",{className:"text-muted-foreground",children:ER()}),a("div",{className:"font-mono truncate font-medium text-foreground mt-0.5",children:e.sessionId})]})]}),a("div",{className:"flex-1 min-h-0 pt-3",children:g(co,{defaultValue:"payload",className:"w-full h-full flex flex-col",children:[g(uo,{className:"grid w-full grid-cols-2",children:[a(Wr,{value:"payload",children:s1()}),a(Wr,{value:"output",children:VT()})]}),a(gn,{value:"payload",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.payload?JSON.stringify(e.payload,null,2):"null"})})}),a(gn,{value:"output",className:"flex-1 mt-2 min-h-0",children:a(Ie,{className:"h-64 w-full rounded-md border border-border/50 bg-muted/30 p-3 font-mono text-xs",children:a("pre",{className:"whitespace-pre-wrap break-all text-foreground/90",children:e.output?JSON.stringify(e.output,null,2):"null"})})})]})})]})})}var Rt=Object.values($l),Dt=Object.values(Hl);function Pe({teamId:e}){let t=ie(),[s,i]=w([]),[n,r]=w([]),[c,u]=w(null),[f,v]=w(null),{ref:p,inView:b}=Vt(),h=G(()=>["teams",e,"workflow-tasks",s,n],[e,s,n]),{data:l,isLoading:C,isError:m,fetchNextPage:x,hasNextPage:T,isFetchingNextPage:k,refetch:_,isRefetching:q}=Tt({queryKey:h,queryFn:async({pageParam:o})=>{let y=await R.api.teams[":teamId"]["workflow-tasks"].$get({param:{teamId:e},query:{first:"20",after:o?String(o):void 0,status:s.length>0?s:void 0,types:n.length>0?n:void 0}});if(!y.ok)throw Error("Failed to fetch workflow tasks");return await y.json()},initialPageParam:"",getNextPageParam:(o)=>o.pageInfo.endCursor||void 0,enabled:!!e});S(()=>{if(b&&T&&!k)x()},[b,T,k,x]);let I=G(()=>l?.pages.flatMap((o)=>o.nodes)||[],[l]),U=l?.pages[0]?.total??0,d=G(()=>I.filter((o)=>o.status==="pending"||o.status==="processing").map((o)=>o.id),[I]);X({queryKey:["teams",e,"workflow-tasks","batch-status",d],queryFn:async()=>{if(d.length===0)return null;let o=await R.api.teams[":teamId"]["workflow-tasks"]["batch-status"].$post({param:{teamId:e},json:{taskIds:d}});if(!o.ok)return null;let y=await o.json();if(y.tasks&&y.tasks.length>0)t.setQueryData(h,(A)=>{if(!A)return A;let V=new Map(y.tasks.map((L)=>[L.id,L]));return{...A,pages:A.pages.map((L)=>({...L,nodes:L.nodes.map((le)=>V.get(le.id)||le)}))}});return y},enabled:d.length>0,refetchInterval:6000});let N=ee({mutationFn:async(o)=>{let y=await R.api.teams[":teamId"]["workflow-tasks"][":taskId"].stop.$post({param:{teamId:e,taskId:o}});if(!y.ok){let A=await y.json().catch(()=>({message:"Failed to stop task"}));throw Error(A.message||"Failed to stop task")}return await y.json()},onSuccess:(o)=>{j.success(kM()),t.setQueryData(h,(y)=>{if(!y)return y;return{...y,pages:y.pages.map((A)=>({...A,nodes:A.nodes.map((V)=>V.id===o.task.id?o.task:V)}))}}),u(null)},onError:(o)=>{j.error(o.message||"Failed to stop task")}}),D=(o)=>{i((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},E=(o)=>{r((y)=>y.includes(o)?y.filter((A)=>A!==o):[...y,o])},Ee=(o)=>{switch(o){case"completed":return a(ve,{variant:"outline",className:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20 font-mono text-xs",children:"completed"});case"processing":return g(ve,{variant:"outline",className:"bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 font-mono text-xs gap-1.5",children:[a(K,{className:"h-3 w-3 animate-spin"}),"processing"]});case"pending":return a(ve,{variant:"outline",className:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 font-mono text-xs",children:"pending"});case"failed":return a(ve,{variant:"outline",className:"bg-destructive/10 text-destructive border-destructive/20 font-mono text-xs",children:"failed"});default:return a(ve,{variant:"outline",className:"font-mono text-xs",children:o||"-"})}},Oe=(o)=>{if(!o)return a(ve,{variant:"outline",children:"-"});if(o.startsWith("transcode"))return a(ve,{variant:"outline",className:"bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 font-mono text-xs",children:o});if(o.startsWith("ai_")||o==="chat")return a(ve,{variant:"outline",className:"bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 font-mono text-xs",children:o});return a(ve,{variant:"secondary",className:"font-mono text-xs",children:o})};return g("div",{className:"space-y-6",children:[g(lt,{className:"border border-border/50 shadow-xs",children:[g(Nt,{className:"pb-4",children:[g("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[g("div",{children:[g(Ft,{className:"text-xl font-bold flex items-center gap-2",children:[a(ae,{className:"h-5 w-5 text-primary"}),Ag()]}),a(Ht,{className:"mt-1",children:eP()})]}),g("div",{className:"flex items-center gap-3",children:[U>0&&g(ve,{variant:"secondary",className:"w-fit text-xs font-normal",children:[U," ",Ag()]}),g(F,{variant:"outline",size:"sm",className:"h-9 gap-1.5 text-xs",onClick:()=>_(),disabled:q,children:[a(be,{className:`h-3.5 w-3.5 ${q?"animate-spin":""}`}),yk()]})]})]}),g("div",{className:"mt-4 flex flex-wrap items-center gap-3 pt-4 border-t border-border/40",children:[g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),hC(),s.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:s.length})]})}),g(ht,{className:"w-56 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:uR()}),a("div",{className:"space-y-1",children:Dt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:s.includes(o),onCheckedChange:()=>D(o)}),a("span",{className:"font-mono",children:o})]},o))}),s.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>i([]),children:Tw()})]})]}),g(pt,{children:[a(mt,{asChild:!0,children:g(F,{variant:"outline",size:"sm",className:"h-9 gap-2 text-xs border-dashed",children:[a(P,{className:"h-3.5 w-3.5"}),gC(),n.length>0&&a(ve,{variant:"secondary",className:"ml-1 px-1.5 py-0 text-[10px]",children:n.length})]})}),g(ht,{className:"w-64 p-2",align:"start",children:[a("div",{className:"text-xs font-semibold text-muted-foreground px-2 py-1 mb-1",children:eg()}),a("div",{className:"max-h-60 overflow-y-auto space-y-1 pr-1",children:Rt.map((o)=>g("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-accent rounded-md cursor-pointer text-xs",children:[a(Sr,{checked:n.includes(o),onCheckedChange:()=>E(o)}),a("span",{className:"font-mono truncate",children:o})]},o))}),n.length>0&&a(F,{variant:"ghost",size:"sm",className:"w-full mt-2 h-7 text-xs text-muted-foreground hover:text-foreground",onClick:()=>r([]),children:kw()})]})]}),(s.length>0||n.length>0)&&a(F,{variant:"ghost",size:"sm",className:"h-9 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{i([]),r([])},children:xw()})]})]}),g(St,{className:"p-0",children:[C?a("div",{className:"flex h-64 items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):m?a("div",{className:"p-8 text-center text-sm text-destructive",children:zx()}):I.length===0?a("div",{className:"p-12 text-center text-sm text-muted-foreground",children:wT()}):g(Bn,{children:[a(Un,{children:g(Tr,{className:"hover:bg-transparent border-b border-border/50",children:[a(ft,{className:"w-[170px] pl-6 text-xs font-semibold",children:by()}),a(ft,{className:"w-[130px] px-4 text-xs font-semibold",children:_y()}),a(ft,{className:"min-w-[180px] px-4 text-xs font-semibold",children:dh()}),a(ft,{className:"w-[110px] px-4 text-xs font-semibold",children:ly()}),a(ft,{className:"w-[160px] px-4 text-xs font-semibold",children:Ip()}),a(ft,{className:"w-[130px] px-4 text-right text-xs font-semibold",children:cp()}),a(ft,{className:"w-[120px] pr-6 text-right text-xs font-semibold",children:Bm()})]})}),a(zn,{children:I.map((o)=>{let y=o.status==="pending"||o.status==="processing";return g(Tr,{className:"hover:bg-muted/40 transition-colors",children:[a(ct,{className:"py-3 pl-6 font-medium",children:Oe(o.type)}),a(ct,{className:"py-3 px-4 font-medium",children:Ee(o.status)}),a(ct,{className:"py-3 px-4 text-xs font-medium",children:a("span",{className:"truncate block max-w-[220px]",title:o.fileName||o.assetId||"-",children:o.fileName||o.assetId||"-"})}),a(ct,{className:"py-3 px-4 text-xs font-mono text-muted-foreground",children:o.fileSize!==null&&o.fileSize!==void 0?on(o.fileSize):"-"}),a(ct,{className:"py-3 px-4 text-xs text-muted-foreground",children:a("span",{className:"truncate block max-w-[160px]",title:o.projectName||o.projectId||"-",children:o.projectName||o.projectId||"-"})}),a(ct,{className:"py-3 px-4 text-right text-xs text-muted-foreground whitespace-nowrap",children:nn(o.createdAt)}),a(ct,{className:"py-3 pr-6 text-right",children:g("div",{className:"flex items-center justify-end gap-1",children:[a(F,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:()=>v(o),title:BO(),children:a(ge,{className:"h-4 w-4"})}),y&&g(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs border-destructive/30 text-destructive hover:bg-destructive/10",onClick:()=>u(o),disabled:N.isPending,children:[a(yu,{className:"h-3 w-3 mr-1 fill-current"}),py()]})]})})]},o.id)})})]}),a("div",{ref:p,className:"py-4 flex justify-center",children:k&&a(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),a(_t,{open:!!c,onOpenChange:(o)=>{if(!o)u(null)},children:g(yt,{children:[g(vt,{children:[g("div",{className:"flex items-center gap-2",children:[a(tn,{className:"h-5 w-5 text-destructive"}),a(wt,{children:sM()})]}),a(Et,{className:"pt-2 text-sm text-muted-foreground",children:oM()}),c&&g("div",{className:"mt-3 p-2.5 rounded-md bg-muted/50 border border-border/40 font-mono text-xs space-y-1",children:[g("div",{children:[gy(),": ",c.id]}),c.fileName&&g("div",{className:"font-sans",children:[dh(),":"," ",a("span",{className:"font-medium text-foreground",children:c.fileName})]}),g("div",{children:[by(),": ",c.type||"unknown"]}),g("div",{children:[_y(),": ",c.status]})]})]}),g(bt,{children:[a(Ct,{disabled:N.isPending,children:Ke()}),a(xt,{className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",disabled:N.isPending,onClick:()=>{if(c)N.mutate(c.id)},children:N.isPending?g(Y,{children:[a(K,{className:"h-3.5 w-3.5 animate-spin mr-1.5"}),iM()]}):py()})]})]})}),a(De,{task:f,open:!!f,onOpenChange:(o)=>{if(!o)v(null)}})]})}function qt(){let{teamId:e}=It.useParams(),[t,s]=w("audit-logs"),{data:i,isLoading:n}=X({queryKey:["teams",e,"me"],queryFn:async()=>{let r=await R.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!r.ok)throw Error("Failed to fetch me");return await r.json()},enabled:!!e});if(n)return a("div",{className:"flex h-screen items-center justify-center",children:a(K,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(i?.role?.toLowerCase()!=="owner")return g("div",{className:"flex h-full flex-col items-center justify-center p-8 text-center",children:[a(iu,{className:"h-12 w-12 text-destructive mb-4"}),a("h2",{className:"text-xl font-bold tracking-tight mb-2",children:$y()}),a("p",{className:"text-sm text-muted-foreground max-w-md",children:IT()})]});return a("div",{className:"h-full bg-background font-sans selection:bg-primary/20 transition-colors duration-300",children:g("div",{className:"flex flex-col md:flex-row h-full",children:[a("div",{className:"w-full h-full md:w-72 bg-sidebar border-b md:border-b-0 md:border-r border-sidebar-border z-10 md:left-16 overflow-y-auto transition-colors duration-300",children:g("nav",{className:"p-4 space-y-1 mt-4",children:[a("div",{className:"mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider",children:c_()}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:OM()}),g("button",{onClick:()=>s("audit-logs"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="audit-logs"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(Li,{className:"w-5 h-5"}),Qm(),t==="audit-logs"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("workflow-tasks"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="workflow-tasks"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(ae,{className:"w-5 h-5"}),Ag(),t==="workflow-tasks"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("quotas"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="quotas"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(gs,{className:"w-5 h-5"}),Fp(),t==="quotas"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),a("div",{className:"mt-4 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border",children:Ab()}),g("button",{onClick:()=>s("ai-usage"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-usage"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(fe,{className:"w-5 h-5"}),OO(),t==="ai-usage"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]}),g("button",{onClick:()=>s("ai-sessions"),className:B("w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all",t==="ai-sessions"?"bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border":"text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[a(W,{className:"w-5 h-5"}),ay(),t==="ai-sessions"&&a("div",{className:"ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary"})]})]})}),a("div",{className:"flex-1 overflow-y-auto p-4 md:p-8",children:g("div",{className:"max-w-6xl mx-auto space-y-8",children:[t==="audit-logs"&&a(Re,{teamId:e}),t==="workflow-tasks"&&a(Pe,{teamId:e}),t==="ai-usage"&&a(he,{teamId:e}),t==="ai-sessions"&&a(Ne,{teamId:e}),t==="quotas"&&a(Ae,{teamId:e})]})})]})})}var It=Je("/teams/$teamId/dashboard")({component:qt});export{It as Route};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{hr,sr}from"./chunk-e4yscwen.js";import{L,ae}from"./chunk-2jj4j8cn.js";var Is=L(function(he){var{hasOwn:V}=hr(),{streamCollector:ee}=hr();he.streamCollector=ee;var{buildQueryString:K,HttpResponse:Q}=sr(),E=ae("https"),{Readable:te}=ae("stream"),_=ae("http2");function I(e){let t=e&&typeof e==="object"&&"reason"in e?e.reason:void 0;if(t){if(t instanceof Error){let s=Error("Request aborted");return s.name="AbortError",s.cause=t,s}let n=Error(String(t));return n.name="AbortError",n}let o=Error("Request aborted");return o.name="AbortError",o}var oe=["ECONNRESET","EPIPE","ETIMEDOUT"],J=(e)=>{let t={};for(let o in e){if(!V(e,o))continue;let n=e[o];t[o]=Array.isArray(n)?n.join(","):n}return t},h={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:(e)=>clearTimeout(e)},F=1000,ne=(e,t,o=0)=>{if(!o)return-1;let n=(s)=>{let i=h.setTimeout(()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${o} ms.`),{name:"TimeoutError"}))},o-s),c=(a)=>{if(a?.connecting)a.on("connect",()=>{h.clearTimeout(i)});else h.clearTimeout(i)};if(e.socket)c(e.socket);else e.on("socket",c)};if(o<2000)return n(0),0;return h.setTimeout(n.bind(null,F),F)},se=(e,t,o=0,n,s)=>{if(o)return h.setTimeout(()=>{let i=`@smithy/node-http-handler - [${n?"ERROR":"WARN"}] a request has exceeded the configured ${o} ms requestTimeout.`;if(n){let c=Object.assign(Error(i),{name:"TimeoutError",code:"ETIMEDOUT"});e.destroy(c),t(c)}else i+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",s?.warn?.(i)},o);return-1},re=3000,ie=(e,{keepAlive:t,keepAliveMsecs:o},n=re)=>{if(t!==!0)return-1;let s=()=>{if(e.socket)e.socket.setKeepAlive(t,o||0);else e.on("socket",(i)=>{i.setKeepAlive(t,o||0)})};if(n===0)return s(),0;return h.setTimeout(s,n)},j=3000,ce=(e,t,o=0)=>{let n=(s)=>{let i=o-s,c=()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket timed out after ${o} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};if(e.socket)e.socket.setTimeout(i,c),e.on("close",()=>e.socket?.removeListener("timeout",c));else e.setTimeout(i,c)};if(0<o&&o<6000)return n(0),0;return h.setTimeout(n.bind(null,o===0?0:j),j)},B=6000;async function G(e,t,o=B,n=!1){let s=t.headers,i=s?s.Expect||s.expect:void 0,c=-1,a=!0;if(!n&&i==="100-continue")a=await Promise.race([new Promise((u)=>{c=Number(h.setTimeout(()=>u(!0),Math.max(B,o)))}),new Promise((u)=>{e.on("continue",()=>{h.clearTimeout(c),u(!0)}),e.on("response",()=>{h.clearTimeout(c),u(!1)}),e.on("error",()=>{h.clearTimeout(c),u(!1)})})]);if(a)ue(e,t.body)}function ue(e,t){if(t instanceof te){t.pipe(e);return}if(t){let o=Buffer.isBuffer(t);if(o||typeof t==="string"){if(o&&t.byteLength===0)e.end();else e.end(t);return}let s=t;if(typeof s==="object"&&s.buffer&&typeof s.byteOffset==="number"&&typeof s.byteLength==="number"){e.end(Buffer.from(s.buffer,s.byteOffset,s.byteLength));return}e.end(Buffer.from(t));return}e.end()}var fe=0,H=void 0,W=void 0;class M{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){if(typeof e?.handle==="function")return e;return new M(e)}static checkSocketUsage(e,t,o=console){let{sockets:n,requests:s,maxSockets:i}=e;if(typeof i!=="number"||i===1/0)return t;let c=15000;if(Date.now()-c<t)return t;if(n&&s)for(let a in n){if(!V(n,a))continue;let u=n[a]?.length??0,l=s[a]?.length??0;if(u>=i&&l>=2*i)return o?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${u} and ${l} additional requests are enqueued.
|
|
3
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
4
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return t}constructor(e){this.configProvider=new Promise((t,o)=>{if(typeof e==="function")e().then((n)=>{t(this.resolveDefaultConfig(n))}).catch(o);else t(this.resolveDefaultConfig(e))})}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:t,requestTimeout:o}={}){if(!this.config)this.config=await this.configProvider;let n=this.config,s=n.logger,i=e.protocol==="https:";if(!i&&!this.config.httpAgent)this.config.httpAgent=await this.config.httpAgentProvider();return new Promise((c,a)=>{let u=void 0,l=-1,m=-1,T=-1,C=-1,w=-1,k=()=>{h.clearTimeout(l),h.clearTimeout(m),h.clearTimeout(T),h.clearTimeout(C),h.clearTimeout(w)},N=async(r)=>{await u,k(),c(r)},p=async(r)=>{await u,k(),a(r)};if(t?.aborted){let r=I(t);p(r);return}let S=e.headers,D=S?(S.Expect??S.expect)==="100-continue":!1,x=i?n.httpsAgent:n.httpAgent;if(D&&!this.externalAgent)x=new(i?E.Agent:H)({keepAlive:!1,maxSockets:1/0});l=h.setTimeout(()=>{this.socketWarningTimestamp=M.checkSocketUsage(x,this.socketWarningTimestamp,s)},n.socketAcquisitionWarningTimeout??(n.requestTimeout??2000)+(n.connectionTimeout??1000));let O=e.query?K(e.query):"",v=void 0;if(e.username!=null||e.password!=null){let r=e.username??"",f=e.password??"";v=`${r}:${f}`}let P=e.path;if(O)P+=`?${O}`;if(e.fragment)P+=`#${e.fragment}`;let y=e.hostname??"";if(y[0]==="["&&y.endsWith("]"))y=e.hostname.slice(1,-1);else y=e.hostname;let R={headers:e.headers,host:y,method:e.method,path:P,port:e.port,agent:x,auth:v},g=(i?E.request:W)(R,(r)=>{let f=new Q({statusCode:r.statusCode||-1,reason:r.statusMessage,headers:J(r.headers),body:r});N({response:f})});if(g.on("error",(r)=>{if(oe.includes(r.code))p(Object.assign(r,{name:"TimeoutError"}));else p(r)}),t){let r=()=>{g.destroy();let f=I(t);p(f)};if(typeof t.addEventListener==="function"){let f=t;f.addEventListener("abort",r,{once:!0}),g.once("close",()=>f.removeEventListener("abort",r))}else t.onabort=r}let b=o??n.requestTimeout;m=ne(g,p,n.connectionTimeout),T=se(g,p,b,n.throwOnRequestTimeout,s??console),C=ce(g,p,n.socketTimeout);let d=R.agent;if(typeof d==="object"&&"keepAlive"in d)w=ie(g,{keepAlive:d.keepAlive,keepAliveMsecs:d.keepAliveMsecs});u=G(g,e,b,this.externalAgent).catch((r)=>(k(),a(r)))})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then((o)=>{if(e===Symbol.for("logger"))return{...o,logger:o.logger??t};return{...o,[e]:t}})}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:t,connectionTimeout:o,socketTimeout:n,socketAcquisitionWarningTimeout:s,httpAgent:i,httpsAgent:c,throwOnRequestTimeout:a,logger:u}=e||{},l=!0,m=50;return{connectionTimeout:o,requestTimeout:t,socketTimeout:n,socketAcquisitionWarningTimeout:s,throwOnRequestTimeout:a,httpAgentProvider:async()=>{let T=ae("http"),{Agent:C,request:w}=T.default??T;if(W=w,H=C,i instanceof H||typeof i?.destroy==="function")return this.externalAgent=!0,i;return new H({keepAlive:!0,maxSockets:50,...i})},httpsAgent:(()=>{if(c instanceof E.Agent||typeof c?.destroy==="function")return this.externalAgent=!0,c;return new E.Agent({keepAlive:!0,maxSockets:50,...c})})(),logger:u}}}var de=new Uint16Array(1);class U{id=de[0]++;total=0;max=0;session;refs=0;constructor(e){e.unref(),this.session=e}retain(){if(this.session.destroyed)throw Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");this.refs+=1,this.total+=1,this.max=Math.max(this.refs,this.max),this.session.ref()}free(){if(this.session.destroyed)return;if(this.refs-=1,this.refs===0)this.session.unref();if(this.refs<0)throw Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.")}deref(){return this.session}close(){if(!this.session.closed)this.session.close()}destroy(){if(this.refs=0,!this.session.destroyed)this.session.destroy()}useCount(){return this.refs}}class X{sessions=[];maxConcurrency=0;constructor(e){this.sessions=(e??[]).map((t)=>new U(t))}poll(){let e=!1;for(let t of this.sessions){if(t.deref().destroyed){e=!0;continue}if(!this.maxConcurrency||t.useCount()<this.maxConcurrency)return t}if(e){for(let t of this.sessions)if(t.deref().destroyed)this.remove(t)}}offerLast(e){this.sessions.push(e)}remove(e){let t=this.sessions.indexOf(e);if(t>-1)this.sessions.splice(t,1)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}setMaxConcurrency(e){this.maxConcurrency=e}destroy(e){this.remove(e),e.destroy()}}class Y{config;connectOptions;connectionPools=new Map;constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError("maxConcurrency must be greater than zero.")}lease(e,t){let o=this.getUrlString(e),n=this.getPool(o);if(!this.config.disableConcurrency&&!t.isEventStream){let u=n.poll();if(u)return u.retain(),u}let s=new U(this.connect(o)),i=s.deref();if(this.config.maxConcurrency)i.settings({maxConcurrentStreams:this.config.maxConcurrency},(u)=>{if(u)throw Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())});let c=()=>{this.removeFromPoolAndClose(o,s)},a=()=>{this.removeFromPoolAndCheckedDestroy(o,s)};if(i.on("goaway",c),i.on("error",a),i.on("frameError",a),i.on("close",a),t.requestTimeout)i.setTimeout(t.requestTimeout,a);return n.offerLast(s),s.retain(),s}release(e,t){t.free()}createIsolatedSession(e,t){let o=this.getUrlString(e),n=new U(this.connect(o)),s=n.deref();s.settings({maxConcurrentStreams:1});let i=()=>{n.destroy()};if(s.on("error",i),s.on("frameError",i),s.on("close",i),t.requestTimeout)s.setTimeout(t.requestTimeout,i);return n.retain(),n}destroy(){for(let[e,t]of this.connectionPools){for(let o of[...t])o.destroy();this.connectionPools.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e;for(let t of this.connectionPools.values())t.setMaxConcurrency(e)}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}setNodeHttp2ConnectOptions(e){this.connectOptions=e}debug(){let e={};for(let[t,o]of this.connectionPools){let n=[];for(let s of o)n.push({id:s.id,active:s.useCount(),maxConcurrent:s.max,totalRequests:s.total});e[t]={sessions:n}}return e}removeFromPoolAndClose(e,t){this.connectionPools.get(e)?.remove(t),t.close()}removeFromPoolAndCheckedDestroy(e,t){this.connectionPools.get(e)?.remove(t),t.destroy()}getPool(e){if(!this.connectionPools.has(e)){let t=new X;if(this.config.maxConcurrency)t.setMaxConcurrency(this.config.maxConcurrency);this.connectionPools.set(e,t)}return this.connectionPools.get(e)}getUrlString(e){return e.destination.toString()}connect(e){return this.connectOptions===void 0?_.connect(e):_.connect(e,this.connectOptions)}}var{constants:z}=_;class q{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new Y({});static create(e){if(typeof e?.handle==="function")return e;return new q(e)}constructor(e){this.configProvider=new Promise((t,o)=>{if(typeof e==="function")e().then((n)=>{t(n||{})}).catch(o);else t(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:t,requestTimeout:o,isEventStream:n}={}){if(!this.config){this.config=await this.configProvider;let{disableConcurrentStreams:u,maxConcurrentStreams:l,nodeHttp2ConnectOptions:m}=this.config;if(this.connectionManager.setDisableConcurrentStreams(u??!1),l)this.connectionManager.setMaxConcurrentStreams(l);if(m)this.connectionManager.setNodeHttp2ConnectOptions(m)}let{requestTimeout:s,disableConcurrentStreams:i}=this.config,c=i||n,a=o??s;return new Promise((u,l)=>{let m=!1,T=void 0,C=async(r)=>{await T,u(r)},w=async(r)=>{await T,l(r)};if(t?.aborted){m=!0;let r=I(t);w(r);return}let{hostname:k,method:N,port:p,protocol:S,query:D}=e,x="";if(e.username!=null||e.password!=null){let r=e.username??"",f=e.password??"";x=`${r}:${f}@`}let O=`${S}//${x}${k}${p?`:${p}`:""}`,v={destination:new URL(O)},P={requestTimeout:this.config?.sessionTimeout,isEventStream:n},y=c?this.connectionManager.createIsolatedSession(v,P):this.connectionManager.lease(v,P),R=y.deref(),A=(r)=>{if(c)y.destroy();m=!0,w(r)},g=D?K(D):"",b=e.path;if(g)b+=`?${g}`;if(e.fragment)b+=`#${e.fragment}`;let d=R.request({...e.headers,[z.HTTP2_HEADER_PATH]:b,[z.HTTP2_HEADER_METHOD]:N});if(a)d.setTimeout(a,()=>{d.close();let r=Error(`Stream timed out because of no activity for ${a} ms`);r.name="TimeoutError",A(r)});if(t){let r=()=>{d.close();let f=I(t);A(f)};if(typeof t.addEventListener==="function"){let f=t;f.addEventListener("abort",r,{once:!0}),d.once("close",()=>f.removeEventListener("abort",r))}else t.onabort=r}d.on("frameError",(r,f,Z)=>{A(Error(`Frame type id ${r} in stream id ${Z} has failed with code ${f}.`))}),d.on("error",A),d.on("aborted",()=>{A(Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${d.rstCode}.`))}),d.on("response",(r)=>{let f=new Q({statusCode:r[":status"]??-1,headers:J(r),body:d});if(m=!0,C({response:f}),c)R.close()}),d.on("close",()=>{if(c)y.destroy();else this.connectionManager.release(v,y);if(!m)A(Error("Unexpected error: http2 request did not get a response"))}),T=G(d,e,a)})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then((o)=>({...o,[e]:t}))}httpHandlerConfigs(){return this.config??{}}}he.DEFAULT_REQUEST_TIMEOUT=fe;he.NodeHttp2Handler=q;he.NodeHttpHandler=M});
|
|
5
|
+
export{Is};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,g,en,z,B}from"./chunk-zarz3sqn.js";var S=[["path",{d:"M5 12h14",key:"1ays0h"}]],ss=z("minus",S);var fi=(o)=>{if(isNaN(o))return"00:00";let n=new Date(o*1000),t=n.getUTCHours(),e=n.getUTCMinutes().toString().padStart(2,"0"),r=n.getUTCSeconds().toString().padStart(2,"0");if(t)return`${t}:${e}:${r}`;return`${e}:${r}`},ro=(o,n,t,e)=>{if(t==="frames")return`${o} fr`;if(t==="standard")return fi(o/n);let r=Math.round(n),u=n!==r,i=!1;if(u&&(r===30||r===60))i=!0;let c=0;if(e){let s=e.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(s){let m=parseInt(s[1],10),l=parseInt(s[2],10),M=parseInt(s[3],10),w=parseInt(s[5],10);if(i=s[4]!==":",c=(m*3600+l*60+M)*r+w,i){let f=m*60+l,I=n<30?2:4;c-=I*(f-Math.floor(f/10))}}}let d=o+c;if(i){let s=n<30?2:4,m=Math.floor(d/(17982*s/2)),l=d%(17982*s/2);if(l<s)l=l+s;d+=9*s*m+s*Math.floor((l-s)/(1798*s/2))}let h=d%r,p=Math.floor(d/r)%60,x=Math.floor(d/(r*60))%60,y=Math.floor(d/(r*3600))%24,b=i?";":":";return`${y.toString().padStart(2,"0")}:${x.toString().padStart(2,"0")}:${p.toString().padStart(2,"0")}${b}${h.toString().padStart(2,"0")}`};var Ia=(o,n)=>{if(!n)return 0;let t=1/n;return o*t+t/2},Vd=(o)=>Math.max(100,3000/(o||30)),Kd=({dbTotalFrames:o,containerDuration:n,frameRate:t})=>{let e=t||30,r=Math.round(n*e);if(o<=0)return r;let u=o/e,i=n-u,c=Vd(e)/1000;return i>c?r:o};var un=en((o,n)=>({isDrawing:!1,currentTool:"arrow",currentColor:"#ef4444",annotations:[],history:[[]],historyIndex:0,setIsDrawing:(t)=>o({isDrawing:t}),setTool:(t)=>o({currentTool:t}),setColor:(t)=>o({currentColor:t}),addAnnotation:(t)=>{let{annotations:e,history:r,historyIndex:u}=n(),i=[...e,t],c=r.slice(0,u+1);c.push(i),o({annotations:i,history:c,historyIndex:c.length-1})},setAnnotations:(t)=>{o({annotations:t,history:[t],historyIndex:0})},undo:()=>{let{historyIndex:t,history:e}=n();if(t>0){let r=t-1;o({annotations:e[r],historyIndex:r})}},redo:()=>{let{historyIndex:t,history:e}=n();if(t<e.length-1){let r=t+1;o({annotations:e[r],historyIndex:r})}},reset:()=>o({isDrawing:!1,currentTool:"arrow",annotations:[],history:[[]],historyIndex:0})}));var dl=({progress:o,className:n})=>{let e=2*Math.PI*20,r=e-Math.min(100,Math.max(0,o))/100*e;return g("svg",{viewBox:"0 0 50 50",className:B("w-12 h-12",n),children:[a("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),a("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:e,strokeDashoffset:r,transform:"rotate(-90 25 25)"}),a("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round(o)}%`})]})};
|
|
2
|
+
export{ss,fi,ro,Ia,Vd,Kd,un,dl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S,Z,a,X,Je,R,Pt,qt,Ig}from"./chunk-zarz3sqn.js";import"./chunk-55h9ze53.js";import"./chunk-1ktk6764.js";import"./chunk-ah8fjb6f.js";import"./chunk-q5vkxee3.js";import{Kl}from"./chunk-srxp5jav.js";import"./chunk-b5rhvzv9.js";import"./chunk-8xb6yz11.js";import"./chunk-7sgrtxbt.js";import"./chunk-hpbn0k9n.js";import{gr}from"./chunk-pk406dgy.js";import"./chunk-257dcd2f.js";import"./chunk-91rb0jpb.js";import"./chunk-ny1kbmxt.js";Z();function m(){let{projectId:e}=c.useParams(),{teamId:r,ensureTeamIdForProject:t}=Pt();S(()=>{t(e)},[e,t]);let{data:n}=gr(Ig(e)),o=n?.rootFolder,{data:s}=X({queryKey:["folders",o],queryFn:async()=>{let d=await R.api.folders[":folderId"].$get({param:{folderId:o}});if(!d.ok)throw Error("failed to fetch folder");return await d.json()},enabled:!!o});if(!r||!o||!s)return a(qt,{});return a(Kl,{teamId:r,projectId:e,projectName:n.name??"",assetId:o,rootFolderId:o,isRoot:!0})}var c=Je("/projects/$projectId/agentsmd")({component:m});export{c as Route};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,B}from"./chunk-zarz3sqn.js";function Bn({className:t,...e}){return a("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:a("table",{"data-slot":"table",className:B("w-full caption-bottom text-sm",t),...e})})}function Un({className:t,...e}){return a("thead",{"data-slot":"table-header",className:B("[&_tr]:border-b",t),...e})}function zn({className:t,...e}){return a("tbody",{"data-slot":"table-body",className:B("[&_tr:last-child]:border-0",t),...e})}function Tr({className:t,...e}){return a("tr",{"data-slot":"table-row",className:B("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),...e})}function ft({className:t,...e}){return a("th",{"data-slot":"table-head",className:B("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function ct({className:t,...e}){return a("td",{"data-slot":"table-cell",className:B("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}
|
|
2
|
+
export{Bn,Un,zn,Tr,ft,ct};
|