syntaur 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{_basePickBy-BhaCV7eH.js → _basePickBy-CWivToyi.js} +1 -1
- package/dashboard/dist/assets/{_baseUniq-CDPcqrs2.js → _baseUniq-C-qj6E4l.js} +1 -1
- package/dashboard/dist/assets/{arc-BP0RxLwl.js → arc-Dn5BIqMa.js} +1 -1
- package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-BDzvaeJp.js → architectureDiagram-2XIMDMQ5-D5D0K7rY.js} +1 -1
- package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-ZeL9mROo.js → blockDiagram-WCTKOSBZ-DVmYPMbu.js} +1 -1
- package/dashboard/dist/assets/{c4Diagram-IC4MRINW-7S5bvFLp.js → c4Diagram-IC4MRINW-BEasxbnl.js} +1 -1
- package/dashboard/dist/assets/channel-DqU_8tiy.js +1 -0
- package/dashboard/dist/assets/{chunk-4BX2VUAB-Ca7R4nv5.js → chunk-4BX2VUAB-LDIrtI5E.js} +1 -1
- package/dashboard/dist/assets/{chunk-55IACEB6-flEv13FB.js → chunk-55IACEB6-CaEBUJYu.js} +1 -1
- package/dashboard/dist/assets/{chunk-FMBD7UC4-CfcYWBM6.js → chunk-FMBD7UC4-B-GjCpdr.js} +1 -1
- package/dashboard/dist/assets/{chunk-JSJVCQXG-Dw4yL0VS.js → chunk-JSJVCQXG-BLVVcezm.js} +1 -1
- package/dashboard/dist/assets/{chunk-KX2RTZJC-B2cDe40G.js → chunk-KX2RTZJC-DqCNEw4h.js} +1 -1
- package/dashboard/dist/assets/{chunk-NQ4KR5QH-LZVm0IWg.js → chunk-NQ4KR5QH-BCPbFf5I.js} +1 -1
- package/dashboard/dist/assets/{chunk-QZHKN3VN-Dg0EeHNI.js → chunk-QZHKN3VN-Ci0C85q_.js} +1 -1
- package/dashboard/dist/assets/{chunk-WL4C6EOR-v3rXNwXc.js → chunk-WL4C6EOR-VVhAMMYU.js} +1 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-D29Eeoe8.js +1 -0
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-D29Eeoe8.js +1 -0
- package/dashboard/dist/assets/clone-Bok8Q3Jj.js +1 -0
- package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-D-3JzLoS.js → cose-bilkent-S5V4N54A-CO9uwgYO.js} +1 -1
- package/dashboard/dist/assets/{dagre-KLK3FWXG-d_mbczhU.js → dagre-KLK3FWXG-bwLLXcL4.js} +1 -1
- package/dashboard/dist/assets/{diagram-E7M64L7V-BUyAp8pW.js → diagram-E7M64L7V-RuS5R6V1.js} +1 -1
- package/dashboard/dist/assets/{diagram-IFDJBPK2-C8doXcyQ.js → diagram-IFDJBPK2-BQDJAHQd.js} +1 -1
- package/dashboard/dist/assets/{diagram-P4PSJMXO-BUSmHa55.js → diagram-P4PSJMXO-yLEsgzE5.js} +1 -1
- package/dashboard/dist/assets/{erDiagram-INFDFZHY-Bn5_0LPU.js → erDiagram-INFDFZHY-na6dUhY0.js} +1 -1
- package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-CnEjerQM.js → flowDiagram-PKNHOUZH-BIcrzwJR.js} +1 -1
- package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-CL94fbyy.js → ganttDiagram-A5KZAMGK-DHWRJn-D.js} +1 -1
- package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-4i_PeG8V.js → gitGraphDiagram-K3NZZRJ6-LGxDjL71.js} +1 -1
- package/dashboard/dist/assets/{graph-BtoFhoAd.js → graph-BUqNu277.js} +1 -1
- package/dashboard/dist/assets/{index-Dv_-SxuL.js → index-D-fepllQ.js} +3 -3
- package/dashboard/dist/assets/index-DnHyQJJH.css +1 -0
- package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-CdUsuNgZ.js → infoDiagram-LFFYTUFH-DidoA2hb.js} +1 -1
- package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-BjggRlUx.js → ishikawaDiagram-PHBUUO56-CdlZkbhV.js} +1 -1
- package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-V4AgexlR.js → journeyDiagram-4ABVD52K-luhcz_gn.js} +1 -1
- package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-ChlylQRf.js → kanban-definition-K7BYSVSG-Coidw9XE.js} +1 -1
- package/dashboard/dist/assets/{layout-DLcz9AmA.js → layout-_aBAAleE.js} +1 -1
- package/dashboard/dist/assets/{linear-l2xnSHze.js → linear-D8mFnDSx.js} +1 -1
- package/dashboard/dist/assets/{mermaid.core-DKO1ytRW.js → mermaid.core-BpP2keU-.js} +4 -4
- package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-DTmTPHrT.js → mindmap-definition-YRQLILUH-LjvrTe2z.js} +1 -1
- package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-CwK80y8Y.js → pieDiagram-SKSYHLDU-CkA2iU6e.js} +1 -1
- package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-Be1xqW_w.js → quadrantDiagram-337W2JSQ-BRmhKHQG.js} +1 -1
- package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-JcspXCs0.js → requirementDiagram-Z7DCOOCP-BYCQ4uFX.js} +1 -1
- package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-nJb1BInq.js → sankeyDiagram-WA2Y5GQK-C8SVk50M.js} +1 -1
- package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-DUrclEgA.js → sequenceDiagram-2WXFIKYE-CbA_2lnP.js} +1 -1
- package/dashboard/dist/assets/{stateDiagram-RAJIS63D-CjinnNtF.js → stateDiagram-RAJIS63D-D6ZtjAHE.js} +1 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-DeYN4wV6.js +1 -0
- package/dashboard/dist/assets/{timeline-definition-YZTLITO2-kM-oVLNz.js → timeline-definition-YZTLITO2-B2Uf-emK.js} +1 -1
- package/dashboard/dist/assets/{treemap-KZPCXAKY-CYziFlrQ.js → treemap-KZPCXAKY-CYnFKsuJ.js} +1 -1
- package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-DX0DbxBN.js → vennDiagram-LZ73GAT5-Cnj0qiDO.js} +1 -1
- package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-BGqM42ZM.js → xychartDiagram-JWTSCODW-BJy2mbL9.js} +1 -1
- package/dashboard/dist/index.html +4 -4
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/scripts/postinstall-submodules.mjs +40 -0
- package/statusline/statusline.sh +29 -0
- package/dashboard/dist/assets/channel-CcB_wcgb.js +0 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-BJr38z2g.js +0 -1
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-BJr38z2g.js +0 -1
- package/dashboard/dist/assets/clone-Cfs2GUGt.js +0 -1
- package/dashboard/dist/assets/index-DZUGYrvE.css +0 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-yfclw-nM.js +0 -1
|
@@ -437,7 +437,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
|
|
|
437
437
|
|
|
438
438
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
439
439
|
|
|
440
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hE="DialogDescriptionWarning",mE=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${N0(hE).contentName}}.`;return g.useEffect(()=>{var a;const i=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},E0=f0,gE=h0,R0=g0,mp=x0,gp=y0,xp=b0,yp=k0,P0=S0;const vp=E0,xE=R0,T0=g.forwardRef(({className:e,...t},n)=>l.jsx(mp,{ref:n,className:$e("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));T0.displayName=mp.displayName;const gc=g.forwardRef(({className:e,children:t,...n},o)=>l.jsxs(xE,{children:[l.jsx(T0,{}),l.jsx(gp,{ref:o,className:$e("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 rounded-xl border border-border/70 bg-card p-6 shadow-2xl outline-none",e),...n,children:t})]}));gc.displayName=gp.displayName;function yE({className:e,...t}){return l.jsx("div",{className:$e("flex flex-col space-y-2 text-left",e),...t})}function vE({className:e,...t}){return l.jsx("div",{className:$e("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const xc=g.forwardRef(({className:e,...t},n)=>l.jsx(xp,{ref:n,className:$e("text-lg font-semibold tracking-tight text-foreground",e),...t}));xc.displayName=xp.displayName;const bp=g.forwardRef(({className:e,...t},n)=>l.jsx(yp,{ref:n,className:$e("text-sm leading-6 text-muted-foreground",e),...t}));bp.displayName=yp.displayName;const bE=-1,wE=-40;function $d(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,o=0,i=-2,a=0;for(let c=0;c<e.length;c++){const d=e[c];let p=!1;for(;o<t.length;)if(t[o]===d){if(n+=100,o===i+1&&(n+=20),o===0)n+=30;else{const h=t[o-1];(h===" "||h==="-"||h==="_"||h==="/")&&(n+=15)}a>0&&(n+=Math.max(wE,a*bE)),i=o,a=0,o++,p=!0;break}else a++,o++;if(!p)return-1/0}return n}const yx={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function kE(e,t,n=50){const o=e.toLowerCase();if(!o)return t.slice(0,n).map(c=>({...c,score:0}));const a=t.map(c=>{var x;const d=$d(o,c.title.toLowerCase())*1,p=c.subtitle?$d(o,c.subtitle.toLowerCase())*.5:-1/0,h=(x=c.keywords)!=null&&x.length?$d(o,c.keywords.join(" ").toLowerCase())*.3:-1/0,m=Math.max(d,p,h);return{...c,score:m}}).filter(c=>c.score>-1/0);return a.sort((c,d)=>d.score!==c.score?d.score-c.score:c.title.length!==d.title.length?c.title.length-d.title.length:c.title!==d.title?c.title<d.title?-1:1:(yx[c.type]??99)-(yx[d.type]??99)),a.slice(0,n)}const jE={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo"};function SE({entries:e}){const{paletteOpen:t,closePalette:n}=Fs(),o=Xt(),[i,a]=g.useState(""),[c,d]=g.useState(0),p=g.useRef(null),h=g.useMemo(()=>kE(i,e,50),[i,e]);g.useEffect(()=>{d(0)},[i,t]),g.useEffect(()=>{t||a("")},[t]),g.useEffect(()=>{var b;const v=(b=p.current)==null?void 0:b.querySelector(`[data-palette-idx="${c}"]`);v==null||v.scrollIntoView({block:"nearest"})},[c]);function m(v){o(v.route),n()}function x(v){if(v.key==="ArrowDown")v.preventDefault(),d(b=>Math.min(h.length-1,b+1));else if(v.key==="ArrowUp")v.preventDefault(),d(b=>Math.max(0,b-1));else if(v.key==="Enter"){v.preventDefault();const b=h[c];b&&m(b)}}return l.jsx(vp,{open:t,onOpenChange:v=>v?null:n(),children:l.jsxs(gc,{className:"max-w-xl p-0 gap-0",children:[l.jsx(xc,{className:"sr-only",children:"Command palette"}),l.jsx("input",{autoFocus:!0,type:"text",value:i,onChange:v=>a(v.target.value),onKeyDown:x,placeholder:"Search projects, assignments, playbooks, servers, todos…",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:ring-0"}),l.jsx("div",{ref:p,className:"max-h-[60vh] overflow-y-auto p-1",children:h.length===0?l.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:i?"No matches":"Start typing to search"}):h.map((v,b)=>{const N=b===c;return l.jsxs("button",{type:"button","data-palette-idx":b,onClick:()=>m(v),onMouseEnter:()=>d(b),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${N?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[l.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:jE[v.type]??v.type}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.title}),v.subtitle?l.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:v.subtitle}):null]},v.id)})}),l.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[l.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," open ","·"," Esc close"]}),l.jsxs("span",{children:[h.length," result",h.length===1?"":"s"]})]})]})})}const CE={global:"Global","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},NE=["global","list:projects","list:assignments","list:todos","project","assignment"];function EE(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Ss(t)} then ${Ss(n)}`}return Ss(e)}function RE(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n}=Fs(),o=g.useMemo(()=>{if(!e)return new Map;const i=n(),a=new Map;for(const c of i){const d=a.get(c.scope)??[];d.push({keys:c.keys,description:c.description}),a.set(c.scope,d)}return a},[e,n]);return l.jsx(vp,{open:e,onOpenChange:i=>i?null:t(),children:l.jsxs(gc,{className:"max-w-2xl",children:[l.jsx(xc,{children:"Keyboard shortcuts"}),l.jsxs(bp,{children:["Press Esc to close. ",Ss("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),l.jsx("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:NE.map(i=>{const a=o.get(i);return!a||a.length===0?null:l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:CE[i]}),l.jsx("ul",{className:"space-y-1",children:a.map((c,d)=>l.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:[l.jsx("span",{className:"text-foreground",children:c.description}),l.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:EE(c.keys)})]},`${i}-${c.keys}-${d}`))})]},i)})})]})})}const vx=1500;function PE(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const A0=g.createContext(null);function TE({children:e}){const{toggleTheme:t}=Fv(),n=fn(),o=Xt(),i=PE(n.pathname),a=dc(),c=Bv(),d=Vv(),p=ap(),h=cp(),m=g.useMemo(()=>{var R,F,J,I;const X=a.data??[],_=((R=c.data)==null?void 0:R.assignments)??[],D=((F=d.data)==null?void 0:F.playbooks)??[],V=((J=p.data)==null?void 0:J.sessions)??[],ee=(((I=h.data)==null?void 0:I.workspaces)??[]).flatMap(de=>de.items.map(ve=>({...ve,workspace:de.workspace})));return DN({projects:X,assignments:_,playbooks:D,servers:V,todos:ee,wsPrefix:i})},[a.data,c.data,d.data,p.data,h.data,i]),x=g.useRef(new Map),v=g.useRef(["global"]),b=g.useRef({phase:"idle"}),N=g.useRef(null),k=g.useRef(1),[j,S]=g.useState(!1),[T,A]=g.useState(!1),L=g.useCallback(X=>{const _=k.current++;return x.current.set(_,{...X,id:_}),_},[]),O=g.useCallback(X=>{x.current.delete(X)},[]),P=g.useCallback(X=>{v.current.push(X)},[]),$=g.useCallback(X=>{const _=v.current;for(let D=_.length-1;D>=0;D--)if(_[D]===X){_.splice(D,1);return}},[]),E=g.useCallback(()=>S(!0),[]),H=g.useCallback(()=>S(!1),[]),Z=g.useCallback(()=>A(!0),[]),G=g.useCallback(()=>A(!1),[]),q=g.useCallback(()=>Array.from(x.current.values()),[]);g.useEffect(()=>{b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[n.pathname]),g.useEffect(()=>{function X(ee){if(!(ee instanceof HTMLElement))return!1;const R=ee.tagName;return!!(R==="INPUT"||R==="TEXTAREA"||R==="SELECT"||ee.isContentEditable||ee.closest('[role="combobox"], [role="textbox"]'))}function _(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function D(){const ee=v.current;return ee[ee.length-1]??"global"}function V(ee){return ee.scope==="global"?!0:ee.scope===D()}function W(ee){const R=Td(ee,"Mod+k"),F=ee.key==="Escape";if(_()&&!R&&!F||X(ee.target)&&!R&&!F)return;const J=b.current;if(J.phase==="awaiting-second")if(Date.now()-J.startedAt>vx)b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null);else{const ve=Array.from(x.current.values());for(const fe of ve){if(!V(fe))continue;const Ee=fe.keys.split(" ");if(!(Ee.length!==2||Ee[0]!=="g")&&Td(ee,Ee[1])&&!(fe.when&&!fe.when())){ee.preventDefault(),b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null),fe.handler(ee);return}}b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null)}const I=Array.from(x.current.values());for(const de of I){if(!V(de))continue;const ve=de.keys.split(" ");if(ve.length===1&&Td(ee,ve[0])&&!(de.when&&!de.when())){ee.preventDefault(),de.handler(ee);return}}ee.key==="g"&&!ee.metaKey&&!ee.ctrlKey&&!ee.altKey&&!ee.shiftKey&&Array.from(x.current.values()).some(ve=>V(ve)&&ve.keys.startsWith("g "))&&(ee.preventDefault(),b.current={phase:"awaiting-second",startedAt:Date.now()},N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{b.current={phase:"idle"},N.current=null},vx))}return window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W),N.current!==null&&(window.clearTimeout(N.current),N.current=null)}},[]),g.useEffect(()=>{const X=L({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>O(X)},[L,O,t]),g.useEffect(()=>{const X=L({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>Z()});return()=>O(X)},[L,O,Z]),g.useEffect(()=>{const X=L({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(j){H();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||E()}});return()=>O(X)},[L,O,E,H,j]),g.useEffect(()=>{const _=[{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:"/attention",desc:"Go to Attention"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map(D=>L({keys:`g ${D.suffix}`,scope:"global",description:D.desc,handler:()=>o(Fa(D.basePath,i))}));return()=>_.forEach(O)},[L,O,o,i]);const Y=g.useMemo(()=>({register:L,unregister:O,pushScope:P,popScope:$,openPalette:E,closePalette:H,paletteOpen:j,openCheatsheet:Z,closeCheatsheet:G,cheatsheetOpen:T,listBindings:q,wsPrefix:i,paletteEntries:m}),[L,O,P,$,E,H,j,Z,G,T,q,i,m]);return l.jsxs(A0.Provider,{value:Y,children:[e,l.jsx(SE,{entries:m}),l.jsx(RE,{})]})}function Fs(){const e=g.useContext(A0);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function yt({keys:e,handler:t,scope:n="global",description:o,when:i,enabled:a=!0}){const{register:c,unregister:d}=Fs(),p=g.useRef(t),h=g.useRef(i);g.useEffect(()=>{p.current=t,h.current=i},[t,i]),g.useEffect(()=>{if(!a)return;const m=c({keys:e,handler:x=>p.current(x),scope:n,description:o,when:h.current?()=>h.current():void 0});return()=>d(m)},[c,d,e,n,o,a])}function zs(e){const{pushScope:t,popScope:n}=Fs();g.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function yc(e,t){const[n,o]=g.useState(e.length===0?-1:0),i=fn();g.useEffect(()=>{o(e.length===0?-1:0)},[i.pathname]),g.useEffect(()=>{o(c=>e.length===0?-1:Math.min(Math.max(0,c),e.length-1))},[e.length]),g.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(d=>{const p=Number(d.getAttribute("data-hotkey-row-index"));d.setAttribute("data-hotkey-selected",p===n?"true":"false")}),n>=0){const d=document.querySelector(`[data-hotkey-row-index="${n}"]`);d==null||d.scrollIntoView({block:"nearest"})}},[n,e.length]),yt({keys:"j",scope:t.scope,description:"Select next row",handler:()=>o(c=>e.length===0?-1:Math.min(e.length-1,c<0?0:c+1))}),yt({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>o(c=>e.length===0?-1:Math.max(0,c<0?0:c-1))}),yt({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),yt({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 a=g.useCallback(c=>({"data-hotkey-row-index":c,"data-hotkey-selected":c===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:a}}function AE({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:o}){const i=Lt(),{resolvedTheme:a,toggleTheme:c}=Fv(),{openPalette:d}=Fs();return l.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/85 backdrop-blur",children:l.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[l.jsx("button",{type:"button",onClick:o,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:l.jsx(yC,{className:"h-4 w-4"})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?l.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((p,h)=>l.jsxs("span",{className:"flex items-center gap-1.5",children:[h>0?l.jsx("span",{children:"/"}):null,l.jsx(Ce,{to:p.path,className:"hover:text-foreground",children:p.label})]},p.path)),l.jsx("span",{children:"/"})]}):null,l.jsx("h1",{className:"truncate text-base font-semibold text-foreground",children:e})]})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:d,className:"shell-action","aria-label":"Open command palette",children:[l.jsx(sl,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Ss("Mod+k")})]}),l.jsx(Ce,{className:"shell-action",to:"/help",children:"Help"}),l.jsxs(Ce,{className:"shell-action",to:`${i}/create/project`,children:[l.jsx(lr,{className:"h-4 w-4"}),l.jsx("span",{children:"New Project"})]}),n?l.jsxs(Ce,{className:"shell-action",to:`${i}/projects/${n}/create/assignment`,children:[l.jsx(lr,{className:"h-4 w-4"}),l.jsx("span",{children:"New Assignment"})]}):null,l.jsxs("button",{type:"button",onClick:c,className:"shell-action","aria-label":"Toggle theme",children:[a==="dark"?l.jsx(PC,{className:"h-4 w-4"}):l.jsx(vC,{className:"h-4 w-4"}),l.jsx("span",{children:a==="dark"?"Light":"Dark"})]})]})]})})}const DE=[{to:"/",label:"Overview",icon:oC},{to:"/attention",label:"Attention",icon:il},{to:"/playbooks",label:"Playbooks",icon:yv},{to:"/todos",label:"Todos",icon:Sr}],IE=[{suffix:"/projects",label:"Projects",icon:np},{suffix:"/assignments",label:"Assignments",icon:xC},{suffix:"/servers",label:"Servers",icon:rp},{suffix:"/agent-sessions",label:"Agent Sessions",icon:uc},{suffix:"/todos",label:"Todos",icon:Sr}],LE=[{to:"/help",label:"Help",icon:mC},{to:"/settings",label:"Settings",icon:EC}],bx="syntaur.dashboard.sourceFirstNoticeDismissed";function OE({title:e,breadcrumbs:t,projectSlug:n,workspace:o,children:i}){const[a,c]=g.useState(!1);yt({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:a,handler:()=>c(!1)});const[d,p]=g.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(bx)==="1"}catch{return!1}});function h(){if(p(!0),!(typeof window>"u"))try{window.localStorage.setItem(bx,"1")}catch{}}return l.jsx("div",{className:"min-h-screen bg-background",children:l.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[l.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar/90 px-4 py-4 backdrop-blur lg:flex lg:flex-col",children:l.jsx(wx,{sourceNoticeDismissed:d,onDismissSourceNotice:h,activeWorkspace:o})}),a?l.jsx("div",{className:"fixed inset-0 z-40 bg-slate-950/40 lg:hidden",children:l.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[l.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[l.jsx(Ce,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),l.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:l.jsx(Ev,{className:"h-4 w-4"})})]}),l.jsx(wx,{sourceNoticeDismissed:d,onDismissSourceNotice:h,activeWorkspace:o,onNavigate:()=>c(!1)})]})}):null,l.jsxs("div",{className:"min-w-0",children:[l.jsx(AE,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),l.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:i})]})]})})}function wx({sourceNoticeDismissed:e,onDismissSourceNotice:t,activeWorkspace:n,onNavigate:o}){const{data:i}=lp(),a=(i==null?void 0:i.workspaces)??[],c=(i==null?void 0:i.hasUngrouped)??!1,d=fn(),[p,h]=g.useState(new Set),[m,x]=g.useState(!1),[v,b]=g.useState(""),N=Xt();function k(S){h(T=>{const A=new Set(T);return A.has(S)?A.delete(S):A.add(S),A})}const j=[...a,...c?["_ungrouped"]:[]];return l.jsxs("div",{className:"flex h-full flex-col gap-3",children:[l.jsx("div",{className:"space-y-3",children:l.jsxs(Ce,{to:"/",className:"inline-flex items-center gap-3",onClick:o,children:[l.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-foreground text-sm font-semibold text-background shadow-sm",children:"S"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),l.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),l.jsx(ox,{items:DE,onNavigate:o}),l.jsx("div",{className:"border-t border-border/40"}),l.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[j.length===0&&!m&&l.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),j.map(S=>{const T=S==="_ungrouped",A=T?"Ungrouped":Cn(S),L=T?"/w/_ungrouped":`/w/${S}`,O=p.has(S),P=n===S||n===null&&T&&d.pathname.startsWith("/w/_ungrouped");return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>k(S),className:`flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${P?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[l.jsx(Yi,{className:`h-3 w-3 transition-transform ${O?"-rotate-90":""}`}),A]}),!O&&l.jsx("nav",{className:"ml-2 space-y-0.5",children:IE.map($=>{const E=`${L}${$.suffix}`,H=Ov(d.pathname,$.suffix)&&d.pathname.startsWith(L),Z=$.icon;return l.jsxs(Ce,{to:E,onClick:o,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${H?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[l.jsx(Z,{className:"h-4 w-4"}),l.jsx("span",{children:$.label})]},E)})})]},S)}),m?l.jsx("form",{className:"px-3 py-1.5",onSubmit:S=>{S.preventDefault();const T=v.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");T&&(x(!1),b(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T})}).then(()=>{o==null||o(),N(`/w/${T}/projects`)}))},children:l.jsx("input",{autoFocus:!0,type:"text",value:v,onChange:S=>b(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(x(!1),b(""))},onBlur:()=>{v.trim()||(x(!1),b(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):l.jsxs("button",{type:"button",onClick:()=>x(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[l.jsx(lr,{className:"h-3 w-3"}),"New Workspace"]})]}),l.jsx("div",{className:"border-t border-border/40"}),l.jsx(ox,{items:LE,onNavigate:o}),e?null:l.jsx("div",{className:"rounded-lg border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Source-first dashboard"}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Project and assignment markdown files stay authoritative. Derived files are read-only projections."})]}),l.jsx("button",{type:"button",onClick:t,className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/70 bg-background/80 text-muted-foreground transition hover:text-foreground","aria-label":"Dismiss source-first dashboard notice",children:l.jsx(Ev,{className:"h-4 w-4"})})]})})]})}function _E(){const e=fn(),{workspace:t}=Et(),{title:n,breadcrumbs:o,projectSlug:i}=mN(e.pathname);return l.jsx(OE,{title:n,breadcrumbs:o,projectSlug:i,workspace:t??null,children:l.jsx(uS,{})})}const Ya={pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:"border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300",icon:nC},in_progress:{label:"In Progress",description:"Actively being worked on.",className:"border-teal-300 bg-teal-100 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",icon:jv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-300",icon:xf},review:{label:"Review",description:"Ready for inspection or approval.",className:"border-violet-300 bg-violet-100 text-violet-800 dark:border-violet-800 dark:bg-violet-950 dark:text-violet-300",icon:SC},completed:{label:"Completed",description:"Finished successfully.",className:"border-emerald-300 bg-emerald-100 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-300",icon:ep},failed:{label:"Failed",description:"Could not be completed as planned.",className:"border-rose-300 bg-rose-100 text-rose-800 dark:border-rose-800 dark:bg-rose-950 dark:text-rose-300",icon:xf},active:{label:"Active",description:"The project has active or review work in flight.",className:"border-teal-300 bg-teal-100 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",icon:yf},stopped:{label:"Stopped",description:"Session ended without completing.",className:"border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300",icon:ZS},archived:{label:"Archived",description:"Archived by a human override.",className:"border-zinc-300 bg-zinc-100 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-300",icon:yf}};function Ht({status:e,className:t,showIcon:n=!0,progress:o}){const i=Ya[e]??{label:e.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase()),description:`Status: ${e}`,className:"border-slate-300 bg-slate-100 text-slate-600 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400",icon:yf},a=i.icon,c=o&&o.total>0,d=c?Math.min(1,Math.max(0,o.checked/o.total)):0,p=c?`${i.description} (${o.checked}/${o.total} criteria)`:i.description,h=n?c?l.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[l.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[l.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),l.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-d)})]}),l.jsx(a,{className:"h-2.5 w-2.5"})]}):l.jsx(a,{className:"h-3.5 w-3.5"}):null;return l.jsxs("span",{title:p,className:$e("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2 py-0.5 text-xs font-semibold tracking-wide",i.className,t),children:[h,l.jsx("span",{children:i.label})]})}function D0(e){var t;return((t=Ya[e])==null?void 0:t.description)??`Status: ${e}`}const ME={default:"border-border/70 bg-card/90",info:"border-teal-200 bg-teal-50 dark:border-teal-900 dark:bg-teal-950/40",warn:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/40",danger:"border-rose-200 bg-rose-50 dark:border-rose-900 dark:bg-rose-950/40",success:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/40"};function it({label:e,value:t,description:n,icon:o,tone:i="default",to:a}){const c=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-start justify-between gap-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),l.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),o?l.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:l.jsx(o,{className:"h-5 w-5"})}):null]}),n?l.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),d=$e("rounded-lg border p-3 shadow-sm",ME[i],a?"block transition hover:-translate-y-0.5 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return a?l.jsx(Ce,{to:a,className:d,children:c}):l.jsx("article",{className:d,children:c})}function Pe({title:e,description:t,children:n,className:o,actions:i}){return l.jsxs("section",{className:$e("surface-panel space-y-3",o),children:[e||i?l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[e?l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?l.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),i]}):null,n]})}function jt({label:e="Loading dashboard data…"}){return l.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:l.jsx("div",{className:"rounded-lg border border-border/70 bg-card/90 px-4 py-3 shadow-sm",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function vt({title:e="Something went wrong",error:t,action:n}){return l.jsx("div",{className:"rounded-lg border border-rose-200 bg-rose-50 px-4 py-5 dark:border-rose-900 dark:bg-rose-950/30",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"text-lg font-semibold text-rose-800 dark:text-rose-200",children:e}),l.jsx("p",{className:"text-sm leading-6 text-rose-700 dark:text-rose-300",children:t}),n?l.jsx("div",{className:"pt-2",children:n}):null]})})}function Ge({title:e,description:t,actions:n}){return l.jsx("div",{className:"rounded-lg border border-dashed border-border/80 bg-muted/30 px-4 py-6 text-center",children:l.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[l.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?l.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}function Ua({command:e,description:t,example:n}){return l.jsxs("div",{className:"rounded-lg border border-border/70 bg-slate-950 px-3 py-3 text-slate-100 shadow-sm",children:[l.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?l.jsx("p",{className:"mt-2 text-sm text-slate-300",children:t}):null,n?l.jsx("p",{className:"mt-2 font-mono text-xs text-slate-400",children:n}):null]})}function $E({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return l.jsx(Pe,{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:l.jsx(Ce,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:l.jsx("div",{className:"space-y-3",children:n.map((o,i)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.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}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?l.jsx(Ua,{command:o.command.command,example:o.command.example}):null]})]})},o.title))})})}function FE(){var c;const{data:e,loading:t,error:n}=vN(),{data:o}=Uv(),{data:i}=cp(),a=i!=null&&i.workspaces?i.workspaces.reduce((d,p)=>d+p.counts.open+p.counts.in_progress,0):0;return t?l.jsx(jt,{label:"Loading overview…"}):n||!e?l.jsx(vt,{error:n||"Overview data is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(160px,1fr))]",children:[l.jsx(it,{label:"Active Projects",value:e.stats.activeProjects,icon:np,to:"/projects"}),l.jsx(it,{label:"In Progress",value:e.stats.inProgressAssignments,icon:dC,tone:"info",to:"/assignments?status=in_progress"}),l.jsx(it,{label:"Blocked",value:e.stats.blockedAssignments,icon:il,tone:"warn",to:"/assignments?status=blocked"}),l.jsx(it,{label:"Review",value:e.stats.reviewAssignments,icon:tC,tone:"info",to:"/assignments?status=review"}),l.jsx(it,{label:"Failed",value:e.stats.failedAssignments,icon:bC,tone:"danger",to:"/assignments?status=failed"}),l.jsx(it,{label:"Stale",value:e.stats.staleAssignments,icon:uc,to:"/assignments?stale=1"}),l.jsx(it,{label:"Open Todos",value:a,icon:Sr,to:"/todos"}),l.jsx(it,{label:"Active Servers",value:e.serverStats?e.serverStats.aliveSessions:"…",description:e.serverStats?`${e.serverStats.totalPorts} ports · ${e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"}`:"connecting",icon:rp,tone:(c=e.serverStats)!=null&&c.deadSessions?"warn":"default",to:"/servers"})]}),l.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(360px,0.9fr)]",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsx(Pe,{title:"Needs Attention Now",description:"Blocked, failed, review, and stale work from the source files.",children:e.attention.length===0?l.jsx(Ge,{title:"Nothing urgent right now",description:"The attention queue is empty. Overview will surface blocked, failed, review, and stale assignments here."}):l.jsx("div",{className:"space-y-3",children:e.attention.map(d=>l.jsxs(Ce,{to:d.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40 hover:bg-background",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:d.assignmentTitle}),l.jsx("p",{className:"text-sm text-muted-foreground",children:d.projectTitle})]}),l.jsx(Ht,{status:d.status})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:d.reason}),l.jsxs("p",{className:"mt-2 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:["Updated ",Cr(d.updated)]})]},d.id))})}),l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Pe,{title:"Recently Updated Projects",children:e.recentProjects.length===0?l.jsx(Ge,{title:"No projects yet",description:"Create your first project to populate the project directory, recent activity, and attention queue.",actions:l.jsx(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:"/create/project",children:"Create Project"})}):l.jsx("div",{className:"space-y-3",children:e.recentProjects.map(d=>l.jsx(Ce,{to:`/projects/${d.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-foreground",children:d.title}),l.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Cr(d.updated)})]}),l.jsx(Ht,{status:d.status})]})},d.slug))})}),l.jsx(Pe,{title:"Recent Activity",children:e.recentActivity.length===0?l.jsx(Ge,{title:"No activity yet",description:"Once projects and assignments exist, Overview will show activity based on parsed source timestamps instead of file mtimes."}):l.jsx("div",{className:"space-y-3",children:e.recentActivity.map(d=>l.jsxs(Ce,{to:d.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"font-semibold text-foreground",children:d.title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:d.summary})]}),l.jsx("span",{className:"text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:Cn(d.type)})]}),l.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:Cr(d.updated)})]},d.id))})})]})]}),e.firstRun&&l.jsx($E,{help:o})]})]})}function zE(){const{data:e,loading:t,error:n}=bN();return t?l.jsx(jt,{label:"Loading attention queue…"}):n||!e?l.jsx(vt,{error:n||"Attention queue is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[l.jsx(it,{label:"Critical",value:e.summary.critical,icon:uC,tone:"danger"}),l.jsx(it,{label:"High",value:e.summary.high,icon:il,tone:"warn"}),l.jsx(it,{label:"Medium",value:e.summary.medium,icon:RC,tone:"info"}),l.jsx(it,{label:"Low",value:e.summary.low,icon:hC})]}),l.jsx(Pe,{title:"Attention Queue",description:"Ordered by severity, then by the latest parsed source update.",children:e.items.length===0?l.jsx(Ge,{title:"Attention queue is clear",description:"No blocked, failed, review, or stale assignments are currently surfacing from the source files."}):l.jsx("div",{className:"space-y-3",children:e.items.map(o=>l.jsxs(Ce,{to:o.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:o.assignmentTitle}),l.jsx("p",{className:"text-sm text-muted-foreground",children:o.projectTitle})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:o.severity}),l.jsx(Ht,{status:o.status})]})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.reason}),l.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",Cr(o.updated)]})]},o.id))})})]})}function BE({term:e,description:t}){return l.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 UE(){const{data:e,loading:t,error:n}=Uv(),{openCheatsheet:o}=Fs();return t?l.jsx(jt,{label:"Loading help…"}):n||!e?l.jsx(vt,{error:n||"Help content is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsx(Pe,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("button",{type:"button",onClick:o,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"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",l.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Ss("Mod+k")," opens the command palette."]})]})}),l.jsx(Pe,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:l.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(i=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:i},i))})}),l.jsx(Pe,{title:"Getting Started",children:l.jsx("div",{className:"space-y-3",children:e.workflow.map((i,a)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:i.detail}),i.command?l.jsx(Ua,{command:i.command.command,description:i.command.description,example:i.command.example}):null,i.href?l.jsx(Ce,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open the related surface"}):null]})]})},i.title))})}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsxs(Pe,{title:"Core Concepts",children:[l.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(i=>l.jsx(BE,{term:i.term,description:i.description},i.term))}),l.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.term}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description})]},i.term))})]}),l.jsx(Pe,{title:"Status Guide",children:l.jsx("div",{className:"space-y-3",children:e.statusGuide.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx(Ht,{status:i.status}),l.jsx("p",{className:"font-semibold text-foreground",children:i.meaning})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.useWhen})]},i.status))})})]}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsx(Pe,{title:"Ownership And File Rules",children:l.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.label}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description}),l.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.files.map(a=>l.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:a},a))})]},i.label))})}),l.jsx(Pe,{title:"How To Navigate The Dashboard",children:l.jsx("div",{className:"space-y-3",children:e.navigation.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.label}),l.jsx(Ce,{className:"text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open"})]}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description})]},i.label))})})]}),l.jsx(Pe,{title:"CLI Quick Reference",children:l.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(i=>l.jsx(Ua,{command:i.command,description:i.description,example:i.example},i.command))})}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsx(Pe,{title:"FAQ",children:l.jsx("div",{className:"space-y-3",children:e.faq.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.question}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.answer})]},i.question))})}),l.jsx(Pe,{title:"First Project Checklist",children:l.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((i,a)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:i.detail}),i.command?l.jsx(Ua,{command:i.command.command,example:i.command.example}):null,i.href?l.jsx(Ce,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open the related surface"}):null]})]})},i.title))})})]})]})}function wp({children:e}){return l.jsx("div",{className:"flex flex-col gap-2 rounded-lg border border-border/60 bg-card/80 p-2.5 shadow-sm md:flex-row md:flex-wrap md:items-center",children:e})}const vc=g.forwardRef(({value:e,onChange:t,placeholder:n="Search"},o)=>l.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[l.jsx(sl,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),l.jsx("input",{ref:o,value:e,onChange:i=>t(i.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"})]}));vc.displayName="SearchInput";function kp({value:e,options:t,onChange:n}){return l.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(o=>l.jsx("button",{type:"button",onClick:()=>n(o.value),className:$e("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===o.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:o.label},o.value))})}function I0({columns:e,items:t,getItemId:n,getColumnId:o,renderCard:i,canDrop:a,onMove:c,emptyMessage:d="No cards in this column."}){const[p,h]=g.useState(null),[m,x]=g.useState(null),v=g.useRef(null),b=g.useMemo(()=>new Map(t.map(O=>[n(O),O])),[n,t]),N=g.useMemo(()=>e.map(O=>({column:O,items:t.filter(P=>o(P)===O.id)})),[e,o,t]),k=p?b.get(p)??null:null;function j(O){if(!k)return{allowed:!1};const P=o(k);return(a==null?void 0:a({item:k,fromColumnId:P,toColumnId:O}))??{allowed:!0}}function S(){h(null),x(null)}function T(O,P){c&&(O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",P),h(P))}function A(O,P,$){!c||!k||!j(P).allowed||(O.preventDefault(),O.dataTransfer.dropEffect="move",x(H=>(H==null?void 0:H.columnId)===P&&H.index===$?H:{columnId:P,index:$}))}async function L(O,P,$){var q;if(O.preventDefault(),!c||!k){S();return}const E=o(k),Z=(((q=N.find(Y=>Y.column.id===E))==null?void 0:q.items)??[]).findIndex(Y=>n(Y)===n(k));if(!j(P).allowed||Z<0){S();return}if(E===P&&($===Z||$===Z+1)){S();return}try{await c({item:k,fromColumnId:E,toColumnId:P,fromIndex:Z,toIndex:$})}finally{S()}}return l.jsx("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"hsl(var(--border)) transparent",scrollbarWidth:"thin"},children:l.jsx("div",{className:"grid min-w-max auto-cols-[minmax(260px,320px)] grid-flow-col gap-4",children:N.map(({column:O,items:P})=>{const $=j(O.id),E=(m==null?void 0:m.columnId)===O.id;return l.jsxs("section",{className:$e("flex min-h-[320px] flex-col rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k&&!$.allowed?"border-dashed opacity-65":"",k&&$.allowed?"border-primary/30 bg-accent/30":"",E?"ring-2 ring-ring/30":""),title:k&&!$.allowed?$.reason:void 0,children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:O.title}),O.description?l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:O.description}):null]}),l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:P.length})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:H=>A(H,O.id,P.length),onDrop:H=>L(H,O.id,P.length),children:[P.length===0?l.jsx(HE,{active:(m==null?void 0:m.columnId)===O.id&&m.index===0,disabled:!!k&&!$.allowed,children:typeof d=="function"?d(O):d}):null,P.map((H,Z)=>{const G=n(H),q=p===G;return l.jsxs(g.Fragment,{children:[l.jsx("div",{className:$e("h-2 rounded-full transition",(m==null?void 0:m.columnId)===O.id&&m.index===Z?"bg-primary/70":"bg-transparent"),onDragOver:Y=>A(Y,O.id,Z),onDrop:Y=>L(Y,O.id,Z)}),l.jsx("div",{draggable:!!c,onMouseDown:Y=>{v.current=Y.target},onDragStart:Y=>{const X=v.current;if(X!=null&&X.closest("a, button")){Y.preventDefault();return}T(Y,G)},onDragEnd:S,className:$e("transition",c?"cursor-grab active:cursor-grabbing":"",q?"scale-[0.98] opacity-50":""),children:i(H,{dragging:q})})]},G)}),P.length>0?l.jsx("div",{className:$e("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(m==null?void 0:m.columnId)===O.id&&m.index===P.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",k&&!$.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},O.id)})})})}function HE({active:e,disabled:t,children:n}){return l.jsx("div",{className:$e("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 L0={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let $i=null,Bo=null;function WE(){return $i?Promise.resolve($i):Bo||(Bo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>($i=e,Bo=null,e)).catch(()=>(Bo=null,L0)),Bo)}function bc(){const[e,t]=g.useState(()=>$i??L0);return g.useEffect(()=>{WE().then(t)},[]),e}function kx(){$i=null,Bo=null}function VE(e,t){const n=e.statuses.find(o=>o.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}const qE={completed:"bg-emerald-500",in_progress:"bg-sky-500",review:"bg-violet-500",blocked:"bg-amber-500",failed:"bg-rose-500",pending:"bg-slate-400"},jx=["bg-cyan-500","bg-indigo-500","bg-orange-500","bg-pink-500","bg-lime-500","bg-fuchsia-500"];function Xa({progress:e,className:t,showLegend:n=!1}){const o=bc(),i=g.useMemo(()=>{let c=0;return(o.order.length>0?o.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:qE[p]??jx[c++%jx.length]}))},[o.order,e]),a=i.filter(c=>(e[c.key]??0)>0);return l.jsxs("div",{className:$e("space-y-2",t),children:[l.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?l.jsx("div",{className:"h-full w-full bg-muted"}):a.map(c=>l.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${Cn(c.key)}: ${e[c.key]??0}`},c.key))}),n?l.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(c=>l.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[l.jsx("span",{className:$e("h-2 w-2 rounded-full",c.className)}),l.jsx("span",{children:Cn(c.key)}),l.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const KE=["pending","active","blocked","failed","completed","archived"],jp=KE,GE=["pending","in_progress","blocked","review","completed","failed"];function YE(e){return e&&e.length>0?e:[...GE]}function XE(e,t,n){if(t<0||t>=e.length)return e;const o=[...e],[i]=o.splice(t,1),a=t<n?n-1:n;return o.splice(Math.max(0,Math.min(a,o.length)),0,i),o}function Sx(){const{workspace:e}=Et(),t=Lt(),n=Xt(),{data:o,loading:i,error:a,refetch:c}=dc(),d=g.useRef(null);zs("list:projects");const[p,h]=g.useState(""),[m,x]=g.useState("all"),[v,b]=g.useState("active"),[N,k]=g.useState("all"),[j,S]=g.useState("updated"),[T,A]=_s(),L=T.get("view"),O=L==="table"||L==="kanban"?L:"cards",P=D=>{A(V=>{const W=new URLSearchParams(V);return D==="cards"?W.delete("view"):W.set("view",D),W})},[$,E]=g.useState({}),H=g.useMemo(()=>o?o.filter(D=>{if(e){if(e==="_ungrouped"){if(D.workspace!==null)return!1}else if(D.workspace!==e)return!1}return v==="active"&&D.archived||v==="archived"&&!D.archived||m!=="all"&&D.status!==m||N!=="all"&&!D.tags.includes(N)?!1:p.trim()?`${D.title} ${D.tags.join(" ")} ${D.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((D,V)=>ZE(D,V,j)):[],[o,p,m,v,N,j,e]),Z=H.map(D=>`${D.slug}:${D.status}`).join("|");g.useEffect(()=>{E(eR(H))},[Z,j]);const G=g.useMemo(()=>{const D=new Map(H.map(V=>[V.slug,V]));return jp.flatMap(V=>($[V]??H.filter(ee=>ee.status===V).map(ee=>ee.slug)).map(ee=>D.get(ee)).filter(ee=>!!ee))},[H,$]),{visibleItems:q,visibleIndexByKey:Y}=g.useMemo(()=>{const D=O==="kanban"?G:H,V=new Map;return D.forEach((W,ee)=>V.set(W.slug,ee)),{visibleItems:D,visibleIndexByKey:V}},[O,H,G]),{hotkeyRowProps:X}=yc(q,{scope:"list:projects",onOpen:D=>n(`${t}/projects/${D.slug}`)});if(yt({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var D;return(D=d.current)==null?void 0:D.focus()}}),yt({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),i)return l.jsx(jt,{label:"Loading projects…"});if(a||!o)return l.jsx(vt,{error:a||"Project list is unavailable."});const _=Array.from(new Set(o.flatMap(D=>D.tags))).sort();return l.jsxs("div",{className:"space-y-5",children:[l.jsxs(wp,{children:[l.jsx(vc,{ref:d,value:p,onChange:h,placeholder:"Search by project title or tag"}),l.jsxs("select",{value:m,onChange:D=>x(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All statuses"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"blocked",children:"Blocked"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]}),l.jsxs("select",{value:v,onChange:D=>b(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"active",children:"Hide archived"}),l.jsx("option",{value:"all",children:"All projects"}),l.jsx("option",{value:"archived",children:"Archived only"})]}),l.jsxs("select",{value:N,onChange:D=>k(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All tags"}),_.map(D=>l.jsx("option",{value:D,children:D},D))]}),l.jsxs("select",{value:j,onChange:D=>S(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"updated",children:"Sort: Updated"}),l.jsx("option",{value:"created",children:"Sort: Created"}),l.jsx("option",{value:"title",children:"Sort: Title"}),l.jsx("option",{value:"attention",children:"Sort: Attention"})]}),l.jsx(kp,{value:O,onChange:D=>P(D),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),H.length===0?l.jsx(Ge,{title:o.length===0?"No projects yet":"No projects match these filters",description:o.length===0?"A project is the high-level objective that groups assignments, resources, and memories. Create one to start the dashboard flow.":"Adjust the current search and filters or create a new project.",actions:l.jsx(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:`${t}/create/project`,children:"Create Project"})}):O==="cards"?l.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:H.map((D,V)=>l.jsxs(Ce,{to:`${t}/projects/${D.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...X(V),children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:D.title}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Vr(D.updated)]})]}),l.jsx(Ht,{status:D.status})]}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsx(Xa,{progress:D.progress,showLegend:!0}),l.jsx("div",{className:"flex flex-wrap gap-2",children:D.tags.map(W=>l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:W},W))}),l.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),l.jsx("p",{className:"mt-1 font-semibold text-foreground",children:D.needsAttention.blockedCount+D.needsAttention.failedCount})]}),l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),l.jsx("p",{className:"mt-1 font-semibold text-foreground",children:D.progress.total})]})]})]})]},D.slug))}):O==="table"?l.jsx(Pe,{title:`${H.length} project${H.length===1?"":"s"}`,children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[l.jsx("th",{className:"pb-3 font-medium",children:"Project"}),l.jsx("th",{className:"pb-3 font-medium",children:"Status"}),l.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),l.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),l.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),l.jsx("tbody",{children:H.map((D,V)=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",...X(V),children:[l.jsxs("td",{className:"py-4 pr-4",children:[l.jsx(Ce,{to:`${t}/projects/${D.slug}`,className:"font-semibold text-foreground hover:text-primary",children:D.title}),l.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:D.tags.map(W=>l.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:W},W))})]}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx(Ht,{status:D.status})}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx("div",{className:"min-w-[220px]",children:l.jsx(Xa,{progress:D.progress})})}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:D.needsAttention.blockedCount+D.needsAttention.failedCount}),l.jsx("td",{className:"py-4 text-muted-foreground",children:Vr(D.updated)})]},D.slug))})]})})}):l.jsx(I0,{columns:JE,items:G,getItemId:D=>D.slug,getColumnId:D=>D.status,canDrop:({fromColumnId:D,toColumnId:V})=>({allowed:!0,reason:D===V?void 0:"This will set a manual status override on the project."}),onMove:({item:D,fromColumnId:V,toColumnId:W,fromIndex:ee,toIndex:R})=>{if(V===W){const F=$[V]??H.filter(J=>J.status===V).map(J=>J.slug);E(J=>({...J,[V]:XE(F,ee,R)}));return}fetch(`/api/projects/${D.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:W})}).then(()=>{window.location.reload()})},emptyMessage:D=>`No ${D.title.toLowerCase()} projects.`,renderCard:(D,{dragging:V})=>{const W=Y.get(D.slug)??-1;return l.jsx("div",{...W>=0?X(W):{},children:l.jsx(tR,{project:D,dragging:V})})}}),l.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(kv,{className:"mt-0.5 h-4 w-4"}),l.jsxs("p",{children:["Project status is derived from assignment state by default.",O==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const QE={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed",archived:"Archived"},JE=jp.map(e=>({id:e,title:QE[e],description:D0(e)}));function ZE(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return Cx(t)-Cx(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function Cx(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function eR(e){return Object.fromEntries(jp.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function tR({project:e,dragging:t}){const n=Lt();return l.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(Ce,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Vr(e.updated)]})]}),l.jsx(Ht,{status:e.status})]}),l.jsx("div",{className:"mt-4",children:l.jsx(Xa,{progress:e.progress})}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(o=>l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:o},o)),l.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),l.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"]})]}),l.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function Hr({value:e}){const[t,n]=g.useState(!1);function o(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}return l.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-foreground",title:t?"Copied!":`Copy: ${e}`,children:t?l.jsx(Zf,{className:"h-3 w-3 text-green-500"}):l.jsx(tp,{className:"h-3 w-3"})})}function Nx(e){const t=nR(e),n=g.forwardRef((o,i)=>{const{children:a,...c}=o,d=g.Children.toArray(a),p=d.find(oR);if(p){const h=p.props.children,m=d.map(x=>x===p?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:x);return l.jsx(t,{...c,ref:i,children:g.isValidElement(h)?g.cloneElement(h,void 0,m):null})}return l.jsx(t,{...c,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}function nR(e){const t=g.forwardRef((n,o)=>{const{children:i,...a}=n;if(g.isValidElement(i)){const c=iR(i),d=sR(a,i.props);return i.type!==g.Fragment&&(d.ref=o?fc(o,c):c),g.cloneElement(i,d)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rR=Symbol("radix.slottable");function oR(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rR}function sR(e,t){const n={...t};for(const o in t){const i=e[o],a=t[o];/^on[A-Z]/.test(o)?i&&a?n[o]=(...d)=>{const p=a(...d);return i(...d),p}:i&&(n[o]=i):o==="style"?n[o]={...i,...a}:o==="className"&&(n[o]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function iR(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function lR(e){const t=e+"CollectionProvider",[n,o]=Vo(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=k=>{const{scope:j,children:S}=k,T=xt.useRef(null),A=xt.useRef(new Map).current;return l.jsx(i,{scope:j,itemMap:A,collectionRef:T,children:S})};c.displayName=t;const d=e+"CollectionSlot",p=Nx(d),h=xt.forwardRef((k,j)=>{const{scope:S,children:T}=k,A=a(d,S),L=ln(j,A.collectionRef);return l.jsx(p,{ref:L,children:T})});h.displayName=d;const m=e+"CollectionItemSlot",x="data-radix-collection-item",v=Nx(m),b=xt.forwardRef((k,j)=>{const{scope:S,children:T,...A}=k,L=xt.useRef(null),O=ln(j,L),P=a(m,S);return xt.useEffect(()=>(P.itemMap.set(L,{ref:L,...A}),()=>void P.itemMap.delete(L))),l.jsx(v,{[x]:"",ref:O,children:T})});b.displayName=m;function N(k){const j=a(e+"CollectionConsumer",k);return xt.useCallback(()=>{const T=j.collectionRef.current;if(!T)return[];const A=Array.from(T.querySelectorAll(`[${x}]`));return Array.from(j.itemMap.values()).sort((P,$)=>A.indexOf(P.ref.current)-A.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:c,Slot:h,ItemSlot:b},N,o]}var aR=g.createContext(void 0);function O0(e){const t=g.useContext(aR);return e||t||"ltr"}var Fd="rovingFocusGroup.onEntryFocus",cR={bubbles:!1,cancelable:!0},ll="RovingFocusGroup",[Sf,_0,uR]=lR(ll),[dR,M0]=Vo(ll,[uR]),[fR,pR]=dR(ll),$0=g.forwardRef((e,t)=>l.jsx(Sf.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Sf.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(hR,{...e,ref:t})})}));$0.displayName=ll;var hR=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:i=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:p,onEntryFocus:h,preventScrollOnEntryFocus:m=!1,...x}=e,v=g.useRef(null),b=ln(t,v),N=O0(a),[k,j]=pc({prop:c,defaultProp:d??null,onChange:p,caller:ll}),[S,T]=g.useState(!1),A=Uo(h),L=_0(n),O=g.useRef(!1),[P,$]=g.useState(0);return g.useEffect(()=>{const E=v.current;if(E)return E.addEventListener(Fd,A),()=>E.removeEventListener(Fd,A)},[A]),l.jsx(fR,{scope:n,orientation:o,dir:N,loop:i,currentTabStopId:k,onItemFocus:g.useCallback(E=>j(E),[j]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>$(E=>E+1),[]),onFocusableItemRemove:g.useCallback(()=>$(E=>E-1),[]),children:l.jsx(Rt.div,{tabIndex:S||P===0?-1:0,"data-orientation":o,...x,ref:b,style:{outline:"none",...e.style},onMouseDown:ct(e.onMouseDown,()=>{O.current=!0}),onFocus:ct(e.onFocus,E=>{const H=!O.current;if(E.target===E.currentTarget&&H&&!S){const Z=new CustomEvent(Fd,cR);if(E.currentTarget.dispatchEvent(Z),!Z.defaultPrevented){const G=L().filter(D=>D.focusable),q=G.find(D=>D.active),Y=G.find(D=>D.id===k),_=[q,Y,...G].filter(Boolean).map(D=>D.ref.current);B0(_,m)}}O.current=!1}),onBlur:ct(e.onBlur,()=>T(!1))})})}),F0="RovingFocusGroupItem",z0=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:i=!1,tabStopId:a,children:c,...d}=e,p=Cs(),h=a||p,m=pR(F0,n),x=m.currentTabStopId===h,v=_0(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:k}=m;return g.useEffect(()=>{if(o)return b(),()=>N()},[o,b,N]),l.jsx(Sf.ItemSlot,{scope:n,id:h,focusable:o,active:i,children:l.jsx(Rt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...d,ref:t,onMouseDown:ct(e.onMouseDown,j=>{o?m.onItemFocus(h):j.preventDefault()}),onFocus:ct(e.onFocus,()=>m.onItemFocus(h)),onKeyDown:ct(e.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){m.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=xR(j,m.orientation,m.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let A=v().filter(L=>L.focusable).map(L=>L.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const L=A.indexOf(j.currentTarget);A=m.loop?yR(A,L+1):A.slice(L+1)}setTimeout(()=>B0(A))}}),children:typeof c=="function"?c({isCurrentTabStop:x,hasTabStop:k!=null}):c})})});z0.displayName=F0;var mR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gR(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function xR(e,t,n){const o=gR(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return mR[o]}function B0(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function yR(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var vR=$0,bR=z0,wc="Tabs",[wR]=Vo(wc,[M0]),U0=M0(),[kR,Sp]=wR(wc),H0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:i,defaultValue:a,orientation:c="horizontal",dir:d,activationMode:p="automatic",...h}=e,m=O0(d),[x,v]=pc({prop:o,onChange:i,defaultProp:a??"",caller:wc});return l.jsx(kR,{scope:n,baseId:Cs(),value:x,onValueChange:v,orientation:c,dir:m,activationMode:p,children:l.jsx(Rt.div,{dir:m,"data-orientation":c,...h,ref:t})})});H0.displayName=wc;var W0="TabsList",V0=g.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...i}=e,a=Sp(W0,n),c=U0(n);return l.jsx(vR,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:o,children:l.jsx(Rt.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:t})})});V0.displayName=W0;var q0="TabsTrigger",K0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:i=!1,...a}=e,c=Sp(q0,n),d=U0(n),p=X0(c.baseId,o),h=Q0(c.baseId,o),m=o===c.value;return l.jsx(bR,{asChild:!0,...d,focusable:!i,active:m,children:l.jsx(Rt.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":h,"data-state":m?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:p,...a,ref:t,onMouseDown:ct(e.onMouseDown,x=>{!i&&x.button===0&&x.ctrlKey===!1?c.onValueChange(o):x.preventDefault()}),onKeyDown:ct(e.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&c.onValueChange(o)}),onFocus:ct(e.onFocus,()=>{const x=c.activationMode!=="manual";!m&&!i&&x&&c.onValueChange(o)})})})});K0.displayName=q0;var G0="TabsContent",Y0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:i,children:a,...c}=e,d=Sp(G0,n),p=X0(d.baseId,o),h=Q0(d.baseId,o),m=o===d.value,x=g.useRef(m);return g.useEffect(()=>{const v=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(v)},[]),l.jsx(qo,{present:i||m,children:({present:v})=>l.jsx(Rt.div,{"data-state":m?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":p,hidden:!v,id:h,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:x.current?"0s":void 0},children:v&&a})})});Y0.displayName=G0;function X0(e,t){return`${e}-trigger-${t}`}function Q0(e,t){return`${e}-content-${t}`}var jR=H0,SR=V0,CR=K0,NR=Y0;function Cp({value:e,onValueChange:t,items:n,className:o}){return l.jsxs(jR,{value:e,onValueChange:t,className:o,children:[l.jsx(SR,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(i=>l.jsxs(CR,{value:i.value,className:$e("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:[l.jsx("span",{children:i.label}),typeof i.count=="number"?l.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:i.count}):null]},i.value))}),n.map(i=>l.jsx(NR,{value:i.value,className:"pt-3",children:i.content},i.value))]})}const ER="modulepreload",RR=function(e){return"/"+e},Ex={},PR=function(t,n,o){let i=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));i=c(n.map(h=>{if(h=RR(h),h in Ex)return;Ex[h]=!0;const m=h.endsWith(".css"),x=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":ER,m||(v.as="script"),v.crossOrigin="",v.href=h,p&&v.setAttribute("nonce",p),document.head.appendChild(v),m)return new Promise((b,N)=>{v.addEventListener("load",b),v.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return i.then(c=>{for(const d of c||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})};function TR({definition:e,className:t,nodeRoutes:n={}}){const o=g.useRef(null),[i,a]=g.useState(null),[c,d]=g.useState(!0),p=Xt(),h=document.documentElement.classList.contains("dark")?"dark":"default";return g.useEffect(()=>{let m=!1;async function x(){if(o.current)try{const v=(await PR(async()=>{const{default:k}=await import("./mermaid.core-DKO1ytRW.js").then(j=>j.bF);return{default:k}},[])).default;if(v.initialize({startOnLoad:!1,theme:h}),m)return;const b=`mermaid-${Date.now()}`,{svg:N}=await v.render(b,e);if(m||!o.current)return;o.current.innerHTML=N,AR(o.current,n,p),d(!1)}catch(v){m||(a(v instanceof Error?v.message:"Failed to render graph"),d(!1))}}return d(!0),a(null),x(),()=>{m=!0}},[e,p,n,h]),i?l.jsxs("div",{className:$e("rounded-lg border border-border bg-card p-4",t),children:[l.jsxs("p",{className:"text-sm text-red-400",children:["Failed to render dependency graph: ",i]}),l.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):l.jsxs("div",{className:$e("rounded-lg border border-border bg-card p-4",t),children:[c&&l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),l.jsx("div",{ref:o,className:"overflow-auto"})]})}function AR(e,t,n){var o;for(const i of e.querySelectorAll(".node")){const a=((o=i.textContent)==null?void 0:o.replace(/\s+/g," ").trim())??"",c=t[a];if(!c)continue;i.style.cursor="pointer",i.setAttribute("role","link"),i.setAttribute("tabindex","0"),i.setAttribute("aria-label",`Open ${a}`);const d=()=>n(c);i.addEventListener("click",d),i.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),d())})}}function DR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const IR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,OR={};function Rx(e,t){return(OR.jsx?LR:IR).test(e)}const _R=/[ \t\n\f\r]/g;function MR(e){return typeof e=="object"?e.type==="text"?Px(e.value):!1:Px(e)}function Px(e){return e.replace(_R,"")===""}class al{constructor(t,n,o){this.normal=n,this.property=t,o&&(this.space=o)}}al.prototype.normal={};al.prototype.property={};al.prototype.space=void 0;function J0(e,t){const n={},o={};for(const i of e)Object.assign(n,i.property),Object.assign(o,i.normal);return new al(n,o,t)}function Cf(e){return e.toLowerCase()}class En{constructor(t,n){this.attribute=n,this.property=t}}En.prototype.attribute="";En.prototype.booleanish=!1;En.prototype.boolean=!1;En.prototype.commaOrSpaceSeparated=!1;En.prototype.commaSeparated=!1;En.prototype.defined=!1;En.prototype.mustUseProperty=!1;En.prototype.number=!1;En.prototype.overloadedBoolean=!1;En.prototype.property="";En.prototype.spaceSeparated=!1;En.prototype.space=void 0;let $R=0;const Me=Ko(),Nt=Ko(),Nf=Ko(),ce=Ko(),Ze=Ko(),Es=Ko(),_n=Ko();function Ko(){return 2**++$R}const Ef=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Nt,commaOrSpaceSeparated:_n,commaSeparated:Es,number:ce,overloadedBoolean:Nf,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),zd=Object.keys(Ef);class Np extends En{constructor(t,n,o,i){let a=-1;if(super(t,n),Tx(this,"space",i),typeof o=="number")for(;++a<zd.length;){const c=zd[a];Tx(this,zd[a],(o&Ef[c])===Ef[c])}}}Np.prototype.defined=!0;function Tx(e,t,n){n&&(e[t]=n)}function Bs(e){const t={},n={};for(const[o,i]of Object.entries(e.properties)){const a=new Np(o,e.transform(e.attributes||{},o),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(o)&&(a.mustUseProperty=!0),t[o]=a,n[Cf(o)]=o,n[Cf(a.attribute)]=o}return new al(t,n,e.space)}const Z0=Bs({properties:{ariaActiveDescendant:null,ariaAtomic:Nt,ariaAutoComplete:null,ariaBusy:Nt,ariaChecked:Nt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:Nt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:Nt,ariaFlowTo:Ze,ariaGrabbed:Nt,ariaHasPopup:null,ariaHidden:Nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:ce,ariaLive:null,ariaModal:Nt,ariaMultiLine:Nt,ariaMultiSelectable:Nt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:Nt,ariaReadOnly:Nt,ariaRelevant:null,ariaRequired:Nt,ariaRoleDescription:Ze,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:Nt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function eb(e,t){return t in e?e[t]:t}function tb(e,t){return eb(e,t.toLowerCase())}const FR=Bs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Es,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:Ze,autoFocus:Me,autoPlay:Me,blocking:Ze,capture:null,charSet:null,checked:Me,cite:null,className:Ze,cols:ce,colSpan:null,content:null,contentEditable:Nt,controls:Me,controlsList:Ze,coords:ce|Es,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:Nf,draggable:Nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:Ze,height:ce,hidden:Nf,high:ce,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Me,inputMode:null,integrity:null,is:null,isMap:Me,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Me,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Me,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,multiple:Me,muted:Me,name:null,nonce:null,noModule:Me,noValidate:Me,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:Me,optimum:ce,pattern:null,ping:Ze,placeholder:null,playsInline:Me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Me,referrerPolicy:null,rel:Ze,required:Me,reversed:Me,rows:ce,rowSpan:ce,sandbox:Ze,scope:null,scoped:Me,seamless:Me,selected:Me,shadowRootClonable:Me,shadowRootDelegatesFocus:Me,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:Nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:Me,useMap:null,value:Nt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Me,declare:Me,event:null,face:null,frame:null,frameBorder:null,hSpace:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:Me,noHref:Me,noShade:Me,noWrap:Me,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:Nt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Me,disableRemotePlayback:Me,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:tb}),zR=Bs({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:_n,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:Ze,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:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:Me,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,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:Es,g2:Es,glyphName:Es,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,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:ce,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:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,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:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:eb}),nb=Bs({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()}}),rb=Bs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:tb}),ob=Bs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),BR={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"},UR=/[A-Z]/g,Ax=/-[a-z]/g,HR=/^data[-\w.:]+$/i;function WR(e,t){const n=Cf(t);let o=t,i=En;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&HR.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(Ax,qR);o="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!Ax.test(a)){let c=a.replace(UR,VR);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=Np}return new i(o,t)}function VR(e){return"-"+e.toLowerCase()}function qR(e){return e.charAt(1).toUpperCase()}const KR=J0([Z0,FR,nb,rb,ob],"html"),Ep=J0([Z0,zR,nb,rb,ob],"svg");function GR(e){return e.join(" ").trim()}var vs={},Bd,Dx;function YR(){if(Dx)return Bd;Dx=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,p=`
|
|
440
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hE="DialogDescriptionWarning",mE=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${N0(hE).contentName}}.`;return g.useEffect(()=>{var a;const i=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},E0=f0,gE=h0,R0=g0,mp=x0,gp=y0,xp=b0,yp=k0,P0=S0;const vp=E0,xE=R0,T0=g.forwardRef(({className:e,...t},n)=>l.jsx(mp,{ref:n,className:$e("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));T0.displayName=mp.displayName;const gc=g.forwardRef(({className:e,children:t,...n},o)=>l.jsxs(xE,{children:[l.jsx(T0,{}),l.jsx(gp,{ref:o,className:$e("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 rounded-xl border border-border/70 bg-card p-6 shadow-2xl outline-none",e),...n,children:t})]}));gc.displayName=gp.displayName;function yE({className:e,...t}){return l.jsx("div",{className:$e("flex flex-col space-y-2 text-left",e),...t})}function vE({className:e,...t}){return l.jsx("div",{className:$e("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const xc=g.forwardRef(({className:e,...t},n)=>l.jsx(xp,{ref:n,className:$e("text-lg font-semibold tracking-tight text-foreground",e),...t}));xc.displayName=xp.displayName;const bp=g.forwardRef(({className:e,...t},n)=>l.jsx(yp,{ref:n,className:$e("text-sm leading-6 text-muted-foreground",e),...t}));bp.displayName=yp.displayName;const bE=-1,wE=-40;function $d(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,o=0,i=-2,a=0;for(let c=0;c<e.length;c++){const d=e[c];let p=!1;for(;o<t.length;)if(t[o]===d){if(n+=100,o===i+1&&(n+=20),o===0)n+=30;else{const h=t[o-1];(h===" "||h==="-"||h==="_"||h==="/")&&(n+=15)}a>0&&(n+=Math.max(wE,a*bE)),i=o,a=0,o++,p=!0;break}else a++,o++;if(!p)return-1/0}return n}const yx={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function kE(e,t,n=50){const o=e.toLowerCase();if(!o)return t.slice(0,n).map(c=>({...c,score:0}));const a=t.map(c=>{var x;const d=$d(o,c.title.toLowerCase())*1,p=c.subtitle?$d(o,c.subtitle.toLowerCase())*.5:-1/0,h=(x=c.keywords)!=null&&x.length?$d(o,c.keywords.join(" ").toLowerCase())*.3:-1/0,m=Math.max(d,p,h);return{...c,score:m}}).filter(c=>c.score>-1/0);return a.sort((c,d)=>d.score!==c.score?d.score-c.score:c.title.length!==d.title.length?c.title.length-d.title.length:c.title!==d.title?c.title<d.title?-1:1:(yx[c.type]??99)-(yx[d.type]??99)),a.slice(0,n)}const jE={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo"};function SE({entries:e}){const{paletteOpen:t,closePalette:n}=Fs(),o=Xt(),[i,a]=g.useState(""),[c,d]=g.useState(0),p=g.useRef(null),h=g.useMemo(()=>kE(i,e,50),[i,e]);g.useEffect(()=>{d(0)},[i,t]),g.useEffect(()=>{t||a("")},[t]),g.useEffect(()=>{var b;const v=(b=p.current)==null?void 0:b.querySelector(`[data-palette-idx="${c}"]`);v==null||v.scrollIntoView({block:"nearest"})},[c]);function m(v){o(v.route),n()}function x(v){if(v.key==="ArrowDown")v.preventDefault(),d(b=>Math.min(h.length-1,b+1));else if(v.key==="ArrowUp")v.preventDefault(),d(b=>Math.max(0,b-1));else if(v.key==="Enter"){v.preventDefault();const b=h[c];b&&m(b)}}return l.jsx(vp,{open:t,onOpenChange:v=>v?null:n(),children:l.jsxs(gc,{className:"max-w-xl p-0 gap-0",children:[l.jsx(xc,{className:"sr-only",children:"Command palette"}),l.jsx("input",{autoFocus:!0,type:"text",value:i,onChange:v=>a(v.target.value),onKeyDown:x,placeholder:"Search projects, assignments, playbooks, servers, todos…",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:ring-0"}),l.jsx("div",{ref:p,className:"max-h-[60vh] overflow-y-auto p-1",children:h.length===0?l.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:i?"No matches":"Start typing to search"}):h.map((v,b)=>{const N=b===c;return l.jsxs("button",{type:"button","data-palette-idx":b,onClick:()=>m(v),onMouseEnter:()=>d(b),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${N?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[l.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:jE[v.type]??v.type}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.title}),v.subtitle?l.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:v.subtitle}):null]},v.id)})}),l.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[l.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," open ","·"," Esc close"]}),l.jsxs("span",{children:[h.length," result",h.length===1?"":"s"]})]})]})})}const CE={global:"Global","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},NE=["global","list:projects","list:assignments","list:todos","project","assignment"];function EE(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Ss(t)} then ${Ss(n)}`}return Ss(e)}function RE(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n}=Fs(),o=g.useMemo(()=>{if(!e)return new Map;const i=n(),a=new Map;for(const c of i){const d=a.get(c.scope)??[];d.push({keys:c.keys,description:c.description}),a.set(c.scope,d)}return a},[e,n]);return l.jsx(vp,{open:e,onOpenChange:i=>i?null:t(),children:l.jsxs(gc,{className:"max-w-2xl",children:[l.jsx(xc,{children:"Keyboard shortcuts"}),l.jsxs(bp,{children:["Press Esc to close. ",Ss("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),l.jsx("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:NE.map(i=>{const a=o.get(i);return!a||a.length===0?null:l.jsxs("section",{children:[l.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:CE[i]}),l.jsx("ul",{className:"space-y-1",children:a.map((c,d)=>l.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:[l.jsx("span",{className:"text-foreground",children:c.description}),l.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:EE(c.keys)})]},`${i}-${c.keys}-${d}`))})]},i)})})]})})}const vx=1500;function PE(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const A0=g.createContext(null);function TE({children:e}){const{toggleTheme:t}=Fv(),n=fn(),o=Xt(),i=PE(n.pathname),a=dc(),c=Bv(),d=Vv(),p=ap(),h=cp(),m=g.useMemo(()=>{var R,F,J,I;const X=a.data??[],_=((R=c.data)==null?void 0:R.assignments)??[],D=((F=d.data)==null?void 0:F.playbooks)??[],V=((J=p.data)==null?void 0:J.sessions)??[],ee=(((I=h.data)==null?void 0:I.workspaces)??[]).flatMap(de=>de.items.map(ve=>({...ve,workspace:de.workspace})));return DN({projects:X,assignments:_,playbooks:D,servers:V,todos:ee,wsPrefix:i})},[a.data,c.data,d.data,p.data,h.data,i]),x=g.useRef(new Map),v=g.useRef(["global"]),b=g.useRef({phase:"idle"}),N=g.useRef(null),k=g.useRef(1),[j,S]=g.useState(!1),[T,A]=g.useState(!1),L=g.useCallback(X=>{const _=k.current++;return x.current.set(_,{...X,id:_}),_},[]),O=g.useCallback(X=>{x.current.delete(X)},[]),P=g.useCallback(X=>{v.current.push(X)},[]),$=g.useCallback(X=>{const _=v.current;for(let D=_.length-1;D>=0;D--)if(_[D]===X){_.splice(D,1);return}},[]),E=g.useCallback(()=>S(!0),[]),H=g.useCallback(()=>S(!1),[]),Z=g.useCallback(()=>A(!0),[]),G=g.useCallback(()=>A(!1),[]),q=g.useCallback(()=>Array.from(x.current.values()),[]);g.useEffect(()=>{b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[n.pathname]),g.useEffect(()=>{function X(ee){if(!(ee instanceof HTMLElement))return!1;const R=ee.tagName;return!!(R==="INPUT"||R==="TEXTAREA"||R==="SELECT"||ee.isContentEditable||ee.closest('[role="combobox"], [role="textbox"]'))}function _(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function D(){const ee=v.current;return ee[ee.length-1]??"global"}function V(ee){return ee.scope==="global"?!0:ee.scope===D()}function W(ee){const R=Td(ee,"Mod+k"),F=ee.key==="Escape";if(_()&&!R&&!F||X(ee.target)&&!R&&!F)return;const J=b.current;if(J.phase==="awaiting-second")if(Date.now()-J.startedAt>vx)b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null);else{const ve=Array.from(x.current.values());for(const fe of ve){if(!V(fe))continue;const Ee=fe.keys.split(" ");if(!(Ee.length!==2||Ee[0]!=="g")&&Td(ee,Ee[1])&&!(fe.when&&!fe.when())){ee.preventDefault(),b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null),fe.handler(ee);return}}b.current={phase:"idle"},N.current!==null&&(window.clearTimeout(N.current),N.current=null)}const I=Array.from(x.current.values());for(const de of I){if(!V(de))continue;const ve=de.keys.split(" ");if(ve.length===1&&Td(ee,ve[0])&&!(de.when&&!de.when())){ee.preventDefault(),de.handler(ee);return}}ee.key==="g"&&!ee.metaKey&&!ee.ctrlKey&&!ee.altKey&&!ee.shiftKey&&Array.from(x.current.values()).some(ve=>V(ve)&&ve.keys.startsWith("g "))&&(ee.preventDefault(),b.current={phase:"awaiting-second",startedAt:Date.now()},N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{b.current={phase:"idle"},N.current=null},vx))}return window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W),N.current!==null&&(window.clearTimeout(N.current),N.current=null)}},[]),g.useEffect(()=>{const X=L({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>O(X)},[L,O,t]),g.useEffect(()=>{const X=L({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>Z()});return()=>O(X)},[L,O,Z]),g.useEffect(()=>{const X=L({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(j){H();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||E()}});return()=>O(X)},[L,O,E,H,j]),g.useEffect(()=>{const _=[{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:"/attention",desc:"Go to Attention"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map(D=>L({keys:`g ${D.suffix}`,scope:"global",description:D.desc,handler:()=>o(Fa(D.basePath,i))}));return()=>_.forEach(O)},[L,O,o,i]);const Y=g.useMemo(()=>({register:L,unregister:O,pushScope:P,popScope:$,openPalette:E,closePalette:H,paletteOpen:j,openCheatsheet:Z,closeCheatsheet:G,cheatsheetOpen:T,listBindings:q,wsPrefix:i,paletteEntries:m}),[L,O,P,$,E,H,j,Z,G,T,q,i,m]);return l.jsxs(A0.Provider,{value:Y,children:[e,l.jsx(SE,{entries:m}),l.jsx(RE,{})]})}function Fs(){const e=g.useContext(A0);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function yt({keys:e,handler:t,scope:n="global",description:o,when:i,enabled:a=!0}){const{register:c,unregister:d}=Fs(),p=g.useRef(t),h=g.useRef(i);g.useEffect(()=>{p.current=t,h.current=i},[t,i]),g.useEffect(()=>{if(!a)return;const m=c({keys:e,handler:x=>p.current(x),scope:n,description:o,when:h.current?()=>h.current():void 0});return()=>d(m)},[c,d,e,n,o,a])}function zs(e){const{pushScope:t,popScope:n}=Fs();g.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function yc(e,t){const[n,o]=g.useState(e.length===0?-1:0),i=fn();g.useEffect(()=>{o(e.length===0?-1:0)},[i.pathname]),g.useEffect(()=>{o(c=>e.length===0?-1:Math.min(Math.max(0,c),e.length-1))},[e.length]),g.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(d=>{const p=Number(d.getAttribute("data-hotkey-row-index"));d.setAttribute("data-hotkey-selected",p===n?"true":"false")}),n>=0){const d=document.querySelector(`[data-hotkey-row-index="${n}"]`);d==null||d.scrollIntoView({block:"nearest"})}},[n,e.length]),yt({keys:"j",scope:t.scope,description:"Select next row",handler:()=>o(c=>e.length===0?-1:Math.min(e.length-1,c<0?0:c+1))}),yt({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>o(c=>e.length===0?-1:Math.max(0,c<0?0:c-1))}),yt({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),yt({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 a=g.useCallback(c=>({"data-hotkey-row-index":c,"data-hotkey-selected":c===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:a}}function AE({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:o}){const i=Lt(),{resolvedTheme:a,toggleTheme:c}=Fv(),{openPalette:d}=Fs();return l.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/85 backdrop-blur",children:l.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[l.jsx("button",{type:"button",onClick:o,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:l.jsx(yC,{className:"h-4 w-4"})}),l.jsx("div",{className:"min-w-0 flex-1",children:l.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?l.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((p,h)=>l.jsxs("span",{className:"flex items-center gap-1.5",children:[h>0?l.jsx("span",{children:"/"}):null,l.jsx(Ce,{to:p.path,className:"hover:text-foreground",children:p.label})]},p.path)),l.jsx("span",{children:"/"})]}):null,l.jsx("h1",{className:"truncate text-base font-semibold text-foreground",children:e})]})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:d,className:"shell-action","aria-label":"Open command palette",children:[l.jsx(sl,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Ss("Mod+k")})]}),l.jsx(Ce,{className:"shell-action",to:"/help",children:"Help"}),l.jsxs(Ce,{className:"shell-action",to:`${i}/create/project`,children:[l.jsx(lr,{className:"h-4 w-4"}),l.jsx("span",{children:"New Project"})]}),n?l.jsxs(Ce,{className:"shell-action",to:`${i}/projects/${n}/create/assignment`,children:[l.jsx(lr,{className:"h-4 w-4"}),l.jsx("span",{children:"New Assignment"})]}):null,l.jsxs("button",{type:"button",onClick:c,className:"shell-action","aria-label":"Toggle theme",children:[a==="dark"?l.jsx(PC,{className:"h-4 w-4"}):l.jsx(vC,{className:"h-4 w-4"}),l.jsx("span",{children:a==="dark"?"Light":"Dark"})]})]})]})})}const DE=[{to:"/",label:"Overview",icon:oC},{to:"/attention",label:"Attention",icon:il},{to:"/playbooks",label:"Playbooks",icon:yv},{to:"/todos",label:"Todos",icon:Sr}],IE=[{suffix:"/projects",label:"Projects",icon:np},{suffix:"/assignments",label:"Assignments",icon:xC},{suffix:"/servers",label:"Servers",icon:rp},{suffix:"/agent-sessions",label:"Agent Sessions",icon:uc},{suffix:"/todos",label:"Todos",icon:Sr}],LE=[{to:"/help",label:"Help",icon:mC},{to:"/settings",label:"Settings",icon:EC}],bx="syntaur.dashboard.sourceFirstNoticeDismissed";function OE({title:e,breadcrumbs:t,projectSlug:n,workspace:o,children:i}){const[a,c]=g.useState(!1);yt({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:a,handler:()=>c(!1)});const[d,p]=g.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(bx)==="1"}catch{return!1}});function h(){if(p(!0),!(typeof window>"u"))try{window.localStorage.setItem(bx,"1")}catch{}}return l.jsx("div",{className:"min-h-screen bg-background",children:l.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[l.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar/90 px-4 py-4 backdrop-blur lg:flex lg:flex-col",children:l.jsx(wx,{sourceNoticeDismissed:d,onDismissSourceNotice:h,activeWorkspace:o})}),a?l.jsx("div",{className:"fixed inset-0 z-40 bg-slate-950/40 lg:hidden",children:l.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[l.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[l.jsx(Ce,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>c(!1),children:"Syntaur"}),l.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80",children:l.jsx(Ev,{className:"h-4 w-4"})})]}),l.jsx(wx,{sourceNoticeDismissed:d,onDismissSourceNotice:h,activeWorkspace:o,onNavigate:()=>c(!1)})]})}):null,l.jsxs("div",{className:"min-w-0",children:[l.jsx(AE,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>c(!0)}),l.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:i})]})]})})}function wx({sourceNoticeDismissed:e,onDismissSourceNotice:t,activeWorkspace:n,onNavigate:o}){const{data:i}=lp(),a=(i==null?void 0:i.workspaces)??[],c=(i==null?void 0:i.hasUngrouped)??!1,d=fn(),[p,h]=g.useState(new Set),[m,x]=g.useState(!1),[v,b]=g.useState(""),N=Xt();function k(S){h(T=>{const A=new Set(T);return A.has(S)?A.delete(S):A.add(S),A})}const j=[...a,...c?["_ungrouped"]:[]];return l.jsxs("div",{className:"flex h-full flex-col gap-3",children:[l.jsx("div",{className:"space-y-3",children:l.jsxs(Ce,{to:"/",className:"inline-flex items-center gap-3",onClick:o,children:[l.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-foreground text-sm font-semibold text-background shadow-sm",children:"S"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),l.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),l.jsx(ox,{items:DE,onNavigate:o}),l.jsx("div",{className:"border-t border-border/40"}),l.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[j.length===0&&!m&&l.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),j.map(S=>{const T=S==="_ungrouped",A=T?"Ungrouped":Cn(S),L=T?"/w/_ungrouped":`/w/${S}`,O=p.has(S),P=n===S||n===null&&T&&d.pathname.startsWith("/w/_ungrouped");return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>k(S),className:`flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${P?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[l.jsx(Yi,{className:`h-3 w-3 transition-transform ${O?"-rotate-90":""}`}),A]}),!O&&l.jsx("nav",{className:"ml-2 space-y-0.5",children:IE.map($=>{const E=`${L}${$.suffix}`,H=Ov(d.pathname,$.suffix)&&d.pathname.startsWith(L),Z=$.icon;return l.jsxs(Ce,{to:E,onClick:o,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${H?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[l.jsx(Z,{className:"h-4 w-4"}),l.jsx("span",{children:$.label})]},E)})})]},S)}),m?l.jsx("form",{className:"px-3 py-1.5",onSubmit:S=>{S.preventDefault();const T=v.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");T&&(x(!1),b(""),fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T})}).then(()=>{o==null||o(),N(`/w/${T}/projects`)}))},children:l.jsx("input",{autoFocus:!0,type:"text",value:v,onChange:S=>b(S.target.value),onKeyDown:S=>{S.key==="Escape"&&(x(!1),b(""))},onBlur:()=>{v.trim()||(x(!1),b(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):l.jsxs("button",{type:"button",onClick:()=>x(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[l.jsx(lr,{className:"h-3 w-3"}),"New Workspace"]})]}),l.jsx("div",{className:"border-t border-border/40"}),l.jsx(ox,{items:LE,onNavigate:o}),e?null:l.jsx("div",{className:"rounded-lg border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Source-first dashboard"}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Project and assignment markdown files stay authoritative. Derived files are read-only projections."})]}),l.jsx("button",{type:"button",onClick:t,className:"inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/70 bg-background/80 text-muted-foreground transition hover:text-foreground","aria-label":"Dismiss source-first dashboard notice",children:l.jsx(Ev,{className:"h-4 w-4"})})]})})]})}function _E(){const e=fn(),{workspace:t}=Et(),{title:n,breadcrumbs:o,projectSlug:i}=mN(e.pathname);return l.jsx(OE,{title:n,breadcrumbs:o,projectSlug:i,workspace:t??null,children:l.jsx(uS,{})})}const Ya={pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:"border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300",icon:nC},in_progress:{label:"In Progress",description:"Actively being worked on.",className:"border-violet-300 bg-violet-100 text-violet-800 dark:border-violet-800 dark:bg-violet-950 dark:text-violet-300",icon:jv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:"border-rose-300 bg-rose-100 text-rose-700 dark:border-rose-800 dark:bg-rose-950 dark:text-rose-300",icon:xf},review:{label:"Review",description:"Ready for inspection or approval.",className:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-300",icon:SC},completed:{label:"Completed",description:"Finished successfully.",className:"border-teal-300 bg-teal-100 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",icon:ep},failed:{label:"Failed",description:"Could not be completed as planned.",className:"border-red-300 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-300",icon:xf},active:{label:"Active",description:"The project has active or review work in flight.",className:"border-violet-300 bg-violet-100 text-violet-800 dark:border-violet-800 dark:bg-violet-950 dark:text-violet-300",icon:yf},stopped:{label:"Stopped",description:"Session ended without completing.",className:"border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300",icon:ZS},archived:{label:"Archived",description:"Archived by a human override.",className:"border-zinc-300 bg-zinc-100 text-zinc-700 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-300",icon:yf}};function Ht({status:e,className:t,showIcon:n=!0,progress:o}){const i=Ya[e]??{label:e.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase()),description:`Status: ${e}`,className:"border-slate-300 bg-slate-100 text-slate-600 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400",icon:yf},a=i.icon,c=o&&o.total>0,d=c?Math.min(1,Math.max(0,o.checked/o.total)):0,p=c?`${i.description} (${o.checked}/${o.total} criteria)`:i.description,h=n?c?l.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 items-center justify-center",children:[l.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[l.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),l.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-d)})]}),l.jsx(a,{className:"h-2.5 w-2.5"})]}):l.jsx(a,{className:"h-3.5 w-3.5"}):null;return l.jsxs("span",{title:p,className:$e("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2 py-0.5 text-xs font-semibold tracking-wide",i.className,t),children:[h,l.jsx("span",{children:i.label})]})}function D0(e){var t;return((t=Ya[e])==null?void 0:t.description)??`Status: ${e}`}const ME={default:"border-border/70 bg-card/90",info:"border-primary/30 bg-primary/5 dark:border-primary/40 dark:bg-primary/10",warn:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/40",danger:"border-rose-200 bg-rose-50 dark:border-rose-900 dark:bg-rose-950/40",success:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/40"};function it({label:e,value:t,description:n,icon:o,tone:i="default",to:a}){const c=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-start justify-between gap-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),l.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),o?l.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:l.jsx(o,{className:"h-5 w-5"})}):null]}),n?l.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),d=$e("rounded-lg border p-3 shadow-sm",ME[i],a?"block transition hover:-translate-y-0.5 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return a?l.jsx(Ce,{to:a,className:d,children:c}):l.jsx("article",{className:d,children:c})}function Pe({title:e,description:t,children:n,className:o,actions:i}){return l.jsxs("section",{className:$e("surface-panel space-y-3",o),children:[e||i?l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[e?l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?l.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),i]}):null,n]})}function jt({label:e="Loading dashboard data…"}){return l.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:l.jsx("div",{className:"rounded-lg border border-border/70 bg-card/90 px-4 py-3 shadow-sm",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function vt({title:e="Something went wrong",error:t,action:n}){return l.jsx("div",{className:"rounded-lg border border-rose-200 bg-rose-50 px-4 py-5 dark:border-rose-900 dark:bg-rose-950/30",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"text-lg font-semibold text-rose-800 dark:text-rose-200",children:e}),l.jsx("p",{className:"text-sm leading-6 text-rose-700 dark:text-rose-300",children:t}),n?l.jsx("div",{className:"pt-2",children:n}):null]})})}function Ge({title:e,description:t,actions:n}){return l.jsx("div",{className:"rounded-lg border border-dashed border-border/80 bg-muted/30 px-4 py-6 text-center",children:l.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[l.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?l.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}function Ua({command:e,description:t,example:n}){return l.jsxs("div",{className:"rounded-lg border border-border/70 bg-slate-950 px-3 py-3 text-slate-100 shadow-sm",children:[l.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?l.jsx("p",{className:"mt-2 text-sm text-slate-300",children:t}):null,n?l.jsx("p",{className:"mt-2 font-mono text-xs text-slate-400",children:n}):null]})}function $E({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return l.jsx(Pe,{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:l.jsx(Ce,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:l.jsx("div",{className:"space-y-3",children:n.map((o,i)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.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}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?l.jsx(Ua,{command:o.command.command,example:o.command.example}):null]})]})},o.title))})})}function FE(){var c;const{data:e,loading:t,error:n}=vN(),{data:o}=Uv(),{data:i}=cp(),a=i!=null&&i.workspaces?i.workspaces.reduce((d,p)=>d+p.counts.open+p.counts.in_progress,0):0;return t?l.jsx(jt,{label:"Loading overview…"}):n||!e?l.jsx(vt,{error:n||"Overview data is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(160px,1fr))]",children:[l.jsx(it,{label:"Active Projects",value:e.stats.activeProjects,icon:np,to:"/projects"}),l.jsx(it,{label:"In Progress",value:e.stats.inProgressAssignments,icon:dC,tone:"info",to:"/assignments?status=in_progress"}),l.jsx(it,{label:"Blocked",value:e.stats.blockedAssignments,icon:il,tone:"warn",to:"/assignments?status=blocked"}),l.jsx(it,{label:"Review",value:e.stats.reviewAssignments,icon:tC,tone:"info",to:"/assignments?status=review"}),l.jsx(it,{label:"Failed",value:e.stats.failedAssignments,icon:bC,tone:"danger",to:"/assignments?status=failed"}),l.jsx(it,{label:"Stale",value:e.stats.staleAssignments,icon:uc,to:"/assignments?stale=1"}),l.jsx(it,{label:"Open Todos",value:a,icon:Sr,to:"/todos"}),l.jsx(it,{label:"Active Servers",value:e.serverStats?e.serverStats.aliveSessions:"…",description:e.serverStats?`${e.serverStats.totalPorts} ports · ${e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"}`:"connecting",icon:rp,tone:(c=e.serverStats)!=null&&c.deadSessions?"warn":"default",to:"/servers"})]}),l.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(360px,0.9fr)]",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsx(Pe,{title:"Needs Attention Now",description:"Blocked, failed, review, and stale work from the source files.",children:e.attention.length===0?l.jsx(Ge,{title:"Nothing urgent right now",description:"The attention queue is empty. Overview will surface blocked, failed, review, and stale assignments here."}):l.jsx("div",{className:"space-y-3",children:e.attention.map(d=>l.jsxs(Ce,{to:d.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40 hover:bg-background",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"text-sm font-semibold text-foreground",children:d.assignmentTitle}),l.jsx("p",{className:"text-sm text-muted-foreground",children:d.projectTitle})]}),l.jsx(Ht,{status:d.status})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:d.reason}),l.jsxs("p",{className:"mt-2 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:["Updated ",Cr(d.updated)]})]},d.id))})}),l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Pe,{title:"Recently Updated Projects",children:e.recentProjects.length===0?l.jsx(Ge,{title:"No projects yet",description:"Create your first project to populate the project directory, recent activity, and attention queue.",actions:l.jsx(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:"/create/project",children:"Create Project"})}):l.jsx("div",{className:"space-y-3",children:e.recentProjects.map(d=>l.jsx(Ce,{to:`/projects/${d.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-foreground",children:d.title}),l.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Cr(d.updated)})]}),l.jsx(Ht,{status:d.status})]})},d.slug))})}),l.jsx(Pe,{title:"Recent Activity",children:e.recentActivity.length===0?l.jsx(Ge,{title:"No activity yet",description:"Once projects and assignments exist, Overview will show activity based on parsed source timestamps instead of file mtimes."}):l.jsx("div",{className:"space-y-3",children:e.recentActivity.map(d=>l.jsxs(Ce,{to:d.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"font-semibold text-foreground",children:d.title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:d.summary})]}),l.jsx("span",{className:"text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:Cn(d.type)})]}),l.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:Cr(d.updated)})]},d.id))})})]})]}),e.firstRun&&l.jsx($E,{help:o})]})]})}function zE(){const{data:e,loading:t,error:n}=bN();return t?l.jsx(jt,{label:"Loading attention queue…"}):n||!e?l.jsx(vt,{error:n||"Attention queue is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[l.jsx(it,{label:"Critical",value:e.summary.critical,icon:uC,tone:"danger"}),l.jsx(it,{label:"High",value:e.summary.high,icon:il,tone:"warn"}),l.jsx(it,{label:"Medium",value:e.summary.medium,icon:RC,tone:"info"}),l.jsx(it,{label:"Low",value:e.summary.low,icon:hC})]}),l.jsx(Pe,{title:"Attention Queue",description:"Ordered by severity, then by the latest parsed source update.",children:e.items.length===0?l.jsx(Ge,{title:"Attention queue is clear",description:"No blocked, failed, review, or stale assignments are currently surfacing from the source files."}):l.jsx("div",{className:"space-y-3",children:e.items.map(o=>l.jsxs(Ce,{to:o.href,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:o.assignmentTitle}),l.jsx("p",{className:"text-sm text-muted-foreground",children:o.projectTitle})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:o.severity}),l.jsx(Ht,{status:o.status})]})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.reason}),l.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Updated ",Cr(o.updated)]})]},o.id))})})]})}function BE({term:e,description:t}){return l.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 UE(){const{data:e,loading:t,error:n}=Uv(),{openCheatsheet:o}=Fs();return t?l.jsx(jt,{label:"Loading help…"}):n||!e?l.jsx(vt,{error:n||"Help content is unavailable."}):l.jsxs("div",{className:"space-y-5",children:[l.jsx(Pe,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("button",{type:"button",onClick:o,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"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",l.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Ss("Mod+k")," opens the command palette."]})]})}),l.jsx(Pe,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:l.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(i=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:i},i))})}),l.jsx(Pe,{title:"Getting Started",children:l.jsx("div",{className:"space-y-3",children:e.workflow.map((i,a)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:i.detail}),i.command?l.jsx(Ua,{command:i.command.command,description:i.command.description,example:i.command.example}):null,i.href?l.jsx(Ce,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open the related surface"}):null]})]})},i.title))})}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsxs(Pe,{title:"Core Concepts",children:[l.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(i=>l.jsx(BE,{term:i.term,description:i.description},i.term))}),l.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.term}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description})]},i.term))})]}),l.jsx(Pe,{title:"Status Guide",children:l.jsx("div",{className:"space-y-3",children:e.statusGuide.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx(Ht,{status:i.status}),l.jsx("p",{className:"font-semibold text-foreground",children:i.meaning})]}),l.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.useWhen})]},i.status))})})]}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsx(Pe,{title:"Ownership And File Rules",children:l.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.label}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description}),l.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.files.map(a=>l.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:a},a))})]},i.label))})}),l.jsx(Pe,{title:"How To Navigate The Dashboard",children:l.jsx("div",{className:"space-y-3",children:e.navigation.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.label}),l.jsx(Ce,{className:"text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open"})]}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.description})]},i.label))})})]}),l.jsx(Pe,{title:"CLI Quick Reference",children:l.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(i=>l.jsx(Ua,{command:i.command,description:i.description,example:i.example},i.command))})}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[l.jsx(Pe,{title:"FAQ",children:l.jsx("div",{className:"space-y-3",children:e.faq.map(i=>l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.question}),l.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.answer})]},i.question))})}),l.jsx(Pe,{title:"First Project Checklist",children:l.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((i,a)=>l.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:a+1}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:i.title}),l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:i.detail}),i.command?l.jsx(Ua,{command:i.command.command,example:i.command.example}):null,i.href?l.jsx(Ce,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:i.href,children:"Open the related surface"}):null]})]})},i.title))})})]})]})}function wp({children:e}){return l.jsx("div",{className:"flex flex-col gap-2 rounded-lg border border-border/60 bg-card/80 p-2.5 shadow-sm md:flex-row md:flex-wrap md:items-center",children:e})}const vc=g.forwardRef(({value:e,onChange:t,placeholder:n="Search"},o)=>l.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[l.jsx(sl,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),l.jsx("input",{ref:o,value:e,onChange:i=>t(i.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"})]}));vc.displayName="SearchInput";function kp({value:e,options:t,onChange:n}){return l.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(o=>l.jsx("button",{type:"button",onClick:()=>n(o.value),className:$e("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===o.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:o.label},o.value))})}function I0({columns:e,items:t,getItemId:n,getColumnId:o,renderCard:i,canDrop:a,onMove:c,emptyMessage:d="No cards in this column."}){const[p,h]=g.useState(null),[m,x]=g.useState(null),v=g.useRef(null),b=g.useMemo(()=>new Map(t.map(O=>[n(O),O])),[n,t]),N=g.useMemo(()=>e.map(O=>({column:O,items:t.filter(P=>o(P)===O.id)})),[e,o,t]),k=p?b.get(p)??null:null;function j(O){if(!k)return{allowed:!1};const P=o(k);return(a==null?void 0:a({item:k,fromColumnId:P,toColumnId:O}))??{allowed:!0}}function S(){h(null),x(null)}function T(O,P){c&&(O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",P),h(P))}function A(O,P,$){!c||!k||!j(P).allowed||(O.preventDefault(),O.dataTransfer.dropEffect="move",x(H=>(H==null?void 0:H.columnId)===P&&H.index===$?H:{columnId:P,index:$}))}async function L(O,P,$){var q;if(O.preventDefault(),!c||!k){S();return}const E=o(k),Z=(((q=N.find(Y=>Y.column.id===E))==null?void 0:q.items)??[]).findIndex(Y=>n(Y)===n(k));if(!j(P).allowed||Z<0){S();return}if(E===P&&($===Z||$===Z+1)){S();return}try{await c({item:k,fromColumnId:E,toColumnId:P,fromIndex:Z,toIndex:$})}finally{S()}}return l.jsx("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:l.jsx("div",{className:"grid min-w-max auto-cols-[minmax(260px,320px)] grid-flow-col gap-4",children:N.map(({column:O,items:P})=>{const $=j(O.id),E=(m==null?void 0:m.columnId)===O.id;return l.jsxs("section",{className:$e("flex min-h-[320px] flex-col rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k&&!$.allowed?"border-dashed opacity-65":"",k&&$.allowed?"border-primary/30 bg-accent/30":"",E?"ring-2 ring-ring/30":""),title:k&&!$.allowed?$.reason:void 0,children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:O.title}),O.description?l.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:O.description}):null]}),l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:P.length})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:H=>A(H,O.id,P.length),onDrop:H=>L(H,O.id,P.length),children:[P.length===0?l.jsx(HE,{active:(m==null?void 0:m.columnId)===O.id&&m.index===0,disabled:!!k&&!$.allowed,children:typeof d=="function"?d(O):d}):null,P.map((H,Z)=>{const G=n(H),q=p===G;return l.jsxs(g.Fragment,{children:[l.jsx("div",{className:$e("h-2 rounded-full transition",(m==null?void 0:m.columnId)===O.id&&m.index===Z?"bg-primary/70":"bg-transparent"),onDragOver:Y=>A(Y,O.id,Z),onDrop:Y=>L(Y,O.id,Z)}),l.jsx("div",{draggable:!!c,onMouseDown:Y=>{v.current=Y.target},onDragStart:Y=>{const X=v.current;if(X!=null&&X.closest("a, button")){Y.preventDefault();return}T(Y,G)},onDragEnd:S,className:$e("transition",c?"cursor-grab active:cursor-grabbing":"",q?"scale-[0.98] opacity-50":""),children:i(H,{dragging:q})})]},G)}),P.length>0?l.jsx("div",{className:$e("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(m==null?void 0:m.columnId)===O.id&&m.index===P.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",k&&!$.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},O.id)})})})}function HE({active:e,disabled:t,children:n}){return l.jsx("div",{className:$e("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 L0={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],custom:!1};let $i=null,Bo=null;function WE(){return $i?Promise.resolve($i):Bo||(Bo=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>($i=e,Bo=null,e)).catch(()=>(Bo=null,L0)),Bo)}function bc(){const[e,t]=g.useState(()=>$i??L0);return g.useEffect(()=>{WE().then(t)},[]),e}function kx(){$i=null,Bo=null}function VE(e,t){const n=e.statuses.find(o=>o.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}const qE={completed:"bg-emerald-500",in_progress:"bg-sky-500",review:"bg-violet-500",blocked:"bg-amber-500",failed:"bg-rose-500",pending:"bg-slate-400"},jx=["bg-cyan-500","bg-indigo-500","bg-orange-500","bg-pink-500","bg-lime-500","bg-fuchsia-500"];function Xa({progress:e,className:t,showLegend:n=!1}){const o=bc(),i=g.useMemo(()=>{let c=0;return(o.order.length>0?o.order:Object.keys(e).filter(p=>p!=="total")).map(p=>({key:p,className:qE[p]??jx[c++%jx.length]}))},[o.order,e]),a=i.filter(c=>(e[c.key]??0)>0);return l.jsxs("div",{className:$e("space-y-2",t),children:[l.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?l.jsx("div",{className:"h-full w-full bg-muted"}):a.map(c=>l.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${Cn(c.key)}: ${e[c.key]??0}`},c.key))}),n?l.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(c=>l.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[l.jsx("span",{className:$e("h-2 w-2 rounded-full",c.className)}),l.jsx("span",{children:Cn(c.key)}),l.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const KE=["pending","active","blocked","failed","completed","archived"],jp=KE,GE=["pending","in_progress","blocked","review","completed","failed"];function YE(e){return e&&e.length>0?e:[...GE]}function XE(e,t,n){if(t<0||t>=e.length)return e;const o=[...e],[i]=o.splice(t,1),a=t<n?n-1:n;return o.splice(Math.max(0,Math.min(a,o.length)),0,i),o}function Sx(){const{workspace:e}=Et(),t=Lt(),n=Xt(),{data:o,loading:i,error:a,refetch:c}=dc(),d=g.useRef(null);zs("list:projects");const[p,h]=g.useState(""),[m,x]=g.useState("all"),[v,b]=g.useState("active"),[N,k]=g.useState("all"),[j,S]=g.useState("updated"),[T,A]=_s(),L=T.get("view"),O=L==="table"||L==="kanban"?L:"cards",P=D=>{A(V=>{const W=new URLSearchParams(V);return D==="cards"?W.delete("view"):W.set("view",D),W})},[$,E]=g.useState({}),H=g.useMemo(()=>o?o.filter(D=>{if(e){if(e==="_ungrouped"){if(D.workspace!==null)return!1}else if(D.workspace!==e)return!1}return v==="active"&&D.archived||v==="archived"&&!D.archived||m!=="all"&&D.status!==m||N!=="all"&&!D.tags.includes(N)?!1:p.trim()?`${D.title} ${D.tags.join(" ")} ${D.slug}`.toLowerCase().includes(p.toLowerCase()):!0}).sort((D,V)=>ZE(D,V,j)):[],[o,p,m,v,N,j,e]),Z=H.map(D=>`${D.slug}:${D.status}`).join("|");g.useEffect(()=>{E(eR(H))},[Z,j]);const G=g.useMemo(()=>{const D=new Map(H.map(V=>[V.slug,V]));return jp.flatMap(V=>($[V]??H.filter(ee=>ee.status===V).map(ee=>ee.slug)).map(ee=>D.get(ee)).filter(ee=>!!ee))},[H,$]),{visibleItems:q,visibleIndexByKey:Y}=g.useMemo(()=>{const D=O==="kanban"?G:H,V=new Map;return D.forEach((W,ee)=>V.set(W.slug,ee)),{visibleItems:D,visibleIndexByKey:V}},[O,H,G]),{hotkeyRowProps:X}=yc(q,{scope:"list:projects",onOpen:D=>n(`${t}/projects/${D.slug}`)});if(yt({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var D;return(D=d.current)==null?void 0:D.focus()}}),yt({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),i)return l.jsx(jt,{label:"Loading projects…"});if(a||!o)return l.jsx(vt,{error:a||"Project list is unavailable."});const _=Array.from(new Set(o.flatMap(D=>D.tags))).sort();return l.jsxs("div",{className:"space-y-5",children:[l.jsxs(wp,{children:[l.jsx(vc,{ref:d,value:p,onChange:h,placeholder:"Search by project title or tag"}),l.jsxs("select",{value:m,onChange:D=>x(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All statuses"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"blocked",children:"Blocked"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]}),l.jsxs("select",{value:v,onChange:D=>b(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"active",children:"Hide archived"}),l.jsx("option",{value:"all",children:"All projects"}),l.jsx("option",{value:"archived",children:"Archived only"})]}),l.jsxs("select",{value:N,onChange:D=>k(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All tags"}),_.map(D=>l.jsx("option",{value:D,children:D},D))]}),l.jsxs("select",{value:j,onChange:D=>S(D.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"updated",children:"Sort: Updated"}),l.jsx("option",{value:"created",children:"Sort: Created"}),l.jsx("option",{value:"title",children:"Sort: Title"}),l.jsx("option",{value:"attention",children:"Sort: Attention"})]}),l.jsx(kp,{value:O,onChange:D=>P(D),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),H.length===0?l.jsx(Ge,{title:o.length===0?"No projects yet":"No projects match these filters",description:o.length===0?"A project is the high-level objective that groups assignments, resources, and memories. Create one to start the dashboard flow.":"Adjust the current search and filters or create a new project.",actions:l.jsx(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:`${t}/create/project`,children:"Create Project"})}):O==="cards"?l.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:H.map((D,V)=>l.jsxs(Ce,{to:`${t}/projects/${D.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...X(V),children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:D.title}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Vr(D.updated)]})]}),l.jsx(Ht,{status:D.status})]}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsx(Xa,{progress:D.progress,showLegend:!0}),l.jsx("div",{className:"flex flex-wrap gap-2",children:D.tags.map(W=>l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:W},W))}),l.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),l.jsx("p",{className:"mt-1 font-semibold text-foreground",children:D.needsAttention.blockedCount+D.needsAttention.failedCount})]}),l.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[l.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),l.jsx("p",{className:"mt-1 font-semibold text-foreground",children:D.progress.total})]})]})]})]},D.slug))}):O==="table"?l.jsx(Pe,{title:`${H.length} project${H.length===1?"":"s"}`,children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[l.jsx("th",{className:"pb-3 font-medium",children:"Project"}),l.jsx("th",{className:"pb-3 font-medium",children:"Status"}),l.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),l.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),l.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),l.jsx("tbody",{children:H.map((D,V)=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",...X(V),children:[l.jsxs("td",{className:"py-4 pr-4",children:[l.jsx(Ce,{to:`${t}/projects/${D.slug}`,className:"font-semibold text-foreground hover:text-primary",children:D.title}),l.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:D.tags.map(W=>l.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:W},W))})]}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx(Ht,{status:D.status})}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx("div",{className:"min-w-[220px]",children:l.jsx(Xa,{progress:D.progress})})}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:D.needsAttention.blockedCount+D.needsAttention.failedCount}),l.jsx("td",{className:"py-4 text-muted-foreground",children:Vr(D.updated)})]},D.slug))})]})})}):l.jsx(I0,{columns:JE,items:G,getItemId:D=>D.slug,getColumnId:D=>D.status,canDrop:({fromColumnId:D,toColumnId:V})=>({allowed:!0,reason:D===V?void 0:"This will set a manual status override on the project."}),onMove:({item:D,fromColumnId:V,toColumnId:W,fromIndex:ee,toIndex:R})=>{if(V===W){const F=$[V]??H.filter(J=>J.status===V).map(J=>J.slug);E(J=>({...J,[V]:XE(F,ee,R)}));return}fetch(`/api/projects/${D.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:W})}).then(()=>{window.location.reload()})},emptyMessage:D=>`No ${D.title.toLowerCase()} projects.`,renderCard:(D,{dragging:V})=>{const W=Y.get(D.slug)??-1;return l.jsx("div",{...W>=0?X(W):{},children:l.jsx(tR,{project:D,dragging:V})})}}),l.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(kv,{className:"mt-0.5 h-4 w-4"}),l.jsxs("p",{children:["Project status is derived from assignment state by default.",O==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const QE={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed",archived:"Archived"},JE=jp.map(e=>({id:e,title:QE[e],description:D0(e)}));function ZE(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return Cx(t)-Cx(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function Cx(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function eR(e){return Object.fromEntries(jp.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function tR({project:e,dragging:t}){const n=Lt();return l.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(Ce,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Vr(e.updated)]})]}),l.jsx(Ht,{status:e.status})]}),l.jsx("div",{className:"mt-4",children:l.jsx(Xa,{progress:e.progress})}),l.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(o=>l.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:o},o)),l.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),l.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"]})]}),l.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function Hr({value:e}){const[t,n]=g.useState(!1);function o(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}return l.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-foreground",title:t?"Copied!":`Copy: ${e}`,children:t?l.jsx(Zf,{className:"h-3 w-3 text-green-500"}):l.jsx(tp,{className:"h-3 w-3"})})}function Nx(e){const t=nR(e),n=g.forwardRef((o,i)=>{const{children:a,...c}=o,d=g.Children.toArray(a),p=d.find(oR);if(p){const h=p.props.children,m=d.map(x=>x===p?g.Children.count(h)>1?g.Children.only(null):g.isValidElement(h)?h.props.children:null:x);return l.jsx(t,{...c,ref:i,children:g.isValidElement(h)?g.cloneElement(h,void 0,m):null})}return l.jsx(t,{...c,ref:i,children:a})});return n.displayName=`${e}.Slot`,n}function nR(e){const t=g.forwardRef((n,o)=>{const{children:i,...a}=n;if(g.isValidElement(i)){const c=iR(i),d=sR(a,i.props);return i.type!==g.Fragment&&(d.ref=o?fc(o,c):c),g.cloneElement(i,d)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rR=Symbol("radix.slottable");function oR(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rR}function sR(e,t){const n={...t};for(const o in t){const i=e[o],a=t[o];/^on[A-Z]/.test(o)?i&&a?n[o]=(...d)=>{const p=a(...d);return i(...d),p}:i&&(n[o]=i):o==="style"?n[o]={...i,...a}:o==="className"&&(n[o]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}function iR(e){var o,i;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function lR(e){const t=e+"CollectionProvider",[n,o]=Vo(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=k=>{const{scope:j,children:S}=k,T=xt.useRef(null),A=xt.useRef(new Map).current;return l.jsx(i,{scope:j,itemMap:A,collectionRef:T,children:S})};c.displayName=t;const d=e+"CollectionSlot",p=Nx(d),h=xt.forwardRef((k,j)=>{const{scope:S,children:T}=k,A=a(d,S),L=ln(j,A.collectionRef);return l.jsx(p,{ref:L,children:T})});h.displayName=d;const m=e+"CollectionItemSlot",x="data-radix-collection-item",v=Nx(m),b=xt.forwardRef((k,j)=>{const{scope:S,children:T,...A}=k,L=xt.useRef(null),O=ln(j,L),P=a(m,S);return xt.useEffect(()=>(P.itemMap.set(L,{ref:L,...A}),()=>void P.itemMap.delete(L))),l.jsx(v,{[x]:"",ref:O,children:T})});b.displayName=m;function N(k){const j=a(e+"CollectionConsumer",k);return xt.useCallback(()=>{const T=j.collectionRef.current;if(!T)return[];const A=Array.from(T.querySelectorAll(`[${x}]`));return Array.from(j.itemMap.values()).sort((P,$)=>A.indexOf(P.ref.current)-A.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:c,Slot:h,ItemSlot:b},N,o]}var aR=g.createContext(void 0);function O0(e){const t=g.useContext(aR);return e||t||"ltr"}var Fd="rovingFocusGroup.onEntryFocus",cR={bubbles:!1,cancelable:!0},ll="RovingFocusGroup",[Sf,_0,uR]=lR(ll),[dR,M0]=Vo(ll,[uR]),[fR,pR]=dR(ll),$0=g.forwardRef((e,t)=>l.jsx(Sf.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Sf.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(hR,{...e,ref:t})})}));$0.displayName=ll;var hR=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:i=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:p,onEntryFocus:h,preventScrollOnEntryFocus:m=!1,...x}=e,v=g.useRef(null),b=ln(t,v),N=O0(a),[k,j]=pc({prop:c,defaultProp:d??null,onChange:p,caller:ll}),[S,T]=g.useState(!1),A=Uo(h),L=_0(n),O=g.useRef(!1),[P,$]=g.useState(0);return g.useEffect(()=>{const E=v.current;if(E)return E.addEventListener(Fd,A),()=>E.removeEventListener(Fd,A)},[A]),l.jsx(fR,{scope:n,orientation:o,dir:N,loop:i,currentTabStopId:k,onItemFocus:g.useCallback(E=>j(E),[j]),onItemShiftTab:g.useCallback(()=>T(!0),[]),onFocusableItemAdd:g.useCallback(()=>$(E=>E+1),[]),onFocusableItemRemove:g.useCallback(()=>$(E=>E-1),[]),children:l.jsx(Rt.div,{tabIndex:S||P===0?-1:0,"data-orientation":o,...x,ref:b,style:{outline:"none",...e.style},onMouseDown:ct(e.onMouseDown,()=>{O.current=!0}),onFocus:ct(e.onFocus,E=>{const H=!O.current;if(E.target===E.currentTarget&&H&&!S){const Z=new CustomEvent(Fd,cR);if(E.currentTarget.dispatchEvent(Z),!Z.defaultPrevented){const G=L().filter(D=>D.focusable),q=G.find(D=>D.active),Y=G.find(D=>D.id===k),_=[q,Y,...G].filter(Boolean).map(D=>D.ref.current);B0(_,m)}}O.current=!1}),onBlur:ct(e.onBlur,()=>T(!1))})})}),F0="RovingFocusGroupItem",z0=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:i=!1,tabStopId:a,children:c,...d}=e,p=Cs(),h=a||p,m=pR(F0,n),x=m.currentTabStopId===h,v=_0(n),{onFocusableItemAdd:b,onFocusableItemRemove:N,currentTabStopId:k}=m;return g.useEffect(()=>{if(o)return b(),()=>N()},[o,b,N]),l.jsx(Sf.ItemSlot,{scope:n,id:h,focusable:o,active:i,children:l.jsx(Rt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...d,ref:t,onMouseDown:ct(e.onMouseDown,j=>{o?m.onItemFocus(h):j.preventDefault()}),onFocus:ct(e.onFocus,()=>m.onItemFocus(h)),onKeyDown:ct(e.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){m.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=xR(j,m.orientation,m.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let A=v().filter(L=>L.focusable).map(L=>L.ref.current);if(S==="last")A.reverse();else if(S==="prev"||S==="next"){S==="prev"&&A.reverse();const L=A.indexOf(j.currentTarget);A=m.loop?yR(A,L+1):A.slice(L+1)}setTimeout(()=>B0(A))}}),children:typeof c=="function"?c({isCurrentTabStop:x,hasTabStop:k!=null}):c})})});z0.displayName=F0;var mR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gR(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function xR(e,t,n){const o=gR(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return mR[o]}function B0(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function yR(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var vR=$0,bR=z0,wc="Tabs",[wR]=Vo(wc,[M0]),U0=M0(),[kR,Sp]=wR(wc),H0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:i,defaultValue:a,orientation:c="horizontal",dir:d,activationMode:p="automatic",...h}=e,m=O0(d),[x,v]=pc({prop:o,onChange:i,defaultProp:a??"",caller:wc});return l.jsx(kR,{scope:n,baseId:Cs(),value:x,onValueChange:v,orientation:c,dir:m,activationMode:p,children:l.jsx(Rt.div,{dir:m,"data-orientation":c,...h,ref:t})})});H0.displayName=wc;var W0="TabsList",V0=g.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...i}=e,a=Sp(W0,n),c=U0(n);return l.jsx(vR,{asChild:!0,...c,orientation:a.orientation,dir:a.dir,loop:o,children:l.jsx(Rt.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:t})})});V0.displayName=W0;var q0="TabsTrigger",K0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:i=!1,...a}=e,c=Sp(q0,n),d=U0(n),p=X0(c.baseId,o),h=Q0(c.baseId,o),m=o===c.value;return l.jsx(bR,{asChild:!0,...d,focusable:!i,active:m,children:l.jsx(Rt.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":h,"data-state":m?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:p,...a,ref:t,onMouseDown:ct(e.onMouseDown,x=>{!i&&x.button===0&&x.ctrlKey===!1?c.onValueChange(o):x.preventDefault()}),onKeyDown:ct(e.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&c.onValueChange(o)}),onFocus:ct(e.onFocus,()=>{const x=c.activationMode!=="manual";!m&&!i&&x&&c.onValueChange(o)})})})});K0.displayName=q0;var G0="TabsContent",Y0=g.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:i,children:a,...c}=e,d=Sp(G0,n),p=X0(d.baseId,o),h=Q0(d.baseId,o),m=o===d.value,x=g.useRef(m);return g.useEffect(()=>{const v=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(v)},[]),l.jsx(qo,{present:i||m,children:({present:v})=>l.jsx(Rt.div,{"data-state":m?"active":"inactive","data-orientation":d.orientation,role:"tabpanel","aria-labelledby":p,hidden:!v,id:h,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:x.current?"0s":void 0},children:v&&a})})});Y0.displayName=G0;function X0(e,t){return`${e}-trigger-${t}`}function Q0(e,t){return`${e}-content-${t}`}var jR=H0,SR=V0,CR=K0,NR=Y0;function Cp({value:e,onValueChange:t,items:n,className:o}){return l.jsxs(jR,{value:e,onValueChange:t,className:o,children:[l.jsx(SR,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(i=>l.jsxs(CR,{value:i.value,className:$e("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:[l.jsx("span",{children:i.label}),typeof i.count=="number"?l.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:i.count}):null]},i.value))}),n.map(i=>l.jsx(NR,{value:i.value,className:"pt-3",children:i.content},i.value))]})}const ER="modulepreload",RR=function(e){return"/"+e},Ex={},PR=function(t,n,o){let i=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(m=>Promise.resolve(m).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));i=c(n.map(h=>{if(h=RR(h),h in Ex)return;Ex[h]=!0;const m=h.endsWith(".css"),x=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const v=document.createElement("link");if(v.rel=m?"stylesheet":ER,m||(v.as="script"),v.crossOrigin="",v.href=h,p&&v.setAttribute("nonce",p),document.head.appendChild(v),m)return new Promise((b,N)=>{v.addEventListener("load",b),v.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function a(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return i.then(c=>{for(const d of c||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})};function TR({definition:e,className:t,nodeRoutes:n={}}){const o=g.useRef(null),[i,a]=g.useState(null),[c,d]=g.useState(!0),p=Xt(),h=document.documentElement.classList.contains("dark")?"dark":"default";return g.useEffect(()=>{let m=!1;async function x(){if(o.current)try{const v=(await PR(async()=>{const{default:k}=await import("./mermaid.core-BpP2keU-.js").then(j=>j.bF);return{default:k}},[])).default;if(v.initialize({startOnLoad:!1,theme:h}),m)return;const b=`mermaid-${Date.now()}`,{svg:N}=await v.render(b,e);if(m||!o.current)return;o.current.innerHTML=N,AR(o.current,n,p),d(!1)}catch(v){m||(a(v instanceof Error?v.message:"Failed to render graph"),d(!1))}}return d(!0),a(null),x(),()=>{m=!0}},[e,p,n,h]),i?l.jsxs("div",{className:$e("rounded-lg border border-border bg-card p-4",t),children:[l.jsxs("p",{className:"text-sm text-red-400",children:["Failed to render dependency graph: ",i]}),l.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):l.jsxs("div",{className:$e("rounded-lg border border-border bg-card p-4",t),children:[c&&l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),l.jsx("div",{ref:o,className:"overflow-auto"})]})}function AR(e,t,n){var o;for(const i of e.querySelectorAll(".node")){const a=((o=i.textContent)==null?void 0:o.replace(/\s+/g," ").trim())??"",c=t[a];if(!c)continue;i.style.cursor="pointer",i.setAttribute("role","link"),i.setAttribute("tabindex","0"),i.setAttribute("aria-label",`Open ${a}`);const d=()=>n(c);i.addEventListener("click",d),i.addEventListener("keydown",p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),d())})}}function DR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const IR=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,OR={};function Rx(e,t){return(OR.jsx?LR:IR).test(e)}const _R=/[ \t\n\f\r]/g;function MR(e){return typeof e=="object"?e.type==="text"?Px(e.value):!1:Px(e)}function Px(e){return e.replace(_R,"")===""}class al{constructor(t,n,o){this.normal=n,this.property=t,o&&(this.space=o)}}al.prototype.normal={};al.prototype.property={};al.prototype.space=void 0;function J0(e,t){const n={},o={};for(const i of e)Object.assign(n,i.property),Object.assign(o,i.normal);return new al(n,o,t)}function Cf(e){return e.toLowerCase()}class En{constructor(t,n){this.attribute=n,this.property=t}}En.prototype.attribute="";En.prototype.booleanish=!1;En.prototype.boolean=!1;En.prototype.commaOrSpaceSeparated=!1;En.prototype.commaSeparated=!1;En.prototype.defined=!1;En.prototype.mustUseProperty=!1;En.prototype.number=!1;En.prototype.overloadedBoolean=!1;En.prototype.property="";En.prototype.spaceSeparated=!1;En.prototype.space=void 0;let $R=0;const Me=Ko(),Nt=Ko(),Nf=Ko(),ce=Ko(),Ze=Ko(),Es=Ko(),_n=Ko();function Ko(){return 2**++$R}const Ef=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Nt,commaOrSpaceSeparated:_n,commaSeparated:Es,number:ce,overloadedBoolean:Nf,spaceSeparated:Ze},Symbol.toStringTag,{value:"Module"})),zd=Object.keys(Ef);class Np extends En{constructor(t,n,o,i){let a=-1;if(super(t,n),Tx(this,"space",i),typeof o=="number")for(;++a<zd.length;){const c=zd[a];Tx(this,zd[a],(o&Ef[c])===Ef[c])}}}Np.prototype.defined=!0;function Tx(e,t,n){n&&(e[t]=n)}function Bs(e){const t={},n={};for(const[o,i]of Object.entries(e.properties)){const a=new Np(o,e.transform(e.attributes||{},o),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(o)&&(a.mustUseProperty=!0),t[o]=a,n[Cf(o)]=o,n[Cf(a.attribute)]=o}return new al(t,n,e.space)}const Z0=Bs({properties:{ariaActiveDescendant:null,ariaAtomic:Nt,ariaAutoComplete:null,ariaBusy:Nt,ariaChecked:Nt,ariaColCount:ce,ariaColIndex:ce,ariaColSpan:ce,ariaControls:Ze,ariaCurrent:null,ariaDescribedBy:Ze,ariaDetails:null,ariaDisabled:Nt,ariaDropEffect:Ze,ariaErrorMessage:null,ariaExpanded:Nt,ariaFlowTo:Ze,ariaGrabbed:Nt,ariaHasPopup:null,ariaHidden:Nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ze,ariaLevel:ce,ariaLive:null,ariaModal:Nt,ariaMultiLine:Nt,ariaMultiSelectable:Nt,ariaOrientation:null,ariaOwns:Ze,ariaPlaceholder:null,ariaPosInSet:ce,ariaPressed:Nt,ariaReadOnly:Nt,ariaRelevant:null,ariaRequired:Nt,ariaRoleDescription:Ze,ariaRowCount:ce,ariaRowIndex:ce,ariaRowSpan:ce,ariaSelected:Nt,ariaSetSize:ce,ariaSort:null,ariaValueMax:ce,ariaValueMin:ce,ariaValueNow:ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function eb(e,t){return t in e?e[t]:t}function tb(e,t){return eb(e,t.toLowerCase())}const FR=Bs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Es,acceptCharset:Ze,accessKey:Ze,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:Ze,autoFocus:Me,autoPlay:Me,blocking:Ze,capture:null,charSet:null,checked:Me,cite:null,className:Ze,cols:ce,colSpan:null,content:null,contentEditable:Nt,controls:Me,controlsList:Ze,coords:ce|Es,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:Nf,draggable:Nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:Ze,height:ce,hidden:Nf,high:ce,href:null,hrefLang:null,htmlFor:Ze,httpEquiv:Ze,id:null,imageSizes:null,imageSrcSet:null,inert:Me,inputMode:null,integrity:null,is:null,isMap:Me,itemId:null,itemProp:Ze,itemRef:Ze,itemScope:Me,itemType:Ze,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Me,low:ce,manifest:null,max:null,maxLength:ce,media:null,method:null,min:null,minLength:ce,multiple:Me,muted:Me,name:null,nonce:null,noModule:Me,noValidate:Me,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:Me,optimum:ce,pattern:null,ping:Ze,placeholder:null,playsInline:Me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Me,referrerPolicy:null,rel:Ze,required:Me,reversed:Me,rows:ce,rowSpan:ce,sandbox:Ze,scope:null,scoped:Me,seamless:Me,selected:Me,shadowRootClonable:Me,shadowRootDelegatesFocus:Me,shadowRootMode:null,shape:null,size:ce,sizes:null,slot:null,span:ce,spellCheck:Nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ce,step:null,style:null,tabIndex:ce,target:null,title:null,translate:null,type:null,typeMustMatch:Me,useMap:null,value:Nt,width:ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ze,axis:null,background:null,bgColor:null,border:ce,borderColor:null,bottomMargin:ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Me,declare:Me,event:null,face:null,frame:null,frameBorder:null,hSpace:ce,leftMargin:ce,link:null,longDesc:null,lowSrc:null,marginHeight:ce,marginWidth:ce,noResize:Me,noHref:Me,noShade:Me,noWrap:Me,object:null,profile:null,prompt:null,rev:null,rightMargin:ce,rules:null,scheme:null,scrolling:Nt,standby:null,summary:null,text:null,topMargin:ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Me,disableRemotePlayback:Me,prefix:null,property:null,results:ce,security:null,unselectable:null},space:"html",transform:tb}),zR=Bs({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:_n,accentHeight:ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ce,amplitude:ce,arabicForm:null,ascent:ce,attributeName:null,attributeType:null,azimuth:ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ce,by:null,calcMode:null,capHeight:ce,className:Ze,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:ce,diffuseConstant:ce,direction:null,display:null,dur:null,divisor:ce,dominantBaseline:null,download:Me,dx:null,dy:null,edgeMode:null,editable:null,elevation:ce,enableBackground:null,end:null,event:null,exponent:ce,externalResourcesRequired:null,fill:null,fillOpacity:ce,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:Es,g2:Es,glyphName:Es,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ce,horizOriginX:ce,horizOriginY:ce,id:null,ideographic:ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ce,k:ce,k1:ce,k2:ce,k3:ce,k4:ce,kernelMatrix:_n,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ce,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:ce,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:ce,overlineThickness:ce,paintOrder:null,panose1:null,path:null,pathLength:ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ze,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ce,pointsAtY:ce,pointsAtZ:ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:_n,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:_n,rev:_n,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:_n,requiredFeatures:_n,requiredFonts:_n,requiredFormats:_n,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:ce,specularExponent:ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ce,strikethroughThickness:ce,string:null,stroke:null,strokeDashArray:_n,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ce,strokeOpacity:ce,strokeWidth:null,style:null,surfaceScale:ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:_n,tabIndex:ce,tableValues:null,target:null,targetX:ce,targetY:ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:_n,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ce,underlineThickness:ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ce,values:null,vAlphabetic:ce,vMathematical:ce,vectorEffect:null,vHanging:ce,vIdeographic:ce,version:null,vertAdvY:ce,vertOriginX:ce,vertOriginY:ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:eb}),nb=Bs({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()}}),rb=Bs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:tb}),ob=Bs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),BR={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"},UR=/[A-Z]/g,Ax=/-[a-z]/g,HR=/^data[-\w.:]+$/i;function WR(e,t){const n=Cf(t);let o=t,i=En;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&HR.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(Ax,qR);o="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!Ax.test(a)){let c=a.replace(UR,VR);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}i=Np}return new i(o,t)}function VR(e){return"-"+e.toLowerCase()}function qR(e){return e.charAt(1).toUpperCase()}const KR=J0([Z0,FR,nb,rb,ob],"html"),Ep=J0([Z0,zR,nb,rb,ob],"svg");function GR(e){return e.join(" ").trim()}var vs={},Bd,Dx;function YR(){if(Dx)return Bd;Dx=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,p=`
|
|
441
441
|
`,h="/",m="*",x="",v="comment",b="declaration";function N(j,S){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];S=S||{};var T=1,A=1;function L(X){var _=X.match(t);_&&(T+=_.length);var D=X.lastIndexOf(p);A=~D?X.length-D:A+X.length}function O(){var X={line:T,column:A};return function(_){return _.position=new P(X),H(),_}}function P(X){this.start=X,this.end={line:T,column:A},this.source=S.source}P.prototype.content=j;function $(X){var _=new Error(S.source+":"+T+":"+A+": "+X);if(_.reason=X,_.filename=S.source,_.line=T,_.column=A,_.source=j,!S.silent)throw _}function E(X){var _=X.exec(j);if(_){var D=_[0];return L(D),j=j.slice(D.length),_}}function H(){E(n)}function Z(X){var _;for(X=X||[];_=G();)_!==!1&&X.push(_);return X}function G(){var X=O();if(!(h!=j.charAt(0)||m!=j.charAt(1))){for(var _=2;x!=j.charAt(_)&&(m!=j.charAt(_)||h!=j.charAt(_+1));)++_;if(_+=2,x===j.charAt(_-1))return $("End of comment missing");var D=j.slice(2,_-2);return A+=2,L(D),j=j.slice(_),A+=2,X({type:v,comment:D})}}function q(){var X=O(),_=E(o);if(_){if(G(),!E(i))return $("property missing ':'");var D=E(a),V=X({type:b,property:k(_[0].replace(e,x)),value:D?k(D[0].replace(e,x)):x});return E(c),V}}function Y(){var X=[];Z(X);for(var _;_=q();)_!==!1&&(X.push(_),Z(X));return X}return H(),Y()}function k(j){return j?j.replace(d,x):x}return Bd=N,Bd}var Ix;function XR(){if(Ix)return vs;Ix=1;var e=vs&&vs.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(vs,"__esModule",{value:!0}),vs.default=n;const t=e(YR());function n(o,i){let a=null;if(!o||typeof o!="string")return a;const c=(0,t.default)(o),d=typeof i=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:m}=p;d?i(h,m,p):m&&(a=a||{},a[h]=m)}),a}return vs}var Di={},Lx;function QR(){if(Lx)return Di;Lx=1,Object.defineProperty(Di,"__esModule",{value:!0}),Di.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(h){return!h||n.test(h)||e.test(h)},c=function(h,m){return m.toUpperCase()},d=function(h,m){return"".concat(m,"-")},p=function(h,m){return m===void 0&&(m={}),a(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(i,d):h=h.replace(o,d),h.replace(t,c))};return Di.camelCase=p,Di}var Ii,Ox;function JR(){if(Ox)return Ii;Ox=1;var e=Ii&&Ii.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(XR()),n=QR();function o(i,a){var c={};return!i||typeof i!="string"||(0,t.default)(i,function(d,p){d&&p&&(c[(0,n.camelCase)(d,a)]=p)}),c}return o.default=o,Ii=o,Ii}var ZR=JR();const eP=lc(ZR),sb=ib("end"),Rp=ib("start");function ib(e){return t;function t(n){const o=n&&n.position&&n.position[e]||{};if(typeof o.line=="number"&&o.line>0&&typeof o.column=="number"&&o.column>0)return{line:o.line,column:o.column,offset:typeof o.offset=="number"&&o.offset>-1?o.offset:void 0}}}function tP(e){const t=Rp(e),n=sb(e);if(t&&n)return{start:t,end:n}}function Fi(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?_x(e.position):"start"in e||"end"in e?_x(e):"line"in e||"column"in e?Rf(e):""}function Rf(e){return Mx(e&&e.line)+":"+Mx(e&&e.column)}function _x(e){return Rf(e&&e.start)+"-"+Rf(e&&e.end)}function Mx(e){return e&&typeof e=="number"?e:1}class an extends Error{constructor(t,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let i="",a={},c=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(c=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof o=="string"){const p=o.indexOf(":");p===-1?a.ruleId=o:(a.source=o.slice(0,p),a.ruleId=o.slice(p+1))}if(!a.place&&a.ancestors&&a.ancestors){const p=a.ancestors[a.ancestors.length-1];p&&(a.place=p.position)}const d=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=d?d.line:void 0,this.name=Fi(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=c&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}an.prototype.file="";an.prototype.name="";an.prototype.reason="";an.prototype.message="";an.prototype.stack="";an.prototype.column=void 0;an.prototype.line=void 0;an.prototype.ancestors=void 0;an.prototype.cause=void 0;an.prototype.fatal=void 0;an.prototype.place=void 0;an.prototype.ruleId=void 0;an.prototype.source=void 0;const Pp={}.hasOwnProperty,nP=new Map,rP=/[A-Z]/g,oP=new Set(["table","tbody","thead","tfoot","tr"]),sP=new Set(["td","th"]),lb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function iP(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let o;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=hP(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");o=pP(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,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"?Ep:KR,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=ab(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function ab(e,t,n){if(t.type==="element")return lP(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return aP(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return uP(e,t,n);if(t.type==="mdxjsEsm")return cP(e,t);if(t.type==="root")return dP(e,t,n);if(t.type==="text")return fP(e,t)}function lP(e,t,n){const o=e.schema;let i=o;t.tagName.toLowerCase()==="svg"&&o.space==="html"&&(i=Ep,e.schema=i),e.ancestors.push(t);const a=ub(e,t.tagName,!1),c=mP(e,t);let d=Ap(e,t);return oP.has(t.tagName)&&(d=d.filter(function(p){return typeof p=="string"?!MR(p):!0})),cb(e,c,a,t),Tp(c,d),e.ancestors.pop(),e.schema=o,e.create(t,a,c,n)}function aP(e,t){if(t.data&&t.data.estree&&e.evaluater){const o=t.data.estree.body[0];return o.type,e.evaluater.evaluateExpression(o.expression)}Xi(e,t.position)}function cP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xi(e,t.position)}function uP(e,t,n){const o=e.schema;let i=o;t.name==="svg"&&o.space==="html"&&(i=Ep,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:ub(e,t.name,!0),c=gP(e,t),d=Ap(e,t);return cb(e,c,a,t),Tp(c,d),e.ancestors.pop(),e.schema=o,e.create(t,a,c,n)}function dP(e,t,n){const o={};return Tp(o,Ap(e,t)),e.create(t,e.Fragment,o,n)}function fP(e,t){return t.value}function cb(e,t,n,o){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=o)}function Tp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function pP(e,t,n){return o;function o(i,a,c,d){const h=Array.isArray(c.children)?n:t;return d?h(a,c,d):h(a,c)}}function hP(e,t){return n;function n(o,i,a,c){const d=Array.isArray(a.children),p=Rp(o);return t(i,a,c,d,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function mP(e,t){const n={};let o,i;for(i in t.properties)if(i!=="children"&&Pp.call(t.properties,i)){const a=xP(e,i,t.properties[i]);if(a){const[c,d]=a;e.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&sP.has(t.tagName)?o=d:n[c]=d}}if(o){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=o}return n}function gP(e,t){const n={};for(const o of t.attributes)if(o.type==="mdxJsxExpressionAttribute")if(o.data&&o.data.estree&&e.evaluater){const a=o.data.estree.body[0];a.type;const c=a.expression;c.type;const d=c.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else Xi(e,t.position);else{const i=o.name;let a;if(o.value&&typeof o.value=="object")if(o.value.data&&o.value.data.estree&&e.evaluater){const d=o.value.data.estree.body[0];d.type,a=e.evaluater.evaluateExpression(d.expression)}else Xi(e,t.position);else a=o.value===null?!0:o.value;n[i]=a}return n}function Ap(e,t){const n=[];let o=-1;const i=e.passKeys?new Map:nP;for(;++o<t.children.length;){const a=t.children[o];let c;if(e.passKeys){const p=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(p){const h=i.get(p)||0;c=p+"-"+h,i.set(p,h+1)}}const d=ab(e,a,c);d!==void 0&&n.push(d)}return n}function xP(e,t,n){const o=WR(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=o.commaSeparated?DR(n):GR(n)),o.property==="style"){let i=typeof n=="object"?n:yP(e,String(n));return e.stylePropertyNameCase==="css"&&(i=vP(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&o.space?BR[o.property]||o.property:o.attribute,n]}}function yP(e,t){try{return eP(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const o=n,i=new an("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:o,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=lb+"#cannot-parse-style-attribute",i}}function ub(e,t,n){let o;if(!n)o={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,c;for(;++a<i.length;){const d=Rx(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(a&&d.type==="Literal"),optional:!1}:d}o=c}else o=Rx(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(o.type==="Literal"){const i=o.value;return Pp.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(o);Xi(e)}function Xi(e,t){const n=new an("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=lb+"#cannot-handle-mdx-estrees-without-createevaluater",n}function vP(e){const t={};let n;for(n in e)Pp.call(e,n)&&(t[bP(n)]=e[n]);return t}function bP(e){let t=e.replace(rP,wP);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function wP(e){return"-"+e.toLowerCase()}const Ud={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"]},kP={};function jP(e,t){const n=kP,o=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return db(e,o,i)}function db(e,t,n){if(SP(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 $x(e.children,t,n)}return Array.isArray(e)?$x(e,t,n):""}function $x(e,t,n){const o=[];let i=-1;for(;++i<e.length;)o[i]=db(e[i],t,n);return o.join("")}function SP(e){return!!(e&&typeof e=="object")}const Fx=document.createElement("i");function Dp(e){const t="&"+e+";";Fx.innerHTML=t;const n=Fx.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Er(e,t,n,o){const i=e.length;let a=0,c;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,o.length<1e4)c=Array.from(o),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);a<o.length;)c=o.slice(a,a+1e4),c.unshift(t,0),e.splice(...c),a+=1e4,t+=1e4}function Yn(e,t){return e.length>0?(Er(e,e.length,0,t),e):t}const zx={}.hasOwnProperty;function CP(e){const t={};let n=-1;for(;++n<e.length;)NP(t,e[n]);return t}function NP(e,t){let n;for(n in t){const i=(zx.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let c;if(a)for(c in a){zx.call(i,c)||(i[c]=[]);const d=a[c];EP(i[c],Array.isArray(d)?d:d?[d]:[])}}}function EP(e,t){let n=-1;const o=[];for(;++n<t.length;)(t[n].add==="after"?e:o).push(t[n]);Er(e,0,0,o)}function fb(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 Rs(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const wr=No(/[A-Za-z]/),$n=No(/[\dA-Za-z]/),RP=No(/[#-'*+\--9=?A-Z^-~]/);function Pf(e){return e!==null&&(e<32||e===127)}const Tf=No(/\d/),PP=No(/[\dA-Fa-f]/),TP=No(/[!-/:-@[-`{-~]/);function Ie(e){return e!==null&&e<-2}function Nn(e){return e!==null&&(e<0||e===32)}function qe(e){return e===-2||e===-1||e===32}const AP=No(new RegExp("\\p{P}|\\p{S}","u")),DP=No(/\s/);function No(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Us(e){const t=[];let n=-1,o=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let c="";if(a===37&&$n(e.charCodeAt(n+1))&&$n(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(c=String.fromCharCode(a));else if(a>55295&&a<57344){const d=e.charCodeAt(n+1);a<56320&&d>56319&&d<57344?(c=String.fromCharCode(a,d),i=1):c="�"}else c=String.fromCharCode(a);c&&(t.push(e.slice(o,n),encodeURIComponent(c)),o=n+i+1,c=""),i&&(n+=i,i=0)}return t.join("")+e.slice(o)}function et(e,t,n,o){const i=o?o-1:Number.POSITIVE_INFINITY;let a=0;return c;function c(p){return qe(p)?(e.enter(n),d(p)):t(p)}function d(p){return qe(p)&&a++<i?(e.consume(p),d):(e.exit(n),t(p))}}const IP={tokenize:LP};function LP(e){const t=e.attempt(this.parser.constructs.contentInitial,o,i);let n;return t;function o(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),et(e,t,"linePrefix")}function i(d){return e.enter("paragraph"),a(d)}function a(d){const p=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=p),n=p,c(d)}function c(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Ie(d)?(e.consume(d),e.exit("chunkText"),a):(e.consume(d),c)}}const OP={tokenize:_P},Bx={tokenize:MP};function _P(e){const t=this,n=[];let o=0,i,a,c;return d;function d(A){if(o<n.length){const L=n[o];return t.containerState=L[1],e.attempt(L[0].continuation,p,h)(A)}return h(A)}function p(A){if(o++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&T();const L=t.events.length;let O=L,P;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){P=t.events[O][1].end;break}S(o);let $=L;for(;$<t.events.length;)t.events[$][1].end={...P},$++;return Er(t.events,O+1,0,t.events.slice(L)),t.events.length=$,h(A)}return d(A)}function h(A){if(o===n.length){if(!i)return v(A);if(i.currentConstruct&&i.currentConstruct.concrete)return N(A);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Bx,m,x)(A)}function m(A){return i&&T(),S(o),v(A)}function x(A){return t.parser.lazy[t.now().line]=o!==n.length,c=t.now().offset,N(A)}function v(A){return t.containerState={},e.attempt(Bx,b,N)(A)}function b(A){return o++,n.push([t.currentConstruct,t.containerState]),v(A)}function N(A){if(A===null){i&&T(),S(0),e.consume(A);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),k(A)}function k(A){if(A===null){j(e.exit("chunkFlow"),!0),S(0),e.consume(A);return}return Ie(A)?(e.consume(A),j(e.exit("chunkFlow")),o=0,t.interrupt=void 0,d):(e.consume(A),k)}function j(A,L){const O=t.sliceStream(A);if(L&&O.push(null),A.previous=a,a&&(a.next=A),a=A,i.defineSkip(A.start),i.write(O),t.parser.lazy[A.start.line]){let P=i.events.length;for(;P--;)if(i.events[P][1].start.offset<c&&(!i.events[P][1].end||i.events[P][1].end.offset>c))return;const $=t.events.length;let E=$,H,Z;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(H){Z=t.events[E][1].end;break}H=!0}for(S(o),P=$;P<t.events.length;)t.events[P][1].end={...Z},P++;Er(t.events,E+1,0,t.events.slice($)),t.events.length=P}}function S(A){let L=n.length;for(;L-- >A;){const O=n[L];t.containerState=O[1],O[0].exit.call(t,e)}n.length=A}function T(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function MP(e,t,n){return et(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ux(e){if(e===null||Nn(e)||DP(e))return 1;if(AP(e))return 2}function Ip(e,t,n){const o=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!o.includes(a)&&(t=a(t,n),o.push(a))}return t}const Af={name:"attention",resolveAll:$P,tokenize:FP};function $P(e,t){let n=-1,o,i,a,c,d,p,h,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(o=n;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[o][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;p=e[o][1].end.offset-e[o][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const x={...e[o][1].end},v={...e[n][1].start};Hx(x,-p),Hx(v,p),c={type:p>1?"strongSequence":"emphasisSequence",start:x,end:{...e[o][1].end}},d={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:v},a={type:p>1?"strongText":"emphasisText",start:{...e[o][1].end},end:{...e[n][1].start}},i={type:p>1?"strong":"emphasis",start:{...c.start},end:{...d.end}},e[o][1].end={...c.start},e[n][1].start={...d.end},h=[],e[o][1].end.offset-e[o][1].start.offset&&(h=Yn(h,[["enter",e[o][1],t],["exit",e[o][1],t]])),h=Yn(h,[["enter",i,t],["enter",c,t],["exit",c,t],["enter",a,t]]),h=Yn(h,Ip(t.parser.constructs.insideSpan.null,e.slice(o+1,n),t)),h=Yn(h,[["exit",a,t],["enter",d,t],["exit",d,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,h=Yn(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,Er(e,o-1,n-o+3,h),n=o+h.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function FP(e,t){const n=this.parser.constructs.attentionMarkers.null,o=this.previous,i=Ux(o);let a;return c;function c(p){return a=p,e.enter("attentionSequence"),d(p)}function d(p){if(p===a)return e.consume(p),d;const h=e.exit("attentionSequence"),m=Ux(p),x=!m||m===2&&i||n.includes(p),v=!i||i===2&&m||n.includes(o);return h._open=!!(a===42?x:x&&(i||!v)),h._close=!!(a===42?v:v&&(m||!x)),t(p)}}function Hx(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const zP={name:"autolink",tokenize:BP};function BP(e,t,n){let o=0;return i;function i(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(b){return wr(b)?(e.consume(b),c):b===64?n(b):h(b)}function c(b){return b===43||b===45||b===46||$n(b)?(o=1,d(b)):h(b)}function d(b){return b===58?(e.consume(b),o=0,p):(b===43||b===45||b===46||$n(b))&&o++<32?(e.consume(b),d):(o=0,h(b))}function p(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||Pf(b)?n(b):(e.consume(b),p)}function h(b){return b===64?(e.consume(b),m):RP(b)?(e.consume(b),h):n(b)}function m(b){return $n(b)?x(b):n(b)}function x(b){return b===46?(e.consume(b),o=0,m):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):v(b)}function v(b){if((b===45||$n(b))&&o++<63){const N=b===45?v:x;return e.consume(b),N}return n(b)}}const kc={partial:!0,tokenize:UP};function UP(e,t,n){return o;function o(a){return qe(a)?et(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||Ie(a)?t(a):n(a)}}const pb={continuation:{tokenize:WP},exit:VP,name:"blockQuote",tokenize:HP};function HP(e,t,n){const o=this;return i;function i(c){if(c===62){const d=o.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),a}return n(c)}function a(c){return qe(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function WP(e,t,n){const o=this;return i;function i(c){return qe(c)?et(e,a,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):a(c)}function a(c){return e.attempt(pb,t,n)(c)}}function VP(e){e.exit("blockQuote")}const hb={name:"characterEscape",tokenize:qP};function qP(e,t,n){return o;function o(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return TP(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const mb={name:"characterReference",tokenize:KP};function KP(e,t,n){const o=this;let i=0,a,c;return d;function d(x){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),p}function p(x){return x===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(x),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),a=31,c=$n,m(x))}function h(x){return x===88||x===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(x),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,c=PP,m):(e.enter("characterReferenceValue"),a=7,c=Tf,m(x))}function m(x){if(x===59&&i){const v=e.exit("characterReferenceValue");return c===$n&&!Dp(o.sliceSerialize(v))?n(x):(e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(x)&&i++<a?(e.consume(x),m):n(x)}}const Wx={partial:!0,tokenize:YP},Vx={concrete:!0,name:"codeFenced",tokenize:GP};function GP(e,t,n){const o=this,i={partial:!0,tokenize:O};let a=0,c=0,d;return p;function p(P){return h(P)}function h(P){const $=o.events[o.events.length-1];return a=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,d=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(P)}function m(P){return P===d?(c++,e.consume(P),m):c<3?n(P):(e.exit("codeFencedFenceSequence"),qe(P)?et(e,x,"whitespace")(P):x(P))}function x(P){return P===null||Ie(P)?(e.exit("codeFencedFence"),o.interrupt?t(P):e.check(Wx,k,L)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(P))}function v(P){return P===null||Ie(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),x(P)):qe(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),et(e,b,"whitespace")(P)):P===96&&P===d?n(P):(e.consume(P),v)}function b(P){return P===null||Ie(P)?x(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),N(P))}function N(P){return P===null||Ie(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),x(P)):P===96&&P===d?n(P):(e.consume(P),N)}function k(P){return e.attempt(i,L,j)(P)}function j(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),S}function S(P){return a>0&&qe(P)?et(e,T,"linePrefix",a+1)(P):T(P)}function T(P){return P===null||Ie(P)?e.check(Wx,k,L)(P):(e.enter("codeFlowValue"),A(P))}function A(P){return P===null||Ie(P)?(e.exit("codeFlowValue"),T(P)):(e.consume(P),A)}function L(P){return e.exit("codeFenced"),t(P)}function O(P,$,E){let H=0;return Z;function Z(_){return P.enter("lineEnding"),P.consume(_),P.exit("lineEnding"),G}function G(_){return P.enter("codeFencedFence"),qe(_)?et(P,q,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):q(_)}function q(_){return _===d?(P.enter("codeFencedFenceSequence"),Y(_)):E(_)}function Y(_){return _===d?(H++,P.consume(_),Y):H>=c?(P.exit("codeFencedFenceSequence"),qe(_)?et(P,X,"whitespace")(_):X(_)):E(_)}function X(_){return _===null||Ie(_)?(P.exit("codeFencedFence"),$(_)):E(_)}}}function YP(e,t,n){const o=this;return i;function i(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a)}function a(c){return o.parser.lazy[o.now().line]?n(c):t(c)}}const Hd={name:"codeIndented",tokenize:QP},XP={partial:!0,tokenize:JP};function QP(e,t,n){const o=this;return i;function i(h){return e.enter("codeIndented"),et(e,a,"linePrefix",5)(h)}function a(h){const m=o.events[o.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?c(h):n(h)}function c(h){return h===null?p(h):Ie(h)?e.attempt(XP,c,p)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Ie(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),d)}function p(h){return e.exit("codeIndented"),t(h)}}function JP(e,t,n){const o=this;return i;function i(c){return o.parser.lazy[o.now().line]?n(c):Ie(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i):et(e,a,"linePrefix",5)(c)}function a(c){const d=o.events[o.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):Ie(c)?i(c):n(c)}}const ZP={name:"codeText",previous:tT,resolve:eT,tokenize:nT};function eT(e){let t=e.length-4,n=3,o,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(o=n;++o<t;)if(e[o][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(o=n-1,t++;++o<=t;)i===void 0?o!==t&&e[o][1].type!=="lineEnding"&&(i=o):(o===t||e[o][1].type==="lineEnding")&&(e[i][1].type="codeTextData",o!==i+2&&(e[i][1].end=e[o-1][1].end,e.splice(i+2,o-i-2),t-=o-i-2,o=i+2),i=void 0);return e}function tT(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function nT(e,t,n){let o=0,i,a;return c;function c(x){return e.enter("codeText"),e.enter("codeTextSequence"),d(x)}function d(x){return x===96?(e.consume(x),o++,d):(e.exit("codeTextSequence"),p(x))}function p(x){return x===null?n(x):x===32?(e.enter("space"),e.consume(x),e.exit("space"),p):x===96?(a=e.enter("codeTextSequence"),i=0,m(x)):Ie(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),p):(e.enter("codeTextData"),h(x))}function h(x){return x===null||x===32||x===96||Ie(x)?(e.exit("codeTextData"),p(x)):(e.consume(x),h)}function m(x){return x===96?(e.consume(x),i++,m):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(x)):(a.type="codeTextData",h(x))}}class rT{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 o=n??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(t,o):t>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(t,n,o){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return o&&Li(this.left,o),a.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),Li(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Li(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);Li(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Li(this.left,n.reverse())}}}function Li(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 gb(e){const t={};let n=-1,o,i,a,c,d,p,h;const m=new rT(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(o=m.get(n),n&&o[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(p=o[1]._tokenizer.events,a=0,a<p.length&&p[a][1].type==="lineEndingBlank"&&(a+=2),a<p.length&&p[a][1].type==="content"))for(;++a<p.length&&p[a][1].type!=="content";)p[a][1].type==="chunkText"&&(p[a][1]._isInFirstContentOfListItem=!0,a++);if(o[0]==="enter")o[1].contentType&&(Object.assign(t,oT(m,n)),n=t[n],h=!0);else if(o[1]._container){for(a=n,i=void 0;a--;)if(c=m.get(a),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(i&&(m.get(i)[1].type="lineEndingBlank"),c[1].type="lineEnding",i=a);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;i&&(o[1].end={...m.get(i)[1].start},d=m.slice(i,n),d.unshift(o),m.splice(i,n-i+1,d))}}return Er(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!h}function oT(e,t){const n=e.get(t)[1],o=e.get(t)[2];let i=t-1;const a=[];let c=n._tokenizer;c||(c=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,p=[],h={};let m,x,v=-1,b=n,N=0,k=0;const j=[k];for(;b;){for(;e.get(++i)[1]!==b;);a.push(i),b._tokenizer||(m=o.sliceStream(b),b.next||m.push(null),x&&c.defineSkip(b.start),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(m),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),x=b,b=b.next}for(b=n;++v<d.length;)d[v][0]==="exit"&&d[v-1][0]==="enter"&&d[v][1].type===d[v-1][1].type&&d[v][1].start.line!==d[v][1].end.line&&(k=v+1,j.push(k),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(c.events=[],b?(b._tokenizer=void 0,b.previous=void 0):j.pop(),v=j.length;v--;){const S=d.slice(j[v],j[v+1]),T=a.pop();p.push([T,T+S.length-1]),e.splice(T,2,S)}for(p.reverse(),v=-1;++v<p.length;)h[N+p[v][0]]=N+p[v][1],N+=p[v][1]-p[v][0]-1;return h}const sT={resolve:lT,tokenize:aT},iT={partial:!0,tokenize:cT};function lT(e){return gb(e),e}function aT(e,t){let n;return o;function o(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(d)}function i(d){return d===null?a(d):Ie(d)?e.check(iT,c,a)(d):(e.consume(d),i)}function a(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function c(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function cT(e,t,n){const o=this;return i;function i(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),et(e,a,"linePrefix")}function a(c){if(c===null||Ie(c))return n(c);const d=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(c):e.interrupt(o.parser.constructs.flow,n,t)(c)}}function xb(e,t,n,o,i,a,c,d,p){const h=p||Number.POSITIVE_INFINITY;let m=0;return x;function x(S){return S===60?(e.enter(o),e.enter(i),e.enter(a),e.consume(S),e.exit(a),v):S===null||S===32||S===41||Pf(S)?n(S):(e.enter(o),e.enter(c),e.enter(d),e.enter("chunkString",{contentType:"string"}),k(S))}function v(S){return S===62?(e.enter(a),e.consume(S),e.exit(a),e.exit(i),e.exit(o),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(d),v(S)):S===null||S===60||Ie(S)?n(S):(e.consume(S),S===92?N:b)}function N(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function k(S){return!m&&(S===null||S===41||Nn(S))?(e.exit("chunkString"),e.exit(d),e.exit(c),e.exit(o),t(S)):m<h&&S===40?(e.consume(S),m++,k):S===41?(e.consume(S),m--,k):S===null||S===32||S===40||Pf(S)?n(S):(e.consume(S),S===92?j:k)}function j(S){return S===40||S===41||S===92?(e.consume(S),k):k(S)}}function yb(e,t,n,o,i,a){const c=this;let d=0,p;return h;function h(b){return e.enter(o),e.enter(i),e.consume(b),e.exit(i),e.enter(a),m}function m(b){return d>999||b===null||b===91||b===93&&!p||b===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?n(b):b===93?(e.exit(a),e.enter(i),e.consume(b),e.exit(i),e.exit(o),t):Ie(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===null||b===91||b===93||Ie(b)||d++>999?(e.exit("chunkString"),m(b)):(e.consume(b),p||(p=!qe(b)),b===92?v:x)}function v(b){return b===91||b===92||b===93?(e.consume(b),d++,x):x(b)}}function vb(e,t,n,o,i,a){let c;return d;function d(v){return v===34||v===39||v===40?(e.enter(o),e.enter(i),e.consume(v),e.exit(i),c=v===40?41:v,p):n(v)}function p(v){return v===c?(e.enter(i),e.consume(v),e.exit(i),e.exit(o),t):(e.enter(a),h(v))}function h(v){return v===c?(e.exit(a),p(c)):v===null?n(v):Ie(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),et(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(v))}function m(v){return v===c||v===null||Ie(v)?(e.exit("chunkString"),h(v)):(e.consume(v),v===92?x:m)}function x(v){return v===c||v===92?(e.consume(v),m):m(v)}}function zi(e,t){let n;return o;function o(i){return Ie(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,o):qe(i)?et(e,o,n?"linePrefix":"lineSuffix")(i):t(i)}}const uT={name:"definition",tokenize:fT},dT={partial:!0,tokenize:pT};function fT(e,t,n){const o=this;let i;return a;function a(b){return e.enter("definition"),c(b)}function c(b){return yb.call(o,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function d(b){return i=Rs(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),p):n(b)}function p(b){return Nn(b)?zi(e,h)(b):h(b)}function h(b){return xb(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(dT,x,x)(b)}function x(b){return qe(b)?et(e,v,"whitespace")(b):v(b)}function v(b){return b===null||Ie(b)?(e.exit("definition"),o.parser.defined.push(i),t(b)):n(b)}}function pT(e,t,n){return o;function o(d){return Nn(d)?zi(e,i)(d):n(d)}function i(d){return vb(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function a(d){return qe(d)?et(e,c,"whitespace")(d):c(d)}function c(d){return d===null||Ie(d)?t(d):n(d)}}const hT={name:"hardBreakEscape",tokenize:mT};function mT(e,t,n){return o;function o(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return Ie(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const gT={name:"headingAtx",resolve:xT,tokenize:yT};function xT(e,t){let n=e.length-2,o=3,i,a;return e[o][1].type==="whitespace"&&(o+=2),n-2>o&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(o===n-1||n-4>o&&e[n-2][1].type==="whitespace")&&(n-=o+1===n?2:4),n>o&&(i={type:"atxHeadingText",start:e[o][1].start,end:e[n][1].end},a={type:"chunkText",start:e[o][1].start,end:e[n][1].end,contentType:"text"},Er(e,o,n-o+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function yT(e,t,n){let o=0;return i;function i(m){return e.enter("atxHeading"),a(m)}function a(m){return e.enter("atxHeadingSequence"),c(m)}function c(m){return m===35&&o++<6?(e.consume(m),c):m===null||Nn(m)?(e.exit("atxHeadingSequence"),d(m)):n(m)}function d(m){return m===35?(e.enter("atxHeadingSequence"),p(m)):m===null||Ie(m)?(e.exit("atxHeading"),t(m)):qe(m)?et(e,d,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function p(m){return m===35?(e.consume(m),p):(e.exit("atxHeadingSequence"),d(m))}function h(m){return m===null||m===35||Nn(m)?(e.exit("atxHeadingText"),d(m)):(e.consume(m),h)}}const vT=["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"],qx=["pre","script","style","textarea"],bT={concrete:!0,name:"htmlFlow",resolveTo:jT,tokenize:ST},wT={partial:!0,tokenize:NT},kT={partial:!0,tokenize:CT};function jT(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 ST(e,t,n){const o=this;let i,a,c,d,p;return h;function h(I){return m(I)}function m(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),x}function x(I){return I===33?(e.consume(I),v):I===47?(e.consume(I),a=!0,k):I===63?(e.consume(I),i=3,o.interrupt?t:R):wr(I)?(e.consume(I),c=String.fromCharCode(I),j):n(I)}function v(I){return I===45?(e.consume(I),i=2,b):I===91?(e.consume(I),i=5,d=0,N):wr(I)?(e.consume(I),i=4,o.interrupt?t:R):n(I)}function b(I){return I===45?(e.consume(I),o.interrupt?t:R):n(I)}function N(I){const de="CDATA[";return I===de.charCodeAt(d++)?(e.consume(I),d===de.length?o.interrupt?t:q:N):n(I)}function k(I){return wr(I)?(e.consume(I),c=String.fromCharCode(I),j):n(I)}function j(I){if(I===null||I===47||I===62||Nn(I)){const de=I===47,ve=c.toLowerCase();return!de&&!a&&qx.includes(ve)?(i=1,o.interrupt?t(I):q(I)):vT.includes(c.toLowerCase())?(i=6,de?(e.consume(I),S):o.interrupt?t(I):q(I)):(i=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(I):a?T(I):A(I))}return I===45||$n(I)?(e.consume(I),c+=String.fromCharCode(I),j):n(I)}function S(I){return I===62?(e.consume(I),o.interrupt?t:q):n(I)}function T(I){return qe(I)?(e.consume(I),T):Z(I)}function A(I){return I===47?(e.consume(I),Z):I===58||I===95||wr(I)?(e.consume(I),L):qe(I)?(e.consume(I),A):Z(I)}function L(I){return I===45||I===46||I===58||I===95||$n(I)?(e.consume(I),L):O(I)}function O(I){return I===61?(e.consume(I),P):qe(I)?(e.consume(I),O):A(I)}function P(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),p=I,$):qe(I)?(e.consume(I),P):E(I)}function $(I){return I===p?(e.consume(I),p=null,H):I===null||Ie(I)?n(I):(e.consume(I),$)}function E(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Nn(I)?O(I):(e.consume(I),E)}function H(I){return I===47||I===62||qe(I)?A(I):n(I)}function Z(I){return I===62?(e.consume(I),G):n(I)}function G(I){return I===null||Ie(I)?q(I):qe(I)?(e.consume(I),G):n(I)}function q(I){return I===45&&i===2?(e.consume(I),D):I===60&&i===1?(e.consume(I),V):I===62&&i===4?(e.consume(I),F):I===63&&i===3?(e.consume(I),R):I===93&&i===5?(e.consume(I),ee):Ie(I)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(wT,J,Y)(I)):I===null||Ie(I)?(e.exit("htmlFlowData"),Y(I)):(e.consume(I),q)}function Y(I){return e.check(kT,X,J)(I)}function X(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),_}function _(I){return I===null||Ie(I)?Y(I):(e.enter("htmlFlowData"),q(I))}function D(I){return I===45?(e.consume(I),R):q(I)}function V(I){return I===47?(e.consume(I),c="",W):q(I)}function W(I){if(I===62){const de=c.toLowerCase();return qx.includes(de)?(e.consume(I),F):q(I)}return wr(I)&&c.length<8?(e.consume(I),c+=String.fromCharCode(I),W):q(I)}function ee(I){return I===93?(e.consume(I),R):q(I)}function R(I){return I===62?(e.consume(I),F):I===45&&i===2?(e.consume(I),R):q(I)}function F(I){return I===null||Ie(I)?(e.exit("htmlFlowData"),J(I)):(e.consume(I),F)}function J(I){return e.exit("htmlFlow"),t(I)}}function CT(e,t,n){const o=this;return i;function i(c){return Ie(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):n(c)}function a(c){return o.parser.lazy[o.now().line]?n(c):t(c)}}function NT(e,t,n){return o;function o(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(kc,t,n)}}const ET={name:"htmlText",tokenize:RT};function RT(e,t,n){const o=this;let i,a,c;return d;function d(R){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(R),p}function p(R){return R===33?(e.consume(R),h):R===47?(e.consume(R),O):R===63?(e.consume(R),A):wr(R)?(e.consume(R),E):n(R)}function h(R){return R===45?(e.consume(R),m):R===91?(e.consume(R),a=0,N):wr(R)?(e.consume(R),T):n(R)}function m(R){return R===45?(e.consume(R),b):n(R)}function x(R){return R===null?n(R):R===45?(e.consume(R),v):Ie(R)?(c=x,V(R)):(e.consume(R),x)}function v(R){return R===45?(e.consume(R),b):x(R)}function b(R){return R===62?D(R):R===45?v(R):x(R)}function N(R){const F="CDATA[";return R===F.charCodeAt(a++)?(e.consume(R),a===F.length?k:N):n(R)}function k(R){return R===null?n(R):R===93?(e.consume(R),j):Ie(R)?(c=k,V(R)):(e.consume(R),k)}function j(R){return R===93?(e.consume(R),S):k(R)}function S(R){return R===62?D(R):R===93?(e.consume(R),S):k(R)}function T(R){return R===null||R===62?D(R):Ie(R)?(c=T,V(R)):(e.consume(R),T)}function A(R){return R===null?n(R):R===63?(e.consume(R),L):Ie(R)?(c=A,V(R)):(e.consume(R),A)}function L(R){return R===62?D(R):A(R)}function O(R){return wr(R)?(e.consume(R),P):n(R)}function P(R){return R===45||$n(R)?(e.consume(R),P):$(R)}function $(R){return Ie(R)?(c=$,V(R)):qe(R)?(e.consume(R),$):D(R)}function E(R){return R===45||$n(R)?(e.consume(R),E):R===47||R===62||Nn(R)?H(R):n(R)}function H(R){return R===47?(e.consume(R),D):R===58||R===95||wr(R)?(e.consume(R),Z):Ie(R)?(c=H,V(R)):qe(R)?(e.consume(R),H):D(R)}function Z(R){return R===45||R===46||R===58||R===95||$n(R)?(e.consume(R),Z):G(R)}function G(R){return R===61?(e.consume(R),q):Ie(R)?(c=G,V(R)):qe(R)?(e.consume(R),G):H(R)}function q(R){return R===null||R===60||R===61||R===62||R===96?n(R):R===34||R===39?(e.consume(R),i=R,Y):Ie(R)?(c=q,V(R)):qe(R)?(e.consume(R),q):(e.consume(R),X)}function Y(R){return R===i?(e.consume(R),i=void 0,_):R===null?n(R):Ie(R)?(c=Y,V(R)):(e.consume(R),Y)}function X(R){return R===null||R===34||R===39||R===60||R===61||R===96?n(R):R===47||R===62||Nn(R)?H(R):(e.consume(R),X)}function _(R){return R===47||R===62||Nn(R)?H(R):n(R)}function D(R){return R===62?(e.consume(R),e.exit("htmlTextData"),e.exit("htmlText"),t):n(R)}function V(R){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),W}function W(R){return qe(R)?et(e,ee,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):ee(R)}function ee(R){return e.enter("htmlTextData"),c(R)}}const Lp={name:"labelEnd",resolveAll:DT,resolveTo:IT,tokenize:LT},PT={tokenize:OT},TT={tokenize:_T},AT={tokenize:MT};function DT(e){let t=-1;const n=[];for(;++t<e.length;){const o=e[t][1];if(n.push(e[t]),o.type==="labelImage"||o.type==="labelLink"||o.type==="labelEnd"){const i=o.type==="labelImage"?4:2;o.type="data",t+=i}}return e.length!==n.length&&Er(e,0,e.length,n),e}function IT(e,t){let n=e.length,o=0,i,a,c,d;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){o=2;break}}else i.type==="labelEnd"&&(c=n);const p={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[a][1].start},end:{...e[c][1].end}},m={type:"labelText",start:{...e[a+o+2][1].end},end:{...e[c-2][1].start}};return d=[["enter",p,t],["enter",h,t]],d=Yn(d,e.slice(a+1,a+o+3)),d=Yn(d,[["enter",m,t]]),d=Yn(d,Ip(t.parser.constructs.insideSpan.null,e.slice(a+o+4,c-3),t)),d=Yn(d,[["exit",m,t],e[c-2],e[c-1],["exit",h,t]]),d=Yn(d,e.slice(c+1)),d=Yn(d,[["exit",p,t]]),Er(e,a,e.length,d),e}function LT(e,t,n){const o=this;let i=o.events.length,a,c;for(;i--;)if((o.events[i][1].type==="labelImage"||o.events[i][1].type==="labelLink")&&!o.events[i][1]._balanced){a=o.events[i][1];break}return d;function d(v){return a?a._inactive?x(v):(c=o.parser.defined.includes(Rs(o.sliceSerialize({start:a.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),p):n(v)}function p(v){return v===40?e.attempt(PT,m,c?m:x)(v):v===91?e.attempt(TT,m,c?h:x)(v):c?m(v):x(v)}function h(v){return e.attempt(AT,m,x)(v)}function m(v){return t(v)}function x(v){return a._balanced=!0,n(v)}}function OT(e,t,n){return o;function o(x){return e.enter("resource"),e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),i}function i(x){return Nn(x)?zi(e,a)(x):a(x)}function a(x){return x===41?m(x):xb(e,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(x)}function c(x){return Nn(x)?zi(e,p)(x):m(x)}function d(x){return n(x)}function p(x){return x===34||x===39||x===40?vb(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(x):m(x)}function h(x){return Nn(x)?zi(e,m)(x):m(x)}function m(x){return x===41?(e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),e.exit("resource"),t):n(x)}}function _T(e,t,n){const o=this;return i;function i(d){return yb.call(o,e,a,c,"reference","referenceMarker","referenceString")(d)}function a(d){return o.parser.defined.includes(Rs(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function c(d){return n(d)}}function MT(e,t,n){return o;function o(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const $T={name:"labelStartImage",resolveAll:Lp.resolveAll,tokenize:FT};function FT(e,t,n){const o=this;return i;function i(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),a}function a(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),c):n(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(d):t(d)}}const zT={name:"labelStartLink",resolveAll:Lp.resolveAll,tokenize:BT};function BT(e,t,n){const o=this;return i;function i(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),a}function a(c){return c===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(c):t(c)}}const Wd={name:"lineEnding",tokenize:UT};function UT(e,t){return n;function n(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),et(e,t,"linePrefix")}}const Ha={name:"thematicBreak",tokenize:HT};function HT(e,t,n){let o=0,i;return a;function a(h){return e.enter("thematicBreak"),c(h)}function c(h){return i=h,d(h)}function d(h){return h===i?(e.enter("thematicBreakSequence"),p(h)):o>=3&&(h===null||Ie(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===i?(e.consume(h),o++,p):(e.exit("thematicBreakSequence"),qe(h)?et(e,d,"whitespace")(h):d(h))}}const jn={continuation:{tokenize:KT},exit:YT,name:"list",tokenize:qT},WT={partial:!0,tokenize:XT},VT={partial:!0,tokenize:GT};function qT(e,t,n){const o=this,i=o.events[o.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,c=0;return d;function d(b){const N=o.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(N==="listUnordered"?!o.containerState.marker||b===o.containerState.marker:Tf(b)){if(o.containerState.type||(o.containerState.type=N,e.enter(N,{_container:!0})),N==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(Ha,n,h)(b):h(b);if(!o.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(b)}return n(b)}function p(b){return Tf(b)&&++c<10?(e.consume(b),p):(!o.interrupt||c<2)&&(o.containerState.marker?b===o.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):n(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||b,e.check(kc,o.interrupt?n:m,e.attempt(WT,v,x))}function m(b){return o.containerState.initialBlankLine=!0,a++,v(b)}function x(b){return qe(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),v):n(b)}function v(b){return o.containerState.size=a+o.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function KT(e,t,n){const o=this;return o.containerState._closeFlow=void 0,e.check(kc,i,a);function i(d){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,et(e,t,"listItemIndent",o.containerState.size+1)(d)}function a(d){return o.containerState.furtherBlankLines||!qe(d)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,c(d)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,e.attempt(VT,t,c)(d))}function c(d){return o.containerState._closeFlow=!0,o.interrupt=void 0,et(e,e.attempt(jn,t,n),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function GT(e,t,n){const o=this;return et(e,i,"listItemIndent",o.containerState.size+1);function i(a){const c=o.events[o.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===o.containerState.size?t(a):n(a)}}function YT(e){e.exit(this.containerState.type)}function XT(e,t,n){const o=this;return et(e,i,"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const c=o.events[o.events.length-1];return!qe(a)&&c&&c[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Kx={name:"setextUnderline",resolveTo:QT,tokenize:JT};function QT(e,t){let n=e.length,o,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){o=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const c={type:"setextHeading",start:{...e[o][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",c,t]),e.splice(a+1,0,["exit",e[o][1],t]),e[o][1].end={...e[a][1].end}):e[o][1]=c,e.push(["exit",c,t]),e}function JT(e,t,n){const o=this;let i;return a;function a(h){let m=o.events.length,x;for(;m--;)if(o.events[m][1].type!=="lineEnding"&&o.events[m][1].type!=="linePrefix"&&o.events[m][1].type!=="content"){x=o.events[m][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||x)?(e.enter("setextHeadingLine"),i=h,c(h)):n(h)}function c(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===i?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),qe(h)?et(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||Ie(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const ZT={tokenize:eA};function eA(e){const t=this,n=e.attempt(kc,o,e.attempt(this.parser.constructs.flowInitial,i,et(e,e.attempt(this.parser.constructs.flow,i,e.attempt(sT,i)),"linePrefix")));return n;function o(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const tA={resolveAll:wb()},nA=bb("string"),rA=bb("text");function bb(e){return{resolveAll:wb(e==="text"?oA:void 0),tokenize:t};function t(n){const o=this,i=this.parser.constructs[e],a=n.attempt(i,c,d);return c;function c(m){return h(m)?a(m):d(m)}function d(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),p}function p(m){return h(m)?(n.exit("data"),a(m)):(n.consume(m),p)}function h(m){if(m===null)return!0;const x=i[m];let v=-1;if(x)for(;++v<x.length;){const b=x[v];if(!b.previous||b.previous.call(o,o.previous))return!0}return!1}}}function wb(e){return t;function t(n,o){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,o):n}}function oA(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 o=e[n-1][1],i=t.sliceStream(o);let a=i.length,c=-1,d=0,p;for(;a--;){const h=i[a];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(h===-2)p=!0,d++;else if(h!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||p||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?c:o.start._bufferIndex+c,_index:o.start._index+a,line:o.end.line,column:o.end.column-d,offset:o.end.offset-d},end:{...o.end}};o.end={...h.start},o.start.offset===o.end.offset?Object.assign(o,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const sA={42:jn,43:jn,45:jn,48:jn,49:jn,50:jn,51:jn,52:jn,53:jn,54:jn,55:jn,56:jn,57:jn,62:pb},iA={91:uT},lA={[-2]:Hd,[-1]:Hd,32:Hd},aA={35:gT,42:Ha,45:[Kx,Ha],60:bT,61:Kx,95:Ha,96:Vx,126:Vx},cA={38:mb,92:hb},uA={[-5]:Wd,[-4]:Wd,[-3]:Wd,33:$T,38:mb,42:Af,60:[zP,ET],91:zT,92:[hT,hb],93:Lp,95:Af,96:ZP},dA={null:[Af,tA]},fA={null:[42,95]},pA={null:[]},hA=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:fA,contentInitial:iA,disable:pA,document:sA,flow:aA,flowInitial:lA,insideSpan:dA,string:cA,text:uA},Symbol.toStringTag,{value:"Module"}));function mA(e,t,n){let o={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},a=[];let c=[],d=[];const p={attempt:$(O),check:$(P),consume:T,enter:A,exit:L,interrupt:$(P,{interrupt:!0})},h={code:null,containerState:{},defineSkip:k,events:[],now:N,parser:e,previous:null,sliceSerialize:v,sliceStream:b,write:x};let m=t.tokenize.call(h,p);return t.resolveAll&&a.push(t),h;function x(G){return c=Yn(c,G),j(),c[c.length-1]!==null?[]:(E(t,0),h.events=Ip(a,h.events,h),h.events)}function v(G,q){return xA(b(G),q)}function b(G){return gA(c,G)}function N(){const{_bufferIndex:G,_index:q,line:Y,column:X,offset:_}=o;return{_bufferIndex:G,_index:q,line:Y,column:X,offset:_}}function k(G){i[G.line]=G.column,Z()}function j(){let G;for(;o._index<c.length;){const q=c[o._index];if(typeof q=="string")for(G=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===G&&o._bufferIndex<q.length;)S(q.charCodeAt(o._bufferIndex));else S(q)}}function S(G){m=m(G)}function T(G){Ie(G)?(o.line++,o.column=1,o.offset+=G===-3?2:1,Z()):G!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===c[o._index].length&&(o._bufferIndex=-1,o._index++)),h.previous=G}function A(G,q){const Y=q||{};return Y.type=G,Y.start=N(),h.events.push(["enter",Y,h]),d.push(Y),Y}function L(G){const q=d.pop();return q.end=N(),h.events.push(["exit",q,h]),q}function O(G,q){E(G,q.from)}function P(G,q){q.restore()}function $(G,q){return Y;function Y(X,_,D){let V,W,ee,R;return Array.isArray(X)?J(X):"tokenize"in X?J([X]):F(X);function F(fe){return Ee;function Ee(Ne){const Re=Ne!==null&&fe[Ne],je=Ne!==null&&fe.null,ut=[...Array.isArray(Re)?Re:Re?[Re]:[],...Array.isArray(je)?je:je?[je]:[]];return J(ut)(Ne)}}function J(fe){return V=fe,W=0,fe.length===0?D:I(fe[W])}function I(fe){return Ee;function Ee(Ne){return R=H(),ee=fe,fe.partial||(h.currentConstruct=fe),fe.name&&h.parser.constructs.disable.null.includes(fe.name)?ve():fe.tokenize.call(q?Object.assign(Object.create(h),q):h,p,de,ve)(Ne)}}function de(fe){return G(ee,R),_}function ve(fe){return R.restore(),++W<V.length?I(V[W]):D}}}function E(G,q){G.resolveAll&&!a.includes(G)&&a.push(G),G.resolve&&Er(h.events,q,h.events.length-q,G.resolve(h.events.slice(q),h)),G.resolveTo&&(h.events=G.resolveTo(h.events,h))}function H(){const G=N(),q=h.previous,Y=h.currentConstruct,X=h.events.length,_=Array.from(d);return{from:X,restore:D};function D(){o=G,h.previous=q,h.currentConstruct=Y,h.events.length=X,d=_,Z()}}function Z(){o.line in i&&o.column<2&&(o.column=i[o.line],o.offset+=i[o.line]-1)}}function gA(e,t){const n=t.start._index,o=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let c;if(n===i)c=[e[n].slice(o,a)];else{if(c=e.slice(n,i),o>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(o):c.shift()}a>0&&c.push(e[i].slice(0,a))}return c}function xA(e,t){let n=-1;const o=[];let i;for(;++n<e.length;){const a=e[n];let c;if(typeof a=="string")c=a;else switch(a){case-5:{c="\r";break}case-4:{c=`
|
|
442
442
|
`;break}case-3:{c=`\r
|
|
443
443
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&i)continue;c=" ";break}default:c=String.fromCharCode(a)}i=a===-2,o.push(c)}return o.join("")}function yA(e){const o={constructs:CP([hA,...(e||{}).extensions||[]]),content:i(IP),defined:[],document:i(OP),flow:i(ZT),lazy:{},string:i(nA),text:i(rA)};return o;function i(a){return c;function c(d){return mA(o,a,d)}}}function vA(e){for(;!gb(e););return e}const Gx=/[\0\t\n\r]/g;function bA(){let e=1,t="",n=!0,o;return i;function i(a,c,d){const p=[];let h,m,x,v,b;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(c||void 0).decode(a)),x=0,t="",n&&(a.charCodeAt(0)===65279&&x++,n=void 0);x<a.length;){if(Gx.lastIndex=x,h=Gx.exec(a),v=h&&h.index!==void 0?h.index:a.length,b=a.charCodeAt(v),!h){t=a.slice(x);break}if(b===10&&x===v&&o)p.push(-3),o=void 0;else switch(o&&(p.push(-5),o=void 0),x<v&&(p.push(a.slice(x,v)),e+=v-x),b){case 0:{p.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,p.push(-2);e++<m;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:o=!0,e=1}x=v+1}return d&&(o&&p.push(-5),t&&p.push(t),p.push(null)),p}}const wA=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kA(e){return e.replace(wA,jA)}function jA(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return fb(n.slice(a?2:1),a?16:10)}return Dp(n)||e}const kb={}.hasOwnProperty;function SA(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),CA(n)(vA(yA(n).document().write(bA()(e,t,!0))))}function CA(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Xe),autolinkProtocol:H,autolinkEmail:H,atxHeading:a(St),blockQuote:a(je),characterEscape:H,characterReference:H,codeFenced:a(ut),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:a(ut,c),codeText:a(tt,c),codeTextData:H,data:H,codeFlowValue:H,definition:a(Ue),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:a(Be),hardBreakEscape:a(Ot),hardBreakTrailing:a(Ot),htmlFlow:a(cn,c),htmlFlowData:H,htmlText:a(cn,c),htmlTextData:H,image:a(hn),label:c,link:a(Xe),listItem:a(Wt),listItemValue:v,listOrdered:a(nt,x),listUnordered:a(nt),paragraph:a(Qt),reference:I,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:a(St),strong:a(mn),thematicBreak:a(Tn)},exit:{atxHeading:p(),atxHeadingSequence:O,autolink:p(),autolinkEmail:Re,autolinkProtocol:Ne,blockQuote:p(),characterEscapeValue:Z,characterReferenceMarkerHexadecimal:ve,characterReferenceMarkerNumeric:ve,characterReferenceValue:fe,characterReference:Ee,codeFenced:p(j),codeFencedFence:k,codeFencedFenceInfo:b,codeFencedFenceMeta:N,codeFlowValue:Z,codeIndented:p(S),codeText:p(_),codeTextData:Z,data:Z,definition:p(),definitionDestinationString:L,definitionLabelString:T,definitionTitleString:A,emphasis:p(),hardBreakEscape:p(q),hardBreakTrailing:p(q),htmlFlow:p(Y),htmlFlowData:Z,htmlText:p(X),htmlTextData:Z,image:p(V),label:ee,labelText:W,lineEnding:G,link:p(D),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:de,resourceDestinationString:R,resourceTitleString:F,resource:J,setextHeading:p(E),setextHeadingLineSequence:$,setextHeadingText:P,strong:p(),thematicBreak:p()}};jb(t,(e||{}).mdastExtensions||[]);const n={};return o;function o(re){let le={type:"root",children:[]};const pe={stack:[le],tokenStack:[],config:t,enter:d,exit:h,buffer:c,resume:m,data:n},ne=[];let me=-1;for(;++me<re.length;)if(re[me][1].type==="listOrdered"||re[me][1].type==="listUnordered")if(re[me][0]==="enter")ne.push(me);else{const ke=ne.pop();me=i(re,ke,me)}for(me=-1;++me<re.length;){const ke=t[re[me][0]];kb.call(ke,re[me][1].type)&&ke[re[me][1].type].call(Object.assign({sliceSerialize:re[me][2].sliceSerialize},pe),re[me][1])}if(pe.tokenStack.length>0){const ke=pe.tokenStack[pe.tokenStack.length-1];(ke[1]||Yx).call(pe,void 0,ke[0])}for(le.position={start:yo(re.length>0?re[0][1].start:{line:1,column:1,offset:0}),end:yo(re.length>0?re[re.length-2][1].end:{line:1,column:1,offset:0})},me=-1;++me<t.transforms.length;)le=t.transforms[me](le)||le;return le}function i(re,le,pe){let ne=le-1,me=-1,ke=!1,_t,Jt,Vt,U;for(;++ne<=pe;){const ae=re[ne];switch(ae[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ae[0]==="enter"?me++:me--,U=void 0;break}case"lineEndingBlank":{ae[0]==="enter"&&(_t&&!U&&!me&&!Vt&&(Vt=ne),U=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:U=void 0}if(!me&&ae[0]==="enter"&&ae[1].type==="listItemPrefix"||me===-1&&ae[0]==="exit"&&(ae[1].type==="listUnordered"||ae[1].type==="listOrdered")){if(_t){let ge=ne;for(Jt=void 0;ge--;){const Oe=re[ge];if(Oe[1].type==="lineEnding"||Oe[1].type==="lineEndingBlank"){if(Oe[0]==="exit")continue;Jt&&(re[Jt][1].type="lineEndingBlank",ke=!0),Oe[1].type="lineEnding",Jt=ge}else if(!(Oe[1].type==="linePrefix"||Oe[1].type==="blockQuotePrefix"||Oe[1].type==="blockQuotePrefixWhitespace"||Oe[1].type==="blockQuoteMarker"||Oe[1].type==="listItemIndent"))break}Vt&&(!Jt||Vt<Jt)&&(_t._spread=!0),_t.end=Object.assign({},Jt?re[Jt][1].start:ae[1].end),re.splice(Jt||ne,0,["exit",_t,ae[2]]),ne++,pe++}if(ae[1].type==="listItemPrefix"){const ge={type:"listItem",_spread:!1,start:Object.assign({},ae[1].start),end:void 0};_t=ge,re.splice(ne,0,["enter",ge,ae[2]]),ne++,pe++,Vt=void 0,U=!0}}}return re[le][1]._spread=ke,pe}function a(re,le){return pe;function pe(ne){d.call(this,re(ne),ne),le&&le.call(this,ne)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(re,le,pe){this.stack[this.stack.length-1].children.push(re),this.stack.push(re),this.tokenStack.push([le,pe||void 0]),re.position={start:yo(le.start),end:void 0}}function p(re){return le;function le(pe){re&&re.call(this,pe),h.call(this,pe)}}function h(re,le){const pe=this.stack.pop(),ne=this.tokenStack.pop();if(ne)ne[0].type!==re.type&&(le?le.call(this,re,ne[0]):(ne[1]||Yx).call(this,re,ne[0]));else throw new Error("Cannot close `"+re.type+"` ("+Fi({start:re.start,end:re.end})+"): it’s not open");pe.position.end=yo(re.end)}function m(){return jP(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function v(re){if(this.data.expectingFirstListItemValue){const le=this.stack[this.stack.length-2];le.start=Number.parseInt(this.sliceSerialize(re),10),this.data.expectingFirstListItemValue=void 0}}function b(){const re=this.resume(),le=this.stack[this.stack.length-1];le.lang=re}function N(){const re=this.resume(),le=this.stack[this.stack.length-1];le.meta=re}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const re=this.resume(),le=this.stack[this.stack.length-1];le.value=re.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const re=this.resume(),le=this.stack[this.stack.length-1];le.value=re.replace(/(\r?\n|\r)$/g,"")}function T(re){const le=this.resume(),pe=this.stack[this.stack.length-1];pe.label=le,pe.identifier=Rs(this.sliceSerialize(re)).toLowerCase()}function A(){const re=this.resume(),le=this.stack[this.stack.length-1];le.title=re}function L(){const re=this.resume(),le=this.stack[this.stack.length-1];le.url=re}function O(re){const le=this.stack[this.stack.length-1];if(!le.depth){const pe=this.sliceSerialize(re).length;le.depth=pe}}function P(){this.data.setextHeadingSlurpLineEnding=!0}function $(re){const le=this.stack[this.stack.length-1];le.depth=this.sliceSerialize(re).codePointAt(0)===61?1:2}function E(){this.data.setextHeadingSlurpLineEnding=void 0}function H(re){const pe=this.stack[this.stack.length-1].children;let ne=pe[pe.length-1];(!ne||ne.type!=="text")&&(ne=Pn(),ne.position={start:yo(re.start),end:void 0},pe.push(ne)),this.stack.push(ne)}function Z(re){const le=this.stack.pop();le.value+=this.sliceSerialize(re),le.position.end=yo(re.end)}function G(re){const le=this.stack[this.stack.length-1];if(this.data.atHardBreak){const pe=le.children[le.children.length-1];pe.position.end=yo(re.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(le.type)&&(H.call(this,re),Z.call(this,re))}function q(){this.data.atHardBreak=!0}function Y(){const re=this.resume(),le=this.stack[this.stack.length-1];le.value=re}function X(){const re=this.resume(),le=this.stack[this.stack.length-1];le.value=re}function _(){const re=this.resume(),le=this.stack[this.stack.length-1];le.value=re}function D(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const le=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=le,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function V(){const re=this.stack[this.stack.length-1];if(this.data.inReference){const le=this.data.referenceType||"shortcut";re.type+="Reference",re.referenceType=le,delete re.url,delete re.title}else delete re.identifier,delete re.label;this.data.referenceType=void 0}function W(re){const le=this.sliceSerialize(re),pe=this.stack[this.stack.length-2];pe.label=kA(le),pe.identifier=Rs(le).toLowerCase()}function ee(){const re=this.stack[this.stack.length-1],le=this.resume(),pe=this.stack[this.stack.length-1];if(this.data.inReference=!0,pe.type==="link"){const ne=re.children;pe.children=ne}else pe.alt=le}function R(){const re=this.resume(),le=this.stack[this.stack.length-1];le.url=re}function F(){const re=this.resume(),le=this.stack[this.stack.length-1];le.title=re}function J(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function de(re){const le=this.resume(),pe=this.stack[this.stack.length-1];pe.label=le,pe.identifier=Rs(this.sliceSerialize(re)).toLowerCase(),this.data.referenceType="full"}function ve(re){this.data.characterReferenceType=re.type}function fe(re){const le=this.sliceSerialize(re),pe=this.data.characterReferenceType;let ne;pe?(ne=fb(le,pe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ne=Dp(le);const me=this.stack[this.stack.length-1];me.value+=ne}function Ee(re){const le=this.stack.pop();le.position.end=yo(re.end)}function Ne(re){Z.call(this,re);const le=this.stack[this.stack.length-1];le.url=this.sliceSerialize(re)}function Re(re){Z.call(this,re);const le=this.stack[this.stack.length-1];le.url="mailto:"+this.sliceSerialize(re)}function je(){return{type:"blockquote",children:[]}}function ut(){return{type:"code",lang:null,meta:null,value:""}}function tt(){return{type:"inlineCode",value:""}}function Ue(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Be(){return{type:"emphasis",children:[]}}function St(){return{type:"heading",depth:0,children:[]}}function Ot(){return{type:"break"}}function cn(){return{type:"html",value:""}}function hn(){return{type:"image",title:null,url:"",alt:null}}function Xe(){return{type:"link",title:null,url:"",children:[]}}function nt(re){return{type:"list",ordered:re.type==="listOrdered",start:null,spread:re._spread,children:[]}}function Wt(re){return{type:"listItem",spread:re._spread,checked:null,children:[]}}function Qt(){return{type:"paragraph",children:[]}}function mn(){return{type:"strong",children:[]}}function Pn(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function yo(e){return{line:e.line,column:e.column,offset:e.offset}}function jb(e,t){let n=-1;for(;++n<t.length;){const o=t[n];Array.isArray(o)?jb(e,o):NA(e,o)}}function NA(e,t){let n;for(n in t)if(kb.call(t,n))switch(n){case"canContainEols":{const o=t[n];o&&e[n].push(...o);break}case"transforms":{const o=t[n];o&&e[n].push(...o);break}case"enter":case"exit":{const o=t[n];o&&Object.assign(e[n],o);break}}}function Yx(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Fi({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Fi({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Fi({start:t.start,end:t.end})+") is still open")}function EA(e){const t=this;t.parser=n;function n(o){return SA(o,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function RA(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 PA(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -467,14 +467,14 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
467
467
|
`).trim(),a=[...t.slice(0,n),...t.slice(o)].join(`
|
|
468
468
|
`).replace(/\n{3,}/g,`
|
|
469
469
|
|
|
470
|
-
`).trim();return{hasSection:!0,todosMarkdown:i,remaining:a}}function cI({projectSlug:e,dependencies:t,blockedReason:n}){const[o,i]=g.useState(!1);if(t.length===0)return null;const a=t.filter(d=>d.status!=="completed"&&d.status!=="review"),c=a.length===0;return c&&!o?l.jsxs("button",{type:"button",onClick:()=>i(!0),className:"flex w-full items-center gap-2 rounded-lg border border-emerald-200 bg-emerald-50/50 px-4 py-2.5 text-left transition hover:bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/20 dark:hover:bg-emerald-950/30",children:[l.jsx(ep,{className:"h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400"}),l.jsxs("span",{className:"text-sm font-medium text-emerald-800 dark:text-emerald-300",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),l.jsx(Yi,{className:"ml-auto h-4 w-4 text-emerald-600 dark:text-emerald-400"})]}):l.jsxs("div",{className:"space-y-3",children:[a.length>0&&l.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 dark:border-amber-900 dark:bg-amber-950/30",children:[l.jsx(xf,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),l.jsxs("div",{className:"text-sm text-amber-800 dark:text-amber-300",children:[l.jsxs("strong",{children:[a.length," ",a.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&l.jsxs("p",{className:"mt-1 text-amber-700 dark:text-amber-400",children:["Blocked reason: ",n]})]})]}),l.jsx(Pe,{title:"Dependencies",description:`${t.length-a.length} of ${t.length} resolved`,actions:c?l.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:l.jsx("div",{className:"divide-y divide-border/40",children:t.map(d=>l.jsxs(Ce,{to:`/projects/${e}/assignments/${d.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(Ht,{status:d.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:d.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:d.slug})]}),d.assignee&&l.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:d.assignee}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},d.slug))})})]})}function uI({links:e}){const t=Lt();if(e.length===0)return null;const n=e.filter(i=>!i.isReverse),o=e.filter(i=>i.isReverse);return l.jsx(Pe,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:l.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(i=>l.jsxs(Ce,{to:`${t}/projects/${i.projectSlug}/assignments/${i.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(QS,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx(Ht,{status:i.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:i.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:i.slug})]}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${i.slug}`)),o.map(i=>l.jsxs(Ce,{to:`${t}/projects/${i.projectSlug}/assignments/${i.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(xv,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx(Ht,{status:i.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:i.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:i.slug})]}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${i.slug}`))]})})}function dI(e){const t=new Map;for(const o of e)t.set(o.id,{entry:o,replies:[]});const n=[];for(const o of e){const i=t.get(o.id);o.replyTo&&t.has(o.replyTo)?t.get(o.replyTo).replies.push(i):n.push(i)}return n}function fI(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function Hw({projectSlug:e,assignmentSlug:t,entries:n}){const[o,i]=g.useState(n);g.useEffect(()=>{i(n)},[n]);const a=g.useMemo(()=>dI(o),[o]),[c,d]=g.useState(""),[p,h]=g.useState("note"),[m,x]=g.useState(!1),[v,b]=g.useState(null);async function N(j){var A;if(j.preventDefault(),!c.trim())return;x(!0),b(null);const S=`tmp-${Date.now()}`,T={id:S,timestamp:new Date().toISOString(),author:"human",type:p,body:c,resolved:p==="question"?!1:void 0};i(L=>[...L,T]);try{const L=await fetch(fI(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:p})});if(!L.ok){const $=await L.text();throw new Error($||`HTTP ${L.status}`)}const O=await L.json().catch(()=>null),P=(A=O==null?void 0:O.comment)==null?void 0:A.id;i($=>$.map(E=>E.id===S?{...E,id:P??E.id}:E)),d(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(L){b(L instanceof Error?L.message:String(L)),i(O=>O.filter(P=>P.id!==S))}finally{x(!1)}}async function k(j,S){i(T=>T.map(A=>A.id===j?{...A,resolved:S}:A));try{const T=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(j)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(j)}/resolved`,A=await fetch(T,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:S})});if(!A.ok)throw new Error(`HTTP ${A.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),i(A=>A.map(L=>L.id===j?{...L,resolved:!S}:L))}}return l.jsx(Pe,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:l.jsxs("div",{className:"space-y-4",children:[a.map(j=>l.jsx(Ww,{node:j,onToggleResolved:k,depth:0},j.entry.id)),l.jsxs("form",{onSubmit:N,className:"mt-6 space-y-2 border-t border-neutral-800 pt-4",children:[l.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-neutral-400",children:"Add comment"}),l.jsx("textarea",{value:c,onChange:j=>d(j.target.value),className:"w-full rounded border border-neutral-700 bg-neutral-900 p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:p,onChange:j=>h(j.target.value),className:"rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-xs",children:[l.jsx("option",{value:"note",children:"note"}),l.jsx("option",{value:"question",children:"question"}),l.jsx("option",{value:"feedback",children:"feedback"})]}),l.jsx("button",{type:"submit",disabled:m||!c.trim(),className:"shell-action",children:m?"Posting…":"Post comment"}),v?l.jsx("span",{className:"text-xs text-red-400",children:v}):null]})]})]})})}function Ww({node:e,depth:t,onToggleResolved:n}){const{entry:o,replies:i}=e,a=o.type==="question";return l.jsxs("div",{className:$e("space-y-2",t>0&&"ml-4 border-l border-neutral-800 pl-4"),children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-neutral-400",children:[l.jsx("span",{className:"font-mono",children:o.id}),l.jsx("span",{children:"·"}),l.jsx("span",{children:o.timestamp}),l.jsx("span",{children:"·"}),l.jsx("span",{className:"font-medium text-neutral-200",children:o.author}),l.jsx("span",{children:"·"}),l.jsx("span",{className:$e("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",a&&"bg-amber-900/40 text-amber-200",o.type==="feedback"&&"bg-sky-900/40 text-sky-200",o.type==="note"&&"bg-neutral-800 text-neutral-300"),children:o.type}),a?l.jsxs("button",{type:"button",onClick:()=>n(o.id,!o.resolved),className:$e("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",o.resolved?"bg-emerald-900/40 text-emerald-200 hover:bg-emerald-900/60":"bg-neutral-800 text-neutral-300 hover:bg-neutral-700"),title:o.resolved?"Mark unresolved":"Mark resolved",children:[o.resolved?l.jsx(ep,{className:"h-3 w-3"}):l.jsx(eC,{className:"h-3 w-3"}),o.resolved?"resolved":"open"]}):null,o.replyTo?l.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[l.jsx(kC,{className:"h-3 w-3"}),o.replyTo]}):null]}),l.jsx(Ut,{content:o.body}),i.length>0?l.jsx("div",{className:"space-y-2",children:i.map(c=>l.jsx(Ww,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const pI=["review","complete","unblock","start","block","fail","reopen"];function Sy(){var mn,Pn,Tn,re,le,pe;const{slug:e,aslug:t}=Et(),n=Xt(),o=Lt(),[i,a]=_s(),[c,d]=g.useState(null),[p,h]=g.useState(null),[m,x]=g.useState(null),[v,b]=g.useState(null),[N,k]=g.useState(null),[j,S]=g.useState(!1),[T,A]=g.useState(!1),[L,O]=g.useState(0),P=i.get("tab")??"summary",$=bc(),{data:E,loading:H,error:Z,refetch:G}=wN(e,t),{data:q}=Hv(e),{data:Y}=ap(),{data:X}=SN(e,t),_=g.useMemo(()=>{if(!E||!q)return[];const ne=new Map(q.assignments.map(me=>[me.slug,me]));return E.dependsOn.map(me=>{const ke=ne.get(me);return{slug:me,title:(ke==null?void 0:ke.title)??me,status:(ke==null?void 0:ke.status)??"pending",priority:(ke==null?void 0:ke.priority)??"medium",assignee:(ke==null?void 0:ke.assignee)??null}})},[E,q]),D=_.filter(ne=>ne.status!=="completed"&&ne.status!=="review");zs("assignment");const V=g.useMemo(()=>((q==null?void 0:q.assignments)??[]).map(ne=>ne.slug),[q]),W=t?V.indexOf(t):-1,ee=W>0?V[W-1]:null,R=W>=0&&W<V.length-1?V[W+1]:null,F=`${o}/projects/${e}/assignments/${t}`;yt({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${F}/edit`)}),yt({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${F}/plan/edit`)}),yt({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${F}/handoff/edit`)}),yt({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${F}/decision-record/edit`)}),yt({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${F}/scratchpad/edit`)}),yt({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ee,handler:()=>ee&&n(`${o}/projects/${e}/assignments/${ee}`)}),yt({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!R,handler:()=>R&&n(`${o}/projects/${e}/assignments/${R}`)});const J=g.useMemo(()=>E?lI(E.body):{acceptanceCriteria:[],summaryBody:""},[E]),I=g.useMemo(()=>aI(J.summaryBody),[J.summaryBody]),de=J.acceptanceCriteria,ve=de.filter(ne=>ne.checked).length,fe=de.length>0&&ve===de.length,Ee=g.useRef(fe),Ne=g.useRef(!1);if(g.useEffect(()=>{if(E){if(!Ne.current){Ee.current=fe,Ne.current=!0;return}fe&&!Ee.current&&O(ne=>ne+1),Ee.current=fe}},[fe,E]),H)return l.jsx(jt,{label:"Loading assignment workspace…"});if(Z||!E||!e||!t)return l.jsx(vt,{error:Z||"Assignment not found."});const Re=e,je=t,ut=de.length>0?{checked:ve,total:de.length}:void 0,tt=E.availableTransitions??[],Ue=tt.filter(ne=>!ne.disabled&&ne.targetStatus!==E.status),Be=pI.map(ne=>Ue.find(me=>me.command===ne)).find(Boolean)??Ue[0]??null,St=[];if(Y!=null&&Y.sessions)for(const ne of Y.sessions)for(const me of ne.windows)for(const ke of me.panes)((mn=ke.assignment)==null?void 0:mn.project)===e&&((Pn=ke.assignment)==null?void 0:Pn.slug)===t&&St.push({sessionName:ne.name,command:ke.command,urls:ke.urls});async function Ot(ne){d(null);try{await Bw(Re,je,ne),G()}catch(me){d(me.message)}}async function cn(){A(!0);try{await iI(Re,je),n(`${o}/projects/${Re}`)}catch(ne){d(ne.message),A(!1),S(!1)}}async function hn(ne,me){d(null),h(ne.command);try{return await zw(Re,je,ne,me),G(),!0}catch(ke){return d(ke.message),!1}finally{h(null)}}function Xe(ne){if(Uw(ne)){x(ne);return}hn(ne)}async function nt(ne,me){b(null),k(ne);try{const ke=await fetch(`/api/projects/${Re}/assignments/${je}/acceptance-criteria/${ne}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:me})}),_t=await ke.json();if(!ke.ok)throw new Error(_t.error||`HTTP ${ke.status}`);G()}catch(ke){b(ke.message)}finally{k(null)}}const Wt=[...Ue.filter(ne=>ne!==Be).map(ne=>({key:`transition-${ne.command}`,label:ne.label,onSelect:()=>Xe(ne),disabled:p===ne.command})),...tt.filter(ne=>ne.disabled||ne.targetStatus===E.status).map(ne=>({key:`transition-${ne.command}`,label:ne.label,disabled:!0,disabledReason:ne.targetStatus===E.status?`Already ${E.status.replace(/_/g," ")}`:ne.disabledReason??ne.warning??ne.description})),...$.statuses.map(ne=>({key:`override-${ne.id}`,label:`Override → ${ne.label}`,onSelect:()=>Ot(ne.id),disabled:ne.id===E.status,disabledReason:ne.id===E.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:aC,href:`${o}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:CC,href:`${o}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:Rd,href:`${o}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:Ka,href:`${o}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:pC,href:`${o}/projects/${e}/assignments/${t}/decision-record/edit`},{key:"delete",label:"Delete assignment",icon:Ms,destructive:!0,onSelect:()=>S(!0)}],Qt=(Be==null?void 0:Be.command)==="review";return l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx(Ht,{status:E.status,progress:ut}),l.jsx("h1",{className:"text-lg font-semibold text-foreground",children:E.title}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",pN(E.updated)]}),D.length>0&&l.jsxs("span",{className:"text-xs text-amber-700 dark:text-amber-300",children:["⚠ ",D.length," unmet dep",D.length===1?"":"s"]}),l.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[Be&&l.jsx("button",{type:"button",title:Be.warning||Be.description,disabled:p===Be.command,onClick:()=>Xe(Be),className:$e("shell-action disabled:cursor-not-allowed disabled:opacity-50",Be.warning&&"border-amber-300 dark:border-amber-700",Qt&&L>0&&"send-to-review-glow"),children:l.jsx("span",{children:p===Be.command?"Working…":Be.label})},Qt?`review-${L}`:Be.command),l.jsx(sI,{items:Wt,align:"end"})]})]}),c?l.jsx("p",{className:"mt-4 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:c}):null,E.blockedReason?l.jsxs("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300",children:[l.jsx("strong",{children:"Blocked reason:"})," ",E.blockedReason]}):null]}),_.length>0&&l.jsx(cI,{projectSlug:e,dependencies:_,blockedReason:E.blockedReason}),E.enrichedLinks&&E.enrichedLinks.length>0&&l.jsx(uI,{links:E.enrichedLinks}),E.referencedBy&&E.referencedBy.length>0&&l.jsx(Pe,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:l.jsx("ul",{className:"space-y-2",children:E.referencedBy.map(ne=>{const me=ne.sourceProjectSlug===null?`/assignments/${ne.sourceId}`:`${o}/projects/${ne.sourceProjectSlug}/assignments/${ne.sourceSlug}`;return l.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[l.jsx(Ce,{to:me,className:"text-foreground hover:text-primary",children:ne.sourceTitle}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",ne.mentions," mention",ne.mentions===1?"":"s",")"]}),ne.sourceProjectSlug===null?l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"}):null]},ne.sourceId)})})}),l.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_280px]",children:[l.jsx("div",{className:"space-y-4",children:l.jsx(Cp,{value:P,onValueChange:ne=>a({tab:ne}),items:[{value:"summary",label:"Summary",content:l.jsxs("div",{className:"space-y-5",children:[J.acceptanceCriteria.length>0?l.jsx(Pe,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:l.jsxs("div",{className:"space-y-3",children:[v?l.jsx("p",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:v}):null,J.acceptanceCriteria.map((ne,me)=>{const ke=N!==null;return l.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[l.jsx("input",{type:"checkbox",checked:ne.checked,disabled:ke,onChange:_t=>nt(me,_t.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),l.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":ne.checked,children:ne.text})]},`${me}-${ne.text}`)})]})}):null,I.hasSection?l.jsx(Pe,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:l.jsx(Ut,{content:I.todosMarkdown,emptyState:"No todos yet."})}):null,l.jsx(Pe,{title:"Assignment Summary",children:l.jsx(Ut,{content:I.remaining,emptyState:J.acceptanceCriteria.length>0||I.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:E.plan?1:0,content:E.plan?l.jsx("div",{className:"space-y-5",children:l.jsxs(Pe,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:l.jsxs(Ce,{className:"shell-action",to:`${o}/projects/${e}/assignments/${t}/plan/edit`,children:[l.jsx(Rd,{className:"h-4 w-4"}),l.jsx("span",{children:"Edit Plan"})]}),children:[l.jsx("div",{className:"mb-4",children:l.jsx(Ht,{status:E.plan.status})}),l.jsx(Ut,{content:E.plan.body,emptyState:"No plan content yet."})]})}):l.jsx(Ge,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:E.scratchpad?1:0,content:E.scratchpad?l.jsx(Pe,{title:"Scratchpad",actions:l.jsxs(Ce,{className:"shell-action",to:`${o}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[l.jsx(Rd,{className:"h-4 w-4"}),l.jsx("span",{children:"Edit Scratchpad"})]}),children:l.jsx(Ut,{content:E.scratchpad.body,emptyState:"Scratchpad is empty."})}):l.jsx(Ge,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((Tn=E.handoff)==null?void 0:Tn.handoffCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.handoff?l.jsx(Pe,{children:l.jsx(Ut,{content:E.handoff.body,emptyState:"No handoff history yet."})}):l.jsx(Ge,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((re=E.progress)==null?void 0:re.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.progress&&E.progress.entries.length>0?l.jsx(Pe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:l.jsx("ol",{className:"space-y-4",children:E.progress.entries.map((ne,me)=>l.jsxs("li",{className:"border-l-2 border-neutral-700 pl-3",children:[l.jsx("div",{className:"text-xs font-mono text-neutral-400",children:ne.timestamp}),l.jsx(Ut,{content:ne.body})]},`${ne.timestamp}-${me}`))})}):l.jsx(Ge,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((le=E.comments)==null?void 0:le.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.comments&&E.comments.entries.length>0?l.jsx(Hw,{projectSlug:e,assignmentSlug:t,entries:E.comments.entries}):l.jsx(Ge,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((pe=E.decisionRecord)==null?void 0:pe.decisionCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.decisionRecord?l.jsx(Pe,{children:l.jsx(Ut,{content:E.decisionRecord.body,emptyState:"No decision history yet."})}):l.jsx(Ge,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),l.jsxs("div",{className:"space-y-5",children:[l.jsx(Pe,{title:"Details",children:l.jsxs("dl",{className:"space-y-3 text-sm",children:[l.jsx(vo,{label:"ID",value:E.id,copyable:!0}),l.jsx(vo,{label:"Priority",value:E.priority}),E.assignee&&l.jsx(vo,{label:"Assignee",value:E.assignee}),l.jsx(vo,{label:"Updated",value:`${fN(E.updated)} · Created ${dN(E.created)}`}),E.workspace.repository&&l.jsx(vo,{label:"Repository",value:E.workspace.repository,copyable:!0}),E.workspace.worktreePath&&l.jsx(vo,{label:"Worktree",value:E.workspace.worktreePath,copyable:!0}),E.workspace.branch&&l.jsx(vo,{label:"Branch",value:E.workspace.branch,copyable:!0}),E.workspace.parentBranch&&l.jsx(vo,{label:"Parent branch",value:E.workspace.parentBranch,copyable:!0})]})}),St.length>0&&l.jsx(Pe,{title:"Servers",children:l.jsx("div",{className:"space-y-2",children:St.map((ne,me)=>l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:ne.command}),l.jsx("span",{className:"text-xs text-muted-foreground",children:ne.sessionName}),ne.urls.map(ke=>l.jsxs("a",{href:ke,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-teal-600 hover:underline dark:text-teal-400",children:[ke.replace("http://localhost:",":"),l.jsx(bv,{className:"h-2.5 w-2.5"})]},ke))]},me))})}),X&&X.sessions.length>0&&l.jsx(Pe,{title:"Agent Sessions",children:l.jsx("div",{className:"space-y-2",children:X.sessions.map(ne=>l.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(uc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"font-medium text-foreground",children:ne.agent}),l.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:ne.sessionId,children:[ne.sessionId.slice(0,8),l.jsx(Hr,{value:ne.sessionId})]})]}),l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(Ht,{status:ne.status}),l.jsx("span",{className:"text-xs text-muted-foreground",children:Cr(ne.started)})]})]},ne.sessionId))})})]})]}),l.jsx(Ib,{open:m!==null,action:m,assignmentTitle:E.title,loading:p===(m==null?void 0:m.command),onOpenChange:ne=>{ne||x(null)},onConfirm:async ne=>{if(!m)return;await hn(m,ne)&&x(null)}}),l.jsx(ow,{open:j,title:"Delete assignment?",description:`This will permanently delete "${E.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:T,onOpenChange:ne=>{ne||S(!1)},onConfirm:cn})]})}function vo({label:e,value:t,copyable:n}){return l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx("dt",{className:"text-muted-foreground",children:e}),l.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[l.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&l.jsx(Hr,{value:t})]})]})}function hI(){var d,p,h,m,x;const{id:e}=Et(),[t,n]=_s(),o=t.get("tab")??"summary",{data:i,loading:a,error:c}=kN(e);return a?l.jsx(jt,{}):c?l.jsx(vt,{error:c}):i?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("header",{className:"space-y-2",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("span",{className:"rounded bg-neutral-800 px-2 py-0.5 font-mono text-xs uppercase tracking-wide text-neutral-300",children:"Standalone"}),l.jsx(Ht,{status:i.status}),l.jsx("span",{className:"text-xs font-mono text-neutral-500",children:i.id}),l.jsx(Ce,{to:`/assignments/${i.id}/edit`,className:"ml-auto rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit"})]}),l.jsx("h1",{className:"text-2xl font-semibold text-neutral-100",children:i.title}),i.blockedReason?l.jsxs("p",{className:"text-sm text-amber-300",children:["Blocked: ",i.blockedReason]}):null]}),i.referencedBy&&i.referencedBy.length>0?l.jsx(Pe,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:l.jsx("ul",{className:"space-y-2",children:i.referencedBy.map(v=>l.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[l.jsx(Ce,{to:v.sourceProjectSlug===null?`/assignments/${v.sourceId}`:`/projects/${v.sourceProjectSlug}/assignments/${v.sourceSlug}`,className:"text-foreground hover:text-primary",children:v.sourceTitle}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",v.mentions," mention",v.mentions===1?"":"s",")"]})]},v.sourceId))})}):null,l.jsx(Cp,{value:o,onValueChange:v=>n({tab:v}),items:[{value:"summary",label:"Summary",content:l.jsx("div",{className:"space-y-5",children:l.jsx(Pe,{title:"Assignment",children:l.jsx(Ut,{content:i.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((d=i.progress)==null?void 0:d.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.progress&&i.progress.entries.length>0?l.jsx(Pe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:l.jsx("ol",{className:"space-y-4",children:i.progress.entries.map((v,b)=>l.jsxs("li",{className:"border-l-2 border-neutral-700 pl-3",children:[l.jsx("div",{className:"text-xs font-mono text-neutral-400",children:v.timestamp}),l.jsx(Ut,{content:v.body})]},`${v.timestamp}-${b}`))})}):l.jsx(Ge,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((p=i.comments)==null?void 0:p.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:l.jsx(Hw,{projectSlug:null,assignmentSlug:i.id,entries:((h=i.comments)==null?void 0:h.entries)??[]})})},{value:"plan",label:"Plan",content:l.jsx("div",{className:"space-y-5",children:i.plan?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.plan.body,emptyState:"Plan file exists but is empty."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/plan/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit plan"})})]}):l.jsx(Ge,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:l.jsx("div",{className:"space-y-5",children:i.scratchpad?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.scratchpad.body,emptyState:"Scratchpad is empty."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/scratchpad/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit scratchpad"})})]}):l.jsx(Ge,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((m=i.handoff)==null?void 0:m.handoffCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.handoff?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.handoff.body,emptyState:"No handoff history yet."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/handoff/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Append handoff"})})]}):l.jsx(Ge,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((x=i.decisionRecord)==null?void 0:x.decisionCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.decisionRecord?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.decisionRecord.body,emptyState:"No decision history yet."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/decision-record/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Append decision"})})]}):l.jsx(Ge,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]})]}):l.jsx(vt,{error:"Assignment not found"})}const mI=["table","list","kanban"],Cy={critical:0,high:1,medium:2,low:3};function Ny(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function gI(e,t){return e.toString()===t.toString()}function Ey(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}function xI(e,t,n){return[...e].sort((i,a)=>{let c=0;switch(t){case"title":c=i.title.localeCompare(a.title);break;case"status":c=i.status.localeCompare(a.status);break;case"priority":c=(Cy[i.priority]??99)-(Cy[a.priority]??99);break;case"assignee":c=(i.assignee??"").localeCompare(a.assignee??"");break;case"dependencies":c=i.dependsOn.length-a.dependsOn.length;break;case"updated":c=i.updated.localeCompare(a.updated);break}return n==="asc"?c:-c})}function Ry(){const{workspace:e}=Et(),t=Lt(),n=Xt(),o=g.useRef(null);zs("list:assignments");const{data:i,loading:a,error:c,refetch:d}=Bv(),p=bc(),[h,m]=_s(),x=g.useMemo(()=>YE(p.order),[p]),v=g.useMemo(()=>{const U={};for(const ae of x)U[ae]=VE(p,ae);return U},[x,p]),b=g.useMemo(()=>x.map(U=>({id:U,title:v[U]??U,description:D0(U)})),[x,v]),N=g.useMemo(()=>new Set(["all",...x]),[x]),k=h.get("view"),j=h.get("status"),S=h.get("stale"),T=k&&mI.includes(k)?k:"kanban";function A(U){return!U||!N.has(U)?"all":U}const L=g.useCallback(U=>{m(ae=>{const ge=new URLSearchParams(ae);return U==="kanban"?ge.delete("view"):ge.set("view",U),ge})},[m]),[O,P]=g.useState(""),[$,E]=g.useState(()=>A(j)),[H,Z]=g.useState("all"),[G,q]=g.useState("all"),[Y,X]=g.useState("all"),[_,D]=g.useState(()=>Ny(S)),[V,W]=g.useState("updated"),[ee,R]=g.useState("desc"),[F,J]=g.useState(()=>new Set(x)),[I,de]=g.useState([]),[ve,fe]=g.useState(null),[Ee,Ne]=g.useState(null),[Re,je]=g.useState(null),[ut,tt]=g.useState(null),[Ue,Be]=g.useState(null);g.useEffect(()=>{de((i==null?void 0:i.assignments)??[])},[i]),g.useEffect(()=>{const U=A(j);U!==$&&E(U);const ae=Ny(S);ae!==_&&D(ae)},[_,S,$,j]),g.useEffect(()=>{m(U=>{const ae=new URLSearchParams(U);return $==="all"?ae.delete("status"):ae.set("status",$),_==="all"?ae.delete("stale"):_==="stale"?ae.set("stale","1"):ae.set("stale","0"),gI(U,ae)?U:ae})},[_,m,$]);const St=g.useMemo(()=>Array.from(new Set(I.map(U=>U.status))).sort(),[I]),Ot=g.useMemo(()=>Array.from(new Set(I.map(U=>U.priority))).sort(),[I]),cn=g.useMemo(()=>Array.from(new Set(I.map(U=>U.assignee??"__unassigned__"))).sort(),[I]),hn=g.useMemo(()=>Array.from(new Map(I.filter(U=>U.projectSlug!==null).map(U=>[U.projectSlug,U.projectTitle]))).sort(([,U],[,ae])=>U.localeCompare(ae)),[I]),Xe=g.useMemo(()=>I.filter(U=>{if(e){if(e==="_ungrouped"){if(U.projectWorkspace!==null)return!1}else if(U.projectWorkspace!==e)return!1}if($!=="all"&&U.status!==$||H!=="all"&&U.priority!==H||_==="stale"&&!Ey(U.updated)||_==="fresh"&&Ey(U.updated)||G!=="all"&&(U.assignee??"__unassigned__")!==G)return!1;if(Y!=="all"){if(Y==="__standalone__"){if(U.projectSlug!==null)return!1}else if(U.projectSlug!==Y)return!1}const ae=O.trim().toLowerCase();return!(ae&&!`${U.title} ${U.slug} ${U.projectTitle??"standalone"} ${U.projectSlug??""}`.toLowerCase().includes(ae))}),[_,I,O,$,H,G,Y,e]),nt=g.useMemo(()=>xI(Xe,V,ee),[Xe,V,ee]),{visibleItems:Wt,visibleIndexByKey:Qt}=g.useMemo(()=>{const U=T==="table"?nt:x.flatMap(ge=>Xe.filter(Oe=>Oe.status===ge)),ae=new Map;return U.forEach((ge,Oe)=>ae.set(Yt(ge),Oe)),{visibleItems:U,visibleIndexByKey:ae}},[T,nt,Xe,x]),{hotkeyRowProps:mn}=yc(Wt,{scope:"list:assignments",onOpen:U=>{if(U.projectSlug===null){n(`/assignments/${U.id}`);return}const ae=U.projectWorkspace?`/w/${U.projectWorkspace}`:t;n(`${ae}/projects/${U.projectSlug}/assignments/${U.slug}`)}});if(yt({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var U;return(U=o.current)==null?void 0:U.focus()}}),yt({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>d()}),a)return l.jsx(jt,{label:"Loading assignments board…"});if(c||!i)return l.jsx(vt,{error:c||"Assignments board is unavailable."});async function Pn({item:U,toColumnId:ae,action:ge,reason:Oe}){fe(null),Ne(Yt(U));const zn=I;de(Zt=>Zt.map(dt=>Yt(dt)===Yt(U)?{...dt,status:ae,blockedReason:ae==="blocked"?Oe??dt.blockedReason:null}:dt));try{if(U.projectSlug===null){if(!ge)throw new Error("Standalone assignments require a transition action, not status override.");const dt=await fetch(`/api/assignments/${encodeURIComponent(U.id)}/transitions/${encodeURIComponent(ge.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Oe?{reason:Oe}:{})});if(!dt.ok)throw new Error((await dt.json()).error??`HTTP ${dt.status}`);const Ye=(await dt.json()).assignment;de(bt=>bt.map(Mt=>Yt(Mt)===Yt(U)?{...Mt,status:Ye.status,blockedReason:Ye.blockedReason,availableTransitions:Ye.availableTransitions,updated:Ye.updated}:Mt));return}const Zt=ge?await zw(U.projectSlug,U.slug,ge,Oe):await Bw(U.projectSlug,U.slug,ae);return de(dt=>dt.map(Fe=>Yt(Fe)===Yt(U)?{...Fe,status:Zt.status,blockedReason:Zt.blockedReason,availableTransitions:Zt.availableTransitions,updated:Zt.updated}:Fe)),d(),!0}catch(Zt){return de(zn),fe(Zt.message),!1}finally{Ne(null)}}async function Tn({item:U,toColumnId:ae}){if(U.status===ae)return;const ge=_i(U,ae);if(ge!=null&&ge.disabled){fe(ge.disabledReason||`Cannot move this assignment to ${ae}.`);return}if(ge&&Uw(ge)){Be({item:U,toColumnId:ae,action:ge});return}await Pn({item:U,toColumnId:ae,action:ge})}function re(U){J(ae=>{const ge=new Set(ae);return ge.has(U)?ge.delete(U):ge.add(U),ge})}function le(U){V===U?R(ae=>ae==="asc"?"desc":"asc"):(W(U),R("asc"))}const pe=Re?I.find(U=>Yt(U)===Re)??null:null;function ne(U,ae){U.dataTransfer.effectAllowed="move",U.dataTransfer.setData("text/plain",ae),je(ae)}function me(){je(null),tt(null)}function ke(U,ae){if(!pe)return;const ge=_i(pe,ae);pe.status===ae||ge!=null&&ge.disabled||(U.preventDefault(),U.dataTransfer.dropEffect="move",tt(ae))}function _t(U,ae){ut===ae&&!U.currentTarget.contains(U.relatedTarget)&&tt(null)}function Jt(U,ae){if(U.preventDefault(),!pe||pe.status===ae){me();return}me(),Tn({item:pe,toColumnId:ae})}function Vt({field:U,children:ae}){const ge=V===U;return l.jsx("th",{className:"pb-3 font-medium",children:l.jsxs("button",{type:"button",onClick:()=>le(U),className:"inline-flex items-center gap-1 hover:text-foreground",children:[ae,ge?ee==="asc"?l.jsx(vv,{className:"h-3 w-3"}):l.jsx(Yi,{className:"h-3 w-3"}):null]})})}return l.jsxs("div",{className:"space-y-5",children:[l.jsxs(wp,{children:[l.jsx(vc,{ref:o,value:O,onChange:P,placeholder:"Search assignments or projects"}),l.jsxs("select",{value:$,onChange:U=>E(A(U.target.value)),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All statuses"}),St.map(U=>l.jsx("option",{value:U,children:v[U]??U},U))]}),l.jsxs("select",{value:H,onChange:U=>Z(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All priorities"}),Ot.map(U=>l.jsx("option",{value:U,className:"capitalize",children:U},U))]}),l.jsxs("select",{value:G,onChange:U=>q(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All assignees"}),cn.map(U=>l.jsx("option",{value:U,children:U==="__unassigned__"?"Unassigned":U},U))]}),l.jsxs("select",{value:Y,onChange:U=>X(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All projects"}),l.jsx("option",{value:"__standalone__",children:"Standalone"}),hn.map(([U,ae])=>l.jsx("option",{value:U,children:ae},U))]}),l.jsxs("select",{value:_,onChange:U=>D(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All activity"}),l.jsx("option",{value:"stale",children:"Stale only"}),l.jsx("option",{value:"fresh",children:"Fresh only"})]}),l.jsx(kp,{value:T,onChange:U=>L(U),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]})]}),ve?l.jsx("div",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:ve}):null,i.assignments.length===0?l.jsx(Ge,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:l.jsxs(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:`${t}/projects`,children:[l.jsx(np,{className:"h-4 w-4"}),l.jsx("span",{children:"Browse Projects"})]})}):Xe.length===0?l.jsx(Ge,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):T==="table"?l.jsx(Pe,{title:`${nt.length} assignment${nt.length===1?"":"s"}`,children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[l.jsx(Vt,{field:"title",children:"Assignment"}),l.jsx(Vt,{field:"status",children:"Status"}),l.jsx(Vt,{field:"priority",children:"Priority"}),l.jsx(Vt,{field:"assignee",children:"Assignee"}),l.jsx(Vt,{field:"dependencies",children:"Dependencies"}),l.jsx(Vt,{field:"updated",children:"Updated"})]})}),l.jsx("tbody",{children:nt.map((U,ae)=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",...mn(ae),children:[l.jsxs("td",{className:"py-4 pr-4",children:[l.jsx(Ce,{to:U.projectSlug===null?`/assignments/${U.id}`:`${t}/projects/${U.projectSlug}/assignments/${U.slug}`,className:"font-semibold text-foreground hover:text-primary",children:U.title}),l.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:U.projectTitle??l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"})}),l.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:U.id,children:[U.id.slice(0,8),l.jsx(Hr,{value:U.id})]})]}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx("select",{value:U.status,disabled:Ee===Yt(U),onChange:ge=>Tn({item:U,toColumnId:ge.target.value}),className:$e("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(Ya[U.status]??Ya.pending).className,Ee===Yt(U)&&"animate-pulse opacity-60"),children:x.map(ge=>{const Oe=U.status===ge?void 0:_i(U,ge),zn=(Oe==null?void 0:Oe.disabled)??!1;return l.jsx("option",{value:ge,disabled:zn,title:zn?(Oe==null?void 0:Oe.disabledReason)??void 0:void 0,children:v[ge]},ge)})})}),l.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:U.priority}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:U.assignee??"Unassigned"}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:U.dependsOn.length}),l.jsx("td",{className:"py-4 text-muted-foreground",children:Vr(U.updated)})]},Yt(U)))})]})})}):T==="list"?l.jsx("div",{className:"space-y-3",children:x.map(U=>{var dt;const ae=Xe.filter(Fe=>Fe.status===U);if(ae.length===0&&!pe)return null;const ge=F.has(U),Oe=pe?pe.status!==U&&!((dt=_i(pe,U))!=null&&dt.disabled):!1,zn=pe?pe.status!==U&&!Oe:!1,Zt=ut===U;return l.jsxs("div",{className:$e("rounded-lg border border-border/60 bg-card/90 transition",Zt&&Oe&&"ring-2 ring-ring/30",zn&&"border-dashed opacity-65"),onDragOver:Fe=>ke(Fe,U),onDragLeave:Fe=>_t(Fe,U),onDrop:Fe=>Jt(Fe,U),children:[l.jsxs("button",{type:"button",onClick:()=>re(U),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[l.jsx(Yi,{className:`h-4 w-4 text-muted-foreground transition-transform ${ge?"":"-rotate-90"}`}),l.jsx("span",{className:"font-semibold text-foreground",children:v[U]}),l.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:ae.length})]}),ge&&ae.length>0&&l.jsx("div",{className:"space-y-3 px-4 pb-4",children:ae.map(Fe=>{const Ye=Yt(Fe),bt=Re===Ye,Mt=Qt.get(Ye)??-1;return l.jsx("div",{draggable:!0,onDragStart:qt=>ne(qt,Ye),onDragEnd:me,...Mt>=0?mn(Mt):{},className:$e("cursor-grab transition active:cursor-grabbing",bt&&"scale-[0.98] opacity-50"),children:l.jsx(Py,{assignment:Fe,dragging:bt,transitioning:Ee===Ye})},Ye)})})]},U)})}):l.jsx(I0,{columns:b,items:Xe,getItemId:Yt,getColumnId:U=>U.status,canDrop:({item:U,fromColumnId:ae,toColumnId:ge})=>{if(ae===ge)return{allowed:!0};const Oe=_i(U,ge);return Oe!=null&&Oe.disabled?{allowed:!1,reason:Oe.disabledReason||Oe.description}:{allowed:!0,reason:Oe?Oe.warning||Oe.description:`Move to ${ge} (direct status change).`}},onMove:({item:U,toColumnId:ae})=>Tn({item:U,toColumnId:ae}),emptyMessage:U=>`No ${U.title.toLowerCase()} assignments.`,renderCard:(U,{dragging:ae})=>{const ge=Qt.get(Yt(U))??-1;return l.jsx("div",{...ge>=0?mn(ge):{},children:l.jsx(Py,{assignment:U,dragging:ae,transitioning:Ee===Yt(U)})})}}),l.jsx(Ib,{open:Ue!==null,action:(Ue==null?void 0:Ue.action)??null,assignmentTitle:(Ue==null?void 0:Ue.item.title)??"Assignment",loading:Ee===(Ue?Yt(Ue.item):null),onOpenChange:U=>{U||Be(null)},onConfirm:async U=>{if(!Ue)return;const ae=Ue;await Pn({item:ae.item,toColumnId:ae.toColumnId,action:ae.action,reason:U})&&Be(null)}})]})}function Py({assignment:e,dragging:t,transitioning:n}){var i;const o=Lt();return l.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(Ce,{to:e.projectSlug===null?`/assignments/${e.id}`:`${o}/projects/${e.projectSlug}/assignments/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"})}),l.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(i=e.id)==null?void 0:i.slice(0,8),e.id&&l.jsx(Hr,{value:e.id})]})]}),l.jsx(Ht,{status:e.status})]}),e.blockedReason?l.jsx("p",{className:"mt-3 rounded-md border border-amber-200/70 bg-amber-50/80 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/70 dark:bg-amber-950/20 dark:text-amber-300",children:e.blockedReason}):null,l.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[l.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),l.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),l.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),l.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),l.jsx("span",{children:Vr(e.updated)})]})]})}function _i(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function Yt(e){return e.id||e.slug||"unknown"}function Tr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],o=e.slice(t[0].length),i=n.split(`
|
|
470
|
+
`).trim();return{hasSection:!0,todosMarkdown:i,remaining:a}}function cI({projectSlug:e,dependencies:t,blockedReason:n}){const[o,i]=g.useState(!1);if(t.length===0)return null;const a=t.filter(d=>d.status!=="completed"&&d.status!=="review"),c=a.length===0;return c&&!o?l.jsxs("button",{type:"button",onClick:()=>i(!0),className:"flex w-full items-center gap-2 rounded-lg border border-emerald-200 bg-emerald-50/50 px-4 py-2.5 text-left transition hover:bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/20 dark:hover:bg-emerald-950/30",children:[l.jsx(ep,{className:"h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400"}),l.jsxs("span",{className:"text-sm font-medium text-emerald-800 dark:text-emerald-300",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),l.jsx(Yi,{className:"ml-auto h-4 w-4 text-emerald-600 dark:text-emerald-400"})]}):l.jsxs("div",{className:"space-y-3",children:[a.length>0&&l.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 dark:border-amber-900 dark:bg-amber-950/30",children:[l.jsx(xf,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),l.jsxs("div",{className:"text-sm text-amber-800 dark:text-amber-300",children:[l.jsxs("strong",{children:[a.length," ",a.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&l.jsxs("p",{className:"mt-1 text-amber-700 dark:text-amber-400",children:["Blocked reason: ",n]})]})]}),l.jsx(Pe,{title:"Dependencies",description:`${t.length-a.length} of ${t.length} resolved`,actions:c?l.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:l.jsx("div",{className:"divide-y divide-border/40",children:t.map(d=>l.jsxs(Ce,{to:`/projects/${e}/assignments/${d.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(Ht,{status:d.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:d.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:d.slug})]}),d.assignee&&l.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:d.assignee}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},d.slug))})})]})}function uI({links:e}){const t=Lt();if(e.length===0)return null;const n=e.filter(i=>!i.isReverse),o=e.filter(i=>i.isReverse);return l.jsx(Pe,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:l.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(i=>l.jsxs(Ce,{to:`${t}/projects/${i.projectSlug}/assignments/${i.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(QS,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx(Ht,{status:i.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:i.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:i.slug})]}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${i.slug}`)),o.map(i=>l.jsxs(Ce,{to:`${t}/projects/${i.projectSlug}/assignments/${i.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[l.jsx(xv,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx(Ht,{status:i.status}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:i.title}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:i.slug})]}),l.jsx(Ka,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${i.slug}`))]})})}function dI(e){const t=new Map;for(const o of e)t.set(o.id,{entry:o,replies:[]});const n=[];for(const o of e){const i=t.get(o.id);o.replyTo&&t.has(o.replyTo)?t.get(o.replyTo).replies.push(i):n.push(i)}return n}function fI(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function Hw({projectSlug:e,assignmentSlug:t,entries:n}){const[o,i]=g.useState(n);g.useEffect(()=>{i(n)},[n]);const a=g.useMemo(()=>dI(o),[o]),[c,d]=g.useState(""),[p,h]=g.useState("note"),[m,x]=g.useState(!1),[v,b]=g.useState(null);async function N(j){var A;if(j.preventDefault(),!c.trim())return;x(!0),b(null);const S=`tmp-${Date.now()}`,T={id:S,timestamp:new Date().toISOString(),author:"human",type:p,body:c,resolved:p==="question"?!1:void 0};i(L=>[...L,T]);try{const L=await fetch(fI(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:p})});if(!L.ok){const $=await L.text();throw new Error($||`HTTP ${L.status}`)}const O=await L.json().catch(()=>null),P=(A=O==null?void 0:O.comment)==null?void 0:A.id;i($=>$.map(E=>E.id===S?{...E,id:P??E.id}:E)),d(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(L){b(L instanceof Error?L.message:String(L)),i(O=>O.filter(P=>P.id!==S))}finally{x(!1)}}async function k(j,S){i(T=>T.map(A=>A.id===j?{...A,resolved:S}:A));try{const T=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(j)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(j)}/resolved`,A=await fetch(T,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:S})});if(!A.ok)throw new Error(`HTTP ${A.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),i(A=>A.map(L=>L.id===j?{...L,resolved:!S}:L))}}return l.jsx(Pe,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:l.jsxs("div",{className:"space-y-4",children:[a.map(j=>l.jsx(Ww,{node:j,onToggleResolved:k,depth:0},j.entry.id)),l.jsxs("form",{onSubmit:N,className:"mt-6 space-y-2 border-t border-neutral-800 pt-4",children:[l.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-neutral-400",children:"Add comment"}),l.jsx("textarea",{value:c,onChange:j=>d(j.target.value),className:"w-full rounded border border-neutral-700 bg-neutral-900 p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:p,onChange:j=>h(j.target.value),className:"rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-xs",children:[l.jsx("option",{value:"note",children:"note"}),l.jsx("option",{value:"question",children:"question"}),l.jsx("option",{value:"feedback",children:"feedback"})]}),l.jsx("button",{type:"submit",disabled:m||!c.trim(),className:"shell-action",children:m?"Posting…":"Post comment"}),v?l.jsx("span",{className:"text-xs text-red-400",children:v}):null]})]})]})})}function Ww({node:e,depth:t,onToggleResolved:n}){const{entry:o,replies:i}=e,a=o.type==="question";return l.jsxs("div",{className:$e("space-y-2",t>0&&"ml-4 border-l border-neutral-800 pl-4"),children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-neutral-400",children:[l.jsx("span",{className:"font-mono",children:o.id}),l.jsx("span",{children:"·"}),l.jsx("span",{children:o.timestamp}),l.jsx("span",{children:"·"}),l.jsx("span",{className:"font-medium text-neutral-200",children:o.author}),l.jsx("span",{children:"·"}),l.jsx("span",{className:$e("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",a&&"bg-amber-900/40 text-amber-200",o.type==="feedback"&&"bg-sky-900/40 text-sky-200",o.type==="note"&&"bg-neutral-800 text-neutral-300"),children:o.type}),a?l.jsxs("button",{type:"button",onClick:()=>n(o.id,!o.resolved),className:$e("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",o.resolved?"bg-emerald-900/40 text-emerald-200 hover:bg-emerald-900/60":"bg-neutral-800 text-neutral-300 hover:bg-neutral-700"),title:o.resolved?"Mark unresolved":"Mark resolved",children:[o.resolved?l.jsx(ep,{className:"h-3 w-3"}):l.jsx(eC,{className:"h-3 w-3"}),o.resolved?"resolved":"open"]}):null,o.replyTo?l.jsxs("span",{className:"inline-flex items-center gap-1 text-neutral-500",children:[l.jsx(kC,{className:"h-3 w-3"}),o.replyTo]}):null]}),l.jsx(Ut,{content:o.body}),i.length>0?l.jsx("div",{className:"space-y-2",children:i.map(c=>l.jsx(Ww,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const pI=["review","complete","unblock","start","block","fail","reopen"];function Sy(){var mn,Pn,Tn,re,le,pe;const{slug:e,aslug:t}=Et(),n=Xt(),o=Lt(),[i,a]=_s(),[c,d]=g.useState(null),[p,h]=g.useState(null),[m,x]=g.useState(null),[v,b]=g.useState(null),[N,k]=g.useState(null),[j,S]=g.useState(!1),[T,A]=g.useState(!1),[L,O]=g.useState(0),P=i.get("tab")??"summary",$=bc(),{data:E,loading:H,error:Z,refetch:G}=wN(e,t),{data:q}=Hv(e),{data:Y}=ap(),{data:X}=SN(e,t),_=g.useMemo(()=>{if(!E||!q)return[];const ne=new Map(q.assignments.map(me=>[me.slug,me]));return E.dependsOn.map(me=>{const ke=ne.get(me);return{slug:me,title:(ke==null?void 0:ke.title)??me,status:(ke==null?void 0:ke.status)??"pending",priority:(ke==null?void 0:ke.priority)??"medium",assignee:(ke==null?void 0:ke.assignee)??null}})},[E,q]),D=_.filter(ne=>ne.status!=="completed"&&ne.status!=="review");zs("assignment");const V=g.useMemo(()=>((q==null?void 0:q.assignments)??[]).map(ne=>ne.slug),[q]),W=t?V.indexOf(t):-1,ee=W>0?V[W-1]:null,R=W>=0&&W<V.length-1?V[W+1]:null,F=`${o}/projects/${e}/assignments/${t}`;yt({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${F}/edit`)}),yt({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${F}/plan/edit`)}),yt({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${F}/handoff/edit`)}),yt({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${F}/decision-record/edit`)}),yt({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${F}/scratchpad/edit`)}),yt({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ee,handler:()=>ee&&n(`${o}/projects/${e}/assignments/${ee}`)}),yt({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!R,handler:()=>R&&n(`${o}/projects/${e}/assignments/${R}`)});const J=g.useMemo(()=>E?lI(E.body):{acceptanceCriteria:[],summaryBody:""},[E]),I=g.useMemo(()=>aI(J.summaryBody),[J.summaryBody]),de=J.acceptanceCriteria,ve=de.filter(ne=>ne.checked).length,fe=de.length>0&&ve===de.length,Ee=g.useRef(fe),Ne=g.useRef(!1);if(g.useEffect(()=>{if(E){if(!Ne.current){Ee.current=fe,Ne.current=!0;return}fe&&!Ee.current&&O(ne=>ne+1),Ee.current=fe}},[fe,E]),H)return l.jsx(jt,{label:"Loading assignment workspace…"});if(Z||!E||!e||!t)return l.jsx(vt,{error:Z||"Assignment not found."});const Re=e,je=t,ut=de.length>0?{checked:ve,total:de.length}:void 0,tt=E.availableTransitions??[],Ue=tt.filter(ne=>!ne.disabled&&ne.targetStatus!==E.status),Be=pI.map(ne=>Ue.find(me=>me.command===ne)).find(Boolean)??Ue[0]??null,St=[];if(Y!=null&&Y.sessions)for(const ne of Y.sessions)for(const me of ne.windows)for(const ke of me.panes)((mn=ke.assignment)==null?void 0:mn.project)===e&&((Pn=ke.assignment)==null?void 0:Pn.slug)===t&&St.push({sessionName:ne.name,command:ke.command,urls:ke.urls});async function Ot(ne){d(null);try{await Bw(Re,je,ne),G()}catch(me){d(me.message)}}async function cn(){A(!0);try{await iI(Re,je),n(`${o}/projects/${Re}`)}catch(ne){d(ne.message),A(!1),S(!1)}}async function hn(ne,me){d(null),h(ne.command);try{return await zw(Re,je,ne,me),G(),!0}catch(ke){return d(ke.message),!1}finally{h(null)}}function Xe(ne){if(Uw(ne)){x(ne);return}hn(ne)}async function nt(ne,me){b(null),k(ne);try{const ke=await fetch(`/api/projects/${Re}/assignments/${je}/acceptance-criteria/${ne}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:me})}),_t=await ke.json();if(!ke.ok)throw new Error(_t.error||`HTTP ${ke.status}`);G()}catch(ke){b(ke.message)}finally{k(null)}}const Wt=[...Ue.filter(ne=>ne!==Be).map(ne=>({key:`transition-${ne.command}`,label:ne.label,onSelect:()=>Xe(ne),disabled:p===ne.command})),...tt.filter(ne=>ne.disabled||ne.targetStatus===E.status).map(ne=>({key:`transition-${ne.command}`,label:ne.label,disabled:!0,disabledReason:ne.targetStatus===E.status?`Already ${E.status.replace(/_/g," ")}`:ne.disabledReason??ne.warning??ne.description})),...$.statuses.map(ne=>({key:`override-${ne.id}`,label:`Override → ${ne.label}`,onSelect:()=>Ot(ne.id),disabled:ne.id===E.status,disabledReason:ne.id===E.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:aC,href:`${o}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:CC,href:`${o}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:Rd,href:`${o}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:Ka,href:`${o}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:pC,href:`${o}/projects/${e}/assignments/${t}/decision-record/edit`},{key:"delete",label:"Delete assignment",icon:Ms,destructive:!0,onSelect:()=>S(!0)}],Qt=(Be==null?void 0:Be.command)==="review";return l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx(Ht,{status:E.status,progress:ut}),l.jsx("h1",{className:"text-lg font-semibold text-foreground",children:E.title}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",pN(E.updated)]}),D.length>0&&l.jsxs("span",{className:"text-xs text-amber-700 dark:text-amber-300",children:["⚠ ",D.length," unmet dep",D.length===1?"":"s"]}),l.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[Be&&l.jsx("button",{type:"button",title:Be.warning||Be.description,disabled:p===Be.command,onClick:()=>Xe(Be),className:$e("shell-action disabled:cursor-not-allowed disabled:opacity-50",Be.warning&&"border-amber-300 dark:border-amber-700",Qt&&L>0&&"send-to-review-glow"),children:l.jsx("span",{children:p===Be.command?"Working…":Be.label})},Qt?`review-${L}`:Be.command),l.jsx(sI,{items:Wt,align:"end"})]})]}),c?l.jsx("p",{className:"mt-4 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:c}):null,E.blockedReason?l.jsxs("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300",children:[l.jsx("strong",{children:"Blocked reason:"})," ",E.blockedReason]}):null]}),_.length>0&&l.jsx(cI,{projectSlug:e,dependencies:_,blockedReason:E.blockedReason}),E.enrichedLinks&&E.enrichedLinks.length>0&&l.jsx(uI,{links:E.enrichedLinks}),E.referencedBy&&E.referencedBy.length>0&&l.jsx(Pe,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:l.jsx("ul",{className:"space-y-2",children:E.referencedBy.map(ne=>{const me=ne.sourceProjectSlug===null?`/assignments/${ne.sourceId}`:`${o}/projects/${ne.sourceProjectSlug}/assignments/${ne.sourceSlug}`;return l.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[l.jsx(Ce,{to:me,className:"text-foreground hover:text-primary",children:ne.sourceTitle}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",ne.mentions," mention",ne.mentions===1?"":"s",")"]}),ne.sourceProjectSlug===null?l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"}):null]},ne.sourceId)})})}),l.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_280px]",children:[l.jsx("div",{className:"space-y-4",children:l.jsx(Cp,{value:P,onValueChange:ne=>a({tab:ne}),items:[{value:"summary",label:"Summary",content:l.jsxs("div",{className:"space-y-5",children:[J.acceptanceCriteria.length>0?l.jsx(Pe,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:l.jsxs("div",{className:"space-y-3",children:[v?l.jsx("p",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:v}):null,J.acceptanceCriteria.map((ne,me)=>{const ke=N!==null;return l.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[l.jsx("input",{type:"checkbox",checked:ne.checked,disabled:ke,onChange:_t=>nt(me,_t.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),l.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":ne.checked,children:ne.text})]},`${me}-${ne.text}`)})]})}):null,I.hasSection?l.jsx(Pe,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:l.jsx(Ut,{content:I.todosMarkdown,emptyState:"No todos yet."})}):null,l.jsx(Pe,{title:"Assignment Summary",children:l.jsx(Ut,{content:I.remaining,emptyState:J.acceptanceCriteria.length>0||I.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:E.plan?1:0,content:E.plan?l.jsx("div",{className:"space-y-5",children:l.jsxs(Pe,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:l.jsxs(Ce,{className:"shell-action",to:`${o}/projects/${e}/assignments/${t}/plan/edit`,children:[l.jsx(Rd,{className:"h-4 w-4"}),l.jsx("span",{children:"Edit Plan"})]}),children:[l.jsx("div",{className:"mb-4",children:l.jsx(Ht,{status:E.plan.status})}),l.jsx(Ut,{content:E.plan.body,emptyState:"No plan content yet."})]})}):l.jsx(Ge,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:E.scratchpad?1:0,content:E.scratchpad?l.jsx(Pe,{title:"Scratchpad",actions:l.jsxs(Ce,{className:"shell-action",to:`${o}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[l.jsx(Rd,{className:"h-4 w-4"}),l.jsx("span",{children:"Edit Scratchpad"})]}),children:l.jsx(Ut,{content:E.scratchpad.body,emptyState:"Scratchpad is empty."})}):l.jsx(Ge,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((Tn=E.handoff)==null?void 0:Tn.handoffCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.handoff?l.jsx(Pe,{children:l.jsx(Ut,{content:E.handoff.body,emptyState:"No handoff history yet."})}):l.jsx(Ge,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((re=E.progress)==null?void 0:re.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.progress&&E.progress.entries.length>0?l.jsx(Pe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:l.jsx("ol",{className:"space-y-4",children:E.progress.entries.map((ne,me)=>l.jsxs("li",{className:"border-l-2 border-neutral-700 pl-3",children:[l.jsx("div",{className:"text-xs font-mono text-neutral-400",children:ne.timestamp}),l.jsx(Ut,{content:ne.body})]},`${ne.timestamp}-${me}`))})}):l.jsx(Ge,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((le=E.comments)==null?void 0:le.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.comments&&E.comments.entries.length>0?l.jsx(Hw,{projectSlug:e,assignmentSlug:t,entries:E.comments.entries}):l.jsx(Ge,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((pe=E.decisionRecord)==null?void 0:pe.decisionCount)??0,content:l.jsx("div",{className:"space-y-5",children:E.decisionRecord?l.jsx(Pe,{children:l.jsx(Ut,{content:E.decisionRecord.body,emptyState:"No decision history yet."})}):l.jsx(Ge,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),l.jsxs("div",{className:"space-y-5",children:[l.jsx(Pe,{title:"Details",children:l.jsxs("dl",{className:"space-y-3 text-sm",children:[l.jsx(vo,{label:"ID",value:E.id,copyable:!0}),l.jsx(vo,{label:"Priority",value:E.priority}),E.assignee&&l.jsx(vo,{label:"Assignee",value:E.assignee}),l.jsx(vo,{label:"Updated",value:`${fN(E.updated)} · Created ${dN(E.created)}`}),E.workspace.repository&&l.jsx(vo,{label:"Repository",value:E.workspace.repository,copyable:!0}),E.workspace.worktreePath&&l.jsx(vo,{label:"Worktree",value:E.workspace.worktreePath,copyable:!0}),E.workspace.branch&&l.jsx(vo,{label:"Branch",value:E.workspace.branch,copyable:!0}),E.workspace.parentBranch&&l.jsx(vo,{label:"Parent branch",value:E.workspace.parentBranch,copyable:!0})]})}),St.length>0&&l.jsx(Pe,{title:"Servers",children:l.jsx("div",{className:"space-y-2",children:St.map((ne,me)=>l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:ne.command}),l.jsx("span",{className:"text-xs text-muted-foreground",children:ne.sessionName}),ne.urls.map(ke=>l.jsxs("a",{href:ke,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[ke.replace("http://localhost:",":"),l.jsx(bv,{className:"h-2.5 w-2.5"})]},ke))]},me))})}),X&&X.sessions.length>0&&l.jsx(Pe,{title:"Agent Sessions",children:l.jsx("div",{className:"space-y-2",children:X.sessions.map(ne=>l.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(uc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"font-medium text-foreground",children:ne.agent}),l.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:ne.sessionId,children:[ne.sessionId.slice(0,8),l.jsx(Hr,{value:ne.sessionId})]})]}),l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(Ht,{status:ne.status}),l.jsx("span",{className:"text-xs text-muted-foreground",children:Cr(ne.started)})]})]},ne.sessionId))})})]})]}),l.jsx(Ib,{open:m!==null,action:m,assignmentTitle:E.title,loading:p===(m==null?void 0:m.command),onOpenChange:ne=>{ne||x(null)},onConfirm:async ne=>{if(!m)return;await hn(m,ne)&&x(null)}}),l.jsx(ow,{open:j,title:"Delete assignment?",description:`This will permanently delete "${E.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:T,onOpenChange:ne=>{ne||S(!1)},onConfirm:cn})]})}function vo({label:e,value:t,copyable:n}){return l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsx("dt",{className:"text-muted-foreground",children:e}),l.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[l.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&l.jsx(Hr,{value:t})]})]})}function hI(){var d,p,h,m,x;const{id:e}=Et(),[t,n]=_s(),o=t.get("tab")??"summary",{data:i,loading:a,error:c}=kN(e);return a?l.jsx(jt,{}):c?l.jsx(vt,{error:c}):i?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("header",{className:"space-y-2",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l.jsx("span",{className:"rounded bg-neutral-800 px-2 py-0.5 font-mono text-xs uppercase tracking-wide text-neutral-300",children:"Standalone"}),l.jsx(Ht,{status:i.status}),l.jsx("span",{className:"text-xs font-mono text-neutral-500",children:i.id}),l.jsx(Ce,{to:`/assignments/${i.id}/edit`,className:"ml-auto rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit"})]}),l.jsx("h1",{className:"text-2xl font-semibold text-neutral-100",children:i.title}),i.blockedReason?l.jsxs("p",{className:"text-sm text-amber-300",children:["Blocked: ",i.blockedReason]}):null]}),i.referencedBy&&i.referencedBy.length>0?l.jsx(Pe,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:l.jsx("ul",{className:"space-y-2",children:i.referencedBy.map(v=>l.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[l.jsx(Ce,{to:v.sourceProjectSlug===null?`/assignments/${v.sourceId}`:`/projects/${v.sourceProjectSlug}/assignments/${v.sourceSlug}`,className:"text-foreground hover:text-primary",children:v.sourceTitle}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",v.mentions," mention",v.mentions===1?"":"s",")"]})]},v.sourceId))})}):null,l.jsx(Cp,{value:o,onValueChange:v=>n({tab:v}),items:[{value:"summary",label:"Summary",content:l.jsx("div",{className:"space-y-5",children:l.jsx(Pe,{title:"Assignment",children:l.jsx(Ut,{content:i.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((d=i.progress)==null?void 0:d.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.progress&&i.progress.entries.length>0?l.jsx(Pe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:l.jsx("ol",{className:"space-y-4",children:i.progress.entries.map((v,b)=>l.jsxs("li",{className:"border-l-2 border-neutral-700 pl-3",children:[l.jsx("div",{className:"text-xs font-mono text-neutral-400",children:v.timestamp}),l.jsx(Ut,{content:v.body})]},`${v.timestamp}-${b}`))})}):l.jsx(Ge,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((p=i.comments)==null?void 0:p.entryCount)??0,content:l.jsx("div",{className:"space-y-5",children:l.jsx(Hw,{projectSlug:null,assignmentSlug:i.id,entries:((h=i.comments)==null?void 0:h.entries)??[]})})},{value:"plan",label:"Plan",content:l.jsx("div",{className:"space-y-5",children:i.plan?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.plan.body,emptyState:"Plan file exists but is empty."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/plan/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit plan"})})]}):l.jsx(Ge,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:l.jsx("div",{className:"space-y-5",children:i.scratchpad?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.scratchpad.body,emptyState:"Scratchpad is empty."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/scratchpad/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Edit scratchpad"})})]}):l.jsx(Ge,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((m=i.handoff)==null?void 0:m.handoffCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.handoff?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.handoff.body,emptyState:"No handoff history yet."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/handoff/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Append handoff"})})]}):l.jsx(Ge,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((x=i.decisionRecord)==null?void 0:x.decisionCount)??0,content:l.jsx("div",{className:"space-y-5",children:i.decisionRecord?l.jsxs(Pe,{children:[l.jsx(Ut,{content:i.decisionRecord.body,emptyState:"No decision history yet."}),l.jsx("div",{className:"mt-3 flex justify-end",children:l.jsx(Ce,{to:`/assignments/${i.id}/decision-record/edit`,className:"rounded border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500 hover:text-neutral-100",children:"Append decision"})})]}):l.jsx(Ge,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]})]}):l.jsx(vt,{error:"Assignment not found"})}const mI=["table","list","kanban"],Cy={critical:0,high:1,medium:2,low:3};function Ny(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function gI(e,t){return e.toString()===t.toString()}function Ey(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}function xI(e,t,n){return[...e].sort((i,a)=>{let c=0;switch(t){case"title":c=i.title.localeCompare(a.title);break;case"status":c=i.status.localeCompare(a.status);break;case"priority":c=(Cy[i.priority]??99)-(Cy[a.priority]??99);break;case"assignee":c=(i.assignee??"").localeCompare(a.assignee??"");break;case"dependencies":c=i.dependsOn.length-a.dependsOn.length;break;case"updated":c=i.updated.localeCompare(a.updated);break}return n==="asc"?c:-c})}function Ry(){const{workspace:e}=Et(),t=Lt(),n=Xt(),o=g.useRef(null);zs("list:assignments");const{data:i,loading:a,error:c,refetch:d}=Bv(),p=bc(),[h,m]=_s(),x=g.useMemo(()=>YE(p.order),[p]),v=g.useMemo(()=>{const U={};for(const ae of x)U[ae]=VE(p,ae);return U},[x,p]),b=g.useMemo(()=>x.map(U=>({id:U,title:v[U]??U,description:D0(U)})),[x,v]),N=g.useMemo(()=>new Set(["all",...x]),[x]),k=h.get("view"),j=h.get("status"),S=h.get("stale"),T=k&&mI.includes(k)?k:"kanban";function A(U){return!U||!N.has(U)?"all":U}const L=g.useCallback(U=>{m(ae=>{const ge=new URLSearchParams(ae);return U==="kanban"?ge.delete("view"):ge.set("view",U),ge})},[m]),[O,P]=g.useState(""),[$,E]=g.useState(()=>A(j)),[H,Z]=g.useState("all"),[G,q]=g.useState("all"),[Y,X]=g.useState("all"),[_,D]=g.useState(()=>Ny(S)),[V,W]=g.useState("updated"),[ee,R]=g.useState("desc"),[F,J]=g.useState(()=>new Set(x)),[I,de]=g.useState([]),[ve,fe]=g.useState(null),[Ee,Ne]=g.useState(null),[Re,je]=g.useState(null),[ut,tt]=g.useState(null),[Ue,Be]=g.useState(null);g.useEffect(()=>{de((i==null?void 0:i.assignments)??[])},[i]),g.useEffect(()=>{const U=A(j);U!==$&&E(U);const ae=Ny(S);ae!==_&&D(ae)},[_,S,$,j]),g.useEffect(()=>{m(U=>{const ae=new URLSearchParams(U);return $==="all"?ae.delete("status"):ae.set("status",$),_==="all"?ae.delete("stale"):_==="stale"?ae.set("stale","1"):ae.set("stale","0"),gI(U,ae)?U:ae})},[_,m,$]);const St=g.useMemo(()=>Array.from(new Set(I.map(U=>U.status))).sort(),[I]),Ot=g.useMemo(()=>Array.from(new Set(I.map(U=>U.priority))).sort(),[I]),cn=g.useMemo(()=>Array.from(new Set(I.map(U=>U.assignee??"__unassigned__"))).sort(),[I]),hn=g.useMemo(()=>Array.from(new Map(I.filter(U=>U.projectSlug!==null).map(U=>[U.projectSlug,U.projectTitle]))).sort(([,U],[,ae])=>U.localeCompare(ae)),[I]),Xe=g.useMemo(()=>I.filter(U=>{if(e){if(e==="_ungrouped"){if(U.projectWorkspace!==null)return!1}else if(U.projectWorkspace!==e)return!1}if($!=="all"&&U.status!==$||H!=="all"&&U.priority!==H||_==="stale"&&!Ey(U.updated)||_==="fresh"&&Ey(U.updated)||G!=="all"&&(U.assignee??"__unassigned__")!==G)return!1;if(Y!=="all"){if(Y==="__standalone__"){if(U.projectSlug!==null)return!1}else if(U.projectSlug!==Y)return!1}const ae=O.trim().toLowerCase();return!(ae&&!`${U.title} ${U.slug} ${U.projectTitle??"standalone"} ${U.projectSlug??""}`.toLowerCase().includes(ae))}),[_,I,O,$,H,G,Y,e]),nt=g.useMemo(()=>xI(Xe,V,ee),[Xe,V,ee]),{visibleItems:Wt,visibleIndexByKey:Qt}=g.useMemo(()=>{const U=T==="table"?nt:x.flatMap(ge=>Xe.filter(Oe=>Oe.status===ge)),ae=new Map;return U.forEach((ge,Oe)=>ae.set(Yt(ge),Oe)),{visibleItems:U,visibleIndexByKey:ae}},[T,nt,Xe,x]),{hotkeyRowProps:mn}=yc(Wt,{scope:"list:assignments",onOpen:U=>{if(U.projectSlug===null){n(`/assignments/${U.id}`);return}const ae=U.projectWorkspace?`/w/${U.projectWorkspace}`:t;n(`${ae}/projects/${U.projectSlug}/assignments/${U.slug}`)}});if(yt({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var U;return(U=o.current)==null?void 0:U.focus()}}),yt({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>d()}),a)return l.jsx(jt,{label:"Loading assignments board…"});if(c||!i)return l.jsx(vt,{error:c||"Assignments board is unavailable."});async function Pn({item:U,toColumnId:ae,action:ge,reason:Oe}){fe(null),Ne(Yt(U));const zn=I;de(Zt=>Zt.map(dt=>Yt(dt)===Yt(U)?{...dt,status:ae,blockedReason:ae==="blocked"?Oe??dt.blockedReason:null}:dt));try{if(U.projectSlug===null){if(!ge)throw new Error("Standalone assignments require a transition action, not status override.");const dt=await fetch(`/api/assignments/${encodeURIComponent(U.id)}/transitions/${encodeURIComponent(ge.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Oe?{reason:Oe}:{})});if(!dt.ok)throw new Error((await dt.json()).error??`HTTP ${dt.status}`);const Ye=(await dt.json()).assignment;de(bt=>bt.map(Mt=>Yt(Mt)===Yt(U)?{...Mt,status:Ye.status,blockedReason:Ye.blockedReason,availableTransitions:Ye.availableTransitions,updated:Ye.updated}:Mt));return}const Zt=ge?await zw(U.projectSlug,U.slug,ge,Oe):await Bw(U.projectSlug,U.slug,ae);return de(dt=>dt.map(Fe=>Yt(Fe)===Yt(U)?{...Fe,status:Zt.status,blockedReason:Zt.blockedReason,availableTransitions:Zt.availableTransitions,updated:Zt.updated}:Fe)),d(),!0}catch(Zt){return de(zn),fe(Zt.message),!1}finally{Ne(null)}}async function Tn({item:U,toColumnId:ae}){if(U.status===ae)return;const ge=_i(U,ae);if(ge!=null&&ge.disabled){fe(ge.disabledReason||`Cannot move this assignment to ${ae}.`);return}if(ge&&Uw(ge)){Be({item:U,toColumnId:ae,action:ge});return}await Pn({item:U,toColumnId:ae,action:ge})}function re(U){J(ae=>{const ge=new Set(ae);return ge.has(U)?ge.delete(U):ge.add(U),ge})}function le(U){V===U?R(ae=>ae==="asc"?"desc":"asc"):(W(U),R("asc"))}const pe=Re?I.find(U=>Yt(U)===Re)??null:null;function ne(U,ae){U.dataTransfer.effectAllowed="move",U.dataTransfer.setData("text/plain",ae),je(ae)}function me(){je(null),tt(null)}function ke(U,ae){if(!pe)return;const ge=_i(pe,ae);pe.status===ae||ge!=null&&ge.disabled||(U.preventDefault(),U.dataTransfer.dropEffect="move",tt(ae))}function _t(U,ae){ut===ae&&!U.currentTarget.contains(U.relatedTarget)&&tt(null)}function Jt(U,ae){if(U.preventDefault(),!pe||pe.status===ae){me();return}me(),Tn({item:pe,toColumnId:ae})}function Vt({field:U,children:ae}){const ge=V===U;return l.jsx("th",{className:"pb-3 font-medium",children:l.jsxs("button",{type:"button",onClick:()=>le(U),className:"inline-flex items-center gap-1 hover:text-foreground",children:[ae,ge?ee==="asc"?l.jsx(vv,{className:"h-3 w-3"}):l.jsx(Yi,{className:"h-3 w-3"}):null]})})}return l.jsxs("div",{className:"space-y-5",children:[l.jsxs(wp,{children:[l.jsx(vc,{ref:o,value:O,onChange:P,placeholder:"Search assignments or projects"}),l.jsxs("select",{value:$,onChange:U=>E(A(U.target.value)),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All statuses"}),St.map(U=>l.jsx("option",{value:U,children:v[U]??U},U))]}),l.jsxs("select",{value:H,onChange:U=>Z(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All priorities"}),Ot.map(U=>l.jsx("option",{value:U,className:"capitalize",children:U},U))]}),l.jsxs("select",{value:G,onChange:U=>q(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All assignees"}),cn.map(U=>l.jsx("option",{value:U,children:U==="__unassigned__"?"Unassigned":U},U))]}),l.jsxs("select",{value:Y,onChange:U=>X(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All projects"}),l.jsx("option",{value:"__standalone__",children:"Standalone"}),hn.map(([U,ae])=>l.jsx("option",{value:U,children:ae},U))]}),l.jsxs("select",{value:_,onChange:U=>D(U.target.value),className:"editor-input max-w-[180px]",children:[l.jsx("option",{value:"all",children:"All activity"}),l.jsx("option",{value:"stale",children:"Stale only"}),l.jsx("option",{value:"fresh",children:"Fresh only"})]}),l.jsx(kp,{value:T,onChange:U=>L(U),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]})]}),ve?l.jsx("div",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:ve}):null,i.assignments.length===0?l.jsx(Ge,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:l.jsxs(Ce,{className:"shell-action bg-foreground text-background hover:opacity-90",to:`${t}/projects`,children:[l.jsx(np,{className:"h-4 w-4"}),l.jsx("span",{children:"Browse Projects"})]})}):Xe.length===0?l.jsx(Ge,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):T==="table"?l.jsx(Pe,{title:`${nt.length} assignment${nt.length===1?"":"s"}`,children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[l.jsx(Vt,{field:"title",children:"Assignment"}),l.jsx(Vt,{field:"status",children:"Status"}),l.jsx(Vt,{field:"priority",children:"Priority"}),l.jsx(Vt,{field:"assignee",children:"Assignee"}),l.jsx(Vt,{field:"dependencies",children:"Dependencies"}),l.jsx(Vt,{field:"updated",children:"Updated"})]})}),l.jsx("tbody",{children:nt.map((U,ae)=>l.jsxs("tr",{className:"border-b border-border/50 last:border-0",...mn(ae),children:[l.jsxs("td",{className:"py-4 pr-4",children:[l.jsx(Ce,{to:U.projectSlug===null?`/assignments/${U.id}`:`${t}/projects/${U.projectSlug}/assignments/${U.slug}`,className:"font-semibold text-foreground hover:text-primary",children:U.title}),l.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:U.projectTitle??l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"})}),l.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:U.id,children:[U.id.slice(0,8),l.jsx(Hr,{value:U.id})]})]}),l.jsx("td",{className:"py-4 pr-4",children:l.jsx("select",{value:U.status,disabled:Ee===Yt(U),onChange:ge=>Tn({item:U,toColumnId:ge.target.value}),className:$e("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(Ya[U.status]??Ya.pending).className,Ee===Yt(U)&&"animate-pulse opacity-60"),children:x.map(ge=>{const Oe=U.status===ge?void 0:_i(U,ge),zn=(Oe==null?void 0:Oe.disabled)??!1;return l.jsx("option",{value:ge,disabled:zn,title:zn?(Oe==null?void 0:Oe.disabledReason)??void 0:void 0,children:v[ge]},ge)})})}),l.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:U.priority}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:U.assignee??"Unassigned"}),l.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:U.dependsOn.length}),l.jsx("td",{className:"py-4 text-muted-foreground",children:Vr(U.updated)})]},Yt(U)))})]})})}):T==="list"?l.jsx("div",{className:"space-y-3",children:x.map(U=>{var dt;const ae=Xe.filter(Fe=>Fe.status===U);if(ae.length===0&&!pe)return null;const ge=F.has(U),Oe=pe?pe.status!==U&&!((dt=_i(pe,U))!=null&&dt.disabled):!1,zn=pe?pe.status!==U&&!Oe:!1,Zt=ut===U;return l.jsxs("div",{className:$e("rounded-lg border border-border/60 bg-card/90 transition",Zt&&Oe&&"ring-2 ring-ring/30",zn&&"border-dashed opacity-65"),onDragOver:Fe=>ke(Fe,U),onDragLeave:Fe=>_t(Fe,U),onDrop:Fe=>Jt(Fe,U),children:[l.jsxs("button",{type:"button",onClick:()=>re(U),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[l.jsx(Yi,{className:`h-4 w-4 text-muted-foreground transition-transform ${ge?"":"-rotate-90"}`}),l.jsx("span",{className:"font-semibold text-foreground",children:v[U]}),l.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:ae.length})]}),ge&&ae.length>0&&l.jsx("div",{className:"space-y-3 px-4 pb-4",children:ae.map(Fe=>{const Ye=Yt(Fe),bt=Re===Ye,Mt=Qt.get(Ye)??-1;return l.jsx("div",{draggable:!0,onDragStart:qt=>ne(qt,Ye),onDragEnd:me,...Mt>=0?mn(Mt):{},className:$e("cursor-grab transition active:cursor-grabbing",bt&&"scale-[0.98] opacity-50"),children:l.jsx(Py,{assignment:Fe,dragging:bt,transitioning:Ee===Ye})},Ye)})})]},U)})}):l.jsx(I0,{columns:b,items:Xe,getItemId:Yt,getColumnId:U=>U.status,canDrop:({item:U,fromColumnId:ae,toColumnId:ge})=>{if(ae===ge)return{allowed:!0};const Oe=_i(U,ge);return Oe!=null&&Oe.disabled?{allowed:!1,reason:Oe.disabledReason||Oe.description}:{allowed:!0,reason:Oe?Oe.warning||Oe.description:`Move to ${ge} (direct status change).`}},onMove:({item:U,toColumnId:ae})=>Tn({item:U,toColumnId:ae}),emptyMessage:U=>`No ${U.title.toLowerCase()} assignments.`,renderCard:(U,{dragging:ae})=>{const ge=Qt.get(Yt(U))??-1;return l.jsx("div",{...ge>=0?mn(ge):{},children:l.jsx(Py,{assignment:U,dragging:ae,transitioning:Ee===Yt(U)})})}}),l.jsx(Ib,{open:Ue!==null,action:(Ue==null?void 0:Ue.action)??null,assignmentTitle:(Ue==null?void 0:Ue.item.title)??"Assignment",loading:Ee===(Ue?Yt(Ue.item):null),onOpenChange:U=>{U||Be(null)},onConfirm:async U=>{if(!Ue)return;const ae=Ue;await Pn({item:ae.item,toColumnId:ae.toColumnId,action:ae.action,reason:U})&&Be(null)}})]})}function Py({assignment:e,dragging:t,transitioning:n}){var i;const o=Lt();return l.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(Ce,{to:e.projectSlug===null?`/assignments/${e.id}`:`${o}/projects/${e.projectSlug}/assignments/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[10px] uppercase text-neutral-300",children:"Standalone"})}),l.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(i=e.id)==null?void 0:i.slice(0,8),e.id&&l.jsx(Hr,{value:e.id})]})]}),l.jsx(Ht,{status:e.status})]}),e.blockedReason?l.jsx("p",{className:"mt-3 rounded-md border border-amber-200/70 bg-amber-50/80 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/70 dark:bg-amber-950/20 dark:text-amber-300",children:e.blockedReason}):null,l.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[l.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),l.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),l.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),l.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),l.jsx("span",{children:Vr(e.updated)})]})]})}function _i(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function Yt(e){return e.id||e.slug||"unknown"}function Tr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],o=e.slice(t[0].length),i=n.split(`
|
|
471
471
|
`),a=[],c=new Map;let d=null,p=[];const h=()=>{d&&(a.push(d),c.set(d,p))};for(const m of i){const x=m.match(/^([A-Za-z_][A-Za-z0-9_-]*):/);if(x&&!m.startsWith(" ")){h(),d=x[1],p=[m];continue}d&&p.push(m)}return h(),{order:a,blocks:c,body:o}}function fl(e){return`---
|
|
472
472
|
${e.order.map(n=>e.blocks.get(n)).filter(n=>!!n).flat().join(`
|
|
473
473
|
`)}
|
|
474
474
|
---
|
|
475
475
|
|
|
476
476
|
${e.body.replace(/^\n+/,"")}`}function Dt(e,t){const n=e.blocks.get(t);if(!(n!=null&&n[0]))return"";const o=n[0].match(/^[^:]+:\s*(.*)$/);if(!o)return"";const i=o[1].trim();return i==="null"?"":i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'")?i.slice(1,-1):i}function yI(e,t){return Dt(e,t)==="true"}function Ui(e,t){const n=e.blocks.get(t);return n!=null&&n.length?n[0].trim().endsWith("[]")?[]:n.slice(1).map(o=>o.trim()).filter(o=>o.startsWith("- ")).map(o=>o.slice(2).trim()):[]}function vI(e){return typeof e=="boolean"?e?"true":"false":e===null||e===""?"null":/^\d{4}-\d{2}-\d{2}T/.test(e)?`"${e}"`:/[:#{}[\],&*?|>!%@`]/.test(e)||/^\s|\s$/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function It(e,t,n){e.blocks.has(t)||e.order.push(t),e.blocks.set(t,[`${t}: ${vI(n)}`])}function Hi(e,t,n){if(e.blocks.has(t)||e.order.push(t),n.length===0){e.blocks.set(t,[`${t}: []`]);return}e.blocks.set(t,[`${t}:`,...n.map(o=>` - ${o}`)])}function Wi(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function Ac(e){const t=Tr(e);return{title:Dt(t,"title"),slug:Dt(t,"slug"),workspace:Dt(t,"workspace"),archived:yI(t,"archived"),archivedAt:Dt(t,"archivedAt"),archivedReason:Dt(t,"archivedReason"),tags:Ui(t,"tags").join(", "),body:t.body}}function bI(e,t){const n=Tr(e),o={...Ac(e),...t};return It(n,"title",o.title),It(n,"slug",o.slug),It(n,"workspace",o.workspace||null),It(n,"archived",o.archived),It(n,"archivedAt",o.archivedAt||null),It(n,"archivedReason",o.archivedReason||null),Hi(n,"tags",Wi(o.tags)),n.body=o.body,fl(n)}function Dc(e){const t=Tr(e);return{title:Dt(t,"title"),slug:Dt(t,"slug"),status:Dt(t,"status"),priority:Dt(t,"priority")||"medium",assignee:Dt(t,"assignee"),dependsOn:Ui(t,"dependsOn").join(", "),links:Ui(t,"links").join(", "),blockedReason:Dt(t,"blockedReason"),tags:Ui(t,"tags").join(", "),body:t.body}}function wI(e,t){const n=Tr(e),o={...Dc(e),...t};return It(n,"title",o.title),It(n,"slug",o.slug),It(n,"status",o.status),It(n,"priority",o.priority),It(n,"assignee",o.assignee||null),Hi(n,"dependsOn",Wi(o.dependsOn)),Hi(n,"links",Wi(o.links)),It(n,"blockedReason",o.blockedReason||null),Hi(n,"tags",Wi(o.tags)),n.body=o.body,fl(n)}function Ic(e){const t=Tr(e);return{assignment:Dt(t,"assignment"),status:Dt(t,"status"),body:t.body}}function kI(e,t){const n=Tr(e),o={...Ic(e),...t};return It(n,"assignment",o.assignment),It(n,"status",o.status),n.body=o.body,fl(n)}function Lc(e){const t=Tr(e);return{assignment:Dt(t,"assignment"),body:t.body}}function jI(e,t){const n=Tr(e),o={...Lc(e),...t};return It(n,"assignment",o.assignment),n.body=o.body,fl(n)}function Oc(e){const t=Tr(e);return{name:Dt(t,"name"),slug:Dt(t,"slug"),description:Dt(t,"description"),whenToUse:Dt(t,"when_to_use"),tags:Ui(t,"tags").join(", "),body:t.body}}function SI(e,t){const n=Tr(e),o={...Oc(e),...t};return It(n,"name",o.name),It(n,"slug",o.slug),It(n,"description",o.description||null),It(n,"when_to_use",o.whenToUse||null),Hi(n,"tags",Wi(o.tags)),n.body=o.body,fl(n)}function at(e,t,n){switch(e){case"project":return bI(t,n);case"assignment":return wI(t,n);case"plan":return kI(t,n);case"scratchpad":return jI(t,n);case"playbook":return SI(t,n);default:return t}}function Ur(e){return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function nf(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}function pl({initialContent:e,documentType:t,mode:n="edit",onSave:o,saving:i,error:a,title:c,description:d,onCancel:p,helpTitle:h,helpBody:m,allowSlugEdit:x=!1}){const[v,b]=g.useState(e),[N,k]=g.useState(!1),[j,S]=g.useState("edit");g.useEffect(()=>{b(e)},[e]);const T=RI(t,v),A=v!==e,L=EI(t,v),O=A?"Unsaved changes":n==="create"?"Draft":"Saved";return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"rounded-lg border border-border/70 bg-card/90 p-3 shadow-sm",children:[l.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-lg font-semibold text-foreground",children:c}),l.jsx("span",{className:"rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-muted-foreground",children:O})]}),d?l.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:d}):null]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("button",{type:"button",onClick:p,className:"shell-action",children:[l.jsx(xv,{className:"h-4 w-4"}),l.jsx("span",{children:"Back"})]}),l.jsxs("button",{type:"button",onClick:()=>k(P=>!P),className:"shell-action",children:[l.jsx(lC,{className:"h-4 w-4"}),l.jsx("span",{children:N?"Structured":"Raw Markdown"})]}),l.jsxs("button",{type:"button",onClick:()=>o(v),disabled:i||T.length>0,className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-semibold text-background transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:[l.jsx(op,{className:"h-4 w-4"}),l.jsx("span",{children:i?"Saving…":"Save"})]})]})]}),a?l.jsx("p",{className:"mt-4 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:a}):null,T.length>0?l.jsx("div",{className:"mt-4 rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300",children:l.jsx("ul",{className:"space-y-1",children:T.map(P=>l.jsx("li",{children:P},P))})}):null]}),l.jsxs("div",{className:"flex items-center gap-2 md:hidden",children:[l.jsx("button",{type:"button",onClick:()=>S("edit"),className:`shell-action ${j==="edit"?"bg-foreground text-background":""}`,children:"Edit"}),l.jsxs("button",{type:"button",onClick:()=>S("preview"),className:`shell-action ${j==="preview"?"bg-foreground text-background":""}`,children:[l.jsx(ex,{className:"h-4 w-4"}),"Preview"]})]}),l.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)]",children:[l.jsx("div",{className:j==="preview"?"hidden md:block":"",children:l.jsx("div",{className:"surface-panel space-y-3",children:N?l.jsx("textarea",{value:v,onChange:P=>b(P.target.value),className:"min-h-[720px] w-full rounded-md border border-border/70 bg-background/90 p-4 font-mono text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30",spellCheck:!1}):l.jsx(CI,{documentType:t,content:v,onChange:b,allowSlugEdit:x})})}),l.jsx("div",{className:j==="edit"?"hidden md:block":"",children:l.jsxs("div",{className:"surface-panel sticky top-16 space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ex,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Preview"})]}),l.jsx(Ut,{content:L,emptyState:"Write markdown body content to preview it here."})]})})]})]})}function CI({documentType:e,content:t,onChange:n,allowSlugEdit:o}){if(e==="project"){const a=Ac(t);return l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Mi,{children:[l.jsx(Je,{label:"Project title",children:l.jsx("input",{value:a.title,onChange:c=>{const d=c.target.value,p={title:d};o&&(a.slug===Ur(a.title)||!a.slug.trim())&&(p.slug=Ur(d)),n(at(e,t,p))},className:"editor-input"})}),l.jsx(Je,{label:"Slug",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{value:a.slug,disabled:!o,onChange:c=>n(at(e,t,{slug:Ur(c.target.value)})),className:`editor-input ${o?"":"editor-input-disabled"}`}),l.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:o?"The slug becomes the folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is the folder name and URL-safe identifier. It is locked after creation so links and file paths stay stable."})]})}),l.jsx(Je,{label:"Tags",children:l.jsx("input",{value:a.tags,onChange:c=>n(at(e,t,{tags:c.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),l.jsx(NI,{value:a.workspace,onChange:c=>n(at(e,t,{workspace:c}))})]}),l.jsx(Je,{label:"Project body",children:l.jsx("textarea",{value:a.body,onChange:c=>n(at(e,t,{body:c.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="assignment"){const a=Dc(t);return l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Mi,{children:[l.jsx(Je,{label:"Assignment title",children:l.jsx("input",{value:a.title,onChange:c=>{const d=c.target.value,p={title:d};o&&(a.slug===Ur(a.title)||!a.slug.trim())&&(p.slug=Ur(d)),n(at(e,t,p))},className:"editor-input"})}),l.jsx(Je,{label:"Slug",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{value:a.slug,disabled:!o,onChange:c=>n(at(e,t,{slug:Ur(c.target.value)})),className:`editor-input ${o?"":"editor-input-disabled"}`}),l.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:o?"The slug becomes the assignment folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is locked after creation because assignment paths and dependency references use it as a stable identifier."})]})}),l.jsx(Je,{label:"Status",children:l.jsxs("select",{value:a.status,onChange:c=>n(at(e,t,{status:c.target.value})),className:"editor-input",children:[l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"in_progress",children:"In Progress"}),l.jsx("option",{value:"blocked",children:"Blocked"}),l.jsx("option",{value:"review",children:"Review"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"failed",children:"Failed"})]})}),l.jsx(Je,{label:"Priority",children:l.jsxs("select",{value:a.priority,onChange:c=>n(at(e,t,{priority:c.target.value})),className:"editor-input",children:[l.jsx("option",{value:"low",children:"Low"}),l.jsx("option",{value:"medium",children:"Medium"}),l.jsx("option",{value:"high",children:"High"}),l.jsx("option",{value:"critical",children:"Critical"})]})}),l.jsx(Je,{label:"Assignee",children:l.jsx("input",{value:a.assignee,onChange:c=>n(at(e,t,{assignee:c.target.value})),placeholder:"Agent name",className:"editor-input"})}),l.jsx(Je,{label:"Depends on",className:"md:col-span-2",children:l.jsx("input",{value:a.dependsOn,onChange:c=>n(at(e,t,{dependsOn:c.target.value})),placeholder:"Comma-separated assignment slugs",className:"editor-input"})}),l.jsx(Je,{label:"Links",className:"md:col-span-2",children:l.jsx("input",{value:a.links,onChange:c=>n(at(e,t,{links:c.target.value})),placeholder:"Comma-separated: projectSlug/assignmentSlug",className:"editor-input"})}),l.jsx(Je,{label:"Blocked reason",className:"md:col-span-2",children:l.jsx("input",{value:a.blockedReason,onChange:c=>n(at(e,t,{blockedReason:c.target.value})),placeholder:"Read-only unless the assignment is actually blocked",className:"editor-input"})}),l.jsx(Je,{label:"Tags",className:"md:col-span-2",children:l.jsx("input",{value:a.tags,onChange:c=>n(at(e,t,{tags:c.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})})]}),l.jsx(Je,{label:"Assignment body",children:l.jsx("textarea",{value:a.body,onChange:c=>n(at(e,t,{body:c.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="plan"){const a=Ic(t);return l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Mi,{children:[l.jsx(Je,{label:"Assignment",children:l.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})}),l.jsx(Je,{label:"Plan status",children:l.jsxs("select",{value:a.status,onChange:c=>n(at(e,t,{status:c.target.value})),className:"editor-input",children:[l.jsx("option",{value:"draft",children:"Draft"}),l.jsx("option",{value:"approved",children:"Approved"}),l.jsx("option",{value:"in_progress",children:"In Progress"}),l.jsx("option",{value:"completed",children:"Completed"})]})})]}),l.jsx(Je,{label:"Plan body",children:l.jsx("textarea",{value:a.body,onChange:c=>n(at(e,t,{body:c.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="scratchpad"){const a=Lc(t);return l.jsxs("div",{className:"space-y-3",children:[l.jsx(Mi,{children:l.jsx(Je,{label:"Assignment",children:l.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})})}),l.jsx(Je,{label:"Scratchpad body",children:l.jsx("textarea",{value:a.body,onChange:c=>n(at(e,t,{body:c.target.value})),className:"editor-textarea",spellCheck:!1})})]})}const i=Oc(t);return l.jsxs("div",{className:"space-y-3",children:[l.jsxs(Mi,{children:[l.jsx(Je,{label:"Playbook name",children:l.jsx("input",{value:i.name,onChange:a=>{const c=a.target.value,d={name:c};o&&(i.slug===Ur(i.name)||!i.slug.trim())&&(d.slug=Ur(c)),n(at(e,t,d))},className:"editor-input"})}),l.jsx(Je,{label:"Slug",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{value:i.slug,disabled:!o,onChange:a=>n(at(e,t,{slug:Ur(a.target.value)})),className:`editor-input ${o?"":"editor-input-disabled"}`}),l.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:o?"The slug becomes the filename. It is auto-generated from the name until you change it.":"The slug is locked after creation because it is the filename."})]})}),l.jsx(Je,{label:"Description",className:"md:col-span-2",children:l.jsx("input",{value:i.description,onChange:a=>n(at(e,t,{description:a.target.value})),placeholder:"One-line description of what this playbook does",className:"editor-input"})}),l.jsx(Je,{label:"Tags",className:"md:col-span-2",children:l.jsx("input",{value:i.tags,onChange:a=>n(at(e,t,{tags:a.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),l.jsx(Je,{label:"When to use",className:"md:col-span-2",children:l.jsx("input",{value:i.whenToUse,onChange:a=>n(at(e,t,{whenToUse:a.target.value})),placeholder:"Describe when agents should apply this playbook",className:"editor-input"})})]}),l.jsx(Je,{label:"Playbook rules",children:l.jsx("textarea",{value:i.body,onChange:a=>n(at(e,t,{body:a.target.value})),className:"editor-textarea",spellCheck:!1})})]})}function Mi({children:e}){return l.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e})}function Je({label:e,children:t,className:n}){return l.jsxs("label",{className:`block space-y-2 ${n??""}`,children:[l.jsx("span",{className:"text-sm font-medium text-foreground",children:e}),t]})}function NI({value:e,onChange:t}){const{data:n}=lp(),o=(n==null?void 0:n.workspaces)??[];return l.jsx(Je,{label:"Workspace",children:l.jsxs("select",{value:e,onChange:i=>t(i.target.value),className:"editor-input",children:[l.jsx("option",{value:"",children:"Ungrouped"}),o.map(i=>l.jsx("option",{value:i,children:i},i))]})})}function EI(e,t){switch(e){case"project":return Ac(t).body;case"assignment":return Dc(t).body;case"plan":return Ic(t).body;case"scratchpad":return Lc(t).body;case"playbook":return Oc(t).body}}function RI(e,t){switch(e){case"project":{const n=Ac(t);return[n.title.trim()?null:"Project title is required.",n.slug.trim()?null:"Project slug is required.",n.slug.trim()&&!nf(n.slug)?"Project slug must be lowercase letters, numbers, and hyphens only.":null].filter(o=>!!o)}case"assignment":{const n=Dc(t);return[n.title.trim()?null:"Assignment title is required.",n.slug.trim()?null:"Assignment slug is required.",n.slug.trim()&&!nf(n.slug)?"Assignment slug must be lowercase letters, numbers, and hyphens only.":null].filter(o=>!!o)}case"plan":return Ic(t).assignment.trim()?[]:["Plan assignment is required."];case"scratchpad":return Lc(t).assignment.trim()?[]:["Scratchpad assignment is required."];case"playbook":{const n=Oc(t);return[n.name.trim()?null:"Playbook name is required.",n.slug.trim()?null:"Playbook slug is required.",n.slug.trim()&&!nf(n.slug)?"Playbook slug must be lowercase letters, numbers, and hyphens only.":null].filter(o=>!!o)}}}function Ty(){const e=Xt(),{workspace:t}=Et(),n=Lt(),[o,i]=g.useState(null),[a,c]=g.useState(!0),[d,p]=g.useState(!1),[h,m]=g.useState(null);g.useEffect(()=>{fetch("/api/templates/project").then(v=>v.json()).then(v=>{let b=v.content;t&&t!=="_ungrouped"&&(b=b.replace(/^(tags: \[\])$/m,`$1
|
|
477
|
-
workspace: ${t}`)),i(b),c(!1)}).catch(v=>{m(v.message),c(!1)})},[t]);async function x(v){p(!0),m(null);try{const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),N=await b.json();if(!b.ok){m(N.error||`HTTP ${b.status}`),p(!1);return}e(`${n}/projects/${N.slug}`)}catch(b){m(b.message),p(!1);return}p(!1)}return a?l.jsx(jt,{label:"Loading project template…"}):h&&!o?l.jsx(vt,{error:h}):l.jsx(pl,{initialContent:o||"",documentType:"project",mode:"create",onSave:x,saving:d,error:h,title:"Create Project",description:"Projects hold the high-level objective, shared context, and human-authored overview. Put execution details in assignments instead of overloading project.md.",onCancel:()=>e(`${n}/projects`),helpTitle:"Project editing rules",helpBody:"Use this form for project intent, slug, tags, and overview content. If you ever need less common metadata, raw markdown mode still exposes the full file.",allowSlugEdit:!0})}function Ay(){const{slug:e}=Et(),t=Lt(),n=Xt(),[o,i]=g.useState(null),[a,c]=g.useState(!0),[d,p]=g.useState(!1),[h,m]=g.useState(null);g.useEffect(()=>{fetch("/api/templates/assignment").then(v=>v.json()).then(v=>{i(v.content),c(!1)}).catch(v=>{m(v.message),c(!1)})},[]);async function x(v){if(!e){m("Project slug is required.");return}p(!0),m(null);try{const b=await fetch(`/api/projects/${e}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),N=await b.json();if(!b.ok){m(N.error||`HTTP ${b.status}`),p(!1);return}n(`${t}/projects/${e}/assignments/${N.slug}`)}catch(b){m(b.message),p(!1);return}p(!1)}return a?l.jsx(jt,{label:"Loading assignment template…"}):h&&!o?l.jsx(vt,{error:h}):l.jsx(pl,{initialContent:o||"",documentType:"assignment",mode:"create",onSave:x,saving:d,error:h,title:"Create Assignment",description:"Assignments are the execution unit. Declare dependencies here, keep status pending until work starts, and use blocked later only for runtime obstacles.",onCancel:()=>n(e?`${t}/projects/${e}`:`${t}/projects`),helpTitle:"Assignment editing rules",helpBody:"Use structured fields for priority, assignee, dependencies, and tags. Status can be changed through lifecycle actions, kanban drag, or the status override.",allowSlugEdit:!0})}function _c({loadUrl:e,saveUrl:t,redirectTo:n,title:o,description:i,documentType:a,helpTitle:c,helpBody:d}){const p=Xt(),{data:h,loading:m,error:x}=Wv(e),[v,b]=g.useState(!1),[N,k]=g.useState(null);async function j(S){b(!0),k(null);try{const T=await fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S})}),A=await T.json();if(!T.ok){k(A.error||`HTTP ${T.status}`),b(!1);return}p(n)}catch(T){k(T.message),b(!1);return}b(!1)}return m?l.jsx(jt,{label:`Loading ${o.toLowerCase()}…`}):x||!h?l.jsx(vt,{error:x||`${o} is unavailable.`}):l.jsx(pl,{initialContent:h.content,documentType:a,onSave:j,saving:v,error:N,title:o,description:i,onCancel:()=>p(n),helpTitle:c,helpBody:d})}function Dy(){const{slug:e}=Et(),t=Lt(),n=e??"";return l.jsx(_c,{loadUrl:`/api/projects/${n}/edit`,saveUrl:`/api/projects/${n}`,redirectTo:`${t}/projects/${n}`,title:"Edit Project",description:"Project edits change the human-authored source document. The structured form stays focused on title, slug, tags, and overview content.",documentType:"project",helpTitle:"Editable vs derived project fields",helpBody:"Project status remains derived from assignment state. If you need less common frontmatter fields, switch to raw markdown mode instead of expanding the structured form."})}function rf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/edit`:`/api/projects/${e}/assignments/${t}/edit`,c=i?`/api/assignments/${n}`:`/api/projects/${e}/assignments/${t}`,d=i?`/assignments/${n}`:`${o}/projects/${e}/assignments/${t}`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Assignment",description:"Edit assignment fields including status, priority, assignee, dependencies, and body.",documentType:"assignment",helpTitle:"Assignment editing",helpBody:"All fields are editable. Status can also be changed through lifecycle actions or kanban drag."})}function of(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/plan/edit`:`/api/projects/${e}/assignments/${t}/plan/edit`,c=i?`/api/assignments/${n}/plan`:`/api/projects/${e}/assignments/${t}/plan`,d=i?`/assignments/${n}?tab=plan`:`${o}/projects/${e}/assignments/${t}?tab=plan`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Plan",description:"Plans are separate from assignment status, so keep implementation steps here instead of overloading the assignment body.",documentType:"plan",helpTitle:"Plan status is separate",helpBody:"Plan status tracks the plan document itself. It does not replace the assignment lifecycle state."})}function sf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/scratchpad/edit`:`/api/projects/${e}/assignments/${t}/scratchpad/edit`,c=i?`/api/assignments/${n}/scratchpad`:`/api/projects/${e}/assignments/${t}/scratchpad`,d=i?`/assignments/${n}?tab=scratchpad`:`${o}/projects/${e}/assignments/${t}?tab=scratchpad`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Scratchpad",description:"Scratchpad is the assignment’s working memory surface for notes, experiments, and temporary context.",documentType:"scratchpad",helpTitle:"Scratchpad usage",helpBody:"Scratchpad is for transient notes. Keep canonical objective and lifecycle data in assignment.md and any active plan files (plan.md, plan-v2.md, ...)."})}function Vw({loadUrl:e,saveUrl:t,redirectTo:n,title:o,description:i,helpTitle:a,helpBody:c}){const d=Xt(),{data:p,loading:h,error:m}=Wv(e),[x,v]=g.useState(""),[b,N]=g.useState(""),[k,j]=g.useState(!1),[S,T]=g.useState(null);async function A(){j(!0),T(null);try{const L=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:x,body:b})}),O=await L.json();if(!L.ok){T(O.error||`HTTP ${L.status}`),j(!1);return}d(n)}catch(L){T(L.message),j(!1);return}j(!1)}return h?l.jsx(jt,{label:`Loading ${o.toLowerCase()}…`}):m||!p?l.jsx(vt,{error:m||`${o} is unavailable.`}):l.jsxs("div",{className:"space-y-4",children:[l.jsx(Pe,{title:o,description:i,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("label",{className:"block space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry title"}),l.jsx("input",{value:x,onChange:L=>v(L.target.value),placeholder:"Optional title",className:"editor-input"})]}),l.jsxs("label",{className:"block space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry body"}),l.jsx("textarea",{value:b,onChange:L=>N(L.target.value),className:"editor-textarea",spellCheck:!1})]}),S?l.jsx("p",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:S}):null,l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsx("button",{type:"button",onClick:()=>d(n),className:"shell-action",children:"Cancel"}),l.jsx("button",{type:"button",onClick:A,disabled:k||!b.trim(),className:"shell-action bg-foreground text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:k?"Appending…":"Append Entry"})]})]})}),l.jsx(Pe,{title:"Current Document",children:l.jsx(Ut,{content:p.content.replace(/^---[\s\S]*?---\n?/,""),emptyState:"No existing content."})})]})}function lf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/handoff/edit`:`/api/projects/${e}/assignments/${t}/handoff/edit`,c=i?`/api/assignments/${n}/handoff/entries`:`/api/projects/${e}/assignments/${t}/handoff/entries`,d=i?`/assignments/${n}?tab=handoff`:`${o}/projects/${e}/assignments/${t}?tab=handoff`;return l.jsx(Vw,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Append Handoff Entry",description:"Add a new handoff without rewriting previous history.",helpTitle:"Append-only handoff history",helpBody:"Handoff log entries preserve the baton-passing trail between sessions and agents. Add a new entry instead of editing older ones."})}function af(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/decision-record/edit`:`/api/projects/${e}/assignments/${t}/decision-record/edit`,c=i?`/api/assignments/${n}/decision-record/entries`:`/api/projects/${e}/assignments/${t}/decision-record/entries`,d=i?`/assignments/${n}?tab=decisions`:`${o}/projects/${e}/assignments/${t}?tab=decisions`;return l.jsx(Vw,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Append Decision Entry",description:"Record a new decision and rationale without editing prior entries.",helpTitle:"Append-only decision history",helpBody:"Decision records should accumulate over time so the implementation rationale remains auditable and reviewable."})}function Iy(){const{workspace:e}=Et(),{data:t}=dc(),{data:n,loading:o,error:i,refetch:a}=ap(),[c,d]=g.useState(!1),[p,h]=g.useState(""),[m,x]=g.useState(!1),v=fn();g.useEffect(()=>{const T=v.hash.match(/^#server-(.+)/);if(!T)return;const A=decodeURIComponent(T[1]),L=document.querySelector(`[data-server-name="${window.CSS.escape(A)}"]`);if(!L)return;L.scrollIntoView({block:"nearest"}),L.classList.add("ring-2","ring-primary/60");const O=window.setTimeout(()=>L.classList.remove("ring-2","ring-primary/60"),1500);return()=>window.clearTimeout(O)},[v.hash,n]);const b=(()=>{if(!e||!n)return(n==null?void 0:n.sessions)??[];if(!t)return[];const T=new Set(t.filter(A=>e==="_ungrouped"?A.workspace===null:A.workspace===e).map(A=>A.slug));return n.sessions.filter(A=>A.windows.some(L=>L.panes.some(O=>O.assignment&&O.assignment.project!==null&&T.has(O.assignment.project))))})();async function N(T){if(T.preventDefault(),!!p.trim())try{await fetch("/api/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim()})}),h(""),d(!1),a()}catch{}}async function k(){x(!0);try{await fetch("/api/servers/refresh",{method:"POST"}),a()}finally{x(!1)}}async function j(T){await fetch(`/api/servers/${encodeURIComponent(T)}`,{method:"DELETE"}),a()}async function S(T){await fetch(`/api/servers/${encodeURIComponent(T)}/refresh`,{method:"POST"}),a()}return o?l.jsx(jt,{label:"Loading servers…"}):i?l.jsx(vt,{error:i}):n?n.tmuxAvailable?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c?l.jsxs("form",{onSubmit:N,className:"flex items-center gap-2",children:[l.jsx("input",{type:"text",value:p,onChange:T=>h(T.target.value),placeholder:"tmux session name",className:"editor-input text-sm",autoFocus:!0}),l.jsx("button",{type:"submit",className:"shell-action",children:"Add"}),l.jsx("button",{type:"button",className:"shell-action",onClick:()=>d(!1),children:"Cancel"})]}):l.jsxs("button",{className:"shell-action",onClick:()=>d(!0),children:[l.jsx(lr,{className:"h-3.5 w-3.5"}),"Track Session"]}),l.jsxs("button",{className:"shell-action",onClick:k,disabled:m,children:[l.jsx(Sv,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`}),"Refresh All"]})]}),b.length===0?l.jsx(Ge,{title:"No sessions tracked",description:"Register a tmux session to start tracking your dev servers."}):l.jsx("div",{className:"mt-4 space-y-4",children:b.map(T=>l.jsx(PI,{session:T,onRefresh:()=>S(T.name),onRemove:()=>j(T.name),onRefetch:a},T.name))})]}):l.jsx(l.Fragment,{children:l.jsxs("div",{className:"surface-panel mt-4 flex flex-col items-center gap-3 py-12 text-center",children:[l.jsx(TC,{className:"h-10 w-10 text-muted-foreground/40"}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:"tmux is not installed"}),l.jsxs("p",{className:"max-w-md text-sm text-muted-foreground",children:["Server tracking requires tmux. Install it with ",l.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"brew install tmux"})," to get started."]})]})}):null}function PI({session:e,onRefresh:t,onRemove:n,onRefetch:o}){return l.jsxs("div",{className:"surface-panel","data-server-name":e.name,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(rp,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),l.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.alive?"border border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:e.alive?"alive":"dead"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last refreshed: ",new Date(e.lastRefreshed).toLocaleString()]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{className:"shell-action",onClick:t,title:"Refresh",children:l.jsx(Sv,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shell-action",onClick:n,title:"Remove",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})]})]}),e.alive&&e.windows.length>0&&l.jsx("div",{className:"mt-3 space-y-3",children:e.windows.map(i=>l.jsxs("div",{children:[l.jsxs("p",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:["Window ",i.index,": ",i.name]}),l.jsx("div",{className:"space-y-1.5",children:i.panes.map(a=>l.jsx(TI,{pane:a,sessionName:e.name,windowIndex:i.index,onRefetch:o},`${i.index}:${a.index}`))})]},i.index))}),!e.alive&&l.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(NC,{className:"h-4 w-4"}),l.jsx("span",{children:e.kind==="process"?"Process no longer running":"Session no longer exists"})]})]})}function TI({pane:e,sessionName:t,windowIndex:n,onRefetch:o}){const i=Lt(),a=e.cwd.replace(/^\/Users\/[^/]+/,"~");return l.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[l.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:[":",e.index]}),l.jsx("span",{className:"shrink-0 rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:e.command}),l.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[l.jsx("span",{className:"truncate",title:e.cwd,children:a}),l.jsx(Hr,{value:e.cwd})]}),e.branch&&l.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[l.jsx(wv,{className:"h-3 w-3"}),e.branch,e.worktree&&l.jsx("span",{className:"rounded bg-violet-100 px-1 py-0.5 text-[10px] font-medium text-violet-700 dark:bg-violet-950/40 dark:text-violet-400",children:"worktree"})]}),e.ports.length>0&&l.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.urls.map(c=>l.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded border border-teal-200 bg-teal-50 px-1.5 py-0.5 text-xs font-medium text-teal-700 hover:bg-teal-100 dark:border-teal-900 dark:bg-teal-950/40 dark:text-teal-400 dark:hover:bg-teal-950/60",children:[c.replace("http://localhost:",":"),l.jsx(bv,{className:"h-2.5 w-2.5"})]},c))}),l.jsx("div",{className:"ml-auto shrink-0",children:e.assignment?l.jsxs(Ce,{to:e.assignment.project===null?`/assignments/${e.assignment.slug}`:`${i}/projects/${e.assignment.project}/assignments/${e.assignment.slug}`,className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20",children:[l.jsx(gC,{className:"h-2.5 w-2.5"}),e.assignment.title,e.assignment.project===null?l.jsx("span",{className:"ml-1 rounded bg-neutral-800/70 px-1 py-0.5 text-[9px] uppercase tracking-wide text-neutral-400",children:"Standalone"}):null]}):l.jsx("span",{className:"text-xs text-muted-foreground/40",children:"unlinked"})})]})}function Ly(){const{workspace:e}=Et(),{data:t}=dc(),{data:n,loading:o,error:i}=jN(),[a,c]=g.useState(""),[d,p]=g.useState(""),[h,m]=g.useState(""),[x,v]=g.useState("started_desc"),[b,N]=g.useState(0),[k,j]=g.useState(new Set),[S,T]=g.useState(!1),[A,L]=g.useState(null),[O,P]=g.useState(null),$=(n==null?void 0:n.sessions.some(Y=>Y.status==="active"))??!1;g.useEffect(()=>{if(!$)return;const Y=window.setInterval(()=>N(X=>X+1),3e4);return()=>window.clearInterval(Y)},[$]),g.useEffect(()=>{j(Y=>{if(Y.size===0)return Y;const X=new Set((n==null?void 0:n.sessions.map(D=>D.sessionId))??[]),_=new Set([...Y].filter(D=>X.has(D)));return _.size===Y.size?Y:_})},[n]);const E=g.useMemo(()=>{if(!n)return[];if(e&&!t)return[];const Y=a.trim().toLowerCase();return[...n.sessions.filter(_=>{var W;if(e&&t){const ee=((W=t.find(R=>R.slug===_.projectSlug))==null?void 0:W.workspace)??null;if(e==="_ungrouped"){if(ee!==null)return!1}else if(ee!==e)return!1}const D=DI(_.started);return d&&(!D||D<d)||h&&(!D||D>h)?!1:Y?[_.projectSlug??"",_.assignmentSlug??"",_.agent,_.sessionId,_.path,_.description??"",_.transcriptPath??""].join(" ").toLowerCase().includes(Y):!0})].sort((_,D)=>II(_,D,x))},[n,a,x,d,h,b,e,t]);function H(Y){j(X=>{const _=new Set(X);return _.has(Y)?_.delete(Y):_.add(Y),_})}function Z(){k.size===E.length&&E.length>0?j(new Set):j(new Set(E.map(Y=>Y.sessionId)))}async function G(Y){L(null),T(!0);try{const X=await fetch("/api/agent-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionIds:Y})}),_=await X.json().catch(()=>null);if(!X.ok)throw new Error((_==null?void 0:_.error)||`HTTP ${X.status}`);j(D=>new Set([...D].filter(V=>!Y.includes(V)))),P(null)}catch(X){L(X.message)}finally{T(!1)}}if(o)return l.jsx(jt,{label:"Loading agent sessions..."});if(i)return l.jsx(vt,{error:i});if(!n)return null;const q=n.sessions.length>0;return l.jsxs(l.Fragment,{children:[l.jsxs(wp,{children:[l.jsx(vc,{value:a,onChange:c,placeholder:"Search project, assignment, agent, session ID, path, or description"}),l.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started From",l.jsx("input",{type:"date",value:d,onChange:Y=>p(Y.target.value),className:"editor-input min-w-[150px]"})]}),l.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started To",l.jsx("input",{type:"date",value:h,onChange:Y=>m(Y.target.value),className:"editor-input min-w-[150px]"})]}),l.jsxs("select",{value:x,onChange:Y=>v(Y.target.value),className:"editor-input max-w-[200px]",children:[l.jsx("option",{value:"started_desc",children:"Newest first"}),l.jsx("option",{value:"started_asc",children:"Oldest first"}),l.jsx("option",{value:"assignment_asc",children:"Assignment A-Z"}),l.jsx("option",{value:"agent_asc",children:"Agent A-Z"})]})]}),A?l.jsx("div",{className:"mt-4 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:A}):null,k.size>0&&l.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded border border-border/40 bg-muted/30 px-4 py-2 text-sm",children:[l.jsxs("span",{className:"text-muted-foreground",children:[k.size," session",k.size!==1?"s":""," selected"]}),l.jsxs("button",{className:"shell-action text-destructive",onClick:()=>P({sessionIds:[...k],title:`Delete ${k.size} selected session${k.size===1?"":"s"}?`,description:"This removes the selected agent session records from the dashboard. This cannot be undone.",confirmLabel:k.size===1?"Delete Session":"Delete Sessions"}),disabled:S,children:[l.jsx(Ms,{className:"mr-1 inline h-3.5 w-3.5"}),"Delete Selected"]}),l.jsx("button",{className:"shell-action",onClick:()=>j(new Set),children:"Clear Selection"})]}),q?E.length===0?l.jsx(Ge,{title:"No agent sessions match these filters",description:"Adjust the status, search term, date range, or sorting controls to show sessions again."}):l.jsx("div",{className:"surface-panel mt-4 overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[1040px] text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/40 text-left text-xs uppercase tracking-wider text-muted-foreground",children:[l.jsx("th",{className:"w-8 pb-2 pr-3",children:l.jsx("button",{onClick:Z,className:"text-muted-foreground hover:text-foreground",children:k.size===E.length&&E.length>0?l.jsx(Sr,{className:"h-4 w-4"}):l.jsx(Cv,{className:"h-4 w-4"})})}),l.jsx("th",{className:"pb-2 pr-3",children:"Project"}),l.jsx("th",{className:"pb-2 pr-3",children:"Assignment"}),l.jsx("th",{className:"pb-2 pr-3",children:"Description"}),l.jsx("th",{className:"pb-2 pr-3",children:"Agent"}),l.jsx("th",{className:"pb-2 pr-3",children:"Session ID"}),l.jsx("th",{className:"pb-2 pr-3",children:"Started"}),l.jsx("th",{className:"pb-2 pr-3",children:"Path"}),l.jsx("th",{className:"pb-2 pr-3",children:"Transcript"}),l.jsx("th",{className:"w-8 pb-2"})]})}),l.jsx("tbody",{children:E.map(Y=>l.jsx(AI,{session:Y,selected:k.has(Y.sessionId),onToggle:()=>H(Y.sessionId),onDelete:()=>P({sessionIds:[Y.sessionId],title:`Delete session ${Y.sessionId.slice(0,8)}...?`,description:`Remove this ${Y.agent} session record${Y.assignmentSlug?` for ${Y.assignmentSlug}`:""}. This cannot be undone.`,confirmLabel:"Delete Session"})},Y.sessionId))})]})}):l.jsx(Ge,{title:"No agent sessions",description:"No agent sessions have been registered yet. Use /grab-assignment or syntaur track-session to register one."}),l.jsx(ow,{open:O!==null,title:(O==null?void 0:O.title)??"Delete session?",description:(O==null?void 0:O.description)??"",confirmLabel:(O==null?void 0:O.confirmLabel)??"Delete",destructive:!0,loading:S,onOpenChange:Y=>{Y||P(null)},onConfirm:async()=>{O&&await G(O.sessionIds)}})]})}function AI({session:e,selected:t,onToggle:n,onDelete:o}){const i=Lt(),a=e.sessionId.length>12?e.sessionId.slice(0,8)+"...":e.sessionId,c=e.path?e.path.replace(/^\/Users\/[^/]+/,"~"):"—",d=e.transcriptPath?e.transcriptPath.replace(/^\/Users\/[^/]+/,"~"):"—";return l.jsxs("tr",{className:"border-b border-border/20 last:border-0",children:[l.jsx("td",{className:"py-2 pr-3",children:l.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-foreground",children:t?l.jsx(Sr,{className:"h-4 w-4"}):l.jsx(Cv,{className:"h-4 w-4"})})}),l.jsx("td",{className:"py-2 pr-3",children:e.projectSlug?l.jsx(Ce,{to:`${i}/projects/${e.projectSlug}`,className:"text-primary hover:underline",children:Cn(e.projectSlug)}):e.assignmentSlug?l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-neutral-300",children:"Standalone"}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2 pr-3",children:e.projectSlug&&e.assignmentSlug?l.jsx(Ce,{to:`${i}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`,className:"text-primary hover:underline",children:Cn(e.assignmentSlug)}):e.assignmentSlug?l.jsx(Ce,{to:`/assignments/${e.assignmentSlug}`,className:"text-primary hover:underline font-mono",children:e.assignmentSlug}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"max-w-[200px] py-2 pr-3",children:e.description?l.jsx("span",{className:"truncate text-xs text-muted-foreground",title:e.description,children:e.description.length>60?e.description.slice(0,57)+"...":e.description}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx(uc,{className:"h-3 w-3 text-muted-foreground"}),e.agent]})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"font-mono text-xs text-muted-foreground",title:e.sessionId,children:a}),l.jsx(Hr,{value:e.sessionId})]})}),l.jsx("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:Cr(e.started)}),l.jsx("td",{className:"max-w-[240px] py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate text-xs text-muted-foreground",title:e.path,children:c}),e.path&&l.jsx(Hr,{value:e.path})]})}),l.jsx("td",{className:"max-w-[260px] py-2 pr-3",children:e.transcriptPath?l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:e.transcriptPath,children:d}),l.jsx(Hr,{value:e.transcriptPath})]}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2",children:l.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-destructive",title:"Delete session",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})})]})}function DI(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${i}`}function Ia(e){const t=Date.parse(e.started),n=e.ended?Date.parse(e.ended):Date.now();return Number.isNaN(t)||Number.isNaN(n)?0:Math.max(0,Math.floor((n-t)/6e4))}function II(e,t,n){switch(n){case"started_asc":return e.started.localeCompare(t.started);case"started_desc":return t.started.localeCompare(e.started);case"duration_asc":return Ia(e)-Ia(t);case"duration_desc":return Ia(t)-Ia(e);case"assignment_asc":return(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"")||(e.projectSlug??"").localeCompare(t.projectSlug??"");case"agent_asc":return e.agent.localeCompare(t.agent)||(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"");default:return 0}}function LI(){const{data:e,loading:t,error:n}=Vv(),[o,i]=g.useState(""),a=g.useMemo(()=>{if(!(e!=null&&e.playbooks))return[];if(!o.trim())return e.playbooks;const c=o.toLowerCase();return e.playbooks.filter(d=>d.name.toLowerCase().includes(c)||d.description.toLowerCase().includes(c)||d.slug.toLowerCase().includes(c)||d.tags.some(p=>p.toLowerCase().includes(c)))},[e,o]);return t?l.jsx(jt,{label:"Loading playbooks..."}):n?l.jsx(vt,{error:n}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsxs("div",{className:"relative flex-1 max-w-sm",children:[l.jsx(sl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l.jsx("input",{type:"text",placeholder:"Search playbooks...",value:o,onChange:c=>i(c.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),l.jsxs(Ce,{to:"/playbooks/create",className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[l.jsx(lr,{className:"h-4 w-4"}),"Create Playbook"]})]}),l.jsxs(Ce,{to:"/playbooks/manifest",className:"surface-panel group flex items-center gap-3 p-3 transition hover:border-foreground/20",children:[l.jsx(cC,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:"Playbook Manifest"}),l.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:"auto-generated"})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Index of all playbooks with descriptions. Include ",l.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px]",children:"~/.syntaur/playbooks/manifest.md"})," in your CLAUDE.md for agent context."]})]})]}),a.length===0?l.jsx(Ge,{title:"No playbooks found",description:(e==null?void 0:e.playbooks.length)===0?"Playbooks define rules and workflows for how agents should operate. Create your first one to get started.":"No playbooks match your search.",actions:(e==null?void 0:e.playbooks.length)===0?l.jsxs(Ce,{to:"/playbooks/create",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[l.jsx(lr,{className:"h-4 w-4"}),"Create Playbook"]}):void 0}):l.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:a.map(c=>l.jsxs(Ce,{to:`/playbooks/${c.slug}`,className:"surface-panel group flex flex-col gap-2 p-4 transition hover:border-foreground/20",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(yv,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:c.name}),c.description?l.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground line-clamp-2",children:c.description}):null]})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.tags.slice(0,3).map(d=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:[l.jsx(Nv,{className:"h-2.5 w-2.5"}),d]},d)),c.tags.length>3?l.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["+",c.tags.length-3]}):null]}),l.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",children:Vr(c.updated)})]})]},c.slug))})]})}function OI(){const{slug:e}=Et(),t=Xt(),{data:n,loading:o,error:i}=CN(e),[a,c]=g.useState(!1),[d,p]=g.useState(!1),h=e==="manifest";async function m(){if(e){p(!0);try{(await fetch(`/api/playbooks/${e}`,{method:"DELETE"})).ok&&t("/playbooks")}finally{p(!1)}}}return o?l.jsx(jt,{label:"Loading playbook..."}):i?l.jsx(vt,{error:i}):n?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:h?"Playbook Manifest":n.name}),h?l.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:"auto-generated"}):null]}),!h&&n.description?l.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:n.description}):null,h?l.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["This file is rebuilt automatically when playbooks are added or removed. Include"," ",l.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.syntaur/playbooks/manifest.md"})," ","in your CLAUDE.md for agent context."]}):null,!h&&n.whenToUse?l.jsxs("p",{className:"mt-2 text-sm text-muted-foreground italic",children:["When to use: ",n.whenToUse]}):null,l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[l.jsxs("span",{children:["Created ",Cr(n.created)]}),l.jsxs("span",{children:["Updated ",Cr(n.updated)]})]}),n.tags.length>0?l.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:n.tags.map(x=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:[l.jsx(Nv,{className:"h-3 w-3"}),x]},x))}):null]}),h?null:l.jsxs("div",{className:"flex shrink-0 gap-2",children:[l.jsxs(Ce,{to:`/playbooks/${e}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[l.jsx(wC,{className:"h-3 w-3"}),"Edit"]}),a?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:m,disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-red-600 px-3 text-xs font-medium text-white transition hover:bg-red-700 disabled:opacity-50",children:d?"Deleting...":"Confirm"}),l.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):l.jsxs("button",{type:"button",onClick:()=>c(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-red-600 transition hover:bg-red-50 dark:hover:bg-red-950/30",children:[l.jsx(Ms,{className:"h-3 w-3"}),"Delete"]})]})]}),l.jsx("div",{className:"surface-panel p-4",children:l.jsx(Ut,{content:n.body})})]}):null}function _I(){const e=Xt(),[t,n]=g.useState(null),[o,i]=g.useState(!0),[a,c]=g.useState(!1),[d,p]=g.useState(null);g.useEffect(()=>{fetch("/api/playbooks/template/new").then(m=>m.json()).then(m=>{n(m.content),i(!1)}).catch(m=>{p(m.message),i(!1)})},[]);async function h(m){c(!0),p(null);try{const x=await fetch("/api/playbooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),v=await x.json();if(!x.ok){p(v.error||`HTTP ${x.status}`),c(!1);return}e(`/playbooks/${v.slug}`)}catch(x){p(x.message),c(!1);return}c(!1)}return o?l.jsx(jt,{label:"Loading playbook template..."}):d&&!t?l.jsx(vt,{error:d}):l.jsx(pl,{initialContent:t||"",documentType:"playbook",mode:"create",onSave:h,saving:a,error:d,title:"Create Playbook",description:"Playbooks define rules and workflows for how agents should operate. Keep them short, imperative, and focused on a single concern.",onCancel:()=>e("/playbooks"),allowSlugEdit:!0})}function MI(){const{slug:e}=Et(),t=Xt(),[n,o]=g.useState(null),[i,a]=g.useState(!0),[c,d]=g.useState(!1),[p,h]=g.useState(null);g.useEffect(()=>{e&&fetch(`/api/playbooks/${e}/edit`).then(x=>x.json()).then(x=>{o(x.content),a(!1)}).catch(x=>{h(x.message),a(!1)})},[e]);async function m(x){if(e){d(!0),h(null);try{const v=await fetch(`/api/playbooks/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}),b=await v.json();if(!v.ok){h(b.error||`HTTP ${v.status}`),d(!1);return}t(`/playbooks/${e}`)}catch(v){h(v.message),d(!1);return}d(!1)}}return i?l.jsx(jt,{label:"Loading playbook..."}):p&&!n?l.jsx(vt,{error:p}):l.jsx(pl,{initialContent:n||"",documentType:"playbook",mode:"edit",onSave:m,saving:c,error:p,title:"Edit Playbook",onCancel:()=>t(`/playbooks/${e}`)})}function $I({value:e,onChange:t}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"color",value:e||"#64748b",onChange:n=>t(n.target.value),className:"h-7 w-7 shrink-0 cursor-pointer rounded-md border border-border/60 bg-transparent p-0.5",title:"Pick a color"}),l.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),placeholder:"#64748b",className:"editor-input w-[5.5rem] font-mono text-xs"})]})}const zf=["projects","playbooks","todos","servers","config"];function FI(e){const t=new Set;for(const n of e.split(",").map(o=>o.trim()))zf.includes(n)&&t.add(n);return t}function Oy(e){if(!e)return"never";try{return new Date(e).toLocaleString()}catch{return e}}function zI(){const[e,t]=g.useState(!0),[n,o]=g.useState(null),[i,a]=g.useState(""),[c,d]=g.useState(new Set(zf)),[p,h]=g.useState(!1),[m,x]=g.useState(!1),[v,b]=g.useState(null),[N,k]=g.useState(null),j=g.useCallback(async()=>{try{const P=await fetch("/api/backup");if(!P.ok)throw new Error(`HTTP ${P.status}`);const $=await P.json();o($),a($.repo??""),d(FI($.categories)),h(!1)}catch(P){k({type:"error",message:`Failed to load backup config: ${P instanceof Error?P.message:String(P)}`})}finally{t(!1)}},[]);g.useEffect(()=>{j()},[j]);function S(P){d($=>{const E=new Set($);return E.has(P)?E.delete(P):E.add(P),E}),h(!0)}async function T(){x(!0),k(null);try{const P=Array.from(c),$=await fetch("/api/backup/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:i.trim()||null,categories:P})}),E=await $.json();if(!$.ok)throw new Error(E.error||`HTTP ${$.status}`);o(E),h(!1),k({type:"success",message:"Backup configuration saved."})}catch(P){k({type:"error",message:`Save failed: ${P instanceof Error?P.message:String(P)}`})}finally{x(!1)}}async function A(){b("push"),k(null);try{const P=await fetch("/api/backup/push",{method:"POST"}),$=await P.json();if(!P.ok||$.success===!1)throw new Error($.error||$.message||`HTTP ${P.status}`);k({type:"success",message:$.message||"Backup complete."}),await j()}catch(P){k({type:"error",message:`Backup failed: ${P instanceof Error?P.message:String(P)}`})}finally{b(null)}}async function L(){if(window.confirm("Restore will overwrite local files for the selected categories with the contents of the GitHub repo. This cannot be undone. Continue?")){b("pull"),k(null);try{const $=await fetch("/api/backup/pull",{method:"POST"}),E=await $.json();if(!$.ok||E.success===!1)throw new Error(E.error||E.message||`HTTP ${$.status}`);k({type:"success",message:E.message||"Restore complete."}),await j()}catch($){k({type:"error",message:`Restore failed: ${$ instanceof Error?$.message:String($)}`})}finally{b(null)}}}if(e)return l.jsx(Pe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})});const O=!!i.trim()&&c.size>0&&!v&&!p;return l.jsx(Pe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository and restore from it",children:l.jsxs("div",{className:"space-y-4",children:[N&&l.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${N.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:N.message}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repository URL"}),l.jsx("input",{type:"text",value:i,onChange:P=>{a(P.target.value),h(!0)},placeholder:"git@github.com:you/syntaur-backup.git",className:"editor-input w-full text-sm"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["SSH or HTTPS URL. Requires ",l.jsx("code",{className:"rounded bg-muted px-1",children:"git"})," installed and credentials configured locally."]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Categories to back up"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:zf.map(P=>{const $=c.has(P);return l.jsxs("button",{type:"button",onClick:()=>S(P),className:`shell-action text-xs ${$?"bg-primary/10 text-primary hover:bg-primary/20":"bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:[l.jsx("span",{className:`mr-1 inline-block h-2 w-2 rounded-full ${$?"bg-primary":"bg-muted-foreground/40"}`}),P]},P)})})]}),l.jsxs("div",{className:"grid grid-cols-1 gap-2 text-xs text-muted-foreground sm:grid-cols-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Last backup: "}),Oy((n==null?void 0:n.lastBackup)??null)]}),l.jsxs("div",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Last restore: "}),Oy((n==null?void 0:n.lastRestore)??null)]}),(n==null?void 0:n.locked)&&l.jsx("div",{className:"sm:col-span-2 text-amber-600 dark:text-amber-400",children:"⚠ A backup operation is in progress or the lock file is stale."})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[l.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:T,disabled:m||!p,children:[l.jsx(op,{className:"h-3.5 w-3.5"}),m?"Saving...":"Save Config"]}),l.jsxs("button",{className:"shell-action",onClick:A,disabled:!O,title:O?"Back up now":p?"Save config first":"Set repo and pick categories",children:[l.jsx(AC,{className:"h-3.5 w-3.5"}),v==="push"?"Backing up...":"Back Up Now"]}),l.jsxs("button",{className:"shell-action",onClick:L,disabled:!O,title:O?"Restore from backup":p?"Save config first":"Set repo and pick categories",children:[l.jsx(sC,{className:"h-3.5 w-3.5"}),v==="pull"?"Restoring...":"Restore"]}),p&&l.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]}),l.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-border/40 bg-muted/20 p-3 text-xs text-muted-foreground",children:[l.jsx(rC,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsxs("span",{children:["Restore never overwrites ",l.jsx("code",{className:"rounded bg-muted px-1",children:"config.md"})," (would clobber backup settings). The agent sessions database is not backed up — only markdown files."]})]})]})})}function cf(e){return{statuses:e.statuses.map(t=>({id:t.id,label:t.label,description:t.description??"",color:t.color??"",terminal:t.terminal??!1})),order:[...e.order]}}function BI(){const[e,t]=g.useState(!0),[n,o]=g.useState(null),[i,a]=g.useState(!1),[c,d]=g.useState([]),[p,h]=g.useState([]),[m,x]=g.useState(!1),[v,b]=g.useState(null),[N,k]=g.useState(!1),j=g.useCallback(async()=>{try{const E=await fetch("/api/config/statuses");if(!E.ok)throw new Error(`HTTP ${E.status}`);const H=await E.json(),Z=cf(H);d(Z.statuses),h(Z.order),a(H.custom),k(!1),o(null)}catch(E){o(E instanceof Error?E.message:"Failed to load config")}finally{t(!1)}},[]);g.useEffect(()=>{j()},[j]);function S(){setTimeout(()=>b(null),3e3)}async function T(){x(!0),b(null);try{const E={statuses:c.map(q=>({id:q.id,label:q.label,...q.description?{description:q.description}:{},...q.color?{color:q.color}:{},...q.terminal?{terminal:!0}:{}})),order:p,transitions:[]},H=await fetch("/api/config/statuses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!H.ok){const q=await H.json().catch(()=>({error:"Unknown error"}));throw new Error(q.error??"Save failed")}const Z=await H.json(),G=cf(Z);d(G.statuses),h(G.order),a(Z.custom),k(!1),kx(),b({type:"success",message:"Status config saved"}),S()}catch(E){b({type:"error",message:E instanceof Error?E.message:"Save failed"})}finally{x(!1)}}async function A(){x(!0),b(null);try{const E=await fetch("/api/config/statuses",{method:"DELETE"});if(!E.ok)throw new Error("Reset failed");const H=await E.json(),Z=cf(H);d(Z.statuses),h(Z.order),a(H.custom),k(!1),kx(),b({type:"success",message:"Reset to defaults"}),S()}catch(E){b({type:"error",message:E instanceof Error?E.message:"Reset failed"})}finally{x(!1)}}function L(E,H,Z){d(G=>{const q=[...G];if(q[E]={...q[E],[H]:Z},H==="id"&&typeof Z=="string"){const Y=G[E].id;h(X=>X.map(_=>_===Y?Z:_))}return q}),k(!0)}function O(){const E=`status_${c.length+1}`;d(H=>[...H,{id:E,label:"New Status",description:"",color:"",terminal:!1}]),h(H=>[...H,E]),k(!0)}function P(E){const H=c[E].id;d(Z=>Z.filter((G,q)=>q!==E)),h(Z=>Z.filter(G=>G!==H)),k(!0)}function $(E,H){const Z=E+H;Z<0||Z>=p.length||(h(G=>{const q=[...G];return[q[E],q[Z]]=[q[Z],q[E]],q}),k(!0))}return e?l.jsx(jt,{label:"Loading settings..."}):n?l.jsx(vt,{error:n}):l.jsx(Mw,{children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:`flex items-center justify-between rounded-lg border px-4 py-3 text-sm ${i?"border-primary/30 bg-primary/5 text-primary":"border-border/60 bg-muted/30 text-muted-foreground"}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(kv,{className:"h-4 w-4"}),i?"Using custom status configuration from ~/.syntaur/config.md":"Using default status configuration"]}),l.jsxs("button",{className:"shell-action text-xs",onClick:A,disabled:m||!i&&!N,children:[l.jsx(jC,{className:"h-3 w-3"}),"Reset to Defaults"]})]}),v&&l.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${v.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:v.message}),l.jsx(Pe,{title:"Status Definitions",description:"Define the statuses assignments can have",actions:l.jsxs("button",{className:"shell-action text-xs",onClick:O,children:[l.jsx(lr,{className:"h-3 w-3"}),"Add Status"]}),children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/50 text-left text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[l.jsx("th",{className:"pb-2 pr-3",children:"ID"}),l.jsx("th",{className:"pb-2 pr-3",children:"Label"}),l.jsx("th",{className:"pb-2 pr-3",children:"Color"}),l.jsx("th",{className:"pb-2 pr-3",children:l.jsxs($w,{children:[l.jsx(Fw,{asChild:!0,children:l.jsx("span",{className:"cursor-help underline decoration-dotted underline-offset-4",children:"Done State"})}),l.jsx(Xp,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:'When enabled, assignments in this status count as finished — they fill the "done" portion of progress bars and satisfy dependency requirements.'})]})}),l.jsx("th",{className:"pb-2 w-10"})]})}),l.jsx("tbody",{className:"divide-y divide-border/30",children:c.map((E,H)=>l.jsxs("tr",{children:[l.jsx("td",{className:"py-2 pr-3",children:l.jsx("input",{type:"text",value:E.id,onChange:Z=>L(H,"id",Z.target.value),className:"editor-input w-full text-sm"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx("input",{type:"text",value:E.label,onChange:Z=>L(H,"label",Z.target.value),className:"editor-input w-full text-sm"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx($I,{value:E.color,onChange:Z=>L(H,"color",Z)})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx("button",{type:"button",role:"switch","aria-checked":E.terminal,onClick:()=>L(H,"terminal",!E.terminal),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${E.terminal?"bg-primary":"bg-muted"}`,children:l.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${E.terminal?"translate-x-4":"translate-x-0"}`})})}),l.jsx("td",{className:"py-2",children:l.jsx("button",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>P(H),title:"Remove status",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})})]},H))})]})})}),l.jsx(Pe,{title:"Status Order",description:"Controls display order in the dashboard (Kanban columns, progress bars, dropdowns)",children:l.jsx("div",{className:"space-y-1",children:p.map((E,H)=>{var G;const Z=((G=c.find(q=>q.id===E))==null?void 0:G.label)??E;return l.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[l.jsx("span",{className:"mr-1 font-mono text-xs text-muted-foreground/60",children:H+1}),l.jsx("span",{className:"flex-1 font-medium",children:Z}),l.jsx("span",{className:"text-xs text-muted-foreground",children:E}),l.jsx("button",{className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-30",onClick:()=>$(H,-1),disabled:H===0,title:"Move up",children:l.jsx(vv,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-30",onClick:()=>$(H,1),disabled:H===p.length-1,title:"Move down",children:l.jsx(Yi,{className:"h-3.5 w-3.5"})})]},H)})})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:T,disabled:m||!N,children:[l.jsx(op,{className:"h-3.5 w-3.5"}),m?"Saving...":"Save Configuration"]}),N&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"shell-action text-xs",onClick:()=>{t(!0),j()},disabled:m,children:"Discard Changes"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]})]}),l.jsx(zI,{})]})})}const _y=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-blue-400"},{value:"completed",icon:"✓",label:"Completed",color:"text-emerald-400"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-amber-400"}];function qw({status:e,onChange:t}){const[n,o]=g.useState(!1),i=g.useRef(null);g.useEffect(()=>{if(!n)return;function c(d){i.current&&!i.current.contains(d.target)&&o(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const a=_y.find(c=>c.value===e);return l.jsxs("div",{className:"relative",ref:i,onClick:c=>c.stopPropagation(),children:[l.jsx("button",{onClick:()=>o(!n),className:`text-lg leading-none ${a.color} hover:opacity-70 transition`,title:a.label,children:a.icon}),n&&l.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:_y.filter(c=>c.value!==e).map(c=>l.jsxs("button",{onClick:()=>{t(c.value),o(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${c.color}`,children:[l.jsx("span",{className:"text-base leading-none",children:c.icon}),l.jsx("span",{children:c.label})]},c.value))})]})}function UI(){const{data:e,loading:t,error:n,refetch:o}=cp(),[i,a]=g.useState(""),c=g.useRef(null);zs("list:todos");const[d,p]=g.useState(""),[h,m]=g.useState(""),[x,v]=g.useState(""),[b,N]=g.useState("_global"),[k,j]=g.useState(null);function S(_,D){_.stopPropagation(),navigator.clipboard.writeText(D),j(D),setTimeout(()=>j(V=>V===D?null:V),1500)}const T=g.useMemo(()=>{if(!(e!=null&&e.workspaces))return[];const _=[];for(const D of e.workspaces)for(const V of D.items)_.push({...V,workspace:D.workspace});return _},[e]),A=g.useMemo(()=>{const _=new Set;for(const D of T)for(const V of D.tags)_.add(V);return Array.from(_).sort()},[T]),L=g.useMemo(()=>{let _=T;if(i.trim()){const D=i.toLowerCase();_=_.filter(V=>V.description.toLowerCase().includes(D)||V.tags.some(W=>W.toLowerCase().includes(D))||V.id.includes(D))}return d&&(_=_.filter(D=>D.status===d)),h&&(_=_.filter(D=>D.tags.includes(h))),_},[T,i,d,h]),O=g.useMemo(()=>{if(!(e!=null&&e.workspaces))return{open:0,in_progress:0,completed:0,blocked:0,total:0};const _={open:0,in_progress:0,completed:0,blocked:0,total:0};for(const D of e.workspaces)_.open+=D.counts.open,_.in_progress+=D.counts.in_progress,_.completed+=D.counts.completed,_.blocked+=D.counts.blocked,_.total+=D.counts.total;return _},[e]);async function P(){x.trim()&&(await qv(b,x.trim()),v(""),o())}const $={open:"in_progress",in_progress:"completed",completed:"open",blocked:"open"};function E(_,D,V){H(_,D,$[V]||"open")}async function H(_,D,V){switch(V){case"open":await Xv(_,D);break;case"in_progress":await Yv(_,D);break;case"completed":await Kv(_,D);break;case"blocked":await Gv(_,D);break}o()}async function Z(_,D){await PN(_,D),o()}const{hotkeyRowProps:G}=yc(L,{scope:"list:todos",bindO:!1,onOpen:_=>E(_.workspace,_.id,_.status)});yt({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var _;return(_=c.current)==null?void 0:_.focus()}}),yt({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>o()});const[q,Y]=_s(),X=q.get("focus");return g.useEffect(()=>{if(!X)return;const _=document.querySelector(`[data-todo-id="${CSS.escape(X)}"]`);if(!_)return;_.scrollIntoView({block:"nearest"}),_.classList.add("ring-2","ring-primary/60");const D=window.setTimeout(()=>{_.classList.remove("ring-2","ring-primary/60"),Y(V=>{const W=new URLSearchParams(V);return W.delete("focus"),W})},1500);return()=>window.clearTimeout(D)},[X,L.length,Y]),t?l.jsx(jt,{label:"Loading todos..."}):n?l.jsx(vt,{error:n}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[l.jsx(it,{label:"Open",value:O.open,icon:Sr}),l.jsx(it,{label:"In Progress",value:O.in_progress,icon:jv,tone:"info"}),l.jsx(it,{label:"Blocked",value:O.blocked,icon:il,tone:"warn"}),l.jsx(it,{label:"Completed",value:O.completed,icon:Sr,tone:"default"})]}),l.jsx("div",{className:"surface-panel p-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("select",{value:b,onChange:_=>N(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"_global",children:"Global"}),e==null?void 0:e.workspaces.filter(_=>_.workspace!=="_global").map(_=>l.jsx("option",{value:_.workspace,children:_.workspace},_.workspace))]}),l.jsx("input",{type:"text",placeholder:"Add a todo...",value:x,onChange:_=>v(_.target.value),onKeyDown:_=>_.key==="Enter"&&P(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),l.jsxs("button",{onClick:P,disabled:!x.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[l.jsx(lr,{className:"h-4 w-4"}),"Add"]})]})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative flex-1 max-w-sm",children:[l.jsx(sl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l.jsx("input",{ref:c,type:"text",placeholder:"Search todos...",value:i,onChange:_=>a(_.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),l.jsxs("select",{value:d,onChange:_=>p(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"",children:"All statuses"}),l.jsx("option",{value:"open",children:"Open"}),l.jsx("option",{value:"in_progress",children:"In Progress"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"blocked",children:"Blocked"})]}),A.length>0&&l.jsxs("select",{value:h,onChange:_=>m(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"",children:"All tags"}),A.map(_=>l.jsxs("option",{value:_,children:["#",_]},_))]})]}),L.length===0?l.jsx(Ge,{title:"No todos",description:"Add your first todo above or use the CLI: syntaur todo add"}):l.jsx("div",{className:"space-y-1",children:L.map((_,D)=>l.jsxs("div",{"data-todo-id":_.id,...G(D),className:"surface-panel flex items-center gap-3 px-3 py-2 group cursor-pointer hover:bg-foreground/[0.03] transition",onClick:()=>E(_.workspace,_.id,_.status),children:[l.jsx(qw,{status:_.status,onChange:V=>H(_.workspace,_.id,V)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:`text-sm ${_.status==="completed"?"line-through text-muted-foreground":"text-foreground"}`,children:_.description}),_.tags.length>0&&l.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:_.tags.map(V=>`#${V}`).join(" ")})]}),l.jsx("span",{className:"text-xs text-muted-foreground/60 font-mono",children:_.workspace!=="_global"&&l.jsx(Ce,{to:`/w/${_.workspace}/todos`,className:"hover:text-foreground transition mr-2",onClick:V=>V.stopPropagation(),children:_.workspace})}),k===_.id?l.jsxs("span",{className:"text-xs text-emerald-400 flex items-center gap-1",children:[l.jsx(Zf,{className:"h-3 w-3"})," Copied to clipboard"]}):l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:V=>S(V,_.id),children:["t:",_.id]}),l.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:V=>S(V,_.id),children:l.jsx(tp,{className:"h-3 w-3"})})]}),l.jsx("button",{onClick:()=>Z(_.workspace,_.id),className:"text-xs text-muted-foreground/40 hover:text-red-400 transition opacity-0 group-hover:opacity-100",children:"delete"})]},`${_.workspace}-${_.id}`))})]})}function HI(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>o=>{t.forEach(i=>i(o))},t)}const Mc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vs(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Qp(e){return"nodeType"in e}function Rn(e){var t,n;return e?Vs(e)?e:Qp(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Jp(e){const{Document:t}=Rn(e);return e instanceof t}function hl(e){return Vs(e)?!1:e instanceof Rn(e).HTMLElement}function Kw(e){return e instanceof Rn(e).SVGElement}function qs(e){return e?Vs(e)?e.document:Qp(e)?Jp(e)?e:hl(e)||Kw(e)?e.ownerDocument:document:document:document}const Rr=Mc?g.useLayoutEffect:g.useEffect;function Zp(e){const t=g.useRef(e);return Rr(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return t.current==null?void 0:t.current(...o)},[])}function WI(){const e=g.useRef(null),t=g.useCallback((o,i)=>{e.current=setInterval(o,i)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Zi(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return Rr(()=>{n.current!==e&&(n.current=e)},t),n}function ml(e,t){const n=g.useRef();return g.useMemo(()=>{const o=e(n.current);return n.current=o,o},[...t])}function rc(e){const t=Zp(e),n=g.useRef(null),o=g.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,o]}function Bf(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let uf={};function gl(e,t){return g.useMemo(()=>{if(t)return t;const n=uf[e]==null?0:uf[e]+1;return uf[e]=n,e+"-"+n},[e,t])}function Gw(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return o.reduce((a,c)=>{const d=Object.entries(c);for(const[p,h]of d){const m=a[p];m!=null&&(a[p]=m+e*h)}return a},{...t})}}const As=Gw(1),oc=Gw(-1);function VI(e){return"clientX"in e&&"clientY"in e}function eh(e){if(!e)return!1;const{KeyboardEvent:t}=Rn(e.target);return t&&e instanceof t}function qI(e){if(!e)return!1;const{TouchEvent:t}=Rn(e.target);return t&&e instanceof t}function Uf(e){if(qI(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return VI(e)?{x:e.clientX,y:e.clientY}:null}const el=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[el.Translate.toString(e),el.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:o}=e;return t+" "+n+"ms "+o}}}),My="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function KI(e){return e.matches(My)?e:e.querySelector(My)}const GI={display:"none"};function YI(e){let{id:t,value:n}=e;return xt.createElement("div",{id:t,style:GI},n)}function XI(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return xt.createElement("div",{id:t,style:i,role:"status","aria-live":o,"aria-atomic":!0},n)}function QI(){const[e,t]=g.useState("");return{announce:g.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Yw=g.createContext(null);function JI(e){const t=g.useContext(Yw);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ZI(){const[e]=g.useState(()=>new Set),t=g.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[g.useCallback(o=>{let{type:i,event:a}=o;e.forEach(c=>{var d;return(d=c[i])==null?void 0:d.call(c,a)})},[e]),t]}const eL={draggable:`
|
|
477
|
+
workspace: ${t}`)),i(b),c(!1)}).catch(v=>{m(v.message),c(!1)})},[t]);async function x(v){p(!0),m(null);try{const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),N=await b.json();if(!b.ok){m(N.error||`HTTP ${b.status}`),p(!1);return}e(`${n}/projects/${N.slug}`)}catch(b){m(b.message),p(!1);return}p(!1)}return a?l.jsx(jt,{label:"Loading project template…"}):h&&!o?l.jsx(vt,{error:h}):l.jsx(pl,{initialContent:o||"",documentType:"project",mode:"create",onSave:x,saving:d,error:h,title:"Create Project",description:"Projects hold the high-level objective, shared context, and human-authored overview. Put execution details in assignments instead of overloading project.md.",onCancel:()=>e(`${n}/projects`),helpTitle:"Project editing rules",helpBody:"Use this form for project intent, slug, tags, and overview content. If you ever need less common metadata, raw markdown mode still exposes the full file.",allowSlugEdit:!0})}function Ay(){const{slug:e}=Et(),t=Lt(),n=Xt(),[o,i]=g.useState(null),[a,c]=g.useState(!0),[d,p]=g.useState(!1),[h,m]=g.useState(null);g.useEffect(()=>{fetch("/api/templates/assignment").then(v=>v.json()).then(v=>{i(v.content),c(!1)}).catch(v=>{m(v.message),c(!1)})},[]);async function x(v){if(!e){m("Project slug is required.");return}p(!0),m(null);try{const b=await fetch(`/api/projects/${e}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),N=await b.json();if(!b.ok){m(N.error||`HTTP ${b.status}`),p(!1);return}n(`${t}/projects/${e}/assignments/${N.slug}`)}catch(b){m(b.message),p(!1);return}p(!1)}return a?l.jsx(jt,{label:"Loading assignment template…"}):h&&!o?l.jsx(vt,{error:h}):l.jsx(pl,{initialContent:o||"",documentType:"assignment",mode:"create",onSave:x,saving:d,error:h,title:"Create Assignment",description:"Assignments are the execution unit. Declare dependencies here, keep status pending until work starts, and use blocked later only for runtime obstacles.",onCancel:()=>n(e?`${t}/projects/${e}`:`${t}/projects`),helpTitle:"Assignment editing rules",helpBody:"Use structured fields for priority, assignee, dependencies, and tags. Status can be changed through lifecycle actions, kanban drag, or the status override.",allowSlugEdit:!0})}function _c({loadUrl:e,saveUrl:t,redirectTo:n,title:o,description:i,documentType:a,helpTitle:c,helpBody:d}){const p=Xt(),{data:h,loading:m,error:x}=Wv(e),[v,b]=g.useState(!1),[N,k]=g.useState(null);async function j(S){b(!0),k(null);try{const T=await fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:S})}),A=await T.json();if(!T.ok){k(A.error||`HTTP ${T.status}`),b(!1);return}p(n)}catch(T){k(T.message),b(!1);return}b(!1)}return m?l.jsx(jt,{label:`Loading ${o.toLowerCase()}…`}):x||!h?l.jsx(vt,{error:x||`${o} is unavailable.`}):l.jsx(pl,{initialContent:h.content,documentType:a,onSave:j,saving:v,error:N,title:o,description:i,onCancel:()=>p(n),helpTitle:c,helpBody:d})}function Dy(){const{slug:e}=Et(),t=Lt(),n=e??"";return l.jsx(_c,{loadUrl:`/api/projects/${n}/edit`,saveUrl:`/api/projects/${n}`,redirectTo:`${t}/projects/${n}`,title:"Edit Project",description:"Project edits change the human-authored source document. The structured form stays focused on title, slug, tags, and overview content.",documentType:"project",helpTitle:"Editable vs derived project fields",helpBody:"Project status remains derived from assignment state. If you need less common frontmatter fields, switch to raw markdown mode instead of expanding the structured form."})}function rf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/edit`:`/api/projects/${e}/assignments/${t}/edit`,c=i?`/api/assignments/${n}`:`/api/projects/${e}/assignments/${t}`,d=i?`/assignments/${n}`:`${o}/projects/${e}/assignments/${t}`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Assignment",description:"Edit assignment fields including status, priority, assignee, dependencies, and body.",documentType:"assignment",helpTitle:"Assignment editing",helpBody:"All fields are editable. Status can also be changed through lifecycle actions or kanban drag."})}function of(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/plan/edit`:`/api/projects/${e}/assignments/${t}/plan/edit`,c=i?`/api/assignments/${n}/plan`:`/api/projects/${e}/assignments/${t}/plan`,d=i?`/assignments/${n}?tab=plan`:`${o}/projects/${e}/assignments/${t}?tab=plan`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Plan",description:"Plans are separate from assignment status, so keep implementation steps here instead of overloading the assignment body.",documentType:"plan",helpTitle:"Plan status is separate",helpBody:"Plan status tracks the plan document itself. It does not replace the assignment lifecycle state."})}function sf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/scratchpad/edit`:`/api/projects/${e}/assignments/${t}/scratchpad/edit`,c=i?`/api/assignments/${n}/scratchpad`:`/api/projects/${e}/assignments/${t}/scratchpad`,d=i?`/assignments/${n}?tab=scratchpad`:`${o}/projects/${e}/assignments/${t}?tab=scratchpad`;return l.jsx(_c,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Edit Scratchpad",description:"Scratchpad is the assignment’s working memory surface for notes, experiments, and temporary context.",documentType:"scratchpad",helpTitle:"Scratchpad usage",helpBody:"Scratchpad is for transient notes. Keep canonical objective and lifecycle data in assignment.md and any active plan files (plan.md, plan-v2.md, ...)."})}function Vw({loadUrl:e,saveUrl:t,redirectTo:n,title:o,description:i,helpTitle:a,helpBody:c}){const d=Xt(),{data:p,loading:h,error:m}=Wv(e),[x,v]=g.useState(""),[b,N]=g.useState(""),[k,j]=g.useState(!1),[S,T]=g.useState(null);async function A(){j(!0),T(null);try{const L=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:x,body:b})}),O=await L.json();if(!L.ok){T(O.error||`HTTP ${L.status}`),j(!1);return}d(n)}catch(L){T(L.message),j(!1);return}j(!1)}return h?l.jsx(jt,{label:`Loading ${o.toLowerCase()}…`}):m||!p?l.jsx(vt,{error:m||`${o} is unavailable.`}):l.jsxs("div",{className:"space-y-4",children:[l.jsx(Pe,{title:o,description:i,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("label",{className:"block space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry title"}),l.jsx("input",{value:x,onChange:L=>v(L.target.value),placeholder:"Optional title",className:"editor-input"})]}),l.jsxs("label",{className:"block space-y-2",children:[l.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry body"}),l.jsx("textarea",{value:b,onChange:L=>N(L.target.value),className:"editor-textarea",spellCheck:!1})]}),S?l.jsx("p",{className:"rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:S}):null,l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsx("button",{type:"button",onClick:()=>d(n),className:"shell-action",children:"Cancel"}),l.jsx("button",{type:"button",onClick:A,disabled:k||!b.trim(),className:"shell-action bg-foreground text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:k?"Appending…":"Append Entry"})]})]})}),l.jsx(Pe,{title:"Current Document",children:l.jsx(Ut,{content:p.content.replace(/^---[\s\S]*?---\n?/,""),emptyState:"No existing content."})})]})}function lf(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/handoff/edit`:`/api/projects/${e}/assignments/${t}/handoff/edit`,c=i?`/api/assignments/${n}/handoff/entries`:`/api/projects/${e}/assignments/${t}/handoff/entries`,d=i?`/assignments/${n}?tab=handoff`:`${o}/projects/${e}/assignments/${t}?tab=handoff`;return l.jsx(Vw,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Append Handoff Entry",description:"Add a new handoff without rewriting previous history.",helpTitle:"Append-only handoff history",helpBody:"Handoff log entries preserve the baton-passing trail between sessions and agents. Add a new entry instead of editing older ones."})}function af(){const{slug:e,aslug:t,id:n}=Et(),o=Lt(),i=!!n,a=i?`/api/assignments/${n}/decision-record/edit`:`/api/projects/${e}/assignments/${t}/decision-record/edit`,c=i?`/api/assignments/${n}/decision-record/entries`:`/api/projects/${e}/assignments/${t}/decision-record/entries`,d=i?`/assignments/${n}?tab=decisions`:`${o}/projects/${e}/assignments/${t}?tab=decisions`;return l.jsx(Vw,{loadUrl:a,saveUrl:c,redirectTo:d,title:"Append Decision Entry",description:"Record a new decision and rationale without editing prior entries.",helpTitle:"Append-only decision history",helpBody:"Decision records should accumulate over time so the implementation rationale remains auditable and reviewable."})}function Iy(){const{workspace:e}=Et(),{data:t}=dc(),{data:n,loading:o,error:i,refetch:a}=ap(),[c,d]=g.useState(!1),[p,h]=g.useState(""),[m,x]=g.useState(!1),v=fn();g.useEffect(()=>{const T=v.hash.match(/^#server-(.+)/);if(!T)return;const A=decodeURIComponent(T[1]),L=document.querySelector(`[data-server-name="${window.CSS.escape(A)}"]`);if(!L)return;L.scrollIntoView({block:"nearest"}),L.classList.add("ring-2","ring-primary/60");const O=window.setTimeout(()=>L.classList.remove("ring-2","ring-primary/60"),1500);return()=>window.clearTimeout(O)},[v.hash,n]);const b=(()=>{if(!e||!n)return(n==null?void 0:n.sessions)??[];if(!t)return[];const T=new Set(t.filter(A=>e==="_ungrouped"?A.workspace===null:A.workspace===e).map(A=>A.slug));return n.sessions.filter(A=>A.windows.some(L=>L.panes.some(O=>O.assignment&&O.assignment.project!==null&&T.has(O.assignment.project))))})();async function N(T){if(T.preventDefault(),!!p.trim())try{await fetch("/api/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim()})}),h(""),d(!1),a()}catch{}}async function k(){x(!0);try{await fetch("/api/servers/refresh",{method:"POST"}),a()}finally{x(!1)}}async function j(T){await fetch(`/api/servers/${encodeURIComponent(T)}`,{method:"DELETE"}),a()}async function S(T){await fetch(`/api/servers/${encodeURIComponent(T)}/refresh`,{method:"POST"}),a()}return o?l.jsx(jt,{label:"Loading servers…"}):i?l.jsx(vt,{error:i}):n?n.tmuxAvailable?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c?l.jsxs("form",{onSubmit:N,className:"flex items-center gap-2",children:[l.jsx("input",{type:"text",value:p,onChange:T=>h(T.target.value),placeholder:"tmux session name",className:"editor-input text-sm",autoFocus:!0}),l.jsx("button",{type:"submit",className:"shell-action",children:"Add"}),l.jsx("button",{type:"button",className:"shell-action",onClick:()=>d(!1),children:"Cancel"})]}):l.jsxs("button",{className:"shell-action",onClick:()=>d(!0),children:[l.jsx(lr,{className:"h-3.5 w-3.5"}),"Track Session"]}),l.jsxs("button",{className:"shell-action",onClick:k,disabled:m,children:[l.jsx(Sv,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`}),"Refresh All"]})]}),b.length===0?l.jsx(Ge,{title:"No sessions tracked",description:"Register a tmux session to start tracking your dev servers."}):l.jsx("div",{className:"mt-4 space-y-4",children:b.map(T=>l.jsx(PI,{session:T,onRefresh:()=>S(T.name),onRemove:()=>j(T.name),onRefetch:a},T.name))})]}):l.jsx(l.Fragment,{children:l.jsxs("div",{className:"surface-panel mt-4 flex flex-col items-center gap-3 py-12 text-center",children:[l.jsx(TC,{className:"h-10 w-10 text-muted-foreground/40"}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:"tmux is not installed"}),l.jsxs("p",{className:"max-w-md text-sm text-muted-foreground",children:["Server tracking requires tmux. Install it with ",l.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"brew install tmux"})," to get started."]})]})}):null}function PI({session:e,onRefresh:t,onRemove:n,onRefetch:o}){return l.jsxs("div",{className:"surface-panel","data-server-name":e.name,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(rp,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),l.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.alive?"border border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:e.alive?"alive":"dead"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last refreshed: ",new Date(e.lastRefreshed).toLocaleString()]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{className:"shell-action",onClick:t,title:"Refresh",children:l.jsx(Sv,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"shell-action",onClick:n,title:"Remove",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})]})]}),e.alive&&e.windows.length>0&&l.jsx("div",{className:"mt-3 space-y-3",children:e.windows.map(i=>l.jsxs("div",{children:[l.jsxs("p",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:["Window ",i.index,": ",i.name]}),l.jsx("div",{className:"space-y-1.5",children:i.panes.map(a=>l.jsx(TI,{pane:a,sessionName:e.name,windowIndex:i.index,onRefetch:o},`${i.index}:${a.index}`))})]},i.index))}),!e.alive&&l.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(NC,{className:"h-4 w-4"}),l.jsx("span",{children:e.kind==="process"?"Process no longer running":"Session no longer exists"})]})]})}function TI({pane:e,sessionName:t,windowIndex:n,onRefetch:o}){const i=Lt(),a=e.cwd.replace(/^\/Users\/[^/]+/,"~");return l.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[l.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:[":",e.index]}),l.jsx("span",{className:"shrink-0 rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:e.command}),l.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[l.jsx("span",{className:"truncate",title:e.cwd,children:a}),l.jsx(Hr,{value:e.cwd})]}),e.branch&&l.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[l.jsx(wv,{className:"h-3 w-3"}),e.branch,e.worktree&&l.jsx("span",{className:"rounded bg-violet-100 px-1 py-0.5 text-[10px] font-medium text-violet-700 dark:bg-violet-950/40 dark:text-violet-400",children:"worktree"})]}),e.ports.length>0&&l.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.urls.map(c=>l.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[c.replace("http://localhost:",":"),l.jsx(bv,{className:"h-2.5 w-2.5"})]},c))}),l.jsx("div",{className:"ml-auto shrink-0",children:e.assignment?l.jsxs(Ce,{to:e.assignment.project===null?`/assignments/${e.assignment.slug}`:`${i}/projects/${e.assignment.project}/assignments/${e.assignment.slug}`,className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20",children:[l.jsx(gC,{className:"h-2.5 w-2.5"}),e.assignment.title,e.assignment.project===null?l.jsx("span",{className:"ml-1 rounded bg-neutral-800/70 px-1 py-0.5 text-[9px] uppercase tracking-wide text-neutral-400",children:"Standalone"}):null]}):l.jsx("span",{className:"text-xs text-muted-foreground/40",children:"unlinked"})})]})}function Ly(){const{workspace:e}=Et(),{data:t}=dc(),{data:n,loading:o,error:i}=jN(),[a,c]=g.useState(""),[d,p]=g.useState(""),[h,m]=g.useState(""),[x,v]=g.useState("started_desc"),[b,N]=g.useState(0),[k,j]=g.useState(new Set),[S,T]=g.useState(!1),[A,L]=g.useState(null),[O,P]=g.useState(null),$=(n==null?void 0:n.sessions.some(Y=>Y.status==="active"))??!1;g.useEffect(()=>{if(!$)return;const Y=window.setInterval(()=>N(X=>X+1),3e4);return()=>window.clearInterval(Y)},[$]),g.useEffect(()=>{j(Y=>{if(Y.size===0)return Y;const X=new Set((n==null?void 0:n.sessions.map(D=>D.sessionId))??[]),_=new Set([...Y].filter(D=>X.has(D)));return _.size===Y.size?Y:_})},[n]);const E=g.useMemo(()=>{if(!n)return[];if(e&&!t)return[];const Y=a.trim().toLowerCase();return[...n.sessions.filter(_=>{var W;if(e&&t){const ee=((W=t.find(R=>R.slug===_.projectSlug))==null?void 0:W.workspace)??null;if(e==="_ungrouped"){if(ee!==null)return!1}else if(ee!==e)return!1}const D=DI(_.started);return d&&(!D||D<d)||h&&(!D||D>h)?!1:Y?[_.projectSlug??"",_.assignmentSlug??"",_.agent,_.sessionId,_.path,_.description??"",_.transcriptPath??""].join(" ").toLowerCase().includes(Y):!0})].sort((_,D)=>II(_,D,x))},[n,a,x,d,h,b,e,t]);function H(Y){j(X=>{const _=new Set(X);return _.has(Y)?_.delete(Y):_.add(Y),_})}function Z(){k.size===E.length&&E.length>0?j(new Set):j(new Set(E.map(Y=>Y.sessionId)))}async function G(Y){L(null),T(!0);try{const X=await fetch("/api/agent-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionIds:Y})}),_=await X.json().catch(()=>null);if(!X.ok)throw new Error((_==null?void 0:_.error)||`HTTP ${X.status}`);j(D=>new Set([...D].filter(V=>!Y.includes(V)))),P(null)}catch(X){L(X.message)}finally{T(!1)}}if(o)return l.jsx(jt,{label:"Loading agent sessions..."});if(i)return l.jsx(vt,{error:i});if(!n)return null;const q=n.sessions.length>0;return l.jsxs(l.Fragment,{children:[l.jsxs(wp,{children:[l.jsx(vc,{value:a,onChange:c,placeholder:"Search project, assignment, agent, session ID, path, or description"}),l.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started From",l.jsx("input",{type:"date",value:d,onChange:Y=>p(Y.target.value),className:"editor-input min-w-[150px]"})]}),l.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started To",l.jsx("input",{type:"date",value:h,onChange:Y=>m(Y.target.value),className:"editor-input min-w-[150px]"})]}),l.jsxs("select",{value:x,onChange:Y=>v(Y.target.value),className:"editor-input max-w-[200px]",children:[l.jsx("option",{value:"started_desc",children:"Newest first"}),l.jsx("option",{value:"started_asc",children:"Oldest first"}),l.jsx("option",{value:"assignment_asc",children:"Assignment A-Z"}),l.jsx("option",{value:"agent_asc",children:"Agent A-Z"})]})]}),A?l.jsx("div",{className:"mt-4 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-950/30 dark:text-rose-300",children:A}):null,k.size>0&&l.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded border border-border/40 bg-muted/30 px-4 py-2 text-sm",children:[l.jsxs("span",{className:"text-muted-foreground",children:[k.size," session",k.size!==1?"s":""," selected"]}),l.jsxs("button",{className:"shell-action text-destructive",onClick:()=>P({sessionIds:[...k],title:`Delete ${k.size} selected session${k.size===1?"":"s"}?`,description:"This removes the selected agent session records from the dashboard. This cannot be undone.",confirmLabel:k.size===1?"Delete Session":"Delete Sessions"}),disabled:S,children:[l.jsx(Ms,{className:"mr-1 inline h-3.5 w-3.5"}),"Delete Selected"]}),l.jsx("button",{className:"shell-action",onClick:()=>j(new Set),children:"Clear Selection"})]}),q?E.length===0?l.jsx(Ge,{title:"No agent sessions match these filters",description:"Adjust the status, search term, date range, or sorting controls to show sessions again."}):l.jsx("div",{className:"surface-panel mt-4 overflow-x-auto",children:l.jsxs("table",{className:"w-full min-w-[1040px] text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/40 text-left text-xs uppercase tracking-wider text-muted-foreground",children:[l.jsx("th",{className:"w-8 pb-2 pr-3",children:l.jsx("button",{onClick:Z,className:"text-muted-foreground hover:text-foreground",children:k.size===E.length&&E.length>0?l.jsx(Sr,{className:"h-4 w-4"}):l.jsx(Cv,{className:"h-4 w-4"})})}),l.jsx("th",{className:"pb-2 pr-3",children:"Project"}),l.jsx("th",{className:"pb-2 pr-3",children:"Assignment"}),l.jsx("th",{className:"pb-2 pr-3",children:"Description"}),l.jsx("th",{className:"pb-2 pr-3",children:"Agent"}),l.jsx("th",{className:"pb-2 pr-3",children:"Session ID"}),l.jsx("th",{className:"pb-2 pr-3",children:"Started"}),l.jsx("th",{className:"pb-2 pr-3",children:"Path"}),l.jsx("th",{className:"pb-2 pr-3",children:"Transcript"}),l.jsx("th",{className:"w-8 pb-2"})]})}),l.jsx("tbody",{children:E.map(Y=>l.jsx(AI,{session:Y,selected:k.has(Y.sessionId),onToggle:()=>H(Y.sessionId),onDelete:()=>P({sessionIds:[Y.sessionId],title:`Delete session ${Y.sessionId.slice(0,8)}...?`,description:`Remove this ${Y.agent} session record${Y.assignmentSlug?` for ${Y.assignmentSlug}`:""}. This cannot be undone.`,confirmLabel:"Delete Session"})},Y.sessionId))})]})}):l.jsx(Ge,{title:"No agent sessions",description:"No agent sessions have been registered yet. Use /grab-assignment or syntaur track-session to register one."}),l.jsx(ow,{open:O!==null,title:(O==null?void 0:O.title)??"Delete session?",description:(O==null?void 0:O.description)??"",confirmLabel:(O==null?void 0:O.confirmLabel)??"Delete",destructive:!0,loading:S,onOpenChange:Y=>{Y||P(null)},onConfirm:async()=>{O&&await G(O.sessionIds)}})]})}function AI({session:e,selected:t,onToggle:n,onDelete:o}){const i=Lt(),a=e.sessionId.length>12?e.sessionId.slice(0,8)+"...":e.sessionId,c=e.path?e.path.replace(/^\/Users\/[^/]+/,"~"):"—",d=e.transcriptPath?e.transcriptPath.replace(/^\/Users\/[^/]+/,"~"):"—";return l.jsxs("tr",{className:"border-b border-border/20 last:border-0",children:[l.jsx("td",{className:"py-2 pr-3",children:l.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-foreground",children:t?l.jsx(Sr,{className:"h-4 w-4"}):l.jsx(Cv,{className:"h-4 w-4"})})}),l.jsx("td",{className:"py-2 pr-3",children:e.projectSlug?l.jsx(Ce,{to:`${i}/projects/${e.projectSlug}`,className:"text-primary hover:underline",children:Cn(e.projectSlug)}):e.assignmentSlug?l.jsx("span",{className:"rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-neutral-300",children:"Standalone"}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2 pr-3",children:e.projectSlug&&e.assignmentSlug?l.jsx(Ce,{to:`${i}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`,className:"text-primary hover:underline",children:Cn(e.assignmentSlug)}):e.assignmentSlug?l.jsx(Ce,{to:`/assignments/${e.assignmentSlug}`,className:"text-primary hover:underline font-mono",children:e.assignmentSlug}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"max-w-[200px] py-2 pr-3",children:e.description?l.jsx("span",{className:"truncate text-xs text-muted-foreground",title:e.description,children:e.description.length>60?e.description.slice(0,57)+"...":e.description}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx(uc,{className:"h-3 w-3 text-muted-foreground"}),e.agent]})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"font-mono text-xs text-muted-foreground",title:e.sessionId,children:a}),l.jsx(Hr,{value:e.sessionId})]})}),l.jsx("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:Cr(e.started)}),l.jsx("td",{className:"max-w-[240px] py-2 pr-3",children:l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate text-xs text-muted-foreground",title:e.path,children:c}),e.path&&l.jsx(Hr,{value:e.path})]})}),l.jsx("td",{className:"max-w-[260px] py-2 pr-3",children:e.transcriptPath?l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:e.transcriptPath,children:d}),l.jsx(Hr,{value:e.transcriptPath})]}):l.jsx("span",{className:"text-muted-foreground",children:"—"})}),l.jsx("td",{className:"py-2",children:l.jsx("button",{onClick:o,className:"text-muted-foreground hover:text-destructive",title:"Delete session",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})})]})}function DI(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${i}`}function Ia(e){const t=Date.parse(e.started),n=e.ended?Date.parse(e.ended):Date.now();return Number.isNaN(t)||Number.isNaN(n)?0:Math.max(0,Math.floor((n-t)/6e4))}function II(e,t,n){switch(n){case"started_asc":return e.started.localeCompare(t.started);case"started_desc":return t.started.localeCompare(e.started);case"duration_asc":return Ia(e)-Ia(t);case"duration_desc":return Ia(t)-Ia(e);case"assignment_asc":return(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"")||(e.projectSlug??"").localeCompare(t.projectSlug??"");case"agent_asc":return e.agent.localeCompare(t.agent)||(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"");default:return 0}}function LI(){const{data:e,loading:t,error:n}=Vv(),[o,i]=g.useState(""),a=g.useMemo(()=>{if(!(e!=null&&e.playbooks))return[];if(!o.trim())return e.playbooks;const c=o.toLowerCase();return e.playbooks.filter(d=>d.name.toLowerCase().includes(c)||d.description.toLowerCase().includes(c)||d.slug.toLowerCase().includes(c)||d.tags.some(p=>p.toLowerCase().includes(c)))},[e,o]);return t?l.jsx(jt,{label:"Loading playbooks..."}):n?l.jsx(vt,{error:n}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsxs("div",{className:"relative flex-1 max-w-sm",children:[l.jsx(sl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l.jsx("input",{type:"text",placeholder:"Search playbooks...",value:o,onChange:c=>i(c.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),l.jsxs(Ce,{to:"/playbooks/create",className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[l.jsx(lr,{className:"h-4 w-4"}),"Create Playbook"]})]}),l.jsxs(Ce,{to:"/playbooks/manifest",className:"surface-panel group flex items-center gap-3 p-3 transition hover:border-foreground/20",children:[l.jsx(cC,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:"Playbook Manifest"}),l.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:"auto-generated"})]}),l.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Index of all playbooks with descriptions. Include ",l.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px]",children:"~/.syntaur/playbooks/manifest.md"})," in your CLAUDE.md for agent context."]})]})]}),a.length===0?l.jsx(Ge,{title:"No playbooks found",description:(e==null?void 0:e.playbooks.length)===0?"Playbooks define rules and workflows for how agents should operate. Create your first one to get started.":"No playbooks match your search.",actions:(e==null?void 0:e.playbooks.length)===0?l.jsxs(Ce,{to:"/playbooks/create",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[l.jsx(lr,{className:"h-4 w-4"}),"Create Playbook"]}):void 0}):l.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:a.map(c=>l.jsxs(Ce,{to:`/playbooks/${c.slug}`,className:"surface-panel group flex flex-col gap-2 p-4 transition hover:border-foreground/20",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(yv,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:c.name}),c.description?l.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground line-clamp-2",children:c.description}):null]})]}),l.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.tags.slice(0,3).map(d=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:[l.jsx(Nv,{className:"h-2.5 w-2.5"}),d]},d)),c.tags.length>3?l.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["+",c.tags.length-3]}):null]}),l.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/60",children:Vr(c.updated)})]})]},c.slug))})]})}function OI(){const{slug:e}=Et(),t=Xt(),{data:n,loading:o,error:i}=CN(e),[a,c]=g.useState(!1),[d,p]=g.useState(!1),h=e==="manifest";async function m(){if(e){p(!0);try{(await fetch(`/api/playbooks/${e}`,{method:"DELETE"})).ok&&t("/playbooks")}finally{p(!1)}}}return o?l.jsx(jt,{label:"Loading playbook..."}):i?l.jsx(vt,{error:i}):n?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:h?"Playbook Manifest":n.name}),h?l.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:"auto-generated"}):null]}),!h&&n.description?l.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:n.description}):null,h?l.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["This file is rebuilt automatically when playbooks are added or removed. Include"," ",l.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.syntaur/playbooks/manifest.md"})," ","in your CLAUDE.md for agent context."]}):null,!h&&n.whenToUse?l.jsxs("p",{className:"mt-2 text-sm text-muted-foreground italic",children:["When to use: ",n.whenToUse]}):null,l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[l.jsxs("span",{children:["Created ",Cr(n.created)]}),l.jsxs("span",{children:["Updated ",Cr(n.updated)]})]}),n.tags.length>0?l.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:n.tags.map(x=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:[l.jsx(Nv,{className:"h-3 w-3"}),x]},x))}):null]}),h?null:l.jsxs("div",{className:"flex shrink-0 gap-2",children:[l.jsxs(Ce,{to:`/playbooks/${e}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[l.jsx(wC,{className:"h-3 w-3"}),"Edit"]}),a?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:m,disabled:d,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-red-600 px-3 text-xs font-medium text-white transition hover:bg-red-700 disabled:opacity-50",children:d?"Deleting...":"Confirm"}),l.jsx("button",{type:"button",onClick:()=>c(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):l.jsxs("button",{type:"button",onClick:()=>c(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-red-600 transition hover:bg-red-50 dark:hover:bg-red-950/30",children:[l.jsx(Ms,{className:"h-3 w-3"}),"Delete"]})]})]}),l.jsx("div",{className:"surface-panel p-4",children:l.jsx(Ut,{content:n.body})})]}):null}function _I(){const e=Xt(),[t,n]=g.useState(null),[o,i]=g.useState(!0),[a,c]=g.useState(!1),[d,p]=g.useState(null);g.useEffect(()=>{fetch("/api/playbooks/template/new").then(m=>m.json()).then(m=>{n(m.content),i(!1)}).catch(m=>{p(m.message),i(!1)})},[]);async function h(m){c(!0),p(null);try{const x=await fetch("/api/playbooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),v=await x.json();if(!x.ok){p(v.error||`HTTP ${x.status}`),c(!1);return}e(`/playbooks/${v.slug}`)}catch(x){p(x.message),c(!1);return}c(!1)}return o?l.jsx(jt,{label:"Loading playbook template..."}):d&&!t?l.jsx(vt,{error:d}):l.jsx(pl,{initialContent:t||"",documentType:"playbook",mode:"create",onSave:h,saving:a,error:d,title:"Create Playbook",description:"Playbooks define rules and workflows for how agents should operate. Keep them short, imperative, and focused on a single concern.",onCancel:()=>e("/playbooks"),allowSlugEdit:!0})}function MI(){const{slug:e}=Et(),t=Xt(),[n,o]=g.useState(null),[i,a]=g.useState(!0),[c,d]=g.useState(!1),[p,h]=g.useState(null);g.useEffect(()=>{e&&fetch(`/api/playbooks/${e}/edit`).then(x=>x.json()).then(x=>{o(x.content),a(!1)}).catch(x=>{h(x.message),a(!1)})},[e]);async function m(x){if(e){d(!0),h(null);try{const v=await fetch(`/api/playbooks/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})}),b=await v.json();if(!v.ok){h(b.error||`HTTP ${v.status}`),d(!1);return}t(`/playbooks/${e}`)}catch(v){h(v.message),d(!1);return}d(!1)}}return i?l.jsx(jt,{label:"Loading playbook..."}):p&&!n?l.jsx(vt,{error:p}):l.jsx(pl,{initialContent:n||"",documentType:"playbook",mode:"edit",onSave:m,saving:c,error:p,title:"Edit Playbook",onCancel:()=>t(`/playbooks/${e}`)})}function $I({value:e,onChange:t}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"color",value:e||"#64748b",onChange:n=>t(n.target.value),className:"h-7 w-7 shrink-0 cursor-pointer rounded-md border border-border/60 bg-transparent p-0.5",title:"Pick a color"}),l.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),placeholder:"#64748b",className:"editor-input w-[5.5rem] font-mono text-xs"})]})}const zf=["projects","playbooks","todos","servers","config"];function FI(e){const t=new Set;for(const n of e.split(",").map(o=>o.trim()))zf.includes(n)&&t.add(n);return t}function Oy(e){if(!e)return"never";try{return new Date(e).toLocaleString()}catch{return e}}function zI(){const[e,t]=g.useState(!0),[n,o]=g.useState(null),[i,a]=g.useState(""),[c,d]=g.useState(new Set(zf)),[p,h]=g.useState(!1),[m,x]=g.useState(!1),[v,b]=g.useState(null),[N,k]=g.useState(null),j=g.useCallback(async()=>{try{const P=await fetch("/api/backup");if(!P.ok)throw new Error(`HTTP ${P.status}`);const $=await P.json();o($),a($.repo??""),d(FI($.categories)),h(!1)}catch(P){k({type:"error",message:`Failed to load backup config: ${P instanceof Error?P.message:String(P)}`})}finally{t(!1)}},[]);g.useEffect(()=>{j()},[j]);function S(P){d($=>{const E=new Set($);return E.has(P)?E.delete(P):E.add(P),E}),h(!0)}async function T(){x(!0),k(null);try{const P=Array.from(c),$=await fetch("/api/backup/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:i.trim()||null,categories:P})}),E=await $.json();if(!$.ok)throw new Error(E.error||`HTTP ${$.status}`);o(E),h(!1),k({type:"success",message:"Backup configuration saved."})}catch(P){k({type:"error",message:`Save failed: ${P instanceof Error?P.message:String(P)}`})}finally{x(!1)}}async function A(){b("push"),k(null);try{const P=await fetch("/api/backup/push",{method:"POST"}),$=await P.json();if(!P.ok||$.success===!1)throw new Error($.error||$.message||`HTTP ${P.status}`);k({type:"success",message:$.message||"Backup complete."}),await j()}catch(P){k({type:"error",message:`Backup failed: ${P instanceof Error?P.message:String(P)}`})}finally{b(null)}}async function L(){if(window.confirm("Restore will overwrite local files for the selected categories with the contents of the GitHub repo. This cannot be undone. Continue?")){b("pull"),k(null);try{const $=await fetch("/api/backup/pull",{method:"POST"}),E=await $.json();if(!$.ok||E.success===!1)throw new Error(E.error||E.message||`HTTP ${$.status}`);k({type:"success",message:E.message||"Restore complete."}),await j()}catch($){k({type:"error",message:`Restore failed: ${$ instanceof Error?$.message:String($)}`})}finally{b(null)}}}if(e)return l.jsx(Pe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})});const O=!!i.trim()&&c.size>0&&!v&&!p;return l.jsx(Pe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository and restore from it",children:l.jsxs("div",{className:"space-y-4",children:[N&&l.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${N.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:N.message}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repository URL"}),l.jsx("input",{type:"text",value:i,onChange:P=>{a(P.target.value),h(!0)},placeholder:"git@github.com:you/syntaur-backup.git",className:"editor-input w-full text-sm"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["SSH or HTTPS URL. Requires ",l.jsx("code",{className:"rounded bg-muted px-1",children:"git"})," installed and credentials configured locally."]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Categories to back up"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:zf.map(P=>{const $=c.has(P);return l.jsxs("button",{type:"button",onClick:()=>S(P),className:`shell-action text-xs ${$?"bg-primary/10 text-primary hover:bg-primary/20":"bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:[l.jsx("span",{className:`mr-1 inline-block h-2 w-2 rounded-full ${$?"bg-primary":"bg-muted-foreground/40"}`}),P]},P)})})]}),l.jsxs("div",{className:"grid grid-cols-1 gap-2 text-xs text-muted-foreground sm:grid-cols-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Last backup: "}),Oy((n==null?void 0:n.lastBackup)??null)]}),l.jsxs("div",{children:[l.jsx("span",{className:"font-medium text-foreground",children:"Last restore: "}),Oy((n==null?void 0:n.lastRestore)??null)]}),(n==null?void 0:n.locked)&&l.jsx("div",{className:"sm:col-span-2 text-amber-600 dark:text-amber-400",children:"⚠ A backup operation is in progress or the lock file is stale."})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[l.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:T,disabled:m||!p,children:[l.jsx(op,{className:"h-3.5 w-3.5"}),m?"Saving...":"Save Config"]}),l.jsxs("button",{className:"shell-action",onClick:A,disabled:!O,title:O?"Back up now":p?"Save config first":"Set repo and pick categories",children:[l.jsx(AC,{className:"h-3.5 w-3.5"}),v==="push"?"Backing up...":"Back Up Now"]}),l.jsxs("button",{className:"shell-action",onClick:L,disabled:!O,title:O?"Restore from backup":p?"Save config first":"Set repo and pick categories",children:[l.jsx(sC,{className:"h-3.5 w-3.5"}),v==="pull"?"Restoring...":"Restore"]}),p&&l.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]}),l.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-border/40 bg-muted/20 p-3 text-xs text-muted-foreground",children:[l.jsx(rC,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsxs("span",{children:["Restore never overwrites ",l.jsx("code",{className:"rounded bg-muted px-1",children:"config.md"})," (would clobber backup settings). The agent sessions database is not backed up — only markdown files."]})]})]})})}function cf(e){return{statuses:e.statuses.map(t=>({id:t.id,label:t.label,description:t.description??"",color:t.color??"",terminal:t.terminal??!1})),order:[...e.order]}}function BI(){const[e,t]=g.useState(!0),[n,o]=g.useState(null),[i,a]=g.useState(!1),[c,d]=g.useState([]),[p,h]=g.useState([]),[m,x]=g.useState(!1),[v,b]=g.useState(null),[N,k]=g.useState(!1),j=g.useCallback(async()=>{try{const E=await fetch("/api/config/statuses");if(!E.ok)throw new Error(`HTTP ${E.status}`);const H=await E.json(),Z=cf(H);d(Z.statuses),h(Z.order),a(H.custom),k(!1),o(null)}catch(E){o(E instanceof Error?E.message:"Failed to load config")}finally{t(!1)}},[]);g.useEffect(()=>{j()},[j]);function S(){setTimeout(()=>b(null),3e3)}async function T(){x(!0),b(null);try{const E={statuses:c.map(q=>({id:q.id,label:q.label,...q.description?{description:q.description}:{},...q.color?{color:q.color}:{},...q.terminal?{terminal:!0}:{}})),order:p,transitions:[]},H=await fetch("/api/config/statuses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!H.ok){const q=await H.json().catch(()=>({error:"Unknown error"}));throw new Error(q.error??"Save failed")}const Z=await H.json(),G=cf(Z);d(G.statuses),h(G.order),a(Z.custom),k(!1),kx(),b({type:"success",message:"Status config saved"}),S()}catch(E){b({type:"error",message:E instanceof Error?E.message:"Save failed"})}finally{x(!1)}}async function A(){x(!0),b(null);try{const E=await fetch("/api/config/statuses",{method:"DELETE"});if(!E.ok)throw new Error("Reset failed");const H=await E.json(),Z=cf(H);d(Z.statuses),h(Z.order),a(H.custom),k(!1),kx(),b({type:"success",message:"Reset to defaults"}),S()}catch(E){b({type:"error",message:E instanceof Error?E.message:"Reset failed"})}finally{x(!1)}}function L(E,H,Z){d(G=>{const q=[...G];if(q[E]={...q[E],[H]:Z},H==="id"&&typeof Z=="string"){const Y=G[E].id;h(X=>X.map(_=>_===Y?Z:_))}return q}),k(!0)}function O(){const E=`status_${c.length+1}`;d(H=>[...H,{id:E,label:"New Status",description:"",color:"",terminal:!1}]),h(H=>[...H,E]),k(!0)}function P(E){const H=c[E].id;d(Z=>Z.filter((G,q)=>q!==E)),h(Z=>Z.filter(G=>G!==H)),k(!0)}function $(E,H){const Z=E+H;Z<0||Z>=p.length||(h(G=>{const q=[...G];return[q[E],q[Z]]=[q[Z],q[E]],q}),k(!0))}return e?l.jsx(jt,{label:"Loading settings..."}):n?l.jsx(vt,{error:n}):l.jsx(Mw,{children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:`flex items-center justify-between rounded-lg border px-4 py-3 text-sm ${i?"border-primary/30 bg-primary/5 text-primary":"border-border/60 bg-muted/30 text-muted-foreground"}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(kv,{className:"h-4 w-4"}),i?"Using custom status configuration from ~/.syntaur/config.md":"Using default status configuration"]}),l.jsxs("button",{className:"shell-action text-xs",onClick:A,disabled:m||!i&&!N,children:[l.jsx(jC,{className:"h-3 w-3"}),"Reset to Defaults"]})]}),v&&l.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${v.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-400":"border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-400"}`,children:v.message}),l.jsx(Pe,{title:"Status Definitions",description:"Define the statuses assignments can have",actions:l.jsxs("button",{className:"shell-action text-xs",onClick:O,children:[l.jsx(lr,{className:"h-3 w-3"}),"Add Status"]}),children:l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-border/50 text-left text-xs font-medium uppercase tracking-wider text-muted-foreground",children:[l.jsx("th",{className:"pb-2 pr-3",children:"ID"}),l.jsx("th",{className:"pb-2 pr-3",children:"Label"}),l.jsx("th",{className:"pb-2 pr-3",children:"Color"}),l.jsx("th",{className:"pb-2 pr-3",children:l.jsxs($w,{children:[l.jsx(Fw,{asChild:!0,children:l.jsx("span",{className:"cursor-help underline decoration-dotted underline-offset-4",children:"Done State"})}),l.jsx(Xp,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:'When enabled, assignments in this status count as finished — they fill the "done" portion of progress bars and satisfy dependency requirements.'})]})}),l.jsx("th",{className:"pb-2 w-10"})]})}),l.jsx("tbody",{className:"divide-y divide-border/30",children:c.map((E,H)=>l.jsxs("tr",{children:[l.jsx("td",{className:"py-2 pr-3",children:l.jsx("input",{type:"text",value:E.id,onChange:Z=>L(H,"id",Z.target.value),className:"editor-input w-full text-sm"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx("input",{type:"text",value:E.label,onChange:Z=>L(H,"label",Z.target.value),className:"editor-input w-full text-sm"})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx($I,{value:E.color,onChange:Z=>L(H,"color",Z)})}),l.jsx("td",{className:"py-2 pr-3",children:l.jsx("button",{type:"button",role:"switch","aria-checked":E.terminal,onClick:()=>L(H,"terminal",!E.terminal),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${E.terminal?"bg-primary":"bg-muted"}`,children:l.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${E.terminal?"translate-x-4":"translate-x-0"}`})})}),l.jsx("td",{className:"py-2",children:l.jsx("button",{className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>P(H),title:"Remove status",children:l.jsx(Ms,{className:"h-3.5 w-3.5"})})})]},H))})]})})}),l.jsx(Pe,{title:"Status Order",description:"Controls display order in the dashboard (Kanban columns, progress bars, dropdowns)",children:l.jsx("div",{className:"space-y-1",children:p.map((E,H)=>{var G;const Z=((G=c.find(q=>q.id===E))==null?void 0:G.label)??E;return l.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[l.jsx("span",{className:"mr-1 font-mono text-xs text-muted-foreground/60",children:H+1}),l.jsx("span",{className:"flex-1 font-medium",children:Z}),l.jsx("span",{className:"text-xs text-muted-foreground",children:E}),l.jsx("button",{className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-30",onClick:()=>$(H,-1),disabled:H===0,title:"Move up",children:l.jsx(vv,{className:"h-3.5 w-3.5"})}),l.jsx("button",{className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-30",onClick:()=>$(H,1),disabled:H===p.length-1,title:"Move down",children:l.jsx(Yi,{className:"h-3.5 w-3.5"})})]},H)})})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:T,disabled:m||!N,children:[l.jsx(op,{className:"h-3.5 w-3.5"}),m?"Saving...":"Save Configuration"]}),N&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"shell-action text-xs",onClick:()=>{t(!0),j()},disabled:m,children:"Discard Changes"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]})]}),l.jsx(zI,{})]})})}const _y=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-blue-400"},{value:"completed",icon:"✓",label:"Completed",color:"text-emerald-400"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-amber-400"}];function qw({status:e,onChange:t}){const[n,o]=g.useState(!1),i=g.useRef(null);g.useEffect(()=>{if(!n)return;function c(d){i.current&&!i.current.contains(d.target)&&o(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const a=_y.find(c=>c.value===e);return l.jsxs("div",{className:"relative",ref:i,onClick:c=>c.stopPropagation(),children:[l.jsx("button",{onClick:()=>o(!n),className:`text-lg leading-none ${a.color} hover:opacity-70 transition`,title:a.label,children:a.icon}),n&&l.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:_y.filter(c=>c.value!==e).map(c=>l.jsxs("button",{onClick:()=>{t(c.value),o(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${c.color}`,children:[l.jsx("span",{className:"text-base leading-none",children:c.icon}),l.jsx("span",{children:c.label})]},c.value))})]})}function UI(){const{data:e,loading:t,error:n,refetch:o}=cp(),[i,a]=g.useState(""),c=g.useRef(null);zs("list:todos");const[d,p]=g.useState(""),[h,m]=g.useState(""),[x,v]=g.useState(""),[b,N]=g.useState("_global"),[k,j]=g.useState(null);function S(_,D){_.stopPropagation(),navigator.clipboard.writeText(D),j(D),setTimeout(()=>j(V=>V===D?null:V),1500)}const T=g.useMemo(()=>{if(!(e!=null&&e.workspaces))return[];const _=[];for(const D of e.workspaces)for(const V of D.items)_.push({...V,workspace:D.workspace});return _},[e]),A=g.useMemo(()=>{const _=new Set;for(const D of T)for(const V of D.tags)_.add(V);return Array.from(_).sort()},[T]),L=g.useMemo(()=>{let _=T;if(i.trim()){const D=i.toLowerCase();_=_.filter(V=>V.description.toLowerCase().includes(D)||V.tags.some(W=>W.toLowerCase().includes(D))||V.id.includes(D))}return d&&(_=_.filter(D=>D.status===d)),h&&(_=_.filter(D=>D.tags.includes(h))),_},[T,i,d,h]),O=g.useMemo(()=>{if(!(e!=null&&e.workspaces))return{open:0,in_progress:0,completed:0,blocked:0,total:0};const _={open:0,in_progress:0,completed:0,blocked:0,total:0};for(const D of e.workspaces)_.open+=D.counts.open,_.in_progress+=D.counts.in_progress,_.completed+=D.counts.completed,_.blocked+=D.counts.blocked,_.total+=D.counts.total;return _},[e]);async function P(){x.trim()&&(await qv(b,x.trim()),v(""),o())}const $={open:"in_progress",in_progress:"completed",completed:"open",blocked:"open"};function E(_,D,V){H(_,D,$[V]||"open")}async function H(_,D,V){switch(V){case"open":await Xv(_,D);break;case"in_progress":await Yv(_,D);break;case"completed":await Kv(_,D);break;case"blocked":await Gv(_,D);break}o()}async function Z(_,D){await PN(_,D),o()}const{hotkeyRowProps:G}=yc(L,{scope:"list:todos",bindO:!1,onOpen:_=>E(_.workspace,_.id,_.status)});yt({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var _;return(_=c.current)==null?void 0:_.focus()}}),yt({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>o()});const[q,Y]=_s(),X=q.get("focus");return g.useEffect(()=>{if(!X)return;const _=document.querySelector(`[data-todo-id="${CSS.escape(X)}"]`);if(!_)return;_.scrollIntoView({block:"nearest"}),_.classList.add("ring-2","ring-primary/60");const D=window.setTimeout(()=>{_.classList.remove("ring-2","ring-primary/60"),Y(V=>{const W=new URLSearchParams(V);return W.delete("focus"),W})},1500);return()=>window.clearTimeout(D)},[X,L.length,Y]),t?l.jsx(jt,{label:"Loading todos..."}):n?l.jsx(vt,{error:n}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[l.jsx(it,{label:"Open",value:O.open,icon:Sr}),l.jsx(it,{label:"In Progress",value:O.in_progress,icon:jv,tone:"info"}),l.jsx(it,{label:"Blocked",value:O.blocked,icon:il,tone:"warn"}),l.jsx(it,{label:"Completed",value:O.completed,icon:Sr,tone:"default"})]}),l.jsx("div",{className:"surface-panel p-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("select",{value:b,onChange:_=>N(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"_global",children:"Global"}),e==null?void 0:e.workspaces.filter(_=>_.workspace!=="_global").map(_=>l.jsx("option",{value:_.workspace,children:_.workspace},_.workspace))]}),l.jsx("input",{type:"text",placeholder:"Add a todo...",value:x,onChange:_=>v(_.target.value),onKeyDown:_=>_.key==="Enter"&&P(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),l.jsxs("button",{onClick:P,disabled:!x.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[l.jsx(lr,{className:"h-4 w-4"}),"Add"]})]})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative flex-1 max-w-sm",children:[l.jsx(sl,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),l.jsx("input",{ref:c,type:"text",placeholder:"Search todos...",value:i,onChange:_=>a(_.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),l.jsxs("select",{value:d,onChange:_=>p(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"",children:"All statuses"}),l.jsx("option",{value:"open",children:"Open"}),l.jsx("option",{value:"in_progress",children:"In Progress"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"blocked",children:"Blocked"})]}),A.length>0&&l.jsxs("select",{value:h,onChange:_=>m(_.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[l.jsx("option",{value:"",children:"All tags"}),A.map(_=>l.jsxs("option",{value:_,children:["#",_]},_))]})]}),L.length===0?l.jsx(Ge,{title:"No todos",description:"Add your first todo above or use the CLI: syntaur todo add"}):l.jsx("div",{className:"space-y-1",children:L.map((_,D)=>l.jsxs("div",{"data-todo-id":_.id,...G(D),className:"surface-panel flex items-center gap-3 px-3 py-2 group cursor-pointer hover:bg-foreground/[0.03] transition",onClick:()=>E(_.workspace,_.id,_.status),children:[l.jsx(qw,{status:_.status,onChange:V=>H(_.workspace,_.id,V)}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:`text-sm ${_.status==="completed"?"line-through text-muted-foreground":"text-foreground"}`,children:_.description}),_.tags.length>0&&l.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:_.tags.map(V=>`#${V}`).join(" ")})]}),l.jsx("span",{className:"text-xs text-muted-foreground/60 font-mono",children:_.workspace!=="_global"&&l.jsx(Ce,{to:`/w/${_.workspace}/todos`,className:"hover:text-foreground transition mr-2",onClick:V=>V.stopPropagation(),children:_.workspace})}),k===_.id?l.jsxs("span",{className:"text-xs text-emerald-400 flex items-center gap-1",children:[l.jsx(Zf,{className:"h-3 w-3"})," Copied to clipboard"]}):l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:V=>S(V,_.id),children:["t:",_.id]}),l.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:V=>S(V,_.id),children:l.jsx(tp,{className:"h-3 w-3"})})]}),l.jsx("button",{onClick:()=>Z(_.workspace,_.id),className:"text-xs text-muted-foreground/40 hover:text-red-400 transition opacity-0 group-hover:opacity-100",children:"delete"})]},`${_.workspace}-${_.id}`))})]})}function HI(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>o=>{t.forEach(i=>i(o))},t)}const Mc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vs(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Qp(e){return"nodeType"in e}function Rn(e){var t,n;return e?Vs(e)?e:Qp(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Jp(e){const{Document:t}=Rn(e);return e instanceof t}function hl(e){return Vs(e)?!1:e instanceof Rn(e).HTMLElement}function Kw(e){return e instanceof Rn(e).SVGElement}function qs(e){return e?Vs(e)?e.document:Qp(e)?Jp(e)?e:hl(e)||Kw(e)?e.ownerDocument:document:document:document}const Rr=Mc?g.useLayoutEffect:g.useEffect;function Zp(e){const t=g.useRef(e);return Rr(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return t.current==null?void 0:t.current(...o)},[])}function WI(){const e=g.useRef(null),t=g.useCallback((o,i)=>{e.current=setInterval(o,i)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Zi(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return Rr(()=>{n.current!==e&&(n.current=e)},t),n}function ml(e,t){const n=g.useRef();return g.useMemo(()=>{const o=e(n.current);return n.current=o,o},[...t])}function rc(e){const t=Zp(e),n=g.useRef(null),o=g.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,o]}function Bf(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let uf={};function gl(e,t){return g.useMemo(()=>{if(t)return t;const n=uf[e]==null?0:uf[e]+1;return uf[e]=n,e+"-"+n},[e,t])}function Gw(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return o.reduce((a,c)=>{const d=Object.entries(c);for(const[p,h]of d){const m=a[p];m!=null&&(a[p]=m+e*h)}return a},{...t})}}const As=Gw(1),oc=Gw(-1);function VI(e){return"clientX"in e&&"clientY"in e}function eh(e){if(!e)return!1;const{KeyboardEvent:t}=Rn(e.target);return t&&e instanceof t}function qI(e){if(!e)return!1;const{TouchEvent:t}=Rn(e.target);return t&&e instanceof t}function Uf(e){if(qI(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return VI(e)?{x:e.clientX,y:e.clientY}:null}const el=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[el.Translate.toString(e),el.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:o}=e;return t+" "+n+"ms "+o}}}),My="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function KI(e){return e.matches(My)?e:e.querySelector(My)}const GI={display:"none"};function YI(e){let{id:t,value:n}=e;return xt.createElement("div",{id:t,style:GI},n)}function XI(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return xt.createElement("div",{id:t,style:i,role:"status","aria-live":o,"aria-atomic":!0},n)}function QI(){const[e,t]=g.useState("");return{announce:g.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Yw=g.createContext(null);function JI(e){const t=g.useContext(Yw);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function ZI(){const[e]=g.useState(()=>new Set),t=g.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[g.useCallback(o=>{let{type:i,event:a}=o;e.forEach(c=>{var d;return(d=c[i])==null?void 0:d.call(c,a)})},[e]),t]}const eL={draggable:`
|
|
478
478
|
To pick up a draggable item, press the space bar.
|
|
479
479
|
While dragging, use the arrow keys to move the item.
|
|
480
480
|
Press space again to drop the item in its new position, or press escape to cancel.
|