syntaur 0.43.0 → 0.43.1
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/.claude-plugin/plugin.json +1 -1
- package/dashboard/dist/assets/{_basePickBy-DzTDKHYU.js → _basePickBy-CabSPDlA.js} +1 -1
- package/dashboard/dist/assets/{_baseUniq-DW7YJayj.js → _baseUniq-DGO4Y46J.js} +1 -1
- package/dashboard/dist/assets/{arc-BkeAbQzV.js → arc-C0lxzBYC.js} +1 -1
- package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-M_COTMq5.js → architectureDiagram-2XIMDMQ5-DAa-zxeT.js} +1 -1
- package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-BMSQm_8K.js → blockDiagram-WCTKOSBZ-BhFavWXG.js} +1 -1
- package/dashboard/dist/assets/{c4Diagram-IC4MRINW-Bte3s8bA.js → c4Diagram-IC4MRINW-BxKqhk8H.js} +1 -1
- package/dashboard/dist/assets/channel-gkqjyV0r.js +1 -0
- package/dashboard/dist/assets/{chunk-4BX2VUAB-BpEBr9cy.js → chunk-4BX2VUAB-CayPDVSU.js} +1 -1
- package/dashboard/dist/assets/{chunk-55IACEB6-C5vYlqEx.js → chunk-55IACEB6-DE34igmQ.js} +1 -1
- package/dashboard/dist/assets/{chunk-FMBD7UC4-C8wRljiW.js → chunk-FMBD7UC4-CWHswGwW.js} +1 -1
- package/dashboard/dist/assets/{chunk-JSJVCQXG-svArzivt.js → chunk-JSJVCQXG-DnsqdfIB.js} +1 -1
- package/dashboard/dist/assets/{chunk-KX2RTZJC-DPZbN7jl.js → chunk-KX2RTZJC-FbqVE08c.js} +1 -1
- package/dashboard/dist/assets/{chunk-NQ4KR5QH-ZqOPA0Z2.js → chunk-NQ4KR5QH-DcsdDqWQ.js} +1 -1
- package/dashboard/dist/assets/{chunk-QZHKN3VN-BoxtsyU8.js → chunk-QZHKN3VN-DZBdzXAZ.js} +1 -1
- package/dashboard/dist/assets/{chunk-WL4C6EOR-BoTByw-8.js → chunk-WL4C6EOR-DV11wZKH.js} +1 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-D1CF55uI.js +1 -0
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-D1CF55uI.js +1 -0
- package/dashboard/dist/assets/clone-Cx1NBdWo.js +1 -0
- package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-CV74D8s_.js → cose-bilkent-S5V4N54A-Cc5iZnSF.js} +1 -1
- package/dashboard/dist/assets/{dagre-KLK3FWXG-NXFGSDTv.js → dagre-KLK3FWXG-DdhTE6jK.js} +1 -1
- package/dashboard/dist/assets/{diagram-E7M64L7V-CO89mocJ.js → diagram-E7M64L7V-DNwcjAks.js} +1 -1
- package/dashboard/dist/assets/{diagram-IFDJBPK2-CGOOte10.js → diagram-IFDJBPK2-UNMmAgBt.js} +1 -1
- package/dashboard/dist/assets/{diagram-P4PSJMXO-tRYoQWNN.js → diagram-P4PSJMXO-DFVklVy0.js} +1 -1
- package/dashboard/dist/assets/{erDiagram-INFDFZHY-D88FnNdx.js → erDiagram-INFDFZHY-CN8yM6gL.js} +1 -1
- package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-C2dCJPYX.js → flowDiagram-PKNHOUZH-CueIaRLY.js} +1 -1
- package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-BVsm_TXU.js → ganttDiagram-A5KZAMGK-DnYhCq5T.js} +1 -1
- package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-DeYEcfwg.js → gitGraphDiagram-K3NZZRJ6-ISNXg3k0.js} +1 -1
- package/dashboard/dist/assets/{graph-iy97f49o.js → graph-BZz0E7Ci.js} +1 -1
- package/dashboard/dist/assets/{index-esLcRMJY.js → index-Dzh96P4Z.js} +2 -2
- package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-B_KPLd9N.js → infoDiagram-LFFYTUFH-bNvKINb_.js} +1 -1
- package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-D0i4hG75.js → ishikawaDiagram-PHBUUO56-DKfRfWXE.js} +1 -1
- package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-DxAv-6Dt.js → journeyDiagram-4ABVD52K-BfKl4TNb.js} +1 -1
- package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-CFV3hwVv.js → kanban-definition-K7BYSVSG-3b_Gc82P.js} +1 -1
- package/dashboard/dist/assets/{layout-DkzGMO0p.js → layout-CDFST2WK.js} +1 -1
- package/dashboard/dist/assets/{linear-Di0t2dWQ.js → linear-DFkg06qv.js} +1 -1
- package/dashboard/dist/assets/{mermaid.core-BWdLQDB3.js → mermaid.core-eqq1_dL_.js} +4 -4
- package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-DHFtApR_.js → mindmap-definition-YRQLILUH-3UicY0_v.js} +1 -1
- package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-CKv_gkpa.js → pieDiagram-SKSYHLDU-CZyg0jjE.js} +1 -1
- package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-D8d0F939.js → quadrantDiagram-337W2JSQ-Cj6oadbs.js} +1 -1
- package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-BpIRQ6xS.js → requirementDiagram-Z7DCOOCP-BlfA8l6H.js} +1 -1
- package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-B6pEFLq9.js → sankeyDiagram-WA2Y5GQK-CHU0rdbD.js} +1 -1
- package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-C_UzJJ9L.js → sequenceDiagram-2WXFIKYE-fP5IFexC.js} +1 -1
- package/dashboard/dist/assets/{stateDiagram-RAJIS63D-DffNJyzP.js → stateDiagram-RAJIS63D-CdthThpd.js} +1 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-kKo_Asao.js +1 -0
- package/dashboard/dist/assets/{timeline-definition-YZTLITO2-BiMYMTvs.js → timeline-definition-YZTLITO2-DI1ep504.js} +1 -1
- package/dashboard/dist/assets/{treemap-KZPCXAKY-CUEZz4mB.js → treemap-KZPCXAKY-CvuW7d81.js} +1 -1
- package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-Cpol_IHC.js → vennDiagram-LZ73GAT5-DEuyxMbM.js} +1 -1
- package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-CbnCJEuN.js → xychartDiagram-JWTSCODW-BVlWbeAK.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/dashboard/server.js +25 -6
- package/dist/dashboard/server.js.map +1 -1
- package/dist/index.js +25 -6
- package/dist/index.js.map +1 -1
- package/dist/launch/index.js +23 -5
- package/dist/launch/index.js.map +1 -1
- package/package.json +1 -1
- package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
- package/platforms/codex/.codex-plugin/plugin.json +1 -1
- package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
- package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
- package/dashboard/dist/assets/channel-BrnqMVFz.js +0 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-BfXVQbAH.js +0 -1
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-BfXVQbAH.js +0 -1
- package/dashboard/dist/assets/clone-Bm7jyblm.js +0 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-Bb4Jseta.js +0 -1
|
@@ -527,7 +527,7 @@ You can add a description to the \`${si}\` by passing a \`${Gk}\` component as a
|
|
|
527
527
|
|
|
528
528
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${si}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
529
529
|
|
|
530
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},ND=Uk,CD=Vk,Zk=Hk,e1=Wk,t1=Jk,n1=Qk,r1=qk,s1=Yk;const Ga=ND,ED=CD,o1=f.forwardRef(({className:e,...t},n)=>r.jsx(Zk,{ref:n,className:ke("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));o1.displayName=Zk.displayName;const Bo=f.forwardRef(({className:e,...t},n)=>r.jsxs(ED,{children:[r.jsx(o1,{}),r.jsx(e1,{ref:n,className:ke("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));Bo.displayName=e1.displayName;function Ya({className:e,...t}){return r.jsx("div",{className:ke("flex flex-col space-y-2 text-left",e),...t})}function Ja({className:e,...t}){return r.jsx("div",{className:ke("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Uo=f.forwardRef(({className:e,...t},n)=>r.jsx(r1,{ref:n,className:ke("text-lg font-semibold tracking-tight text-foreground",e),...t}));Uo.displayName=r1.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>r.jsx(s1,{ref:n,className:ke("text-sm leading-6 text-muted-foreground",e),...t}));Vo.displayName=s1.displayName;const oo=f.forwardRef(({className:e,...t},n)=>r.jsx(t1,{ref:n,className:ke(e),...t}));oo.displayName=t1.displayName;const Ul=f.forwardRef(({className:e,...t},n)=>r.jsx(n1,{ref:n,className:ke(e),...t}));Ul.displayName=n1.displayName;const TD=[{to:"/",label:"Overview",icon:m0},{to:"/playbooks",label:"Playbooks",icon:d0},{to:"/memories",label:"Memories",icon:rP},{to:"/resources",label:"Resources",icon:yP},{to:"/inventories",label:"Inventories",icon:Ld},{to:"/usage",label:"Usage",icon:Od},{to:"/todos",label:"Todos",icon:Dr},{to:"/views",label:"Saved Views",icon:x0},{to:"/archive",label:"Archive",icon:Dd}],PD=[{suffix:"/projects",label:"Projects",icon:tg},{suffix:"/assignments",label:"Assignments",icon:wP},{suffix:"/servers",label:"Servers",icon:og},{suffix:"/inventories",label:"Inventories",icon:Ld},{suffix:"/usage",label:"Usage",icon:Od},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Ad},{suffix:"/todos",label:"Todos",icon:Dr}],RD=[{to:"/help",label:"Help",icon:bP},{to:"/settings",label:"Settings",icon:AP}];function AD({title:e,breadcrumbs:t,projectSlug:n,workspace:s,children:a}){const[l,c]=f.useState(!1);return Ht({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:l,handler:()=>c(!1)}),r.jsx("div",{className:"min-h-screen bg-background",children:r.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[r.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:r.jsx(Bv,{activeWorkspace:s})}),l?r.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:r.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx(Ee,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:r.jsx(lg,{className:"h-4 w-4"})})]}),r.jsx(Bv,{activeWorkspace:s,onNavigate:()=>c(!1)})]})}):null,r.jsxs("div",{className:"min-w-0",children:[r.jsx(sD,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),r.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:a})]})]})})}function Bv({activeWorkspace:e,onNavigate:t}){const{data:n}=oc(),s=(n==null?void 0:n.workspaces)??[],a=(n==null?void 0:n.hasUngrouped)??!1,{hidden:l}=zk(),c=qn(),[u,p]=f.useState(new Set),[m,h]=f.useState(!1),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),O=Dt();function P(B){p($=>{const K=new Set($);return K.has(B)?K.delete(B):K.add(B),K})}const D=iD([...s,...a?[ld]:[]],l);async function L(B){if(j){T(!0);try{const $=`/api/workspaces/${encodeURIComponent(j)}${B?"?cascade=true":""}`,K=await fetch($,{method:"DELETE"});if(K.status===409){const re=await K.json().catch(()=>({}));C((re==null?void 0:re.blockedBy)??{projects:[],standalones:[]});return}if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to delete workspace")}w(null),C(null)}catch($){console.error($),alert($ instanceof Error?$.message:"Failed to delete workspace")}finally{T(!1)}}}async function W(B,$){try{if(B.type==="project"){const K=await fetch(`/api/projects/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:$})});if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to move project")}return}if(B.type==="standalone-assignment"){const K=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:$})});if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to move assignment")}return}if(B.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(K){console.error(K),alert(K instanceof Error?K.message:"Failed to move item")}}return r.jsxs("div",{className:"flex h-full flex-col gap-3",children:[r.jsx("div",{className:"space-y-3",children:r.jsxs(Ee,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[r.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:r.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),r.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),r.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),r.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),r.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),r.jsx(wv,{items:TD,onNavigate:t}),r.jsx("div",{className:"border-t border-border/40"}),r.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[D.length===0&&!m&&r.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),D.map(B=>{const $=B==="_ungrouped",K=$?"Ungrouped":bn(B),re=$?"/w/_ungrouped":`/w/${B}`,I=u.has(B),H=e===B||e===null&&$&&c.pathname.startsWith("/w/_ungrouped"),J=b===B;return r.jsxs("div",{className:`rounded-md transition ${J?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:ne=>{ne.dataTransfer.types.includes("application/json")&&(ne.preventDefault(),ne.dataTransfer.dropEffect="move",E(B))},onDragLeave:ne=>{ne.currentTarget.contains(ne.relatedTarget)||E(_=>_===B?null:_)},onDrop:async ne=>{try{const _=ne.dataTransfer.getData("application/json");if(!_)return;ne.preventDefault();let G;try{G=JSON.parse(_)}catch{return}if(!(G!=null&&G.type)||!(G!=null&&G.id))return;await W(G,$?null:B)}finally{E(null)}},children:[r.jsxs("div",{className:"group flex items-center",children:[r.jsxs("button",{type:"button",onClick:()=>P(B),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${H?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[r.jsx(br,{className:`h-3 w-3 transition-transform ${I?"-rotate-90":""}`}),K]}),$?null:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w(B),C(null)},title:`Delete workspace "${B}"`,"aria-label":`Delete workspace "${B}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:r.jsx(ar,{className:"h-3 w-3"})})]}),!I&&r.jsx("nav",{className:"ml-2 space-y-0.5",children:PD.map(ne=>{const _=`${re}${ne.suffix}`,G=A0(c.pathname,ne.suffix)&&c.pathname.startsWith(re),A=ne.icon;return r.jsxs(Ee,{to:_,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${G?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[r.jsx(A,{className:"h-4 w-4"}),r.jsx("span",{children:ne.label})]},_)})})]},B)}),m?r.jsx("form",{className:"px-3 py-1.5",onSubmit:B=>{B.preventDefault();const $=g.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");$&&(h(!1),y(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})}).then(()=>{t==null||t(),O(`/w/${$}/projects`)}))},children:r.jsx("input",{autoFocus:!0,type:"text",value:g,onChange:B=>y(B.target.value),onKeyDown:B=>{B.key==="Escape"&&(h(!1),y(""))},onBlur:()=>{g.trim()||(h(!1),y(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[r.jsx(rn,{className:"h-3 w-3"}),"New Workspace"]})]}),r.jsx("div",{className:"border-t border-border/40"}),r.jsx(wv,{items:RD,onNavigate:t}),r.jsx(Ga,{open:j!==null,onOpenChange:B=>{N||B||(w(null),C(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:k?"Workspace has references":"Delete workspace?"}),r.jsx(Vo,{children:k?r.jsxs(r.Fragment,{children:["The workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," is still referenced by:"]}):r.jsxs(r.Fragment,{children:["Remove the workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),k?r.jsxs("div",{className:"space-y-2 text-sm",children:[k.projects.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",k.projects.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.projects.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/projects/${B}`,className:"hover:underline",children:B})},B))})]}):null,k.standalones.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",k.standalones.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.standalones.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/assignments/${B}`,className:"hover:underline",children:B})},B))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',r.jsx("code",{children:"workspace:"})," / ",r.jsx("code",{children:"workspaceGroup:"})," to ",r.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:N,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),k?r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Clear references and delete"}):r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Delete"})]})]})})]})}function DD(){const e=qn(),{workspace:t}=$t(),{title:n,breadcrumbs:s,projectSlug:a}=D0(e.pathname);return r.jsx(AD,{title:n,breadcrumbs:s,projectSlug:a,workspace:t??null,children:r.jsx(hT,{})})}function ht({label:e="Loading dashboard data…"}){return r.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:r.jsx("div",{className:"chrome-card !px-4 !py-3",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function jt({title:e="Something went wrong",error:t,action:n}){return r.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?r.jsx("div",{className:"pt-2",children:n}):null]})})}function qu({command:e,description:t,example:n}){return r.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[r.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?r.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function We({title:e,description:t,children:n,className:s,actions:a}){return r.jsxs("section",{className:ke("surface-panel space-y-3",s),children:[e||a?r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?r.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),a]}):null,n]})}function $D({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return r.jsx(We,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:r.jsx("div",{className:"space-y-3",children:n.map((s,a)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s.detail}),s.command?r.jsx(qu,{command:s.command.command,example:s.command.example}):null]})]})},s.title))})})}const jm={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},Ho={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function LD(e,t){return e.replace(/\{(\w+)\}/g,(n,s)=>String(t[s]??`{${s}}`))}function OD({hero:e,itemsById:t}){const n=ln();if(e.kind==="clean")return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:Ho.emptyStateCleanTitle}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:jm.clean}),r.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),r.jsx("div",{className:"mt-4",children:r.jsx(Ee,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:Ho.emptyStateCleanCTA})})]});const s=e.itemId?t[e.itemId]:void 0,a=(s==null?void 0:s.assignmentTitle)??"",l=jm[e.copyKey]??jm[e.kind],c=LD(l,{total:e.total,title:a}),u=s?ID(s,n):`${n}/assignments`;return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:"What needs you today"}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:c}),s?r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",r.jsx("span",{className:"font-medium text-foreground",children:s.projectTitle??"Standalone"})," ","· status ",r.jsx("span",{className:"font-medium text-foreground",children:s.status})]}):null,r.jsx("div",{className:"mt-4",children:r.jsxs(Ee,{to:u,className:"shell-action shell-action--cta",children:["Open ",a||"assignment"]})})]})}function ID(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const Dg=["kanban","list","table"],a1=["title","status","priority","assignee","dependencies","created","updated"],MD=["asc","desc"],_D=["comfortable","compact"],FD=["none","status","type","priority","assignee","project"],zD=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function nt(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const s of t){if(typeof s!="string")continue;const a=s.trim();!a||a==="all"||n.includes(a)||n.push(a)}return n}function BD(e,t){const n=nt(e),s=nt(t);return n.length===s.length&&n.every(a=>s.includes(a))}const UD={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},Vl={version:1,global:UD,projects:{}};function km(e){return e==="table"?"table":"kanban"}function VD(e,t){return t?{...e,...t}:{...e}}function i1(e,t){const n=e.global;if(t===null)return n;const s=e.projects[t];return s?{defaultView:s.defaultView??n.defaultView,sortField:s.sortField??n.sortField,sortDirection:s.sortDirection??n.sortDirection,density:n.density,grouping:s.grouping??n.grouping,filters:VD(n.filters,s.filters)}:n}const Sm=["title","status","priority","assignee","dependencies","created","updated"],HD=["small","wide","tall","large"],WD={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},Uv="2026-05-21T00:00:00Z";function Nm(e,t,n){return{id:e,name:t,workspace:null,config:{viewMode:"list",filters:{...WD,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:Uv,updatedAt:Uv}}const ao={version:1,views:[Nm("default-recently-updated","Recently updated",{}),Nm("default-high-priority","High priority",{priority:"high"}),Nm("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function l1(e,t){const n=nt(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,a=e.filters.activity,l=typeof e.filters.search=="string"&&e.filters.search.trim().length>0;return s&&(!a||a==="all")&&!l}function c1(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?l1(e.config,t.slug):!1}}const u1=`syntaur.savedViews.cache.v${ao.version}`;let oi=KD(),_o=null,$g=null;const yh=new Set,cd=new Set;let d1=0;function f1(){return++d1}function bh(e){return e===d1}function KD(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(u1);if(!e)return null;const t=JSON.parse(e);return t.version!==ao.version?null:t}catch{return null}}function qD(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(u1,JSON.stringify(e))}catch{}}function p1(e){oi=e,$g=null,qD(e);for(const t of yh)t(e);for(const t of cd)t(null)}function GD(e){$g=e;for(const t of cd)t(e)}function m1(e){if(!e||typeof e!="object")return ao;const t=e;return t.version!==ao.version||!Array.isArray(t.views)||!t.dashboard?ao:t}function Vv(){if(_o)return _o;const e=f1();return _o=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=m1(t);return bh(e)&&p1(n),_o=null,oi??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return bh(e)&&GD(n),_o=null,oi??ao}),_o}function Lg(){const[e,t]=f.useState(()=>oi??ao),[n,s]=f.useState(()=>oi===null),[a,l]=f.useState(!1),[c,u]=f.useState(()=>$g);return f.useEffect(()=>{let m=!1;oi===null&&s(!0),Vv().then(y=>{m||(t(y),s(!1),l(!0))});const h=y=>{m||(t(y),s(!1),l(!0),u(null))},g=y=>{m||(u(y),s(!1),l(!0))};return yh.add(h),cd.add(g),()=>{m=!0,yh.delete(h),cd.delete(g)}},[]),{file:e,loading:n,ready:a,error:c,refetch:()=>{_o=null,s(!0),u(null),l(!1),Vv()}}}function Vd(){const{file:e,loading:t}=Lg();return{views:e.views,loading:t}}function YD(){const{file:e,loading:t}=Lg();return{layout:e.dashboard,loading:t}}function Go(e){const{file:t,loading:n,ready:s,error:a,refetch:l}=Lg();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:a,refetch:l}:{view:null,loading:!1,ready:!0,error:null,refetch:l}}async function Hd(e,t,n){const s=f1(),a=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!a.ok){const c=await a.json().catch(()=>({error:`HTTP ${a.status}`}));throw new Error(c.error??`HTTP ${a.status}`)}const l=m1(await a.json());return bh(s)&&p1(l),l}function Wd(e){return Hd("POST","/api/saved-views",e)}function Og(e,t){return Hd("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function JD(e){return Hd("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function XD(e){return Hd("PUT","/api/dashboard",{slots:e})}const QD=["top","right","bottom","left"],co=Math.min,hr=Math.max,ud=Math.round,Pu=Math.floor,ps=e=>({x:e,y:e}),ZD={left:"right",right:"left",bottom:"top",top:"bottom"};function vh(e,t,n){return hr(e,co(t,n))}function $s(e,t){return typeof e=="function"?e(t):e}function Ls(e){return e.split("-")[0]}function wi(e){return e.split("-")[1]}function Ig(e){return e==="x"?"y":"x"}function Mg(e){return e==="y"?"height":"width"}function us(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function _g(e){return Ig(us(e))}function e4(e,t,n){n===void 0&&(n=!1);const s=wi(e),a=_g(e),l=Mg(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=dd(c)),[c,dd(c)]}function t4(e){const t=dd(e);return[wh(e),t,wh(t)]}function wh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hv=["left","right"],Wv=["right","left"],n4=["top","bottom"],r4=["bottom","top"];function s4(e,t,n){switch(e){case"top":case"bottom":return n?t?Wv:Hv:t?Hv:Wv;case"left":case"right":return t?n4:r4;default:return[]}}function o4(e,t,n,s){const a=wi(e);let l=s4(Ls(e),n==="start",s);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(wh)))),l}function dd(e){const t=Ls(e);return ZD[t]+e.slice(t.length)}function a4(e){return{top:0,right:0,bottom:0,left:0,...e}}function h1(e){return typeof e!="number"?a4(e):{top:e,right:e,bottom:e,left:e}}function fd(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Kv(e,t,n){let{reference:s,floating:a}=e;const l=us(t),c=_g(t),u=Mg(c),p=Ls(t),m=l==="y",h=s.x+s.width/2-a.width/2,g=s.y+s.height/2-a.height/2,y=s[u]/2-a[u]/2;let b;switch(p){case"top":b={x:h,y:s.y-a.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-a.width,y:g};break;default:b={x:s.x,y:s.y}}switch(wi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function i4(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:l,rects:c,elements:u,strategy:p}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=$s(t,e),E=h1(b),w=u[y?g==="floating"?"reference":"floating":g],k=fd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(w)))==null||n?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:p})),C=g==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),T=await(l.isElement==null?void 0:l.isElement(N))?await(l.getScale==null?void 0:l.getScale(N))||{x:1,y:1}:{x:1,y:1},O=fd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:C,offsetParent:N,strategy:p}):C);return{top:(k.top-O.top+E.top)/T.y,bottom:(O.bottom-k.bottom+E.bottom)/T.y,left:(k.left-O.left+E.left)/T.x,right:(O.right-k.right+E.right)/T.x}}const l4=50,c4=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:l=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:i4},p=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:h,y:g}=Kv(m,s,p),y=s,b=0;const E={};for(let j=0;j<l.length;j++){const w=l[j];if(!w)continue;const{name:k,fn:C}=w,{x:N,y:T,data:O,reset:P}=await C({x:h,y:g,initialPlacement:s,placement:y,strategy:a,middlewareData:E,rects:m,platform:u,elements:{reference:e,floating:t}});h=N??h,g=T??g,E[k]={...E[k],...O},P&&b<l4&&(b++,typeof P=="object"&&(P.placement&&(y=P.placement),P.rects&&(m=P.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):P.rects),{x:h,y:g}=Kv(m,y,p)),j=-1)}return{x:h,y:g,placement:y,strategy:a,middlewareData:E}},u4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:l,platform:c,elements:u,middlewareData:p}=t,{element:m,padding:h=0}=$s(e,t)||{};if(m==null)return{};const g=h1(h),y={x:n,y:s},b=_g(a),E=Mg(b),j=await c.getDimensions(m),w=b==="y",k=w?"top":"left",C=w?"bottom":"right",N=w?"clientHeight":"clientWidth",T=l.reference[E]+l.reference[b]-y[b]-l.floating[E],O=y[b]-l.reference[b],P=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let D=P?P[N]:0;(!D||!await(c.isElement==null?void 0:c.isElement(P)))&&(D=u.floating[N]||l.floating[E]);const L=T/2-O/2,W=D/2-j[E]/2-1,B=co(g[k],W),$=co(g[C],W),K=B,re=D-j[E]-$,I=D/2-j[E]/2+L,H=vh(K,I,re),J=!p.arrow&&wi(a)!=null&&I!==H&&l.reference[E]/2-(I<K?B:$)-j[E]/2<0,ne=J?I<K?I-K:I-re:0;return{[b]:y[b]+ne,data:{[b]:H,centerOffset:I-H-ne,...J&&{alignmentOffset:ne}},reset:J}}}),d4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:p,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:j=!0,...w}=$s(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const k=Ls(a),C=us(u),N=Ls(u)===u,T=await(p.isRTL==null?void 0:p.isRTL(m.floating)),O=y||(N||!j?[dd(u)]:t4(u)),P=E!=="none";!y&&P&&O.push(...o4(u,j,E,T));const D=[u,...O],L=await p.detectOverflow(t,w),W=[];let B=((s=l.flip)==null?void 0:s.overflows)||[];if(h&&W.push(L[k]),g){const I=e4(a,c,T);W.push(L[I[0]],L[I[1]])}if(B=[...B,{placement:a,overflows:W}],!W.every(I=>I<=0)){var $,K;const I=((($=l.flip)==null?void 0:$.index)||0)+1,H=D[I];if(H&&(!(g==="alignment"?C!==us(H):!1)||B.every(_=>us(_.placement)===C?_.overflows[0]>0:!0)))return{data:{index:I,overflows:B},reset:{placement:H}};let J=(K=B.filter(ne=>ne.overflows[0]<=0).sort((ne,_)=>ne.overflows[1]-_.overflows[1])[0])==null?void 0:K.placement;if(!J)switch(b){case"bestFit":{var re;const ne=(re=B.filter(_=>{if(P){const G=us(_.placement);return G===C||G==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(G=>G>0).reduce((G,A)=>G+A,0)]).sort((_,G)=>_[1]-G[1])[0])==null?void 0:re[0];ne&&(J=ne);break}case"initialPlacement":J=u;break}if(a!==J)return{reset:{placement:J}}}return{}}}};function qv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Gv(e){return QD.some(t=>e[t]>=0)}const f4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...l}=$s(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),u=qv(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:Gv(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),u=qv(c,n.floating);return{data:{escapedOffsets:u,escaped:Gv(u)}}}default:return{}}}}},g1=new Set(["left","top"]);async function p4(e,t){const{placement:n,platform:s,elements:a}=e,l=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Ls(n),u=wi(n),p=us(n)==="y",m=g1.has(c)?-1:1,h=l&&p?-1:1,g=$s(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof E=="number"&&(b=u==="end"?E*-1:E),p?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const m4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:l,placement:c,middlewareData:u}=t,p=await p4(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:a+p.x,y:l+p.y,data:{...p,placement:c}}}}},h4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:p={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...m}=$s(e,t),h={x:n,y:s},g=await l.detectOverflow(t,m),y=us(Ls(a)),b=Ig(y);let E=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",N=E+g[k],T=E-g[C];E=vh(N,E,T)}if(u){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",N=j+g[k],T=j-g[C];j=vh(N,j,T)}const w=p.fn({...t,[b]:E,[y]:j});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[b]:c,[y]:u}}}}}},g4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:m=!0}=$s(e,t),h={x:n,y:s},g=us(a),y=Ig(g);let b=h[y],E=h[g];const j=$s(u,t),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(p){const N=y==="y"?"height":"width",T=l.reference[y]-l.floating[N]+w.mainAxis,O=l.reference[y]+l.reference[N]-w.mainAxis;b<T?b=T:b>O&&(b=O)}if(m){var k,C;const N=y==="y"?"width":"height",T=g1.has(Ls(a)),O=l.reference[g]-l.floating[N]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:w.crossAxis),P=l.reference[g]+l.reference[N]+(T?0:((C=c.offset)==null?void 0:C[g])||0)-(T?w.crossAxis:0);E<O?E=O:E>P&&(E=P)}return{[y]:b,[g]:E}}}},x4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:l,platform:c,elements:u}=t,{apply:p=()=>{},...m}=$s(e,t),h=await c.detectOverflow(t,m),g=Ls(a),y=wi(a),b=us(a)==="y",{width:E,height:j}=l.floating;let w,k;g==="top"||g==="bottom"?(w=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,w=y==="end"?"top":"bottom");const C=j-h.top-h.bottom,N=E-h.left-h.right,T=co(j-h[w],C),O=co(E-h[k],N),P=!t.middlewareData.shift;let D=T,L=O;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(D=C),P&&!y){const B=hr(h.left,0),$=hr(h.right,0),K=hr(h.top,0),re=hr(h.bottom,0);b?L=E-2*(B!==0||$!==0?B+$:hr(h.left,h.right)):D=j-2*(K!==0||re!==0?K+re:hr(h.top,h.bottom))}await p({...t,availableWidth:L,availableHeight:D});const W=await c.getDimensions(u.floating);return E!==W.width||j!==W.height?{reset:{rects:!0}}:{}}}};function Kd(){return typeof window<"u"}function ji(e){return x1(e)?(e.nodeName||"").toLowerCase():"#document"}function yr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ys(e){var t;return(t=(x1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function x1(e){return Kd()?e instanceof Node||e instanceof yr(e).Node:!1}function Gr(e){return Kd()?e instanceof Element||e instanceof yr(e).Element:!1}function Is(e){return Kd()?e instanceof HTMLElement||e instanceof yr(e).HTMLElement:!1}function Yv(e){return!Kd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yr(e).ShadowRoot}function ic(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=Yr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function y4(e){return/^(table|td|th)$/.test(ji(e))}function qd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const b4=/transform|translate|scale|rotate|perspective|filter/,v4=/paint|layout|strict|content/,Io=e=>!!e&&e!=="none";let Cm;function Fg(e){const t=Gr(e)?Yr(e):e;return Io(t.transform)||Io(t.translate)||Io(t.scale)||Io(t.rotate)||Io(t.perspective)||!zg()&&(Io(t.backdropFilter)||Io(t.filter))||b4.test(t.willChange||"")||v4.test(t.contain||"")}function w4(e){let t=uo(e);for(;Is(t)&&!fi(t);){if(Fg(t))return t;if(qd(t))return null;t=uo(t)}return null}function zg(){return Cm==null&&(Cm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cm}function fi(e){return/^(html|body|#document)$/.test(ji(e))}function Yr(e){return yr(e).getComputedStyle(e)}function Gd(e){return Gr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function uo(e){if(ji(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Yv(e)&&e.host||ys(e);return Yv(t)?t.host:t}function y1(e){const t=uo(e);return fi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Is(t)&&ic(t)?t:y1(t)}function Hl(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=y1(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),c=yr(a);if(l){const u=jh(c);return t.concat(c,c.visualViewport||[],ic(a)?a:[],u&&n?Hl(u):[])}else return t.concat(a,Hl(a,[],n))}function jh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function b1(e){const t=Yr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Is(e),l=a?e.offsetWidth:n,c=a?e.offsetHeight:s,u=ud(n)!==l||ud(s)!==c;return u&&(n=l,s=c),{width:n,height:s,$:u}}function Bg(e){return Gr(e)?e:e.contextElement}function ai(e){const t=Bg(e);if(!Is(t))return ps(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=b1(t);let c=(l?ud(n.width):n.width)/s,u=(l?ud(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const j4=ps(0);function v1(e){const t=yr(e);return!zg()||!t.visualViewport?j4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function k4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yr(e)?!1:t}function Yo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=Bg(e);let c=ps(1);t&&(s?Gr(s)&&(c=ai(s)):c=ai(e));const u=k4(l,n,s)?v1(l):ps(0);let p=(a.left+u.x)/c.x,m=(a.top+u.y)/c.y,h=a.width/c.x,g=a.height/c.y;if(l){const y=yr(l),b=s&&Gr(s)?yr(s):s;let E=y,j=jh(E);for(;j&&s&&b!==E;){const w=ai(j),k=j.getBoundingClientRect(),C=Yr(j),N=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,T=k.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;p*=w.x,m*=w.y,h*=w.x,g*=w.y,p+=N,m+=T,E=yr(j),j=jh(E)}}return fd({width:h,height:g,x:p,y:m})}function Yd(e,t){const n=Gd(e).scrollLeft;return t?t.left+n:Yo(ys(e)).left+n}function w1(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Yd(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function S4(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",c=ys(s),u=t?qd(t.floating):!1;if(s===c||u&&l)return n;let p={scrollLeft:0,scrollTop:0},m=ps(1);const h=ps(0),g=Is(s);if((g||!g&&!l)&&((ji(s)!=="body"||ic(c))&&(p=Gd(s)),g)){const b=Yo(s);m=ai(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!l?w1(c,p):ps(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-p.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-p.scrollTop*m.y+h.y+y.y}}function N4(e){return Array.from(e.getClientRects())}function C4(e){const t=ys(e),n=Gd(e),s=e.ownerDocument.body,a=hr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=hr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Yd(e);const u=-n.scrollTop;return Yr(s).direction==="rtl"&&(c+=hr(t.clientWidth,s.clientWidth)-a),{width:a,height:l,x:c,y:u}}const Jv=25;function E4(e,t){const n=yr(e),s=ys(e),a=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,p=0;if(a){l=a.width,c=a.height;const h=zg();(!h||h&&t==="fixed")&&(u=a.offsetLeft,p=a.offsetTop)}const m=Yd(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,E=Math.abs(s.clientWidth-g.clientWidth-b);E<=Jv&&(l-=E)}else m<=Jv&&(l+=m);return{width:l,height:c,x:u,y:p}}function T4(e,t){const n=Yo(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=Is(e)?ai(e):ps(1),c=e.clientWidth*l.x,u=e.clientHeight*l.y,p=a*l.x,m=s*l.y;return{width:c,height:u,x:p,y:m}}function Xv(e,t,n){let s;if(t==="viewport")s=E4(e,n);else if(t==="document")s=C4(ys(e));else if(Gr(t))s=T4(t,n);else{const a=v1(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return fd(s)}function j1(e,t){const n=uo(e);return n===t||!Gr(n)||fi(n)?!1:Yr(n).position==="fixed"||j1(n,t)}function P4(e,t){const n=t.get(e);if(n)return n;let s=Hl(e,[],!1).filter(u=>Gr(u)&&ji(u)!=="body"),a=null;const l=Yr(e).position==="fixed";let c=l?uo(e):e;for(;Gr(c)&&!fi(c);){const u=Yr(c),p=Fg(c);!p&&u.position==="fixed"&&(a=null),(l?!p&&!a:!p&&u.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ic(c)&&!p&&j1(e,c))?s=s.filter(h=>h!==c):a=u,c=uo(c)}return t.set(e,s),s}function R4(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?qd(t)?[]:P4(t,this._c):[].concat(n),s],u=Xv(t,c[0],a);let p=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=Xv(t,c[y],a);p=hr(b.top,p),m=co(b.right,m),h=co(b.bottom,h),g=hr(b.left,g)}return{width:m-g,height:h-p,x:g,y:p}}function A4(e){const{width:t,height:n}=b1(e);return{width:t,height:n}}function D4(e,t,n){const s=Is(t),a=ys(t),l=n==="fixed",c=Yo(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const p=ps(0);function m(){p.x=Yd(a)}if(s||!s&&!l)if((ji(t)!=="body"||ic(a))&&(u=Gd(t)),s){const b=Yo(t,!0,l,t);p.x=b.x+t.clientLeft,p.y=b.y+t.clientTop}else a&&m();l&&!s&&a&&m();const h=a&&!s&&!l?w1(a,u):ps(0),g=c.left+u.scrollLeft-p.x-h.x,y=c.top+u.scrollTop-p.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Em(e){return Yr(e).position==="static"}function Qv(e,t){if(!Is(e)||Yr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ys(e)===n&&(n=n.ownerDocument.body),n}function k1(e,t){const n=yr(e);if(qd(e))return n;if(!Is(e)){let a=uo(e);for(;a&&!fi(a);){if(Gr(a)&&!Em(a))return a;a=uo(a)}return n}let s=Qv(e,t);for(;s&&y4(s)&&Em(s);)s=Qv(s,t);return s&&fi(s)&&Em(s)&&!Fg(s)?n:s||w4(e)||n}const $4=async function(e){const t=this.getOffsetParent||k1,n=this.getDimensions,s=await n(e.floating);return{reference:D4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function L4(e){return Yr(e).direction==="rtl"}const O4={convertOffsetParentRelativeRectToViewportRelativeRect:S4,getDocumentElement:ys,getClippingRect:R4,getOffsetParent:k1,getElementRects:$4,getClientRects:N4,getDimensions:A4,getScale:ai,isElement:Gr,isRTL:L4};function S1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function I4(e,t){let n=null,s;const a=ys(e);function l(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,p){u===void 0&&(u=!1),p===void 0&&(p=1),l();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const E=Pu(g),j=Pu(a.clientWidth-(h+y)),w=Pu(a.clientHeight-(g+b)),k=Pu(h),N={rootMargin:-E+"px "+-j+"px "+-w+"px "+-k+"px",threshold:hr(0,co(1,p))||1};let T=!0;function O(P){const D=P[0].intersectionRatio;if(D!==p){if(!T)return c();D?c(!1,D):s=setTimeout(()=>{c(!1,1e-7)},1e3)}D===1&&!S1(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(O,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,N)}n.observe(e)}return c(!0),l}function M4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:p=!1}=s,m=Bg(e),h=a||l?[...m?Hl(m):[],...t?Hl(t):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),l&&k.addEventListener("resize",n)});const g=m&&u?I4(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[C]=k;C&&C.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var N;(N=b)==null||N.observe(t)})),n()}),m&&!p&&b.observe(m),t&&b.observe(t));let E,j=p?Yo(e):null;p&&w();function w(){const k=Yo(e);j&&!S1(j,k)&&n(),j=k,E=requestAnimationFrame(w)}return n(),()=>{var k;h.forEach(C=>{a&&C.removeEventListener("scroll",n),l&&C.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,p&&cancelAnimationFrame(E)}}const _4=m4,F4=h4,z4=d4,B4=x4,U4=f4,Zv=u4,V4=g4,H4=(e,t,n)=>{const s=new Map,a={platform:O4,...n},l={...a.platform,_c:s};return c4(e,t,{...a,platform:l})};var W4=typeof document<"u",K4=function(){},Gu=W4?f.useLayoutEffect:K4;function pd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!pd(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const l=a[s];if(!(l==="_owner"&&e.$$typeof)&&!pd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function N1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ew(e,t){const n=N1(e);return Math.round(t*n)/n}function Tm(e){const t=f.useRef(e);return Gu(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:p,open:m}=e,[h,g]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=f.useState(s);pd(y,s)||b(s);const[E,j]=f.useState(null),[w,k]=f.useState(null),C=f.useCallback(_=>{_!==P.current&&(P.current=_,j(_))},[]),N=f.useCallback(_=>{_!==D.current&&(D.current=_,k(_))},[]),T=l||E,O=c||w,P=f.useRef(null),D=f.useRef(null),L=f.useRef(h),W=p!=null,B=Tm(p),$=Tm(a),K=Tm(m),re=f.useCallback(()=>{if(!P.current||!D.current)return;const _={placement:t,strategy:n,middleware:y};$.current&&(_.platform=$.current),H4(P.current,D.current,_).then(G=>{const A={...G,isPositioned:K.current!==!1};I.current&&!pd(L.current,A)&&(L.current=A,Rs.flushSync(()=>{g(A)}))})},[y,t,n,$,K]);Gu(()=>{m===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,g(_=>({..._,isPositioned:!1})))},[m]);const I=f.useRef(!1);Gu(()=>(I.current=!0,()=>{I.current=!1}),[]),Gu(()=>{if(T&&(P.current=T),O&&(D.current=O),T&&O){if(B.current)return B.current(T,O,re);re()}},[T,O,re,B,W]);const H=f.useMemo(()=>({reference:P,floating:D,setReference:C,setFloating:N}),[C,N]),J=f.useMemo(()=>({reference:T,floating:O}),[T,O]),ne=f.useMemo(()=>{const _={position:n,left:0,top:0};if(!J.floating)return _;const G=ew(J.floating,h.x),A=ew(J.floating,h.y);return u?{..._,transform:"translate("+G+"px, "+A+"px)",...N1(J.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:A}},[n,u,J.floating,h.x,h.y]);return f.useMemo(()=>({...h,update:re,refs:H,elements:J,floatingStyles:ne}),[h,re,H,J,ne])}const G4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Zv({element:s.current,padding:a}).fn(n):{}:s?Zv({element:s,padding:a}).fn(n):{}}}},Y4=(e,t)=>{const n=_4(e);return{name:n.name,fn:n.fn,options:[e,t]}},J4=(e,t)=>{const n=F4(e);return{name:n.name,fn:n.fn,options:[e,t]}},X4=(e,t)=>({fn:V4(e).fn,options:[e,t]}),Q4=(e,t)=>{const n=z4(e);return{name:n.name,fn:n.fn,options:[e,t]}},Z4=(e,t)=>{const n=B4(e);return{name:n.name,fn:n.fn,options:[e,t]}},e$=(e,t)=>{const n=U4(e);return{name:n.name,fn:n.fn,options:[e,t]}},t$=(e,t)=>{const n=G4(e);return{name:n.name,fn:n.fn,options:[e,t]}};var n$="Arrow",C1=f.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...l}=e;return r.jsx(hn.svg,{...l,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});C1.displayName=n$;var r$=C1;function s$(e){const[t,n]=f.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let c,u;if("borderBoxSize"in l){const p=l.borderBoxSize,m=Array.isArray(p)?p[0]:p;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Ug="Popper",[E1,T1]=Xo(Ug),[o$,P1]=E1(Ug),R1=e=>{const{__scopePopper:t,children:n}=e,[s,a]=f.useState(null);return r.jsx(o$,{scope:t,anchor:s,onAnchorChange:a,children:n})};R1.displayName=Ug;var A1="PopperAnchor",D1=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,l=P1(A1,n),c=f.useRef(null),u=Fn(t,c),p=f.useRef(null);return f.useEffect(()=>{const m=p.current;p.current=(s==null?void 0:s.current)||c.current,m!==p.current&&l.onAnchorChange(p.current)}),s?null:r.jsx(hn.div,{...a,ref:u})});D1.displayName=A1;var Vg="PopperContent",[a$,i$]=E1(Vg),$1=f.forwardRef((e,t)=>{var ae,me,ve,Se,he,Je;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:E,...j}=e,w=P1(Vg,n),[k,C]=f.useState(null),N=Fn(t,Ye=>C(Ye)),[T,O]=f.useState(null),P=s$(T),D=(P==null?void 0:P.width)??0,L=(P==null?void 0:P.height)??0,W=s+(l!=="center"?"-"+l:""),B=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(m)?m:[m],K=$.length>0,re={padding:B,boundary:$.filter(c$),altBoundary:K},{refs:I,floatingStyles:H,placement:J,isPositioned:ne,middlewareData:_}=q4({strategy:"fixed",placement:W,whileElementsMounted:(...Ye)=>M4(...Ye,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[Y4({mainAxis:a+L,alignmentAxis:c}),p&&J4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?X4():void 0,...re}),p&&Q4({...re}),Z4({...re,apply:({elements:Ye,rects:at,availableWidth:X,availableHeight:Ie})=>{const{width:Ne,height:Oe}=at.reference,Xe=Ye.floating.style;Xe.setProperty("--radix-popper-available-width",`${X}px`),Xe.setProperty("--radix-popper-available-height",`${Ie}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),T&&t$({element:T,padding:u}),u$({arrowWidth:D,arrowHeight:L}),y&&e$({strategy:"referenceHidden",...re})]}),[G,A]=I1(J),z=Ko(E);lo(()=>{ne&&(z==null||z())},[ne,z]);const ee=(ae=_.arrow)==null?void 0:ae.x,M=(me=_.arrow)==null?void 0:me.y,ue=((ve=_.arrow)==null?void 0:ve.centerOffset)!==0,[ge,V]=f.useState();return lo(()=>{k&&V(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:ne?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Se=_.transformOrigin)==null?void 0:Se.x,(he=_.transformOrigin)==null?void 0:he.y].join(" "),...((Je=_.hide)==null?void 0:Je.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(a$,{scope:n,placedSide:G,onArrowChange:O,arrowX:ee,arrowY:M,shouldHideArrow:ue,children:r.jsx(hn.div,{"data-side":G,"data-align":A,...j,ref:N,style:{...j.style,animation:ne?void 0:"none"}})})})});$1.displayName=Vg;var L1="PopperArrow",l$={top:"bottom",right:"left",bottom:"top",left:"right"},O1=f.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,l=i$(L1,s),c=l$[l.placedSide];return r.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:r.jsx(r$,{...a,ref:n,style:{...a.style,display:"block"}})})});O1.displayName=L1;function c$(e){return e!==null}var u$=e=>({name:"transformOrigin",options:e,fn(t){var w,k,C;const{placement:n,rects:s,middlewareData:a}=t,c=((w=a.arrow)==null?void 0:w.centerOffset)!==0,u=c?0:e.arrowWidth,p=c?0:e.arrowHeight,[m,h]=I1(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=a.arrow)==null?void 0:k.x)??0)+u/2,b=(((C=a.arrow)==null?void 0:C.y)??0)+p/2;let E="",j="";return m==="bottom"?(E=c?g:`${y}px`,j=`${-p}px`):m==="top"?(E=c?g:`${y}px`,j=`${s.floating.height+p}px`):m==="right"?(E=`${-p}px`,j=c?g:`${b}px`):m==="left"&&(E=`${s.floating.width+p}px`,j=c?g:`${b}px`),{data:{x:E,y:j}}}});function I1(e){const[t,n="center"]=e.split("-");return[t,n]}var d$=R1,f$=D1,p$=$1,m$=O1,h$=Symbol("radix.slottable");function g$(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=h$,t}var x$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),y$="VisuallyHidden",M1=f.forwardRef((e,t)=>r.jsx(hn.span,{...e,ref:t,style:{...x$,...e.style}}));M1.displayName=y$;var b$=M1,[Jd]=Xo("Tooltip",[T1]),Xd=T1(),_1="TooltipProvider",v$=700,kh="tooltip.open",[w$,Hg]=Jd(_1),F1=e=>{const{__scopeTooltip:t,delayDuration:n=v$,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:l}=e,c=f.useRef(!0),u=f.useRef(!1),p=f.useRef(0);return f.useEffect(()=>{const m=p.current;return()=>window.clearTimeout(m)},[]),r.jsx(w$,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(p.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:f.useCallback(m=>{u.current=m},[]),disableHoverableContent:a,children:l})};F1.displayName=_1;var Wl="Tooltip",[j$,lc]=Jd(Wl),z1=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:a,onOpenChange:l,disableHoverableContent:c,delayDuration:u}=e,p=Hg(Wl,e.__scopeTooltip),m=Xd(t),[h,g]=f.useState(null),y=ni(),b=f.useRef(0),E=c??p.disableHoverableContent,j=u??p.delayDuration,w=f.useRef(!1),[k,C]=zd({prop:s,defaultProp:a??!1,onChange:D=>{D?(p.onOpen(),document.dispatchEvent(new CustomEvent(kh))):p.onClose(),l==null||l(D)},caller:Wl}),N=f.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),T=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,C(!0)},[C]),O=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C(!1)},[C]),P=f.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,C(!0),b.current=0},j)},[j,C]);return f.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(d$,{...m,children:r.jsx(j$,{scope:t,contentId:y,open:k,stateAttribute:N,trigger:h,onTriggerChange:g,onTriggerEnter:f.useCallback(()=>{p.isOpenDelayedRef.current?P():T()},[p.isOpenDelayedRef,P,T]),onTriggerLeave:f.useCallback(()=>{E?O():(window.clearTimeout(b.current),b.current=0)},[O,E]),onOpen:T,onClose:O,disableHoverableContent:E,children:n})})};z1.displayName=Wl;var Sh="TooltipTrigger",B1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=lc(Sh,n),l=Hg(Sh,n),c=Xd(n),u=f.useRef(null),p=Fn(t,u,a.onTriggerChange),m=f.useRef(!1),h=f.useRef(!1),g=f.useCallback(()=>m.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(f$,{asChild:!0,...c,children:r.jsx(hn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:p,onPointerMove:qt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:qt(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:qt(e.onPointerDown,()=>{a.open&&a.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:qt(e.onFocus,()=>{m.current||a.onOpen()}),onBlur:qt(e.onBlur,a.onClose),onClick:qt(e.onClick,a.onClose)})})});B1.displayName=Sh;var Wg="TooltipPortal",[k$,S$]=Jd(Wg,{forceMount:void 0}),U1=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:a}=e,l=lc(Wg,t);return r.jsx(k$,{scope:t,forceMount:n,children:r.jsx(Qo,{present:n||l.open,children:r.jsx(yg,{asChild:!0,container:a,children:s})})})};U1.displayName=Wg;var pi="TooltipContent",V1=f.forwardRef((e,t)=>{const n=S$(pi,e.__scopeTooltip),{forceMount:s=n.forceMount,side:a="top",...l}=e,c=lc(pi,e.__scopeTooltip);return r.jsx(Qo,{present:s||c.open,children:c.disableHoverableContent?r.jsx(H1,{side:a,...l,ref:t}):r.jsx(N$,{side:a,...l,ref:t})})}),N$=f.forwardRef((e,t)=>{const n=lc(pi,e.__scopeTooltip),s=Hg(pi,e.__scopeTooltip),a=f.useRef(null),l=Fn(t,a),[c,u]=f.useState(null),{trigger:p,onClose:m}=n,h=a.current,{onPointerInTransitChange:g}=s,y=f.useCallback(()=>{u(null),g(!1)},[g]),b=f.useCallback((E,j)=>{const w=E.currentTarget,k={x:E.clientX,y:E.clientY},C=R$(k,w.getBoundingClientRect()),N=A$(k,C),T=D$(j.getBoundingClientRect()),O=L$([...N,...T]);u(O),g(!0)},[g]);return f.useEffect(()=>()=>y(),[y]),f.useEffect(()=>{if(p&&h){const E=w=>b(w,h),j=w=>b(w,p);return p.addEventListener("pointerleave",E),h.addEventListener("pointerleave",j),()=>{p.removeEventListener("pointerleave",E),h.removeEventListener("pointerleave",j)}}},[p,h,b,y]),f.useEffect(()=>{if(c){const E=j=>{const w=j.target,k={x:j.clientX,y:j.clientY},C=(p==null?void 0:p.contains(w))||(h==null?void 0:h.contains(w)),N=!$$(k,c);C?y():N&&(y(),m())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[p,h,c,m,y]),r.jsx(H1,{...e,ref:l})}),[C$,E$]=Jd(Wl,{isInside:!1}),T$=g$("TooltipContent"),H1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=e,p=lc(pi,n),m=Xd(n),{onClose:h}=p;return f.useEffect(()=>(document.addEventListener(kh,h),()=>document.removeEventListener(kh,h)),[h]),f.useEffect(()=>{if(p.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(p.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,h]),r.jsx(xg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(p$,{"data-state":p.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(T$,{children:s}),r.jsx(C$,{scope:n,isInside:!0,children:r.jsx(b$,{id:p.contentId,role:"tooltip",children:a||s})})]})})});V1.displayName=pi;var W1="TooltipArrow",P$=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=Xd(n);return E$(W1,n).isInside?null:r.jsx(m$,{...a,...s,ref:t})});P$.displayName=W1;function R$(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,s,a,l)){case l:return"left";case a:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function A$(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function D$(e){const{top:t,right:n,bottom:s,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:s},{x:a,y:s}]}function $$(e,t){const{x:n,y:s}=e;let a=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const u=t[l],p=t[c],m=u.x,h=u.y,g=p.x,y=p.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(a=!a)}return a}function L$(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),O$(t)}function O$(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const a=e[s];for(;t.length>=2;){const l=t[t.length-1],c=t[t.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var I$=F1,M$=z1,_$=B1,F$=U1,K1=V1;const Wo=I$,Rr=M$,Ar=_$,gr=f.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(F$,{children:r.jsx(K1,{ref:s,sideOffset:t,className:ke("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gr.displayName=K1.displayName;function Kg({items:e,align:t="end"}){const[n,s]=f.useState(!1),[a,l]=f.useState(null),c=f.useRef(null);if(f.useEffect(()=>{if(!n){l(null);return}function p(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(p,m){const h=p.icon,g=ke("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",p.disabled?"opacity-50 cursor-not-allowed":p.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?p.active?r.jsx(Qr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:p.label})]});if(p.disabled){const E=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return p.disabledReason?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:E}),r.jsx(gr,{side:"left",children:p.disabledReason})]},p.key):r.jsx("div",{children:E},p.key)}return p.href?r.jsx(Ee,{to:p.href,className:g,onClick:()=>s(!1),children:b},p.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var E;(E=p.onSelect)==null||E.call(p),s(!1)},children:b},p.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(fP,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:ke("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(Wo,{delayDuration:200,children:e.map(p=>{if(p.submenu&&p.submenu.length>0){const m=p.icon,h=a===p.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:ke("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>l(h?null:p.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:p.label}),h?r.jsx(br,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(f0,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?p.submenu.map(g=>u(g,!0)):null]},p.key)}return u(p,!1)})})})]})}function tw(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const z$={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function B$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function U$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function V$(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,a=Date.parse(s);if(Number.isNaN(a))return!1;if(t.preset){const u=z$[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-a>u:a>=n-u&&a<=n}const l=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!l&&!c?!0:!(l&&a<B$(l)||c&&a>U$(c))}function qg(e,t,n={}){const{workspace:s,search:a,includeArchived:l}=n;if(e.archived===!0&&!l)return!1;const c=nt(t.status),u=nt(t.priority),p=nt(t.type),m=nt(t.assignee),h=nt(t.project),g=nt(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||p.length&&!p.includes(e.type??"")||y==="stale"&&!tw(e.updated)||y==="fresh"&&tw(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(E=>E==="__standalone__"?e.projectSlug==null:e.projectSlug===E))return!1;if(g.length){const b=e.tags??[];if(!g.some(E=>b.includes(E)))return!1}if(!V$(e,t.dateRange))return!1;if(a){const b=a.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function Kl(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const q1={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let Rl=null,Fo=null;function H$(){return Rl?Promise.resolve(Rl):Fo||(Fo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Rl=e,Fo=null,e)).catch(()=>(Fo=null,q1)),Fo)}function Zo(){const[e,t]=f.useState(()=>Rl??q1);return f.useEffect(()=>{H$().then(t)},[]),e}function nw(){Rl=null,Fo=null}function cc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const rw={critical:0,high:1,medium:2,low:3};function Ru(e){return Date.parse(e??"")||0}function uc(e,t,n){return[...e].sort((a,l)=>{let c=0;switch(t){case"title":c=a.title.localeCompare(l.title);break;case"status":c=a.status.localeCompare(l.status);break;case"priority":c=(rw[a.priority]??99)-(rw[l.priority]??99);break;case"assignee":c=(a.assignee??"").localeCompare(l.assignee??"");break;case"dependencies":c=a.dependsOn.length-l.dependsOn.length;break;case"created":c=Ru(a.created)-Ru(l.created);break;case"updated":c=Ru(a.updated)-Ru(l.updated);break}return n==="asc"?c:-c})}function Nt({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const mi='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Qd({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:a,canDrop:l,onMove:c,getExternalDragData:u,onCardContextMenu:p,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const E=f.useMemo(()=>new Set(h??[]),[h]),j=f.useMemo(()=>e.filter(I=>!E.has(I.id)),[e,E]),w=f.useMemo(()=>e.filter(I=>E.has(I.id)),[e,E]),[k,C]=f.useState(null),[N,T]=f.useState(null),O=f.useRef(null),P=f.useMemo(()=>new Map(t.map(I=>[n(I),I])),[n,t]),D=f.useMemo(()=>j.map(I=>({column:I,items:t.filter(H=>s(H)===I.id)})),[j,s,t]),L=k?P.get(k)??null:null;function W(I){if(!L)return{allowed:!1};const H=s(L);return(l==null?void 0:l({item:L,fromColumnId:H,toColumnId:I}))??{allowed:!0}}function B(){C(null),T(null)}function $(I,H,J){if(b)return;const ne=(u==null?void 0:u(H))??null;!c&&!ne||(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",J),ne&&I.dataTransfer.setData("application/json",JSON.stringify(ne)),c&&C(J))}function K(I,H,J){b||!c||!L||!W(H).allowed||(I.preventDefault(),I.dataTransfer.dropEffect="move",T(_=>(_==null?void 0:_.columnId)===H&&_.index===J?_:{columnId:H,index:J}))}async function re(I,H,J){var z;if(I.preventDefault(),b||!c||!L){B();return}const ne=s(L),G=(((z=D.find(ee=>ee.column.id===ne))==null?void 0:z.items)??[]).findIndex(ee=>n(ee)===n(L));if(!W(H).allowed||G<0){B();return}if(ne===H&&(J===G||J===G+1)){B();return}try{await c({item:L,fromColumnId:ne,toColumnId:H,fromIndex:G,toIndex:J})}finally{B()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[w.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),w.map(I=>r.jsxs("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${I.title}" column`,children:[I.title," ×"]},I.id))]}):null,r.jsx("div",{className:ke("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(200px,240px)]":"auto-cols-[minmax(260px,320px)]"),children:D.map(({column:I,items:H})=>{const J=W(I.id),ne=(N==null?void 0:N.columnId)===I.id;return r.jsxs("section",{className:ke("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",L&&!J.allowed?"border-dashed opacity-65":"",L&&J.allowed?"border-primary/30 bg-accent/30":"",ne?"ring-2 ring-ring/30":""),title:L&&!J.allowed?J.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:ke("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:I.title}),I.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:I.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:H.length}),g?r.jsx("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${I.title}" column`,"aria-label":`Hide column ${I.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:_=>K(_,I.id,H.length),onDrop:_=>re(_,I.id,H.length),children:[H.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(I):m}):r.jsx(W$,{active:(N==null?void 0:N.columnId)===I.id&&N.index===0,disabled:!!L&&!J.allowed,children:typeof m=="function"?m(I):m}):null,H.map((_,G)=>{const A=n(_),z=k===A;return r.jsxs(f.Fragment,{children:[r.jsx("div",{className:ke("h-2 rounded-full transition",(N==null?void 0:N.columnId)===I.id&&N.index===G?"bg-primary/70":"bg-transparent"),onDragOver:ee=>K(ee,I.id,G),onDrop:ee=>re(ee,I.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:ee=>{O.current=ee.target},onDragStart:ee=>{const M=O.current;if(M!=null&&M.closest(mi)){ee.preventDefault();return}$(ee,_,A)},onDragEnd:B,onContextMenu:ee=>{if(!p)return;const M=ee.target;M!=null&&M.closest(mi)||p(_,ee)},className:ke("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",z?"scale-[0.98] opacity-50":""),children:a(_,{dragging:z})})]},A)}),H.length>0&&!b?r.jsx("div",{className:ke("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(N==null?void 0:N.columnId)===I.id&&N.index===H.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",L&&!J.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},I.id)})})]})}function W$({active:e,disabled:t,children:n}){return r.jsx("div",{className:ke("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const El="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Pm="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",K$="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",q$="border-status-review-foreground/30 bg-status-review text-status-review-foreground",G$="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",Y$="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",J$="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",md={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:El,icon:bi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:El,icon:iP},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:El,icon:m0},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Pm,icon:NP},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Pm,icon:sg},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:K$,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:q$,icon:TP},completed:{label:"Completed",description:"Finished successfully.",className:G$,icon:eg},failed:{label:"Failed",description:"Could not be completed as planned.",className:Y$,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Pm,icon:ch},stopped:{label:"Stopped",description:"Session ended without completing.",className:El,icon:oP},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:J$,icon:ch}};function hd(e){const t=md[e];return t||{className:El,icon:ch,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function G1(e,t){return ke("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",hd(e).className,t)}function mn({status:e,className:t,showIcon:n=!0,progress:s}){const a=hd(e),l=a.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,p=c?`${a.description} (${s.checked}/${s.total} criteria)`:a.description,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(l,{className:"h-2.5 w-2.5"})]}):r.jsx(l,{className:"h-3.5 w-3.5"}):null;return r.jsxs("span",{title:p,className:G1(e,t),children:[m,r.jsx("span",{children:a.label})]})}function Zd(e){var t;return((t=md[e])==null?void 0:t.description)??`Status: ${e}`}const Y1={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Yu=null,za=null;function X$(){return Yu?Promise.resolve(Yu):za||(za=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Yu=e,za=null,e)).catch(()=>(za=null,Y1)),za)}function ef(){const[e,t]=f.useState(()=>Yu??Y1);return f.useEffect(()=>{X$().then(t)},[]),e}function ii(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Q$(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ea({type:e,className:t,compact:n=!1}){const s=ef();if(!e)return null;const a=Q$(s,e),l=(a==null?void 0:a.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=a!=null&&a.color?{backgroundColor:`color-mix(in oklch, ${a.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${a.color} 50%, transparent)`,color:a.color}:void 0;return r.jsx("span",{title:(a==null?void 0:a.description)??`Type: ${l}`,style:c,className:ke("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:l})}function $r({value:e,label:t,disabled:n=!1,disabledReason:s,onError:a}){const[l,c]=f.useState(!1);async function u(){if(!n)try{if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch(p){a==null||a(p instanceof Error?p:new Error(String(p)))}}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:l?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:l?r.jsx(Qr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})})}function Z$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function eL({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:a,compact:l=!1}){const c=Zo(),[u,p]=f.useState(()=>new Set(a.collapsed));f.useEffect(()=>{p(new Set(a.collapsed))},[a]);const m=h=>{p(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:ke("space-y-2",l?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=uc(e.filter(E=>E.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=cc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:ke("flex w-full items-center gap-2 text-left",l?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(br,{className:ke("text-muted-foreground transition-transform",l?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:ke("rounded-full border border-border/60 text-muted-foreground",l?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:ke("divide-y divide-border/40 border-t border-border/40",l?"text-xs":"text-sm"),children:g.map(E=>{const j=Z$(E);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:ke("flex items-center gap-3 hover:bg-muted/40",l?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:E.title}),E.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:E.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:$n(E.updated)})]})},`${E.projectSlug??"standalone"}:${E.id}`)})})]},h)})})}function tL(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function nL({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:a=!1}){const l=new Set(s.hidden);l.delete("title");const c=h=>!l.has(h),u=uc(e,t,n),p=a?"py-2 pr-3":"py-3 pr-4",m=a?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:ke("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:ke("font-medium",p),children:"Assignment"}):null,c("status")?r.jsx("th",{className:ke("font-medium",p),children:"Status"}):null,c("priority")?r.jsx("th",{className:ke("font-medium",p),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:ke("font-medium",p),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:ke("font-medium",p),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:ke("font-medium",p),children:"Created"}):null,c("updated")?r.jsx("th",{className:ke("font-medium",p),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=tL(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:p,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:p,children:r.jsx(mn,{status:h.status})}):null,c("priority")?r.jsx("td",{className:ke("capitalize text-muted-foreground",p),children:h.priority}):null,c("assignee")?r.jsx("td",{className:ke("text-muted-foreground",p),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:ke("text-muted-foreground",p),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:ke("text-muted-foreground",p),children:$n(h.created)}):null,c("updated")?r.jsx("td",{className:ke("text-muted-foreground",p),children:$n(h.updated)}):null]},y)})})]})})}function rL(e,t,n){return e.filter(s=>qg(s,t,{workspace:n,search:t.search}))}function J1({view:e,compact:t,emptyDescription:n}){const{data:s,loading:a,error:l}=Md(),c=Zo(),u=f.useMemo(()=>c.order.map(m=>({id:m,title:cc(c,m),description:Zd(m)})),[c]),p=f.useMemo(()=>{if(!s)return[];const m=rL(s.assignments,e.config.filters,e.workspace);return uc(m,e.config.sortField,e.config.sortDirection)},[s,e]);if(a&&!s)return r.jsx(ht,{label:"Loading assignments…"});if(l)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l})]});if(p.length===0)return r.jsx(Nt,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(Qd,{compact:t,dragDisabled:!0,columns:u,items:p,getItemId:m=>m.slug||m.id,getColumnId:m=>m.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:m=>t?r.jsx(sL,{item:m}):r.jsx(oL,{item:m})});case"list":return r.jsx(eL,{items:p,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(nL,{items:p,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function sL({item:e}){const t=Kl(e);return r.jsxs("div",{className:ke("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(mn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:$n(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx($r,{value:e.id})]}):null]})}function oL({item:e}){const t=Kl(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(mn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ea,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:$n(e.updated)})]})]})}function aL({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:a,refetch:l}=Go(e);return s?r.jsx(ht,{label:"Loading view…"}):a?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.message}),r.jsx("button",{type:"button",onClick:()=>l(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(J1,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function iL({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:Ho.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:Ho.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(lL,{session:t})},t.sessionId))})]})}function lL({session:e}){const t=ln(),[n,s]=f.useState(!1),a=cL(e,t),l=uL(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:a,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[l," · ",P0(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ho.recentSessionsCopyFallbackHint})]}):null]}),r.jsx($r,{value:e.path,label:Ho.recentSessionsCopyPathLabel,disabled:c,disabledReason:Ho.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function cL(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function uL(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}function dL(){const{data:e,loading:t,error:n}=K0();return t&&!e?r.jsx(ht,{label:"Loading sessions…"}):n?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]}):r.jsx(iL,{sessions:(e==null?void 0:e.sessions)??[]})}const fL=5;function pL(){const{data:e,loading:t,error:n}=W0();if(t&&!e)return r.jsx(ht,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const a=((e==null?void 0:e.inventories)??[]).slice(0,fL);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),a.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:a.map(l=>{const c=l.inventory,u=l.active_leases.length,p=l.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",p," leased"]})]})},c.slug)})})]})}const X1={"saved-view":{title:"Saved view",icon:x0,render:(e,t)=>e.kind!=="saved-view"?null:f.createElement(aL,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Ad,render:()=>f.createElement(dL)},inventories:{title:"Inventories",icon:Ld,render:()=>f.createElement(pL)}},mL={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},hL={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function gL({slot:e,onReplace:t,onRemove:n,onResize:s}){const a=e.size??"small",l=mL[a];if(e.widget===null)return r.jsx("div",{className:ke("flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",l),children:r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add widget"]})});const c=X1[e.widget.kind];if(!c)return r.jsx("div",{className:ke("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})});const u=c.icon;return r.jsxs("div",{className:ke("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(xL,{slot:e,fallback:c.title})})]}),r.jsx(Kg,{items:[{key:"replace",label:"Replace…",icon:CP,onSelect:t},{key:"size",label:"Size",icon:jP,submenu:HD.map(p=>({key:`size-${p}`,label:hL[p],active:p===a,onSelect:()=>s(p)}))},{key:"remove",label:"Remove",icon:ar,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:c.render(e.widget,{slotId:e.id,onPickAnother:t})})]})}function xL({slot:e,fallback:t}){var a,l;const n=((a=e.widget)==null?void 0:a.kind)==="saved-view"?e.widget.viewId:null,{view:s}=Go(n);return((l=e.widget)==null?void 0:l.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const yL=["agent-sessions","inventories"];function bL({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:a}=Vd();function l(c){n(c),t(!1)}return r.jsx(Gn,{open:e,onOpenChange:t,children:r.jsxs(zn,{className:"max-w-xl",children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Add a widget"}),r.jsx(es,{children:"Choose a built-in widget or one of your saved views."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:yL.map(c=>{const u=X1[c],p=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(p,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),a?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsx("ul",{className:"max-h-72 divide-y divide-border/40 overflow-auto rounded-md border border-border/60",children:s.map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))}),!a&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}function vL(){const{data:e,error:t,refetch:n}=SR(),{data:s}=U0(),{layout:a}=YD(),[l,c]=f.useState(!1),[u,p]=f.useState(null),[m,h]=f.useState(null);mo("list:overview"),Ht({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const g=f.useCallback(k=>{p(k),c(!0)},[]),y=f.useCallback(async k=>{h(null);try{await XD(k)}catch(C){h(C instanceof Error?C.message:String(C))}},[]),b=f.useCallback(k=>{if(u===null)return;const C=a.slots.map((N,T)=>T===u?{...N,widget:k}:N);p(null),y(C)},[a.slots,u,y]),E=f.useCallback(k=>{const C=a.slots.map((N,T)=>T===k?{...N,widget:null}:N);y(C)},[a.slots,y]),j=f.useCallback((k,C)=>{const N=a.slots.map((T,O)=>O===k?{...T,size:C}:T);y(N)},[a.slots,y]),w={};if(e)for(const k of Object.keys(e.segments))for(const C of e.segments[k].items)w[C.id]=C;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(OD,{hero:e.hero,itemsById:w}):t?r.jsx(jt,{error:t}):r.jsx(ht,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx($D,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:a.slots.map((k,C)=>r.jsx(gL,{slot:k,index:C,onReplace:()=>g(C),onRemove:()=>E(C),onResize:N=>j(C,N)},k.id))}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(og,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(bL,{open:l,onOpenChange:k=>{c(k),k||p(null)},onSelect:b})]})}function wL({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function jL(){const{data:e,loading:t,error:n}=U0(),{openCheatsheet:s}=po();return t?r.jsx(ht,{label:"Loading help…"}):n||!e?r.jsx(jt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",fs("Mod+k")," opens the command palette."]})]})}),r.jsx(We,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(a=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:a},a))})}),r.jsx(We,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,description:a.command.description,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(We,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(a=>r.jsx(wL,{term:a.term,description:a.description},a.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.term))})]}),r.jsx(We,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(mn,{status:a.status}),r.jsx("p",{className:"font-semibold text-foreground",children:a.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:a.useWhen})]},a.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.files.map(l=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:l},l))})]},a.label))})}),r.jsx(We,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.label))})})]}),r.jsx(We,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(a=>r.jsx(qu,{command:a.command,description:a.description,example:a.example},a.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.answer})]},a.question))})}),r.jsx(We,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})})]})]})}function Gg({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const tf=f.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(fo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:a=>t(a.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));tf.displayName="SearchInput";function nf({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:ke("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const kL={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},sw=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function gd({progress:e,className:t,showLegend:n=!1}){const s=Zo(),a=f.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:kL[p]??sw[c++%sw.length]}))},[s.order,e]),l=a.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:ke("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):l.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${bn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:a.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:ke("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:bn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const SL=["pending","active","blocked","failed","completed"],Yg=SL,NL=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function Q1(e){return e&&e.length>0?e:[...NL]}function CL(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[a]=s.splice(t,1),l=t<n?n-1:n;return s.splice(Math.max(0,Math.min(l,s.length)),0,a),s}const EL=220,Au=8;function Z1({anchor:e,items:t,onClose:n}){const s=f.useRef(null),[a,l]=f.useState(null);return f.useLayoutEffect(()=>{if(!e){l(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??EL,p=(c==null?void 0:c.offsetHeight)??0,m=Math.max(Au,window.innerWidth-u-Au),h=Math.max(Au,window.innerHeight-p-Au);l({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),f.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function p(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",p,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",p,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(a==null?void 0:a.left)??e.x,top:(a==null?void 0:a.top)??e.y,visibility:a?"visible":"hidden"},children:r.jsx(Wo,{delayDuration:200,children:t.map(c=>{const u=c.icon,p=ke("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:p,children:m})});return c.disabledReason?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:h}),r.jsx(gr,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:p,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:p,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const TL="__ungrouped__";function Jg({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:a="Move to workspace",description:l="Pick the workspace this item should belong to."}){const{data:c,loading:u}=oc(),[p,m]=f.useState(n),[h,g]=f.useState(!1),[y,b]=f.useState(null);f.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const E=f.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(C=>({key:C,label:C,value:C})),{key:TL,label:"Ungrouped",value:null}],[c]),j=!h&&p!==n;async function w(){if(j){g(!0),b(null);try{await s(p),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(Gn,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(zn,{children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:a}),r.jsx(es,{children:l})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&E.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(sg,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):E.map(k=>{const C=k.value===n,N=k.value===p;return r.jsxs("button",{type:"button",disabled:C||h,onClick:()=>m(k.value),className:ke("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",C?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:ke("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,C?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?r.jsx(Qr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:w,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function ow(){const{workspace:e}=$t(),t=ln(),n=Dt(),{data:s,loading:a,error:l,refetch:c}=Jo(),u=f.useRef(null);mo("list:projects");const[p,m]=f.useState(""),[h,g]=f.useState("all"),[y,b]=f.useState("all"),[E,j]=f.useState("updated"),[w,k]=gs(),C=w.get("view"),N=C==="table"||C==="kanban"?C:"cards",T=_=>{k(G=>{const A=new URLSearchParams(G);return _==="cards"?A.delete("view"):A.set("view",_),A})},[O,P]=f.useState({}),[D,L]=f.useState(null),[W,B]=f.useState(null),$=f.useMemo(()=>s?s.filter(_=>{if(e){if(e==="_ungrouped"){if(_.workspace!==null)return!1}else if(_.workspace!==e)return!1}return h!=="all"&&_.status!==h||y!=="all"&&!_.tags.includes(y)?!1:p.trim()?`${_.title} ${_.tags.join(" ")} ${_.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((_,G)=>AL(_,G,E)):[],[s,p,h,y,E,e]),K=$.map(_=>`${_.slug}:${_.status}`).join("|");f.useEffect(()=>{P(DL($))},[K,E]);const re=f.useMemo(()=>{const _=new Map($.map(G=>[G.slug,G]));return Yg.flatMap(G=>(O[G]??$.filter(z=>z.status===G).map(z=>z.slug)).map(z=>_.get(z)).filter(z=>!!z))},[$,O]),{visibleItems:I,visibleIndexByKey:H}=f.useMemo(()=>{const _=N==="kanban"?re:$,G=new Map;return _.forEach((A,z)=>G.set(A.slug,z)),{visibleItems:_,visibleIndexByKey:G}},[N,$,re]),{hotkeyRowProps:J}=ac(I,{scope:"list:projects",onOpen:_=>n(`${t}/projects/${_.slug}`)});if(Ht({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var _;return(_=u.current)==null?void 0:_.focus()}}),Ht({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),a)return r.jsx(ht,{label:"Loading projects…"});if(l||!s)return r.jsx(jt,{error:l||"Project list is unavailable."});const ne=Array.from(new Set(s.flatMap(_=>_.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(Gg,{children:[r.jsx(tf,{ref:u,value:p,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:_=>g(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:_=>b(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),ne.map(_=>r.jsx("option",{value:_,children:_},_))]}),r.jsxs("select",{value:E,onChange:_=>j(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(nf,{value:N,onChange:_=>T(_),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),$.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(Nt,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):N==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:$.map((_,G)=>r.jsxs(Ee,{to:`${t}/projects/${_.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...J(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:_.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",$n(_.updated)]})]}),r.jsx(mn,{status:_.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(gd,{progress:_.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:_.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:A},A))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:_.needsAttention.blockedCount+_.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:_.progress.total})]})]})]})]},_.slug))}):N==="table"?r.jsx(We,{title:`${$.length} project${$.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:$.map((_,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...J(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${_.slug}`,className:"font-semibold text-foreground hover:text-primary",children:_.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:_.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:A},A))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(mn,{status:_.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(gd,{progress:_.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:_.needsAttention.blockedCount+_.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:$n(_.updated)})]},_.slug))})]})})}):r.jsx(Qd,{columns:RL,items:re,getItemId:_=>_.slug,getColumnId:_=>_.status,canDrop:({fromColumnId:_,toColumnId:G})=>({allowed:!0,reason:_===G?void 0:"This will set a manual status override on the project."}),onMove:({item:_,fromColumnId:G,toColumnId:A,fromIndex:z,toIndex:ee})=>{if(G===A){const M=O[G]??$.filter(ue=>ue.status===G).map(ue=>ue.slug);P(ue=>({...ue,[G]:CL(M,z,ee)}));return}fetch(`/api/projects/${_.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})}).then(()=>{window.location.reload()})},getExternalDragData:_=>({type:"project",id:_.slug}),onCardContextMenu:(_,G)=>{G.preventDefault(),L({project:_,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:_=>`No ${_.title.toLowerCase()} projects.`,renderCard:(_,{dragging:G})=>{const A=H.get(_.slug)??-1;return r.jsx("div",{...A>=0?J(A):{},children:r.jsx($L,{project:_,dragging:G})})}}),r.jsx(Z1,{anchor:(D==null?void 0:D.anchor)??null,items:D?[{key:"edit",label:"Edit",icon:bi,onSelect:()=>n(`${t}/projects/${D.project.slug}`)},{key:"move",label:"Move to workspace…",icon:$d,onSelect:()=>B(D.project)}]:[],onClose:()=>L(null)}),r.jsx(Jg,{open:W!==null,onOpenChange:_=>{_||B(null)},currentWorkspace:(W==null?void 0:W.workspace)??null,title:"Move project to workspace",onSubmit:async _=>{if(!W)return;const G=await fetch(`/api/projects/${encodeURIComponent(W.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:_})});if(!G.ok){const A=await G.json().catch(()=>({}));throw new Error(A.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(rg,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",N==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const PL={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},RL=Yg.map(e=>({id:e,title:PL[e],description:Zd(e)}));function AL(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return aw(t)-aw(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function aw(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function DL(e){return Object.fromEntries(Yg.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function $L({project:e,dragging:t}){const n=ln();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",$n(e.updated)]})]}),r.jsx(mn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(gd,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function xd({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:ke("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}const LL=4e3;function ta(){const[e,t]=f.useState(null),n=f.useRef(null),s=f.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),a=f.useCallback((l,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:l,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},LL)},[]);return f.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:a,dismissToast:s}}function na({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:ke("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function OL(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(Dd,{className:"h-3 w-3"}),"Archived"]})}function iw(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function IL(){const{data:e,loading:t,error:n,refetch:s}=NR(),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState({}),{toast:h,showToast:g,dismissToast:y}=ta();async function b(N,T,O){l(T),u(null);try{const P=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!P.ok){const D=await P.json().catch(()=>null);throw new Error((D==null?void 0:D.error)||`HTTP ${P.status}`)}s(),g(O,"success")}catch(P){u(P instanceof Error?P.message:"Restore failed")}finally{l(null)}}function E(N){return b(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function j(N){const T=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return b(T,`assignment:${N.id}`,"Assignment restored")}if(t)return r.jsx(ht,{label:"Loading archived content…"});if(n)return r.jsx(jt,{error:n});const w=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],C=w.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:h,onDismiss:y}),r.jsx(xd,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,C?r.jsx(Nt,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[w.length>0&&r.jsx(We,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:w.map(N=>{const T=p[N.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(O=>({...O,[N.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(br,{className:"h-4 w-4"}):r.jsx(f0,{className:"h-4 w-4"}),r.jsx(tg,{className:"h-4 w-4 text-muted-foreground"}),N.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${N.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>E(N),disabled:a===`project:${N.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&N.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(O=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:iw(O),className:"text-foreground hover:text-foreground/80",children:O.title}),r.jsx(mn,{status:O.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},O.id))})]},N.slug)})})}),k.length>0&&r.jsx(We,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(N=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:iw(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),r.jsx(mn,{status:N.status,showIcon:!1}),r.jsx(OL,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(N),disabled:a===`assignment:${N.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const lw="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",cw="block min-w-0 truncate";function Xg({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:ke("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const a=`${n.system}:${n.id}`,l=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:ke(lw,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${a} in ${n.system}`,children:[r.jsx("span",{className:cw,children:a}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},l):r.jsx("span",{className:lw,title:a,children:r.jsx("span",{className:cw,children:a})},l)})})}const ML={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function Dn({label:e,value:t,description:n,icon:s,tone:a="default",to:l}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=ke(ML[a],l?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return l?r.jsx(Ee,{to:l,className:u,children:c}):r.jsx("article",{className:u,children:c})}function uw(e){const t=_L(e),n=f.forwardRef((s,a)=>{const{children:l,...c}=s,u=f.Children.toArray(l),p=u.find(zL);if(p){const m=p.props.children,h=u.map(g=>g===p?f.Children.count(m)>1?f.Children.only(null):f.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:a,children:f.isValidElement(m)?f.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function _L(e){const t=f.forwardRef((n,s)=>{const{children:a,...l}=n;if(f.isValidElement(a)){const c=UL(a),u=BL(l,a.props);return a.type!==f.Fragment&&(u.ref=s?Fd(s,c):c),f.cloneElement(a,u)}return f.Children.count(a)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var FL=Symbol("radix.slottable");function zL(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===FL}function BL(e,t){const n={...t};for(const s in t){const a=e[s],l=t[s];/^on[A-Z]/.test(s)?a&&l?n[s]=(...u)=>{const p=l(...u);return a(...u),p}:a&&(n[s]=a):s==="style"?n[s]={...a,...l}:s==="className"&&(n[s]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function UL(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function VL(e){const t=e+"CollectionProvider",[n,s]=Xo(t),[a,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:w,children:k}=j,C=nn.useRef(null),N=nn.useRef(new Map).current;return r.jsx(a,{scope:w,itemMap:N,collectionRef:C,children:k})};c.displayName=t;const u=e+"CollectionSlot",p=uw(u),m=nn.forwardRef((j,w)=>{const{scope:k,children:C}=j,N=l(u,k),T=Fn(w,N.collectionRef);return r.jsx(p,{ref:T,children:C})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=uw(h),b=nn.forwardRef((j,w)=>{const{scope:k,children:C,...N}=j,T=nn.useRef(null),O=Fn(w,T),P=l(h,k);return nn.useEffect(()=>(P.itemMap.set(T,{ref:T,...N}),()=>void P.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:O,children:C})});b.displayName=h;function E(j){const w=l(e+"CollectionConsumer",j);return nn.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(w.itemMap.values()).sort((P,D)=>N.indexOf(P.ref.current)-N.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},E,s]}var HL=f.createContext(void 0);function eS(e){const t=f.useContext(HL);return e||t||"ltr"}var Rm="rovingFocusGroup.onEntryFocus",WL={bubbles:!1,cancelable:!0},dc="RovingFocusGroup",[Nh,tS,KL]=VL(dc),[qL,nS]=Xo(dc,[KL]),[GL,YL]=qL(dc),rS=f.forwardRef((e,t)=>r.jsx(Nh.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Nh.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(JL,{...e,ref:t})})}));rS.displayName=dc;var JL=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:p,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=f.useRef(null),b=Fn(t,y),E=eS(l),[j,w]=zd({prop:c,defaultProp:u??null,onChange:p,caller:dc}),[k,C]=f.useState(!1),N=Ko(m),T=tS(n),O=f.useRef(!1),[P,D]=f.useState(0);return f.useEffect(()=>{const L=y.current;if(L)return L.addEventListener(Rm,N),()=>L.removeEventListener(Rm,N)},[N]),r.jsx(GL,{scope:n,orientation:s,dir:E,loop:a,currentTabStopId:j,onItemFocus:f.useCallback(L=>w(L),[w]),onItemShiftTab:f.useCallback(()=>C(!0),[]),onFocusableItemAdd:f.useCallback(()=>D(L=>L+1),[]),onFocusableItemRemove:f.useCallback(()=>D(L=>L-1),[]),children:r.jsx(hn.div,{tabIndex:k||P===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:qt(e.onMouseDown,()=>{O.current=!0}),onFocus:qt(e.onFocus,L=>{const W=!O.current;if(L.target===L.currentTarget&&W&&!k){const B=new CustomEvent(Rm,WL);if(L.currentTarget.dispatchEvent(B),!B.defaultPrevented){const $=T().filter(J=>J.focusable),K=$.find(J=>J.active),re=$.find(J=>J.id===j),H=[K,re,...$].filter(Boolean).map(J=>J.ref.current);aS(H,h)}}O.current=!1}),onBlur:qt(e.onBlur,()=>C(!1))})})}),sS="RovingFocusGroupItem",oS=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:l,children:c,...u}=e,p=ni(),m=l||p,h=YL(sS,n),g=h.currentTabStopId===m,y=tS(n),{onFocusableItemAdd:b,onFocusableItemRemove:E,currentTabStopId:j}=h;return f.useEffect(()=>{if(s)return b(),()=>E()},[s,b,E]),r.jsx(Nh.ItemSlot,{scope:n,id:m,focusable:s,active:a,children:r.jsx(hn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:qt(e.onMouseDown,w=>{s?h.onItemFocus(m):w.preventDefault()}),onFocus:qt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:qt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=ZL(w,h.orientation,h.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let N=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const T=N.indexOf(w.currentTarget);N=h.loop?eO(N,T+1):N.slice(T+1)}setTimeout(()=>aS(N))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});oS.displayName=sS;var XL={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function QL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ZL(e,t,n){const s=QL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return XL[s]}function aS(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function eO(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var tO=rS,nO=oS,rf="Tabs",[rO]=Xo(rf,[nS]),iS=nS(),[sO,Qg]=rO(rf),lS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:l,orientation:c="horizontal",dir:u,activationMode:p="automatic",...m}=e,h=eS(u),[g,y]=zd({prop:s,onChange:a,defaultProp:l??"",caller:rf});return r.jsx(sO,{scope:n,baseId:ni(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:p,children:r.jsx(hn.div,{dir:h,"data-orientation":c,...m,ref:t})})});lS.displayName=rf;var cS="TabsList",uS=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,l=Qg(cS,n),c=iS(n);return r.jsx(tO,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:r.jsx(hn.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:t})})});uS.displayName=cS;var dS="TabsTrigger",fS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...l}=e,c=Qg(dS,n),u=iS(n),p=hS(c.baseId,s),m=gS(c.baseId,s),h=s===c.value;return r.jsx(nO,{asChild:!0,...u,focusable:!a,active:h,children:r.jsx(hn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:p,...l,ref:t,onMouseDown:qt(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:qt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:qt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!a&&g&&c.onValueChange(s)})})})});fS.displayName=dS;var pS="TabsContent",mS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:l,...c}=e,u=Qg(pS,n),p=hS(u.baseId,s),m=gS(u.baseId,s),h=s===u.value,g=f.useRef(h);return f.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(Qo,{present:a||h,children:({present:y})=>r.jsx(hn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":p,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&l})})});mS.displayName=pS;function hS(e,t){return`${e}-trigger-${t}`}function gS(e,t){return`${e}-content-${t}`}var xS=lS,yS=uS,Ch=fS,Eh=mS;function Zg({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(xS,{value:e,onValueChange:t,className:s,children:[r.jsx(yS,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(a=>r.jsxs(Ch,{value:a.value,className:ke("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:a.label}),typeof a.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:a.count}):null]},a.value))}),n.map(a=>r.jsx(Eh,{value:a.value,className:"pt-3",children:a.content},a.value))]})}const oO="modulepreload",aO=function(e){return"/"+e},dw={},iO=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),p=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(m=>{if(m=aO(m),m in dw)return;dw[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":oO,h||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),h)return new Promise((b,E)=>{y.addEventListener("load",b),y.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})};function lO({definition:e,className:t,nodeRoutes:n={}}){const s=f.useRef(null),[a,l]=f.useState(null),[c,u]=f.useState(!0),p=Dt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return f.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await iO(async()=>{const{default:j}=await import("./mermaid.core-BWdLQDB3.js").then(w=>w.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:cO(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:E}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=E,uO(s.current,n,p),u(!1)}catch(y){h||(l(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),l(null),g(),()=>{h=!0}},[e,p,n,m]),a?r.jsxs("div",{className:ke("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",a]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:ke("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function cO(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),a=n("--card-foreground"),l=n("--border"),c=n("--primary"),u=n("--primary-foreground"),p=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:a,primaryBorderColor:l,secondaryColor:p,secondaryTextColor:a,secondaryBorderColor:l,tertiaryColor:p,tertiaryTextColor:m,tertiaryBorderColor:l,lineColor:e?m:l,textColor:a,mainBkg:s,nodeBkg:s,nodeTextColor:a,nodeBorder:l,clusterBkg:p,clusterBorder:l,edgeLabelBackground:s,titleColor:a,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:p,labelColor:a,errorBkgColor:h,errorTextColor:u}}function uO(e,t,n){var s;for(const a of e.querySelectorAll(".node")){const l=((s=a.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[l];if(!c)continue;a.style.cursor="pointer",a.setAttribute("role","link"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",`Open ${l}`);const u=()=>n(c);a.addEventListener("click",u),a.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),u())})}}function dO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mO={};function fw(e,t){return(mO.jsx?pO:fO).test(e)}const hO=/[ \t\n\f\r]/g;function gO(e){return typeof e=="object"?e.type==="text"?pw(e.value):!1:pw(e)}function pw(e){return e.replace(hO,"")===""}class fc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}fc.prototype.normal={};fc.prototype.property={};fc.prototype.space=void 0;function bS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new fc(n,s,t)}function Th(e){return e.toLowerCase()}class ir{constructor(t,n){this.attribute=n,this.property=t}}ir.prototype.attribute="";ir.prototype.booleanish=!1;ir.prototype.boolean=!1;ir.prototype.commaOrSpaceSeparated=!1;ir.prototype.commaSeparated=!1;ir.prototype.defined=!1;ir.prototype.mustUseProperty=!1;ir.prototype.number=!1;ir.prototype.overloadedBoolean=!1;ir.prototype.property="";ir.prototype.spaceSeparated=!1;ir.prototype.space=void 0;let xO=0;const ft=ra(),fn=ra(),Ph=ra(),Te=ra(),It=ra(),li=ra(),pr=ra();function ra(){return 2**++xO}const Rh=Object.freeze(Object.defineProperty({__proto__:null,boolean:ft,booleanish:fn,commaOrSpaceSeparated:pr,commaSeparated:li,number:Te,overloadedBoolean:Ph,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),Am=Object.keys(Rh);class ex extends ir{constructor(t,n,s,a){let l=-1;if(super(t,n),mw(this,"space",a),typeof s=="number")for(;++l<Am.length;){const c=Am[l];mw(this,Am[l],(s&Rh[c])===Rh[c])}}}ex.prototype.defined=!0;function mw(e,t,n){n&&(e[t]=n)}function ki(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new ex(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Th(s)]=s,n[Th(l.attribute)]=s}return new fc(t,n,e.space)}const vS=ki({properties:{ariaActiveDescendant:null,ariaAtomic:fn,ariaAutoComplete:null,ariaBusy:fn,ariaChecked:fn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:fn,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:fn,ariaFlowTo:It,ariaGrabbed:fn,ariaHasPopup:null,ariaHidden:fn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:Te,ariaLive:null,ariaModal:fn,ariaMultiLine:fn,ariaMultiSelectable:fn,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:fn,ariaReadOnly:fn,ariaRelevant:null,ariaRequired:fn,ariaRoleDescription:It,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:fn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function wS(e,t){return t in e?e[t]:t}function jS(e,t){return wS(e,t.toLowerCase())}const yO=ki({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:li,acceptCharset:It,accessKey:It,action:null,allow:null,allowFullScreen:ft,allowPaymentRequest:ft,allowUserMedia:ft,alt:null,as:null,async:ft,autoCapitalize:null,autoComplete:It,autoFocus:ft,autoPlay:ft,blocking:It,capture:null,charSet:null,checked:ft,cite:null,className:It,cols:Te,colSpan:null,content:null,contentEditable:fn,controls:ft,controlsList:It,coords:Te|li,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ft,defer:ft,dir:null,dirName:null,disabled:ft,download:Ph,draggable:fn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ft,formTarget:null,headers:It,height:Te,hidden:Ph,high:Te,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:ft,inputMode:null,integrity:null,is:null,isMap:ft,itemId:null,itemProp:It,itemRef:It,itemScope:ft,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ft,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:ft,muted:ft,name:null,nonce:null,noModule:ft,noValidate:ft,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ft,optimum:Te,pattern:null,ping:It,placeholder:null,playsInline:ft,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ft,referrerPolicy:null,rel:It,required:ft,reversed:ft,rows:Te,rowSpan:Te,sandbox:It,scope:null,scoped:ft,seamless:ft,selected:ft,shadowRootClonable:ft,shadowRootDelegatesFocus:ft,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:fn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:ft,useMap:null,value:fn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ft,declare:ft,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:ft,noHref:ft,noShade:ft,noWrap:ft,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:fn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ft,disableRemotePlayback:ft,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:jS}),bO=ki({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pr,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:It,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:ft,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:li,g2:li,glyphName:li,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:pr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:pr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pr,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:wS}),kS=ki({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),SS=ki({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:jS}),NS=ki({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),vO={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wO=/[A-Z]/g,hw=/-[a-z]/g,jO=/^data[-\w.:]+$/i;function kO(e,t){const n=Th(t);let s=t,a=ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jO.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(hw,NO);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!hw.test(l)){let c=l.replace(wO,SO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=ex}return new a(s,t)}function SO(e){return"-"+e.toLowerCase()}function NO(e){return e.charAt(1).toUpperCase()}const CO=bS([vS,yO,kS,SS,NS],"html"),tx=bS([vS,bO,kS,SS,NS],"svg");function EO(e){return e.join(" ").trim()}var Ba={},Dm,gw;function TO(){if(gw)return Dm;gw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,p=`
|
|
530
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return f.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},ND=Uk,CD=Vk,Zk=Hk,e1=Wk,t1=Jk,n1=Qk,r1=qk,s1=Yk;const Ga=ND,ED=CD,o1=f.forwardRef(({className:e,...t},n)=>r.jsx(Zk,{ref:n,className:ke("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));o1.displayName=Zk.displayName;const Bo=f.forwardRef(({className:e,...t},n)=>r.jsxs(ED,{children:[r.jsx(o1,{}),r.jsx(e1,{ref:n,className:ke("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));Bo.displayName=e1.displayName;function Ya({className:e,...t}){return r.jsx("div",{className:ke("flex flex-col space-y-2 text-left",e),...t})}function Ja({className:e,...t}){return r.jsx("div",{className:ke("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Uo=f.forwardRef(({className:e,...t},n)=>r.jsx(r1,{ref:n,className:ke("text-lg font-semibold tracking-tight text-foreground",e),...t}));Uo.displayName=r1.displayName;const Vo=f.forwardRef(({className:e,...t},n)=>r.jsx(s1,{ref:n,className:ke("text-sm leading-6 text-muted-foreground",e),...t}));Vo.displayName=s1.displayName;const oo=f.forwardRef(({className:e,...t},n)=>r.jsx(t1,{ref:n,className:ke(e),...t}));oo.displayName=t1.displayName;const Ul=f.forwardRef(({className:e,...t},n)=>r.jsx(n1,{ref:n,className:ke(e),...t}));Ul.displayName=n1.displayName;const TD=[{to:"/",label:"Overview",icon:m0},{to:"/playbooks",label:"Playbooks",icon:d0},{to:"/memories",label:"Memories",icon:rP},{to:"/resources",label:"Resources",icon:yP},{to:"/inventories",label:"Inventories",icon:Ld},{to:"/usage",label:"Usage",icon:Od},{to:"/todos",label:"Todos",icon:Dr},{to:"/views",label:"Saved Views",icon:x0},{to:"/archive",label:"Archive",icon:Dd}],PD=[{suffix:"/projects",label:"Projects",icon:tg},{suffix:"/assignments",label:"Assignments",icon:wP},{suffix:"/servers",label:"Servers",icon:og},{suffix:"/inventories",label:"Inventories",icon:Ld},{suffix:"/usage",label:"Usage",icon:Od},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Ad},{suffix:"/todos",label:"Todos",icon:Dr}],RD=[{to:"/help",label:"Help",icon:bP},{to:"/settings",label:"Settings",icon:AP}];function AD({title:e,breadcrumbs:t,projectSlug:n,workspace:s,children:a}){const[l,c]=f.useState(!1);return Ht({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:l,handler:()=>c(!1)}),r.jsx("div",{className:"min-h-screen bg-background",children:r.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[r.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:r.jsx(Bv,{activeWorkspace:s})}),l?r.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:r.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx(Ee,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),r.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:r.jsx(lg,{className:"h-4 w-4"})})]}),r.jsx(Bv,{activeWorkspace:s,onNavigate:()=>c(!1)})]})}):null,r.jsxs("div",{className:"min-w-0",children:[r.jsx(sD,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),r.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:a})]})]})})}function Bv({activeWorkspace:e,onNavigate:t}){const{data:n}=oc(),s=(n==null?void 0:n.workspaces)??[],a=(n==null?void 0:n.hasUngrouped)??!1,{hidden:l}=zk(),c=qn(),[u,p]=f.useState(new Set),[m,h]=f.useState(!1),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null),[N,T]=f.useState(!1),O=Dt();function P(B){p($=>{const K=new Set($);return K.has(B)?K.delete(B):K.add(B),K})}const D=iD([...s,...a?[ld]:[]],l);async function L(B){if(j){T(!0);try{const $=`/api/workspaces/${encodeURIComponent(j)}${B?"?cascade=true":""}`,K=await fetch($,{method:"DELETE"});if(K.status===409){const re=await K.json().catch(()=>({}));C((re==null?void 0:re.blockedBy)??{projects:[],standalones:[]});return}if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to delete workspace")}w(null),C(null)}catch($){console.error($),alert($ instanceof Error?$.message:"Failed to delete workspace")}finally{T(!1)}}}async function W(B,$){try{if(B.type==="project"){const K=await fetch(`/api/projects/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:$})});if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to move project")}return}if(B.type==="standalone-assignment"){const K=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:$})});if(!K.ok){const re=await K.json().catch(()=>({}));throw new Error(re.error||"Failed to move assignment")}return}if(B.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(K){console.error(K),alert(K instanceof Error?K.message:"Failed to move item")}}return r.jsxs("div",{className:"flex h-full flex-col gap-3",children:[r.jsx("div",{className:"space-y-3",children:r.jsxs(Ee,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[r.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:r.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),r.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),r.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),r.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),r.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),r.jsx(wv,{items:TD,onNavigate:t}),r.jsx("div",{className:"border-t border-border/40"}),r.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[D.length===0&&!m&&r.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),D.map(B=>{const $=B==="_ungrouped",K=$?"Ungrouped":bn(B),re=$?"/w/_ungrouped":`/w/${B}`,I=u.has(B),H=e===B||e===null&&$&&c.pathname.startsWith("/w/_ungrouped"),J=b===B;return r.jsxs("div",{className:`rounded-md transition ${J?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:ne=>{ne.dataTransfer.types.includes("application/json")&&(ne.preventDefault(),ne.dataTransfer.dropEffect="move",E(B))},onDragLeave:ne=>{ne.currentTarget.contains(ne.relatedTarget)||E(_=>_===B?null:_)},onDrop:async ne=>{try{const _=ne.dataTransfer.getData("application/json");if(!_)return;ne.preventDefault();let G;try{G=JSON.parse(_)}catch{return}if(!(G!=null&&G.type)||!(G!=null&&G.id))return;await W(G,$?null:B)}finally{E(null)}},children:[r.jsxs("div",{className:"group flex items-center",children:[r.jsxs("button",{type:"button",onClick:()=>P(B),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${H?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[r.jsx(br,{className:`h-3 w-3 transition-transform ${I?"-rotate-90":""}`}),K]}),$?null:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w(B),C(null)},title:`Delete workspace "${B}"`,"aria-label":`Delete workspace "${B}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:r.jsx(ar,{className:"h-3 w-3"})})]}),!I&&r.jsx("nav",{className:"ml-2 space-y-0.5",children:PD.map(ne=>{const _=`${re}${ne.suffix}`,G=A0(c.pathname,ne.suffix)&&c.pathname.startsWith(re),A=ne.icon;return r.jsxs(Ee,{to:_,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${G?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[r.jsx(A,{className:"h-4 w-4"}),r.jsx("span",{children:ne.label})]},_)})})]},B)}),m?r.jsx("form",{className:"px-3 py-1.5",onSubmit:B=>{B.preventDefault();const $=g.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");$&&(h(!1),y(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})}).then(()=>{t==null||t(),O(`/w/${$}/projects`)}))},children:r.jsx("input",{autoFocus:!0,type:"text",value:g,onChange:B=>y(B.target.value),onKeyDown:B=>{B.key==="Escape"&&(h(!1),y(""))},onBlur:()=>{g.trim()||(h(!1),y(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[r.jsx(rn,{className:"h-3 w-3"}),"New Workspace"]})]}),r.jsx("div",{className:"border-t border-border/40"}),r.jsx(wv,{items:RD,onNavigate:t}),r.jsx(Ga,{open:j!==null,onOpenChange:B=>{N||B||(w(null),C(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:k?"Workspace has references":"Delete workspace?"}),r.jsx(Vo,{children:k?r.jsxs(r.Fragment,{children:["The workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," is still referenced by:"]}):r.jsxs(r.Fragment,{children:["Remove the workspace ",r.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:j})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),k?r.jsxs("div",{className:"space-y-2 text-sm",children:[k.projects.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",k.projects.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.projects.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/projects/${B}`,className:"hover:underline",children:B})},B))})]}):null,k.standalones.length>0?r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",k.standalones.length,")"]}),r.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:k.standalones.map(B=>r.jsx("li",{children:r.jsx(Ee,{to:`/assignments/${B}`,className:"hover:underline",children:B})},B))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',r.jsx("code",{children:"workspace:"})," / ",r.jsx("code",{children:"workspaceGroup:"})," to ",r.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:N,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),k?r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Clear references and delete"}):r.jsx(oo,{disabled:N,onClick:B=>{B.preventDefault(),L(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:N?"Working…":"Delete"})]})]})})]})}function DD(){const e=qn(),{workspace:t}=$t(),{title:n,breadcrumbs:s,projectSlug:a}=D0(e.pathname);return r.jsx(AD,{title:n,breadcrumbs:s,projectSlug:a,workspace:t??null,children:r.jsx(hT,{})})}function ht({label:e="Loading dashboard data…"}){return r.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:r.jsx("div",{className:"chrome-card !px-4 !py-3",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function jt({title:e="Something went wrong",error:t,action:n}){return r.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?r.jsx("div",{className:"pt-2",children:n}):null]})})}function qu({command:e,description:t,example:n}){return r.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[r.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?r.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function We({title:e,description:t,children:n,className:s,actions:a}){return r.jsxs("section",{className:ke("surface-panel space-y-3",s),children:[e||a?r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?r.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),a]}):null,n]})}function $D({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return r.jsx(We,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:r.jsx("div",{className:"space-y-3",children:n.map((s,a)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s.detail}),s.command?r.jsx(qu,{command:s.command.command,example:s.command.example}):null]})]})},s.title))})})}const jm={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},Ho={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function LD(e,t){return e.replace(/\{(\w+)\}/g,(n,s)=>String(t[s]??`{${s}}`))}function OD({hero:e,itemsById:t}){const n=ln();if(e.kind==="clean")return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:Ho.emptyStateCleanTitle}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:jm.clean}),r.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),r.jsx("div",{className:"mt-4",children:r.jsx(Ee,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:Ho.emptyStateCleanCTA})})]});const s=e.itemId?t[e.itemId]:void 0,a=(s==null?void 0:s.assignmentTitle)??"",l=jm[e.copyKey]??jm[e.kind],c=LD(l,{total:e.total,title:a}),u=s?ID(s,n):`${n}/assignments`;return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:"What needs you today"}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:c}),s?r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",r.jsx("span",{className:"font-medium text-foreground",children:s.projectTitle??"Standalone"})," ","· status ",r.jsx("span",{className:"font-medium text-foreground",children:s.status})]}):null,r.jsx("div",{className:"mt-4",children:r.jsxs(Ee,{to:u,className:"shell-action shell-action--cta",children:["Open ",a||"assignment"]})})]})}function ID(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const Dg=["kanban","list","table"],a1=["title","status","priority","assignee","dependencies","created","updated"],MD=["asc","desc"],_D=["comfortable","compact"],FD=["none","status","type","priority","assignee","project"],zD=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function nt(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const s of t){if(typeof s!="string")continue;const a=s.trim();!a||a==="all"||n.includes(a)||n.push(a)}return n}function BD(e,t){const n=nt(e),s=nt(t);return n.length===s.length&&n.every(a=>s.includes(a))}const UD={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},Vl={version:1,global:UD,projects:{}};function km(e){return e==="table"?"table":"kanban"}function VD(e,t){return t?{...e,...t}:{...e}}function i1(e,t){const n=e.global;if(t===null)return n;const s=e.projects[t];return s?{defaultView:s.defaultView??n.defaultView,sortField:s.sortField??n.sortField,sortDirection:s.sortDirection??n.sortDirection,density:n.density,grouping:s.grouping??n.grouping,filters:VD(n.filters,s.filters)}:n}const Sm=["title","status","priority","assignee","dependencies","created","updated"],HD=["small","wide","tall","large"],WD={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},Uv="2026-05-21T00:00:00Z";function Nm(e,t,n){return{id:e,name:t,workspace:null,config:{viewMode:"list",filters:{...WD,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:Uv,updatedAt:Uv}}const ao={version:1,views:[Nm("default-recently-updated","Recently updated",{}),Nm("default-high-priority","High priority",{priority:"high"}),Nm("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function l1(e,t){const n=nt(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,a=e.filters.activity,l=typeof e.filters.search=="string"&&e.filters.search.trim().length>0;return s&&(!a||a==="all")&&!l}function c1(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?l1(e.config,t.slug):!1}}const u1=`syntaur.savedViews.cache.v${ao.version}`;let oi=KD(),_o=null,$g=null;const yh=new Set,cd=new Set;let d1=0;function f1(){return++d1}function bh(e){return e===d1}function KD(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(u1);if(!e)return null;const t=JSON.parse(e);return t.version!==ao.version?null:t}catch{return null}}function qD(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(u1,JSON.stringify(e))}catch{}}function p1(e){oi=e,$g=null,qD(e);for(const t of yh)t(e);for(const t of cd)t(null)}function GD(e){$g=e;for(const t of cd)t(e)}function m1(e){if(!e||typeof e!="object")return ao;const t=e;return t.version!==ao.version||!Array.isArray(t.views)||!t.dashboard?ao:t}function Vv(){if(_o)return _o;const e=f1();return _o=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=m1(t);return bh(e)&&p1(n),_o=null,oi??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return bh(e)&&GD(n),_o=null,oi??ao}),_o}function Lg(){const[e,t]=f.useState(()=>oi??ao),[n,s]=f.useState(()=>oi===null),[a,l]=f.useState(!1),[c,u]=f.useState(()=>$g);return f.useEffect(()=>{let m=!1;oi===null&&s(!0),Vv().then(y=>{m||(t(y),s(!1),l(!0))});const h=y=>{m||(t(y),s(!1),l(!0),u(null))},g=y=>{m||(u(y),s(!1),l(!0))};return yh.add(h),cd.add(g),()=>{m=!0,yh.delete(h),cd.delete(g)}},[]),{file:e,loading:n,ready:a,error:c,refetch:()=>{_o=null,s(!0),u(null),l(!1),Vv()}}}function Vd(){const{file:e,loading:t}=Lg();return{views:e.views,loading:t}}function YD(){const{file:e,loading:t}=Lg();return{layout:e.dashboard,loading:t}}function Go(e){const{file:t,loading:n,ready:s,error:a,refetch:l}=Lg();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:a,refetch:l}:{view:null,loading:!1,ready:!0,error:null,refetch:l}}async function Hd(e,t,n){const s=f1(),a=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!a.ok){const c=await a.json().catch(()=>({error:`HTTP ${a.status}`}));throw new Error(c.error??`HTTP ${a.status}`)}const l=m1(await a.json());return bh(s)&&p1(l),l}function Wd(e){return Hd("POST","/api/saved-views",e)}function Og(e,t){return Hd("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function JD(e){return Hd("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function XD(e){return Hd("PUT","/api/dashboard",{slots:e})}const QD=["top","right","bottom","left"],co=Math.min,hr=Math.max,ud=Math.round,Pu=Math.floor,ps=e=>({x:e,y:e}),ZD={left:"right",right:"left",bottom:"top",top:"bottom"};function vh(e,t,n){return hr(e,co(t,n))}function $s(e,t){return typeof e=="function"?e(t):e}function Ls(e){return e.split("-")[0]}function wi(e){return e.split("-")[1]}function Ig(e){return e==="x"?"y":"x"}function Mg(e){return e==="y"?"height":"width"}function us(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function _g(e){return Ig(us(e))}function e4(e,t,n){n===void 0&&(n=!1);const s=wi(e),a=_g(e),l=Mg(a);let c=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(c=dd(c)),[c,dd(c)]}function t4(e){const t=dd(e);return[wh(e),t,wh(t)]}function wh(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Hv=["left","right"],Wv=["right","left"],n4=["top","bottom"],r4=["bottom","top"];function s4(e,t,n){switch(e){case"top":case"bottom":return n?t?Wv:Hv:t?Hv:Wv;case"left":case"right":return t?n4:r4;default:return[]}}function o4(e,t,n,s){const a=wi(e);let l=s4(Ls(e),n==="start",s);return a&&(l=l.map(c=>c+"-"+a),t&&(l=l.concat(l.map(wh)))),l}function dd(e){const t=Ls(e);return ZD[t]+e.slice(t.length)}function a4(e){return{top:0,right:0,bottom:0,left:0,...e}}function h1(e){return typeof e!="number"?a4(e):{top:e,right:e,bottom:e,left:e}}function fd(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function Kv(e,t,n){let{reference:s,floating:a}=e;const l=us(t),c=_g(t),u=Mg(c),p=Ls(t),m=l==="y",h=s.x+s.width/2-a.width/2,g=s.y+s.height/2-a.height/2,y=s[u]/2-a[u]/2;let b;switch(p){case"top":b={x:h,y:s.y-a.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-a.width,y:g};break;default:b={x:s.x,y:s.y}}switch(wi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function i4(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:l,rects:c,elements:u,strategy:p}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=$s(t,e),E=h1(b),w=u[y?g==="floating"?"reference":"floating":g],k=fd(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(w)))==null||n?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:p})),C=g==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,N=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),T=await(l.isElement==null?void 0:l.isElement(N))?await(l.getScale==null?void 0:l.getScale(N))||{x:1,y:1}:{x:1,y:1},O=fd(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:C,offsetParent:N,strategy:p}):C);return{top:(k.top-O.top+E.top)/T.y,bottom:(O.bottom-k.bottom+E.bottom)/T.y,left:(k.left-O.left+E.left)/T.x,right:(O.right-k.right+E.right)/T.x}}const l4=50,c4=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:l=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:i4},p=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:a}),{x:h,y:g}=Kv(m,s,p),y=s,b=0;const E={};for(let j=0;j<l.length;j++){const w=l[j];if(!w)continue;const{name:k,fn:C}=w,{x:N,y:T,data:O,reset:P}=await C({x:h,y:g,initialPlacement:s,placement:y,strategy:a,middlewareData:E,rects:m,platform:u,elements:{reference:e,floating:t}});h=N??h,g=T??g,E[k]={...E[k],...O},P&&b<l4&&(b++,typeof P=="object"&&(P.placement&&(y=P.placement),P.rects&&(m=P.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:a}):P.rects),{x:h,y:g}=Kv(m,y,p)),j=-1)}return{x:h,y:g,placement:y,strategy:a,middlewareData:E}},u4=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:l,platform:c,elements:u,middlewareData:p}=t,{element:m,padding:h=0}=$s(e,t)||{};if(m==null)return{};const g=h1(h),y={x:n,y:s},b=_g(a),E=Mg(b),j=await c.getDimensions(m),w=b==="y",k=w?"top":"left",C=w?"bottom":"right",N=w?"clientHeight":"clientWidth",T=l.reference[E]+l.reference[b]-y[b]-l.floating[E],O=y[b]-l.reference[b],P=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let D=P?P[N]:0;(!D||!await(c.isElement==null?void 0:c.isElement(P)))&&(D=u.floating[N]||l.floating[E]);const L=T/2-O/2,W=D/2-j[E]/2-1,B=co(g[k],W),$=co(g[C],W),K=B,re=D-j[E]-$,I=D/2-j[E]/2+L,H=vh(K,I,re),J=!p.arrow&&wi(a)!=null&&I!==H&&l.reference[E]/2-(I<K?B:$)-j[E]/2<0,ne=J?I<K?I-K:I-re:0;return{[b]:y[b]+ne,data:{[b]:H,centerOffset:I-H-ne,...J&&{alignmentOffset:ne}},reset:J}}}),d4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:l,rects:c,initialPlacement:u,platform:p,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:j=!0,...w}=$s(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const k=Ls(a),C=us(u),N=Ls(u)===u,T=await(p.isRTL==null?void 0:p.isRTL(m.floating)),O=y||(N||!j?[dd(u)]:t4(u)),P=E!=="none";!y&&P&&O.push(...o4(u,j,E,T));const D=[u,...O],L=await p.detectOverflow(t,w),W=[];let B=((s=l.flip)==null?void 0:s.overflows)||[];if(h&&W.push(L[k]),g){const I=e4(a,c,T);W.push(L[I[0]],L[I[1]])}if(B=[...B,{placement:a,overflows:W}],!W.every(I=>I<=0)){var $,K;const I=((($=l.flip)==null?void 0:$.index)||0)+1,H=D[I];if(H&&(!(g==="alignment"?C!==us(H):!1)||B.every(_=>us(_.placement)===C?_.overflows[0]>0:!0)))return{data:{index:I,overflows:B},reset:{placement:H}};let J=(K=B.filter(ne=>ne.overflows[0]<=0).sort((ne,_)=>ne.overflows[1]-_.overflows[1])[0])==null?void 0:K.placement;if(!J)switch(b){case"bestFit":{var re;const ne=(re=B.filter(_=>{if(P){const G=us(_.placement);return G===C||G==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(G=>G>0).reduce((G,A)=>G+A,0)]).sort((_,G)=>_[1]-G[1])[0])==null?void 0:re[0];ne&&(J=ne);break}case"initialPlacement":J=u;break}if(a!==J)return{reset:{placement:J}}}return{}}}};function qv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Gv(e){return QD.some(t=>e[t]>=0)}const f4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...l}=$s(e,t);switch(a){case"referenceHidden":{const c=await s.detectOverflow(t,{...l,elementContext:"reference"}),u=qv(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:Gv(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...l,altBoundary:!0}),u=qv(c,n.floating);return{data:{escapedOffsets:u,escaped:Gv(u)}}}default:return{}}}}},g1=new Set(["left","top"]);async function p4(e,t){const{placement:n,platform:s,elements:a}=e,l=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Ls(n),u=wi(n),p=us(n)==="y",m=g1.has(c)?-1:1,h=l&&p?-1:1,g=$s(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:E}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof E=="number"&&(b=u==="end"?E*-1:E),p?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const m4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:l,placement:c,middlewareData:u}=t,p=await p4(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:a+p.x,y:l+p.y,data:{...p,placement:c}}}}},h4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:l}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:p={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...m}=$s(e,t),h={x:n,y:s},g=await l.detectOverflow(t,m),y=us(Ls(a)),b=Ig(y);let E=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",C=b==="y"?"bottom":"right",N=E+g[k],T=E-g[C];E=vh(N,E,T)}if(u){const k=y==="y"?"top":"left",C=y==="y"?"bottom":"right",N=j+g[k],T=j-g[C];j=vh(N,j,T)}const w=p.fn({...t,[b]:E,[y]:j});return{...w,data:{x:w.x-n,y:w.y-s,enabled:{[b]:c,[y]:u}}}}}},g4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:p=!0,crossAxis:m=!0}=$s(e,t),h={x:n,y:s},g=us(a),y=Ig(g);let b=h[y],E=h[g];const j=$s(u,t),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(p){const N=y==="y"?"height":"width",T=l.reference[y]-l.floating[N]+w.mainAxis,O=l.reference[y]+l.reference[N]-w.mainAxis;b<T?b=T:b>O&&(b=O)}if(m){var k,C;const N=y==="y"?"width":"height",T=g1.has(Ls(a)),O=l.reference[g]-l.floating[N]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:w.crossAxis),P=l.reference[g]+l.reference[N]+(T?0:((C=c.offset)==null?void 0:C[g])||0)-(T?w.crossAxis:0);E<O?E=O:E>P&&(E=P)}return{[y]:b,[g]:E}}}},x4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:l,platform:c,elements:u}=t,{apply:p=()=>{},...m}=$s(e,t),h=await c.detectOverflow(t,m),g=Ls(a),y=wi(a),b=us(a)==="y",{width:E,height:j}=l.floating;let w,k;g==="top"||g==="bottom"?(w=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,w=y==="end"?"top":"bottom");const C=j-h.top-h.bottom,N=E-h.left-h.right,T=co(j-h[w],C),O=co(E-h[k],N),P=!t.middlewareData.shift;let D=T,L=O;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(L=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(D=C),P&&!y){const B=hr(h.left,0),$=hr(h.right,0),K=hr(h.top,0),re=hr(h.bottom,0);b?L=E-2*(B!==0||$!==0?B+$:hr(h.left,h.right)):D=j-2*(K!==0||re!==0?K+re:hr(h.top,h.bottom))}await p({...t,availableWidth:L,availableHeight:D});const W=await c.getDimensions(u.floating);return E!==W.width||j!==W.height?{reset:{rects:!0}}:{}}}};function Kd(){return typeof window<"u"}function ji(e){return x1(e)?(e.nodeName||"").toLowerCase():"#document"}function yr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ys(e){var t;return(t=(x1(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function x1(e){return Kd()?e instanceof Node||e instanceof yr(e).Node:!1}function Gr(e){return Kd()?e instanceof Element||e instanceof yr(e).Element:!1}function Is(e){return Kd()?e instanceof HTMLElement||e instanceof yr(e).HTMLElement:!1}function Yv(e){return!Kd()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yr(e).ShadowRoot}function ic(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=Yr(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&a!=="inline"&&a!=="contents"}function y4(e){return/^(table|td|th)$/.test(ji(e))}function qd(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const b4=/transform|translate|scale|rotate|perspective|filter/,v4=/paint|layout|strict|content/,Io=e=>!!e&&e!=="none";let Cm;function Fg(e){const t=Gr(e)?Yr(e):e;return Io(t.transform)||Io(t.translate)||Io(t.scale)||Io(t.rotate)||Io(t.perspective)||!zg()&&(Io(t.backdropFilter)||Io(t.filter))||b4.test(t.willChange||"")||v4.test(t.contain||"")}function w4(e){let t=uo(e);for(;Is(t)&&!fi(t);){if(Fg(t))return t;if(qd(t))return null;t=uo(t)}return null}function zg(){return Cm==null&&(Cm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cm}function fi(e){return/^(html|body|#document)$/.test(ji(e))}function Yr(e){return yr(e).getComputedStyle(e)}function Gd(e){return Gr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function uo(e){if(ji(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Yv(e)&&e.host||ys(e);return Yv(t)?t.host:t}function y1(e){const t=uo(e);return fi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Is(t)&&ic(t)?t:y1(t)}function Hl(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=y1(e),l=a===((s=e.ownerDocument)==null?void 0:s.body),c=yr(a);if(l){const u=jh(c);return t.concat(c,c.visualViewport||[],ic(a)?a:[],u&&n?Hl(u):[])}else return t.concat(a,Hl(a,[],n))}function jh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function b1(e){const t=Yr(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Is(e),l=a?e.offsetWidth:n,c=a?e.offsetHeight:s,u=ud(n)!==l||ud(s)!==c;return u&&(n=l,s=c),{width:n,height:s,$:u}}function Bg(e){return Gr(e)?e:e.contextElement}function ai(e){const t=Bg(e);if(!Is(t))return ps(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:l}=b1(t);let c=(l?ud(n.width):n.width)/s,u=(l?ud(n.height):n.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const j4=ps(0);function v1(e){const t=yr(e);return!zg()||!t.visualViewport?j4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function k4(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yr(e)?!1:t}function Yo(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),l=Bg(e);let c=ps(1);t&&(s?Gr(s)&&(c=ai(s)):c=ai(e));const u=k4(l,n,s)?v1(l):ps(0);let p=(a.left+u.x)/c.x,m=(a.top+u.y)/c.y,h=a.width/c.x,g=a.height/c.y;if(l){const y=yr(l),b=s&&Gr(s)?yr(s):s;let E=y,j=jh(E);for(;j&&s&&b!==E;){const w=ai(j),k=j.getBoundingClientRect(),C=Yr(j),N=k.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,T=k.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;p*=w.x,m*=w.y,h*=w.x,g*=w.y,p+=N,m+=T,E=yr(j),j=jh(E)}}return fd({width:h,height:g,x:p,y:m})}function Yd(e,t){const n=Gd(e).scrollLeft;return t?t.left+n:Yo(ys(e)).left+n}function w1(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Yd(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function S4(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const l=a==="fixed",c=ys(s),u=t?qd(t.floating):!1;if(s===c||u&&l)return n;let p={scrollLeft:0,scrollTop:0},m=ps(1);const h=ps(0),g=Is(s);if((g||!g&&!l)&&((ji(s)!=="body"||ic(c))&&(p=Gd(s)),g)){const b=Yo(s);m=ai(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!l?w1(c,p):ps(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-p.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-p.scrollTop*m.y+h.y+y.y}}function N4(e){return Array.from(e.getClientRects())}function C4(e){const t=ys(e),n=Gd(e),s=e.ownerDocument.body,a=hr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),l=hr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Yd(e);const u=-n.scrollTop;return Yr(s).direction==="rtl"&&(c+=hr(t.clientWidth,s.clientWidth)-a),{width:a,height:l,x:c,y:u}}const Jv=25;function E4(e,t){const n=yr(e),s=ys(e),a=n.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,p=0;if(a){l=a.width,c=a.height;const h=zg();(!h||h&&t==="fixed")&&(u=a.offsetLeft,p=a.offsetTop)}const m=Yd(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,E=Math.abs(s.clientWidth-g.clientWidth-b);E<=Jv&&(l-=E)}else m<=Jv&&(l+=m);return{width:l,height:c,x:u,y:p}}function T4(e,t){const n=Yo(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,l=Is(e)?ai(e):ps(1),c=e.clientWidth*l.x,u=e.clientHeight*l.y,p=a*l.x,m=s*l.y;return{width:c,height:u,x:p,y:m}}function Xv(e,t,n){let s;if(t==="viewport")s=E4(e,n);else if(t==="document")s=C4(ys(e));else if(Gr(t))s=T4(t,n);else{const a=v1(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return fd(s)}function j1(e,t){const n=uo(e);return n===t||!Gr(n)||fi(n)?!1:Yr(n).position==="fixed"||j1(n,t)}function P4(e,t){const n=t.get(e);if(n)return n;let s=Hl(e,[],!1).filter(u=>Gr(u)&&ji(u)!=="body"),a=null;const l=Yr(e).position==="fixed";let c=l?uo(e):e;for(;Gr(c)&&!fi(c);){const u=Yr(c),p=Fg(c);!p&&u.position==="fixed"&&(a=null),(l?!p&&!a:!p&&u.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||ic(c)&&!p&&j1(e,c))?s=s.filter(h=>h!==c):a=u,c=uo(c)}return t.set(e,s),s}function R4(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const c=[...n==="clippingAncestors"?qd(t)?[]:P4(t,this._c):[].concat(n),s],u=Xv(t,c[0],a);let p=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=Xv(t,c[y],a);p=hr(b.top,p),m=co(b.right,m),h=co(b.bottom,h),g=hr(b.left,g)}return{width:m-g,height:h-p,x:g,y:p}}function A4(e){const{width:t,height:n}=b1(e);return{width:t,height:n}}function D4(e,t,n){const s=Is(t),a=ys(t),l=n==="fixed",c=Yo(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const p=ps(0);function m(){p.x=Yd(a)}if(s||!s&&!l)if((ji(t)!=="body"||ic(a))&&(u=Gd(t)),s){const b=Yo(t,!0,l,t);p.x=b.x+t.clientLeft,p.y=b.y+t.clientTop}else a&&m();l&&!s&&a&&m();const h=a&&!s&&!l?w1(a,u):ps(0),g=c.left+u.scrollLeft-p.x-h.x,y=c.top+u.scrollTop-p.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Em(e){return Yr(e).position==="static"}function Qv(e,t){if(!Is(e)||Yr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ys(e)===n&&(n=n.ownerDocument.body),n}function k1(e,t){const n=yr(e);if(qd(e))return n;if(!Is(e)){let a=uo(e);for(;a&&!fi(a);){if(Gr(a)&&!Em(a))return a;a=uo(a)}return n}let s=Qv(e,t);for(;s&&y4(s)&&Em(s);)s=Qv(s,t);return s&&fi(s)&&Em(s)&&!Fg(s)?n:s||w4(e)||n}const $4=async function(e){const t=this.getOffsetParent||k1,n=this.getDimensions,s=await n(e.floating);return{reference:D4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function L4(e){return Yr(e).direction==="rtl"}const O4={convertOffsetParentRelativeRectToViewportRelativeRect:S4,getDocumentElement:ys,getClippingRect:R4,getOffsetParent:k1,getElementRects:$4,getClientRects:N4,getDimensions:A4,getScale:ai,isElement:Gr,isRTL:L4};function S1(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function I4(e,t){let n=null,s;const a=ys(e);function l(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,p){u===void 0&&(u=!1),p===void 0&&(p=1),l();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const E=Pu(g),j=Pu(a.clientWidth-(h+y)),w=Pu(a.clientHeight-(g+b)),k=Pu(h),N={rootMargin:-E+"px "+-j+"px "+-w+"px "+-k+"px",threshold:hr(0,co(1,p))||1};let T=!0;function O(P){const D=P[0].intersectionRatio;if(D!==p){if(!T)return c();D?c(!1,D):s=setTimeout(()=>{c(!1,1e-7)},1e3)}D===1&&!S1(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(O,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(O,N)}n.observe(e)}return c(!0),l}function M4(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:l=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:p=!1}=s,m=Bg(e),h=a||l?[...m?Hl(m):[],...t?Hl(t):[]]:[];h.forEach(k=>{a&&k.addEventListener("scroll",n,{passive:!0}),l&&k.addEventListener("resize",n)});const g=m&&u?I4(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[C]=k;C&&C.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var N;(N=b)==null||N.observe(t)})),n()}),m&&!p&&b.observe(m),t&&b.observe(t));let E,j=p?Yo(e):null;p&&w();function w(){const k=Yo(e);j&&!S1(j,k)&&n(),j=k,E=requestAnimationFrame(w)}return n(),()=>{var k;h.forEach(C=>{a&&C.removeEventListener("scroll",n),l&&C.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,p&&cancelAnimationFrame(E)}}const _4=m4,F4=h4,z4=d4,B4=x4,U4=f4,Zv=u4,V4=g4,H4=(e,t,n)=>{const s=new Map,a={platform:O4,...n},l={...a.platform,_c:s};return c4(e,t,{...a,platform:l})};var W4=typeof document<"u",K4=function(){},Gu=W4?f.useLayoutEffect:K4;function pd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!pd(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const l=a[s];if(!(l==="_owner"&&e.$$typeof)&&!pd(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function N1(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ew(e,t){const n=N1(e);return Math.round(t*n)/n}function Tm(e){const t=f.useRef(e);return Gu(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:l,floating:c}={},transform:u=!0,whileElementsMounted:p,open:m}=e,[h,g]=f.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=f.useState(s);pd(y,s)||b(s);const[E,j]=f.useState(null),[w,k]=f.useState(null),C=f.useCallback(_=>{_!==P.current&&(P.current=_,j(_))},[]),N=f.useCallback(_=>{_!==D.current&&(D.current=_,k(_))},[]),T=l||E,O=c||w,P=f.useRef(null),D=f.useRef(null),L=f.useRef(h),W=p!=null,B=Tm(p),$=Tm(a),K=Tm(m),re=f.useCallback(()=>{if(!P.current||!D.current)return;const _={placement:t,strategy:n,middleware:y};$.current&&(_.platform=$.current),H4(P.current,D.current,_).then(G=>{const A={...G,isPositioned:K.current!==!1};I.current&&!pd(L.current,A)&&(L.current=A,Rs.flushSync(()=>{g(A)}))})},[y,t,n,$,K]);Gu(()=>{m===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,g(_=>({..._,isPositioned:!1})))},[m]);const I=f.useRef(!1);Gu(()=>(I.current=!0,()=>{I.current=!1}),[]),Gu(()=>{if(T&&(P.current=T),O&&(D.current=O),T&&O){if(B.current)return B.current(T,O,re);re()}},[T,O,re,B,W]);const H=f.useMemo(()=>({reference:P,floating:D,setReference:C,setFloating:N}),[C,N]),J=f.useMemo(()=>({reference:T,floating:O}),[T,O]),ne=f.useMemo(()=>{const _={position:n,left:0,top:0};if(!J.floating)return _;const G=ew(J.floating,h.x),A=ew(J.floating,h.y);return u?{..._,transform:"translate("+G+"px, "+A+"px)",...N1(J.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:A}},[n,u,J.floating,h.x,h.y]);return f.useMemo(()=>({...h,update:re,refs:H,elements:J,floatingStyles:ne}),[h,re,H,J,ne])}const G4=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?Zv({element:s.current,padding:a}).fn(n):{}:s?Zv({element:s,padding:a}).fn(n):{}}}},Y4=(e,t)=>{const n=_4(e);return{name:n.name,fn:n.fn,options:[e,t]}},J4=(e,t)=>{const n=F4(e);return{name:n.name,fn:n.fn,options:[e,t]}},X4=(e,t)=>({fn:V4(e).fn,options:[e,t]}),Q4=(e,t)=>{const n=z4(e);return{name:n.name,fn:n.fn,options:[e,t]}},Z4=(e,t)=>{const n=B4(e);return{name:n.name,fn:n.fn,options:[e,t]}},e$=(e,t)=>{const n=U4(e);return{name:n.name,fn:n.fn,options:[e,t]}},t$=(e,t)=>{const n=G4(e);return{name:n.name,fn:n.fn,options:[e,t]}};var n$="Arrow",C1=f.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...l}=e;return r.jsx(hn.svg,{...l,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});C1.displayName=n$;var r$=C1;function s$(e){const[t,n]=f.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const l=a[0];let c,u;if("borderBoxSize"in l){const p=l.borderBoxSize,m=Array.isArray(p)?p[0]:p;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Ug="Popper",[E1,T1]=Xo(Ug),[o$,P1]=E1(Ug),R1=e=>{const{__scopePopper:t,children:n}=e,[s,a]=f.useState(null);return r.jsx(o$,{scope:t,anchor:s,onAnchorChange:a,children:n})};R1.displayName=Ug;var A1="PopperAnchor",D1=f.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,l=P1(A1,n),c=f.useRef(null),u=Fn(t,c),p=f.useRef(null);return f.useEffect(()=>{const m=p.current;p.current=(s==null?void 0:s.current)||c.current,m!==p.current&&l.onAnchorChange(p.current)}),s?null:r.jsx(hn.div,{...a,ref:u})});D1.displayName=A1;var Vg="PopperContent",[a$,i$]=E1(Vg),$1=f.forwardRef((e,t)=>{var ae,me,ve,Se,he,Je;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:l="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:E,...j}=e,w=P1(Vg,n),[k,C]=f.useState(null),N=Fn(t,Ye=>C(Ye)),[T,O]=f.useState(null),P=s$(T),D=(P==null?void 0:P.width)??0,L=(P==null?void 0:P.height)??0,W=s+(l!=="center"?"-"+l:""),B=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},$=Array.isArray(m)?m:[m],K=$.length>0,re={padding:B,boundary:$.filter(c$),altBoundary:K},{refs:I,floatingStyles:H,placement:J,isPositioned:ne,middlewareData:_}=q4({strategy:"fixed",placement:W,whileElementsMounted:(...Ye)=>M4(...Ye,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[Y4({mainAxis:a+L,alignmentAxis:c}),p&&J4({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?X4():void 0,...re}),p&&Q4({...re}),Z4({...re,apply:({elements:Ye,rects:at,availableWidth:X,availableHeight:Ie})=>{const{width:Ne,height:Oe}=at.reference,Xe=Ye.floating.style;Xe.setProperty("--radix-popper-available-width",`${X}px`),Xe.setProperty("--radix-popper-available-height",`${Ie}px`),Xe.setProperty("--radix-popper-anchor-width",`${Ne}px`),Xe.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),T&&t$({element:T,padding:u}),u$({arrowWidth:D,arrowHeight:L}),y&&e$({strategy:"referenceHidden",...re})]}),[G,A]=I1(J),z=Ko(E);lo(()=>{ne&&(z==null||z())},[ne,z]);const ee=(ae=_.arrow)==null?void 0:ae.x,M=(me=_.arrow)==null?void 0:me.y,ue=((ve=_.arrow)==null?void 0:ve.centerOffset)!==0,[ge,V]=f.useState();return lo(()=>{k&&V(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:ne?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Se=_.transformOrigin)==null?void 0:Se.x,(he=_.transformOrigin)==null?void 0:he.y].join(" "),...((Je=_.hide)==null?void 0:Je.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(a$,{scope:n,placedSide:G,onArrowChange:O,arrowX:ee,arrowY:M,shouldHideArrow:ue,children:r.jsx(hn.div,{"data-side":G,"data-align":A,...j,ref:N,style:{...j.style,animation:ne?void 0:"none"}})})})});$1.displayName=Vg;var L1="PopperArrow",l$={top:"bottom",right:"left",bottom:"top",left:"right"},O1=f.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,l=i$(L1,s),c=l$[l.placedSide];return r.jsx("span",{ref:l.onArrowChange,style:{position:"absolute",left:l.arrowX,top:l.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[l.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[l.placedSide],visibility:l.shouldHideArrow?"hidden":void 0},children:r.jsx(r$,{...a,ref:n,style:{...a.style,display:"block"}})})});O1.displayName=L1;function c$(e){return e!==null}var u$=e=>({name:"transformOrigin",options:e,fn(t){var w,k,C;const{placement:n,rects:s,middlewareData:a}=t,c=((w=a.arrow)==null?void 0:w.centerOffset)!==0,u=c?0:e.arrowWidth,p=c?0:e.arrowHeight,[m,h]=I1(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=a.arrow)==null?void 0:k.x)??0)+u/2,b=(((C=a.arrow)==null?void 0:C.y)??0)+p/2;let E="",j="";return m==="bottom"?(E=c?g:`${y}px`,j=`${-p}px`):m==="top"?(E=c?g:`${y}px`,j=`${s.floating.height+p}px`):m==="right"?(E=`${-p}px`,j=c?g:`${b}px`):m==="left"&&(E=`${s.floating.width+p}px`,j=c?g:`${b}px`),{data:{x:E,y:j}}}});function I1(e){const[t,n="center"]=e.split("-");return[t,n]}var d$=R1,f$=D1,p$=$1,m$=O1,h$=Symbol("radix.slottable");function g$(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=h$,t}var x$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),y$="VisuallyHidden",M1=f.forwardRef((e,t)=>r.jsx(hn.span,{...e,ref:t,style:{...x$,...e.style}}));M1.displayName=y$;var b$=M1,[Jd]=Xo("Tooltip",[T1]),Xd=T1(),_1="TooltipProvider",v$=700,kh="tooltip.open",[w$,Hg]=Jd(_1),F1=e=>{const{__scopeTooltip:t,delayDuration:n=v$,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:l}=e,c=f.useRef(!0),u=f.useRef(!1),p=f.useRef(0);return f.useEffect(()=>{const m=p.current;return()=>window.clearTimeout(m)},[]),r.jsx(w$,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:f.useCallback(()=>{window.clearTimeout(p.current),c.current=!1},[]),onClose:f.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:f.useCallback(m=>{u.current=m},[]),disableHoverableContent:a,children:l})};F1.displayName=_1;var Wl="Tooltip",[j$,lc]=Jd(Wl),z1=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:a,onOpenChange:l,disableHoverableContent:c,delayDuration:u}=e,p=Hg(Wl,e.__scopeTooltip),m=Xd(t),[h,g]=f.useState(null),y=ni(),b=f.useRef(0),E=c??p.disableHoverableContent,j=u??p.delayDuration,w=f.useRef(!1),[k,C]=zd({prop:s,defaultProp:a??!1,onChange:D=>{D?(p.onOpen(),document.dispatchEvent(new CustomEvent(kh))):p.onClose(),l==null||l(D)},caller:Wl}),N=f.useMemo(()=>k?w.current?"delayed-open":"instant-open":"closed",[k]),T=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,C(!0)},[C]),O=f.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C(!1)},[C]),P=f.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,C(!0),b.current=0},j)},[j,C]);return f.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(d$,{...m,children:r.jsx(j$,{scope:t,contentId:y,open:k,stateAttribute:N,trigger:h,onTriggerChange:g,onTriggerEnter:f.useCallback(()=>{p.isOpenDelayedRef.current?P():T()},[p.isOpenDelayedRef,P,T]),onTriggerLeave:f.useCallback(()=>{E?O():(window.clearTimeout(b.current),b.current=0)},[O,E]),onOpen:T,onClose:O,disableHoverableContent:E,children:n})})};z1.displayName=Wl;var Sh="TooltipTrigger",B1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=lc(Sh,n),l=Hg(Sh,n),c=Xd(n),u=f.useRef(null),p=Fn(t,u,a.onTriggerChange),m=f.useRef(!1),h=f.useRef(!1),g=f.useCallback(()=>m.current=!1,[]);return f.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(f$,{asChild:!0,...c,children:r.jsx(hn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:p,onPointerMove:qt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!l.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:qt(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:qt(e.onPointerDown,()=>{a.open&&a.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:qt(e.onFocus,()=>{m.current||a.onOpen()}),onBlur:qt(e.onBlur,a.onClose),onClick:qt(e.onClick,a.onClose)})})});B1.displayName=Sh;var Wg="TooltipPortal",[k$,S$]=Jd(Wg,{forceMount:void 0}),U1=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:a}=e,l=lc(Wg,t);return r.jsx(k$,{scope:t,forceMount:n,children:r.jsx(Qo,{present:n||l.open,children:r.jsx(yg,{asChild:!0,container:a,children:s})})})};U1.displayName=Wg;var pi="TooltipContent",V1=f.forwardRef((e,t)=>{const n=S$(pi,e.__scopeTooltip),{forceMount:s=n.forceMount,side:a="top",...l}=e,c=lc(pi,e.__scopeTooltip);return r.jsx(Qo,{present:s||c.open,children:c.disableHoverableContent?r.jsx(H1,{side:a,...l,ref:t}):r.jsx(N$,{side:a,...l,ref:t})})}),N$=f.forwardRef((e,t)=>{const n=lc(pi,e.__scopeTooltip),s=Hg(pi,e.__scopeTooltip),a=f.useRef(null),l=Fn(t,a),[c,u]=f.useState(null),{trigger:p,onClose:m}=n,h=a.current,{onPointerInTransitChange:g}=s,y=f.useCallback(()=>{u(null),g(!1)},[g]),b=f.useCallback((E,j)=>{const w=E.currentTarget,k={x:E.clientX,y:E.clientY},C=R$(k,w.getBoundingClientRect()),N=A$(k,C),T=D$(j.getBoundingClientRect()),O=L$([...N,...T]);u(O),g(!0)},[g]);return f.useEffect(()=>()=>y(),[y]),f.useEffect(()=>{if(p&&h){const E=w=>b(w,h),j=w=>b(w,p);return p.addEventListener("pointerleave",E),h.addEventListener("pointerleave",j),()=>{p.removeEventListener("pointerleave",E),h.removeEventListener("pointerleave",j)}}},[p,h,b,y]),f.useEffect(()=>{if(c){const E=j=>{const w=j.target,k={x:j.clientX,y:j.clientY},C=(p==null?void 0:p.contains(w))||(h==null?void 0:h.contains(w)),N=!$$(k,c);C?y():N&&(y(),m())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[p,h,c,m,y]),r.jsx(H1,{...e,ref:l})}),[C$,E$]=Jd(Wl,{isInside:!1}),T$=g$("TooltipContent"),H1=f.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":a,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=e,p=lc(pi,n),m=Xd(n),{onClose:h}=p;return f.useEffect(()=>(document.addEventListener(kh,h),()=>document.removeEventListener(kh,h)),[h]),f.useEffect(()=>{if(p.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(p.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,h]),r.jsx(xg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(p$,{"data-state":p.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(T$,{children:s}),r.jsx(C$,{scope:n,isInside:!0,children:r.jsx(b$,{id:p.contentId,role:"tooltip",children:a||s})})]})})});V1.displayName=pi;var W1="TooltipArrow",P$=f.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,a=Xd(n);return E$(W1,n).isInside?null:r.jsx(m$,{...a,...s,ref:t})});P$.displayName=W1;function R$(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),l=Math.abs(t.left-e.x);switch(Math.min(n,s,a,l)){case l:return"left";case a:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function A$(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function D$(e){const{top:t,right:n,bottom:s,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:s},{x:a,y:s}]}function $$(e,t){const{x:n,y:s}=e;let a=!1;for(let l=0,c=t.length-1;l<t.length;c=l++){const u=t[l],p=t[c],m=u.x,h=u.y,g=p.x,y=p.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(a=!a)}return a}function L$(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),O$(t)}function O$(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const a=e[s];for(;t.length>=2;){const l=t[t.length-1],c=t[t.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(a.y-c.y)>=(l.y-c.y)*(a.x-c.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var I$=F1,M$=z1,_$=B1,F$=U1,K1=V1;const Wo=I$,Rr=M$,Ar=_$,gr=f.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(F$,{children:r.jsx(K1,{ref:s,sideOffset:t,className:ke("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gr.displayName=K1.displayName;function Kg({items:e,align:t="end"}){const[n,s]=f.useState(!1),[a,l]=f.useState(null),c=f.useRef(null);if(f.useEffect(()=>{if(!n){l(null);return}function p(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(p,m){const h=p.icon,g=ke("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",p.disabled?"opacity-50 cursor-not-allowed":p.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?p.active?r.jsx(Qr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:p.label})]});if(p.disabled){const E=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return p.disabledReason?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:E}),r.jsx(gr,{side:"left",children:p.disabledReason})]},p.key):r.jsx("div",{children:E},p.key)}return p.href?r.jsx(Ee,{to:p.href,className:g,onClick:()=>s(!1),children:b},p.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var E;(E=p.onSelect)==null||E.call(p),s(!1)},children:b},p.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(fP,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:ke("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(Wo,{delayDuration:200,children:e.map(p=>{if(p.submenu&&p.submenu.length>0){const m=p.icon,h=a===p.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:ke("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>l(h?null:p.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:p.label}),h?r.jsx(br,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(f0,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?p.submenu.map(g=>u(g,!0)):null]},p.key)}return u(p,!1)})})})]})}function tw(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const z$={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function B$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function U$(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function V$(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,a=Date.parse(s);if(Number.isNaN(a))return!1;if(t.preset){const u=z$[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-a>u:a>=n-u&&a<=n}const l=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!l&&!c?!0:!(l&&a<B$(l)||c&&a>U$(c))}function qg(e,t,n={}){const{workspace:s,search:a,includeArchived:l}=n;if(e.archived===!0&&!l)return!1;const c=nt(t.status),u=nt(t.priority),p=nt(t.type),m=nt(t.assignee),h=nt(t.project),g=nt(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||p.length&&!p.includes(e.type??"")||y==="stale"&&!tw(e.updated)||y==="fresh"&&tw(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(E=>E==="__standalone__"?e.projectSlug==null:e.projectSlug===E))return!1;if(g.length){const b=e.tags??[];if(!g.some(E=>b.includes(E)))return!1}if(!V$(e,t.dateRange))return!1;if(a){const b=a.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function Kl(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const q1={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let Rl=null,Fo=null;function H$(){return Rl?Promise.resolve(Rl):Fo||(Fo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Rl=e,Fo=null,e)).catch(()=>(Fo=null,q1)),Fo)}function Zo(){const[e,t]=f.useState(()=>Rl??q1);return f.useEffect(()=>{H$().then(t)},[]),e}function nw(){Rl=null,Fo=null}function cc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const rw={critical:0,high:1,medium:2,low:3};function Ru(e){return Date.parse(e??"")||0}function uc(e,t,n){return[...e].sort((a,l)=>{let c=0;switch(t){case"title":c=a.title.localeCompare(l.title);break;case"status":c=a.status.localeCompare(l.status);break;case"priority":c=(rw[a.priority]??99)-(rw[l.priority]??99);break;case"assignee":c=(a.assignee??"").localeCompare(l.assignee??"");break;case"dependencies":c=a.dependsOn.length-l.dependsOn.length;break;case"created":c=Ru(a.created)-Ru(l.created);break;case"updated":c=Ru(a.updated)-Ru(l.updated);break}return n==="asc"?c:-c})}function Nt({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const mi='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Qd({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:a,canDrop:l,onMove:c,getExternalDragData:u,onCardContextMenu:p,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const E=f.useMemo(()=>new Set(h??[]),[h]),j=f.useMemo(()=>e.filter(I=>!E.has(I.id)),[e,E]),w=f.useMemo(()=>e.filter(I=>E.has(I.id)),[e,E]),[k,C]=f.useState(null),[N,T]=f.useState(null),O=f.useRef(null),P=f.useMemo(()=>new Map(t.map(I=>[n(I),I])),[n,t]),D=f.useMemo(()=>j.map(I=>({column:I,items:t.filter(H=>s(H)===I.id)})),[j,s,t]),L=k?P.get(k)??null:null;function W(I){if(!L)return{allowed:!1};const H=s(L);return(l==null?void 0:l({item:L,fromColumnId:H,toColumnId:I}))??{allowed:!0}}function B(){C(null),T(null)}function $(I,H,J){if(b)return;const ne=(u==null?void 0:u(H))??null;!c&&!ne||(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",J),ne&&I.dataTransfer.setData("application/json",JSON.stringify(ne)),c&&C(J))}function K(I,H,J){b||!c||!L||!W(H).allowed||(I.preventDefault(),I.dataTransfer.dropEffect="move",T(_=>(_==null?void 0:_.columnId)===H&&_.index===J?_:{columnId:H,index:J}))}async function re(I,H,J){var z;if(I.preventDefault(),b||!c||!L){B();return}const ne=s(L),G=(((z=D.find(ee=>ee.column.id===ne))==null?void 0:z.items)??[]).findIndex(ee=>n(ee)===n(L));if(!W(H).allowed||G<0){B();return}if(ne===H&&(J===G||J===G+1)){B();return}try{await c({item:L,fromColumnId:ne,toColumnId:H,fromIndex:G,toIndex:J})}finally{B()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[w.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),w.map(I=>r.jsxs("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${I.title}" column`,children:[I.title," ×"]},I.id))]}):null,r.jsx("div",{className:ke("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(200px,240px)]":"auto-cols-[minmax(260px,320px)]"),children:D.map(({column:I,items:H})=>{const J=W(I.id),ne=(N==null?void 0:N.columnId)===I.id;return r.jsxs("section",{className:ke("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",L&&!J.allowed?"border-dashed opacity-65":"",L&&J.allowed?"border-primary/30 bg-accent/30":"",ne?"ring-2 ring-ring/30":""),title:L&&!J.allowed?J.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:ke("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:I.title}),I.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:I.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:H.length}),g?r.jsx("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${I.title}" column`,"aria-label":`Hide column ${I.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:_=>K(_,I.id,H.length),onDrop:_=>re(_,I.id,H.length),children:[H.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(I):m}):r.jsx(W$,{active:(N==null?void 0:N.columnId)===I.id&&N.index===0,disabled:!!L&&!J.allowed,children:typeof m=="function"?m(I):m}):null,H.map((_,G)=>{const A=n(_),z=k===A;return r.jsxs(f.Fragment,{children:[r.jsx("div",{className:ke("h-2 rounded-full transition",(N==null?void 0:N.columnId)===I.id&&N.index===G?"bg-primary/70":"bg-transparent"),onDragOver:ee=>K(ee,I.id,G),onDrop:ee=>re(ee,I.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:ee=>{O.current=ee.target},onDragStart:ee=>{const M=O.current;if(M!=null&&M.closest(mi)){ee.preventDefault();return}$(ee,_,A)},onDragEnd:B,onContextMenu:ee=>{if(!p)return;const M=ee.target;M!=null&&M.closest(mi)||p(_,ee)},className:ke("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",z?"scale-[0.98] opacity-50":""),children:a(_,{dragging:z})})]},A)}),H.length>0&&!b?r.jsx("div",{className:ke("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(N==null?void 0:N.columnId)===I.id&&N.index===H.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",L&&!J.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},I.id)})})]})}function W$({active:e,disabled:t,children:n}){return r.jsx("div",{className:ke("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const El="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Pm="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",K$="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",q$="border-status-review-foreground/30 bg-status-review text-status-review-foreground",G$="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",Y$="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",J$="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",md={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:El,icon:bi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:El,icon:iP},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:El,icon:m0},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Pm,icon:NP},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Pm,icon:sg},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:K$,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:q$,icon:TP},completed:{label:"Completed",description:"Finished successfully.",className:G$,icon:eg},failed:{label:"Failed",description:"Could not be completed as planned.",className:Y$,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Pm,icon:ch},stopped:{label:"Stopped",description:"Session ended without completing.",className:El,icon:oP},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:J$,icon:ch}};function hd(e){const t=md[e];return t||{className:El,icon:ch,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function G1(e,t){return ke("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",hd(e).className,t)}function mn({status:e,className:t,showIcon:n=!0,progress:s}){const a=hd(e),l=a.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,p=c?`${a.description} (${s.checked}/${s.total} criteria)`:a.description,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(l,{className:"h-2.5 w-2.5"})]}):r.jsx(l,{className:"h-3.5 w-3.5"}):null;return r.jsxs("span",{title:p,className:G1(e,t),children:[m,r.jsx("span",{children:a.label})]})}function Zd(e){var t;return((t=md[e])==null?void 0:t.description)??`Status: ${e}`}const Y1={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Yu=null,za=null;function X$(){return Yu?Promise.resolve(Yu):za||(za=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Yu=e,za=null,e)).catch(()=>(za=null,Y1)),za)}function ef(){const[e,t]=f.useState(()=>Yu??Y1);return f.useEffect(()=>{X$().then(t)},[]),e}function ii(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Q$(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ea({type:e,className:t,compact:n=!1}){const s=ef();if(!e)return null;const a=Q$(s,e),l=(a==null?void 0:a.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=a!=null&&a.color?{backgroundColor:`color-mix(in oklch, ${a.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${a.color} 50%, transparent)`,color:a.color}:void 0;return r.jsx("span",{title:(a==null?void 0:a.description)??`Type: ${l}`,style:c,className:ke("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:l})}function $r({value:e,label:t,disabled:n=!1,disabledReason:s,onError:a}){const[l,c]=f.useState(!1);async function u(){if(!n)try{if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(e),c(!0),setTimeout(()=>c(!1),1500)}catch(p){a==null||a(p instanceof Error?p:new Error(String(p)))}}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:l?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:l?r.jsx(Qr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(rd,{className:"h-3 w-3","aria-hidden":"true"})})}function Z$(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function eL({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:a,compact:l=!1}){const c=Zo(),[u,p]=f.useState(()=>new Set(a.collapsed));f.useEffect(()=>{p(new Set(a.collapsed))},[a]);const m=h=>{p(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:ke("space-y-2",l?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=uc(e.filter(E=>E.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=cc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:ke("flex w-full items-center gap-2 text-left",l?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(br,{className:ke("text-muted-foreground transition-transform",l?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:ke("rounded-full border border-border/60 text-muted-foreground",l?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:ke("divide-y divide-border/40 border-t border-border/40",l?"text-xs":"text-sm"),children:g.map(E=>{const j=Z$(E);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:ke("flex items-center gap-3 hover:bg-muted/40",l?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:E.title}),E.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:E.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:$n(E.updated)})]})},`${E.projectSlug??"standalone"}:${E.id}`)})})]},h)})})}function tL(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function nL({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:a=!1}){const l=new Set(s.hidden);l.delete("title");const c=h=>!l.has(h),u=uc(e,t,n),p=a?"py-2 pr-3":"py-3 pr-4",m=a?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:ke("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:ke("font-medium",p),children:"Assignment"}):null,c("status")?r.jsx("th",{className:ke("font-medium",p),children:"Status"}):null,c("priority")?r.jsx("th",{className:ke("font-medium",p),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:ke("font-medium",p),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:ke("font-medium",p),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:ke("font-medium",p),children:"Created"}):null,c("updated")?r.jsx("th",{className:ke("font-medium",p),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=tL(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:p,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:p,children:r.jsx(mn,{status:h.status})}):null,c("priority")?r.jsx("td",{className:ke("capitalize text-muted-foreground",p),children:h.priority}):null,c("assignee")?r.jsx("td",{className:ke("text-muted-foreground",p),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:ke("text-muted-foreground",p),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:ke("text-muted-foreground",p),children:$n(h.created)}):null,c("updated")?r.jsx("td",{className:ke("text-muted-foreground",p),children:$n(h.updated)}):null]},y)})})]})})}function rL(e,t,n){return e.filter(s=>qg(s,t,{workspace:n,search:t.search}))}function J1({view:e,compact:t,emptyDescription:n}){const{data:s,loading:a,error:l}=Md(),c=Zo(),u=f.useMemo(()=>c.order.map(m=>({id:m,title:cc(c,m),description:Zd(m)})),[c]),p=f.useMemo(()=>{if(!s)return[];const m=rL(s.assignments,e.config.filters,e.workspace);return uc(m,e.config.sortField,e.config.sortDirection)},[s,e]);if(a&&!s)return r.jsx(ht,{label:"Loading assignments…"});if(l)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l})]});if(p.length===0)return r.jsx(Nt,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(Qd,{compact:t,dragDisabled:!0,columns:u,items:p,getItemId:m=>m.slug||m.id,getColumnId:m=>m.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:m=>t?r.jsx(sL,{item:m}):r.jsx(oL,{item:m})});case"list":return r.jsx(eL,{items:p,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(nL,{items:p,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function sL({item:e}){const t=Kl(e);return r.jsxs("div",{className:ke("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(mn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:$n(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx($r,{value:e.id})]}):null]})}function oL({item:e}){const t=Kl(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(mn,{status:e.status})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ea,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:$n(e.updated)})]})]})}function aL({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:a,refetch:l}=Go(e);return s?r.jsx(ht,{label:"Loading view…"}):a?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.message}),r.jsx("button",{type:"button",onClick:()=>l(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(J1,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function iL({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:Ho.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:Ho.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(lL,{session:t})},t.sessionId))})]})}function lL({session:e}){const t=ln(),[n,s]=f.useState(!1),a=cL(e,t),l=uL(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:a,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[l," · ",P0(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ho.recentSessionsCopyFallbackHint})]}):null]}),r.jsx($r,{value:e.path,label:Ho.recentSessionsCopyPathLabel,disabled:c,disabledReason:Ho.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function cL(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function uL(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}function dL(){const{data:e,loading:t,error:n}=K0();return t&&!e?r.jsx(ht,{label:"Loading sessions…"}):n?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]}):r.jsx(iL,{sessions:(e==null?void 0:e.sessions)??[]})}const fL=5;function pL(){const{data:e,loading:t,error:n}=W0();if(t&&!e)return r.jsx(ht,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const a=((e==null?void 0:e.inventories)??[]).slice(0,fL);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),a.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:a.map(l=>{const c=l.inventory,u=l.active_leases.length,p=l.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",p," leased"]})]})},c.slug)})})]})}const X1={"saved-view":{title:"Saved view",icon:x0,render:(e,t)=>e.kind!=="saved-view"?null:f.createElement(aL,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Ad,render:()=>f.createElement(dL)},inventories:{title:"Inventories",icon:Ld,render:()=>f.createElement(pL)}},mL={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},hL={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function gL({slot:e,onReplace:t,onRemove:n,onResize:s}){const a=e.size??"small",l=mL[a];if(e.widget===null)return r.jsx("div",{className:ke("flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",l),children:r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add widget"]})});const c=X1[e.widget.kind];if(!c)return r.jsx("div",{className:ke("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})});const u=c.icon;return r.jsxs("div",{className:ke("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",l),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(u,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(xL,{slot:e,fallback:c.title})})]}),r.jsx(Kg,{items:[{key:"replace",label:"Replace…",icon:CP,onSelect:t},{key:"size",label:"Size",icon:jP,submenu:HD.map(p=>({key:`size-${p}`,label:hL[p],active:p===a,onSelect:()=>s(p)}))},{key:"remove",label:"Remove",icon:ar,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:c.render(e.widget,{slotId:e.id,onPickAnother:t})})]})}function xL({slot:e,fallback:t}){var a,l;const n=((a=e.widget)==null?void 0:a.kind)==="saved-view"?e.widget.viewId:null,{view:s}=Go(n);return((l=e.widget)==null?void 0:l.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const yL=["agent-sessions","inventories"];function bL({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:a}=Vd();function l(c){n(c),t(!1)}return r.jsx(Gn,{open:e,onOpenChange:t,children:r.jsxs(zn,{className:"max-w-xl",children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Add a widget"}),r.jsx(es,{children:"Choose a built-in widget or one of your saved views."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:yL.map(c=>{const u=X1[c],p=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(p,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),a?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsx("ul",{className:"max-h-72 divide-y divide-border/40 overflow-auto rounded-md border border-border/60",children:s.map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))}),!a&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}function vL(){const{data:e,error:t,refetch:n}=SR(),{data:s}=U0(),{layout:a}=YD(),[l,c]=f.useState(!1),[u,p]=f.useState(null),[m,h]=f.useState(null);mo("list:overview"),Ht({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const g=f.useCallback(k=>{p(k),c(!0)},[]),y=f.useCallback(async k=>{h(null);try{await XD(k)}catch(C){h(C instanceof Error?C.message:String(C))}},[]),b=f.useCallback(k=>{if(u===null)return;const C=a.slots.map((N,T)=>T===u?{...N,widget:k}:N);p(null),y(C)},[a.slots,u,y]),E=f.useCallback(k=>{const C=a.slots.map((N,T)=>T===k?{...N,widget:null}:N);y(C)},[a.slots,y]),j=f.useCallback((k,C)=>{const N=a.slots.map((T,O)=>O===k?{...T,size:C}:T);y(N)},[a.slots,y]),w={};if(e)for(const k of Object.keys(e.segments))for(const C of e.segments[k].items)w[C.id]=C;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(OD,{hero:e.hero,itemsById:w}):t?r.jsx(jt,{error:t}):r.jsx(ht,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx($D,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:a.slots.map((k,C)=>r.jsx(gL,{slot:k,index:C,onReplace:()=>g(C),onRemove:()=>E(C),onResize:N=>j(C,N)},k.id))}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(og,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(bL,{open:l,onOpenChange:k=>{c(k),k||p(null)},onSelect:b})]})}function wL({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function jL(){const{data:e,loading:t,error:n}=U0(),{openCheatsheet:s}=po();return t?r.jsx(ht,{label:"Loading help…"}):n||!e?r.jsx(jt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",fs("Mod+k")," opens the command palette."]})]})}),r.jsx(We,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(a=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:a},a))})}),r.jsx(We,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,description:a.command.description,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(We,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(a=>r.jsx(wL,{term:a.term,description:a.description},a.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.term))})]}),r.jsx(We,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(mn,{status:a.status}),r.jsx("p",{className:"font-semibold text-foreground",children:a.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:a.useWhen})]},a.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.files.map(l=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:l},l))})]},a.label))})}),r.jsx(We,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.description})]},a.label))})})]}),r.jsx(We,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(a=>r.jsx(qu,{command:a.command,description:a.description,example:a.example},a.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(We,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(a=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.answer})]},a.question))})}),r.jsx(We,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((a,l)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:l+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:a.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:a.detail}),a.command?r.jsx(qu,{command:a.command.command,example:a.command.example}):null,a.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:a.href,children:"Open the related surface"}):null]})]})},a.title))})})]})]})}function Gg({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const tf=f.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(fo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:a=>t(a.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));tf.displayName="SearchInput";function nf({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:ke("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const kL={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},sw=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function gd({progress:e,className:t,showLegend:n=!1}){const s=Zo(),a=f.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:kL[p]??sw[c++%sw.length]}))},[s.order,e]),l=a.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:ke("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):l.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${bn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:a.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:ke("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:bn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const SL=["pending","active","blocked","failed","completed"],Yg=SL,NL=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function Q1(e){return e&&e.length>0?e:[...NL]}function CL(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[a]=s.splice(t,1),l=t<n?n-1:n;return s.splice(Math.max(0,Math.min(l,s.length)),0,a),s}const EL=220,Au=8;function Z1({anchor:e,items:t,onClose:n}){const s=f.useRef(null),[a,l]=f.useState(null);return f.useLayoutEffect(()=>{if(!e){l(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??EL,p=(c==null?void 0:c.offsetHeight)??0,m=Math.max(Au,window.innerWidth-u-Au),h=Math.max(Au,window.innerHeight-p-Au);l({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),f.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function p(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",p,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",p,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(a==null?void 0:a.left)??e.x,top:(a==null?void 0:a.top)??e.y,visibility:a?"visible":"hidden"},children:r.jsx(Wo,{delayDuration:200,children:t.map(c=>{const u=c.icon,p=ke("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:p,children:m})});return c.disabledReason?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:h}),r.jsx(gr,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:p,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:p,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const TL="__ungrouped__";function Jg({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:a="Move to workspace",description:l="Pick the workspace this item should belong to."}){const{data:c,loading:u}=oc(),[p,m]=f.useState(n),[h,g]=f.useState(!1),[y,b]=f.useState(null);f.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const E=f.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(C=>({key:C,label:C,value:C})),{key:TL,label:"Ungrouped",value:null}],[c]),j=!h&&p!==n;async function w(){if(j){g(!0),b(null);try{await s(p),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(Gn,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(zn,{children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:a}),r.jsx(es,{children:l})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&E.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(sg,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):E.map(k=>{const C=k.value===n,N=k.value===p;return r.jsxs("button",{type:"button",disabled:C||h,onClick:()=>m(k.value),className:ke("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",C?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:ke("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,C?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?r.jsx(Qr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:w,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function ow(){const{workspace:e}=$t(),t=ln(),n=Dt(),{data:s,loading:a,error:l,refetch:c}=Jo(),u=f.useRef(null);mo("list:projects");const[p,m]=f.useState(""),[h,g]=f.useState("all"),[y,b]=f.useState("all"),[E,j]=f.useState("updated"),[w,k]=gs(),C=w.get("view"),N=C==="table"||C==="kanban"?C:"cards",T=_=>{k(G=>{const A=new URLSearchParams(G);return _==="cards"?A.delete("view"):A.set("view",_),A})},[O,P]=f.useState({}),[D,L]=f.useState(null),[W,B]=f.useState(null),$=f.useMemo(()=>s?s.filter(_=>{if(e){if(e==="_ungrouped"){if(_.workspace!==null)return!1}else if(_.workspace!==e)return!1}return h!=="all"&&_.status!==h||y!=="all"&&!_.tags.includes(y)?!1:p.trim()?`${_.title} ${_.tags.join(" ")} ${_.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((_,G)=>AL(_,G,E)):[],[s,p,h,y,E,e]),K=$.map(_=>`${_.slug}:${_.status}`).join("|");f.useEffect(()=>{P(DL($))},[K,E]);const re=f.useMemo(()=>{const _=new Map($.map(G=>[G.slug,G]));return Yg.flatMap(G=>(O[G]??$.filter(z=>z.status===G).map(z=>z.slug)).map(z=>_.get(z)).filter(z=>!!z))},[$,O]),{visibleItems:I,visibleIndexByKey:H}=f.useMemo(()=>{const _=N==="kanban"?re:$,G=new Map;return _.forEach((A,z)=>G.set(A.slug,z)),{visibleItems:_,visibleIndexByKey:G}},[N,$,re]),{hotkeyRowProps:J}=ac(I,{scope:"list:projects",onOpen:_=>n(`${t}/projects/${_.slug}`)});if(Ht({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var _;return(_=u.current)==null?void 0:_.focus()}}),Ht({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),a)return r.jsx(ht,{label:"Loading projects…"});if(l||!s)return r.jsx(jt,{error:l||"Project list is unavailable."});const ne=Array.from(new Set(s.flatMap(_=>_.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(Gg,{children:[r.jsx(tf,{ref:u,value:p,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:_=>g(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:_=>b(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),ne.map(_=>r.jsx("option",{value:_,children:_},_))]}),r.jsxs("select",{value:E,onChange:_=>j(_.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(nf,{value:N,onChange:_=>T(_),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),$.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(Nt,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):N==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:$.map((_,G)=>r.jsxs(Ee,{to:`${t}/projects/${_.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...J(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:_.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",$n(_.updated)]})]}),r.jsx(mn,{status:_.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(gd,{progress:_.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:_.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:A},A))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:_.needsAttention.blockedCount+_.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:_.progress.total})]})]})]})]},_.slug))}):N==="table"?r.jsx(We,{title:`${$.length} project${$.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:$.map((_,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...J(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${_.slug}`,className:"font-semibold text-foreground hover:text-primary",children:_.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:_.tags.map(A=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:A},A))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(mn,{status:_.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(gd,{progress:_.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:_.needsAttention.blockedCount+_.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:$n(_.updated)})]},_.slug))})]})})}):r.jsx(Qd,{columns:RL,items:re,getItemId:_=>_.slug,getColumnId:_=>_.status,canDrop:({fromColumnId:_,toColumnId:G})=>({allowed:!0,reason:_===G?void 0:"This will set a manual status override on the project."}),onMove:({item:_,fromColumnId:G,toColumnId:A,fromIndex:z,toIndex:ee})=>{if(G===A){const M=O[G]??$.filter(ue=>ue.status===G).map(ue=>ue.slug);P(ue=>({...ue,[G]:CL(M,z,ee)}));return}fetch(`/api/projects/${_.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})}).then(()=>{window.location.reload()})},getExternalDragData:_=>({type:"project",id:_.slug}),onCardContextMenu:(_,G)=>{G.preventDefault(),L({project:_,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:_=>`No ${_.title.toLowerCase()} projects.`,renderCard:(_,{dragging:G})=>{const A=H.get(_.slug)??-1;return r.jsx("div",{...A>=0?J(A):{},children:r.jsx($L,{project:_,dragging:G})})}}),r.jsx(Z1,{anchor:(D==null?void 0:D.anchor)??null,items:D?[{key:"edit",label:"Edit",icon:bi,onSelect:()=>n(`${t}/projects/${D.project.slug}`)},{key:"move",label:"Move to workspace…",icon:$d,onSelect:()=>B(D.project)}]:[],onClose:()=>L(null)}),r.jsx(Jg,{open:W!==null,onOpenChange:_=>{_||B(null)},currentWorkspace:(W==null?void 0:W.workspace)??null,title:"Move project to workspace",onSubmit:async _=>{if(!W)return;const G=await fetch(`/api/projects/${encodeURIComponent(W.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:_})});if(!G.ok){const A=await G.json().catch(()=>({}));throw new Error(A.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(rg,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",N==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const PL={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},RL=Yg.map(e=>({id:e,title:PL[e],description:Zd(e)}));function AL(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return aw(t)-aw(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function aw(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function DL(e){return Object.fromEntries(Yg.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function $L({project:e,dragging:t}){const n=ln();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",$n(e.updated)]})]}),r.jsx(mn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(gd,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function xd({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:ke("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}const LL=4e3;function ta(){const[e,t]=f.useState(null),n=f.useRef(null),s=f.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),a=f.useCallback((l,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:l,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},LL)},[]);return f.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:a,dismissToast:s}}function na({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:ke("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function OL(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(Dd,{className:"h-3 w-3"}),"Archived"]})}function iw(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function IL(){const{data:e,loading:t,error:n,refetch:s}=NR(),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState({}),{toast:h,showToast:g,dismissToast:y}=ta();async function b(N,T,O){l(T),u(null);try{const P=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!P.ok){const D=await P.json().catch(()=>null);throw new Error((D==null?void 0:D.error)||`HTTP ${P.status}`)}s(),g(O,"success")}catch(P){u(P instanceof Error?P.message:"Restore failed")}finally{l(null)}}function E(N){return b(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function j(N){const T=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return b(T,`assignment:${N.id}`,"Assignment restored")}if(t)return r.jsx(ht,{label:"Loading archived content…"});if(n)return r.jsx(jt,{error:n});const w=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],C=w.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(na,{toast:h,onDismiss:y}),r.jsx(xd,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,C?r.jsx(Nt,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[w.length>0&&r.jsx(We,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:w.map(N=>{const T=p[N.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(O=>({...O,[N.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(br,{className:"h-4 w-4"}):r.jsx(f0,{className:"h-4 w-4"}),r.jsx(tg,{className:"h-4 w-4 text-muted-foreground"}),N.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${N.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>E(N),disabled:a===`project:${N.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&N.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(O=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:iw(O),className:"text-foreground hover:text-foreground/80",children:O.title}),r.jsx(mn,{status:O.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},O.id))})]},N.slug)})})}),k.length>0&&r.jsx(We,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(N=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:iw(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),r.jsx(mn,{status:N.status,showIcon:!1}),r.jsx(OL,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Lr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(N),disabled:a===`assignment:${N.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(ed,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const lw="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",cw="block min-w-0 truncate";function Xg({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:ke("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const a=`${n.system}:${n.id}`,l=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:ke(lw,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${a} in ${n.system}`,children:[r.jsx("span",{className:cw,children:a}),r.jsx(yi,{className:"h-2.5 w-2.5 shrink-0"})]},l):r.jsx("span",{className:lw,title:a,children:r.jsx("span",{className:cw,children:a})},l)})})}const ML={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function Dn({label:e,value:t,description:n,icon:s,tone:a="default",to:l}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=ke(ML[a],l?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return l?r.jsx(Ee,{to:l,className:u,children:c}):r.jsx("article",{className:u,children:c})}function uw(e){const t=_L(e),n=f.forwardRef((s,a)=>{const{children:l,...c}=s,u=f.Children.toArray(l),p=u.find(zL);if(p){const m=p.props.children,h=u.map(g=>g===p?f.Children.count(m)>1?f.Children.only(null):f.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:a,children:f.isValidElement(m)?f.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function _L(e){const t=f.forwardRef((n,s)=>{const{children:a,...l}=n;if(f.isValidElement(a)){const c=UL(a),u=BL(l,a.props);return a.type!==f.Fragment&&(u.ref=s?Fd(s,c):c),f.cloneElement(a,u)}return f.Children.count(a)>1?f.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var FL=Symbol("radix.slottable");function zL(e){return f.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===FL}function BL(e,t){const n={...t};for(const s in t){const a=e[s],l=t[s];/^on[A-Z]/.test(s)?a&&l?n[s]=(...u)=>{const p=l(...u);return a(...u),p}:a&&(n[s]=a):s==="style"?n[s]={...a,...l}:s==="className"&&(n[s]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function UL(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function VL(e){const t=e+"CollectionProvider",[n,s]=Xo(t),[a,l]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:w,children:k}=j,C=nn.useRef(null),N=nn.useRef(new Map).current;return r.jsx(a,{scope:w,itemMap:N,collectionRef:C,children:k})};c.displayName=t;const u=e+"CollectionSlot",p=uw(u),m=nn.forwardRef((j,w)=>{const{scope:k,children:C}=j,N=l(u,k),T=Fn(w,N.collectionRef);return r.jsx(p,{ref:T,children:C})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=uw(h),b=nn.forwardRef((j,w)=>{const{scope:k,children:C,...N}=j,T=nn.useRef(null),O=Fn(w,T),P=l(h,k);return nn.useEffect(()=>(P.itemMap.set(T,{ref:T,...N}),()=>void P.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:O,children:C})});b.displayName=h;function E(j){const w=l(e+"CollectionConsumer",j);return nn.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(w.itemMap.values()).sort((P,D)=>N.indexOf(P.ref.current)-N.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},E,s]}var HL=f.createContext(void 0);function eS(e){const t=f.useContext(HL);return e||t||"ltr"}var Rm="rovingFocusGroup.onEntryFocus",WL={bubbles:!1,cancelable:!0},dc="RovingFocusGroup",[Nh,tS,KL]=VL(dc),[qL,nS]=Xo(dc,[KL]),[GL,YL]=qL(dc),rS=f.forwardRef((e,t)=>r.jsx(Nh.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Nh.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(JL,{...e,ref:t})})}));rS.displayName=dc;var JL=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:a=!1,dir:l,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:p,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=f.useRef(null),b=Fn(t,y),E=eS(l),[j,w]=zd({prop:c,defaultProp:u??null,onChange:p,caller:dc}),[k,C]=f.useState(!1),N=Ko(m),T=tS(n),O=f.useRef(!1),[P,D]=f.useState(0);return f.useEffect(()=>{const L=y.current;if(L)return L.addEventListener(Rm,N),()=>L.removeEventListener(Rm,N)},[N]),r.jsx(GL,{scope:n,orientation:s,dir:E,loop:a,currentTabStopId:j,onItemFocus:f.useCallback(L=>w(L),[w]),onItemShiftTab:f.useCallback(()=>C(!0),[]),onFocusableItemAdd:f.useCallback(()=>D(L=>L+1),[]),onFocusableItemRemove:f.useCallback(()=>D(L=>L-1),[]),children:r.jsx(hn.div,{tabIndex:k||P===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:qt(e.onMouseDown,()=>{O.current=!0}),onFocus:qt(e.onFocus,L=>{const W=!O.current;if(L.target===L.currentTarget&&W&&!k){const B=new CustomEvent(Rm,WL);if(L.currentTarget.dispatchEvent(B),!B.defaultPrevented){const $=T().filter(J=>J.focusable),K=$.find(J=>J.active),re=$.find(J=>J.id===j),H=[K,re,...$].filter(Boolean).map(J=>J.ref.current);aS(H,h)}}O.current=!1}),onBlur:qt(e.onBlur,()=>C(!1))})})}),sS="RovingFocusGroupItem",oS=f.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:a=!1,tabStopId:l,children:c,...u}=e,p=ni(),m=l||p,h=YL(sS,n),g=h.currentTabStopId===m,y=tS(n),{onFocusableItemAdd:b,onFocusableItemRemove:E,currentTabStopId:j}=h;return f.useEffect(()=>{if(s)return b(),()=>E()},[s,b,E]),r.jsx(Nh.ItemSlot,{scope:n,id:m,focusable:s,active:a,children:r.jsx(hn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:qt(e.onMouseDown,w=>{s?h.onItemFocus(m):w.preventDefault()}),onFocus:qt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:qt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const k=ZL(w,h.orientation,h.dir);if(k!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let N=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const T=N.indexOf(w.currentTarget);N=h.loop?eO(N,T+1):N.slice(T+1)}setTimeout(()=>aS(N))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});oS.displayName=sS;var XL={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function QL(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ZL(e,t,n){const s=QL(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return XL[s]}function aS(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function eO(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var tO=rS,nO=oS,rf="Tabs",[rO]=Xo(rf,[nS]),iS=nS(),[sO,Qg]=rO(rf),lS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:a,defaultValue:l,orientation:c="horizontal",dir:u,activationMode:p="automatic",...m}=e,h=eS(u),[g,y]=zd({prop:s,onChange:a,defaultProp:l??"",caller:rf});return r.jsx(sO,{scope:n,baseId:ni(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:p,children:r.jsx(hn.div,{dir:h,"data-orientation":c,...m,ref:t})})});lS.displayName=rf;var cS="TabsList",uS=f.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...a}=e,l=Qg(cS,n),c=iS(n);return r.jsx(tO,{asChild:!0,...c,orientation:l.orientation,dir:l.dir,loop:s,children:r.jsx(hn.div,{role:"tablist","aria-orientation":l.orientation,...a,ref:t})})});uS.displayName=cS;var dS="TabsTrigger",fS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:a=!1,...l}=e,c=Qg(dS,n),u=iS(n),p=hS(c.baseId,s),m=gS(c.baseId,s),h=s===c.value;return r.jsx(nO,{asChild:!0,...u,focusable:!a,active:h,children:r.jsx(hn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:p,...l,ref:t,onMouseDown:qt(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:qt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:qt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!a&&g&&c.onValueChange(s)})})})});fS.displayName=dS;var pS="TabsContent",mS=f.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:a,children:l,...c}=e,u=Qg(pS,n),p=hS(u.baseId,s),m=gS(u.baseId,s),h=s===u.value,g=f.useRef(h);return f.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(Qo,{present:a||h,children:({present:y})=>r.jsx(hn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":p,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&l})})});mS.displayName=pS;function hS(e,t){return`${e}-trigger-${t}`}function gS(e,t){return`${e}-content-${t}`}var xS=lS,yS=uS,Ch=fS,Eh=mS;function Zg({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(xS,{value:e,onValueChange:t,className:s,children:[r.jsx(yS,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(a=>r.jsxs(Ch,{value:a.value,className:ke("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:a.label}),typeof a.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:a.count}):null]},a.value))}),n.map(a=>r.jsx(Eh,{value:a.value,className:"pt-3",children:a.content},a.value))]})}const oO="modulepreload",aO=function(e){return"/"+e},dw={},iO=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),p=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));a=c(n.map(m=>{if(m=aO(m),m in dw)return;dw[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":oO,h||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),h)return new Promise((b,E)=>{y.addEventListener("load",b),y.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return a.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})};function lO({definition:e,className:t,nodeRoutes:n={}}){const s=f.useRef(null),[a,l]=f.useState(null),[c,u]=f.useState(!0),p=Dt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return f.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await iO(async()=>{const{default:j}=await import("./mermaid.core-eqq1_dL_.js").then(w=>w.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:cO(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:E}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=E,uO(s.current,n,p),u(!1)}catch(y){h||(l(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),l(null),g(),()=>{h=!0}},[e,p,n,m]),a?r.jsxs("div",{className:ke("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",a]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:ke("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function cO(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),a=n("--card-foreground"),l=n("--border"),c=n("--primary"),u=n("--primary-foreground"),p=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:a,primaryBorderColor:l,secondaryColor:p,secondaryTextColor:a,secondaryBorderColor:l,tertiaryColor:p,tertiaryTextColor:m,tertiaryBorderColor:l,lineColor:e?m:l,textColor:a,mainBkg:s,nodeBkg:s,nodeTextColor:a,nodeBorder:l,clusterBkg:p,clusterBorder:l,edgeLabelBackground:s,titleColor:a,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:p,labelColor:a,errorBkgColor:h,errorTextColor:u}}function uO(e,t,n){var s;for(const a of e.querySelectorAll(".node")){const l=((s=a.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[l];if(!c)continue;a.style.cursor="pointer",a.setAttribute("role","link"),a.setAttribute("tabindex","0"),a.setAttribute("aria-label",`Open ${l}`);const u=()=>n(c);a.addEventListener("click",u),a.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),u())})}}function dO(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const fO=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pO=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mO={};function fw(e,t){return(mO.jsx?pO:fO).test(e)}const hO=/[ \t\n\f\r]/g;function gO(e){return typeof e=="object"?e.type==="text"?pw(e.value):!1:pw(e)}function pw(e){return e.replace(hO,"")===""}class fc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}fc.prototype.normal={};fc.prototype.property={};fc.prototype.space=void 0;function bS(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new fc(n,s,t)}function Th(e){return e.toLowerCase()}class ir{constructor(t,n){this.attribute=n,this.property=t}}ir.prototype.attribute="";ir.prototype.booleanish=!1;ir.prototype.boolean=!1;ir.prototype.commaOrSpaceSeparated=!1;ir.prototype.commaSeparated=!1;ir.prototype.defined=!1;ir.prototype.mustUseProperty=!1;ir.prototype.number=!1;ir.prototype.overloadedBoolean=!1;ir.prototype.property="";ir.prototype.spaceSeparated=!1;ir.prototype.space=void 0;let xO=0;const ft=ra(),fn=ra(),Ph=ra(),Te=ra(),It=ra(),li=ra(),pr=ra();function ra(){return 2**++xO}const Rh=Object.freeze(Object.defineProperty({__proto__:null,boolean:ft,booleanish:fn,commaOrSpaceSeparated:pr,commaSeparated:li,number:Te,overloadedBoolean:Ph,spaceSeparated:It},Symbol.toStringTag,{value:"Module"})),Am=Object.keys(Rh);class ex extends ir{constructor(t,n,s,a){let l=-1;if(super(t,n),mw(this,"space",a),typeof s=="number")for(;++l<Am.length;){const c=Am[l];mw(this,Am[l],(s&Rh[c])===Rh[c])}}}ex.prototype.defined=!0;function mw(e,t,n){n&&(e[t]=n)}function ki(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new ex(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Th(s)]=s,n[Th(l.attribute)]=s}return new fc(t,n,e.space)}const vS=ki({properties:{ariaActiveDescendant:null,ariaAtomic:fn,ariaAutoComplete:null,ariaBusy:fn,ariaChecked:fn,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:It,ariaCurrent:null,ariaDescribedBy:It,ariaDetails:null,ariaDisabled:fn,ariaDropEffect:It,ariaErrorMessage:null,ariaExpanded:fn,ariaFlowTo:It,ariaGrabbed:fn,ariaHasPopup:null,ariaHidden:fn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:It,ariaLevel:Te,ariaLive:null,ariaModal:fn,ariaMultiLine:fn,ariaMultiSelectable:fn,ariaOrientation:null,ariaOwns:It,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:fn,ariaReadOnly:fn,ariaRelevant:null,ariaRequired:fn,ariaRoleDescription:It,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:fn,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function wS(e,t){return t in e?e[t]:t}function jS(e,t){return wS(e,t.toLowerCase())}const yO=ki({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:li,acceptCharset:It,accessKey:It,action:null,allow:null,allowFullScreen:ft,allowPaymentRequest:ft,allowUserMedia:ft,alt:null,as:null,async:ft,autoCapitalize:null,autoComplete:It,autoFocus:ft,autoPlay:ft,blocking:It,capture:null,charSet:null,checked:ft,cite:null,className:It,cols:Te,colSpan:null,content:null,contentEditable:fn,controls:ft,controlsList:It,coords:Te|li,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ft,defer:ft,dir:null,dirName:null,disabled:ft,download:Ph,draggable:fn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ft,formTarget:null,headers:It,height:Te,hidden:Ph,high:Te,href:null,hrefLang:null,htmlFor:It,httpEquiv:It,id:null,imageSizes:null,imageSrcSet:null,inert:ft,inputMode:null,integrity:null,is:null,isMap:ft,itemId:null,itemProp:It,itemRef:It,itemScope:ft,itemType:It,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ft,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:ft,muted:ft,name:null,nonce:null,noModule:ft,noValidate:ft,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ft,optimum:Te,pattern:null,ping:It,placeholder:null,playsInline:ft,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ft,referrerPolicy:null,rel:It,required:ft,reversed:ft,rows:Te,rowSpan:Te,sandbox:It,scope:null,scoped:ft,seamless:ft,selected:ft,shadowRootClonable:ft,shadowRootDelegatesFocus:ft,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:fn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:ft,useMap:null,value:fn,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:It,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ft,declare:ft,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:ft,noHref:ft,noShade:ft,noWrap:ft,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:fn,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ft,disableRemotePlayback:ft,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:jS}),bO=ki({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pr,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:It,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:ft,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:li,g2:li,glyphName:li,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:pr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Te,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:It,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pr,rev:pr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pr,requiredFeatures:pr,requiredFonts:pr,requiredFormats:pr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:pr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pr,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:wS}),kS=ki({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),SS=ki({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:jS}),NS=ki({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),vO={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},wO=/[A-Z]/g,hw=/-[a-z]/g,jO=/^data[-\w.:]+$/i;function kO(e,t){const n=Th(t);let s=t,a=ir;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&jO.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(hw,NO);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!hw.test(l)){let c=l.replace(wO,SO);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=ex}return new a(s,t)}function SO(e){return"-"+e.toLowerCase()}function NO(e){return e.charAt(1).toUpperCase()}const CO=bS([vS,yO,kS,SS,NS],"html"),tx=bS([vS,bO,kS,SS,NS],"svg");function EO(e){return e.join(" ").trim()}var Ba={},Dm,gw;function TO(){if(gw)return Dm;gw=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,p=`
|
|
531
531
|
`,m="/",h="*",g="",y="comment",b="declaration";function E(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var C=1,N=1;function T(I){var H=I.match(t);H&&(C+=H.length);var J=I.lastIndexOf(p);N=~J?I.length-J:N+I.length}function O(){var I={line:C,column:N};return function(H){return H.position=new P(I),W(),H}}function P(I){this.start=I,this.end={line:C,column:N},this.source=k.source}P.prototype.content=w;function D(I){var H=new Error(k.source+":"+C+":"+N+": "+I);if(H.reason=I,H.filename=k.source,H.line=C,H.column=N,H.source=w,!k.silent)throw H}function L(I){var H=I.exec(w);if(H){var J=H[0];return T(J),w=w.slice(J.length),H}}function W(){L(n)}function B(I){var H;for(I=I||[];H=$();)H!==!1&&I.push(H);return I}function $(){var I=O();if(!(m!=w.charAt(0)||h!=w.charAt(1))){for(var H=2;g!=w.charAt(H)&&(h!=w.charAt(H)||m!=w.charAt(H+1));)++H;if(H+=2,g===w.charAt(H-1))return D("End of comment missing");var J=w.slice(2,H-2);return N+=2,T(J),w=w.slice(H),N+=2,I({type:y,comment:J})}}function K(){var I=O(),H=L(s);if(H){if($(),!L(a))return D("property missing ':'");var J=L(l),ne=I({type:b,property:j(H[0].replace(e,g)),value:J?j(J[0].replace(e,g)):g});return L(c),ne}}function re(){var I=[];B(I);for(var H;H=K();)H!==!1&&(I.push(H),B(I));return I}return W(),re()}function j(w){return w?w.replace(u,g):g}return Dm=E,Dm}var xw;function PO(){if(xw)return Ba;xw=1;var e=Ba&&Ba.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.default=n;const t=e(TO());function n(s,a){let l=null;if(!s||typeof s!="string")return l;const c=(0,t.default)(s),u=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:m,value:h}=p;u?a(m,h,p):h&&(l=l||{},l[m]=h)}),l}return Ba}var yl={},yw;function RO(){if(yw)return yl;yw=1,Object.defineProperty(yl,"__esModule",{value:!0}),yl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(m){return!m||n.test(m)||e.test(m)},c=function(m,h){return h.toUpperCase()},u=function(m,h){return"".concat(h,"-")},p=function(m,h){return h===void 0&&(h={}),l(m)?m:(m=m.toLowerCase(),h.reactCompat?m=m.replace(a,u):m=m.replace(s,u),m.replace(t,c))};return yl.camelCase=p,yl}var bl,bw;function AO(){if(bw)return bl;bw=1;var e=bl&&bl.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(PO()),n=RO();function s(a,l){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(u,p){u&&p&&(c[(0,n.camelCase)(u,l)]=p)}),c}return s.default=s,bl=s,bl}var DO=AO();const $O=Td(DO),CS=ES("end"),nx=ES("start");function ES(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function LO(e){const t=nx(e),n=CS(e);if(t&&n)return{start:t,end:n}}function Al(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?vw(e.position):"start"in e||"end"in e?vw(e):"line"in e||"column"in e?Ah(e):""}function Ah(e){return ww(e&&e.line)+":"+ww(e&&e.column)}function vw(e){return Ah(e&&e.start)+"-"+Ah(e&&e.end)}function ww(e){return e&&typeof e=="number"?e:1}class Un extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let a="",l={},c=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(c=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?l.ruleId=s:(l.source=s.slice(0,p),l.ruleId=s.slice(p+1))}if(!l.place&&l.ancestors&&l.ancestors){const p=l.ancestors[l.ancestors.length-1];p&&(l.place=p.position)}const u=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=u?u.line:void 0,this.name=Al(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=c&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Un.prototype.file="";Un.prototype.name="";Un.prototype.reason="";Un.prototype.message="";Un.prototype.stack="";Un.prototype.column=void 0;Un.prototype.line=void 0;Un.prototype.ancestors=void 0;Un.prototype.cause=void 0;Un.prototype.fatal=void 0;Un.prototype.place=void 0;Un.prototype.ruleId=void 0;Un.prototype.source=void 0;const rx={}.hasOwnProperty,OO=new Map,IO=/[A-Z]/g,MO=new Set(["table","tbody","thead","tfoot","tr"]),_O=new Set(["td","th"]),TS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function FO(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=qO(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=KO(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?tx:CO,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=PS(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function PS(e,t,n){if(t.type==="element")return zO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return BO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return VO(e,t,n);if(t.type==="mdxjsEsm")return UO(e,t);if(t.type==="root")return HO(e,t,n);if(t.type==="text")return WO(e,t)}function zO(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=tx,e.schema=a),e.ancestors.push(t);const l=AS(e,t.tagName,!1),c=GO(e,t);let u=ox(e,t);return MO.has(t.tagName)&&(u=u.filter(function(p){return typeof p=="string"?!gO(p):!0})),RS(e,c,l,t),sx(c,u),e.ancestors.pop(),e.schema=s,e.create(t,l,c,n)}function BO(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}ql(e,t.position)}function UO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ql(e,t.position)}function VO(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=tx,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:AS(e,t.name,!0),c=YO(e,t),u=ox(e,t);return RS(e,c,l,t),sx(c,u),e.ancestors.pop(),e.schema=s,e.create(t,l,c,n)}function HO(e,t,n){const s={};return sx(s,ox(e,t)),e.create(t,e.Fragment,s,n)}function WO(e,t){return t.value}function RS(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function sx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function KO(e,t,n){return s;function s(a,l,c,u){const m=Array.isArray(c.children)?n:t;return u?m(l,c,u):m(l,c)}}function qO(e,t){return n;function n(s,a,l,c){const u=Array.isArray(l.children),p=nx(s);return t(a,l,c,u,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function GO(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&rx.call(t.properties,a)){const l=JO(e,a,t.properties[a]);if(l){const[c,u]=l;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&_O.has(t.tagName)?s=u:n[c]=u}}if(s){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function YO(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const l=s.data.estree.body[0];l.type;const c=l.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else ql(e,t.position);else{const a=s.name;let l;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const u=s.value.data.estree.body[0];u.type,l=e.evaluater.evaluateExpression(u.expression)}else ql(e,t.position);else l=s.value===null?!0:s.value;n[a]=l}return n}function ox(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:OO;for(;++s<t.children.length;){const l=t.children[s];let c;if(e.passKeys){const p=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(p){const m=a.get(p)||0;c=p+"-"+m,a.set(p,m+1)}}const u=PS(e,l,c);u!==void 0&&n.push(u)}return n}function JO(e,t,n){const s=kO(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?dO(n):EO(n)),s.property==="style"){let a=typeof n=="object"?n:XO(e,String(n));return e.stylePropertyNameCase==="css"&&(a=QO(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?vO[s.property]||s.property:s.attribute,n]}}function XO(e,t){try{return $O(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,a=new Un("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=TS+"#cannot-parse-style-attribute",a}}function AS(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,c;for(;++l<a.length;){const u=fw(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(l&&u.type==="Literal"),optional:!1}:u}s=c}else s=fw(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return rx.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);ql(e)}function ql(e,t){const n=new Un("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=TS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function QO(e){const t={};let n;for(n in e)rx.call(e,n)&&(t[ZO(n)]=e[n]);return t}function ZO(e){let t=e.replace(IO,eI);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function eI(e){return"-"+e.toLowerCase()}const $m={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},tI={};function nI(e,t){const n=tI,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return DS(e,s,a)}function DS(e,t,n){if(rI(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return jw(e.children,t,n)}return Array.isArray(e)?jw(e,t,n):""}function jw(e,t,n){const s=[];let a=-1;for(;++a<e.length;)s[a]=DS(e[a],t,n);return s.join("")}function rI(e){return!!(e&&typeof e=="object")}const kw=document.createElement("i");function ax(e){const t="&"+e+";";kw.innerHTML=t;const n=kw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ms(e,t,n,s){const a=e.length;let l=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);l<s.length;)c=s.slice(l,l+1e4),c.unshift(t,0),e.splice(...c),l+=1e4,t+=1e4}function Pr(e,t){return e.length>0?(ms(e,e.length,0,t),e):t}const Sw={}.hasOwnProperty;function sI(e){const t={};let n=-1;for(;++n<e.length;)oI(t,e[n]);return t}function oI(e,t){let n;for(n in t){const a=(Sw.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let c;if(l)for(c in l){Sw.call(a,c)||(a[c]=[]);const u=l[c];aI(a[c],Array.isArray(u)?u:u?[u]:[])}}}function aI(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);ms(e,0,0,s)}function $S(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function ci(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const cs=ho(/[A-Za-z]/),xr=ho(/[\dA-Za-z]/),iI=ho(/[#-'*+\--9=?A-Z^-~]/);function Dh(e){return e!==null&&(e<32||e===127)}const $h=ho(/\d/),lI=ho(/[\dA-Fa-f]/),cI=ho(/[!-/:-@[-`{-~]/);function ot(e){return e!==null&&e<-2}function or(e){return e!==null&&(e<0||e===32)}function Tt(e){return e===-2||e===-1||e===32}const uI=ho(new RegExp("\\p{P}|\\p{S}","u")),dI=ho(/\s/);function ho(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Si(e){const t=[];let n=-1,s=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let c="";if(l===37&&xr(e.charCodeAt(n+1))&&xr(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(c=String.fromCharCode(l));else if(l>55295&&l<57344){const u=e.charCodeAt(n+1);l<56320&&u>56319&&u<57344?(c=String.fromCharCode(l,u),a=1):c="�"}else c=String.fromCharCode(l);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+a+1,c=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function Mt(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let l=0;return c;function c(p){return Tt(p)?(e.enter(n),u(p)):t(p)}function u(p){return Tt(p)&&l++<a?(e.consume(p),u):(e.exit(n),t(p))}}const fI={tokenize:pI};function pI(e){const t=e.attempt(this.parser.constructs.contentInitial,s,a);let n;return t;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Mt(e,t,"linePrefix")}function a(u){return e.enter("paragraph"),l(u)}function l(u){const p=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=p),n=p,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return ot(u)?(e.consume(u),e.exit("chunkText"),l):(e.consume(u),c)}}const mI={tokenize:hI},Nw={tokenize:gI};function hI(e){const t=this,n=[];let s=0,a,l,c;return u;function u(N){if(s<n.length){const T=n[s];return t.containerState=T[1],e.attempt(T[0].continuation,p,m)(N)}return m(N)}function p(N){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&C();const T=t.events.length;let O=T,P;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){P=t.events[O][1].end;break}k(s);let D=T;for(;D<t.events.length;)t.events[D][1].end={...P},D++;return ms(t.events,O+1,0,t.events.slice(T)),t.events.length=D,m(N)}return u(N)}function m(N){if(s===n.length){if(!a)return y(N);if(a.currentConstruct&&a.currentConstruct.concrete)return E(N);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Nw,h,g)(N)}function h(N){return a&&C(),k(s),y(N)}function g(N){return t.parser.lazy[t.now().line]=s!==n.length,c=t.now().offset,E(N)}function y(N){return t.containerState={},e.attempt(Nw,b,E)(N)}function b(N){return s++,n.push([t.currentConstruct,t.containerState]),y(N)}function E(N){if(N===null){a&&C(),k(0),e.consume(N);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),j(N)}function j(N){if(N===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(N);return}return ot(N)?(e.consume(N),w(e.exit("chunkFlow")),s=0,t.interrupt=void 0,u):(e.consume(N),j)}function w(N,T){const O=t.sliceStream(N);if(T&&O.push(null),N.previous=l,l&&(l.next=N),l=N,a.defineSkip(N.start),a.write(O),t.parser.lazy[N.start.line]){let P=a.events.length;for(;P--;)if(a.events[P][1].start.offset<c&&(!a.events[P][1].end||a.events[P][1].end.offset>c))return;const D=t.events.length;let L=D,W,B;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(W){B=t.events[L][1].end;break}W=!0}for(k(s),P=D;P<t.events.length;)t.events[P][1].end={...B},P++;ms(t.events,L+1,0,t.events.slice(D)),t.events.length=P}}function k(N){let T=n.length;for(;T-- >N;){const O=n[T];t.containerState=O[1],O[0].exit.call(t,e)}n.length=N}function C(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function gI(e,t,n){return Mt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Cw(e){if(e===null||or(e)||dI(e))return 1;if(uI(e))return 2}function ix(e,t,n){const s=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!s.includes(l)&&(t=l(t,n),s.push(l))}return t}const Lh={name:"attention",resolveAll:xI,tokenize:yI};function xI(e,t){let n=-1,s,a,l,c,u,p,m,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[s][1].end},y={...e[n][1].start};Ew(g,-p),Ew(y,p),c={type:p>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},u={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},l={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[s][1].end={...c.start},e[n][1].start={...u.end},m=[],e[s][1].end.offset-e[s][1].start.offset&&(m=Pr(m,[["enter",e[s][1],t],["exit",e[s][1],t]])),m=Pr(m,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",l,t]]),m=Pr(m,ix(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),m=Pr(m,[["exit",l,t],["enter",u,t],["exit",u,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,m=Pr(m,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,ms(e,s-1,n-s+3,m),n=s+m.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function yI(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Cw(s);let l;return c;function c(p){return l=p,e.enter("attentionSequence"),u(p)}function u(p){if(p===l)return e.consume(p),u;const m=e.exit("attentionSequence"),h=Cw(p),g=!h||h===2&&a||n.includes(p),y=!a||a===2&&h||n.includes(s);return m._open=!!(l===42?g:g&&(a||!y)),m._close=!!(l===42?y:y&&(h||!g)),t(p)}}function Ew(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const bI={name:"autolink",tokenize:vI};function vI(e,t,n){let s=0;return a;function a(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(b){return cs(b)?(e.consume(b),c):b===64?n(b):m(b)}function c(b){return b===43||b===45||b===46||xr(b)?(s=1,u(b)):m(b)}function u(b){return b===58?(e.consume(b),s=0,p):(b===43||b===45||b===46||xr(b))&&s++<32?(e.consume(b),u):(s=0,m(b))}function p(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||Dh(b)?n(b):(e.consume(b),p)}function m(b){return b===64?(e.consume(b),h):iI(b)?(e.consume(b),m):n(b)}function h(b){return xr(b)?g(b):n(b)}function g(b){return b===46?(e.consume(b),s=0,h):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):y(b)}function y(b){if((b===45||xr(b))&&s++<63){const E=b===45?y:g;return e.consume(b),E}return n(b)}}const sf={partial:!0,tokenize:wI};function wI(e,t,n){return s;function s(l){return Tt(l)?Mt(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||ot(l)?t(l):n(l)}}const LS={continuation:{tokenize:kI},exit:SI,name:"blockQuote",tokenize:jI};function jI(e,t,n){const s=this;return a;function a(c){if(c===62){const u=s.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),l}return n(c)}function l(c){return Tt(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function kI(e,t,n){const s=this;return a;function a(c){return Tt(c)?Mt(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):l(c)}function l(c){return e.attempt(LS,t,n)(c)}}function SI(e){e.exit("blockQuote")}const OS={name:"characterEscape",tokenize:NI};function NI(e,t,n){return s;function s(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return cI(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const IS={name:"characterReference",tokenize:CI};function CI(e,t,n){const s=this;let a=0,l,c;return u;function u(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),p}function p(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),m):(e.enter("characterReferenceValue"),l=31,c=xr,h(g))}function m(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,c=lI,h):(e.enter("characterReferenceValue"),l=7,c=$h,h(g))}function h(g){if(g===59&&a){const y=e.exit("characterReferenceValue");return c===xr&&!ax(s.sliceSerialize(y))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&a++<l?(e.consume(g),h):n(g)}}const Tw={partial:!0,tokenize:TI},Pw={concrete:!0,name:"codeFenced",tokenize:EI};function EI(e,t,n){const s=this,a={partial:!0,tokenize:O};let l=0,c=0,u;return p;function p(P){return m(P)}function m(P){const D=s.events[s.events.length-1];return l=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,u=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(P)}function h(P){return P===u?(c++,e.consume(P),h):c<3?n(P):(e.exit("codeFencedFenceSequence"),Tt(P)?Mt(e,g,"whitespace")(P):g(P))}function g(P){return P===null||ot(P)?(e.exit("codeFencedFence"),s.interrupt?t(P):e.check(Tw,j,T)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(P))}function y(P){return P===null||ot(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(P)):Tt(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mt(e,b,"whitespace")(P)):P===96&&P===u?n(P):(e.consume(P),y)}function b(P){return P===null||ot(P)?g(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(P))}function E(P){return P===null||ot(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(P)):P===96&&P===u?n(P):(e.consume(P),E)}function j(P){return e.attempt(a,T,w)(P)}function w(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),k}function k(P){return l>0&&Tt(P)?Mt(e,C,"linePrefix",l+1)(P):C(P)}function C(P){return P===null||ot(P)?e.check(Tw,j,T)(P):(e.enter("codeFlowValue"),N(P))}function N(P){return P===null||ot(P)?(e.exit("codeFlowValue"),C(P)):(e.consume(P),N)}function T(P){return e.exit("codeFenced"),t(P)}function O(P,D,L){let W=0;return B;function B(H){return P.enter("lineEnding"),P.consume(H),P.exit("lineEnding"),$}function $(H){return P.enter("codeFencedFence"),Tt(H)?Mt(P,K,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):K(H)}function K(H){return H===u?(P.enter("codeFencedFenceSequence"),re(H)):L(H)}function re(H){return H===u?(W++,P.consume(H),re):W>=c?(P.exit("codeFencedFenceSequence"),Tt(H)?Mt(P,I,"whitespace")(H):I(H)):L(H)}function I(H){return H===null||ot(H)?(P.exit("codeFencedFence"),D(H)):L(H)}}}function TI(e,t,n){const s=this;return a;function a(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l)}function l(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const Lm={name:"codeIndented",tokenize:RI},PI={partial:!0,tokenize:AI};function RI(e,t,n){const s=this;return a;function a(m){return e.enter("codeIndented"),Mt(e,l,"linePrefix",5)(m)}function l(m){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?c(m):n(m)}function c(m){return m===null?p(m):ot(m)?e.attempt(PI,c,p)(m):(e.enter("codeFlowValue"),u(m))}function u(m){return m===null||ot(m)?(e.exit("codeFlowValue"),c(m)):(e.consume(m),u)}function p(m){return e.exit("codeIndented"),t(m)}}function AI(e,t,n){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?n(c):ot(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Mt(e,l,"linePrefix",5)(c)}function l(c){const u=s.events[s.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):ot(c)?a(c):n(c)}}const DI={name:"codeText",previous:LI,resolve:$I,tokenize:OI};function $I(e){let t=e.length-4,n=3,s,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)a===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(a=s):(s===t||e[s][1].type==="lineEnding")&&(e[a][1].type="codeTextData",s!==a+2&&(e[a][1].end=e[s-1][1].end,e.splice(a+2,s-a-2),t-=s-a-2,s=a+2),a=void 0);return e}function LI(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function OI(e,t,n){let s=0,a,l;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),s++,u):(e.exit("codeTextSequence"),p(g))}function p(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),p):g===96?(l=e.enter("codeTextSequence"),a=0,h(g)):ot(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("codeTextData"),m(g))}function m(g){return g===null||g===32||g===96||ot(g)?(e.exit("codeTextData"),p(g)):(e.consume(g),m)}function h(g){return g===96?(e.consume(g),a++,h):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(l.type="codeTextData",m(g))}}class II{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&vl(this.left,s),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),vl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),vl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);vl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);vl(this.left,n.reverse())}}}function vl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function MS(e){const t={};let n=-1,s,a,l,c,u,p,m;const h=new II(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(s=h.get(n),n&&s[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,l=0,l<p.length&&p[l][1].type==="lineEndingBlank"&&(l+=2),l<p.length&&p[l][1].type==="content"))for(;++l<p.length&&p[l][1].type!=="content";)p[l][1].type==="chunkText"&&(p[l][1]._isInFirstContentOfListItem=!0,l++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,MI(h,n)),n=t[n],m=!0);else if(s[1]._container){for(l=n,a=void 0;l--;)if(c=h.get(l),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(h.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=l);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(s[1].end={...h.get(a)[1].start},u=h.slice(a,n),u.unshift(s),h.splice(a,n-a+1,u))}}return ms(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!m}function MI(e,t){const n=e.get(t)[1],s=e.get(t)[2];let a=t-1;const l=[];let c=n._tokenizer;c||(c=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,p=[],m={};let h,g,y=-1,b=n,E=0,j=0;const w=[j];for(;b;){for(;e.get(++a)[1]!==b;);l.push(a),b._tokenizer||(h=s.sliceStream(b),b.next||h.push(null),g&&c.defineSkip(b.start),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(h),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=n;++y<u.length;)u[y][0]==="exit"&&u[y-1][0]==="enter"&&u[y][1].type===u[y-1][1].type&&u[y][1].start.line!==u[y][1].end.line&&(j=y+1,w.push(j),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(c.events=[],b?(b._tokenizer=void 0,b.previous=void 0):w.pop(),y=w.length;y--;){const k=u.slice(w[y],w[y+1]),C=l.pop();p.push([C,C+k.length-1]),e.splice(C,2,k)}for(p.reverse(),y=-1;++y<p.length;)m[E+p[y][0]]=E+p[y][1],E+=p[y][1]-p[y][0]-1;return m}const _I={resolve:zI,tokenize:BI},FI={partial:!0,tokenize:UI};function zI(e){return MS(e),e}function BI(e,t){let n;return s;function s(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(u)}function a(u){return u===null?l(u):ot(u)?e.check(FI,c,l)(u):(e.consume(u),a)}function l(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function UI(e,t,n){const s=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Mt(e,l,"linePrefix")}function l(c){if(c===null||ot(c))return n(c);const u=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function _S(e,t,n,s,a,l,c,u,p){const m=p||Number.POSITIVE_INFINITY;let h=0;return g;function g(k){return k===60?(e.enter(s),e.enter(a),e.enter(l),e.consume(k),e.exit(l),y):k===null||k===32||k===41||Dh(k)?n(k):(e.enter(s),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),j(k))}function y(k){return k===62?(e.enter(l),e.consume(k),e.exit(l),e.exit(a),e.exit(s),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),b(k))}function b(k){return k===62?(e.exit("chunkString"),e.exit(u),y(k)):k===null||k===60||ot(k)?n(k):(e.consume(k),k===92?E:b)}function E(k){return k===60||k===62||k===92?(e.consume(k),b):b(k)}function j(k){return!h&&(k===null||k===41||or(k))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(s),t(k)):h<m&&k===40?(e.consume(k),h++,j):k===41?(e.consume(k),h--,j):k===null||k===32||k===40||Dh(k)?n(k):(e.consume(k),k===92?w:j)}function w(k){return k===40||k===41||k===92?(e.consume(k),j):j(k)}}function FS(e,t,n,s,a,l){const c=this;let u=0,p;return m;function m(b){return e.enter(s),e.enter(a),e.consume(b),e.exit(a),e.enter(l),h}function h(b){return u>999||b===null||b===91||b===93&&!p||b===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(b):b===93?(e.exit(l),e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):ot(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||ot(b)||u++>999?(e.exit("chunkString"),h(b)):(e.consume(b),p||(p=!Tt(b)),b===92?y:g)}function y(b){return b===91||b===92||b===93?(e.consume(b),u++,g):g(b)}}function zS(e,t,n,s,a,l){let c;return u;function u(y){return y===34||y===39||y===40?(e.enter(s),e.enter(a),e.consume(y),e.exit(a),c=y===40?41:y,p):n(y)}function p(y){return y===c?(e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):(e.enter(l),m(y))}function m(y){return y===c?(e.exit(l),p(c)):y===null?n(y):ot(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Mt(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===c||y===null||ot(y)?(e.exit("chunkString"),m(y)):(e.consume(y),y===92?g:h)}function g(y){return y===c||y===92?(e.consume(y),h):h(y)}}function Dl(e,t){let n;return s;function s(a){return ot(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):Tt(a)?Mt(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const VI={name:"definition",tokenize:WI},HI={partial:!0,tokenize:KI};function WI(e,t,n){const s=this;let a;return l;function l(b){return e.enter("definition"),c(b)}function c(b){return FS.call(s,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return a=ci(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),p):n(b)}function p(b){return or(b)?Dl(e,m)(b):m(b)}function m(b){return _S(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function h(b){return e.attempt(HI,g,g)(b)}function g(b){return Tt(b)?Mt(e,y,"whitespace")(b):y(b)}function y(b){return b===null||ot(b)?(e.exit("definition"),s.parser.defined.push(a),t(b)):n(b)}}function KI(e,t,n){return s;function s(u){return or(u)?Dl(e,a)(u):n(u)}function a(u){return zS(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function l(u){return Tt(u)?Mt(e,c,"whitespace")(u):c(u)}function c(u){return u===null||ot(u)?t(u):n(u)}}const qI={name:"hardBreakEscape",tokenize:GI};function GI(e,t,n){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return ot(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const YI={name:"headingAtx",resolve:JI,tokenize:XI};function JI(e,t){let n=e.length-2,s=3,a,l;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},l={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},ms(e,s,n-s+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function XI(e,t,n){let s=0;return a;function a(h){return e.enter("atxHeading"),l(h)}function l(h){return e.enter("atxHeadingSequence"),c(h)}function c(h){return h===35&&s++<6?(e.consume(h),c):h===null||or(h)?(e.exit("atxHeadingSequence"),u(h)):n(h)}function u(h){return h===35?(e.enter("atxHeadingSequence"),p(h)):h===null||ot(h)?(e.exit("atxHeading"),t(h)):Tt(h)?Mt(e,u,"whitespace")(h):(e.enter("atxHeadingText"),m(h))}function p(h){return h===35?(e.consume(h),p):(e.exit("atxHeadingSequence"),u(h))}function m(h){return h===null||h===35||or(h)?(e.exit("atxHeadingText"),u(h)):(e.consume(h),m)}}const QI=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rw=["pre","script","style","textarea"],ZI={concrete:!0,name:"htmlFlow",resolveTo:n5,tokenize:r5},e5={partial:!0,tokenize:o5},t5={partial:!0,tokenize:s5};function n5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function r5(e,t,n){const s=this;let a,l,c,u,p;return m;function m(M){return h(M)}function h(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),g}function g(M){return M===33?(e.consume(M),y):M===47?(e.consume(M),l=!0,j):M===63?(e.consume(M),a=3,s.interrupt?t:A):cs(M)?(e.consume(M),c=String.fromCharCode(M),w):n(M)}function y(M){return M===45?(e.consume(M),a=2,b):M===91?(e.consume(M),a=5,u=0,E):cs(M)?(e.consume(M),a=4,s.interrupt?t:A):n(M)}function b(M){return M===45?(e.consume(M),s.interrupt?t:A):n(M)}function E(M){const ue="CDATA[";return M===ue.charCodeAt(u++)?(e.consume(M),u===ue.length?s.interrupt?t:K:E):n(M)}function j(M){return cs(M)?(e.consume(M),c=String.fromCharCode(M),w):n(M)}function w(M){if(M===null||M===47||M===62||or(M)){const ue=M===47,ge=c.toLowerCase();return!ue&&!l&&Rw.includes(ge)?(a=1,s.interrupt?t(M):K(M)):QI.includes(c.toLowerCase())?(a=6,ue?(e.consume(M),k):s.interrupt?t(M):K(M)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(M):l?C(M):N(M))}return M===45||xr(M)?(e.consume(M),c+=String.fromCharCode(M),w):n(M)}function k(M){return M===62?(e.consume(M),s.interrupt?t:K):n(M)}function C(M){return Tt(M)?(e.consume(M),C):B(M)}function N(M){return M===47?(e.consume(M),B):M===58||M===95||cs(M)?(e.consume(M),T):Tt(M)?(e.consume(M),N):B(M)}function T(M){return M===45||M===46||M===58||M===95||xr(M)?(e.consume(M),T):O(M)}function O(M){return M===61?(e.consume(M),P):Tt(M)?(e.consume(M),O):N(M)}function P(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),p=M,D):Tt(M)?(e.consume(M),P):L(M)}function D(M){return M===p?(e.consume(M),p=null,W):M===null||ot(M)?n(M):(e.consume(M),D)}function L(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||or(M)?O(M):(e.consume(M),L)}function W(M){return M===47||M===62||Tt(M)?N(M):n(M)}function B(M){return M===62?(e.consume(M),$):n(M)}function $(M){return M===null||ot(M)?K(M):Tt(M)?(e.consume(M),$):n(M)}function K(M){return M===45&&a===2?(e.consume(M),J):M===60&&a===1?(e.consume(M),ne):M===62&&a===4?(e.consume(M),z):M===63&&a===3?(e.consume(M),A):M===93&&a===5?(e.consume(M),G):ot(M)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(e5,ee,re)(M)):M===null||ot(M)?(e.exit("htmlFlowData"),re(M)):(e.consume(M),K)}function re(M){return e.check(t5,I,ee)(M)}function I(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),H}function H(M){return M===null||ot(M)?re(M):(e.enter("htmlFlowData"),K(M))}function J(M){return M===45?(e.consume(M),A):K(M)}function ne(M){return M===47?(e.consume(M),c="",_):K(M)}function _(M){if(M===62){const ue=c.toLowerCase();return Rw.includes(ue)?(e.consume(M),z):K(M)}return cs(M)&&c.length<8?(e.consume(M),c+=String.fromCharCode(M),_):K(M)}function G(M){return M===93?(e.consume(M),A):K(M)}function A(M){return M===62?(e.consume(M),z):M===45&&a===2?(e.consume(M),A):K(M)}function z(M){return M===null||ot(M)?(e.exit("htmlFlowData"),ee(M)):(e.consume(M),z)}function ee(M){return e.exit("htmlFlow"),t(M)}}function s5(e,t,n){const s=this;return a;function a(c){return ot(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):n(c)}function l(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function o5(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(sf,t,n)}}const a5={name:"htmlText",tokenize:i5};function i5(e,t,n){const s=this;let a,l,c;return u;function u(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),p}function p(A){return A===33?(e.consume(A),m):A===47?(e.consume(A),O):A===63?(e.consume(A),N):cs(A)?(e.consume(A),L):n(A)}function m(A){return A===45?(e.consume(A),h):A===91?(e.consume(A),l=0,E):cs(A)?(e.consume(A),C):n(A)}function h(A){return A===45?(e.consume(A),b):n(A)}function g(A){return A===null?n(A):A===45?(e.consume(A),y):ot(A)?(c=g,ne(A)):(e.consume(A),g)}function y(A){return A===45?(e.consume(A),b):g(A)}function b(A){return A===62?J(A):A===45?y(A):g(A)}function E(A){const z="CDATA[";return A===z.charCodeAt(l++)?(e.consume(A),l===z.length?j:E):n(A)}function j(A){return A===null?n(A):A===93?(e.consume(A),w):ot(A)?(c=j,ne(A)):(e.consume(A),j)}function w(A){return A===93?(e.consume(A),k):j(A)}function k(A){return A===62?J(A):A===93?(e.consume(A),k):j(A)}function C(A){return A===null||A===62?J(A):ot(A)?(c=C,ne(A)):(e.consume(A),C)}function N(A){return A===null?n(A):A===63?(e.consume(A),T):ot(A)?(c=N,ne(A)):(e.consume(A),N)}function T(A){return A===62?J(A):N(A)}function O(A){return cs(A)?(e.consume(A),P):n(A)}function P(A){return A===45||xr(A)?(e.consume(A),P):D(A)}function D(A){return ot(A)?(c=D,ne(A)):Tt(A)?(e.consume(A),D):J(A)}function L(A){return A===45||xr(A)?(e.consume(A),L):A===47||A===62||or(A)?W(A):n(A)}function W(A){return A===47?(e.consume(A),J):A===58||A===95||cs(A)?(e.consume(A),B):ot(A)?(c=W,ne(A)):Tt(A)?(e.consume(A),W):J(A)}function B(A){return A===45||A===46||A===58||A===95||xr(A)?(e.consume(A),B):$(A)}function $(A){return A===61?(e.consume(A),K):ot(A)?(c=$,ne(A)):Tt(A)?(e.consume(A),$):W(A)}function K(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),a=A,re):ot(A)?(c=K,ne(A)):Tt(A)?(e.consume(A),K):(e.consume(A),I)}function re(A){return A===a?(e.consume(A),a=void 0,H):A===null?n(A):ot(A)?(c=re,ne(A)):(e.consume(A),re)}function I(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||or(A)?W(A):(e.consume(A),I)}function H(A){return A===47||A===62||or(A)?W(A):n(A)}function J(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function ne(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),_}function _(A){return Tt(A)?Mt(e,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):G(A)}function G(A){return e.enter("htmlTextData"),c(A)}}const lx={name:"labelEnd",resolveAll:d5,resolveTo:f5,tokenize:p5},l5={tokenize:m5},c5={tokenize:h5},u5={tokenize:g5};function d5(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",t+=a}}return e.length!==n.length&&ms(e,0,e.length,n),e}function f5(e,t){let n=e.length,s=0,a,l,c,u;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(c=n);const p={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},m={type:"label",start:{...e[l][1].start},end:{...e[c][1].end}},h={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",p,t],["enter",m,t]],u=Pr(u,e.slice(l+1,l+s+3)),u=Pr(u,[["enter",h,t]]),u=Pr(u,ix(t.parser.constructs.insideSpan.null,e.slice(l+s+4,c-3),t)),u=Pr(u,[["exit",h,t],e[c-2],e[c-1],["exit",m,t]]),u=Pr(u,e.slice(c+1)),u=Pr(u,[["exit",p,t]]),ms(e,l,e.length,u),e}function p5(e,t,n){const s=this;let a=s.events.length,l,c;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){l=s.events[a][1];break}return u;function u(y){return l?l._inactive?g(y):(c=s.parser.defined.includes(ci(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),p):n(y)}function p(y){return y===40?e.attempt(l5,h,c?h:g)(y):y===91?e.attempt(c5,h,c?m:g)(y):c?h(y):g(y)}function m(y){return e.attempt(u5,h,g)(y)}function h(y){return t(y)}function g(y){return l._balanced=!0,n(y)}}function m5(e,t,n){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),a}function a(g){return or(g)?Dl(e,l)(g):l(g)}function l(g){return g===41?h(g):_S(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return or(g)?Dl(e,p)(g):h(g)}function u(g){return n(g)}function p(g){return g===34||g===39||g===40?zS(e,m,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):h(g)}function m(g){return or(g)?Dl(e,h)(g):h(g)}function h(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function h5(e,t,n){const s=this;return a;function a(u){return FS.call(s,e,l,c,"reference","referenceMarker","referenceString")(u)}function l(u){return s.parser.defined.includes(ci(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function g5(e,t,n){return s;function s(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const x5={name:"labelStartImage",resolveAll:lx.resolveAll,tokenize:y5};function y5(e,t,n){const s=this;return a;function a(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),l}function l(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(u):t(u)}}const b5={name:"labelStartLink",resolveAll:lx.resolveAll,tokenize:v5};function v5(e,t,n){const s=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),l}function l(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):t(c)}}const Om={name:"lineEnding",tokenize:w5};function w5(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Mt(e,t,"linePrefix")}}const Ju={name:"thematicBreak",tokenize:j5};function j5(e,t,n){let s=0,a;return l;function l(m){return e.enter("thematicBreak"),c(m)}function c(m){return a=m,u(m)}function u(m){return m===a?(e.enter("thematicBreakSequence"),p(m)):s>=3&&(m===null||ot(m))?(e.exit("thematicBreak"),t(m)):n(m)}function p(m){return m===a?(e.consume(m),s++,p):(e.exit("thematicBreakSequence"),Tt(m)?Mt(e,u,"whitespace")(m):u(m))}}const nr={continuation:{tokenize:C5},exit:T5,name:"list",tokenize:N5},k5={partial:!0,tokenize:P5},S5={partial:!0,tokenize:E5};function N5(e,t,n){const s=this,a=s.events[s.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return u;function u(b){const E=s.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(E==="listUnordered"?!s.containerState.marker||b===s.containerState.marker:$h(b)){if(s.containerState.type||(s.containerState.type=E,e.enter(E,{_container:!0})),E==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Ju,n,m)(b):m(b);if(!s.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(b)}return n(b)}function p(b){return $h(b)&&++c<10?(e.consume(b),p):(!s.interrupt||c<2)&&(s.containerState.marker?b===s.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),m(b)):n(b)}function m(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||b,e.check(sf,s.interrupt?n:h,e.attempt(k5,y,g))}function h(b){return s.containerState.initialBlankLine=!0,l++,y(b)}function g(b){return Tt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),y):n(b)}function y(b){return s.containerState.size=l+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function C5(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(sf,a,l);function a(u){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Mt(e,t,"listItemIndent",s.containerState.size+1)(u)}function l(u){return s.containerState.furtherBlankLines||!Tt(u)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(u)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(S5,t,c)(u))}function c(u){return s.containerState._closeFlow=!0,s.interrupt=void 0,Mt(e,e.attempt(nr,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function E5(e,t,n){const s=this;return Mt(e,a,"listItemIndent",s.containerState.size+1);function a(l){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(l):n(l)}}function T5(e){e.exit(this.containerState.type)}function P5(e,t,n){const s=this;return Mt(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const c=s.events[s.events.length-1];return!Tt(l)&&c&&c[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Aw={name:"setextUnderline",resolveTo:R5,tokenize:A5};function R5(e,t){let n=e.length,s,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",c,t]),e.splice(l+1,0,["exit",e[s][1],t]),e[s][1].end={...e[l][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function A5(e,t,n){const s=this;let a;return l;function l(m){let h=s.events.length,g;for(;h--;)if(s.events[h][1].type!=="lineEnding"&&s.events[h][1].type!=="linePrefix"&&s.events[h][1].type!=="content"){g=s.events[h][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),a=m,c(m)):n(m)}function c(m){return e.enter("setextHeadingLineSequence"),u(m)}function u(m){return m===a?(e.consume(m),u):(e.exit("setextHeadingLineSequence"),Tt(m)?Mt(e,p,"lineSuffix")(m):p(m))}function p(m){return m===null||ot(m)?(e.exit("setextHeadingLine"),t(m)):n(m)}}const D5={tokenize:$5};function $5(e){const t=this,n=e.attempt(sf,s,e.attempt(this.parser.constructs.flowInitial,a,Mt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(_I,a)),"linePrefix")));return n;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const L5={resolveAll:US()},O5=BS("string"),I5=BS("text");function BS(e){return{resolveAll:US(e==="text"?M5:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],l=n.attempt(a,c,u);return c;function c(h){return m(h)?l(h):u(h)}function u(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),p}function p(h){return m(h)?(n.exit("data"),l(h)):(n.consume(h),p)}function m(h){if(h===null)return!0;const g=a[h];let y=-1;if(g)for(;++y<g.length;){const b=g[y];if(!b.previous||b.previous.call(s,s.previous))return!0}return!1}}}function US(e){return t;function t(n,s){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,s):n}}function M5(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],a=t.sliceStream(s);let l=a.length,c=-1,u=0,p;for(;l--;){const m=a[l];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(m===-2)p=!0,u++;else if(m!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const m={type:n===e.length||p||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?c:s.start._bufferIndex+c,_index:s.start._index+l,line:s.end.line,column:s.end.column-u,offset:s.end.offset-u},end:{...s.end}};s.end={...m.start},s.start.offset===s.end.offset?Object.assign(s,m):(e.splice(n,0,["enter",m,t],["exit",m,t]),n+=2)}n++}return e}const _5={42:nr,43:nr,45:nr,48:nr,49:nr,50:nr,51:nr,52:nr,53:nr,54:nr,55:nr,56:nr,57:nr,62:LS},F5={91:VI},z5={[-2]:Lm,[-1]:Lm,32:Lm},B5={35:YI,42:Ju,45:[Aw,Ju],60:ZI,61:Aw,95:Ju,96:Pw,126:Pw},U5={38:IS,92:OS},V5={[-5]:Om,[-4]:Om,[-3]:Om,33:x5,38:IS,42:Lh,60:[bI,a5],91:b5,92:[qI,OS],93:lx,95:Lh,96:DI},H5={null:[Lh,L5]},W5={null:[42,95]},K5={null:[]},q5=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:W5,contentInitial:F5,disable:K5,document:_5,flow:B5,flowInitial:z5,insideSpan:H5,string:U5,text:V5},Symbol.toStringTag,{value:"Module"}));function G5(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let c=[],u=[];const p={attempt:D(O),check:D(P),consume:C,enter:N,exit:T,interrupt:D(P,{interrupt:!0})},m={code:null,containerState:{},defineSkip:j,events:[],now:E,parser:e,previous:null,sliceSerialize:y,sliceStream:b,write:g};let h=t.tokenize.call(m,p);return t.resolveAll&&l.push(t),m;function g($){return c=Pr(c,$),w(),c[c.length-1]!==null?[]:(L(t,0),m.events=ix(l,m.events,m),m.events)}function y($,K){return J5(b($),K)}function b($){return Y5(c,$)}function E(){const{_bufferIndex:$,_index:K,line:re,column:I,offset:H}=s;return{_bufferIndex:$,_index:K,line:re,column:I,offset:H}}function j($){a[$.line]=$.column,B()}function w(){let $;for(;s._index<c.length;){const K=c[s._index];if(typeof K=="string")for($=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===$&&s._bufferIndex<K.length;)k(K.charCodeAt(s._bufferIndex));else k(K)}}function k($){h=h($)}function C($){ot($)?(s.line++,s.column=1,s.offset+=$===-3?2:1,B()):$!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),m.previous=$}function N($,K){const re=K||{};return re.type=$,re.start=E(),m.events.push(["enter",re,m]),u.push(re),re}function T($){const K=u.pop();return K.end=E(),m.events.push(["exit",K,m]),K}function O($,K){L($,K.from)}function P($,K){K.restore()}function D($,K){return re;function re(I,H,J){let ne,_,G,A;return Array.isArray(I)?ee(I):"tokenize"in I?ee([I]):z(I);function z(V){return ae;function ae(me){const ve=me!==null&&V[me],Se=me!==null&&V.null,he=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(Se)?Se:Se?[Se]:[]];return ee(he)(me)}}function ee(V){return ne=V,_=0,V.length===0?J:M(V[_])}function M(V){return ae;function ae(me){return A=W(),G=V,V.partial||(m.currentConstruct=V),V.name&&m.parser.constructs.disable.null.includes(V.name)?ge():V.tokenize.call(K?Object.assign(Object.create(m),K):m,p,ue,ge)(me)}}function ue(V){return $(G,A),H}function ge(V){return A.restore(),++_<ne.length?M(ne[_]):J}}}function L($,K){$.resolveAll&&!l.includes($)&&l.push($),$.resolve&&ms(m.events,K,m.events.length-K,$.resolve(m.events.slice(K),m)),$.resolveTo&&(m.events=$.resolveTo(m.events,m))}function W(){const $=E(),K=m.previous,re=m.currentConstruct,I=m.events.length,H=Array.from(u);return{from:I,restore:J};function J(){s=$,m.previous=K,m.currentConstruct=re,m.events.length=I,u=H,B()}}function B(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function Y5(e,t){const n=t.start._index,s=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let c;if(n===a)c=[e[n].slice(s,l)];else{if(c=e.slice(n,a),s>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(s):c.shift()}l>0&&c.push(e[a].slice(0,l))}return c}function J5(e,t){let n=-1;const s=[];let a;for(;++n<e.length;){const l=e[n];let c;if(typeof l=="string")c=l;else switch(l){case-5:{c="\r";break}case-4:{c=`
|
|
532
532
|
`;break}case-3:{c=`\r
|
|
533
533
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(l)}a=l===-2,s.push(c)}return s.join("")}function X5(e){const s={constructs:sI([q5,...(e||{}).extensions||[]]),content:a(fI),defined:[],document:a(mI),flow:a(D5),lazy:{},string:a(O5),text:a(I5)};return s;function a(l){return c;function c(u){return G5(s,l,u)}}}function Q5(e){for(;!MS(e););return e}const Dw=/[\0\t\n\r]/g;function Z5(){let e=1,t="",n=!0,s;return a;function a(l,c,u){const p=[];let m,h,g,y,b;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(c||void 0).decode(l)),g=0,t="",n&&(l.charCodeAt(0)===65279&&g++,n=void 0);g<l.length;){if(Dw.lastIndex=g,m=Dw.exec(l),y=m&&m.index!==void 0?m.index:l.length,b=l.charCodeAt(y),!m){t=l.slice(g);break}if(b===10&&g===y&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),g<y&&(p.push(l.slice(g,y)),e+=y-g),b){case 0:{p.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,p.push(-2);e++<h;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}g=y+1}return u&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const eM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tM(e){return e.replace(eM,nM)}function nM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return $S(n.slice(l?2:1),l?16:10)}return ax(n)||e}const VS={}.hasOwnProperty;function rM(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),sM(n)(Q5(X5(n).document().write(Z5()(e,t,!0))))}function sM(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Xe),autolinkProtocol:W,autolinkEmail:W,atxHeading:l(X),blockQuote:l(Se),characterEscape:W,characterReference:W,codeFenced:l(he),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:l(he,c),codeText:l(Je,c),codeTextData:W,data:W,codeFlowValue:W,definition:l(Ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:l(at),hardBreakEscape:l(Ie),hardBreakTrailing:l(Ie),htmlFlow:l(Ne,c),htmlFlowData:W,htmlText:l(Ne,c),htmlTextData:W,image:l(Oe),label:c,link:l(Xe),listItem:l(rt),listItemValue:y,listOrdered:l(Me,g),listUnordered:l(Me),paragraph:l(Ke),reference:M,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:l(X),strong:l(xt),thematicBreak:l(it)},exit:{atxHeading:p(),atxHeadingSequence:O,autolink:p(),autolinkEmail:ve,autolinkProtocol:me,blockQuote:p(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:V,characterReference:ae,codeFenced:p(w),codeFencedFence:j,codeFencedFenceInfo:b,codeFencedFenceMeta:E,codeFlowValue:B,codeIndented:p(k),codeText:p(H),codeTextData:B,data:B,definition:p(),definitionDestinationString:T,definitionLabelString:C,definitionTitleString:N,emphasis:p(),hardBreakEscape:p(K),hardBreakTrailing:p(K),htmlFlow:p(re),htmlFlowData:B,htmlText:p(I),htmlTextData:B,image:p(ne),label:G,labelText:_,lineEnding:$,link:p(J),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:ue,resourceDestinationString:A,resourceTitleString:z,resource:ee,setextHeading:p(L),setextHeadingLineSequence:D,setextHeadingText:P,strong:p(),thematicBreak:p()}};HS(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(ie){let Y={type:"root",children:[]};const fe={stack:[Y],tokenStack:[],config:t,enter:u,exit:m,buffer:c,resume:h,data:n},Z=[];let ye=-1;for(;++ye<ie.length;)if(ie[ye][1].type==="listOrdered"||ie[ye][1].type==="listUnordered")if(ie[ye][0]==="enter")Z.push(ye);else{const Re=Z.pop();ye=a(ie,Re,ye)}for(ye=-1;++ye<ie.length;){const Re=t[ie[ye][0]];VS.call(Re,ie[ye][1].type)&&Re[ie[ye][1].type].call(Object.assign({sliceSerialize:ie[ye][2].sliceSerialize},fe),ie[ye][1])}if(fe.tokenStack.length>0){const Re=fe.tokenStack[fe.tokenStack.length-1];(Re[1]||$w).call(fe,void 0,Re[0])}for(Y.position={start:eo(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:eo(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},ye=-1;++ye<t.transforms.length;)Y=t.transforms[ye](Y)||Y;return Y}function a(ie,Y,fe){let Z=Y-1,ye=-1,Re=!1,ct,te,be,Le;for(;++Z<=fe;){const lt=ie[Z];switch(lt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{lt[0]==="enter"?ye++:ye--,Le=void 0;break}case"lineEndingBlank":{lt[0]==="enter"&&(ct&&!Le&&!ye&&!be&&(be=Z),Le=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Le=void 0}if(!ye&<[0]==="enter"&<[1].type==="listItemPrefix"||ye===-1&<[0]==="exit"&&(lt[1].type==="listUnordered"||lt[1].type==="listOrdered")){if(ct){let _e=Z;for(te=void 0;_e--;){const vt=ie[_e];if(vt[1].type==="lineEnding"||vt[1].type==="lineEndingBlank"){if(vt[0]==="exit")continue;te&&(ie[te][1].type="lineEndingBlank",Re=!0),vt[1].type="lineEnding",te=_e}else if(!(vt[1].type==="linePrefix"||vt[1].type==="blockQuotePrefix"||vt[1].type==="blockQuotePrefixWhitespace"||vt[1].type==="blockQuoteMarker"||vt[1].type==="listItemIndent"))break}be&&(!te||be<te)&&(ct._spread=!0),ct.end=Object.assign({},te?ie[te][1].start:lt[1].end),ie.splice(te||Z,0,["exit",ct,lt[2]]),Z++,fe++}if(lt[1].type==="listItemPrefix"){const _e={type:"listItem",_spread:!1,start:Object.assign({},lt[1].start),end:void 0};ct=_e,ie.splice(Z,0,["enter",_e,lt[2]]),Z++,fe++,be=void 0,Le=!0}}}return ie[Y][1]._spread=Re,fe}function l(ie,Y){return fe;function fe(Z){u.call(this,ie(Z),Z),Y&&Y.call(this,Z)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(ie,Y,fe){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([Y,fe||void 0]),ie.position={start:eo(Y.start),end:void 0}}function p(ie){return Y;function Y(fe){ie&&ie.call(this,fe),m.call(this,fe)}}function m(ie,Y){const fe=this.stack.pop(),Z=this.tokenStack.pop();if(Z)Z[0].type!==ie.type&&(Y?Y.call(this,ie,Z[0]):(Z[1]||$w).call(this,ie,Z[0]));else throw new Error("Cannot close `"+ie.type+"` ("+Al({start:ie.start,end:ie.end})+"): it’s not open");fe.position.end=eo(ie.end)}function h(){return nI(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function y(ie){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function b(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=ie}function E(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=ie}function j(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie.replace(/(\r?\n|\r)$/g,"")}function C(ie){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=ci(this.sliceSerialize(ie)).toLowerCase()}function N(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.title=ie}function T(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.url=ie}function O(ie){const Y=this.stack[this.stack.length-1];if(!Y.depth){const fe=this.sliceSerialize(ie).length;Y.depth=fe}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function D(ie){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function W(ie){const fe=this.stack[this.stack.length-1].children;let Z=fe[fe.length-1];(!Z||Z.type!=="text")&&(Z=Pt(),Z.position={start:eo(ie.start),end:void 0},fe.push(Z)),this.stack.push(Z)}function B(ie){const Y=this.stack.pop();Y.value+=this.sliceSerialize(ie),Y.position.end=eo(ie.end)}function $(ie){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=Y.children[Y.children.length-1];fe.position.end=eo(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(W.call(this,ie),B.call(this,ie))}function K(){this.data.atHardBreak=!0}function re(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function I(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function H(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.value=ie}function J(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Y,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function ne(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=Y,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function _(ie){const Y=this.sliceSerialize(ie),fe=this.stack[this.stack.length-2];fe.label=tM(Y),fe.identifier=ci(Y).toLowerCase()}function G(){const ie=this.stack[this.stack.length-1],Y=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const Z=ie.children;fe.children=Z}else fe.alt=Y}function A(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.url=ie}function z(){const ie=this.resume(),Y=this.stack[this.stack.length-1];Y.title=ie}function ee(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function ue(ie){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=ci(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function ge(ie){this.data.characterReferenceType=ie.type}function V(ie){const Y=this.sliceSerialize(ie),fe=this.data.characterReferenceType;let Z;fe?(Z=$S(Y,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=ax(Y);const ye=this.stack[this.stack.length-1];ye.value+=Z}function ae(ie){const Y=this.stack.pop();Y.position.end=eo(ie.end)}function me(ie){B.call(this,ie);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(ie)}function ve(ie){B.call(this,ie);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(ie)}function Se(){return{type:"blockquote",children:[]}}function he(){return{type:"code",lang:null,meta:null,value:""}}function Je(){return{type:"inlineCode",value:""}}function Ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function at(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function Ie(){return{type:"break"}}function Ne(){return{type:"html",value:""}}function Oe(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function Me(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function rt(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function Ke(){return{type:"paragraph",children:[]}}function xt(){return{type:"strong",children:[]}}function Pt(){return{type:"text",value:""}}function it(){return{type:"thematicBreak"}}}function eo(e){return{line:e.line,column:e.column,offset:e.offset}}function HS(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?HS(e,s):oM(e,s)}}function oM(e,t){let n;for(n in t)if(VS.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function $w(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Al({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Al({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Al({start:t.start,end:t.end})+") is still open")}function aM(e){const t=this;t.parser=n;function n(s){return rM(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function iM(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function lM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -541,7 +541,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
541
541
|
`}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
542
542
|
`}),n}function Bw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Uw(e,t){const n=JM(e,t),s=n.one(e,void 0),a=FM(n),l=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
|
|
543
543
|
`},a),l}function t_(e,t){return e&&"run"in e?async function(n,s){const a=Uw(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Uw(n,{file:s,...e||t})}}function Vw(e){if(e)throw e}var Im,Hw;function n_(){if(Hw)return Im;Hw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},l=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var h=e.call(m,"constructor"),g=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!h&&!g)return!1;var y;for(y in m);return typeof y>"u"||e.call(m,y)},c=function(m,h){n&&h.name==="__proto__"?n(m,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):m[h.name]=h.newValue},u=function(m,h){if(h==="__proto__")if(e.call(m,h)){if(s)return s(m,h).value}else return;return m[h]};return Im=function p(){var m,h,g,y,b,E,j=arguments[0],w=1,k=arguments.length,C=!1;for(typeof j=="boolean"&&(C=j,j=arguments[1]||{},w=2),(j==null||typeof j!="object"&&typeof j!="function")&&(j={});w<k;++w)if(m=arguments[w],m!=null)for(h in m)g=u(j,h),y=u(m,h),j!==y&&(C&&y&&(l(y)||(b=a(y)))?(b?(b=!1,E=g&&a(g)?g:[]):E=g&&l(g)?g:{},c(j,{name:h,newValue:p(C,E,y)})):typeof y<"u"&&c(j,{name:h,newValue:y}));return j},Im}var r_=n_();const Mm=Td(r_);function Ih(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function s_(){const e=[],t={run:n,use:s};return t;function n(...a){let l=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);u(null,...a);function u(p,...m){const h=e[++l];let g=-1;if(p){c(p);return}for(;++g<a.length;)(m[g]===null||m[g]===void 0)&&(m[g]=a[g]);a=m,h?o_(h,u)(...m):c(null,...m)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function o_(e,t){let n;return s;function s(...c){const u=e.length>c.length;let p;u&&c.push(a);try{p=e.apply(this,c)}catch(m){const h=m;if(u&&n)throw h;return a(h)}u||(p&&p.then&&typeof p.then=="function"?p.then(l,a):p instanceof Error?a(p):l(p))}function a(c,...u){n||(n=!0,t(c,...u))}function l(c){a(null,c)}}const is={basename:a_,dirname:i_,extname:l_,join:c_,sep:"/"};function a_(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pc(e);let n=0,s=-1,a=e.length,l;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else s<0&&(l=!0,s=a+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let c=-1,u=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(l){n=a+1;break}}else c<0&&(l=!0,c=a+1),u>-1&&(e.codePointAt(a)===t.codePointAt(u--)?u<0&&(s=a):(u=-1,s=c));return n===s?s=c:s<0&&(s=e.length),e.slice(n,s)}function i_(e){if(pc(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function l_(e){pc(e);let t=e.length,n=-1,s=0,a=-1,l=0,c;for(;t--;){const u=e.codePointAt(t);if(u===47){if(c){s=t+1;break}continue}n<0&&(c=!0,n=t+1),u===46?a<0?a=t:l!==1&&(l=1):a>-1&&(l=-1)}return a<0||n<0||l===0||l===1&&a===n-1&&a===s+1?"":e.slice(a,n)}function c_(...e){let t=-1,n;for(;++t<e.length;)pc(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":u_(n)}function u_(e){pc(e);const t=e.codePointAt(0)===47;let n=d_(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function d_(e,t){let n="",s=0,a=-1,l=0,c=-1,u,p;for(;++c<=e.length;){if(c<e.length)u=e.codePointAt(c);else{if(u===47)break;u=47}if(u===47){if(!(a===c-1||l===1))if(a!==c-1&&l===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),a=c,l=0;continue}}else if(n.length>0){n="",s=0,a=c,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(a+1,c):n=e.slice(a+1,c),s=c-a-1;a=c,l=0}else u===46&&l>-1?l++:l=-1}return n}function pc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const f_={cwd:p_};function p_(){return"/"}function Mh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function m_(e){if(typeof e=="string")e=new URL(e);else if(!Mh(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return h_(e)}function h_(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const _m=["history","path","basename","stem","extname","dirname"];class ZS{constructor(t){let n;t?Mh(t)?n={path:t}:typeof t=="string"||g_(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":f_.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<_m.length;){const l=_m[s];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)_m.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?is.basename(this.path):void 0}set basename(t){zm(t,"basename"),Fm(t,"basename"),this.path=is.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?is.dirname(this.path):void 0}set dirname(t){Ww(this.basename,"dirname"),this.path=is.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?is.extname(this.path):void 0}set extname(t){if(Fm(t,"extname"),Ww(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=is.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Mh(t)&&(t=m_(t)),zm(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?is.basename(this.path,this.extname):void 0}set stem(t){zm(t,"stem"),Fm(t,"stem"),this.path=is.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const a=this.message(t,n,s);throw a.fatal=!0,a}info(t,n,s){const a=this.message(t,n,s);return a.fatal=void 0,a}message(t,n,s){const a=new Un(t,n,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Fm(e,t){if(e&&e.includes(is.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+is.sep+"`")}function zm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ww(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function g_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const x_=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),y_={}.hasOwnProperty;class px extends x_{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=s_()}copy(){const t=new px;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Mm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Vm("data",this.frozen),this.namespace[t]=n,this):y_.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Vm("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=n.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Lu(t),s=this.parser||this.Parser;return Bm("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Bm("process",this.parser||this.Parser),Um("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,c){const u=Lu(t),p=s.parse(u);s.run(p,u,function(h,g,y){if(h||!g||!y)return m(h);const b=g,E=s.stringify(b,y);w_(E)?y.value=E:y.result=E,m(h,y)});function m(h,g){h||!g?c(h):l?l(g):n(void 0,g)}}}processSync(t){let n=!1,s;return this.freeze(),Bm("processSync",this.parser||this.Parser),Um("processSync",this.compiler||this.Compiler),this.process(t,a),qw("processSync","process",n),s;function a(l,c){n=!0,Vw(l),s=c}}run(t,n,s){Kw(t),this.freeze();const a=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?l(void 0,s):new Promise(l);function l(c,u){const p=Lu(n);a.run(t,p,m);function m(h,g,y){const b=g||t;h?u(h):c?c(b):s(void 0,b,y)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),qw("runSync","run",s),a;function l(c,u){Vw(c),a=u,s=!0}}stringify(t,n){this.freeze();const s=Lu(n),a=this.compiler||this.Compiler;return Um("stringify",a),Kw(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(Vm("use",this.frozen),t!=null)if(typeof t=="function")p(t,n);else if(typeof t=="object")Array.isArray(t)?u(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(m){if(typeof m=="function")p(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[h,...g]=m;p(h,g)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");u(m.plugins),m.settings&&(a.settings=Mm(!0,a.settings,m.settings))}function u(m){let h=-1;if(m!=null)if(Array.isArray(m))for(;++h<m.length;){const g=m[h];l(g)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function p(m,h){let g=-1,y=-1;for(;++g<s.length;)if(s[g][0]===m){y=g;break}if(y===-1)s.push([m,...h]);else if(h.length>0){let[b,...E]=h;const j=s[y][1];Ih(j)&&Ih(b)&&(b=Mm(!0,j,b)),s[y]=[m,b,...E]}}}}const b_=new px().freeze();function Bm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Um(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Vm(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Kw(e){if(!Ih(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Lu(e){return v_(e)?e:new ZS(e)}function v_(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function w_(e){return typeof e=="string"||j_(e)}function j_(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k_="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Gw=[],Yw={allowDangerousHtml:!0},S_=/^(https?|ircs?|mailto|xmpp)$/i,N_=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function C_(e){const t=E_(e),n=T_(e);return P_(t.runSync(t.parse(n),n),e)}function E_(e){const t=e.rehypePlugins||Gw,n=e.remarkPlugins||Gw,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Yw}:Yw;return b_().use(aM).use(n).use(t_,s).use(t)}function T_(e){const t=e.children||"",n=new ZS;return typeof t=="string"&&(n.value=t),n}function P_(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,c=t.skipHtml,u=t.unwrapDisallowed,p=t.urlTransform||R_;for(const h of N_)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+k_+h.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),QS(e,m),FO(e,{Fragment:r.Fragment,components:a,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function m(h,g,y){if(h.type==="raw"&&y&&typeof g=="number")return c?y.children.splice(g,1):y.children[g]={type:"text",value:h.value},g;if(h.type==="element"){let b;for(b in $m)if(Object.hasOwn($m,b)&&Object.hasOwn(h.properties,b)){const E=h.properties[b],j=$m[b];(j===null||j.includes(h.tagName))&&(h.properties[b]=p(String(E||""),b,h))}}if(h.type==="element"){let b=n?!n.includes(h.tagName):l?l.includes(h.tagName):!1;if(!b&&s&&typeof g=="number"&&(b=!s(h,g,y)),b&&y&&typeof g=="number")return u&&h.children?y.children.splice(g,1,...h.children):y.children.splice(g,1),g}}}function R_(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||s!==-1&&t>s||S_.test(e.slice(0,t))?e:""}function pn({content:e,className:t,emptyState:n="No markdown content yet."}){const s=e.replace(/<!--[\s\S]*?-->/g,"");return s.trim()?r.jsx("div",{className:ke("prose-syntaur max-w-none",t),children:r.jsx(C_,{children:s})}):r.jsx("div",{className:"rounded-md border border-dashed border-border/80 bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:n})}function Mr(e){return`/api/projects/${encodeURIComponent(e)}/todos`}function A_(e){const[t,n]=f.useState(null),[s,a]=f.useState(!0),[l,c]=f.useState(null),u=f.useCallback(async()=>{if(e)try{const p=await fetch(Mr(e));if(!p.ok)throw new Error(`HTTP ${p.status}`);n(await p.json()),c(null)}catch(p){c(p instanceof Error?p.message:"Failed to fetch todos")}finally{a(!1)}},[e]);return f.useEffect(()=>{u()},[u]),sc(p=>{p.type==="todos-updated"&&p.projectSlug===e&&u()}),{data:t,loading:s,error:l,refetch:u}}async function D_(e,t,n){await fetch(Mr(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t,tags:n})})}async function $_(e,t,n){await fetch(`${Mr(e)}/${t}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({summary:"Completed."})})}async function L_(e,t,n){await fetch(`${Mr(e)}/${t}/block`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:n})})}async function O_(e,t,n){await fetch(`${Mr(e)}/${t}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:n})})}async function I_(e,t){await fetch(`${Mr(e)}/${t}/reopen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})})}async function M_(e,t){await fetch(`${Mr(e)}/${t}`,{method:"DELETE"})}async function __(e,t,n){const s=await fetch(`${Mr(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}function eN(e,t,n){return`${Mr(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function F_(e,t,n){for(const s of n){const a=await fetch(`${Mr(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(s.name||"file"),"x-attachment-mime":s.type||"application/octet-stream"},body:s});if(!a.ok)throw new Error(await a.text().catch(()=>"")||`HTTP ${a.status}`)}}async function z_(e,t,n){const s=await fetch(eN(e,t,n),{method:"DELETE"});if(!s.ok)throw new Error(await s.text().catch(()=>"")||`HTTP ${s.status}`)}async function tN(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const s=await n.text().catch(()=>"");let a=null;try{a=s?JSON.parse(s):null}catch{}const l=(a==null?void 0:a.error)||s||`HTTP ${n.status}`,c=new Error(l);throw c.status=n.status,c}return n.json().catch(()=>({}))}async function B_(e,t){return await tN(`${Mr(e)}/promote`,t)}async function U_(e,t,n){await tN(`${Mr(e)}/${t}/move`,{to:n})}const Jw=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-status-in-progress-foreground"},{value:"completed",icon:"✓",label:"Completed",color:"text-status-completed-foreground"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-status-blocked-foreground"}];function nN({status:e,onChange:t}){const[n,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(!n)return;function c(u){a.current&&!a.current.contains(u.target)&&s(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const l=Jw.find(c=>c.value===e);return r.jsxs("div",{className:"relative",ref:a,onClick:c=>c.stopPropagation(),children:[r.jsx("button",{onClick:()=>s(!n),className:`text-lg leading-none ${l.color} hover:opacity-70 transition`,title:l.label,children:l.icon}),n&&r.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:Jw.filter(c=>c.value!==e).map(c=>r.jsxs("button",{onClick:()=>{t(c.value),s(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${c.color}`,children:[r.jsx("span",{className:"text-base leading-none",children:c.icon}),r.jsx("span",{children:c.label})]},c.value))})]})}function rN({item:e,copiedId:t,selected:n,editing:s,onBeginEdit:a,onEndEdit:l,onPatchDescription:c,onAddAttachments:u,onDeleteAttachment:p,attachmentUrl:m,onToggleSelected:h,onMoveOne:g,onStatusChange:y,onCopyId:b,onDelete:E,hotkeyRowProps:j,onDragOrigin:w,onDragStart:k,onDragEnd:C,isDragging:N}){return r.jsxs("div",{draggable:!0,"data-todo-id":e.id,...j??{},onMouseDown:w,onDragStart:T=>k(T,e.id),onDragEnd:C,className:`surface-panel flex items-start gap-3 px-3 py-2 cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${N?"opacity-50 shadow-lg":""}`,children:[r.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${e.id}`,title:"Select",checked:n,onChange:T=>h(e.id,T),onClick:T=>T.stopPropagation(),className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),r.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),r.jsx("div",{className:"mt-0.5 shrink-0",children:r.jsx(nN,{status:e.status,onChange:T=>y(e.id,T)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[r.jsx(sN,{description:e.description,status:e.status,editing:s,onBeginEdit:()=>a(e.id),onEndEdit:l,onSave:T=>c(e.id,T)}),e.tags.length>0&&r.jsx("span",{className:"text-xs text-muted-foreground",children:e.tags.map(T=>`#${T}`).join(" ")}),e.session&&r.jsxs("span",{className:"text-xs text-info-foreground/70 font-mono",children:["session:",e.session.slice(0,8)]}),r.jsx(q_,{item:e})]}),r.jsx(oN,{item:e,attachmentUrl:m,onAdd:T=>u(e.id,T),onDelete:T=>p(e.id,T)})]}),t===e.id?r.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[r.jsx(Qr,{className:"h-3 w-3"})," Copied to clipboard"]}):r.jsxs(r.Fragment,{children:[r.jsxs("button",{"data-no-drag":!0,className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:T=>b(T,e.id),children:["t:",e.id]}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:T=>b(T,e.id),children:r.jsx(rd,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Move to...",onClick:T=>g(e.id,T),children:r.jsx($d,{className:"h-3 w-3"})}),r.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-destructive transition",title:"Delete todo",onClick:T=>E(T,e.id,e.description),children:r.jsx(ar,{className:"h-3 w-3"})})]})]})}function sN({description:e,status:t,editing:n,onBeginEdit:s,onEndEdit:a,onSave:l}){return n?r.jsx(V_,{initialValue:e,onSave:l,onExit:a}):r.jsx("button",{type:"button","data-no-drag":!0,onClick:c=>{c.stopPropagation(),s()},title:"Click to edit",className:ke("text-left text-sm rounded-sm transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",t==="completed"?"line-through text-muted-foreground":"text-foreground"),children:e})}function V_({initialValue:e,onSave:t,onExit:n}){const s=f.useRef(e),[a,l]=f.useState(e),[c,u]=f.useState(!1),[p,m]=f.useState(!1),h=f.useRef(null),g=f.useRef(!1);f.useEffect(()=>{const j=h.current;j&&(j.focus(),j.select())},[]);const y=f.useCallback(()=>{var j;m(!0),window.setTimeout(()=>m(!1),260),(j=h.current)==null||j.focus()},[]),b=f.useCallback(async()=>{if(g.current)return;const j=a.trim();if(j.length===0){y();return}if(j===s.current){n();return}g.current=!0,u(!0);try{await t(j)}catch{}finally{u(!1),n()}},[a,n,t,y]);function E(j){j.key==="Enter"?(j.preventDefault(),b()):j.key==="Escape"&&(j.preventDefault(),g.current=!0,n())}return r.jsx("input",{ref:h,type:"text","data-no-drag":!0,disabled:c,value:a,onClick:j=>j.stopPropagation(),onChange:j=>l(j.target.value),onKeyDown:E,onBlur:()=>void b(),className:ke("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-sm text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",p&&"syntaur-input-shake",c&&"opacity-70")})}function H_(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function W_(e){const t=e.clipboardData,n=[];if(t.files&&t.files.length&&n.push(...Array.from(t.files)),!n.length&&t.items){for(const s of Array.from(t.items))if(s.kind==="file"){const a=s.getAsFile();a&&n.push(a)}}return n}function oN({item:e,attachmentUrl:t,onAdd:n,onDelete:s}){const a=e.attachments??[],[l,c]=f.useState(!1),[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null);f.useEffect(()=>{var y;l&&((y=h.current)==null||y.focus())},[l]);const g=f.useCallback(async y=>{if(y.length){p(!0);try{await n(y),c(!1)}finally{p(!1)}}},[n]);return r.jsxs("div",{className:"mt-1","data-no-drag":!0,onClick:y=>y.stopPropagation(),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.map(y=>r.jsx(K_,{att:y,url:t(e.id,y.id),onDelete:()=>void s(y.id)},y.id)),r.jsxs("button",{type:"button","data-no-drag":!0,title:"Attach files",onClick:()=>c(y=>!y),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground hover:border-border transition",children:[r.jsx(y0,{className:"h-3 w-3"}),a.length===0?"Attach":""]})]}),l&&r.jsxs("div",{ref:h,"data-no-drag":!0,tabIndex:0,role:"button","aria-label":"Add attachments: drop, paste, or click",onPaste:y=>{const b=W_(y);b.length&&(y.preventDefault(),g(b))},onDragOver:y=>{Array.from(y.dataTransfer.types).includes("Files")&&y.preventDefault()},onDrop:y=>{const b=Array.from(y.dataTransfer.files);b.length&&(y.preventDefault(),g(b))},onClick:()=>{var y;return(y=m.current)==null?void 0:y.click()},className:"mt-1 cursor-pointer rounded-md border border-dashed border-border/70 px-3 py-2 text-xs text-muted-foreground hover:border-border focus:outline-none focus:ring-2 focus:ring-ring/40",children:[u?"Uploading…":"Drop, paste (⌘V / Ctrl+V), or click to add files",r.jsx("input",{ref:m,type:"file",multiple:!0,className:"hidden",onChange:y=>{const b=Array.from(y.target.files??[]);y.target.value="",g(b)}})]})]})}function K_({att:e,url:t,onDelete:n}){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/60 bg-background px-1.5 py-0.5 text-xs",children:[H_(e.mime)?r.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:e.filename,children:r.jsx("img",{src:t,alt:e.filename,className:"h-6 w-6 rounded object-cover"})}):r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-foreground hover:text-primary",children:[r.jsx(y0,{className:"h-3 w-3"}),r.jsx("span",{className:"block max-w-[160px] truncate",children:e.filename})]}),r.jsx("button",{type:"button",title:"Remove attachment",onClick:n,className:"text-muted-foreground/60 hover:text-destructive transition",children:r.jsx(lg,{className:"h-3 w-3"})})]})}function q_({item:e}){return!(e.branch||e.planDir||e.worktreePath||e.createdAt||e.updatedAt)?null:r.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[e.branch?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-info-foreground/30 bg-info/30 px-1.5 py-0.5 text-[10px] font-mono text-info-foreground",children:[r.jsx(ng,{className:"h-2.5 w-2.5"}),r.jsx("span",{className:"block min-w-0 max-w-[120px] truncate",children:e.branch})]})}),r.jsx(gr,{children:e.branch})]})}):null,e.planDir?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("button",{type:"button","data-no-drag":!0,onClick:n=>{n.stopPropagation(),navigator.clipboard.writeText(e.planDir)},className:"inline-flex items-center rounded-full border border-status-completed-foreground/40 bg-status-completed/30 p-1 text-status-completed-foreground hover:bg-status-completed/50","aria-label":"Copy plan directory path",children:r.jsx(h0,{className:"h-2.5 w-2.5"})})}),r.jsxs(gr,{children:["Plan: ",e.planDir]})]})}):null,e.worktreePath||e.createdAt||e.updatedAt?r.jsx(Wo,{delayDuration:120,children:r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{className:"text-[10px] text-muted-foreground/60 cursor-default",children:"·"})}),r.jsx(gr,{children:r.jsxs("div",{className:"space-y-0.5 text-xs font-mono",children:[e.worktreePath?r.jsxs("div",{children:["worktree: ",e.worktreePath]}):null,e.createdAt?r.jsxs("div",{children:["created: ",e.createdAt]}):null,e.updatedAt?r.jsxs("div",{children:["updated: ",e.updatedAt]}):null]})})]})}):null]})}const aN="__one_off__";function mx({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a,defaultProject:l,defaultTitle:c,allowOneOff:u=!0}){const[p,m]=f.useState("new"),[h,g]=f.useState(!1),[y,b]=f.useState(null),[E,j]=f.useState(null),[w,k]=f.useState(null),[C,N]=f.useState(""),[T,O]=f.useState(""),[P,D]=f.useState(""),[L,W]=f.useState(""),[B,$]=f.useState(""),[K,re]=f.useState(""),[I,H]=f.useState(null),[J,ne]=f.useState(!1),_=t.length>1;f.useEffect(()=>{if(!e){m("new"),b(null),N(""),O(""),D(""),W(""),$(""),re(""),H(null);return}N(l??""),O(c??"");let ue=!1;return(async()=>{try{const ge=await fetch("/api/projects");if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();ue||j(V.filter(ae=>!ae.archived))}catch(ge){ue||k(ge instanceof Error?ge.message:String(ge))}})(),()=>{ue=!0}},[e,l,c]),f.useEffect(()=>{if(!B){H(null);return}let ue=!1;return ne(!0),(async()=>{try{const ge=await fetch(`/api/projects/${encodeURIComponent(B)}/assignments`);if(!ge.ok)throw new Error(`HTTP ${ge.status}`);const V=await ge.json();ue||H(V)}catch{ue||H([])}finally{ue||ne(!1)}})(),()=>{ue=!0}},[B]);const G=f.useMemo(()=>E??[],[E]);async function A(ue){if(ue.preventDefault(),!C){b('Pick a target project (or "One-off").');return}if(_&&!T.trim()){b("Title is required when promoting multiple todos.");return}const ge=C===aN?{oneOff:!0}:{project:C};if(n.kind==="aggregate"){const ae={groups:n.groups,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:P.trim()||void 0,priority:L||void 0};await M(ae);return}const V={todoIds:t,mode:"new-assignment",target:ge,title:T.trim()||void 0,type:P.trim()||void 0,priority:L||void 0};await ee(V)}async function z(ue){if(ue.preventDefault(),n.kind==="aggregate"){b("Existing-assignment mode does not support cross-workspace selections yet.");return}if(!B||!K){b("Pick both project and assignment.");return}const ge={todoIds:t,mode:"to-assignment",target:{assignment:`${B}/${K}`}};await ee(ge)}async function ee(ue){g(!0),b(null);try{let ge;if(n.kind==="workspace")ge=await WR(n.workspace,ue);else if(n.kind==="project")ge=await B_(n.projectId,ue);else throw new Error("Aggregate scope requires runBulkMutation.");a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}async function M(ue){g(!0),b(null);try{const ge=await KR(ue);a(ge),s(!1)}catch(ge){b(ge instanceof Error?ge.message:String(ge))}finally{g(!1)}}return r.jsx(Gn,{open:e,onOpenChange:ue=>h?void 0:s(ue),children:r.jsxs(zn,{className:"max-w-xl",children:[r.jsxs(Ir,{children:[r.jsxs(Bn,{children:["Promote ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(es,{children:["Convert the selected todo",t.length===1?"":"s"," to a new or existing assignment. Source todo",t.length===1?"":"s"," will be marked ",r.jsx("strong",{children:"in progress"})," and linked to the new assignment (auto-completed when the assignment closes)."]})]}),r.jsxs(xS,{value:p,onValueChange:ue=>m(ue),children:[r.jsxs(yS,{className:"flex gap-2 rounded-md border border-border/70 bg-card/80 p-1 mb-4",children:[r.jsx(Ch,{value:"new",className:ke("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"New assignment"}),r.jsx(Ch,{value:"existing",className:ke("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:"Existing assignment"})]}),r.jsx(Eh,{value:"new",children:r.jsxs("form",{onSubmit:A,className:"space-y-4",children:[r.jsx(Va,{label:"Target project",children:r.jsx(Xw,{value:C,onChange:N,projects:G,error:w,disabled:h,allowOneOff:u})}),r.jsx(Va,{label:_?"Title (required)":"Title (defaults to first todo)",children:r.jsx("input",{type:"text",value:T,onChange:ue=>O(ue.target.value),disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Va,{label:"Type",children:r.jsx("input",{type:"text",value:P,onChange:ue=>D(ue.target.value),placeholder:"feature",disabled:h,className:"editor-input bg-background/95 font-sans"})}),r.jsx(Va,{label:"Priority",children:r.jsxs("select",{value:L,onChange:ue=>W(ue.target.value),disabled:h,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"—"}),r.jsx("option",{value:"low",children:"low"}),r.jsx("option",{value:"medium",children:"medium"}),r.jsx("option",{value:"high",children:"high"}),r.jsx("option",{value:"critical",children:"critical"})]})})]}),y?r.jsx(Qw,{message:y}):null,r.jsx(Zw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})}),r.jsx(Eh,{value:"existing",children:r.jsxs("form",{onSubmit:z,className:"space-y-4",children:[r.jsx(Va,{label:"Project",children:r.jsx(Xw,{value:B,onChange:ue=>{$(ue),re("")},projects:G,error:w,disabled:h})}),r.jsx(Va,{label:J?"Assignment (loading...)":"Assignment",children:r.jsxs("select",{value:K,onChange:ue=>re(ue.target.value),disabled:h||!B||J,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:B?"Select assignment...":"Pick a project first"}),(I??[]).map(ue=>r.jsxs("option",{value:ue.slug,children:[ue.title," (",ue.status,")"]},ue.slug))]})}),y?r.jsx(Qw,{message:y}):null,r.jsx(Zw,{onCancel:()=>s(!1),submitting:h,submitLabel:"Promote"})]})})]})]})})}function Va({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Xw({value:e,onChange:t,projects:n,error:s,disabled:a,allowOneOff:l}){return s?r.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load projects: ",s]}):r.jsxs("select",{value:e,onChange:c=>t(c.target.value),disabled:a,className:"editor-input bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),l?r.jsx("option",{value:aN,children:"One-off (no project)"}):null,n.map(c=>r.jsxs("option",{value:c.slug,children:[c.title," (",c.slug,")"]},c.slug))]})}function Qw({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function Zw({onCancel:e,submitting:t,submitLabel:n}){return r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:e,disabled:t,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:t,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:t?"Submitting...":n})]})}function iN({open:e,selectedIds:t,scope:n,onOpenChange:s,onDone:a}){const[l,c]=f.useState("project"),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(!1),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(null);f.useEffect(()=>{if(!e){c("project"),p(""),h(""),E(null),w(null);return}let D=!1;return(async()=>{try{const L=await fetch("/api/projects");if(!L.ok)throw new Error(`HTTP ${L.status}`);const W=await L.json();D||C(W.filter(B=>!B.archived))}catch(L){D||w(L instanceof Error?L.message:String(L))}})(),()=>{D=!0}},[e]);const N=f.useMemo(()=>k?n.kind==="project"?k.filter(D=>D.slug!==n.projectId):k:[],[k,n]);function T(){if(l==="global")return{global:!0};if(l==="workspace"){const D=u.trim();return D?{workspace:D}:"Workspace name is required."}return m?{project:m}:"Pick a target project."}async function O(D,L){try{return n.kind==="workspace"?await qR(n.workspace,D,L):await U_(n.projectId,D,L),{ok:!0}}catch(W){return{ok:!1,error:W instanceof Error?W.message:String(W)}}}async function P(D){D.preventDefault(),w(null);const L=T();if(typeof L=="string"){w(L);return}y(!0),E(null);const W=[],B=[];for(const $ of t){const K=await O($,L);K.ok?W.push($):B.push({id:$,error:K.error})}y(!1),a(),B.length===0?s(!1):E({succeeded:W,failed:B})}return r.jsx(Gn,{open:e,onOpenChange:D=>g?void 0:s(D),children:r.jsx(zn,{className:"max-w-xl",children:r.jsxs("form",{onSubmit:P,className:"space-y-4",children:[r.jsxs(Ir,{children:[r.jsxs(Bn,{children:["Move ",t.length," todo",t.length===1?"":"s"]}),r.jsxs(es,{children:["Move the selected todo",t.length===1?"":"s"," to a different scope. id, tags, branch, timestamps, and plan dir are preserved."]})]}),r.jsxs("fieldset",{className:"space-y-2",disabled:g,children:[r.jsx("legend",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground mb-1",children:"Target scope"}),r.jsx(Hm,{kind:"project",checked:l==="project",onChange:()=>c("project"),label:"Project"}),r.jsx(Hm,{kind:"workspace",checked:l==="workspace",onChange:()=>c("workspace"),label:"Workspace"}),r.jsx(Hm,{kind:"global",checked:l==="global",onChange:()=>c("global"),label:"Global"})]}),l==="project"?r.jsx(ej,{label:"Target project",children:r.jsxs("select",{value:m,onChange:D=>h(D.target.value),disabled:g,className:"editor-textarea w-full bg-background/95 font-sans",children:[r.jsx("option",{value:"",children:"Select project..."}),N.map(D=>r.jsxs("option",{value:D.slug,children:[D.title," (",D.slug,")"]},D.slug))]})}):null,l==="workspace"?r.jsx(ej,{label:"Target workspace name",children:r.jsx("input",{type:"text",value:u,onChange:D=>p(D.target.value),disabled:g,placeholder:"e.g. syntaur",className:"editor-textarea w-full bg-background/95 font-sans"})}):null,j?r.jsx(G_,{message:j}):null,b?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground space-y-1",children:[r.jsxs("div",{className:"font-medium",children:["Moved ",b.succeeded.length," of ",t.length,"; ",b.failed.length," failed."]}),r.jsx("ul",{className:"text-xs space-y-0.5",children:b.failed.map(D=>r.jsxs("li",{children:["[t:",D.id,"] ",D.error]},D.id))})]}):null,r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>s(!1),disabled:g,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:b?"Close":"Cancel"}),b===null?r.jsx("button",{type:"submit",disabled:g,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:g?"Moving...":"Move"}):null]})]})})})}function ej({label:e,children:t}){return r.jsxs("label",{className:"block space-y-1.5",children:[r.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Hm({kind:e,checked:t,onChange:n,label:s}){return r.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r.jsx("input",{type:"radio",name:"move-target-kind",value:e,checked:t,onChange:n}),r.jsx("span",{children:s})]})}function G_({message:e}){return r.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function hx({label:e,count:t,expanded:n,onToggle:s,isDropTarget:a=!1,onDragOver:l,onDragLeave:c,onDrop:u,children:p}){return r.jsxs("div",{className:ke("rounded-lg border border-border/60 bg-card/40 transition",a&&"ring-2 ring-ring/30"),onDragOver:l,onDragLeave:c,onDrop:u,children:[r.jsxs("button",{type:"button",onClick:s,"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2.5 text-left",children:[r.jsx(br,{className:ke("h-4 w-4 text-muted-foreground transition-transform",!n&&"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:e}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:t})]}),n&&r.jsx("div",{className:"space-y-1 px-2 pb-2",children:p})]})}const lN=[{id:"open-blocked",label:"Open / Blocked",statuses:["open","blocked"],dropStatus:"open",defaultCollapsed:!1},{id:"in-progress",label:"In Progress",statuses:["in_progress"],dropStatus:"in_progress",defaultCollapsed:!1},{id:"done",label:"Done",statuses:["completed"],dropStatus:"completed",defaultCollapsed:!0}];function lf(e){switch(e){case"in_progress":return"in-progress";case"completed":return"done";case"open":case"blocked":default:return"open-blocked"}}function gx(e){const t={"open-blocked":[],"in-progress":[],done:[]};for(const n of e)t[lf(n.status)].push(n);return lN.map(n=>({config:n,items:t[n.id]}))}const cN="syntaur.todos.sections.collapsed.v1",tj=Object.fromEntries(lN.map(e=>[e.id,e.defaultCollapsed]));function Wm(){if(typeof window>"u"||!window.localStorage)return{};try{const e=window.localStorage.getItem(cN);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function Y_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(cN,JSON.stringify(e))}catch{}}function xx(e){const[t,n]=f.useState(()=>Wm()[e]??{});f.useEffect(()=>{n(Wm()[e]??{})},[e]);const s=f.useCallback(l=>t[l]??tj[l],[t]),a=f.useCallback(l=>{const c=Wm(),u=c[e]??{},p=u[l]??tj[l],m={...u,[l]:!p};c[e]=m,Y_(c),n(m)},[e]);return{isCollapsed:s,toggle:a}}function J_({projectId:e}){const{data:t,loading:n,error:s,refetch:a}=A_(e),[l,c]=f.useState(""),[u,p]=f.useState(""),[m,h]=f.useState(""),[g,y]=f.useState(""),[b,E]=f.useState(null),[j,w]=f.useState(null),[k,C]=f.useState(new Set),[N,T]=f.useState(!1),[O,P]=f.useState(!1),[D,L]=f.useState(null),W=f.useRef(null);mo("list:todos");const B=xx("project:"+e),[$,K]=f.useState(null),[re,I]=f.useState(null),H=f.useRef(null);function J(Y,fe){Y.stopPropagation(),navigator.clipboard.writeText(fe),E(fe),setTimeout(()=>E(Z=>Z===fe?null:Z),1500)}const ne=f.useMemo(()=>{if(!(t!=null&&t.items))return[];const Y=new Set;for(const fe of t.items)for(const Z of fe.tags)Y.add(Z);return Array.from(Y).sort()},[t]),_=f.useMemo(()=>{if(!(t!=null&&t.items))return[];let Y=t.items;if(l.trim()){const fe=l.toLowerCase();Y=Y.filter(Z=>Z.description.toLowerCase().includes(fe)||Z.tags.some(ye=>ye.toLowerCase().includes(fe))||Z.id.includes(fe))}return u&&(Y=Y.filter(fe=>fe.status===u)),m&&(Y=Y.filter(fe=>fe.tags.includes(m))),Y},[t,l,u,m]);f.useEffect(()=>{C(new Set)},[l,u,m,e]);const G=f.useMemo(()=>_.filter(Y=>k.has(Y.id)).length,[_,k]),A=_.length>0&&G===_.length,z=G>0&&!A;function ee(Y){C(fe=>{const Z=new Set(fe);return Z.has(Y)?Z.delete(Y):Z.add(Y),Z})}function M(){C(Y=>{const fe=new Set(Y);if(A)for(const Z of _)fe.delete(Z.id);else for(const Z of _)fe.add(Z.id);return fe})}function ue(){C(new Set)}const ge=D?[D]:Array.from(k);function V(){C(new Set),L(null),a()}function ae(){C(new Set),a()}async function me(){g.trim()&&(await D_(e,g.trim()),y(""),a())}async function ve(Y,fe,Z){Y.stopPropagation(),window.confirm(`Delete "${Z}"? This can't be undone.`)&&(await M_(e,fe),a())}async function Se(Y,fe){switch(fe){case"open":await I_(e,Y);break;case"in_progress":await O_(e,Y);break;case"completed":await $_(e,Y);break;case"blocked":await L_(e,Y);break}a()}async function he(Y,fe){await __(e,Y,fe),a()}async function Je(Y,fe){await F_(e,Y,fe),a()}async function Ye(Y,fe){await z_(e,Y,fe),a()}const at=gx(_),X=at.filter(Y=>!B.isCollapsed(Y.config.id)).flatMap(Y=>Y.items),{hotkeyRowProps:Ie}=ac(X,{scope:"list:todos",bindO:!1,onOpen:Y=>w(Y.id)});Ht({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var Y;return(Y=W.current)==null?void 0:Y.focus()}}),Ht({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>a()});const[Ne,Oe]=gs(),Xe=Ne.get("focus");f.useEffect(()=>{if(!Xe||!(t!=null&&t.items))return;const Y=t.items.find(Z=>Z.id===Xe);if(!Y)return;const fe=lf(Y.status);B.isCollapsed(fe)&&B.toggle(fe)},[Xe,t==null?void 0:t.items]),f.useEffect(()=>{if(!Xe)return;const Y=document.querySelector(`[data-todo-id="${window.CSS.escape(Xe)}"]`);if(!Y)return;Y.scrollIntoView({block:"nearest"}),Y.classList.add("ring-2","ring-primary/60");const fe=window.setTimeout(()=>{Y.classList.remove("ring-2","ring-primary/60"),Oe(Z=>{const ye=new URLSearchParams(Z);return ye.delete("focus"),ye},{replace:!0})},1500);return()=>window.clearTimeout(fe)},[Xe,X.length,Oe]);const Me=$?(t==null?void 0:t.items.find(Y=>Y.id===$))??null:null;function rt(Y,fe){const Z=H.current;if(Z!=null&&Z.closest(mi)){Y.preventDefault();return}Y.dataTransfer.effectAllowed="move",Y.dataTransfer.setData("text/plain",fe),K(fe)}function Ke(){K(null),I(null)}function xt(Y,fe){!Me||fe.statuses.includes(Me.status)||(Y.preventDefault(),Y.dataTransfer.dropEffect="move",I(fe.id))}function Pt(Y,fe){re===fe.id&&!Y.currentTarget.contains(Y.relatedTarget)&&I(null)}function it(Y,fe){Y.preventDefault();const Z=Me;Ke(),!(!Z||fe.statuses.includes(Z.status))&&Se(Z.id,fe.dropStatus)}if(n)return r.jsx(ht,{label:"Loading todos..."});if(s)return r.jsx(jt,{error:s});const ie=(t==null?void 0:t.counts)||{open:0,in_progress:0,blocked:0,total:0};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[r.jsx(Dn,{label:"Open",value:ie.open,icon:Dr}),r.jsx(Dn,{label:"In Progress",value:ie.in_progress,icon:Dr,tone:"info"}),r.jsx(Dn,{label:"Blocked",value:ie.blocked,icon:ig,tone:"warn"}),r.jsx(Dn,{label:"Total",value:ie.total,icon:Dr})]}),r.jsx("div",{className:"surface-panel p-3",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",placeholder:"Add a todo...",value:g,onChange:Y=>y(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&me(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),r.jsxs("button",{onClick:me,disabled:!g.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[r.jsx(rn,{className:"h-4 w-4"}),"Add"]})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(fo,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx("input",{ref:W,type:"text",placeholder:"Search...",value:l,onChange:Y=>c(Y.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),r.jsxs("select",{value:u,onChange:Y=>p(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All statuses"}),r.jsx("option",{value:"open",children:"Open"}),r.jsx("option",{value:"in_progress",children:"In Progress"}),r.jsx("option",{value:"completed",children:"Completed"}),r.jsx("option",{value:"blocked",children:"Blocked"})]}),ne.length>0&&r.jsxs("select",{value:m,onChange:Y=>h(Y.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[r.jsx("option",{value:"",children:"All tags"}),ne.map(Y=>r.jsxs("option",{value:Y,children:["#",Y]},Y))]})]}),k.size>0?r.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[r.jsxs("span",{className:"text-sm font-medium",children:[k.size," selected"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>T(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),r.jsx("button",{type:"button",onClick:()=>{L(null),P(!0)},className:"shell-action",children:"Move to…"}),r.jsx("button",{type:"button",onClick:ue,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,_.length>0&&r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[r.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:A,ref:Y=>{Y&&(Y.indeterminate=z)},onChange:M,className:"h-4 w-4 cursor-pointer accent-foreground"}),r.jsxs("span",{children:["Select all in current filter (",_.length,")"]})]}),r.jsx("div",{className:"space-y-3",children:(()=>{let Y=-1;return at.map(({config:fe,items:Z})=>{const ye=!B.isCollapsed(fe.id);return r.jsx(hx,{label:fe.label,count:Z.length,expanded:ye,onToggle:()=>B.toggle(fe.id),isDropTarget:re===fe.id,onDragOver:Re=>xt(Re,fe),onDragLeave:Re=>Pt(Re,fe),onDrop:Re=>it(Re,fe),children:ye&&Z.map(Re=>(Y+=1,r.jsx(rN,{item:Re,copiedId:b,selected:k.has(Re.id),editing:j===Re.id,onBeginEdit:ct=>w(ct),onEndEdit:()=>w(null),onPatchDescription:he,onAddAttachments:Je,onDeleteAttachment:Ye,attachmentUrl:(ct,te)=>eN(e,ct,te),onToggleSelected:ct=>ee(ct),onMoveOne:(ct,te)=>{te.stopPropagation(),L(ct),P(!0)},onStatusChange:Se,onCopyId:J,onDelete:ve,hotkeyRowProps:Ie(Y),onDragOrigin:ct=>{H.current=ct.target},onDragStart:rt,onDragEnd:Ke,isDragging:$===Re.id},Re.id)))},fe.id)})})()}),r.jsx(mx,{open:N,selectedIds:Array.from(k),scope:{kind:"project",projectId:e},onOpenChange:T,onDone:ae}),r.jsx(iN,{open:O,selectedIds:ge,scope:{kind:"project",projectId:e},onOpenChange:Y=>{P(Y),Y||L(null)},onDone:V})]})}const X_={title:"Assignment",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},nj=new Set(["title"]);function uN({visibility:e,onChange:t}){const[n,s]=f.useState(!1);function a(c){if(nj.has(c))return;const p=e.hidden.includes(c)?e.hidden.filter(m=>m!==c):[...e.hidden,c];t({hidden:p})}const l=e.hidden.length;return r.jsxs(Gn,{open:n,onOpenChange:s,children:[r.jsx(M3,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Show or hide table columns",children:[r.jsx(uP,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsxs("span",{children:["Columns",l>0?` (${Sm.length-l}/${Sm.length})`:""]})]})}),r.jsxs(zn,{className:"max-w-sm",children:[r.jsx(Ir,{children:r.jsx(Bn,{children:"Columns"})}),r.jsx("div",{className:"space-y-2",children:Sm.map(c=>{const u=e.hidden.includes(c),p=nj.has(c);return r.jsxs("label",{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${p?"opacity-60":"cursor-pointer hover:bg-background/80"}`,children:[r.jsx("input",{type:"checkbox",checked:!u,onChange:()=>a(c),disabled:p,className:"h-4 w-4 rounded border-border accent-foreground"}),r.jsx("span",{children:X_[c]}),p?r.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"always shown"}):null]},c)})})]})]})}const ui={...Vl,custom:!1},dN=`view-prefs.cache.v${Vl.version}`;let Gl=Q_(),Ha=null;const Yl=new Set;let fN=0;function yx(){return++fN}function bx(e){return e===fN}function Q_(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(dN);if(!e)return null;const t=JSON.parse(e);return t.version!==Vl.version?null:t}catch{return null}}function Z_(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(dN,JSON.stringify(e))}catch{}}function vx(e){Gl=e,Z_(e);for(const t of Yl)t(e)}function wx(e){if(!e||typeof e!="object")return ui;const t=e;return t.version!==Vl.version||!t.global||!t.projects?ui:{version:Vl.version,global:t.global,projects:t.projects,custom:t.custom===!0}}function jx(){if(Ha)return Ha;const e=yx();return Ha=fetch("/api/view-prefs").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=wx(t);return bx(e)&&vx(n),Ha=null,Gl??n}).catch(()=>(Ha=null,Gl??ui)),Ha}function pN(e){const[t,n]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let s=!1;return jx().then(a=>{s||n(a)}),Yl.add(n),()=>{s=!0,Yl.delete(n)}},[]),i1(t,e??null)}function eF(){const[e,t]=f.useState(()=>Gl??ui);return f.useEffect(()=>{let n=!1;return jx().then(s=>{n||t(s)}),Yl.add(t),()=>{n=!0,Yl.delete(t)}},[]),e}async function mN(e){const t=yx(),n=await fetch("/api/view-prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const a=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(a.error??"Failed to save view-prefs")}const s=wx(await n.json());return bx(t)&&vx(s),s}function hN(e){return mN({global:e})}function gN(e,t){return mN({projects:{[e]:t}})}async function tF(){const e=yx(),t=await fetch("/api/view-prefs",{method:"DELETE"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=wx(await t.json());return bx(e)&&vx(n),n}const rj=80;function xN({open:e,onOpenChange:t,initialName:n="",onSubmit:s,title:a="Save view"}){const[l,c]=f.useState(n),[u,p]=f.useState(!1),[m,h]=f.useState(null);f.useEffect(()=>{e&&(c(n),h(null),p(!1))},[e,n]);const g=l.trim(),y=g.length>0&&g.length<=rj;return r.jsx(Gn,{open:e,onOpenChange:t,children:r.jsx(zn,{className:"max-w-md",children:r.jsxs("form",{className:"space-y-4",onSubmit:async b=>{if(b.preventDefault(),!(!y||u)){p(!0),h(null);try{await s(g)}catch(E){h(E instanceof Error?E.message:String(E)),p(!1)}}},children:[r.jsx(Ir,{children:r.jsx(Bn,{children:a})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("input",{type:"text",value:l,autoFocus:!0,required:!0,maxLength:rj,onChange:b=>c(b.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),m?r.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:m}):null]}),r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:u,children:"Cancel"}),r.jsx("button",{type:"submit",disabled:!y||u,className:"shell-action shell-action--cta disabled:opacity-50",children:u?"Saving…":"Save"})]})]})})})}function yN({scope:e,loadedViewId:t,onApply:n,onOpenSaveDialog:s}){const{views:a,loading:l}=Vd(),[c,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{if(!c)return;function y(E){p.current&&!p.current.contains(E.target)&&u(!1)}function b(E){E.key==="Escape"&&u(!1)}return document.addEventListener("mousedown",y),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",b)}},[c]);const m=f.useMemo(()=>a.filter(y=>c1(y,e)),[a,e]),h=t?a.find(y=>y.id===t)??null:null,g=l?"Saved views…":h?h.name:"Saved views";return r.jsxs("div",{className:"relative",ref:p,children:[r.jsxs("button",{type:"button",disabled:l,onClick:()=>u(y=>!y),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":c,title:"Saved views",children:[r.jsx("span",{className:"max-w-[160px] truncate",children:g}),r.jsx(br,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),c&&r.jsx("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:m.length===0?r.jsxs("div",{className:"px-3 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"mb-2",children:"No saved views yet — Save the current view to start."}),r.jsx("button",{type:"button",onClick:()=>{u(!1),s()},className:"shell-action w-full justify-center",children:"Save current view"})]}):m.map(y=>{const b=y.id===t;return r.jsxs("button",{type:"button",onClick:()=>{u(!1),n(y)},className:ke("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",b&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:b?r.jsx(Qr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),r.jsx("span",{className:"truncate",children:y.name})]},y.id)})})]})}const nF={__unassigned__:"Unassigned",__standalone__:"No project"};function An({options:e,value:t,onChange:n,allLabel:s="Any",className:a,disabled:l,ariaLabel:c}){const[u,p]=f.useState(!1),m=f.useRef(null),h=f.useRef(null),g=f.useRef([]),y=f.useMemo(()=>{const C=new Set(e.map(T=>T.value)),N=t.filter(T=>!C.has(T)).map(T=>({value:T,label:nF[T]??T}));return[...e,...N]},[e,t]),b=f.useMemo(()=>new Set(t),[t]);f.useEffect(()=>{if(!u)return;function C(N){m.current&&!m.current.contains(N.target)&&p(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[u]),f.useEffect(()=>{var C;u&&((C=g.current[0])==null||C.focus())},[u]);const E=f.useMemo(()=>{if(t.length===0)return s;if(t.length===1){const C=y.find(N=>N.value===t[0]);return C?C.label:t[0]}return`${t.length} selected`},[t,y,s]);function j(C){n(b.has(C)?t.filter(N=>N!==C):[...t,C])}function w(C){var T;const N=Math.max(0,Math.min(C,y.length-1));(T=g.current[N])==null||T.focus()}function k(C){var P;const N=g.current,T=document.activeElement,O=N.findIndex(D=>D===T);C.key==="ArrowDown"?(C.preventDefault(),w(O<0?0:O+1)):C.key==="ArrowUp"?(C.preventDefault(),w(O<0?y.length-1:O-1)):C.key==="Home"?(C.preventDefault(),w(0)):C.key==="End"?(C.preventDefault(),w(y.length-1)):C.key==="Escape"&&(C.preventDefault(),p(!1),(P=h.current)==null||P.focus())}return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{type:"button",ref:h,disabled:l,"aria-haspopup":"menu","aria-expanded":u,"aria-label":c,onClick:()=>p(C=>!C),onKeyDown:C=>{!u&&(C.key==="ArrowDown"||C.key==="ArrowUp")&&(C.preventDefault(),p(!0))},className:ke("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",a),children:[r.jsx("span",{className:"truncate",children:E}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),u?r.jsxs("div",{role:"menu","aria-label":c,onKeyDown:k,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===y.length,onClick:()=>n(y.map(C=>C.value)),children:"Select all"}),r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),y.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):y.map((C,N)=>{const T=b.has(C.value);return r.jsxs("button",{ref:O=>{g.current[N]=O},type:"button",role:"menuitemcheckbox","aria-checked":T,tabIndex:-1,onClick:()=>j(C.value),className:ke("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",T?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:ke("flex h-4 w-4 shrink-0 items-center justify-center rounded border",T?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:T?r.jsx(Qr,{className:"h-3 w-3"}):null}),r.jsx("span",{className:"truncate",children:C.label})]},C.value)})]}):null]})}const sj={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},rF=["updated","created"];function kx({value:e,onChange:t,className:n,ariaLabel:s="Date range filter"}){const[a,l]=f.useState(!1),c=f.useRef(null),u=(e==null?void 0:e.field)??"updated",p=!!(e&&!e.preset&&(e.from||e.to)),[m,h]=f.useState(p);f.useEffect(()=>h(p),[p]),f.useEffect(()=>{if(!a)return;function k(N){c.current&&!c.current.contains(N.target)&&l(!1)}function C(N){N.key==="Escape"&&l(!1)}return document.addEventListener("mousedown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",C)}},[a]);const g=!!(e&&(e.preset||e.from||e.to)),y=f.useMemo(()=>!g||!e?"Any date":e.preset?`${u}: ${sj[e.preset]??e.preset}`:`${u}: ${e.from||"…"} → ${e.to||"…"}`,[g,e,u]);function b(k){t(e?{...e,field:k}:{field:k,preset:"",from:"",to:""})}function E(k){h(!1),t({field:u,preset:k,from:"",to:""})}function j(){h(!1),t(null)}function w(k,C){const N={field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...N,[k]:C})}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":a,"aria-label":s,onClick:()=>l(k=>!k),className:ke("editor-input inline-flex items-center justify-between gap-1.5 text-left",g&&"border-foreground/40 text-foreground",n),children:[r.jsx("span",{className:"truncate",children:y}),r.jsx(br,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),a?r.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[r.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:rF.map(k=>r.jsx("button",{type:"button","aria-pressed":u===k,onClick:()=>b(k),className:ke("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",u===k?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:k},k))}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Km,{label:"Any date",selected:!g,onClick:j}),zD.map(k=>r.jsx(Km,{label:sj[k],selected:(e==null?void 0:e.preset)===k,onClick:()=>E(k)},k)),r.jsx(Km,{label:"Custom range…",selected:m,onClick:()=>{h(!0),t({field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),m?r.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",r.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:k=>w("from",k.target.value),className:"editor-input w-40"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",r.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:k=>w("to",k.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Km({label:e,selected:t,onClick:n}){return r.jsxs("button",{type:"button",onClick:n,className:ke("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{children:e}),t?r.jsx(Qr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const sF=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search"]);function oF(e,t){const n={};for(const[s,a]of Object.entries(e))sF.has(s)||(n[s]=a);return{...n,...t}}function Sx(e,t,n){return{...e,viewMode:t.viewMode,filters:oF(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function aF(e,t){var m;const n={},s=nt(e.status);s.length&&(n.status=s);const a=nt(e.type);a.length&&(n.type=a);const l=nt(e.priority);l.length&&(n.priority=l);const c=nt(e.assignee);c.length&&(n.assignee=c);const u=nt(e.tags);if(u.length&&(n.tags=u),t&&t!=="all")n.project=[t];else{const h=nt(e.project);h.length&&(n.project=h)}e.activity&&e.activity!=="all"&&(n.activity=e.activity),e.dateRange&&(n.dateRange=e.dateRange);const p=(m=e.search)==null?void 0:m.trim();return p&&(n.search=p),n}function Jl(e){const t={viewMode:e.state.viewMode,filters:aF(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const Wa={viewMode:"kanban",sortField:"updated",sortDirection:"desc"};function bN(e,t){const{config:n}=Jl({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}});return{workspace:t,config:n}}function Xl(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function vN(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function wN(e,t){var s,a,l,c,u,p,m,h,g,y,b,E,j,w;const{config:n}=e;if((s=t.setViewMode)==null||s.call(t,n.viewMode),(a=t.setStatusFilter)==null||a.call(t,nt(n.filters.status)),(l=t.setTypeFilter)==null||l.call(t,nt(n.filters.type)),(c=t.setPriorityFilter)==null||c.call(t,nt(n.filters.priority)),(u=t.setAssigneeFilter)==null||u.call(t,nt(n.filters.assignee)),(p=t.setProjectFilter)==null||p.call(t,nt(n.filters.project)),(m=t.setTagsFilter)==null||m.call(t,nt(n.filters.tags)),(h=t.setDateRange)==null||h.call(t,vN(n.filters.dateRange)),(g=t.setSearch)==null||g.call(t,n.filters.search??""),t.setActivityFilter){const k=n.filters.activity??"all";t.setActivityFilter(k==="fresh"||k==="stale"?k:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(b=t.setSortDirection)==null||b.call(t,n.sortDirection),(E=t.setListSectionVisibility)==null||E.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(j=t.setKanbanColumnVisibility)==null||j.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(w=t.setTableColumnVisibility)==null||w.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Xu(e){return e?`/w/${e}/views`:"/views"}function jN(e){return`${Xu(e.workspace)}/${encodeURIComponent(e.id)}`}function kN(e){const t=e.workspace?`/w/${e.workspace}`:"",n=nt(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&l1(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const iF=["critical","high","medium","low"],lF={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function cF(e){if(e.preset)return`${e.field} ${lF[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function SN(e){var s;const t=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=nt(e[a]);l.length&&t.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&t.push(`activity=${e.activity}`),e.dateRange&&t.push(cF(e.dateRange));const n=(s=e.search)==null?void 0:s.trim();return n&&t.push(`search="${n}"`),t.join(" · ")||"no filters"}const uF=new Set(["overview","assignments","todos","dependencies","knowledge"]),oj="__unknown_type__";function aj(){const{slug:e,workspace:t}=$t(),n=ln(),s=Dt();mo("project"),Ht({keys:"a",scope:"project",description:"Create assignment",handler:()=>s(`${n}/projects/${e}/create/assignment`)}),Ht({keys:"e",scope:"project",description:"Edit project",handler:()=>s(`${n}/projects/${e}/edit`)});const{data:a,loading:l,error:c,refetch:u}=V0(e),p=Zo(),m=ef(),{data:h}=oc(),[g,y]=gs(),b=g.get("tab"),E=b&&uF.has(b)?b:"overview";function j(se){y(Ae=>{const Qe=new URLSearchParams(Ae);return se==="overview"?Qe.delete("tab"):Qe.set("tab",se),Qe},{replace:!0})}const w=e?`p:${e}`:null,k=pN(w),[C,N]=f.useState(()=>km(k.defaultView)),[T,O]=f.useState(()=>nt(k.filters.status)),[P,D]=f.useState(()=>nt(k.filters.assignee)),[L,W]=f.useState(()=>nt(k.filters.priority)),[B,$]=f.useState(()=>nt(k.filters.type)),[K,re]=f.useState(()=>nt(k.filters.tags)),[I,H]=f.useState(null),[J,ne]=f.useState(()=>k.grouping),[_,G]=f.useState(()=>k.sortField),[A,z]=f.useState(()=>k.sortDirection),[ee,M]=f.useState(()=>({collapsed:[]})),[ue,ge]=f.useState(()=>({hidden:[]})),[V,ae]=f.useState(()=>({hidden:[]})),[me,ve]=f.useState(null),[Se,he]=f.useState(!1),[Je,Ye]=f.useState(!1),{toast:at,showToast:X,dismissToast:Ie}=ta(),Ne={kind:"project",slug:e??"",workspace:t??null},Oe=g.get("loadView"),{view:Xe,loading:Me,error:rt}=Go(Oe),{view:Ke,loading:xt,error:Pt}=Go(me),it=f.useRef(null);f.useEffect(()=>{me&&!xt&&!Pt&&!Ke&&ve(null)},[Ke,Pt,me,xt]),f.useEffect(()=>{ve(null),it.current=null,H(null)},[e,t]),f.useEffect(()=>{N(km(k.defaultView)),O(nt(k.filters.status)),D(nt(k.filters.assignee)),W(nt(k.filters.priority)),$(nt(k.filters.type)),re(nt(k.filters.tags)),ne(k.grouping),G(k.sortField),z(k.sortDirection)},[e,k.defaultView,k.filters.status,k.filters.assignee,k.filters.priority,k.filters.type,k.filters.tags,k.grouping,k.sortField,k.sortDirection]);const ie=f.useCallback(se=>{w&&gN(w,se).catch(Ae=>{console.warn("Failed to persist project view prefs:",Ae)})},[w]),Y=f.useCallback(se=>{N(se),ie({defaultView:se})},[ie]),fe=f.useCallback(se=>{O(se),ie({filters:{status:se}})},[ie]),Z=f.useCallback(se=>{D(se),ie({filters:{assignee:se}})},[ie]),ye=f.useCallback(se=>{W(se),ie({filters:{priority:se}})},[ie]),Re=f.useCallback(se=>{$(se),ie({filters:{type:se}})},[ie]),ct=f.useCallback(se=>{re(se),ie({filters:{tags:se}})},[ie]),te=f.useCallback(se=>{ne(se),ie({grouping:se})},[ie]),be=f.useCallback(se=>{G(se),ie({sortField:se})},[ie]),Le=f.useCallback(se=>{z(se),ie({sortDirection:se})},[ie]),lt=f.useCallback(()=>({viewMode:C,filters:{status:T,priority:L,type:B,assignee:P,tags:K,project:"all",activity:"all",dateRange:Xl(I)},sortField:_,sortDirection:A,listSectionVisibility:ee,kanbanColumnVisibility:ue,tableColumnVisibility:V}),[C,T,L,B,P,K,I,_,A,ee,ue,V]),_e=f.useCallback(se=>{wN(se,{setViewMode:Ae=>N(km(Ae)),setStatusFilter:fe,setPriorityFilter:ye,setTypeFilter:Re,setAssigneeFilter:Z,setTagsFilter:ct,setDateRange:H,setSortField:be,setSortDirection:Le,setListSectionVisibility:M,setKanbanColumnVisibility:ge,setTableColumnVisibility:ae}),ve(se.id)},[fe,ye,Re,Z,ct,be,Le]),vt=f.useCallback(se=>{_e(se),it.current=se.id,y(Ae=>{const Qe=new URLSearchParams(Ae);return Qe.set("loadView",se.id),Qe},{replace:!0})},[_e,y]),_t=f.useCallback(async se=>{try{const Ae=Jl({name:se,context:{workspace:t??null,projectSlug:e??null},state:lt()}),Qe=await Wd(Ae),Ft=Qe.views[Qe.views.length-1];ve((Ft==null?void 0:Ft.id)??null),Ft&&(it.current=Ft.id,y(gn=>{const Ct=new URLSearchParams(gn);return Ct.set("loadView",Ft.id),Ct},{replace:!0})),he(!1),Ye(!1),X(`Saved view "${se}"`,"success")}catch(Ae){throw X(Ae instanceof Error?Ae.message:"Failed to save view","error"),Ae}},[lt,y,X,e,t]),Gt=f.useCallback(async()=>{if(!(!me||!Ke))try{const se=nt(Ke.config.filters.project)[0]??null,Ae=Jl({name:Ke.name,context:{workspace:t??null,projectSlug:se},state:lt()}),Qe=Sx(Ke.config,Ae.config,Ae.config);await Og(me,{config:Qe}),X("View updated","success")}catch(se){X(se instanceof Error?se.message:"Failed to update view","error")}},[lt,Ke,me,X,t]);f.useEffect(()=>{if(!Oe){it.current=null;return}if(it.current!==Oe&&(me&&me!==Oe&&ve(null),!Me)){if(rt){X("Couldn't load saved view — try again","error");return}if(Xe){if(it.current=Oe,!c1(Xe,{kind:"project",slug:e??"",workspace:t??null})){s(kN(Xe),{replace:!0});return}_e(Xe),y(se=>{const Ae=new URLSearchParams(se);return Ae.delete("loadView"),Ae},{replace:!0});return}it.current=Oe,X("Saved view no longer exists","error"),y(se=>{const Ae=new URLSearchParams(se);return Ae.delete("loadView"),Ae},{replace:!0})}},[Oe,Xe,Me,rt,me,_e,y,X,s,e,t]);function tt(se){_===se?Le(A==="asc"?"desc":"asc"):(be(se),Le("asc"))}const pe=f.useMemo(()=>a?Object.fromEntries(a.assignments.flatMap(se=>{const Ae=`${n}/projects/${a.slug}/assignments/${se.slug}`;return[[se.slug,Ae],[se.title,Ae]]})):{},[a]);async function ze(se){await fetch(`/api/projects/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:se})}),u()}async function Ue(se){try{const Ae=await fetch(`/api/projects/${e}/${se?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Ae.ok){const Qe=await Ae.json().catch(()=>null);X((Qe==null?void 0:Qe.error)||`HTTP ${Ae.status}`,"error");return}u(),X(se?"Project archived":"Project restored","success")}catch(Ae){X(Ae instanceof Error?Ae.message:"Failed to update archive state","error")}}async function cn(se){await fetch(`/api/projects/${e}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:se})}),u()}if(l)return r.jsx(ht,{label:"Loading project workspace…"});if(c||!a)return r.jsx(jt,{error:c||"Project not found."});const Yt=(()=>{const se=new Set;for(const Qe of a.assignments)Qe.assignee&&se.add(Qe.assignee);const Ae=[{value:"__unassigned__",label:"Unassigned"}];for(const Qe of Array.from(se).sort())Ae.push({value:Qe,label:Qe});return Ae})(),sn=Array.from(new Set(a.assignments.flatMap(se=>se.tags??[]))).sort().map(se=>({value:se,label:se})),Wt=a.assignments.filter(se=>qg(se,{status:T,priority:L,type:B,assignee:P,tags:K,dateRange:Xl(I)})),Yn=uc(Wt,_,A),yt=new Set(m.definitions.map(se=>se.id)),kn=J==="type"?[...m.definitions.map(se=>({id:se.id,title:ii(m,se.id),description:se.description})),...Wt.some(se=>!se.type||!yt.has(se.type))?[{id:oj,title:"Other",description:"Assignments with no recognized type."}]:[]]:Q1(p.order).map(se=>({id:se,title:cc(p,se),description:Zd(se)}));function Rt({field:se,children:Ae}){const Qe=_===se;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>tt(se),className:"inline-flex items-center gap-1 hover:text-foreground",children:[Ae,Qe?A==="asc"?r.jsx(p0,{className:"h-3 w-3"}):r.jsx(br,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":k.density,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(mn,{status:a.status}),a.statusOverride&&r.jsx("button",{type:"button",className:"shell-action border-warning-foreground/40 text-warning-foreground",onClick:()=>ze(null),title:"Clear manual status override and return to derived status",children:"Clear Override"}),r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:se=>{se.target.value&&ze(se.target.value)},title:"Override project status",children:[r.jsx("option",{value:"",children:"Set Status…"}),p.statuses.map(se=>r.jsx("option",{value:se.id,children:se.label},se.id)),r.jsx("option",{value:"active",children:"Active"})]}),r.jsx("button",{type:"button",className:"shell-action",onClick:()=>Ue(!a.archived),title:a.archived?"Restore this project and its cascade-hidden assignments":"Archive this project (hides it and its assignments from normal views)",children:a.archived?"Restore":"Archive"}),h&&h.workspaces.length>0&&r.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm",value:"",onChange:se=>{se.target.value==="_ungrouped"?cn(null):se.target.value&&cn(se.target.value)},title:"Move project to a different workspace",children:[r.jsx("option",{value:"",children:"Move to Workspace…"}),h.workspaces.filter(se=>se!==a.workspace).map(se=>r.jsx("option",{value:se,children:se},se)),a.workspace&&r.jsx("option",{value:"_ungrouped",children:"Ungrouped"})]}),r.jsxs(Ee,{className:"shell-action",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(xv,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Project"})]}),r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Assignment"})]}),r.jsx(Xg,{externalIds:a.externalIds}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Created ",$n(a.created),". Last source update ",Lr(a.updated),"."]})]}),r.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-5",children:[r.jsx(Dn,{label:"Assignments",value:a.progress.total}),r.jsx(Dn,{label:"In Progress",value:a.progress.in_progress??0,tone:"info"}),r.jsx(Dn,{label:"Review",value:a.progress.review??0,tone:"info"}),r.jsx(Dn,{label:"Blocked",value:a.progress.blocked??0,tone:"warn"}),r.jsx(Dn,{label:"Completed",value:a.progress.completed??0,tone:"success"})]}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(Zg,{value:E,onValueChange:j,items:[{value:"overview",label:"Overview",content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Project Overview",children:r.jsx(pn,{content:a.body,emptyState:"This project does not have overview content yet."})})})},{value:"assignments",label:"Assignments",count:a.assignments.filter(se=>!se.archived).length,content:r.jsx("div",{className:"space-y-5",children:r.jsx(We,{title:"Assignment Queue",description:"Board and table views over the source assignment files.",actions:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(An,{ariaLabel:"Status filter",className:"max-w-[170px]",allLabel:"All statuses",options:p.statuses.map(se=>({value:se.id,label:se.label})),value:T,onChange:fe}),r.jsx(An,{ariaLabel:"Assignee filter",className:"max-w-[170px]",allLabel:"All assignees",options:Yt,value:P,onChange:Z}),r.jsx(An,{ariaLabel:"Priority filter",className:"max-w-[170px]",allLabel:"All priorities",options:[{value:"critical",label:"Critical"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],value:L,onChange:ye}),r.jsx(An,{ariaLabel:"Type filter",className:"max-w-[170px]",allLabel:"All types",options:m.definitions.map(se=>({value:se.id,label:ii(m,se.id)})),value:B,onChange:Re}),r.jsx(An,{ariaLabel:"Tags filter",className:"max-w-[170px]",allLabel:"Any tags",options:sn,value:K,onChange:ct}),r.jsx(kx,{className:"max-w-[190px]",value:I,onChange:H}),C==="kanban"&&r.jsxs("select",{value:J==="type"?"type":"status",onChange:se=>te(se.target.value),className:"editor-input max-w-[170px]",title:"Group kanban by",children:[r.jsx("option",{value:"status",children:"Group: Status"}),r.jsx("option",{value:"type",children:"Group: Type"})]}),r.jsx(nf,{value:C,onChange:se=>Y(se),options:[{value:"kanban",label:"Kanban"},{value:"table",label:"Table"}]}),r.jsx(yN,{scope:Ne,loadedViewId:me,onApply:vt,onOpenSaveDialog:()=>{Ye(!1),he(!0)}}),r.jsx("button",{type:"button",onClick:()=>{Ke?Gt():(Ye(!1),he(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:Ke?`Update ${Ke.name}`:"Save current view",children:Ke?`Update '${Ke.name}'`:"Save view"}),Ke?r.jsx("button",{type:"button",onClick:()=>{Ye(!0),he(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),children:Wt.length===0?r.jsx(Nt,{title:"No assignments match these filters",description:"Clear the current filters or create a new assignment for this project.",actions:r.jsx(Ee,{className:"shell-action shell-action--cta",to:`${n}/projects/${a.slug}/create/assignment`,children:"Create Assignment"})}):C==="kanban"?r.jsx(Qd,{columns:kn,items:Yn,getItemId:se=>se.slug,getColumnId:se=>J==="type"?se.type&&yt.has(se.type)?se.type:oj:se.status,dragDisabled:!0,renderCard:se=>r.jsx(dF,{projectSlug:a.slug,assignment:se}),emptyMessage:se=>`No ${se.title.toLowerCase()} assignments.`,hiddenColumnIds:ue.hidden,onHideColumn:se=>ge(Ae=>({hidden:Ae.hidden.includes(se)?Ae.hidden.filter(Ft=>Ft!==se):[...Ae.hidden,se]}))}):(()=>{const se=new Set(V.hidden),Ae=Qe=>Qe==="title"||!se.has(Qe);return r.jsxs("div",{className:"overflow-x-auto",children:[r.jsx("div",{className:"mb-3 flex items-center justify-end",children:r.jsx(uN,{visibility:V,onChange:ae})}),r.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[Ae("title")?r.jsx(Rt,{field:"title",children:"Assignment"}):null,Ae("status")?r.jsx(Rt,{field:"status",children:"Status"}):null,r.jsx("th",{className:"pb-3 font-medium",children:"Type"}),Ae("priority")?r.jsx(Rt,{field:"priority",children:"Priority"}):null,Ae("assignee")?r.jsx(Rt,{field:"assignee",children:"Assignee"}):null,Ae("dependencies")?r.jsx(Rt,{field:"dependencies",children:"Dependencies"}):null,Ae("created")?r.jsx(Rt,{field:"created",children:"Created"}):null,Ae("updated")?r.jsx(Rt,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:Yn.map(Qe=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[Ae("title")?r.jsx("td",{className:"py-4",children:r.jsx(Ee,{to:`${n}/projects/${a.slug}/assignments/${Qe.slug}`,className:"font-semibold text-foreground hover:text-primary",children:Qe.title})}):null,Ae("status")?r.jsx("td",{className:"py-4",children:r.jsx(mn,{status:Qe.status})}):null,r.jsx("td",{className:"py-4",children:r.jsx(ea,{type:Qe.type,compact:!0})}),Ae("priority")?r.jsx("td",{className:"py-4 capitalize text-muted-foreground",children:Qe.priority}):null,Ae("assignee")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.assignee??"—"}):null,Ae("dependencies")?r.jsx("td",{className:"py-4 text-muted-foreground",children:Qe.dependsOn.length}):null,Ae("created")?r.jsx("td",{className:"py-4 text-muted-foreground",children:$n(Qe.created)}):null,Ae("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:$n(Qe.updated)}):null]},Qe.slug))})]})]})})()})})},{value:"todos",label:"Todos",content:r.jsx(J_,{projectId:a.slug})},{value:"dependencies",label:"Dependencies",content:a.dependencyGraph?r.jsx(We,{title:"Dependency Graph",description:"Rendered from the derived graph when available, with a source-based fallback.",children:r.jsx(lO,{definition:a.dependencyGraph,nodeRoutes:pe})}):r.jsx(Nt,{title:"No dependency graph yet",description:"Dependencies appear here once assignments declare dependsOn relationships."})},{value:"knowledge",label:"Knowledge",content:r.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[r.jsx(We,{title:"Resources",description:"Shared project references.",actions:r.jsxs(Ee,{className:"shell-action",to:`/resources/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Resource"})]}),children:a.resources.length===0?r.jsx(Nt,{title:"No resources yet",description:"Resources live at the project level and stay available to every assignment."}):r.jsx("div",{className:"space-y-3",children:a.resources.map(se=>r.jsxs(Ee,{to:`/projects/${a.slug}/resources/${se.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:se.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[se.category," · ",se.source]})]},se.slug))})}),r.jsx(We,{title:"Memories",description:"Learnings and patterns captured during the project.",actions:r.jsxs(Ee,{className:"shell-action",to:`/memories/new?project=${a.slug}`,children:[r.jsx(rn,{className:"h-4 w-4"}),r.jsx("span",{children:"New Memory"})]}),children:a.memories.length===0?r.jsx(Nt,{title:"No memories yet",description:"Memories capture patterns discovered during execution so later assignments can reuse them."}):r.jsx("div",{className:"space-y-3",children:a.memories.map(se=>r.jsxs(Ee,{to:`/projects/${a.slug}/memories/${se.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:se.name}),r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[se.scope," · ",se.source]})]},se.slug))})})]})}]})}),r.jsxs("div",{className:"space-y-5",children:[r.jsx(We,{title:"Progress Summary",children:r.jsx(gd,{progress:a.progress,showLegend:!0})}),r.jsx(We,{title:"Attention",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Blocked"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.blockedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Failed"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.failedCount})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("dt",{className:"text-muted-foreground",children:"Unanswered questions"}),r.jsx("dd",{className:"font-semibold text-foreground",children:a.needsAttention.openQuestions})]})]})}),r.jsx(We,{title:"Quick Links",children:r.jsxs("div",{className:"space-y-2 text-sm",children:[r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/edit`,children:[r.jsx(xv,{className:"h-4 w-4"}),"Edit project source"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${a.slug}/create/assignment`,children:[r.jsx(rn,{className:"h-4 w-4"}),"Create assignment"]}),r.jsxs(Ee,{className:"flex items-center gap-2 text-primary hover:underline",to:"/help",children:[r.jsx(nP,{className:"h-4 w-4"}),"Review project rules"]}),r.jsxs("button",{type:"button",onClick:()=>j("dependencies"),className:"flex items-center gap-2 text-primary hover:underline",children:[r.jsx(ng,{className:"h-4 w-4"}),"Jump to dependencies"]})]})}),a.archived?r.jsxs(We,{title:"Archive Metadata",children:[r.jsxs("p",{className:"text-sm leading-6 text-muted-foreground",children:["Archived ",a.archivedAt?Lr(a.archivedAt):"with no timestamp recorded","."]}),a.archivedReason?r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:a.archivedReason}):null]}):null]})]}),r.jsx(na,{toast:at,onDismiss:Ie}),r.jsx(xN,{open:Se,onOpenChange:se=>{he(se),se||Ye(!1)},initialName:Je&&Ke?`${Ke.name} (copy)`:"",title:Je?"Save as new view":"Save view",onSubmit:_t})]})}function dF({projectSlug:e,assignment:t}){const n=ln();return r.jsxs(Ee,{to:`${n}/projects/${e}/assignments/${t.slug}`,className:"vp-card block rounded-lg border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:t.title}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:t.id,children:[t.id.slice(0,8),r.jsx("span",{onClick:s=>{s.preventDefault(),s.stopPropagation()},children:r.jsx($r,{value:t.id})})]}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",$n(t.updated)]})]}),r.jsx(mn,{status:t.status})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ea,{type:t.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:t.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:t.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[t.dependsOn.length," dependencies"]})]})]})}function NN({sessionId:e,disabled:t=!1,disabledReason:n,onError:s,onNotice:a}){const[l,c]=f.useState(!1),[u,p]=f.useState(!1);async function m(){if(!(t||u)){p(!0);try{const h=await fetch(`/api/launch/command?session=${encodeURIComponent(e)}&mode=resume`);if(!h.ok){const y=await h.json().catch(()=>null);throw new Error((y==null?void 0:y.error)??`HTTP ${h.status}`)}const g=await h.json().catch(()=>null);if(!g||typeof g.command!="string")throw new Error("Malformed response from launch command endpoint");if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(g.command),c(!0),setTimeout(()=>c(!1),1500),typeof g.fallbackWarning=="string"&&g.fallbackWarning&&(a==null||a(g.fallbackWarning))}catch(h){s==null||s(h instanceof Error?h:new Error(String(h)))}finally{p(!1)}}}return t?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:n??"Copy launch command unavailable","aria-label":"Copy launch command",children:r.jsx(yv,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:m,disabled:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded disabled:cursor-wait",title:l?"Copied!":"Copy launch command (cd + resume)","aria-label":"Copy launch command",children:l?r.jsx(Qr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(yv,{className:"h-3 w-3","aria-hidden":"true"})})}function jl(e,t,n,s,a){let l=`syntaur://open?${e.kind}=${encodeURIComponent(e.id)}`;return e.kind==="session"&&t&&(l+=`&mode=${encodeURIComponent(t)}`),n&&(l+=`&terminal=${encodeURIComponent(n)}`),s&&e.kind==="assignment"&&(l+=`&agent=${encodeURIComponent(s)}`),a!==void 0&&e.kind==="assignment"&&(l+=`&prompt=${encodeURIComponent(a)}`),l}function fF(e){return e.kind==="session"?{method:"POST",url:`/api/agent-sessions/${encodeURIComponent(e.id)}/worktree/recreate`}:e.projectSlug&&e.assignmentSlug?{method:"POST",url:`/api/projects/${encodeURIComponent(e.projectSlug)}/assignments/${encodeURIComponent(e.assignmentSlug)}/worktree/recreate`}:{method:"POST",url:`/api/assignments/${encodeURIComponent(e.id)}/worktree/recreate`}}function pF(e){if(!e.trim())return"Branch name is required.";if(/\s/.test(e))return"Branch name cannot contain whitespace.";if(/[\x00-\x1F\x7F~^:?*[\\]/.test(e))return"Branch name cannot contain any of: ~ ^ : ? * [ \\ or control characters.";if(e.startsWith("-"))return'Branch name cannot start with "-".';if(e.startsWith("/")||e.endsWith("/"))return'Branch name cannot start or end with "/".';if(e.endsWith("."))return'Branch name cannot end with ".".';if(e.includes(".."))return'Branch name cannot contain "..".';if(e.includes("@{"))return'Branch name cannot contain "@{".';if(e==="@")return'Branch name cannot be "@".';for(const t of e.split("/")){if(!t)return'Branch name cannot contain empty path segments (e.g. "a//b").';if(t.startsWith("."))return'Branch name segments cannot start with ".".';if(t.endsWith(".lock"))return'Branch name segments cannot end with ".lock".'}return null}async function CN(e,t,n,s){const a=await fetch(`/api/projects/${e}/assignments/${t}/transitions/${n.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{reason:s}:{})}),l=await a.json().catch(()=>null);if(!a.ok)throw new Error((l==null?void 0:l.error)||`HTTP ${a.status}`);return l.assignment}async function EN(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})}),a=await s.json().catch(()=>null);if(!s.ok)throw new Error((a==null?void 0:a.error)||`HTTP ${s.status}`);return a.assignment}async function mF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}`,{method:"DELETE"}),s=await n.json().catch(()=>null);if(!n.ok)throw new Error((s==null?void 0:s.error)||`HTTP ${n.status}`)}function TN(e){return e.requiresReason||e.command==="block"}async function hF(e){const t=await fetch(`/api/projects/${e.projectSlug}/assignments/${e.assignmentSlug}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}async function gF(e){const t=await fetch(`/api/assignments/${e.id}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}class Nx extends Error{constructor(t,n){super(t),this.stderr=n,this.name="CreateWorktreeError"}}async function Cx(e){const t=await e.json().catch(()=>null);return new Nx((t==null?void 0:t.error)||`HTTP ${e.status}`,t==null?void 0:t.stderr)}async function xF(e){const t=await fetch(`/api/projects/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function yF(e){const t=await fetch(`/api/assignments/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function bF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok)throw await Cx(s);return(await s.json()).assignment}async function vF(e,t){const n=await fetch(`/api/assignments/${e}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await Cx(n);return(await n.json()).assignment}async function wF(e){const{url:t}=fF(e),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!n.ok)throw await Cx(n);return await n.json()}async function cf(e){const t=await e.json().catch(()=>null);if(!e.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${e.status}`);return t}async function jF(e,t,n){const s=await fetch(`/api/projects/${e}/assignments/${t}/repository-branches?repo=${encodeURIComponent(n)}`);return cf(s)}async function kF(e,t){const n=await fetch(`/api/assignments/${e}/repository-branches?repo=${encodeURIComponent(t)}`);return cf(n)}async function SF(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}/source-assignments`);return(await cf(n)).sourceAssignments}async function NF(e){const t=await fetch(`/api/assignments/${e}/source-assignments`);return(await cf(t)).sourceAssignments}function PN(){const[e,t]=f.useState(!1),[n,s]=f.useState(null),[a,l]=f.useState(null),[c,u]=f.useState(null),[p,m]=f.useState(null),[h,g]=f.useState(null),[y,b]=f.useState(!1),[E,j]=f.useState(null),[w,k]=f.useState(null);async function C(P,D,L,W){if(!e){t(!0);try{const B=await fetch("/api/launch/preflight",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:{kind:P.kind,id:P.id}})});if(!B.ok){window.location.href=jl(P,D,void 0,L,W);return}const $=await B.json();if($.ok){window.location.href=jl(P,D,void 0,L,W);return}if($.reason==="workspace-path-invalid"){$.recreate?(m($.recreate),g({target:P,mode:D,agentId:L,prompt:W})):u($.message);return}s($),l({target:P,mode:D,agentId:L,prompt:W})}catch(B){console.warn("preflight failed, firing without override:",B),window.location.href=jl(P,D,void 0,L,W)}finally{t(!1)}}}function N(){!n||!a||(window.location.href=jl(a.target,a.mode,n.suggestedFallback,a.agentId,a.prompt),s(null),l(null))}async function T(){if(!(!p||!h||y)){b(!0),j(null);try{const P=await wF({kind:p.kind,id:p.id,projectSlug:p.projectSlug,assignmentSlug:p.assignmentSlug}),{target:D,mode:L,agentId:W,prompt:B}=h;m(null),g(null),window.location.href=jl(D,L,void 0,W,B),!P.exact&&!P.alreadyExisted&&k(`Recreated from ${P.baseUsed} — the original branch couldn't be restored exactly, but the directory is back and your agent is opening.`)}catch(P){j(P instanceof Nx&&P.stderr?`${P.message}
|
|
544
|
-
${P.stderr}`:P instanceof Error?P.message:String(P))}finally{b(!1)}}}const O=r.jsxs(r.Fragment,{children:[r.jsx(Ga,{open:n!==null,onOpenChange:P=>!P&&(s(null),l(null)),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsxs(Uo,{children:[n==null?void 0:n.terminal," is not installed"]}),r.jsxs(Vo,{children:["Open in ",r.jsx("strong",{children:n==null?void 0:n.suggestedFallback})," instead? You can change the default in"," ",r.jsx(Ee,{to:"/settings",className:"underline hover:text-foreground",onClick:()=>{s(null),l(null)},children:"Settings"}),"."]})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",children:"Cancel"}),r.jsxs(oo,{className:"shell-action mt-0 shell-action--cta",onClick:P=>{P.preventDefault(),N()},children:["Open in ",n==null?void 0:n.suggestedFallback]})]})]})}),r.jsx(Ga,{open:c!==null,onOpenChange:P=>!P&&u(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Can't open in agent"}),r.jsxs(Vo,{children:[c," Set a valid worktree or repository, then try again."]})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>u(null),children:"OK"})})]})}),r.jsx(Ga,{open:p!==null,onOpenChange:P=>{!P&&!y&&(m(null),g(null),j(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree was deleted"}),r.jsxs(Vo,{children:["The worktree at ",r.jsx("code",{children:p==null?void 0:p.deletedPath})," no longer exists. Recreate it",p!=null&&p.branch?r.jsxs(r.Fragment,{children:[" ","on branch ",r.jsx("code",{children:p.branch})]}):null," ","so this can open?"]})]}),E&&r.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-muted p-2 text-xs text-destructive",children:E}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",disabled:y,children:"No"}),r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",disabled:y,onClick:P=>{P.preventDefault(),T()},children:y?"Recreating…":"Yes, recreate"})]})]})}),r.jsx(Ga,{open:w!==null,onOpenChange:P=>!P&&k(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree recreated"}),r.jsx(Vo,{children:w})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>k(null),children:"OK"})})]})})]});return{open:C,pending:e,dialogs:O}}function RN({session:e,onMarkStopped:t}){const n=PN(),s={kind:"session",id:e.sessionId},a="size-3.5",l=ke("shell-action","inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50"),c="inline-flex outline-none focus-visible:ring-1 focus-visible:ring-ring rounded-sm",u=!e.resumeSupported&&!e.forkSupported;return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{delayDuration:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1",children:[u&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Reopen"})]})})}),r.jsx(gr,{side:"top",children:"Reopen unavailable — this agent has no resume/fork command configured"})]}),e.resumeSupported&&(e.isLive?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})})}),r.jsx(gr,{side:"top",children:"Session appears active — fork instead to avoid transcript corruption"})]}):r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"resume"),children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})}),r.jsx(gr,{side:"top",children:"Continue this session in its agent (same session id, same transcript)"})]})),e.forkSupported&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"fork"),children:[r.jsx(gP,{className:a}),r.jsx("span",{children:"Fork"})]})}),r.jsx(gr,{side:"top",children:"Branch a new session from this point — safe even when the original is still running"})]}),e.status==="active"&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,onClick:()=>t(e.sessionId),children:[r.jsx(ag,{className:a}),r.jsx("span",{children:"Mark stopped"})]})}),r.jsx(gr,{side:"top",children:e.resumeSupported?"Tell the dashboard this session has ended so Resume re-enables":"Tell the dashboard this session has ended"})]})]})}),n.dialogs]})}async function CF(e){await fetch(`/api/agent-sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})})}function AN({sessions:e,loading:t,error:n,onError:s,onNotice:a}){return t&&!e?null:n&&!e?r.jsx(We,{title:"Agent Sessions",children:r.jsx(Nt,{title:"Couldn't load sessions",description:n})}):!e||e.length===0?r.jsx(We,{title:"Agent Sessions",children:r.jsx(Nt,{title:"No agent sessions yet",description:"Sessions appear here when an agent registers one via /grab-assignment or syntaur track-session."})}):r.jsx(We,{title:"Agent Sessions",children:r.jsx("div",{className:"space-y-2",children:e.map(l=>r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Ad,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"font-medium text-foreground",children:l.agent}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:l.sessionId,children:[l.sessionId.slice(0,8),r.jsx($r,{value:l.sessionId}),r.jsx(NN,{sessionId:l.sessionId,disabled:!l.resumeSupported,disabledReason:"Resume not supported for this agent",onError:s,onNotice:a})]})]}),r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(mn,{status:l.status}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Lr(l.started)})]}),r.jsx(RN,{session:l,onMarkStopped:CF})]},l.sessionId))})})}const qm="Cost / Usage";function DN({summary:e,error:t}){return t&&!e?r.jsx(We,{title:qm,children:r.jsx(Nt,{title:"Couldn't load usage",description:t})}):e?e.lastEventDay===null?r.jsx(We,{title:qm,children:r.jsx(Nt,{title:"No usage recorded yet",description:"Cost and token totals appear here once the usage collector records activity for this assignment."})}):r.jsx(We,{title:qm,children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(ij,{label:"Total cost",value:od(e.totalCost)}),r.jsx(ij,{label:"Total tokens",value:sd(e.totalTokens)})]}),e.byModel.length>1?r.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),r.jsx("div",{className:"space-y-1",children:e.byModel.map(n=>r.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(Od,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono text-xs text-foreground",title:n.model,children:n.model})]}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[sd(n.totalTokens)," · ",od(n.totalCost)]})]},n.model))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last usage recorded ",hR(e.lastEventDay)]})]})}):null}function ij({label:e,value:t}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("p",{className:"text-lg font-semibold tabular-nums text-foreground",children:t})]})}function $N({open:e,action:t,assignmentTitle:n,loading:s=!1,onConfirm:a,onOpenChange:l}){const[c,u]=f.useState("");f.useEffect(()=>{e||u("")},[e,t==null?void 0:t.command]);const p=f.useMemo(()=>t&&t.command==="block"?"Blocked Reason":"Reason",[t]);if(!t)return null;const m=`${t.label} "${n}"`,h=s?"Applying...":t.label,g=c.trim()||void 0;return r.jsx(Gn,{open:e,onOpenChange:y=>s?void 0:l(y),children:r.jsx(zn,{className:"max-w-xl",children:r.jsxs("form",{className:"space-y-5",onSubmit:y=>{y.preventDefault(),a(g)},children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:m}),r.jsx(es,{children:t.description})]}),t.warning?r.jsx("div",{className:"rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:t.warning}):null,r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:p}),r.jsx("textarea",{value:c,onChange:y=>u(y.target.value),autoFocus:!0,rows:4,disabled:s,placeholder:"Optional context for why this assignment is blocked.",className:"editor-textarea min-h-[120px] bg-background/95 font-sans"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave this blank to continue without a written reason."})]}),r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>l(!1),disabled:s,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:s,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h})]})]})})})}function sa({open:e,title:t,description:n,confirmLabel:s,cancelLabel:a="Cancel",loading:l=!1,destructive:c=!1,onConfirm:u,onOpenChange:p}){return r.jsx(Ga,{open:e,onOpenChange:m=>l?void 0:p(m),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:t}),r.jsx(Vo,{children:n})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:l,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:a}),r.jsx(oo,{disabled:l,className:`shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90":"shell-action--cta"}`,onClick:m=>{m.preventDefault(),u()},children:l?"Working...":s})]})]})})}const EF=/^[a-z0-9][a-z0-9_-]*$/,LN=["first","last","none"];class ON extends Error{constructor(n,s){super(n);Zb(this,"fieldErrors");this.name="AgentsConfigError",this.fieldErrors=s}}const Ex={agents:[],custom:!1};let Xa=null,Ka=null,vd=0;const _h=new Set;function IN(e){Xa=e;for(const t of _h)t(e)}function TF(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.id!="string"||t.id.length===0||typeof t.label!="string"||typeof t.command!="string")return null;const n={id:t.id,label:t.label,command:t.command};return Array.isArray(t.args)&&t.args.every(s=>typeof s=="string")&&(n.args=t.args),typeof t.promptArgPosition=="string"&&LN.includes(t.promptArgPosition)&&(n.promptArgPosition=t.promptArgPosition),typeof t.resolveFromShellAliases=="boolean"&&(n.resolveFromShellAliases=t.resolveFromShellAliases),typeof t.default=="boolean"&&(n.default=t.default),typeof t.model=="string"&&(n.model=t.model),typeof t.playbook=="string"&&(n.playbook=t.playbook),typeof t.launchPrompt=="string"&&(n.launchPrompt=t.launchPrompt),n}function Tx(e){if(!e||typeof e!="object")return Ex;const t=e,n=Array.isArray(t.agents)?t.agents:[],s=[];for(const a of n){const l=TF(a);l&&s.push(l)}return{agents:s,custom:t.custom===!0}}function PF(){if(Xa)return Promise.resolve(Xa);if(Ka)return Ka;const e=++vd;return Ka=fetch("/api/config/agents").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{Ka=null;const n=Tx(t);return e!==vd?Xa??n:(Xa=n,n)}).catch(()=>(Ka=null,Ex)),Ka}function MN(){const[e,t]=f.useState(()=>Xa??Ex);return f.useEffect(()=>{let n=!1;return PF().then(s=>{n||t(s)}),_h.add(t),()=>{n=!0,_h.delete(t)}},[]),e}async function _N(e){const t=await e.json().catch(()=>null),n=(t==null?void 0:t.error)??`HTTP ${e.status}`;return new ON(n,t==null?void 0:t.fieldErrors)}async function RF(e){++vd;const t=await fetch("/api/config/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:e})});if(!t.ok)throw await _N(t);const n=Tx(await t.json());return IN(n),n}async function AF(){++vd;const e=await fetch("/api/config/agents",{method:"DELETE"});if(!e.ok)throw await _N(e);const t=Tx(await e.json());return IN(t),t}const lj=/[A-Za-z0-9_-]/,DF=/^[a-z0-9]+(-[a-z0-9]+)*$/,cj=/(^|\s)@([A-Za-z0-9_-]+)/g,Fh="assignment";function $F(e,t){const n=Math.max(0,Math.min(t,e.length));let s=n;for(;s>0&&lj.test(e[s-1]);)s--;const a=s-1;if(a<0||e[a]!=="@"||a>0&&!/\s/.test(e[a-1]))return null;let l=n;for(;l<e.length&&lj.test(e[l]);)l++;return{start:a,end:l,partial:e.slice(a+1,n)}}function LF(e,t){const n=[Fh,...t.filter(c=>c!==Fh)],s=e.toLowerCase();if(s==="")return n;const a=[],l=[];for(const c of n){const u=c.toLowerCase();u.startsWith(s)?a.push(c):u.includes(s)&&l.push(c)}return[...a,...l]}function OF(e,t,n){const s=`@${n}`;return{text:e.slice(0,t.start)+s+e.slice(t.end),caret:t.start+s.length}}function IF(e,t){const n=t instanceof Set?t:new Set(t),s=[];cj.lastIndex=0;let a;for(;(a=cj.exec(e))!==null;){const l=a[2];l!==Fh&&(DF.test(l)?n.has(l)||s.push(`Playbook "${l}" is not installed — "@${l}" will be left as literal text.`):s.push(`"@${l}" is not a valid playbook token — it will be left as literal text.`))}return s}const uj=2e3;function MF({open:e,assignmentId:t,agentId:n,onConfirm:s,onOpenChange:a}){const[l,c]=f.useState(""),[u,p]=f.useState([]),[m,h]=f.useState(!1),[g,y]=f.useState(null),[b,E]=f.useState(0),[j,w]=f.useState(0),[k,C]=f.useState(!1),N=f.useRef(null);f.useEffect(()=>{if(!e)return;let I=!1;h(!0),y(null),C(!1);const H=new URLSearchParams({assignment:t});return n&&H.set("agent",n),fetch(`/api/launch/prompt?${H.toString()}`).then(async J=>{if(!J.ok){const ne=await J.json().catch(()=>null);throw new Error((ne==null?void 0:ne.error)??`HTTP ${J.status}`)}return await J.json()}).then(J=>{I||(c(J.template??""),p(J.knownPlaybookSlugs??[]),E((J.template??"").length))}).catch(J=>{I||y(J instanceof Error?J.message:String(J))}).finally(()=>{I||h(!1)}),()=>{I=!0}},[e,t,n]);const T=$F(l,b),O=T?LF(T.partial,u):[],P=e&&!m&&!k&&O.length>0,D=IF(l,u),L=l.length>uj;function W(I){c(I.target.value.replace(/[\r\n]+/g," ")),E(I.target.selectionStart??I.target.value.length),w(0),C(!1)}function B(I){E(I.currentTarget.selectionStart??l.length),w(0)}function $(I){if(!T||!I)return;const H=OF(l,T,I);c(H.text),E(H.caret),w(0),requestAnimationFrame(()=>{const J=N.current;J&&(J.focus(),J.setSelectionRange(H.caret,H.caret))})}function K(I){P&&(I.key==="ArrowDown"?(I.preventDefault(),w(H=>Math.min(H+1,O.length-1))):I.key==="ArrowUp"?(I.preventDefault(),w(H=>Math.max(H-1,0))):(I.key==="Enter"||I.key==="Tab")&&(I.preventDefault(),$(O[j])))}function re(){L||m||(s(l),a(!1))}return r.jsx(Gn,{open:e,onOpenChange:a,children:r.jsxs(zn,{onEscapeKeyDown:I=>{P&&(I.preventDefault(),C(!0))},children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Edit launch prompt"}),r.jsxs(es,{children:["The first message the agent starts with. ",r.jsx("code",{children:"@assignment"})," and"," ",r.jsx("code",{children:"@<playbook>"})," tokens resolve at launch. This edit applies to this launch only."]})]}),g?r.jsxs("p",{className:"text-sm text-error-foreground",children:["Couldn't load the prompt: ",g]}):r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:N,value:l,disabled:m,rows:4,spellCheck:!1,placeholder:m?"Loading…":"@assignment Run @<playbook> end-to-end.",onChange:W,onKeyDown:K,onKeyUp:B,onClick:B,className:ke("editor-input w-full font-mono text-sm",L&&"border-error-foreground")}),P&&r.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:O.map((I,H)=>r.jsx("li",{children:r.jsxs("button",{type:"button",role:"option","aria-selected":H===j,onMouseDown:J=>{J.preventDefault(),$(I)},className:ke("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",H===j&&"bg-accent"),children:[r.jsx("span",{className:"text-muted-foreground",children:"@"}),r.jsx("span",{className:"truncate",children:I})]})},I))})]}),D.length>0&&!g&&r.jsx("ul",{className:"space-y-0.5 text-[11px] text-error-foreground",children:D.map(I=>r.jsx("li",{children:I},I))}),L&&r.jsxs("p",{className:"text-[11px] text-error-foreground",children:["Too long — keep it under ",uj," characters (",l.length,")."]}),r.jsxs(xs,{children:[r.jsx("button",{type:"button",className:"shell-action mt-0",onClick:()=>a(!1),children:"Cancel"}),r.jsx("button",{type:"button",className:"shell-action mt-0 shell-action--cta",disabled:m||L||g!==null,onClick:re,children:"Launch"})]})]})})}function FN({target:e,worktreePath:t=null,repository:n=null,size:s="default",title:a}){const l=e.kind==="assignment"&&!t&&!n,c=PN(),[u,p]=f.useState(null),h=MN().agents,[g,y]=f.useState(null);f.useEffect(()=>{h.length!==0&&y(D=>D&&h.some(W=>W.id===D)?D:(h.find(W=>W.default)??h[0]).id)},[h]);const b=e.kind==="assignment"&&h.length>1,E=h.find(D=>D.id===g)??null,j=f.useRef(null),[w,k]=f.useState(!1);f.useEffect(()=>{if(!w)return;function D(W){j.current&&!j.current.contains(W.target)&&k(!1)}function L(W){W.key==="Escape"&&k(!1)}return document.addEventListener("mousedown",D),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",L)}},[w]);function C(D){e.kind==="assignment"?p({agentId:D}):c.open(e,void 0,D)}const N=e.kind==="assignment"?"Open this assignment in your configured terminal + agent":"Resume this session in its agent",T="Set a workspace path first — see the Workspace Before Code playbook",O=ke("shell-action",s==="compact"&&"inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50");if(l)return r.jsxs("button",{type:"button",disabled:!0,title:T,className:O,"aria-disabled":!0,children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:"Open in agent"})]});const P=e.kind==="session"?"Open":"Open in agent";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative inline-flex",ref:j,children:[r.jsxs("div",{className:"inline-flex items-stretch",children:[r.jsxs("button",{type:"button",onClick:()=>C(g??void 0),disabled:c.pending,title:(a??N)+(b&&E?` (${E.label})`:""),className:ke(O,b&&"rounded-r-none"),children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:P})]}),b&&r.jsx("button",{type:"button",onClick:()=>k(D=>!D),disabled:c.pending,"aria-haspopup":"menu","aria-expanded":w,"aria-label":"Choose which agent to launch",title:"Choose which agent to launch",className:ke(O,"-ml-px rounded-l-none",s==="compact"?"px-1":"px-1.5"),children:r.jsx(br,{className:ke("size-3.5 opacity-70 transition-transform",w&&"rotate-180")})})]}),w&&b&&r.jsxs("div",{role:"menu","aria-label":"Open with agent",className:"absolute right-0 top-full z-30 mt-1 min-w-[180px] overflow-hidden rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsx("div",{className:"px-2.5 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Open with agent"}),h.map(D=>r.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":D.id===g,onClick:()=>{y(D.id),k(!1),C(D.id)},className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent",children:[r.jsx(Qr,{className:ke("size-3.5 shrink-0",D.id===g?"opacity-100":"opacity-0")}),r.jsx("span",{className:"truncate",children:D.label}),D.default&&r.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"default"})]},D.id))]})]}),c.dialogs,e.kind==="assignment"&&u&&r.jsx(MF,{open:!0,assignmentId:e.id,agentId:u.agentId,onConfirm:D=>{c.open(e,void 0,u.agentId,D)},onOpenChange:D=>{D||p(null)}})]})}const Gm="w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";function zN({projectSlug:e,assignmentSlug:t,assignmentId:n,defaultBranch:s,defaultParentBranch:a="main",onCreated:l}){const c=e&&t?{kind:"project-nested",projectSlug:e,assignmentSlug:t}:{kind:"standalone",assignmentId:n},[u,p]=f.useState(!1),[m,h]=f.useState("new-branch"),[g,y]=f.useState(null),[b,E]=f.useState(null),[j,w]=f.useState(""),[k,C]=f.useState(!1),[N,T]=f.useState(""),[O,P]=f.useState([]),[D,L]=f.useState(!1),[W,B]=f.useState(null),[$,K]=f.useState(""),[re,I]=f.useState(null),[H,J]=f.useState(null),[ne,_]=f.useState(""),[G,A]=f.useState(s),[z,ee]=f.useState(!1),[M,ue]=f.useState(null);f.useEffect(()=>{if(!u)return;let X=!1;return h("new-branch"),y(null),E(null),w(""),C(!1),T(""),P([]),L(!1),B(null),K(""),I(null),J(null),_(""),A(s),ue(null),(c.kind==="project-nested"?xF(c.projectSlug):yF(c.assignmentId)).then(Oe=>{if(!X)if(y(Oe),Oe.length===0)C(!0);else{const Xe=Oe.find(rt=>rt.source==="project"),Me=Oe.find(rt=>rt.source==="sibling");w((Xe==null?void 0:Xe.path)??(Me==null?void 0:Me.path)??Oe[0].path)}}).catch(Oe=>{X||(E(Oe.message),y([]),C(!0))}),(c.kind==="project-nested"?SF(c.projectSlug,c.assignmentSlug):NF(c.assignmentId)).then(Oe=>{X||I(Oe)}).catch(Oe=>{X||(J(Oe.message),I([]))}),()=>{X=!0}},[u,s,a,e,t,n]);const ge=m==="branch-off"?(re??[]).find(X=>X.id===ne)??null:null,V=m==="branch-off"?(ge==null?void 0:ge.repository)??"":k?N.trim():j;f.useEffect(()=>{if(!u||m!=="new-branch")return;if(!V){P([]),B(null),L(!1),K("");return}let X=!1;return L(!0),B(null),K(""),(c.kind==="project-nested"?jF(c.projectSlug,c.assignmentSlug,V):kF(c.assignmentId,V)).then(Ne=>{if(X)return;P(Ne.branches);const Oe=(Ne.defaultBranch&&Ne.branches.includes(Ne.defaultBranch)?Ne.defaultBranch:Ne.branches.includes(a)?a:Ne.branches[0])??"";K(Oe),L(!1)}).catch(Ne=>{X||(P([]),B(Ne.message),L(!1))}),()=>{X=!0}},[u,m,V,a,e,t,n]);const ae=pF(G.trim()),me=f.useMemo(()=>!V||!G.trim()?"":`${V.replace(/\/+$/,"")}/.worktrees/${G.trim()}`,[V,G]),ve=g!==null&&g.length===0,Se=re!==null&&re.length===0,he=X=>{X!==m&&(h(X),_(""),ue(null),X==="branch-off"&&(K(""),P([]),B(null),L(!1)))},Je=X=>{_(X);const Ie=(re??[]).find(Ne=>Ne.id===X);K((Ie==null?void 0:Ie.branch)??"")},Ye=z||ae!==null||!V||!$.trim()||(m==="new-branch"?g===null||D:re===null||!ne),at=async()=>{ee(!0),ue(null);try{const X={repository:V,branch:G.trim(),parentBranch:$.trim()};c.kind==="project-nested"?await bF(c.projectSlug,c.assignmentSlug,X):await vF(c.assignmentId,X),p(!1),l()}catch(X){X instanceof Nx?ue({message:X.message,stderr:X.stderr}):X instanceof Error?ue({message:X.message}):ue({message:String(X)})}finally{ee(!1)}};return r.jsxs(Gn,{open:u,onOpenChange:X=>z?void 0:p(X),children:[r.jsxs("button",{type:"button",className:"shell-action inline-flex items-center gap-1.5",onClick:()=>p(!0),children:[r.jsx(hP,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{children:"Create worktree"})]}),r.jsxs(zn,{children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Create worktree"}),r.jsxs(es,{children:["Creates a git worktree at ",r.jsx("code",{children:"<repo>/.worktrees/<branch>"})," and records the workspace fields on this assignment's frontmatter."]})]}),r.jsxs("div",{className:"grid gap-4 text-sm",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-1 rounded-md border border-border/70 p-1",children:[r.jsx("button",{type:"button",disabled:z,onClick:()=>he("new-branch"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="new-branch"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"New branch from repo"}),r.jsx("button",{type:"button",disabled:z,onClick:()=>he("branch-off"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="branch-off"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"Branch off another assignment"})]}),m==="new-branch"?r.jsxs(r.Fragment,{children:[ve?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:["No repositories configured for this project. Enter a repo path below, or add a"," ",r.jsx("code",{children:"repositories:"})," list to ",r.jsx("code",{children:"project.md"}),"."]}):null,b?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load repository candidates: ",b]}):null,r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Repository"}),r.jsx("select",{className:Gm,value:j,onChange:X=>w(X.target.value),disabled:z||g===null||k,children:(g??[]).map(X=>r.jsxs("option",{value:X.path,children:[X.path,X.source==="project"?" (project)":X.sourceAssignmentSlug?` (sibling — ${X.sourceAssignmentSlug})`:" (sibling)"]},`${X.source}:${X.path}`))}),ve?null:r.jsx("button",{type:"button",className:"justify-self-start text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:z,onClick:()=>C(X=>!X),children:k?"Use a listed repository":"Enter a custom repository path (advanced)"}),k?r.jsx("input",{className:"mt-1 w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",placeholder:"/absolute/path/to/repo",value:N,onChange:X=>T(X.target.value),disabled:z}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Parent branch"}),r.jsx("select",{className:Gm,value:$,onChange:X=>K(X.target.value),disabled:z||D||O.length===0,children:D?r.jsx("option",{value:"",children:"Loading branches…"}):O.length===0?r.jsx("option",{value:"",children:W?"Could not load branches":V?"No branches found":"— pick a repository —"}):O.map(X=>r.jsx("option",{value:X,children:X},X))}),W?r.jsxs("span",{className:"text-[11px] text-error-foreground",children:["Could not load branches: ",W]}):null]})]}):r.jsxs(r.Fragment,{children:[H?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load assignments: ",H]}):null,Se?r.jsx("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:"No other assignments with a configured workspace to branch off. Create a worktree for one first, or use “New branch from repo”."}):r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Source assignment"}),r.jsxs("select",{className:Gm,value:ne,onChange:X=>Je(X.target.value),disabled:z||re===null,children:[r.jsx("option",{value:"",children:"— select an assignment —"}),(re??[]).map(X=>r.jsxs("option",{value:X.id,children:[X.title," (",X.branch,")"]},X.id))]})]}),ge?r.jsxs("div",{className:"grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2 text-xs",children:[r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Repository (from source)"}),r.jsx("code",{className:"break-all",children:ge.repository})]}),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Parent branch (from source)"}),r.jsx("code",{children:ge.branch})]})]}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"New branch name"}),r.jsx("input",{className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",value:G,onChange:X=>A(X.target.value),disabled:z}),ae?r.jsx("span",{className:"text-[11px] text-error-foreground",children:ae}):null]}),r.jsxs("div",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Worktree path"}),r.jsx("code",{className:"rounded-md border border-border bg-muted px-2 py-1 text-xs break-all",children:me||r.jsx("span",{className:"opacity-60",children:"— pick a repo & branch —"})})]}),M?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:[r.jsx("div",{className:"font-medium",children:M.message}),M.stderr?r.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-[11px] opacity-90",children:M.stderr}):null]}):null]}),r.jsxs(xs,{children:[r.jsx(F3,{disabled:z,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",disabled:Ye,onClick:()=>void at(),className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:z?"Working…":"Create worktree"})]})]})]})}function _F(e){const t=e.split(`
|
|
544
|
+
${P.stderr}`:P instanceof Error?P.message:String(P))}finally{b(!1)}}}const O=r.jsxs(r.Fragment,{children:[r.jsx(Ga,{open:n!==null,onOpenChange:P=>!P&&(s(null),l(null)),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsxs(Uo,{children:[n==null?void 0:n.terminal," is not installed"]}),r.jsxs(Vo,{children:[(n==null?void 0:n.terminal)==="cmux"?r.jsxs(r.Fragment,{children:["To use cmux, install ",r.jsx("strong",{children:"cmux.app"})," into"," ",r.jsx("code",{children:"/Applications"}),"."," "]}):null,"Open in ",r.jsx("strong",{children:n==null?void 0:n.suggestedFallback})," instead? You can change the default in"," ",r.jsx(Ee,{to:"/settings",className:"underline hover:text-foreground",onClick:()=>{s(null),l(null)},children:"Settings"}),"."]})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",children:"Cancel"}),r.jsxs(oo,{className:"shell-action mt-0 shell-action--cta",onClick:P=>{P.preventDefault(),N()},children:["Open in ",n==null?void 0:n.suggestedFallback]})]})]})}),r.jsx(Ga,{open:c!==null,onOpenChange:P=>!P&&u(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Can't open in agent"}),r.jsxs(Vo,{children:[c," Set a valid worktree or repository, then try again."]})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>u(null),children:"OK"})})]})}),r.jsx(Ga,{open:p!==null,onOpenChange:P=>{!P&&!y&&(m(null),g(null),j(null))},children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree was deleted"}),r.jsxs(Vo,{children:["The worktree at ",r.jsx("code",{children:p==null?void 0:p.deletedPath})," no longer exists. Recreate it",p!=null&&p.branch?r.jsxs(r.Fragment,{children:[" ","on branch ",r.jsx("code",{children:p.branch})]}):null," ","so this can open?"]})]}),E&&r.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-muted p-2 text-xs text-destructive",children:E}),r.jsxs(Ja,{children:[r.jsx(Ul,{className:"shell-action mt-0",disabled:y,children:"No"}),r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",disabled:y,onClick:P=>{P.preventDefault(),T()},children:y?"Recreating…":"Yes, recreate"})]})]})}),r.jsx(Ga,{open:w!==null,onOpenChange:P=>!P&&k(null),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:"Worktree recreated"}),r.jsx(Vo,{children:w})]}),r.jsx(Ja,{children:r.jsx(oo,{className:"shell-action mt-0 shell-action--cta",onClick:()=>k(null),children:"OK"})})]})})]});return{open:C,pending:e,dialogs:O}}function RN({session:e,onMarkStopped:t}){const n=PN(),s={kind:"session",id:e.sessionId},a="size-3.5",l=ke("shell-action","inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50"),c="inline-flex outline-none focus-visible:ring-1 focus-visible:ring-ring rounded-sm",u=!e.resumeSupported&&!e.forkSupported;return r.jsxs(r.Fragment,{children:[r.jsx(Wo,{delayDuration:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1",children:[u&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Reopen"})]})})}),r.jsx(gr,{side:"top",children:"Reopen unavailable — this agent has no resume/fork command configured"})]}),e.resumeSupported&&(e.isLive?r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsx("span",{tabIndex:0,className:c,children:r.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:l,children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})})}),r.jsx(gr,{side:"top",children:"Session appears active — fork instead to avoid transcript corruption"})]}):r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"resume"),children:[r.jsx(Za,{className:a}),r.jsx("span",{children:"Resume"})]})}),r.jsx(gr,{side:"top",children:"Continue this session in its agent (same session id, same transcript)"})]})),e.forkSupported&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,disabled:n.pending,onClick:()=>void n.open(s,"fork"),children:[r.jsx(gP,{className:a}),r.jsx("span",{children:"Fork"})]})}),r.jsx(gr,{side:"top",children:"Branch a new session from this point — safe even when the original is still running"})]}),e.status==="active"&&r.jsxs(Rr,{children:[r.jsx(Ar,{asChild:!0,children:r.jsxs("button",{type:"button",className:l,onClick:()=>t(e.sessionId),children:[r.jsx(ag,{className:a}),r.jsx("span",{children:"Mark stopped"})]})}),r.jsx(gr,{side:"top",children:e.resumeSupported?"Tell the dashboard this session has ended so Resume re-enables":"Tell the dashboard this session has ended"})]})]})}),n.dialogs]})}async function CF(e){await fetch(`/api/agent-sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})})}function AN({sessions:e,loading:t,error:n,onError:s,onNotice:a}){return t&&!e?null:n&&!e?r.jsx(We,{title:"Agent Sessions",children:r.jsx(Nt,{title:"Couldn't load sessions",description:n})}):!e||e.length===0?r.jsx(We,{title:"Agent Sessions",children:r.jsx(Nt,{title:"No agent sessions yet",description:"Sessions appear here when an agent registers one via /grab-assignment or syntaur track-session."})}):r.jsx(We,{title:"Agent Sessions",children:r.jsx("div",{className:"space-y-2",children:e.map(l=>r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Ad,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"font-medium text-foreground",children:l.agent}),r.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:l.sessionId,children:[l.sessionId.slice(0,8),r.jsx($r,{value:l.sessionId}),r.jsx(NN,{sessionId:l.sessionId,disabled:!l.resumeSupported,disabledReason:"Resume not supported for this agent",onError:s,onNotice:a})]})]}),r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(mn,{status:l.status}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Lr(l.started)})]}),r.jsx(RN,{session:l,onMarkStopped:CF})]},l.sessionId))})})}const qm="Cost / Usage";function DN({summary:e,error:t}){return t&&!e?r.jsx(We,{title:qm,children:r.jsx(Nt,{title:"Couldn't load usage",description:t})}):e?e.lastEventDay===null?r.jsx(We,{title:qm,children:r.jsx(Nt,{title:"No usage recorded yet",description:"Cost and token totals appear here once the usage collector records activity for this assignment."})}):r.jsx(We,{title:qm,children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(ij,{label:"Total cost",value:od(e.totalCost)}),r.jsx(ij,{label:"Total tokens",value:sd(e.totalTokens)})]}),e.byModel.length>1?r.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),r.jsx("div",{className:"space-y-1",children:e.byModel.map(n=>r.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[r.jsx(Od,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono text-xs text-foreground",title:n.model,children:n.model})]}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[sd(n.totalTokens)," · ",od(n.totalCost)]})]},n.model))})]}):null,r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last usage recorded ",hR(e.lastEventDay)]})]})}):null}function ij({label:e,value:t}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("p",{className:"text-lg font-semibold tabular-nums text-foreground",children:t})]})}function $N({open:e,action:t,assignmentTitle:n,loading:s=!1,onConfirm:a,onOpenChange:l}){const[c,u]=f.useState("");f.useEffect(()=>{e||u("")},[e,t==null?void 0:t.command]);const p=f.useMemo(()=>t&&t.command==="block"?"Blocked Reason":"Reason",[t]);if(!t)return null;const m=`${t.label} "${n}"`,h=s?"Applying...":t.label,g=c.trim()||void 0;return r.jsx(Gn,{open:e,onOpenChange:y=>s?void 0:l(y),children:r.jsx(zn,{className:"max-w-xl",children:r.jsxs("form",{className:"space-y-5",onSubmit:y=>{y.preventDefault(),a(g)},children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:m}),r.jsx(es,{children:t.description})]}),t.warning?r.jsx("div",{className:"rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:t.warning}):null,r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:p}),r.jsx("textarea",{value:c,onChange:y=>u(y.target.value),autoFocus:!0,rows:4,disabled:s,placeholder:"Optional context for why this assignment is blocked.",className:"editor-textarea min-h-[120px] bg-background/95 font-sans"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave this blank to continue without a written reason."})]}),r.jsxs(xs,{children:[r.jsx("button",{type:"button",onClick:()=>l(!1),disabled:s,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:s,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h})]})]})})})}function sa({open:e,title:t,description:n,confirmLabel:s,cancelLabel:a="Cancel",loading:l=!1,destructive:c=!1,onConfirm:u,onOpenChange:p}){return r.jsx(Ga,{open:e,onOpenChange:m=>l?void 0:p(m),children:r.jsxs(Bo,{children:[r.jsxs(Ya,{children:[r.jsx(Uo,{children:t}),r.jsx(Vo,{children:n})]}),r.jsxs(Ja,{children:[r.jsx(Ul,{disabled:l,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:a}),r.jsx(oo,{disabled:l,className:`shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50 ${c?"border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90":"shell-action--cta"}`,onClick:m=>{m.preventDefault(),u()},children:l?"Working...":s})]})]})})}const EF=/^[a-z0-9][a-z0-9_-]*$/,LN=["first","last","none"];class ON extends Error{constructor(n,s){super(n);Zb(this,"fieldErrors");this.name="AgentsConfigError",this.fieldErrors=s}}const Ex={agents:[],custom:!1};let Xa=null,Ka=null,vd=0;const _h=new Set;function IN(e){Xa=e;for(const t of _h)t(e)}function TF(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.id!="string"||t.id.length===0||typeof t.label!="string"||typeof t.command!="string")return null;const n={id:t.id,label:t.label,command:t.command};return Array.isArray(t.args)&&t.args.every(s=>typeof s=="string")&&(n.args=t.args),typeof t.promptArgPosition=="string"&&LN.includes(t.promptArgPosition)&&(n.promptArgPosition=t.promptArgPosition),typeof t.resolveFromShellAliases=="boolean"&&(n.resolveFromShellAliases=t.resolveFromShellAliases),typeof t.default=="boolean"&&(n.default=t.default),typeof t.model=="string"&&(n.model=t.model),typeof t.playbook=="string"&&(n.playbook=t.playbook),typeof t.launchPrompt=="string"&&(n.launchPrompt=t.launchPrompt),n}function Tx(e){if(!e||typeof e!="object")return Ex;const t=e,n=Array.isArray(t.agents)?t.agents:[],s=[];for(const a of n){const l=TF(a);l&&s.push(l)}return{agents:s,custom:t.custom===!0}}function PF(){if(Xa)return Promise.resolve(Xa);if(Ka)return Ka;const e=++vd;return Ka=fetch("/api/config/agents").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{Ka=null;const n=Tx(t);return e!==vd?Xa??n:(Xa=n,n)}).catch(()=>(Ka=null,Ex)),Ka}function MN(){const[e,t]=f.useState(()=>Xa??Ex);return f.useEffect(()=>{let n=!1;return PF().then(s=>{n||t(s)}),_h.add(t),()=>{n=!0,_h.delete(t)}},[]),e}async function _N(e){const t=await e.json().catch(()=>null),n=(t==null?void 0:t.error)??`HTTP ${e.status}`;return new ON(n,t==null?void 0:t.fieldErrors)}async function RF(e){++vd;const t=await fetch("/api/config/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:e})});if(!t.ok)throw await _N(t);const n=Tx(await t.json());return IN(n),n}async function AF(){++vd;const e=await fetch("/api/config/agents",{method:"DELETE"});if(!e.ok)throw await _N(e);const t=Tx(await e.json());return IN(t),t}const lj=/[A-Za-z0-9_-]/,DF=/^[a-z0-9]+(-[a-z0-9]+)*$/,cj=/(^|\s)@([A-Za-z0-9_-]+)/g,Fh="assignment";function $F(e,t){const n=Math.max(0,Math.min(t,e.length));let s=n;for(;s>0&&lj.test(e[s-1]);)s--;const a=s-1;if(a<0||e[a]!=="@"||a>0&&!/\s/.test(e[a-1]))return null;let l=n;for(;l<e.length&&lj.test(e[l]);)l++;return{start:a,end:l,partial:e.slice(a+1,n)}}function LF(e,t){const n=[Fh,...t.filter(c=>c!==Fh)],s=e.toLowerCase();if(s==="")return n;const a=[],l=[];for(const c of n){const u=c.toLowerCase();u.startsWith(s)?a.push(c):u.includes(s)&&l.push(c)}return[...a,...l]}function OF(e,t,n){const s=`@${n}`;return{text:e.slice(0,t.start)+s+e.slice(t.end),caret:t.start+s.length}}function IF(e,t){const n=t instanceof Set?t:new Set(t),s=[];cj.lastIndex=0;let a;for(;(a=cj.exec(e))!==null;){const l=a[2];l!==Fh&&(DF.test(l)?n.has(l)||s.push(`Playbook "${l}" is not installed — "@${l}" will be left as literal text.`):s.push(`"@${l}" is not a valid playbook token — it will be left as literal text.`))}return s}const uj=2e3;function MF({open:e,assignmentId:t,agentId:n,onConfirm:s,onOpenChange:a}){const[l,c]=f.useState(""),[u,p]=f.useState([]),[m,h]=f.useState(!1),[g,y]=f.useState(null),[b,E]=f.useState(0),[j,w]=f.useState(0),[k,C]=f.useState(!1),N=f.useRef(null);f.useEffect(()=>{if(!e)return;let I=!1;h(!0),y(null),C(!1);const H=new URLSearchParams({assignment:t});return n&&H.set("agent",n),fetch(`/api/launch/prompt?${H.toString()}`).then(async J=>{if(!J.ok){const ne=await J.json().catch(()=>null);throw new Error((ne==null?void 0:ne.error)??`HTTP ${J.status}`)}return await J.json()}).then(J=>{I||(c(J.template??""),p(J.knownPlaybookSlugs??[]),E((J.template??"").length))}).catch(J=>{I||y(J instanceof Error?J.message:String(J))}).finally(()=>{I||h(!1)}),()=>{I=!0}},[e,t,n]);const T=$F(l,b),O=T?LF(T.partial,u):[],P=e&&!m&&!k&&O.length>0,D=IF(l,u),L=l.length>uj;function W(I){c(I.target.value.replace(/[\r\n]+/g," ")),E(I.target.selectionStart??I.target.value.length),w(0),C(!1)}function B(I){E(I.currentTarget.selectionStart??l.length),w(0)}function $(I){if(!T||!I)return;const H=OF(l,T,I);c(H.text),E(H.caret),w(0),requestAnimationFrame(()=>{const J=N.current;J&&(J.focus(),J.setSelectionRange(H.caret,H.caret))})}function K(I){P&&(I.key==="ArrowDown"?(I.preventDefault(),w(H=>Math.min(H+1,O.length-1))):I.key==="ArrowUp"?(I.preventDefault(),w(H=>Math.max(H-1,0))):(I.key==="Enter"||I.key==="Tab")&&(I.preventDefault(),$(O[j])))}function re(){L||m||(s(l),a(!1))}return r.jsx(Gn,{open:e,onOpenChange:a,children:r.jsxs(zn,{onEscapeKeyDown:I=>{P&&(I.preventDefault(),C(!0))},children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Edit launch prompt"}),r.jsxs(es,{children:["The first message the agent starts with. ",r.jsx("code",{children:"@assignment"})," and"," ",r.jsx("code",{children:"@<playbook>"})," tokens resolve at launch. This edit applies to this launch only."]})]}),g?r.jsxs("p",{className:"text-sm text-error-foreground",children:["Couldn't load the prompt: ",g]}):r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:N,value:l,disabled:m,rows:4,spellCheck:!1,placeholder:m?"Loading…":"@assignment Run @<playbook> end-to-end.",onChange:W,onKeyDown:K,onKeyUp:B,onClick:B,className:ke("editor-input w-full font-mono text-sm",L&&"border-error-foreground")}),P&&r.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:O.map((I,H)=>r.jsx("li",{children:r.jsxs("button",{type:"button",role:"option","aria-selected":H===j,onMouseDown:J=>{J.preventDefault(),$(I)},className:ke("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",H===j&&"bg-accent"),children:[r.jsx("span",{className:"text-muted-foreground",children:"@"}),r.jsx("span",{className:"truncate",children:I})]})},I))})]}),D.length>0&&!g&&r.jsx("ul",{className:"space-y-0.5 text-[11px] text-error-foreground",children:D.map(I=>r.jsx("li",{children:I},I))}),L&&r.jsxs("p",{className:"text-[11px] text-error-foreground",children:["Too long — keep it under ",uj," characters (",l.length,")."]}),r.jsxs(xs,{children:[r.jsx("button",{type:"button",className:"shell-action mt-0",onClick:()=>a(!1),children:"Cancel"}),r.jsx("button",{type:"button",className:"shell-action mt-0 shell-action--cta",disabled:m||L||g!==null,onClick:re,children:"Launch"})]})]})})}function FN({target:e,worktreePath:t=null,repository:n=null,size:s="default",title:a}){const l=e.kind==="assignment"&&!t&&!n,c=PN(),[u,p]=f.useState(null),h=MN().agents,[g,y]=f.useState(null);f.useEffect(()=>{h.length!==0&&y(D=>D&&h.some(W=>W.id===D)?D:(h.find(W=>W.default)??h[0]).id)},[h]);const b=e.kind==="assignment"&&h.length>1,E=h.find(D=>D.id===g)??null,j=f.useRef(null),[w,k]=f.useState(!1);f.useEffect(()=>{if(!w)return;function D(W){j.current&&!j.current.contains(W.target)&&k(!1)}function L(W){W.key==="Escape"&&k(!1)}return document.addEventListener("mousedown",D),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",L)}},[w]);function C(D){e.kind==="assignment"?p({agentId:D}):c.open(e,void 0,D)}const N=e.kind==="assignment"?"Open this assignment in your configured terminal + agent":"Resume this session in its agent",T="Set a workspace path first — see the Workspace Before Code playbook",O=ke("shell-action",s==="compact"&&"inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50");if(l)return r.jsxs("button",{type:"button",disabled:!0,title:T,className:O,"aria-disabled":!0,children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:"Open in agent"})]});const P=e.kind==="session"?"Open":"Open in agent";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative inline-flex",ref:j,children:[r.jsxs("div",{className:"inline-flex items-stretch",children:[r.jsxs("button",{type:"button",onClick:()=>C(g??void 0),disabled:c.pending,title:(a??N)+(b&&E?` (${E.label})`:""),className:ke(O,b&&"rounded-r-none"),children:[r.jsx(Za,{className:"size-3.5"}),r.jsx("span",{children:P})]}),b&&r.jsx("button",{type:"button",onClick:()=>k(D=>!D),disabled:c.pending,"aria-haspopup":"menu","aria-expanded":w,"aria-label":"Choose which agent to launch",title:"Choose which agent to launch",className:ke(O,"-ml-px rounded-l-none",s==="compact"?"px-1":"px-1.5"),children:r.jsx(br,{className:ke("size-3.5 opacity-70 transition-transform",w&&"rotate-180")})})]}),w&&b&&r.jsxs("div",{role:"menu","aria-label":"Open with agent",className:"absolute right-0 top-full z-30 mt-1 min-w-[180px] overflow-hidden rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsx("div",{className:"px-2.5 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Open with agent"}),h.map(D=>r.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":D.id===g,onClick:()=>{y(D.id),k(!1),C(D.id)},className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent",children:[r.jsx(Qr,{className:ke("size-3.5 shrink-0",D.id===g?"opacity-100":"opacity-0")}),r.jsx("span",{className:"truncate",children:D.label}),D.default&&r.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"default"})]},D.id))]})]}),c.dialogs,e.kind==="assignment"&&u&&r.jsx(MF,{open:!0,assignmentId:e.id,agentId:u.agentId,onConfirm:D=>{c.open(e,void 0,u.agentId,D)},onOpenChange:D=>{D||p(null)}})]})}const Gm="w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";function zN({projectSlug:e,assignmentSlug:t,assignmentId:n,defaultBranch:s,defaultParentBranch:a="main",onCreated:l}){const c=e&&t?{kind:"project-nested",projectSlug:e,assignmentSlug:t}:{kind:"standalone",assignmentId:n},[u,p]=f.useState(!1),[m,h]=f.useState("new-branch"),[g,y]=f.useState(null),[b,E]=f.useState(null),[j,w]=f.useState(""),[k,C]=f.useState(!1),[N,T]=f.useState(""),[O,P]=f.useState([]),[D,L]=f.useState(!1),[W,B]=f.useState(null),[$,K]=f.useState(""),[re,I]=f.useState(null),[H,J]=f.useState(null),[ne,_]=f.useState(""),[G,A]=f.useState(s),[z,ee]=f.useState(!1),[M,ue]=f.useState(null);f.useEffect(()=>{if(!u)return;let X=!1;return h("new-branch"),y(null),E(null),w(""),C(!1),T(""),P([]),L(!1),B(null),K(""),I(null),J(null),_(""),A(s),ue(null),(c.kind==="project-nested"?xF(c.projectSlug):yF(c.assignmentId)).then(Oe=>{if(!X)if(y(Oe),Oe.length===0)C(!0);else{const Xe=Oe.find(rt=>rt.source==="project"),Me=Oe.find(rt=>rt.source==="sibling");w((Xe==null?void 0:Xe.path)??(Me==null?void 0:Me.path)??Oe[0].path)}}).catch(Oe=>{X||(E(Oe.message),y([]),C(!0))}),(c.kind==="project-nested"?SF(c.projectSlug,c.assignmentSlug):NF(c.assignmentId)).then(Oe=>{X||I(Oe)}).catch(Oe=>{X||(J(Oe.message),I([]))}),()=>{X=!0}},[u,s,a,e,t,n]);const ge=m==="branch-off"?(re??[]).find(X=>X.id===ne)??null:null,V=m==="branch-off"?(ge==null?void 0:ge.repository)??"":k?N.trim():j;f.useEffect(()=>{if(!u||m!=="new-branch")return;if(!V){P([]),B(null),L(!1),K("");return}let X=!1;return L(!0),B(null),K(""),(c.kind==="project-nested"?jF(c.projectSlug,c.assignmentSlug,V):kF(c.assignmentId,V)).then(Ne=>{if(X)return;P(Ne.branches);const Oe=(Ne.defaultBranch&&Ne.branches.includes(Ne.defaultBranch)?Ne.defaultBranch:Ne.branches.includes(a)?a:Ne.branches[0])??"";K(Oe),L(!1)}).catch(Ne=>{X||(P([]),B(Ne.message),L(!1))}),()=>{X=!0}},[u,m,V,a,e,t,n]);const ae=pF(G.trim()),me=f.useMemo(()=>!V||!G.trim()?"":`${V.replace(/\/+$/,"")}/.worktrees/${G.trim()}`,[V,G]),ve=g!==null&&g.length===0,Se=re!==null&&re.length===0,he=X=>{X!==m&&(h(X),_(""),ue(null),X==="branch-off"&&(K(""),P([]),B(null),L(!1)))},Je=X=>{_(X);const Ie=(re??[]).find(Ne=>Ne.id===X);K((Ie==null?void 0:Ie.branch)??"")},Ye=z||ae!==null||!V||!$.trim()||(m==="new-branch"?g===null||D:re===null||!ne),at=async()=>{ee(!0),ue(null);try{const X={repository:V,branch:G.trim(),parentBranch:$.trim()};c.kind==="project-nested"?await bF(c.projectSlug,c.assignmentSlug,X):await vF(c.assignmentId,X),p(!1),l()}catch(X){X instanceof Nx?ue({message:X.message,stderr:X.stderr}):X instanceof Error?ue({message:X.message}):ue({message:String(X)})}finally{ee(!1)}};return r.jsxs(Gn,{open:u,onOpenChange:X=>z?void 0:p(X),children:[r.jsxs("button",{type:"button",className:"shell-action inline-flex items-center gap-1.5",onClick:()=>p(!0),children:[r.jsx(hP,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{children:"Create worktree"})]}),r.jsxs(zn,{children:[r.jsxs(Ir,{children:[r.jsx(Bn,{children:"Create worktree"}),r.jsxs(es,{children:["Creates a git worktree at ",r.jsx("code",{children:"<repo>/.worktrees/<branch>"})," and records the workspace fields on this assignment's frontmatter."]})]}),r.jsxs("div",{className:"grid gap-4 text-sm",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-1 rounded-md border border-border/70 p-1",children:[r.jsx("button",{type:"button",disabled:z,onClick:()=>he("new-branch"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="new-branch"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"New branch from repo"}),r.jsx("button",{type:"button",disabled:z,onClick:()=>he("branch-off"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${m==="branch-off"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"Branch off another assignment"})]}),m==="new-branch"?r.jsxs(r.Fragment,{children:[ve?r.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:["No repositories configured for this project. Enter a repo path below, or add a"," ",r.jsx("code",{children:"repositories:"})," list to ",r.jsx("code",{children:"project.md"}),"."]}):null,b?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load repository candidates: ",b]}):null,r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Repository"}),r.jsx("select",{className:Gm,value:j,onChange:X=>w(X.target.value),disabled:z||g===null||k,children:(g??[]).map(X=>r.jsxs("option",{value:X.path,children:[X.path,X.source==="project"?" (project)":X.sourceAssignmentSlug?` (sibling — ${X.sourceAssignmentSlug})`:" (sibling)"]},`${X.source}:${X.path}`))}),ve?null:r.jsx("button",{type:"button",className:"justify-self-start text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:z,onClick:()=>C(X=>!X),children:k?"Use a listed repository":"Enter a custom repository path (advanced)"}),k?r.jsx("input",{className:"mt-1 w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",placeholder:"/absolute/path/to/repo",value:N,onChange:X=>T(X.target.value),disabled:z}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Parent branch"}),r.jsx("select",{className:Gm,value:$,onChange:X=>K(X.target.value),disabled:z||D||O.length===0,children:D?r.jsx("option",{value:"",children:"Loading branches…"}):O.length===0?r.jsx("option",{value:"",children:W?"Could not load branches":V?"No branches found":"— pick a repository —"}):O.map(X=>r.jsx("option",{value:X,children:X},X))}),W?r.jsxs("span",{className:"text-[11px] text-error-foreground",children:["Could not load branches: ",W]}):null]})]}):r.jsxs(r.Fragment,{children:[H?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load assignments: ",H]}):null,Se?r.jsx("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:"No other assignments with a configured workspace to branch off. Create a worktree for one first, or use “New branch from repo”."}):r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Source assignment"}),r.jsxs("select",{className:Gm,value:ne,onChange:X=>Je(X.target.value),disabled:z||re===null,children:[r.jsx("option",{value:"",children:"— select an assignment —"}),(re??[]).map(X=>r.jsxs("option",{value:X.id,children:[X.title," (",X.branch,")"]},X.id))]})]}),ge?r.jsxs("div",{className:"grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2 text-xs",children:[r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Repository (from source)"}),r.jsx("code",{className:"break-all",children:ge.repository})]}),r.jsxs("div",{className:"grid gap-0.5",children:[r.jsx("span",{className:"font-medium text-muted-foreground",children:"Parent branch (from source)"}),r.jsx("code",{children:ge.branch})]})]}):null]}),r.jsxs("label",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"New branch name"}),r.jsx("input",{className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",type:"text",value:G,onChange:X=>A(X.target.value),disabled:z}),ae?r.jsx("span",{className:"text-[11px] text-error-foreground",children:ae}):null]}),r.jsxs("div",{className:"grid gap-1",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Worktree path"}),r.jsx("code",{className:"rounded-md border border-border bg-muted px-2 py-1 text-xs break-all",children:me||r.jsx("span",{className:"opacity-60",children:"— pick a repo & branch —"})})]}),M?r.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:[r.jsx("div",{className:"font-medium",children:M.message}),M.stderr?r.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-[11px] opacity-90",children:M.stderr}):null]}):null]}),r.jsxs(xs,{children:[r.jsx(F3,{disabled:z,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",disabled:Ye,onClick:()=>void at(),className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:z?"Working…":"Create worktree"})]})]})]})}function _F(e){const t=e.split(`
|
|
545
545
|
`),n=t.findIndex(c=>/^##\s+Acceptance Criteria\s*$/i.test(c.trim()));if(n===-1)return{acceptanceCriteria:[],summaryBody:e};let s=t.length;for(let c=n+1;c<t.length;c+=1)if(/^#{1,2}\s+\S/.test(t[c].trim())){s=c;break}const a=t.slice(n+1,s).map(c=>c.match(/^\s*[-*]\s+\[( |x|X)\]\s+(.*)$/)).filter(c=>!!c).map(c=>({checked:c[1].toLowerCase()==="x",text:c[2].trim()})),l=[...t.slice(0,n),...t.slice(s)].join(`
|
|
546
546
|
`).replace(/\n{3,}/g,`
|
|
547
547
|
|