@shumai-one/shumai 0.5.2 → 0.5.3
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-zf5cyxnt.js → chunk-03zkxckm.js} +1 -1
- package/bin/{chunk-2w6gve12.js → chunk-04nqnkzs.js} +3 -3
- package/bin/{chunk-rw5h0n0s.js → chunk-157axqz1.js} +1 -1
- package/bin/{chunk-w9z27p0m.js → chunk-1tesbv8w.js} +1 -1
- package/bin/{chunk-vzdgsfkf.js → chunk-24da4wg9.js} +1 -1
- package/bin/chunk-24nx3krz.js +2 -0
- package/bin/{chunk-twpc640e.js → chunk-26am2rzm.js} +1 -1
- package/bin/{chunk-8ayz61rc.js → chunk-2pt9h882.js} +3 -3
- package/bin/{chunk-mn108p93.js → chunk-2rrcdhkj.js} +1 -1
- package/bin/{chunk-ryepy5er.js → chunk-2w2bknn2.js} +4 -4
- package/bin/{chunk-ypkkfwfb.js → chunk-3ahax79y.js} +2 -2
- package/bin/{chunk-zdzkjp4q.js → chunk-3fjgf7eb.js} +2 -2
- package/bin/{chunk-rmvhyqyb.js → chunk-3wcvema0.js} +3 -3
- package/bin/{chunk-kvwec0p3.js → chunk-40tmh04g.js} +2 -2
- package/bin/chunk-45p7d22e.js +2 -0
- package/bin/chunk-461gcgrs.js +2 -0
- package/bin/{chunk-p0j4wpa5.js → chunk-4bc3gqmn.js} +1 -1
- package/bin/{chunk-8tzfcqtb.js → chunk-4nkwe7dz.js} +1 -1
- package/bin/{chunk-eqr0znmc.js → chunk-59ayg5am.js} +1 -1
- package/bin/{chunk-8zgq5sav.js → chunk-5ebb2pdf.js} +2 -2
- package/bin/{chunk-n76w2wcr.js → chunk-5y3kx4kk.js} +1 -1
- package/bin/{chunk-d2dgazjj.js → chunk-68xsb3t8.js} +1 -1
- package/bin/{chunk-n9vp9nbg.js → chunk-6hs63sva.js} +30 -30
- package/bin/{chunk-bpxw19ez.js → chunk-6pwf7qa6.js} +1 -1
- package/bin/{chunk-f5z3096k.js → chunk-6sq6dfa1.js} +2 -2
- package/bin/chunk-87secbzy.js +1 -0
- package/bin/chunk-8pykp70z.js +1 -0
- package/bin/{chunk-3pm6q6kg.js → chunk-8ts3xkme.js} +1 -1
- package/bin/{chunk-rza95y4z.js → chunk-909h3qzp.js} +2 -2
- package/bin/{chunk-0v9srsdz.js → chunk-929abwgr.js} +1 -1
- package/bin/{chunk-j53sjkxt.js → chunk-9ca8a5f2.js} +1 -1
- package/bin/{chunk-2pw7xcrn.js → chunk-9fyb95r5.js} +1 -1
- package/bin/{chunk-mneeg71d.js → chunk-axeq2pq5.js} +2 -2
- package/bin/{chunk-r249n1xe.js → chunk-b3tkvdfk.js} +2 -2
- package/bin/{chunk-9ggwc289.js → chunk-b6dbqs39.js} +1 -1
- package/bin/{chunk-w73v578p.js → chunk-b88tdt79.js} +2 -2
- package/bin/{chunk-19q13a80.js → chunk-bcyvxp1c.js} +4 -4
- package/bin/{chunk-7qvvf0yd.js → chunk-bn0taqr3.js} +2 -2
- package/bin/chunk-cb37q6t0.js +1 -0
- package/bin/chunk-cfqny70c.js +3 -0
- package/bin/{chunk-ffj9cq9y.js → chunk-cqnected.js} +1 -1
- package/bin/{chunk-98mg3dpd.js → chunk-cvfznrnt.js} +4 -4
- package/bin/{chunk-951r2rx1.js → chunk-d1q1tn36.js} +1 -1
- package/bin/{chunk-0asthrjf.js → chunk-d1rjpbgv.js} +2 -2
- package/bin/{chunk-81dawvn4.js → chunk-eshwjf91.js} +2 -2
- package/bin/{chunk-04avc4fn.js → chunk-fa9yq17g.js} +26 -26
- package/bin/{chunk-m6v8vt2b.js → chunk-fnkkwna8.js} +2 -2
- package/bin/{chunk-3q5qkfkc.js → chunk-fpjvr3qw.js} +1 -1
- package/bin/{chunk-ggfx2b0f.js → chunk-fsr83nb1.js} +1 -1
- package/bin/{chunk-kzr6ecke.js → chunk-fznchvm7.js} +1 -1
- package/bin/chunk-g2z0c39g.js +1 -0
- package/bin/{chunk-5vqbzsjv.js → chunk-gvcjqcjf.js} +1 -1
- package/bin/{chunk-0ge2mm8j.js → chunk-hbnpx0a5.js} +1 -1
- package/bin/{chunk-tvkekn4z.js → chunk-hgy9rqt1.js} +1 -1
- package/bin/chunk-hk659cg2.css +1 -0
- package/bin/{chunk-8ny7wvzb.js → chunk-hn2g40r6.js} +1 -1
- package/bin/{chunk-0y4zq3y4.js → chunk-hsx4pns6.js} +1 -1
- package/bin/{chunk-bbcmhcvc.js → chunk-hy5ncvpf.js} +2 -2
- package/bin/{chunk-5nqvqvqp.js → chunk-j420aqk8.js} +3 -3
- package/bin/{chunk-t1yamxgk.js → chunk-k3ds96cb.js} +1 -1
- package/bin/{chunk-dppfek34.js → chunk-m41tbrvt.js} +2 -2
- package/bin/chunk-m9f21ye9.js +1 -0
- package/bin/chunk-md7pgk86.js +2 -0
- package/bin/chunk-me3zmpj5.js +14 -0
- package/bin/chunk-mg6sybt0.js +1 -0
- package/bin/{chunk-jgfye6nf.js → chunk-mzme3m82.js} +1 -1
- package/bin/{chunk-ce0bhc72.js → chunk-n08h1jgx.js} +1 -1
- package/bin/{chunk-ae6zgjhd.js → chunk-ncv8v6mj.js} +2 -2
- package/bin/{chunk-cx32wsa1.js → chunk-nmd1901j.js} +1 -1
- package/bin/{chunk-wnqxyqrg.js → chunk-np39aknv.js} +2 -2
- package/bin/{chunk-dche0gy0.js → chunk-p7zw53ep.js} +1 -1
- package/bin/{chunk-xr2v0d6y.js → chunk-ppb4aj0y.js} +4 -4
- package/bin/{chunk-15vsw36h.js → chunk-pwq6dbb5.js} +5 -5
- package/bin/chunk-q1gfypy3.js +2 -0
- package/bin/{chunk-0j22699g.js → chunk-q4qqmes7.js} +2 -2
- package/bin/{chunk-vm2pz2hm.js → chunk-q7t5zs7n.js} +2 -2
- package/bin/{chunk-e439kt05.js → chunk-qcpeefhr.js} +1 -1
- package/bin/{chunk-6rn094yj.js → chunk-qjdvs1s5.js} +1 -1
- package/bin/{chunk-9zgqjdx1.js → chunk-qqapw198.js} +2 -2
- package/bin/chunk-qx553512.js +211 -0
- package/bin/chunk-r3s1x5wp.js +1 -0
- package/bin/{chunk-rtaya5wc.js → chunk-rh8dy99a.js} +2 -2
- package/bin/{chunk-5rzxekn4.js → chunk-s0vfj06y.js} +1 -1
- package/bin/{chunk-4zksqvwj.js → chunk-s6g2mzpn.js} +2 -2
- package/bin/{chunk-zckxc8m6.js → chunk-s9sf37dv.js} +2 -2
- package/bin/{chunk-19jpn3r6.js → chunk-scvepfv8.js} +1 -1
- package/bin/chunk-sjbvt3wa.js +2 -0
- package/bin/{chunk-mn208vrv.js → chunk-srmx5z3v.js} +2 -2
- package/bin/{chunk-r776bhsg.js → chunk-srv5kvm4.js} +1 -1
- package/bin/{chunk-qmrg2jhs.js → chunk-t1h12r3q.js} +5 -5
- package/bin/{chunk-gvas3xkp.js → chunk-t6myw0jf.js} +1 -1
- package/bin/{chunk-z8e4wc59.js → chunk-t8jfp3vx.js} +1 -1
- package/bin/{chunk-15w79661.js → chunk-tqdde9bj.js} +1 -1
- package/bin/chunk-vk9ecq8n.js +2 -0
- package/bin/{chunk-d5hbzp7t.js → chunk-vsnq4381.js} +1 -1
- package/bin/{chunk-1nvj833s.js → chunk-w4adkd0a.js} +5 -5
- package/bin/{chunk-qxscgcn9.js → chunk-wbmqbpgm.js} +1 -1
- package/bin/{chunk-v034sfw8.js → chunk-wperd2h9.js} +2 -2
- package/bin/{chunk-y2dhf3p0.js → chunk-xbw7ffrz.js} +2 -2
- package/bin/{chunk-9bakwac0.js → chunk-xdrpahym.js} +4 -4
- package/bin/{chunk-6jkjx0n2.js → chunk-xfmnfcv2.js} +3 -3
- package/bin/chunk-xhngtwn9.js +1 -0
- package/bin/chunk-xjnehexk.js +2 -0
- package/bin/chunk-xzb0t8mx.js +1 -0
- package/bin/{chunk-k3prp6c6.js → chunk-y5h5d5gx.js} +4 -4
- package/bin/{chunk-wwkhskce.js → chunk-y6xyc4wp.js} +2 -2
- package/bin/{chunk-93p27bbm.js → chunk-zpk87b33.js} +5 -5
- package/bin/{chunk-asy868kq.js → chunk-zq5j9wsc.js} +1 -1
- package/bin/{chunk-grjek810.js → chunk-zsg61vr0.js} +2 -2
- package/bin/chunk-zts21ft7.js +1 -0
- package/bin/{chunk-cpj562n6.js → chunk-zzbn0b6c.js} +1 -1
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +350 -333
- package/package.json +7 -7
- package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
- package/prisma/schema.prisma +10 -8
- package/bin/chunk-2gf95tj0.js +0 -1
- package/bin/chunk-2tk5w3jc.js +0 -1
- package/bin/chunk-301e7g3z.js +0 -2
- package/bin/chunk-3kmjbc3m.js +0 -2
- package/bin/chunk-3td60k1m.js +0 -2
- package/bin/chunk-42hrvk6k.js +0 -211
- package/bin/chunk-5bk16qdp.js +0 -2
- package/bin/chunk-8abhmarc.js +0 -2
- package/bin/chunk-965102pf.js +0 -3
- package/bin/chunk-acn3r2m2.js +0 -1
- package/bin/chunk-ce75dw3k.css +0 -1
- package/bin/chunk-d9qpgkek.js +0 -2
- package/bin/chunk-dv6p6n5e.js +0 -1
- package/bin/chunk-qb178ntp.js +0 -2
- package/bin/chunk-s4r6e6ms.js +0 -1
- package/bin/chunk-syjjke3f.js +0 -1
- package/bin/chunk-tgfxe0sb.js +0 -1
- package/bin/chunk-tjretpx8.js +0 -1
- package/bin/chunk-w4yjgez6.js +0 -14
- package/bin/chunk-wjcebkpb.js +0 -1
- package/bin/chunk-ws71fg50.js +0 -2
- package/bin/chunk-yfp3q4da.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m,D,u,S,L,t,o,V,Z,B,mt,ze,A,I,or,O,Kr,Tt,jn,on,Et,ka,rr,js,xo,de,So,we,Ne,E,C,Ce,Ie,Te,ge,Ae,_e,K,Ym,nh,De,B_,$_,Uc,by,vy,Ff,ct,Qy,Ky,sb,ib,gd,gb,bh,Mn,$v,Gv,Vv,Qv,Kv,Wv,Yv,xd,zw,Wx,dg,yS,RS,Eg,Vg,Gs,zd,Op,jd,hA,qp,NT,DT,gA,AA,_A,yA,bA,Hd,vA,UT,_s,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,qe,le,Mt,z,ce,es,Dr,yn,Vn,bs,Or,Qd,Nt,M,xe,Ar,Qe,zr,wi,LA,io,tm,aa,la,Si,W,Me,Le,Ze,Be,Ue,ne,Ei,Xd,ef,tf,nf}from"./chunk-42hrvk6k.js";import{$a}from"./chunk-r249n1xe.js";import{Kn,co}from"./chunk-8tzfcqtb.js";import{fn}from"./chunk-grjek810.js";S();var Ye=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ye=I("pen",Ye);function Se({scope:e,onScopeChange:r,selectedGoal:v,onClearGoal:f,onCreateTask:w,canCreateTask:h=!0}){return o("header",{className:"h-14 border-b border-border bg-card/60 backdrop-blur-sm px-4 flex items-center justify-between gap-3 shrink-0 select-none",children:[o("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:"flex items-center bg-muted/60 p-0.5 rounded-lg border border-border/50",children:[o(C,{variant:e==="team"?"secondary":"ghost",size:"sm",onClick:()=>r("team"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="team"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(co,{className:"w-3.5 h-3.5"}),t("span",{children:UT()})]}),o(C,{variant:e==="my"?"secondary":"ghost",size:"sm",onClick:()=>r("my"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="my"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(Kn,{className:"w-3.5 h-3.5"}),t("span",{children:Wx()})]})]}),v&&o("div",{className:"hidden sm:flex items-center gap-1.5 px-2 py-1 rounded-md bg-sidebar-accent border border-sidebar-border text-xs text-sidebar-accent-foreground min-w-0 max-w-[200px] md:max-w-[280px]",children:[t(So,{className:"w-3.5 h-3.5 text-sidebar-primary shrink-0"}),t("span",{className:"truncate font-medium",children:v.id===wi?_s():v.title}),t(C,{variant:"ghost",size:"icon-xs",onClick:f,className:"h-4 w-4 p-0 ml-0.5 text-muted-foreground hover:text-foreground",title:$_(),children:t(Ne,{className:"w-3 h-3"})})]})]}),h&&t("div",{className:"flex items-center gap-2 shrink-0",children:o(C,{size:"sm",onClick:w,className:"h-8 px-3 text-xs gap-1.5 shadow-xs",children:[t(de,{className:"w-3.5 h-3.5"}),t("span",{children:Ff()})]})})]})}S();S();function fe({teamId:e,isOpen:r,onClose:v,goalToEdit:f}){let w=V(),[h,_]=u(""),[b,P]=u("");m(()=>{if(f)_(f.title),P(f.description||"");else _(""),P("")},[f,r]);let{mutate:G,isPending:q}=B({mutationFn:async()=>{let n=await A.api.teams[":teamId"].kanban.goals.$post({param:{teamId:e},json:{title:h.trim(),description:b.trim()||void 0}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success($v()),v()},onError:(n)=>{M.error(n.message)}}),{mutate:Q,isPending:F}=B({mutationFn:async()=>{if(!f)return;let n=await A.api.teams[":teamId"].kanban.goals[":goalId"].$patch({param:{teamId:e,goalId:f.id},json:{title:h.trim(),description:b.trim()||null}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(Yv()),v()},onError:(n)=>{M.error(n.message)}}),H=(n)=>{if(n.preventDefault(),!h.trim())return;if(f)Q();else G()},d=q||F;return t(ue,{open:r,onOpenChange:(n)=>!n&&v(),children:t(ae,{className:"sm:max-w-xl",children:o("form",{onSubmit:H,className:"space-y-4",children:[o(pe,{children:[t(le,{children:f?bh():vy()}),t(Mt,{children:f?bh():by()})]}),o("div",{className:"space-y-3 py-2",children:[o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"goal-title",children:Kv()}),t(z,{id:"goal-title",value:h,onChange:(n)=>_(n.target.value),placeholder:Wv(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"goal-description",children:Vv()}),t(Si,{id:"goal-description",value:b,onChange:(n)=>P(n.target.value),placeholder:Qv(),rows:3})]})]}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:v,disabled:d,children:De()}),o(C,{type:"submit",disabled:!h.trim()||d,children:[d&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),f?Gs():Uc()]})]})]})})})}function Ke({teamId:e,selectedGoalId:r,onSelectGoal:v,isOwnerOrEditor:f=!0}){let w=V(),[h,_]=u(!1),[b,P]=u(null),[G,q]=u(null),[Q,F]=u(!1),{data:H,isLoading:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let i=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!i.ok)throw Error("Failed to fetch goals");return await i.json()},enabled:!!e}),n=H?.data||[],x=n.reduce((i,s)=>i+(s.taskCount||0),0),{mutate:N,isPending:l}=B({mutationFn:async(i)=>{let s=await A.api.teams[":teamId"].kanban.goals[":goalId"].$delete({param:{teamId:e,goalId:i}});if(!s.ok){let p=await s.json().catch(()=>({message:Mn()}));throw Error(p.message||Mn())}return await s.json()},onSuccess:(i,s)=>{if(w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),w.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),M.success(Gv()),r===s)v(null);q(null)},onError:(i)=>{M.error(i.message)}});if(Q)return o("div",{className:"border-r border-sidebar-border bg-sidebar flex flex-col items-center w-12 shrink-0 transition-all duration-300",children:[t("div",{className:"h-14 flex items-center justify-center border-b border-sidebar-border w-full shrink-0",children:t(C,{variant:"ghost",size:"icon-sm",onClick:()=>F(!1),title:xd(),className:"text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(Et,{className:"w-4 h-4"})})}),o("div",{className:"mt-3 flex flex-col items-center gap-2",children:[t(C,{variant:r===null?"secondary":"ghost",size:"icon-sm",onClick:()=>v(null),title:Ym(),className:E("w-8 h-8 rounded-md",r===null&&"bg-sidebar-accent text-sidebar-accent-foreground"),children:t($a,{className:"w-4 h-4"})}),t(C,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),title:dg(),className:"w-8 h-8 rounded-md text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(de,{className:"w-4 h-4"})})]}),h&&t(fe,{teamId:e,isOpen:h,onClose:()=>_(!1)})]});return o("aside",{className:"w-64 border-r border-sidebar-border bg-sidebar flex flex-col shrink-0 transition-all duration-300 select-none",children:[o("div",{className:"h-14 px-3 flex items-center justify-between border-b border-sidebar-border shrink-0",children:[o("div",{className:"flex items-center gap-2 font-semibold text-xs tracking-wider uppercase text-sidebar-foreground/70",children:[t(So,{className:"w-4 h-4 text-sidebar-primary"}),t("span",{children:xd()})]}),o("div",{className:"flex items-center gap-1",children:[f&&t(C,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:dg(),children:t(de,{className:"w-4 h-4"})}),t(C,{variant:"ghost",size:"icon-sm",onClick:()=>F(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:"Collapse",children:t(on,{className:"w-4 h-4"})})]})]}),t(ce,{className:"flex-1 p-2",children:o("div",{className:"space-y-1",children:[o("div",{onClick:()=>v(null),className:E("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group h-8 min-h-[32px]",r===null?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 truncate min-w-0",children:[t($a,{className:"w-3.5 h-3.5 shrink-0 text-sidebar-primary"}),t("span",{className:"truncate",children:Ym()})]}),x>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 shrink-0",children:x})]}),d?t("div",{className:"flex items-center justify-center p-4",children:t(O,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):n.length===0?t("div",{className:"px-2.5 py-4 text-center text-xs text-muted-foreground",children:yS()}):n.map((i)=>{let s=r===i.id,p=i.id===wi,k=p?_s():i.title,g=f&&!p;return o("div",{onClick:()=>v(i.id),className:E("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group relative min-h-[32px]",s?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t(So,{className:E("w-3.5 h-3.5 shrink-0",s?"text-sidebar-primary":"text-muted-foreground")}),t("span",{className:"line-clamp-2 break-words leading-tight",title:k,children:k})]}),t("div",{className:"flex items-center shrink-0 ml-1",children:g?o(L,{children:[(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 group-hover:hidden group-focus-within:hidden [&:has(~_div_[data-state=open])]:hidden",children:i.taskCount}),t("div",{className:"hidden group-hover:flex group-focus-within:flex [&:has([data-state=open])]:flex items-center",onClick:(c)=>c.stopPropagation(),children:o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"icon-xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",children:t(or,{className:"w-3.5 h-3.5"})})}),o(_e,{align:"end",className:"w-36",children:[o(K,{onClick:()=>{P(i)},children:[t(ye,{className:"w-3.5 h-3.5 mr-2"}),gb()]}),o(K,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q(i)},children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),ct()]})]})]})})]}):(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60",children:i.taskCount})})]},i.id)})]})}),(h||b)&&t(fe,{teamId:e,isOpen:h||!!b,goalToEdit:b,onClose:()=>{_(!1),P(null)}}),G&&t(Xe,{open:!!G,onOpenChange:(i)=>!i&&q(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:Qy()}),t(ot,{children:Ky({title:G.title})})]}),o(rt,{children:[t(it,{disabled:l,children:De()}),o(st,{onClick:()=>N(G.id),disabled:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[l&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),ct()]})]})]})})]})}S();S();function Pe(e){return+xe(e)<Date.now()}function Fe({task:e,onClick:r,onDelete:v,disabled:f,isFirst:w,isLast:h,showBottomIndicator:_,currentUserId:b,currentUserRole:P}){let{source:G}=Qd(),q=!!G,Q=P?.toLowerCase()==="owner",F=P?.toLowerCase()==="editor",H=!!b&&e.creator?.id===b,d=e.reporter?.id===b||H,n=e.assignee?.id===b,x=Q||F||d||n,N=H||Q||d,l=f||!x,{ref:i,isDragging:s}=bs({id:e.id,data:{type:"kanban_task",task:e},disabled:l}),{ref:p,isDropTarget:k}=Or({id:`reorder-before-${e.id}`,data:{type:"reorder",task:e,position:"before"},disabled:s||f}),{ref:g,isDropTarget:c}=Or({id:`reorder-after-${e.id}`,data:{type:"reorder",task:e,position:"after"},disabled:s||f}),T=e.isAgentTask,j=e.status===Qe.BLOCKED,y=e.dueDate?Pe(new Date(e.dueDate))&&e.status!==Qe.DONE:!1;return o("div",{className:"relative",children:[t("div",{ref:p,className:E("absolute left-0 right-0 z-20",w?"-top-6 h-[calc(50%+24px)]":"-top-1 h-[calc(50%+4px)]",q&&!s?"pointer-events-auto":"pointer-events-none")}),t("div",{ref:g,className:E("absolute bottom-0 left-0 right-0 z-20",h?"-bottom-6 h-[calc(50%+24px)]":"h-1/2",q&&!s?"pointer-events-auto":"pointer-events-none")}),k&&!s&&t("div",{className:"absolute -top-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),(c||_)&&!s&&t("div",{className:"absolute -bottom-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),o("div",{ref:i,onClick:()=>r(e),className:E("group relative flex flex-col gap-2 p-3 rounded-lg border text-card-foreground transition-all duration-200 cursor-pointer select-none",s&&"opacity-40 scale-95 shadow-lg ring-2 ring-primary",!s&&"hover:shadow-md","border-border/80 bg-card hover:border-primary/50 shadow-2xs",j&&"border-red-500/60 bg-red-500/[0.03] ring-1 ring-red-500/20"),children:[o("div",{className:"flex items-center justify-between gap-1.5 min-w-0",children:[o("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[t("span",{className:E("px-1.5 py-0.5 rounded text-[10px] font-medium border uppercase tracking-wider shrink-0",la(e.priority)),children:aa(e.priority)}),T&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-orange-500/15 text-orange-600 dark:text-orange-400 border border-orange-500/30 shrink-0",children:[t(Tt,{className:"w-3 h-3"}),t("span",{children:Hd()})]}),e.goal&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-muted text-muted-foreground border border-border/70 truncate max-w-[130px]",children:[t(So,{className:"w-2.5 h-2.5 shrink-0"}),t("span",{className:"truncate",children:e.goal.title})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:N&&t("div",{className:"opacity-0 group-hover:opacity-100 [&:has([data-state=open])]:opacity-100 focus-within:opacity-100 transition-opacity flex items-center",onClick:(X)=>X.stopPropagation(),children:o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground",children:t(or,{className:"w-3.5 h-3.5"})})}),t(_e,{align:"end",className:"w-32",children:o(K,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>v?.(e),children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),ct()]})})]})})})]}),t("h4",{className:"text-xs font-semibold leading-snug line-clamp-2 text-foreground break-words",children:e.title}),j&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-red-500/10 border border-red-500/20 text-[11px] text-red-600 dark:text-red-400",children:[t(Kr,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent?.blockReason||e.latestStatusEvent?.reason||e.latestStatusEvent?.summary||hA()})]}),e.status===Qe.IN_REVIEW&&e.latestStatusEvent?.summary&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-purple-500/10 border border-purple-500/20 text-[11px] text-purple-600 dark:text-purple-400",children:[t(fn,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent.summary})]}),o("div",{className:"flex items-center justify-between gap-2 pt-1 mt-auto border-t border-border/40 text-[11px] text-muted-foreground",children:[t("div",{className:"flex items-center gap-1.5 min-w-0",children:e.assignee?o(L,{children:[T?t("div",{className:"w-5 h-5 rounded-full bg-orange-500/15 border border-orange-500/30 flex items-center justify-center shrink-0",children:t(Tt,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"})}):o(Ce,{size:"sm",className:"w-5 h-5 border border-border",children:[t(Ie,{src:e.assignee.image}),t(Te,{className:"text-[9px]",children:e.assignee.name.slice(0,2).toUpperCase()})]}),t("span",{className:"truncate text-xs font-medium text-foreground/80 max-w-[90px]",children:e.assignee.name})]}):t("span",{className:"text-[11px] italic text-muted-foreground/60",children:_s()})}),o("div",{className:"flex items-center gap-2 shrink-0",children:[e.dueDate&&o("div",{className:E("flex items-center gap-1 text-[10px] font-mono",y?"text-red-500 font-semibold":"text-muted-foreground"),title:Ar(new Date(e.dueDate),"yyyy/MM/dd HH:mm"),children:[t(jn,{className:"w-3 h-3"}),t("span",{children:Ar(new Date(e.dueDate),"MM/dd")})]}),e.assetCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:zw({count:e.assetCount}),children:[t(ka,{className:"w-3 h-3"}),t("span",{children:e.assetCount})]}),e.dependencyCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.dependencyCount} dependencies`,children:[t(js,{className:"w-3 h-3"}),t("span",{children:e.dependencyCount})]}),e.commentCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.commentCount} comments`,children:[t(xo,{className:"w-3 h-3"}),t("span",{children:e.commentCount})]})]})]})]})]})}function Ee({teamId:e,status:r,selectedGoalId:v,scope:f,currentUserId:w,currentUserRole:h,onTaskClick:_,onDeleteTask:b,onCreateTaskInColumn:P}){let G=h?.toLowerCase()==="owner"||h?.toLowerCase()==="editor",q=f==="my"?w:void 0,{data:Q,fetchNextPage:F,hasNextPage:H,isFetchingNextPage:d,isLoading:n}=mt({queryKey:["teams",e,"kanban","tasks",{status:r,goalId:v,assigneeId:q}],queryFn:async({pageParam:R=""})=>{let J=await A.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:e},query:{status:r,goalId:v||void 0,assigneeId:q||void 0,first:"20",after:R||void 0}});if(!J.ok)throw Error("Failed to fetch column tasks");return await J.json()},initialPageParam:"",getNextPageParam:(R)=>R.pageInfo?.cursor||void 0,refetchInterval:5000,enabled:!!e}),{ref:x,inView:N}=Nt({threshold:0.1});m(()=>{if(N&&H&&!d)F()},[N,H,d,F]);let l=D(()=>Q?.pages?.flatMap((R)=>Array.isArray(R?.data)?R.data:[])||[],[Q]),{source:i,target:s}=Qd(),p=l.filter((R)=>R.id!==i?.id).at(-1),{ref:k,isDropTarget:g}=Or({id:r,data:{type:"kanban_column",status:r,lastTask:p}}),c=i?.data?.type==="kanban_task",T=c&&(g||s?.data?.type==="kanban_column"&&s.data.status===r||s?.data?.type==="reorder"&&s.data.task?.status===r),j=c&&s?.data?.type==="kanban_column"&&s.data.status===r,y=Q?.pages?.[0]?.pageInfo?.total??l.length,X=tm(r);return o("div",{ref:k,className:E("flex flex-col h-full max-h-full w-80 md:w-84 shrink-0 rounded-xl bg-card/60 border border-border/70 shadow-xs transition-colors duration-200 overflow-hidden select-none",T&&"ring-2 ring-primary/60 bg-primary/[0.03] border-primary/40"),children:[o("div",{className:"h-11 px-3.5 flex items-center justify-between border-b border-border/60 bg-card/80 shrink-0",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[t("div",{className:E("w-2.5 h-2.5 rounded-full shrink-0",X.dot)}),t("h3",{className:"text-xs font-bold tracking-wide uppercase text-foreground/90 truncate",children:io(r)})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-muted font-medium text-muted-foreground",children:y})})]}),t(ce,{className:"flex-1 min-h-0 [&>div>div]:block!",children:o("div",{className:"p-2.5 space-y-2.5 min-h-full flex flex-col",children:[n?t("div",{className:"flex items-center justify-center py-10",children:t(O,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):l.length===0?t("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:t("p",{className:"text-xs text-muted-foreground/70",children:RS()})}):l.map((R,J)=>t(Fe,{task:R,onClick:_,onDelete:b,isFirst:J===0,isLast:J===l.length-1,showBottomIndicator:j&&R.id===p?.id,currentUserId:w,currentUserRole:h},R.id)),t("div",{ref:x,className:"h-2"}),d&&t("div",{className:"flex justify-center py-2",children:t(O,{className:"w-4 h-4 animate-spin text-muted-foreground"})})]})}),G&&t("div",{className:"p-2 border-t border-border/50 bg-card/90 shrink-0",children:o(C,{variant:"ghost",size:"sm",onClick:()=>P(r),className:"w-full justify-center h-8 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/80 border border-dashed border-border/80",children:[t(de,{className:"w-3.5 h-3.5 mr-1.5"}),t("span",{children:Ff()})]})})]})}function Oe({teamId:e,selectedGoalId:r,scope:v,currentUserId:f,currentUserRole:w,onTaskClick:h,onCreateTaskInColumn:_}){let b=V(),[P,G]=u(null),{mutate:q,isPending:Q}=B({mutationFn:async(d)=>{let n=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$delete({param:{teamId:e,taskId:d}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{b.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),b.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(DT()),G(null)},onError:(d)=>{M.error(d.message)}}),{mutate:F}=B({mutationFn:async({taskId:d,fromStatus:n,status:x,reason:N,beforeIndex:l,afterIndex:i})=>{let s=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$patch({param:{teamId:e,taskId:d},json:{fromStatus:n,status:x,reason:N,beforeIndex:l,afterIndex:i}});if(!s.ok){let p=await s.json().catch(()=>({message:Mn()}));throw Error(p.message||Mn())}return await s.json()},onMutate:async({taskId:d,status:n,targetTaskId:x,position:N})=>{await b.cancelQueries({queryKey:["teams",e,"kanban","tasks"]});let l=b.getQueriesData({queryKey:["teams",e,"kanban","tasks"]}),i=null,s=(p)=>p[0]==="teams"&&p[1]===e&&p[2]==="kanban"&&p[3]==="tasks"&&typeof p[4]==="object"&&p[4]!==null&&("status"in p[4]);if(b.setQueriesData({predicate:(p)=>s(p.queryKey)},(p)=>{if(!p||!Array.isArray(p.pages))return p;let k=!1,g=p.pages.map((c)=>{if(!c||!Array.isArray(c.data))return c;let T=c.data.find((j)=>j.id===d);if(T)return i={...T,status:n},k=!0,{...c,data:c.data.filter((j)=>j.id!==d),pageInfo:{...c.pageInfo,total:Math.max(0,(c.pageInfo?.total??c.data.length)-1)}};return c});return k?{...p,pages:g}:p}),i){let p=i;b.setQueriesData({predicate:(k)=>{if(!s(k.queryKey))return!1;return k.queryKey[4]?.status===n}},(k)=>{if(!k||!Array.isArray(k.pages))return k;let g=k.pages.flatMap((y)=>y?.data??[]).filter((y)=>y.id!==d),c=g.length;if(x){let y=g.findIndex((X)=>X.id===x);if(y!==-1)c=N==="before"?y:y+1}g.splice(c,0,p);let T=0,j=k.pages.map((y,X)=>{let R=y?.data?y.data.length:0,J=X===0&&R===0?1:X===k.pages.length-1?g.length-T:R,te=g.slice(T,T+J);return T+=J,{...y,data:te,pageInfo:{...y?.pageInfo,total:(y?.pageInfo?.total??0)+1}}});if(T<g.length&&j.length>0){let y=j.length-1;j[y]={...j[y],data:[...j[y]?.data??[],...g.slice(T)]}}return{...k,pages:j}})}return{previousQueries:l}},onError:(d,n,x)=>{if(x?.previousQueries)for(let[N,l]of x.previousQueries)b.setQueryData(N,l);M.error(d.message)},onSettled:()=>{b.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]})}}),H=(d)=>{if(d.canceled)return;let{source:n,target:x}=d.operation;if(!n||!x)return;let N=n.data;if(N?.type!=="kanban_task"||!N.task)return;let l=N.task,i=w?.toLowerCase()==="owner",s=w?.toLowerCase()==="editor",p=l.reporter?.id===f||l.creator?.id===f,k=l.assignee?.id===f;if(!i&&!s&&!p&&!k){M.error(B_());return}let g=x.data;if(!g)return;if(g.type==="reorder"&&g.task&&g.position){let c=g.task,T=c.status;if(l.id===c.id)return;let j=g.position==="before"?c.sortIndex??void 0:void 0,y=g.position==="after"?c.sortIndex??void 0:void 0;F({taskId:l.id,fromStatus:l.status,status:T,beforeIndex:j,afterIndex:y,targetTaskId:c.id,position:g.position});return}if(g.type==="kanban_column"&&g.status){let{status:c,lastTask:T}=g;if(T){if(l.id===T.id){if(l.status===c)return;F({taskId:l.id,fromStatus:l.status,status:c});return}F({taskId:l.id,fromStatus:l.status,status:c,afterIndex:T.sortIndex??void 0,targetTaskId:T.id,position:"after"});return}if(l.status===c)return;F({taskId:l.id,fromStatus:l.status,status:c})}};return o(Vn,{sensors:[yn.configure({activationConstraints:[new Dr.Distance({value:8})]}),es],onDragEnd:H,children:[t("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden p-4 bg-background/50",children:t("div",{className:"flex gap-4 h-full min-w-max pb-2",children:LA.map((d)=>t(Ee,{teamId:e,status:d,selectedGoalId:r,scope:v,currentUserId:f,currentUserRole:w,onTaskClick:h,onDeleteTask:(n)=>G(n),onCreateTaskInColumn:_},d))})}),P&&t(Xe,{open:!!P,onOpenChange:(d)=>!d&&G(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:sb()}),t(ot,{children:ib({title:P.title})})]}),o(rt,{children:[t(it,{disabled:Q,children:De()}),o(st,{onClick:()=>q(P.id),disabled:Q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[Q&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),ct()]})]})]})})]})}S();function Ge({teamId:e,isOpen:r,onClose:v,initialGoalId:f}){let w=V(),h=f===wi||!f?"none":f,[_,b]=u(""),[P,G]=u(""),[q,Q]=u(!1),[F,H]=u(zr.MEDIUM),[d,n]=u(h),[x,N]=u("none"),[l,i]=u("none"),[s,p]=u(void 0),[k,g]=u(void 0),[c,T]=u(null),[j,y]=u(null),[X,R]=u(null),[J,te]=u([]),[re,oe]=u([]),[be,ve]=u(!1),{data:he}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let a=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!a.ok)return null;return await a.json()},enabled:!!e&&r});m(()=>{if(r)b(""),G(""),Q(!1),H(zr.MEDIUM),n(h),N("none"),i(he?.id||"none"),p(void 0),g(void 0),T(null),y(null),R(null),te([]),oe([])},[r,h,he?.id]);let{data:ke=[]}=Z({queryKey:["teams",e,"members","human"],queryFn:async()=>{let a=await A.api.teams[":teamId"].members.$get({param:{teamId:e},query:{includeAgents:"false"}});if(!a.ok)return[];let U=await a.json();return Array.isArray(U)?U:[]},enabled:!!e&&r}),{data:$e=[]}=Z({queryKey:["teams",e,"agents"],queryFn:async()=>{let a=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!a.ok)return[];return await a.json()||[]},enabled:!!e&&r}),{data:He}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let a=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!a.ok)return{data:[]};return await a.json()},enabled:!!e&&r}),Ve=He?.data||[],{mutate:Je,isPending:se}=B({mutationFn:async()=>{let a=await A.api.teams[":teamId"].kanban.tasks.$post({param:{teamId:e},json:{title:_.trim(),description:P.trim()||void 0,isAgentTask:q,priority:F,goalId:d!=="none"?d:void 0,assigneeId:x!=="none"?x:void 0,reporterId:l!=="none"?l:void 0,startDate:s?s.toISOString():void 0,dueDate:k?k.toISOString():void 0,projectId:c||void 0,targetFolderId:j||void 0,parentIds:J.length>0?J:void 0,assetIds:re.length>0?re.map((U)=>U.id):void 0}});if(!a.ok){let U=await a.text().catch(()=>""),Y=Mn();if(U)try{let me=JSON.parse(U);if(me&&typeof me.message==="string")Y=me.message}catch{Y=U}throw Error(Y)}return await a.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(NT()),v()},onError:(a)=>{M.error(a.message)}}),We=(a)=>{if(a.preventDefault(),!_.trim()||se)return;Je()},ie=q;return t(ue,{open:r,onOpenChange:(a)=>!a&&v(),children:o(ae,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto",children:[o("form",{onSubmit:We,className:"space-y-4",children:[t(pe,{children:t(le,{children:Ff()})}),o("div",{className:"space-y-3.5 py-1",children:[o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"create-task-title",children:yA()}),t(z,{id:"create-task-title",value:_,onChange:(a)=>b(a.target.value),placeholder:bA(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"create-task-desc",children:gA()}),t(Si,{id:"create-task-desc",value:P,onChange:(a)=>G(a.target.value),placeholder:AA(),rows:3})]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o("div",{className:"sm:col-span-2 flex items-center justify-between space-x-2 rounded-lg border border-border/80 bg-muted/30 p-2.5 h-14",children:[o("div",{className:"space-y-0.5 min-w-0 pr-2",children:[o(W,{htmlFor:"create-is-agent-task",className:"text-xs font-medium cursor-pointer flex items-center gap-1.5",children:[t(Tt,{className:"w-3.5 h-3.5 text-orange-500"}),t("span",{children:Hd()})]}),t("p",{className:"text-[11px] text-muted-foreground line-clamp-1",children:vA()})]}),t(Me,{id:"create-is-agent-task",checked:q,onCheckedChange:(a)=>{Q(a),N("none")}})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:_A()}),o(Le,{value:F,onValueChange:(a)=>H(a),children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{})}),t(Ue,{children:Object.values(zr).map((a)=>t(ne,{value:a,children:t("span",{className:E("px-1.5 py-0.5 rounded text-[10px] uppercase font-medium",la(a)),children:aa(a)})},a))})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:xd()}),o(Le,{value:d,onValueChange:n,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:"None"})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:"None"})}),Ve.filter((a)=>a.id!==wi).map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(So,{className:"w-3.5 h-3.5 text-primary"}),t("span",{children:a.title})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:ie?zd():nh()}),o(Le,{value:x,onValueChange:N,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:_s()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:_s()})}),ie?$e.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(Tt,{className:"w-3.5 h-3.5 text-purple-500"}),t("span",{children:a.name})]})},a.id)):ke.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:Vg()}),o(Le,{value:l,onValueChange:i,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:_s()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:_s()})}),ke.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),ie&&o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:qp()}),o(C,{type:"button",variant:"outline",size:"sm",onClick:()=>ve(!0),className:"w-full justify-start h-9 text-xs truncate font-normal",children:[t(rr,{className:"w-3.5 h-3.5 mr-2 text-primary shrink-0"}),t("span",{className:"truncate",children:X||Op()})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:jd()}),t(Ei,{value:s,onChange:p,placeholder:jd(),className:"h-9 text-xs"})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:gd()}),t(Ei,{value:k,onChange:g,placeholder:gd(),className:"h-9 text-xs"})]}),o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:Eg()}),t(Xd,{teamId:e,value:J,onChange:te})]}),t("div",{className:"sm:col-span-2 pt-1",children:t(ef,{teamId:e,projectId:c,assets:re,onAddAssets:(a)=>oe((U)=>[...U,...a]),onRemoveAsset:(a)=>oe((U)=>U.filter((Y)=>Y.id!==a))})})]})]}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:v,disabled:se,children:De()}),o(C,{type:"submit",disabled:!_.trim()||se,children:[se&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),Uc()]})]})]}),be&&t(tf,{teamId:e,currentProjectId:c,currentTargetFolderId:j,isOpen:be,onClose:()=>ve(!1),onSelect:(a,U,Y)=>{T(a),y(U),R(Y||"Selected Folder")}})]})})}function je({teamId:e,initialTaskId:r}){let[v,f]=u("team"),[w,h]=u(null),[_,b]=u(r??null),[P,G]=u(!1);m(()=>{if(r)b(r)},[r]);let[q,Q]=u(Qe.TODO),{data:F,isLoading:H}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let s=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!s.ok)throw Error("Failed to fetch me");return await s.json()},enabled:!!e}),{data:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let s=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!s.ok)return{data:[]};return await s.json()},enabled:!!e}),n=d?.data||[],x=w?n.find((s)=>s.id===w)||null:null,N=F?.role?.toLowerCase()==="owner"||F?.role?.toLowerCase()==="editor",l=(s=Qe.TODO)=>{Q(s),G(!0)},i=(s)=>{b(s.id)};if(H)return t("div",{className:"flex h-full items-center justify-center",children:t(O,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-row h-full bg-background overflow-hidden font-sans",children:[t(Ke,{teamId:e,selectedGoalId:w,onSelectGoal:h,isOwnerOrEditor:N}),o("div",{className:"flex-1 flex flex-col min-w-0 h-full overflow-hidden",children:[t(Se,{scope:v,onScopeChange:f,selectedGoal:x,onClearGoal:()=>h(null),onCreateTask:()=>l(Qe.TODO),canCreateTask:N}),t(Oe,{teamId:e,selectedGoalId:w,scope:v,currentUserId:F?.id,currentUserRole:F?.role,onTaskClick:i,onCreateTaskInColumn:(s)=>l(s)})]}),_&&t(nf,{teamId:e,taskId:_,isOpen:!!_,onClose:()=>b(null),canEdit:N}),P&&t(Ge,{teamId:e,isOpen:P,initialStatus:q,initialGoalId:w,onClose:()=>G(!1)})]})}function at(){let{teamId:e}=Re.useParams(),{taskId:r}=Re.useSearch();return t(je,{teamId:e,initialTaskId:r})}var Re=ze("/teams/$teamId/kanban")({component:at});export{Re as Route};
|
|
1
|
+
import{m,D,u,S,L,t,o,V,Z,B,mt,ze,A,I,rr,O,Kr,Tt,jn,nn,Et,ka,lr,qs,xo,de,So,we,Ne,C,E,Ce,Ie,Te,ge,Ae,_e,K,Ym,nh,De,U_,G_,jc,vy,wy,Ff,ct,Ky,Wy,ib,ab,gd,Ab,bh,Mn,Gv,Vv,Qv,Kv,Wv,Yv,Jv,xd,jw,Wx,ug,yS,RS,Sg,Gg,Vs,zd,Op,jd,mA,qp,PT,NT,hA,gA,AA,_A,yA,Hd,bA,BT,_s,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,qe,le,Mt,z,ce,es,Dr,_n,Vn,bs,Or,Qd,Nt,M,xe,Ar,Qe,zr,xi,FA,io,tm,aa,la,Ei,W,Me,Le,Ze,Be,Ue,ne,Ci,Xd,ef,tf,nf}from"./chunk-qx553512.js";import{Ga}from"./chunk-b3tkvdfk.js";import{Kn,co}from"./chunk-4nkwe7dz.js";import{dn}from"./chunk-zsg61vr0.js";S();var Ye=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ye=I("pen",Ye);function Se({scope:e,onScopeChange:r,selectedGoal:v,onClearGoal:f,onCreateTask:w,canCreateTask:h=!0}){return o("header",{className:"h-14 border-b border-border bg-card/60 backdrop-blur-sm px-4 flex items-center justify-between gap-3 shrink-0 select-none",children:[o("div",{className:"flex items-center gap-3 min-w-0",children:[o("div",{className:"flex items-center bg-muted/60 p-0.5 rounded-lg border border-border/50",children:[o(E,{variant:e==="team"?"secondary":"ghost",size:"sm",onClick:()=>r("team"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="team"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(co,{className:"w-3.5 h-3.5"}),t("span",{children:BT()})]}),o(E,{variant:e==="my"?"secondary":"ghost",size:"sm",onClick:()=>r("my"),className:`h-7 px-2.5 text-xs font-medium gap-1.5 transition-all ${e==="my"?"bg-background text-foreground shadow-xs":"text-muted-foreground hover:text-foreground"}`,children:[t(Kn,{className:"w-3.5 h-3.5"}),t("span",{children:Wx()})]})]}),v&&o("div",{className:"hidden sm:flex items-center gap-1.5 px-2 py-1 rounded-md bg-sidebar-accent border border-sidebar-border text-xs text-sidebar-accent-foreground min-w-0 max-w-[200px] md:max-w-[280px]",children:[t(So,{className:"w-3.5 h-3.5 text-sidebar-primary shrink-0"}),t("span",{className:"truncate font-medium",children:v.id===xi?_s():v.title}),t(E,{variant:"ghost",size:"icon-xs",onClick:f,className:"h-4 w-4 p-0 ml-0.5 text-muted-foreground hover:text-foreground",title:G_(),children:t(Ne,{className:"w-3 h-3"})})]})]}),h&&t("div",{className:"flex items-center gap-2 shrink-0",children:o(E,{size:"sm",onClick:w,className:"h-8 px-3 text-xs gap-1.5 shadow-xs",children:[t(de,{className:"w-3.5 h-3.5"}),t("span",{children:Ff()})]})})]})}S();S();function fe({teamId:e,isOpen:r,onClose:v,goalToEdit:f}){let w=V(),[h,_]=u(""),[b,P]=u("");m(()=>{if(f)_(f.title),P(f.description||"");else _(""),P("")},[f,r]);let{mutate:G,isPending:q}=B({mutationFn:async()=>{let n=await A.api.teams[":teamId"].kanban.goals.$post({param:{teamId:e},json:{title:h.trim(),description:b.trim()||void 0}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(Gv()),v()},onError:(n)=>{M.error(n.message)}}),{mutate:Q,isPending:F}=B({mutationFn:async()=>{if(!f)return;let n=await A.api.teams[":teamId"].kanban.goals[":goalId"].$patch({param:{teamId:e,goalId:f.id},json:{title:h.trim(),description:b.trim()||null}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(Jv()),v()},onError:(n)=>{M.error(n.message)}}),H=(n)=>{if(n.preventDefault(),!h.trim())return;if(f)Q();else G()},d=q||F;return t(ue,{open:r,onOpenChange:(n)=>!n&&v(),children:t(ae,{className:"sm:max-w-xl",children:o("form",{onSubmit:H,className:"space-y-4",children:[o(pe,{children:[t(le,{children:f?bh():wy()}),t(Mt,{children:f?bh():vy()})]}),o("div",{className:"space-y-3 py-2",children:[o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"goal-title",children:Wv()}),t(z,{id:"goal-title",value:h,onChange:(n)=>_(n.target.value),placeholder:Yv(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"goal-description",children:Qv()}),t(Ei,{id:"goal-description",value:b,onChange:(n)=>P(n.target.value),placeholder:Kv(),rows:3})]})]}),o(qe,{children:[t(E,{type:"button",variant:"outline",onClick:v,disabled:d,children:De()}),o(E,{type:"submit",disabled:!h.trim()||d,children:[d&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),f?Vs():jc()]})]})]})})})}function Ke({teamId:e,selectedGoalId:r,onSelectGoal:v,isOwnerOrEditor:f=!0}){let w=V(),[h,_]=u(!1),[b,P]=u(null),[G,q]=u(null),[Q,F]=u(!1),{data:H,isLoading:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let i=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!i.ok)throw Error("Failed to fetch goals");return await i.json()},enabled:!!e}),n=H?.data||[],x=n.reduce((i,s)=>i+(s.taskCount||0),0),{mutate:N,isPending:l}=B({mutationFn:async(i)=>{let s=await A.api.teams[":teamId"].kanban.goals[":goalId"].$delete({param:{teamId:e,goalId:i}});if(!s.ok){let p=await s.json().catch(()=>({message:Mn()}));throw Error(p.message||Mn())}return await s.json()},onSuccess:(i,s)=>{if(w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),w.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),M.success(Vv()),r===s)v(null);q(null)},onError:(i)=>{M.error(i.message)}});if(Q)return o("div",{className:"border-r border-sidebar-border bg-sidebar flex flex-col items-center w-12 shrink-0 transition-all duration-300",children:[t("div",{className:"h-14 flex items-center justify-center border-b border-sidebar-border w-full shrink-0",children:t(E,{variant:"ghost",size:"icon-sm",onClick:()=>F(!1),title:xd(),className:"text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(Et,{className:"w-4 h-4"})})}),o("div",{className:"mt-3 flex flex-col items-center gap-2",children:[t(E,{variant:r===null?"secondary":"ghost",size:"icon-sm",onClick:()=>v(null),title:Ym(),className:C("w-8 h-8 rounded-md",r===null&&"bg-sidebar-accent text-sidebar-accent-foreground"),children:t(Ga,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),title:ug(),className:"w-8 h-8 rounded-md text-sidebar-foreground/70 hover:text-sidebar-foreground",children:t(de,{className:"w-4 h-4"})})]}),h&&t(fe,{teamId:e,isOpen:h,onClose:()=>_(!1)})]});return o("aside",{className:"w-64 border-r border-sidebar-border bg-sidebar flex flex-col shrink-0 transition-all duration-300 select-none",children:[o("div",{className:"h-14 px-3 flex items-center justify-between border-b border-sidebar-border shrink-0",children:[o("div",{className:"flex items-center gap-2 font-semibold text-xs tracking-wider uppercase text-sidebar-foreground/70",children:[t(So,{className:"w-4 h-4 text-sidebar-primary"}),t("span",{children:xd()})]}),o("div",{className:"flex items-center gap-1",children:[f&&t(E,{variant:"ghost",size:"icon-sm",onClick:()=>_(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:ug(),children:t(de,{className:"w-4 h-4"})}),t(E,{variant:"ghost",size:"icon-sm",onClick:()=>F(!0),className:"h-7 w-7 text-sidebar-foreground/70 hover:text-sidebar-foreground",title:"Collapse",children:t(nn,{className:"w-4 h-4"})})]})]}),t(ce,{className:"flex-1 p-2",children:o("div",{className:"space-y-1",children:[o("div",{onClick:()=>v(null),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group h-8 min-h-[32px]",r===null?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 truncate min-w-0",children:[t(Ga,{className:"w-3.5 h-3.5 shrink-0 text-sidebar-primary"}),t("span",{className:"truncate",children:Ym()})]}),x>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 shrink-0",children:x})]}),d?t("div",{className:"flex items-center justify-center p-4",children:t(O,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):n.length===0?t("div",{className:"px-2.5 py-4 text-center text-xs text-muted-foreground",children:yS()}):n.map((i)=>{let s=r===i.id,p=i.id===xi,k=p?_s():i.title,g=f&&!p;return o("div",{onClick:()=>v(i.id),className:C("flex items-center justify-between px-2.5 py-1 rounded-md text-xs font-medium cursor-pointer transition-colors group relative min-h-[32px]",s?"bg-sidebar-accent text-sidebar-accent-foreground font-semibold shadow-xs":"text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"),children:[o("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t(So,{className:C("w-3.5 h-3.5 shrink-0",s?"text-sidebar-primary":"text-muted-foreground")}),t("span",{className:"line-clamp-2 break-words leading-tight",title:k,children:k})]}),t("div",{className:"flex items-center shrink-0 ml-1",children:g?o(L,{children:[(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60 group-hover:hidden group-focus-within:hidden [&:has(~_div_[data-state=open])]:hidden",children:i.taskCount}),t("div",{className:"hidden group-hover:flex group-focus-within:flex [&:has([data-state=open])]:flex items-center",onClick:(c)=>c.stopPropagation(),children:o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",children:t(rr,{className:"w-3.5 h-3.5"})})}),o(_e,{align:"end",className:"w-36",children:[o(K,{onClick:()=>{P(i)},children:[t(ye,{className:"w-3.5 h-3.5 mr-2"}),Ab()]}),o(K,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>{q(i)},children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),ct()]})]})]})})]}):(i.taskCount??0)>0&&t("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded-full bg-sidebar-border text-sidebar-foreground/60",children:i.taskCount})})]},i.id)})]})}),(h||b)&&t(fe,{teamId:e,isOpen:h||!!b,goalToEdit:b,onClose:()=>{_(!1),P(null)}}),G&&t(Xe,{open:!!G,onOpenChange:(i)=>!i&&q(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:Ky()}),t(ot,{children:Wy({title:G.title})})]}),o(rt,{children:[t(it,{disabled:l,children:De()}),o(st,{onClick:()=>N(G.id),disabled:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[l&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),ct()]})]})]})})]})}S();S();function Pe(e){return+xe(e)<Date.now()}function Fe({task:e,onClick:r,onDelete:v,disabled:f,isFirst:w,isLast:h,showBottomIndicator:_,currentUserId:b,currentUserRole:P}){let{source:G}=Qd(),q=!!G,Q=P?.toLowerCase()==="owner",F=P?.toLowerCase()==="editor",H=!!b&&e.creator?.id===b,d=e.reporter?.id===b||H,n=e.assignee?.id===b,x=Q||F||d||n,N=H||Q||d,l=f||!x,{ref:i,isDragging:s}=bs({id:e.id,data:{type:"kanban_task",task:e},disabled:l}),{ref:p,isDropTarget:k}=Or({id:`reorder-before-${e.id}`,data:{type:"reorder",task:e,position:"before"},disabled:s||f}),{ref:g,isDropTarget:c}=Or({id:`reorder-after-${e.id}`,data:{type:"reorder",task:e,position:"after"},disabled:s||f}),T=e.isAgentTask,j=e.status===Qe.BLOCKED,y=e.dueDate?Pe(new Date(e.dueDate))&&e.status!==Qe.DONE:!1;return o("div",{className:"relative",children:[t("div",{ref:p,className:C("absolute left-0 right-0 z-20",w?"-top-6 h-[calc(50%+24px)]":"-top-1 h-[calc(50%+4px)]",q&&!s?"pointer-events-auto":"pointer-events-none")}),t("div",{ref:g,className:C("absolute bottom-0 left-0 right-0 z-20",h?"-bottom-6 h-[calc(50%+24px)]":"h-1/2",q&&!s?"pointer-events-auto":"pointer-events-none")}),k&&!s&&t("div",{className:"absolute -top-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),(c||_)&&!s&&t("div",{className:"absolute -bottom-1.5 left-0 right-0 h-[3px] rounded-full bg-primary shadow-[0_0_8px_rgba(var(--primary),0.6)] z-30 pointer-events-none"}),o("div",{ref:i,onClick:()=>r(e),className:C("group relative flex flex-col gap-2 p-3 rounded-lg border text-card-foreground transition-all duration-200 cursor-pointer select-none",s&&"opacity-40 scale-95 shadow-lg ring-2 ring-primary",!s&&"hover:shadow-md","border-border/80 bg-card hover:border-primary/50 shadow-2xs",j&&"border-red-500/60 bg-red-500/[0.03] ring-1 ring-red-500/20"),children:[o("div",{className:"flex items-center justify-between gap-1.5 min-w-0",children:[o("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] font-medium border uppercase tracking-wider shrink-0",la(e.priority)),children:aa(e.priority)}),T&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold bg-orange-500/15 text-orange-600 dark:text-orange-400 border border-orange-500/30 shrink-0",children:[t(Tt,{className:"w-3 h-3"}),t("span",{children:Hd()})]}),e.goal&&o("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-muted text-muted-foreground border border-border/70 truncate max-w-[130px]",children:[t(So,{className:"w-2.5 h-2.5 shrink-0"}),t("span",{className:"truncate",children:e.goal.title})]})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:N&&t("div",{className:"opacity-0 group-hover:opacity-100 [&:has([data-state=open])]:opacity-100 focus-within:opacity-100 transition-opacity flex items-center",onClick:(X)=>X.stopPropagation(),children:o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(E,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground",children:t(rr,{className:"w-3.5 h-3.5"})})}),t(_e,{align:"end",className:"w-32",children:o(K,{className:"text-destructive focus:text-destructive focus:bg-destructive/10",onClick:()=>v?.(e),children:[t(we,{className:"w-3.5 h-3.5 mr-2"}),ct()]})})]})})})]}),t("h4",{className:"text-xs font-semibold leading-snug line-clamp-2 text-foreground break-words",children:e.title}),j&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-red-500/10 border border-red-500/20 text-[11px] text-red-600 dark:text-red-400",children:[t(Kr,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent?.blockReason||e.latestStatusEvent?.reason||e.latestStatusEvent?.summary||mA()})]}),e.status===Qe.IN_REVIEW&&e.latestStatusEvent?.summary&&o("div",{className:"flex items-start gap-1.5 p-1.5 rounded bg-purple-500/10 border border-purple-500/20 text-[11px] text-purple-600 dark:text-purple-400",children:[t(dn,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t("span",{className:"line-clamp-2 break-words",children:e.latestStatusEvent.summary})]}),o("div",{className:"flex items-center justify-between gap-2 pt-1 mt-auto border-t border-border/40 text-[11px] text-muted-foreground",children:[t("div",{className:"flex items-center gap-1.5 min-w-0",children:e.assignee?o(L,{children:[T?t("div",{className:"w-5 h-5 rounded-full bg-orange-500/15 border border-orange-500/30 flex items-center justify-center shrink-0",children:t(Tt,{className:"w-3 h-3 text-orange-600 dark:text-orange-400"})}):o(Ce,{size:"sm",className:"w-5 h-5 border border-border",children:[t(Ie,{src:e.assignee.image}),t(Te,{className:"text-[9px]",children:e.assignee.name.slice(0,2).toUpperCase()})]}),t("span",{className:"truncate text-xs font-medium text-foreground/80 max-w-[90px]",children:e.assignee.name})]}):t("span",{className:"text-[11px] italic text-muted-foreground/60",children:_s()})}),o("div",{className:"flex items-center gap-2 shrink-0",children:[e.dueDate&&o("div",{className:C("flex items-center gap-1 text-[10px] font-mono",y?"text-red-500 font-semibold":"text-muted-foreground"),title:Ar(new Date(e.dueDate),"yyyy/MM/dd HH:mm"),children:[t(jn,{className:"w-3 h-3"}),t("span",{children:Ar(new Date(e.dueDate),"MM/dd")})]}),e.assetCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:jw({count:e.assetCount}),children:[t(ka,{className:"w-3 h-3"}),t("span",{children:e.assetCount})]}),e.dependencyCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.dependencyCount} dependencies`,children:[t(qs,{className:"w-3 h-3"}),t("span",{children:e.dependencyCount})]}),e.commentCount>0&&o("div",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground",title:`${e.commentCount} comments`,children:[t(xo,{className:"w-3 h-3"}),t("span",{children:e.commentCount})]})]})]})]})]})}function Ee({teamId:e,status:r,selectedGoalId:v,scope:f,currentUserId:w,currentUserRole:h,onTaskClick:_,onDeleteTask:b,onCreateTaskInColumn:P}){let G=h?.toLowerCase()==="owner"||h?.toLowerCase()==="editor",q=f==="my"?w:void 0,{data:Q,fetchNextPage:F,hasNextPage:H,isFetchingNextPage:d,isLoading:n}=mt({queryKey:["teams",e,"kanban","tasks",{status:r,goalId:v,assigneeId:q}],queryFn:async({pageParam:R=""})=>{let J=await A.api.teams[":teamId"].kanban.tasks.$get({param:{teamId:e},query:{status:r,goalId:v||void 0,assigneeId:q||void 0,first:"20",after:R||void 0}});if(!J.ok)throw Error("Failed to fetch column tasks");return await J.json()},initialPageParam:"",getNextPageParam:(R)=>R.pageInfo?.cursor||void 0,refetchInterval:5000,enabled:!!e}),{ref:x,inView:N}=Nt({threshold:0.1});m(()=>{if(N&&H&&!d)F()},[N,H,d,F]);let l=D(()=>Q?.pages?.flatMap((R)=>Array.isArray(R?.data)?R.data:[])||[],[Q]),{source:i,target:s}=Qd(),p=l.filter((R)=>R.id!==i?.id).at(-1),{ref:k,isDropTarget:g}=Or({id:r,data:{type:"kanban_column",status:r,lastTask:p}}),c=i?.data?.type==="kanban_task",T=c&&(g||s?.data?.type==="kanban_column"&&s.data.status===r||s?.data?.type==="reorder"&&s.data.task?.status===r),j=c&&s?.data?.type==="kanban_column"&&s.data.status===r,y=Q?.pages?.[0]?.pageInfo?.total??l.length,X=tm(r);return o("div",{ref:k,className:C("flex flex-col h-full max-h-full w-80 md:w-84 shrink-0 rounded-xl bg-card/60 border border-border/70 shadow-xs transition-colors duration-200 overflow-hidden select-none",T&&"ring-2 ring-primary/60 bg-primary/[0.03] border-primary/40"),children:[o("div",{className:"h-11 px-3.5 flex items-center justify-between border-b border-border/60 bg-card/80 shrink-0",children:[o("div",{className:"flex items-center gap-2 min-w-0",children:[t("div",{className:C("w-2.5 h-2.5 rounded-full shrink-0",X.dot)}),t("h3",{className:"text-xs font-bold tracking-wide uppercase text-foreground/90 truncate",children:io(r)})]}),t("div",{className:"flex items-center gap-1 shrink-0",children:t("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-muted font-medium text-muted-foreground",children:y})})]}),t(ce,{className:"flex-1 min-h-0 [&>div>div]:block!",children:o("div",{className:"p-2.5 space-y-2.5 min-h-full flex flex-col",children:[n?t("div",{className:"flex items-center justify-center py-10",children:t(O,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):l.length===0?t("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center",children:t("p",{className:"text-xs text-muted-foreground/70",children:RS()})}):l.map((R,J)=>t(Fe,{task:R,onClick:_,onDelete:b,isFirst:J===0,isLast:J===l.length-1,showBottomIndicator:j&&R.id===p?.id,currentUserId:w,currentUserRole:h},R.id)),t("div",{ref:x,className:"h-2"}),d&&t("div",{className:"flex justify-center py-2",children:t(O,{className:"w-4 h-4 animate-spin text-muted-foreground"})})]})}),G&&t("div",{className:"p-2 border-t border-border/50 bg-card/90 shrink-0",children:o(E,{variant:"ghost",size:"sm",onClick:()=>P(r),className:"w-full justify-center h-8 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/80 border border-dashed border-border/80",children:[t(de,{className:"w-3.5 h-3.5 mr-1.5"}),t("span",{children:Ff()})]})})]})}function Oe({teamId:e,selectedGoalId:r,scope:v,currentUserId:f,currentUserRole:w,onTaskClick:h,onCreateTaskInColumn:_}){let b=V(),[P,G]=u(null),{mutate:q,isPending:Q}=B({mutationFn:async(d)=>{let n=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$delete({param:{teamId:e,taskId:d}});if(!n.ok){let x=await n.json().catch(()=>({message:Mn()}));throw Error(x.message||Mn())}return await n.json()},onSuccess:()=>{b.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),b.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(NT()),G(null)},onError:(d)=>{M.error(d.message)}}),{mutate:F}=B({mutationFn:async({taskId:d,fromStatus:n,status:x,reason:N,beforeIndex:l,afterIndex:i})=>{let s=await A.api.teams[":teamId"].kanban.tasks[":taskId"].$patch({param:{teamId:e,taskId:d},json:{fromStatus:n,status:x,reason:N,beforeIndex:l,afterIndex:i}});if(!s.ok){let p=await s.json().catch(()=>({message:Mn()}));throw Error(p.message||Mn())}return await s.json()},onMutate:async({taskId:d,status:n,targetTaskId:x,position:N})=>{await b.cancelQueries({queryKey:["teams",e,"kanban","tasks"]});let l=b.getQueriesData({queryKey:["teams",e,"kanban","tasks"]}),i=null,s=(p)=>p[0]==="teams"&&p[1]===e&&p[2]==="kanban"&&p[3]==="tasks"&&typeof p[4]==="object"&&p[4]!==null&&("status"in p[4]);if(b.setQueriesData({predicate:(p)=>s(p.queryKey)},(p)=>{if(!p||!Array.isArray(p.pages))return p;let k=!1,g=p.pages.map((c)=>{if(!c||!Array.isArray(c.data))return c;let T=c.data.find((j)=>j.id===d);if(T)return i={...T,status:n},k=!0,{...c,data:c.data.filter((j)=>j.id!==d),pageInfo:{...c.pageInfo,total:Math.max(0,(c.pageInfo?.total??c.data.length)-1)}};return c});return k?{...p,pages:g}:p}),i){let p=i;b.setQueriesData({predicate:(k)=>{if(!s(k.queryKey))return!1;return k.queryKey[4]?.status===n}},(k)=>{if(!k||!Array.isArray(k.pages))return k;let g=k.pages.flatMap((y)=>y?.data??[]).filter((y)=>y.id!==d),c=g.length;if(x){let y=g.findIndex((X)=>X.id===x);if(y!==-1)c=N==="before"?y:y+1}g.splice(c,0,p);let T=0,j=k.pages.map((y,X)=>{let R=y?.data?y.data.length:0,J=X===0&&R===0?1:X===k.pages.length-1?g.length-T:R,te=g.slice(T,T+J);return T+=J,{...y,data:te,pageInfo:{...y?.pageInfo,total:(y?.pageInfo?.total??0)+1}}});if(T<g.length&&j.length>0){let y=j.length-1;j[y]={...j[y],data:[...j[y]?.data??[],...g.slice(T)]}}return{...k,pages:j}})}return{previousQueries:l}},onError:(d,n,x)=>{if(x?.previousQueries)for(let[N,l]of x.previousQueries)b.setQueryData(N,l);M.error(d.message)},onSettled:()=>{b.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]})}}),H=(d)=>{if(d.canceled)return;let{source:n,target:x}=d.operation;if(!n||!x)return;let N=n.data;if(N?.type!=="kanban_task"||!N.task)return;let l=N.task,i=w?.toLowerCase()==="owner",s=w?.toLowerCase()==="editor",p=l.reporter?.id===f||l.creator?.id===f,k=l.assignee?.id===f;if(!i&&!s&&!p&&!k){M.error(U_());return}let g=x.data;if(!g)return;if(g.type==="reorder"&&g.task&&g.position){let c=g.task,T=c.status;if(l.id===c.id)return;let j=g.position==="before"?c.sortIndex??void 0:void 0,y=g.position==="after"?c.sortIndex??void 0:void 0;F({taskId:l.id,fromStatus:l.status,status:T,beforeIndex:j,afterIndex:y,targetTaskId:c.id,position:g.position});return}if(g.type==="kanban_column"&&g.status){let{status:c,lastTask:T}=g;if(T){if(l.id===T.id){if(l.status===c)return;F({taskId:l.id,fromStatus:l.status,status:c});return}F({taskId:l.id,fromStatus:l.status,status:c,afterIndex:T.sortIndex??void 0,targetTaskId:T.id,position:"after"});return}if(l.status===c)return;F({taskId:l.id,fromStatus:l.status,status:c})}};return o(Vn,{sensors:[_n.configure({activationConstraints:[new Dr.Distance({value:8})]}),es],onDragEnd:H,children:[t("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-hidden p-4 bg-background/50",children:t("div",{className:"flex gap-4 h-full min-w-max pb-2",children:FA.map((d)=>t(Ee,{teamId:e,status:d,selectedGoalId:r,scope:v,currentUserId:f,currentUserRole:w,onTaskClick:h,onDeleteTask:(n)=>G(n),onCreateTaskInColumn:_},d))})}),P&&t(Xe,{open:!!P,onOpenChange:(d)=>!d&&G(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:ib()}),t(ot,{children:ab({title:P.title})})]}),o(rt,{children:[t(it,{disabled:Q,children:De()}),o(st,{onClick:()=>q(P.id),disabled:Q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[Q&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),ct()]})]})]})})]})}S();function Ge({teamId:e,isOpen:r,onClose:v,initialGoalId:f}){let w=V(),h=f===xi||!f?"none":f,[_,b]=u(""),[P,G]=u(""),[q,Q]=u(!1),[F,H]=u(zr.MEDIUM),[d,n]=u(h),[x,N]=u("none"),[l,i]=u("none"),[s,p]=u(void 0),[k,g]=u(void 0),[c,T]=u(null),[j,y]=u(null),[X,R]=u(null),[J,te]=u([]),[re,oe]=u([]),[be,ve]=u(!1),{data:he}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let a=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!a.ok)return null;return await a.json()},enabled:!!e&&r});m(()=>{if(r)b(""),G(""),Q(!1),H(zr.MEDIUM),n(h),N("none"),i(he?.id||"none"),p(void 0),g(void 0),T(null),y(null),R(null),te([]),oe([])},[r,h,he?.id]);let{data:ke=[]}=Z({queryKey:["teams",e,"members","human"],queryFn:async()=>{let a=await A.api.teams[":teamId"].members.$get({param:{teamId:e},query:{includeAgents:"false"}});if(!a.ok)return[];let U=await a.json();return Array.isArray(U)?U:[]},enabled:!!e&&r}),{data:$e=[]}=Z({queryKey:["teams",e,"agents"],queryFn:async()=>{let a=await A.api.teams[":teamId"].agents.$get({param:{teamId:e}});if(!a.ok)return[];return await a.json()||[]},enabled:!!e&&r}),{data:He}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let a=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!a.ok)return{data:[]};return await a.json()},enabled:!!e&&r}),Ve=He?.data||[],{mutate:Je,isPending:se}=B({mutationFn:async()=>{let a=await A.api.teams[":teamId"].kanban.tasks.$post({param:{teamId:e},json:{title:_.trim(),description:P.trim()||void 0,isAgentTask:q,priority:F,goalId:d!=="none"?d:void 0,assigneeId:x!=="none"?x:void 0,reporterId:l!=="none"?l:void 0,startDate:s?s.toISOString():void 0,dueDate:k?k.toISOString():void 0,projectId:c||void 0,targetFolderId:j||void 0,parentIds:J.length>0?J:void 0,assetIds:re.length>0?re.map((U)=>U.id):void 0}});if(!a.ok){let U=await a.text().catch(()=>""),Y=Mn();if(U)try{let me=JSON.parse(U);if(me&&typeof me.message==="string")Y=me.message}catch{Y=U}throw Error(Y)}return await a.json()},onSuccess:()=>{w.invalidateQueries({queryKey:["teams",e,"kanban","tasks"]}),w.invalidateQueries({queryKey:["teams",e,"kanban","goals"]}),M.success(PT()),v()},onError:(a)=>{M.error(a.message)}}),We=(a)=>{if(a.preventDefault(),!_.trim()||se)return;Je()},ie=q;return t(ue,{open:r,onOpenChange:(a)=>!a&&v(),children:o(ae,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto",children:[o("form",{onSubmit:We,className:"space-y-4",children:[t(pe,{children:t(le,{children:Ff()})}),o("div",{className:"space-y-3.5 py-1",children:[o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"create-task-title",children:_A()}),t(z,{id:"create-task-title",value:_,onChange:(a)=>b(a.target.value),placeholder:yA(),required:!0,autoFocus:!0})]}),o("div",{className:"space-y-1.5",children:[t(W,{htmlFor:"create-task-desc",children:hA()}),t(Ei,{id:"create-task-desc",value:P,onChange:(a)=>G(a.target.value),placeholder:gA(),rows:3})]}),o("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[o("div",{className:"sm:col-span-2 flex items-center justify-between space-x-2 rounded-lg border border-border/80 bg-muted/30 p-2.5 h-14",children:[o("div",{className:"space-y-0.5 min-w-0 pr-2",children:[o(W,{htmlFor:"create-is-agent-task",className:"text-xs font-medium cursor-pointer flex items-center gap-1.5",children:[t(Tt,{className:"w-3.5 h-3.5 text-orange-500"}),t("span",{children:Hd()})]}),t("p",{className:"text-[11px] text-muted-foreground line-clamp-1",children:bA()})]}),t(Me,{id:"create-is-agent-task",checked:q,onCheckedChange:(a)=>{Q(a),N("none")}})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:AA()}),o(Le,{value:F,onValueChange:(a)=>H(a),children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{})}),t(Ue,{children:Object.values(zr).map((a)=>t(ne,{value:a,children:t("span",{className:C("px-1.5 py-0.5 rounded text-[10px] uppercase font-medium",la(a)),children:aa(a)})},a))})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:xd()}),o(Le,{value:d,onValueChange:n,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:"None"})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:"None"})}),Ve.filter((a)=>a.id!==xi).map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(So,{className:"w-3.5 h-3.5 text-primary"}),t("span",{children:a.title})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:ie?zd():nh()}),o(Le,{value:x,onValueChange:N,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:_s()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:_s()})}),ie?$e.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[t(Tt,{className:"w-3.5 h-3.5 text-purple-500"}),t("span",{children:a.name})]})},a.id)):ke.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:Gg()}),o(Le,{value:l,onValueChange:i,children:[t(Be,{className:"w-full h-9 text-xs",children:t(Ze,{placeholder:_s()})}),o(Ue,{children:[t(ne,{value:"none",children:t("span",{className:"text-muted-foreground italic",children:_s()})}),ke.map((a)=>t(ne,{value:a.id,children:o("div",{className:"flex items-center gap-2",children:[o(Ce,{size:"sm",className:"w-4 h-4",children:[t(Ie,{src:a.image}),t(Te,{className:"text-[8px]",children:a.name.slice(0,2).toUpperCase()})]}),t("span",{children:a.name})]})},a.id))]})]})]}),ie&&o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:qp()}),o(E,{type:"button",variant:"outline",size:"sm",onClick:()=>ve(!0),className:"w-full justify-start h-9 text-xs truncate font-normal",children:[t(lr,{className:"w-3.5 h-3.5 mr-2 text-primary shrink-0"}),t("span",{className:"truncate",children:X||Op()})]})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:jd()}),t(Ci,{value:s,onChange:p,placeholder:jd(),className:"h-9 text-xs"})]}),o("div",{className:"space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:gd()}),t(Ci,{value:k,onChange:g,placeholder:gd(),className:"h-9 text-xs"})]}),o("div",{className:"sm:col-span-2 space-y-1.5",children:[t(W,{className:"text-xs font-medium text-muted-foreground",children:Sg()}),t(Xd,{teamId:e,value:J,onChange:te})]}),t("div",{className:"sm:col-span-2 pt-1",children:t(ef,{teamId:e,projectId:c,assets:re,onAddAssets:(a)=>oe((U)=>[...U,...a]),onRemoveAsset:(a)=>oe((U)=>U.filter((Y)=>Y.id!==a))})})]})]}),o(qe,{children:[t(E,{type:"button",variant:"outline",onClick:v,disabled:se,children:De()}),o(E,{type:"submit",disabled:!_.trim()||se,children:[se&&t(O,{className:"w-4 h-4 mr-1.5 animate-spin"}),jc()]})]})]}),be&&t(tf,{teamId:e,currentProjectId:c,currentTargetFolderId:j,isOpen:be,onClose:()=>ve(!1),onSelect:(a,U,Y)=>{T(a),y(U),R(Y||"Selected Folder")}})]})})}function je({teamId:e,initialTaskId:r}){let[v,f]=u("team"),[w,h]=u(null),[_,b]=u(r??null),[P,G]=u(!1);m(()=>{if(r)b(r)},[r]);let[q,Q]=u(Qe.TODO),{data:F,isLoading:H}=Z({queryKey:["teams",e,"me"],queryFn:async()=>{let s=await A.api.teams[":teamId"].me.$get({param:{teamId:e}});if(!s.ok)throw Error("Failed to fetch me");return await s.json()},enabled:!!e}),{data:d}=Z({queryKey:["teams",e,"kanban","goals"],queryFn:async()=>{let s=await A.api.teams[":teamId"].kanban.goals.$get({param:{teamId:e},query:{}});if(!s.ok)return{data:[]};return await s.json()},enabled:!!e}),n=d?.data||[],x=w?n.find((s)=>s.id===w)||null:null,N=F?.role?.toLowerCase()==="owner"||F?.role?.toLowerCase()==="editor",l=(s=Qe.TODO)=>{Q(s),G(!0)},i=(s)=>{b(s.id)};if(H)return t("div",{className:"flex h-full items-center justify-center",children:t(O,{className:"w-8 h-8 animate-spin text-muted-foreground"})});return o("div",{className:"flex flex-row h-full bg-background overflow-hidden font-sans",children:[t(Ke,{teamId:e,selectedGoalId:w,onSelectGoal:h,isOwnerOrEditor:N}),o("div",{className:"flex-1 flex flex-col min-w-0 h-full overflow-hidden",children:[t(Se,{scope:v,onScopeChange:f,selectedGoal:x,onClearGoal:()=>h(null),onCreateTask:()=>l(Qe.TODO),canCreateTask:N}),t(Oe,{teamId:e,selectedGoalId:w,scope:v,currentUserId:F?.id,currentUserRole:F?.role,onTaskClick:i,onCreateTaskInColumn:(s)=>l(s)})]}),_&&t(nf,{teamId:e,taskId:_,isOpen:!!_,onClose:()=>b(null),canEdit:N}),P&&t(Ge,{teamId:e,isOpen:P,initialStatus:q,initialGoalId:w,onClose:()=>G(!1)})]})}function at(){let{teamId:e}=Re.useParams(),{taskId:r}=Re.useSearch();return t(je,{teamId:e,initialTaskId:r})}var Re=ze("/teams/$teamId/kanban")({component:at});export{Re as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P,m,D,_,u,S,L,t,o,V,Z,B,mt,ze,A,I,O,Pe,on,Et,ro,no,Lo,de,we,Ne,C,ge,Ae,_e,K,Wr,Vt,Ef,km,If,e_,t_,Mf,kf,De,W_,na,fy,hy,fh,ct,Bf,bb,Ob,Ch,jb,Gb,Vb,Qb,Kb,Wb,Da,vi,Hc,Gf,Oa,Cv,Dv,lw,ww,Sw,Uw,jw,qw,Ed,$x,PS,DS,zS,qS,gp,xg,Ap,xE,SE,Rl,OC,$C,Gn,WC,iI,cI,aA,Ua,Qc,Pl,Zp,Bp,Up,Nl,Kc,Wc,zp,jp,Yc,jT,qT,HT,$T,VT,_n,Yp,D1,O1,Jc,MA,H1,$1,G1,V1,Q1,ue,ae,pe,qe,le,z,ce,ut,Dr,yn,Vn,eu,M,vr,dn,W,Me,Le,Ze,Be,Ue,ne,Ei,$t,_r,Ct,lm}from"./chunk-42hrvk6k.js";import{Va}from"./chunk-04avc4fn.js";import{au,Ti}from"./chunk-w4yjgez6.js";import{jo}from"./chunk-w9z27p0m.js";import"./chunk-ffj9cq9y.js";import"./chunk-wnqxyqrg.js";import"./chunk-5bk16qdp.js";import{Ir}from"./chunk-bpxw19ez.js";import{da,Hl}from"./chunk-rza95y4z.js";import{ua}from"./chunk-jgfye6nf.js";import{Ul}from"./chunk-v034sfw8.js";import{zl}from"./chunk-8abhmarc.js";import{nr}from"./chunk-qb178ntp.js";import"./chunk-wwkhskce.js";import{Wl,Yl}from"./chunk-bbcmhcvc.js";import"./chunk-8tzfcqtb.js";import"./chunk-9zgqjdx1.js";import{uo}from"./chunk-qxscgcn9.js";import"./chunk-grjek810.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-d2dgazjj.js";S();var kt=[["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=I("folder-open",kt);var St=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=I("list-filter",St);S();function _t({ratio:a}){switch(a){case"16:9":return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return t("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return t("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return t("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return t("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function st(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:st(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function It(){return{id:st(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var rt=[{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"}],Ft={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function ft({open:a,onOpenChange:y,initialConfig:h,shareId:f,teamId:N,onSaveSuccess:v}){let q=V(),[d,w]=u([]),[c,x]=u(null),[R,H]=u(null),[k,xe]=u("16:9"),[ve,be]=u("grid"),[Ce,J]=u(!1),[he,ie]=u("new"),[fe,ee]=u(""),[te,re]=u(null),F=_(null),se=_(null),[oe,Ie]=u({w:0,h:0}),[T,G]=u(!1),s=P((e)=>{if(se.current=e,!e)return;let l=()=>{let{clientWidth:E,clientHeight:b}=e;if(E<=0||b<=0)return;let Q=Ft[k],at=E,Re=at/Q;if(Re>b)Re=b,at=Re*Q;Ie({w:Math.round(at),h:Math.round(Re)})};l();let n=new ResizeObserver(l);return n.observe(e),()=>{n.disconnect(),se.current=null}},[k]),X=ut((e)=>e.teamId),ye=N||X,[Qe,je]=u(!1),[Y,Fe]=u({}),me=_(null),ke=A.api.teams[":teamId"].files.$post,Te=async(e,l)=>{let n=e.target.files?.[0];if(!n)return;if(n.size>1048576){if(M.error(Cv()),me.current)me.current.value="";return}if(!ye){M.error(Hc());return}je(!0);let E=URL.createObjectURL(n);Fe((b)=>({...b,[l]:E}));try{let b=await ke({param:{teamId:ye},form:{file:n}});if(!b.ok)throw Error(Hc());let Q=await b.json();j(l,{imageAssetKey:Q.key,imageAssetUrl:Q.url})}catch(b){let Q=b instanceof Error?b.message:Hc();M.error(Q)}finally{if(je(!1),me.current)me.current.value=""}};m(()=>{if(a){if(h?.blocks&&h.blocks.length>0)w(h.blocks),x(h.blocks[0].id);else{let e=dt();w([e]),x(e.id)}H(null)}},[a,h]);let{data:U=[]}=Z({queryKey:["watermark-templates",N],queryFn:async()=>{let e=await A.api["watermark-templates"].$get({query:N?{teamId:N}:{}});if(!e.ok)return[];return await e.json()},enabled:a}),Ee=A.api.shares[":shareId"].watermark.$put,{mutate:Se,isPending:Ve}=B({mutationFn:async(e)=>{let l=await Ee({param:{shareId:f},json:{enabled:!0,config:e}});if(!l.ok){let n=await l.json().catch(()=>null);throw Error(n?.error||vi())}return await l.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["share",f]}),q.invalidateQueries({queryKey:["shares"]}),M.success(Q1()),y(!1),v?.()},onError:(e)=>{M.error(e.message||vi())}}),He=A.api["watermark-templates"].$post,{mutate:Ge,isPending:Xe}=B({mutationFn:async({name:e,config:l})=>{let n=await He({json:{name:e,teamId:N||void 0,config:l}});if(!n.ok)throw Error(vi());return await n.json()},onSuccess:(e)=>{q.invalidateQueries({queryKey:["watermark-templates"]}),H(e.id),J(!1),M.success(HT())},onError:()=>{M.error(vi())}}),Ye=A.api["watermark-templates"][":templateId"].$put,{mutate:We,isPending:Je}=B({mutationFn:async({templateId:e,config:l})=>{let n=await Ye({param:{templateId:e},json:{config:l}});if(!n.ok)throw Error(vi());return await n.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["watermark-templates"]}),J(!1),M.success($T())},onError:()=>{M.error(vi())}}),r=A.api["watermark-templates"][":templateId"].$delete,{mutate:p}=B({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Da())},onSuccess:(e,l)=>{if(q.invalidateQueries({queryKey:["watermark-templates"]}),R===l)H(null);M.success(jT())},onError:()=>{M.error(Da())}}),g=d.findIndex((e)=>e.id===c),i=g>=0?d[g]:null,$e=()=>{let e=dt();w((l)=>[...l,e]),x(e.id)},xt=()=>{let e=It();w((l)=>[...l,e]),x(e.id)},nt=(e)=>{if(!e)return;w((l)=>{let n=l.filter((E)=>E.id!==e);if(c===e)x(n.length>0?n[Math.max(0,g-1)].id:null);return n})},j=(e,l)=>{w((n)=>n.map((E)=>E.id===e?{...E,...l}:E))},ht=()=>{if(d.length===0)return;let e=(g-1+d.length)%d.length;x(d[e].id)},vt=()=>{if(d.length===0)return;let e=(g+1)%d.length;x(d[e].id)},wt=(e,l)=>{e.stopPropagation(),x(l),G(!0)},et=P((e)=>{if(!T||!c||!F.current)return;let l=F.current.getBoundingClientRect(),n=(e.clientX-l.left)/l.width,E=(e.clientY-l.top)/l.height,b=Math.max(0,Math.min(1,Math.round(n*100)/100)),Q=Math.max(0,Math.min(1,Math.round(E*100)/100));j(c,{x:b,y:Q})},[T,c]),tt=P(()=>{G(!1)},[]);m(()=>{if(T)window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt);return()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}},[T,et,tt]),m(()=>{let e=(l)=>{if(!a||!c)return;let n=l.target?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||n==="select")return;if(l.key==="Delete"||l.key==="Backspace")l.preventDefault(),nt(c)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,g]);let bt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let l=e.config.blocks.map((n)=>({...n,id:st()}));w(l),x(l[0].id),H(e.id)}},yt=()=>{if(d.length===0){M.error(DS());return}Se({blocks:d})},Nt=()=>{if(he==="new"){if(!fe.trim()){M.error(Ch());return}Ge({name:fe.trim(),config:{blocks:d}})}else{let e=te||R;if(!e){M.error(aA());return}We({templateId:e,config:{blocks:d}})}};return o(L,{children:[t(ue,{open:a,onOpenChange:y,children:o(ae,{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:[o("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[t("div",{className:"flex items-center gap-3",children:t(le,{className:"text-base font-semibold",children:$1()})}),o("div",{className:"flex items-center gap-2",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[t(it,{className:"h-4 w-4 text-muted-foreground"}),G1()]})}),o(_e,{align:"end",className:"w-56",children:[t(Wr,{className:"text-xs font-semibold text-muted-foreground",children:qw()}),U.length===0?t("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:PS()}):U.map((e)=>o(K,{onClick:()=>bt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{className:"truncate flex-1",children:e.name}),R===e.id&&t(Pe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),t(C,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(l)=>{l.stopPropagation(),p(e.id)},children:t(we,{className:"h-3 w-3"})})]},e.id)),t(Vt,{}),o(K,{onClick:()=>{ie("new"),ee(""),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(de,{className:"h-3.5 w-3.5 text-primary"}),fh()]}),U.length>0&&o(K,{onClick:()=>{ie("overwrite"),re(R||U[0].id),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(ua,{className:"h-3.5 w-3.5 text-muted-foreground"}),xg()]})]})]}),t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>y(!1),children:De()}),o(C,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ve,onClick:yt,children:[t(ua,{className:"h-3.5 w-3.5"}),WC()]})]})]}),o("div",{className:"flex-1 flex overflow-hidden",children:[o("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[o("div",{className:"flex items-center justify-between mb-3",children:[t("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)=>o(C,{variant:k===e?"secondary":"ghost",size:"sm",className:Oe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",k===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>xe(e),children:[t(_t,{ratio:e}),t("span",{children:e})]},e))}),t("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:rt.map((e)=>t("button",{type:"button",onClick:()=>be(e.id),style:{backgroundColor:e.bg},className:Oe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",ve===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),t("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=rt.find((n)=>n.id===ve)||rt[0],l=oe.w>0&&oe.h>0;return t("div",{ref:F,onClick:()=>x(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...l?{width:oe.w,height:oe.h}:{}},className:Oe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",k==="16:9"&&"aspect-[16/9] w-full max-h-full",k==="9:16"&&"aspect-[9/16] h-full max-w-full",k==="4:3"&&"aspect-[4/3] w-full max-h-full",k==="3:4"&&"aspect-[3/4] h-full max-w-full",k==="1:1"&&"aspect-square h-full max-w-full"),children:d.map((n)=>{let E=n.id===c,b=n.size*(oe.w||640);return t("div",{onMouseDown:(Q)=>wt(Q,n.id),onClick:(Q)=>{Q.stopPropagation(),x(n.id)},style:{left:`${n.x*100}%`,top:`${n.y*100}%`,transform:`translate(-50%, -50%) rotate(${n.rotation}deg)`,opacity:n.opacity},className:Oe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",E?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:n.type==="text"?t("span",{style:{fontSize:`${b}px`,color:n.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.text||"Text"}):t("div",{style:{width:`${b}px`,height:`${b}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:Y[n.id]||n.imageAssetUrl?t("img",{src:Y[n.id]||n.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):t(ro,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},n.id)})})})()})]}),o("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[t("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:o("div",{className:"flex items-center gap-2",children:[t(no,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-xs font-semibold",children:MA()})]})}),o("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-1",children:[t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:ht,children:t(on,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:d.length===0?"0 / 0":`${g+1} / ${d.length}`})}),t(_e,{align:"start",className:"w-48",children:d.map((e,l)=>o(K,{onClick:()=>x(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[o("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?t(Va,{className:"h-3.5 w-3.5 text-muted-foreground"}):t(ro,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),o("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",l+1]})]},e.id))})]}),t(C,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:vt,children:t(Et,{className:"h-4 w-4"})})]}),o("div",{className:"flex items-center gap-1",children:[i&&t(C,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:ct(),onClick:()=>nt(i.id),children:t(we,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(C,{size:"sm",className:"h-7 text-xs gap-1",children:[t(de,{className:"h-3.5 w-3.5"}),Ef()]})}),o(_e,{align:"end",children:[o(K,{onClick:$e,className:"text-xs gap-2 cursor-pointer",children:[t(Va,{className:"h-3.5 w-3.5"}),If()]}),o(K,{onClick:xt,className:"text-xs gap-2 cursor-pointer",children:[t(ro,{className:"h-3.5 w-3.5"}),km()]})]})]})]})]}),t(ce,{className:"flex-1 min-h-0 p-4",children:i?o("div",{className:"space-y-5 text-xs",children:[o("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[o("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[i.type==="text"?t(Va,{className:"h-4 w-4 text-primary"}):t(ro,{className:"h-4 w-4 text-primary"}),i.type==="text"?If():km()]}),o("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",i.id.slice(0,6)]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[t(W,{className:"text-xs",children:VT()}),t(z,{type:"text",value:i.text,onChange:(e)=>j(i.id,{text:e.target.value}),className:"text-xs h-8"})]}),i.type==="image"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:ww()}),i.imageAssetKey&&o("button",{type:"button",onClick:()=>j(i.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:[t(Ne,{className:"w-3.5 h-3.5"}),Rl?Rl():"Remove"]})]}),t("input",{type:"file",ref:me,className:"hidden",accept:"image/*",onChange:(e)=>Te(e,i.id)}),o("div",{onClick:()=>me.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:[Qe&&t("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:o("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[t(O,{className:"w-4 h-4 animate-spin text-primary"}),t("span",{className:"text-xs font-semibold",children:Jc()})]})}),Y[i.id]||i.imageAssetUrl?o(L,{children:[t("img",{src:Y[i.id]||i.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),o("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:[t(uo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),t("span",{className:"text-xs font-semibold",children:Yp()})]})]}):o("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[t("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:t(uo,{className:"w-4 h-4 text-muted-foreground"})}),o("div",{children:[t("p",{className:"text-xs font-medium text-foreground",children:D1()}),t("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:O1()})]})]})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:i.type==="text"?Dv():Sw()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.size*100),"%"]})]}),o("div",{className:"flex items-center gap-3",children:[t(jo,{min:i.type==="text"?0.01:0.02,max:i.type==="text"?0.12:0.5,step:0.005,value:[i.size],onValueChange:([e])=>j(i.id,{size:e}),className:"flex-1"}),t(z,{type:"number",min:1,max:100,value:Math.round(i.size*100),onChange:(e)=>j(i.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"})]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:W_()}),t("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:i.color})]}),o("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),t(z,{type:"text",value:i.color,onChange:(e)=>j(i.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),t("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>t("button",{type:"button",onClick:()=>j(i.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:zS()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.opacity*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.opacity],onValueChange:([e])=>j(i.id,{opacity:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:$C()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[i.rotation,"°"]})]}),t(jo,{min:-180,max:180,step:1,value:[i.rotation],onValueChange:([e])=>j(i.id,{rotation:e})}),t("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>o(C,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>j(i.id,{rotation:e}),children:[e,"°"]},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.x*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.x],onValueChange:([e])=>j(i.id,{x:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:SE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.y*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.y],onValueChange:([e])=>j(i.id,{y:e})})]})]}):o("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[t("p",{children:cI()}),o(C,{size:"sm",variant:"outline",onClick:$e,children:[t(de,{className:"h-3.5 w-3.5 mr-1"}),If()]})]})})]})]})]})}),t(ue,{open:Ce,onOpenChange:J,children:o(ae,{className:"max-w-md",children:[t(pe,{children:t(le,{className:"text-sm font-semibold",children:he==="new"?fh():xg()})}),t("div",{className:"py-3 space-y-4 text-xs",children:he==="new"?o("div",{className:"space-y-2",children:[t(W,{children:qT()}),t(z,{type:"text",value:fe,onChange:(e)=>ee(e.target.value),placeholder:Ch(),className:"text-xs"})]}):o("div",{className:"space-y-2",children:[t(W,{children:aA()}),t("select",{value:te||"",onChange:(e)=>re(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:U.map((e)=>t("option",{value:e.id,children:e.name},e.id))})]})}),o(qe,{children:[t(C,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>J(!1),children:De()}),t(C,{size:"sm",className:"text-xs",disabled:Xe||Je,onClick:Nt,children:na()})]})]})})]})}function Oe(...a){return a.filter(Boolean).join(" ")}S();function gt({shareLink:a,viewMode:y,onViewModeChange:h,defaultSortOrder:f,onSortOrderChange:N}){let v=V(),[q,d]=u(a.password||""),[w,c]=u(a.expireAt?new Date(a.expireAt):void 0),[x,R]=u(!1);m(()=>{d(a.password||"")},[a.password]);let[H,k]=u(a.hasPassword),[xe,ve]=u(!!a.expireAt),{data:be,refetch:Ce}=Z({queryKey:["share-watermark",a.id],queryFn:async()=>{let s=await A.api.shares[":shareId"].watermark.$get({param:{shareId:a.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||a.watermarkStatus)==="processing"?3000:!1}),J=A.api.shares[":shareId"].watermark.$put,{mutate:he}=B({mutationFn:async()=>{let s=await J({param:{shareId:a.id},json:{enabled:!1}});if(!s.ok)throw Error(vi());return await s.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["share-watermark",a.id]}),M.success(H1())}}),ie=be?.watermarkStatus??a.watermarkStatus??(a.watermarkConfigId?"ready":"disabled"),fe=be?.watermarkConfig?.config??a.watermarkConfig?.config??null,ee=fe!==null&&ie!=="disabled",{data:te}=Z({queryKey:["fields",a.projectId],queryFn:async()=>{let s=await A.api.projects[":projectId"].fields.$get({param:{projectId:a.projectId}});if(!s.ok)throw Error(Gb());return await s.json()},enabled:!!a.projectId}),re=A.api.shares[":shareId"].$put,{mutate:F}=B({mutationFn:async(s)=>{let X=await re({param:{shareId:a.id},json:s});if(!X.ok)throw Error(vi());return await X.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),M.success(Ua())}}),se=`${window.location.origin}/share/${a.id}`,oe=async(s)=>{if(await fo(s))M.success(fy())},Ie=(s)=>{let X=a.fieldVisibility||{},ye={...X,[s]:!X[s]};F({fieldVisibility:ye})},T="index",G="asc";if(f){let s=f.split(":");T=s[0],G=s[1]||"asc"}return o("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[t("div",{className:"flex-1 overflow-y-auto",children:o("div",{className:"p-4 space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[t("h3",{className:"text-sm font-medium",children:Uw()}),t(Me,{checked:!a.isDisabled,onCheckedChange:(s)=>F({isDisabled:!s})})]}),o("div",{className:"relative w-full",children:[t(z,{value:se,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),t(C,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>oe(se),children:t(Nr,{className:"h-4 w-4"})})]})]}),o("div",{className:"space-y-1",children:[t(Ke,{title:iI(),icon:t(Yl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Ap()}),t(Me,{checked:H,onCheckedChange:(s)=>{if(k(s),!s)F({password:null})}})]}),H&&o("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[t(z,{type:"text",value:q,onChange:(s)=>d(s.target.value),placeholder:Ob(),className:"text-xs"}),t(C,{size:"sm",onClick:()=>F({password:q}),children:Gn()})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:jb()}),t(Me,{checked:xe,onCheckedChange:(s)=>{if(ve(s),!s)c(void 0),F({expireAt:null})}})]}),xe&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:t(Ei,{value:w,onChange:(s)=>{c(s),F({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:e_()}),t(Me,{checked:a.allowDownload,onCheckedChange:(s)=>F({allowDownload:s})})]}),t("p",{className:"text-xs text-muted-foreground",children:t_()})]}),o("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:MA()}),t(Me,{checked:ee,disabled:ie==="processing",onCheckedChange:(s)=>{if(!s)he();else R(!0)}})]}),ee&&ie==="processing"&&o("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[t(O,{className:"h-3.5 w-3.5 animate-spin"}),t("span",{children:V1()})]}),ee&&ie!=="processing"&&t(C,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>R(!0),children:bb()})]})]})}),t(Ke,{title:Mf(),icon:t(Wl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[o(C,{variant:y==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("card"),children:[t(no,{className:"h-4 w-4"}),lw()]}),o(C,{variant:y==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("list"),children:[t(Lo,{className:"h-4 w-4"}),jw()]})]})}),t(Ke,{title:Oa(),icon:t(lt,{className:"h-4 w-4"}),children:t("div",{className:"p-3 space-y-3 pt-2",children:te?.map((s)=>o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:s.config?.name}),t(Me,{checked:a.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>Ie(s.id)})]},s.id))})}),t(Ke,{title:Pl(),icon:t(zl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Gf()}),o(Le,{value:T,onValueChange:(s)=>{if(s==="index")N(null);else N(`${s}:${G}`)},children:[t(Be,{className:"w-full text-xs h-9",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"index",children:Zp()}),t(ne,{value:"name",children:Nl()}),t(ne,{value:"createdAt",children:Bp()}),t(ne,{value:"size",children:zp()})]})]})]}),o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:gp()}),o(C,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:T==="index",onClick:()=>{N(`${T}:${G==="asc"?"desc":"asc"}`)},children:[t("span",{children:T==="name"?G==="asc"?Qc():Yc():T==="createdAt"?G==="asc"?Wc():Kc():T==="size"?G==="asc"?jp():Up():G==="asc"?kf():Bf()}),t(au,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),o("div",{className:"p-4 border-t border-border space-y-2",children:[o(C,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(se,"_blank"),children:[t(Ul,{className:"h-4 w-4 mr-2"}),qS()]}),o(C,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>oe(se),children:[t(Nr,{className:"h-4 w-4 mr-2"}),hy()]})]}),t(ft,{open:x,onOpenChange:R,initialConfig:fe,shareId:a.id,onSaveSuccess:()=>{Ce(),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["shares",a.projectId]})}})]})}function Ke({title:a,icon:y,children:h}){let[f,N]=u(!1);return o("div",{className:"border-b border-border last:border-0",children:[o("button",{onClick:()=>N(!f),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[o("div",{className:"flex items-center gap-3",children:[y,t("span",{className:"text-sm font-medium",children:a})]}),t(Et,{className:Dt("h-4 w-4 transition-transform",f&&"rotate-90")})]}),f&&h&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:h})]})}function Dt(...a){return a.filter(Boolean).join(" ")}function ot({teamId:a,projectId:y,projectName:h,shareId:f,rootFolderId:N}){let v=V(),{fetchMetadata:q}=_r();m(()=>{if(a)q(a)},[a,q]);let{data:d}=Z({queryKey:["share",f],queryFn:async()=>{let r=await A.api.shares[":shareId"].$get({param:{shareId:f}});if(!r.ok)throw Error(Kb());return await r.json()}}),w=d?.rootFolderId,[c,x]=u(null),[R,H]=u([]);m(()=>{if(w)x(w),H([]),U(new Set)},[w,f]);let k=dn((r)=>r.setProjectState),xe=dn((r)=>r.clearProjectState),ve=(r)=>{if(r===c)return;if(r===w)x(w),H([]);else{let p=R.findIndex((g)=>g.id===r);if(p!==-1)x(r),H(R.slice(p+1))}U(new Set)},[be,Ce]=u(240),[J,he]=u(360),{shareConfigLeftSidebarCollapsed:ie,shareConfigRightSidebarCollapsed:fe}=$t(),ee=d?.defaultSortOrder||null,te,re;if(ee){let r=ee.split(":");te=r[0],re=r[1]}let F=d?.viewMode??"card",{data:se,fetchNextPage:oe,hasNextPage:Ie,isFetchingNextPage:T,isLoading:G}=mt({queryKey:["folder-children",a,c,"folder",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"folder",after:r,sort:te,order:re}});if(!p.ok)throw Error(Qb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:X,hasNextPage:ye,isFetchingNextPage:Qe,isLoading:je}=mt({queryKey:["folder-children",a,c,"file",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"file",after:r,sort:te,order:re}});if(!p.ok)throw Error(Vb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),Y=D(()=>se?.pages.flatMap((r)=>r.data??[])??[],[se]),Fe=D(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);m(()=>{if(d)k({teamId:a,projectId:y,projectName:h,ancestorFolders:R,currentAsset:{name:c===w?d.name:Y.find((r)=>r.id===c)?.name||d.name,type:"folder"},isRootFolder:!1,shareId:f,onFolderClick:ve});return()=>xe()},[a,y,h,R,c,w,d,f,Y,k,xe]);let[me,ke]=u(null),[Te,U]=u(new Set),Ee=()=>{U(new Set),ke(null)},{dragState:Se,handleDragStart:Ve,handleDragEnd:He}=Hl({teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedIds:Te,onClearSelection:Ee}),Ge=A.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Xe}=B({mutationFn:async(r)=>{if(!(await Ge({param:{shareId:f,assetId:r}})).ok)throw Error(Wb())},onSuccess:()=>{v.invalidateQueries({queryKey:["folder-children",a,c]}),M.success(OC())}}),Ye=A.api.shares[":shareId"].$put,{mutate:We}=B({mutationFn:async(r)=>{let p=await Ye({param:{shareId:f},json:r});if(!p.ok)throw Error(vi());return await p.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["share",f]}),M.success(Ua())}}),Je=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let p=c===w?d?.name||"":Y.find((g)=>g.id===c)?.name||_n();H((g)=>[{id:c,name:p},...g]),x(r.id),U(new Set)}};if(!d)return t("div",{children:Ed()});return o(Vn,{modifiers:[da.configure({anchor:{x:0,y:0}})],sensors:[yn.configure({activationConstraints:[new Dr.Distance({value:10})]})],onDragStart:Ve,onDragEnd:He,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!ie&&o(L,{children:[t("div",{className:"bg-background",style:{width:be},children:t(vr,{teamId:a,projectId:y,projectName:h,rootFolderId:N,dragState:Se})}),t(Ir,{onResize:(r)=>Ce((p)=>Math.max(180,Math.min(400,p+r)))})]}),t(Ti,{teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedItem:me,selectedIds:Te,onItemSelect:(r,p)=>{if(p.metaKey||p.ctrlKey){let g=new Set(Te);if(g.has(r.id)){if(g.delete(r.id),U(g),me?.id===r.id){let i=[...Y,...Fe].find(($e)=>g.has($e.id));ke(i||null)}}else g.add(r.id),U(g),ke(r)}else U(new Set([r.id])),ke(r)},onItemDoubleClick:Je,onSaveField:()=>{},displayStyle:F,onClearSelection:Ee,fetchNextFoldersPage:oe,hasNextFoldersPage:Ie,isFetchingNextFoldersPage:T,fetchNextFilesPage:X,hasNextFilesPage:ye,isFetchingNextFilesPage:Qe,isLoading:G||je,filterConditions:[],onFilterChange:()=>{},dragState:Se,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((p)=>Xe(p.id))},fieldVisibility:d.fieldVisibility}),!fe&&o(L,{children:[t(Ir,{onResize:(r)=>he((p)=>Math.max(240,Math.min(600,p-r)))}),t("div",{style:{width:J},className:"flex-shrink-0 h-full",children:t(gt,{shareLink:d,viewMode:F,onViewModeChange:(r)=>We({viewMode:r}),defaultSortOrder:ee,onSortOrderChange:(r)=>We({defaultSortOrder:r})})})]})]})}),t(eu,{children:Se?.isActive?t("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:$x({count:Se.itemCount})}):null})]})}S();function Mt(){let{projectId:a,shareId:y}=Tt.useParams(),{teamId:h,ensureTeamIdForProject:f}=ut();m(()=>{f(a)},[a,f]);let{data:N}=nr(lm(a)),v=N?.rootFolder,{data:q}=Z({queryKey:["folders",v],queryFn:async()=>{let d=await A.api.folders[":folderId"].$get({param:{folderId:v}});if(!d.ok)throw Error("Failed to fetch folder");return await d.json()},enabled:!!v});if(!h||!v||!q)return t(Ct,{});return t(ot,{teamId:h,projectId:a,projectName:N.name??"",shareId:y,rootFolderId:v})}var Tt=ze("/projects/$projectId/shares/$shareId")({component:Mt});export{Tt as Route};
|
|
1
|
+
import{P,m,D,_,u,S,L,t,o,V,Z,B,mt,ze,A,I,O,Pe,nn,Et,ro,no,Lo,de,we,Ne,E,ge,Ae,_e,K,Wr,Vt,Ef,km,If,t_,r_,Mf,kf,De,Y_,na,py,gy,fh,ct,Bf,vb,Fb,Ch,qb,Vb,Qb,Kb,Wb,Yb,Oa,wi,Gc,Gf,Fa,Iv,Ov,cw,xw,Ew,zw,qw,Hw,Ed,$x,PS,DS,zS,qS,gp,wg,Ap,xE,SE,Dl,OC,$C,Gn,WC,iI,cI,iA,za,Wc,Ol,Zp,Bp,Up,Fl,Yc,Jc,zp,jp,Xc,zT,jT,qT,HT,GT,An,Yp,N1,D1,eu,TA,q1,H1,$1,G1,V1,ue,ae,pe,qe,le,z,ce,ut,Dr,_n,Vn,ru,M,vr,un,W,Me,Le,Ze,Be,Ue,ne,Ci,$t,_r,Ct,lm}from"./chunk-qx553512.js";import{Wa}from"./chunk-fa9yq17g.js";import{cu,Mi}from"./chunk-me3zmpj5.js";import{jo}from"./chunk-1tesbv8w.js";import"./chunk-cqnected.js";import"./chunk-np39aknv.js";import"./chunk-461gcgrs.js";import{Ir}from"./chunk-6pwf7qa6.js";import{da,Vl}from"./chunk-909h3qzp.js";import{ua}from"./chunk-mzme3m82.js";import{ql}from"./chunk-wperd2h9.js";import{Hl}from"./chunk-24nx3krz.js";import{tr}from"./chunk-md7pgk86.js";import"./chunk-y6xyc4wp.js";import{Xl,ec}from"./chunk-hy5ncvpf.js";import"./chunk-4nkwe7dz.js";import"./chunk-qqapw198.js";import{uo}from"./chunk-wbmqbpgm.js";import"./chunk-zsg61vr0.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-68xsb3t8.js";S();var kt=[["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=I("folder-open",kt);var St=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],lt=I("list-filter",St);S();function _t({ratio:a}){switch(a){case"16:9":return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"});case"9:16":return t("span",{className:"inline-block w-2.5 h-4 border border-current rounded-[1px] shrink-0"});case"4:3":return t("span",{className:"inline-block w-3.5 h-2.5 border border-current rounded-[1px] shrink-0"});case"3:4":return t("span",{className:"inline-block w-2.5 h-3.5 border border-current rounded-[1px] shrink-0"});case"1:1":return t("span",{className:"inline-block w-3 h-3 border border-current rounded-[1px] shrink-0"});default:return t("span",{className:"inline-block w-4 h-2.5 border border-current rounded-[1px] shrink-0"})}}function st(){return Math.random().toString(36).substring(2,9)}function dt(){return{id:st(),type:"text",text:"CONFIDENTIAL",x:0.5,y:0.5,size:0.05,color:"#999999",opacity:0.5,rotation:-30}}function It(){return{id:st(),type:"image",imageAssetKey:"",x:0.5,y:0.5,size:0.15,opacity:0.5,rotation:0}}var rt=[{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"}],Ft={"16:9":1.7777777777777777,"9:16":0.5625,"4:3":1.3333333333333333,"3:4":0.75,"1:1":1};function ft({open:a,onOpenChange:y,initialConfig:h,shareId:f,teamId:N,onSaveSuccess:v}){let q=V(),[d,w]=u([]),[c,x]=u(null),[R,H]=u(null),[k,xe]=u("16:9"),[ve,be]=u("grid"),[Ce,J]=u(!1),[he,ie]=u("new"),[fe,ee]=u(""),[te,re]=u(null),C=_(null),se=_(null),[oe,Ie]=u({w:0,h:0}),[F,G]=u(!1),s=P((e)=>{if(se.current=e,!e)return;let l=()=>{let{clientWidth:j,clientHeight:b}=e;if(j<=0||b<=0)return;let Q=Ft[k],at=j,Re=at/Q;if(Re>b)Re=b,at=Re*Q;Ie({w:Math.round(at),h:Math.round(Re)})};l();let n=new ResizeObserver(l);return n.observe(e),()=>{n.disconnect(),se.current=null}},[k]),X=ut((e)=>e.teamId),ye=N||X,[Qe,je]=u(!1),[Y,Fe]=u({}),me=_(null),ke=A.api.teams[":teamId"].files.$post,Te=async(e,l)=>{let n=e.target.files?.[0];if(!n)return;if(n.size>1048576){if(M.error(Iv()),me.current)me.current.value="";return}if(!ye){M.error(Gc());return}je(!0);let j=URL.createObjectURL(n);Fe((b)=>({...b,[l]:j}));try{let b=await ke({param:{teamId:ye},form:{file:n}});if(!b.ok)throw Error(Gc());let Q=await b.json();T(l,{imageAssetKey:Q.key,imageAssetUrl:Q.url})}catch(b){let Q=b instanceof Error?b.message:Gc();M.error(Q)}finally{if(je(!1),me.current)me.current.value=""}};m(()=>{if(a){if(h?.blocks&&h.blocks.length>0)w(h.blocks),x(h.blocks[0].id);else{let e=dt();w([e]),x(e.id)}H(null)}},[a,h]);let{data:U=[]}=Z({queryKey:["watermark-templates",N],queryFn:async()=>{let e=await A.api["watermark-templates"].$get({query:N?{teamId:N}:{}});if(!e.ok)return[];return await e.json()},enabled:a}),Ee=A.api.shares[":shareId"].watermark.$put,{mutate:Se,isPending:Ve}=B({mutationFn:async(e)=>{let l=await Ee({param:{shareId:f},json:{enabled:!0,config:e}});if(!l.ok){let n=await l.json().catch(()=>null);throw Error(n?.error||wi())}return await l.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["share",f]}),q.invalidateQueries({queryKey:["shares"]}),M.success(V1()),y(!1),v?.()},onError:(e)=>{M.error(e.message||wi())}}),He=A.api["watermark-templates"].$post,{mutate:Ge,isPending:Xe}=B({mutationFn:async({name:e,config:l})=>{let n=await He({json:{name:e,teamId:N||void 0,config:l}});if(!n.ok)throw Error(wi());return await n.json()},onSuccess:(e)=>{q.invalidateQueries({queryKey:["watermark-templates"]}),H(e.id),J(!1),M.success(qT())},onError:()=>{M.error(wi())}}),Ye=A.api["watermark-templates"][":templateId"].$put,{mutate:We,isPending:Je}=B({mutationFn:async({templateId:e,config:l})=>{let n=await Ye({param:{templateId:e},json:{config:l}});if(!n.ok)throw Error(wi());return await n.json()},onSuccess:()=>{q.invalidateQueries({queryKey:["watermark-templates"]}),J(!1),M.success(HT())},onError:()=>{M.error(wi())}}),r=A.api["watermark-templates"][":templateId"].$delete,{mutate:p}=B({mutationFn:async(e)=>{if(!(await r({param:{templateId:e}})).ok)throw Error(Oa())},onSuccess:(e,l)=>{if(q.invalidateQueries({queryKey:["watermark-templates"]}),R===l)H(null);M.success(zT())},onError:()=>{M.error(Oa())}}),g=d.findIndex((e)=>e.id===c),i=g>=0?d[g]:null,$e=()=>{let e=dt();w((l)=>[...l,e]),x(e.id)},xt=()=>{let e=It();w((l)=>[...l,e]),x(e.id)},nt=(e)=>{if(!e)return;w((l)=>{let n=l.filter((j)=>j.id!==e);if(c===e)x(n.length>0?n[Math.max(0,g-1)].id:null);return n})},T=(e,l)=>{w((n)=>n.map((j)=>j.id===e?{...j,...l}:j))},ht=()=>{if(d.length===0)return;let e=(g-1+d.length)%d.length;x(d[e].id)},vt=()=>{if(d.length===0)return;let e=(g+1)%d.length;x(d[e].id)},wt=(e,l)=>{e.stopPropagation(),x(l),G(!0)},et=P((e)=>{if(!F||!c||!C.current)return;let l=C.current.getBoundingClientRect(),n=(e.clientX-l.left)/l.width,j=(e.clientY-l.top)/l.height,b=Math.max(0,Math.min(1,Math.round(n*100)/100)),Q=Math.max(0,Math.min(1,Math.round(j*100)/100));T(c,{x:b,y:Q})},[F,c]),tt=P(()=>{G(!1)},[]);m(()=>{if(F)window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt);return()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}},[F,et,tt]),m(()=>{let e=(l)=>{if(!a||!c)return;let n=l.target?.tagName?.toLowerCase();if(n==="input"||n==="textarea"||n==="select")return;if(l.key==="Delete"||l.key==="Backspace")l.preventDefault(),nt(c)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,c,g]);let bt=(e)=>{if(e.config?.blocks&&e.config.blocks.length>0){let l=e.config.blocks.map((n)=>({...n,id:st()}));w(l),x(l[0].id),H(e.id)}},yt=()=>{if(d.length===0){M.error(DS());return}Se({blocks:d})},Nt=()=>{if(he==="new"){if(!fe.trim()){M.error(Ch());return}Ge({name:fe.trim(),config:{blocks:d}})}else{let e=te||R;if(!e){M.error(iA());return}We({templateId:e,config:{blocks:d}})}};return o(L,{children:[t(ue,{open:a,onOpenChange:y,children:o(ae,{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:[o("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border bg-card",children:[t("div",{className:"flex items-center gap-3",children:t(le,{className:"text-base font-semibold",children:H1()})}),o("div",{className:"flex items-center gap-2",children:[o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(E,{variant:"outline",size:"sm",className:"gap-2 text-xs",children:[t(it,{className:"h-4 w-4 text-muted-foreground"}),$1()]})}),o(_e,{align:"end",className:"w-56",children:[t(Wr,{className:"text-xs font-semibold text-muted-foreground",children:Hw()}),U.length===0?t("div",{className:"px-2 py-1.5 text-xs text-muted-foreground italic",children:PS()}):U.map((e)=>o(K,{onClick:()=>bt(e),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{className:"truncate flex-1",children:e.name}),R===e.id&&t(Pe,{className:"h-3.5 w-3.5 text-primary ml-2 flex-shrink-0"}),t(E,{variant:"ghost",size:"icon",className:"h-5 w-5 hover:bg-destructive/10 hover:text-destructive ml-1",onClick:(l)=>{l.stopPropagation(),p(e.id)},children:t(we,{className:"h-3 w-3"})})]},e.id)),t(Vt,{}),o(K,{onClick:()=>{ie("new"),ee(""),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(de,{className:"h-3.5 w-3.5 text-primary"}),fh()]}),U.length>0&&o(K,{onClick:()=>{ie("overwrite"),re(R||U[0].id),J(!0)},className:"text-xs gap-2 cursor-pointer",children:[t(ua,{className:"h-3.5 w-3.5 text-muted-foreground"}),wg()]})]})]}),t(E,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>y(!1),children:De()}),o(E,{size:"sm",className:"text-xs bg-primary hover:bg-primary/90 text-primary-foreground gap-1.5",disabled:Ve,onClick:yt,children:[t(ua,{className:"h-3.5 w-3.5"}),WC()]})]})]}),o("div",{className:"flex-1 flex overflow-hidden",children:[o("div",{className:"w-[65%] flex flex-col p-4 bg-muted/20 border-r border-border overflow-hidden select-none",children:[o("div",{className:"flex items-center justify-between mb-3",children:[t("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)=>o(E,{variant:k===e?"secondary":"ghost",size:"sm",className:Oe("h-7 px-2.5 text-xs gap-1.5 font-mono transition-all",k===e?"bg-background shadow-xs font-semibold text-foreground border border-border/50":"text-muted-foreground hover:text-foreground"),onClick:()=>xe(e),children:[t(_t,{ratio:e}),t("span",{children:e})]},e))}),t("div",{className:"flex items-center gap-1.5 bg-background border border-border/60 rounded-md p-1",children:rt.map((e)=>t("button",{type:"button",onClick:()=>be(e.id),style:{backgroundColor:e.bg},className:Oe("w-5 h-5 rounded-full border border-border/80 transition-all cursor-pointer relative",ve===e.id?"ring-2 ring-primary ring-offset-1 scale-110":"hover:scale-105 opacity-80 hover:opacity-100"),title:e.label},e.id))})]}),t("div",{ref:s,className:"flex-1 flex items-center justify-center overflow-hidden",children:(()=>{let e=rt.find((n)=>n.id===ve)||rt[0],l=oe.w>0&&oe.h>0;return t("div",{ref:C,onClick:()=>x(null),style:{backgroundColor:e.bg,backgroundImage:`radial-gradient(${e.dot} 1px, transparent 1px)`,backgroundSize:"16px 16px",...l?{width:oe.w,height:oe.h}:{}},className:Oe("relative rounded-lg border border-border overflow-hidden shadow-inner transition-all",k==="16:9"&&"aspect-[16/9] w-full max-h-full",k==="9:16"&&"aspect-[9/16] h-full max-w-full",k==="4:3"&&"aspect-[4/3] w-full max-h-full",k==="3:4"&&"aspect-[3/4] h-full max-w-full",k==="1:1"&&"aspect-square h-full max-w-full"),children:d.map((n)=>{let j=n.id===c,b=n.size*(oe.w||640);return t("div",{onMouseDown:(Q)=>wt(Q,n.id),onClick:(Q)=>{Q.stopPropagation(),x(n.id)},style:{left:`${n.x*100}%`,top:`${n.y*100}%`,transform:`translate(-50%, -50%) rotate(${n.rotation}deg)`,opacity:n.opacity},className:Oe("absolute cursor-move select-none transition-shadow rounded p-1.5 flex items-center justify-center",j?"ring-2 ring-primary ring-offset-2 ring-offset-background/80 bg-primary/10":"hover:ring-1 hover:ring-muted-foreground/50"),children:n.type==="text"?t("span",{style:{fontSize:`${b}px`,color:n.color,lineHeight:1,whiteSpace:"nowrap",fontWeight:700,textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.text||"Text"}):t("div",{style:{width:`${b}px`,height:`${b}px`},className:"bg-primary/20 border border-primary/40 rounded flex items-center justify-center p-1 overflow-hidden",children:Y[n.id]||n.imageAssetUrl?t("img",{src:Y[n.id]||n.imageAssetUrl,alt:"Watermark logo",className:"w-full h-full object-contain pointer-events-none"}):t(ro,{className:"h-1/2 w-1/2 opacity-70 text-primary"})})},n.id)})})})()})]}),o("div",{className:"w-[35%] flex flex-col bg-card overflow-hidden border-l border-border",children:[t("div",{className:"p-4 border-b border-border bg-muted/10 flex items-center justify-between",children:o("div",{className:"flex items-center gap-2",children:[t(no,{className:"h-4 w-4 text-muted-foreground"}),t("span",{className:"text-xs font-semibold",children:TA()})]})}),o("div",{className:"p-3 border-b border-border bg-background flex items-center justify-between gap-2",children:[o("div",{className:"flex items-center gap-1",children:[t(E,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:ht,children:t(nn,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(E,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs font-mono",children:d.length===0?"0 / 0":`${g+1} / ${d.length}`})}),t(_e,{align:"start",className:"w-48",children:d.map((e,l)=>o(K,{onClick:()=>x(e.id),className:"text-xs flex items-center justify-between cursor-pointer",children:[o("span",{className:"flex items-center gap-2 truncate",children:[e.type==="text"?t(Wa,{className:"h-3.5 w-3.5 text-muted-foreground"}):t(ro,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.type==="text"?e.text||"Text":e.imageAssetKey||"Image"]}),o("span",{className:"text-[10px] font-mono text-muted-foreground ml-2",children:["#",l+1]})]},e.id))})]}),t(E,{variant:"outline",size:"icon",className:"h-7 w-7",disabled:d.length<=1,onClick:vt,children:t(Et,{className:"h-4 w-4"})})]}),o("div",{className:"flex items-center gap-1",children:[i&&t(E,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",title:ct(),onClick:()=>nt(i.id),children:t(we,{className:"h-4 w-4"})}),o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o(E,{size:"sm",className:"h-7 text-xs gap-1",children:[t(de,{className:"h-3.5 w-3.5"}),Ef()]})}),o(_e,{align:"end",children:[o(K,{onClick:$e,className:"text-xs gap-2 cursor-pointer",children:[t(Wa,{className:"h-3.5 w-3.5"}),If()]}),o(K,{onClick:xt,className:"text-xs gap-2 cursor-pointer",children:[t(ro,{className:"h-3.5 w-3.5"}),km()]})]})]})]})]}),t(ce,{className:"flex-1 min-h-0 p-4",children:i?o("div",{className:"space-y-5 text-xs",children:[o("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[o("span",{className:"font-semibold text-muted-foreground flex items-center gap-1.5",children:[i.type==="text"?t(Wa,{className:"h-4 w-4 text-primary"}):t(ro,{className:"h-4 w-4 text-primary"}),i.type==="text"?If():km()]}),o("span",{className:"text-[10px] font-mono text-muted-foreground",children:["ID: ",i.id.slice(0,6)]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[t(W,{className:"text-xs",children:GT()}),t(z,{type:"text",value:i.text,onChange:(e)=>T(i.id,{text:e.target.value}),className:"text-xs h-8"})]}),i.type==="image"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xw()}),i.imageAssetKey&&o("button",{type:"button",onClick:()=>T(i.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:[t(Ne,{className:"w-3.5 h-3.5"}),Dl?Dl():"Remove"]})]}),t("input",{type:"file",ref:me,className:"hidden",accept:"image/*",onChange:(e)=>Te(e,i.id)}),o("div",{onClick:()=>me.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:[Qe&&t("div",{className:"absolute inset-0 bg-background/70 backdrop-blur-xs flex flex-col items-center justify-center gap-2 z-20",children:o("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-background border rounded-full shadow-lg",children:[t(O,{className:"w-4 h-4 animate-spin text-primary"}),t("span",{className:"text-xs font-semibold",children:eu()})]})}),Y[i.id]||i.imageAssetUrl?o(L,{children:[t("img",{src:Y[i.id]||i.imageAssetUrl,alt:"Uploaded logo preview",className:"max-w-full max-h-full object-contain transition-transform duration-300 group-hover:scale-105"}),o("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:[t(uo,{className:"w-5 h-5 transform translate-y-1 group-hover:translate-y-0 transition-transform duration-300"}),t("span",{className:"text-xs font-semibold",children:Yp()})]})]}):o("div",{className:"flex flex-col items-center gap-1.5 text-center p-3",children:[t("div",{className:"p-2 rounded-full bg-background border shadow-xs group-hover:scale-110 transition-transform duration-300",children:t(uo,{className:"w-4 h-4 text-muted-foreground"})}),o("div",{children:[t("p",{className:"text-xs font-medium text-foreground",children:N1()}),t("p",{className:"text-[10px] text-muted-foreground mt-0.5 max-w-[150px] mx-auto leading-normal",children:D1()})]})]})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:i.type==="text"?Ov():Ew()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.size*100),"%"]})]}),o("div",{className:"flex items-center gap-3",children:[t(jo,{min:i.type==="text"?0.01:0.02,max:i.type==="text"?0.12:0.5,step:0.005,value:[i.size],onValueChange:([e])=>T(i.id,{size:e}),className:"flex-1"}),t(z,{type:"number",min:1,max:100,value:Math.round(i.size*100),onChange:(e)=>T(i.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"})]})]}),i.type==="text"&&o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Y_()}),t("span",{className:"font-mono text-[11px] text-muted-foreground uppercase",children:i.color})]}),o("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",value:i.color,onChange:(e)=>T(i.id,{color:e.target.value}),className:"w-8 h-8 rounded border border-border cursor-pointer bg-transparent p-0"}),t(z,{type:"text",value:i.color,onChange:(e)=>T(i.id,{color:e.target.value}),className:"flex-1 h-8 text-xs font-mono"})]}),t("div",{className:"flex items-center gap-1.5 pt-1",children:["#FFFFFF","#000000","#999999","#EF4444","#3B82F6","#10B981","#F59E0B"].map((e)=>t("button",{type:"button",onClick:()=>T(i.id,{color:e}),style:{backgroundColor:e},className:"w-5 h-5 rounded-full border border-border hover:scale-110 transition-transform"},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:zS()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.opacity*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.opacity],onValueChange:([e])=>T(i.id,{opacity:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:$C()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[i.rotation,"°"]})]}),t(jo,{min:-180,max:180,step:1,value:[i.rotation],onValueChange:([e])=>T(i.id,{rotation:e})}),t("div",{className:"flex items-center gap-1.5 pt-1",children:[-45,-30,0,30,45].map((e)=>o(E,{variant:"outline",size:"sm",className:"h-6 text-[10px] flex-1 px-1 font-mono",onClick:()=>T(i.id,{rotation:e}),children:[e,"°"]},e))})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:xE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.x*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.x],onValueChange:([e])=>T(i.id,{x:e})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:SE()}),o("span",{className:"font-mono text-[11px] text-muted-foreground",children:[Math.round(i.y*100),"%"]})]}),t(jo,{min:0,max:1,step:0.01,value:[i.y],onValueChange:([e])=>T(i.id,{y:e})})]})]}):o("div",{className:"py-12 text-center text-xs text-muted-foreground space-y-3",children:[t("p",{children:cI()}),o(E,{size:"sm",variant:"outline",onClick:$e,children:[t(de,{className:"h-3.5 w-3.5 mr-1"}),If()]})]})})]})]})]})}),t(ue,{open:Ce,onOpenChange:J,children:o(ae,{className:"max-w-md",children:[t(pe,{children:t(le,{className:"text-sm font-semibold",children:he==="new"?fh():wg()})}),t("div",{className:"py-3 space-y-4 text-xs",children:he==="new"?o("div",{className:"space-y-2",children:[t(W,{children:jT()}),t(z,{type:"text",value:fe,onChange:(e)=>ee(e.target.value),placeholder:Ch(),className:"text-xs"})]}):o("div",{className:"space-y-2",children:[t(W,{children:iA()}),t("select",{value:te||"",onChange:(e)=>re(e.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:U.map((e)=>t("option",{value:e.id,children:e.name},e.id))})]})}),o(qe,{children:[t(E,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>J(!1),children:De()}),t(E,{size:"sm",className:"text-xs",disabled:Xe||Je,onClick:Nt,children:na()})]})]})})]})}function Oe(...a){return a.filter(Boolean).join(" ")}S();function gt({shareLink:a,viewMode:y,onViewModeChange:h,defaultSortOrder:f,onSortOrderChange:N}){let v=V(),[q,d]=u(a.password||""),[w,c]=u(a.expireAt?new Date(a.expireAt):void 0),[x,R]=u(!1);m(()=>{d(a.password||"")},[a.password]);let[H,k]=u(a.hasPassword),[xe,ve]=u(!!a.expireAt),{data:be,refetch:Ce}=Z({queryKey:["share-watermark",a.id],queryFn:async()=>{let s=await A.api.shares[":shareId"].watermark.$get({param:{shareId:a.id}});if(!s.ok)return null;return await s.json()},refetchInterval:(s)=>(s.state.data?.watermarkStatus||a.watermarkStatus)==="processing"?3000:!1}),J=A.api.shares[":shareId"].watermark.$put,{mutate:he}=B({mutationFn:async()=>{let s=await J({param:{shareId:a.id},json:{enabled:!1}});if(!s.ok)throw Error(wi());return await s.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["share-watermark",a.id]}),M.success(q1())}}),ie=be?.watermarkStatus??a.watermarkStatus??(a.watermarkConfigId?"ready":"disabled"),fe=be?.watermarkConfig?.config??a.watermarkConfig?.config??null,ee=fe!==null&&ie!=="disabled",{data:te}=Z({queryKey:["fields",a.projectId],queryFn:async()=>{let s=await A.api.projects[":projectId"].fields.$get({param:{projectId:a.projectId}});if(!s.ok)throw Error(Vb());return await s.json()},enabled:!!a.projectId}),re=A.api.shares[":shareId"].$put,{mutate:C}=B({mutationFn:async(s)=>{let X=await re({param:{shareId:a.id},json:s});if(!X.ok)throw Error(wi());return await X.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["shares",a.projectId]}),v.invalidateQueries({queryKey:["share",a.id]}),M.success(za())}}),se=`${window.location.origin}/share/${a.id}`,oe=async(s)=>{if(await fo(s))M.success(py())},Ie=(s)=>{let X=a.fieldVisibility||{},ye={...X,[s]:!X[s]};C({fieldVisibility:ye})},F="index",G="asc";if(f){let s=f.split(":");F=s[0],G=s[1]||"asc"}return o("div",{className:"flex flex-col h-full bg-background border-l border-border",children:[t("div",{className:"flex-1 overflow-y-auto",children:o("div",{className:"p-4 space-y-6",children:[o("div",{className:"space-y-4",children:[o("div",{className:"flex items-center justify-between",children:[t("h3",{className:"text-sm font-medium",children:zw()}),t(Me,{checked:!a.isDisabled,onCheckedChange:(s)=>C({isDisabled:!s})})]}),o("div",{className:"relative w-full",children:[t(z,{value:se,readOnly:!0,className:"pr-10 bg-muted/50 text-xs"}),t(E,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full",onClick:()=>oe(se),children:t(Nr,{className:"h-4 w-4"})})]})]}),o("div",{className:"space-y-1",children:[t(Ke,{title:iI(),icon:t(ec,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:Ap()}),t(Me,{checked:H,onCheckedChange:(s)=>{if(k(s),!s)C({password:null})}})]}),H&&o("div",{className:"flex gap-2 animate-in fade-in slide-in-from-top-1 duration-200",children:[t(z,{type:"text",value:q,onChange:(s)=>d(s.target.value),placeholder:Fb(),className:"text-xs"}),t(E,{size:"sm",onClick:()=>C({password:q}),children:Gn()})]})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:qb()}),t(Me,{checked:xe,onCheckedChange:(s)=>{if(ve(s),!s)c(void 0),C({expireAt:null})}})]}),xe&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:t(Ci,{value:w,onChange:(s)=>{c(s),C({expireAt:s?s.toISOString():null})},className:"text-xs"})})]}),o("div",{className:"space-y-2",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:t_()}),t(Me,{checked:a.allowDownload,onCheckedChange:(s)=>C({allowDownload:s})})]}),t("p",{className:"text-xs text-muted-foreground",children:r_()})]}),o("div",{className:"space-y-2 pt-2 border-t border-border/50",children:[o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:TA()}),t(Me,{checked:ee,disabled:ie==="processing",onCheckedChange:(s)=>{if(!s)he();else R(!0)}})]}),ee&&ie==="processing"&&o("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 font-medium py-1 animate-pulse",children:[t(O,{className:"h-3.5 w-3.5 animate-spin"}),t("span",{children:G1()})]}),ee&&ie!=="processing"&&t(E,{variant:"outline",size:"sm",className:"w-full text-xs gap-1.5 mt-1",onClick:()=>R(!0),children:vb()})]})]})}),t(Ke,{title:Mf(),icon:t(Xl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-3 pt-2 flex gap-2",children:[o(E,{variant:y==="card"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("card"),children:[t(no,{className:"h-4 w-4"}),cw()]}),o(E,{variant:y==="list"?"secondary":"outline",size:"sm",className:"flex-1 gap-2 text-xs",onClick:()=>h("list"),children:[t(Lo,{className:"h-4 w-4"}),qw()]})]})}),t(Ke,{title:Fa(),icon:t(lt,{className:"h-4 w-4"}),children:t("div",{className:"p-3 space-y-3 pt-2",children:te?.map((s)=>o("div",{className:"flex items-center justify-between",children:[t(W,{className:"text-xs",children:s.config?.name}),t(Me,{checked:a.fieldVisibility?.[s.id]??!1,onCheckedChange:()=>Ie(s.id)})]},s.id))})}),t(Ke,{title:Ol(),icon:t(Hl,{className:"h-4 w-4"}),children:o("div",{className:"p-3 space-y-4 pt-2",children:[o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:Gf()}),o(Le,{value:F,onValueChange:(s)=>{if(s==="index")N(null);else N(`${s}:${G}`)},children:[t(Be,{className:"w-full text-xs h-9",children:t(Ze,{})}),o(Ue,{children:[t(ne,{value:"index",children:Zp()}),t(ne,{value:"name",children:Fl()}),t(ne,{value:"createdAt",children:Bp()}),t(ne,{value:"size",children:zp()})]})]})]}),o("div",{className:"space-y-2",children:[t(W,{className:"text-xs text-muted-foreground",children:gp()}),o(E,{variant:"outline",className:"w-full justify-between font-normal text-xs h-9",disabled:F==="index",onClick:()=>{N(`${F}:${G==="asc"?"desc":"asc"}`)},children:[t("span",{children:F==="name"?G==="asc"?Wc():Xc():F==="createdAt"?G==="asc"?Jc():Yc():F==="size"?G==="asc"?jp():Up():G==="asc"?kf():Bf()}),t(cu,{className:"h-4 w-4 opacity-50"})]})]})]})})]})]})}),o("div",{className:"p-4 border-t border-border space-y-2",children:[o(E,{variant:"outline",className:"w-full justify-center",onClick:()=>window.open(se,"_blank"),children:[t(ql,{className:"h-4 w-4 mr-2"}),qS()]}),o(E,{className:"w-full justify-center bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>oe(se),children:[t(Nr,{className:"h-4 w-4 mr-2"}),gy()]})]}),t(ft,{open:x,onOpenChange:R,initialConfig:fe,shareId:a.id,onSaveSuccess:()=>{Ce(),v.invalidateQueries({queryKey:["share",a.id]}),v.invalidateQueries({queryKey:["shares",a.projectId]})}})]})}function Ke({title:a,icon:y,children:h}){let[f,N]=u(!1);return o("div",{className:"border-b border-border last:border-0",children:[o("button",{onClick:()=>N(!f),className:"w-full flex items-center justify-between py-3 px-2 hover:bg-muted/50 transition-colors",children:[o("div",{className:"flex items-center gap-3",children:[y,t("span",{className:"text-sm font-medium",children:a})]}),t(Et,{className:Dt("h-4 w-4 transition-transform",f&&"rotate-90")})]}),f&&h&&t("div",{className:"animate-in fade-in slide-in-from-top-1 duration-200",children:h})]})}function Dt(...a){return a.filter(Boolean).join(" ")}function ot({teamId:a,projectId:y,projectName:h,shareId:f,rootFolderId:N}){let v=V(),{fetchMetadata:q}=_r();m(()=>{if(a)q(a)},[a,q]);let{data:d}=Z({queryKey:["share",f],queryFn:async()=>{let r=await A.api.shares[":shareId"].$get({param:{shareId:f}});if(!r.ok)throw Error(Wb());return await r.json()}}),w=d?.rootFolderId,[c,x]=u(null),[R,H]=u([]);m(()=>{if(w)x(w),H([]),U(new Set)},[w,f]);let k=un((r)=>r.setProjectState),xe=un((r)=>r.clearProjectState),ve=(r)=>{if(r===c)return;if(r===w)x(w),H([]);else{let p=R.findIndex((g)=>g.id===r);if(p!==-1)x(r),H(R.slice(p+1))}U(new Set)},[be,Ce]=u(240),[J,he]=u(360),{shareConfigLeftSidebarCollapsed:ie,shareConfigRightSidebarCollapsed:fe}=$t(),ee=d?.defaultSortOrder||null,te,re;if(ee){let r=ee.split(":");te=r[0],re=r[1]}let C=d?.viewMode??"card",{data:se,fetchNextPage:oe,hasNextPage:Ie,isFetchingNextPage:F,isLoading:G}=mt({queryKey:["folder-children",a,c,"folder",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"folder",after:r,sort:te,order:re}});if(!p.ok)throw Error(Kb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),{data:s,fetchNextPage:X,hasNextPage:ye,isFetchingNextPage:Qe,isLoading:je}=mt({queryKey:["folder-children",a,c,"file",te,re],queryFn:async({pageParam:r})=>{let p=await A.api.folders[":folderId"].children.$get({param:{folderId:c},query:{assetType:"file",after:r,sort:te,order:re}});if(!p.ok)throw Error(Qb());return await p.json()},enabled:!!c,initialPageParam:"",getNextPageParam:(r)=>r.pageInfo?.cursor||void 0}),Y=D(()=>se?.pages.flatMap((r)=>r.data??[])??[],[se]),Fe=D(()=>s?.pages.flatMap((r)=>r.data??[])??[],[s]);m(()=>{if(d)k({teamId:a,projectId:y,projectName:h,ancestorFolders:R,currentAsset:{name:c===w?d.name:Y.find((r)=>r.id===c)?.name||d.name,type:"folder"},isRootFolder:!1,shareId:f,onFolderClick:ve});return()=>xe()},[a,y,h,R,c,w,d,f,Y,k,xe]);let[me,ke]=u(null),[Te,U]=u(new Set),Ee=()=>{U(new Set),ke(null)},{dragState:Se,handleDragStart:Ve,handleDragEnd:He}=Vl({teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedIds:Te,onClearSelection:Ee}),Ge=A.api.shares[":shareId"].assets[":assetId"].$delete,{mutate:Xe}=B({mutationFn:async(r)=>{if(!(await Ge({param:{shareId:f,assetId:r}})).ok)throw Error(Yb())},onSuccess:()=>{v.invalidateQueries({queryKey:["folder-children",a,c]}),M.success(OC())}}),Ye=A.api.shares[":shareId"].$put,{mutate:We}=B({mutationFn:async(r)=>{let p=await Ye({param:{shareId:f},json:r});if(!p.ok)throw Error(wi());return await p.json()},onSuccess:()=>{v.invalidateQueries({queryKey:["share",f]}),M.success(za())}}),Je=(r)=>{if(r.type==="folder"||r.targetType==="folder"){let p=c===w?d?.name||"":Y.find((g)=>g.id===c)?.name||An();H((g)=>[{id:c,name:p},...g]),x(r.id),U(new Set)}};if(!d)return t("div",{children:Ed()});return o(Vn,{modifiers:[da.configure({anchor:{x:0,y:0}})],sensors:[_n.configure({activationConstraints:[new Dr.Distance({value:10})]})],onDragStart:Ve,onDragEnd:He,children:[t("div",{className:"flex flex-1 flex-col bg-background min-h-0",children:o("div",{className:"flex flex-1 overflow-hidden relative",children:[!ie&&o(L,{children:[t("div",{className:"bg-background",style:{width:be},children:t(vr,{teamId:a,projectId:y,projectName:h,rootFolderId:N,dragState:Se})}),t(Ir,{onResize:(r)=>Ce((p)=>Math.max(180,Math.min(400,p+r)))})]}),t(Mi,{teamId:a,projectId:y,assetId:c||"",folders:Y,files:Fe,selectedItem:me,selectedIds:Te,onItemSelect:(r,p)=>{if(p.metaKey||p.ctrlKey){let g=new Set(Te);if(g.has(r.id)){if(g.delete(r.id),U(g),me?.id===r.id){let i=[...Y,...Fe].find(($e)=>g.has($e.id));ke(i||null)}}else g.add(r.id),U(g),ke(r)}else U(new Set([r.id])),ke(r)},onItemDoubleClick:Je,onSaveField:()=>{},displayStyle:C,onClearSelection:Ee,fetchNextFoldersPage:oe,hasNextFoldersPage:Ie,isFetchingNextFoldersPage:F,fetchNextFilesPage:X,hasNextFilesPage:ye,isFetchingNextFilesPage:Qe,isLoading:G||je,filterConditions:[],onFilterChange:()=>{},dragState:Se,isShareView:!0,onRemoveFromShare:(r)=>{r.forEach((p)=>Xe(p.id))},fieldVisibility:d.fieldVisibility}),!fe&&o(L,{children:[t(Ir,{onResize:(r)=>he((p)=>Math.max(240,Math.min(600,p-r)))}),t("div",{style:{width:J},className:"flex-shrink-0 h-full",children:t(gt,{shareLink:d,viewMode:C,onViewModeChange:(r)=>We({viewMode:r}),defaultSortOrder:ee,onSortOrderChange:(r)=>We({defaultSortOrder:r})})})]})]})}),t(ru,{children:Se?.isActive?t("div",{className:"flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md",children:$x({count:Se.itemCount})}):null})]})}S();function Mt(){let{projectId:a,shareId:y}=Tt.useParams(),{teamId:h,ensureTeamIdForProject:f}=ut();m(()=>{f(a)},[a,f]);let{data:N}=tr(lm(a)),v=N?.rootFolder,{data:q}=Z({queryKey:["folders",v],queryFn:async()=>{let d=await A.api.folders[":folderId"].$get({param:{folderId:v}});if(!d.ok)throw Error("Failed to fetch folder");return await d.json()},enabled:!!v});if(!h||!v||!q)return t(Ct,{});return t(ot,{teamId:h,projectId:a,projectName:N.name??"",shareId:y,rootFolderId:v})}var Tt=ze("/projects/$projectId/shares/$shareId")({component:Mt});export{Tt as Route};
|