syntaur 0.69.0 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dashboard/dist/assets/{_basePickBy-DKk6tHtk.js → _basePickBy-BfpzwNC3.js} +1 -1
  3. package/dashboard/dist/assets/{_baseUniq-DM-f7DWz.js → _baseUniq-wFEHBTCT.js} +1 -1
  4. package/dashboard/dist/assets/{arc-ZBlA3YdV.js → arc-Bdcw4sCg.js} +1 -1
  5. package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-BUmvtGTF.js → architectureDiagram-2XIMDMQ5-BessFAtJ.js} +1 -1
  6. package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-B3qxWK6s.js → blockDiagram-WCTKOSBZ-CmjyyZPp.js} +1 -1
  7. package/dashboard/dist/assets/{c4Diagram-IC4MRINW-BEq_UJO-.js → c4Diagram-IC4MRINW-dT6p8cwc.js} +1 -1
  8. package/dashboard/dist/assets/channel-BOguQ5S4.js +1 -0
  9. package/dashboard/dist/assets/{chunk-4BX2VUAB-C-Y9ryMm.js → chunk-4BX2VUAB-BlY-k8DY.js} +1 -1
  10. package/dashboard/dist/assets/{chunk-55IACEB6-CGdtbsjw.js → chunk-55IACEB6-CtQ0p0jb.js} +1 -1
  11. package/dashboard/dist/assets/{chunk-FMBD7UC4-DllxJhUp.js → chunk-FMBD7UC4-DEevt_Yh.js} +1 -1
  12. package/dashboard/dist/assets/{chunk-JSJVCQXG-jjMM8O5F.js → chunk-JSJVCQXG-CpjLL7Nh.js} +1 -1
  13. package/dashboard/dist/assets/{chunk-KX2RTZJC-B_6BPltQ.js → chunk-KX2RTZJC-BWNRms_o.js} +1 -1
  14. package/dashboard/dist/assets/{chunk-NQ4KR5QH-D0hJiXHp.js → chunk-NQ4KR5QH-qo2zbylv.js} +1 -1
  15. package/dashboard/dist/assets/{chunk-QZHKN3VN-BCWo4hLS.js → chunk-QZHKN3VN-DRvojtzc.js} +1 -1
  16. package/dashboard/dist/assets/{chunk-WL4C6EOR-DH_jEAwg.js → chunk-WL4C6EOR-A40iPU5N.js} +1 -1
  17. package/dashboard/dist/assets/classDiagram-VBA2DB6C-BLSHooma.js +1 -0
  18. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-BLSHooma.js +1 -0
  19. package/dashboard/dist/assets/clone-iSEXw5tA.js +1 -0
  20. package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-5ld00TOH.js → cose-bilkent-S5V4N54A-CYaO7nsk.js} +1 -1
  21. package/dashboard/dist/assets/{dagre-KLK3FWXG-Cnu6eQWy.js → dagre-KLK3FWXG-NX3inwVZ.js} +1 -1
  22. package/dashboard/dist/assets/{diagram-E7M64L7V-_CBBKNP-.js → diagram-E7M64L7V-D9cJwhQW.js} +1 -1
  23. package/dashboard/dist/assets/{diagram-IFDJBPK2-DE6WjIb1.js → diagram-IFDJBPK2-Bo5sFrMg.js} +1 -1
  24. package/dashboard/dist/assets/{diagram-P4PSJMXO-DpW7UzNK.js → diagram-P4PSJMXO-DfRH0XU7.js} +1 -1
  25. package/dashboard/dist/assets/{erDiagram-INFDFZHY-BD2409fE.js → erDiagram-INFDFZHY-BgP1bwgw.js} +1 -1
  26. package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-1p0khhFI.js → flowDiagram-PKNHOUZH-C8Wws1ci.js} +1 -1
  27. package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-B2zFyA4s.js → ganttDiagram-A5KZAMGK-BgJhUuj8.js} +1 -1
  28. package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-bH-4YH7h.js → gitGraphDiagram-K3NZZRJ6-CI9FgCgo.js} +1 -1
  29. package/dashboard/dist/assets/{graph-BT24B6iQ.js → graph-B_7GyeiA.js} +1 -1
  30. package/dashboard/dist/assets/{index-Cxqr3rQB.js → index-CbndxFlO.js} +3 -3
  31. package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-CMzP4Hcg.js → infoDiagram-LFFYTUFH-BEtZcRxI.js} +1 -1
  32. package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-DMEmFC7M.js → ishikawaDiagram-PHBUUO56-0o9Bksuc.js} +1 -1
  33. package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-CAtzYQUm.js → journeyDiagram-4ABVD52K-RyRU3as7.js} +1 -1
  34. package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-d1JVbtvX.js → kanban-definition-K7BYSVSG-hLrHHizB.js} +1 -1
  35. package/dashboard/dist/assets/{layout-BVuI38I_.js → layout-w458wydd.js} +1 -1
  36. package/dashboard/dist/assets/{linear-Bc8PGMbp.js → linear-CnRlR5_w.js} +1 -1
  37. package/dashboard/dist/assets/{mermaid.core-UtwFYLNj.js → mermaid.core-DJ_9ty0Y.js} +4 -4
  38. package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-DHc5RCDj.js → mindmap-definition-YRQLILUH-C7TIzJVC.js} +1 -1
  39. package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-9anIsdIA.js → pieDiagram-SKSYHLDU-BZ9ysteM.js} +1 -1
  40. package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-FZ0D9HnU.js → quadrantDiagram-337W2JSQ-DpaMVSO1.js} +1 -1
  41. package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-BkjCvH_u.js → requirementDiagram-Z7DCOOCP-EXFcskZZ.js} +1 -1
  42. package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-DzqwYHDo.js → sankeyDiagram-WA2Y5GQK-BdImdXkY.js} +1 -1
  43. package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-BW4g5Ao-.js → sequenceDiagram-2WXFIKYE-CWN3faYf.js} +1 -1
  44. package/dashboard/dist/assets/{stateDiagram-RAJIS63D-D0tKU3Z0.js → stateDiagram-RAJIS63D-DIQdn-BF.js} +1 -1
  45. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-1u62oWzq.js +1 -0
  46. package/dashboard/dist/assets/{timeline-definition-YZTLITO2-Bu269QDX.js → timeline-definition-YZTLITO2-DMTIpUOE.js} +1 -1
  47. package/dashboard/dist/assets/{treemap-KZPCXAKY-BGu_rrva.js → treemap-KZPCXAKY-Y2AH2GB7.js} +1 -1
  48. package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-Cx_n5FRZ.js → vennDiagram-LZ73GAT5-BF4bJK-l.js} +1 -1
  49. package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-BOJsKV_W.js → xychartDiagram-JWTSCODW-DH-tOBC5.js} +1 -1
  50. package/dashboard/dist/index.html +1 -1
  51. package/dist/dashboard/server.js +1427 -550
  52. package/dist/dashboard/server.js.map +1 -1
  53. package/dist/index.js +2816 -1559
  54. package/dist/index.js.map +1 -1
  55. package/dist/launch/index.js +913 -141
  56. package/dist/launch/index.js.map +1 -1
  57. package/package.json +1 -1
  58. package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
  59. package/platforms/claude-code/hooks/enforce-boundaries.sh +49 -16
  60. package/platforms/claude-code/hooks/session-cleanup.sh +4 -2
  61. package/platforms/claude-code/skills/add-memory/SKILL.md +3 -2
  62. package/platforms/claude-code/skills/add-resource/SKILL.md +3 -2
  63. package/platforms/claude-code/skills/bundle-worktree/SKILL.md +3 -3
  64. package/platforms/claude-code/skills/capture-artifacts/SKILL.md +2 -2
  65. package/platforms/claude-code/skills/claim-resource/SKILL.md +3 -3
  66. package/platforms/claude-code/skills/clear-assignment/SKILL.md +9 -27
  67. package/platforms/claude-code/skills/complete-assignment/SKILL.md +3 -3
  68. package/platforms/claude-code/skills/create-assignment/SKILL.md +2 -2
  69. package/platforms/claude-code/skills/extend-resource/SKILL.md +2 -2
  70. package/platforms/claude-code/skills/grab-assignment/SKILL.md +17 -12
  71. package/platforms/claude-code/skills/grab-bundle/SKILL.md +10 -6
  72. package/platforms/claude-code/skills/log-progress/SKILL.md +6 -4
  73. package/platforms/claude-code/skills/plan-assignment/SKILL.md +3 -3
  74. package/platforms/claude-code/skills/plan-bundle/SKILL.md +4 -3
  75. package/platforms/claude-code/skills/replan/SKILL.md +9 -6
  76. package/platforms/claude-code/skills/resume-session/SKILL.md +14 -8
  77. package/platforms/claude-code/skills/save-session-summary/SKILL.md +4 -4
  78. package/platforms/claude-code/skills/set-workspace/SKILL.md +9 -6
  79. package/platforms/claude-code/skills/syntaur-protocol/SKILL.md +9 -7
  80. package/platforms/claude-code/skills/syntaur-protocol/references/file-ownership.md +1 -1
  81. package/platforms/claude-code/skills/syntaur-worktree/SKILL.md +11 -7
  82. package/platforms/codex/.codex-plugin/plugin.json +1 -1
  83. package/platforms/codex/scripts/enforce-boundaries.sh +74 -12
  84. package/platforms/codex/scripts/session-cleanup.sh +20 -13
  85. package/platforms/codex/skills/add-memory/SKILL.md +3 -2
  86. package/platforms/codex/skills/add-resource/SKILL.md +3 -2
  87. package/platforms/codex/skills/bundle-worktree/SKILL.md +3 -3
  88. package/platforms/codex/skills/capture-artifacts/SKILL.md +2 -2
  89. package/platforms/codex/skills/claim-resource/SKILL.md +3 -3
  90. package/platforms/codex/skills/clear-assignment/SKILL.md +9 -27
  91. package/platforms/codex/skills/complete-assignment/SKILL.md +3 -3
  92. package/platforms/codex/skills/create-assignment/SKILL.md +2 -2
  93. package/platforms/codex/skills/extend-resource/SKILL.md +2 -2
  94. package/platforms/codex/skills/grab-assignment/SKILL.md +17 -12
  95. package/platforms/codex/skills/grab-bundle/SKILL.md +10 -6
  96. package/platforms/codex/skills/log-progress/SKILL.md +6 -4
  97. package/platforms/codex/skills/plan-assignment/SKILL.md +3 -3
  98. package/platforms/codex/skills/plan-bundle/SKILL.md +4 -3
  99. package/platforms/codex/skills/replan/SKILL.md +9 -6
  100. package/platforms/codex/skills/resume-session/SKILL.md +14 -8
  101. package/platforms/codex/skills/save-session-summary/SKILL.md +4 -4
  102. package/platforms/codex/skills/set-workspace/SKILL.md +9 -6
  103. package/platforms/codex/skills/syntaur-protocol/SKILL.md +9 -7
  104. package/platforms/codex/skills/syntaur-protocol/references/file-ownership.md +1 -1
  105. package/platforms/codex/skills/syntaur-worktree/SKILL.md +11 -7
  106. package/platforms/hermes/plugins/syntaur/__init__.py +29 -3
  107. package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
  108. package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
  109. package/platforms/hermes/plugins/syntaur/boundary.py +18 -9
  110. package/platforms/pi/extensions/syntaur/index.ts +84 -29
  111. package/skills/add-memory/SKILL.md +3 -2
  112. package/skills/add-resource/SKILL.md +3 -2
  113. package/skills/bundle-worktree/SKILL.md +3 -3
  114. package/skills/capture-artifacts/SKILL.md +2 -2
  115. package/skills/claim-resource/SKILL.md +3 -3
  116. package/skills/clear-assignment/SKILL.md +9 -27
  117. package/skills/complete-assignment/SKILL.md +3 -3
  118. package/skills/create-assignment/SKILL.md +2 -2
  119. package/skills/extend-resource/SKILL.md +2 -2
  120. package/skills/grab-assignment/SKILL.md +17 -12
  121. package/skills/grab-bundle/SKILL.md +10 -6
  122. package/skills/log-progress/SKILL.md +6 -4
  123. package/skills/plan-assignment/SKILL.md +3 -3
  124. package/skills/plan-bundle/SKILL.md +4 -3
  125. package/skills/replan/SKILL.md +9 -6
  126. package/skills/resume-session/SKILL.md +14 -8
  127. package/skills/save-session-summary/SKILL.md +4 -4
  128. package/skills/set-workspace/SKILL.md +9 -6
  129. package/skills/syntaur-protocol/SKILL.md +9 -7
  130. package/skills/syntaur-protocol/references/file-ownership.md +1 -1
  131. package/skills/syntaur-worktree/SKILL.md +11 -7
  132. package/dashboard/dist/assets/channel-fypxffzQ.js +0 -1
  133. package/dashboard/dist/assets/classDiagram-VBA2DB6C-1KnjQvtL.js +0 -1
  134. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-1KnjQvtL.js +0 -1
  135. package/dashboard/dist/assets/clone-CKMabBhS.js +0 -1
  136. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-DxWQhjNO.js +0 -1
@@ -557,7 +557,7 @@ Please change the parent <Route path="${j}"> to <Route path="${j==="/"?"*":`${j}
557
557
  ${t}: ${JSON.stringify(n)}
558
558
  ---
559
559
  ${e}`;const o=r[1],i=r[2],a=r[3],l=e.slice(r[0].length),u=JSON.stringify(n),f=new RegExp(`^${t}:\\s*.*$`,"m");let p;return f.test(i)?p=i.replace(f,`${t}: ${u}`):p=`${i}
560
- ${t}: ${u}`,`${o}${p}${a}${l}`}const D5=/^[a-z0-9][a-z0-9-]*$/;function $5(e){const{playbooks:t,projectSlug:n,currentProjectTitle:r,currentProjectWorkspace:o,wsPrefix:i,refetchPlaybooks:a,navigate:l,toggleTheme:u}=e,f=[];if(f.push({id:"new-workspace",title:"New Workspace",subtitle:"Create a Syntaur workspace",group:"Create",keywords:["new","create","workspace"],bindableKind:"new-workspace",flow:{steps:[{kind:"text",id:"name",label:"Workspace name",placeholder:"lowercase, hyphenated (e.g. acme-app)",required:!0,pattern:{regex:D5,message:"Use lowercase letters, digits, and hyphens (e.g. acme-app). Must start with a letter or digit."}}],submit:async(p,h)=>{const g=(p.name??"").trim();if(!g)throw new Error("Name is required");const y=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})});if(!y.ok){const k=await y.json().catch(()=>({}));throw new Error(k.error||`Failed to create workspace (HTTP ${y.status})`)}h.navigate(`/w/${g}/projects`)}}}),f.push({id:"new-project",title:"New Project",subtitle:"Create a project (pick workspace)",group:"Create",keywords:["new","create","project"],bindableKind:"new-project",flow:{steps:[{kind:"picker",id:"workspace",label:"Workspace",emptyMessage:'No workspaces yet — create one with "New Workspace"',loadOptions:async()=>{const{workspaces:p,hasUngrouped:h}=await F1(),g=[{value:"_ungrouped",label:"Ungrouped",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});return g}},{kind:"text",id:"title",label:"Project title",placeholder:"e.g. Marketing site rebuild",required:!0}],submit:async(p,h)=>{const g=(p.workspace??"").trim(),y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");let v=await ry("/api/templates/project");v=Qi(v,"slug",k),v=Qi(v,"title",y),g&&g!=="_ungrouped"&&(v=Qi(v,"workspace",g));const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create project (HTTP ${b.status})`);const S=g&&g!=="_ungrouped"?`/w/${g}/projects/${j.slug??k}`:`/projects/${j.slug??k}`;h.navigate(S)}}}),f.push({id:"new-todo",title:"New Todo",subtitle:"Pick scope (global / workspace / project)",group:"Create",keywords:["new","create","todo","task"],bindableKind:"new-todo",flow:{steps:[{kind:"picker",id:"scope",label:"Scope",loadOptions:async()=>{const[{workspaces:p},h]=await Promise.all([F1(),z1()]),g=[{value:"_ungrouped",label:"Global",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});for(const y of h){const k=y.workspace??"_ungrouped";g.push({value:k,label:`${y.title}`,hint:`project · ${y.workspace??"ungrouped"}`})}return g}},{kind:"text",id:"description",label:"Description",placeholder:"Describe the todo…",required:!0}],submit:async p=>{const h=(p.scope??"_ungrouped").trim()||"_ungrouped",g=(p.description??"").trim();if(!g)throw new Error("Description is required");await rw(h,g)}}}),f.push({id:"new-assignment",title:"New Assignment",subtitle:"Pick standalone or a project",group:"Create",keywords:["new","create","assignment"],bindableKind:"new-assignment",flow:{steps:[{kind:"picker",id:"project",label:"Project",loadOptions:async()=>{const p=await z1(),h=[{value:"_standalone",label:"Standalone",hint:"one-off / not in a project"}];for(const g of p)h.push({value:g.slug,label:g.title,hint:g.workspace?`workspace · ${g.workspace}`:"ungrouped"});return h}},{kind:"text",id:"title",label:"Assignment title",placeholder:"What needs to get done?",required:!0}],submit:async(p,h)=>{var N;const g=(p.project??"_standalone").trim()||"_standalone",y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");if(g==="_standalone"){let C=await ry("/api/templates/assignment?standalone=1");C=Qi(C,"slug",k),C=Qi(C,"title",y);const P=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:C})}),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||`Failed to create assignment (HTTP ${P.status})`);const R=((N=T==null?void 0:T.assignment)==null?void 0:N.id)??(T==null?void 0:T.id);R?h.navigate(`/assignments/${R}`):h.navigate("/assignments");return}let v=await ry("/api/templates/assignment");v=Qi(v,"slug",k),v=Qi(v,"title",y);const b=await fetch(`/api/projects/${encodeURIComponent(g)}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create assignment (HTTP ${b.status})`);const S=j.slug??k;h.navigate(`/projects/${g}/assignments/${S}`)}}}),f.push({id:"create-project-route",title:"New Project (advanced editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","project","advanced","editor"],run:()=>l(`${i}/create/project`)}),f.push({id:"create-standalone-assignment",title:"New Standalone Assignment (editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","assignment","standalone","one-off","editor"],run:()=>l(`${i}/assignments/new`)}),n&&f.push({id:`create-assignment-in-${n}`,title:`New Assignment in ${r??n}`,subtitle:n,group:"Create",keywords:["new","create","assignment",n],run:()=>l(`${i}/projects/${n}/create/assignment`)}),f.push({id:"create-playbook",title:"New Playbook",group:"Create",keywords:["new","create","playbook"],run:()=>l("/playbooks/create")}),f.push({id:"create-todo-global",title:"New Todo (global, quick)",subtitle:"Ungrouped, single-step",group:"Create",keywords:["new","create","todo","global","ungrouped","quick"],requiresInput:{placeholder:"Describe the todo…",runWithInput:async p=>{const h=p.trim();h&&await ny("_ungrouped",h)}}}),i){const p=i.replace(/^\/w\//,"");f.push({id:`create-todo-workspace-${p}`,title:`New Todo in workspace ${p}`,subtitle:p,group:"Create",keywords:["new","create","todo","workspace",p],requiresInput:{placeholder:`Describe the todo for workspace ${p}…`,runWithInput:async h=>{const g=h.trim();g&&await ny(p,g)}}})}n&&o&&f.push({id:`create-todo-project-${n}`,title:`New Todo in project ${r??n}`,subtitle:`${n} · workspace ${o}`,group:"Create",keywords:["new","create","todo","project",n,o],requiresInput:{placeholder:`Describe the todo for project ${r??n}…`,runWithInput:async p=>{const h=p.trim();h&&await ny(o,h)}}});for(const p of t)f.push({id:`toggle-playbook-${p.slug}`,title:`Toggle Playbook: ${p.name}`,subtitle:p.enabled?"enabled":"disabled",group:"Toggle",keywords:["toggle","playbook",p.slug,...p.tags??[]],run:()=>_5(p.slug,p.enabled,a)});return f.push({id:"toggle-theme",title:"Toggle theme",subtitle:"Light / dark",group:"Theme",keywords:["theme","toggle","light","dark","appearance"],run:()=>u()}),f}const I5=["low","medium","high","critical"],fm={status:{kind:"enum"},priority:{kind:"ordinal",order:I5},type:{kind:"enum"},assignee:{kind:"string",noneSentinel:!0},project:{kind:"string",noneSentinel:!0},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},archived:{kind:"bool"},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title},created:{kind:"timestamp"},updated:{kind:"timestamp"},completedat:{kind:"timestamp",get:e=>e.completedAt},statusage:{kind:"duration",get:e=>e.statusAge},phase:{kind:"enum"},disposition:{kind:"enum"},phaseage:{kind:"duration",get:e=>e.phaseAge},hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},progressstaledays:{kind:"duration",get:e=>e.progressStaleDays},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function M5(e,t){return e[t.toLowerCase()]??null}function Mr(e,t,n){return e.get?e.get(n):n[t]??n[t.toLowerCase()]}class br extends Error{constructor(t){super(t.map(n=>`${n.message} (at ${n.pos})`).join("; ")),this.errors=t,this.name="CompileError"}}function fT(e){const[t,n,r]=e.raw.split("-").map(a=>parseInt(a,10)),o=new Date(t,n-1,r);if(o.getFullYear()!==t||o.getMonth()!==n-1||o.getDate()!==r)throw new br([{pos:e.pos,message:`Invalid date "${e.raw}"`}]);const i=new Date(t,n-1,r+1).getTime();return[o.getTime(),i]}function Ab(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.length>0){const t=Date.parse(e);return Number.isNaN(t)?null:t}return null}function zu(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function sy(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function L5(e){return e==null||e===""}function Fp(e,t,n,r){switch(e.kind){case"enum":case"string":return e.noneSentinel&&n.raw.toLowerCase()==="none"?o=>L5(Mr(e,t,o)):o=>sy(Mr(e,t,o),n.raw);case"substring":return o=>{const i=Mr(e,t,o);return typeof i=="string"&&i.toLowerCase().includes(n.raw.toLowerCase())};case"bool":{const o=n.raw.toLowerCase();if(o!=="true"&&o!=="false")throw new br([{pos:n.pos,message:`Field "${t}" is boolean — use ${t}:true or ${t}:false`}]);const i=o==="true";return a=>{const l=Mr(e,t,a),u=typeof l=="boolean"?l:l==="true"?!0:l==="false"||l===null||l===void 0||l===""?!1:null;return u!==null&&u===i}}case"number":{const o=n.num??zu(n.raw);if(o===null)throw new br([{pos:n.pos,message:`Field "${t}" is numeric — "${n.raw}" is not a number`}]);return i=>zu(Mr(e,t,i))===o}case"ordinal":return o=>sy(Mr(e,t,o),n.raw);case"list":return o=>{const i=Mr(e,t,o);return Array.isArray(i)&&i.some(a=>sy(a,n.raw))};case"timestamp":{if(n.type==="date"){const[o,i]=fT(n);return a=>{const l=Ab(Mr(e,t,a));return l!==null&&l>=o&&l<i}}throw new br([{pos:n.pos,message:`Field "${t}" is a timestamp — use a comparison (e.g. ${t} > -36h) or an absolute date (${t}:2026-06-01)`}])}case"duration":throw new br([{pos:r,message:`Field "${t}" is a duration — use a comparison (e.g. ${t} > 3d)`}])}}function O5(e,t,n,r){const o=(i,a)=>{switch(n){case"<":return i<a;case">":return i>a;case"<=":return i<=a;case">=":return i>=a;case"=":return i===a;case"!=":return i!==a;default:return!1}};switch(e.kind){case"number":{const i=r.num??zu(r.raw);if(i===null)throw new br([{pos:r.pos,message:`"${r.raw}" is not a number (field "${t}")`}]);return a=>{const l=zu(Mr(e,t,a));return l!==null&&o(l,i)}}case"ordinal":{const i=e.order??[],a=i.findIndex(l=>l.toLowerCase()===r.raw.toLowerCase());if(a<0)throw new br([{pos:r.pos,message:`"${r.raw}" is not a valid ${t} (expected one of: ${i.join(", ")})`}]);return l=>{const u=Mr(e,t,l),f=typeof u=="string"?i.findIndex(p=>p.toLowerCase()===u.toLowerCase()):-1;return f>=0&&o(f,a)}}case"timestamp":{if(r.type==="duration"){const a=(r.sign===0?-1:r.sign??-1)*(r.num??0);return(l,u)=>{const f=Ab(Mr(e,t,l));return f!==null&&o(f,u.now+a)}}if(r.type==="date"){const[i,a]=fT(r);return l=>{const u=Ab(Mr(e,t,l));if(u===null)return!1;switch(n){case"<":return u<i;case"<=":return u<a;case">":return u>=a;case">=":return u>=i;case"=":return u>=i&&u<a;case"!=":return u<i||u>=a;default:return!1}}}throw new br([{pos:r.pos,message:`Compare timestamp field "${t}" to a duration (e.g. -36h) or a date (YYYY-MM-DD)`}])}case"duration":{if(r.type!=="duration")throw new br([{pos:r.pos,message:`Compare duration field "${t}" to a duration literal (e.g. 3d)`}]);const i=r.num??0;return a=>{const l=zu(Mr(e,t,a));return l!==null&&o(l,i)}}case"enum":case"string":case"substring":case"list":{if(n==="=")return Fp(e,t,r,r.pos);if(n==="!="){const i=Fp(e,t,r,r.pos);return(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" does not support ordering comparisons (use ":" or "=").`}])}case"bool":{if(n==="="||n==="!="){const i=Fp(e,t,r,r.pos);return n==="="?i:(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" is boolean — use ${t}:true / ${t}:false`}])}}}function F5(e,t){const n=M5(t,e.field);if(!n)throw new br([{pos:e.pos,message:`Unknown field "${e.field}"`}]);if(e.op===":"){const r=e.values.map(o=>Fp(n,e.field,o,e.pos));return r.length===1?r[0]:(o,i)=>r.some(a=>a(o,i))}return O5(n,e.field,e.op,e.values[0])}function Bu(e,t){switch(e.kind){case"all":return()=>!0;case"atom":return F5(e,t);case"not":{const n=Bu(e.child,t);return(r,o)=>!n(r,o)}case"and":{const n=e.children.map(r=>Bu(r,t));return(r,o)=>n.every(i=>i(r,o))}case"or":{const n=e.children.map(r=>Bu(r,t));return(r,o)=>n.some(i=>i(r,o))}}}class ia extends Error{constructor(t,n){super(n),this.pos=t,this.name="LexError"}}const z5={h:36e5,d:864e5,w:7*864e5,m:30*864e5,mo:30*864e5,y:365*864e5},B5=/[A-Za-z_]/,U5=/[A-Za-z0-9_-]/,H5=/^\d{4}-\d{2}-\d{2}(?![\d-])/;function pm(e){const t=[];let n=0;const r=(o,i)=>{let a=n;for(;a<e.length&&/\d/.test(e[a]);)a++;const l=e.slice(n,a);let u="";for(;a<e.length&&/[a-z]/i.test(e[a]);)u+=e[a],a++;if(n=a,u.length>0){const f=z5[u.toLowerCase()];if(f===void 0)throw new ia(o,`Unknown duration unit "${u}" (expected h, d, w, m, mo, or y)`);return{type:"DURATION",text:e.slice(o,a),pos:o,num:parseInt(l,10)*f,sign:i}}return i!==0?{type:"NUMBER",text:e.slice(o,a),pos:o,num:i*parseInt(l,10)}:{type:"NUMBER",text:l,pos:o,num:parseInt(l,10)}};for(;n<e.length;){const o=e[n],i=n;if(o===" "||o===" "||o===`
560
+ ${t}: ${u}`,`${o}${p}${a}${l}`}const D5=/^[a-z0-9][a-z0-9-]*$/;function $5(e){const{playbooks:t,projectSlug:n,currentProjectTitle:r,currentProjectWorkspace:o,wsPrefix:i,refetchPlaybooks:a,navigate:l,toggleTheme:u}=e,f=[];if(f.push({id:"new-workspace",title:"New Workspace",subtitle:"Create a Syntaur workspace",group:"Create",keywords:["new","create","workspace"],bindableKind:"new-workspace",flow:{steps:[{kind:"text",id:"name",label:"Workspace name",placeholder:"lowercase, hyphenated (e.g. acme-app)",required:!0,pattern:{regex:D5,message:"Use lowercase letters, digits, and hyphens (e.g. acme-app). Must start with a letter or digit."}}],submit:async(p,h)=>{const g=(p.name??"").trim();if(!g)throw new Error("Name is required");const y=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})});if(!y.ok){const k=await y.json().catch(()=>({}));throw new Error(k.error||`Failed to create workspace (HTTP ${y.status})`)}h.navigate(`/w/${g}/projects`)}}}),f.push({id:"new-project",title:"New Project",subtitle:"Create a project (pick workspace)",group:"Create",keywords:["new","create","project"],bindableKind:"new-project",flow:{steps:[{kind:"picker",id:"workspace",label:"Workspace",emptyMessage:'No workspaces yet — create one with "New Workspace"',loadOptions:async()=>{const{workspaces:p,hasUngrouped:h}=await F1(),g=[{value:"_ungrouped",label:"Ungrouped",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});return g}},{kind:"text",id:"title",label:"Project title",placeholder:"e.g. Marketing site rebuild",required:!0}],submit:async(p,h)=>{const g=(p.workspace??"").trim(),y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");let v=await ry("/api/templates/project");v=Qi(v,"slug",k),v=Qi(v,"title",y),g&&g!=="_ungrouped"&&(v=Qi(v,"workspace",g));const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create project (HTTP ${b.status})`);const S=g&&g!=="_ungrouped"?`/w/${g}/projects/${j.slug??k}`:`/projects/${j.slug??k}`;h.navigate(S)}}}),f.push({id:"new-todo",title:"New Todo",subtitle:"Pick scope (global / workspace / project)",group:"Create",keywords:["new","create","todo","task"],bindableKind:"new-todo",flow:{steps:[{kind:"picker",id:"scope",label:"Scope",loadOptions:async()=>{const[{workspaces:p},h]=await Promise.all([F1(),z1()]),g=[{value:"_ungrouped",label:"Global",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});for(const y of h){const k=y.workspace??"_ungrouped";g.push({value:k,label:`${y.title}`,hint:`project · ${y.workspace??"ungrouped"}`})}return g}},{kind:"text",id:"description",label:"Description",placeholder:"Describe the todo…",required:!0}],submit:async p=>{const h=(p.scope??"_ungrouped").trim()||"_ungrouped",g=(p.description??"").trim();if(!g)throw new Error("Description is required");await rw(h,g)}}}),f.push({id:"new-assignment",title:"New Assignment",subtitle:"Pick standalone or a project",group:"Create",keywords:["new","create","assignment"],bindableKind:"new-assignment",flow:{steps:[{kind:"picker",id:"project",label:"Project",loadOptions:async()=>{const p=await z1(),h=[{value:"_standalone",label:"Standalone",hint:"one-off / not in a project"}];for(const g of p)h.push({value:g.slug,label:g.title,hint:g.workspace?`workspace · ${g.workspace}`:"ungrouped"});return h}},{kind:"text",id:"title",label:"Assignment title",placeholder:"What needs to get done?",required:!0}],submit:async(p,h)=>{var N;const g=(p.project??"_standalone").trim()||"_standalone",y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");if(g==="_standalone"){let C=await ry("/api/templates/assignment?standalone=1");C=Qi(C,"slug",k),C=Qi(C,"title",y);const P=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:C})}),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||`Failed to create assignment (HTTP ${P.status})`);const R=((N=T==null?void 0:T.assignment)==null?void 0:N.id)??(T==null?void 0:T.id);R?h.navigate(`/assignments/${R}`):h.navigate("/assignments");return}let v=await ry("/api/templates/assignment");v=Qi(v,"slug",k),v=Qi(v,"title",y);const b=await fetch(`/api/projects/${encodeURIComponent(g)}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create assignment (HTTP ${b.status})`);const S=j.slug??k;h.navigate(`/projects/${g}/assignments/${S}`)}}}),f.push({id:"create-project-route",title:"New Project (advanced editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","project","advanced","editor"],run:()=>l(`${i}/create/project`)}),f.push({id:"create-standalone-assignment",title:"New Standalone Assignment (editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","assignment","standalone","one-off","editor"],run:()=>l(`${i}/assignments/new`)}),n&&f.push({id:`create-assignment-in-${n}`,title:`New Assignment in ${r??n}`,subtitle:n,group:"Create",keywords:["new","create","assignment",n],run:()=>l(`${i}/projects/${n}/create/assignment`)}),f.push({id:"create-playbook",title:"New Playbook",group:"Create",keywords:["new","create","playbook"],run:()=>l("/playbooks/create")}),f.push({id:"create-todo-global",title:"New Todo (global, quick)",subtitle:"Ungrouped, single-step",group:"Create",keywords:["new","create","todo","global","ungrouped","quick"],requiresInput:{placeholder:"Describe the todo…",runWithInput:async p=>{const h=p.trim();h&&await ny("_ungrouped",h)}}}),i){const p=i.replace(/^\/w\//,"");f.push({id:`create-todo-workspace-${p}`,title:`New Todo in workspace ${p}`,subtitle:p,group:"Create",keywords:["new","create","todo","workspace",p],requiresInput:{placeholder:`Describe the todo for workspace ${p}…`,runWithInput:async h=>{const g=h.trim();g&&await ny(p,g)}}})}n&&o&&f.push({id:`create-todo-project-${n}`,title:`New Todo in project ${r??n}`,subtitle:`${n} · workspace ${o}`,group:"Create",keywords:["new","create","todo","project",n,o],requiresInput:{placeholder:`Describe the todo for project ${r??n}…`,runWithInput:async p=>{const h=p.trim();h&&await ny(o,h)}}});for(const p of t)f.push({id:`toggle-playbook-${p.slug}`,title:`Toggle Playbook: ${p.name}`,subtitle:p.enabled?"enabled":"disabled",group:"Toggle",keywords:["toggle","playbook",p.slug,...p.tags??[]],run:()=>_5(p.slug,p.enabled,a)});return f.push({id:"toggle-theme",title:"Toggle theme",subtitle:"Light / dark",group:"Theme",keywords:["theme","toggle","light","dark","appearance"],run:()=>u()}),f}const I5=["low","medium","high","critical"],fm={status:{kind:"enum"},priority:{kind:"ordinal",order:I5},type:{kind:"enum"},assignee:{kind:"string",noneSentinel:!0},project:{kind:"string",noneSentinel:!0},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},archived:{kind:"bool"},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title},created:{kind:"timestamp"},updated:{kind:"timestamp"},completedat:{kind:"timestamp",get:e=>e.completedAt},statusage:{kind:"duration",get:e=>e.statusAge},phase:{kind:"enum"},disposition:{kind:"enum"},phaseage:{kind:"duration",get:e=>e.phaseAge},hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},progressstaledays:{kind:"duration",get:e=>e.progressStaleDays},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},reworkrequested:{kind:"bool",get:e=>e.reworkRequested},pinned:{kind:"bool"}};function M5(e,t){return e[t.toLowerCase()]??null}function Mr(e,t,n){return e.get?e.get(n):n[t]??n[t.toLowerCase()]}class br extends Error{constructor(t){super(t.map(n=>`${n.message} (at ${n.pos})`).join("; ")),this.errors=t,this.name="CompileError"}}function fT(e){const[t,n,r]=e.raw.split("-").map(a=>parseInt(a,10)),o=new Date(t,n-1,r);if(o.getFullYear()!==t||o.getMonth()!==n-1||o.getDate()!==r)throw new br([{pos:e.pos,message:`Invalid date "${e.raw}"`}]);const i=new Date(t,n-1,r+1).getTime();return[o.getTime(),i]}function Ab(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.length>0){const t=Date.parse(e);return Number.isNaN(t)?null:t}return null}function zu(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function sy(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function L5(e){return e==null||e===""}function Fp(e,t,n,r){switch(e.kind){case"enum":case"string":return e.noneSentinel&&n.raw.toLowerCase()==="none"?o=>L5(Mr(e,t,o)):o=>sy(Mr(e,t,o),n.raw);case"substring":return o=>{const i=Mr(e,t,o);return typeof i=="string"&&i.toLowerCase().includes(n.raw.toLowerCase())};case"bool":{const o=n.raw.toLowerCase();if(o!=="true"&&o!=="false")throw new br([{pos:n.pos,message:`Field "${t}" is boolean — use ${t}:true or ${t}:false`}]);const i=o==="true";return a=>{const l=Mr(e,t,a),u=typeof l=="boolean"?l:l==="true"?!0:l==="false"||l===null||l===void 0||l===""?!1:null;return u!==null&&u===i}}case"number":{const o=n.num??zu(n.raw);if(o===null)throw new br([{pos:n.pos,message:`Field "${t}" is numeric — "${n.raw}" is not a number`}]);return i=>zu(Mr(e,t,i))===o}case"ordinal":return o=>sy(Mr(e,t,o),n.raw);case"list":return o=>{const i=Mr(e,t,o);return Array.isArray(i)&&i.some(a=>sy(a,n.raw))};case"timestamp":{if(n.type==="date"){const[o,i]=fT(n);return a=>{const l=Ab(Mr(e,t,a));return l!==null&&l>=o&&l<i}}throw new br([{pos:n.pos,message:`Field "${t}" is a timestamp — use a comparison (e.g. ${t} > -36h) or an absolute date (${t}:2026-06-01)`}])}case"duration":throw new br([{pos:r,message:`Field "${t}" is a duration — use a comparison (e.g. ${t} > 3d)`}])}}function O5(e,t,n,r){const o=(i,a)=>{switch(n){case"<":return i<a;case">":return i>a;case"<=":return i<=a;case">=":return i>=a;case"=":return i===a;case"!=":return i!==a;default:return!1}};switch(e.kind){case"number":{const i=r.num??zu(r.raw);if(i===null)throw new br([{pos:r.pos,message:`"${r.raw}" is not a number (field "${t}")`}]);return a=>{const l=zu(Mr(e,t,a));return l!==null&&o(l,i)}}case"ordinal":{const i=e.order??[],a=i.findIndex(l=>l.toLowerCase()===r.raw.toLowerCase());if(a<0)throw new br([{pos:r.pos,message:`"${r.raw}" is not a valid ${t} (expected one of: ${i.join(", ")})`}]);return l=>{const u=Mr(e,t,l),f=typeof u=="string"?i.findIndex(p=>p.toLowerCase()===u.toLowerCase()):-1;return f>=0&&o(f,a)}}case"timestamp":{if(r.type==="duration"){const a=(r.sign===0?-1:r.sign??-1)*(r.num??0);return(l,u)=>{const f=Ab(Mr(e,t,l));return f!==null&&o(f,u.now+a)}}if(r.type==="date"){const[i,a]=fT(r);return l=>{const u=Ab(Mr(e,t,l));if(u===null)return!1;switch(n){case"<":return u<i;case"<=":return u<a;case">":return u>=a;case">=":return u>=i;case"=":return u>=i&&u<a;case"!=":return u<i||u>=a;default:return!1}}}throw new br([{pos:r.pos,message:`Compare timestamp field "${t}" to a duration (e.g. -36h) or a date (YYYY-MM-DD)`}])}case"duration":{if(r.type!=="duration")throw new br([{pos:r.pos,message:`Compare duration field "${t}" to a duration literal (e.g. 3d)`}]);const i=r.num??0;return a=>{const l=zu(Mr(e,t,a));return l!==null&&o(l,i)}}case"enum":case"string":case"substring":case"list":{if(n==="=")return Fp(e,t,r,r.pos);if(n==="!="){const i=Fp(e,t,r,r.pos);return(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" does not support ordering comparisons (use ":" or "=").`}])}case"bool":{if(n==="="||n==="!="){const i=Fp(e,t,r,r.pos);return n==="="?i:(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" is boolean — use ${t}:true / ${t}:false`}])}}}function F5(e,t){const n=M5(t,e.field);if(!n)throw new br([{pos:e.pos,message:`Unknown field "${e.field}"`}]);if(e.op===":"){const r=e.values.map(o=>Fp(n,e.field,o,e.pos));return r.length===1?r[0]:(o,i)=>r.some(a=>a(o,i))}return O5(n,e.field,e.op,e.values[0])}function Bu(e,t){switch(e.kind){case"all":return()=>!0;case"atom":return F5(e,t);case"not":{const n=Bu(e.child,t);return(r,o)=>!n(r,o)}case"and":{const n=e.children.map(r=>Bu(r,t));return(r,o)=>n.every(i=>i(r,o))}case"or":{const n=e.children.map(r=>Bu(r,t));return(r,o)=>n.some(i=>i(r,o))}}}class ia extends Error{constructor(t,n){super(n),this.pos=t,this.name="LexError"}}const z5={h:36e5,d:864e5,w:7*864e5,m:30*864e5,mo:30*864e5,y:365*864e5},B5=/[A-Za-z_]/,U5=/[A-Za-z0-9_-]/,H5=/^\d{4}-\d{2}-\d{2}(?![\d-])/;function pm(e){const t=[];let n=0;const r=(o,i)=>{let a=n;for(;a<e.length&&/\d/.test(e[a]);)a++;const l=e.slice(n,a);let u="";for(;a<e.length&&/[a-z]/i.test(e[a]);)u+=e[a],a++;if(n=a,u.length>0){const f=z5[u.toLowerCase()];if(f===void 0)throw new ia(o,`Unknown duration unit "${u}" (expected h, d, w, m, mo, or y)`);return{type:"DURATION",text:e.slice(o,a),pos:o,num:parseInt(l,10)*f,sign:i}}return i!==0?{type:"NUMBER",text:e.slice(o,a),pos:o,num:i*parseInt(l,10)}:{type:"NUMBER",text:l,pos:o,num:parseInt(l,10)}};for(;n<e.length;){const o=e[n],i=n;if(o===" "||o===" "||o===`
561
561
  `||o==="\r"){n++;continue}if(o==="("){t.push({type:"LPAREN",text:o,pos:i}),n++;continue}if(o===")"){t.push({type:"RPAREN",text:o,pos:i}),n++;continue}if(o===","){t.push({type:"COMMA",text:o,pos:i}),n++;continue}if(o===":"){t.push({type:"COLON",text:o,pos:i}),n++;continue}if(o==="*"){t.push({type:"STAR",text:o,pos:i}),n++;continue}if(o==="<"||o===">"){e[n+1]==="="?(t.push({type:"OP",text:o+"=",pos:i}),n+=2):(t.push({type:"OP",text:o,pos:i}),n++);continue}if(o==="!"){if(e[n+1]==="="){t.push({type:"OP",text:"!=",pos:i}),n+=2;continue}throw new ia(i,'Unexpected "!" (did you mean "!="?)')}if(o==="="){n+=e[n+1]==="="?2:1,t.push({type:"OP",text:"=",pos:i});continue}if(o==='"'||o==="'"){const a=o;let l=n+1,u="";for(;l<e.length&&e[l]!==a;)e[l]==="\\"&&l+1<e.length?(u+=e[l+1],l+=2):(u+=e[l],l++);if(l>=e.length)throw new ia(i,"Unterminated string literal");t.push({type:"STRING",text:u,pos:i}),n=l+1;continue}if(o==="-"||o==="+"){if(/\d/.test(e[n+1]??"")){const a=o==="-"?-1:1;n++,t.push(r(i,a));continue}if(o==="-"){t.push({type:"MINUS",text:"-",pos:i}),n++;continue}throw new ia(i,'Unexpected "+"')}if(/\d/.test(o)){const a=e.slice(n).match(H5);if(a){t.push({type:"DATE",text:a[0],pos:i}),n+=a[0].length;continue}t.push(r(i,0));continue}if(B5.test(o)){let a=n+1;for(;a<e.length&&U5.test(e[a]);)a++;const l=e.slice(n,a),u=l.toLowerCase();u==="and"?t.push({type:"AND",text:l,pos:i}):u==="or"?t.push({type:"OR",text:l,pos:i}):u==="not"?t.push({type:"NOT",text:l,pos:i}):t.push({type:"IDENT",text:l,pos:i}),n=a;continue}throw new ia(i,`Unexpected character "${o}"`)}return t.push({type:"EOF",text:"",pos:e.length}),t}class Zi extends Error{constructor(t,n){super(n),this.pos=t,this.name="ParseError"}}const V5=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]),W5=new Set(["IDENT","NOT","MINUS","LPAREN","STAR"]);class K5{constructor(t){Vx(this,"pos",0);this.tokens=t}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(t,n){const r=this.peek();if(r.type!==t)throw new Zi(r.pos,`Expected ${n}, got "${r.text||r.type}"`);return this.next()}parseQuery(){if(this.peek().type==="EOF")return{kind:"all"};const t=this.orExpr(),n=this.peek();if(n.type!=="EOF")throw new Zi(n.pos,`Unexpected "${n.text}" — unbalanced parentheses or stray token`);return t}orExpr(){const t=[this.andExpr()];for(;this.peek().type==="OR";)this.next(),t.push(this.andExpr());return t.length===1?t[0]:{kind:"or",children:t}}andExpr(){const t=[this.unary()];for(;;){const n=this.peek();if(n.type==="AND")this.next(),t.push(this.unary());else if(W5.has(n.type))t.push(this.unary());else break}return t.length===1?t[0]:{kind:"and",children:t}}unary(){const t=this.peek();if(t.type==="NOT")return this.next(),{kind:"not",child:this.unary()};if(t.type==="MINUS"){this.next();const n=this.peek();if(n.type!=="IDENT")throw new Zi(n.pos,'Expected a field atom after "-" negation');return{kind:"not",child:this.atom()}}return this.primary()}primary(){const t=this.peek();if(t.type==="LPAREN"){this.next();const n=this.orExpr();return this.expect("RPAREN",'")"'),n}if(t.type==="STAR")return this.next(),{kind:"all"};if(t.type==="IDENT")return this.atom();throw new Zi(t.pos,`Expected a field, "(", "*", or NOT — got "${t.text||"end of query"}"`)}atom(){const t=this.expect("IDENT","a field name"),n=this.peek();if(n.type==="COLON"){this.next();const r=this.valueOrList();return{kind:"atom",field:t.text,op:":",values:r,pos:t.pos}}if(n.type==="OP"){this.next();const r=this.value();return{kind:"atom",field:t.text,op:n.text,values:[r],pos:t.pos}}throw new Zi(n.pos,`Expected ":" or a comparison operator after field "${t.text}"`)}valueOrList(){if(this.peek().type==="LPAREN"){this.next();const t=[this.value()];for(;this.peek().type==="COMMA";)this.next(),t.push(this.value());return this.expect("RPAREN",'")" to close the value list'),t}return[this.value()]}value(){const t=this.peek();if(!V5.has(t.type))throw new Zi(t.pos,`Expected a value, got "${t.text||t.type}"`);switch(this.next(),t.type){case"STRING":return{type:"string",raw:t.text,pos:t.pos};case"NUMBER":return{type:"number",raw:t.text,num:t.num,pos:t.pos};case"DATE":return{type:"date",raw:t.text,pos:t.pos};case"DURATION":return{type:"duration",raw:t.text,num:t.num,sign:t.sign??0,pos:t.pos};default:return{type:"word",raw:t.text,pos:t.pos}}}}function hm(e){try{const t=pm(e);return{ast:new K5(t).parseQuery(),errors:[]}}catch(t){if(t instanceof ia||t instanceof Zi)return{ast:null,errors:[{pos:t.pos,message:t.message}]};throw t}}function Zl(e,t=fm){const n=hm(e);if(!n.ast)return{query:null,errors:n.errors};try{return{query:{predicate:Bu(n.ast,t),ast:n.ast},errors:[]}}catch(r){if(r instanceof br)return{query:null,errors:r.errors};throw r}}function sn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function B1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function mm(...e){return t=>{let n=!1;const r=e.map(o=>{const i=B1(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():B1(e[o],null)}}}}function rr(...e){return m.useCallback(mm(...e),e)}function q5(e,t){const n=m.createContext(t),r=i=>{const{children:a,...l}=i,u=m.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:u,children:a})};r.displayName=e+"Provider";function o(i){const a=m.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Ra(e,t=[]){let n=[];function r(i,a){const l=m.createContext(a),u=n.length;n=[...n,a];const f=h=>{var j;const{scope:g,children:y,...k}=h,v=((j=g==null?void 0:g[e])==null?void 0:j[u])||l,b=m.useMemo(()=>k,Object.values(k));return s.jsx(v.Provider,{value:b,children:y})};f.displayName=i+"Provider";function p(h,g){var v;const y=((v=g==null?void 0:g[e])==null?void 0:v[u])||l,k=m.useContext(y);if(k)return k;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const o=()=>{const i=n.map(a=>m.createContext(a));return function(l){const u=(l==null?void 0:l[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[r,G5(o,...t)]}function G5(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((l,{useScope:u,scopeName:f})=>{const h=u(i)[`__scope${f}`];return{...l,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var ji=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Y5=WE[" useId ".trim().toString()]||(()=>{}),X5=0;function Ol(e){const[t,n]=m.useState(Y5());return ji(()=>{n(r=>r??String(X5++))},[e]),e||(t?`radix-${t}`:"")}var Q5=WE[" useInsertionEffect ".trim().toString()]||ji;function gm({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=J5({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const p=m.useRef(e!==void 0);m.useEffect(()=>{const h=p.current;h!==l&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=l},[l,r])}const f=m.useCallback(p=>{var h;if(l){const g=Z5(p)?p(e):p;g!==e&&((h=a.current)==null||h.call(a,g))}else i(p)},[l,e,i,a]);return[u,f]}function J5({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return Q5(()=>{i.current=t},[t]),m.useEffect(()=>{var a;o.current!==n&&((a=i.current)==null||a.call(i,n),o.current=n)},[n,o]),[n,r,i]}function Z5(e){return typeof e=="function"}function eF(e){const t=tF(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(rF);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function tF(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=oF(o),l=sF(i,o.props);return o.type!==m.Fragment&&(l.ref=r?mm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var nF=Symbol("radix.slottable");function rF(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===nF}function sF(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function oF(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var iF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nn=iF.reduce((e,t)=>{const n=eF(`Primitive.${t}`),r=m.forwardRef((o,i)=>{const{asChild:a,...l}=o,u=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function aF(e,t){e&&Ys.flushSync(()=>e.dispatchEvent(t))}function va(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lF(e,t=globalThis==null?void 0:globalThis.document){const n=va(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var cF="DismissableLayer",Pb="dismissableLayer.update",uF="dismissableLayer.pointerDownOutside",dF="dismissableLayer.focusOutside",U1,pT=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cw=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...u}=e,f=m.useContext(pT),[p,h]=m.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=rr(t,R=>h(R)),v=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(b),S=p?v.indexOf(p):-1,N=f.layersWithOutsidePointerEventsDisabled.size>0,C=S>=j,P=hF(R=>{const I=R.target,_=[...f.branches].some(F=>F.contains(I));!C||_||(o==null||o(R),a==null||a(R),R.defaultPrevented||l==null||l())},g),T=mF(R=>{const I=R.target;[...f.branches].some(F=>F.contains(I))||(i==null||i(R),a==null||a(R),R.defaultPrevented||l==null||l())},g);return lF(R=>{S===f.layers.size-1&&(r==null||r(R),!R.defaultPrevented&&l&&(R.preventDefault(),l()))},g),m.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(U1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),H1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=U1)}},[p,g,n,f]),m.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),H1())},[p,f]),m.useEffect(()=>{const R=()=>y({});return document.addEventListener(Pb,R),()=>document.removeEventListener(Pb,R)},[]),s.jsx(Nn.div,{...u,ref:k,style:{pointerEvents:N?C?"auto":"none":void 0,...e.style},onFocusCapture:sn(e.onFocusCapture,T.onFocusCapture),onBlurCapture:sn(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:sn(e.onPointerDownCapture,P.onPointerDownCapture)})});cw.displayName=cF;var fF="DismissableLayerBranch",pF=m.forwardRef((e,t)=>{const n=m.useContext(pT),r=m.useRef(null),o=rr(t,r);return m.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Nn.div,{...e,ref:o})});pF.displayName=fF;function hF(e,t=globalThis==null?void 0:globalThis.document){const n=va(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let u=function(){hT(uF,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mF(e,t=globalThis==null?void 0:globalThis.document){const n=va(e),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&hT(dF,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function H1(){const e=new CustomEvent(Pb);document.dispatchEvent(e)}function hT(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?aF(o,i):o.dispatchEvent(i)}var oy="focusScope.autoFocusOnMount",iy="focusScope.autoFocusOnUnmount",V1={bubbles:!1,cancelable:!0},gF="FocusScope",mT=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,u]=m.useState(null),f=va(o),p=va(i),h=m.useRef(null),g=rr(t,v=>u(v)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(N){if(y.paused||!l)return;const C=N.target;l.contains(C)?h.current=C:gi(h.current,{select:!0})},b=function(N){if(y.paused||!l)return;const C=N.relatedTarget;C!==null&&(l.contains(C)||gi(h.current,{select:!0}))},j=function(N){if(document.activeElement===document.body)for(const P of N)P.removedNodes.length>0&&gi(l)};document.addEventListener("focusin",v),document.addEventListener("focusout",b);const S=new MutationObserver(j);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),S.disconnect()}}},[r,l,y.paused]),m.useEffect(()=>{if(l){K1.add(y);const v=document.activeElement;if(!l.contains(v)){const j=new CustomEvent(oy,V1);l.addEventListener(oy,f),l.dispatchEvent(j),j.defaultPrevented||(xF(jF(gT(l)),{select:!0}),document.activeElement===v&&gi(l))}return()=>{l.removeEventListener(oy,f),setTimeout(()=>{const j=new CustomEvent(iy,V1);l.addEventListener(iy,p),l.dispatchEvent(j),j.defaultPrevented||gi(v??document.body,{select:!0}),l.removeEventListener(iy,p),K1.remove(y)},0)}}},[l,f,p,y]);const k=m.useCallback(v=>{if(!n&&!r||y.paused)return;const b=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(b&&j){const S=v.currentTarget,[N,C]=yF(S);N&&C?!v.shiftKey&&j===C?(v.preventDefault(),n&&gi(N,{select:!0})):v.shiftKey&&j===N&&(v.preventDefault(),n&&gi(C,{select:!0})):j===S&&v.preventDefault()}},[n,r,y.paused]);return s.jsx(Nn.div,{tabIndex:-1,...a,ref:g,onKeyDown:k})});mT.displayName=gF;function xF(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(gi(r,{select:t}),document.activeElement!==n)return}function yF(e){const t=gT(e),n=W1(t,e),r=W1(t.reverse(),e);return[n,r]}function gT(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function W1(e,t){for(const n of e)if(!bF(n,{upTo:t}))return n}function bF(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function vF(e){return e instanceof HTMLInputElement&&"select"in e}function gi(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&vF(e)&&t&&e.select()}}var K1=wF();function wF(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=q1(e,t),e.unshift(t)},remove(t){var n;e=q1(e,t),(n=e[0])==null||n.resume()}}}function q1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jF(e){return e.filter(t=>t.tagName!=="A")}var kF="Portal",uw=m.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,i]=m.useState(!1);ji(()=>i(!0),[]);const a=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?ZL.createPortal(s.jsx(Nn.div,{...r,ref:t}),a):null});uw.displayName=kF;function NF(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Aa=e=>{const{present:t,children:n}=e,r=SF(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=rr(r.ref,CF(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};Aa.displayName="Presence";function SF(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),a=e?"mounted":"unmounted",[l,u]=NF(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=ip(r.current);i.current=l==="mounted"?f:"none"},[l]),ji(()=>{const f=r.current,p=o.current;if(p!==e){const g=i.current,y=ip(f);e?u("MOUNT"):y==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(p&&g!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),ji(()=>{if(t){let f;const p=t.ownerDocument.defaultView??window,h=y=>{const v=ip(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&v&&(u("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},g=y=>{y.target===t&&(i.current=ip(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{p.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:m.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function ip(e){return(e==null?void 0:e.animationName)||"none"}function CF(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ay=0;function EF(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??G1()),document.body.insertAdjacentElement("beforeend",e[1]??G1()),ay++,()=>{ay===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ay--}},[])}function G1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var qs=function(){return qs=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},qs.apply(this,arguments)};function xT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function TF(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var zp="right-scroll-bar-position",Bp="width-before-scroll-bar",RF="with-scroll-bars-hidden",AF="--removed-body-scroll-bar-size";function ly(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function PF(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var _F=typeof window<"u"?m.useLayoutEffect:m.useEffect,Y1=new WeakMap;function DF(e,t){var n=PF(null,function(r){return e.forEach(function(o){return ly(o,r)})});return _F(function(){var r=Y1.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||ly(l,null)}),i.forEach(function(l){o.has(l)||ly(l,a)})}Y1.set(n,e)},[e]),n}function $F(e){return e}function IF(e,t){t===void 0&&(t=$F);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var u=function(){var p=a;a=[],p.forEach(i)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(p){a.push(p),f()},filter:function(p){return a=a.filter(p),n}}}};return o}function MF(e){e===void 0&&(e={});var t=IF(null);return t.options=qs({async:!0,ssr:!1},e),t}var yT=function(e){var t=e.sideCar,n=xT(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,qs({},n))};yT.isSideCarExport=!0;function LF(e,t){return e.useMedium(t),yT}var bT=MF(),cy=function(){},xm=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:cy,onWheelCapture:cy,onTouchMoveCapture:cy}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,u=e.className,f=e.removeScrollBar,p=e.enabled,h=e.shards,g=e.sideCar,y=e.noRelative,k=e.noIsolation,v=e.inert,b=e.allowPinchZoom,j=e.as,S=j===void 0?"div":j,N=e.gapMode,C=xT(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),P=g,T=DF([n,t]),R=qs(qs({},C),o);return m.createElement(m.Fragment,null,p&&m.createElement(P,{sideCar:bT,removeScrollBar:f,shards:h,noRelative:y,noIsolation:k,inert:v,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:N}),a?m.cloneElement(m.Children.only(l),qs(qs({},R),{ref:T})):m.createElement(S,qs({},R,{className:u,ref:T}),l))});xm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};xm.classNames={fullWidth:Bp,zeroRight:zp};var OF=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function FF(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=OF();return t&&e.setAttribute("nonce",t),e}function zF(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BF(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var UF=function(){var e=0,t=null;return{add:function(n){e==0&&(t=FF())&&(zF(t,n),BF(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},HF=function(){var e=UF();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},vT=function(){var e=HF(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},VF={left:0,top:0,right:0,gap:0},uy=function(e){return parseInt(e||"",10)||0},WF=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[uy(n),uy(r),uy(o)]},KF=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return VF;var t=WF(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},qF=vT(),Fl="data-scroll-locked",GF=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
562
562
  .`.concat(RF,` {
563
563
  overflow: hidden `).concat(r,`;
@@ -602,7 +602,7 @@ ${t}: ${u}`,`${o}${p}${a}${l}`}const D5=/^[a-z0-9][a-z0-9-]*$/;function $5(e){co
602
602
 
603
603
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
604
604
 
605
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},T6="DialogDescriptionWarning",R6=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${UT(T6).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},HT=TT,VT=AT,WT=_T,hw=DT,mw=$T,gw=MT,xw=OT,yw=zT;const Ln=HT,A6=VT,P6=WT,KT=yw,qT=m.forwardRef(({className:e,...t},n)=>s.jsx(hw,{ref:n,className:je("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));qT.displayName=hw.displayName;const Sn=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(P6,{children:[s.jsx(qT,{}),s.jsx(mw,{ref:r,className:je("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),...n,children:t})]}));Sn.displayName=mw.displayName;function or({className:e,...t}){return s.jsx("div",{className:je("flex flex-col space-y-2 text-left",e),...t})}function Wr({className:e,...t}){return s.jsx("div",{className:je("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Cn=m.forwardRef(({className:e,...t},n)=>s.jsx(gw,{ref:n,className:je("text-lg font-semibold tracking-tight text-foreground",e),...t}));Cn.displayName=gw.displayName;const ns=m.forwardRef(({className:e,...t},n)=>s.jsx(xw,{ref:n,className:je("text-sm leading-6 text-muted-foreground",e),...t}));ns.displayName=xw.displayName;const _6=-1,D6=-40;function fy(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,r=0,o=-2,i=0;for(let a=0;a<e.length;a++){const l=e[a];let u=!1;for(;r<t.length;)if(t[r]===l){if(n+=100,r===o+1&&(n+=20),r===0)n+=30;else{const f=t[r-1];(f===" "||f==="-"||f==="_"||f==="/")&&(n+=15)}i>0&&(n+=Math.max(D6,i*_6)),o=r,i=0,r++,u=!0;break}else i++,r++;if(!u)return-1/0}return n}const eN={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function bw(e,t,n=50){const r=e.toLowerCase();if(!r)return t.slice(0,n).map(a=>({...a,score:0}));const i=t.map(a=>{var h;const l=fy(r,a.title.toLowerCase())*1,u=a.subtitle?fy(r,a.subtitle.toLowerCase())*.5:-1/0,f=(h=a.keywords)!=null&&h.length?fy(r,a.keywords.join(" ").toLowerCase())*.3:-1/0,p=Math.max(l,u,f);return{...a,score:p}}).filter(a=>a.score>-1/0);return i.sort((a,l)=>l.score!==a.score?l.score-a.score:a.title.length!==l.title.length?a.title.length-l.title.length:a.title!==l.title?a.title<l.title?-1:1:(eN[a.type]??99)-(eN[l.type]??99)),i.slice(0,n)}const $6={a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},tN=Symbol("absent");function dp(e){return e.replace(/\s+/g," ").trim()}const nN=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]);function I6(e){const t=e.externalIds;return Array.isArray(t)?t.map(n=>n&&typeof n=="object"?`${n.system}:${n.id}`:"").join(" "):""}function M6(e){const t=e.externalIds;return Array.isArray(t)?t.filter(n=>{const r=n==null?void 0:n.system;return typeof r=="string"&&r.toLowerCase()==="jira"}).map(n=>String(n.id)).join(" "):""}const sd={kind:{kind:"enum",get:e=>e.type},status:{kind:"enum"},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},assignee:{kind:"string",noneSentinel:!0,get:e=>"assignee"in e?e.assignee:tN},type:{kind:"enum",get:e=>e.assignmentType},project:{kind:"string",noneSentinel:!0,get:e=>"project"in e?e.project:tN},externalid:{kind:"substring",get:I6},jira:{kind:"substring",get:M6},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title}};function L6(e,t=$6,n){const r=(n==null?void 0:n.defaultScope)??"all",o=e.match(/^\s*all:\s*/i),i=o!==null,a=i?e.slice(o[0].length):e,l=F6(a,t),u={aqlExpr:l.aqlExpr,fuzzy:l.fuzzy};if(r!=="all"&&!i&&e.trim()!==""&&!O6(l.aqlExpr)){const f=`kind:${r}`;u.aqlExpr=l.aqlExpr?l.explicit?`${f} (${l.aqlExpr})`:`${f} ${l.aqlExpr}`:f}return u}function O6(e){if(!e)return!1;let t;try{t=pm(e)}catch{return!1}for(let n=0;n<t.length-1;n++)if(t[n].type==="IDENT"&&t[n].text.toLowerCase()==="kind"&&t[n+1].type==="COLON")return!0;return!1}function F6(e,t){let n;try{n=pm(e)}catch(h){if(h instanceof ia)return{aqlExpr:"",fuzzy:dp(e),explicit:!1};throw h}const r=n.length,o=(h,g)=>e.slice(n[h].pos,g<r?n[g].pos:e.length);let i=!1;for(let h=0;h<r;h++){const g=n[h];if(g.type==="OR"||g.type==="LPAREN"&&(h===0||n[h-1].type!=="COLON")){i=!0;break}}if(i){const h=dp(U6(e,n,r,t));return Zl(h,sd).query?{aqlExpr:h,fuzzy:"",explicit:!0}:{aqlExpr:"",fuzzy:dp(e),explicit:!0}}const a=[],l=[];let u=0,f=0;const p=h=>{if(h>f){const g=dp(o(f,h));g&&l.push(g)}};for(;u<r-1;){const h=z6(n,u,t);if(h){p(u),a.push(h.atom),u=h.end,f=u;continue}const g=B6(n,u,r);if(g!==null){const y=o(u,g).trim();if(Zl(y,sd).query){p(u),a.push(y),u=g,f=u;continue}u=g;continue}u++}return p(r-1),{aqlExpr:a.join(" "),fuzzy:l.join(" "),explicit:!1}}function z6(e,t,n){var l;let r=t,o="";e[r].type==="MINUS"?(o="-",r++):e[r].type==="NOT"&&(o="NOT ",r++);const i=e[r];if(!i||i.type!=="IDENT")return null;const a=n[i.text.toLowerCase()];return!a||((l=e[r+1])==null?void 0:l.type)!=="COLON"?null:{atom:`${o}kind:${a}`,end:r+2}}function B6(e,t,n){let r=t;(e[r].type==="MINUS"||e[r].type==="NOT")&&r++;const o=e[r];if(!o||o.type!=="IDENT"||!Object.prototype.hasOwnProperty.call(sd,o.text.toLowerCase()))return null;const i=e[r+1];if(!i)return null;if(i.type==="COLON"){const a=e[r+2];if(!a)return null;if(a.type==="LPAREN"){let l=0;for(let u=r+2;u<n;u++)if(e[u].type==="LPAREN")l++;else if(e[u].type==="RPAREN"){if(l--,l===0)return u+1}else if(e[u].type==="EOF")return null;return null}return nN.has(a.type)?r+3:null}if(i.type==="OP"){const a=e[r+2];return a&&nN.has(a.type)?r+3:null}return null}function U6(e,t,n,r){var a;let o="",i=0;for(let l=0;l<n;l++){const u=t[l];u.type==="IDENT"&&Object.prototype.hasOwnProperty.call(r,u.text.toLowerCase())&&((a=t[l+1])==null?void 0:a.type)==="COLON"&&(o+=e.slice(i,u.pos)+`kind:${r[u.text.toLowerCase()]} `,i=t[l+1].pos+1)}return o+=e.slice(i),o}const vw=["kanban","list","table"],GT=["title","status","priority","assignee","dependencies","created","updated"],H6=["asc","desc"],V6=["comfortable","compact"],W6=["none","status","type","priority","assignee","project"],K6=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function Ve(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const r of t){if(typeof r!="string")continue;const o=r.trim();!o||o==="all"||n.includes(o)||n.push(o)}return n}function q6(e,t){const n=Ve(e),r=Ve(t);return n.length===r.length&&n.every(o=>r.includes(o))}const G6={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},od={version:1,global:G6,projects:{}};function py(e){return e==="table"?"table":"kanban"}function Y6(e,t){return t?{...e,...t}:{...e}}function YT(e,t){const n=e.global;if(t===null)return n;const r=e.projects[t];return r?{defaultView:r.defaultView??n.defaultView,sortField:r.sortField??n.sortField,sortDirection:r.sortDirection??n.sortDirection,density:n.density,grouping:r.grouping??n.grouping,filters:Y6(n.filters,r.filters)}:n}const X6=/^[A-Za-z_][A-Za-z0-9_-]*$/,Q6=new Set(["and","or","not"]);function ww(e){return X6.test(e)&&!Q6.has(e.toLowerCase())?e:XT(e)}function XT(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const QT="__unassigned__",JT="__standalone__",J6={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function Z6(e){return e.startsWith("older_")?"<":">="}const jw=["status","type","priority","assignee","project","tags"],ez=["created","updated"];function tz(e){var i;const t={};for(const a of jw){const l=Ve(e[a]);l.length&&(t[a]=l)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let r=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const a=nz(o);if(a)r||(r=a);else{const l=rz(o);l&&(t.dateRange=l)}}return r&&(t.activity=r),t}function nz(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function rz(e){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 null;const r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Uu(e){const t=tz(e),n=[];for(const r of jw){const o=t[r]??[];o.length&&n.push(sz(r,o))}return t.search&&n.push(`search:${XT(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...iz(t.dateRange)),n.join(" AND ")}function sz(e,t){const n=t.map(r=>oz(e,r));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function oz(e,t){return e==="assignee"&&t===QT||e==="project"&&t===JT?"none":ww(t)}function iz(e){if(e.preset)return[`${e.field} ${Z6(e.preset)} -${J6[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function Hu(e){const t=hm(e);if(!t.ast)return null;const n=az(t.ast);if(n===null)return null;const r={},o=new Set,i=new Map;for(const a of n){const l=lz(a);if(!l)return null;switch(l.kind){case"value":{if(o.has(l.field))return null;o.add(l.field),r[l.field]=l.values;break}case"search":{if(o.has("search"))return null;o.add("search"),r.search=l.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),r.activity=l.activity;break}case"datePreset":{const u=`date:${l.field}`;if(o.has(u)||i.has(l.field))return null;o.add(u),r.dateRange={field:l.field,preset:l.preset};break}case"dateBound":{const u=`date:${l.field}`;if(o.has(u))return null;const f=i.get(l.field)??{};if(l.bound==="from"){if(f.from!==void 0)return null;f.from=l.date}else{if(f.to!==void 0)return null;f.to=l.date}i.set(l.field,f);break}}}if(i.size>1)return null;for(const[a,l]of i){if(r.dateRange)return null;const u={field:a};l.from!==void 0&&(u.from=l.from),l.to!==void 0&&(u.to=l.to),r.dateRange=u}return r}function az(e){if(e.kind==="all")return[];if(e.kind==="atom")return[e];if(e.kind==="and"){const t=[];for(const n of e.children){if(n.kind!=="atom")return null;t.push(n)}return t}return null}function lz(e){const t=e.field.toLowerCase();if(e.op===":"){if(jw.includes(t)){const o=t,i=[];for(const a of e.values){const l=pz(o,a);if(l===null)return null;i.push(l)}return i.length===0?null:{kind:"value",field:o,values:i}}return t==="search"?e.values.length!==1?null:{kind:"search",text:e.values[0].raw}:null}if(!ez.includes(t))return null;const n=t;if(e.values.length!==1)return null;const r=e.values[0];return r.type==="duration"?cz(n,e.op,r):r.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:r.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:r.raw}:null:null}function cz(e,t,n){if(n.sign!==-1)return null;const r=uz(n.raw);if(e==="updated"){if(t==="<"&&r==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&r==="7d")return{kind:"activity",activity:"fresh"}}const o=fz(t,r);return o?{kind:"datePreset",field:e,preset:o}:null}function uz(e){return e.replace(/^[-+]/,"")}const dz={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function fz(e,t){return e!==">="&&e!=="<"?null:dz[e][t]??null}function pz(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?QT:e==="project"&&n.toLowerCase()==="none"?JT:n}const hz=new Set(["status","type","tag","assignee","externalid"]),hy=new Set(["IDENT","STRING","NUMBER","DATE","DURATION","STAR"]),rN=8;function mz(e,t,n){var k,v,b,j,S;let r;try{r=pm(e)}catch{return[]}const o=r.length,i=N=>{const C=N+1<o?r[N+1].pos:e.length;return r[N].pos+e.slice(r[N].pos,C).replace(/\s+$/,"").length};let a=-1;for(let N=0;N<o-1;N++)if(t>r[N].pos&&t<=i(N)){a=N;break}let l=a>=0?a-1:-1;if(a<0)for(let N=0;N<o-1&&i(N)<=t;N++)l=N;let u=null,f=null,p="";if(a>=0&&r[a].type==="COLON"&&((k=r[a-1])==null?void 0:k.type)==="IDENT"?(u=r[a-1].text.toLowerCase(),f=[t,t]):a>=0&&hy.has(r[a].type)&&((v=r[a-1])==null?void 0:v.type)==="COLON"&&((b=r[a-2])==null?void 0:b.type)==="IDENT"?(u=r[a-2].text.toLowerCase(),f=[r[a].pos,i(a)],p=r[a].text):a<0&&l>=0&&r[l].type==="COLON"&&((j=r[l-1])==null?void 0:j.type)==="IDENT"&&(u=r[l-1].text.toLowerCase(),f=[t,t]),u!==null){if(!hz.has(u))return[];const N=n.values[u]??[],C=p.toLowerCase(),P=[];for(const T of N)if(!(C&&!T.toLowerCase().startsWith(C))&&T.toLowerCase()!==C&&(P.push({label:T,insert:ww(T),replace:f,kind:"value"}),P.length>=rN))break;return P}if(a>=0&&!hy.has(r[a].type))return[];if(a>=0&&r[a].type==="IDENT"&&((S=r[a+1])==null?void 0:S.type)==="COLON")return[];if(l>=0){const N=r[l].type;if(!(N==="AND"||N==="OR"||N==="NOT"||N==="MINUS"||N==="LPAREN"||N==="RPAREN"||hy.has(N)))return[]}const h=(a>=0?r[a].text:"").toLowerCase(),g=a>=0?[r[a].pos,i(a)]:[t,t],y=[];for(const[N,C]of Object.entries(n.aliases))h&&!N.toLowerCase().startsWith(h)||y.push({label:`${N}: (${C})`,insert:`${N}:`,replace:g,kind:"prefix"});for(const N of n.fields)h&&!N.toLowerCase().startsWith(h)||y.push({label:`${N}:`,insert:`${N}:`,replace:g,kind:"field"});return y.slice(0,rN)}const gz=200,xz=2;function yz(e,t){const[n,r]=m.useState(e),[o,i]=m.useState([]),[a,l]=m.useState(!1),[u,f]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{const y=setTimeout(()=>r(e),gz);return()=>clearTimeout(y)},[e]);const h=n.trim(),g=t&&h.length>=xz;return m.useEffect(()=>{if(!g){p.current=null,i([]),l(!1),f(null);return}const y=new AbortController;p.current=h,l(!0),f(null);const k=()=>p.current===h&&!y.signal.aborted;return fetch(`/api/search?q=${encodeURIComponent(h)}`,{signal:y.signal}).then(async v=>{if(!v.ok){const b=await v.json().catch(()=>null);throw new Error((b==null?void 0:b.error)||`HTTP ${v.status}`)}return v.json()}).then(v=>{k()&&(i(v.hits??[]),l(!1))}).catch(v=>{v.name!=="AbortError"&&k()&&(f(v.message),i([]),l(!1))}),()=>{y.abort()}},[g,h]),{hits:o,loading:a,error:u}}const Up={phaseLadder:[{phase:"draft",when:"*",next:"Fill in the objective and acceptance criteria"},{phase:"ready_for_planning",when:"hasRealObjective:true AND acRealTotal > 0",next:"Write a plan and get it approved"},{phase:"ready_to_implement",when:"planApproved:true",next:"Start implementing"},{phase:"in_progress",when:"planApproved:true AND implementationStarted:true",next:"Finish acceptance criteria, then request review"},{phase:"review",when:"acAllChecked:true OR reviewRequested:true",next:"Complete, or address review feedback"}],disposition:[{when:"parked:true",is:"parked"},{when:"blocked:true",is:"blocked"},{when:null,is:"active"}],headline:{terminal:"passthrough",parked:"parked",blocked:"blocked",active:"phase"}};function bz(e,t,n=()=>null){const r=[],o=new Set(t.statuses.map(l=>l.id));e.phaseLadder.length===0&&r.push("phaseLadder must have at least one rung");for(const l of e.phaseLadder){o.has(l.phase)||r.push(`phaseLadder rung "${l.phase}" is not a defined status id`);const u=l.when==="*"?null:n(l.when);u&&r.push(`phaseLadder rung "${l.phase}": invalid condition — ${u}`)}const i=new Set(["active","blocked","parked"]);for(const l of e.disposition)if(i.has(l.is)||r.push(`disposition "${l.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),l.when!==null){const u=n(l.when);u&&r.push(`disposition rule "${l.is}": invalid condition — ${u}`)}const a=e.disposition.map((l,u)=>l.when===null?u:-1).filter(l=>l>=0);a.length===0?r.push("disposition rules must end with an `else:` arm (a rule with when: null)"):a.length>1?r.push("disposition rules must have exactly one `else:` arm (when: null)"):a[0]!==e.disposition.length-1&&r.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const l of["parked","blocked"])o.has(e.headline[l])||r.push(`headline.${l} → "${e.headline[l]}" is not a defined status id (add the definition or run migrate-derive)`);return r}const ZT={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:[],transitionsCustom:!1,custom:!1,derive:Up,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let Vu=null,ea=null;function vz(){return Vu?Promise.resolve(Vu):ea||(ea=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Vu=e,ea=null,e)).catch(()=>(ea=null,ZT)),ea)}function As(){const[e,t]=m.useState(()=>Vu??ZT);return m.useEffect(()=>{vz().then(t)},[]),e}function sN(){Vu=null,ea=null}function Eo(e,t){const n=e.statuses.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const eR={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 Hp=null,hl=null;function wz(){return Hp?Promise.resolve(Hp):hl||(hl=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Hp=e,hl=null,e)).catch(()=>(hl=null,eR)),hl)}function Md(){const[e,t]=m.useState(()=>Hp??eR);return m.useEffect(()=>{wz().then(t)},[]),e}function zl(e,t){if(!t)return"—";const n=e.definitions.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function jz(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}const kz={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo",content:"Content"};function Nz(e,t){const n=e.map(o=>({start:Math.max(0,Math.min(o.start,t)),end:Math.max(0,Math.min(o.end,t))})).filter(o=>o.end>o.start).sort((o,i)=>o.start-i.start||o.end-i.end),r=[];for(const o of n){const i=r[r.length-1];i&&o.start<=i.end?i.end=Math.max(i.end,o.end):r.push({...o})}return r}function Sz(e,t){if(!t||t.length===0)return e;const n=Nz(t,e.length);if(n.length===0)return e;const r=[];let o=0;return n.forEach((i,a)=>{i.start>o&&r.push(s.jsx(m.Fragment,{children:e.slice(o,i.start)},`t${a}`)),r.push(s.jsx("mark",{className:"rounded bg-yellow-200/70 px-0.5 text-foreground dark:bg-yellow-500/30",children:e.slice(i.start,i.end)},`m${a}`)),o=i.end}),o<e.length&&r.push(s.jsx(m.Fragment,{children:e.slice(o)},"tail")),r}function Cz({entries:e}){const{paletteOpen:t,closePalette:n}=Ai(),r=Wt(),[o,i]=m.useState(""),[a,l]=m.useState(0),[u,f]=m.useState(0),[p,h]=m.useState(!0),[g,y]=m.useState(0),k=m.useRef(null),v=m.useRef(null),b=m.useId(),{search:j}=lw(),S=As(),N=Md(),{aqlExpr:C,fuzzy:P}=m.useMemo(()=>L6(o,j.aliases,{defaultScope:j.defaultScope}),[o,j.aliases,j.defaultScope]),T=m.useMemo(()=>{const M=new Set,V=new Set,L=new Set;for(const Y of e){for(const B of Y.tags??[])M.add(B);Y.assignee&&V.add(Y.assignee);for(const B of Y.externalIds??[])B.id&&(L.add(B.id),B.system&&L.add(`${B.system}:${B.id}`))}const z=Object.keys(sd);return{aliases:j.aliases,fields:j.externalIds?z:z.filter(Y=>Y!=="jira"&&Y!=="externalid"),values:{status:S.statuses.map(Y=>Y.id),type:N.definitions.map(Y=>Y.id),tag:[...M],assignee:[...V],externalid:j.externalIds?[...L]:[]}}},[e,j.aliases,j.externalIds,S.statuses,N.definitions]),R=m.useMemo(()=>mz(o,u,T),[o,u,T]),I=p&&R.length>0&&o.trim()!=="",_=m.useMemo(()=>{let M=e,V=P;if(C){const L=Zl(C,sd);if(L.query){const z=Date.now(),{predicate:Y}=L.query;M=e.filter(B=>Y(B,{now:z}))}else V=o}return bw(V,M,50)},[e,C,P,o]),{hits:F}=yz(o,t),D=m.useMemo(()=>P5(F),[F]),W=m.useMemo(()=>[..._,...D],[_,D]);m.useEffect(()=>{l(0)},[o,t]),m.useEffect(()=>{y(0)},[R]),m.useEffect(()=>{t||(i(""),f(0),h(!0))},[t]),m.useEffect(()=>{var V;const M=(V=k.current)==null?void 0:V.querySelector(`[data-palette-idx="${a}"]`);M==null||M.scrollIntoView({block:"nearest"})},[a]);function H(M){r(M.route),n()}function $(M,V){const L=V===a,z=M.type==="content";return s.jsxs("button",{type:"button","data-palette-idx":V,onClick:()=>H(M),onMouseEnter:()=>l(V),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${L?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:kz[M.type]??M.type}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate",children:M.title}),z&&M.snippet?s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Sz(M.snippet,M.snippetMatches)}):null]}),M.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:M.subtitle}):null]},M.id)}function O(M){const V=o.slice(0,M.replace[0])+M.insert+o.slice(M.replace[1]),L=M.replace[0]+M.insert.length;i(V),f(L),requestAnimationFrame(()=>{const z=v.current;z&&(z.focus(),z.setSelectionRange(L,L))})}function U(M){if(I){if(M.key==="Tab"||M.key==="ArrowRight"&&u>=o.length){M.preventDefault();const V=R[g];V&&O(V);return}if(M.key==="ArrowDown"){M.preventDefault(),y(V=>Math.min(R.length-1,V+1));return}if(M.key==="ArrowUp"){M.preventDefault(),y(V=>Math.max(0,V-1));return}if(M.key==="Enter"){M.preventDefault();const V=W[a];V&&H(V);return}return}if(M.key==="ArrowDown")M.preventDefault(),l(V=>Math.min(W.length-1,V+1));else if(M.key==="ArrowUp")M.preventDefault(),l(V=>Math.max(0,V-1));else if(M.key==="Enter"){M.preventDefault();const V=W[a];V&&H(V)}}const K=I&&R[g]?`${b}-option-${g}`:void 0;return s.jsx(Ln,{open:t,onOpenChange:M=>M?null:n(),children:s.jsxs(Sn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:M=>{I&&(M.preventDefault(),h(!1))},children:[s.jsx(Cn,{className:"sr-only",children:"Command palette"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:v,autoFocus:!0,type:"text",role:"combobox","aria-expanded":I,"aria-controls":I?b:void 0,"aria-activedescendant":K,"aria-autocomplete":"list",value:o,onChange:M=>{i(M.target.value),f(M.target.selectionStart??M.target.value.length),h(!0)},onSelect:M=>f(M.currentTarget.selectionStart??0),onKeyDown:U,placeholder:"Search… try a: p: jira:PROJ-123 tag:backend",className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary"}),I?s.jsx("div",{role:"listbox",id:b,"aria-label":"Query suggestions",className:"absolute left-0 right-0 top-full z-50 max-h-64 overflow-y-auto border-b border-border/70 bg-background shadow-lg",children:R.map((M,V)=>{const L=V===g;return s.jsxs("button",{id:`${b}-option-${V}`,role:"option","aria-selected":L,type:"button",onMouseDown:z=>{z.preventDefault(),O(M)},onMouseEnter:()=>y(V),className:`flex w-full items-center justify-between gap-3 px-4 py-1.5 text-left text-sm ${L?"bg-accent text-accent-foreground":"text-foreground"}`,children:[s.jsx("code",{className:"truncate",children:M.label}),s.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:M.kind})]},`${M.kind}-${M.insert}-${V}`)})}):null]}),C?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Filtering"})," ",s.jsx("code",{className:"text-foreground",children:C}),P?s.jsxs("span",{children:[" · ranking “",P,"”"]}):null]}):o.trim()===""?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Prefixes"})," ",Object.keys(j.aliases).map(M=>s.jsxs("code",{className:"mr-1",children:[M,":"]},M))," · ",s.jsx("code",{children:"status:"})," ",s.jsx("code",{children:"tag:"})," ",s.jsx("code",{children:"assignee:"})," ",s.jsx("code",{children:"type:"})," ",j.externalIds?s.jsx("code",{children:"jira:"}):null]}):null,s.jsx("div",{ref:k,className:"max-h-[60vh] overflow-y-auto p-1",children:W.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No matches"}):s.jsxs(s.Fragment,{children:[_.map((M,V)=>$(M,V)),D.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Content"}),D.map((M,V)=>$(M,_.length+V))]}):null]})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:I?"⇥/→ accept · ↑↓ suggestions · Esc close":"↑↓ navigate · ↵ open · Esc close"}),s.jsxs("span",{children:[W.length," result",W.length===1?"":"s"]})]})]})})}function Ez({label:e,onBack:t,disabled:n,stepCounter:r}){return s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2",children:[s.jsxs("button",{type:"button",onClick:t,disabled:n,className:"inline-flex h-7 items-center gap-1 rounded border border-border/70 bg-background/60 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50","aria-label":"Back",children:[s.jsx(i4,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Back"})]}),s.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r?s.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/80",children:["step ",r.current," of ",r.total]}):null]})}function Tz({step:e,initialValue:t,disabled:n,onSubmit:r}){const[o,i]=m.useState(t??""),[a,l]=m.useState(!1),u=m.useRef(null);m.useEffect(()=>{var k;(k=u.current)==null||k.focus()},[]);const f=o.trim(),p=e.required!==!1,h=e.pattern&&f.length>0&&!e.pattern.regex.test(f),g=!n&&(!p||f.length>0)&&!h;function y(k){if(k.key==="Enter"){if(k.preventDefault(),!g){l(!0);return}r(f)}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:u,type:"text",value:o,onChange:k=>{i(k.target.value),l(!1)},onKeyDown:y,placeholder:e.placeholder,disabled:n,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),a&&e.pattern&&h?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:e.pattern.message}):null]})}function Rz({step:e,disabled:t,onSubmit:n}){const[r,o]=m.useState({phase:"loading"}),[i,a]=m.useState(""),[l,u]=m.useState(0),[f,p]=m.useState(0),h=m.useRef(null),g=m.useRef(null);m.useEffect(()=>{var v;(v=h.current)==null||v.focus()},[]),m.useEffect(()=>{let v=!1;return o({phase:"loading"}),Promise.resolve().then(()=>e.loadOptions()).then(b=>{v||o({phase:"loaded",options:b})}).catch(b=>{if(v)return;const j=b instanceof Error?b.message:"Failed to load options";o({phase:"error",message:j})}),()=>{v=!0}},[e,f]);const y=m.useMemo(()=>{if(r.phase!=="loaded")return[];const v=r.options.map(b=>({type:"option",title:b.label,subtitle:b.hint,keywords:[b.value],option:b}));return bw(i,v,100)},[r,i]);m.useEffect(()=>{u(0)},[y.length]),m.useEffect(()=>{var b;const v=(b=g.current)==null?void 0:b.querySelector(`[data-picker-idx="${l}"]`);v==null||v.scrollIntoView({block:"nearest"})},[l]);function k(v){if(r.phase==="loaded"){if(v.key==="ArrowDown")v.preventDefault(),u(b=>Math.min(y.length-1,b+1));else if(v.key==="ArrowUp")v.preventDefault(),u(b=>Math.max(0,b-1));else if(v.key==="Enter"){v.preventDefault();const b=y[l];b&&n(b.option.value)}}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:h,type:"text",value:i,onChange:v=>a(v.target.value),onKeyDown:k,placeholder:`Filter ${e.label.toLowerCase()}…`,disabled:t||r.phase==="loading",className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),s.jsx("div",{ref:g,className:"max-h-[60vh] min-h-[120px] overflow-y-auto p-1",children:r.phase==="loading"?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"Loading…"}):r.phase==="error"?s.jsxs("div",{className:"px-4 py-4 text-sm",children:[s.jsxs("div",{className:"mb-2 text-destructive",children:["Failed to load: ",r.message]}),s.jsx("button",{type:"button",onClick:()=>p(v=>v+1),className:"rounded border border-border/70 bg-background/60 px-2 py-1 text-xs text-foreground hover:bg-accent/40",children:"Retry"})]}):y.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:r.options.length===0?e.emptyMessage??"No options available":"No matches"}):y.map((v,b)=>{const j=b===l;return s.jsxs("button",{type:"button","data-picker-idx":b,onClick:()=>n(v.option.value),onMouseEnter:()=>u(b),disabled:t,className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${j?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.option.label}),v.option.hint?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:v.option.hint}):null]},v.option.value)})})]})}function Az({entries:e}){var Q,J;const t=Wt(),{actionsPaletteOpen:n,closeActionsPalette:r,customBindings:o,bindAction:i,findConflict:a,pendingActionKind:l,consumePendingActionKind:u}=Ai(),[f,p]=m.useState(""),[h,g]=m.useState(0),[y,k]=m.useState(null),[v,b]=m.useState(""),[j,S]=m.useState(null),[N,C]=m.useState(null),[P,T]=m.useState(!1),[R,I]=m.useState(null),_=m.useRef(null),F=m.useMemo(()=>e.map(Z=>({type:Z.group.toLowerCase(),title:Z.title,subtitle:Z.subtitle,keywords:Z.keywords,action:Z})),[e]),D=m.useMemo(()=>bw(f,F,50),[f,F]);m.useEffect(()=>{g(0)},[f,n]),m.useEffect(()=>{n||(p(""),k(null),b(""),S(null),C(null),T(!1),I(null))},[n]),m.useEffect(()=>{if(!n||!l)return;const Z=u();if(!Z)return;const oe=e.find(ne=>ne.bindableKind===Z);oe&&W(oe)},[n,l]),m.useEffect(()=>{var oe;const Z=(oe=_.current)==null?void 0:oe.querySelector(`[data-palette-idx="${h}"]`);Z==null||Z.scrollIntoView({block:"nearest"})},[h]);async function W(Z){if(!P){if(Z.flow&&Z.flow.steps.length>0){S({action:Z,stepIndex:0,values:{}}),I(null);return}if(Z.requiresInput){k(Z),b(""),I(null);return}if(Z.run){T(!0),I(null);try{await Z.run(),r()}catch(oe){I(oe instanceof Error?oe.message:"Action failed")}finally{T(!1)}}}}async function H(Z){if(!j)return;const oe=j.action.flow.steps[j.stepIndex],ne={...j.values,[oe.id]:Z};if(j.stepIndex+1<j.action.flow.steps.length){S({action:j.action,stepIndex:j.stepIndex+1,values:ne});return}T(!0),I(null);try{await j.action.flow.submit(ne,{navigate:t}),r()}catch(ue){I(ue instanceof Error?ue.message:"Action failed")}finally{T(!1)}}function $(){if(j&&!P){if(j.stepIndex===0){S(null),I(null);return}S({action:j.action,stepIndex:j.stepIndex-1,values:j.values}),I(null)}}async function O(){if(P||!(y!=null&&y.requiresInput))return;const Z=v.trim();if(Z){T(!0),I(null);try{await y.requiresInput.runWithInput(Z),r()}catch(oe){I(oe instanceof Error?oe.message:"Action failed")}finally{T(!1)}}}function U(Z){if(Z.key==="ArrowDown")Z.preventDefault(),g(oe=>Math.min(D.length-1,oe+1));else if(Z.key==="ArrowUp")Z.preventDefault(),g(oe=>Math.max(0,oe-1));else if(Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)){Z.preventDefault();const oe=D[h];oe!=null&&oe.action.bindableKind&&C({action:oe.action,combo:null,conflict:null,saving:!1,error:null})}else if(Z.key==="Enter"){Z.preventDefault();const oe=D[h];oe&&W(oe.action)}}function K(Z){Z.key==="Enter"?(Z.preventDefault(),O()):Z.key==="Escape"&&(Z.preventDefault(),k(null),b(""))}function M(Z){if(!N||Z.key==="Escape"||Z.key==="Enter"&&!N.combo)return;if(Z.key==="Enter"&&N.combo){Z.preventDefault(),Z.stopPropagation(),V();return}Z.preventDefault(),Z.stopPropagation();const oe=Z2(Z.nativeEvent);if(!oe)return;const ne=a(oe,N.action.bindableKind);C({...N,combo:oe,conflict:ne,error:null})}async function V(){var Z;if(!(!N||!N.combo||!N.action.bindableKind)){if((Z=N.conflict)!=null&&Z.description){C({...N,error:`Reserved: ${N.conflict.description}`});return}C({...N,saving:!0,error:null});try{await i(N.action.bindableKind,N.combo),C(null)}catch(oe){C({...N,saving:!1,error:oe instanceof Error?oe.message:"Failed to save binding"})}}}const L=y!==null,z=j!==null,Y=N!==null,B=j?j.action.flow.steps[j.stepIndex]:null;return s.jsx(Ln,{open:n,onOpenChange:Z=>Z?null:r(),children:s.jsxs(Sn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:Z=>{if(!P){if(Y){Z.preventDefault(),C(null);return}if(z){Z.preventDefault(),$();return}L&&(Z.preventDefault(),k(null),b(""),I(null))}},children:[s.jsx(Cn,{className:"sr-only",children:"Actions palette"}),Y&&N?s.jsxs("div",{onKeyDown:M,tabIndex:-1,autoFocus:!0,children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx(jb,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("span",{className:"text-sm text-foreground",children:["Bind hotkey for ",N.action.title]})]}),s.jsx("div",{className:"px-4 py-6 text-center",children:N.combo?s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-wide text-foreground",children:Zs(N.combo)}),(Q=N.conflict)!=null&&Q.description?s.jsxs("div",{className:"text-sm text-destructive",children:["Reserved: ",N.conflict.description," (cannot bind)"]}):(J=N.conflict)!=null&&J.kind?s.jsxs("div",{className:"text-sm text-amber-500 dark:text-amber-400",children:['Already bound to "',N.conflict.kind,'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press Enter to save, or another key to retry."}),N.error?s.jsx("div",{className:"text-sm text-destructive",children:N.error}):null]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press the key combination you want to bind…"})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"any key records · Enter saves · Esc cancels"}),s.jsx("span",{children:N.saving?"Saving…":""})]}),s.jsx("button",{type:"button",className:"sr-only",onClick:()=>void V(),"data-bind-confirm":!0}),s.jsx("input",{type:"hidden",onKeyDown:Z=>{Z.key==="Enter"&&V()}})]}):z&&B&&j?s.jsxs(s.Fragment,{children:[s.jsx(Ez,{label:`${j.action.title} · ${B.label}`,onBack:$,disabled:P,stepCounter:{current:j.stepIndex+1,total:j.action.flow.steps.length}}),B.kind==="text"?s.jsx(Tz,{step:B,initialValue:j.values[B.id],disabled:P,onSubmit:H}):s.jsx(Rz,{step:B,disabled:P,onSubmit:H}),R?s.jsx("div",{className:"border-t border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"↵ next · ← back · Esc back"}),s.jsx("span",{children:P?"Running…":""})]})]}):L?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:y.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.title})]}),s.jsx("input",{autoFocus:!0,type:"text",value:v,onChange:Z=>b(Z.target.value),onKeyDown:K,placeholder:y.requiresInput.placeholder,disabled:P,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↵"," submit ","·"," Esc back"]}),s.jsx("span",{children:P?"Running…":""})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("input",{autoFocus:!0,type:"text",value:f,onChange:Z=>p(Z.target.value),onKeyDown:U,placeholder:"Run an action: new project, new todo, toggle…",disabled:P,className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsx("div",{ref:_,className:"max-h-[60vh] overflow-y-auto p-1",children:D.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:f?"No matches":"Start typing to search actions"}):D.map((Z,oe)=>{const ne=oe===h,ue=Z.action.bindableKind,ge=ue?o[ue]:void 0;return s.jsxs("button",{type:"button","data-palette-idx":oe,onClick:()=>W(Z.action),onMouseEnter:()=>g(oe),disabled:P,className:`group flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${ne?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:Z.action.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Z.action.title}),Z.action.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:Z.action.subtitle}):null,ge?s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tracking-wide text-foreground",children:Zs(ge)}):null,ue?s.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Bind hotkey",onClick:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),C({action:Z.action,combo:null,conflict:null,saving:!1,error:null})},className:`shrink-0 inline-flex h-6 w-6 items-center justify-center rounded border border-border/70 bg-background/60 text-muted-foreground transition-opacity hover:text-foreground ${ne?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:s.jsx(jb,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):null]},Z.action.id)})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," run ","·"," ⌘↵ bind ","·"," Esc close"]}),s.jsx("span",{children:P?"Running…":`${D.length} action${D.length===1?"":"s"}`})]})]})]})})}const Pz=[{combo:"mod+k",description:"Open command palette",scope:"global"},{combo:"mod+shift+k",description:"Open actions palette",scope:"global"},{combo:"?",description:"Show keyboard shortcuts",scope:"global"},{combo:"escape",description:"Close dialog or cancel",scope:"global"},{combo:"enter",description:"Activate selected item",scope:"global"},{combo:"shift+t",description:"Toggle light/dark theme",scope:"global"},{combo:"g",description:"Start navigation chord",scope:"global"},{combo:"g o",description:"Go to Overview",scope:"global"},{combo:"g m",description:"Go to Projects",scope:"global"},{combo:"g a",description:"Go to Assignments",scope:"global"},{combo:"g t",description:"Go to Todos",scope:"global"},{combo:"g s",description:"Go to Servers",scope:"global"},{combo:"g !",description:"Go to Attention",scope:"global"},{combo:"g ,",description:"Go to Settings",scope:"global"},{combo:"j",description:"Move selection down",scope:"list"},{combo:"k",description:"Move selection up",scope:"list"},{combo:"o",description:"Open selected item",scope:"list"},{combo:"a",description:"New assignment in project",scope:"project"},{combo:"e",description:"Edit project / assignment",scope:"project|assignment"},{combo:"/",description:"Focus search",scope:"assignments-board"},{combo:"r",description:"Refresh board",scope:"assignments-board"},{combo:"p",description:"Edit plan",scope:"assignment"},{combo:"h",description:"Append handoff",scope:"assignment"},{combo:"d",description:"Append decision record",scope:"assignment"},{combo:"s",description:"Edit scratchpad",scope:"assignment"},{combo:"[",description:"Previous assignment",scope:"assignment"},{combo:"]",description:"Next assignment",scope:"assignment"}];function _z(e){const t=wr(e);return t?Pz.find(n=>n.combo===t)??null:null}const vu={"new-workspace":"New Workspace","new-project":"New Project","new-todo":"New Todo","new-assignment":"New Assignment"},Dz={global:"Global","list:overview":"Overview","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},$z=["global","list:overview","list:projects","list:assignments","list:todos","project","assignment"];function oN(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Zs(t)} then ${Zs(n)}`}return Zs(e)}function Iz(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n,customBindings:r,actionEntries:o}=Ai(),i=m.useMemo(()=>{const u=new Set;for(const f of Object.values(r))typeof f=="string"&&f&&u.add(wr(f));return u},[r]),a=m.useMemo(()=>{if(!e)return new Map;const u=n(),f=new Map;for(const p of u){if(i.has(wr(p.keys)))continue;const h=f.get(p.scope)??[];h.push({keys:p.keys,description:p.description}),f.set(p.scope,h)}return f},[e,n,i]),l=m.useMemo(()=>{const u=[];for(const[f,p]of Object.entries(r)){if(!p)continue;const h=o.find(g=>g.bindableKind===f);u.push({kind:f,combo:p,title:h?h.title:f})}return u},[r,o]);return s.jsx(Ln,{open:e,onOpenChange:u=>u?null:t(),children:s.jsxs(Sn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:"Keyboard shortcuts"}),s.jsxs(ns,{children:["Press Esc to close. ",Zs("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),s.jsxs("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:[$z.map(u=>{const f=a.get(u);return!f||f.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:Dz[u]}),s.jsx("ul",{className:"space-y-1",children:f.map((p,h)=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:p.description}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:oN(p.keys)})]},`${u}-${p.keys}-${h}`))})]},u)}),l.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Custom bindings"}),s.jsx("ul",{className:"space-y-1",children:l.map(u=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:u.title}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:oN(u.combo)})]},`custom-${u.kind}`))})]}):null]})]})})}const kw={bindings:{},custom:!1};let Wu=null,ml=null;const Db=new Set;function tR(e){Wu=e;for(const t of Db)t(e)}function Nw(e){if(!e||typeof e!="object")return kw;const t=e,n={};if(t.bindings&&typeof t.bindings=="object"&&!Array.isArray(t.bindings))for(const[r,o]of Object.entries(t.bindings)){if(!a5(r)||typeof o!="string"||o.trim()==="")continue;const i=wr(o);i&&(n[r]=i)}return{bindings:n,custom:t.custom===!0}}function Mz(){return Wu?Promise.resolve(Wu):ml||(ml=fetch("/api/config/hotkeys").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=Nw(e);return Wu=t,ml=null,t}).catch(()=>(ml=null,kw)),ml)}function Lz(){const[e,t]=m.useState(()=>Wu??kw);return m.useEffect(()=>{let n=!1;return Mz().then(r=>{n||t(r)}),Db.add(t),()=>{n=!0,Db.delete(t)}},[]),e}async function iN(e){const t={};for(const o of um){const i=e[o];if(typeof i!="string")continue;const a=wr(i);a&&(t[o]=a)}const n=await fetch("/api/config/hotkeys",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bindings:t})});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save hotkey bindings")}const r=Nw(await n.json());return tR(r),r}async function Oz(){const e=await fetch("/api/config/hotkeys",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=Nw(await e.json());return tR(t),t}const aN=1500;function Fz(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const nR=m.createContext(null);function zz({children:e}){const{toggleTheme:t}=ew(),n=sr(),r=Wt(),o=Fz(n.pathname),[i,a]=m.useState(!1),l=ro(i),u=lm(i),f=nw(i),p=tw(i),h=eT(i),{search:g}=lw(),y=m.useMemo(()=>{var ot,St,mt,at;const ve=l.data??[],be=((ot=u.data)==null?void 0:ot.assignments)??[],Re=((St=f.data)==null?void 0:St.playbooks)??[],He=((mt=p.data)==null?void 0:mt.sessions)??[],Fe=(((at=h.data)==null?void 0:at.workspaces)??[]).flatMap(ce=>ce.items.map(me=>({...me,workspace:ce.workspace})));return R5({projects:ve,assignments:be,playbooks:Re,servers:He,todos:Fe,wsPrefix:o,externalIds:g.externalIds})},[l.data,u.data,f.data,p.data,h.data,o,g.externalIds]),v=m.useMemo(()=>I2(n.pathname),[n.pathname]).projectSlug,b=m.useMemo(()=>{var ve;return v?((ve=l.data)==null?void 0:ve.find(be=>be.slug===v))??null:null},[l.data,v]),j=(b==null?void 0:b.title)??null,S=(b==null?void 0:b.workspace)??null,N=m.useMemo(()=>{var ve;return $5({playbooks:((ve=f.data)==null?void 0:ve.playbooks)??[],projectSlug:v,currentProjectTitle:j,currentProjectWorkspace:S,wsPrefix:o,refetchPlaybooks:f.refetch,navigate:r,toggleTheme:t})},[f.data,f.refetch,v,j,S,o,r,t]),C=m.useRef(new Map),P=m.useRef(["global"]),T=m.useRef({phase:"idle"}),R=m.useRef(null),I=m.useRef(1),[_,F]=m.useState(!1),[D,W]=m.useState(!1),[H,$]=m.useState(!1),[O,U]=m.useState(null);m.useEffect(()=>{(_||H)&&a(!0)},[_,H]);const{bindings:K}=Lz(),M=m.useMemo(()=>f5(K),[K]),V=m.useCallback(ve=>{const be=I.current++;return C.current.set(be,{...ve,id:be}),be},[]),L=m.useCallback(ve=>{C.current.delete(ve)},[]),z=m.useCallback(ve=>{P.current.push(ve)},[]),Y=m.useCallback(ve=>{const be=P.current;for(let Re=be.length-1;Re>=0;Re--)if(be[Re]===ve){be.splice(Re,1);return}},[]),B=m.useCallback(()=>F(!0),[]),Q=m.useCallback(()=>F(!1),[]),J=m.useCallback(()=>W(!0),[]),Z=m.useCallback(()=>W(!1),[]),oe=m.useCallback(()=>$(!0),[]),ne=m.useCallback(()=>{$(!1),U(null)},[]),ue=m.useCallback(()=>Array.from(C.current.values()),[]),ge=m.useCallback(()=>{let ve=null;return U(be=>(ve=be,null)),ve},[]),Ce=m.useCallback(ve=>{U(ve),$(!0)},[]),Ne=m.useCallback((ve,be)=>{const Re=wr(ve);if(!Re)return null;if(u5(Re)){const He=_z(Re);return{description:(He==null?void 0:He.description)??"Reserved built-in shortcut"}}for(const[He,rt]of Object.entries(M))if(!(be&&He===be)&&rt===Re)return{kind:He};return null},[M]),ke=m.useCallback(async(ve,be)=>{const Re=wr(be);if(!Re)throw new Error("Empty combo");const He=Ne(Re,ve);if(He){const Fe=He.description?`Reserved: ${He.description}`:`Already bound to "${He.kind}"`;throw new Error(Fe)}const rt={...K,[ve]:Re};return await iN(rt),Re},[K,Ne]),Ue=m.useCallback(async ve=>{if(!K[ve])return;const be={...K};delete be[ve],await iN(be)},[K]);m.useEffect(()=>{T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[n.pathname]),m.useEffect(()=>{function ve(Fe){if(!(Fe instanceof HTMLElement))return!1;const ot=Fe.tagName;return!!(ot==="INPUT"||ot==="TEXTAREA"||ot==="SELECT"||Fe.isContentEditable||Fe.closest('[role="combobox"], [role="textbox"]'))}function be(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function Re(){const Fe=P.current;return Fe[Fe.length-1]??"global"}function He(Fe){return Fe.scope==="global"?!0:Fe.scope===Re()}function rt(Fe){const ot=op(Fe,"Mod+k"),St=op(Fe,"Mod+Shift+k"),mt=Fe.key==="Escape",at=ot||St||mt;if(be()&&!at||ve(Fe.target)&&!at)return;const ce=T.current;if(ce.phase==="awaiting-second")if(Date.now()-ce.startedAt>aN)T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null);else{const Ae=Array.from(C.current.values());for(const We of Ae){if(!He(We))continue;const pt=We.keys.split(" ");if(!(pt.length!==2||pt[0]!=="g")&&op(Fe,pt[1])&&!(We.when&&!We.when())){Fe.preventDefault(),T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null),We.handler(Fe);return}}T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)}const me=Array.from(C.current.values());for(const Ie of me){if(!He(Ie))continue;const Ae=Ie.keys.split(" ");if(Ae.length===1&&op(Fe,Ae[0])&&!(Ie.when&&!Ie.when())){Fe.preventDefault(),Ie.handler(Fe);return}}Fe.key==="g"&&!Fe.metaKey&&!Fe.ctrlKey&&!Fe.altKey&&!Fe.shiftKey&&Array.from(C.current.values()).some(Ae=>He(Ae)&&Ae.keys.startsWith("g "))&&(Fe.preventDefault(),T.current={phase:"awaiting-second",startedAt:Date.now()},R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{T.current={phase:"idle"},R.current=null},aN))}return window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[]),m.useEffect(()=>{const ve=V({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>L(ve)},[V,L,t]),m.useEffect(()=>{const ve=V({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>J()});return()=>L(ve)},[V,L,J]),m.useEffect(()=>{const ve=V({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(_){Q();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||B()}});return()=>L(ve)},[V,L,B,Q,_]),m.useEffect(()=>{const ve=V({keys:"Mod+Shift+k",scope:"global",description:"Open actions palette",handler:()=>{if(H){ne();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||oe()}});return()=>L(ve)},[V,L,oe,ne,H]),m.useEffect(()=>{const be=[{suffix:"o",basePath:"/",desc:"Go to Overview"},{suffix:"m",basePath:"/projects",desc:"Go to Projects"},{suffix:"a",basePath:"/assignments",desc:"Go to Assignments"},{suffix:"t",basePath:"/todos",desc:"Go to Todos"},{suffix:"s",basePath:"/servers",desc:"Go to Servers"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map(Re=>V({keys:`g ${Re.suffix}`,scope:"global",description:Re.desc,handler:()=>r(Lp(Re.basePath,o))}));return()=>be.forEach(L)},[V,L,r,o]),m.useEffect(()=>{const ve=[];for(const[be,Re]of Object.entries(M)){if(!Re)continue;const He=N.find(Fe=>Fe.bindableKind===be),rt=He?`Custom: ${He.title}`:`Custom: ${be}`;ve.push(V({keys:Re,scope:"global",description:rt,handler:()=>{U(be),$(!0)}}))}return()=>ve.forEach(L)},[V,L,M,N]);const ie=m.useMemo(()=>({register:V,unregister:L,pushScope:z,popScope:Y,openPalette:B,closePalette:Q,paletteOpen:_,openCheatsheet:J,closeCheatsheet:Z,cheatsheetOpen:D,openActionsPalette:oe,closeActionsPalette:ne,actionsPaletteOpen:H,listBindings:ue,wsPrefix:o,paletteEntries:y,actionEntries:N,userBindings:K,customBindings:M,bindAction:ke,unbindAction:Ue,findConflict:Ne,openActionsPaletteWithAction:Ce,pendingActionKind:O,consumePendingActionKind:ge}),[V,L,z,Y,B,Q,_,J,Z,D,oe,ne,H,ue,o,y,N,K,M,ke,Ue,Ne,Ce,O,ge]);return s.jsxs(nR.Provider,{value:ie,children:[e,s.jsx(Cz,{entries:y}),s.jsx(Az,{entries:N}),s.jsx(Iz,{})]})}function Ai(){const e=m.useContext(nR);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function en({keys:e,handler:t,scope:n="global",description:r,when:o,enabled:i=!0}){const{register:a,unregister:l}=Ai(),u=m.useRef(t),f=m.useRef(o);m.useEffect(()=>{u.current=t,f.current=o},[t,o]),m.useEffect(()=>{if(!i)return;const p=a({keys:e,handler:h=>u.current(h),scope:n,description:r,when:f.current?()=>f.current():void 0});return()=>l(p)},[a,l,e,n,r,i])}function Pi(e){const{pushScope:t,popScope:n}=Ai();m.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function Ld(e,t){const[n,r]=m.useState(e.length===0?-1:0),o=sr();m.useEffect(()=>{r(e.length===0?-1:0)},[o.pathname]),m.useEffect(()=>{r(a=>e.length===0?-1:Math.min(Math.max(0,a),e.length-1))},[e.length]),m.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(l=>{const u=Number(l.getAttribute("data-hotkey-row-index"));l.setAttribute("data-hotkey-selected",u===n?"true":"false")}),n>=0){const l=document.querySelector(`[data-hotkey-row-index="${n}"]`);l==null||l.scrollIntoView({block:"nearest"})}},[n,e.length]),en({keys:"j",scope:t.scope,description:"Select next row",handler:()=>r(a=>e.length===0?-1:Math.min(e.length-1,a<0?0:a+1))}),en({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>r(a=>e.length===0?-1:Math.max(0,a<0?0:a-1))}),en({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),en({keys:"o",scope:t.scope,description:"Open selected row",enabled:t.bindO??!0,handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}});const i=m.useCallback(a=>({"data-hotkey-row-index":a,"data-hotkey-selected":a===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:i}}function Bz(){return m.useSyncExternalStore(IO,M1,M1)}function Uz(e){switch(e){case"reconnecting":return{show:!0,label:"Reconnecting…",tone:"amber"};case"closed":return{show:!0,label:"Offline",tone:"amber"};case"connecting":return{show:!0,label:"Connecting…",tone:"muted"};case"open":return{show:!1,label:"Live",tone:"muted"}}}function Hz(){const e=Bz(),t=Uz(e);return s.jsx("div",{role:"status","aria-live":"polite",className:"flex items-center",children:t.show?s.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${t.tone==="amber"?"border-warning-foreground/30 bg-warning text-warning-foreground":"border-border/70 bg-background/80 text-muted-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${t.tone==="amber"?"bg-warning-foreground animate-pulse":"bg-muted-foreground/60"}`}),t.label]}):s.jsx("span",{className:"sr-only"})})}function Vz({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:r}){const o=gn(),{resolvedTheme:i,toggleTheme:a}=ew(),{openPalette:l}=Ai();return s.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/70 backdrop-blur",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[s.jsx("button",{type:"button",onClick:r,className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-card/80 text-foreground lg:hidden","aria-label":"Open navigation",children:s.jsx(P4,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?s.jsxs("nav",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:[t.slice(0,-1).map((u,f)=>s.jsxs("span",{className:"flex items-center gap-1.5",children:[f>0?s.jsx("span",{children:"/"}):null,s.jsx($e,{to:u.path,className:"hover:text-foreground",children:u.label})]},u.path)),s.jsx("span",{children:"/"})]}):null,s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:e})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hz,{}),s.jsxs("button",{type:"button",onClick:l,className:"shell-action","aria-label":"Open command palette",children:[s.jsx(Ei,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Zs("Mod+k")})]}),s.jsx($e,{className:"shell-action hidden sm:inline-flex",to:"/help",children:"Help"}),s.jsxs($e,{className:"shell-action",to:`${o}/create/project`,"aria-label":"New Project",children:[s.jsx(Pt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Project"})]}),n?s.jsxs($e,{className:"shell-action",to:`${o}/projects/${n}/create/assignment`,"aria-label":"New Assignment",children:[s.jsx(Pt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Assignment"})]}):null,s.jsxs("button",{type:"button",onClick:a,className:"shell-action","aria-label":"Toggle theme",children:[i==="dark"?s.jsx(H4,{className:"h-4 w-4"}):s.jsx(_4,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:i==="dark"?"Light":"Dark"})]})]})]})})}const Wz=4e3;function Qn(){const[e,t]=m.useState(null),n=m.useRef(null),r=m.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=m.useCallback((i,a="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:a}),n.current=setTimeout(()=>{t(null),n.current=null},Wz)},[]);return m.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:r}}function Xn({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return s.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:s.jsx("button",{type:"button",onClick:t,className:je("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)})}const lN={review:0,blocked:0,question:0,"plan-approval":0};function rR(){const[e,t]=m.useState([]),[n,r]=m.useState(lN),[o,i]=m.useState(0),[a,l]=m.useState(!0),[u,f]=m.useState(null),[p,h]=m.useState(0),g=m.useCallback(()=>{h(y=>y+1)},[]);return m.useEffect(()=>{let y=!1;return l(!0),f(null),fetch("/api/inbox").then(async k=>{if(!k.ok){const v=await k.json().catch(()=>null);throw new Error((v==null?void 0:v.error)||`HTTP ${k.status}`)}return k.json()}).then(k=>{y||(t(Array.isArray(k.items)?k.items:[]),r(k.counts??lN),i(typeof k.total=="number"?k.total:0),l(!1))}).catch(k=>{y||(f(k.message),l(!1))}),()=>{y=!0}},[p]),Ti(y=>{(y.type==="assignment-updated"||y.type==="project-updated")&&g()}),{items:e,counts:n,total:o,loading:a,error:u,refetch:g}}const sR="syntaur.sidebar.collapsed.v1";function oR(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Kz(e){if(!e)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}function qz(e,t){return{...e,[t]:!(e[t]??!1)}}function Gz(){const e=oR();if(!e)return{};try{return Kz(e.getItem(sR))}catch{return{}}}let Vp=Gz();const $b=new Set,Yz={};function Xz(e){const t=oR();if(t)try{t.setItem(sR,JSON.stringify(e))}catch{}}function Qz(e){return $b.add(e),()=>{$b.delete(e)}}function Jz(){return Vp}function Zz(){return Yz}function eB(e){Vp=qz(Vp,e),Xz(Vp);for(const t of $b)t()}function tB(){const e=m.useSyncExternalStore(Qz,Jz,Zz);return{isCollapsed:(n,r=!1)=>e[n]??r,toggle:eB}}const hh="_ungrouped",nB=256;function rB(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const o=r.trim();o.length!==0&&(o.length>nB||/[\r\n]/.test(o)||t.has(o)||(t.add(o),n.push(o)))}return n}function sB(e,t){if(t.length===0)return[...e];const n=new Set(t);return e.filter(r=>!n.has(r))}function oB(e,t){return t.includes(e)}const Sw={hidden:[],custom:!1};let No=null,ta=null,id=0;const Ib=new Set;function iR(e){No=e;for(const t of Ib)t(e)}function Cw(e){if(!e||typeof e!="object")return Sw;const t=e;return{hidden:rB(t.hidden),custom:t.custom===!0}}function iB(){if(No)return Promise.resolve({value:No,ok:!0});if(ta)return ta;const e=++id;return ta=fetch("/api/config/workspace-visibility").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{ta=null;const n=Cw(t);return e!==id?{value:No??n,ok:!0}:(No=n,{value:n,ok:!0})}).catch(()=>(ta=null,{value:Sw,ok:!1})),ta}function aR(){const[e,t]=m.useState(()=>No??Sw),[n,r]=m.useState(()=>No===null),[o,i]=m.useState(!1),[a,l]=m.useState(0);m.useEffect(()=>{let f=!1;return r(No===null),iB().then(p=>{f||(t(p.value),r(!1),i(!p.ok))}),Ib.add(t),()=>{f=!0,Ib.delete(t)}},[a]);function u(){aB(),l(f=>f+1)}return{...e,loading:n,error:o,reload:u}}function aB(){No=null,ta=null,++id}async function lB(e){++id;const t=await fetch("/api/config/workspace-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hidden:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=Cw(await t.json());return iR(n),n}async function cB(){++id;const e=await fetch("/api/config/workspace-visibility",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=Cw(await e.json());return iR(t),t}var uB=Symbol("radix.slottable");function dB(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=uB,t}var lR="AlertDialog",[fB]=Ra(lR,[ET]),_o=ET(),cR=e=>{const{__scopeAlertDialog:t,...n}=e,r=_o(t);return s.jsx(HT,{...r,...n,modal:!0})};cR.displayName=lR;var pB="AlertDialogTrigger",hB=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(VT,{...o,...r,ref:t})});hB.displayName=pB;var mB="AlertDialogPortal",uR=e=>{const{__scopeAlertDialog:t,...n}=e,r=_o(t);return s.jsx(WT,{...r,...n})};uR.displayName=mB;var gB="AlertDialogOverlay",dR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(hw,{...o,...r,ref:t})});dR.displayName=gB;var Bl="AlertDialogContent",[xB,yB]=fB(Bl),bB=dB("AlertDialogContent"),fR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,i=_o(n),a=m.useRef(null),l=rr(t,a),u=m.useRef(null);return s.jsx(C6,{contentName:Bl,titleName:pR,docsSlug:"alert-dialog",children:s.jsx(xB,{scope:n,cancelRef:u,children:s.jsxs(mw,{role:"alertdialog",...i,...o,ref:l,onOpenAutoFocus:sn(o.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=u.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[s.jsx(bB,{children:r}),s.jsx(wB,{contentRef:a})]})})})});fR.displayName=Bl;var pR="AlertDialogTitle",hR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(gw,{...o,...r,ref:t})});hR.displayName=pR;var mR="AlertDialogDescription",gR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(xw,{...o,...r,ref:t})});gR.displayName=mR;var vB="AlertDialogAction",xR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(yw,{...o,...r,ref:t})});xR.displayName=vB;var yR="AlertDialogCancel",bR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=yB(yR,n),i=_o(n),a=rr(t,o);return s.jsx(yw,{...i,...r,ref:a})});bR.displayName=yR;var wB=({contentRef:e})=>{const t=`\`${Bl}\` requires a description for the component to be accessible for screen reader users.
605
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},T6="DialogDescriptionWarning",R6=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${UT(T6).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},HT=TT,VT=AT,WT=_T,hw=DT,mw=$T,gw=MT,xw=OT,yw=zT;const Ln=HT,A6=VT,P6=WT,KT=yw,qT=m.forwardRef(({className:e,...t},n)=>s.jsx(hw,{ref:n,className:je("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));qT.displayName=hw.displayName;const Sn=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(P6,{children:[s.jsx(qT,{}),s.jsx(mw,{ref:r,className:je("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),...n,children:t})]}));Sn.displayName=mw.displayName;function or({className:e,...t}){return s.jsx("div",{className:je("flex flex-col space-y-2 text-left",e),...t})}function Wr({className:e,...t}){return s.jsx("div",{className:je("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Cn=m.forwardRef(({className:e,...t},n)=>s.jsx(gw,{ref:n,className:je("text-lg font-semibold tracking-tight text-foreground",e),...t}));Cn.displayName=gw.displayName;const ns=m.forwardRef(({className:e,...t},n)=>s.jsx(xw,{ref:n,className:je("text-sm leading-6 text-muted-foreground",e),...t}));ns.displayName=xw.displayName;const _6=-1,D6=-40;function fy(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,r=0,o=-2,i=0;for(let a=0;a<e.length;a++){const l=e[a];let u=!1;for(;r<t.length;)if(t[r]===l){if(n+=100,r===o+1&&(n+=20),r===0)n+=30;else{const f=t[r-1];(f===" "||f==="-"||f==="_"||f==="/")&&(n+=15)}i>0&&(n+=Math.max(D6,i*_6)),o=r,i=0,r++,u=!0;break}else i++,r++;if(!u)return-1/0}return n}const eN={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function bw(e,t,n=50){const r=e.toLowerCase();if(!r)return t.slice(0,n).map(a=>({...a,score:0}));const i=t.map(a=>{var h;const l=fy(r,a.title.toLowerCase())*1,u=a.subtitle?fy(r,a.subtitle.toLowerCase())*.5:-1/0,f=(h=a.keywords)!=null&&h.length?fy(r,a.keywords.join(" ").toLowerCase())*.3:-1/0,p=Math.max(l,u,f);return{...a,score:p}}).filter(a=>a.score>-1/0);return i.sort((a,l)=>l.score!==a.score?l.score-a.score:a.title.length!==l.title.length?a.title.length-l.title.length:a.title!==l.title?a.title<l.title?-1:1:(eN[a.type]??99)-(eN[l.type]??99)),i.slice(0,n)}const $6={a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},tN=Symbol("absent");function dp(e){return e.replace(/\s+/g," ").trim()}const nN=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]);function I6(e){const t=e.externalIds;return Array.isArray(t)?t.map(n=>n&&typeof n=="object"?`${n.system}:${n.id}`:"").join(" "):""}function M6(e){const t=e.externalIds;return Array.isArray(t)?t.filter(n=>{const r=n==null?void 0:n.system;return typeof r=="string"&&r.toLowerCase()==="jira"}).map(n=>String(n.id)).join(" "):""}const sd={kind:{kind:"enum",get:e=>e.type},status:{kind:"enum"},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},assignee:{kind:"string",noneSentinel:!0,get:e=>"assignee"in e?e.assignee:tN},type:{kind:"enum",get:e=>e.assignmentType},project:{kind:"string",noneSentinel:!0,get:e=>"project"in e?e.project:tN},externalid:{kind:"substring",get:I6},jira:{kind:"substring",get:M6},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title}};function L6(e,t=$6,n){const r=(n==null?void 0:n.defaultScope)??"all",o=e.match(/^\s*all:\s*/i),i=o!==null,a=i?e.slice(o[0].length):e,l=F6(a,t),u={aqlExpr:l.aqlExpr,fuzzy:l.fuzzy};if(r!=="all"&&!i&&e.trim()!==""&&!O6(l.aqlExpr)){const f=`kind:${r}`;u.aqlExpr=l.aqlExpr?l.explicit?`${f} (${l.aqlExpr})`:`${f} ${l.aqlExpr}`:f}return u}function O6(e){if(!e)return!1;let t;try{t=pm(e)}catch{return!1}for(let n=0;n<t.length-1;n++)if(t[n].type==="IDENT"&&t[n].text.toLowerCase()==="kind"&&t[n+1].type==="COLON")return!0;return!1}function F6(e,t){let n;try{n=pm(e)}catch(h){if(h instanceof ia)return{aqlExpr:"",fuzzy:dp(e),explicit:!1};throw h}const r=n.length,o=(h,g)=>e.slice(n[h].pos,g<r?n[g].pos:e.length);let i=!1;for(let h=0;h<r;h++){const g=n[h];if(g.type==="OR"||g.type==="LPAREN"&&(h===0||n[h-1].type!=="COLON")){i=!0;break}}if(i){const h=dp(U6(e,n,r,t));return Zl(h,sd).query?{aqlExpr:h,fuzzy:"",explicit:!0}:{aqlExpr:"",fuzzy:dp(e),explicit:!0}}const a=[],l=[];let u=0,f=0;const p=h=>{if(h>f){const g=dp(o(f,h));g&&l.push(g)}};for(;u<r-1;){const h=z6(n,u,t);if(h){p(u),a.push(h.atom),u=h.end,f=u;continue}const g=B6(n,u,r);if(g!==null){const y=o(u,g).trim();if(Zl(y,sd).query){p(u),a.push(y),u=g,f=u;continue}u=g;continue}u++}return p(r-1),{aqlExpr:a.join(" "),fuzzy:l.join(" "),explicit:!1}}function z6(e,t,n){var l;let r=t,o="";e[r].type==="MINUS"?(o="-",r++):e[r].type==="NOT"&&(o="NOT ",r++);const i=e[r];if(!i||i.type!=="IDENT")return null;const a=n[i.text.toLowerCase()];return!a||((l=e[r+1])==null?void 0:l.type)!=="COLON"?null:{atom:`${o}kind:${a}`,end:r+2}}function B6(e,t,n){let r=t;(e[r].type==="MINUS"||e[r].type==="NOT")&&r++;const o=e[r];if(!o||o.type!=="IDENT"||!Object.prototype.hasOwnProperty.call(sd,o.text.toLowerCase()))return null;const i=e[r+1];if(!i)return null;if(i.type==="COLON"){const a=e[r+2];if(!a)return null;if(a.type==="LPAREN"){let l=0;for(let u=r+2;u<n;u++)if(e[u].type==="LPAREN")l++;else if(e[u].type==="RPAREN"){if(l--,l===0)return u+1}else if(e[u].type==="EOF")return null;return null}return nN.has(a.type)?r+3:null}if(i.type==="OP"){const a=e[r+2];return a&&nN.has(a.type)?r+3:null}return null}function U6(e,t,n,r){var a;let o="",i=0;for(let l=0;l<n;l++){const u=t[l];u.type==="IDENT"&&Object.prototype.hasOwnProperty.call(r,u.text.toLowerCase())&&((a=t[l+1])==null?void 0:a.type)==="COLON"&&(o+=e.slice(i,u.pos)+`kind:${r[u.text.toLowerCase()]} `,i=t[l+1].pos+1)}return o+=e.slice(i),o}const vw=["kanban","list","table"],GT=["title","status","priority","assignee","dependencies","created","updated"],H6=["asc","desc"],V6=["comfortable","compact"],W6=["none","status","type","priority","assignee","project"],K6=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function Ve(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const r of t){if(typeof r!="string")continue;const o=r.trim();!o||o==="all"||n.includes(o)||n.push(o)}return n}function q6(e,t){const n=Ve(e),r=Ve(t);return n.length===r.length&&n.every(o=>r.includes(o))}const G6={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},od={version:1,global:G6,projects:{}};function py(e){return e==="table"?"table":"kanban"}function Y6(e,t){return t?{...e,...t}:{...e}}function YT(e,t){const n=e.global;if(t===null)return n;const r=e.projects[t];return r?{defaultView:r.defaultView??n.defaultView,sortField:r.sortField??n.sortField,sortDirection:r.sortDirection??n.sortDirection,density:n.density,grouping:r.grouping??n.grouping,filters:Y6(n.filters,r.filters)}:n}const X6=/^[A-Za-z_][A-Za-z0-9_-]*$/,Q6=new Set(["and","or","not"]);function ww(e){return X6.test(e)&&!Q6.has(e.toLowerCase())?e:XT(e)}function XT(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const QT="__unassigned__",JT="__standalone__",J6={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function Z6(e){return e.startsWith("older_")?"<":">="}const jw=["status","type","priority","assignee","project","tags"],ez=["created","updated"];function tz(e){var i;const t={};for(const a of jw){const l=Ve(e[a]);l.length&&(t[a]=l)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let r=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const a=nz(o);if(a)r||(r=a);else{const l=rz(o);l&&(t.dateRange=l)}}return r&&(t.activity=r),t}function nz(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function rz(e){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 null;const r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Uu(e){const t=tz(e),n=[];for(const r of jw){const o=t[r]??[];o.length&&n.push(sz(r,o))}return t.search&&n.push(`search:${XT(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...iz(t.dateRange)),n.join(" AND ")}function sz(e,t){const n=t.map(r=>oz(e,r));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function oz(e,t){return e==="assignee"&&t===QT||e==="project"&&t===JT?"none":ww(t)}function iz(e){if(e.preset)return[`${e.field} ${Z6(e.preset)} -${J6[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function Hu(e){const t=hm(e);if(!t.ast)return null;const n=az(t.ast);if(n===null)return null;const r={},o=new Set,i=new Map;for(const a of n){const l=lz(a);if(!l)return null;switch(l.kind){case"value":{if(o.has(l.field))return null;o.add(l.field),r[l.field]=l.values;break}case"search":{if(o.has("search"))return null;o.add("search"),r.search=l.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),r.activity=l.activity;break}case"datePreset":{const u=`date:${l.field}`;if(o.has(u)||i.has(l.field))return null;o.add(u),r.dateRange={field:l.field,preset:l.preset};break}case"dateBound":{const u=`date:${l.field}`;if(o.has(u))return null;const f=i.get(l.field)??{};if(l.bound==="from"){if(f.from!==void 0)return null;f.from=l.date}else{if(f.to!==void 0)return null;f.to=l.date}i.set(l.field,f);break}}}if(i.size>1)return null;for(const[a,l]of i){if(r.dateRange)return null;const u={field:a};l.from!==void 0&&(u.from=l.from),l.to!==void 0&&(u.to=l.to),r.dateRange=u}return r}function az(e){if(e.kind==="all")return[];if(e.kind==="atom")return[e];if(e.kind==="and"){const t=[];for(const n of e.children){if(n.kind!=="atom")return null;t.push(n)}return t}return null}function lz(e){const t=e.field.toLowerCase();if(e.op===":"){if(jw.includes(t)){const o=t,i=[];for(const a of e.values){const l=pz(o,a);if(l===null)return null;i.push(l)}return i.length===0?null:{kind:"value",field:o,values:i}}return t==="search"?e.values.length!==1?null:{kind:"search",text:e.values[0].raw}:null}if(!ez.includes(t))return null;const n=t;if(e.values.length!==1)return null;const r=e.values[0];return r.type==="duration"?cz(n,e.op,r):r.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:r.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:r.raw}:null:null}function cz(e,t,n){if(n.sign!==-1)return null;const r=uz(n.raw);if(e==="updated"){if(t==="<"&&r==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&r==="7d")return{kind:"activity",activity:"fresh"}}const o=fz(t,r);return o?{kind:"datePreset",field:e,preset:o}:null}function uz(e){return e.replace(/^[-+]/,"")}const dz={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function fz(e,t){return e!==">="&&e!=="<"?null:dz[e][t]??null}function pz(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?QT:e==="project"&&n.toLowerCase()==="none"?JT:n}const hz=new Set(["status","type","tag","assignee","externalid"]),hy=new Set(["IDENT","STRING","NUMBER","DATE","DURATION","STAR"]),rN=8;function mz(e,t,n){var k,v,b,j,S;let r;try{r=pm(e)}catch{return[]}const o=r.length,i=N=>{const C=N+1<o?r[N+1].pos:e.length;return r[N].pos+e.slice(r[N].pos,C).replace(/\s+$/,"").length};let a=-1;for(let N=0;N<o-1;N++)if(t>r[N].pos&&t<=i(N)){a=N;break}let l=a>=0?a-1:-1;if(a<0)for(let N=0;N<o-1&&i(N)<=t;N++)l=N;let u=null,f=null,p="";if(a>=0&&r[a].type==="COLON"&&((k=r[a-1])==null?void 0:k.type)==="IDENT"?(u=r[a-1].text.toLowerCase(),f=[t,t]):a>=0&&hy.has(r[a].type)&&((v=r[a-1])==null?void 0:v.type)==="COLON"&&((b=r[a-2])==null?void 0:b.type)==="IDENT"?(u=r[a-2].text.toLowerCase(),f=[r[a].pos,i(a)],p=r[a].text):a<0&&l>=0&&r[l].type==="COLON"&&((j=r[l-1])==null?void 0:j.type)==="IDENT"&&(u=r[l-1].text.toLowerCase(),f=[t,t]),u!==null){if(!hz.has(u))return[];const N=n.values[u]??[],C=p.toLowerCase(),P=[];for(const T of N)if(!(C&&!T.toLowerCase().startsWith(C))&&T.toLowerCase()!==C&&(P.push({label:T,insert:ww(T),replace:f,kind:"value"}),P.length>=rN))break;return P}if(a>=0&&!hy.has(r[a].type))return[];if(a>=0&&r[a].type==="IDENT"&&((S=r[a+1])==null?void 0:S.type)==="COLON")return[];if(l>=0){const N=r[l].type;if(!(N==="AND"||N==="OR"||N==="NOT"||N==="MINUS"||N==="LPAREN"||N==="RPAREN"||hy.has(N)))return[]}const h=(a>=0?r[a].text:"").toLowerCase(),g=a>=0?[r[a].pos,i(a)]:[t,t],y=[];for(const[N,C]of Object.entries(n.aliases))h&&!N.toLowerCase().startsWith(h)||y.push({label:`${N}: (${C})`,insert:`${N}:`,replace:g,kind:"prefix"});for(const N of n.fields)h&&!N.toLowerCase().startsWith(h)||y.push({label:`${N}:`,insert:`${N}:`,replace:g,kind:"field"});return y.slice(0,rN)}const gz=200,xz=2;function yz(e,t){const[n,r]=m.useState(e),[o,i]=m.useState([]),[a,l]=m.useState(!1),[u,f]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{const y=setTimeout(()=>r(e),gz);return()=>clearTimeout(y)},[e]);const h=n.trim(),g=t&&h.length>=xz;return m.useEffect(()=>{if(!g){p.current=null,i([]),l(!1),f(null);return}const y=new AbortController;p.current=h,l(!0),f(null);const k=()=>p.current===h&&!y.signal.aborted;return fetch(`/api/search?q=${encodeURIComponent(h)}`,{signal:y.signal}).then(async v=>{if(!v.ok){const b=await v.json().catch(()=>null);throw new Error((b==null?void 0:b.error)||`HTTP ${v.status}`)}return v.json()}).then(v=>{k()&&(i(v.hits??[]),l(!1))}).catch(v=>{v.name!=="AbortError"&&k()&&(f(v.message),i([]),l(!1))}),()=>{y.abort()}},[g,h]),{hits:o,loading:a,error:u}}const Up={phaseLadder:[{phase:"draft",when:"*",next:"Fill in the objective and acceptance criteria"},{phase:"ready_for_planning",when:"hasRealObjective:true AND acRealTotal > 0",next:"Write a plan and get it approved"},{phase:"ready_to_implement",when:"planApproved:true",next:"Start implementing"},{phase:"in_progress",when:"planApproved:true AND implementationStarted:true",next:"Finish acceptance criteria, then request review"},{phase:"review",when:"(acAllChecked:true OR reviewRequested:true) AND NOT reworkRequested:true",next:"Complete, or address review feedback"}],disposition:[{when:"parked:true",is:"parked"},{when:"blocked:true",is:"blocked"},{when:null,is:"active"}],headline:{terminal:"passthrough",parked:"parked",blocked:"blocked",active:"phase"}};function bz(e,t,n=()=>null){const r=[],o=new Set(t.statuses.map(l=>l.id));e.phaseLadder.length===0&&r.push("phaseLadder must have at least one rung");for(const l of e.phaseLadder){o.has(l.phase)||r.push(`phaseLadder rung "${l.phase}" is not a defined status id`);const u=l.when==="*"?null:n(l.when);u&&r.push(`phaseLadder rung "${l.phase}": invalid condition — ${u}`)}const i=new Set(["active","blocked","parked"]);for(const l of e.disposition)if(i.has(l.is)||r.push(`disposition "${l.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),l.when!==null){const u=n(l.when);u&&r.push(`disposition rule "${l.is}": invalid condition — ${u}`)}const a=e.disposition.map((l,u)=>l.when===null?u:-1).filter(l=>l>=0);a.length===0?r.push("disposition rules must end with an `else:` arm (a rule with when: null)"):a.length>1?r.push("disposition rules must have exactly one `else:` arm (when: null)"):a[0]!==e.disposition.length-1&&r.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const l of["parked","blocked"])o.has(e.headline[l])||r.push(`headline.${l} → "${e.headline[l]}" is not a defined status id (add the definition or run migrate-derive)`);return r}const ZT={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:[],transitionsCustom:!1,custom:!1,derive:Up,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let Vu=null,ea=null;function vz(){return Vu?Promise.resolve(Vu):ea||(ea=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Vu=e,ea=null,e)).catch(()=>(ea=null,ZT)),ea)}function As(){const[e,t]=m.useState(()=>Vu??ZT);return m.useEffect(()=>{vz().then(t)},[]),e}function sN(){Vu=null,ea=null}function Eo(e,t){const n=e.statuses.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const eR={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 Hp=null,hl=null;function wz(){return Hp?Promise.resolve(Hp):hl||(hl=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Hp=e,hl=null,e)).catch(()=>(hl=null,eR)),hl)}function Md(){const[e,t]=m.useState(()=>Hp??eR);return m.useEffect(()=>{wz().then(t)},[]),e}function zl(e,t){if(!t)return"—";const n=e.definitions.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function jz(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}const kz={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo",content:"Content"};function Nz(e,t){const n=e.map(o=>({start:Math.max(0,Math.min(o.start,t)),end:Math.max(0,Math.min(o.end,t))})).filter(o=>o.end>o.start).sort((o,i)=>o.start-i.start||o.end-i.end),r=[];for(const o of n){const i=r[r.length-1];i&&o.start<=i.end?i.end=Math.max(i.end,o.end):r.push({...o})}return r}function Sz(e,t){if(!t||t.length===0)return e;const n=Nz(t,e.length);if(n.length===0)return e;const r=[];let o=0;return n.forEach((i,a)=>{i.start>o&&r.push(s.jsx(m.Fragment,{children:e.slice(o,i.start)},`t${a}`)),r.push(s.jsx("mark",{className:"rounded bg-yellow-200/70 px-0.5 text-foreground dark:bg-yellow-500/30",children:e.slice(i.start,i.end)},`m${a}`)),o=i.end}),o<e.length&&r.push(s.jsx(m.Fragment,{children:e.slice(o)},"tail")),r}function Cz({entries:e}){const{paletteOpen:t,closePalette:n}=Ai(),r=Wt(),[o,i]=m.useState(""),[a,l]=m.useState(0),[u,f]=m.useState(0),[p,h]=m.useState(!0),[g,y]=m.useState(0),k=m.useRef(null),v=m.useRef(null),b=m.useId(),{search:j}=lw(),S=As(),N=Md(),{aqlExpr:C,fuzzy:P}=m.useMemo(()=>L6(o,j.aliases,{defaultScope:j.defaultScope}),[o,j.aliases,j.defaultScope]),T=m.useMemo(()=>{const M=new Set,V=new Set,L=new Set;for(const Y of e){for(const B of Y.tags??[])M.add(B);Y.assignee&&V.add(Y.assignee);for(const B of Y.externalIds??[])B.id&&(L.add(B.id),B.system&&L.add(`${B.system}:${B.id}`))}const z=Object.keys(sd);return{aliases:j.aliases,fields:j.externalIds?z:z.filter(Y=>Y!=="jira"&&Y!=="externalid"),values:{status:S.statuses.map(Y=>Y.id),type:N.definitions.map(Y=>Y.id),tag:[...M],assignee:[...V],externalid:j.externalIds?[...L]:[]}}},[e,j.aliases,j.externalIds,S.statuses,N.definitions]),R=m.useMemo(()=>mz(o,u,T),[o,u,T]),I=p&&R.length>0&&o.trim()!=="",_=m.useMemo(()=>{let M=e,V=P;if(C){const L=Zl(C,sd);if(L.query){const z=Date.now(),{predicate:Y}=L.query;M=e.filter(B=>Y(B,{now:z}))}else V=o}return bw(V,M,50)},[e,C,P,o]),{hits:F}=yz(o,t),D=m.useMemo(()=>P5(F),[F]),W=m.useMemo(()=>[..._,...D],[_,D]);m.useEffect(()=>{l(0)},[o,t]),m.useEffect(()=>{y(0)},[R]),m.useEffect(()=>{t||(i(""),f(0),h(!0))},[t]),m.useEffect(()=>{var V;const M=(V=k.current)==null?void 0:V.querySelector(`[data-palette-idx="${a}"]`);M==null||M.scrollIntoView({block:"nearest"})},[a]);function H(M){r(M.route),n()}function $(M,V){const L=V===a,z=M.type==="content";return s.jsxs("button",{type:"button","data-palette-idx":V,onClick:()=>H(M),onMouseEnter:()=>l(V),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${L?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:kz[M.type]??M.type}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate",children:M.title}),z&&M.snippet?s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Sz(M.snippet,M.snippetMatches)}):null]}),M.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:M.subtitle}):null]},M.id)}function O(M){const V=o.slice(0,M.replace[0])+M.insert+o.slice(M.replace[1]),L=M.replace[0]+M.insert.length;i(V),f(L),requestAnimationFrame(()=>{const z=v.current;z&&(z.focus(),z.setSelectionRange(L,L))})}function U(M){if(I){if(M.key==="Tab"||M.key==="ArrowRight"&&u>=o.length){M.preventDefault();const V=R[g];V&&O(V);return}if(M.key==="ArrowDown"){M.preventDefault(),y(V=>Math.min(R.length-1,V+1));return}if(M.key==="ArrowUp"){M.preventDefault(),y(V=>Math.max(0,V-1));return}if(M.key==="Enter"){M.preventDefault();const V=W[a];V&&H(V);return}return}if(M.key==="ArrowDown")M.preventDefault(),l(V=>Math.min(W.length-1,V+1));else if(M.key==="ArrowUp")M.preventDefault(),l(V=>Math.max(0,V-1));else if(M.key==="Enter"){M.preventDefault();const V=W[a];V&&H(V)}}const K=I&&R[g]?`${b}-option-${g}`:void 0;return s.jsx(Ln,{open:t,onOpenChange:M=>M?null:n(),children:s.jsxs(Sn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:M=>{I&&(M.preventDefault(),h(!1))},children:[s.jsx(Cn,{className:"sr-only",children:"Command palette"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:v,autoFocus:!0,type:"text",role:"combobox","aria-expanded":I,"aria-controls":I?b:void 0,"aria-activedescendant":K,"aria-autocomplete":"list",value:o,onChange:M=>{i(M.target.value),f(M.target.selectionStart??M.target.value.length),h(!0)},onSelect:M=>f(M.currentTarget.selectionStart??0),onKeyDown:U,placeholder:"Search… try a: p: jira:PROJ-123 tag:backend",className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary"}),I?s.jsx("div",{role:"listbox",id:b,"aria-label":"Query suggestions",className:"absolute left-0 right-0 top-full z-50 max-h-64 overflow-y-auto border-b border-border/70 bg-background shadow-lg",children:R.map((M,V)=>{const L=V===g;return s.jsxs("button",{id:`${b}-option-${V}`,role:"option","aria-selected":L,type:"button",onMouseDown:z=>{z.preventDefault(),O(M)},onMouseEnter:()=>y(V),className:`flex w-full items-center justify-between gap-3 px-4 py-1.5 text-left text-sm ${L?"bg-accent text-accent-foreground":"text-foreground"}`,children:[s.jsx("code",{className:"truncate",children:M.label}),s.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:M.kind})]},`${M.kind}-${M.insert}-${V}`)})}):null]}),C?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Filtering"})," ",s.jsx("code",{className:"text-foreground",children:C}),P?s.jsxs("span",{children:[" · ranking “",P,"”"]}):null]}):o.trim()===""?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Prefixes"})," ",Object.keys(j.aliases).map(M=>s.jsxs("code",{className:"mr-1",children:[M,":"]},M))," · ",s.jsx("code",{children:"status:"})," ",s.jsx("code",{children:"tag:"})," ",s.jsx("code",{children:"assignee:"})," ",s.jsx("code",{children:"type:"})," ",j.externalIds?s.jsx("code",{children:"jira:"}):null]}):null,s.jsx("div",{ref:k,className:"max-h-[60vh] overflow-y-auto p-1",children:W.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No matches"}):s.jsxs(s.Fragment,{children:[_.map((M,V)=>$(M,V)),D.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Content"}),D.map((M,V)=>$(M,_.length+V))]}):null]})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:I?"⇥/→ accept · ↑↓ suggestions · Esc close":"↑↓ navigate · ↵ open · Esc close"}),s.jsxs("span",{children:[W.length," result",W.length===1?"":"s"]})]})]})})}function Ez({label:e,onBack:t,disabled:n,stepCounter:r}){return s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2",children:[s.jsxs("button",{type:"button",onClick:t,disabled:n,className:"inline-flex h-7 items-center gap-1 rounded border border-border/70 bg-background/60 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50","aria-label":"Back",children:[s.jsx(i4,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Back"})]}),s.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r?s.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/80",children:["step ",r.current," of ",r.total]}):null]})}function Tz({step:e,initialValue:t,disabled:n,onSubmit:r}){const[o,i]=m.useState(t??""),[a,l]=m.useState(!1),u=m.useRef(null);m.useEffect(()=>{var k;(k=u.current)==null||k.focus()},[]);const f=o.trim(),p=e.required!==!1,h=e.pattern&&f.length>0&&!e.pattern.regex.test(f),g=!n&&(!p||f.length>0)&&!h;function y(k){if(k.key==="Enter"){if(k.preventDefault(),!g){l(!0);return}r(f)}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:u,type:"text",value:o,onChange:k=>{i(k.target.value),l(!1)},onKeyDown:y,placeholder:e.placeholder,disabled:n,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),a&&e.pattern&&h?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:e.pattern.message}):null]})}function Rz({step:e,disabled:t,onSubmit:n}){const[r,o]=m.useState({phase:"loading"}),[i,a]=m.useState(""),[l,u]=m.useState(0),[f,p]=m.useState(0),h=m.useRef(null),g=m.useRef(null);m.useEffect(()=>{var v;(v=h.current)==null||v.focus()},[]),m.useEffect(()=>{let v=!1;return o({phase:"loading"}),Promise.resolve().then(()=>e.loadOptions()).then(b=>{v||o({phase:"loaded",options:b})}).catch(b=>{if(v)return;const j=b instanceof Error?b.message:"Failed to load options";o({phase:"error",message:j})}),()=>{v=!0}},[e,f]);const y=m.useMemo(()=>{if(r.phase!=="loaded")return[];const v=r.options.map(b=>({type:"option",title:b.label,subtitle:b.hint,keywords:[b.value],option:b}));return bw(i,v,100)},[r,i]);m.useEffect(()=>{u(0)},[y.length]),m.useEffect(()=>{var b;const v=(b=g.current)==null?void 0:b.querySelector(`[data-picker-idx="${l}"]`);v==null||v.scrollIntoView({block:"nearest"})},[l]);function k(v){if(r.phase==="loaded"){if(v.key==="ArrowDown")v.preventDefault(),u(b=>Math.min(y.length-1,b+1));else if(v.key==="ArrowUp")v.preventDefault(),u(b=>Math.max(0,b-1));else if(v.key==="Enter"){v.preventDefault();const b=y[l];b&&n(b.option.value)}}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:h,type:"text",value:i,onChange:v=>a(v.target.value),onKeyDown:k,placeholder:`Filter ${e.label.toLowerCase()}…`,disabled:t||r.phase==="loading",className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),s.jsx("div",{ref:g,className:"max-h-[60vh] min-h-[120px] overflow-y-auto p-1",children:r.phase==="loading"?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"Loading…"}):r.phase==="error"?s.jsxs("div",{className:"px-4 py-4 text-sm",children:[s.jsxs("div",{className:"mb-2 text-destructive",children:["Failed to load: ",r.message]}),s.jsx("button",{type:"button",onClick:()=>p(v=>v+1),className:"rounded border border-border/70 bg-background/60 px-2 py-1 text-xs text-foreground hover:bg-accent/40",children:"Retry"})]}):y.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:r.options.length===0?e.emptyMessage??"No options available":"No matches"}):y.map((v,b)=>{const j=b===l;return s.jsxs("button",{type:"button","data-picker-idx":b,onClick:()=>n(v.option.value),onMouseEnter:()=>u(b),disabled:t,className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${j?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.option.label}),v.option.hint?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:v.option.hint}):null]},v.option.value)})})]})}function Az({entries:e}){var Q,J;const t=Wt(),{actionsPaletteOpen:n,closeActionsPalette:r,customBindings:o,bindAction:i,findConflict:a,pendingActionKind:l,consumePendingActionKind:u}=Ai(),[f,p]=m.useState(""),[h,g]=m.useState(0),[y,k]=m.useState(null),[v,b]=m.useState(""),[j,S]=m.useState(null),[N,C]=m.useState(null),[P,T]=m.useState(!1),[R,I]=m.useState(null),_=m.useRef(null),F=m.useMemo(()=>e.map(Z=>({type:Z.group.toLowerCase(),title:Z.title,subtitle:Z.subtitle,keywords:Z.keywords,action:Z})),[e]),D=m.useMemo(()=>bw(f,F,50),[f,F]);m.useEffect(()=>{g(0)},[f,n]),m.useEffect(()=>{n||(p(""),k(null),b(""),S(null),C(null),T(!1),I(null))},[n]),m.useEffect(()=>{if(!n||!l)return;const Z=u();if(!Z)return;const oe=e.find(ne=>ne.bindableKind===Z);oe&&W(oe)},[n,l]),m.useEffect(()=>{var oe;const Z=(oe=_.current)==null?void 0:oe.querySelector(`[data-palette-idx="${h}"]`);Z==null||Z.scrollIntoView({block:"nearest"})},[h]);async function W(Z){if(!P){if(Z.flow&&Z.flow.steps.length>0){S({action:Z,stepIndex:0,values:{}}),I(null);return}if(Z.requiresInput){k(Z),b(""),I(null);return}if(Z.run){T(!0),I(null);try{await Z.run(),r()}catch(oe){I(oe instanceof Error?oe.message:"Action failed")}finally{T(!1)}}}}async function H(Z){if(!j)return;const oe=j.action.flow.steps[j.stepIndex],ne={...j.values,[oe.id]:Z};if(j.stepIndex+1<j.action.flow.steps.length){S({action:j.action,stepIndex:j.stepIndex+1,values:ne});return}T(!0),I(null);try{await j.action.flow.submit(ne,{navigate:t}),r()}catch(ue){I(ue instanceof Error?ue.message:"Action failed")}finally{T(!1)}}function $(){if(j&&!P){if(j.stepIndex===0){S(null),I(null);return}S({action:j.action,stepIndex:j.stepIndex-1,values:j.values}),I(null)}}async function O(){if(P||!(y!=null&&y.requiresInput))return;const Z=v.trim();if(Z){T(!0),I(null);try{await y.requiresInput.runWithInput(Z),r()}catch(oe){I(oe instanceof Error?oe.message:"Action failed")}finally{T(!1)}}}function U(Z){if(Z.key==="ArrowDown")Z.preventDefault(),g(oe=>Math.min(D.length-1,oe+1));else if(Z.key==="ArrowUp")Z.preventDefault(),g(oe=>Math.max(0,oe-1));else if(Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)){Z.preventDefault();const oe=D[h];oe!=null&&oe.action.bindableKind&&C({action:oe.action,combo:null,conflict:null,saving:!1,error:null})}else if(Z.key==="Enter"){Z.preventDefault();const oe=D[h];oe&&W(oe.action)}}function K(Z){Z.key==="Enter"?(Z.preventDefault(),O()):Z.key==="Escape"&&(Z.preventDefault(),k(null),b(""))}function M(Z){if(!N||Z.key==="Escape"||Z.key==="Enter"&&!N.combo)return;if(Z.key==="Enter"&&N.combo){Z.preventDefault(),Z.stopPropagation(),V();return}Z.preventDefault(),Z.stopPropagation();const oe=Z2(Z.nativeEvent);if(!oe)return;const ne=a(oe,N.action.bindableKind);C({...N,combo:oe,conflict:ne,error:null})}async function V(){var Z;if(!(!N||!N.combo||!N.action.bindableKind)){if((Z=N.conflict)!=null&&Z.description){C({...N,error:`Reserved: ${N.conflict.description}`});return}C({...N,saving:!0,error:null});try{await i(N.action.bindableKind,N.combo),C(null)}catch(oe){C({...N,saving:!1,error:oe instanceof Error?oe.message:"Failed to save binding"})}}}const L=y!==null,z=j!==null,Y=N!==null,B=j?j.action.flow.steps[j.stepIndex]:null;return s.jsx(Ln,{open:n,onOpenChange:Z=>Z?null:r(),children:s.jsxs(Sn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:Z=>{if(!P){if(Y){Z.preventDefault(),C(null);return}if(z){Z.preventDefault(),$();return}L&&(Z.preventDefault(),k(null),b(""),I(null))}},children:[s.jsx(Cn,{className:"sr-only",children:"Actions palette"}),Y&&N?s.jsxs("div",{onKeyDown:M,tabIndex:-1,autoFocus:!0,children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx(jb,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("span",{className:"text-sm text-foreground",children:["Bind hotkey for ",N.action.title]})]}),s.jsx("div",{className:"px-4 py-6 text-center",children:N.combo?s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-wide text-foreground",children:Zs(N.combo)}),(Q=N.conflict)!=null&&Q.description?s.jsxs("div",{className:"text-sm text-destructive",children:["Reserved: ",N.conflict.description," (cannot bind)"]}):(J=N.conflict)!=null&&J.kind?s.jsxs("div",{className:"text-sm text-amber-500 dark:text-amber-400",children:['Already bound to "',N.conflict.kind,'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press Enter to save, or another key to retry."}),N.error?s.jsx("div",{className:"text-sm text-destructive",children:N.error}):null]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press the key combination you want to bind…"})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"any key records · Enter saves · Esc cancels"}),s.jsx("span",{children:N.saving?"Saving…":""})]}),s.jsx("button",{type:"button",className:"sr-only",onClick:()=>void V(),"data-bind-confirm":!0}),s.jsx("input",{type:"hidden",onKeyDown:Z=>{Z.key==="Enter"&&V()}})]}):z&&B&&j?s.jsxs(s.Fragment,{children:[s.jsx(Ez,{label:`${j.action.title} · ${B.label}`,onBack:$,disabled:P,stepCounter:{current:j.stepIndex+1,total:j.action.flow.steps.length}}),B.kind==="text"?s.jsx(Tz,{step:B,initialValue:j.values[B.id],disabled:P,onSubmit:H}):s.jsx(Rz,{step:B,disabled:P,onSubmit:H}),R?s.jsx("div",{className:"border-t border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"↵ next · ← back · Esc back"}),s.jsx("span",{children:P?"Running…":""})]})]}):L?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:y.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.title})]}),s.jsx("input",{autoFocus:!0,type:"text",value:v,onChange:Z=>b(Z.target.value),onKeyDown:K,placeholder:y.requiresInput.placeholder,disabled:P,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↵"," submit ","·"," Esc back"]}),s.jsx("span",{children:P?"Running…":""})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("input",{autoFocus:!0,type:"text",value:f,onChange:Z=>p(Z.target.value),onKeyDown:U,placeholder:"Run an action: new project, new todo, toggle…",disabled:P,className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsx("div",{ref:_,className:"max-h-[60vh] overflow-y-auto p-1",children:D.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:f?"No matches":"Start typing to search actions"}):D.map((Z,oe)=>{const ne=oe===h,ue=Z.action.bindableKind,ge=ue?o[ue]:void 0;return s.jsxs("button",{type:"button","data-palette-idx":oe,onClick:()=>W(Z.action),onMouseEnter:()=>g(oe),disabled:P,className:`group flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${ne?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:Z.action.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Z.action.title}),Z.action.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:Z.action.subtitle}):null,ge?s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tracking-wide text-foreground",children:Zs(ge)}):null,ue?s.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Bind hotkey",onClick:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),C({action:Z.action,combo:null,conflict:null,saving:!1,error:null})},className:`shrink-0 inline-flex h-6 w-6 items-center justify-center rounded border border-border/70 bg-background/60 text-muted-foreground transition-opacity hover:text-foreground ${ne?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:s.jsx(jb,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):null]},Z.action.id)})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," run ","·"," ⌘↵ bind ","·"," Esc close"]}),s.jsx("span",{children:P?"Running…":`${D.length} action${D.length===1?"":"s"}`})]})]})]})})}const Pz=[{combo:"mod+k",description:"Open command palette",scope:"global"},{combo:"mod+shift+k",description:"Open actions palette",scope:"global"},{combo:"?",description:"Show keyboard shortcuts",scope:"global"},{combo:"escape",description:"Close dialog or cancel",scope:"global"},{combo:"enter",description:"Activate selected item",scope:"global"},{combo:"shift+t",description:"Toggle light/dark theme",scope:"global"},{combo:"g",description:"Start navigation chord",scope:"global"},{combo:"g o",description:"Go to Overview",scope:"global"},{combo:"g m",description:"Go to Projects",scope:"global"},{combo:"g a",description:"Go to Assignments",scope:"global"},{combo:"g t",description:"Go to Todos",scope:"global"},{combo:"g s",description:"Go to Servers",scope:"global"},{combo:"g !",description:"Go to Attention",scope:"global"},{combo:"g ,",description:"Go to Settings",scope:"global"},{combo:"j",description:"Move selection down",scope:"list"},{combo:"k",description:"Move selection up",scope:"list"},{combo:"o",description:"Open selected item",scope:"list"},{combo:"a",description:"New assignment in project",scope:"project"},{combo:"e",description:"Edit project / assignment",scope:"project|assignment"},{combo:"/",description:"Focus search",scope:"assignments-board"},{combo:"r",description:"Refresh board",scope:"assignments-board"},{combo:"p",description:"Edit plan",scope:"assignment"},{combo:"h",description:"Append handoff",scope:"assignment"},{combo:"d",description:"Append decision record",scope:"assignment"},{combo:"s",description:"Edit scratchpad",scope:"assignment"},{combo:"[",description:"Previous assignment",scope:"assignment"},{combo:"]",description:"Next assignment",scope:"assignment"}];function _z(e){const t=wr(e);return t?Pz.find(n=>n.combo===t)??null:null}const vu={"new-workspace":"New Workspace","new-project":"New Project","new-todo":"New Todo","new-assignment":"New Assignment"},Dz={global:"Global","list:overview":"Overview","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},$z=["global","list:overview","list:projects","list:assignments","list:todos","project","assignment"];function oN(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Zs(t)} then ${Zs(n)}`}return Zs(e)}function Iz(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n,customBindings:r,actionEntries:o}=Ai(),i=m.useMemo(()=>{const u=new Set;for(const f of Object.values(r))typeof f=="string"&&f&&u.add(wr(f));return u},[r]),a=m.useMemo(()=>{if(!e)return new Map;const u=n(),f=new Map;for(const p of u){if(i.has(wr(p.keys)))continue;const h=f.get(p.scope)??[];h.push({keys:p.keys,description:p.description}),f.set(p.scope,h)}return f},[e,n,i]),l=m.useMemo(()=>{const u=[];for(const[f,p]of Object.entries(r)){if(!p)continue;const h=o.find(g=>g.bindableKind===f);u.push({kind:f,combo:p,title:h?h.title:f})}return u},[r,o]);return s.jsx(Ln,{open:e,onOpenChange:u=>u?null:t(),children:s.jsxs(Sn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:"Keyboard shortcuts"}),s.jsxs(ns,{children:["Press Esc to close. ",Zs("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),s.jsxs("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:[$z.map(u=>{const f=a.get(u);return!f||f.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:Dz[u]}),s.jsx("ul",{className:"space-y-1",children:f.map((p,h)=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:p.description}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:oN(p.keys)})]},`${u}-${p.keys}-${h}`))})]},u)}),l.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Custom bindings"}),s.jsx("ul",{className:"space-y-1",children:l.map(u=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:u.title}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:oN(u.combo)})]},`custom-${u.kind}`))})]}):null]})]})})}const kw={bindings:{},custom:!1};let Wu=null,ml=null;const Db=new Set;function tR(e){Wu=e;for(const t of Db)t(e)}function Nw(e){if(!e||typeof e!="object")return kw;const t=e,n={};if(t.bindings&&typeof t.bindings=="object"&&!Array.isArray(t.bindings))for(const[r,o]of Object.entries(t.bindings)){if(!a5(r)||typeof o!="string"||o.trim()==="")continue;const i=wr(o);i&&(n[r]=i)}return{bindings:n,custom:t.custom===!0}}function Mz(){return Wu?Promise.resolve(Wu):ml||(ml=fetch("/api/config/hotkeys").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=Nw(e);return Wu=t,ml=null,t}).catch(()=>(ml=null,kw)),ml)}function Lz(){const[e,t]=m.useState(()=>Wu??kw);return m.useEffect(()=>{let n=!1;return Mz().then(r=>{n||t(r)}),Db.add(t),()=>{n=!0,Db.delete(t)}},[]),e}async function iN(e){const t={};for(const o of um){const i=e[o];if(typeof i!="string")continue;const a=wr(i);a&&(t[o]=a)}const n=await fetch("/api/config/hotkeys",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bindings:t})});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save hotkey bindings")}const r=Nw(await n.json());return tR(r),r}async function Oz(){const e=await fetch("/api/config/hotkeys",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=Nw(await e.json());return tR(t),t}const aN=1500;function Fz(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const nR=m.createContext(null);function zz({children:e}){const{toggleTheme:t}=ew(),n=sr(),r=Wt(),o=Fz(n.pathname),[i,a]=m.useState(!1),l=ro(i),u=lm(i),f=nw(i),p=tw(i),h=eT(i),{search:g}=lw(),y=m.useMemo(()=>{var ot,St,mt,at;const ve=l.data??[],be=((ot=u.data)==null?void 0:ot.assignments)??[],Re=((St=f.data)==null?void 0:St.playbooks)??[],He=((mt=p.data)==null?void 0:mt.sessions)??[],Fe=(((at=h.data)==null?void 0:at.workspaces)??[]).flatMap(ce=>ce.items.map(me=>({...me,workspace:ce.workspace})));return R5({projects:ve,assignments:be,playbooks:Re,servers:He,todos:Fe,wsPrefix:o,externalIds:g.externalIds})},[l.data,u.data,f.data,p.data,h.data,o,g.externalIds]),v=m.useMemo(()=>I2(n.pathname),[n.pathname]).projectSlug,b=m.useMemo(()=>{var ve;return v?((ve=l.data)==null?void 0:ve.find(be=>be.slug===v))??null:null},[l.data,v]),j=(b==null?void 0:b.title)??null,S=(b==null?void 0:b.workspace)??null,N=m.useMemo(()=>{var ve;return $5({playbooks:((ve=f.data)==null?void 0:ve.playbooks)??[],projectSlug:v,currentProjectTitle:j,currentProjectWorkspace:S,wsPrefix:o,refetchPlaybooks:f.refetch,navigate:r,toggleTheme:t})},[f.data,f.refetch,v,j,S,o,r,t]),C=m.useRef(new Map),P=m.useRef(["global"]),T=m.useRef({phase:"idle"}),R=m.useRef(null),I=m.useRef(1),[_,F]=m.useState(!1),[D,W]=m.useState(!1),[H,$]=m.useState(!1),[O,U]=m.useState(null);m.useEffect(()=>{(_||H)&&a(!0)},[_,H]);const{bindings:K}=Lz(),M=m.useMemo(()=>f5(K),[K]),V=m.useCallback(ve=>{const be=I.current++;return C.current.set(be,{...ve,id:be}),be},[]),L=m.useCallback(ve=>{C.current.delete(ve)},[]),z=m.useCallback(ve=>{P.current.push(ve)},[]),Y=m.useCallback(ve=>{const be=P.current;for(let Re=be.length-1;Re>=0;Re--)if(be[Re]===ve){be.splice(Re,1);return}},[]),B=m.useCallback(()=>F(!0),[]),Q=m.useCallback(()=>F(!1),[]),J=m.useCallback(()=>W(!0),[]),Z=m.useCallback(()=>W(!1),[]),oe=m.useCallback(()=>$(!0),[]),ne=m.useCallback(()=>{$(!1),U(null)},[]),ue=m.useCallback(()=>Array.from(C.current.values()),[]),ge=m.useCallback(()=>{let ve=null;return U(be=>(ve=be,null)),ve},[]),Ce=m.useCallback(ve=>{U(ve),$(!0)},[]),Ne=m.useCallback((ve,be)=>{const Re=wr(ve);if(!Re)return null;if(u5(Re)){const He=_z(Re);return{description:(He==null?void 0:He.description)??"Reserved built-in shortcut"}}for(const[He,rt]of Object.entries(M))if(!(be&&He===be)&&rt===Re)return{kind:He};return null},[M]),ke=m.useCallback(async(ve,be)=>{const Re=wr(be);if(!Re)throw new Error("Empty combo");const He=Ne(Re,ve);if(He){const Fe=He.description?`Reserved: ${He.description}`:`Already bound to "${He.kind}"`;throw new Error(Fe)}const rt={...K,[ve]:Re};return await iN(rt),Re},[K,Ne]),Ue=m.useCallback(async ve=>{if(!K[ve])return;const be={...K};delete be[ve],await iN(be)},[K]);m.useEffect(()=>{T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[n.pathname]),m.useEffect(()=>{function ve(Fe){if(!(Fe instanceof HTMLElement))return!1;const ot=Fe.tagName;return!!(ot==="INPUT"||ot==="TEXTAREA"||ot==="SELECT"||Fe.isContentEditable||Fe.closest('[role="combobox"], [role="textbox"]'))}function be(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function Re(){const Fe=P.current;return Fe[Fe.length-1]??"global"}function He(Fe){return Fe.scope==="global"?!0:Fe.scope===Re()}function rt(Fe){const ot=op(Fe,"Mod+k"),St=op(Fe,"Mod+Shift+k"),mt=Fe.key==="Escape",at=ot||St||mt;if(be()&&!at||ve(Fe.target)&&!at)return;const ce=T.current;if(ce.phase==="awaiting-second")if(Date.now()-ce.startedAt>aN)T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null);else{const Ae=Array.from(C.current.values());for(const We of Ae){if(!He(We))continue;const pt=We.keys.split(" ");if(!(pt.length!==2||pt[0]!=="g")&&op(Fe,pt[1])&&!(We.when&&!We.when())){Fe.preventDefault(),T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null),We.handler(Fe);return}}T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)}const me=Array.from(C.current.values());for(const Ie of me){if(!He(Ie))continue;const Ae=Ie.keys.split(" ");if(Ae.length===1&&op(Fe,Ae[0])&&!(Ie.when&&!Ie.when())){Fe.preventDefault(),Ie.handler(Fe);return}}Fe.key==="g"&&!Fe.metaKey&&!Fe.ctrlKey&&!Fe.altKey&&!Fe.shiftKey&&Array.from(C.current.values()).some(Ae=>He(Ae)&&Ae.keys.startsWith("g "))&&(Fe.preventDefault(),T.current={phase:"awaiting-second",startedAt:Date.now()},R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{T.current={phase:"idle"},R.current=null},aN))}return window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[]),m.useEffect(()=>{const ve=V({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>L(ve)},[V,L,t]),m.useEffect(()=>{const ve=V({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>J()});return()=>L(ve)},[V,L,J]),m.useEffect(()=>{const ve=V({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(_){Q();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||B()}});return()=>L(ve)},[V,L,B,Q,_]),m.useEffect(()=>{const ve=V({keys:"Mod+Shift+k",scope:"global",description:"Open actions palette",handler:()=>{if(H){ne();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||oe()}});return()=>L(ve)},[V,L,oe,ne,H]),m.useEffect(()=>{const be=[{suffix:"o",basePath:"/",desc:"Go to Overview"},{suffix:"m",basePath:"/projects",desc:"Go to Projects"},{suffix:"a",basePath:"/assignments",desc:"Go to Assignments"},{suffix:"t",basePath:"/todos",desc:"Go to Todos"},{suffix:"s",basePath:"/servers",desc:"Go to Servers"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map(Re=>V({keys:`g ${Re.suffix}`,scope:"global",description:Re.desc,handler:()=>r(Lp(Re.basePath,o))}));return()=>be.forEach(L)},[V,L,r,o]),m.useEffect(()=>{const ve=[];for(const[be,Re]of Object.entries(M)){if(!Re)continue;const He=N.find(Fe=>Fe.bindableKind===be),rt=He?`Custom: ${He.title}`:`Custom: ${be}`;ve.push(V({keys:Re,scope:"global",description:rt,handler:()=>{U(be),$(!0)}}))}return()=>ve.forEach(L)},[V,L,M,N]);const ie=m.useMemo(()=>({register:V,unregister:L,pushScope:z,popScope:Y,openPalette:B,closePalette:Q,paletteOpen:_,openCheatsheet:J,closeCheatsheet:Z,cheatsheetOpen:D,openActionsPalette:oe,closeActionsPalette:ne,actionsPaletteOpen:H,listBindings:ue,wsPrefix:o,paletteEntries:y,actionEntries:N,userBindings:K,customBindings:M,bindAction:ke,unbindAction:Ue,findConflict:Ne,openActionsPaletteWithAction:Ce,pendingActionKind:O,consumePendingActionKind:ge}),[V,L,z,Y,B,Q,_,J,Z,D,oe,ne,H,ue,o,y,N,K,M,ke,Ue,Ne,Ce,O,ge]);return s.jsxs(nR.Provider,{value:ie,children:[e,s.jsx(Cz,{entries:y}),s.jsx(Az,{entries:N}),s.jsx(Iz,{})]})}function Ai(){const e=m.useContext(nR);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function en({keys:e,handler:t,scope:n="global",description:r,when:o,enabled:i=!0}){const{register:a,unregister:l}=Ai(),u=m.useRef(t),f=m.useRef(o);m.useEffect(()=>{u.current=t,f.current=o},[t,o]),m.useEffect(()=>{if(!i)return;const p=a({keys:e,handler:h=>u.current(h),scope:n,description:r,when:f.current?()=>f.current():void 0});return()=>l(p)},[a,l,e,n,r,i])}function Pi(e){const{pushScope:t,popScope:n}=Ai();m.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function Ld(e,t){const[n,r]=m.useState(e.length===0?-1:0),o=sr();m.useEffect(()=>{r(e.length===0?-1:0)},[o.pathname]),m.useEffect(()=>{r(a=>e.length===0?-1:Math.min(Math.max(0,a),e.length-1))},[e.length]),m.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(l=>{const u=Number(l.getAttribute("data-hotkey-row-index"));l.setAttribute("data-hotkey-selected",u===n?"true":"false")}),n>=0){const l=document.querySelector(`[data-hotkey-row-index="${n}"]`);l==null||l.scrollIntoView({block:"nearest"})}},[n,e.length]),en({keys:"j",scope:t.scope,description:"Select next row",handler:()=>r(a=>e.length===0?-1:Math.min(e.length-1,a<0?0:a+1))}),en({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>r(a=>e.length===0?-1:Math.max(0,a<0?0:a-1))}),en({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),en({keys:"o",scope:t.scope,description:"Open selected row",enabled:t.bindO??!0,handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}});const i=m.useCallback(a=>({"data-hotkey-row-index":a,"data-hotkey-selected":a===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:i}}function Bz(){return m.useSyncExternalStore(IO,M1,M1)}function Uz(e){switch(e){case"reconnecting":return{show:!0,label:"Reconnecting…",tone:"amber"};case"closed":return{show:!0,label:"Offline",tone:"amber"};case"connecting":return{show:!0,label:"Connecting…",tone:"muted"};case"open":return{show:!1,label:"Live",tone:"muted"}}}function Hz(){const e=Bz(),t=Uz(e);return s.jsx("div",{role:"status","aria-live":"polite",className:"flex items-center",children:t.show?s.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${t.tone==="amber"?"border-warning-foreground/30 bg-warning text-warning-foreground":"border-border/70 bg-background/80 text-muted-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${t.tone==="amber"?"bg-warning-foreground animate-pulse":"bg-muted-foreground/60"}`}),t.label]}):s.jsx("span",{className:"sr-only"})})}function Vz({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:r}){const o=gn(),{resolvedTheme:i,toggleTheme:a}=ew(),{openPalette:l}=Ai();return s.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/70 backdrop-blur",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[s.jsx("button",{type:"button",onClick:r,className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-card/80 text-foreground lg:hidden","aria-label":"Open navigation",children:s.jsx(P4,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?s.jsxs("nav",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:[t.slice(0,-1).map((u,f)=>s.jsxs("span",{className:"flex items-center gap-1.5",children:[f>0?s.jsx("span",{children:"/"}):null,s.jsx($e,{to:u.path,className:"hover:text-foreground",children:u.label})]},u.path)),s.jsx("span",{children:"/"})]}):null,s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:e})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hz,{}),s.jsxs("button",{type:"button",onClick:l,className:"shell-action","aria-label":"Open command palette",children:[s.jsx(Ei,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Zs("Mod+k")})]}),s.jsx($e,{className:"shell-action hidden sm:inline-flex",to:"/help",children:"Help"}),s.jsxs($e,{className:"shell-action",to:`${o}/create/project`,"aria-label":"New Project",children:[s.jsx(Pt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Project"})]}),n?s.jsxs($e,{className:"shell-action",to:`${o}/projects/${n}/create/assignment`,"aria-label":"New Assignment",children:[s.jsx(Pt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Assignment"})]}):null,s.jsxs("button",{type:"button",onClick:a,className:"shell-action","aria-label":"Toggle theme",children:[i==="dark"?s.jsx(H4,{className:"h-4 w-4"}):s.jsx(_4,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:i==="dark"?"Light":"Dark"})]})]})]})})}const Wz=4e3;function Qn(){const[e,t]=m.useState(null),n=m.useRef(null),r=m.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=m.useCallback((i,a="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:a}),n.current=setTimeout(()=>{t(null),n.current=null},Wz)},[]);return m.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:r}}function Xn({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return s.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:s.jsx("button",{type:"button",onClick:t,className:je("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)})}const lN={review:0,blocked:0,question:0,"plan-approval":0};function rR(){const[e,t]=m.useState([]),[n,r]=m.useState(lN),[o,i]=m.useState(0),[a,l]=m.useState(!0),[u,f]=m.useState(null),[p,h]=m.useState(0),g=m.useCallback(()=>{h(y=>y+1)},[]);return m.useEffect(()=>{let y=!1;return l(!0),f(null),fetch("/api/inbox").then(async k=>{if(!k.ok){const v=await k.json().catch(()=>null);throw new Error((v==null?void 0:v.error)||`HTTP ${k.status}`)}return k.json()}).then(k=>{y||(t(Array.isArray(k.items)?k.items:[]),r(k.counts??lN),i(typeof k.total=="number"?k.total:0),l(!1))}).catch(k=>{y||(f(k.message),l(!1))}),()=>{y=!0}},[p]),Ti(y=>{(y.type==="assignment-updated"||y.type==="project-updated")&&g()}),{items:e,counts:n,total:o,loading:a,error:u,refetch:g}}const sR="syntaur.sidebar.collapsed.v1";function oR(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Kz(e){if(!e)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}function qz(e,t){return{...e,[t]:!(e[t]??!1)}}function Gz(){const e=oR();if(!e)return{};try{return Kz(e.getItem(sR))}catch{return{}}}let Vp=Gz();const $b=new Set,Yz={};function Xz(e){const t=oR();if(t)try{t.setItem(sR,JSON.stringify(e))}catch{}}function Qz(e){return $b.add(e),()=>{$b.delete(e)}}function Jz(){return Vp}function Zz(){return Yz}function eB(e){Vp=qz(Vp,e),Xz(Vp);for(const t of $b)t()}function tB(){const e=m.useSyncExternalStore(Qz,Jz,Zz);return{isCollapsed:(n,r=!1)=>e[n]??r,toggle:eB}}const hh="_ungrouped",nB=256;function rB(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const o=r.trim();o.length!==0&&(o.length>nB||/[\r\n]/.test(o)||t.has(o)||(t.add(o),n.push(o)))}return n}function sB(e,t){if(t.length===0)return[...e];const n=new Set(t);return e.filter(r=>!n.has(r))}function oB(e,t){return t.includes(e)}const Sw={hidden:[],custom:!1};let No=null,ta=null,id=0;const Ib=new Set;function iR(e){No=e;for(const t of Ib)t(e)}function Cw(e){if(!e||typeof e!="object")return Sw;const t=e;return{hidden:rB(t.hidden),custom:t.custom===!0}}function iB(){if(No)return Promise.resolve({value:No,ok:!0});if(ta)return ta;const e=++id;return ta=fetch("/api/config/workspace-visibility").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{ta=null;const n=Cw(t);return e!==id?{value:No??n,ok:!0}:(No=n,{value:n,ok:!0})}).catch(()=>(ta=null,{value:Sw,ok:!1})),ta}function aR(){const[e,t]=m.useState(()=>No??Sw),[n,r]=m.useState(()=>No===null),[o,i]=m.useState(!1),[a,l]=m.useState(0);m.useEffect(()=>{let f=!1;return r(No===null),iB().then(p=>{f||(t(p.value),r(!1),i(!p.ok))}),Ib.add(t),()=>{f=!0,Ib.delete(t)}},[a]);function u(){aB(),l(f=>f+1)}return{...e,loading:n,error:o,reload:u}}function aB(){No=null,ta=null,++id}async function lB(e){++id;const t=await fetch("/api/config/workspace-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hidden:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=Cw(await t.json());return iR(n),n}async function cB(){++id;const e=await fetch("/api/config/workspace-visibility",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=Cw(await e.json());return iR(t),t}var uB=Symbol("radix.slottable");function dB(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=uB,t}var lR="AlertDialog",[fB]=Ra(lR,[ET]),_o=ET(),cR=e=>{const{__scopeAlertDialog:t,...n}=e,r=_o(t);return s.jsx(HT,{...r,...n,modal:!0})};cR.displayName=lR;var pB="AlertDialogTrigger",hB=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(VT,{...o,...r,ref:t})});hB.displayName=pB;var mB="AlertDialogPortal",uR=e=>{const{__scopeAlertDialog:t,...n}=e,r=_o(t);return s.jsx(WT,{...r,...n})};uR.displayName=mB;var gB="AlertDialogOverlay",dR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(hw,{...o,...r,ref:t})});dR.displayName=gB;var Bl="AlertDialogContent",[xB,yB]=fB(Bl),bB=dB("AlertDialogContent"),fR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,i=_o(n),a=m.useRef(null),l=rr(t,a),u=m.useRef(null);return s.jsx(C6,{contentName:Bl,titleName:pR,docsSlug:"alert-dialog",children:s.jsx(xB,{scope:n,cancelRef:u,children:s.jsxs(mw,{role:"alertdialog",...i,...o,ref:l,onOpenAutoFocus:sn(o.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=u.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[s.jsx(bB,{children:r}),s.jsx(wB,{contentRef:a})]})})})});fR.displayName=Bl;var pR="AlertDialogTitle",hR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(gw,{...o,...r,ref:t})});hR.displayName=pR;var mR="AlertDialogDescription",gR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(xw,{...o,...r,ref:t})});gR.displayName=mR;var vB="AlertDialogAction",xR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=_o(n);return s.jsx(yw,{...o,...r,ref:t})});xR.displayName=vB;var yR="AlertDialogCancel",bR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=yB(yR,n),i=_o(n),a=rr(t,o);return s.jsx(yw,{...i,...r,ref:a})});bR.displayName=yR;var wB=({contentRef:e})=>{const t=`\`${Bl}\` requires a description for the component to be accessible for screen reader users.
606
606
 
607
607
  You can add a description to the \`${Bl}\` by passing a \`${mR}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
608
608
 
@@ -612,7 +612,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
612
612
  To pick up a draggable item, press the space bar.
613
613
  While dragging, use the arrow keys to move the item.
614
614
  Press space again to drop the item in its new position, or press escape to cancel.
615
- `},HB={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function VB(e){let{announcements:t=HB,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=UB}=e;const{announce:i,announcement:a}=FB(),l=zd("DndLiveRegion"),[u,f]=m.useState(!1);if(m.useEffect(()=>{f(!0)},[]),zB(m.useMemo(()=>({onDragStart(h){let{active:g}=h;i(t.onDragStart({active:g}))},onDragMove(h){let{active:g,over:y}=h;t.onDragMove&&i(t.onDragMove({active:g,over:y}))},onDragOver(h){let{active:g,over:y}=h;i(t.onDragOver({active:g,over:y}))},onDragEnd(h){let{active:g,over:y}=h;i(t.onDragEnd({active:g,over:y}))},onDragCancel(h){let{active:g,over:y}=h;i(t.onDragCancel({active:g,over:y}))}}),[i,t])),!u)return null;const p=Lt.createElement(Lt.Fragment,null,Lt.createElement(LB,{id:r,value:o.draggable}),Lt.createElement(OB,{id:l,announcement:a}));return n?Ys.createPortal(p,n):p}var $n;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})($n||($n={}));function yh(){}function ki(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function jm(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ks=Object.freeze({x:0,y:0});function AR(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function WB(e,t){const n=xh(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function PR(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function KB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function dN(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function _R(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function fN(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const km=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=fN(t,t.left,t.top),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=AR(fN(u),o);i.push({id:l,data:{droppableContainer:a,value:f}})}}return i.sort(PR)},qB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=dN(t),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=dN(u),p=o.reduce((g,y,k)=>g+AR(f[k],y),0),h=Number((p/4).toFixed(4));i.push({id:l,data:{droppableContainer:a,value:h}})}}return i.sort(PR)};function GB(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r<o&&n<i){const u=t.width*t.height,f=e.width*e.height,p=a*l,h=p/(u+f-p);return Number(h.toFixed(4))}return 0}const YB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const u=GB(l,t);u>0&&o.push({id:a,data:{droppableContainer:i,value:u}})}}return o.sort(KB)};function XB(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function DR(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ks}function QB(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,l)=>({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const JB=QB(1);function $R(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ZB(e,t,n){const r=$R(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,u=e.left-a-(1-o)*parseFloat(n),f=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),p=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:p,height:h,top:f,right:u+p,bottom:f+h,left:u}}const e8={ignoreTransform:!1};function Sc(e,t){t===void 0&&(t=e8);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:p}=ur(e).getComputedStyle(e);f&&(n=ZB(n,f,p))}const{top:r,left:o,width:i,height:a,bottom:l,right:u}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:u}}function pN(e){return Sc(e,{ignoreTransform:!0})}function t8(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function n8(e,t){return t===void 0&&(t=ur(e).getComputedStyle(e)),t.position==="fixed"}function r8(e,t){t===void 0&&(t=ur(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function Nm(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Tw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Od(o)||ER(o)||n.includes(o))return n;const i=ur(e).getComputedStyle(o);return o!==e&&r8(o,i)&&n.push(o),n8(o,i)?n:r(o.parentNode)}return e?r(e):n}function IR(e){const[t]=Nm(e,1);return t??null}function gy(e){return!bm||!e?null:kc(e)?e:Ew(e)?Tw(e)||e===Nc(e).scrollingElement?window:Od(e)?e:null:null}function MR(e){return kc(e)?e.scrollX:e.scrollLeft}function LR(e){return kc(e)?e.scrollY:e.scrollTop}function Mb(e){return{x:MR(e),y:LR(e)}}var Vn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vn||(Vn={}));function OR(e){return!bm||!e?!1:e===document.scrollingElement}function FR(e){const t={x:0,y:0},n=OR(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:l,maxScroll:r,minScroll:t}}const s8={x:.2,y:.2};function o8(e,t,n,r,o){let{top:i,left:a,right:l,bottom:u}=n;r===void 0&&(r=10),o===void 0&&(o=s8);const{isTop:f,isBottom:p,isLeft:h,isRight:g}=FR(e),y={x:0,y:0},k={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!f&&i<=t.top+v.height?(y.y=Vn.Backward,k.y=r*Math.abs((t.top+v.height-i)/v.height)):!p&&u>=t.bottom-v.height&&(y.y=Vn.Forward,k.y=r*Math.abs((t.bottom-v.height-u)/v.height)),!g&&l>=t.right-v.width?(y.x=Vn.Forward,k.x=r*Math.abs((t.right-v.width-l)/v.width)):!h&&a<=t.left+v.width&&(y.x=Vn.Backward,k.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:y,speed:k}}function i8(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function zR(e){return e.reduce((t,n)=>Ul(t,Mb(n)),ks)}function a8(e){return e.reduce((t,n)=>t+MR(n),0)}function l8(e){return e.reduce((t,n)=>t+LR(n),0)}function BR(e,t){if(t===void 0&&(t=Sc),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);IR(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const c8=[["x",["left","right"],a8],["y",["top","bottom"],l8]];class Rw{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Nm(n),o=zR(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,l]of c8)for(const u of a)Object.defineProperty(this,u,{get:()=>{const f=l(r),p=o[i]-f;return this.rect[u]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ku{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function u8(e){const{EventTarget:t}=ur(e);return e instanceof t?e:Nc(e)}function xy(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Zr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Zr||(Zr={}));function hN(e){e.preventDefault()}function d8(e){e.stopPropagation()}var At;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(At||(At={}));const UR={start:[At.Space,At.Enter],cancel:[At.Esc],end:[At.Space,At.Enter,At.Tab]},f8=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case At.Right:return{...n,x:n.x+25};case At.Left:return{...n,x:n.x-25};case At.Down:return{...n,y:n.y+25};case At.Up:return{...n,y:n.y-25}}};class Cc{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ku(Nc(n)),this.windowListeners=new Ku(ur(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&BR(r),n(ks)}handleKeyDown(t){if(wm(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=UR,coordinateGetter:a=f8,scrollBehavior:l="smooth"}=o,{code:u}=t;if(i.end.includes(u)){this.handleEnd(t);return}if(i.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:f}=r.current,p=f?{x:f.left,y:f.top}:ks;this.referenceCoordinates||(this.referenceCoordinates=p);const h=a(t,{active:n,context:r.current,currentCoordinates:p});if(h){const g=cd(h,p),y={x:0,y:0},{scrollableAncestors:k}=r.current;for(const v of k){const b=t.code,{isTop:j,isRight:S,isLeft:N,isBottom:C,maxScroll:P,minScroll:T}=FR(v),R=i8(v),I={x:Math.min(b===At.Right?R.right-R.width/2:R.right,Math.max(b===At.Right?R.left:R.left+R.width/2,h.x)),y:Math.min(b===At.Down?R.bottom-R.height/2:R.bottom,Math.max(b===At.Down?R.top:R.top+R.height/2,h.y))},_=b===At.Right&&!S||b===At.Left&&!N,F=b===At.Down&&!C||b===At.Up&&!j;if(_&&I.x!==h.x){const D=v.scrollLeft+g.x,W=b===At.Right&&D<=P.x||b===At.Left&&D>=T.x;if(W&&!g.y){v.scrollTo({left:D,behavior:l});return}W?y.x=v.scrollLeft-D:y.x=b===At.Right?v.scrollLeft-P.x:v.scrollLeft-T.x,y.x&&v.scrollBy({left:-y.x,behavior:l});break}else if(F&&I.y!==h.y){const D=v.scrollTop+g.y,W=b===At.Down&&D<=P.y||b===At.Up&&D>=T.y;if(W&&!g.x){v.scrollTo({top:D,behavior:l});return}W?y.y=v.scrollTop-D:y.y=b===At.Down?v.scrollTop-P.y:v.scrollTop-T.y,y.y&&v.scrollBy({top:-y.y,behavior:l});break}}this.handleMove(t,Ul(cd(h,this.referenceCoordinates),y))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Cc.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=UR,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function mN(e){return!!(e&&"distance"in e)}function gN(e){return!!(e&&"delay"in e)}class Aw{constructor(t,n,r){var o;r===void 0&&(r=u8(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=Nc(a),this.documentListeners=new Ku(this.document),this.listeners=new Ku(r),this.windowListeners=new Ku(ur(a)),this.initialCoordinates=(o=xh(i))!=null?o:ks,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.DragStart,hN),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),this.windowListeners.add(Zr.ContextMenu,hN),this.documentListeners.add(Zr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gN(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(mN(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Zr.Click,d8,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:l}}=i;if(!o)return;const u=(n=xh(t))!=null?n:ks,f=cd(o,u);if(!r&&l){if(mN(l)){if(l.tolerance!=null&&xy(f,l.tolerance))return this.handleCancel();if(xy(f,l.distance))return this.handleStart()}if(gN(l)&&xy(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),a(u)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===At.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const p8={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ec extends Aw{constructor(t){const{event:n}=t,r=Nc(n.target);super(t,p8,r)}}Ec.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const h8={move:{name:"mousemove"},end:{name:"mouseup"}};var Lb;(function(e){e[e.RightClick=2]="RightClick"})(Lb||(Lb={}));class m8 extends Aw{constructor(t){super(t,h8,Nc(t.event.target))}}m8.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Lb.RightClick?!1:(r==null||r({event:n}),!0)}}];const yy={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class g8 extends Aw{constructor(t){super(t,yy)}static setup(){return window.addEventListener(yy.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(yy.move.name,t)};function t(){}}}g8.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var qu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qu||(qu={}));var bh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bh||(bh={}));function x8(e){let{acceleration:t,activator:n=qu.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=bh.TreeOrder,pointerCoordinates:u,scrollableAncestors:f,scrollableAncestorRects:p,delta:h,threshold:g}=e;const y=b8({delta:h,disabled:!i}),[k,v]=_B(),b=m.useRef({x:0,y:0}),j=m.useRef({x:0,y:0}),S=m.useMemo(()=>{switch(n){case qu.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case qu.DraggableRect:return o}},[n,o,u]),N=m.useRef(null),C=m.useCallback(()=>{const T=N.current;if(!T)return;const R=b.current.x*j.current.x,I=b.current.y*j.current.y;T.scrollBy(R,I)},[]),P=m.useMemo(()=>l===bh.TreeOrder?[...f].reverse():f,[l,f]);m.useEffect(()=>{if(!i||!f.length||!S){v();return}for(const T of P){if((r==null?void 0:r(T))===!1)continue;const R=f.indexOf(T),I=p[R];if(!I)continue;const{direction:_,speed:F}=o8(T,I,S,t,g);for(const D of["x","y"])y[D][_[D]]||(F[D]=0,_[D]=0);if(F.x>0||F.y>0){v(),N.current=T,k(C,a),b.current=F,j.current=_;return}}b.current={x:0,y:0},j.current={x:0,y:0},v()},[t,C,r,v,i,a,JSON.stringify(S),JSON.stringify(y),k,f,P,p,JSON.stringify(g)])}const y8={x:{[Vn.Backward]:!1,[Vn.Forward]:!1},y:{[Vn.Backward]:!1,[Vn.Forward]:!1}};function b8(e){let{delta:t,disabled:n}=e;const r=gh(t);return Fd(o=>{if(n||!r||!o)return y8;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Vn.Backward]:o.x[Vn.Backward]||i.x===-1,[Vn.Forward]:o.x[Vn.Forward]||i.x===1},y:{[Vn.Backward]:o.y[Vn.Backward]||i.y===-1,[Vn.Forward]:o.y[Vn.Forward]||i.y===1}}},[n,t,r])}function v8(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fd(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function w8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var ud;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ud||(ud={}));var Ob;(function(e){e.Optimized="optimized"})(Ob||(Ob={}));const xN=new Map;function j8(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=m.useState(null),{frequency:l,measure:u,strategy:f}=o,p=m.useRef(e),h=b(),g=ld(h),y=m.useCallback(function(j){j===void 0&&(j=[]),!g.current&&a(S=>S===null?j:S.concat(j.filter(N=>!S.includes(N))))},[g]),k=m.useRef(null),v=Fd(j=>{if(h&&!n)return xN;if(!j||j===xN||p.current!==e||i!=null){const S=new Map;for(let N of e){if(!N)continue;if(i&&i.length>0&&!i.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const C=N.node.current,P=C?new Rw(u(C),C):null;N.rect.current=P,P&&S.set(N.id,P)}return S}return j},[e,i,n,h,u]);return m.useEffect(()=>{p.current=e},[e]),m.useEffect(()=>{h||y()},[n,h]),m.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),m.useEffect(()=>{h||typeof l!="number"||k.current!==null||(k.current=setTimeout(()=>{y(),k.current=null},l))},[l,h,y,...r]),{droppableRects:v,measureDroppableContainers:y,measuringScheduled:i!=null};function b(){switch(f){case ud.Always:return!1;case ud.BeforeDragging:return n;default:return!n}}}function Pw(e,t){return Fd(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function k8(e,t){return Pw(e,t)}function N8(e){let{callback:t,disabled:n}=e;const r=vm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Sm(e){let{callback:t,disabled:n}=e;const r=vm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function S8(e){return new Rw(Sc(e),e)}function yN(e,t,n){t===void 0&&(t=S8);const[r,o]=m.useState(null);function i(){o(u=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=u??n)!=null?f:null}const p=t(e);return JSON.stringify(u)===JSON.stringify(p)?u:p})}const a=N8({callback(u){if(e)for(const f of u){const{type:p,target:h}=f;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=Sm({callback:i});return ws(()=>{i(),e?(l==null||l.observe(e),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[e]),r}function C8(e){const t=Pw(e);return DR(e,t)}const bN=[];function E8(e){const t=m.useRef(e),n=Fd(r=>e?r&&r!==bN&&e&&t.current&&e.parentNode===t.current.parentNode?r:Nm(e):bN,[e]);return m.useEffect(()=>{t.current=e},[e]),n}function T8(e){const[t,n]=m.useState(null),r=m.useRef(e),o=m.useCallback(i=>{const a=gy(i.target);a&&n(l=>l?(l.set(a,Mb(a)),new Map(l)):null)},[]);return m.useEffect(()=>{const i=r.current;if(e!==i){a(i);const l=e.map(u=>{const f=gy(u);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Mb(f)]):null}).filter(u=>u!=null);n(l.length?new Map(l):null),r.current=e}return()=>{a(e),a(i)};function a(l){l.forEach(u=>{const f=gy(u);f==null||f.removeEventListener("scroll",o)})}},[o,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>Ul(i,a),ks):zR(e):ks,[e,t])}function vN(e,t){t===void 0&&(t=[]);const n=m.useRef(null);return m.useEffect(()=>{n.current=null},t),m.useEffect(()=>{const r=e!==ks;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?cd(e,n.current):ks}function R8(e){m.useEffect(()=>{if(!bm)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function A8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function HR(e){return m.useMemo(()=>e?t8(e):null,[e])}const wN=[];function P8(e,t){t===void 0&&(t=Sc);const[n]=e,r=HR(n?ur(n):null),[o,i]=m.useState(wN);function a(){i(()=>e.length?e.map(u=>OR(u)?r:new Rw(t(u),u)):wN)}const l=Sm({callback:a});return ws(()=>{l==null||l.disconnect(),a(),e.forEach(u=>l==null?void 0:l.observe(u))},[e]),o}function VR(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Od(t)?t:e}function _8(e){let{measure:t}=e;const[n,r]=m.useState(null),o=m.useCallback(f=>{for(const{target:p}of f)if(Od(p)){r(h=>{const g=t(p);return h?{...h,width:g.width,height:g.height}:g});break}},[t]),i=Sm({callback:o}),a=m.useCallback(f=>{const p=VR(f);i==null||i.disconnect(),p&&(i==null||i.observe(p)),r(p?t(p):null)},[t,i]),[l,u]=mh(a);return m.useMemo(()=>({nodeRef:l,rect:n,setRef:u}),[n,l,u])}const D8=[{sensor:Ec,options:{}},{sensor:Cc,options:{}}],$8={current:{}},Wp={draggable:{measure:pN},droppable:{measure:pN,strategy:ud.WhileDragging,frequency:Ob.Optimized},dragOverlay:{measure:Sc}};class Gu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const I8={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Gu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Wp,measureDroppableContainers:yh,windowRect:null,measuringScheduled:!1},WR={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yh,draggableNodes:new Map,over:null,measureDroppableContainers:yh},Bd=m.createContext(WR),KR=m.createContext(I8);function M8(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Gu}}}function L8(e,t){switch(t.type){case $n.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $n.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case $n.DragEnd:case $n.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $n.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Gu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $n.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Gu(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case $n.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Gu(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function O8(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=m.useContext(Bd),i=gh(r),a=gh(n==null?void 0:n.id);return m.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!wm(i)||document.activeElement===i.target)return;const l=o.get(a);if(!l)return;const{activatorNode:u,node:f}=l;if(!u.current&&!f.current)return;requestAnimationFrame(()=>{for(const p of[u.current,f.current]){if(!p)continue;const h=IB(p);if(h){h.focus();break}}})}},[r,t,o,a,i]),null}function qR(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function F8(e){return m.useMemo(()=>({draggable:{...Wp.draggable,...e==null?void 0:e.draggable},droppable:{...Wp.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Wp.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function z8(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=m.useRef(!1),{x:a,y:l}=typeof o=="boolean"?{x:o,y:o}:o;ws(()=>{if(!a&&!l||!t){i.current=!1;return}if(i.current||!r)return;const f=t==null?void 0:t.node.current;if(!f||f.isConnected===!1)return;const p=n(f),h=DR(p,r);if(a||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=IR(f);g&&g.scrollBy({top:h.y,left:h.x})}},[t,a,l,r,n])}const Cm=m.createContext({...ks,scaleX:1,scaleY:1});var xi;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(xi||(xi={}));const Em=m.memo(function(t){var n,r,o,i;let{id:a,accessibility:l,autoScroll:u=!0,children:f,sensors:p=D8,collisionDetection:h=YB,measuring:g,modifiers:y,...k}=t;const v=m.useReducer(L8,void 0,M8),[b,j]=v,[S,N]=BB(),[C,P]=m.useState(xi.Uninitialized),T=C===xi.Initialized,{draggable:{active:R,nodes:I,translate:_},droppable:{containers:F}}=b,D=R!=null?I.get(R):null,W=m.useRef({initial:null,translated:null}),H=m.useMemo(()=>{var lt;return R!=null?{id:R,data:(lt=D==null?void 0:D.data)!=null?lt:$8,rect:W}:null},[R,D]),$=m.useRef(null),[O,U]=m.useState(null),[K,M]=m.useState(null),V=ld(k,Object.values(k)),L=zd("DndDescribedBy",a),z=m.useMemo(()=>F.getEnabled(),[F]),Y=F8(g),{droppableRects:B,measureDroppableContainers:Q,measuringScheduled:J}=j8(z,{dragging:T,dependencies:[_.x,_.y],config:Y.droppable}),Z=v8(I,R),oe=m.useMemo(()=>K?xh(K):null,[K]),ne=ze(),ue=k8(Z,Y.draggable.measure);z8({activeNode:R!=null?I.get(R):null,config:ne.layoutShiftCompensation,initialRect:ue,measure:Y.draggable.measure});const ge=yN(Z,Y.draggable.measure,ue),Ce=yN(Z?Z.parentElement:null),Ne=m.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ke=F.getNodeFor((n=Ne.current.over)==null?void 0:n.id),Ue=_8({measure:Y.dragOverlay.measure}),ie=(r=Ue.nodeRef.current)!=null?r:Z,ve=T?(o=Ue.rect)!=null?o:ge:null,be=!!(Ue.nodeRef.current&&Ue.rect),Re=C8(be?null:ge),He=HR(ie?ur(ie):null),rt=E8(T?ke??Z:null),Fe=P8(rt),ot=qR(y,{transform:{x:_.x-Re.x,y:_.y-Re.y,scaleX:1,scaleY:1},activatorEvent:K,active:H,activeNodeRect:ge,containerNodeRect:Ce,draggingNodeRect:ve,over:Ne.current.over,overlayNodeRect:Ue.rect,scrollableAncestors:rt,scrollableAncestorRects:Fe,windowRect:He}),St=oe?Ul(oe,_):null,mt=T8(rt),at=vN(mt),ce=vN(mt,[ge]),me=Ul(ot,at),Ie=ve?JB(ve,ot):null,Ae=H&&Ie?h({active:H,collisionRect:Ie,droppableRects:B,droppableContainers:z,pointerCoordinates:St}):null,We=_R(Ae,"id"),[pt,_e]=m.useState(null),Qe=be?ot:Ul(ot,ce),Je=XB(Qe,(i=pt==null?void 0:pt.rect)!=null?i:null,ge),ut=m.useRef(null),fe=m.useCallback((lt,ht)=>{let{sensor:vt,options:tt}=ht;if($.current==null)return;const Dt=I.get($.current);if(!Dt)return;const zt=lt.nativeEvent,Bt=new vt({active:$.current,activeNode:Dt,event:zt,options:tt,context:Ne,onAbort(Oe){if(!I.get(Oe))return;const{onDragAbort:Et}=V.current,ln={id:Oe};Et==null||Et(ln),S({type:"onDragAbort",event:ln})},onPending(Oe,it,Et,ln){if(!I.get(Oe))return;const{onDragPending:le}=V.current,Se={id:Oe,constraint:it,initialCoordinates:Et,offset:ln};le==null||le(Se),S({type:"onDragPending",event:Se})},onStart(Oe){const it=$.current;if(it==null)return;const Et=I.get(it);if(!Et)return;const{onDragStart:ln}=V.current,Ut={activatorEvent:zt,active:{id:it,data:Et.data,rect:W}};Ys.unstable_batchedUpdates(()=>{ln==null||ln(Ut),P(xi.Initializing),j({type:$n.DragStart,initialCoordinates:Oe,active:it}),S({type:"onDragStart",event:Ut}),U(ut.current),M(zt)})},onMove(Oe){j({type:$n.DragMove,coordinates:Oe})},onEnd:we($n.DragEnd),onCancel:we($n.DragCancel)});ut.current=Bt;function we(Oe){return async function(){const{active:Et,collisions:ln,over:Ut,scrollAdjustedTranslate:le}=Ne.current;let Se=null;if(Et&&le){const{cancelDrop:nt}=V.current;Se={activatorEvent:zt,active:Et,collisions:ln,delta:le,over:Ut},Oe===$n.DragEnd&&typeof nt=="function"&&await Promise.resolve(nt(Se))&&(Oe=$n.DragCancel)}$.current=null,Ys.unstable_batchedUpdates(()=>{j({type:Oe}),P(xi.Uninitialized),_e(null),U(null),M(null),ut.current=null;const nt=Oe===$n.DragEnd?"onDragEnd":"onDragCancel";if(Se){const Tn=V.current[nt];Tn==null||Tn(Se),S({type:nt,event:Se})}})}}},[I]),q=m.useCallback((lt,ht)=>(vt,tt)=>{const Dt=vt.nativeEvent,zt=I.get(tt);if($.current!==null||!zt||Dt.dndKit||Dt.defaultPrevented)return;const Bt={active:zt};lt(vt,ht.options,Bt)===!0&&(Dt.dndKit={capturedBy:ht.sensor},$.current=tt,fe(vt,ht))},[I,fe]),re=w8(p,q);R8(p),ws(()=>{ge&&C===xi.Initializing&&P(xi.Initialized)},[ge,C]),m.useEffect(()=>{const{onDragMove:lt}=V.current,{active:ht,activatorEvent:vt,collisions:tt,over:Dt}=Ne.current;if(!ht||!vt)return;const zt={active:ht,activatorEvent:vt,collisions:tt,delta:{x:me.x,y:me.y},over:Dt};Ys.unstable_batchedUpdates(()=>{lt==null||lt(zt),S({type:"onDragMove",event:zt})})},[me.x,me.y]),m.useEffect(()=>{const{active:lt,activatorEvent:ht,collisions:vt,droppableContainers:tt,scrollAdjustedTranslate:Dt}=Ne.current;if(!lt||$.current==null||!ht||!Dt)return;const{onDragOver:zt}=V.current,Bt=tt.get(We),we=Bt&&Bt.rect.current?{id:Bt.id,rect:Bt.rect.current,data:Bt.data,disabled:Bt.disabled}:null,Oe={active:lt,activatorEvent:ht,collisions:vt,delta:{x:Dt.x,y:Dt.y},over:we};Ys.unstable_batchedUpdates(()=>{_e(we),zt==null||zt(Oe),S({type:"onDragOver",event:Oe})})},[We]),ws(()=>{Ne.current={activatorEvent:K,active:H,activeNode:Z,collisionRect:Ie,collisions:Ae,droppableRects:B,draggableNodes:I,draggingNode:ie,draggingNodeRect:ve,droppableContainers:F,over:pt,scrollableAncestors:rt,scrollAdjustedTranslate:me},W.current={initial:ve,translated:Ie}},[H,Z,Ae,Ie,I,ie,ve,B,F,pt,rt,me]),x8({...ne,delta:_,draggingRect:Ie,pointerCoordinates:St,scrollableAncestors:rt,scrollableAncestorRects:Fe});const xe=m.useMemo(()=>({active:H,activeNode:Z,activeNodeRect:ge,activatorEvent:K,collisions:Ae,containerNodeRect:Ce,dragOverlay:Ue,draggableNodes:I,droppableContainers:F,droppableRects:B,over:pt,measureDroppableContainers:Q,scrollableAncestors:rt,scrollableAncestorRects:Fe,measuringConfiguration:Y,measuringScheduled:J,windowRect:He}),[H,Z,ge,K,Ae,Ce,Ue,I,F,B,pt,Q,rt,Fe,Y,J,He]),Ge=m.useMemo(()=>({activatorEvent:K,activators:re,active:H,activeNodeRect:ge,ariaDescribedById:{draggable:L},dispatch:j,draggableNodes:I,over:pt,measureDroppableContainers:Q}),[K,re,H,ge,j,L,I,pt,Q]);return Lt.createElement(RR.Provider,{value:N},Lt.createElement(Bd.Provider,{value:Ge},Lt.createElement(KR.Provider,{value:xe},Lt.createElement(Cm.Provider,{value:Je},f)),Lt.createElement(O8,{disabled:(l==null?void 0:l.restoreFocus)===!1})),Lt.createElement(VB,{...l,hiddenTextDescribedById:L}));function ze(){const lt=(O==null?void 0:O.autoScrollEnabled)===!1,ht=typeof u=="object"?u.enabled===!1:u===!1,vt=T&&!lt&&!ht;return typeof u=="object"?{...u,enabled:vt}:{enabled:vt}}}),B8=m.createContext(null),jN="button",U8="Draggable";function H8(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=zd(U8),{activators:a,activatorEvent:l,active:u,activeNodeRect:f,ariaDescribedById:p,draggableNodes:h,over:g}=m.useContext(Bd),{role:y=jN,roleDescription:k="draggable",tabIndex:v=0}=o??{},b=(u==null?void 0:u.id)===t,j=m.useContext(b?Cm:B8),[S,N]=mh(),[C,P]=mh(),T=A8(a,t),R=ld(n);ws(()=>(h.set(t,{id:t,key:i,node:S,activatorNode:C,data:R}),()=>{const _=h.get(t);_&&_.key===i&&h.delete(t)}),[h,t]);const I=m.useMemo(()=>({role:y,tabIndex:v,"aria-disabled":r,"aria-pressed":b&&y===jN?!0:void 0,"aria-roledescription":k,"aria-describedby":p.draggable}),[r,y,v,b,k,p.draggable]);return{active:u,activatorEvent:l,activeNodeRect:f,attributes:I,isDragging:b,listeners:r?void 0:T,node:S,over:g,setNodeRef:N,setActivatorNodeRef:P,transform:j}}function GR(){return m.useContext(KR)}const V8="Droppable",W8={timeout:25};function K8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=zd(V8),{active:a,dispatch:l,over:u,measureDroppableContainers:f}=m.useContext(Bd),p=m.useRef({disabled:n}),h=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),{disabled:k,updateMeasurementsFor:v,timeout:b}={...W8,...o},j=ld(v??r),S=m.useCallback(()=>{if(!h.current){h.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{f(Array.isArray(j.current)?j.current:[j.current]),y.current=null},b)},[b]),N=Sm({callback:S,disabled:k||!a}),C=m.useCallback((I,_)=>{N&&(_&&(N.unobserve(_),h.current=!1),I&&N.observe(I))},[N]),[P,T]=mh(C),R=ld(t);return m.useEffect(()=>{!N||!P.current||(N.disconnect(),h.current=!1,N.observe(P.current))},[P,N]),m.useEffect(()=>(l({type:$n.RegisterDroppable,element:{id:r,key:i,disabled:n,node:P,rect:g,data:R}}),()=>l({type:$n.UnregisterDroppable,key:i,id:r})),[r]),m.useEffect(()=>{n!==p.current.disabled&&(l({type:$n.SetDroppableDisabled,id:r,key:i,disabled:n}),p.current.disabled=n)},[r,i,n,l]),{active:a,rect:g,isOver:(u==null?void 0:u.id)===r,node:P,over:u,setNodeRef:T}}function q8(e){let{animation:t,children:n}=e;const[r,o]=m.useState(null),[i,a]=m.useState(null),l=gh(n);return!n&&!r&&l&&o(l),ws(()=>{if(!i)return;const u=r==null?void 0:r.key,f=r==null?void 0:r.props.id;if(u==null||f==null){o(null);return}Promise.resolve(t(f,i)).then(()=>{o(null)})},[t,r,i]),Lt.createElement(Lt.Fragment,null,n,r?m.cloneElement(r,{ref:a}):null)}const G8={x:0,y:0,scaleX:1,scaleY:1};function Y8(e){let{children:t}=e;return Lt.createElement(Bd.Provider,{value:WR},Lt.createElement(Cm.Provider,{value:G8},t))}const X8={position:"fixed",touchAction:"none"},Q8=e=>wm(e)?"transform 250ms ease":void 0,J8=m.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:l,style:u,transform:f,transition:p=Q8}=e;if(!l)return null;const h=o?f:{...f,scaleX:1,scaleY:1},g={...X8,width:l.width,height:l.height,top:l.top,left:l.left,transform:js.Transform.toString(h),transformOrigin:o&&r?WB(r,l):void 0,transition:typeof p=="function"?p(r):p,...u};return Lt.createElement(n,{className:a,style:g,ref:t},i)}),Z8=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(i!=null&&i.active)for(const[l,u]of Object.entries(i.active))u!==void 0&&(o[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,u));if(i!=null&&i.dragOverlay)for(const[l,u]of Object.entries(i.dragOverlay))u!==void 0&&r.node.style.setProperty(l,u);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[u,f]of Object.entries(o))n.node.style.setProperty(u,f);a!=null&&a.active&&n.node.classList.remove(a.active)}},e7=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:js.Transform.toString(t)},{transform:js.Transform.toString(n)}]},t7={duration:250,easing:"ease",keyframes:e7,sideEffects:Z8({styles:{active:{opacity:"0"}}})};function n7(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return vm((i,a)=>{if(t===null)return;const l=n.get(i);if(!l)return;const u=l.node.current;if(!u)return;const f=VR(a);if(!f)return;const{transform:p}=ur(a).getComputedStyle(a),h=$R(p);if(!h)return;const g=typeof t=="function"?t:r7(t);return BR(u,o.draggable.measure),g({active:{id:i,data:l.data,node:u,rect:o.draggable.measure(u)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(f)},droppableContainers:r,measuringConfiguration:o,transform:h})})}function r7(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...t7,...e};return i=>{let{active:a,dragOverlay:l,transform:u,...f}=i;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},h={scaleX:u.scaleX!==1?a.rect.width*u.scaleX/l.rect.width:1,scaleY:u.scaleY!==1?a.rect.height*u.scaleY/l.rect.height:1},g={x:u.x-p.x,y:u.y-p.y,...h},y=o({...f,active:a,dragOverlay:l,transform:{initial:u,final:g}}),[k]=y,v=y[y.length-1];if(JSON.stringify(k)===JSON.stringify(v))return;const b=r==null?void 0:r({active:a,dragOverlay:l,...f}),j=l.node.animate(y,{duration:t,easing:n,fill:"forwards"});return new Promise(S=>{j.onfinish=()=>{b==null||b(),S()}})}}let kN=0;function s7(e){return m.useMemo(()=>{if(e!=null)return kN++,kN},[e])}const o7=Lt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:l="div",className:u,zIndex:f=999}=e;const{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggableNodes:k,droppableContainers:v,dragOverlay:b,over:j,measuringConfiguration:S,scrollableAncestors:N,scrollableAncestorRects:C,windowRect:P}=GR(),T=m.useContext(Cm),R=s7(h==null?void 0:h.id),I=qR(a,{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggingNodeRect:b.rect,over:j,overlayNodeRect:b.rect,scrollableAncestors:N,scrollableAncestorRects:C,transform:T,windowRect:P}),_=Pw(g),F=n7({config:r,draggableNodes:k,droppableContainers:v,measuringConfiguration:S}),D=_?b.setRef:void 0;return Lt.createElement(Y8,null,Lt.createElement(q8,{animation:F},h&&R?Lt.createElement(J8,{key:R,id:h.id,ref:D,as:l,activatorEvent:p,adjustScale:t,className:u,transition:i,rect:_,style:{zIndex:f,...o},transform:I},n):null))});function Tc(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function i7(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function fp(e){return e!==null&&e>=0}function a7(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function l7(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const _w=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Tc(t,r,n),a=t[o],l=i[o];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},pp={scaleX:1,scaleY:1},Dw=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=(t=i[n])!=null?t:r;if(!l)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(l.top+l.height):f.top-l.top,...pp}:null}const u=c7(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-u,...pp}:o<n&&o>=a?{x:0,y:l.height+u,...pp}:{x:0,y:0,...pp}};function c7(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const YR="Sortable",XR=Lt.createContext({activeIndex:-1,containerId:YR,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:_w,disabled:{draggable:!1,droppable:!1}});function Tm(e){let{children:t,id:n,items:r,strategy:o=_w,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:u,over:f,measureDroppableContainers:p}=GR(),h=zd(YR,n),g=l.rect!==null,y=m.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),k=a!=null,v=a?y.indexOf(a.id):-1,b=f?y.indexOf(f.id):-1,j=m.useRef(y),S=!a7(y,j.current),N=b!==-1&&v===-1||S,C=l7(i);ws(()=>{S&&k&&p(y)},[S,y,k,p]),m.useEffect(()=>{j.current=y},[y]);const P=m.useMemo(()=>({activeIndex:v,containerId:h,disabled:C,disableTransforms:N,items:y,overIndex:b,useDragOverlay:g,sortedRects:i7(y,u),strategy:o}),[v,h,C.draggable,C.droppable,N,y,b,u,g,o]);return Lt.createElement(XR.Provider,{value:P},t)}const u7=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Tc(n,r,o).indexOf(t)},d7=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:u,transition:f}=e;return!f||!r||l!==i&&o===a?!1:n?!0:a!==o&&t===u},f7={duration:200,easing:"ease"},QR="transform",p7=js.Transition.toString({property:QR,duration:0,easing:"linear"}),h7={roleDescription:"sortable"};function m7(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=m.useState(null),l=m.useRef(n);return ws(()=>{if(!t&&n!==l.current&&r.current){const u=o.current;if(u){const f=Sc(r.current,{ignoreTransform:!0}),p={x:u.left-f.left,y:u.top-f.top,scaleX:u.width/f.width,scaleY:u.height/f.height};(p.x||p.y)&&a(p)}}n!==l.current&&(l.current=n)},[t,n,r,o]),m.useEffect(()=>{i&&a(null)},[i]),i}function Rm(e){let{animateLayoutChanges:t=d7,attributes:n,disabled:r,data:o,getNewIndex:i=u7,id:a,strategy:l,resizeObserverConfig:u,transition:f=f7}=e;const{items:p,containerId:h,activeIndex:g,disabled:y,disableTransforms:k,sortedRects:v,overIndex:b,useDragOverlay:j,strategy:S}=m.useContext(XR),N=g7(r,y),C=p.indexOf(a),P=m.useMemo(()=>({sortable:{containerId:h,index:C,items:p},...o}),[h,o,C,p]),T=m.useMemo(()=>p.slice(p.indexOf(a)),[p,a]),{rect:R,node:I,isOver:_,setNodeRef:F}=K8({id:a,data:P,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...u}}),{active:D,activatorEvent:W,activeNodeRect:H,attributes:$,setNodeRef:O,listeners:U,isDragging:K,over:M,setActivatorNodeRef:V,transform:L}=H8({id:a,data:P,attributes:{...h7,...n},disabled:N.draggable}),z=PB(F,O),Y=!!D,B=Y&&!k&&fp(g)&&fp(b),Q=!j&&K,J=Q&&B?L:null,oe=B?J??(l??S)({rects:v,activeNodeRect:H,activeIndex:g,overIndex:b,index:C}):null,ne=fp(g)&&fp(b)?i({id:a,items:p,activeIndex:g,overIndex:b}):C,ue=D==null?void 0:D.id,ge=m.useRef({activeId:ue,items:p,newIndex:ne,containerId:h}),Ce=p!==ge.current.items,Ne=t({active:D,containerId:h,isDragging:K,isSorting:Y,id:a,index:C,items:p,newIndex:ge.current.newIndex,previousItems:ge.current.items,previousContainerId:ge.current.containerId,transition:f,wasDragging:ge.current.activeId!=null}),ke=m7({disabled:!Ne,index:C,node:I,rect:R});return m.useEffect(()=>{Y&&ge.current.newIndex!==ne&&(ge.current.newIndex=ne),h!==ge.current.containerId&&(ge.current.containerId=h),p!==ge.current.items&&(ge.current.items=p)},[Y,ne,h,p]),m.useEffect(()=>{if(ue===ge.current.activeId)return;if(ue!=null&&ge.current.activeId==null){ge.current.activeId=ue;return}const ie=setTimeout(()=>{ge.current.activeId=ue},50);return()=>clearTimeout(ie)},[ue]),{active:D,activeIndex:g,attributes:$,data:P,rect:R,index:C,newIndex:ne,items:p,isOver:_,isSorting:Y,isDragging:K,listeners:U,node:I,overIndex:b,over:M,setNodeRef:z,setActivatorNodeRef:V,setDroppableNodeRef:F,setDraggableNodeRef:O,transform:ke??oe,transition:Ue()};function Ue(){if(ke||Ce&&ge.current.newIndex===C)return p7;if(!(Q&&!wm(W)||!f)&&(Y||Ne))return js.Transition.toString({...f,property:QR})}}function g7(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function vh(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const x7=[At.Down,At.Right,At.Up,At.Left],JR=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(x7.includes(e.code)){if(e.preventDefault(),!n||!r)return;const u=[];i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=o.get(h.id);if(g)switch(e.code){case At.Down:r.top<g.top&&u.push(h);break;case At.Up:r.top>g.top&&u.push(h);break;case At.Left:r.left>g.left&&u.push(h);break;case At.Right:r.left<g.left&&u.push(h);break}});const f=qB({collisionRect:r,droppableRects:o,droppableContainers:u});let p=_R(f,"id");if(p===(a==null?void 0:a.id)&&f.length>1&&(p=f[1].id),p!=null){const h=i.get(n.id),g=i.get(p),y=g?o.get(g.id):null,k=g==null?void 0:g.node.current;if(k&&y&&h&&g){const b=Nm(k).some((T,R)=>l[R]!==T),j=ZR(h,g),S=y7(h,g),N=b||!j?{x:0,y:0}:{x:S?r.width-y.width:0,y:S?r.height-y.height:0},C={x:y.left,y:y.top};return N.x&&N.y?C:cd(C,N)}}}};function ZR(e,t){return!vh(e)||!vh(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function y7(e,t){return!vh(e)||!vh(t)||!ZR(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function bt({label:e="Loading dashboard data…"}){return s.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:s.jsx("div",{className:"chrome-card !px-4 !py-3",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function Rt({title:e="Something went wrong",error:t,action:n,onRetry:r,retryLabel:o="Retry"}){const i=n??(r?s.jsxs("button",{type:"button",onClick:r,className:"shell-action",children:[s.jsx(M4,{className:"h-4 w-4"}),s.jsx("span",{children:o})]}):null);return s.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),i?s.jsx("div",{className:"pt-2",children:i}):null]})})}function Kp({command:e,description:t,example:n}){return s.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[s.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?s.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function Ke({title:e,description:t,children:n,className:r,actions:o}){return s.jsxs("section",{className:je("surface-panel space-y-3",r),children:[e||o?s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?s.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),o]}):null,n]})}function b7({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return s.jsx(Ke,{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:s.jsx($e,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:s.jsx("div",{className:"space-y-3",children:n.map((r,o)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:o+1}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:r.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:r.detail}),r.command?s.jsx(Kp,{command:r.command.command,example:r.command.example}):null]})]})},r.title))})})}const by={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."},ha={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 v7(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function w7({hero:e,itemsById:t}){const n=gn();if(e.kind==="clean")return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:ha.emptyStateCleanTitle}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:by.clean}),s.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."}),s.jsx("div",{className:"mt-4",children:s.jsx($e,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:ha.emptyStateCleanCTA})})]});const r=e.itemId?t[e.itemId]:void 0,o=(r==null?void 0:r.assignmentTitle)??"",i=by[e.copyKey]??by[e.kind],a=v7(i,{total:e.total,title:o}),l=r?j7(r,n):`${n}/assignments`;return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:"Top priority"}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:a}),r?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",s.jsx("span",{className:"font-medium text-foreground",children:r.projectTitle??"Standalone"})," ","· status ",s.jsx("span",{className:"font-medium text-foreground",children:r.status})]}):null,s.jsx("div",{className:"mt-4",children:s.jsxs($e,{to:l,className:"shell-action shell-action--cta",children:["Open ",o||"assignment"]})})]})}function j7(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const vy=["title","status","priority","assignee","dependencies","created","updated"],dd=24,eA=60;function k7(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isInteger(t.w)&&t.w>=1&&t.w<=dd&&Number.isInteger(t.h)&&t.h>=1&&t.h<=eA}const N7={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},NN="2026-05-21T00:00:00Z";function wy(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...N7,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:NN,updatedAt:NN}}const vi={version:1,views:[wy("default-recently-updated","Recently updated",{}),wy("default-high-priority","High priority",{priority:"high"}),wy("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 tA(e,t){const n=Ve(e.filters.project),r=n.length===0||n.length===1&&n[0]===t,o=e.filters.activity,i=typeof e.filters.search=="string"&&e.filters.search.trim().length>0,a=e.filters.query,l=typeof a=="string"&&a.trim().length>0&&Hu(a)===null;return r&&(!o||o==="all")&&!i&&!l}function nA(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?tA(e.config,t.slug):!1}}const rA=`syntaur.savedViews.cache.v${vi.version}`;let Hl=S7(),na=null,$w=null;const Fb=new Set,wh=new Set;let sA=0;function oA(){return++sA}function zb(e){return e===sA}function S7(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(rA);if(!e)return null;const t=JSON.parse(e);return t.version!==vi.version?null:t}catch{return null}}function C7(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(rA,JSON.stringify(e))}catch{}}function iA(e){Hl=e,$w=null,C7(e);for(const t of Fb)t(e);for(const t of wh)t(null)}function E7(e){$w=e;for(const t of wh)t(e)}function aA(e){if(!e||typeof e!="object")return vi;const t=e;return t.version!==vi.version||!Array.isArray(t.views)||!t.dashboard?vi:t}function SN(){if(na)return na;const e=oA();return na=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=aA(t);return zb(e)&&iA(n),na=null,Hl??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return zb(e)&&E7(n),na=null,Hl??vi}),na}function Iw(){const[e,t]=m.useState(()=>Hl??vi),[n,r]=m.useState(()=>Hl===null),[o,i]=m.useState(!1),[a,l]=m.useState(()=>$w);return m.useEffect(()=>{let f=!1;Hl===null&&r(!0),SN().then(g=>{f||(t(g),r(!1),i(!0))});const p=g=>{f||(t(g),r(!1),i(!0),l(null))},h=g=>{f||(l(g),r(!1),i(!0))};return Fb.add(p),wh.add(h),()=>{f=!0,Fb.delete(p),wh.delete(h)}},[]),{file:e,loading:n,ready:o,error:a,refetch:()=>{na=null,r(!0),l(null),i(!1),SN()}}}function Ud(){const{file:e,loading:t}=Iw();return{views:e.views,loading:t}}function lA(){const{file:e,loading:t}=Iw();return{layout:e.dashboard,loading:t}}function Ni(e){const{file:t,loading:n,ready:r,error:o,refetch:i}=Iw();return e?{view:t.views.find(l=>l.id===e)??null,loading:n,ready:r,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function Am(e,t,n){const r=oA(),o=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(!o.ok){const a=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(a.error??`HTTP ${o.status}`)}const i=aA(await o.json());return zb(r)&&iA(i),i}function ec(e){return Am("POST","/api/saved-views",e)}function jh(e,t){return Am("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function T7(e){return Am("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Bb(e){return Am("PUT","/api/dashboard",{slots:e})}const R7=["top","right","bottom","left"],Si=Math.min,Lr=Math.max,kh=Math.round,hp=Math.floor,eo=e=>({x:e,y:e}),A7={left:"right",right:"left",bottom:"top",top:"bottom"};function Ub(e,t,n){return Lr(e,Si(t,n))}function Ro(e,t){return typeof e=="function"?e(t):e}function Ao(e){return e.split("-")[0]}function Rc(e){return e.split("-")[1]}function Mw(e){return e==="x"?"y":"x"}function Lw(e){return e==="y"?"height":"width"}function Xs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ow(e){return Mw(Xs(e))}function P7(e,t,n){n===void 0&&(n=!1);const r=Rc(e),o=Ow(e),i=Lw(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Nh(a)),[a,Nh(a)]}function _7(e){const t=Nh(e);return[Hb(e),t,Hb(t)]}function Hb(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const CN=["left","right"],EN=["right","left"],D7=["top","bottom"],$7=["bottom","top"];function I7(e,t,n){switch(e){case"top":case"bottom":return n?t?EN:CN:t?CN:EN;case"left":case"right":return t?D7:$7;default:return[]}}function M7(e,t,n,r){const o=Rc(e);let i=I7(Ao(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Hb)))),i}function Nh(e){const t=Ao(e);return A7[t]+e.slice(t.length)}function L7(e){return{top:0,right:0,bottom:0,left:0,...e}}function cA(e){return typeof e!="number"?L7(e):{top:e,right:e,bottom:e,left:e}}function Sh(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function TN(e,t,n){let{reference:r,floating:o}=e;const i=Xs(t),a=Ow(t),l=Lw(a),u=Ao(t),f=i==="y",p=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[l]/2-o[l]/2;let y;switch(u){case"top":y={x:p,y:r.y-o.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:h};break;case"left":y={x:r.x-o.width,y:h};break;default:y={x:r.x,y:r.y}}switch(Rc(t)){case"start":y[a]-=g*(n&&f?-1:1);break;case"end":y[a]+=g*(n&&f?-1:1);break}return y}async function O7(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:g=!1,padding:y=0}=Ro(t,e),k=cA(y),b=l[g?h==="floating"?"reference":"floating":h],j=Sh(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:p,strategy:u})),S=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=await(i.isElement==null?void 0:i.isElement(N))?await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1}:{x:1,y:1},P=Sh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:N,strategy:u}):S);return{top:(j.top-P.top+k.top)/C.y,bottom:(P.bottom-j.bottom+k.bottom)/C.y,left:(j.left-P.left+k.left)/C.x,right:(P.right-j.right+k.right)/C.x}}const F7=50,z7=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:O7},u=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:h}=TN(f,r,u),g=r,y=0;const k={};for(let v=0;v<i.length;v++){const b=i[v];if(!b)continue;const{name:j,fn:S}=b,{x:N,y:C,data:P,reset:T}=await S({x:p,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:k,rects:f,platform:l,elements:{reference:e,floating:t}});p=N??p,h=C??h,k[j]={...k[j],...P},T&&y<F7&&(y++,typeof T=="object"&&(T.placement&&(g=T.placement),T.rects&&(f=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y:h}=TN(f,g,u)),v=-1)}return{x:p,y:h,placement:g,strategy:o,middlewareData:k}},B7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:f,padding:p=0}=Ro(e,t)||{};if(f==null)return{};const h=cA(p),g={x:n,y:r},y=Ow(o),k=Lw(y),v=await a.getDimensions(f),b=y==="y",j=b?"top":"left",S=b?"bottom":"right",N=b?"clientHeight":"clientWidth",C=i.reference[k]+i.reference[y]-g[y]-i.floating[k],P=g[y]-i.reference[y],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let R=T?T[N]:0;(!R||!await(a.isElement==null?void 0:a.isElement(T)))&&(R=l.floating[N]||i.floating[k]);const I=C/2-P/2,_=R/2-v[k]/2-1,F=Si(h[j],_),D=Si(h[S],_),W=F,H=R-v[k]-D,$=R/2-v[k]/2+I,O=Ub(W,$,H),U=!u.arrow&&Rc(o)!=null&&$!==O&&i.reference[k]/2-($<W?F:D)-v[k]/2<0,K=U?$<W?$-W:$-H:0;return{[y]:g[y]+K,data:{[y]:O,centerOffset:$-O-K,...U&&{alignmentOffset:K}},reset:U}}}),U7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:f}=t,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:v=!0,...b}=Ro(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=Ao(o),S=Xs(l),N=Ao(l)===l,C=await(u.isRTL==null?void 0:u.isRTL(f.floating)),P=g||(N||!v?[Nh(l)]:_7(l)),T=k!=="none";!g&&T&&P.push(...M7(l,v,k,C));const R=[l,...P],I=await u.detectOverflow(t,b),_=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&_.push(I[j]),h){const $=P7(o,a,C);_.push(I[$[0]],I[$[1]])}if(F=[...F,{placement:o,overflows:_}],!_.every($=>$<=0)){var D,W;const $=(((D=i.flip)==null?void 0:D.index)||0)+1,O=R[$];if(O&&(!(h==="alignment"?S!==Xs(O):!1)||F.every(M=>Xs(M.placement)===S?M.overflows[0]>0:!0)))return{data:{index:$,overflows:F},reset:{placement:O}};let U=(W=F.filter(K=>K.overflows[0]<=0).sort((K,M)=>K.overflows[1]-M.overflows[1])[0])==null?void 0:W.placement;if(!U)switch(y){case"bestFit":{var H;const K=(H=F.filter(M=>{if(T){const V=Xs(M.placement);return V===S||V==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(V=>V>0).reduce((V,L)=>V+L,0)]).sort((M,V)=>M[1]-V[1])[0])==null?void 0:H[0];K&&(U=K);break}case"initialPlacement":U=l;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function RN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function AN(e){return R7.some(t=>e[t]>=0)}const H7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Ro(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=RN(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:AN(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=RN(a,n.floating);return{data:{escapedOffsets:l,escaped:AN(l)}}}default:return{}}}}},uA=new Set(["left","top"]);async function V7(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ao(n),l=Rc(n),u=Xs(n)==="y",f=uA.has(a)?-1:1,p=i&&u?-1:1,h=Ro(t,e);let{mainAxis:g,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof k=="number"&&(y=l==="end"?k*-1:k),u?{x:y*p,y:g*f}:{x:g*f,y:y*p}}const W7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await V7(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},K7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:j=>{let{x:S,y:N}=j;return{x:S,y:N}}},...f}=Ro(e,t),p={x:n,y:r},h=await i.detectOverflow(t,f),g=Xs(Ao(o)),y=Mw(g);let k=p[y],v=p[g];if(a){const j=y==="y"?"top":"left",S=y==="y"?"bottom":"right",N=k+h[j],C=k-h[S];k=Ub(N,k,C)}if(l){const j=g==="y"?"top":"left",S=g==="y"?"bottom":"right",N=v+h[j],C=v-h[S];v=Ub(N,v,C)}const b=u.fn({...t,[y]:k,[g]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:a,[g]:l}}}}}},q7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=Ro(e,t),p={x:n,y:r},h=Xs(o),g=Mw(h);let y=p[g],k=p[h];const v=Ro(l,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const N=g==="y"?"height":"width",C=i.reference[g]-i.floating[N]+b.mainAxis,P=i.reference[g]+i.reference[N]-b.mainAxis;y<C?y=C:y>P&&(y=P)}if(f){var j,S;const N=g==="y"?"width":"height",C=uA.has(Ao(o)),P=i.reference[h]-i.floating[N]+(C&&((j=a.offset)==null?void 0:j[h])||0)+(C?0:b.crossAxis),T=i.reference[h]+i.reference[N]+(C?0:((S=a.offset)==null?void 0:S[h])||0)-(C?b.crossAxis:0);k<P?k=P:k>T&&(k=T)}return{[g]:y,[h]:k}}}},G7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...f}=Ro(e,t),p=await a.detectOverflow(t,f),h=Ao(o),g=Rc(o),y=Xs(o)==="y",{width:k,height:v}=i.floating;let b,j;h==="top"||h==="bottom"?(b=h,j=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,b=g==="end"?"top":"bottom");const S=v-p.top-p.bottom,N=k-p.left-p.right,C=Si(v-p[b],S),P=Si(k-p[j],N),T=!t.middlewareData.shift;let R=C,I=P;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=N),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(R=S),T&&!g){const F=Lr(p.left,0),D=Lr(p.right,0),W=Lr(p.top,0),H=Lr(p.bottom,0);y?I=k-2*(F!==0||D!==0?F+D:Lr(p.left,p.right)):R=v-2*(W!==0||H!==0?W+H:Lr(p.top,p.bottom))}await u({...t,availableWidth:I,availableHeight:R});const _=await a.getDimensions(l.floating);return k!==_.width||v!==_.height?{reset:{rects:!0}}:{}}}};function Pm(){return typeof window<"u"}function Ac(e){return dA(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function so(e){var t;return(t=(dA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dA(e){return Pm()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ns(e){return Pm()?e instanceof Element||e instanceof Ur(e).Element:!1}function Do(e){return Pm()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function PN(e){return!Pm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function Hd(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ss(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Y7(e){return/^(table|td|th)$/.test(Ac(e))}function _m(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const X7=/transform|translate|scale|rotate|perspective|filter/,Q7=/paint|layout|strict|content/,Ji=e=>!!e&&e!=="none";let jy;function Fw(e){const t=Ns(e)?Ss(e):e;return Ji(t.transform)||Ji(t.translate)||Ji(t.scale)||Ji(t.rotate)||Ji(t.perspective)||!zw()&&(Ji(t.backdropFilter)||Ji(t.filter))||X7.test(t.willChange||"")||Q7.test(t.contain||"")}function J7(e){let t=Ci(e);for(;Do(t)&&!tc(t);){if(Fw(t))return t;if(_m(t))return null;t=Ci(t)}return null}function zw(){return jy==null&&(jy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jy}function tc(e){return/^(html|body|#document)$/.test(Ac(e))}function Ss(e){return Ur(e).getComputedStyle(e)}function Dm(e){return Ns(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ci(e){if(Ac(e)==="html")return e;const t=e.assignedSlot||e.parentNode||PN(e)&&e.host||so(e);return PN(t)?t.host:t}function fA(e){const t=Ci(e);return tc(t)?e.ownerDocument?e.ownerDocument.body:e.body:Do(t)&&Hd(t)?t:fA(t)}function fd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=fA(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=Ur(o);if(i){const l=Vb(a);return t.concat(a,a.visualViewport||[],Hd(o)?o:[],l&&n?fd(l):[])}else return t.concat(o,fd(o,[],n))}function Vb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pA(e){const t=Ss(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Do(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=kh(n)!==i||kh(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Bw(e){return Ns(e)?e:e.contextElement}function Vl(e){const t=Bw(e);if(!Do(t))return eo(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=pA(t);let a=(i?kh(n.width):n.width)/r,l=(i?kh(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Z7=eo(0);function hA(e){const t=Ur(e);return!zw()||!t.visualViewport?Z7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function eU(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ur(e)?!1:t}function ja(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Bw(e);let a=eo(1);t&&(r?Ns(r)&&(a=Vl(r)):a=Vl(e));const l=eU(i,n,r)?hA(i):eo(0);let u=(o.left+l.x)/a.x,f=(o.top+l.y)/a.y,p=o.width/a.x,h=o.height/a.y;if(i){const g=Ur(i),y=r&&Ns(r)?Ur(r):r;let k=g,v=Vb(k);for(;v&&r&&y!==k;){const b=Vl(v),j=v.getBoundingClientRect(),S=Ss(v),N=j.left+(v.clientLeft+parseFloat(S.paddingLeft))*b.x,C=j.top+(v.clientTop+parseFloat(S.paddingTop))*b.y;u*=b.x,f*=b.y,p*=b.x,h*=b.y,u+=N,f+=C,k=Ur(v),v=Vb(k)}}return Sh({width:p,height:h,x:u,y:f})}function $m(e,t){const n=Dm(e).scrollLeft;return t?t.left+n:ja(so(e)).left+n}function mA(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-$m(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function tU(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=so(r),l=t?_m(t.floating):!1;if(r===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},f=eo(1);const p=eo(0),h=Do(r);if((h||!h&&!i)&&((Ac(r)!=="body"||Hd(a))&&(u=Dm(r)),h)){const y=ja(r);f=Vl(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const g=a&&!h&&!i?mA(a,u):eo(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+p.x+g.x,y:n.y*f.y-u.scrollTop*f.y+p.y+g.y}}function nU(e){return Array.from(e.getClientRects())}function rU(e){const t=so(e),n=Dm(e),r=e.ownerDocument.body,o=Lr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Lr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+$m(e);const l=-n.scrollTop;return Ss(r).direction==="rtl"&&(a+=Lr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const _N=25;function sU(e,t){const n=Ur(e),r=so(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const p=zw();(!p||p&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=$m(r);if(f<=0){const p=r.ownerDocument,h=p.body,g=getComputedStyle(h),y=p.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,k=Math.abs(r.clientWidth-h.clientWidth-y);k<=_N&&(i-=k)}else f<=_N&&(i+=f);return{width:i,height:a,x:l,y:u}}function oU(e,t){const n=ja(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Do(e)?Vl(e):eo(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:a,height:l,x:u,y:f}}function DN(e,t,n){let r;if(t==="viewport")r=sU(e,n);else if(t==="document")r=rU(so(e));else if(Ns(t))r=oU(t,n);else{const o=hA(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Sh(r)}function gA(e,t){const n=Ci(e);return n===t||!Ns(n)||tc(n)?!1:Ss(n).position==="fixed"||gA(n,t)}function iU(e,t){const n=t.get(e);if(n)return n;let r=fd(e,[],!1).filter(l=>Ns(l)&&Ac(l)!=="body"),o=null;const i=Ss(e).position==="fixed";let a=i?Ci(e):e;for(;Ns(a)&&!tc(a);){const l=Ss(a),u=Fw(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Hd(a)&&!u&&gA(e,a))?r=r.filter(p=>p!==a):o=l,a=Ci(a)}return t.set(e,r),r}function aU(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?_m(t)?[]:iU(t,this._c):[].concat(n),r],l=DN(t,a[0],o);let u=l.top,f=l.right,p=l.bottom,h=l.left;for(let g=1;g<a.length;g++){const y=DN(t,a[g],o);u=Lr(y.top,u),f=Si(y.right,f),p=Si(y.bottom,p),h=Lr(y.left,h)}return{width:f-h,height:p-u,x:h,y:u}}function lU(e){const{width:t,height:n}=pA(e);return{width:t,height:n}}function cU(e,t,n){const r=Do(t),o=so(t),i=n==="fixed",a=ja(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=eo(0);function f(){u.x=$m(o)}if(r||!r&&!i)if((Ac(t)!=="body"||Hd(o))&&(l=Dm(t)),r){const y=ja(t,!0,i,t);u.x=y.x+t.clientLeft,u.y=y.y+t.clientTop}else o&&f();i&&!r&&o&&f();const p=o&&!r&&!i?mA(o,l):eo(0),h=a.left+l.scrollLeft-u.x-p.x,g=a.top+l.scrollTop-u.y-p.y;return{x:h,y:g,width:a.width,height:a.height}}function ky(e){return Ss(e).position==="static"}function $N(e,t){if(!Do(e)||Ss(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return so(e)===n&&(n=n.ownerDocument.body),n}function xA(e,t){const n=Ur(e);if(_m(e))return n;if(!Do(e)){let o=Ci(e);for(;o&&!tc(o);){if(Ns(o)&&!ky(o))return o;o=Ci(o)}return n}let r=$N(e,t);for(;r&&Y7(r)&&ky(r);)r=$N(r,t);return r&&tc(r)&&ky(r)&&!Fw(r)?n:r||J7(e)||n}const uU=async function(e){const t=this.getOffsetParent||xA,n=this.getDimensions,r=await n(e.floating);return{reference:cU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function dU(e){return Ss(e).direction==="rtl"}const fU={convertOffsetParentRelativeRectToViewportRelativeRect:tU,getDocumentElement:so,getClippingRect:aU,getOffsetParent:xA,getElementRects:uU,getClientRects:nU,getDimensions:lU,getScale:Vl,isElement:Ns,isRTL:dU};function yA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function pU(e,t){let n=null,r;const o=so(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const f=e.getBoundingClientRect(),{left:p,top:h,width:g,height:y}=f;if(l||t(),!g||!y)return;const k=hp(h),v=hp(o.clientWidth-(p+g)),b=hp(o.clientHeight-(h+y)),j=hp(p),N={rootMargin:-k+"px "+-v+"px "+-b+"px "+-j+"px",threshold:Lr(0,Si(1,u))||1};let C=!0;function P(T){const R=T[0].intersectionRatio;if(R!==u){if(!C)return a();R?a(!1,R):r=setTimeout(()=>{a(!1,1e-7)},1e3)}R===1&&!yA(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(P,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,N)}n.observe(e)}return a(!0),i}function hU(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Bw(e),p=o||i?[...f?fd(f):[],...t?fd(t):[]]:[];p.forEach(j=>{o&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&l?pU(f,n):null;let g=-1,y=null;a&&(y=new ResizeObserver(j=>{let[S]=j;S&&S.target===f&&y&&t&&(y.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=y)==null||N.observe(t)})),n()}),f&&!u&&y.observe(f),t&&y.observe(t));let k,v=u?ja(e):null;u&&b();function b(){const j=ja(e);v&&!yA(v,j)&&n(),v=j,k=requestAnimationFrame(b)}return n(),()=>{var j;p.forEach(S=>{o&&S.removeEventListener("scroll",n),i&&S.removeEventListener("resize",n)}),h==null||h(),(j=y)==null||j.disconnect(),y=null,u&&cancelAnimationFrame(k)}}const mU=W7,gU=K7,xU=U7,yU=G7,bU=H7,IN=B7,vU=q7,wU=(e,t,n)=>{const r=new Map,o={platform:fU,...n},i={...o.platform,_c:r};return z7(e,t,{...o,platform:i})};var jU=typeof document<"u",kU=function(){},qp=jU?m.useLayoutEffect:kU;function Ch(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ch(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ch(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function bA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MN(e,t){const n=bA(e);return Math.round(t*n)/n}function Ny(e){const t=m.useRef(e);return qp(()=>{t.current=e}),t}function NU(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[p,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,y]=m.useState(r);Ch(g,r)||y(r);const[k,v]=m.useState(null),[b,j]=m.useState(null),S=m.useCallback(M=>{M!==T.current&&(T.current=M,v(M))},[]),N=m.useCallback(M=>{M!==R.current&&(R.current=M,j(M))},[]),C=i||k,P=a||b,T=m.useRef(null),R=m.useRef(null),I=m.useRef(p),_=u!=null,F=Ny(u),D=Ny(o),W=Ny(f),H=m.useCallback(()=>{if(!T.current||!R.current)return;const M={placement:t,strategy:n,middleware:g};D.current&&(M.platform=D.current),wU(T.current,R.current,M).then(V=>{const L={...V,isPositioned:W.current!==!1};$.current&&!Ch(I.current,L)&&(I.current=L,Ys.flushSync(()=>{h(L)}))})},[g,t,n,D,W]);qp(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,h(M=>({...M,isPositioned:!1})))},[f]);const $=m.useRef(!1);qp(()=>($.current=!0,()=>{$.current=!1}),[]),qp(()=>{if(C&&(T.current=C),P&&(R.current=P),C&&P){if(F.current)return F.current(C,P,H);H()}},[C,P,H,F,_]);const O=m.useMemo(()=>({reference:T,floating:R,setReference:S,setFloating:N}),[S,N]),U=m.useMemo(()=>({reference:C,floating:P}),[C,P]),K=m.useMemo(()=>{const M={position:n,left:0,top:0};if(!U.floating)return M;const V=MN(U.floating,p.x),L=MN(U.floating,p.y);return l?{...M,transform:"translate("+V+"px, "+L+"px)",...bA(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:L}},[n,l,U.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:H,refs:O,elements:U,floatingStyles:K}),[p,H,O,U,K])}const SU=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?IN({element:r.current,padding:o}).fn(n):{}:r?IN({element:r,padding:o}).fn(n):{}}}},CU=(e,t)=>{const n=mU(e);return{name:n.name,fn:n.fn,options:[e,t]}},EU=(e,t)=>{const n=gU(e);return{name:n.name,fn:n.fn,options:[e,t]}},TU=(e,t)=>({fn:vU(e).fn,options:[e,t]}),RU=(e,t)=>{const n=xU(e);return{name:n.name,fn:n.fn,options:[e,t]}},AU=(e,t)=>{const n=yU(e);return{name:n.name,fn:n.fn,options:[e,t]}},PU=(e,t)=>{const n=bU(e);return{name:n.name,fn:n.fn,options:[e,t]}},_U=(e,t)=>{const n=SU(e);return{name:n.name,fn:n.fn,options:[e,t]}};var DU="Arrow",vA=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Nn.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});vA.displayName=DU;var $U=vA;function IU(e){const[t,n]=m.useState(void 0);return ji(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,f=Array.isArray(u)?u[0]:u;a=f.inlineSize,l=f.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Uw="Popper",[wA,jA]=Ra(Uw),[MU,kA]=wA(Uw),NA=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(MU,{scope:t,anchor:r,onAnchorChange:o,children:n})};NA.displayName=Uw;var SA="PopperAnchor",CA=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=kA(SA,n),a=m.useRef(null),l=rr(t,a),u=m.useRef(null);return m.useEffect(()=>{const f=u.current;u.current=(r==null?void 0:r.current)||a.current,f!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(Nn.div,{...o,ref:l})});CA.displayName=SA;var Hw="PopperContent",[LU,OU]=wA(Hw),EA=m.forwardRef((e,t)=>{var oe,ne,ue,ge,Ce,Ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:k,...v}=e,b=kA(Hw,n),[j,S]=m.useState(null),N=rr(t,ke=>S(ke)),[C,P]=m.useState(null),T=IU(C),R=(T==null?void 0:T.width)??0,I=(T==null?void 0:T.height)??0,_=r+(i!=="center"?"-"+i:""),F=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},D=Array.isArray(f)?f:[f],W=D.length>0,H={padding:F,boundary:D.filter(zU),altBoundary:W},{refs:$,floatingStyles:O,placement:U,isPositioned:K,middlewareData:M}=NU({strategy:"fixed",placement:_,whileElementsMounted:(...ke)=>hU(...ke,{animationFrame:y==="always"}),elements:{reference:b.anchor},middleware:[CU({mainAxis:o+I,alignmentAxis:a}),u&&EU({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?TU():void 0,...H}),u&&RU({...H}),AU({...H,apply:({elements:ke,rects:Ue,availableWidth:ie,availableHeight:ve})=>{const{width:be,height:Re}=Ue.reference,He=ke.floating.style;He.setProperty("--radix-popper-available-width",`${ie}px`),He.setProperty("--radix-popper-available-height",`${ve}px`),He.setProperty("--radix-popper-anchor-width",`${be}px`),He.setProperty("--radix-popper-anchor-height",`${Re}px`)}}),C&&_U({element:C,padding:l}),BU({arrowWidth:R,arrowHeight:I}),g&&PU({strategy:"referenceHidden",...H})]}),[V,L]=AA(U),z=va(k);ji(()=>{K&&(z==null||z())},[K,z]);const Y=(oe=M.arrow)==null?void 0:oe.x,B=(ne=M.arrow)==null?void 0:ne.y,Q=((ue=M.arrow)==null?void 0:ue.centerOffset)!==0,[J,Z]=m.useState();return ji(()=>{j&&Z(window.getComputedStyle(j).zIndex)},[j]),s.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:K?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ge=M.transformOrigin)==null?void 0:ge.x,(Ce=M.transformOrigin)==null?void 0:Ce.y].join(" "),...((Ne=M.hide)==null?void 0:Ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(LU,{scope:n,placedSide:V,onArrowChange:P,arrowX:Y,arrowY:B,shouldHideArrow:Q,children:s.jsx(Nn.div,{"data-side":V,"data-align":L,...v,ref:N,style:{...v.style,animation:K?void 0:"none"}})})})});EA.displayName=Hw;var TA="PopperArrow",FU={top:"bottom",right:"left",bottom:"top",left:"right"},RA=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=OU(TA,r),a=FU[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx($U,{...o,ref:n,style:{...o.style,display:"block"}})})});RA.displayName=TA;function zU(e){return e!==null}var BU=e=>({name:"transformOrigin",options:e,fn(t){var b,j,S;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[f,p]=AA(n),h={start:"0%",center:"50%",end:"100%"}[p],g=(((j=o.arrow)==null?void 0:j.x)??0)+l/2,y=(((S=o.arrow)==null?void 0:S.y)??0)+u/2;let k="",v="";return f==="bottom"?(k=a?h:`${g}px`,v=`${-u}px`):f==="top"?(k=a?h:`${g}px`,v=`${r.floating.height+u}px`):f==="right"?(k=`${-u}px`,v=a?h:`${y}px`):f==="left"&&(k=`${r.floating.width+u}px`,v=a?h:`${y}px`),{data:{x:k,y:v}}}});function AA(e){const[t,n="center"]=e.split("-");return[t,n]}var UU=NA,HU=CA,VU=EA,WU=RA,KU=Symbol("radix.slottable");function qU(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=KU,t}var GU=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"}),YU="VisuallyHidden",PA=m.forwardRef((e,t)=>s.jsx(Nn.span,{...e,ref:t,style:{...GU,...e.style}}));PA.displayName=YU;var XU=PA,[Im]=Ra("Tooltip",[jA]),Mm=jA(),_A="TooltipProvider",QU=700,Wb="tooltip.open",[JU,Vw]=Im(_A),DA=e=>{const{__scopeTooltip:t,delayDuration:n=QU,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),l=m.useRef(!1),u=m.useRef(0);return m.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),s.jsx(JU,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:i})};DA.displayName=_A;var pd="Tooltip",[ZU,Vd]=Im(pd),$A=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=Vw(pd,e.__scopeTooltip),f=Mm(t),[p,h]=m.useState(null),g=Ol(),y=m.useRef(0),k=a??u.disableHoverableContent,v=l??u.delayDuration,b=m.useRef(!1),[j,S]=gm({prop:r,defaultProp:o??!1,onChange:R=>{R?(u.onOpen(),document.dispatchEvent(new CustomEvent(Wb))):u.onClose(),i==null||i(R)},caller:pd}),N=m.useMemo(()=>j?b.current?"delayed-open":"instant-open":"closed",[j]),C=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,S(!0)},[S]),P=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,S(!1)},[S]),T=m.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,S(!0),y.current=0},v)},[v,S]);return m.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),s.jsx(UU,{...f,children:s.jsx(ZU,{scope:t,contentId:g,open:j,stateAttribute:N,trigger:p,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{u.isOpenDelayedRef.current?T():C()},[u.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{k?P():(window.clearTimeout(y.current),y.current=0)},[P,k]),onOpen:C,onClose:P,disableHoverableContent:k,children:n})})};$A.displayName=pd;var Kb="TooltipTrigger",IA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vd(Kb,n),i=Vw(Kb,n),a=Mm(n),l=m.useRef(null),u=rr(t,l,o.onTriggerChange),f=m.useRef(!1),p=m.useRef(!1),h=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(HU,{asChild:!0,...a,children:s.jsx(Nn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:sn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:sn(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:sn(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:sn(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:sn(e.onBlur,o.onClose),onClick:sn(e.onClick,o.onClose)})})});IA.displayName=Kb;var Ww="TooltipPortal",[eH,tH]=Im(Ww,{forceMount:void 0}),MA=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Vd(Ww,t);return s.jsx(eH,{scope:t,forceMount:n,children:s.jsx(Aa,{present:n||i.open,children:s.jsx(uw,{asChild:!0,container:o,children:r})})})};MA.displayName=Ww;var nc="TooltipContent",LA=m.forwardRef((e,t)=>{const n=tH(nc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Vd(nc,e.__scopeTooltip);return s.jsx(Aa,{present:r||a.open,children:a.disableHoverableContent?s.jsx(OA,{side:o,...i,ref:t}):s.jsx(nH,{side:o,...i,ref:t})})}),nH=m.forwardRef((e,t)=>{const n=Vd(nc,e.__scopeTooltip),r=Vw(nc,e.__scopeTooltip),o=m.useRef(null),i=rr(t,o),[a,l]=m.useState(null),{trigger:u,onClose:f}=n,p=o.current,{onPointerInTransitChange:h}=r,g=m.useCallback(()=>{l(null),h(!1)},[h]),y=m.useCallback((k,v)=>{const b=k.currentTarget,j={x:k.clientX,y:k.clientY},S=aH(j,b.getBoundingClientRect()),N=lH(j,S),C=cH(v.getBoundingClientRect()),P=dH([...N,...C]);l(P),h(!0)},[h]);return m.useEffect(()=>()=>g(),[g]),m.useEffect(()=>{if(u&&p){const k=b=>y(b,p),v=b=>y(b,u);return u.addEventListener("pointerleave",k),p.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",k),p.removeEventListener("pointerleave",v)}}},[u,p,y,g]),m.useEffect(()=>{if(a){const k=v=>{const b=v.target,j={x:v.clientX,y:v.clientY},S=(u==null?void 0:u.contains(b))||(p==null?void 0:p.contains(b)),N=!uH(j,a);S?g():N&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[u,p,a,f,g]),s.jsx(OA,{...e,ref:i})}),[rH,sH]=Im(pd,{isInside:!1}),oH=qU("TooltipContent"),OA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=Vd(nc,n),f=Mm(n),{onClose:p}=u;return m.useEffect(()=>(document.addEventListener(Wb,p),()=>document.removeEventListener(Wb,p)),[p]),m.useEffect(()=>{if(u.trigger){const h=g=>{const y=g.target;y!=null&&y.contains(u.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,p]),s.jsx(cw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:s.jsxs(VU,{"data-state":u.stateAttribute,...f,...l,ref:t,style:{...l.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:[s.jsx(oH,{children:r}),s.jsx(rH,{scope:n,isInside:!0,children:s.jsx(XU,{id:u.contentId,role:"tooltip",children:o||r})})]})})});LA.displayName=nc;var FA="TooltipArrow",iH=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Mm(n);return sH(FA,n).isInside?null:s.jsx(WU,{...o,...r,ref:t})});iH.displayName=FA;function aH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function lH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function cH(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function uH(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],f=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-f)*(r-p)/(g-p)+f&&(o=!o)}return o}function dH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),fH(t)}function fH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}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 pH=DA,hH=$A,mH=IA,gH=MA,zA=LA;const ma=pH,Or=hH,Fr=mH,vr=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(gH,{children:s.jsx(zA,{ref:r,sideOffset:t,className:je("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})}));vr.displayName=zA.displayName;function Kw({items:e,align:t="end"}){const[n,r]=m.useState(!1),[o,i]=m.useState(null),a=m.useRef(null);if(m.useEffect(()=>{if(!n){i(null);return}function u(p){a.current&&!a.current.contains(p.target)&&r(!1)}function f(p){p.key==="Escape"&&r(!1)}return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[n]),e.length===0)return null;function l(u,f){const p=u.icon,h=je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",f&&"pl-8",u.disabled?"opacity-50 cursor-not-allowed":u.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),g=f?u.active?s.jsx(Nr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):s.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p?s.jsx(p,{className:"h-4 w-4 shrink-0"}):null,y=s.jsxs(s.Fragment,{children:[g,s.jsx("span",{className:"block min-w-0 truncate",children:u.label})]});if(u.disabled){const k=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:h,children:y})});return u.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:k}),s.jsx(vr,{side:"left",children:u.disabledReason})]},u.key):s.jsx("div",{children:k},u.key)}return u.href?s.jsx($e,{to:u.href,className:h,onClick:()=>r(!1),children:y},u.key):s.jsx("button",{type:"button",className:h,onClick:()=>{var k;(k=u.onSelect)==null||k.call(u),r(!1)},children:y},u.key)}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsx("button",{type:"button",onClick:()=>r(u=>!u),className:"shell-action",title:"More actions","aria-label":"More actions","aria-haspopup":"true","aria-expanded":n,children:s.jsx(m4,{className:"h-4 w-4"})}),n&&s.jsx("div",{className:je("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:s.jsx(ma,{delayDuration:200,children:e.map(u=>{if(u.submenu&&u.submenu.length>0){const f=u.icon,p=o===u.key;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":p,onClick:()=>i(p?null:u.key),children:[f?s.jsx(f,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 flex-1 truncate",children:u.label}),p?s.jsx(nr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):s.jsx(Hv,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),p?u.submenu.map(h=>l(h,!0)):null]},u.key)}return l(u,!1)})})})]})}function LN(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const xH={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 yH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,0,0,0,0).getTime()}function bH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function vH(e,t,n=Date.now()){if(!t)return!0;const r=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(r);if(Number.isNaN(o))return!1;if(t.preset){const l=xH[t.preset];return l===void 0?!0:t.preset.startsWith("older_")?n-o>l:o>=n-l&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,a=t.to&&t.to.length>0?t.to:void 0;return!i&&!a?!0:!(i&&o<yH(i)||a&&o>bH(a))}function wH(e,t,n={}){const{workspace:r,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const a=Ve(t.status),l=Ve(t.priority),u=Ve(t.type),f=Ve(t.assignee),p=Ve(t.project),h=Ve(t.tags),{activity:g}=t;if(r){if(r==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==r)return!1}if(a.length&&!a.includes(e.status)||l.length&&!l.includes(e.priority)||u.length&&!u.includes(e.type??"")||g==="stale"&&!LN(e.updated)||g==="fresh"&&LN(e.updated))return!1;if(f.length){const y=e.assignee??"__unassigned__";if(!f.includes(y))return!1}if(p.length&&!p.some(k=>k==="__standalone__"?e.projectSlug==null:e.projectSlug===k))return!1;if(h.length){const y=e.tags??[];if(!h.some(k=>y.includes(k)))return!1}if(!vH(e,t.dateRange))return!1;if(o){const y=o.trim().toLowerCase();if(y&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(y))return!1}return!0}function hd(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const ON={critical:0,high:1,medium:2,low:3};function mp(e){return Date.parse(e??"")||0}function Wd(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"title":a=o.title.localeCompare(i.title);break;case"status":a=o.status.localeCompare(i.status);break;case"priority":a=(ON[o.priority]??99)-(ON[i.priority]??99);break;case"assignee":a=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":a=o.dependsOn.length-i.dependsOn.length;break;case"created":a=mp(o.created)-mp(i.created);break;case"updated":a=mp(o.updated)-mp(i.updated);break}return n==="asc"?a:-a})}function jH(e){const t=`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`;return{...e.facts??{},status:e.status,phase:e.phase,disposition:e.disposition,priority:e.priority,type:e.type,assignee:e.assignee,project:e.projectSlug,tags:e.tags,archived:e.archived,title:e.title,created:e.created,updated:e.updated,completedAt:e.completedAt,statusAge:e.statusAge,phaseAge:e.phaseAge,searchText:t}}function BA(e,t,n={}){const{workspace:r,includeArchived:o=!1,now:i=Date.now()}=n,a={now:i};return e.filter(l=>{if(l.archived===!0&&!o)return!1;if(r){if(r==="_ungrouped"){if(l.projectWorkspace!=null)return!1}else if(l.projectWorkspace!==r)return!1}if(!t)return!0;const u=jH(l);return t.predicate(u,a)})}const Lm={hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function Om(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},r=e.type==="attestation"?[n.fact,n.approved,n.changesRequested,n.by,n.approvedBy].map(o=>o.toLowerCase()):[n.fact.toLowerCase()];return{storageKey:t,exports:n,registryKeys:r}}function kH(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const r=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(r))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:r,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:r,type:"attestation",binds:i})}}return t}function qb(e){const t=[],n=new Map;for(const r of Object.keys(Lm))n.set(r,"built-in");for(const r of Object.keys(fm))n.set(r,"built-in");for(const r of e??[]){const o=((r==null?void 0:r.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(r==null?void 0:r.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(r.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${r.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const f=(r.binds??"none").toString().trim()||"none";if(f!=="plan"&&f!=="commit"&&f!=="none"){t.push(`fact "${o}": invalid binds "${r.binds}" — expected plan, commit, or none`);continue}}const l=Om(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,u=l.find(f=>n.has(f));if(u!==void 0){const f=n.get(u);f==="built-in"?t.push(`fact "${o}": exported field "${u}" collides with a built-in field`):f===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${u}" collides with fact "${f}"`);continue}for(const f of l)n.set(f,o)}return t}function NH(e){const t=new Set([...Object.keys(Lm),...Object.keys(fm)]),n=[];for(const r of e){const o=Om(r).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(r)}}return n}function UA(e,t){const n=Om(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:r=>r[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:r=>r[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:r=>r[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:r=>r[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:r=>r[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:r=>r[n.exports.fact]}}function qw(e){const t={...Lm};for(const n of e)UA(t,n);return t}function HA(e){const t={...fm};for(const n of e)UA(t,n);return t}function VA(e){const t=["status","priority","type","assignee","project","tag","tags","archived","title","search","created","updated","completedAt","statusAge","phase","disposition","phaseAge","hasRealObjective","acRealTotal","acRealChecked","acAllChecked","planExists","planApproved","workspaceSet","implementationStarted","depsSatisfied","unresolvedQuestions","progressStaleDays","blocked","parked","reviewRequested","pinned"],n=[];for(const r of e){const o=Om(r);r.type==="attestation"?n.push(o.exports.fact,o.exports.approved,o.exports.changesRequested,o.exports.by,o.exports.approvedBy):n.push(o.exports.fact)}return[...t,...n]}function Nt({title:e,description:t,actions:n}){return s.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:s.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?s.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const rc='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Fm({columns:e,items:t,getItemId:n,getColumnId:r,renderCard:o,canDrop:i,onMove:a,getExternalDragData:l,onCardContextMenu:u,emptyMessage:f="No cards in this column.",hiddenColumnIds:p,onHideColumn:h,compact:g=!1,dragDisabled:y=!1,boundedColumns:k=!1}){const v=k&&!g,b=m.useMemo(()=>new Set(p??[]),[p]),j=m.useMemo(()=>e.filter(U=>!b.has(U.id)),[e,b]),S=m.useMemo(()=>e.filter(U=>b.has(U.id)),[e,b]),[N,C]=m.useState(null),[P,T]=m.useState(null),R=m.useRef(null),I=m.useMemo(()=>new Map(t.map(U=>[n(U),U])),[n,t]),_=m.useMemo(()=>j.map(U=>({column:U,items:t.filter(K=>r(K)===U.id)})),[j,r,t]),F=N?I.get(N)??null:null;function D(U){if(!F)return{allowed:!1};const K=r(F);return(i==null?void 0:i({item:F,fromColumnId:K,toColumnId:U}))??{allowed:!0}}function W(){C(null),T(null)}function H(U,K,M){if(y)return;const V=(l==null?void 0:l(K))??null;!a&&!V||(U.dataTransfer.effectAllowed="move",U.dataTransfer.setData("text/plain",M),V&&U.dataTransfer.setData("application/json",JSON.stringify(V)),a&&C(M))}function $(U,K,M){y||!a||!F||!D(K).allowed||(U.preventDefault(),U.dataTransfer.dropEffect="move",T(L=>(L==null?void 0:L.columnId)===K&&L.index===M?L:{columnId:K,index:M}))}async function O(U,K,M){var B;if(U.preventDefault(),y||!a||!F){W();return}const V=r(F),z=(((B=_.find(Q=>Q.column.id===V))==null?void 0:B.items)??[]).findIndex(Q=>n(Q)===n(F));if(!D(K).allowed||z<0){W();return}if(V===K&&(M===z||M===z+1)){W();return}try{await a({item:F,fromColumnId:V,toColumnId:K,fromIndex:z,toIndex:M})}finally{W()}}return s.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[S.length>0&&h?s.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Hidden:"}),S.map(U=>s.jsxs("button",{type:"button",onClick:()=>h(U.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${U.title}" column`,children:[U.title," ×"]},U.id))]}):null,s.jsx("div",{className:je("grid min-w-max grid-flow-col items-start gap-4",g?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:_.map(({column:U,items:K})=>{const M=D(U.id),V=(P==null?void 0:P.columnId)===U.id;return s.jsxs("section",{className:je("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",g?"min-h-[200px] p-2":"min-h-[320px] p-3",v?"max-h-[70vh]":"",F&&!M.allowed?"border-dashed opacity-65":"",F&&M.allowed?"border-primary/30 bg-accent/30":"",V?"ring-2 ring-ring/30":""),title:F&&!M.allowed?M.reason:void 0,children:[s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:je("font-semibold uppercase tracking-[0.16em] text-muted-foreground",g?"text-xs":"text-sm"),children:U.title}),U.description&&!g?s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:U.description}):null]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:K.length}),h?s.jsx("button",{type:"button",onClick:()=>h(U.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 "${U.title}" column`,"aria-label":`Hide column ${U.title}`,children:"×"}):null]})]}),s.jsxs("div",{className:je("flex flex-1 flex-col gap-3",v?"min-h-0 overflow-y-auto pr-1":""),onDragOver:L=>$(L,U.id,K.length),onDrop:L=>O(L,U.id,K.length),children:[K.length===0?y?s.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 f=="function"?f(U):f}):s.jsx(SH,{active:(P==null?void 0:P.columnId)===U.id&&P.index===0,disabled:!!F&&!M.allowed,children:typeof f=="function"?f(U):f}):null,K.map((L,z)=>{const Y=n(L),B=N===Y;return s.jsxs(m.Fragment,{children:[s.jsx("div",{className:je("h-2 rounded-full transition",(P==null?void 0:P.columnId)===U.id&&P.index===z?"bg-primary/70":"bg-transparent"),onDragOver:Q=>$(Q,U.id,z),onDrop:Q=>O(Q,U.id,z)}),s.jsx("div",{draggable:!y&&!!(a||l),onMouseDown:Q=>{R.current=Q.target},onDragStart:Q=>{const J=R.current;if(J!=null&&J.closest(rc)){Q.preventDefault();return}H(Q,L,Y)},onDragEnd:W,onContextMenu:Q=>{if(!u)return;const J=Q.target;J!=null&&J.closest(rc)||u(L,Q)},className:je("transition",!y&&(a||l)?"cursor-grab active:cursor-grabbing":"",B?"scale-[0.98] opacity-50":""),children:o(L,{dragging:B})})]},Y)}),K.length>0&&!y?s.jsx("div",{className:je("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(P==null?void 0:P.columnId)===U.id&&P.index===K.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",F&&!M.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},U.id)})})]})}function SH({active:e,disabled:t,children:n}){return s.jsx("div",{className:je("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 So="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Wl="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",WA="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",Gb="border-status-review-foreground/30 bg-status-review text-status-review-foreground",KA="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",qA="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",GA="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",Gp=So,CH={draft:So,pending:So,ready_for_planning:So,ready_to_implement:Wl,in_progress:Wl,blocked:WA,review:Gb,code_review:Gb,completed:KA,failed:qA,active:Wl,stopped:So,archived:GA};function EH(e){return CH[e]??Gp}const TH={slate:Gp,gray:Gp,grey:Gp};function YA(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function RH(e){let t=e.trim().replace(/^#/,"");return t.length===3&&(t=t.split("").map(n=>n+n).join("")),t.length!==6||/[^0-9a-fA-F]/.test(t)?null:{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function AH(e,t){const n=t==null?void 0:t.trim();if(n)if(n.startsWith("#")){const r=RH(n);if(r){const{r:o,g:i,b:a}=r;return{className:"",style:{backgroundColor:`rgba(${o}, ${i}, ${a}, 0.15)`,borderColor:`rgba(${o}, ${i}, ${a}, 0.4)`,color:n}}}}else{const r=TH[n.toLowerCase()];if(r)return{className:r}}return{className:EH(e)}}function md(e,t){const n=e.find(i=>i.id===t),{className:r,style:o}=AH(t,n==null?void 0:n.color);return{label:(n==null?void 0:n.label)??YA(t),className:r,style:o,iconName:n==null?void 0:n.icon}}function Yb(e){return e?!!e.terminal||e.id==="completed"||e.id==="failed":!1}function XA(e){const t=new Map(e.statuses.map(a=>[a.id,a])),n=e.order.length>0?e.order:e.statuses.map(a=>a.id),r=new Set,o=[],i=(a,l)=>{r.has(a)||(r.add(a),o.push({id:a,label:(l==null?void 0:l.label)??YA(a),terminal:Yb(l??{id:a})}))};for(const a of n)i(a,t.get(a));for(const a of e.statuses)i(a.id,a);return o}const QA={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:So,icon:bc},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:So,icon:c4},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:So,icon:g2},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Wl,icon:D4},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Wl,icon:qv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:WA,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:Gb,icon:L4},completed:{label:"Completed",description:"Finished successfully.",className:KA,icon:sm},failed:{label:"Failed",description:"Could not be completed as planned.",className:qA,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Wl,icon:wb},stopped:{label:"Stopped",description:"Session ended without completing.",className:So,icon:a4},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:GA,icon:wb}},JA="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)]";function Xb(e){var t;return((t=QA[e])==null?void 0:t.icon)??wb}function kn({status:e,className:t,showIcon:n=!0,progress:r}){var y;const o=As(),i=md(o.statuses,e),a=Xb(e),l=i.label,u=((y=o.statuses.find(k=>k.id===e))==null?void 0:y.description)??Kd(e),f=r&&r.total>0,p=f?Math.min(1,Math.max(0,r.checked/r.total)):0,h=f?`${l} — ${u} (${r.checked}/${r.total} criteria)`:`${l} — ${u}`,g=n?f?s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[s.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),s.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-p)})]}),s.jsx(a,{className:"h-2.5 w-2.5"})]}):s.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}):null;return s.jsxs("span",{title:h,className:je(JA,i.className,t),style:i.style,children:[g,s.jsx("span",{className:"min-w-0 truncate",children:l})]})}function Kd(e){var t;return((t=QA[e])==null?void 0:t.description)??`Status: ${e}`}function Pa({type:e,className:t,compact:n=!1}){const r=Md();if(!e)return null;const o=jz(r,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),a=o!=null&&o.color?{backgroundColor:`color-mix(in oklch, ${o.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${o.color} 50%, transparent)`,color:o.color}:void 0;return s.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:a,className:je("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!a&&"border-border/60 text-muted-foreground",t),children:i})}async function qd(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return PH(e)}function PH(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Hr({value:e,label:t,disabled:n=!1,disabledReason:r,onError:o}){const[i,a]=m.useState(!1);async function l(){n||(await qd(e)?(a(!0),setTimeout(()=>a(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:r??"Copy unavailable","aria-label":t??"Copy",children:s.jsx(ch,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:l,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:i?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:i?s.jsx(Nr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(ch,{className:"h-3 w-3","aria-hidden":"true"})})}function _H(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function DH({items:e,statusOrder:t,sortField:n,sortDirection:r,listSectionVisibility:o,compact:i=!1}){const a=As(),[l,u]=m.useState(()=>new Set(o.collapsed));m.useEffect(()=>{u(new Set(o.collapsed))},[o]);const f=p=>{u(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})};return s.jsx("div",{className:je("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(p=>{const h=Wd(e.filter(k=>k.status===p),n,r);if(h.length===0)return null;const g=!l.has(p),y=Eo(a,p);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[s.jsxs("button",{type:"button",onClick:()=>f(p),className:je("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[s.jsx(nr,{className:je("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",g?"":"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:y}),s.jsx("span",{className:je("rounded-full border border-border/60 text-muted-foreground",i?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:h.length})]}),g&&s.jsx("ul",{className:je("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:h.map(k=>{const v=_H(k);return s.jsx("li",{children:s.jsxs($e,{to:v,className:je("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:k.title}),k.projectTitle?s.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:k.projectTitle}):null,s.jsx("span",{className:"shrink-0 text-muted-foreground",children:Yn(k.updated)})]})},`${k.projectSlug??"standalone"}:${k.id}`)})})]},p)})})}function $H(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function IH({items:e,sortField:t,sortDirection:n,tableColumnVisibility:r,compact:o=!1}){const i=new Set(r.hidden);i.delete("title");const a=p=>!i.has(p),l=Wd(e,t,n),u=o?"py-2 pr-3":"py-3 pr-4",f=o?"text-xs":"text-sm";return s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:je("w-full text-left",f),children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[a("title")?s.jsx("th",{className:je("font-medium",u),children:"Assignment"}):null,a("status")?s.jsx("th",{className:je("font-medium",u),children:"Status"}):null,a("priority")?s.jsx("th",{className:je("font-medium",u),children:"Priority"}):null,a("assignee")?s.jsx("th",{className:je("font-medium",u),children:"Assignee"}):null,a("dependencies")?s.jsx("th",{className:je("font-medium",u),children:"Dependencies"}):null,a("created")?s.jsx("th",{className:je("font-medium",u),children:"Created"}):null,a("updated")?s.jsx("th",{className:je("font-medium",u),children:"Updated"}):null]})}),s.jsx("tbody",{children:l.map(p=>{const h=$H(p),g=`${p.projectSlug??"standalone"}:${p.id}`;return s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[a("title")?s.jsxs("td",{className:u,children:[s.jsx($e,{to:h,className:"font-semibold text-foreground hover:text-primary",children:p.title}),p.projectTitle?s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.projectTitle}):null]}):null,a("status")?s.jsx("td",{className:u,children:s.jsx(kn,{status:p.status,className:"max-w-[150px]"})}):null,a("priority")?s.jsx("td",{className:je("capitalize text-muted-foreground",u),children:p.priority}):null,a("assignee")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.assignee??"Unassigned"}):null,a("dependencies")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.dependsOn.length}):null,a("created")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.created)}):null,a("updated")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.updated)}):null]},g)})})]})})}function ZA({view:e,compact:t,emptyDescription:n}){const{data:r,loading:o,error:i}=lm(),a=As(),l=m.useMemo(()=>a.order.map(p=>({id:p,title:Eo(a,p),description:Kd(p)})),[a]),u=m.useMemo(()=>HA(a.factDeclarations),[a.factDeclarations]),f=m.useMemo(()=>{if(!r)return[];const p=e.config.filters.query??Uu(e.config.filters);let h=null;p.trim()!==""&&(h=Zl(p,u).query);const g=BA(r.assignments,h,{workspace:e.workspace});return Wd(g,e.config.sortField,e.config.sortDirection)},[r,e,u]);if(o&&!r)return s.jsx(bt,{label:"Loading assignments…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(f.length===0)return s.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 s.jsx(Fm,{compact:t,dragDisabled:!0,columns:l,items:f,getItemId:p=>p.slug||p.id,getColumnId:p=>p.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:p=>t?s.jsx(MH,{item:p}):s.jsx(LH,{item:p})});case"list":return s.jsx(DH,{items:f,statusOrder:a.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return s.jsx(IH,{items:f,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function MH({item:e}){const t=hd(e);return s.jsxs("div",{className:je("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]}),e.id?s.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),s.jsx(Hr,{value:e.id})]}):null]})}function LH({item:e}){const t=hd(e);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx(Pa,{type:e.type,compact:!0}),s.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]})]})}function OH({viewId:e,onPickAnother:t}){const{view:n,loading:r,error:o,refetch:i}=Ni(e);return r?s.jsx(bt,{label:"Loading view…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),s.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?s.jsx(ZA,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),s.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function eP({sessions:e}){return s.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:s.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:ha.recentSessionsEmptyTitle}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:ha.recentSessionsEmptyHint})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>s.jsx("li",{children:s.jsx(FH,{session:t})},t.sessionId))})]})}function FH({session:e}){const t=gn(),[n,r]=m.useState(!1),o=zH(e,t),i=BH(e),a=!e.path;return s.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:o,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}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",Jv(e.started)]}),n&&e.path?s.jsxs("div",{className:"mt-1 space-y-0.5",children:[s.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}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:ha.recentSessionsCopyFallbackHint})]}):null]}),s.jsx(Hr,{value:e.path,label:ha.recentSessionsCopyPathLabel,disabled:a,disabledReason:ha.recentSessionsCopyPathDisabled,onError:()=>r(!0)})]})}function zH(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function BH(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const UH={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 ra(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function HH(e,t,n=Date.now()){const r=ra(e);if(t.preset){const a=UH[t.preset];return a?t.preset.startsWith("older_")?r<n-a:r>=n-a:!0}const o=t.from?Date.parse(`${t.from}T00:00:00.000Z`):null,i=t.to?Date.parse(`${t.to}T23:59:59.999Z`):null;return!(o!==null&&Number.isFinite(o)&&r<o||i!==null&&Number.isFinite(i)&&r>i)}function VH(e,t,n=Date.now()){const{dateRange:r,project:o,agent:i,sessionStatus:a}=t,l=new Set(o??[]),u=new Set(i??[]),f=new Set(a??[]);return e.filter(p=>{if(r&&!HH(p.started,r,n))return!1;if(l.size>0){const h=p.projectSlug??"__standalone__";if(!l.has(h))return!1}if(u.size>0&&!Array.from(u).some(g=>g.toLowerCase()===p.agent.toLowerCase()))return!1;if(f.size>0){let h=!1;for(const g of f){switch(g){case"active":p.status==="active"&&(h=!0);break;case"ended":(p.status==="completed"||p.status==="stopped")&&(h=!0);break;case"tracked":h=!0;break}if(h)break}if(!h)return!1}return!0})}function WH(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"started":a=ra(o.started)-ra(i.started);break;case"lastActivity":a=ra(o.updatedAt)-ra(i.updatedAt);break;case"projectName":{const l=o.projectSlug??"",u=i.projectSlug??"";a=l.localeCompare(u);break}case"agentName":a=o.agent.localeCompare(i.agent);break;default:a=ra(o.started)-ra(i.started);break}return n==="asc"?a:-a})}function KH(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function qH({view:e,emptyDescription:t}){const{data:n,loading:r,error:o}=cm(),i=m.useMemo(()=>{if(!n)return[];const a=n.sessions??[],{config:l}=e,u=l.filters,f={dateRange:u.dateRange?{...u.dateRange,field:"started"}:void 0,project:Ve(u.project),agent:Ve(u.agent),sessionStatus:Ve(u.sessionStatus),limit:l.limit};let p=VH(a,f);return p=WH(p,l.sortField,l.sortDirection),p=KH(p,l.limit),p},[n,e]);return r&&!n?s.jsx(bt,{label:"Loading sessions…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?s.jsx(Nt,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):s.jsx(eP,{sessions:i})}function GH({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:r,loading:o}=Ud(),[i,a]=m.useState(!1),l=m.useRef(null),u=m.useMemo(()=>r.filter(h=>h.entityType==="session"),[r]);m.useEffect(()=>{if(!i)return;function h(y){l.current&&!l.current.contains(y.target)&&a(!1)}function g(y){y.key==="Escape"&&a(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",g)}},[i]);const f=e?r.find(h=>h.id===e)??null:null,p=o?"Session views…":f?f.name:"Session views";return s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",disabled:o,onClick:()=>a(h=>!h),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":i,title:"Session views",children:[s.jsx("span",{className:"max-w-[160px] truncate",children:p}),s.jsx(nr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&s.jsxs("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:[s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(null)},className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",!e&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:s.jsx(Nr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),s.jsx("span",{children:"All sessions"})]}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"my-1 border-t border-border/40"}),u.map(h=>{const g=h.id===e;return s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(h.id)},className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",g&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:g?s.jsx(Nr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:h.name})]},h.id)})]}),s.jsx("div",{className:"my-1 border-t border-border/40"}),s.jsxs("button",{type:"button",onClick:()=>{a(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5 text-muted-foreground",children:[s.jsx(Pt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"Create new view…"})]})]})]})}const YH={__unassigned__:"Unassigned",__standalone__:"No project"};function jn({options:e,value:t,onChange:n,allLabel:r="Any",className:o,disabled:i,ariaLabel:a}){const[l,u]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),h=m.useRef([]),g=m.useMemo(()=>{const S=new Set(e.map(C=>C.value)),N=t.filter(C=>!S.has(C)).map(C=>({value:C,label:YH[C]??C}));return[...e,...N]},[e,t]),y=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{if(!l)return;function S(N){f.current&&!f.current.contains(N.target)&&u(!1)}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[l]),m.useEffect(()=>{var S;l&&((S=h.current[0])==null||S.focus())},[l]);const k=m.useMemo(()=>{if(t.length===0)return r;if(t.length===1){const S=g.find(N=>N.value===t[0]);return S?S.label:t[0]}return`${t.length} selected`},[t,g,r]);function v(S){n(y.has(S)?t.filter(N=>N!==S):[...t,S])}function b(S){var C;const N=Math.max(0,Math.min(S,g.length-1));(C=h.current[N])==null||C.focus()}function j(S){var T;const N=h.current,C=document.activeElement,P=N.findIndex(R=>R===C);S.key==="ArrowDown"?(S.preventDefault(),b(P<0?0:P+1)):S.key==="ArrowUp"?(S.preventDefault(),b(P<0?g.length-1:P-1)):S.key==="Home"?(S.preventDefault(),b(0)):S.key==="End"?(S.preventDefault(),b(g.length-1)):S.key==="Escape"&&(S.preventDefault(),u(!1),(T=p.current)==null||T.focus())}return s.jsxs("div",{className:"relative",ref:f,children:[s.jsxs("button",{type:"button",ref:p,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-label":a,onClick:()=>u(S=>!S),onKeyDown:S=>{!l&&(S.key==="ArrowDown"||S.key==="ArrowUp")&&(S.preventDefault(),u(!0))},className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[s.jsx("span",{className:"truncate",children:k}),s.jsx(nr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),l?s.jsxs("div",{role:"menu","aria-label":a,onKeyDown:j,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:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[s.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===g.length,onClick:()=>n(g.map(S=>S.value)),children:"Select all"}),s.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"})]}),g.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):g.map((S,N)=>{const C=y.has(S.value);return s.jsxs("button",{ref:P=>{h.current[N]=P},type:"button",role:"menuitemcheckbox","aria-checked":C,tabIndex:-1,onClick:()=>v(S.value),className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",C?"text-foreground":"text-muted-foreground"),children:[s.jsx("span",{className:je("flex h-4 w-4 shrink-0 items-center justify-center rounded border",C?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:C?s.jsx(Nr,{className:"h-3 w-3"}):null}),s.jsx("span",{className:"truncate",children:S.label})]},S.value)})]}):null]})}const FN={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"},XH=["updated","created"];function zm({value:e,onChange:t,className:n,ariaLabel:r="Date range filter"}){const[o,i]=m.useState(!1),a=m.useRef(null),l=(e==null?void 0:e.field)??"updated",u=!!(e&&!e.preset&&(e.from||e.to)),[f,p]=m.useState(u);m.useEffect(()=>p(u),[u]),m.useEffect(()=>{if(!o)return;function j(N){a.current&&!a.current.contains(N.target)&&i(!1)}function S(N){N.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",j),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",S)}},[o]);const h=!!(e&&(e.preset||e.from||e.to)),g=m.useMemo(()=>!h||!e?"Any date":e.preset?`${l}: ${FN[e.preset]??e.preset}`:`${l}: ${e.from||"…"} → ${e.to||"…"}`,[h,e,l]);function y(j){t(e?{...e,field:j}:{field:j,preset:"",from:"",to:""})}function k(j){p(!1),t({field:l,preset:j,from:"",to:""})}function v(){p(!1),t(null)}function b(j,S){const N={field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...N,[j]:S})}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":r,onClick:()=>i(j=>!j),className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",h&&"border-foreground/40 text-foreground",n),children:[s.jsx("span",{className:"truncate",children:g}),s.jsx(nr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?s.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:[s.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:XH.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j,onClick:()=>y(j),className:je("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",l===j?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:j},j))}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Sy,{label:"Any date",selected:!h,onClick:v}),K6.map(j=>s.jsx(Sy,{label:FN[j],selected:(e==null?void 0:e.preset)===j,onClick:()=>k(j)},j)),s.jsx(Sy,{label:"Custom range…",selected:f,onClick:()=>{p(!0),t({field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),f?s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",s.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:j=>b("from",j.target.value),className:"editor-input w-40"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",s.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:j=>b("to",j.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Sy({label:e,selected:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:je("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:[s.jsx("span",{children:e}),t?s.jsx(Nr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const QH=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function JH(e,t){const n={};for(const[r,o]of Object.entries(e))QH.has(r)||(n[r]=o);return{...n,...t}}function Eh(e,t,n){return{...e,viewMode:t.viewMode,filters:JH(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,limit:t.limit,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function ZH(e,t){var g,y;const n={},r=Ve(e.status);r.length&&(n.status=r);const o=Ve(e.type);o.length&&(n.type=o);const i=Ve(e.priority);i.length&&(n.priority=i);const a=Ve(e.assignee);a.length&&(n.assignee=a);const l=Ve(e.tags);if(l.length&&(n.tags=l),t&&t!=="all")n.project=[t];else{const k=Ve(e.project);k.length&&(n.project=k)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const u=Ve(e.sessionStatus);u.length&&(n.sessionStatus=u);const f=Ve(e.agent);f.length&&(n.agent=f),e.dateRange&&(n.dateRange=e.dateRange);const p=(g=e.search)==null?void 0:g.trim();p&&(n.search=p);const h=(y=e.query)==null?void 0:y.trim();return h&&(n.query=h),n}function sc(e){const t={viewMode:e.state.viewMode,filters:ZH(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 gl={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},gp={sortField:"started",sortDirection:"desc"};function tP(e,t){const{config:n}=sc({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:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function Gw(e,t){const{config:n}=sc({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function ga(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 r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Bm(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function nP(e,t){var r,o,i,a,l,u,f,p,h,g,y,k,v,b,j;const{config:n}=e;if((r=t.setViewMode)==null||r.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,Ve(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,Ve(n.filters.type)),(a=t.setPriorityFilter)==null||a.call(t,Ve(n.filters.priority)),(l=t.setAssigneeFilter)==null||l.call(t,Ve(n.filters.assignee)),(u=t.setProjectFilter)==null||u.call(t,Ve(n.filters.project)),(f=t.setTagsFilter)==null||f.call(t,Ve(n.filters.tags)),(p=t.setDateRange)==null||p.call(t,Bm(n.filters.dateRange)),(h=t.setSearch)==null||h.call(t,n.filters.search??""),(g=t.setQuery)==null||g.call(t,n.filters.query??Uu(n.filters)),t.setActivityFilter){const S=n.filters.activity??"all";t.setActivityFilter(S==="fresh"||S==="stale"?S:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(k=t.setSortDirection)==null||k.call(t,n.sortDirection),(v=t.setListSectionVisibility)==null||v.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(b=t.setKanbanColumnVisibility)==null||b.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(j=t.setTableColumnVisibility)==null||j.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Yp(e){return e?`/w/${e}/views`:"/views"}function rP(e){return`${Yp(e.workspace)}/${encodeURIComponent(e.id)}`}function sP(e){const t=e.workspace?`/w/${e.workspace}`:"",n=Ve(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&tA(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const e9=["critical","high","medium","low"],t9={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 n9(e){if(e.preset)return`${e.field} ${t9[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function oP(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&Hu(t)===null)return`query: ${t}`;const n=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=Ve(e[a]);l.length&&n.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(n9(e.dateRange));const r=(i=e.search)==null?void 0:i.trim();return r&&n.push(`search="${r}"`),n.join(" · ")||"no filters"}const zN=80,r9=["started","lastActivity","projectName","agentName"],s9={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},o9=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function iP({open:e,onOpenChange:t,initialView:n,onSubmit:r}){const o=!!n,{data:i}=ro(),{data:a}=cm(),[l,u]=m.useState(""),[f,p]=m.useState([]),[h,g]=m.useState([]),[y,k]=m.useState([]),[v,b]=m.useState(null),[j,S]=m.useState(gp.sortField),[N,C]=m.useState(gp.sortDirection),[P,T]=m.useState(""),[R,I]=m.useState(!1),[_,F]=m.useState(null);function D(){p([]),g([]),k([]),b(null),S(gp.sortField),C(gp.sortDirection),T("")}m.useEffect(()=>{if(e)if(F(null),I(!1),n){const M=n.config.filters;u(n.name),p(Ve(M.project)),g(Ve(M.agent)),k(Ve(M.sessionStatus)),b(Bm(M.dateRange)),S(n.config.sortField),C(n.config.sortDirection),T(n.config.limit!==void 0?String(n.config.limit):"")}else u(""),D()},[e,n]);const W=m.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(V=>({value:V.slug,label:V.title}))],[i]),H=m.useMemo(()=>{const M=new Set;for(const V of(a==null?void 0:a.sessions)??[])V.agent&&M.add(V.agent);return Array.from(M).sort().map(V=>({value:V,label:V}))},[a]),$=l.trim(),O=$.length>0&&$.length<=zN,U=P.trim()===""?void 0:parseInt(P.trim(),10),K=P.trim()===""||Number.isFinite(U)&&U!==void 0&&U>0&&U<=500;return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsx(Sn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async M=>{if(M.preventDefault(),!O||!K||R)return;I(!0),F(null);const V=ga(v),L=V?{...V,field:"started"}:void 0,z={filters:{project:f,agent:h,sessionStatus:y,dateRange:L},sortField:j,sortDirection:N,limit:U};try{await r($,z)}catch(Y){F(Y instanceof Error?Y.message:String(Y)),I(!1)}},children:[s.jsx(or,{children:s.jsx(Cn,{children:o?"Edit session view":"Create session view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),s.jsx("input",{id:"create-session-view-name",type:"text",value:l,autoFocus:!0,required:!0,maxLength:zN,onChange:M=>u(M.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"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(xl,{label:"Date range (session start)",children:s.jsx(zm,{className:"w-full",value:v,onChange:b})}),s.jsx(xl,{label:"Project",children:s.jsx(jn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:W,value:f,onChange:p})}),s.jsx(xl,{label:"Agent",children:s.jsx(jn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:H,value:h,onChange:g})}),s.jsx(xl,{label:"Session status",children:s.jsx(jn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:o9,value:y,onChange:k})}),s.jsx(xl,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:j,onChange:M=>S(M.target.value),className:"editor-input w-full",children:r9.map(M=>s.jsx("option",{value:M,children:s9[M]??M},M))}),s.jsx("button",{type:"button",onClick:()=>C(M=>M==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:N==="asc"?"Ascending":"Descending",children:N==="asc"?"Asc":"Desc"})]})}),s.jsxs(xl,{label:"Max results",className:"sm:col-span-2",children:[s.jsx("input",{type:"number",min:1,max:500,value:P,onChange:M=>T(M.target.value),placeholder:"No limit",className:"editor-input w-full"}),K?null:s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),_?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:_}):null,s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:D,className:"shell-action",disabled:R,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:R,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!O||!K||R,className:"shell-action shell-action--cta disabled:opacity-50",children:R?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function xl({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}function Cy({title:e,message:t,onPickAnother:n}){return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:e}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?s.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function i9({viewId:e,slotId:t,onPickAnother:n}){const{data:r,loading:o,error:i}=cm(),{view:a,loading:l,ready:u}=Ni(e??null),{layout:f}=lA(),{showToast:p}=Qn(),[h,g]=m.useState(!1),y=m.useCallback(async b=>{if(!t)return;const j=f.slots.map(S=>S.id===t?{...S,widget:b?{kind:"agent-sessions",viewId:b}:{kind:"agent-sessions"}}:S);try{await Bb(j)}catch(S){p(S instanceof Error?S.message:"Failed to update widget")}},[f,t,p]);async function k(b,j){const{workspace:S,config:N}=Gw(j,null);try{const P=(await ec({name:b,workspace:S,config:N,entityType:"session"})).views.find(T=>T.name===b&&T.entityType==="session");P&&await y(P.id),g(!1),p(`Created session view "${b}"`)}catch(C){throw p(C instanceof Error?C.message:"Failed to create session view"),C}}let v;return e?l&&!u?v=s.jsx(bt,{label:"Loading view…"}):a?a.entityType!=="session"?v=s.jsx(Cy,{title:"Wrong view type",message:"This widget is bound to an assignment view. Choose a session view above, or pick a different widget.",onPickAnother:n}):v=s.jsx(qH,{view:a,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):v=s.jsx(Cy,{title:"View no longer exists",message:"The saved view this widget was bound to has been deleted. Pick another session view above, or choose a different widget.",onPickAnother:n}):o&&!r?v=s.jsx(bt,{label:"Loading sessions…"}):i?v=s.jsx(Cy,{title:"Couldn't load sessions",message:i}):v=s.jsx(eP,{sessions:(r==null?void 0:r.sessions)??[]}),s.jsxs("div",{className:"space-y-2",children:[t?s.jsx("div",{className:"flex items-center justify-between gap-2",children:s.jsx(GH,{activeViewId:e??null,onSelectView:b=>void y(b),onCreateNew:()=>g(!0)})}):null,v,s.jsx(iP,{open:h,onOpenChange:g,workspace:null,onSubmit:k})]})}const a9=5;function l9(){const{data:e,loading:t,error:n}=Q2();if(t&&!e)return s.jsx(bt,{label:"Loading inventories…"});if(n)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),s.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,a9);return s.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[s.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),s.jsx($e,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const a=i.inventory,l=i.active_leases.length,u=i.members.length,f=a.display_name??a.slug;return s.jsx("li",{children:s.jsxs($e,{to:`/inventories/${encodeURIComponent(a.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:f}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[l,"/",u," leased"]})]})},a.slug)})})]})}function c9(e){let t=0,n=0;for(const r of e.daily)t+=r.total_tokens,n+=r.total_cost;return{tokens:t,cost:n}}function BN({filters:e,metric:t}){const n=e??{},{data:r,loading:o,error:i}=t5(n),a=t==="cost"?"Spend":"Token Usage",l=`/usage?${Eb(n).toString()}`;let u;if(o&&!r)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!r)u=s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!r||r.daily.length===0)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:f,cost:p}=c9(r),h=t==="cost"?{label:"Total spend",value:Jl(p)}:{label:"Total tokens",value:Ql(f)},g=t==="cost"?{label:"Tokens",value:Ql(f)}:{label:"Spend",value:Jl(p)};u=s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(UN,{label:h.label,value:h.value,emphasize:!0}),s.jsx(UN,{label:g.label,value:g.value})]})}return s.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:a}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",title:O1(n),children:O1(n)})]}),s.jsx($e,{to:l,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),s.jsx("div",{className:"px-4 py-4",children:u})]})}function UN({label:e,value:t,emphasize:n}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const u9={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function d9(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const yl="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function HN({config:e,open:t,onSave:n,onCancel:r}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=ro(),{data:a}=Ta(),{data:l}=J2(t),[u,f]=m.useState("30d"),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,v]=m.useState(""),[b,j]=m.useState(""),[S,N]=m.useState(""),[C,P]=m.useState(""),[T,R]=m.useState(!1),[I,_]=m.useState(null);m.useEffect(()=>{if(!t)return;const O=d9(e);f(O.window??"30d"),h(O.since??""),y(O.until??""),v(O.project??""),j(O.workspace??""),N(O.model??""),P(O.tool??""),R(!1),_(null)},[t,e]);function F(){return Id({window:u,since:u==="custom"?p:void 0,until:u==="custom"?g:void 0,project:k||void 0,workspace:b||void 0,model:S||void 0,tool:C||void 0})}async function D(O){if(O.preventDefault(),T)return;const U=F(),K=VO(U);if(!K.ok){_(K.errors.join("; "));return}R(!0),_(null);const M=e.kind==="token-usage"?{kind:"token-usage",filters:U}:e.kind==="spend"?{kind:"spend",filters:U}:e;try{await n(M)}catch(V){_(V instanceof Error?V.message:String(V)),R(!1)}}const W=(i==null?void 0:i.map(O=>O.slug))??[],H=(a==null?void 0:a.workspaces)??[],$=(a==null?void 0:a.hasUngrouped)??!1;return s.jsx(Ln,{open:t,onOpenChange:O=>{O||r()},children:s.jsx(Sn,{className:"max-w-md",children:s.jsxs("form",{onSubmit:D,children:[s.jsx(or,{children:s.jsx(Cn,{children:o})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:am.map(O=>s.jsx("button",{type:"button",onClick:()=>f(O),className:"rounded px-2.5 py-1 text-sm border "+(O===u?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:u9[O]},O))})]}),u==="custom"?s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:p,onChange:O=>h(O.target.value),className:yl})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:g,onChange:O=>y(O.target.value),className:yl})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:b,onChange:O=>{j(O.target.value),O.target.value&&v("")},className:yl,children:[s.jsx("option",{value:"",children:"All workspaces"}),$?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,H.map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:k,onChange:O=>{v(O.target.value),O.target.value&&j("")},className:yl,children:[s.jsx("option",{value:"",children:"All projects"}),W.map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:S,onChange:O=>N(O.target.value),className:yl,children:[s.jsx("option",{value:"",children:"All models"}),((l==null?void 0:l.models)??[]).map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:C,onChange:O=>P(O.target.value),className:yl,children:[s.jsx("option",{value:"",children:"All tools"}),((l==null?void 0:l.tools)??[]).map(O=>s.jsx("option",{value:O,children:O},O))]})]})]}),I?s.jsx("p",{className:"text-xs text-destructive",role:"alert",children:I}):null]}),s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:r,disabled:T,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:T,className:"shell-action shell-action--cta",children:T?"Saving…":"Save"})]})]})})})}const Yw={"saved-view":{title:"Saved view",icon:b2,render:(e,t)=>e.kind!=="saved-view"?null:m.createElement(OH,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:em,render:(e,t)=>e.kind!=="agent-sessions"?null:m.createElement(i9,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:Uv,render:()=>m.createElement(l9)},"token-usage":{title:"Token Usage",icon:k4,render:e=>e.kind!=="token-usage"?null:m.createElement(BN,{filters:e.filters,metric:"tokens"}),ConfigEditor:HN},spend:{title:"Spend",icon:om,render:e=>e.kind!=="spend"?null:m.createElement(BN,{filters:e.filters,metric:"cost"}),ConfigEditor:HN}},aP=50,Qb=16,f9=2,da=6,Th=11,Jb={w:6,h:2};function Xp(e,t,n){return Math.min(Math.max(e,t),n)}const p9=[{minWidth:1280,columns:24},{minWidth:1024,columns:16},{minWidth:768,columns:12},{minWidth:640,columns:6},{minWidth:0,columns:1}];function h9(e){if(!Number.isFinite(e)||e<0)return 1;for(const t of p9)if(e>=t.minWidth)return t.columns;return 1}function Qp(e,t){return t<=0?1:Xp(Math.round(e/dd*t),1,t)}function Zb(e){if(k7(e))return e;switch(e){case"small":return{w:8,h:da};case"wide":return{w:16,h:da};case"tall":return{w:8,h:Th};case"large":return{w:16,h:Th};default:return{w:8,h:da}}}function m9(e,t){return t>0?Math.round(e/t):0}function g9(e,t=aP){return Math.round(e/t)}const x9=[{label:"Third",w:8,h:da},{label:"Half",w:12,h:da},{label:"Two-thirds",w:16,h:da},{label:"Full",w:24,h:da},{label:"Half tall",w:12,h:Th},{label:"Full tall",w:24,h:Th}];function y9({slot:e,activeColumns:t,colWidthPx:n,onReplace:r,onRemove:o,onRemoveSlot:i,onResize:a,onConfigChange:l}){const[u,f]=m.useState(!1),[p,h]=m.useState(null),g=m.useRef(null),{attributes:y,listeners:k,setNodeRef:v,setActivatorNodeRef:b,transform:j,transition:S,isDragging:N}=Rm({id:e.id}),C=Zb(e.size),P=p?p.renderW:Qp(C.w,t),T=p?p.h:C.h,R={transform:js.Translate.toString(j),transition:S,zIndex:N?50:void 0,position:N?"relative":void 0,gridColumn:`span ${P}`,gridRow:`span ${T}`};function I(U){g.current=null;try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}h(null)}function _(U){return{onPointerDown:K=>{if(g.current)return;K.preventDefault(),K.stopPropagation(),K.currentTarget.setPointerCapture(K.pointerId);const M=Qp(C.w,t);g.current={pointerId:K.pointerId,startX:K.clientX,startY:K.clientY,startRenderW:M,startH:C.h,axis:U,lastRenderW:M,lastH:C.h},h({renderW:M,h:C.h})},onPointerMove:K=>{const M=g.current;if(!M||K.pointerId!==M.pointerId)return;let V=M.startRenderW,L=M.startH;(M.axis==="w"||M.axis==="both")&&(V=Xp(M.startRenderW+m9(K.clientX-M.startX,n),1,t)),(M.axis==="h"||M.axis==="both")&&(L=Xp(M.startH+g9(K.clientY-M.startY),f9,eA)),M.lastRenderW=V,M.lastH=L,h({renderW:V,h:L})},onPointerUp:K=>{const M=g.current;if(!M||K.pointerId!==M.pointerId)return;const V=Zb(e.size),z={w:M.axis==="h"?V.w:Xp(Math.round(M.lastRenderW/t*dd),1,dd),h:M.lastH};I(K),(z.w!==V.w||z.h!==V.h)&&a(z)},onPointerCancel:K=>{const M=g.current;M&&K.pointerId===M.pointerId&&I(K)},onLostPointerCapture:K=>{const M=g.current;M&&K.pointerId===M.pointerId&&I(K)}}}const F="absolute z-10 touch-none rounded-sm bg-transparent transition hover:bg-primary/30",D=s.jsxs(s.Fragment,{children:[t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"right-0 top-0 h-full w-1.5 cursor-ew-resize"),..._("w")}):null,s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 left-0 h-1.5 w-full cursor-ns-resize"),..._("h")}),t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 right-0 h-3 w-3 cursor-nwse-resize"),..._("both")}):null]}),W=s.jsx("button",{ref:b,...y,...k,type:"button","aria-label":"Drag to reorder widget",className:"touch-none cursor-grab text-muted-foreground/40 transition hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing",children:s.jsx(yc,{className:"h-4 w-4","aria-hidden":"true"})});if(e.widget===null)return s.jsxs("div",{ref:v,style:{...R,gridColumn:`span ${Qp(Jb.w,t)}`,gridRow:`span ${Jb.h}`},className:je("relative flex items-center justify-center rounded-lg border border-dashed border-border bg-card/40 p-3 shadow-sm transition-colors hover:border-primary/40 hover:bg-card/60",N&&"opacity-0"),children:[s.jsx("div",{className:"absolute left-2 top-2",children:W}),s.jsx("button",{type:"button","aria-label":"Remove slot",onClick:i,onPointerDown:U=>U.stopPropagation(),className:"absolute right-2 top-2 z-10 text-muted-foreground/50 transition hover:text-destructive",children:s.jsx(mn,{className:"h-4 w-4"})}),s.jsxs("button",{type:"button",onClick:r,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Pt,{className:"h-4 w-4"}),"Add widget"]})]});const H=Yw[e.widget.kind];if(!H)return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",N&&"opacity-0"),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[W,s.jsxs("div",{className:"flex-1 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]})]}),D]});const $=H.icon,O=H.ConfigEditor;return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",N&&"opacity-0"),children:[s.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[W,s.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:s.jsx(v9,{slot:e,fallback:H.title})})]}),s.jsx(Kw,{items:[{key:"replace",label:"Replace…",icon:$4,onSelect:r},...H.ConfigEditor?[{key:"configure",label:"Configure…",icon:z4,onSelect:()=>f(!0)}]:[],{key:"size",label:"Size",icon:v2,submenu:x9.map(U=>({key:`size-${U.label}`,label:U.label,active:C.w===U.w&&C.h===U.h,onSelect:()=>a({w:U.w,h:U.h})}))},{key:"remove",label:"Remove",icon:mn,destructive:!0,onSelect:o}]})]}),s.jsx("div",{children:H.render(e.widget,{slotId:e.id,onPickAnother:r})}),O?s.jsx(O,{config:e.widget,open:u,onSave:async U=>{await l(U),f(!1)},onCancel:()=>f(!1)}):null,D]})}function b9({slot:e,activeColumns:t,colWidthPx:n}){const r=e.widget?Yw[e.widget.kind]:null,o=r==null?void 0:r.icon,i=e.widget===null?"Empty widget slot":(r==null?void 0:r.title)??`Unknown widget kind: ${e.widget.kind}`,a=e.widget===null?Jb:Zb(e.size),l=Qp(a.w,t),u=n>0?l*n+(l-1)*Qb:void 0;return s.jsx("div",{"aria-hidden":"true",className:"min-w-[200px] rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",style:{width:u?`${Math.max(u,200)}px`:void 0},children:s.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[s.jsx(yc,{className:"h-4 w-4","aria-hidden":"true"}),o?s.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,s.jsx("span",{className:"min-w-0 flex-1 truncate",children:i})]})})}function v9({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:r}=Ni(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&r?s.jsx(s.Fragment,{children:r.name}):s.jsx(s.Fragment,{children:t})}const w9=["agent-sessions","inventories","token-usage","spend"];function j9({open:e,onOpenChange:t,onSelect:n}){const{views:r,loading:o}=Ud();function i(a){n(a),t(!1)}return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsxs(Sn,{className:"max-w-xl",children:[s.jsxs(or,{children:[s.jsx(Cn,{children:"Add a widget"}),s.jsx(ns,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:w9.map(a=>{const l=Yw[a],u=l.icon;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:a}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx(u,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsx("span",{className:"font-medium text-foreground",children:l.title})]})},a)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?s.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):r.length===0?s.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),s.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",s.jsx($e,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):s.jsxs("div",{className:"space-y-3",children:[r.some(a=>a.entityType!=="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType!=="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null,s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:a.config.viewMode})]})},a.id))})]}),r.some(a=>a.entityType==="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType==="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null]})},a.id))})]})]}),!o&&r.some(a=>a.workspace!==null)?s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}const k9=(e,{currentCoordinates:t,context:n})=>{var h;const r=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(r===0)return;e.preventDefault();const o=n.over??n.active,i=(h=o==null?void 0:o.data.current)==null?void 0:h.sortable,a=i==null?void 0:i.items;if(!o||!a)return t;const l=a.indexOf(o.id);if(l===-1)return t;const u=a[l+r],f=u===void 0?null:n.droppableRects.get(u),p=n.collisionRect;return!f||!p?t:{x:f.left+(f.width-p.width)/2,y:f.top+(f.height-p.height)/2}};function N9(e){const t=new Set(e.map(o=>o.id));let n=-1;for(const o of t){const i=/^slot-(\d+)$/.exec(o);if(i){const a=parseInt(i[1],10);a>n&&(n=a)}}let r=n+1;for(;t.has(`slot-${r}`);)r++;return`slot-${r}`}function S9(e,t){const n={id:N9(e),widget:null};return[...e,n]}function C9(e,t){return e.filter(n=>n.id!==t)}function E9(){const{data:e,error:t,refetch:n}=qO(),{data:r}=G2(),{layout:o}=lA(),[i,a]=m.useState(!1),[l,u]=m.useState(null),[f,p]=m.useState(null),[h,g]=m.useState(o.slots),[y,k]=m.useState(null),v=m.useRef(null),[b,j]=m.useState(dd),[S,N]=m.useState(0);m.useEffect(()=>{const K=v.current;if(!K)return;const M=new ResizeObserver(V=>{for(const L of V){const z=L.contentRect.width,Y=h9(z),B=Y>0?(z-(Y-1)*Qb)/Y:0;j(Y),N(B)}});return M.observe(K),()=>M.disconnect()},[]),m.useEffect(()=>{g(o.slots)},[o.slots]);const C=jm(ki(Ec,{activationConstraint:{distance:8}}),ki(Cc,{coordinateGetter:k9}));Pi("list:overview"),en({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const P=m.useCallback(K=>{u(K),a(!0)},[]),T=m.useCallback(async(K,M)=>{p(null),g(K);try{await Bb(K)}catch(V){g(M),p(V instanceof Error?V.message:String(V))}},[]),R=m.useCallback(K=>{if(l===null)return;const M=h.map((V,L)=>L===l?{...V,widget:K}:V);u(null),T(M,h)},[h,l,T]),I=m.useCallback(K=>{const M=h.map((V,L)=>L===K?{...V,widget:null,size:void 0}:V);T(M,h)},[h,T]),_=m.useCallback(K=>{const M=C9(h,K);T(M,h)},[h,T]),F=m.useCallback(()=>{const K=S9(h);T(K,h)},[h,T]),D=m.useCallback((K,M)=>{const V=h.map((L,z)=>z===K?{...L,size:M}:L);T(V,h)},[h,T]),W=m.useCallback(K=>{const{active:M,over:V}=K;if(k(null),!V||M.id===V.id)return;const L=h.findIndex(B=>B.id===M.id),z=h.findIndex(B=>B.id===V.id);if(L===-1||z===-1)return;const Y=Tc(h,L,z);T(Y,h)},[h,T]),H=m.useCallback(K=>{k(String(K.active.id))},[]),$=h.find(K=>K.id===y)??null,O=m.useCallback(async(K,M)=>{const V=h,L=h.map((z,Y)=>Y===K?{...z,widget:M}:z);p(null),g(L);try{await Bb(L)}catch(z){g(V);const Y=z instanceof Error?z.message:String(z);throw p(Y),z instanceof Error?z:new Error(Y)}},[h]),U={};if(e)for(const K of Object.keys(e.segments))for(const M of e.segments[K].items)U[M.id]=M;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("header",{className:"space-y-2",children:[s.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),s.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?s.jsx(w7,{hero:e.hero,itemsById:U}):t?s.jsx(Rt,{error:t,onRetry:n}):s.jsx(bt,{label:"Loading overview…"}),e!=null&&e.firstRun?s.jsx(b7,{help:r}):null,f?s.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: ",f]}):null,s.jsxs(Em,{sensors:C,collisionDetection:km,onDragStart:H,onDragCancel:()=>k(null),onDragEnd:W,children:[s.jsx(Tm,{items:h.map(K=>K.id),strategy:_w,children:s.jsx("div",{ref:v,style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gridAutoRows:`${aP}px`,gridAutoFlow:"dense",gap:`${Qb}px`},children:h.map((K,M)=>s.jsx(y9,{slot:K,index:M,activeColumns:b,colWidthPx:S,onReplace:()=>P(M),onRemove:()=>I(M),onRemoveSlot:()=>_(K.id),onResize:V=>D(M,V),onConfigChange:V=>O(M,V)},K.id))})}),s.jsx(o7,{dropAnimation:null,children:$?s.jsx(b9,{slot:$,activeColumns:b,colWidthPx:S}):null})]}),s.jsxs("button",{type:"button",onClick:F,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Pt,{className:"h-4 w-4"}),"Add slot"]}),e!=null&&e.serverStats?s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Gv,{className:"h-3 w-3","aria-hidden":"true"}),s.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,s.jsx(j9,{open:i,onOpenChange:K=>{a(K),K||u(null)},onSelect:R})]})}const T9=["review","blocked","question","plan-approval"],R9={review:"Review",blocked:"Blocked",question:"Questions","plan-approval":"Plan approval"};function A9(e){const t=[];for(const n of T9){const r=e.filter(o=>o.category===n).sort((o,i)=>i.ageMs-o.ageMs);r.length!==0&&t.push({category:n,label:R9[n],count:r.length,items:r})}return t}function P9(e){if(!Number.isFinite(e)||e<0)return"just now";const t=Math.floor(e/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function lP(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/transitions/${n}`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/transitions/${n}`}}function _9(e){return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments`}}function D9(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"PATCH",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments/${n}/resolved`}:{method:"PATCH",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments/${n}/resolved`}}function Xw(e,t){const n=t?`?tab=${t}`:"";return e.project===null?`/assignments/${encodeURIComponent(e.assignmentId)}${n}`:`/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}${n}`}function $9(){const{items:e,total:t,loading:n,error:r,refetch:o}=rR(),{toast:i,showToast:a,dismissToast:l}=Qn();if(n&&e.length===0)return s.jsx(bt,{label:"Loading your inbox…"});if(r&&e.length===0)return s.jsx(Rt,{title:"Inbox unavailable",error:r,action:s.jsx("button",{type:"button",className:"shell-action",onClick:o,children:"Retry"})});const u=A9(e);return u.length===0?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(VN,{total:0}),s.jsx(Nt,{title:"Nothing needs you right now",description:"No reviews, blocks, open questions, or plans awaiting approval across your projects. New items appear here the moment something needs a human decision."})]}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(VN,{total:t}),u.map(f=>s.jsx(Ke,{title:f.label,actions:s.jsx("span",{className:"rounded-full bg-foreground px-2.5 py-0.5 text-xs font-semibold text-background",children:f.count}),children:s.jsx("ul",{className:"space-y-3",children:f.items.map(p=>s.jsx(I9,{item:p,onMutated:o,onError:h=>a(h,"error"),onSuccess:h=>a(h,"success")},`${p.category}:${p.assignmentId}:${p.since}`))})},f.category))]})}function VN({total:e}){return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:s.jsx(y2,{className:"h-4 w-4"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Needs me"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e===0?"Everything is handled.":`${e} ${e===1?"item":"items"} awaiting your decision.`})]})]})}async function Rh(e,t,n,r){try{const o=await fetch(e.url,{method:e.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){const i=await o.json().catch(()=>null);throw new Error((i==null?void 0:i.error)||`HTTP ${o.status}`)}return n.onSuccess(r),n.onMutated(),!0}catch(o){return n.onError(o instanceof Error?o.message:String(o)),!1}}function I9({item:e,onMutated:t,onError:n,onSuccess:r}){return s.jsxs("li",{className:"flex flex-col gap-2 rounded-lg border border-border/70 bg-background/40 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[s.jsx($e,{to:Xw(e),className:"text-sm font-semibold text-foreground hover:underline",children:e.title}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.project?e.project:"standalone"}),s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",title:e.since,children:P9(e.ageMs)})]}),e.summary?s.jsx("p",{className:"text-sm text-muted-foreground",children:e.summary}):null,s.jsx(M9,{item:e,onMutated:t,onError:n,onSuccess:r}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted/60 px-2 py-1 font-mono text-[11px] text-muted-foreground",children:e.action.command}),s.jsx(Hr,{value:e.action.command,label:"Copy",onError:o=>n(o.message)})]})]})}function M9(e){switch(e.item.category){case"review":return s.jsx(L9,{...e});case"blocked":return s.jsx(O9,{...e});case"question":return s.jsx(F9,{...e});case"plan-approval":return s.jsx(z9,{...e});default:return null}}const xa="shell-action inline-flex items-center gap-1.5";function L9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(null),{acceptCommand:a,reopenCommand:l}=e;async function u(f,p){i(f),await Rh(lP(e,f),void 0,{onMutated:t,onError:n,onSuccess:r},`${p} — ${e.title}`),i(null)}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?s.jsxs("button",{type:"button",className:xa,disabled:o!==null,onClick:()=>u(a,"Accepted"),children:[s.jsx(Nr,{className:"h-3.5 w-3.5"}),o===a?"Accepting…":"Accept"]}):null,l?s.jsxs("button",{type:"button",className:xa,disabled:o!==null,onClick:()=>u(l,"Reopened"),children:[s.jsx(vs,{className:"h-3.5 w-3.5"}),o===l?"Reopening…":"Reopen"]}):null]})}function O9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1);async function u(){l(!0);const f=await Rh(lP(e,"unblock"),o.trim()?{reason:o.trim()}:void 0,{onMutated:t,onError:n,onSuccess:r},`Unblocked — ${e.title}`);l(!1),f&&i("")}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:f=>i(f.target.value),placeholder:"Reason (optional)",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:xa,disabled:a,onClick:u,children:[s.jsx(A4,{className:"h-3.5 w-3.5"}),a?"Unblocking…":"Unblock"]})]})}function F9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1),u=e.commentId;async function f(){if(!o.trim())return;l(!0);const h=await Rh(_9(e),{body:o.trim(),type:"note",author:"human",...u?{replyTo:u}:{}},{onMutated:t,onError:n,onSuccess:r},`Replied — ${e.title}`);l(!1),h&&i("")}async function p(){if(!u){n("Could not determine which question to resolve — open the assignment to resolve it.");return}l(!0),await Rh({...D9(e,u)},{resolved:!0},{onMutated:t,onError:n,onSuccess:r},`Resolved — ${e.title}`),l(!1)}return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs($e,{to:Xw(e,"comments"),className:xa,children:[s.jsx(rm,{className:"h-3.5 w-3.5"}),"Open to answer"]}),s.jsxs("button",{type:"button",className:xa,disabled:a||!u,title:u?void 0:"Open the assignment to resolve this question.",onClick:p,children:[s.jsx(sm,{className:"h-3.5 w-3.5"}),"Resolve"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),placeholder:"Reply inline…",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:xa,disabled:a||!o.trim(),onClick:f,children:[s.jsx(m2,{className:"h-3.5 w-3.5"}),a?"Posting…":"Reply"]})]})]})}function z9({item:e}){return s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs($e,{to:Xw(e,"plan"),className:xa,children:[s.jsx(rm,{className:"h-3.5 w-3.5"}),"Review plan"]})})}function B9({term:e,description:t}){return s.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 U9(){const{data:e,loading:t,error:n}=G2(),{openCheatsheet:r}=Ai();return t?s.jsx(bt,{label:"Loading help…"}):n||!e?s.jsx(Rt,{error:n||"Help content is unavailable."}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Ke,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:r,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"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Zs("Mod+k")," opens the command palette."]})]})}),s.jsx(Ke,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),s.jsx(Ke,{title:"Getting Started",children:s.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Kp,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?s.jsx($e,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsxs(Ke,{title:"Core Concepts",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>s.jsx(B9,{term:o.term,description:o.description},o.term))}),s.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),s.jsx(Ke,{title:"Status Guide",children:s.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:o.status}),s.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),s.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Ke,{title:"Ownership And File Rules",children:s.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),s.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>s.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:i},i))})]},o.label))})}),s.jsx(Ke,{title:"How To Navigate The Dashboard",children:s.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx($e,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),s.jsx(Ke,{title:"CLI Quick Reference",children:s.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>s.jsx(Kp,{command:o.command,description:o.description,example:o.example},o.command))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Ke,{title:"FAQ",children:s.jsx("div",{className:"space-y-3",children:e.faq.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),s.jsx(Ke,{title:"First Project Checklist",children:s.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Kp,{command:o.command.command,example:o.command.example}):null,o.href?s.jsx($e,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function Qw({children:e}){return s.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 Um=m.forwardRef(({value:e,onChange:t,placeholder:n="Search"},r)=>s.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[s.jsx(Ei,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),s.jsx("input",{ref:r,value:e,onChange:o=>t(o.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"})]}));Um.displayName="SearchInput";function Hm({value:e,options:t,onChange:n}){return s.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(r=>s.jsx("button",{type:"button","aria-pressed":e===r.value,onClick:()=>n(r.value),className:je("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===r.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}const H9={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"},WN=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function Ah({progress:e,className:t,showLegend:n=!1}){const r=As(),i=m.useMemo(()=>{let a=0;const l=Object.keys(e).filter(f=>f!=="total");return(r.order.length>0?[...r.order,...l.filter(f=>!r.order.includes(f))]:l).map(f=>({key:f,className:H9[f]??WN[a++%WN.length]}))},[r.order,e]).filter(a=>(e[a.key]??0)>0);return s.jsxs("div",{className:je("space-y-2",t),children:[s.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?s.jsx("div",{className:"h-full w-full bg-muted"}):i.map(a=>s.jsx("div",{className:a.className,style:{width:`${(e[a.key]??0)/e.total*100}%`},title:`${vn(a.key)}: ${e[a.key]??0}`},a.key))}),n?i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[s.jsx("span",{className:je("h-2 w-2 rounded-full",a.className)}),s.jsx("span",{children:vn(a.key)}),s.jsx("span",{className:"font-medium text-foreground",children:e[a.key]??0})]},a.key))}):s.jsx("p",{className:"text-xs text-muted-foreground/70",children:"No assignments yet"}):null]})}const V9=["pending","active","blocked","failed","completed"],Jw=V9,W9=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function cP(e){return e&&e.length>0?e:[...W9]}function K9(e,t,n){if(t<0||t>=e.length)return e;const r=[...e],[o]=r.splice(t,1),i=t<n?n-1:n;return r.splice(Math.max(0,Math.min(i,r.length)),0,o),r}const q9=220,xp=8;function uP({anchor:e,items:t,onClose:n}){const r=m.useRef(null),[o,i]=m.useState(null);return m.useLayoutEffect(()=>{if(!e){i(null);return}const a=r.current,l=(a==null?void 0:a.offsetWidth)??q9,u=(a==null?void 0:a.offsetHeight)??0,f=Math.max(xp,window.innerWidth-l-xp),p=Math.max(xp,window.innerHeight-u-xp);i({left:Math.min(e.x,f),top:Math.min(e.y,p)})},[e]),m.useEffect(()=>{if(!e)return;function a(f){r.current&&!r.current.contains(f.target)&&n()}function l(f){f.key==="Escape"&&n()}function u(){n()}return document.addEventListener("mousedown",a),document.addEventListener("keydown",l),document.addEventListener("contextmenu",a),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",l),document.removeEventListener("contextmenu",a),window.removeEventListener("scroll",u,!0)}},[e,n]),!e||t.length===0?null:s.jsx("div",{ref:r,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(o==null?void 0:o.left)??e.x,top:(o==null?void 0:o.top)??e.y,visibility:o?"visible":"hidden"},children:s.jsx(ma,{delayDuration:200,children:t.map(a=>{const l=a.icon,u=je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",a.disabled?"cursor-not-allowed opacity-50":a.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),f=s.jsxs(s.Fragment,{children:[l?s.jsx(l,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 truncate",children:a.label})]});if(a.disabled){const p=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:u,children:f})});return a.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:p}),s.jsx(vr,{side:"left",children:a.disabledReason})]},a.key):s.jsx("div",{children:p},a.key)}return a.href?s.jsx($e,{to:a.href,className:u,onClick:()=>n(),children:f},a.key):s.jsx("button",{type:"button",className:u,onClick:()=>{var p;(p=a.onSelect)==null||p.call(a),n()},children:f},a.key)})})})}const G9="__ungrouped__";function Zw({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:r,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:a,loading:l}=Ta(),[u,f]=m.useState(n),[p,h]=m.useState(!1),[g,y]=m.useState(null);m.useEffect(()=>{e&&(f(n),y(null))},[e,n]);const k=m.useMemo(()=>[...((a==null?void 0:a.workspaces)??[]).map(S=>({key:S,label:S,value:S})),{key:G9,label:"Ungrouped",value:null}],[a]),v=!p&&u!==n;async function b(){if(v){h(!0),y(null);try{await r(u),t(!1)}catch(j){y(j instanceof Error?j.message:"Failed to move item")}finally{h(!1)}}}return s.jsx(Ln,{open:e,onOpenChange:j=>p?void 0:t(j),children:s.jsxs(Sn,{children:[s.jsxs(or,{children:[s.jsx(Cn,{children:o}),s.jsx(ns,{children:i})]}),s.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:l&&k.length===0?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[s.jsx(qv,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):k.map(j=>{const S=j.value===n,N=j.value===u;return s.jsxs("button",{type:"button",disabled:S||p,onClick:()=>f(j.value),className:je("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",S?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:je("block min-w-0 truncate",j.value===null?"italic text-muted-foreground":""),children:[j.label,S?s.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?s.jsx(Nr,{className:"h-4 w-4 text-foreground"}):null]},j.key)})}),g?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:g}):null,s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),disabled:p,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:b,disabled:!v,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p?"Moving…":"Move"})]})]})})}function KN(){const{workspace:e}=Kt(),t=gn(),n=Wt(),{data:r,loading:o,error:i,refetch:a}=ro(),{toast:l,showToast:u,dismissToast:f}=Qn(),p=m.useRef(null);Pi("list:projects");const[h,g]=m.useState(""),[y,k]=m.useState("all"),[v,b]=m.useState("all"),[j,S]=m.useState("updated"),[N,C]=Ts(),P=N.get("view"),T=P==="table"||P==="kanban"?P:"cards",R=z=>{C(Y=>{const B=new URLSearchParams(Y);return z==="cards"?B.delete("view"):B.set("view",z),B})},[I,_]=m.useState({}),[F,D]=m.useState(null),[W,H]=m.useState(null),$=m.useMemo(()=>r?r.filter(z=>{if(e){if(e==="_ungrouped"){if(z.workspace!==null)return!1}else if(z.workspace!==e)return!1}return y!=="all"&&z.status!==y||v!=="all"&&!z.tags.includes(v)?!1:h.trim()?`${z.title} ${z.tags.join(" ")} ${z.slug}`.toLowerCase().includes(h.toLowerCase()):!0}).sort((z,Y)=>X9(z,Y,j)):[],[r,h,y,v,j,e]),O=$.map(z=>`${z.slug}:${z.status}`).join("|");m.useEffect(()=>{_(Q9($))},[O,j]);const U=m.useMemo(()=>{const z=new Map($.map(Y=>[Y.slug,Y]));return Jw.flatMap(Y=>(I[Y]??$.filter(Q=>Q.status===Y).map(Q=>Q.slug)).map(Q=>z.get(Q)).filter(Q=>!!Q))},[$,I]),{visibleItems:K,visibleIndexByKey:M}=m.useMemo(()=>{const z=T==="kanban"?U:$,Y=new Map;return z.forEach((B,Q)=>Y.set(B.slug,Q)),{visibleItems:z,visibleIndexByKey:Y}},[T,$,U]),{hotkeyRowProps:V}=Ld(K,{scope:"list:projects",onOpen:z=>n(`${t}/projects/${z.slug}`)});if(en({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var z;return(z=p.current)==null?void 0:z.focus()}}),en({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>a()}),o)return s.jsx(bt,{label:"Loading projects…"});if(i||!r)return s.jsx(Rt,{error:i||"Project list is unavailable.",onRetry:a});const L=Array.from(new Set(r.flatMap(z=>z.tags))).sort();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:l,onDismiss:f}),s.jsxs(Qw,{children:[s.jsx(Um,{ref:p,value:h,onChange:g,placeholder:"Search by project title or tag"}),s.jsxs("select",{value:y,onChange:z=>k(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All statuses"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"blocked",children:"Blocked"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"completed",children:"Completed"})]}),s.jsxs("select",{value:v,onChange:z=>b(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All tags"}),L.map(z=>s.jsx("option",{value:z,children:z},z))]}),s.jsxs("select",{value:j,onChange:z=>S(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"updated",children:"Sort: Updated"}),s.jsx("option",{value:"created",children:"Sort: Created"}),s.jsx("option",{value:"title",children:"Sort: Title"}),s.jsx("option",{value:"attention",children:"Sort: Attention"})]}),s.jsx(Hm,{value:T,onChange:z=>R(z),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),$.length===0?r.length===0?s.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[s.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),s.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"}),s.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."}),s.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[s.jsx($e,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),s.jsx($e,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):s.jsx(Nt,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:s.jsx($e,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):T==="cards"?s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:$.map((z,Y)=>s.jsxs($e,{to:`${t}/projects/${z.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...V(Y),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:z.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(z.updated)]})]}),s.jsx(kn,{status:z.status})]}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsx(Ah,{progress:z.progress,showLegend:!0}),s.jsx("div",{className:"flex flex-wrap gap-2",children:z.tags.map(B=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:B},B))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount})]}),s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.progress.total})]})]})]})]},z.slug))}):T==="table"?s.jsx(Ke,{title:`${$.length} project${$.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"pb-3 font-medium",children:"Project"}),s.jsx("th",{className:"pb-3 font-medium",children:"Status"}),s.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),s.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),s.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:$.map((z,Y)=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",...V(Y),children:[s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx($e,{to:`${t}/projects/${z.slug}`,className:"font-semibold text-foreground hover:text-primary",children:z.title}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:z.tags.map(B=>s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:B},B))})]}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx(kn,{status:z.status})}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx("div",{className:"min-w-[220px]",children:s.jsx(Ah,{progress:z.progress})})}),s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount}),s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(z.updated)})]},z.slug))})]})})}):s.jsx(Fm,{columns:qN,items:U,getItemId:z=>z.slug,getColumnId:z=>z.status,canDrop:({fromColumnId:z,toColumnId:Y})=>({allowed:!0,reason:z===Y?void 0:"This will set a manual status override on the project."}),onMove:async({item:z,fromColumnId:Y,toColumnId:B,fromIndex:Q,toIndex:J})=>{var Z;if(Y===B){const oe=I[Y]??$.filter(ne=>ne.status===Y).map(ne=>ne.slug);_(ne=>({...ne,[Y]:K9(oe,Q,J)}));return}try{const oe=await fetch(`/api/projects/${z.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:B})});if(!oe.ok){const ue=await oe.json().catch(()=>null);u((ue==null?void 0:ue.error)||`HTTP ${oe.status}`,"error");return}a();const ne=((Z=qN.find(ue=>ue.id===B))==null?void 0:Z.title)??B;u(`Moved "${z.title}" to ${ne}`,"success")}catch(oe){u(oe instanceof Error?oe.message:"Failed to move project","error")}},getExternalDragData:z=>({type:"project",id:z.slug}),onCardContextMenu:(z,Y)=>{Y.preventDefault(),D({project:z,anchor:{x:Y.clientX,y:Y.clientY}})},emptyMessage:z=>`No ${z.title.toLowerCase()} projects.`,renderCard:(z,{dragging:Y})=>{const B=M.get(z.slug)??-1;return s.jsx("div",{...B>=0?V(B):{},children:s.jsx(J9,{project:z,dragging:Y})})}}),s.jsx(uP,{anchor:(F==null?void 0:F.anchor)??null,items:F?[{key:"edit",label:"Edit",icon:bc,onSelect:()=>n(`${t}/projects/${F.project.slug}`)},{key:"move",label:"Move to workspace…",icon:nm,onSelect:()=>H(F.project)}]:[],onClose:()=>D(null)}),s.jsx(Zw,{open:W!==null,onOpenChange:z=>{z||H(null)},currentWorkspace:(W==null?void 0:W.workspace)??null,title:"Move project to workspace",onSubmit:async z=>{if(!W)return;const Y=await fetch(`/api/projects/${encodeURIComponent(W.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:z})});if(!Y.ok){const B=await Y.json().catch(()=>({}));throw new Error(B.error||"Failed to move project")}a()}}),s.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Kv,{className:"mt-0.5 h-4 w-4"}),s.jsxs("p",{children:["Project status is derived from assignment state by default.",T==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const Y9={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},qN=Jw.map(e=>({id:e,title:Y9[e],description:Kd(e)}));function X9(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return GN(t)-GN(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function GN(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function Q9(e){return Object.fromEntries(Jw.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function J9({project:e,dragging:t}){const n=gn();return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx($e,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(e.updated)]})]}),s.jsx(kn,{status:e.status})]}),s.jsx("div",{className:"mt-4",children:s.jsx(Ah,{progress:e.progress})}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(r=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:r},r)),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),s.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"]})]}),s.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function Ph({title:e,description:t,actions:n,className:r}){return s.jsxs("div",{className:je("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",r),children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?s.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function Z9(){return s.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:[s.jsx(tm,{className:"h-3 w-3"}),"Archived"]})}function YN(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function eV(){const{data:e,loading:t,error:n,refetch:r}=GO(),[o,i]=m.useState(null),[a,l]=m.useState(null),[u,f]=m.useState({}),{toast:p,showToast:h,dismissToast:g}=Qn();async function y(N,C,P){i(C),l(null);try{const T=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)||`HTTP ${T.status}`)}r(),h(P,"success")}catch(T){l(T instanceof Error?T.message:"Restore failed")}finally{i(null)}}function k(N){return y(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function v(N){const C=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return y(C,`assignment:${N.id}`,"Assignment restored")}if(t)return s.jsx(bt,{label:"Loading archived content…"});if(n)return s.jsx(Rt,{error:n});const b=(e==null?void 0:e.projects)??[],j=(e==null?void 0:e.assignments)??[],S=b.length===0&&j.length===0;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Xn,{toast:p,onDismiss:g}),s.jsx(Ph,{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."}),a?s.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:a}):null,S?s.jsx(Nt,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):s.jsxs(s.Fragment,{children:[b.length>0&&s.jsx(Ke,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:s.jsx("ul",{className:"divide-y divide-border",children:b.map(N=>{const C=u[N.slug]??!1;return s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>f(P=>({...P,[N.slug]:!C})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":C,children:[C?s.jsx(nr,{className:"h-4 w-4"}):s.jsx(Hv,{className:"h-4 w-4"}),s.jsx(Vv,{className:"h-4 w-4 text-muted-foreground"}),N.title,s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Sr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx($e,{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"}),s.jsxs("button",{type:"button",onClick:()=>k(N),disabled:o===`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:[s.jsx(oh,{className:"h-3 w-3"}),"Restore"]})]})]}),C&&N.assignments.length>0&&s.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(P=>s.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsx($e,{to:YN(P),className:"text-foreground hover:text-foreground/80",children:P.title}),s.jsx(kn,{status:P.status,showIcon:!1}),s.jsx("span",{className:"text-xs text-muted-foreground",children:P.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},P.id))})]},N.slug)})})}),j.length>0&&s.jsx(Ke,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:s.jsx("ul",{className:"divide-y divide-border",children:j.map(N=>s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsx($e,{to:YN(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),s.jsx(kn,{status:N.status,showIcon:!1}),s.jsx(Z9,{}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Sr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),s.jsxs("button",{type:"button",onClick:()=>v(N),disabled:o===`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:[s.jsx(oh,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const XN="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",QN="block min-w-0 truncate";function e0({externalIds:e,className:t}){return e.length===0?null:s.jsx("span",{className:je("flex flex-wrap items-center gap-1.5",t),children:e.map((n,r)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${r}`;return n.url!=null&&n.url.length>0?s.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:je(XN,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[s.jsx("span",{className:QN,children:o}),s.jsx(xc,{className:"h-2.5 w-2.5 shrink-0"})]},i):s.jsx("span",{className:XN,title:o,children:s.jsx("span",{className:QN,children:o})},i)})})}const tV={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 Gn({label:e,value:t,description:n,icon:r,tone:o="default",to:i}){const a=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),s.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),r?s.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:s.jsx(r,{className:"h-5 w-5"})}):null]}),n?s.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),f=je(tV[(t===0||t==="0")&&(o==="warn"||o==="danger")?"default":o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?s.jsx($e,{to:i,className:f,children:a}):s.jsx("article",{className:f,children:a})}function JN(e){const t=nV(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(sV);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function nV(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=iV(o),l=oV(i,o.props);return o.type!==m.Fragment&&(l.ref=r?mm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rV=Symbol("radix.slottable");function sV(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rV}function oV(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function iV(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function aV(e){const t=e+"CollectionProvider",[n,r]=Ra(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:b,children:j}=v,S=Lt.useRef(null),N=Lt.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:N,collectionRef:S,children:j})};a.displayName=t;const l=e+"CollectionSlot",u=JN(l),f=Lt.forwardRef((v,b)=>{const{scope:j,children:S}=v,N=i(l,j),C=rr(b,N.collectionRef);return s.jsx(u,{ref:C,children:S})});f.displayName=l;const p=e+"CollectionItemSlot",h="data-radix-collection-item",g=JN(p),y=Lt.forwardRef((v,b)=>{const{scope:j,children:S,...N}=v,C=Lt.useRef(null),P=rr(b,C),T=i(p,j);return Lt.useEffect(()=>(T.itemMap.set(C,{ref:C,...N}),()=>void T.itemMap.delete(C))),s.jsx(g,{[h]:"",ref:P,children:S})});y.displayName=p;function k(v){const b=i(e+"CollectionConsumer",v);return Lt.useCallback(()=>{const S=b.collectionRef.current;if(!S)return[];const N=Array.from(S.querySelectorAll(`[${h}]`));return Array.from(b.itemMap.values()).sort((T,R)=>N.indexOf(T.ref.current)-N.indexOf(R.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:y},k,r]}var lV=m.createContext(void 0);function dP(e){const t=m.useContext(lV);return e||t||"ltr"}var Ey="rovingFocusGroup.onEntryFocus",cV={bubbles:!1,cancelable:!0},Gd="RovingFocusGroup",[ev,fP,uV]=aV(Gd),[dV,pP]=Ra(Gd,[uV]),[fV,pV]=dV(Gd),hP=m.forwardRef((e,t)=>s.jsx(ev.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ev.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(hV,{...e,ref:t})})}));hP.displayName=Gd;var hV=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=e,g=m.useRef(null),y=rr(t,g),k=dP(i),[v,b]=gm({prop:a,defaultProp:l??null,onChange:u,caller:Gd}),[j,S]=m.useState(!1),N=va(f),C=fP(n),P=m.useRef(!1),[T,R]=m.useState(0);return m.useEffect(()=>{const I=g.current;if(I)return I.addEventListener(Ey,N),()=>I.removeEventListener(Ey,N)},[N]),s.jsx(fV,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(I=>b(I),[b]),onItemShiftTab:m.useCallback(()=>S(!0),[]),onFocusableItemAdd:m.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:m.useCallback(()=>R(I=>I-1),[]),children:s.jsx(Nn.div,{tabIndex:j||T===0?-1:0,"data-orientation":r,...h,ref:y,style:{outline:"none",...e.style},onMouseDown:sn(e.onMouseDown,()=>{P.current=!0}),onFocus:sn(e.onFocus,I=>{const _=!P.current;if(I.target===I.currentTarget&&_&&!j){const F=new CustomEvent(Ey,cV);if(I.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=C().filter(U=>U.focusable),W=D.find(U=>U.active),H=D.find(U=>U.id===v),O=[W,H,...D].filter(Boolean).map(U=>U.ref.current);xP(O,p)}}P.current=!1}),onBlur:sn(e.onBlur,()=>S(!1))})})}),mP="RovingFocusGroupItem",gP=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=Ol(),f=i||u,p=pV(mP,n),h=p.currentTabStopId===f,g=fP(n),{onFocusableItemAdd:y,onFocusableItemRemove:k,currentTabStopId:v}=p;return m.useEffect(()=>{if(r)return y(),()=>k()},[r,y,k]),s.jsx(ev.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:s.jsx(Nn.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:sn(e.onMouseDown,b=>{r?p.onItemFocus(f):b.preventDefault()}),onFocus:sn(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:sn(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){p.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const j=xV(b,p.orientation,p.dir);if(j!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let N=g().filter(C=>C.focusable).map(C=>C.ref.current);if(j==="last")N.reverse();else if(j==="prev"||j==="next"){j==="prev"&&N.reverse();const C=N.indexOf(b.currentTarget);N=p.loop?yV(N,C+1):N.slice(C+1)}setTimeout(()=>xP(N))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:v!=null}):a})})});gP.displayName=mP;var mV={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gV(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function xV(e,t,n){const r=gV(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return mV[r]}function xP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function yV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bV=hP,vV=gP,Vm="Tabs",[wV]=Ra(Vm,[pP]),yP=pP(),[jV,t0]=wV(Vm),bP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...f}=e,p=dP(l),[h,g]=gm({prop:r,onChange:o,defaultProp:i??"",caller:Vm});return s.jsx(jV,{scope:n,baseId:Ol(),value:h,onValueChange:g,orientation:a,dir:p,activationMode:u,children:s.jsx(Nn.div,{dir:p,"data-orientation":a,...f,ref:t})})});bP.displayName=Vm;var vP="TabsList",wP=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=t0(vP,n),a=yP(n);return s.jsx(bV,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Nn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});wP.displayName=vP;var jP="TabsTrigger",kP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=t0(jP,n),l=yP(n),u=CP(a.baseId,r),f=EP(a.baseId,r),p=r===a.value;return s.jsx(vV,{asChild:!0,...l,focusable:!o,active:p,children:s.jsx(Nn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:sn(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(r):h.preventDefault()}),onKeyDown:sn(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(r)}),onFocus:sn(e.onFocus,()=>{const h=a.activationMode!=="manual";!p&&!o&&h&&a.onValueChange(r)})})})});kP.displayName=jP;var NP="TabsContent",SP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=t0(NP,n),u=CP(l.baseId,r),f=EP(l.baseId,r),p=r===l.value,h=m.useRef(p);return m.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(Aa,{present:o||p,children:({present:g})=>s.jsx(Nn.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:f,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&i})})});SP.displayName=NP;function CP(e,t){return`${e}-trigger-${t}`}function EP(e,t){return`${e}-content-${t}`}var TP=bP,RP=wP,tv=kP,nv=SP;function Wm({value:e,onValueChange:t,items:n,className:r}){const o=m.useRef(null),[i,a]=m.useState(!1),l=m.useCallback(()=>{const u=o.current;u&&a(u.scrollLeft+u.clientWidth<u.scrollWidth-1)},[]);return m.useEffect(()=>{const u=o.current;if(!u)return;l(),u.addEventListener("scroll",l,{passive:!0});const f=new ResizeObserver(l);return f.observe(u),()=>{u.removeEventListener("scroll",l),f.disconnect()}},[l,n.length]),s.jsxs(TP,{value:e,onValueChange:t,className:r,children:[s.jsxs("div",{className:"relative",children:[s.jsx(RP,{ref:o,className:"flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(u=>s.jsxs(tv,{value:u.value,className:je("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:[s.jsx("span",{children:u.label}),typeof u.count=="number"?s.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:u.count}):null,u.problemCount&&u.problemCount>0?s.jsx("span",{className:"rounded-full bg-destructive/15 px-2 py-0.5 text-xs text-destructive","aria-label":`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,title:`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,children:u.problemCount}):null]},u.value))}),i?s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 w-8 rounded-r-md bg-gradient-to-l from-card to-transparent"}):null]}),n.map(u=>s.jsx(nv,{value:u.value,className:"pt-3",children:u.content},u.value))]})}const kV="modulepreload",NV=function(e){return"/"+e},ZN={},SV=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(n.map(f=>{if(f=NV(f),f in ZN)return;ZN[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":kV,p||(g.as="script"),g.crossOrigin="",g.href=f,u&&g.setAttribute("nonce",u),document.head.appendChild(g),p)return new Promise((y,k)=>{g.addEventListener("load",y),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};function CV({definition:e,className:t,nodeRoutes:n={}}){const r=m.useRef(null),[o,i]=m.useState(null),[a,l]=m.useState(!0),u=Wt(),f=document.documentElement.classList.contains("dark")?"dark":"default";return m.useEffect(()=>{let p=!1;async function h(){if(r.current)try{const g=(await SV(async()=>{const{default:v}=await import("./mermaid.core-UtwFYLNj.js").then(b=>b.bs);return{default:v}},[])).default;if(g.initialize({startOnLoad:!1,theme:"base",themeVariables:EV(f==="dark")}),p)return;const y=`mermaid-${Date.now()}`,{svg:k}=await g.render(y,e);if(p||!r.current)return;r.current.innerHTML=k,TV(r.current,n,u),l(!1)}catch(g){p||(i(g instanceof Error?g.message:"Failed to render graph"),l(!1))}}return l(!0),i(null),h(),()=>{p=!0}},[e,u,n,f]),o?s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[s.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),s.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),s.jsx("div",{ref:r,className:"overflow-auto"})]})}function EV(e){const t=document.documentElement,n=h=>{const g=getComputedStyle(t).getPropertyValue(h).trim();return g?`oklch(${g})`:""},r=n("--card"),o=n("--card-foreground"),i=n("--border"),a=n("--primary"),l=n("--primary-foreground"),u=n("--muted"),f=n("--muted-foreground"),p=n("--secondary");return{background:r,primaryColor:r,primaryTextColor:o,primaryBorderColor:i,secondaryColor:u,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:u,tertiaryTextColor:f,tertiaryBorderColor:i,lineColor:e?f:i,textColor:o,mainBkg:r,nodeBkg:r,nodeTextColor:o,nodeBorder:i,clusterBkg:u,clusterBorder:i,edgeLabelBackground:r,titleColor:o,activeTaskBkgColor:a,activeTaskBorderColor:a,altBackground:u,labelColor:o,errorBkgColor:p,errorTextColor:l}}function TV(e,t,n){var r;for(const o of e.querySelectorAll(".node")){const i=((r=o.textContent)==null?void 0:r.replace(/\s+/g," ").trim())??"",a=t[i];if(!a)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const l=()=>n(a);o.addEventListener("click",l),o.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l())})}}function RV(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const AV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_V={};function eS(e,t){return(_V.jsx?PV:AV).test(e)}const DV=/[ \t\n\f\r]/g;function $V(e){return typeof e=="object"?e.type==="text"?tS(e.value):!1:tS(e)}function tS(e){return e.replace(DV,"")===""}class Yd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Yd.prototype.normal={};Yd.prototype.property={};Yd.prototype.space=void 0;function AP(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Yd(n,r,t)}function rv(e){return e.toLowerCase()}class Cr{constructor(t,n){this.attribute=n,this.property=t}}Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let IV=0;const kt=_a(),bn=_a(),sv=_a(),Me=_a(),Gt=_a(),Kl=_a(),$r=_a();function _a(){return 2**++IV}const ov=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:bn,commaOrSpaceSeparated:$r,commaSeparated:Kl,number:Me,overloadedBoolean:sv,spaceSeparated:Gt},Symbol.toStringTag,{value:"Module"})),Ty=Object.keys(ov);class n0 extends Cr{constructor(t,n,r,o){let i=-1;if(super(t,n),nS(this,"space",o),typeof r=="number")for(;++i<Ty.length;){const a=Ty[i];nS(this,Ty[i],(r&ov[a])===ov[a])}}}n0.prototype.defined=!0;function nS(e,t,n){n&&(e[t]=n)}function Pc(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new n0(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[rv(r)]=r,n[rv(i.attribute)]=r}return new Yd(t,n,e.space)}const PP=Pc({properties:{ariaActiveDescendant:null,ariaAtomic:bn,ariaAutoComplete:null,ariaBusy:bn,ariaChecked:bn,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:Gt,ariaCurrent:null,ariaDescribedBy:Gt,ariaDetails:null,ariaDisabled:bn,ariaDropEffect:Gt,ariaErrorMessage:null,ariaExpanded:bn,ariaFlowTo:Gt,ariaGrabbed:bn,ariaHasPopup:null,ariaHidden:bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Gt,ariaLevel:Me,ariaLive:null,ariaModal:bn,ariaMultiLine:bn,ariaMultiSelectable:bn,ariaOrientation:null,ariaOwns:Gt,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:bn,ariaReadOnly:bn,ariaRelevant:null,ariaRequired:bn,ariaRoleDescription:Gt,ariaRowCount:Me,ariaRowIndex:Me,ariaRowSpan:Me,ariaSelected:bn,ariaSetSize:Me,ariaSort:null,ariaValueMax:Me,ariaValueMin:Me,ariaValueNow:Me,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function _P(e,t){return t in e?e[t]:t}function DP(e,t){return _P(e,t.toLowerCase())}const MV=Pc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kl,acceptCharset:Gt,accessKey:Gt,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:Gt,autoFocus:kt,autoPlay:kt,blocking:Gt,capture:null,charSet:null,checked:kt,cite:null,className:Gt,cols:Me,colSpan:null,content:null,contentEditable:bn,controls:kt,controlsList:Gt,coords:Me|Kl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:sv,draggable:bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:Gt,height:Me,hidden:sv,high:Me,href:null,hrefLang:null,htmlFor:Gt,httpEquiv:Gt,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:Gt,itemRef:Gt,itemScope:kt,itemType:Gt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,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:kt,optimum:Me,pattern:null,ping:Gt,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:Gt,required:kt,reversed:kt,rows:Me,rowSpan:Me,sandbox:Gt,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Me,sizes:null,slot:null,span:Me,spellCheck:bn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Me,step:null,style:null,tabIndex:Me,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:bn,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Gt,axis:null,background:null,bgColor:null,border:Me,borderColor:null,bottomMargin:Me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Me,rules:null,scheme:null,scrolling:bn,standby:null,summary:null,text:null,topMargin:Me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Me,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:DP}),LV=Pc({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:$r,accentHeight:Me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Me,amplitude:Me,arabicForm:null,ascent:Me,attributeName:null,attributeType:null,azimuth:Me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Me,by:null,calcMode:null,capHeight:Me,className:Gt,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:Me,diffuseConstant:Me,direction:null,display:null,dur:null,divisor:Me,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Me,enableBackground:null,end:null,event:null,exponent:Me,externalResourcesRequired:null,fill:null,fillOpacity:Me,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:Kl,g2:Kl,glyphName:Kl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Me,horizOriginX:Me,horizOriginY:Me,id:null,ideographic:Me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Me,k:Me,k1:Me,k2:Me,k3:Me,k4:Me,kernelMatrix:$r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Me,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:Me,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:Me,overlineThickness:Me,paintOrder:null,panose1:null,path:null,pathLength:Me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Gt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$r,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$r,rev:$r,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$r,requiredFeatures:$r,requiredFonts:$r,requiredFormats:$r,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:Me,specularExponent:Me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Me,strikethroughThickness:Me,string:null,stroke:null,strokeDashArray:$r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Me,strokeOpacity:Me,strokeWidth:null,style:null,surfaceScale:Me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$r,tabIndex:Me,tableValues:null,target:null,targetX:Me,targetY:Me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$r,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Me,underlineThickness:Me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Me,values:null,vAlphabetic:Me,vMathematical:Me,vectorEffect:null,vHanging:Me,vIdeographic:Me,version:null,vertAdvY:Me,vertOriginX:Me,vertOriginY:Me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:_P}),$P=Pc({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()}}),IP=Pc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:DP}),MP=Pc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),OV={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"},FV=/[A-Z]/g,rS=/-[a-z]/g,zV=/^data[-\w.:]+$/i;function BV(e,t){const n=rv(t);let r=t,o=Cr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&zV.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(rS,HV);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!rS.test(i)){let a=i.replace(FV,UV);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=n0}return new o(r,t)}function UV(e){return"-"+e.toLowerCase()}function HV(e){return e.charAt(1).toUpperCase()}const VV=AP([PP,MV,$P,IP,MP],"html"),r0=AP([PP,LV,$P,IP,MP],"svg");function WV(e){return e.join(" ").trim()}var bl={},Ry,sS;function KV(){if(sS)return Ry;sS=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
615
+ `},HB={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function VB(e){let{announcements:t=HB,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=UB}=e;const{announce:i,announcement:a}=FB(),l=zd("DndLiveRegion"),[u,f]=m.useState(!1);if(m.useEffect(()=>{f(!0)},[]),zB(m.useMemo(()=>({onDragStart(h){let{active:g}=h;i(t.onDragStart({active:g}))},onDragMove(h){let{active:g,over:y}=h;t.onDragMove&&i(t.onDragMove({active:g,over:y}))},onDragOver(h){let{active:g,over:y}=h;i(t.onDragOver({active:g,over:y}))},onDragEnd(h){let{active:g,over:y}=h;i(t.onDragEnd({active:g,over:y}))},onDragCancel(h){let{active:g,over:y}=h;i(t.onDragCancel({active:g,over:y}))}}),[i,t])),!u)return null;const p=Lt.createElement(Lt.Fragment,null,Lt.createElement(LB,{id:r,value:o.draggable}),Lt.createElement(OB,{id:l,announcement:a}));return n?Ys.createPortal(p,n):p}var $n;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})($n||($n={}));function yh(){}function ki(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function jm(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ks=Object.freeze({x:0,y:0});function AR(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function WB(e,t){const n=xh(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function PR(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function KB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function dN(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function _R(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function fN(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const km=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=fN(t,t.left,t.top),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=AR(fN(u),o);i.push({id:l,data:{droppableContainer:a,value:f}})}}return i.sort(PR)},qB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=dN(t),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=dN(u),p=o.reduce((g,y,k)=>g+AR(f[k],y),0),h=Number((p/4).toFixed(4));i.push({id:l,data:{droppableContainer:a,value:h}})}}return i.sort(PR)};function GB(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r<o&&n<i){const u=t.width*t.height,f=e.width*e.height,p=a*l,h=p/(u+f-p);return Number(h.toFixed(4))}return 0}const YB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const u=GB(l,t);u>0&&o.push({id:a,data:{droppableContainer:i,value:u}})}}return o.sort(KB)};function XB(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function DR(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ks}function QB(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,l)=>({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const JB=QB(1);function $R(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ZB(e,t,n){const r=$R(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,u=e.left-a-(1-o)*parseFloat(n),f=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),p=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:p,height:h,top:f,right:u+p,bottom:f+h,left:u}}const e8={ignoreTransform:!1};function Sc(e,t){t===void 0&&(t=e8);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:p}=ur(e).getComputedStyle(e);f&&(n=ZB(n,f,p))}const{top:r,left:o,width:i,height:a,bottom:l,right:u}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:u}}function pN(e){return Sc(e,{ignoreTransform:!0})}function t8(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function n8(e,t){return t===void 0&&(t=ur(e).getComputedStyle(e)),t.position==="fixed"}function r8(e,t){t===void 0&&(t=ur(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function Nm(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Tw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Od(o)||ER(o)||n.includes(o))return n;const i=ur(e).getComputedStyle(o);return o!==e&&r8(o,i)&&n.push(o),n8(o,i)?n:r(o.parentNode)}return e?r(e):n}function IR(e){const[t]=Nm(e,1);return t??null}function gy(e){return!bm||!e?null:kc(e)?e:Ew(e)?Tw(e)||e===Nc(e).scrollingElement?window:Od(e)?e:null:null}function MR(e){return kc(e)?e.scrollX:e.scrollLeft}function LR(e){return kc(e)?e.scrollY:e.scrollTop}function Mb(e){return{x:MR(e),y:LR(e)}}var Vn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vn||(Vn={}));function OR(e){return!bm||!e?!1:e===document.scrollingElement}function FR(e){const t={x:0,y:0},n=OR(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:l,maxScroll:r,minScroll:t}}const s8={x:.2,y:.2};function o8(e,t,n,r,o){let{top:i,left:a,right:l,bottom:u}=n;r===void 0&&(r=10),o===void 0&&(o=s8);const{isTop:f,isBottom:p,isLeft:h,isRight:g}=FR(e),y={x:0,y:0},k={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!f&&i<=t.top+v.height?(y.y=Vn.Backward,k.y=r*Math.abs((t.top+v.height-i)/v.height)):!p&&u>=t.bottom-v.height&&(y.y=Vn.Forward,k.y=r*Math.abs((t.bottom-v.height-u)/v.height)),!g&&l>=t.right-v.width?(y.x=Vn.Forward,k.x=r*Math.abs((t.right-v.width-l)/v.width)):!h&&a<=t.left+v.width&&(y.x=Vn.Backward,k.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:y,speed:k}}function i8(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function zR(e){return e.reduce((t,n)=>Ul(t,Mb(n)),ks)}function a8(e){return e.reduce((t,n)=>t+MR(n),0)}function l8(e){return e.reduce((t,n)=>t+LR(n),0)}function BR(e,t){if(t===void 0&&(t=Sc),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);IR(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const c8=[["x",["left","right"],a8],["y",["top","bottom"],l8]];class Rw{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Nm(n),o=zR(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,l]of c8)for(const u of a)Object.defineProperty(this,u,{get:()=>{const f=l(r),p=o[i]-f;return this.rect[u]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ku{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function u8(e){const{EventTarget:t}=ur(e);return e instanceof t?e:Nc(e)}function xy(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Zr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Zr||(Zr={}));function hN(e){e.preventDefault()}function d8(e){e.stopPropagation()}var At;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(At||(At={}));const UR={start:[At.Space,At.Enter],cancel:[At.Esc],end:[At.Space,At.Enter,At.Tab]},f8=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case At.Right:return{...n,x:n.x+25};case At.Left:return{...n,x:n.x-25};case At.Down:return{...n,y:n.y+25};case At.Up:return{...n,y:n.y-25}}};class Cc{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ku(Nc(n)),this.windowListeners=new Ku(ur(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&BR(r),n(ks)}handleKeyDown(t){if(wm(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=UR,coordinateGetter:a=f8,scrollBehavior:l="smooth"}=o,{code:u}=t;if(i.end.includes(u)){this.handleEnd(t);return}if(i.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:f}=r.current,p=f?{x:f.left,y:f.top}:ks;this.referenceCoordinates||(this.referenceCoordinates=p);const h=a(t,{active:n,context:r.current,currentCoordinates:p});if(h){const g=cd(h,p),y={x:0,y:0},{scrollableAncestors:k}=r.current;for(const v of k){const b=t.code,{isTop:j,isRight:S,isLeft:N,isBottom:C,maxScroll:P,minScroll:T}=FR(v),R=i8(v),I={x:Math.min(b===At.Right?R.right-R.width/2:R.right,Math.max(b===At.Right?R.left:R.left+R.width/2,h.x)),y:Math.min(b===At.Down?R.bottom-R.height/2:R.bottom,Math.max(b===At.Down?R.top:R.top+R.height/2,h.y))},_=b===At.Right&&!S||b===At.Left&&!N,F=b===At.Down&&!C||b===At.Up&&!j;if(_&&I.x!==h.x){const D=v.scrollLeft+g.x,W=b===At.Right&&D<=P.x||b===At.Left&&D>=T.x;if(W&&!g.y){v.scrollTo({left:D,behavior:l});return}W?y.x=v.scrollLeft-D:y.x=b===At.Right?v.scrollLeft-P.x:v.scrollLeft-T.x,y.x&&v.scrollBy({left:-y.x,behavior:l});break}else if(F&&I.y!==h.y){const D=v.scrollTop+g.y,W=b===At.Down&&D<=P.y||b===At.Up&&D>=T.y;if(W&&!g.x){v.scrollTo({top:D,behavior:l});return}W?y.y=v.scrollTop-D:y.y=b===At.Down?v.scrollTop-P.y:v.scrollTop-T.y,y.y&&v.scrollBy({top:-y.y,behavior:l});break}}this.handleMove(t,Ul(cd(h,this.referenceCoordinates),y))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Cc.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=UR,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function mN(e){return!!(e&&"distance"in e)}function gN(e){return!!(e&&"delay"in e)}class Aw{constructor(t,n,r){var o;r===void 0&&(r=u8(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=Nc(a),this.documentListeners=new Ku(this.document),this.listeners=new Ku(r),this.windowListeners=new Ku(ur(a)),this.initialCoordinates=(o=xh(i))!=null?o:ks,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.DragStart,hN),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),this.windowListeners.add(Zr.ContextMenu,hN),this.documentListeners.add(Zr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gN(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(mN(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Zr.Click,d8,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:l}}=i;if(!o)return;const u=(n=xh(t))!=null?n:ks,f=cd(o,u);if(!r&&l){if(mN(l)){if(l.tolerance!=null&&xy(f,l.tolerance))return this.handleCancel();if(xy(f,l.distance))return this.handleStart()}if(gN(l)&&xy(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),a(u)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===At.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const p8={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ec extends Aw{constructor(t){const{event:n}=t,r=Nc(n.target);super(t,p8,r)}}Ec.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const h8={move:{name:"mousemove"},end:{name:"mouseup"}};var Lb;(function(e){e[e.RightClick=2]="RightClick"})(Lb||(Lb={}));class m8 extends Aw{constructor(t){super(t,h8,Nc(t.event.target))}}m8.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Lb.RightClick?!1:(r==null||r({event:n}),!0)}}];const yy={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class g8 extends Aw{constructor(t){super(t,yy)}static setup(){return window.addEventListener(yy.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(yy.move.name,t)};function t(){}}}g8.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var qu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qu||(qu={}));var bh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bh||(bh={}));function x8(e){let{acceleration:t,activator:n=qu.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=bh.TreeOrder,pointerCoordinates:u,scrollableAncestors:f,scrollableAncestorRects:p,delta:h,threshold:g}=e;const y=b8({delta:h,disabled:!i}),[k,v]=_B(),b=m.useRef({x:0,y:0}),j=m.useRef({x:0,y:0}),S=m.useMemo(()=>{switch(n){case qu.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case qu.DraggableRect:return o}},[n,o,u]),N=m.useRef(null),C=m.useCallback(()=>{const T=N.current;if(!T)return;const R=b.current.x*j.current.x,I=b.current.y*j.current.y;T.scrollBy(R,I)},[]),P=m.useMemo(()=>l===bh.TreeOrder?[...f].reverse():f,[l,f]);m.useEffect(()=>{if(!i||!f.length||!S){v();return}for(const T of P){if((r==null?void 0:r(T))===!1)continue;const R=f.indexOf(T),I=p[R];if(!I)continue;const{direction:_,speed:F}=o8(T,I,S,t,g);for(const D of["x","y"])y[D][_[D]]||(F[D]=0,_[D]=0);if(F.x>0||F.y>0){v(),N.current=T,k(C,a),b.current=F,j.current=_;return}}b.current={x:0,y:0},j.current={x:0,y:0},v()},[t,C,r,v,i,a,JSON.stringify(S),JSON.stringify(y),k,f,P,p,JSON.stringify(g)])}const y8={x:{[Vn.Backward]:!1,[Vn.Forward]:!1},y:{[Vn.Backward]:!1,[Vn.Forward]:!1}};function b8(e){let{delta:t,disabled:n}=e;const r=gh(t);return Fd(o=>{if(n||!r||!o)return y8;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Vn.Backward]:o.x[Vn.Backward]||i.x===-1,[Vn.Forward]:o.x[Vn.Forward]||i.x===1},y:{[Vn.Backward]:o.y[Vn.Backward]||i.y===-1,[Vn.Forward]:o.y[Vn.Forward]||i.y===1}}},[n,t,r])}function v8(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fd(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function w8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var ud;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(ud||(ud={}));var Ob;(function(e){e.Optimized="optimized"})(Ob||(Ob={}));const xN=new Map;function j8(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=m.useState(null),{frequency:l,measure:u,strategy:f}=o,p=m.useRef(e),h=b(),g=ld(h),y=m.useCallback(function(j){j===void 0&&(j=[]),!g.current&&a(S=>S===null?j:S.concat(j.filter(N=>!S.includes(N))))},[g]),k=m.useRef(null),v=Fd(j=>{if(h&&!n)return xN;if(!j||j===xN||p.current!==e||i!=null){const S=new Map;for(let N of e){if(!N)continue;if(i&&i.length>0&&!i.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const C=N.node.current,P=C?new Rw(u(C),C):null;N.rect.current=P,P&&S.set(N.id,P)}return S}return j},[e,i,n,h,u]);return m.useEffect(()=>{p.current=e},[e]),m.useEffect(()=>{h||y()},[n,h]),m.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),m.useEffect(()=>{h||typeof l!="number"||k.current!==null||(k.current=setTimeout(()=>{y(),k.current=null},l))},[l,h,y,...r]),{droppableRects:v,measureDroppableContainers:y,measuringScheduled:i!=null};function b(){switch(f){case ud.Always:return!1;case ud.BeforeDragging:return n;default:return!n}}}function Pw(e,t){return Fd(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function k8(e,t){return Pw(e,t)}function N8(e){let{callback:t,disabled:n}=e;const r=vm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Sm(e){let{callback:t,disabled:n}=e;const r=vm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function S8(e){return new Rw(Sc(e),e)}function yN(e,t,n){t===void 0&&(t=S8);const[r,o]=m.useState(null);function i(){o(u=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=u??n)!=null?f:null}const p=t(e);return JSON.stringify(u)===JSON.stringify(p)?u:p})}const a=N8({callback(u){if(e)for(const f of u){const{type:p,target:h}=f;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=Sm({callback:i});return ws(()=>{i(),e?(l==null||l.observe(e),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[e]),r}function C8(e){const t=Pw(e);return DR(e,t)}const bN=[];function E8(e){const t=m.useRef(e),n=Fd(r=>e?r&&r!==bN&&e&&t.current&&e.parentNode===t.current.parentNode?r:Nm(e):bN,[e]);return m.useEffect(()=>{t.current=e},[e]),n}function T8(e){const[t,n]=m.useState(null),r=m.useRef(e),o=m.useCallback(i=>{const a=gy(i.target);a&&n(l=>l?(l.set(a,Mb(a)),new Map(l)):null)},[]);return m.useEffect(()=>{const i=r.current;if(e!==i){a(i);const l=e.map(u=>{const f=gy(u);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,Mb(f)]):null}).filter(u=>u!=null);n(l.length?new Map(l):null),r.current=e}return()=>{a(e),a(i)};function a(l){l.forEach(u=>{const f=gy(u);f==null||f.removeEventListener("scroll",o)})}},[o,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>Ul(i,a),ks):zR(e):ks,[e,t])}function vN(e,t){t===void 0&&(t=[]);const n=m.useRef(null);return m.useEffect(()=>{n.current=null},t),m.useEffect(()=>{const r=e!==ks;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?cd(e,n.current):ks}function R8(e){m.useEffect(()=>{if(!bm)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function A8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function HR(e){return m.useMemo(()=>e?t8(e):null,[e])}const wN=[];function P8(e,t){t===void 0&&(t=Sc);const[n]=e,r=HR(n?ur(n):null),[o,i]=m.useState(wN);function a(){i(()=>e.length?e.map(u=>OR(u)?r:new Rw(t(u),u)):wN)}const l=Sm({callback:a});return ws(()=>{l==null||l.disconnect(),a(),e.forEach(u=>l==null?void 0:l.observe(u))},[e]),o}function VR(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Od(t)?t:e}function _8(e){let{measure:t}=e;const[n,r]=m.useState(null),o=m.useCallback(f=>{for(const{target:p}of f)if(Od(p)){r(h=>{const g=t(p);return h?{...h,width:g.width,height:g.height}:g});break}},[t]),i=Sm({callback:o}),a=m.useCallback(f=>{const p=VR(f);i==null||i.disconnect(),p&&(i==null||i.observe(p)),r(p?t(p):null)},[t,i]),[l,u]=mh(a);return m.useMemo(()=>({nodeRef:l,rect:n,setRef:u}),[n,l,u])}const D8=[{sensor:Ec,options:{}},{sensor:Cc,options:{}}],$8={current:{}},Wp={draggable:{measure:pN},droppable:{measure:pN,strategy:ud.WhileDragging,frequency:Ob.Optimized},dragOverlay:{measure:Sc}};class Gu extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const I8={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Gu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:yh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Wp,measureDroppableContainers:yh,windowRect:null,measuringScheduled:!1},WR={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:yh,draggableNodes:new Map,over:null,measureDroppableContainers:yh},Bd=m.createContext(WR),KR=m.createContext(I8);function M8(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Gu}}}function L8(e,t){switch(t.type){case $n.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $n.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case $n.DragEnd:case $n.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $n.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Gu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $n.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Gu(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case $n.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Gu(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function O8(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=m.useContext(Bd),i=gh(r),a=gh(n==null?void 0:n.id);return m.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!wm(i)||document.activeElement===i.target)return;const l=o.get(a);if(!l)return;const{activatorNode:u,node:f}=l;if(!u.current&&!f.current)return;requestAnimationFrame(()=>{for(const p of[u.current,f.current]){if(!p)continue;const h=IB(p);if(h){h.focus();break}}})}},[r,t,o,a,i]),null}function qR(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function F8(e){return m.useMemo(()=>({draggable:{...Wp.draggable,...e==null?void 0:e.draggable},droppable:{...Wp.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Wp.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function z8(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=m.useRef(!1),{x:a,y:l}=typeof o=="boolean"?{x:o,y:o}:o;ws(()=>{if(!a&&!l||!t){i.current=!1;return}if(i.current||!r)return;const f=t==null?void 0:t.node.current;if(!f||f.isConnected===!1)return;const p=n(f),h=DR(p,r);if(a||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=IR(f);g&&g.scrollBy({top:h.y,left:h.x})}},[t,a,l,r,n])}const Cm=m.createContext({...ks,scaleX:1,scaleY:1});var xi;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(xi||(xi={}));const Em=m.memo(function(t){var n,r,o,i;let{id:a,accessibility:l,autoScroll:u=!0,children:f,sensors:p=D8,collisionDetection:h=YB,measuring:g,modifiers:y,...k}=t;const v=m.useReducer(L8,void 0,M8),[b,j]=v,[S,N]=BB(),[C,P]=m.useState(xi.Uninitialized),T=C===xi.Initialized,{draggable:{active:R,nodes:I,translate:_},droppable:{containers:F}}=b,D=R!=null?I.get(R):null,W=m.useRef({initial:null,translated:null}),H=m.useMemo(()=>{var lt;return R!=null?{id:R,data:(lt=D==null?void 0:D.data)!=null?lt:$8,rect:W}:null},[R,D]),$=m.useRef(null),[O,U]=m.useState(null),[K,M]=m.useState(null),V=ld(k,Object.values(k)),L=zd("DndDescribedBy",a),z=m.useMemo(()=>F.getEnabled(),[F]),Y=F8(g),{droppableRects:B,measureDroppableContainers:Q,measuringScheduled:J}=j8(z,{dragging:T,dependencies:[_.x,_.y],config:Y.droppable}),Z=v8(I,R),oe=m.useMemo(()=>K?xh(K):null,[K]),ne=ze(),ue=k8(Z,Y.draggable.measure);z8({activeNode:R!=null?I.get(R):null,config:ne.layoutShiftCompensation,initialRect:ue,measure:Y.draggable.measure});const ge=yN(Z,Y.draggable.measure,ue),Ce=yN(Z?Z.parentElement:null),Ne=m.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ke=F.getNodeFor((n=Ne.current.over)==null?void 0:n.id),Ue=_8({measure:Y.dragOverlay.measure}),ie=(r=Ue.nodeRef.current)!=null?r:Z,ve=T?(o=Ue.rect)!=null?o:ge:null,be=!!(Ue.nodeRef.current&&Ue.rect),Re=C8(be?null:ge),He=HR(ie?ur(ie):null),rt=E8(T?ke??Z:null),Fe=P8(rt),ot=qR(y,{transform:{x:_.x-Re.x,y:_.y-Re.y,scaleX:1,scaleY:1},activatorEvent:K,active:H,activeNodeRect:ge,containerNodeRect:Ce,draggingNodeRect:ve,over:Ne.current.over,overlayNodeRect:Ue.rect,scrollableAncestors:rt,scrollableAncestorRects:Fe,windowRect:He}),St=oe?Ul(oe,_):null,mt=T8(rt),at=vN(mt),ce=vN(mt,[ge]),me=Ul(ot,at),Ie=ve?JB(ve,ot):null,Ae=H&&Ie?h({active:H,collisionRect:Ie,droppableRects:B,droppableContainers:z,pointerCoordinates:St}):null,We=_R(Ae,"id"),[pt,_e]=m.useState(null),Qe=be?ot:Ul(ot,ce),Je=XB(Qe,(i=pt==null?void 0:pt.rect)!=null?i:null,ge),ut=m.useRef(null),fe=m.useCallback((lt,ht)=>{let{sensor:vt,options:tt}=ht;if($.current==null)return;const Dt=I.get($.current);if(!Dt)return;const zt=lt.nativeEvent,Bt=new vt({active:$.current,activeNode:Dt,event:zt,options:tt,context:Ne,onAbort(Oe){if(!I.get(Oe))return;const{onDragAbort:Et}=V.current,ln={id:Oe};Et==null||Et(ln),S({type:"onDragAbort",event:ln})},onPending(Oe,it,Et,ln){if(!I.get(Oe))return;const{onDragPending:le}=V.current,Se={id:Oe,constraint:it,initialCoordinates:Et,offset:ln};le==null||le(Se),S({type:"onDragPending",event:Se})},onStart(Oe){const it=$.current;if(it==null)return;const Et=I.get(it);if(!Et)return;const{onDragStart:ln}=V.current,Ut={activatorEvent:zt,active:{id:it,data:Et.data,rect:W}};Ys.unstable_batchedUpdates(()=>{ln==null||ln(Ut),P(xi.Initializing),j({type:$n.DragStart,initialCoordinates:Oe,active:it}),S({type:"onDragStart",event:Ut}),U(ut.current),M(zt)})},onMove(Oe){j({type:$n.DragMove,coordinates:Oe})},onEnd:we($n.DragEnd),onCancel:we($n.DragCancel)});ut.current=Bt;function we(Oe){return async function(){const{active:Et,collisions:ln,over:Ut,scrollAdjustedTranslate:le}=Ne.current;let Se=null;if(Et&&le){const{cancelDrop:nt}=V.current;Se={activatorEvent:zt,active:Et,collisions:ln,delta:le,over:Ut},Oe===$n.DragEnd&&typeof nt=="function"&&await Promise.resolve(nt(Se))&&(Oe=$n.DragCancel)}$.current=null,Ys.unstable_batchedUpdates(()=>{j({type:Oe}),P(xi.Uninitialized),_e(null),U(null),M(null),ut.current=null;const nt=Oe===$n.DragEnd?"onDragEnd":"onDragCancel";if(Se){const Tn=V.current[nt];Tn==null||Tn(Se),S({type:nt,event:Se})}})}}},[I]),q=m.useCallback((lt,ht)=>(vt,tt)=>{const Dt=vt.nativeEvent,zt=I.get(tt);if($.current!==null||!zt||Dt.dndKit||Dt.defaultPrevented)return;const Bt={active:zt};lt(vt,ht.options,Bt)===!0&&(Dt.dndKit={capturedBy:ht.sensor},$.current=tt,fe(vt,ht))},[I,fe]),re=w8(p,q);R8(p),ws(()=>{ge&&C===xi.Initializing&&P(xi.Initialized)},[ge,C]),m.useEffect(()=>{const{onDragMove:lt}=V.current,{active:ht,activatorEvent:vt,collisions:tt,over:Dt}=Ne.current;if(!ht||!vt)return;const zt={active:ht,activatorEvent:vt,collisions:tt,delta:{x:me.x,y:me.y},over:Dt};Ys.unstable_batchedUpdates(()=>{lt==null||lt(zt),S({type:"onDragMove",event:zt})})},[me.x,me.y]),m.useEffect(()=>{const{active:lt,activatorEvent:ht,collisions:vt,droppableContainers:tt,scrollAdjustedTranslate:Dt}=Ne.current;if(!lt||$.current==null||!ht||!Dt)return;const{onDragOver:zt}=V.current,Bt=tt.get(We),we=Bt&&Bt.rect.current?{id:Bt.id,rect:Bt.rect.current,data:Bt.data,disabled:Bt.disabled}:null,Oe={active:lt,activatorEvent:ht,collisions:vt,delta:{x:Dt.x,y:Dt.y},over:we};Ys.unstable_batchedUpdates(()=>{_e(we),zt==null||zt(Oe),S({type:"onDragOver",event:Oe})})},[We]),ws(()=>{Ne.current={activatorEvent:K,active:H,activeNode:Z,collisionRect:Ie,collisions:Ae,droppableRects:B,draggableNodes:I,draggingNode:ie,draggingNodeRect:ve,droppableContainers:F,over:pt,scrollableAncestors:rt,scrollAdjustedTranslate:me},W.current={initial:ve,translated:Ie}},[H,Z,Ae,Ie,I,ie,ve,B,F,pt,rt,me]),x8({...ne,delta:_,draggingRect:Ie,pointerCoordinates:St,scrollableAncestors:rt,scrollableAncestorRects:Fe});const xe=m.useMemo(()=>({active:H,activeNode:Z,activeNodeRect:ge,activatorEvent:K,collisions:Ae,containerNodeRect:Ce,dragOverlay:Ue,draggableNodes:I,droppableContainers:F,droppableRects:B,over:pt,measureDroppableContainers:Q,scrollableAncestors:rt,scrollableAncestorRects:Fe,measuringConfiguration:Y,measuringScheduled:J,windowRect:He}),[H,Z,ge,K,Ae,Ce,Ue,I,F,B,pt,Q,rt,Fe,Y,J,He]),Ge=m.useMemo(()=>({activatorEvent:K,activators:re,active:H,activeNodeRect:ge,ariaDescribedById:{draggable:L},dispatch:j,draggableNodes:I,over:pt,measureDroppableContainers:Q}),[K,re,H,ge,j,L,I,pt,Q]);return Lt.createElement(RR.Provider,{value:N},Lt.createElement(Bd.Provider,{value:Ge},Lt.createElement(KR.Provider,{value:xe},Lt.createElement(Cm.Provider,{value:Je},f)),Lt.createElement(O8,{disabled:(l==null?void 0:l.restoreFocus)===!1})),Lt.createElement(VB,{...l,hiddenTextDescribedById:L}));function ze(){const lt=(O==null?void 0:O.autoScrollEnabled)===!1,ht=typeof u=="object"?u.enabled===!1:u===!1,vt=T&&!lt&&!ht;return typeof u=="object"?{...u,enabled:vt}:{enabled:vt}}}),B8=m.createContext(null),jN="button",U8="Draggable";function H8(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=zd(U8),{activators:a,activatorEvent:l,active:u,activeNodeRect:f,ariaDescribedById:p,draggableNodes:h,over:g}=m.useContext(Bd),{role:y=jN,roleDescription:k="draggable",tabIndex:v=0}=o??{},b=(u==null?void 0:u.id)===t,j=m.useContext(b?Cm:B8),[S,N]=mh(),[C,P]=mh(),T=A8(a,t),R=ld(n);ws(()=>(h.set(t,{id:t,key:i,node:S,activatorNode:C,data:R}),()=>{const _=h.get(t);_&&_.key===i&&h.delete(t)}),[h,t]);const I=m.useMemo(()=>({role:y,tabIndex:v,"aria-disabled":r,"aria-pressed":b&&y===jN?!0:void 0,"aria-roledescription":k,"aria-describedby":p.draggable}),[r,y,v,b,k,p.draggable]);return{active:u,activatorEvent:l,activeNodeRect:f,attributes:I,isDragging:b,listeners:r?void 0:T,node:S,over:g,setNodeRef:N,setActivatorNodeRef:P,transform:j}}function GR(){return m.useContext(KR)}const V8="Droppable",W8={timeout:25};function K8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=zd(V8),{active:a,dispatch:l,over:u,measureDroppableContainers:f}=m.useContext(Bd),p=m.useRef({disabled:n}),h=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),{disabled:k,updateMeasurementsFor:v,timeout:b}={...W8,...o},j=ld(v??r),S=m.useCallback(()=>{if(!h.current){h.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{f(Array.isArray(j.current)?j.current:[j.current]),y.current=null},b)},[b]),N=Sm({callback:S,disabled:k||!a}),C=m.useCallback((I,_)=>{N&&(_&&(N.unobserve(_),h.current=!1),I&&N.observe(I))},[N]),[P,T]=mh(C),R=ld(t);return m.useEffect(()=>{!N||!P.current||(N.disconnect(),h.current=!1,N.observe(P.current))},[P,N]),m.useEffect(()=>(l({type:$n.RegisterDroppable,element:{id:r,key:i,disabled:n,node:P,rect:g,data:R}}),()=>l({type:$n.UnregisterDroppable,key:i,id:r})),[r]),m.useEffect(()=>{n!==p.current.disabled&&(l({type:$n.SetDroppableDisabled,id:r,key:i,disabled:n}),p.current.disabled=n)},[r,i,n,l]),{active:a,rect:g,isOver:(u==null?void 0:u.id)===r,node:P,over:u,setNodeRef:T}}function q8(e){let{animation:t,children:n}=e;const[r,o]=m.useState(null),[i,a]=m.useState(null),l=gh(n);return!n&&!r&&l&&o(l),ws(()=>{if(!i)return;const u=r==null?void 0:r.key,f=r==null?void 0:r.props.id;if(u==null||f==null){o(null);return}Promise.resolve(t(f,i)).then(()=>{o(null)})},[t,r,i]),Lt.createElement(Lt.Fragment,null,n,r?m.cloneElement(r,{ref:a}):null)}const G8={x:0,y:0,scaleX:1,scaleY:1};function Y8(e){let{children:t}=e;return Lt.createElement(Bd.Provider,{value:WR},Lt.createElement(Cm.Provider,{value:G8},t))}const X8={position:"fixed",touchAction:"none"},Q8=e=>wm(e)?"transform 250ms ease":void 0,J8=m.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:l,style:u,transform:f,transition:p=Q8}=e;if(!l)return null;const h=o?f:{...f,scaleX:1,scaleY:1},g={...X8,width:l.width,height:l.height,top:l.top,left:l.left,transform:js.Transform.toString(h),transformOrigin:o&&r?WB(r,l):void 0,transition:typeof p=="function"?p(r):p,...u};return Lt.createElement(n,{className:a,style:g,ref:t},i)}),Z8=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(i!=null&&i.active)for(const[l,u]of Object.entries(i.active))u!==void 0&&(o[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,u));if(i!=null&&i.dragOverlay)for(const[l,u]of Object.entries(i.dragOverlay))u!==void 0&&r.node.style.setProperty(l,u);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[u,f]of Object.entries(o))n.node.style.setProperty(u,f);a!=null&&a.active&&n.node.classList.remove(a.active)}},e7=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:js.Transform.toString(t)},{transform:js.Transform.toString(n)}]},t7={duration:250,easing:"ease",keyframes:e7,sideEffects:Z8({styles:{active:{opacity:"0"}}})};function n7(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return vm((i,a)=>{if(t===null)return;const l=n.get(i);if(!l)return;const u=l.node.current;if(!u)return;const f=VR(a);if(!f)return;const{transform:p}=ur(a).getComputedStyle(a),h=$R(p);if(!h)return;const g=typeof t=="function"?t:r7(t);return BR(u,o.draggable.measure),g({active:{id:i,data:l.data,node:u,rect:o.draggable.measure(u)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(f)},droppableContainers:r,measuringConfiguration:o,transform:h})})}function r7(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...t7,...e};return i=>{let{active:a,dragOverlay:l,transform:u,...f}=i;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},h={scaleX:u.scaleX!==1?a.rect.width*u.scaleX/l.rect.width:1,scaleY:u.scaleY!==1?a.rect.height*u.scaleY/l.rect.height:1},g={x:u.x-p.x,y:u.y-p.y,...h},y=o({...f,active:a,dragOverlay:l,transform:{initial:u,final:g}}),[k]=y,v=y[y.length-1];if(JSON.stringify(k)===JSON.stringify(v))return;const b=r==null?void 0:r({active:a,dragOverlay:l,...f}),j=l.node.animate(y,{duration:t,easing:n,fill:"forwards"});return new Promise(S=>{j.onfinish=()=>{b==null||b(),S()}})}}let kN=0;function s7(e){return m.useMemo(()=>{if(e!=null)return kN++,kN},[e])}const o7=Lt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:l="div",className:u,zIndex:f=999}=e;const{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggableNodes:k,droppableContainers:v,dragOverlay:b,over:j,measuringConfiguration:S,scrollableAncestors:N,scrollableAncestorRects:C,windowRect:P}=GR(),T=m.useContext(Cm),R=s7(h==null?void 0:h.id),I=qR(a,{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggingNodeRect:b.rect,over:j,overlayNodeRect:b.rect,scrollableAncestors:N,scrollableAncestorRects:C,transform:T,windowRect:P}),_=Pw(g),F=n7({config:r,draggableNodes:k,droppableContainers:v,measuringConfiguration:S}),D=_?b.setRef:void 0;return Lt.createElement(Y8,null,Lt.createElement(q8,{animation:F},h&&R?Lt.createElement(J8,{key:R,id:h.id,ref:D,as:l,activatorEvent:p,adjustScale:t,className:u,transition:i,rect:_,style:{zIndex:f,...o},transform:I},n):null))});function Tc(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function i7(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function fp(e){return e!==null&&e>=0}function a7(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function l7(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const _w=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Tc(t,r,n),a=t[o],l=i[o];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},pp={scaleX:1,scaleY:1},Dw=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=(t=i[n])!=null?t:r;if(!l)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(l.top+l.height):f.top-l.top,...pp}:null}const u=c7(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-u,...pp}:o<n&&o>=a?{x:0,y:l.height+u,...pp}:{x:0,y:0,...pp}};function c7(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const YR="Sortable",XR=Lt.createContext({activeIndex:-1,containerId:YR,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:_w,disabled:{draggable:!1,droppable:!1}});function Tm(e){let{children:t,id:n,items:r,strategy:o=_w,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:u,over:f,measureDroppableContainers:p}=GR(),h=zd(YR,n),g=l.rect!==null,y=m.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),k=a!=null,v=a?y.indexOf(a.id):-1,b=f?y.indexOf(f.id):-1,j=m.useRef(y),S=!a7(y,j.current),N=b!==-1&&v===-1||S,C=l7(i);ws(()=>{S&&k&&p(y)},[S,y,k,p]),m.useEffect(()=>{j.current=y},[y]);const P=m.useMemo(()=>({activeIndex:v,containerId:h,disabled:C,disableTransforms:N,items:y,overIndex:b,useDragOverlay:g,sortedRects:i7(y,u),strategy:o}),[v,h,C.draggable,C.droppable,N,y,b,u,g,o]);return Lt.createElement(XR.Provider,{value:P},t)}const u7=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Tc(n,r,o).indexOf(t)},d7=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:u,transition:f}=e;return!f||!r||l!==i&&o===a?!1:n?!0:a!==o&&t===u},f7={duration:200,easing:"ease"},QR="transform",p7=js.Transition.toString({property:QR,duration:0,easing:"linear"}),h7={roleDescription:"sortable"};function m7(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=m.useState(null),l=m.useRef(n);return ws(()=>{if(!t&&n!==l.current&&r.current){const u=o.current;if(u){const f=Sc(r.current,{ignoreTransform:!0}),p={x:u.left-f.left,y:u.top-f.top,scaleX:u.width/f.width,scaleY:u.height/f.height};(p.x||p.y)&&a(p)}}n!==l.current&&(l.current=n)},[t,n,r,o]),m.useEffect(()=>{i&&a(null)},[i]),i}function Rm(e){let{animateLayoutChanges:t=d7,attributes:n,disabled:r,data:o,getNewIndex:i=u7,id:a,strategy:l,resizeObserverConfig:u,transition:f=f7}=e;const{items:p,containerId:h,activeIndex:g,disabled:y,disableTransforms:k,sortedRects:v,overIndex:b,useDragOverlay:j,strategy:S}=m.useContext(XR),N=g7(r,y),C=p.indexOf(a),P=m.useMemo(()=>({sortable:{containerId:h,index:C,items:p},...o}),[h,o,C,p]),T=m.useMemo(()=>p.slice(p.indexOf(a)),[p,a]),{rect:R,node:I,isOver:_,setNodeRef:F}=K8({id:a,data:P,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...u}}),{active:D,activatorEvent:W,activeNodeRect:H,attributes:$,setNodeRef:O,listeners:U,isDragging:K,over:M,setActivatorNodeRef:V,transform:L}=H8({id:a,data:P,attributes:{...h7,...n},disabled:N.draggable}),z=PB(F,O),Y=!!D,B=Y&&!k&&fp(g)&&fp(b),Q=!j&&K,J=Q&&B?L:null,oe=B?J??(l??S)({rects:v,activeNodeRect:H,activeIndex:g,overIndex:b,index:C}):null,ne=fp(g)&&fp(b)?i({id:a,items:p,activeIndex:g,overIndex:b}):C,ue=D==null?void 0:D.id,ge=m.useRef({activeId:ue,items:p,newIndex:ne,containerId:h}),Ce=p!==ge.current.items,Ne=t({active:D,containerId:h,isDragging:K,isSorting:Y,id:a,index:C,items:p,newIndex:ge.current.newIndex,previousItems:ge.current.items,previousContainerId:ge.current.containerId,transition:f,wasDragging:ge.current.activeId!=null}),ke=m7({disabled:!Ne,index:C,node:I,rect:R});return m.useEffect(()=>{Y&&ge.current.newIndex!==ne&&(ge.current.newIndex=ne),h!==ge.current.containerId&&(ge.current.containerId=h),p!==ge.current.items&&(ge.current.items=p)},[Y,ne,h,p]),m.useEffect(()=>{if(ue===ge.current.activeId)return;if(ue!=null&&ge.current.activeId==null){ge.current.activeId=ue;return}const ie=setTimeout(()=>{ge.current.activeId=ue},50);return()=>clearTimeout(ie)},[ue]),{active:D,activeIndex:g,attributes:$,data:P,rect:R,index:C,newIndex:ne,items:p,isOver:_,isSorting:Y,isDragging:K,listeners:U,node:I,overIndex:b,over:M,setNodeRef:z,setActivatorNodeRef:V,setDroppableNodeRef:F,setDraggableNodeRef:O,transform:ke??oe,transition:Ue()};function Ue(){if(ke||Ce&&ge.current.newIndex===C)return p7;if(!(Q&&!wm(W)||!f)&&(Y||Ne))return js.Transition.toString({...f,property:QR})}}function g7(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function vh(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const x7=[At.Down,At.Right,At.Up,At.Left],JR=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(x7.includes(e.code)){if(e.preventDefault(),!n||!r)return;const u=[];i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=o.get(h.id);if(g)switch(e.code){case At.Down:r.top<g.top&&u.push(h);break;case At.Up:r.top>g.top&&u.push(h);break;case At.Left:r.left>g.left&&u.push(h);break;case At.Right:r.left<g.left&&u.push(h);break}});const f=qB({collisionRect:r,droppableRects:o,droppableContainers:u});let p=_R(f,"id");if(p===(a==null?void 0:a.id)&&f.length>1&&(p=f[1].id),p!=null){const h=i.get(n.id),g=i.get(p),y=g?o.get(g.id):null,k=g==null?void 0:g.node.current;if(k&&y&&h&&g){const b=Nm(k).some((T,R)=>l[R]!==T),j=ZR(h,g),S=y7(h,g),N=b||!j?{x:0,y:0}:{x:S?r.width-y.width:0,y:S?r.height-y.height:0},C={x:y.left,y:y.top};return N.x&&N.y?C:cd(C,N)}}}};function ZR(e,t){return!vh(e)||!vh(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function y7(e,t){return!vh(e)||!vh(t)||!ZR(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function bt({label:e="Loading dashboard data…"}){return s.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:s.jsx("div",{className:"chrome-card !px-4 !py-3",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function Rt({title:e="Something went wrong",error:t,action:n,onRetry:r,retryLabel:o="Retry"}){const i=n??(r?s.jsxs("button",{type:"button",onClick:r,className:"shell-action",children:[s.jsx(M4,{className:"h-4 w-4"}),s.jsx("span",{children:o})]}):null);return s.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),i?s.jsx("div",{className:"pt-2",children:i}):null]})})}function Kp({command:e,description:t,example:n}){return s.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[s.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?s.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function Ke({title:e,description:t,children:n,className:r,actions:o}){return s.jsxs("section",{className:je("surface-panel space-y-3",r),children:[e||o?s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?s.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),o]}):null,n]})}function b7({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return s.jsx(Ke,{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:s.jsx($e,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:s.jsx("div",{className:"space-y-3",children:n.map((r,o)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:o+1}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:r.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:r.detail}),r.command?s.jsx(Kp,{command:r.command.command,example:r.command.example}):null]})]})},r.title))})})}const by={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."},ha={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 v7(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function w7({hero:e,itemsById:t}){const n=gn();if(e.kind==="clean")return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:ha.emptyStateCleanTitle}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:by.clean}),s.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."}),s.jsx("div",{className:"mt-4",children:s.jsx($e,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:ha.emptyStateCleanCTA})})]});const r=e.itemId?t[e.itemId]:void 0,o=(r==null?void 0:r.assignmentTitle)??"",i=by[e.copyKey]??by[e.kind],a=v7(i,{total:e.total,title:o}),l=r?j7(r,n):`${n}/assignments`;return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:"Top priority"}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:a}),r?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",s.jsx("span",{className:"font-medium text-foreground",children:r.projectTitle??"Standalone"})," ","· status ",s.jsx("span",{className:"font-medium text-foreground",children:r.status})]}):null,s.jsx("div",{className:"mt-4",children:s.jsxs($e,{to:l,className:"shell-action shell-action--cta",children:["Open ",o||"assignment"]})})]})}function j7(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const vy=["title","status","priority","assignee","dependencies","created","updated"],dd=24,eA=60;function k7(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isInteger(t.w)&&t.w>=1&&t.w<=dd&&Number.isInteger(t.h)&&t.h>=1&&t.h<=eA}const N7={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},NN="2026-05-21T00:00:00Z";function wy(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...N7,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:NN,updatedAt:NN}}const vi={version:1,views:[wy("default-recently-updated","Recently updated",{}),wy("default-high-priority","High priority",{priority:"high"}),wy("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 tA(e,t){const n=Ve(e.filters.project),r=n.length===0||n.length===1&&n[0]===t,o=e.filters.activity,i=typeof e.filters.search=="string"&&e.filters.search.trim().length>0,a=e.filters.query,l=typeof a=="string"&&a.trim().length>0&&Hu(a)===null;return r&&(!o||o==="all")&&!i&&!l}function nA(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?tA(e.config,t.slug):!1}}const rA=`syntaur.savedViews.cache.v${vi.version}`;let Hl=S7(),na=null,$w=null;const Fb=new Set,wh=new Set;let sA=0;function oA(){return++sA}function zb(e){return e===sA}function S7(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(rA);if(!e)return null;const t=JSON.parse(e);return t.version!==vi.version?null:t}catch{return null}}function C7(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(rA,JSON.stringify(e))}catch{}}function iA(e){Hl=e,$w=null,C7(e);for(const t of Fb)t(e);for(const t of wh)t(null)}function E7(e){$w=e;for(const t of wh)t(e)}function aA(e){if(!e||typeof e!="object")return vi;const t=e;return t.version!==vi.version||!Array.isArray(t.views)||!t.dashboard?vi:t}function SN(){if(na)return na;const e=oA();return na=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=aA(t);return zb(e)&&iA(n),na=null,Hl??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return zb(e)&&E7(n),na=null,Hl??vi}),na}function Iw(){const[e,t]=m.useState(()=>Hl??vi),[n,r]=m.useState(()=>Hl===null),[o,i]=m.useState(!1),[a,l]=m.useState(()=>$w);return m.useEffect(()=>{let f=!1;Hl===null&&r(!0),SN().then(g=>{f||(t(g),r(!1),i(!0))});const p=g=>{f||(t(g),r(!1),i(!0),l(null))},h=g=>{f||(l(g),r(!1),i(!0))};return Fb.add(p),wh.add(h),()=>{f=!0,Fb.delete(p),wh.delete(h)}},[]),{file:e,loading:n,ready:o,error:a,refetch:()=>{na=null,r(!0),l(null),i(!1),SN()}}}function Ud(){const{file:e,loading:t}=Iw();return{views:e.views,loading:t}}function lA(){const{file:e,loading:t}=Iw();return{layout:e.dashboard,loading:t}}function Ni(e){const{file:t,loading:n,ready:r,error:o,refetch:i}=Iw();return e?{view:t.views.find(l=>l.id===e)??null,loading:n,ready:r,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function Am(e,t,n){const r=oA(),o=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(!o.ok){const a=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(a.error??`HTTP ${o.status}`)}const i=aA(await o.json());return zb(r)&&iA(i),i}function ec(e){return Am("POST","/api/saved-views",e)}function jh(e,t){return Am("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function T7(e){return Am("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Bb(e){return Am("PUT","/api/dashboard",{slots:e})}const R7=["top","right","bottom","left"],Si=Math.min,Lr=Math.max,kh=Math.round,hp=Math.floor,eo=e=>({x:e,y:e}),A7={left:"right",right:"left",bottom:"top",top:"bottom"};function Ub(e,t,n){return Lr(e,Si(t,n))}function Ro(e,t){return typeof e=="function"?e(t):e}function Ao(e){return e.split("-")[0]}function Rc(e){return e.split("-")[1]}function Mw(e){return e==="x"?"y":"x"}function Lw(e){return e==="y"?"height":"width"}function Xs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Ow(e){return Mw(Xs(e))}function P7(e,t,n){n===void 0&&(n=!1);const r=Rc(e),o=Ow(e),i=Lw(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Nh(a)),[a,Nh(a)]}function _7(e){const t=Nh(e);return[Hb(e),t,Hb(t)]}function Hb(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const CN=["left","right"],EN=["right","left"],D7=["top","bottom"],$7=["bottom","top"];function I7(e,t,n){switch(e){case"top":case"bottom":return n?t?EN:CN:t?CN:EN;case"left":case"right":return t?D7:$7;default:return[]}}function M7(e,t,n,r){const o=Rc(e);let i=I7(Ao(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Hb)))),i}function Nh(e){const t=Ao(e);return A7[t]+e.slice(t.length)}function L7(e){return{top:0,right:0,bottom:0,left:0,...e}}function cA(e){return typeof e!="number"?L7(e):{top:e,right:e,bottom:e,left:e}}function Sh(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function TN(e,t,n){let{reference:r,floating:o}=e;const i=Xs(t),a=Ow(t),l=Lw(a),u=Ao(t),f=i==="y",p=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[l]/2-o[l]/2;let y;switch(u){case"top":y={x:p,y:r.y-o.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:h};break;case"left":y={x:r.x-o.width,y:h};break;default:y={x:r.x,y:r.y}}switch(Rc(t)){case"start":y[a]-=g*(n&&f?-1:1);break;case"end":y[a]+=g*(n&&f?-1:1);break}return y}async function O7(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:g=!1,padding:y=0}=Ro(t,e),k=cA(y),b=l[g?h==="floating"?"reference":"floating":h],j=Sh(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:p,strategy:u})),S=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=await(i.isElement==null?void 0:i.isElement(N))?await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1}:{x:1,y:1},P=Sh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:N,strategy:u}):S);return{top:(j.top-P.top+k.top)/C.y,bottom:(P.bottom-j.bottom+k.bottom)/C.y,left:(j.left-P.left+k.left)/C.x,right:(P.right-j.right+k.right)/C.x}}const F7=50,z7=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:O7},u=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:h}=TN(f,r,u),g=r,y=0;const k={};for(let v=0;v<i.length;v++){const b=i[v];if(!b)continue;const{name:j,fn:S}=b,{x:N,y:C,data:P,reset:T}=await S({x:p,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:k,rects:f,platform:l,elements:{reference:e,floating:t}});p=N??p,h=C??h,k[j]={...k[j],...P},T&&y<F7&&(y++,typeof T=="object"&&(T.placement&&(g=T.placement),T.rects&&(f=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y:h}=TN(f,g,u)),v=-1)}return{x:p,y:h,placement:g,strategy:o,middlewareData:k}},B7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:f,padding:p=0}=Ro(e,t)||{};if(f==null)return{};const h=cA(p),g={x:n,y:r},y=Ow(o),k=Lw(y),v=await a.getDimensions(f),b=y==="y",j=b?"top":"left",S=b?"bottom":"right",N=b?"clientHeight":"clientWidth",C=i.reference[k]+i.reference[y]-g[y]-i.floating[k],P=g[y]-i.reference[y],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let R=T?T[N]:0;(!R||!await(a.isElement==null?void 0:a.isElement(T)))&&(R=l.floating[N]||i.floating[k]);const I=C/2-P/2,_=R/2-v[k]/2-1,F=Si(h[j],_),D=Si(h[S],_),W=F,H=R-v[k]-D,$=R/2-v[k]/2+I,O=Ub(W,$,H),U=!u.arrow&&Rc(o)!=null&&$!==O&&i.reference[k]/2-($<W?F:D)-v[k]/2<0,K=U?$<W?$-W:$-H:0;return{[y]:g[y]+K,data:{[y]:O,centerOffset:$-O-K,...U&&{alignmentOffset:K}},reset:U}}}),U7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:f}=t,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:v=!0,...b}=Ro(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=Ao(o),S=Xs(l),N=Ao(l)===l,C=await(u.isRTL==null?void 0:u.isRTL(f.floating)),P=g||(N||!v?[Nh(l)]:_7(l)),T=k!=="none";!g&&T&&P.push(...M7(l,v,k,C));const R=[l,...P],I=await u.detectOverflow(t,b),_=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&_.push(I[j]),h){const $=P7(o,a,C);_.push(I[$[0]],I[$[1]])}if(F=[...F,{placement:o,overflows:_}],!_.every($=>$<=0)){var D,W;const $=(((D=i.flip)==null?void 0:D.index)||0)+1,O=R[$];if(O&&(!(h==="alignment"?S!==Xs(O):!1)||F.every(M=>Xs(M.placement)===S?M.overflows[0]>0:!0)))return{data:{index:$,overflows:F},reset:{placement:O}};let U=(W=F.filter(K=>K.overflows[0]<=0).sort((K,M)=>K.overflows[1]-M.overflows[1])[0])==null?void 0:W.placement;if(!U)switch(y){case"bestFit":{var H;const K=(H=F.filter(M=>{if(T){const V=Xs(M.placement);return V===S||V==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(V=>V>0).reduce((V,L)=>V+L,0)]).sort((M,V)=>M[1]-V[1])[0])==null?void 0:H[0];K&&(U=K);break}case"initialPlacement":U=l;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function RN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function AN(e){return R7.some(t=>e[t]>=0)}const H7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=Ro(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=RN(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:AN(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=RN(a,n.floating);return{data:{escapedOffsets:l,escaped:AN(l)}}}default:return{}}}}},uA=new Set(["left","top"]);async function V7(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ao(n),l=Rc(n),u=Xs(n)==="y",f=uA.has(a)?-1:1,p=i&&u?-1:1,h=Ro(t,e);let{mainAxis:g,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof k=="number"&&(y=l==="end"?k*-1:k),u?{x:y*p,y:g*f}:{x:g*f,y:y*p}}const W7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await V7(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},K7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:j=>{let{x:S,y:N}=j;return{x:S,y:N}}},...f}=Ro(e,t),p={x:n,y:r},h=await i.detectOverflow(t,f),g=Xs(Ao(o)),y=Mw(g);let k=p[y],v=p[g];if(a){const j=y==="y"?"top":"left",S=y==="y"?"bottom":"right",N=k+h[j],C=k-h[S];k=Ub(N,k,C)}if(l){const j=g==="y"?"top":"left",S=g==="y"?"bottom":"right",N=v+h[j],C=v-h[S];v=Ub(N,v,C)}const b=u.fn({...t,[y]:k,[g]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:a,[g]:l}}}}}},q7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=Ro(e,t),p={x:n,y:r},h=Xs(o),g=Mw(h);let y=p[g],k=p[h];const v=Ro(l,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const N=g==="y"?"height":"width",C=i.reference[g]-i.floating[N]+b.mainAxis,P=i.reference[g]+i.reference[N]-b.mainAxis;y<C?y=C:y>P&&(y=P)}if(f){var j,S;const N=g==="y"?"width":"height",C=uA.has(Ao(o)),P=i.reference[h]-i.floating[N]+(C&&((j=a.offset)==null?void 0:j[h])||0)+(C?0:b.crossAxis),T=i.reference[h]+i.reference[N]+(C?0:((S=a.offset)==null?void 0:S[h])||0)-(C?b.crossAxis:0);k<P?k=P:k>T&&(k=T)}return{[g]:y,[h]:k}}}},G7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...f}=Ro(e,t),p=await a.detectOverflow(t,f),h=Ao(o),g=Rc(o),y=Xs(o)==="y",{width:k,height:v}=i.floating;let b,j;h==="top"||h==="bottom"?(b=h,j=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,b=g==="end"?"top":"bottom");const S=v-p.top-p.bottom,N=k-p.left-p.right,C=Si(v-p[b],S),P=Si(k-p[j],N),T=!t.middlewareData.shift;let R=C,I=P;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=N),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(R=S),T&&!g){const F=Lr(p.left,0),D=Lr(p.right,0),W=Lr(p.top,0),H=Lr(p.bottom,0);y?I=k-2*(F!==0||D!==0?F+D:Lr(p.left,p.right)):R=v-2*(W!==0||H!==0?W+H:Lr(p.top,p.bottom))}await u({...t,availableWidth:I,availableHeight:R});const _=await a.getDimensions(l.floating);return k!==_.width||v!==_.height?{reset:{rects:!0}}:{}}}};function Pm(){return typeof window<"u"}function Ac(e){return dA(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function so(e){var t;return(t=(dA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dA(e){return Pm()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ns(e){return Pm()?e instanceof Element||e instanceof Ur(e).Element:!1}function Do(e){return Pm()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function PN(e){return!Pm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function Hd(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ss(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Y7(e){return/^(table|td|th)$/.test(Ac(e))}function _m(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const X7=/transform|translate|scale|rotate|perspective|filter/,Q7=/paint|layout|strict|content/,Ji=e=>!!e&&e!=="none";let jy;function Fw(e){const t=Ns(e)?Ss(e):e;return Ji(t.transform)||Ji(t.translate)||Ji(t.scale)||Ji(t.rotate)||Ji(t.perspective)||!zw()&&(Ji(t.backdropFilter)||Ji(t.filter))||X7.test(t.willChange||"")||Q7.test(t.contain||"")}function J7(e){let t=Ci(e);for(;Do(t)&&!tc(t);){if(Fw(t))return t;if(_m(t))return null;t=Ci(t)}return null}function zw(){return jy==null&&(jy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jy}function tc(e){return/^(html|body|#document)$/.test(Ac(e))}function Ss(e){return Ur(e).getComputedStyle(e)}function Dm(e){return Ns(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ci(e){if(Ac(e)==="html")return e;const t=e.assignedSlot||e.parentNode||PN(e)&&e.host||so(e);return PN(t)?t.host:t}function fA(e){const t=Ci(e);return tc(t)?e.ownerDocument?e.ownerDocument.body:e.body:Do(t)&&Hd(t)?t:fA(t)}function fd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=fA(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=Ur(o);if(i){const l=Vb(a);return t.concat(a,a.visualViewport||[],Hd(o)?o:[],l&&n?fd(l):[])}else return t.concat(o,fd(o,[],n))}function Vb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pA(e){const t=Ss(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Do(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=kh(n)!==i||kh(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Bw(e){return Ns(e)?e:e.contextElement}function Vl(e){const t=Bw(e);if(!Do(t))return eo(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=pA(t);let a=(i?kh(n.width):n.width)/r,l=(i?kh(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Z7=eo(0);function hA(e){const t=Ur(e);return!zw()||!t.visualViewport?Z7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function eU(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ur(e)?!1:t}function ja(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Bw(e);let a=eo(1);t&&(r?Ns(r)&&(a=Vl(r)):a=Vl(e));const l=eU(i,n,r)?hA(i):eo(0);let u=(o.left+l.x)/a.x,f=(o.top+l.y)/a.y,p=o.width/a.x,h=o.height/a.y;if(i){const g=Ur(i),y=r&&Ns(r)?Ur(r):r;let k=g,v=Vb(k);for(;v&&r&&y!==k;){const b=Vl(v),j=v.getBoundingClientRect(),S=Ss(v),N=j.left+(v.clientLeft+parseFloat(S.paddingLeft))*b.x,C=j.top+(v.clientTop+parseFloat(S.paddingTop))*b.y;u*=b.x,f*=b.y,p*=b.x,h*=b.y,u+=N,f+=C,k=Ur(v),v=Vb(k)}}return Sh({width:p,height:h,x:u,y:f})}function $m(e,t){const n=Dm(e).scrollLeft;return t?t.left+n:ja(so(e)).left+n}function mA(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-$m(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function tU(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=so(r),l=t?_m(t.floating):!1;if(r===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},f=eo(1);const p=eo(0),h=Do(r);if((h||!h&&!i)&&((Ac(r)!=="body"||Hd(a))&&(u=Dm(r)),h)){const y=ja(r);f=Vl(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const g=a&&!h&&!i?mA(a,u):eo(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+p.x+g.x,y:n.y*f.y-u.scrollTop*f.y+p.y+g.y}}function nU(e){return Array.from(e.getClientRects())}function rU(e){const t=so(e),n=Dm(e),r=e.ownerDocument.body,o=Lr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Lr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+$m(e);const l=-n.scrollTop;return Ss(r).direction==="rtl"&&(a+=Lr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const _N=25;function sU(e,t){const n=Ur(e),r=so(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const p=zw();(!p||p&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=$m(r);if(f<=0){const p=r.ownerDocument,h=p.body,g=getComputedStyle(h),y=p.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,k=Math.abs(r.clientWidth-h.clientWidth-y);k<=_N&&(i-=k)}else f<=_N&&(i+=f);return{width:i,height:a,x:l,y:u}}function oU(e,t){const n=ja(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Do(e)?Vl(e):eo(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:a,height:l,x:u,y:f}}function DN(e,t,n){let r;if(t==="viewport")r=sU(e,n);else if(t==="document")r=rU(so(e));else if(Ns(t))r=oU(t,n);else{const o=hA(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Sh(r)}function gA(e,t){const n=Ci(e);return n===t||!Ns(n)||tc(n)?!1:Ss(n).position==="fixed"||gA(n,t)}function iU(e,t){const n=t.get(e);if(n)return n;let r=fd(e,[],!1).filter(l=>Ns(l)&&Ac(l)!=="body"),o=null;const i=Ss(e).position==="fixed";let a=i?Ci(e):e;for(;Ns(a)&&!tc(a);){const l=Ss(a),u=Fw(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Hd(a)&&!u&&gA(e,a))?r=r.filter(p=>p!==a):o=l,a=Ci(a)}return t.set(e,r),r}function aU(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?_m(t)?[]:iU(t,this._c):[].concat(n),r],l=DN(t,a[0],o);let u=l.top,f=l.right,p=l.bottom,h=l.left;for(let g=1;g<a.length;g++){const y=DN(t,a[g],o);u=Lr(y.top,u),f=Si(y.right,f),p=Si(y.bottom,p),h=Lr(y.left,h)}return{width:f-h,height:p-u,x:h,y:u}}function lU(e){const{width:t,height:n}=pA(e);return{width:t,height:n}}function cU(e,t,n){const r=Do(t),o=so(t),i=n==="fixed",a=ja(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=eo(0);function f(){u.x=$m(o)}if(r||!r&&!i)if((Ac(t)!=="body"||Hd(o))&&(l=Dm(t)),r){const y=ja(t,!0,i,t);u.x=y.x+t.clientLeft,u.y=y.y+t.clientTop}else o&&f();i&&!r&&o&&f();const p=o&&!r&&!i?mA(o,l):eo(0),h=a.left+l.scrollLeft-u.x-p.x,g=a.top+l.scrollTop-u.y-p.y;return{x:h,y:g,width:a.width,height:a.height}}function ky(e){return Ss(e).position==="static"}function $N(e,t){if(!Do(e)||Ss(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return so(e)===n&&(n=n.ownerDocument.body),n}function xA(e,t){const n=Ur(e);if(_m(e))return n;if(!Do(e)){let o=Ci(e);for(;o&&!tc(o);){if(Ns(o)&&!ky(o))return o;o=Ci(o)}return n}let r=$N(e,t);for(;r&&Y7(r)&&ky(r);)r=$N(r,t);return r&&tc(r)&&ky(r)&&!Fw(r)?n:r||J7(e)||n}const uU=async function(e){const t=this.getOffsetParent||xA,n=this.getDimensions,r=await n(e.floating);return{reference:cU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function dU(e){return Ss(e).direction==="rtl"}const fU={convertOffsetParentRelativeRectToViewportRelativeRect:tU,getDocumentElement:so,getClippingRect:aU,getOffsetParent:xA,getElementRects:uU,getClientRects:nU,getDimensions:lU,getScale:Vl,isElement:Ns,isRTL:dU};function yA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function pU(e,t){let n=null,r;const o=so(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const f=e.getBoundingClientRect(),{left:p,top:h,width:g,height:y}=f;if(l||t(),!g||!y)return;const k=hp(h),v=hp(o.clientWidth-(p+g)),b=hp(o.clientHeight-(h+y)),j=hp(p),N={rootMargin:-k+"px "+-v+"px "+-b+"px "+-j+"px",threshold:Lr(0,Si(1,u))||1};let C=!0;function P(T){const R=T[0].intersectionRatio;if(R!==u){if(!C)return a();R?a(!1,R):r=setTimeout(()=>{a(!1,1e-7)},1e3)}R===1&&!yA(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(P,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,N)}n.observe(e)}return a(!0),i}function hU(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Bw(e),p=o||i?[...f?fd(f):[],...t?fd(t):[]]:[];p.forEach(j=>{o&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&l?pU(f,n):null;let g=-1,y=null;a&&(y=new ResizeObserver(j=>{let[S]=j;S&&S.target===f&&y&&t&&(y.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=y)==null||N.observe(t)})),n()}),f&&!u&&y.observe(f),t&&y.observe(t));let k,v=u?ja(e):null;u&&b();function b(){const j=ja(e);v&&!yA(v,j)&&n(),v=j,k=requestAnimationFrame(b)}return n(),()=>{var j;p.forEach(S=>{o&&S.removeEventListener("scroll",n),i&&S.removeEventListener("resize",n)}),h==null||h(),(j=y)==null||j.disconnect(),y=null,u&&cancelAnimationFrame(k)}}const mU=W7,gU=K7,xU=U7,yU=G7,bU=H7,IN=B7,vU=q7,wU=(e,t,n)=>{const r=new Map,o={platform:fU,...n},i={...o.platform,_c:r};return z7(e,t,{...o,platform:i})};var jU=typeof document<"u",kU=function(){},qp=jU?m.useLayoutEffect:kU;function Ch(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Ch(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Ch(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function bA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MN(e,t){const n=bA(e);return Math.round(t*n)/n}function Ny(e){const t=m.useRef(e);return qp(()=>{t.current=e}),t}function NU(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[p,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,y]=m.useState(r);Ch(g,r)||y(r);const[k,v]=m.useState(null),[b,j]=m.useState(null),S=m.useCallback(M=>{M!==T.current&&(T.current=M,v(M))},[]),N=m.useCallback(M=>{M!==R.current&&(R.current=M,j(M))},[]),C=i||k,P=a||b,T=m.useRef(null),R=m.useRef(null),I=m.useRef(p),_=u!=null,F=Ny(u),D=Ny(o),W=Ny(f),H=m.useCallback(()=>{if(!T.current||!R.current)return;const M={placement:t,strategy:n,middleware:g};D.current&&(M.platform=D.current),wU(T.current,R.current,M).then(V=>{const L={...V,isPositioned:W.current!==!1};$.current&&!Ch(I.current,L)&&(I.current=L,Ys.flushSync(()=>{h(L)}))})},[g,t,n,D,W]);qp(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,h(M=>({...M,isPositioned:!1})))},[f]);const $=m.useRef(!1);qp(()=>($.current=!0,()=>{$.current=!1}),[]),qp(()=>{if(C&&(T.current=C),P&&(R.current=P),C&&P){if(F.current)return F.current(C,P,H);H()}},[C,P,H,F,_]);const O=m.useMemo(()=>({reference:T,floating:R,setReference:S,setFloating:N}),[S,N]),U=m.useMemo(()=>({reference:C,floating:P}),[C,P]),K=m.useMemo(()=>{const M={position:n,left:0,top:0};if(!U.floating)return M;const V=MN(U.floating,p.x),L=MN(U.floating,p.y);return l?{...M,transform:"translate("+V+"px, "+L+"px)",...bA(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:L}},[n,l,U.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:H,refs:O,elements:U,floatingStyles:K}),[p,H,O,U,K])}const SU=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?IN({element:r.current,padding:o}).fn(n):{}:r?IN({element:r,padding:o}).fn(n):{}}}},CU=(e,t)=>{const n=mU(e);return{name:n.name,fn:n.fn,options:[e,t]}},EU=(e,t)=>{const n=gU(e);return{name:n.name,fn:n.fn,options:[e,t]}},TU=(e,t)=>({fn:vU(e).fn,options:[e,t]}),RU=(e,t)=>{const n=xU(e);return{name:n.name,fn:n.fn,options:[e,t]}},AU=(e,t)=>{const n=yU(e);return{name:n.name,fn:n.fn,options:[e,t]}},PU=(e,t)=>{const n=bU(e);return{name:n.name,fn:n.fn,options:[e,t]}},_U=(e,t)=>{const n=SU(e);return{name:n.name,fn:n.fn,options:[e,t]}};var DU="Arrow",vA=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Nn.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});vA.displayName=DU;var $U=vA;function IU(e){const[t,n]=m.useState(void 0);return ji(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,f=Array.isArray(u)?u[0]:u;a=f.inlineSize,l=f.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Uw="Popper",[wA,jA]=Ra(Uw),[MU,kA]=wA(Uw),NA=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(MU,{scope:t,anchor:r,onAnchorChange:o,children:n})};NA.displayName=Uw;var SA="PopperAnchor",CA=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=kA(SA,n),a=m.useRef(null),l=rr(t,a),u=m.useRef(null);return m.useEffect(()=>{const f=u.current;u.current=(r==null?void 0:r.current)||a.current,f!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(Nn.div,{...o,ref:l})});CA.displayName=SA;var Hw="PopperContent",[LU,OU]=wA(Hw),EA=m.forwardRef((e,t)=>{var oe,ne,ue,ge,Ce,Ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:k,...v}=e,b=kA(Hw,n),[j,S]=m.useState(null),N=rr(t,ke=>S(ke)),[C,P]=m.useState(null),T=IU(C),R=(T==null?void 0:T.width)??0,I=(T==null?void 0:T.height)??0,_=r+(i!=="center"?"-"+i:""),F=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},D=Array.isArray(f)?f:[f],W=D.length>0,H={padding:F,boundary:D.filter(zU),altBoundary:W},{refs:$,floatingStyles:O,placement:U,isPositioned:K,middlewareData:M}=NU({strategy:"fixed",placement:_,whileElementsMounted:(...ke)=>hU(...ke,{animationFrame:y==="always"}),elements:{reference:b.anchor},middleware:[CU({mainAxis:o+I,alignmentAxis:a}),u&&EU({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?TU():void 0,...H}),u&&RU({...H}),AU({...H,apply:({elements:ke,rects:Ue,availableWidth:ie,availableHeight:ve})=>{const{width:be,height:Re}=Ue.reference,He=ke.floating.style;He.setProperty("--radix-popper-available-width",`${ie}px`),He.setProperty("--radix-popper-available-height",`${ve}px`),He.setProperty("--radix-popper-anchor-width",`${be}px`),He.setProperty("--radix-popper-anchor-height",`${Re}px`)}}),C&&_U({element:C,padding:l}),BU({arrowWidth:R,arrowHeight:I}),g&&PU({strategy:"referenceHidden",...H})]}),[V,L]=AA(U),z=va(k);ji(()=>{K&&(z==null||z())},[K,z]);const Y=(oe=M.arrow)==null?void 0:oe.x,B=(ne=M.arrow)==null?void 0:ne.y,Q=((ue=M.arrow)==null?void 0:ue.centerOffset)!==0,[J,Z]=m.useState();return ji(()=>{j&&Z(window.getComputedStyle(j).zIndex)},[j]),s.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...O,transform:K?O.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ge=M.transformOrigin)==null?void 0:ge.x,(Ce=M.transformOrigin)==null?void 0:Ce.y].join(" "),...((Ne=M.hide)==null?void 0:Ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(LU,{scope:n,placedSide:V,onArrowChange:P,arrowX:Y,arrowY:B,shouldHideArrow:Q,children:s.jsx(Nn.div,{"data-side":V,"data-align":L,...v,ref:N,style:{...v.style,animation:K?void 0:"none"}})})})});EA.displayName=Hw;var TA="PopperArrow",FU={top:"bottom",right:"left",bottom:"top",left:"right"},RA=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=OU(TA,r),a=FU[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx($U,{...o,ref:n,style:{...o.style,display:"block"}})})});RA.displayName=TA;function zU(e){return e!==null}var BU=e=>({name:"transformOrigin",options:e,fn(t){var b,j,S;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[f,p]=AA(n),h={start:"0%",center:"50%",end:"100%"}[p],g=(((j=o.arrow)==null?void 0:j.x)??0)+l/2,y=(((S=o.arrow)==null?void 0:S.y)??0)+u/2;let k="",v="";return f==="bottom"?(k=a?h:`${g}px`,v=`${-u}px`):f==="top"?(k=a?h:`${g}px`,v=`${r.floating.height+u}px`):f==="right"?(k=`${-u}px`,v=a?h:`${y}px`):f==="left"&&(k=`${r.floating.width+u}px`,v=a?h:`${y}px`),{data:{x:k,y:v}}}});function AA(e){const[t,n="center"]=e.split("-");return[t,n]}var UU=NA,HU=CA,VU=EA,WU=RA,KU=Symbol("radix.slottable");function qU(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=KU,t}var GU=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"}),YU="VisuallyHidden",PA=m.forwardRef((e,t)=>s.jsx(Nn.span,{...e,ref:t,style:{...GU,...e.style}}));PA.displayName=YU;var XU=PA,[Im]=Ra("Tooltip",[jA]),Mm=jA(),_A="TooltipProvider",QU=700,Wb="tooltip.open",[JU,Vw]=Im(_A),DA=e=>{const{__scopeTooltip:t,delayDuration:n=QU,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),l=m.useRef(!1),u=m.useRef(0);return m.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),s.jsx(JU,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:i})};DA.displayName=_A;var pd="Tooltip",[ZU,Vd]=Im(pd),$A=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=Vw(pd,e.__scopeTooltip),f=Mm(t),[p,h]=m.useState(null),g=Ol(),y=m.useRef(0),k=a??u.disableHoverableContent,v=l??u.delayDuration,b=m.useRef(!1),[j,S]=gm({prop:r,defaultProp:o??!1,onChange:R=>{R?(u.onOpen(),document.dispatchEvent(new CustomEvent(Wb))):u.onClose(),i==null||i(R)},caller:pd}),N=m.useMemo(()=>j?b.current?"delayed-open":"instant-open":"closed",[j]),C=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,S(!0)},[S]),P=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,S(!1)},[S]),T=m.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,S(!0),y.current=0},v)},[v,S]);return m.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),s.jsx(UU,{...f,children:s.jsx(ZU,{scope:t,contentId:g,open:j,stateAttribute:N,trigger:p,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{u.isOpenDelayedRef.current?T():C()},[u.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{k?P():(window.clearTimeout(y.current),y.current=0)},[P,k]),onOpen:C,onClose:P,disableHoverableContent:k,children:n})})};$A.displayName=pd;var Kb="TooltipTrigger",IA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Vd(Kb,n),i=Vw(Kb,n),a=Mm(n),l=m.useRef(null),u=rr(t,l,o.onTriggerChange),f=m.useRef(!1),p=m.useRef(!1),h=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx(HU,{asChild:!0,...a,children:s.jsx(Nn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:sn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:sn(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:sn(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:sn(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:sn(e.onBlur,o.onClose),onClick:sn(e.onClick,o.onClose)})})});IA.displayName=Kb;var Ww="TooltipPortal",[eH,tH]=Im(Ww,{forceMount:void 0}),MA=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Vd(Ww,t);return s.jsx(eH,{scope:t,forceMount:n,children:s.jsx(Aa,{present:n||i.open,children:s.jsx(uw,{asChild:!0,container:o,children:r})})})};MA.displayName=Ww;var nc="TooltipContent",LA=m.forwardRef((e,t)=>{const n=tH(nc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Vd(nc,e.__scopeTooltip);return s.jsx(Aa,{present:r||a.open,children:a.disableHoverableContent?s.jsx(OA,{side:o,...i,ref:t}):s.jsx(nH,{side:o,...i,ref:t})})}),nH=m.forwardRef((e,t)=>{const n=Vd(nc,e.__scopeTooltip),r=Vw(nc,e.__scopeTooltip),o=m.useRef(null),i=rr(t,o),[a,l]=m.useState(null),{trigger:u,onClose:f}=n,p=o.current,{onPointerInTransitChange:h}=r,g=m.useCallback(()=>{l(null),h(!1)},[h]),y=m.useCallback((k,v)=>{const b=k.currentTarget,j={x:k.clientX,y:k.clientY},S=aH(j,b.getBoundingClientRect()),N=lH(j,S),C=cH(v.getBoundingClientRect()),P=dH([...N,...C]);l(P),h(!0)},[h]);return m.useEffect(()=>()=>g(),[g]),m.useEffect(()=>{if(u&&p){const k=b=>y(b,p),v=b=>y(b,u);return u.addEventListener("pointerleave",k),p.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",k),p.removeEventListener("pointerleave",v)}}},[u,p,y,g]),m.useEffect(()=>{if(a){const k=v=>{const b=v.target,j={x:v.clientX,y:v.clientY},S=(u==null?void 0:u.contains(b))||(p==null?void 0:p.contains(b)),N=!uH(j,a);S?g():N&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[u,p,a,f,g]),s.jsx(OA,{...e,ref:i})}),[rH,sH]=Im(pd,{isInside:!1}),oH=qU("TooltipContent"),OA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=Vd(nc,n),f=Mm(n),{onClose:p}=u;return m.useEffect(()=>(document.addEventListener(Wb,p),()=>document.removeEventListener(Wb,p)),[p]),m.useEffect(()=>{if(u.trigger){const h=g=>{const y=g.target;y!=null&&y.contains(u.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,p]),s.jsx(cw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:s.jsxs(VU,{"data-state":u.stateAttribute,...f,...l,ref:t,style:{...l.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:[s.jsx(oH,{children:r}),s.jsx(rH,{scope:n,isInside:!0,children:s.jsx(XU,{id:u.contentId,role:"tooltip",children:o||r})})]})})});LA.displayName=nc;var FA="TooltipArrow",iH=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Mm(n);return sH(FA,n).isInside?null:s.jsx(WU,{...o,...r,ref:t})});iH.displayName=FA;function aH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function lH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function cH(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function uH(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],f=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-f)*(r-p)/(g-p)+f&&(o=!o)}return o}function dH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),fH(t)}function fH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}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 pH=DA,hH=$A,mH=IA,gH=MA,zA=LA;const ma=pH,Or=hH,Fr=mH,vr=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(gH,{children:s.jsx(zA,{ref:r,sideOffset:t,className:je("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})}));vr.displayName=zA.displayName;function Kw({items:e,align:t="end"}){const[n,r]=m.useState(!1),[o,i]=m.useState(null),a=m.useRef(null);if(m.useEffect(()=>{if(!n){i(null);return}function u(p){a.current&&!a.current.contains(p.target)&&r(!1)}function f(p){p.key==="Escape"&&r(!1)}return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[n]),e.length===0)return null;function l(u,f){const p=u.icon,h=je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",f&&"pl-8",u.disabled?"opacity-50 cursor-not-allowed":u.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),g=f?u.active?s.jsx(Nr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):s.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p?s.jsx(p,{className:"h-4 w-4 shrink-0"}):null,y=s.jsxs(s.Fragment,{children:[g,s.jsx("span",{className:"block min-w-0 truncate",children:u.label})]});if(u.disabled){const k=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:h,children:y})});return u.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:k}),s.jsx(vr,{side:"left",children:u.disabledReason})]},u.key):s.jsx("div",{children:k},u.key)}return u.href?s.jsx($e,{to:u.href,className:h,onClick:()=>r(!1),children:y},u.key):s.jsx("button",{type:"button",className:h,onClick:()=>{var k;(k=u.onSelect)==null||k.call(u),r(!1)},children:y},u.key)}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsx("button",{type:"button",onClick:()=>r(u=>!u),className:"shell-action",title:"More actions","aria-label":"More actions","aria-haspopup":"true","aria-expanded":n,children:s.jsx(m4,{className:"h-4 w-4"})}),n&&s.jsx("div",{className:je("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:s.jsx(ma,{delayDuration:200,children:e.map(u=>{if(u.submenu&&u.submenu.length>0){const f=u.icon,p=o===u.key;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":p,onClick:()=>i(p?null:u.key),children:[f?s.jsx(f,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 flex-1 truncate",children:u.label}),p?s.jsx(nr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):s.jsx(Hv,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),p?u.submenu.map(h=>l(h,!0)):null]},u.key)}return l(u,!1)})})})]})}function LN(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const xH={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 yH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,0,0,0,0).getTime()}function bH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function vH(e,t,n=Date.now()){if(!t)return!0;const r=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(r);if(Number.isNaN(o))return!1;if(t.preset){const l=xH[t.preset];return l===void 0?!0:t.preset.startsWith("older_")?n-o>l:o>=n-l&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,a=t.to&&t.to.length>0?t.to:void 0;return!i&&!a?!0:!(i&&o<yH(i)||a&&o>bH(a))}function wH(e,t,n={}){const{workspace:r,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const a=Ve(t.status),l=Ve(t.priority),u=Ve(t.type),f=Ve(t.assignee),p=Ve(t.project),h=Ve(t.tags),{activity:g}=t;if(r){if(r==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==r)return!1}if(a.length&&!a.includes(e.status)||l.length&&!l.includes(e.priority)||u.length&&!u.includes(e.type??"")||g==="stale"&&!LN(e.updated)||g==="fresh"&&LN(e.updated))return!1;if(f.length){const y=e.assignee??"__unassigned__";if(!f.includes(y))return!1}if(p.length&&!p.some(k=>k==="__standalone__"?e.projectSlug==null:e.projectSlug===k))return!1;if(h.length){const y=e.tags??[];if(!h.some(k=>y.includes(k)))return!1}if(!vH(e,t.dateRange))return!1;if(o){const y=o.trim().toLowerCase();if(y&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(y))return!1}return!0}function hd(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const ON={critical:0,high:1,medium:2,low:3};function mp(e){return Date.parse(e??"")||0}function Wd(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"title":a=o.title.localeCompare(i.title);break;case"status":a=o.status.localeCompare(i.status);break;case"priority":a=(ON[o.priority]??99)-(ON[i.priority]??99);break;case"assignee":a=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":a=o.dependsOn.length-i.dependsOn.length;break;case"created":a=mp(o.created)-mp(i.created);break;case"updated":a=mp(o.updated)-mp(i.updated);break}return n==="asc"?a:-a})}function jH(e){const t=`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`;return{...e.facts??{},status:e.status,phase:e.phase,disposition:e.disposition,priority:e.priority,type:e.type,assignee:e.assignee,project:e.projectSlug,tags:e.tags,archived:e.archived,title:e.title,created:e.created,updated:e.updated,completedAt:e.completedAt,statusAge:e.statusAge,phaseAge:e.phaseAge,searchText:t}}function BA(e,t,n={}){const{workspace:r,includeArchived:o=!1,now:i=Date.now()}=n,a={now:i};return e.filter(l=>{if(l.archived===!0&&!o)return!1;if(r){if(r==="_ungrouped"){if(l.projectWorkspace!=null)return!1}else if(l.projectWorkspace!==r)return!1}if(!t)return!0;const u=jH(l);return t.predicate(u,a)})}const Lm={hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},reworkrequested:{kind:"bool",get:e=>e.reworkRequested},pinned:{kind:"bool"}};function Om(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},r=e.type==="attestation"?[n.fact,n.approved,n.changesRequested,n.by,n.approvedBy].map(o=>o.toLowerCase()):[n.fact.toLowerCase()];return{storageKey:t,exports:n,registryKeys:r}}function kH(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const r=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(r))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:r,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:r,type:"attestation",binds:i})}}return t}function qb(e){const t=[],n=new Map;for(const r of Object.keys(Lm))n.set(r,"built-in");for(const r of Object.keys(fm))n.set(r,"built-in");for(const r of e??[]){const o=((r==null?void 0:r.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(r==null?void 0:r.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(r.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${r.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const f=(r.binds??"none").toString().trim()||"none";if(f!=="plan"&&f!=="commit"&&f!=="none"){t.push(`fact "${o}": invalid binds "${r.binds}" — expected plan, commit, or none`);continue}}const l=Om(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,u=l.find(f=>n.has(f));if(u!==void 0){const f=n.get(u);f==="built-in"?t.push(`fact "${o}": exported field "${u}" collides with a built-in field`):f===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${u}" collides with fact "${f}"`);continue}for(const f of l)n.set(f,o)}return t}function NH(e){const t=new Set([...Object.keys(Lm),...Object.keys(fm)]),n=[];for(const r of e){const o=Om(r).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(r)}}return n}function UA(e,t){const n=Om(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:r=>r[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:r=>r[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:r=>r[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:r=>r[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:r=>r[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:r=>r[n.exports.fact]}}function qw(e){const t={...Lm};for(const n of e)UA(t,n);return t}function HA(e){const t={...fm};for(const n of e)UA(t,n);return t}function VA(e){const t=["status","priority","type","assignee","project","tag","tags","archived","title","search","created","updated","completedAt","statusAge","phase","disposition","phaseAge","hasRealObjective","acRealTotal","acRealChecked","acAllChecked","planExists","planApproved","workspaceSet","implementationStarted","depsSatisfied","unresolvedQuestions","progressStaleDays","blocked","parked","reviewRequested","reworkRequested","pinned"],n=[];for(const r of e){const o=Om(r);r.type==="attestation"?n.push(o.exports.fact,o.exports.approved,o.exports.changesRequested,o.exports.by,o.exports.approvedBy):n.push(o.exports.fact)}return[...t,...n]}function Nt({title:e,description:t,actions:n}){return s.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:s.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?s.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const rc='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Fm({columns:e,items:t,getItemId:n,getColumnId:r,renderCard:o,canDrop:i,onMove:a,getExternalDragData:l,onCardContextMenu:u,emptyMessage:f="No cards in this column.",hiddenColumnIds:p,onHideColumn:h,compact:g=!1,dragDisabled:y=!1,boundedColumns:k=!1}){const v=k&&!g,b=m.useMemo(()=>new Set(p??[]),[p]),j=m.useMemo(()=>e.filter(U=>!b.has(U.id)),[e,b]),S=m.useMemo(()=>e.filter(U=>b.has(U.id)),[e,b]),[N,C]=m.useState(null),[P,T]=m.useState(null),R=m.useRef(null),I=m.useMemo(()=>new Map(t.map(U=>[n(U),U])),[n,t]),_=m.useMemo(()=>j.map(U=>({column:U,items:t.filter(K=>r(K)===U.id)})),[j,r,t]),F=N?I.get(N)??null:null;function D(U){if(!F)return{allowed:!1};const K=r(F);return(i==null?void 0:i({item:F,fromColumnId:K,toColumnId:U}))??{allowed:!0}}function W(){C(null),T(null)}function H(U,K,M){if(y)return;const V=(l==null?void 0:l(K))??null;!a&&!V||(U.dataTransfer.effectAllowed="move",U.dataTransfer.setData("text/plain",M),V&&U.dataTransfer.setData("application/json",JSON.stringify(V)),a&&C(M))}function $(U,K,M){y||!a||!F||!D(K).allowed||(U.preventDefault(),U.dataTransfer.dropEffect="move",T(L=>(L==null?void 0:L.columnId)===K&&L.index===M?L:{columnId:K,index:M}))}async function O(U,K,M){var B;if(U.preventDefault(),y||!a||!F){W();return}const V=r(F),z=(((B=_.find(Q=>Q.column.id===V))==null?void 0:B.items)??[]).findIndex(Q=>n(Q)===n(F));if(!D(K).allowed||z<0){W();return}if(V===K&&(M===z||M===z+1)){W();return}try{await a({item:F,fromColumnId:V,toColumnId:K,fromIndex:z,toIndex:M})}finally{W()}}return s.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[S.length>0&&h?s.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Hidden:"}),S.map(U=>s.jsxs("button",{type:"button",onClick:()=>h(U.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${U.title}" column`,children:[U.title," ×"]},U.id))]}):null,s.jsx("div",{className:je("grid min-w-max grid-flow-col items-start gap-4",g?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:_.map(({column:U,items:K})=>{const M=D(U.id),V=(P==null?void 0:P.columnId)===U.id;return s.jsxs("section",{className:je("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",g?"min-h-[200px] p-2":"min-h-[320px] p-3",v?"max-h-[70vh]":"",F&&!M.allowed?"border-dashed opacity-65":"",F&&M.allowed?"border-primary/30 bg-accent/30":"",V?"ring-2 ring-ring/30":""),title:F&&!M.allowed?M.reason:void 0,children:[s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:je("font-semibold uppercase tracking-[0.16em] text-muted-foreground",g?"text-xs":"text-sm"),children:U.title}),U.description&&!g?s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:U.description}):null]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:K.length}),h?s.jsx("button",{type:"button",onClick:()=>h(U.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 "${U.title}" column`,"aria-label":`Hide column ${U.title}`,children:"×"}):null]})]}),s.jsxs("div",{className:je("flex flex-1 flex-col gap-3",v?"min-h-0 overflow-y-auto pr-1":""),onDragOver:L=>$(L,U.id,K.length),onDrop:L=>O(L,U.id,K.length),children:[K.length===0?y?s.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 f=="function"?f(U):f}):s.jsx(SH,{active:(P==null?void 0:P.columnId)===U.id&&P.index===0,disabled:!!F&&!M.allowed,children:typeof f=="function"?f(U):f}):null,K.map((L,z)=>{const Y=n(L),B=N===Y;return s.jsxs(m.Fragment,{children:[s.jsx("div",{className:je("h-2 rounded-full transition",(P==null?void 0:P.columnId)===U.id&&P.index===z?"bg-primary/70":"bg-transparent"),onDragOver:Q=>$(Q,U.id,z),onDrop:Q=>O(Q,U.id,z)}),s.jsx("div",{draggable:!y&&!!(a||l),onMouseDown:Q=>{R.current=Q.target},onDragStart:Q=>{const J=R.current;if(J!=null&&J.closest(rc)){Q.preventDefault();return}H(Q,L,Y)},onDragEnd:W,onContextMenu:Q=>{if(!u)return;const J=Q.target;J!=null&&J.closest(rc)||u(L,Q)},className:je("transition",!y&&(a||l)?"cursor-grab active:cursor-grabbing":"",B?"scale-[0.98] opacity-50":""),children:o(L,{dragging:B})})]},Y)}),K.length>0&&!y?s.jsx("div",{className:je("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(P==null?void 0:P.columnId)===U.id&&P.index===K.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",F&&!M.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},U.id)})})]})}function SH({active:e,disabled:t,children:n}){return s.jsx("div",{className:je("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 So="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Wl="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",WA="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",Gb="border-status-review-foreground/30 bg-status-review text-status-review-foreground",KA="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",qA="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",GA="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",Gp=So,CH={draft:So,pending:So,ready_for_planning:So,ready_to_implement:Wl,in_progress:Wl,blocked:WA,review:Gb,code_review:Gb,completed:KA,failed:qA,active:Wl,stopped:So,archived:GA};function EH(e){return CH[e]??Gp}const TH={slate:Gp,gray:Gp,grey:Gp};function YA(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function RH(e){let t=e.trim().replace(/^#/,"");return t.length===3&&(t=t.split("").map(n=>n+n).join("")),t.length!==6||/[^0-9a-fA-F]/.test(t)?null:{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function AH(e,t){const n=t==null?void 0:t.trim();if(n)if(n.startsWith("#")){const r=RH(n);if(r){const{r:o,g:i,b:a}=r;return{className:"",style:{backgroundColor:`rgba(${o}, ${i}, ${a}, 0.15)`,borderColor:`rgba(${o}, ${i}, ${a}, 0.4)`,color:n}}}}else{const r=TH[n.toLowerCase()];if(r)return{className:r}}return{className:EH(e)}}function md(e,t){const n=e.find(i=>i.id===t),{className:r,style:o}=AH(t,n==null?void 0:n.color);return{label:(n==null?void 0:n.label)??YA(t),className:r,style:o,iconName:n==null?void 0:n.icon}}function Yb(e){return e?!!e.terminal||e.id==="completed"||e.id==="failed":!1}function XA(e){const t=new Map(e.statuses.map(a=>[a.id,a])),n=e.order.length>0?e.order:e.statuses.map(a=>a.id),r=new Set,o=[],i=(a,l)=>{r.has(a)||(r.add(a),o.push({id:a,label:(l==null?void 0:l.label)??YA(a),terminal:Yb(l??{id:a})}))};for(const a of n)i(a,t.get(a));for(const a of e.statuses)i(a.id,a);return o}const QA={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:So,icon:bc},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:So,icon:c4},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:So,icon:g2},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Wl,icon:D4},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Wl,icon:qv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:WA,icon:lh},review:{label:"Review",description:"Ready for inspection or approval.",className:Gb,icon:L4},completed:{label:"Completed",description:"Finished successfully.",className:KA,icon:sm},failed:{label:"Failed",description:"Could not be completed as planned.",className:qA,icon:lh},active:{label:"Active",description:"The project has active or review work in flight.",className:Wl,icon:wb},stopped:{label:"Stopped",description:"Session ended without completing.",className:So,icon:a4},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:GA,icon:wb}},JA="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)]";function Xb(e){var t;return((t=QA[e])==null?void 0:t.icon)??wb}function kn({status:e,className:t,showIcon:n=!0,progress:r}){var y;const o=As(),i=md(o.statuses,e),a=Xb(e),l=i.label,u=((y=o.statuses.find(k=>k.id===e))==null?void 0:y.description)??Kd(e),f=r&&r.total>0,p=f?Math.min(1,Math.max(0,r.checked/r.total)):0,h=f?`${l} — ${u} (${r.checked}/${r.total} criteria)`:`${l} — ${u}`,g=n?f?s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[s.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),s.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-p)})]}),s.jsx(a,{className:"h-2.5 w-2.5"})]}):s.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}):null;return s.jsxs("span",{title:h,className:je(JA,i.className,t),style:i.style,children:[g,s.jsx("span",{className:"min-w-0 truncate",children:l})]})}function Kd(e){var t;return((t=QA[e])==null?void 0:t.description)??`Status: ${e}`}function Pa({type:e,className:t,compact:n=!1}){const r=Md();if(!e)return null;const o=jz(r,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),a=o!=null&&o.color?{backgroundColor:`color-mix(in oklch, ${o.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${o.color} 50%, transparent)`,color:o.color}:void 0;return s.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:a,className:je("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!a&&"border-border/60 text-muted-foreground",t),children:i})}async function qd(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return PH(e)}function PH(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Hr({value:e,label:t,disabled:n=!1,disabledReason:r,onError:o}){const[i,a]=m.useState(!1);async function l(){n||(await qd(e)?(a(!0),setTimeout(()=>a(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:r??"Copy unavailable","aria-label":t??"Copy",children:s.jsx(ch,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:l,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:i?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:i?s.jsx(Nr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(ch,{className:"h-3 w-3","aria-hidden":"true"})})}function _H(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function DH({items:e,statusOrder:t,sortField:n,sortDirection:r,listSectionVisibility:o,compact:i=!1}){const a=As(),[l,u]=m.useState(()=>new Set(o.collapsed));m.useEffect(()=>{u(new Set(o.collapsed))},[o]);const f=p=>{u(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})};return s.jsx("div",{className:je("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(p=>{const h=Wd(e.filter(k=>k.status===p),n,r);if(h.length===0)return null;const g=!l.has(p),y=Eo(a,p);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[s.jsxs("button",{type:"button",onClick:()=>f(p),className:je("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[s.jsx(nr,{className:je("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",g?"":"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:y}),s.jsx("span",{className:je("rounded-full border border-border/60 text-muted-foreground",i?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:h.length})]}),g&&s.jsx("ul",{className:je("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:h.map(k=>{const v=_H(k);return s.jsx("li",{children:s.jsxs($e,{to:v,className:je("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:k.title}),k.projectTitle?s.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:k.projectTitle}):null,s.jsx("span",{className:"shrink-0 text-muted-foreground",children:Yn(k.updated)})]})},`${k.projectSlug??"standalone"}:${k.id}`)})})]},p)})})}function $H(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function IH({items:e,sortField:t,sortDirection:n,tableColumnVisibility:r,compact:o=!1}){const i=new Set(r.hidden);i.delete("title");const a=p=>!i.has(p),l=Wd(e,t,n),u=o?"py-2 pr-3":"py-3 pr-4",f=o?"text-xs":"text-sm";return s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:je("w-full text-left",f),children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[a("title")?s.jsx("th",{className:je("font-medium",u),children:"Assignment"}):null,a("status")?s.jsx("th",{className:je("font-medium",u),children:"Status"}):null,a("priority")?s.jsx("th",{className:je("font-medium",u),children:"Priority"}):null,a("assignee")?s.jsx("th",{className:je("font-medium",u),children:"Assignee"}):null,a("dependencies")?s.jsx("th",{className:je("font-medium",u),children:"Dependencies"}):null,a("created")?s.jsx("th",{className:je("font-medium",u),children:"Created"}):null,a("updated")?s.jsx("th",{className:je("font-medium",u),children:"Updated"}):null]})}),s.jsx("tbody",{children:l.map(p=>{const h=$H(p),g=`${p.projectSlug??"standalone"}:${p.id}`;return s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[a("title")?s.jsxs("td",{className:u,children:[s.jsx($e,{to:h,className:"font-semibold text-foreground hover:text-primary",children:p.title}),p.projectTitle?s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.projectTitle}):null]}):null,a("status")?s.jsx("td",{className:u,children:s.jsx(kn,{status:p.status,className:"max-w-[150px]"})}):null,a("priority")?s.jsx("td",{className:je("capitalize text-muted-foreground",u),children:p.priority}):null,a("assignee")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.assignee??"Unassigned"}):null,a("dependencies")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.dependsOn.length}):null,a("created")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.created)}):null,a("updated")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.updated)}):null]},g)})})]})})}function ZA({view:e,compact:t,emptyDescription:n}){const{data:r,loading:o,error:i}=lm(),a=As(),l=m.useMemo(()=>a.order.map(p=>({id:p,title:Eo(a,p),description:Kd(p)})),[a]),u=m.useMemo(()=>HA(a.factDeclarations),[a.factDeclarations]),f=m.useMemo(()=>{if(!r)return[];const p=e.config.filters.query??Uu(e.config.filters);let h=null;p.trim()!==""&&(h=Zl(p,u).query);const g=BA(r.assignments,h,{workspace:e.workspace});return Wd(g,e.config.sortField,e.config.sortDirection)},[r,e,u]);if(o&&!r)return s.jsx(bt,{label:"Loading assignments…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(f.length===0)return s.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 s.jsx(Fm,{compact:t,dragDisabled:!0,columns:l,items:f,getItemId:p=>p.slug||p.id,getColumnId:p=>p.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:p=>t?s.jsx(MH,{item:p}):s.jsx(LH,{item:p})});case"list":return s.jsx(DH,{items:f,statusOrder:a.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return s.jsx(IH,{items:f,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function MH({item:e}){const t=hd(e);return s.jsxs("div",{className:je("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]}),e.id?s.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),s.jsx(Hr,{value:e.id})]}):null]})}function LH({item:e}){const t=hd(e);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx(Pa,{type:e.type,compact:!0}),s.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]})]})}function OH({viewId:e,onPickAnother:t}){const{view:n,loading:r,error:o,refetch:i}=Ni(e);return r?s.jsx(bt,{label:"Loading view…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),s.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?s.jsx(ZA,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),s.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function eP({sessions:e}){return s.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:s.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:ha.recentSessionsEmptyTitle}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:ha.recentSessionsEmptyHint})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>s.jsx("li",{children:s.jsx(FH,{session:t})},t.sessionId))})]})}function FH({session:e}){const t=gn(),[n,r]=m.useState(!1),o=zH(e,t),i=BH(e),a=!e.path;return s.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx($e,{to:o,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}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",Jv(e.started)]}),n&&e.path?s.jsxs("div",{className:"mt-1 space-y-0.5",children:[s.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}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:ha.recentSessionsCopyFallbackHint})]}):null]}),s.jsx(Hr,{value:e.path,label:ha.recentSessionsCopyPathLabel,disabled:a,disabledReason:ha.recentSessionsCopyPathDisabled,onError:()=>r(!0)})]})}function zH(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function BH(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const UH={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 ra(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function HH(e,t,n=Date.now()){const r=ra(e);if(t.preset){const a=UH[t.preset];return a?t.preset.startsWith("older_")?r<n-a:r>=n-a:!0}const o=t.from?Date.parse(`${t.from}T00:00:00.000Z`):null,i=t.to?Date.parse(`${t.to}T23:59:59.999Z`):null;return!(o!==null&&Number.isFinite(o)&&r<o||i!==null&&Number.isFinite(i)&&r>i)}function VH(e,t,n=Date.now()){const{dateRange:r,project:o,agent:i,sessionStatus:a}=t,l=new Set(o??[]),u=new Set(i??[]),f=new Set(a??[]);return e.filter(p=>{if(r&&!HH(p.started,r,n))return!1;if(l.size>0){const h=p.projectSlug??"__standalone__";if(!l.has(h))return!1}if(u.size>0&&!Array.from(u).some(g=>g.toLowerCase()===p.agent.toLowerCase()))return!1;if(f.size>0){let h=!1;for(const g of f){switch(g){case"active":p.status==="active"&&(h=!0);break;case"ended":(p.status==="completed"||p.status==="stopped")&&(h=!0);break;case"tracked":h=!0;break}if(h)break}if(!h)return!1}return!0})}function WH(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"started":a=ra(o.started)-ra(i.started);break;case"lastActivity":a=ra(o.updatedAt)-ra(i.updatedAt);break;case"projectName":{const l=o.projectSlug??"",u=i.projectSlug??"";a=l.localeCompare(u);break}case"agentName":a=o.agent.localeCompare(i.agent);break;default:a=ra(o.started)-ra(i.started);break}return n==="asc"?a:-a})}function KH(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function qH({view:e,emptyDescription:t}){const{data:n,loading:r,error:o}=cm(),i=m.useMemo(()=>{if(!n)return[];const a=n.sessions??[],{config:l}=e,u=l.filters,f={dateRange:u.dateRange?{...u.dateRange,field:"started"}:void 0,project:Ve(u.project),agent:Ve(u.agent),sessionStatus:Ve(u.sessionStatus),limit:l.limit};let p=VH(a,f);return p=WH(p,l.sortField,l.sortDirection),p=KH(p,l.limit),p},[n,e]);return r&&!n?s.jsx(bt,{label:"Loading sessions…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?s.jsx(Nt,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):s.jsx(eP,{sessions:i})}function GH({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:r,loading:o}=Ud(),[i,a]=m.useState(!1),l=m.useRef(null),u=m.useMemo(()=>r.filter(h=>h.entityType==="session"),[r]);m.useEffect(()=>{if(!i)return;function h(y){l.current&&!l.current.contains(y.target)&&a(!1)}function g(y){y.key==="Escape"&&a(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",g)}},[i]);const f=e?r.find(h=>h.id===e)??null:null,p=o?"Session views…":f?f.name:"Session views";return s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",disabled:o,onClick:()=>a(h=>!h),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":i,title:"Session views",children:[s.jsx("span",{className:"max-w-[160px] truncate",children:p}),s.jsx(nr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&s.jsxs("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:[s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(null)},className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",!e&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:s.jsx(Nr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),s.jsx("span",{children:"All sessions"})]}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"my-1 border-t border-border/40"}),u.map(h=>{const g=h.id===e;return s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(h.id)},className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",g&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:g?s.jsx(Nr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:h.name})]},h.id)})]}),s.jsx("div",{className:"my-1 border-t border-border/40"}),s.jsxs("button",{type:"button",onClick:()=>{a(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5 text-muted-foreground",children:[s.jsx(Pt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"Create new view…"})]})]})]})}const YH={__unassigned__:"Unassigned",__standalone__:"No project"};function jn({options:e,value:t,onChange:n,allLabel:r="Any",className:o,disabled:i,ariaLabel:a}){const[l,u]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),h=m.useRef([]),g=m.useMemo(()=>{const S=new Set(e.map(C=>C.value)),N=t.filter(C=>!S.has(C)).map(C=>({value:C,label:YH[C]??C}));return[...e,...N]},[e,t]),y=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{if(!l)return;function S(N){f.current&&!f.current.contains(N.target)&&u(!1)}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[l]),m.useEffect(()=>{var S;l&&((S=h.current[0])==null||S.focus())},[l]);const k=m.useMemo(()=>{if(t.length===0)return r;if(t.length===1){const S=g.find(N=>N.value===t[0]);return S?S.label:t[0]}return`${t.length} selected`},[t,g,r]);function v(S){n(y.has(S)?t.filter(N=>N!==S):[...t,S])}function b(S){var C;const N=Math.max(0,Math.min(S,g.length-1));(C=h.current[N])==null||C.focus()}function j(S){var T;const N=h.current,C=document.activeElement,P=N.findIndex(R=>R===C);S.key==="ArrowDown"?(S.preventDefault(),b(P<0?0:P+1)):S.key==="ArrowUp"?(S.preventDefault(),b(P<0?g.length-1:P-1)):S.key==="Home"?(S.preventDefault(),b(0)):S.key==="End"?(S.preventDefault(),b(g.length-1)):S.key==="Escape"&&(S.preventDefault(),u(!1),(T=p.current)==null||T.focus())}return s.jsxs("div",{className:"relative",ref:f,children:[s.jsxs("button",{type:"button",ref:p,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-label":a,onClick:()=>u(S=>!S),onKeyDown:S=>{!l&&(S.key==="ArrowDown"||S.key==="ArrowUp")&&(S.preventDefault(),u(!0))},className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[s.jsx("span",{className:"truncate",children:k}),s.jsx(nr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),l?s.jsxs("div",{role:"menu","aria-label":a,onKeyDown:j,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:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[s.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===g.length,onClick:()=>n(g.map(S=>S.value)),children:"Select all"}),s.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"})]}),g.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):g.map((S,N)=>{const C=y.has(S.value);return s.jsxs("button",{ref:P=>{h.current[N]=P},type:"button",role:"menuitemcheckbox","aria-checked":C,tabIndex:-1,onClick:()=>v(S.value),className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",C?"text-foreground":"text-muted-foreground"),children:[s.jsx("span",{className:je("flex h-4 w-4 shrink-0 items-center justify-center rounded border",C?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:C?s.jsx(Nr,{className:"h-3 w-3"}):null}),s.jsx("span",{className:"truncate",children:S.label})]},S.value)})]}):null]})}const FN={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"},XH=["updated","created"];function zm({value:e,onChange:t,className:n,ariaLabel:r="Date range filter"}){const[o,i]=m.useState(!1),a=m.useRef(null),l=(e==null?void 0:e.field)??"updated",u=!!(e&&!e.preset&&(e.from||e.to)),[f,p]=m.useState(u);m.useEffect(()=>p(u),[u]),m.useEffect(()=>{if(!o)return;function j(N){a.current&&!a.current.contains(N.target)&&i(!1)}function S(N){N.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",j),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",S)}},[o]);const h=!!(e&&(e.preset||e.from||e.to)),g=m.useMemo(()=>!h||!e?"Any date":e.preset?`${l}: ${FN[e.preset]??e.preset}`:`${l}: ${e.from||"…"} → ${e.to||"…"}`,[h,e,l]);function y(j){t(e?{...e,field:j}:{field:j,preset:"",from:"",to:""})}function k(j){p(!1),t({field:l,preset:j,from:"",to:""})}function v(){p(!1),t(null)}function b(j,S){const N={field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...N,[j]:S})}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":r,onClick:()=>i(j=>!j),className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",h&&"border-foreground/40 text-foreground",n),children:[s.jsx("span",{className:"truncate",children:g}),s.jsx(nr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?s.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:[s.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:XH.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j,onClick:()=>y(j),className:je("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",l===j?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:j},j))}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Sy,{label:"Any date",selected:!h,onClick:v}),K6.map(j=>s.jsx(Sy,{label:FN[j],selected:(e==null?void 0:e.preset)===j,onClick:()=>k(j)},j)),s.jsx(Sy,{label:"Custom range…",selected:f,onClick:()=>{p(!0),t({field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),f?s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",s.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:j=>b("from",j.target.value),className:"editor-input w-40"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",s.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:j=>b("to",j.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Sy({label:e,selected:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:je("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:[s.jsx("span",{children:e}),t?s.jsx(Nr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const QH=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function JH(e,t){const n={};for(const[r,o]of Object.entries(e))QH.has(r)||(n[r]=o);return{...n,...t}}function Eh(e,t,n){return{...e,viewMode:t.viewMode,filters:JH(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,limit:t.limit,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function ZH(e,t){var g,y;const n={},r=Ve(e.status);r.length&&(n.status=r);const o=Ve(e.type);o.length&&(n.type=o);const i=Ve(e.priority);i.length&&(n.priority=i);const a=Ve(e.assignee);a.length&&(n.assignee=a);const l=Ve(e.tags);if(l.length&&(n.tags=l),t&&t!=="all")n.project=[t];else{const k=Ve(e.project);k.length&&(n.project=k)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const u=Ve(e.sessionStatus);u.length&&(n.sessionStatus=u);const f=Ve(e.agent);f.length&&(n.agent=f),e.dateRange&&(n.dateRange=e.dateRange);const p=(g=e.search)==null?void 0:g.trim();p&&(n.search=p);const h=(y=e.query)==null?void 0:y.trim();return h&&(n.query=h),n}function sc(e){const t={viewMode:e.state.viewMode,filters:ZH(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 gl={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},gp={sortField:"started",sortDirection:"desc"};function tP(e,t){const{config:n}=sc({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:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function Gw(e,t){const{config:n}=sc({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function ga(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 r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Bm(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function nP(e,t){var r,o,i,a,l,u,f,p,h,g,y,k,v,b,j;const{config:n}=e;if((r=t.setViewMode)==null||r.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,Ve(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,Ve(n.filters.type)),(a=t.setPriorityFilter)==null||a.call(t,Ve(n.filters.priority)),(l=t.setAssigneeFilter)==null||l.call(t,Ve(n.filters.assignee)),(u=t.setProjectFilter)==null||u.call(t,Ve(n.filters.project)),(f=t.setTagsFilter)==null||f.call(t,Ve(n.filters.tags)),(p=t.setDateRange)==null||p.call(t,Bm(n.filters.dateRange)),(h=t.setSearch)==null||h.call(t,n.filters.search??""),(g=t.setQuery)==null||g.call(t,n.filters.query??Uu(n.filters)),t.setActivityFilter){const S=n.filters.activity??"all";t.setActivityFilter(S==="fresh"||S==="stale"?S:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(k=t.setSortDirection)==null||k.call(t,n.sortDirection),(v=t.setListSectionVisibility)==null||v.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(b=t.setKanbanColumnVisibility)==null||b.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(j=t.setTableColumnVisibility)==null||j.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Yp(e){return e?`/w/${e}/views`:"/views"}function rP(e){return`${Yp(e.workspace)}/${encodeURIComponent(e.id)}`}function sP(e){const t=e.workspace?`/w/${e.workspace}`:"",n=Ve(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&tA(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const e9=["critical","high","medium","low"],t9={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 n9(e){if(e.preset)return`${e.field} ${t9[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function oP(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&Hu(t)===null)return`query: ${t}`;const n=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=Ve(e[a]);l.length&&n.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(n9(e.dateRange));const r=(i=e.search)==null?void 0:i.trim();return r&&n.push(`search="${r}"`),n.join(" · ")||"no filters"}const zN=80,r9=["started","lastActivity","projectName","agentName"],s9={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},o9=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function iP({open:e,onOpenChange:t,initialView:n,onSubmit:r}){const o=!!n,{data:i}=ro(),{data:a}=cm(),[l,u]=m.useState(""),[f,p]=m.useState([]),[h,g]=m.useState([]),[y,k]=m.useState([]),[v,b]=m.useState(null),[j,S]=m.useState(gp.sortField),[N,C]=m.useState(gp.sortDirection),[P,T]=m.useState(""),[R,I]=m.useState(!1),[_,F]=m.useState(null);function D(){p([]),g([]),k([]),b(null),S(gp.sortField),C(gp.sortDirection),T("")}m.useEffect(()=>{if(e)if(F(null),I(!1),n){const M=n.config.filters;u(n.name),p(Ve(M.project)),g(Ve(M.agent)),k(Ve(M.sessionStatus)),b(Bm(M.dateRange)),S(n.config.sortField),C(n.config.sortDirection),T(n.config.limit!==void 0?String(n.config.limit):"")}else u(""),D()},[e,n]);const W=m.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(V=>({value:V.slug,label:V.title}))],[i]),H=m.useMemo(()=>{const M=new Set;for(const V of(a==null?void 0:a.sessions)??[])V.agent&&M.add(V.agent);return Array.from(M).sort().map(V=>({value:V,label:V}))},[a]),$=l.trim(),O=$.length>0&&$.length<=zN,U=P.trim()===""?void 0:parseInt(P.trim(),10),K=P.trim()===""||Number.isFinite(U)&&U!==void 0&&U>0&&U<=500;return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsx(Sn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async M=>{if(M.preventDefault(),!O||!K||R)return;I(!0),F(null);const V=ga(v),L=V?{...V,field:"started"}:void 0,z={filters:{project:f,agent:h,sessionStatus:y,dateRange:L},sortField:j,sortDirection:N,limit:U};try{await r($,z)}catch(Y){F(Y instanceof Error?Y.message:String(Y)),I(!1)}},children:[s.jsx(or,{children:s.jsx(Cn,{children:o?"Edit session view":"Create session view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),s.jsx("input",{id:"create-session-view-name",type:"text",value:l,autoFocus:!0,required:!0,maxLength:zN,onChange:M=>u(M.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"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(xl,{label:"Date range (session start)",children:s.jsx(zm,{className:"w-full",value:v,onChange:b})}),s.jsx(xl,{label:"Project",children:s.jsx(jn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:W,value:f,onChange:p})}),s.jsx(xl,{label:"Agent",children:s.jsx(jn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:H,value:h,onChange:g})}),s.jsx(xl,{label:"Session status",children:s.jsx(jn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:o9,value:y,onChange:k})}),s.jsx(xl,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:j,onChange:M=>S(M.target.value),className:"editor-input w-full",children:r9.map(M=>s.jsx("option",{value:M,children:s9[M]??M},M))}),s.jsx("button",{type:"button",onClick:()=>C(M=>M==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:N==="asc"?"Ascending":"Descending",children:N==="asc"?"Asc":"Desc"})]})}),s.jsxs(xl,{label:"Max results",className:"sm:col-span-2",children:[s.jsx("input",{type:"number",min:1,max:500,value:P,onChange:M=>T(M.target.value),placeholder:"No limit",className:"editor-input w-full"}),K?null:s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),_?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:_}):null,s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:D,className:"shell-action",disabled:R,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:R,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!O||!K||R,className:"shell-action shell-action--cta disabled:opacity-50",children:R?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function xl({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}function Cy({title:e,message:t,onPickAnother:n}){return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:e}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?s.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function i9({viewId:e,slotId:t,onPickAnother:n}){const{data:r,loading:o,error:i}=cm(),{view:a,loading:l,ready:u}=Ni(e??null),{layout:f}=lA(),{showToast:p}=Qn(),[h,g]=m.useState(!1),y=m.useCallback(async b=>{if(!t)return;const j=f.slots.map(S=>S.id===t?{...S,widget:b?{kind:"agent-sessions",viewId:b}:{kind:"agent-sessions"}}:S);try{await Bb(j)}catch(S){p(S instanceof Error?S.message:"Failed to update widget")}},[f,t,p]);async function k(b,j){const{workspace:S,config:N}=Gw(j,null);try{const P=(await ec({name:b,workspace:S,config:N,entityType:"session"})).views.find(T=>T.name===b&&T.entityType==="session");P&&await y(P.id),g(!1),p(`Created session view "${b}"`)}catch(C){throw p(C instanceof Error?C.message:"Failed to create session view"),C}}let v;return e?l&&!u?v=s.jsx(bt,{label:"Loading view…"}):a?a.entityType!=="session"?v=s.jsx(Cy,{title:"Wrong view type",message:"This widget is bound to an assignment view. Choose a session view above, or pick a different widget.",onPickAnother:n}):v=s.jsx(qH,{view:a,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):v=s.jsx(Cy,{title:"View no longer exists",message:"The saved view this widget was bound to has been deleted. Pick another session view above, or choose a different widget.",onPickAnother:n}):o&&!r?v=s.jsx(bt,{label:"Loading sessions…"}):i?v=s.jsx(Cy,{title:"Couldn't load sessions",message:i}):v=s.jsx(eP,{sessions:(r==null?void 0:r.sessions)??[]}),s.jsxs("div",{className:"space-y-2",children:[t?s.jsx("div",{className:"flex items-center justify-between gap-2",children:s.jsx(GH,{activeViewId:e??null,onSelectView:b=>void y(b),onCreateNew:()=>g(!0)})}):null,v,s.jsx(iP,{open:h,onOpenChange:g,workspace:null,onSubmit:k})]})}const a9=5;function l9(){const{data:e,loading:t,error:n}=Q2();if(t&&!e)return s.jsx(bt,{label:"Loading inventories…"});if(n)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),s.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,a9);return s.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[s.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),s.jsx($e,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const a=i.inventory,l=i.active_leases.length,u=i.members.length,f=a.display_name??a.slug;return s.jsx("li",{children:s.jsxs($e,{to:`/inventories/${encodeURIComponent(a.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:f}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[l,"/",u," leased"]})]})},a.slug)})})]})}function c9(e){let t=0,n=0;for(const r of e.daily)t+=r.total_tokens,n+=r.total_cost;return{tokens:t,cost:n}}function BN({filters:e,metric:t}){const n=e??{},{data:r,loading:o,error:i}=t5(n),a=t==="cost"?"Spend":"Token Usage",l=`/usage?${Eb(n).toString()}`;let u;if(o&&!r)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!r)u=s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!r||r.daily.length===0)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:f,cost:p}=c9(r),h=t==="cost"?{label:"Total spend",value:Jl(p)}:{label:"Total tokens",value:Ql(f)},g=t==="cost"?{label:"Tokens",value:Ql(f)}:{label:"Spend",value:Jl(p)};u=s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(UN,{label:h.label,value:h.value,emphasize:!0}),s.jsx(UN,{label:g.label,value:g.value})]})}return s.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:a}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",title:O1(n),children:O1(n)})]}),s.jsx($e,{to:l,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),s.jsx("div",{className:"px-4 py-4",children:u})]})}function UN({label:e,value:t,emphasize:n}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const u9={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function d9(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const yl="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function HN({config:e,open:t,onSave:n,onCancel:r}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=ro(),{data:a}=Ta(),{data:l}=J2(t),[u,f]=m.useState("30d"),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,v]=m.useState(""),[b,j]=m.useState(""),[S,N]=m.useState(""),[C,P]=m.useState(""),[T,R]=m.useState(!1),[I,_]=m.useState(null);m.useEffect(()=>{if(!t)return;const O=d9(e);f(O.window??"30d"),h(O.since??""),y(O.until??""),v(O.project??""),j(O.workspace??""),N(O.model??""),P(O.tool??""),R(!1),_(null)},[t,e]);function F(){return Id({window:u,since:u==="custom"?p:void 0,until:u==="custom"?g:void 0,project:k||void 0,workspace:b||void 0,model:S||void 0,tool:C||void 0})}async function D(O){if(O.preventDefault(),T)return;const U=F(),K=VO(U);if(!K.ok){_(K.errors.join("; "));return}R(!0),_(null);const M=e.kind==="token-usage"?{kind:"token-usage",filters:U}:e.kind==="spend"?{kind:"spend",filters:U}:e;try{await n(M)}catch(V){_(V instanceof Error?V.message:String(V)),R(!1)}}const W=(i==null?void 0:i.map(O=>O.slug))??[],H=(a==null?void 0:a.workspaces)??[],$=(a==null?void 0:a.hasUngrouped)??!1;return s.jsx(Ln,{open:t,onOpenChange:O=>{O||r()},children:s.jsx(Sn,{className:"max-w-md",children:s.jsxs("form",{onSubmit:D,children:[s.jsx(or,{children:s.jsx(Cn,{children:o})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:am.map(O=>s.jsx("button",{type:"button",onClick:()=>f(O),className:"rounded px-2.5 py-1 text-sm border "+(O===u?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:u9[O]},O))})]}),u==="custom"?s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:p,onChange:O=>h(O.target.value),className:yl})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:g,onChange:O=>y(O.target.value),className:yl})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:b,onChange:O=>{j(O.target.value),O.target.value&&v("")},className:yl,children:[s.jsx("option",{value:"",children:"All workspaces"}),$?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,H.map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:k,onChange:O=>{v(O.target.value),O.target.value&&j("")},className:yl,children:[s.jsx("option",{value:"",children:"All projects"}),W.map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:S,onChange:O=>N(O.target.value),className:yl,children:[s.jsx("option",{value:"",children:"All models"}),((l==null?void 0:l.models)??[]).map(O=>s.jsx("option",{value:O,children:O},O))]})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:C,onChange:O=>P(O.target.value),className:yl,children:[s.jsx("option",{value:"",children:"All tools"}),((l==null?void 0:l.tools)??[]).map(O=>s.jsx("option",{value:O,children:O},O))]})]})]}),I?s.jsx("p",{className:"text-xs text-destructive",role:"alert",children:I}):null]}),s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:r,disabled:T,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:T,className:"shell-action shell-action--cta",children:T?"Saving…":"Save"})]})]})})})}const Yw={"saved-view":{title:"Saved view",icon:b2,render:(e,t)=>e.kind!=="saved-view"?null:m.createElement(OH,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:em,render:(e,t)=>e.kind!=="agent-sessions"?null:m.createElement(i9,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:Uv,render:()=>m.createElement(l9)},"token-usage":{title:"Token Usage",icon:k4,render:e=>e.kind!=="token-usage"?null:m.createElement(BN,{filters:e.filters,metric:"tokens"}),ConfigEditor:HN},spend:{title:"Spend",icon:om,render:e=>e.kind!=="spend"?null:m.createElement(BN,{filters:e.filters,metric:"cost"}),ConfigEditor:HN}},aP=50,Qb=16,f9=2,da=6,Th=11,Jb={w:6,h:2};function Xp(e,t,n){return Math.min(Math.max(e,t),n)}const p9=[{minWidth:1280,columns:24},{minWidth:1024,columns:16},{minWidth:768,columns:12},{minWidth:640,columns:6},{minWidth:0,columns:1}];function h9(e){if(!Number.isFinite(e)||e<0)return 1;for(const t of p9)if(e>=t.minWidth)return t.columns;return 1}function Qp(e,t){return t<=0?1:Xp(Math.round(e/dd*t),1,t)}function Zb(e){if(k7(e))return e;switch(e){case"small":return{w:8,h:da};case"wide":return{w:16,h:da};case"tall":return{w:8,h:Th};case"large":return{w:16,h:Th};default:return{w:8,h:da}}}function m9(e,t){return t>0?Math.round(e/t):0}function g9(e,t=aP){return Math.round(e/t)}const x9=[{label:"Third",w:8,h:da},{label:"Half",w:12,h:da},{label:"Two-thirds",w:16,h:da},{label:"Full",w:24,h:da},{label:"Half tall",w:12,h:Th},{label:"Full tall",w:24,h:Th}];function y9({slot:e,activeColumns:t,colWidthPx:n,onReplace:r,onRemove:o,onRemoveSlot:i,onResize:a,onConfigChange:l}){const[u,f]=m.useState(!1),[p,h]=m.useState(null),g=m.useRef(null),{attributes:y,listeners:k,setNodeRef:v,setActivatorNodeRef:b,transform:j,transition:S,isDragging:N}=Rm({id:e.id}),C=Zb(e.size),P=p?p.renderW:Qp(C.w,t),T=p?p.h:C.h,R={transform:js.Translate.toString(j),transition:S,zIndex:N?50:void 0,position:N?"relative":void 0,gridColumn:`span ${P}`,gridRow:`span ${T}`};function I(U){g.current=null;try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}h(null)}function _(U){return{onPointerDown:K=>{if(g.current)return;K.preventDefault(),K.stopPropagation(),K.currentTarget.setPointerCapture(K.pointerId);const M=Qp(C.w,t);g.current={pointerId:K.pointerId,startX:K.clientX,startY:K.clientY,startRenderW:M,startH:C.h,axis:U,lastRenderW:M,lastH:C.h},h({renderW:M,h:C.h})},onPointerMove:K=>{const M=g.current;if(!M||K.pointerId!==M.pointerId)return;let V=M.startRenderW,L=M.startH;(M.axis==="w"||M.axis==="both")&&(V=Xp(M.startRenderW+m9(K.clientX-M.startX,n),1,t)),(M.axis==="h"||M.axis==="both")&&(L=Xp(M.startH+g9(K.clientY-M.startY),f9,eA)),M.lastRenderW=V,M.lastH=L,h({renderW:V,h:L})},onPointerUp:K=>{const M=g.current;if(!M||K.pointerId!==M.pointerId)return;const V=Zb(e.size),z={w:M.axis==="h"?V.w:Xp(Math.round(M.lastRenderW/t*dd),1,dd),h:M.lastH};I(K),(z.w!==V.w||z.h!==V.h)&&a(z)},onPointerCancel:K=>{const M=g.current;M&&K.pointerId===M.pointerId&&I(K)},onLostPointerCapture:K=>{const M=g.current;M&&K.pointerId===M.pointerId&&I(K)}}}const F="absolute z-10 touch-none rounded-sm bg-transparent transition hover:bg-primary/30",D=s.jsxs(s.Fragment,{children:[t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"right-0 top-0 h-full w-1.5 cursor-ew-resize"),..._("w")}):null,s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 left-0 h-1.5 w-full cursor-ns-resize"),..._("h")}),t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 right-0 h-3 w-3 cursor-nwse-resize"),..._("both")}):null]}),W=s.jsx("button",{ref:b,...y,...k,type:"button","aria-label":"Drag to reorder widget",className:"touch-none cursor-grab text-muted-foreground/40 transition hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing",children:s.jsx(yc,{className:"h-4 w-4","aria-hidden":"true"})});if(e.widget===null)return s.jsxs("div",{ref:v,style:{...R,gridColumn:`span ${Qp(Jb.w,t)}`,gridRow:`span ${Jb.h}`},className:je("relative flex items-center justify-center rounded-lg border border-dashed border-border bg-card/40 p-3 shadow-sm transition-colors hover:border-primary/40 hover:bg-card/60",N&&"opacity-0"),children:[s.jsx("div",{className:"absolute left-2 top-2",children:W}),s.jsx("button",{type:"button","aria-label":"Remove slot",onClick:i,onPointerDown:U=>U.stopPropagation(),className:"absolute right-2 top-2 z-10 text-muted-foreground/50 transition hover:text-destructive",children:s.jsx(mn,{className:"h-4 w-4"})}),s.jsxs("button",{type:"button",onClick:r,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Pt,{className:"h-4 w-4"}),"Add widget"]})]});const H=Yw[e.widget.kind];if(!H)return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",N&&"opacity-0"),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[W,s.jsxs("div",{className:"flex-1 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]})]}),D]});const $=H.icon,O=H.ConfigEditor;return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",N&&"opacity-0"),children:[s.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[W,s.jsx($,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:s.jsx(v9,{slot:e,fallback:H.title})})]}),s.jsx(Kw,{items:[{key:"replace",label:"Replace…",icon:$4,onSelect:r},...H.ConfigEditor?[{key:"configure",label:"Configure…",icon:z4,onSelect:()=>f(!0)}]:[],{key:"size",label:"Size",icon:v2,submenu:x9.map(U=>({key:`size-${U.label}`,label:U.label,active:C.w===U.w&&C.h===U.h,onSelect:()=>a({w:U.w,h:U.h})}))},{key:"remove",label:"Remove",icon:mn,destructive:!0,onSelect:o}]})]}),s.jsx("div",{children:H.render(e.widget,{slotId:e.id,onPickAnother:r})}),O?s.jsx(O,{config:e.widget,open:u,onSave:async U=>{await l(U),f(!1)},onCancel:()=>f(!1)}):null,D]})}function b9({slot:e,activeColumns:t,colWidthPx:n}){const r=e.widget?Yw[e.widget.kind]:null,o=r==null?void 0:r.icon,i=e.widget===null?"Empty widget slot":(r==null?void 0:r.title)??`Unknown widget kind: ${e.widget.kind}`,a=e.widget===null?Jb:Zb(e.size),l=Qp(a.w,t),u=n>0?l*n+(l-1)*Qb:void 0;return s.jsx("div",{"aria-hidden":"true",className:"min-w-[200px] rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",style:{width:u?`${Math.max(u,200)}px`:void 0},children:s.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[s.jsx(yc,{className:"h-4 w-4","aria-hidden":"true"}),o?s.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,s.jsx("span",{className:"min-w-0 flex-1 truncate",children:i})]})})}function v9({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:r}=Ni(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&r?s.jsx(s.Fragment,{children:r.name}):s.jsx(s.Fragment,{children:t})}const w9=["agent-sessions","inventories","token-usage","spend"];function j9({open:e,onOpenChange:t,onSelect:n}){const{views:r,loading:o}=Ud();function i(a){n(a),t(!1)}return s.jsx(Ln,{open:e,onOpenChange:t,children:s.jsxs(Sn,{className:"max-w-xl",children:[s.jsxs(or,{children:[s.jsx(Cn,{children:"Add a widget"}),s.jsx(ns,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:w9.map(a=>{const l=Yw[a],u=l.icon;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:a}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx(u,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsx("span",{className:"font-medium text-foreground",children:l.title})]})},a)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?s.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):r.length===0?s.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),s.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",s.jsx($e,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):s.jsxs("div",{className:"space-y-3",children:[r.some(a=>a.entityType!=="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType!=="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null,s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:a.config.viewMode})]})},a.id))})]}),r.some(a=>a.entityType==="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType==="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null]})},a.id))})]})]}),!o&&r.some(a=>a.workspace!==null)?s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}const k9=(e,{currentCoordinates:t,context:n})=>{var h;const r=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(r===0)return;e.preventDefault();const o=n.over??n.active,i=(h=o==null?void 0:o.data.current)==null?void 0:h.sortable,a=i==null?void 0:i.items;if(!o||!a)return t;const l=a.indexOf(o.id);if(l===-1)return t;const u=a[l+r],f=u===void 0?null:n.droppableRects.get(u),p=n.collisionRect;return!f||!p?t:{x:f.left+(f.width-p.width)/2,y:f.top+(f.height-p.height)/2}};function N9(e){const t=new Set(e.map(o=>o.id));let n=-1;for(const o of t){const i=/^slot-(\d+)$/.exec(o);if(i){const a=parseInt(i[1],10);a>n&&(n=a)}}let r=n+1;for(;t.has(`slot-${r}`);)r++;return`slot-${r}`}function S9(e,t){const n={id:N9(e),widget:null};return[...e,n]}function C9(e,t){return e.filter(n=>n.id!==t)}function E9(){const{data:e,error:t,refetch:n}=qO(),{data:r}=G2(),{layout:o}=lA(),[i,a]=m.useState(!1),[l,u]=m.useState(null),[f,p]=m.useState(null),[h,g]=m.useState(o.slots),[y,k]=m.useState(null),v=m.useRef(null),[b,j]=m.useState(dd),[S,N]=m.useState(0);m.useEffect(()=>{const K=v.current;if(!K)return;const M=new ResizeObserver(V=>{for(const L of V){const z=L.contentRect.width,Y=h9(z),B=Y>0?(z-(Y-1)*Qb)/Y:0;j(Y),N(B)}});return M.observe(K),()=>M.disconnect()},[]),m.useEffect(()=>{g(o.slots)},[o.slots]);const C=jm(ki(Ec,{activationConstraint:{distance:8}}),ki(Cc,{coordinateGetter:k9}));Pi("list:overview"),en({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const P=m.useCallback(K=>{u(K),a(!0)},[]),T=m.useCallback(async(K,M)=>{p(null),g(K);try{await Bb(K)}catch(V){g(M),p(V instanceof Error?V.message:String(V))}},[]),R=m.useCallback(K=>{if(l===null)return;const M=h.map((V,L)=>L===l?{...V,widget:K}:V);u(null),T(M,h)},[h,l,T]),I=m.useCallback(K=>{const M=h.map((V,L)=>L===K?{...V,widget:null,size:void 0}:V);T(M,h)},[h,T]),_=m.useCallback(K=>{const M=C9(h,K);T(M,h)},[h,T]),F=m.useCallback(()=>{const K=S9(h);T(K,h)},[h,T]),D=m.useCallback((K,M)=>{const V=h.map((L,z)=>z===K?{...L,size:M}:L);T(V,h)},[h,T]),W=m.useCallback(K=>{const{active:M,over:V}=K;if(k(null),!V||M.id===V.id)return;const L=h.findIndex(B=>B.id===M.id),z=h.findIndex(B=>B.id===V.id);if(L===-1||z===-1)return;const Y=Tc(h,L,z);T(Y,h)},[h,T]),H=m.useCallback(K=>{k(String(K.active.id))},[]),$=h.find(K=>K.id===y)??null,O=m.useCallback(async(K,M)=>{const V=h,L=h.map((z,Y)=>Y===K?{...z,widget:M}:z);p(null),g(L);try{await Bb(L)}catch(z){g(V);const Y=z instanceof Error?z.message:String(z);throw p(Y),z instanceof Error?z:new Error(Y)}},[h]),U={};if(e)for(const K of Object.keys(e.segments))for(const M of e.segments[K].items)U[M.id]=M;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("header",{className:"space-y-2",children:[s.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),s.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?s.jsx(w7,{hero:e.hero,itemsById:U}):t?s.jsx(Rt,{error:t,onRetry:n}):s.jsx(bt,{label:"Loading overview…"}),e!=null&&e.firstRun?s.jsx(b7,{help:r}):null,f?s.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: ",f]}):null,s.jsxs(Em,{sensors:C,collisionDetection:km,onDragStart:H,onDragCancel:()=>k(null),onDragEnd:W,children:[s.jsx(Tm,{items:h.map(K=>K.id),strategy:_w,children:s.jsx("div",{ref:v,style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gridAutoRows:`${aP}px`,gridAutoFlow:"dense",gap:`${Qb}px`},children:h.map((K,M)=>s.jsx(y9,{slot:K,index:M,activeColumns:b,colWidthPx:S,onReplace:()=>P(M),onRemove:()=>I(M),onRemoveSlot:()=>_(K.id),onResize:V=>D(M,V),onConfigChange:V=>O(M,V)},K.id))})}),s.jsx(o7,{dropAnimation:null,children:$?s.jsx(b9,{slot:$,activeColumns:b,colWidthPx:S}):null})]}),s.jsxs("button",{type:"button",onClick:F,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Pt,{className:"h-4 w-4"}),"Add slot"]}),e!=null&&e.serverStats?s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Gv,{className:"h-3 w-3","aria-hidden":"true"}),s.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,s.jsx(j9,{open:i,onOpenChange:K=>{a(K),K||u(null)},onSelect:R})]})}const T9=["review","blocked","question","plan-approval"],R9={review:"Review",blocked:"Blocked",question:"Questions","plan-approval":"Plan approval"};function A9(e){const t=[];for(const n of T9){const r=e.filter(o=>o.category===n).sort((o,i)=>i.ageMs-o.ageMs);r.length!==0&&t.push({category:n,label:R9[n],count:r.length,items:r})}return t}function P9(e){if(!Number.isFinite(e)||e<0)return"just now";const t=Math.floor(e/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function lP(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/transitions/${n}`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/transitions/${n}`}}function _9(e){return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments`}}function D9(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"PATCH",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments/${n}/resolved`}:{method:"PATCH",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments/${n}/resolved`}}function Xw(e,t){const n=t?`?tab=${t}`:"";return e.project===null?`/assignments/${encodeURIComponent(e.assignmentId)}${n}`:`/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}${n}`}function $9(){const{items:e,total:t,loading:n,error:r,refetch:o}=rR(),{toast:i,showToast:a,dismissToast:l}=Qn();if(n&&e.length===0)return s.jsx(bt,{label:"Loading your inbox…"});if(r&&e.length===0)return s.jsx(Rt,{title:"Inbox unavailable",error:r,action:s.jsx("button",{type:"button",className:"shell-action",onClick:o,children:"Retry"})});const u=A9(e);return u.length===0?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(VN,{total:0}),s.jsx(Nt,{title:"Nothing needs you right now",description:"No reviews, blocks, open questions, or plans awaiting approval across your projects. New items appear here the moment something needs a human decision."})]}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(VN,{total:t}),u.map(f=>s.jsx(Ke,{title:f.label,actions:s.jsx("span",{className:"rounded-full bg-foreground px-2.5 py-0.5 text-xs font-semibold text-background",children:f.count}),children:s.jsx("ul",{className:"space-y-3",children:f.items.map(p=>s.jsx(I9,{item:p,onMutated:o,onError:h=>a(h,"error"),onSuccess:h=>a(h,"success")},`${p.category}:${p.assignmentId}:${p.since}`))})},f.category))]})}function VN({total:e}){return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:s.jsx(y2,{className:"h-4 w-4"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Needs me"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e===0?"Everything is handled.":`${e} ${e===1?"item":"items"} awaiting your decision.`})]})]})}async function Rh(e,t,n,r){try{const o=await fetch(e.url,{method:e.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){const i=await o.json().catch(()=>null);throw new Error((i==null?void 0:i.error)||`HTTP ${o.status}`)}return n.onSuccess(r),n.onMutated(),!0}catch(o){return n.onError(o instanceof Error?o.message:String(o)),!1}}function I9({item:e,onMutated:t,onError:n,onSuccess:r}){return s.jsxs("li",{className:"flex flex-col gap-2 rounded-lg border border-border/70 bg-background/40 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[s.jsx($e,{to:Xw(e),className:"text-sm font-semibold text-foreground hover:underline",children:e.title}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.project?e.project:"standalone"}),s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",title:e.since,children:P9(e.ageMs)})]}),e.summary?s.jsx("p",{className:"text-sm text-muted-foreground",children:e.summary}):null,s.jsx(M9,{item:e,onMutated:t,onError:n,onSuccess:r}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted/60 px-2 py-1 font-mono text-[11px] text-muted-foreground",children:e.action.command}),s.jsx(Hr,{value:e.action.command,label:"Copy",onError:o=>n(o.message)})]})]})}function M9(e){switch(e.item.category){case"review":return s.jsx(L9,{...e});case"blocked":return s.jsx(O9,{...e});case"question":return s.jsx(F9,{...e});case"plan-approval":return s.jsx(z9,{...e});default:return null}}const xa="shell-action inline-flex items-center gap-1.5";function L9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(null),{acceptCommand:a,reopenCommand:l}=e;async function u(f,p){i(f),await Rh(lP(e,f),void 0,{onMutated:t,onError:n,onSuccess:r},`${p} — ${e.title}`),i(null)}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?s.jsxs("button",{type:"button",className:xa,disabled:o!==null,onClick:()=>u(a,"Accepted"),children:[s.jsx(Nr,{className:"h-3.5 w-3.5"}),o===a?"Accepting…":"Accept"]}):null,l?s.jsxs("button",{type:"button",className:xa,disabled:o!==null,onClick:()=>u(l,"Reopened"),children:[s.jsx(vs,{className:"h-3.5 w-3.5"}),o===l?"Reopening…":"Reopen"]}):null]})}function O9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1);async function u(){l(!0);const f=await Rh(lP(e,"unblock"),o.trim()?{reason:o.trim()}:void 0,{onMutated:t,onError:n,onSuccess:r},`Unblocked — ${e.title}`);l(!1),f&&i("")}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:f=>i(f.target.value),placeholder:"Reason (optional)",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:xa,disabled:a,onClick:u,children:[s.jsx(A4,{className:"h-3.5 w-3.5"}),a?"Unblocking…":"Unblock"]})]})}function F9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1),u=e.commentId;async function f(){if(!o.trim())return;l(!0);const h=await Rh(_9(e),{body:o.trim(),type:"note",author:"human",...u?{replyTo:u}:{}},{onMutated:t,onError:n,onSuccess:r},`Replied — ${e.title}`);l(!1),h&&i("")}async function p(){if(!u){n("Could not determine which question to resolve — open the assignment to resolve it.");return}l(!0),await Rh({...D9(e,u)},{resolved:!0},{onMutated:t,onError:n,onSuccess:r},`Resolved — ${e.title}`),l(!1)}return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs($e,{to:Xw(e,"comments"),className:xa,children:[s.jsx(rm,{className:"h-3.5 w-3.5"}),"Open to answer"]}),s.jsxs("button",{type:"button",className:xa,disabled:a||!u,title:u?void 0:"Open the assignment to resolve this question.",onClick:p,children:[s.jsx(sm,{className:"h-3.5 w-3.5"}),"Resolve"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),placeholder:"Reply inline…",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:xa,disabled:a||!o.trim(),onClick:f,children:[s.jsx(m2,{className:"h-3.5 w-3.5"}),a?"Posting…":"Reply"]})]})]})}function z9({item:e}){return s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs($e,{to:Xw(e,"plan"),className:xa,children:[s.jsx(rm,{className:"h-3.5 w-3.5"}),"Review plan"]})})}function B9({term:e,description:t}){return s.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 U9(){const{data:e,loading:t,error:n}=G2(),{openCheatsheet:r}=Ai();return t?s.jsx(bt,{label:"Loading help…"}):n||!e?s.jsx(Rt,{error:n||"Help content is unavailable."}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Ke,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:r,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"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Zs("Mod+k")," opens the command palette."]})]})}),s.jsx(Ke,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),s.jsx(Ke,{title:"Getting Started",children:s.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Kp,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?s.jsx($e,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsxs(Ke,{title:"Core Concepts",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>s.jsx(B9,{term:o.term,description:o.description},o.term))}),s.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),s.jsx(Ke,{title:"Status Guide",children:s.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:o.status}),s.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),s.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Ke,{title:"Ownership And File Rules",children:s.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),s.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>s.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:i},i))})]},o.label))})}),s.jsx(Ke,{title:"How To Navigate The Dashboard",children:s.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx($e,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),s.jsx(Ke,{title:"CLI Quick Reference",children:s.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>s.jsx(Kp,{command:o.command,description:o.description,example:o.example},o.command))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(Ke,{title:"FAQ",children:s.jsx("div",{className:"space-y-3",children:e.faq.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),s.jsx(Ke,{title:"First Project Checklist",children:s.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Kp,{command:o.command.command,example:o.command.example}):null,o.href?s.jsx($e,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function Qw({children:e}){return s.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 Um=m.forwardRef(({value:e,onChange:t,placeholder:n="Search"},r)=>s.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[s.jsx(Ei,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),s.jsx("input",{ref:r,value:e,onChange:o=>t(o.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"})]}));Um.displayName="SearchInput";function Hm({value:e,options:t,onChange:n}){return s.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(r=>s.jsx("button",{type:"button","aria-pressed":e===r.value,onClick:()=>n(r.value),className:je("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===r.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}const H9={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"},WN=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function Ah({progress:e,className:t,showLegend:n=!1}){const r=As(),i=m.useMemo(()=>{let a=0;const l=Object.keys(e).filter(f=>f!=="total");return(r.order.length>0?[...r.order,...l.filter(f=>!r.order.includes(f))]:l).map(f=>({key:f,className:H9[f]??WN[a++%WN.length]}))},[r.order,e]).filter(a=>(e[a.key]??0)>0);return s.jsxs("div",{className:je("space-y-2",t),children:[s.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?s.jsx("div",{className:"h-full w-full bg-muted"}):i.map(a=>s.jsx("div",{className:a.className,style:{width:`${(e[a.key]??0)/e.total*100}%`},title:`${vn(a.key)}: ${e[a.key]??0}`},a.key))}),n?i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[s.jsx("span",{className:je("h-2 w-2 rounded-full",a.className)}),s.jsx("span",{children:vn(a.key)}),s.jsx("span",{className:"font-medium text-foreground",children:e[a.key]??0})]},a.key))}):s.jsx("p",{className:"text-xs text-muted-foreground/70",children:"No assignments yet"}):null]})}const V9=["pending","active","blocked","failed","completed"],Jw=V9,W9=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function cP(e){return e&&e.length>0?e:[...W9]}function K9(e,t,n){if(t<0||t>=e.length)return e;const r=[...e],[o]=r.splice(t,1),i=t<n?n-1:n;return r.splice(Math.max(0,Math.min(i,r.length)),0,o),r}const q9=220,xp=8;function uP({anchor:e,items:t,onClose:n}){const r=m.useRef(null),[o,i]=m.useState(null);return m.useLayoutEffect(()=>{if(!e){i(null);return}const a=r.current,l=(a==null?void 0:a.offsetWidth)??q9,u=(a==null?void 0:a.offsetHeight)??0,f=Math.max(xp,window.innerWidth-l-xp),p=Math.max(xp,window.innerHeight-u-xp);i({left:Math.min(e.x,f),top:Math.min(e.y,p)})},[e]),m.useEffect(()=>{if(!e)return;function a(f){r.current&&!r.current.contains(f.target)&&n()}function l(f){f.key==="Escape"&&n()}function u(){n()}return document.addEventListener("mousedown",a),document.addEventListener("keydown",l),document.addEventListener("contextmenu",a),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",l),document.removeEventListener("contextmenu",a),window.removeEventListener("scroll",u,!0)}},[e,n]),!e||t.length===0?null:s.jsx("div",{ref:r,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(o==null?void 0:o.left)??e.x,top:(o==null?void 0:o.top)??e.y,visibility:o?"visible":"hidden"},children:s.jsx(ma,{delayDuration:200,children:t.map(a=>{const l=a.icon,u=je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",a.disabled?"cursor-not-allowed opacity-50":a.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),f=s.jsxs(s.Fragment,{children:[l?s.jsx(l,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 truncate",children:a.label})]});if(a.disabled){const p=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:u,children:f})});return a.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:p}),s.jsx(vr,{side:"left",children:a.disabledReason})]},a.key):s.jsx("div",{children:p},a.key)}return a.href?s.jsx($e,{to:a.href,className:u,onClick:()=>n(),children:f},a.key):s.jsx("button",{type:"button",className:u,onClick:()=>{var p;(p=a.onSelect)==null||p.call(a),n()},children:f},a.key)})})})}const G9="__ungrouped__";function Zw({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:r,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:a,loading:l}=Ta(),[u,f]=m.useState(n),[p,h]=m.useState(!1),[g,y]=m.useState(null);m.useEffect(()=>{e&&(f(n),y(null))},[e,n]);const k=m.useMemo(()=>[...((a==null?void 0:a.workspaces)??[]).map(S=>({key:S,label:S,value:S})),{key:G9,label:"Ungrouped",value:null}],[a]),v=!p&&u!==n;async function b(){if(v){h(!0),y(null);try{await r(u),t(!1)}catch(j){y(j instanceof Error?j.message:"Failed to move item")}finally{h(!1)}}}return s.jsx(Ln,{open:e,onOpenChange:j=>p?void 0:t(j),children:s.jsxs(Sn,{children:[s.jsxs(or,{children:[s.jsx(Cn,{children:o}),s.jsx(ns,{children:i})]}),s.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:l&&k.length===0?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[s.jsx(qv,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):k.map(j=>{const S=j.value===n,N=j.value===u;return s.jsxs("button",{type:"button",disabled:S||p,onClick:()=>f(j.value),className:je("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",S?"cursor-not-allowed bg-foreground/5 text-muted-foreground":N?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:je("block min-w-0 truncate",j.value===null?"italic text-muted-foreground":""),children:[j.label,S?s.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),N?s.jsx(Nr,{className:"h-4 w-4 text-foreground"}):null]},j.key)})}),g?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:g}):null,s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),disabled:p,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:b,disabled:!v,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p?"Moving…":"Move"})]})]})})}function KN(){const{workspace:e}=Kt(),t=gn(),n=Wt(),{data:r,loading:o,error:i,refetch:a}=ro(),{toast:l,showToast:u,dismissToast:f}=Qn(),p=m.useRef(null);Pi("list:projects");const[h,g]=m.useState(""),[y,k]=m.useState("all"),[v,b]=m.useState("all"),[j,S]=m.useState("updated"),[N,C]=Ts(),P=N.get("view"),T=P==="table"||P==="kanban"?P:"cards",R=z=>{C(Y=>{const B=new URLSearchParams(Y);return z==="cards"?B.delete("view"):B.set("view",z),B})},[I,_]=m.useState({}),[F,D]=m.useState(null),[W,H]=m.useState(null),$=m.useMemo(()=>r?r.filter(z=>{if(e){if(e==="_ungrouped"){if(z.workspace!==null)return!1}else if(z.workspace!==e)return!1}return y!=="all"&&z.status!==y||v!=="all"&&!z.tags.includes(v)?!1:h.trim()?`${z.title} ${z.tags.join(" ")} ${z.slug}`.toLowerCase().includes(h.toLowerCase()):!0}).sort((z,Y)=>X9(z,Y,j)):[],[r,h,y,v,j,e]),O=$.map(z=>`${z.slug}:${z.status}`).join("|");m.useEffect(()=>{_(Q9($))},[O,j]);const U=m.useMemo(()=>{const z=new Map($.map(Y=>[Y.slug,Y]));return Jw.flatMap(Y=>(I[Y]??$.filter(Q=>Q.status===Y).map(Q=>Q.slug)).map(Q=>z.get(Q)).filter(Q=>!!Q))},[$,I]),{visibleItems:K,visibleIndexByKey:M}=m.useMemo(()=>{const z=T==="kanban"?U:$,Y=new Map;return z.forEach((B,Q)=>Y.set(B.slug,Q)),{visibleItems:z,visibleIndexByKey:Y}},[T,$,U]),{hotkeyRowProps:V}=Ld(K,{scope:"list:projects",onOpen:z=>n(`${t}/projects/${z.slug}`)});if(en({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var z;return(z=p.current)==null?void 0:z.focus()}}),en({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>a()}),o)return s.jsx(bt,{label:"Loading projects…"});if(i||!r)return s.jsx(Rt,{error:i||"Project list is unavailable.",onRetry:a});const L=Array.from(new Set(r.flatMap(z=>z.tags))).sort();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:l,onDismiss:f}),s.jsxs(Qw,{children:[s.jsx(Um,{ref:p,value:h,onChange:g,placeholder:"Search by project title or tag"}),s.jsxs("select",{value:y,onChange:z=>k(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All statuses"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"blocked",children:"Blocked"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"completed",children:"Completed"})]}),s.jsxs("select",{value:v,onChange:z=>b(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All tags"}),L.map(z=>s.jsx("option",{value:z,children:z},z))]}),s.jsxs("select",{value:j,onChange:z=>S(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"updated",children:"Sort: Updated"}),s.jsx("option",{value:"created",children:"Sort: Created"}),s.jsx("option",{value:"title",children:"Sort: Title"}),s.jsx("option",{value:"attention",children:"Sort: Attention"})]}),s.jsx(Hm,{value:T,onChange:z=>R(z),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),$.length===0?r.length===0?s.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[s.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),s.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"}),s.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."}),s.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[s.jsx($e,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),s.jsx($e,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):s.jsx(Nt,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:s.jsx($e,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):T==="cards"?s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:$.map((z,Y)=>s.jsxs($e,{to:`${t}/projects/${z.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...V(Y),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:z.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(z.updated)]})]}),s.jsx(kn,{status:z.status})]}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsx(Ah,{progress:z.progress,showLegend:!0}),s.jsx("div",{className:"flex flex-wrap gap-2",children:z.tags.map(B=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:B},B))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount})]}),s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.progress.total})]})]})]})]},z.slug))}):T==="table"?s.jsx(Ke,{title:`${$.length} project${$.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"pb-3 font-medium",children:"Project"}),s.jsx("th",{className:"pb-3 font-medium",children:"Status"}),s.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),s.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),s.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:$.map((z,Y)=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",...V(Y),children:[s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx($e,{to:`${t}/projects/${z.slug}`,className:"font-semibold text-foreground hover:text-primary",children:z.title}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:z.tags.map(B=>s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:B},B))})]}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx(kn,{status:z.status})}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx("div",{className:"min-w-[220px]",children:s.jsx(Ah,{progress:z.progress})})}),s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount}),s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(z.updated)})]},z.slug))})]})})}):s.jsx(Fm,{columns:qN,items:U,getItemId:z=>z.slug,getColumnId:z=>z.status,canDrop:({fromColumnId:z,toColumnId:Y})=>({allowed:!0,reason:z===Y?void 0:"This will set a manual status override on the project."}),onMove:async({item:z,fromColumnId:Y,toColumnId:B,fromIndex:Q,toIndex:J})=>{var Z;if(Y===B){const oe=I[Y]??$.filter(ne=>ne.status===Y).map(ne=>ne.slug);_(ne=>({...ne,[Y]:K9(oe,Q,J)}));return}try{const oe=await fetch(`/api/projects/${z.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:B})});if(!oe.ok){const ue=await oe.json().catch(()=>null);u((ue==null?void 0:ue.error)||`HTTP ${oe.status}`,"error");return}a();const ne=((Z=qN.find(ue=>ue.id===B))==null?void 0:Z.title)??B;u(`Moved "${z.title}" to ${ne}`,"success")}catch(oe){u(oe instanceof Error?oe.message:"Failed to move project","error")}},getExternalDragData:z=>({type:"project",id:z.slug}),onCardContextMenu:(z,Y)=>{Y.preventDefault(),D({project:z,anchor:{x:Y.clientX,y:Y.clientY}})},emptyMessage:z=>`No ${z.title.toLowerCase()} projects.`,renderCard:(z,{dragging:Y})=>{const B=M.get(z.slug)??-1;return s.jsx("div",{...B>=0?V(B):{},children:s.jsx(J9,{project:z,dragging:Y})})}}),s.jsx(uP,{anchor:(F==null?void 0:F.anchor)??null,items:F?[{key:"edit",label:"Edit",icon:bc,onSelect:()=>n(`${t}/projects/${F.project.slug}`)},{key:"move",label:"Move to workspace…",icon:nm,onSelect:()=>H(F.project)}]:[],onClose:()=>D(null)}),s.jsx(Zw,{open:W!==null,onOpenChange:z=>{z||H(null)},currentWorkspace:(W==null?void 0:W.workspace)??null,title:"Move project to workspace",onSubmit:async z=>{if(!W)return;const Y=await fetch(`/api/projects/${encodeURIComponent(W.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:z})});if(!Y.ok){const B=await Y.json().catch(()=>({}));throw new Error(B.error||"Failed to move project")}a()}}),s.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Kv,{className:"mt-0.5 h-4 w-4"}),s.jsxs("p",{children:["Project status is derived from assignment state by default.",T==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const Y9={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},qN=Jw.map(e=>({id:e,title:Y9[e],description:Kd(e)}));function X9(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return GN(t)-GN(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function GN(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function Q9(e){return Object.fromEntries(Jw.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function J9({project:e,dragging:t}){const n=gn();return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx($e,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(e.updated)]})]}),s.jsx(kn,{status:e.status})]}),s.jsx("div",{className:"mt-4",children:s.jsx(Ah,{progress:e.progress})}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(r=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:r},r)),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),s.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"]})]}),s.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function Ph({title:e,description:t,actions:n,className:r}){return s.jsxs("div",{className:je("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",r),children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?s.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function Z9(){return s.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:[s.jsx(tm,{className:"h-3 w-3"}),"Archived"]})}function YN(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function eV(){const{data:e,loading:t,error:n,refetch:r}=GO(),[o,i]=m.useState(null),[a,l]=m.useState(null),[u,f]=m.useState({}),{toast:p,showToast:h,dismissToast:g}=Qn();async function y(N,C,P){i(C),l(null);try{const T=await fetch(N,{method:"POST",headers:{"Content-Type":"application/json"}});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)||`HTTP ${T.status}`)}r(),h(P,"success")}catch(T){l(T instanceof Error?T.message:"Restore failed")}finally{i(null)}}function k(N){return y(`/api/projects/${N.slug}/unarchive`,`project:${N.slug}`,"Project restored")}function v(N){const C=N.projectSlug?`/api/projects/${N.projectSlug}/assignments/${N.slug}/unarchive`:`/api/assignments/${N.id}/unarchive`;return y(C,`assignment:${N.id}`,"Assignment restored")}if(t)return s.jsx(bt,{label:"Loading archived content…"});if(n)return s.jsx(Rt,{error:n});const b=(e==null?void 0:e.projects)??[],j=(e==null?void 0:e.assignments)??[],S=b.length===0&&j.length===0;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Xn,{toast:p,onDismiss:g}),s.jsx(Ph,{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."}),a?s.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:a}):null,S?s.jsx(Nt,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):s.jsxs(s.Fragment,{children:[b.length>0&&s.jsx(Ke,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:s.jsx("ul",{className:"divide-y divide-border",children:b.map(N=>{const C=u[N.slug]??!1;return s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>f(P=>({...P,[N.slug]:!C})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":C,children:[C?s.jsx(nr,{className:"h-4 w-4"}):s.jsx(Hv,{className:"h-4 w-4"}),s.jsx(Vv,{className:"h-4 w-4 text-muted-foreground"}),N.title,s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",N.assignments.length," assignment",N.assignments.length===1?"":"s",")"]})]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",N.archivedAt?Sr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx($e,{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"}),s.jsxs("button",{type:"button",onClick:()=>k(N),disabled:o===`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:[s.jsx(oh,{className:"h-3 w-3"}),"Restore"]})]})]}),C&&N.assignments.length>0&&s.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:N.assignments.map(P=>s.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsx($e,{to:YN(P),className:"text-foreground hover:text-foreground/80",children:P.title}),s.jsx(kn,{status:P.status,showIcon:!1}),s.jsx("span",{className:"text-xs text-muted-foreground",children:P.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},P.id))})]},N.slug)})})}),j.length>0&&s.jsx(Ke,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:s.jsx("ul",{className:"divide-y divide-border",children:j.map(N=>s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsx($e,{to:YN(N),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:N.title}),s.jsx(kn,{status:N.status,showIcon:!1}),s.jsx(Z9,{}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[N.projectTitle??"Standalone"," · Archived"," ",N.archivedAt?Sr(N.archivedAt):"with no timestamp",N.archivedReason?` · ${N.archivedReason}`:""]}),s.jsxs("button",{type:"button",onClick:()=>v(N),disabled:o===`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:[s.jsx(oh,{className:"h-3 w-3"}),"Restore"]})]},N.id))})})]})]})}const XN="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",QN="block min-w-0 truncate";function e0({externalIds:e,className:t}){return e.length===0?null:s.jsx("span",{className:je("flex flex-wrap items-center gap-1.5",t),children:e.map((n,r)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${r}`;return n.url!=null&&n.url.length>0?s.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:je(XN,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[s.jsx("span",{className:QN,children:o}),s.jsx(xc,{className:"h-2.5 w-2.5 shrink-0"})]},i):s.jsx("span",{className:XN,title:o,children:s.jsx("span",{className:QN,children:o})},i)})})}const tV={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 Gn({label:e,value:t,description:n,icon:r,tone:o="default",to:i}){const a=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),s.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),r?s.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:s.jsx(r,{className:"h-5 w-5"})}):null]}),n?s.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),f=je(tV[(t===0||t==="0")&&(o==="warn"||o==="danger")?"default":o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?s.jsx($e,{to:i,className:f,children:a}):s.jsx("article",{className:f,children:a})}function JN(e){const t=nV(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(sV);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function nV(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=iV(o),l=oV(i,o.props);return o.type!==m.Fragment&&(l.ref=r?mm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rV=Symbol("radix.slottable");function sV(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rV}function oV(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function iV(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function aV(e){const t=e+"CollectionProvider",[n,r]=Ra(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:b,children:j}=v,S=Lt.useRef(null),N=Lt.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:N,collectionRef:S,children:j})};a.displayName=t;const l=e+"CollectionSlot",u=JN(l),f=Lt.forwardRef((v,b)=>{const{scope:j,children:S}=v,N=i(l,j),C=rr(b,N.collectionRef);return s.jsx(u,{ref:C,children:S})});f.displayName=l;const p=e+"CollectionItemSlot",h="data-radix-collection-item",g=JN(p),y=Lt.forwardRef((v,b)=>{const{scope:j,children:S,...N}=v,C=Lt.useRef(null),P=rr(b,C),T=i(p,j);return Lt.useEffect(()=>(T.itemMap.set(C,{ref:C,...N}),()=>void T.itemMap.delete(C))),s.jsx(g,{[h]:"",ref:P,children:S})});y.displayName=p;function k(v){const b=i(e+"CollectionConsumer",v);return Lt.useCallback(()=>{const S=b.collectionRef.current;if(!S)return[];const N=Array.from(S.querySelectorAll(`[${h}]`));return Array.from(b.itemMap.values()).sort((T,R)=>N.indexOf(T.ref.current)-N.indexOf(R.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:y},k,r]}var lV=m.createContext(void 0);function dP(e){const t=m.useContext(lV);return e||t||"ltr"}var Ey="rovingFocusGroup.onEntryFocus",cV={bubbles:!1,cancelable:!0},Gd="RovingFocusGroup",[ev,fP,uV]=aV(Gd),[dV,pP]=Ra(Gd,[uV]),[fV,pV]=dV(Gd),hP=m.forwardRef((e,t)=>s.jsx(ev.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ev.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(hV,{...e,ref:t})})}));hP.displayName=Gd;var hV=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=e,g=m.useRef(null),y=rr(t,g),k=dP(i),[v,b]=gm({prop:a,defaultProp:l??null,onChange:u,caller:Gd}),[j,S]=m.useState(!1),N=va(f),C=fP(n),P=m.useRef(!1),[T,R]=m.useState(0);return m.useEffect(()=>{const I=g.current;if(I)return I.addEventListener(Ey,N),()=>I.removeEventListener(Ey,N)},[N]),s.jsx(fV,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(I=>b(I),[b]),onItemShiftTab:m.useCallback(()=>S(!0),[]),onFocusableItemAdd:m.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:m.useCallback(()=>R(I=>I-1),[]),children:s.jsx(Nn.div,{tabIndex:j||T===0?-1:0,"data-orientation":r,...h,ref:y,style:{outline:"none",...e.style},onMouseDown:sn(e.onMouseDown,()=>{P.current=!0}),onFocus:sn(e.onFocus,I=>{const _=!P.current;if(I.target===I.currentTarget&&_&&!j){const F=new CustomEvent(Ey,cV);if(I.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=C().filter(U=>U.focusable),W=D.find(U=>U.active),H=D.find(U=>U.id===v),O=[W,H,...D].filter(Boolean).map(U=>U.ref.current);xP(O,p)}}P.current=!1}),onBlur:sn(e.onBlur,()=>S(!1))})})}),mP="RovingFocusGroupItem",gP=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=Ol(),f=i||u,p=pV(mP,n),h=p.currentTabStopId===f,g=fP(n),{onFocusableItemAdd:y,onFocusableItemRemove:k,currentTabStopId:v}=p;return m.useEffect(()=>{if(r)return y(),()=>k()},[r,y,k]),s.jsx(ev.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:s.jsx(Nn.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:sn(e.onMouseDown,b=>{r?p.onItemFocus(f):b.preventDefault()}),onFocus:sn(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:sn(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){p.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const j=xV(b,p.orientation,p.dir);if(j!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let N=g().filter(C=>C.focusable).map(C=>C.ref.current);if(j==="last")N.reverse();else if(j==="prev"||j==="next"){j==="prev"&&N.reverse();const C=N.indexOf(b.currentTarget);N=p.loop?yV(N,C+1):N.slice(C+1)}setTimeout(()=>xP(N))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:v!=null}):a})})});gP.displayName=mP;var mV={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gV(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function xV(e,t,n){const r=gV(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return mV[r]}function xP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function yV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bV=hP,vV=gP,Vm="Tabs",[wV]=Ra(Vm,[pP]),yP=pP(),[jV,t0]=wV(Vm),bP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...f}=e,p=dP(l),[h,g]=gm({prop:r,onChange:o,defaultProp:i??"",caller:Vm});return s.jsx(jV,{scope:n,baseId:Ol(),value:h,onValueChange:g,orientation:a,dir:p,activationMode:u,children:s.jsx(Nn.div,{dir:p,"data-orientation":a,...f,ref:t})})});bP.displayName=Vm;var vP="TabsList",wP=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=t0(vP,n),a=yP(n);return s.jsx(bV,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Nn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});wP.displayName=vP;var jP="TabsTrigger",kP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=t0(jP,n),l=yP(n),u=CP(a.baseId,r),f=EP(a.baseId,r),p=r===a.value;return s.jsx(vV,{asChild:!0,...l,focusable:!o,active:p,children:s.jsx(Nn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:sn(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(r):h.preventDefault()}),onKeyDown:sn(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(r)}),onFocus:sn(e.onFocus,()=>{const h=a.activationMode!=="manual";!p&&!o&&h&&a.onValueChange(r)})})})});kP.displayName=jP;var NP="TabsContent",SP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=t0(NP,n),u=CP(l.baseId,r),f=EP(l.baseId,r),p=r===l.value,h=m.useRef(p);return m.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(Aa,{present:o||p,children:({present:g})=>s.jsx(Nn.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:f,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&i})})});SP.displayName=NP;function CP(e,t){return`${e}-trigger-${t}`}function EP(e,t){return`${e}-content-${t}`}var TP=bP,RP=wP,tv=kP,nv=SP;function Wm({value:e,onValueChange:t,items:n,className:r}){const o=m.useRef(null),[i,a]=m.useState(!1),l=m.useCallback(()=>{const u=o.current;u&&a(u.scrollLeft+u.clientWidth<u.scrollWidth-1)},[]);return m.useEffect(()=>{const u=o.current;if(!u)return;l(),u.addEventListener("scroll",l,{passive:!0});const f=new ResizeObserver(l);return f.observe(u),()=>{u.removeEventListener("scroll",l),f.disconnect()}},[l,n.length]),s.jsxs(TP,{value:e,onValueChange:t,className:r,children:[s.jsxs("div",{className:"relative",children:[s.jsx(RP,{ref:o,className:"flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(u=>s.jsxs(tv,{value:u.value,className:je("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:[s.jsx("span",{children:u.label}),typeof u.count=="number"?s.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:u.count}):null,u.problemCount&&u.problemCount>0?s.jsx("span",{className:"rounded-full bg-destructive/15 px-2 py-0.5 text-xs text-destructive","aria-label":`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,title:`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,children:u.problemCount}):null]},u.value))}),i?s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 w-8 rounded-r-md bg-gradient-to-l from-card to-transparent"}):null]}),n.map(u=>s.jsx(nv,{value:u.value,className:"pt-3",children:u.content},u.value))]})}const kV="modulepreload",NV=function(e){return"/"+e},ZN={},SV=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(n.map(f=>{if(f=NV(f),f in ZN)return;ZN[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":kV,p||(g.as="script"),g.crossOrigin="",g.href=f,u&&g.setAttribute("nonce",u),document.head.appendChild(g),p)return new Promise((y,k)=>{g.addEventListener("load",y),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};function CV({definition:e,className:t,nodeRoutes:n={}}){const r=m.useRef(null),[o,i]=m.useState(null),[a,l]=m.useState(!0),u=Wt(),f=document.documentElement.classList.contains("dark")?"dark":"default";return m.useEffect(()=>{let p=!1;async function h(){if(r.current)try{const g=(await SV(async()=>{const{default:v}=await import("./mermaid.core-DJ_9ty0Y.js").then(b=>b.bs);return{default:v}},[])).default;if(g.initialize({startOnLoad:!1,theme:"base",themeVariables:EV(f==="dark")}),p)return;const y=`mermaid-${Date.now()}`,{svg:k}=await g.render(y,e);if(p||!r.current)return;r.current.innerHTML=k,TV(r.current,n,u),l(!1)}catch(g){p||(i(g instanceof Error?g.message:"Failed to render graph"),l(!1))}}return l(!0),i(null),h(),()=>{p=!0}},[e,u,n,f]),o?s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[s.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),s.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),s.jsx("div",{ref:r,className:"overflow-auto"})]})}function EV(e){const t=document.documentElement,n=h=>{const g=getComputedStyle(t).getPropertyValue(h).trim();return g?`oklch(${g})`:""},r=n("--card"),o=n("--card-foreground"),i=n("--border"),a=n("--primary"),l=n("--primary-foreground"),u=n("--muted"),f=n("--muted-foreground"),p=n("--secondary");return{background:r,primaryColor:r,primaryTextColor:o,primaryBorderColor:i,secondaryColor:u,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:u,tertiaryTextColor:f,tertiaryBorderColor:i,lineColor:e?f:i,textColor:o,mainBkg:r,nodeBkg:r,nodeTextColor:o,nodeBorder:i,clusterBkg:u,clusterBorder:i,edgeLabelBackground:r,titleColor:o,activeTaskBkgColor:a,activeTaskBorderColor:a,altBackground:u,labelColor:o,errorBkgColor:p,errorTextColor:l}}function TV(e,t,n){var r;for(const o of e.querySelectorAll(".node")){const i=((r=o.textContent)==null?void 0:r.replace(/\s+/g," ").trim())??"",a=t[i];if(!a)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const l=()=>n(a);o.addEventListener("click",l),o.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l())})}}function RV(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const AV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_V={};function eS(e,t){return(_V.jsx?PV:AV).test(e)}const DV=/[ \t\n\f\r]/g;function $V(e){return typeof e=="object"?e.type==="text"?tS(e.value):!1:tS(e)}function tS(e){return e.replace(DV,"")===""}class Yd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Yd.prototype.normal={};Yd.prototype.property={};Yd.prototype.space=void 0;function AP(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Yd(n,r,t)}function rv(e){return e.toLowerCase()}class Cr{constructor(t,n){this.attribute=n,this.property=t}}Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let IV=0;const kt=_a(),bn=_a(),sv=_a(),Me=_a(),Gt=_a(),Kl=_a(),$r=_a();function _a(){return 2**++IV}const ov=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:bn,commaOrSpaceSeparated:$r,commaSeparated:Kl,number:Me,overloadedBoolean:sv,spaceSeparated:Gt},Symbol.toStringTag,{value:"Module"})),Ty=Object.keys(ov);class n0 extends Cr{constructor(t,n,r,o){let i=-1;if(super(t,n),nS(this,"space",o),typeof r=="number")for(;++i<Ty.length;){const a=Ty[i];nS(this,Ty[i],(r&ov[a])===ov[a])}}}n0.prototype.defined=!0;function nS(e,t,n){n&&(e[t]=n)}function Pc(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new n0(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[rv(r)]=r,n[rv(i.attribute)]=r}return new Yd(t,n,e.space)}const PP=Pc({properties:{ariaActiveDescendant:null,ariaAtomic:bn,ariaAutoComplete:null,ariaBusy:bn,ariaChecked:bn,ariaColCount:Me,ariaColIndex:Me,ariaColSpan:Me,ariaControls:Gt,ariaCurrent:null,ariaDescribedBy:Gt,ariaDetails:null,ariaDisabled:bn,ariaDropEffect:Gt,ariaErrorMessage:null,ariaExpanded:bn,ariaFlowTo:Gt,ariaGrabbed:bn,ariaHasPopup:null,ariaHidden:bn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Gt,ariaLevel:Me,ariaLive:null,ariaModal:bn,ariaMultiLine:bn,ariaMultiSelectable:bn,ariaOrientation:null,ariaOwns:Gt,ariaPlaceholder:null,ariaPosInSet:Me,ariaPressed:bn,ariaReadOnly:bn,ariaRelevant:null,ariaRequired:bn,ariaRoleDescription:Gt,ariaRowCount:Me,ariaRowIndex:Me,ariaRowSpan:Me,ariaSelected:bn,ariaSetSize:Me,ariaSort:null,ariaValueMax:Me,ariaValueMin:Me,ariaValueNow:Me,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function _P(e,t){return t in e?e[t]:t}function DP(e,t){return _P(e,t.toLowerCase())}const MV=Pc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Kl,acceptCharset:Gt,accessKey:Gt,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:Gt,autoFocus:kt,autoPlay:kt,blocking:Gt,capture:null,charSet:null,checked:kt,cite:null,className:Gt,cols:Me,colSpan:null,content:null,contentEditable:bn,controls:kt,controlsList:Gt,coords:Me|Kl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:sv,draggable:bn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:Gt,height:Me,hidden:sv,high:Me,href:null,hrefLang:null,htmlFor:Gt,httpEquiv:Gt,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:Gt,itemRef:Gt,itemScope:kt,itemType:Gt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Me,manifest:null,max:null,maxLength:Me,media:null,method:null,min:null,minLength:Me,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,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:kt,optimum:Me,pattern:null,ping:Gt,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:Gt,required:kt,reversed:kt,rows:Me,rowSpan:Me,sandbox:Gt,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Me,sizes:null,slot:null,span:Me,spellCheck:bn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Me,step:null,style:null,tabIndex:Me,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:bn,width:Me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Gt,axis:null,background:null,bgColor:null,border:Me,borderColor:null,bottomMargin:Me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Me,leftMargin:Me,link:null,longDesc:null,lowSrc:null,marginHeight:Me,marginWidth:Me,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Me,rules:null,scheme:null,scrolling:bn,standby:null,summary:null,text:null,topMargin:Me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Me,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Me,security:null,unselectable:null},space:"html",transform:DP}),LV=Pc({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:$r,accentHeight:Me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Me,amplitude:Me,arabicForm:null,ascent:Me,attributeName:null,attributeType:null,azimuth:Me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Me,by:null,calcMode:null,capHeight:Me,className:Gt,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:Me,diffuseConstant:Me,direction:null,display:null,dur:null,divisor:Me,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Me,enableBackground:null,end:null,event:null,exponent:Me,externalResourcesRequired:null,fill:null,fillOpacity:Me,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:Kl,g2:Kl,glyphName:Kl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Me,horizOriginX:Me,horizOriginY:Me,id:null,ideographic:Me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Me,k:Me,k1:Me,k2:Me,k3:Me,k4:Me,kernelMatrix:$r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Me,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:Me,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:Me,overlineThickness:Me,paintOrder:null,panose1:null,path:null,pathLength:Me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Gt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Me,pointsAtY:Me,pointsAtZ:Me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$r,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$r,rev:$r,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$r,requiredFeatures:$r,requiredFonts:$r,requiredFormats:$r,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:Me,specularExponent:Me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Me,strikethroughThickness:Me,string:null,stroke:null,strokeDashArray:$r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Me,strokeOpacity:Me,strokeWidth:null,style:null,surfaceScale:Me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$r,tabIndex:Me,tableValues:null,target:null,targetX:Me,targetY:Me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$r,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Me,underlineThickness:Me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Me,values:null,vAlphabetic:Me,vMathematical:Me,vectorEffect:null,vHanging:Me,vIdeographic:Me,version:null,vertAdvY:Me,vertOriginX:Me,vertOriginY:Me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:_P}),$P=Pc({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()}}),IP=Pc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:DP}),MP=Pc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),OV={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"},FV=/[A-Z]/g,rS=/-[a-z]/g,zV=/^data[-\w.:]+$/i;function BV(e,t){const n=rv(t);let r=t,o=Cr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&zV.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(rS,HV);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!rS.test(i)){let a=i.replace(FV,UV);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=n0}return new o(r,t)}function UV(e){return"-"+e.toLowerCase()}function HV(e){return e.charAt(1).toUpperCase()}const VV=AP([PP,MV,$P,IP,MP],"html"),r0=AP([PP,LV,$P,IP,MP],"svg");function WV(e){return e.join(" ").trim()}var bl={},Ry,sS;function KV(){if(sS)return Ry;sS=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
616
616
  `,f="/",p="*",h="",g="comment",y="declaration";function k(b,j){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];j=j||{};var S=1,N=1;function C($){var O=$.match(t);O&&(S+=O.length);var U=$.lastIndexOf(u);N=~U?$.length-U:N+$.length}function P(){var $={line:S,column:N};return function(O){return O.position=new T($),_(),O}}function T($){this.start=$,this.end={line:S,column:N},this.source=j.source}T.prototype.content=b;function R($){var O=new Error(j.source+":"+S+":"+N+": "+$);if(O.reason=$,O.filename=j.source,O.line=S,O.column=N,O.source=b,!j.silent)throw O}function I($){var O=$.exec(b);if(O){var U=O[0];return C(U),b=b.slice(U.length),O}}function _(){I(n)}function F($){var O;for($=$||[];O=D();)O!==!1&&$.push(O);return $}function D(){var $=P();if(!(f!=b.charAt(0)||p!=b.charAt(1))){for(var O=2;h!=b.charAt(O)&&(p!=b.charAt(O)||f!=b.charAt(O+1));)++O;if(O+=2,h===b.charAt(O-1))return R("End of comment missing");var U=b.slice(2,O-2);return N+=2,C(U),b=b.slice(O),N+=2,$({type:g,comment:U})}}function W(){var $=P(),O=I(r);if(O){if(D(),!I(o))return R("property missing ':'");var U=I(i),K=$({type:y,property:v(O[0].replace(e,h)),value:U?v(U[0].replace(e,h)):h});return I(a),K}}function H(){var $=[];F($);for(var O;O=W();)O!==!1&&($.push(O),F($));return $}return _(),H()}function v(b){return b?b.replace(l,h):h}return Ry=k,Ry}var oS;function qV(){if(oS)return bl;oS=1;var e=bl&&bl.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bl,"__esModule",{value:!0}),bl.default=n;const t=e(KV());function n(r,o){let i=null;if(!r||typeof r!="string")return i;const a=(0,t.default)(r),l=typeof o=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:f,value:p}=u;l?o(f,p,u):p&&(i=i||{},i[f]=p)}),i}return bl}var wu={},iS;function GV(){if(iS)return wu;iS=1,Object.defineProperty(wu,"__esModule",{value:!0}),wu.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,i=function(f){return!f||n.test(f)||e.test(f)},a=function(f,p){return p.toUpperCase()},l=function(f,p){return"".concat(p,"-")},u=function(f,p){return p===void 0&&(p={}),i(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,l):f=f.replace(r,l),f.replace(t,a))};return wu.camelCase=u,wu}var ju,aS;function YV(){if(aS)return ju;aS=1;var e=ju&&ju.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(qV()),n=GV();function r(o,i){var a={};return!o||typeof o!="string"||(0,t.default)(o,function(l,u){l&&u&&(a[(0,n.camelCase)(l,i)]=u)}),a}return r.default=r,ju=r,ju}var XV=YV();const QV=Rd(XV),LP=OP("end"),s0=OP("start");function OP(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function JV(e){const t=s0(e),n=LP(e);if(t&&n)return{start:t,end:n}}function Yu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?lS(e.position):"start"in e||"end"in e?lS(e):"line"in e||"column"in e?iv(e):""}function iv(e){return cS(e&&e.line)+":"+cS(e&&e.column)}function lS(e){return iv(e&&e.start)+"-"+iv(e&&e.end)}function cS(e){return e&&typeof e=="number"?e:1}class ir extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(a=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){const u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=l?l.line:void 0,this.name=Yu(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ir.prototype.file="";ir.prototype.name="";ir.prototype.reason="";ir.prototype.message="";ir.prototype.stack="";ir.prototype.column=void 0;ir.prototype.line=void 0;ir.prototype.ancestors=void 0;ir.prototype.cause=void 0;ir.prototype.fatal=void 0;ir.prototype.place=void 0;ir.prototype.ruleId=void 0;ir.prototype.source=void 0;const o0={}.hasOwnProperty,ZV=new Map,eW=/[A-Z]/g,tW=new Set(["table","tbody","thead","tfoot","tr"]),nW=new Set(["td","th"]),FP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function rW(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=dW(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");r=uW(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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"?r0:VV,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=zP(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function zP(e,t,n){if(t.type==="element")return sW(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return oW(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return aW(e,t,n);if(t.type==="mdxjsEsm")return iW(e,t);if(t.type==="root")return lW(e,t,n);if(t.type==="text")return cW(e,t)}function sW(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=r0,e.schema=o),e.ancestors.push(t);const i=UP(e,t.tagName,!1),a=fW(e,t);let l=a0(e,t);return tW.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!$V(u):!0})),BP(e,a,i,t),i0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function oW(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}gd(e,t.position)}function iW(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gd(e,t.position)}function aW(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=r0,e.schema=o),e.ancestors.push(t);const i=t.name===null?e.Fragment:UP(e,t.name,!0),a=pW(e,t),l=a0(e,t);return BP(e,a,i,t),i0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function lW(e,t,n){const r={};return i0(r,a0(e,t)),e.create(t,e.Fragment,r,n)}function cW(e,t){return t.value}function BP(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function i0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function uW(e,t,n){return r;function r(o,i,a,l){const f=Array.isArray(a.children)?n:t;return l?f(i,a,l):f(i,a)}}function dW(e,t){return n;function n(r,o,i,a){const l=Array.isArray(i.children),u=s0(r);return t(o,i,a,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function fW(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&o0.call(t.properties,o)){const i=hW(e,o,t.properties[o]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&nW.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function pW(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else gd(e,t.position);else{const o=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else gd(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function a0(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:ZV;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){const f=o.get(u)||0;a=u+"-"+f,o.set(u,f+1)}}const l=zP(e,i,a);l!==void 0&&n.push(l)}return n}function hW(e,t,n){const r=BV(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?RV(n):WV(n)),r.property==="style"){let o=typeof n=="object"?n:mW(e,String(n));return e.stylePropertyNameCase==="css"&&(o=gW(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?OV[r.property]||r.property:r.attribute,n]}}function mW(e,t){try{return QV(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new ir("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=FP+"#cannot-parse-style-attribute",o}}function UP(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let i=-1,a;for(;++i<o.length;){const l=eS(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=eS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return o0.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);gd(e)}function gd(e,t){const n=new ir("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=FP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function gW(e){const t={};let n;for(n in e)o0.call(e,n)&&(t[xW(n)]=e[n]);return t}function xW(e){let t=e.replace(eW,yW);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function yW(e){return"-"+e.toLowerCase()}const Ay={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"]},bW={};function vW(e,t){const n=bW,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return HP(e,r,o)}function HP(e,t,n){if(wW(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 uS(e.children,t,n)}return Array.isArray(e)?uS(e,t,n):""}function uS(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=HP(e[o],t,n);return r.join("")}function wW(e){return!!(e&&typeof e=="object")}const dS=document.createElement("i");function l0(e){const t="&"+e+";";dS.innerHTML=t;const n=dS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function no(e,t,n,r){const o=e.length;let i=0,a;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function es(e,t){return e.length>0?(no(e,e.length,0,t),e):t}const fS={}.hasOwnProperty;function jW(e){const t={};let n=-1;for(;++n<e.length;)kW(t,e[n]);return t}function kW(e,t){let n;for(n in t){const o=(fS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){fS.call(o,a)||(o[a]=[]);const l=i[a];NW(o[a],Array.isArray(l)?l:l?[l]:[])}}}function NW(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);no(e,0,0,r)}function VP(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 ql(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Gs=_i(/[A-Za-z]/),Br=_i(/[\dA-Za-z]/),SW=_i(/[#-'*+\--9=?A-Z^-~]/);function av(e){return e!==null&&(e<32||e===127)}const lv=_i(/\d/),CW=_i(/[\dA-Fa-f]/),EW=_i(/[!-/:-@[-`{-~]/);function xt(e){return e!==null&&e<-2}function kr(e){return e!==null&&(e<0||e===32)}function Ft(e){return e===-2||e===-1||e===32}const TW=_i(new RegExp("\\p{P}|\\p{S}","u")),RW=_i(/\s/);function _i(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function _c(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Br(e.charCodeAt(n+1))&&Br(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),o=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+o+1,a=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Yt(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(u){return Ft(u)?(e.enter(n),l(u)):t(u)}function l(u){return Ft(u)&&i++<o?(e.consume(u),l):(e.exit(n),t(u))}}const AW={tokenize:PW};function PW(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Yt(e,t,"linePrefix")}function o(l){return e.enter("paragraph"),i(l)}function i(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return xt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const _W={tokenize:DW},pS={tokenize:$W};function DW(e){const t=this,n=[];let r=0,o,i,a;return l;function l(N){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,u,f)(N)}return f(N)}function u(N){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&S();const C=t.events.length;let P=C,T;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){T=t.events[P][1].end;break}j(r);let R=C;for(;R<t.events.length;)t.events[R][1].end={...T},R++;return no(t.events,P+1,0,t.events.slice(C)),t.events.length=R,f(N)}return l(N)}function f(N){if(r===n.length){if(!o)return g(N);if(o.currentConstruct&&o.currentConstruct.concrete)return k(N);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(pS,p,h)(N)}function p(N){return o&&S(),j(r),g(N)}function h(N){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,k(N)}function g(N){return t.containerState={},e.attempt(pS,y,k)(N)}function y(N){return r++,n.push([t.currentConstruct,t.containerState]),g(N)}function k(N){if(N===null){o&&S(),j(0),e.consume(N);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),v(N)}function v(N){if(N===null){b(e.exit("chunkFlow"),!0),j(0),e.consume(N);return}return xt(N)?(e.consume(N),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(N),v)}function b(N,C){const P=t.sliceStream(N);if(C&&P.push(null),N.previous=i,i&&(i.next=N),i=N,o.defineSkip(N.start),o.write(P),t.parser.lazy[N.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<a&&(!o.events[T][1].end||o.events[T][1].end.offset>a))return;const R=t.events.length;let I=R,_,F;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){if(_){F=t.events[I][1].end;break}_=!0}for(j(r),T=R;T<t.events.length;)t.events[T][1].end={...F},T++;no(t.events,I+1,0,t.events.slice(R)),t.events.length=T}}function j(N){let C=n.length;for(;C-- >N;){const P=n[C];t.containerState=P[1],P[0].exit.call(t,e)}n.length=N}function S(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function $W(e,t,n){return Yt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function hS(e){if(e===null||kr(e)||RW(e))return 1;if(TW(e))return 2}function c0(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const cv={name:"attention",resolveAll:IW,tokenize:MW};function IW(e,t){let n=-1,r,o,i,a,l,u,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},g={...e[n][1].start};mS(h,-u),mS(g,u),a={type:u>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=es(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=es(f,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",i,t]]),f=es(f,c0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=es(f,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=es(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,no(e,r-1,n-r+3,f),n=r+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function MW(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=hS(r);let i;return a;function a(u){return i=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===i)return e.consume(u),l;const f=e.exit("attentionSequence"),p=hS(u),h=!p||p===2&&o||n.includes(u),g=!o||o===2&&p||n.includes(r);return f._open=!!(i===42?h:h&&(o||!g)),f._close=!!(i===42?g:g&&(p||!h)),t(u)}}function mS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const LW={name:"autolink",tokenize:OW};function OW(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(y){return Gs(y)?(e.consume(y),a):y===64?n(y):f(y)}function a(y){return y===43||y===45||y===46||Br(y)?(r=1,l(y)):f(y)}function l(y){return y===58?(e.consume(y),r=0,u):(y===43||y===45||y===46||Br(y))&&r++<32?(e.consume(y),l):(r=0,f(y))}function u(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||av(y)?n(y):(e.consume(y),u)}function f(y){return y===64?(e.consume(y),p):SW(y)?(e.consume(y),f):n(y)}function p(y){return Br(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):g(y)}function g(y){if((y===45||Br(y))&&r++<63){const k=y===45?g:h;return e.consume(y),k}return n(y)}}const Km={partial:!0,tokenize:FW};function FW(e,t,n){return r;function r(i){return Ft(i)?Yt(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||xt(i)?t(i):n(i)}}const WP={continuation:{tokenize:BW},exit:UW,name:"blockQuote",tokenize:zW};function zW(e,t,n){const r=this;return o;function o(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return Ft(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function BW(e,t,n){const r=this;return o;function o(a){return Ft(a)?Yt(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(WP,t,n)(a)}}function UW(e){e.exit("blockQuote")}const KP={name:"characterEscape",tokenize:HW};function HW(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return EW(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const qP={name:"characterReference",tokenize:VW};function VW(e,t,n){const r=this;let o=0,i,a;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),u}function u(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),i=31,a=Br,p(h))}function f(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=CW,p):(e.enter("characterReferenceValue"),i=7,a=lv,p(h))}function p(h){if(h===59&&o){const g=e.exit("characterReferenceValue");return a===Br&&!l0(r.sliceSerialize(g))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(h)&&o++<i?(e.consume(h),p):n(h)}}const gS={partial:!0,tokenize:KW},xS={concrete:!0,name:"codeFenced",tokenize:WW};function WW(e,t,n){const r=this,o={partial:!0,tokenize:P};let i=0,a=0,l;return u;function u(T){return f(T)}function f(T){const R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===l?(a++,e.consume(T),p):a<3?n(T):(e.exit("codeFencedFenceSequence"),Ft(T)?Yt(e,h,"whitespace")(T):h(T))}function h(T){return T===null||xt(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(gS,v,C)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||xt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(T)):Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Yt(e,y,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),g)}function y(T){return T===null||xt(T)?h(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||xt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(T)):T===96&&T===l?n(T):(e.consume(T),k)}function v(T){return e.attempt(o,C,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),j}function j(T){return i>0&&Ft(T)?Yt(e,S,"linePrefix",i+1)(T):S(T)}function S(T){return T===null||xt(T)?e.check(gS,v,C)(T):(e.enter("codeFlowValue"),N(T))}function N(T){return T===null||xt(T)?(e.exit("codeFlowValue"),S(T)):(e.consume(T),N)}function C(T){return e.exit("codeFenced"),t(T)}function P(T,R,I){let _=0;return F;function F(O){return T.enter("lineEnding"),T.consume(O),T.exit("lineEnding"),D}function D(O){return T.enter("codeFencedFence"),Ft(O)?Yt(T,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):W(O)}function W(O){return O===l?(T.enter("codeFencedFenceSequence"),H(O)):I(O)}function H(O){return O===l?(_++,T.consume(O),H):_>=a?(T.exit("codeFencedFenceSequence"),Ft(O)?Yt(T,$,"whitespace")(O):$(O)):I(O)}function $(O){return O===null||xt(O)?(T.exit("codeFencedFence"),R(O)):I(O)}}}function KW(e,t,n){const r=this;return o;function o(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Py={name:"codeIndented",tokenize:GW},qW={partial:!0,tokenize:YW};function GW(e,t,n){const r=this;return o;function o(f){return e.enter("codeIndented"),Yt(e,i,"linePrefix",5)(f)}function i(f){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(f):n(f)}function a(f){return f===null?u(f):xt(f)?e.attempt(qW,a,u)(f):(e.enter("codeFlowValue"),l(f))}function l(f){return f===null||xt(f)?(e.exit("codeFlowValue"),a(f)):(e.consume(f),l)}function u(f){return e.exit("codeIndented"),t(f)}}function YW(e,t,n){const r=this;return o;function o(a){return r.parser.lazy[r.now().line]?n(a):xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):Yt(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):xt(a)?o(a):n(a)}}const XW={name:"codeText",previous:JW,resolve:QW,tokenize:ZW};function QW(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function JW(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function ZW(e,t,n){let r=0,o,i;return a;function a(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),r++,l):(e.exit("codeTextSequence"),u(h))}function u(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),u):h===96?(i=e.enter("codeTextSequence"),o=0,p(h)):xt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("codeTextData"),f(h))}function f(h){return h===null||h===32||h===96||xt(h)?(e.exit("codeTextData"),u(h)):(e.consume(h),f)}function p(h){return h===96?(e.consume(h),o++,p):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(i.type="codeTextData",f(h))}}class eK{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 r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&ku(this.left,r),i.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),ku(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ku(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);ku(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ku(this.left,n.reverse())}}}function ku(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 GP(e){const t={};let n=-1,r,o,i,a,l,u,f;const p=new eK(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,tK(p,n)),n=t[n],f=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(a=p.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;o&&(r[1].end={...p.get(o)[1].start},l=p.slice(o,n),l.unshift(r),p.splice(o,n-o+1,l))}}return no(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function tK(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,u=[],f={};let p,h,g=-1,y=n,k=0,v=0;const b=[v];for(;y;){for(;e.get(++o)[1]!==y;);i.push(o),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),h&&a.defineSkip(y.start),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++g<l.length;)l[g][0]==="exit"&&l[g-1][0]==="enter"&&l[g][1].type===l[g-1][1].type&&l[g][1].start.line!==l[g][1].end.line&&(v=g+1,b.push(v),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(a.events=[],y?(y._tokenizer=void 0,y.previous=void 0):b.pop(),g=b.length;g--;){const j=l.slice(b[g],b[g+1]),S=i.pop();u.push([S,S+j.length-1]),e.splice(S,2,j)}for(u.reverse(),g=-1;++g<u.length;)f[k+u[g][0]]=k+u[g][1],k+=u[g][1]-u[g][0]-1;return f}const nK={resolve:sK,tokenize:oK},rK={partial:!0,tokenize:iK};function sK(e){return GP(e),e}function oK(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(l)}function o(l){return l===null?i(l):xt(l)?e.check(rK,a,i)(l):(e.consume(l),o)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function iK(e,t,n){const r=this;return o;function o(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Yt(e,i,"linePrefix")}function i(a){if(a===null||xt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function YP(e,t,n,r,o,i,a,l,u){const f=u||Number.POSITIVE_INFINITY;let p=0;return h;function h(j){return j===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(j),e.exit(i),g):j===null||j===32||j===41||av(j)?n(j):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(j))}function g(j){return j===62?(e.enter(i),e.consume(j),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),y(j))}function y(j){return j===62?(e.exit("chunkString"),e.exit(l),g(j)):j===null||j===60||xt(j)?n(j):(e.consume(j),j===92?k:y)}function k(j){return j===60||j===62||j===92?(e.consume(j),y):y(j)}function v(j){return!p&&(j===null||j===41||kr(j))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(j)):p<f&&j===40?(e.consume(j),p++,v):j===41?(e.consume(j),p--,v):j===null||j===32||j===40||av(j)?n(j):(e.consume(j),j===92?b:v)}function b(j){return j===40||j===41||j===92?(e.consume(j),v):v(j)}}function XP(e,t,n,r,o,i){const a=this;let l=0,u;return f;function f(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(i),p}function p(y){return l>999||y===null||y===91||y===93&&!u||y===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(y):y===93?(e.exit(i),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):xt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||xt(y)||l++>999?(e.exit("chunkString"),p(y)):(e.consume(y),u||(u=!Ft(y)),y===92?g:h)}function g(y){return y===91||y===92||y===93?(e.consume(y),l++,h):h(y)}}function QP(e,t,n,r,o,i){let a;return l;function l(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),a=g===40?41:g,u):n(g)}function u(g){return g===a?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),f(g))}function f(g){return g===a?(e.exit(i),u(a)):g===null?n(g):xt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Yt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===a||g===null||xt(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?h:p)}function h(g){return g===a||g===92?(e.consume(g),p):p(g)}}function Xu(e,t){let n;return r;function r(o){return xt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ft(o)?Yt(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const aK={name:"definition",tokenize:cK},lK={partial:!0,tokenize:uK};function cK(e,t,n){const r=this;let o;return i;function i(y){return e.enter("definition"),a(y)}function a(y){return XP.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function l(y){return o=ql(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),u):n(y)}function u(y){return kr(y)?Xu(e,f)(y):f(y)}function f(y){return YP(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(lK,h,h)(y)}function h(y){return Ft(y)?Yt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||xt(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function uK(e,t,n){return r;function r(l){return kr(l)?Xu(e,o)(l):n(l)}function o(l){return QP(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Ft(l)?Yt(e,a,"whitespace")(l):a(l)}function a(l){return l===null||xt(l)?t(l):n(l)}}const dK={name:"hardBreakEscape",tokenize:fK};function fK(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return xt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const pK={name:"headingAtx",resolve:hK,tokenize:mK};function hK(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},no(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function mK(e,t,n){let r=0;return o;function o(p){return e.enter("atxHeading"),i(p)}function i(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||kr(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||xt(p)?(e.exit("atxHeading"),t(p)):Ft(p)?Yt(e,l,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),l(p))}function f(p){return p===null||p===35||kr(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),f)}}const gK=["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"],yS=["pre","script","style","textarea"],xK={concrete:!0,name:"htmlFlow",resolveTo:vK,tokenize:wK},yK={partial:!0,tokenize:kK},bK={partial:!0,tokenize:jK};function vK(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 wK(e,t,n){const r=this;let o,i,a,l,u;return f;function f(B){return p(B)}function p(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),h}function h(B){return B===33?(e.consume(B),g):B===47?(e.consume(B),i=!0,v):B===63?(e.consume(B),o=3,r.interrupt?t:L):Gs(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function g(B){return B===45?(e.consume(B),o=2,y):B===91?(e.consume(B),o=5,l=0,k):Gs(B)?(e.consume(B),o=4,r.interrupt?t:L):n(B)}function y(B){return B===45?(e.consume(B),r.interrupt?t:L):n(B)}function k(B){const Q="CDATA[";return B===Q.charCodeAt(l++)?(e.consume(B),l===Q.length?r.interrupt?t:W:k):n(B)}function v(B){return Gs(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function b(B){if(B===null||B===47||B===62||kr(B)){const Q=B===47,J=a.toLowerCase();return!Q&&!i&&yS.includes(J)?(o=1,r.interrupt?t(B):W(B)):gK.includes(a.toLowerCase())?(o=6,Q?(e.consume(B),j):r.interrupt?t(B):W(B)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):i?S(B):N(B))}return B===45||Br(B)?(e.consume(B),a+=String.fromCharCode(B),b):n(B)}function j(B){return B===62?(e.consume(B),r.interrupt?t:W):n(B)}function S(B){return Ft(B)?(e.consume(B),S):F(B)}function N(B){return B===47?(e.consume(B),F):B===58||B===95||Gs(B)?(e.consume(B),C):Ft(B)?(e.consume(B),N):F(B)}function C(B){return B===45||B===46||B===58||B===95||Br(B)?(e.consume(B),C):P(B)}function P(B){return B===61?(e.consume(B),T):Ft(B)?(e.consume(B),P):N(B)}function T(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),u=B,R):Ft(B)?(e.consume(B),T):I(B)}function R(B){return B===u?(e.consume(B),u=null,_):B===null||xt(B)?n(B):(e.consume(B),R)}function I(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||kr(B)?P(B):(e.consume(B),I)}function _(B){return B===47||B===62||Ft(B)?N(B):n(B)}function F(B){return B===62?(e.consume(B),D):n(B)}function D(B){return B===null||xt(B)?W(B):Ft(B)?(e.consume(B),D):n(B)}function W(B){return B===45&&o===2?(e.consume(B),U):B===60&&o===1?(e.consume(B),K):B===62&&o===4?(e.consume(B),z):B===63&&o===3?(e.consume(B),L):B===93&&o===5?(e.consume(B),V):xt(B)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(yK,Y,H)(B)):B===null||xt(B)?(e.exit("htmlFlowData"),H(B)):(e.consume(B),W)}function H(B){return e.check(bK,$,Y)(B)}function $(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),O}function O(B){return B===null||xt(B)?H(B):(e.enter("htmlFlowData"),W(B))}function U(B){return B===45?(e.consume(B),L):W(B)}function K(B){return B===47?(e.consume(B),a="",M):W(B)}function M(B){if(B===62){const Q=a.toLowerCase();return yS.includes(Q)?(e.consume(B),z):W(B)}return Gs(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),M):W(B)}function V(B){return B===93?(e.consume(B),L):W(B)}function L(B){return B===62?(e.consume(B),z):B===45&&o===2?(e.consume(B),L):W(B)}function z(B){return B===null||xt(B)?(e.exit("htmlFlowData"),Y(B)):(e.consume(B),z)}function Y(B){return e.exit("htmlFlow"),t(B)}}function jK(e,t,n){const r=this;return o;function o(a){return xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function kK(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Km,t,n)}}const NK={name:"htmlText",tokenize:SK};function SK(e,t,n){const r=this;let o,i,a;return l;function l(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),u}function u(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),P):L===63?(e.consume(L),N):Gs(L)?(e.consume(L),I):n(L)}function f(L){return L===45?(e.consume(L),p):L===91?(e.consume(L),i=0,k):Gs(L)?(e.consume(L),S):n(L)}function p(L){return L===45?(e.consume(L),y):n(L)}function h(L){return L===null?n(L):L===45?(e.consume(L),g):xt(L)?(a=h,K(L)):(e.consume(L),h)}function g(L){return L===45?(e.consume(L),y):h(L)}function y(L){return L===62?U(L):L===45?g(L):h(L)}function k(L){const z="CDATA[";return L===z.charCodeAt(i++)?(e.consume(L),i===z.length?v:k):n(L)}function v(L){return L===null?n(L):L===93?(e.consume(L),b):xt(L)?(a=v,K(L)):(e.consume(L),v)}function b(L){return L===93?(e.consume(L),j):v(L)}function j(L){return L===62?U(L):L===93?(e.consume(L),j):v(L)}function S(L){return L===null||L===62?U(L):xt(L)?(a=S,K(L)):(e.consume(L),S)}function N(L){return L===null?n(L):L===63?(e.consume(L),C):xt(L)?(a=N,K(L)):(e.consume(L),N)}function C(L){return L===62?U(L):N(L)}function P(L){return Gs(L)?(e.consume(L),T):n(L)}function T(L){return L===45||Br(L)?(e.consume(L),T):R(L)}function R(L){return xt(L)?(a=R,K(L)):Ft(L)?(e.consume(L),R):U(L)}function I(L){return L===45||Br(L)?(e.consume(L),I):L===47||L===62||kr(L)?_(L):n(L)}function _(L){return L===47?(e.consume(L),U):L===58||L===95||Gs(L)?(e.consume(L),F):xt(L)?(a=_,K(L)):Ft(L)?(e.consume(L),_):U(L)}function F(L){return L===45||L===46||L===58||L===95||Br(L)?(e.consume(L),F):D(L)}function D(L){return L===61?(e.consume(L),W):xt(L)?(a=D,K(L)):Ft(L)?(e.consume(L),D):_(L)}function W(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),o=L,H):xt(L)?(a=W,K(L)):Ft(L)?(e.consume(L),W):(e.consume(L),$)}function H(L){return L===o?(e.consume(L),o=void 0,O):L===null?n(L):xt(L)?(a=H,K(L)):(e.consume(L),H)}function $(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||kr(L)?_(L):(e.consume(L),$)}function O(L){return L===47||L===62||kr(L)?_(L):n(L)}function U(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function K(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),M}function M(L){return Ft(L)?Yt(e,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):V(L)}function V(L){return e.enter("htmlTextData"),a(L)}}const u0={name:"labelEnd",resolveAll:RK,resolveTo:AK,tokenize:PK},CK={tokenize:_K},EK={tokenize:DK},TK={tokenize:$K};function RK(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&no(e,0,e.length,n),e}function AK(e,t){let n=e.length,r=0,o,i,a,l;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(a=n);const u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",u,t],["enter",f,t]],l=es(l,e.slice(i+1,i+r+3)),l=es(l,[["enter",p,t]]),l=es(l,c0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=es(l,[["exit",p,t],e[a-2],e[a-1],["exit",f,t]]),l=es(l,e.slice(a+1)),l=es(l,[["exit",u,t]]),no(e,i,e.length,l),e}function PK(e,t,n){const r=this;let o=r.events.length,i,a;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return l;function l(g){return i?i._inactive?h(g):(a=r.parser.defined.includes(ql(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(CK,p,a?p:h)(g):g===91?e.attempt(EK,p,a?f:h)(g):a?p(g):h(g)}function f(g){return e.attempt(TK,p,h)(g)}function p(g){return t(g)}function h(g){return i._balanced=!0,n(g)}}function _K(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),o}function o(h){return kr(h)?Xu(e,i)(h):i(h)}function i(h){return h===41?p(h):YP(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return kr(h)?Xu(e,u)(h):p(h)}function l(h){return n(h)}function u(h){return h===34||h===39||h===40?QP(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):p(h)}function f(h){return kr(h)?Xu(e,p)(h):p(h)}function p(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function DK(e,t,n){const r=this;return o;function o(l){return XP.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(ql(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function $K(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const IK={name:"labelStartImage",resolveAll:u0.resolveAll,tokenize:MK};function MK(e,t,n){const r=this;return o;function o(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const LK={name:"labelStartLink",resolveAll:u0.resolveAll,tokenize:OK};function OK(e,t,n){const r=this;return o;function o(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const _y={name:"lineEnding",tokenize:FK};function FK(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Yt(e,t,"linePrefix")}}const Jp={name:"thematicBreak",tokenize:zK};function zK(e,t,n){let r=0,o;return i;function i(f){return e.enter("thematicBreak"),a(f)}function a(f){return o=f,l(f)}function l(f){return f===o?(e.enter("thematicBreakSequence"),u(f)):r>=3&&(f===null||xt(f))?(e.exit("thematicBreak"),t(f)):n(f)}function u(f){return f===o?(e.consume(f),r++,u):(e.exit("thematicBreakSequence"),Ft(f)?Yt(e,l,"whitespace")(f):l(f))}}const yr={continuation:{tokenize:VK},exit:KK,name:"list",tokenize:HK},BK={partial:!0,tokenize:qK},UK={partial:!0,tokenize:WK};function HK(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,a=0;return l;function l(y){const k=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:lv(y)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Jp,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(y)}return n(y)}function u(y){return lv(y)&&++a<10?(e.consume(y),u):(!r.interrupt||a<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Km,r.interrupt?n:p,e.attempt(BK,g,h))}function p(y){return r.containerState.initialBlankLine=!0,i++,g(y)}function h(y){return Ft(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):n(y)}function g(y){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function VK(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Km,o,i);function o(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Yt(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Ft(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(UK,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Yt(e,e.attempt(yr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function WK(e,t,n){const r=this;return Yt(e,o,"listItemIndent",r.containerState.size+1);function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function KK(e){e.exit(this.containerState.type)}function qK(e,t,n){const r=this;return Yt(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){const a=r.events[r.events.length-1];return!Ft(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const bS={name:"setextUnderline",resolveTo:GK,tokenize:YK};function GK(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function YK(e,t,n){const r=this;let o;return i;function i(f){let p=r.events.length,h;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){h=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),o=f,a(f)):n(f)}function a(f){return e.enter("setextHeadingLineSequence"),l(f)}function l(f){return f===o?(e.consume(f),l):(e.exit("setextHeadingLineSequence"),Ft(f)?Yt(e,u,"lineSuffix")(f):u(f))}function u(f){return f===null||xt(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const XK={tokenize:QK};function QK(e){const t=this,n=e.attempt(Km,r,e.attempt(this.parser.constructs.flowInitial,o,Yt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(nK,o)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const JK={resolveAll:ZP()},ZK=JP("string"),eq=JP("text");function JP(e){return{resolveAll:ZP(e==="text"?tq:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],i=n.attempt(o,a,l);return a;function a(p){return f(p)?i(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return f(p)?(n.exit("data"),i(p)):(n.consume(p),u)}function f(p){if(p===null)return!0;const h=o[p];let g=-1;if(h)for(;++g<h.length;){const y=h[g];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function ZP(e){return t;function t(n,r){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,r):n}}function tq(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 r=e[n-1][1],o=t.sliceStream(r);let i=o.length,a=-1,l=0,u;for(;i--;){const f=o[i];if(typeof f=="string"){for(a=f.length;f.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(f===-2)u=!0,l++;else if(f!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const f={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const nq={42:yr,43:yr,45:yr,48:yr,49:yr,50:yr,51:yr,52:yr,53:yr,54:yr,55:yr,56:yr,57:yr,62:WP},rq={91:aK},sq={[-2]:Py,[-1]:Py,32:Py},oq={35:pK,42:Jp,45:[bS,Jp],60:xK,61:bS,95:Jp,96:xS,126:xS},iq={38:qP,92:KP},aq={[-5]:_y,[-4]:_y,[-3]:_y,33:IK,38:qP,42:cv,60:[LW,NK],91:LK,92:[dK,KP],93:u0,95:cv,96:XW},lq={null:[cv,JK]},cq={null:[42,95]},uq={null:[]},dq=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:cq,contentInitial:rq,disable:uq,document:nq,flow:oq,flowInitial:sq,insideSpan:lq,string:iq,text:aq},Symbol.toStringTag,{value:"Module"}));function fq(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let a=[],l=[];const u={attempt:R(P),check:R(T),consume:S,enter:N,exit:C,interrupt:R(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:v,events:[],now:k,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:h};let p=t.tokenize.call(f,u);return t.resolveAll&&i.push(t),f;function h(D){return a=es(a,D),b(),a[a.length-1]!==null?[]:(I(t,0),f.events=c0(i,f.events,f),f.events)}function g(D,W){return hq(y(D),W)}function y(D){return pq(a,D)}function k(){const{_bufferIndex:D,_index:W,line:H,column:$,offset:O}=r;return{_bufferIndex:D,_index:W,line:H,column:$,offset:O}}function v(D){o[D.line]=D.column,F()}function b(){let D;for(;r._index<a.length;){const W=a[r._index];if(typeof W=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<W.length;)j(W.charCodeAt(r._bufferIndex));else j(W)}}function j(D){p=p(D)}function S(D){xt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,F()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=D}function N(D,W){const H=W||{};return H.type=D,H.start=k(),f.events.push(["enter",H,f]),l.push(H),H}function C(D){const W=l.pop();return W.end=k(),f.events.push(["exit",W,f]),W}function P(D,W){I(D,W.from)}function T(D,W){W.restore()}function R(D,W){return H;function H($,O,U){let K,M,V,L;return Array.isArray($)?Y($):"tokenize"in $?Y([$]):z($);function z(Z){return oe;function oe(ne){const ue=ne!==null&&Z[ne],ge=ne!==null&&Z.null,Ce=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ge)?ge:ge?[ge]:[]];return Y(Ce)(ne)}}function Y(Z){return K=Z,M=0,Z.length===0?U:B(Z[M])}function B(Z){return oe;function oe(ne){return L=_(),V=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?J():Z.tokenize.call(W?Object.assign(Object.create(f),W):f,u,Q,J)(ne)}}function Q(Z){return D(V,L),O}function J(Z){return L.restore(),++M<K.length?B(K[M]):U}}}function I(D,W){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&no(f.events,W,f.events.length-W,D.resolve(f.events.slice(W),f)),D.resolveTo&&(f.events=D.resolveTo(f.events,f))}function _(){const D=k(),W=f.previous,H=f.currentConstruct,$=f.events.length,O=Array.from(l);return{from:$,restore:U};function U(){r=D,f.previous=W,f.currentConstruct=H,f.events.length=$,l=O,F()}}function F(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function pq(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let a;if(n===o)a=[e[n].slice(r,i)];else{if(a=e.slice(n,o),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[o].slice(0,i))}return a}function hq(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
617
617
  `;break}case-3:{a=`\r
618
618
  `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&o)continue;a=" ";break}default:a=String.fromCharCode(i)}o=i===-2,r.push(a)}return r.join("")}function mq(e){const r={constructs:jW([dq,...(e||{}).extensions||[]]),content:o(AW),defined:[],document:o(_W),flow:o(XK),lazy:{},string:o(ZK),text:o(eq)};return r;function o(i){return a;function a(l){return fq(r,i,l)}}}function gq(e){for(;!GP(e););return e}const vS=/[\0\t\n\r]/g;function xq(){let e=1,t="",n=!0,r;return o;function o(i,a,l){const u=[];let f,p,h,g,y;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),h=0,t="",n&&(i.charCodeAt(0)===65279&&h++,n=void 0);h<i.length;){if(vS.lastIndex=h,f=vS.exec(i),g=f&&f.index!==void 0?f.index:i.length,y=i.charCodeAt(g),!f){t=i.slice(h);break}if(y===10&&h===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),h<g&&(u.push(i.slice(h,g)),e+=g-h),y){case 0:{u.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,u.push(-2);e++<p;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const yq=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function bq(e){return e.replace(yq,vq)}function vq(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),i=o===120||o===88;return VP(n.slice(i?2:1),i?16:10)}return l0(n)||e}const e_={}.hasOwnProperty;function wq(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),jq(n)(gq(mq(n).document().write(xq()(e,t,!0))))}function jq(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(He),autolinkProtocol:_,autolinkEmail:_,atxHeading:i(ie),blockQuote:i(ge),characterEscape:_,characterReference:_,codeFenced:i(Ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Ce,a),codeText:i(Ne,a),codeTextData:_,data:_,codeFlowValue:_,definition:i(ke),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Ue),hardBreakEscape:i(ve),hardBreakTrailing:i(ve),htmlFlow:i(be,a),htmlFlowData:_,htmlText:i(be,a),htmlTextData:_,image:i(Re),label:a,link:i(He),listItem:i(Fe),listItemValue:g,listOrdered:i(rt,h),listUnordered:i(rt),paragraph:i(ot),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ie),strong:i(St),thematicBreak:i(at)},exit:{atxHeading:u(),atxHeadingSequence:P,autolink:u(),autolinkEmail:ue,autolinkProtocol:ne,blockQuote:u(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:J,characterReferenceMarkerNumeric:J,characterReferenceValue:Z,characterReference:oe,codeFenced:u(b),codeFencedFence:v,codeFencedFenceInfo:y,codeFencedFenceMeta:k,codeFlowValue:F,codeIndented:u(j),codeText:u(O),codeTextData:F,data:F,definition:u(),definitionDestinationString:C,definitionLabelString:S,definitionTitleString:N,emphasis:u(),hardBreakEscape:u(W),hardBreakTrailing:u(W),htmlFlow:u(H),htmlFlowData:F,htmlText:u($),htmlTextData:F,image:u(K),label:V,labelText:M,lineEnding:D,link:u(U),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Q,resourceDestinationString:L,resourceTitleString:z,resource:Y,setextHeading:u(I),setextHeadingLineSequence:R,setextHeadingText:T,strong:u(),thematicBreak:u()}};t_(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ce){let me={type:"root",children:[]};const Ie={stack:[me],tokenStack:[],config:t,enter:l,exit:f,buffer:a,resume:p,data:n},Ae=[];let We=-1;for(;++We<ce.length;)if(ce[We][1].type==="listOrdered"||ce[We][1].type==="listUnordered")if(ce[We][0]==="enter")Ae.push(We);else{const pt=Ae.pop();We=o(ce,pt,We)}for(We=-1;++We<ce.length;){const pt=t[ce[We][0]];e_.call(pt,ce[We][1].type)&&pt[ce[We][1].type].call(Object.assign({sliceSerialize:ce[We][2].sliceSerialize},Ie),ce[We][1])}if(Ie.tokenStack.length>0){const pt=Ie.tokenStack[Ie.tokenStack.length-1];(pt[1]||wS).call(Ie,void 0,pt[0])}for(me.position={start:ui(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:ui(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},We=-1;++We<t.transforms.length;)me=t.transforms[We](me)||me;return me}function o(ce,me,Ie){let Ae=me-1,We=-1,pt=!1,_e,Qe,Je,ut;for(;++Ae<=Ie;){const fe=ce[Ae];switch(fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{fe[0]==="enter"?We++:We--,ut=void 0;break}case"lineEndingBlank":{fe[0]==="enter"&&(_e&&!ut&&!We&&!Je&&(Je=Ae),ut=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ut=void 0}if(!We&&fe[0]==="enter"&&fe[1].type==="listItemPrefix"||We===-1&&fe[0]==="exit"&&(fe[1].type==="listUnordered"||fe[1].type==="listOrdered")){if(_e){let q=Ae;for(Qe=void 0;q--;){const re=ce[q];if(re[1].type==="lineEnding"||re[1].type==="lineEndingBlank"){if(re[0]==="exit")continue;Qe&&(ce[Qe][1].type="lineEndingBlank",pt=!0),re[1].type="lineEnding",Qe=q}else if(!(re[1].type==="linePrefix"||re[1].type==="blockQuotePrefix"||re[1].type==="blockQuotePrefixWhitespace"||re[1].type==="blockQuoteMarker"||re[1].type==="listItemIndent"))break}Je&&(!Qe||Je<Qe)&&(_e._spread=!0),_e.end=Object.assign({},Qe?ce[Qe][1].start:fe[1].end),ce.splice(Qe||Ae,0,["exit",_e,fe[2]]),Ae++,Ie++}if(fe[1].type==="listItemPrefix"){const q={type:"listItem",_spread:!1,start:Object.assign({},fe[1].start),end:void 0};_e=q,ce.splice(Ae,0,["enter",q,fe[2]]),Ae++,Ie++,Je=void 0,ut=!0}}}return ce[me][1]._spread=pt,Ie}function i(ce,me){return Ie;function Ie(Ae){l.call(this,ce(Ae),Ae),me&&me.call(this,Ae)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ce,me,Ie){this.stack[this.stack.length-1].children.push(ce),this.stack.push(ce),this.tokenStack.push([me,Ie||void 0]),ce.position={start:ui(me.start),end:void 0}}function u(ce){return me;function me(Ie){ce&&ce.call(this,Ie),f.call(this,Ie)}}function f(ce,me){const Ie=this.stack.pop(),Ae=this.tokenStack.pop();if(Ae)Ae[0].type!==ce.type&&(me?me.call(this,ce,Ae[0]):(Ae[1]||wS).call(this,ce,Ae[0]));else throw new Error("Cannot close `"+ce.type+"` ("+Yu({start:ce.start,end:ce.end})+"): it’s not open");Ie.position.end=ui(ce.end)}function p(){return vW(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function g(ce){if(this.data.expectingFirstListItemValue){const me=this.stack[this.stack.length-2];me.start=Number.parseInt(this.sliceSerialize(ce),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.lang=ce}function k(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.meta=ce}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce.replace(/(\r?\n|\r)$/g,"")}function S(ce){const me=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=me,Ie.identifier=ql(this.sliceSerialize(ce)).toLowerCase()}function N(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.title=ce}function C(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.url=ce}function P(ce){const me=this.stack[this.stack.length-1];if(!me.depth){const Ie=this.sliceSerialize(ce).length;me.depth=Ie}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function R(ce){const me=this.stack[this.stack.length-1];me.depth=this.sliceSerialize(ce).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function _(ce){const Ie=this.stack[this.stack.length-1].children;let Ae=Ie[Ie.length-1];(!Ae||Ae.type!=="text")&&(Ae=mt(),Ae.position={start:ui(ce.start),end:void 0},Ie.push(Ae)),this.stack.push(Ae)}function F(ce){const me=this.stack.pop();me.value+=this.sliceSerialize(ce),me.position.end=ui(ce.end)}function D(ce){const me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ie=me.children[me.children.length-1];Ie.position.end=ui(ce.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(me.type)&&(_.call(this,ce),F.call(this,ce))}function W(){this.data.atHardBreak=!0}function H(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function $(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function O(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function U(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=me,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function K(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=me,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function M(ce){const me=this.sliceSerialize(ce),Ie=this.stack[this.stack.length-2];Ie.label=bq(me),Ie.identifier=ql(me).toLowerCase()}function V(){const ce=this.stack[this.stack.length-1],me=this.resume(),Ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ie.type==="link"){const Ae=ce.children;Ie.children=Ae}else Ie.alt=me}function L(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.url=ce}function z(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.title=ce}function Y(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function Q(ce){const me=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=me,Ie.identifier=ql(this.sliceSerialize(ce)).toLowerCase(),this.data.referenceType="full"}function J(ce){this.data.characterReferenceType=ce.type}function Z(ce){const me=this.sliceSerialize(ce),Ie=this.data.characterReferenceType;let Ae;Ie?(Ae=VP(me,Ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=l0(me);const We=this.stack[this.stack.length-1];We.value+=Ae}function oe(ce){const me=this.stack.pop();me.position.end=ui(ce.end)}function ne(ce){F.call(this,ce);const me=this.stack[this.stack.length-1];me.url=this.sliceSerialize(ce)}function ue(ce){F.call(this,ce);const me=this.stack[this.stack.length-1];me.url="mailto:"+this.sliceSerialize(ce)}function ge(){return{type:"blockquote",children:[]}}function Ce(){return{type:"code",lang:null,meta:null,value:""}}function Ne(){return{type:"inlineCode",value:""}}function ke(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ue(){return{type:"emphasis",children:[]}}function ie(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function be(){return{type:"html",value:""}}function Re(){return{type:"image",title:null,url:"",alt:null}}function He(){return{type:"link",title:null,url:"",children:[]}}function rt(ce){return{type:"list",ordered:ce.type==="listOrdered",start:null,spread:ce._spread,children:[]}}function Fe(ce){return{type:"listItem",spread:ce._spread,checked:null,children:[]}}function ot(){return{type:"paragraph",children:[]}}function St(){return{type:"strong",children:[]}}function mt(){return{type:"text",value:""}}function at(){return{type:"thematicBreak"}}}function ui(e){return{line:e.line,column:e.column,offset:e.offset}}function t_(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?t_(e,r):kq(e,r)}}function kq(e,t){let n;for(n in t)if(e_.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function wS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Yu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Yu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Yu({start:t.start,end:t.end})+") is still open")}function Nq(e){const t=this;t.parser=n;function n(r){return wq(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Sq(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 Cq(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`