@smartmemory/compose 0.1.35-beta → 0.1.37-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/assets/{App-DMCO9aNs.js → App-BOmZUQK9.js} +8 -8
  2. package/dist/assets/{arc-DsXb95RZ.js → arc-BFMYxU8d.js} +1 -1
  3. package/dist/assets/{architectureDiagram-3BPJPVTR-BaBYippI.js → architectureDiagram-3BPJPVTR-Dr1TLm4n.js} +1 -1
  4. package/dist/assets/{blockDiagram-GPEHLZMM-HwB_eL3_.js → blockDiagram-GPEHLZMM-DfiOIWI5.js} +1 -1
  5. package/dist/assets/{c4Diagram-AAUBKEIU-CPSXghc8.js → c4Diagram-AAUBKEIU-CWZPV6Gi.js} +1 -1
  6. package/dist/assets/channel-GvJclmQg.js +1 -0
  7. package/dist/assets/{chunk-2J33WTMH-CCN3bc9J.js → chunk-2J33WTMH-DsfEX96t.js} +1 -1
  8. package/dist/assets/{chunk-4BX2VUAB-DuqFxpoV.js → chunk-4BX2VUAB-BYmdEdqH.js} +1 -1
  9. package/dist/assets/{chunk-55IACEB6-DT20mkDV.js → chunk-55IACEB6-C074eKNZ.js} +1 -1
  10. package/dist/assets/{chunk-727SXJPM-ByMH6Qvp.js → chunk-727SXJPM-rxaajQx0.js} +1 -1
  11. package/dist/assets/{chunk-AQP2D5EJ-CLgYtOHw.js → chunk-AQP2D5EJ-Cg6-5M28.js} +1 -1
  12. package/dist/assets/{chunk-FMBD7UC4-BXWmTsAA.js → chunk-FMBD7UC4-FSbyjfSh.js} +1 -1
  13. package/dist/assets/{chunk-ND2GUHAM-C2WgVbpE.js → chunk-ND2GUHAM-DhD_mt3D.js} +1 -1
  14. package/dist/assets/{chunk-QZHKN3VN-DFuQRJeh.js → chunk-QZHKN3VN-LMU-D6pF.js} +1 -1
  15. package/dist/assets/classDiagram-4FO5ZUOK-DV6SPGMl.js +1 -0
  16. package/dist/assets/classDiagram-v2-Q7XG4LA2-DV6SPGMl.js +1 -0
  17. package/dist/assets/{cose-bilkent-S5V4N54A-CdyvK5N2.js → cose-bilkent-S5V4N54A-CknvjYWn.js} +1 -1
  18. package/dist/assets/{dagre-BM42HDAG-Drkta_n5.js → dagre-BM42HDAG-BWNVctIO.js} +1 -1
  19. package/dist/assets/{diagram-2AECGRRQ-BRiBkuu5.js → diagram-2AECGRRQ-DhPeu8mD.js} +1 -1
  20. package/dist/assets/{diagram-5GNKFQAL-IrSBDK26.js → diagram-5GNKFQAL-B8e2ppCQ.js} +1 -1
  21. package/dist/assets/{diagram-KO2AKTUF-BUktYepH.js → diagram-KO2AKTUF-CJ2bkC5P.js} +1 -1
  22. package/dist/assets/{diagram-LMA3HP47-B5erGOiF.js → diagram-LMA3HP47-CCyEuSkM.js} +1 -1
  23. package/dist/assets/{diagram-OG6HWLK6-5KoSfwod.js → diagram-OG6HWLK6-CDe7c8Ym.js} +1 -1
  24. package/dist/assets/{erDiagram-TEJ5UH35-CXSf-i6t.js → erDiagram-TEJ5UH35-BDTpNyUZ.js} +1 -1
  25. package/dist/assets/{flowDiagram-I6XJVG4X-DiwEgd9q.js → flowDiagram-I6XJVG4X-CSEQ9sFL.js} +1 -1
  26. package/dist/assets/{ganttDiagram-6RSMTGT7-zQ94YEl2.js → ganttDiagram-6RSMTGT7-CJI3ZQCl.js} +1 -1
  27. package/dist/assets/{gitGraphDiagram-PVQCEYII-CWNWantF.js → gitGraphDiagram-PVQCEYII-BmIOl3oN.js} +1 -1
  28. package/dist/assets/{graph-DPbJeZyN.js → graph-uO5hwVZK.js} +1 -1
  29. package/dist/assets/{index-CyFM4bTc.js → index-DHyg44Px.js} +3 -3
  30. package/dist/assets/index-Dh2rRpBR.css +1 -0
  31. package/dist/assets/{infoDiagram-5YYISTIA-BcnrgEm6.js → infoDiagram-5YYISTIA-BiJXa7xo.js} +1 -1
  32. package/dist/assets/{ishikawaDiagram-YF4QCWOH-BRzURsJQ.js → ishikawaDiagram-YF4QCWOH-D2S-R9bH.js} +1 -1
  33. package/dist/assets/{journeyDiagram-JHISSGLW-CdwMwMPo.js → journeyDiagram-JHISSGLW-Dk6NJYdI.js} +1 -1
  34. package/dist/assets/{kanban-definition-UN3LZRKU-Difj4Zd-.js → kanban-definition-UN3LZRKU-DrTme_f5.js} +1 -1
  35. package/dist/assets/{linear-CKwgBFBW.js → linear-DAL46yON.js} +1 -1
  36. package/dist/assets/{mindmap-definition-RKZ34NQL-C2aCD1L4.js → mindmap-definition-RKZ34NQL-lzCtbkrz.js} +1 -1
  37. package/dist/assets/mobile-BwduHUEq.js +17 -0
  38. package/dist/assets/{pieDiagram-4H26LBE5-C9qGrfV0.js → pieDiagram-4H26LBE5-BGGc2f7U.js} +1 -1
  39. package/dist/assets/{quadrantDiagram-W4KKPZXB-COA0Z2JV.js → quadrantDiagram-W4KKPZXB-DN8kBgF9.js} +1 -1
  40. package/dist/assets/{requirementDiagram-4Y6WPE33-BJCU8yFE.js → requirementDiagram-4Y6WPE33-CqTXzyF-.js} +1 -1
  41. package/dist/assets/{sankeyDiagram-5OEKKPKP-vYzK7FJ6.js → sankeyDiagram-5OEKKPKP-l5oIrkxp.js} +1 -1
  42. package/dist/assets/{sequenceDiagram-3UESZ5HK-Bkh_RWpN.js → sequenceDiagram-3UESZ5HK-B5mMGwpr.js} +1 -1
  43. package/dist/assets/{stateDiagram-AJRCARHV-BlUsbYTW.js → stateDiagram-AJRCARHV-B8yZRkdR.js} +1 -1
  44. package/dist/assets/stateDiagram-v2-BHNVJYJU-BK-1uf4O.js +1 -0
  45. package/dist/assets/{timeline-definition-PNZ67QCA-DuYEZwxg.js → timeline-definition-PNZ67QCA-uc4a9RNG.js} +1 -1
  46. package/dist/assets/{vennDiagram-CIIHVFJN-D9a3Q3Ni.js → vennDiagram-CIIHVFJN-Dxp9IL4U.js} +1 -1
  47. package/dist/assets/{wardley-L42UT6IY-h2fQnc_J.js → wardley-L42UT6IY-1u4vjxUt.js} +1 -1
  48. package/dist/assets/{wardleyDiagram-YWT4CUSO-C-_dzSY5.js → wardleyDiagram-YWT4CUSO-DWpWWd1b.js} +1 -1
  49. package/dist/assets/{xychartDiagram-2RQKCTM6-CKxMIB7j.js → xychartDiagram-2RQKCTM6-Cpcj31O3.js} +1 -1
  50. package/dist/index.html +3 -3
  51. package/package.json +1 -1
  52. package/dist/assets/channel-TOlxWxU-.js +0 -1
  53. package/dist/assets/classDiagram-4FO5ZUOK-DZsvwI1V.js +0 -1
  54. package/dist/assets/classDiagram-v2-Q7XG4LA2-DZsvwI1V.js +0 -1
  55. package/dist/assets/index-CHkeTiSt.css +0 -1
  56. package/dist/assets/mobile-CsuriFuT.js +0 -17
  57. package/dist/assets/stateDiagram-v2-BHNVJYJU-_AUWPuja.js +0 -1
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-BM42HDAG-Drkta_n5.js","assets/graph-BEmEBUp_.js","assets/layout-Bw0msyOw.js","assets/mobile-CsuriFuT.js","assets/mobile-5PV1E6OC.css","assets/index-CyFM4bTc.js","assets/index-CHkeTiSt.css","assets/graph-DPbJeZyN.js","assets/cose-bilkent-S5V4N54A-CdyvK5N2.js","assets/c4Diagram-AAUBKEIU-CPSXghc8.js","assets/chunk-ND2GUHAM-C2WgVbpE.js","assets/flowDiagram-I6XJVG4X-DiwEgd9q.js","assets/chunk-FMBD7UC4-BXWmTsAA.js","assets/chunk-55IACEB6-DT20mkDV.js","assets/chunk-2J33WTMH-CCN3bc9J.js","assets/channel-TOlxWxU-.js","assets/erDiagram-TEJ5UH35-CXSf-i6t.js","assets/gitGraphDiagram-PVQCEYII-CWNWantF.js","assets/chunk-4BX2VUAB-DuqFxpoV.js","assets/chunk-QZHKN3VN-DFuQRJeh.js","assets/wardley-L42UT6IY-h2fQnc_J.js","assets/ganttDiagram-6RSMTGT7-zQ94YEl2.js","assets/linear-CKwgBFBW.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-CrowFXzY.js","assets/infoDiagram-5YYISTIA-BcnrgEm6.js","assets/pieDiagram-4H26LBE5-C9qGrfV0.js","assets/arc-DsXb95RZ.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-W4KKPZXB-COA0Z2JV.js","assets/xychartDiagram-2RQKCTM6-CKxMIB7j.js","assets/requirementDiagram-4Y6WPE33-BJCU8yFE.js","assets/sequenceDiagram-3UESZ5HK-Bkh_RWpN.js","assets/classDiagram-4FO5ZUOK-DZsvwI1V.js","assets/chunk-727SXJPM-ByMH6Qvp.js","assets/classDiagram-v2-Q7XG4LA2-DZsvwI1V.js","assets/stateDiagram-AJRCARHV-BlUsbYTW.js","assets/chunk-AQP2D5EJ-CLgYtOHw.js","assets/stateDiagram-v2-BHNVJYJU-_AUWPuja.js","assets/journeyDiagram-JHISSGLW-CdwMwMPo.js","assets/timeline-definition-PNZ67QCA-DuYEZwxg.js","assets/mindmap-definition-RKZ34NQL-C2aCD1L4.js","assets/kanban-definition-UN3LZRKU-Difj4Zd-.js","assets/sankeyDiagram-5OEKKPKP-vYzK7FJ6.js","assets/diagram-LMA3HP47-B5erGOiF.js","assets/diagram-2AECGRRQ-BRiBkuu5.js","assets/blockDiagram-GPEHLZMM-HwB_eL3_.js","assets/diagram-5GNKFQAL-IrSBDK26.js","assets/architectureDiagram-3BPJPVTR-BaBYippI.js","assets/diagram-KO2AKTUF-BUktYepH.js","assets/ishikawaDiagram-YF4QCWOH-BRzURsJQ.js","assets/vennDiagram-CIIHVFJN-D9a3Q3Ni.js","assets/diagram-OG6HWLK6-5KoSfwod.js","assets/wardleyDiagram-YWT4CUSO-C-_dzSY5.js"])))=>i.map(i=>d[i]);
2
- var h_=Object.defineProperty;var u_=(t,e,r)=>e in t?h_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>u_(t,typeof e!="symbol"?e+"":e,r);import{r as C,j as h,R as Yt,b as d_,g as Tc,f as Rt,d as f_,a as tf,w as Mo}from"./mobile-CsuriFuT.js";import{r as p_,_ as Qt,u as m_}from"./index-CyFM4bTc.js";import{a as la,b as ry,f as g_}from"./graph-DPbJeZyN.js";const xr={feature:"#3b82f6",track:"#06b6d4",decision:"#22c55e",task:"#94a3b8",spec:"#8b5cf6",idea:"#f59e0b",question:"#ec4899",evaluation:"#f97316",thread:"#64748b",artifact:"#a855f7"},qn={planned:"#64748b",ready:"#0ea5e9",in_progress:"#3b82f6",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#475569",killed:"#1e293b"},x_=["planned","ready","in_progress","review","complete","blocked","parked","killed"],ny=["vision","specification","planning","implementation","verification","release"],jl={vision:"Vision",specification:"Specification",planning:"Planning",implementation:"Implementation",verification:"Verification",release:"Release"},ef=["Untested","Low","Moderate","High","Crystallized"],ve={explore_design:"Design",prd:"PRD",architecture:"Architecture",blueprint:"Blueprint",verification:"Verification",plan:"Plan",execute:"Execute",report:"Report",docs:"Docs",ship:"Ship",complete:"Complete",killed:"Killed"},iy={explore_design:"design.md",prd:"prd.md",architecture:"architecture.md",blueprint:"blueprint.md",plan:"plan.md",report:"report.md"},sy=["claude","codex","gemini","human","unassigned"],Gp={building:"bg-blue-500/10 text-blue-400",debugging:"bg-rose-500/10 text-rose-400",testing:"bg-amber-500/10 text-amber-400",exploring:"bg-purple-500/10 text-purple-400",thinking:"bg-cyan-500/10 text-cyan-400",reviewing:"bg-emerald-500/10 text-emerald-400"},ph=[{id:"explore_design",name:"Explore Design",agent:"claude",phase:"design",hasGate:!1},{id:"design_review",name:"Design Review",agent:"codex",phase:"design",hasGate:!1},{id:"design_gate",name:"Design Gate",agent:"human",phase:"design",hasGate:!0},{id:"prd",name:"PRD",agent:"claude",phase:"design",hasGate:!1},{id:"prd_review",name:"PRD Review",agent:"codex",phase:"design",hasGate:!1},{id:"prd_gate",name:"PRD Gate",agent:"human",phase:"design",hasGate:!0},{id:"architecture",name:"Architecture",agent:"claude",phase:"design",hasGate:!1},{id:"architecture_review",name:"Arch Review",agent:"codex",phase:"design",hasGate:!1},{id:"architecture_gate",name:"Arch Gate",agent:"human",phase:"design",hasGate:!0},{id:"blueprint",name:"Blueprint",agent:"claude",phase:"blueprint",hasGate:!1},{id:"verification",name:"Verification",agent:"claude",phase:"blueprint",hasGate:!1},{id:"blueprint_review",name:"BP Review",agent:"codex",phase:"blueprint",hasGate:!1},{id:"plan",name:"Plan",agent:"claude",phase:"implementation",hasGate:!1},{id:"plan_review",name:"Plan Review",agent:"codex",phase:"implementation",hasGate:!1},{id:"plan_gate",name:"Plan Gate",agent:"human",phase:"implementation",hasGate:!0},{id:"execute",name:"Execute",agent:"claude",phase:"implementation",hasGate:!1},{id:"review",name:"Review Loop",agent:"codex",phase:"implementation",hasGate:!1},{id:"coverage",name:"Coverage Sweep",agent:"claude",phase:"implementation",hasGate:!1},{id:"report",name:"Report",agent:"claude",phase:"ship",hasGate:!1},{id:"report_review",name:"Report Review",agent:"codex",phase:"ship",hasGate:!1},{id:"report_gate",name:"Report Gate",agent:"human",phase:"ship",hasGate:!0},{id:"docs",name:"Docs",agent:"claude",phase:"ship",hasGate:!1},{id:"ship",name:"Ship",agent:"claude",phase:"ship",hasGate:!1},{id:"ship_gate",name:"Ship Gate",agent:"human",phase:"ship",hasGate:!0}],vn={design_gate:"Review Design",prd_gate:"Review PRD",architecture_gate:"Review Architecture",plan_gate:"Review Plan",report_gate:"Review Report",ship_gate:"Approve for Ship"};function Go(t,e){const r=vn[t.stepId]??(t.fromPhase&&t.toPhase?`${ve[t.fromPhase]??t.fromPhase} → ${ve[t.toPhase]??t.toPhase}`:"Gate"),n=(e==null?void 0:e.title)||t.featureCode||null;return n?`${r} — ${n}`:r}const Vp={design:{label:"Phase 1: Design",color:"border-blue-500/30 bg-blue-500/5"},blueprint:{label:"Phase 2: Blueprint",color:"border-violet-500/30 bg-violet-500/5"},implementation:{label:"Phase 3: Implement",color:"border-amber-500/30 bg-amber-500/5"},ship:{label:"Phase 4: Ship",color:"border-emerald-500/30 bg-emerald-500/5"}},y_={reading:"hsl(210 70% 60%)",writing:"hsl(142 60% 50%)",executing:"hsl(38 90% 60%)",searching:"hsl(270 60% 65%)",fetching:"hsl(190 70% 55%)",delegating:"hsl(330 60% 65%)",thinking:"hsl(240 30% 70%)"},Yp={complete:"hsl(var(--success, 160 60% 45%))",active:"hsl(var(--accent))",failed:"hsl(var(--destructive))",pending:"hsl(var(--muted-foreground) / 0.3)"},b_={development:"border-blue-500/30 bg-blue-500/5 text-blue-400",quality:"border-emerald-500/30 bg-emerald-500/5 text-emerald-400",maintenance:"border-amber-500/30 bg-amber-500/5 text-amber-400",documentation:"border-violet-500/30 bg-violet-500/5 text-violet-400",exploration:"border-cyan-500/30 bg-cyan-500/5 text-cyan-400"},C_={explore_design:{bg:"bg-blue-500/5",border:"border-blue-500/40",text:"text-blue-300"},prd:{bg:"bg-purple-500/5",border:"border-purple-500/40",text:"text-purple-300"},architecture:{bg:"bg-cyan-500/5",border:"border-cyan-500/40",text:"text-cyan-300"},blueprint:{bg:"bg-violet-500/5",border:"border-violet-500/40",text:"text-violet-300"},plan:{bg:"bg-amber-500/5",border:"border-amber-500/40",text:"text-amber-300"},report:{bg:"bg-emerald-500/5",border:"border-emerald-500/40",text:"text-emerald-300"},ship:{bg:"bg-green-500/5",border:"border-green-500/40",text:"text-green-300"}},k_={bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground"},Xp=["bg-slate-600","bg-rose-500","bg-amber-500","bg-emerald-500","bg-emerald-500"],v_={info:"text-zinc-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400"},w_={phase:"text-blue-400",gate:"text-purple-400",session:"text-zinc-400",iteration:"text-blue-300",error:"text-red-400"},S_={"compose-explorer":"#06b6d4","compose-architect":"#a855f7",codex:"#10b981",claude:"#3b82f6"},Kp={reading:"var(--color-category-reading)",writing:"var(--color-category-writing)",executing:"var(--color-category-executing)",searching:"var(--color-category-searching)",fetching:"var(--color-category-fetching)",delegating:"var(--color-category-delegating)",thinking:"hsl(var(--muted-foreground))"},oy={branch:{label:"Branch",icon:"⑂",color:"text-purple-400"},phase_transition:{label:"Phase",icon:"→",color:"text-blue-400"},iteration:{label:"Iteration",icon:"↻",color:"text-cyan-400"},gate:{label:"Gate",icon:"◈",color:"text-amber-400"},drift_threshold:{label:"Drift",icon:"⚠",color:"text-rose-400"}};function T_(t,e){return!Array.isArray(t)||t.length===0?"hidden":e?"expanded":"collapsed"}function __(t){return`violations (${Array.isArray(t)?t.length:0})`}function E_(t){return t?"▾":"▸"}function N_({violations:t=[],expanded:e,onToggle:r}){const[n,i]=C.useState(!1),s=e!==void 0,o=s?e:n,a=T_(t,o);if(a==="hidden")return null;function l(){s?r==null||r():i(d=>!d)}const c=E_(o),u=__(t);return h.jsxs("div",{style:{background:"hsl(38 90% 50% / 0.06)",borderLeft:"2px solid hsl(38 90% 50% / 0.3)",borderRadius:"3px",marginTop:"4px"},children:[h.jsxs("div",{onClick:l,style:{display:"flex",alignItems:"center",gap:"4px",padding:"3px 8px",cursor:"pointer",color:"hsl(38 90% 70%)",fontSize:"10px",fontFamily:"monospace",userSelect:"none"},children:[h.jsx("span",{style:{opacity:.7},children:c}),h.jsx("span",{children:u})]}),a==="expanded"&&h.jsx("ul",{style:{listStyle:"none",margin:0,padding:"0 8px 6px 16px"},children:t.map((d,p)=>h.jsx("li",{style:{color:"hsl(38 50% 60%)",fontSize:"10px",fontFamily:"monospace",lineHeight:"1.5"},children:d},p))})]})}function j_({msg:t,mode:e="stream"}){const[r,n]=C.useState(!1),i=t.retries??0,s=t.violations??[],o=s.length>0;return e==="strip"?i===0?null:h.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:i}):h.jsxs("div",{className:"text-[10px] py-0.5",children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsxs("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.7},children:["step complete -- ",t.stepId]}),i>0&&h.jsxs("span",{onClick:()=>n(a=>!a),style:{background:"hsl(38 90% 50% / 0.15)",color:"hsl(38 90% 60%)",padding:"1px 6px",borderRadius:"9999px",fontSize:"10px",cursor:"pointer"},children:[i," ",i===1?"retry":"retries"]}),o?h.jsxs("span",{onClick:()=>n(a=>!a),style:{color:"hsl(38 90% 60%)",fontSize:"10px",cursor:"pointer"},children:[s.length," ",s.length===1?"violation":"violations"]}):h.jsx("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.4,fontSize:"10px"},children:"✓ checks passed"})]}),r&&o&&h.jsx(N_,{violations:s,expanded:!0,onToggle:()=>n(!1)})]})}const L_=/\b(Error|error:|Traceback|FAILED|ENOENT|Cannot find)\b/,Zp=20;function B_({summary:t,output:e}){const[r,n]=C.useState(!1),[i,s]=C.useState(!1),o=e?L_.test(e):!1,a=e!=null&&e.length>0,l=a?e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-BM42HDAG-BWNVctIO.js","assets/graph-BEmEBUp_.js","assets/layout-Bw0msyOw.js","assets/mobile-BwduHUEq.js","assets/mobile-5PV1E6OC.css","assets/index-DHyg44Px.js","assets/index-Dh2rRpBR.css","assets/graph-uO5hwVZK.js","assets/cose-bilkent-S5V4N54A-CknvjYWn.js","assets/c4Diagram-AAUBKEIU-CWZPV6Gi.js","assets/chunk-ND2GUHAM-DhD_mt3D.js","assets/flowDiagram-I6XJVG4X-CSEQ9sFL.js","assets/chunk-FMBD7UC4-FSbyjfSh.js","assets/chunk-55IACEB6-C074eKNZ.js","assets/chunk-2J33WTMH-DsfEX96t.js","assets/channel-GvJclmQg.js","assets/erDiagram-TEJ5UH35-BDTpNyUZ.js","assets/gitGraphDiagram-PVQCEYII-BmIOl3oN.js","assets/chunk-4BX2VUAB-BYmdEdqH.js","assets/chunk-QZHKN3VN-LMU-D6pF.js","assets/wardley-L42UT6IY-1u4vjxUt.js","assets/ganttDiagram-6RSMTGT7-CJI3ZQCl.js","assets/linear-DAL46yON.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-CrowFXzY.js","assets/infoDiagram-5YYISTIA-BiJXa7xo.js","assets/pieDiagram-4H26LBE5-BGGc2f7U.js","assets/arc-BFMYxU8d.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-W4KKPZXB-DN8kBgF9.js","assets/xychartDiagram-2RQKCTM6-Cpcj31O3.js","assets/requirementDiagram-4Y6WPE33-CqTXzyF-.js","assets/sequenceDiagram-3UESZ5HK-B5mMGwpr.js","assets/classDiagram-4FO5ZUOK-DV6SPGMl.js","assets/chunk-727SXJPM-rxaajQx0.js","assets/classDiagram-v2-Q7XG4LA2-DV6SPGMl.js","assets/stateDiagram-AJRCARHV-B8yZRkdR.js","assets/chunk-AQP2D5EJ-Cg6-5M28.js","assets/stateDiagram-v2-BHNVJYJU-BK-1uf4O.js","assets/journeyDiagram-JHISSGLW-Dk6NJYdI.js","assets/timeline-definition-PNZ67QCA-uc4a9RNG.js","assets/mindmap-definition-RKZ34NQL-lzCtbkrz.js","assets/kanban-definition-UN3LZRKU-DrTme_f5.js","assets/sankeyDiagram-5OEKKPKP-l5oIrkxp.js","assets/diagram-LMA3HP47-CCyEuSkM.js","assets/diagram-2AECGRRQ-DhPeu8mD.js","assets/blockDiagram-GPEHLZMM-DfiOIWI5.js","assets/diagram-5GNKFQAL-B8e2ppCQ.js","assets/architectureDiagram-3BPJPVTR-Dr1TLm4n.js","assets/diagram-KO2AKTUF-CJ2bkC5P.js","assets/ishikawaDiagram-YF4QCWOH-D2S-R9bH.js","assets/vennDiagram-CIIHVFJN-Dxp9IL4U.js","assets/diagram-OG6HWLK6-CDe7c8Ym.js","assets/wardleyDiagram-YWT4CUSO-DWpWWd1b.js"])))=>i.map(i=>d[i]);
2
+ var h_=Object.defineProperty;var u_=(t,e,r)=>e in t?h_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>u_(t,typeof e!="symbol"?e+"":e,r);import{r as C,j as h,R as Yt,b as d_,g as Tc,f as Rt,d as f_,a as tf,w as Mo}from"./mobile-BwduHUEq.js";import{r as p_,_ as Qt,u as m_}from"./index-DHyg44Px.js";import{a as la,b as ry,f as g_}from"./graph-uO5hwVZK.js";const xr={feature:"#3b82f6",track:"#06b6d4",decision:"#22c55e",task:"#94a3b8",spec:"#8b5cf6",idea:"#f59e0b",question:"#ec4899",evaluation:"#f97316",thread:"#64748b",artifact:"#a855f7"},qn={planned:"#64748b",ready:"#0ea5e9",in_progress:"#3b82f6",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#475569",killed:"#1e293b"},x_=["planned","ready","in_progress","review","complete","blocked","parked","killed"],ny=["vision","specification","planning","implementation","verification","release"],jl={vision:"Vision",specification:"Specification",planning:"Planning",implementation:"Implementation",verification:"Verification",release:"Release"},ef=["Untested","Low","Moderate","High","Crystallized"],ve={explore_design:"Design",prd:"PRD",architecture:"Architecture",blueprint:"Blueprint",verification:"Verification",plan:"Plan",execute:"Execute",report:"Report",docs:"Docs",ship:"Ship",complete:"Complete",killed:"Killed"},iy={explore_design:"design.md",prd:"prd.md",architecture:"architecture.md",blueprint:"blueprint.md",plan:"plan.md",report:"report.md"},sy=["claude","codex","gemini","human","unassigned"],Gp={building:"bg-blue-500/10 text-blue-400",debugging:"bg-rose-500/10 text-rose-400",testing:"bg-amber-500/10 text-amber-400",exploring:"bg-purple-500/10 text-purple-400",thinking:"bg-cyan-500/10 text-cyan-400",reviewing:"bg-emerald-500/10 text-emerald-400"},ph=[{id:"explore_design",name:"Explore Design",agent:"claude",phase:"design",hasGate:!1},{id:"design_review",name:"Design Review",agent:"codex",phase:"design",hasGate:!1},{id:"design_gate",name:"Design Gate",agent:"human",phase:"design",hasGate:!0},{id:"prd",name:"PRD",agent:"claude",phase:"design",hasGate:!1},{id:"prd_review",name:"PRD Review",agent:"codex",phase:"design",hasGate:!1},{id:"prd_gate",name:"PRD Gate",agent:"human",phase:"design",hasGate:!0},{id:"architecture",name:"Architecture",agent:"claude",phase:"design",hasGate:!1},{id:"architecture_review",name:"Arch Review",agent:"codex",phase:"design",hasGate:!1},{id:"architecture_gate",name:"Arch Gate",agent:"human",phase:"design",hasGate:!0},{id:"blueprint",name:"Blueprint",agent:"claude",phase:"blueprint",hasGate:!1},{id:"verification",name:"Verification",agent:"claude",phase:"blueprint",hasGate:!1},{id:"blueprint_review",name:"BP Review",agent:"codex",phase:"blueprint",hasGate:!1},{id:"plan",name:"Plan",agent:"claude",phase:"implementation",hasGate:!1},{id:"plan_review",name:"Plan Review",agent:"codex",phase:"implementation",hasGate:!1},{id:"plan_gate",name:"Plan Gate",agent:"human",phase:"implementation",hasGate:!0},{id:"execute",name:"Execute",agent:"claude",phase:"implementation",hasGate:!1},{id:"review",name:"Review Loop",agent:"codex",phase:"implementation",hasGate:!1},{id:"coverage",name:"Coverage Sweep",agent:"claude",phase:"implementation",hasGate:!1},{id:"report",name:"Report",agent:"claude",phase:"ship",hasGate:!1},{id:"report_review",name:"Report Review",agent:"codex",phase:"ship",hasGate:!1},{id:"report_gate",name:"Report Gate",agent:"human",phase:"ship",hasGate:!0},{id:"docs",name:"Docs",agent:"claude",phase:"ship",hasGate:!1},{id:"ship",name:"Ship",agent:"claude",phase:"ship",hasGate:!1},{id:"ship_gate",name:"Ship Gate",agent:"human",phase:"ship",hasGate:!0}],vn={design_gate:"Review Design",prd_gate:"Review PRD",architecture_gate:"Review Architecture",plan_gate:"Review Plan",report_gate:"Review Report",ship_gate:"Approve for Ship"};function Go(t,e){const r=vn[t.stepId]??(t.fromPhase&&t.toPhase?`${ve[t.fromPhase]??t.fromPhase} → ${ve[t.toPhase]??t.toPhase}`:"Gate"),n=(e==null?void 0:e.title)||t.featureCode||null;return n?`${r} — ${n}`:r}const Vp={design:{label:"Phase 1: Design",color:"border-blue-500/30 bg-blue-500/5"},blueprint:{label:"Phase 2: Blueprint",color:"border-violet-500/30 bg-violet-500/5"},implementation:{label:"Phase 3: Implement",color:"border-amber-500/30 bg-amber-500/5"},ship:{label:"Phase 4: Ship",color:"border-emerald-500/30 bg-emerald-500/5"}},y_={reading:"hsl(210 70% 60%)",writing:"hsl(142 60% 50%)",executing:"hsl(38 90% 60%)",searching:"hsl(270 60% 65%)",fetching:"hsl(190 70% 55%)",delegating:"hsl(330 60% 65%)",thinking:"hsl(240 30% 70%)"},Yp={complete:"hsl(var(--success, 160 60% 45%))",active:"hsl(var(--accent))",failed:"hsl(var(--destructive))",pending:"hsl(var(--muted-foreground) / 0.3)"},b_={development:"border-blue-500/30 bg-blue-500/5 text-blue-400",quality:"border-emerald-500/30 bg-emerald-500/5 text-emerald-400",maintenance:"border-amber-500/30 bg-amber-500/5 text-amber-400",documentation:"border-violet-500/30 bg-violet-500/5 text-violet-400",exploration:"border-cyan-500/30 bg-cyan-500/5 text-cyan-400"},C_={explore_design:{bg:"bg-blue-500/5",border:"border-blue-500/40",text:"text-blue-300"},prd:{bg:"bg-purple-500/5",border:"border-purple-500/40",text:"text-purple-300"},architecture:{bg:"bg-cyan-500/5",border:"border-cyan-500/40",text:"text-cyan-300"},blueprint:{bg:"bg-violet-500/5",border:"border-violet-500/40",text:"text-violet-300"},plan:{bg:"bg-amber-500/5",border:"border-amber-500/40",text:"text-amber-300"},report:{bg:"bg-emerald-500/5",border:"border-emerald-500/40",text:"text-emerald-300"},ship:{bg:"bg-green-500/5",border:"border-green-500/40",text:"text-green-300"}},k_={bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground"},Xp=["bg-slate-600","bg-rose-500","bg-amber-500","bg-emerald-500","bg-emerald-500"],v_={info:"text-zinc-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400"},w_={phase:"text-blue-400",gate:"text-purple-400",session:"text-zinc-400",iteration:"text-blue-300",error:"text-red-400"},S_={"compose-explorer":"#06b6d4","compose-architect":"#a855f7",codex:"#10b981",claude:"#3b82f6"},Kp={reading:"var(--color-category-reading)",writing:"var(--color-category-writing)",executing:"var(--color-category-executing)",searching:"var(--color-category-searching)",fetching:"var(--color-category-fetching)",delegating:"var(--color-category-delegating)",thinking:"hsl(var(--muted-foreground))"},oy={branch:{label:"Branch",icon:"⑂",color:"text-purple-400"},phase_transition:{label:"Phase",icon:"→",color:"text-blue-400"},iteration:{label:"Iteration",icon:"↻",color:"text-cyan-400"},gate:{label:"Gate",icon:"◈",color:"text-amber-400"},drift_threshold:{label:"Drift",icon:"⚠",color:"text-rose-400"}};function T_(t,e){return!Array.isArray(t)||t.length===0?"hidden":e?"expanded":"collapsed"}function __(t){return`violations (${Array.isArray(t)?t.length:0})`}function E_(t){return t?"▾":"▸"}function N_({violations:t=[],expanded:e,onToggle:r}){const[n,i]=C.useState(!1),s=e!==void 0,o=s?e:n,a=T_(t,o);if(a==="hidden")return null;function l(){s?r==null||r():i(d=>!d)}const c=E_(o),u=__(t);return h.jsxs("div",{style:{background:"hsl(38 90% 50% / 0.06)",borderLeft:"2px solid hsl(38 90% 50% / 0.3)",borderRadius:"3px",marginTop:"4px"},children:[h.jsxs("div",{onClick:l,style:{display:"flex",alignItems:"center",gap:"4px",padding:"3px 8px",cursor:"pointer",color:"hsl(38 90% 70%)",fontSize:"10px",fontFamily:"monospace",userSelect:"none"},children:[h.jsx("span",{style:{opacity:.7},children:c}),h.jsx("span",{children:u})]}),a==="expanded"&&h.jsx("ul",{style:{listStyle:"none",margin:0,padding:"0 8px 6px 16px"},children:t.map((d,p)=>h.jsx("li",{style:{color:"hsl(38 50% 60%)",fontSize:"10px",fontFamily:"monospace",lineHeight:"1.5"},children:d},p))})]})}function j_({msg:t,mode:e="stream"}){const[r,n]=C.useState(!1),i=t.retries??0,s=t.violations??[],o=s.length>0;return e==="strip"?i===0?null:h.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:i}):h.jsxs("div",{className:"text-[10px] py-0.5",children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsxs("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.7},children:["step complete -- ",t.stepId]}),i>0&&h.jsxs("span",{onClick:()=>n(a=>!a),style:{background:"hsl(38 90% 50% / 0.15)",color:"hsl(38 90% 60%)",padding:"1px 6px",borderRadius:"9999px",fontSize:"10px",cursor:"pointer"},children:[i," ",i===1?"retry":"retries"]}),o?h.jsxs("span",{onClick:()=>n(a=>!a),style:{color:"hsl(38 90% 60%)",fontSize:"10px",cursor:"pointer"},children:[s.length," ",s.length===1?"violation":"violations"]}):h.jsx("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.4,fontSize:"10px"},children:"✓ checks passed"})]}),r&&o&&h.jsx(N_,{violations:s,expanded:!0,onToggle:()=>n(!1)})]})}const L_=/\b(Error|error:|Traceback|FAILED|ENOENT|Cannot find)\b/,Zp=20;function B_({summary:t,output:e}){const[r,n]=C.useState(!1),[i,s]=C.useState(!1),o=e?L_.test(e):!1,a=e!=null&&e.length>0,l=a?e.split(`
3
3
  `):[],c=l.length>Zp,u=r&&!i&&c?l.slice(0,Zp):l,d=o?"hsl(var(--destructive, 0 84% 60%))":"hsl(215 20% 20%)";return a?h.jsxs("div",{style:{marginLeft:8,borderLeft:`1px solid ${d}`,paddingLeft:8,marginTop:2},children:[h.jsxs("div",{onClick:()=>n(p=>!p),style:{opacity:.6,fontSize:"10px",cursor:"pointer",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace",userSelect:"none",display:"flex",alignItems:"center",gap:4},children:[h.jsx("span",{style:{fontSize:9},children:r?"▾":"▸"}),t]}),r&&h.jsxs("pre",{style:{margin:"4px 0 0 0",padding:0,fontSize:"10px",fontFamily:"ui-monospace, monospace",color:o?"hsl(var(--destructive, 0 84% 60%))":"hsl(var(--muted-foreground))",opacity:o?.9:.7,whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.5},children:[u.join(`
4
4
  `),!i&&c&&h.jsxs(h.Fragment,{children:[`
5
- `,h.jsxs("span",{onClick:p=>{p.stopPropagation(),s(!0)},style:{color:"hsl(var(--accent))",cursor:"pointer",textDecoration:"underline",fontSize:"10px"},children:["Show all (",l.length," lines)"]})]})]})]}):h.jsx("div",{style:{marginLeft:8,opacity:.6,fontSize:"10px",padding:"2px 0",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:t})}const A_={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"};function M_(t){return y_[A_[t]||"thinking"]}function I_(t){return t?t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`:""}function F_(t){return t==null?"":t<.001?"<$0.001":`$${t.toFixed(3)}`}function P_({input:t}){const[e,r]=C.useState(!1);if(!t||Object.keys(t).length===0)return null;const n=Object.keys(t)[0],i=String(t[n]??""),s=i.length>60?i.slice(0,57)+"…":i;return h.jsxs("div",{className:"mt-1",children:[h.jsxs("button",{onClick:()=>r(o=>!o),className:"text-[10px] font-mono flex items-center gap-1",style:{color:"hsl(var(--muted-foreground))",background:"none",border:"none",cursor:"pointer",padding:0},children:[h.jsx("span",{style:{opacity:.6},children:e?"▾":"▸"}),!e&&h.jsxs("span",{style:{opacity:.6},children:[n,": ",s]}),e&&h.jsx("span",{style:{opacity:.6},children:"collapse"})]}),e&&h.jsx("pre",{className:"mt-1 text-[10px] font-mono rounded p-2 overflow-x-auto",style:{background:"hsl(var(--muted) / 0.4)",color:"hsl(var(--muted-foreground))",maxHeight:"200px",overflowY:"auto"},children:JSON.stringify(t,null,2)})]})}function D_({block:t}){const e=M_(t.name);return h.jsxs("div",{className:"rounded px-2 py-1.5 my-1",style:{background:"hsl(var(--muted) / 0.3)",borderLeft:`2px solid ${e}`},children:[h.jsx("div",{className:"flex items-center gap-1.5",children:h.jsx("span",{className:"text-[11px] font-semibold font-mono",style:{color:e},children:t.name})}),h.jsx(P_,{input:t.input})]})}function O_({msg:t}){var r;const e=((r=t.message)==null?void 0:r.content)??[];return h.jsx("div",{className:"flex flex-col gap-1 py-1",children:e.map((n,i)=>{if(n.type==="text")return h.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"hsl(var(--foreground))"},children:n.text},i);if(n.type==="tool_use"){const s=!e.slice(i+1).some(o=>o.type==="tool_use");return h.jsxs(Yt.Fragment,{children:[h.jsx(D_,{block:n}),s&&t._toolResult&&h.jsx(B_,{summary:t._toolResult.summary,output:t._toolResult.output})]},i)}return null})})}function R_({msg:t}){const e=t.subtype!=="success",r=e?"hsl(var(--destructive))":"hsl(var(--success, 142 60% 50%))";return h.jsxs("div",{className:"rounded px-3 py-2 text-xs font-mono flex items-center gap-3 flex-wrap",style:{background:"hsl(var(--muted) / 0.4)",borderLeft:`2px solid ${r}`,color:r},children:[h.jsx("span",{children:e?"✗ error":"✓ done"}),!e&&t.num_turns!=null&&h.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[t.num_turns," turn",t.num_turns!==1?"s":""]}),t.duration_ms!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:I_(t.duration_ms)}),t.total_cost_usd!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:F_(t.total_cost_usd)}),e&&t.errors&&h.jsx("span",{style:{color:"hsl(var(--destructive))"},children:t.errors.join("; ")})]})}function $_({msg:t}){var r,n,i,s;const e=typeof((r=t.message)==null?void 0:r.content)=="string"?t.message.content:((s=(i=(n=t.message)==null?void 0:n.content)==null?void 0:i[0])==null?void 0:s.text)??"";return!e||t.isSynthetic?null:h.jsx("div",{className:"flex justify-end py-1",children:h.jsx("div",{className:"rounded-lg px-3 py-2 text-sm max-w-[80%] whitespace-pre-wrap",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--accent) / 0.3)"},children:e})})}function z_({msg:t}){var e,r;if(t.type==="stream_event"||!t.verbose&&t.type==="tool_progress"||!t.verbose&&t.type==="tool_use_summary")return null;if(t.verbose){const n=t.type==="tool_progress"?`${t.tool||"tool"} · ${t.elapsed!=null?t.elapsed+"s":""}`:t.summary||"summary",i=t.type==="tool_progress"?"progress":"summary";return h.jsxs("div",{style:{opacity:.6,fontSize:"10px",padding:"2px 0",paddingLeft:4,borderLeft:"1px solid hsl(215 20% 20%)",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:[h.jsx("span",{style:{color:"hsl(210 40% 45%)",background:"hsl(210 40% 45% / 0.1)",padding:"0 4px",borderRadius:2,fontSize:"10px"},children:i})," ",n]})}if(t.type==="system"&&t.subtype==="init")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-3 flex-wrap",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:[h.jsxs("span",{children:["session ",(e=t.session_id)==null?void 0:e.slice(0,8)]}),h.jsx("span",{children:t.model}),h.jsx("span",{children:t.permissionMode})]});if(t.type==="system"&&t.subtype==="connected")return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))",opacity:.5},children:["reconnected · session ",(r=t.sessionId)==null?void 0:r.slice(0,8)]});if(t.type==="system"&&(t.subtype==="build_start"||t.subtype==="build_resume")){const n=t.subtype==="build_resume"?"build resumed":"build started";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(var(--accent))",opacity:.8},children:[n," -- ",t.featureCode]})}if(t.type==="system"&&t.subtype==="build_step")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-2",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{children:["step ",t.stepNum,"/",t.totalSteps]}),h.jsx("span",{className:"font-mono",children:t.stepId}),h.jsx("span",{style:{opacity:.5},children:t.agent})]});if(t.type==="system"&&t.subtype==="build_step_done")return h.jsx(j_,{msg:t,mode:"stream"});if(t.type==="system"&&t.subtype==="build_gate")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(38 90% 60%)"},children:["gate -- ",t.stepId]});if(t.type==="system"&&t.subtype==="build_gate_resolved"){const n=t.outcome==="approved"||t.outcome==="approve"?"hsl(var(--success, 142 60% 50%))":t.outcome==="revise"?"hsl(38 90% 60%)":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:n,opacity:.8},children:["gate ",t.outcome," -- ",t.stepId]})}if(t.type==="system"&&t.subtype==="build_end"){const n=t.status==="complete"?"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:n},children:["build ",t.status," -- ",t.featureCode]})}return t.type==="assistant"?h.jsx(O_,{msg:t}):t.type==="user"?h.jsx($_,{msg:t}):t.type==="result"?h.jsx(R_,{msg:t}):t.type==="error"?h.jsx("div",{className:"text-xs rounded px-2 py-1.5 font-mono",style:{background:"hsl(var(--destructive) / 0.1)",color:"hsl(var(--destructive))",borderLeft:"2px solid hsl(var(--destructive))"},children:t.message}):null}function W_({onSend:t,disabled:e=!1,placeholder:r="Message Claude…"}){const n=C.useRef(null);C.useEffect(()=>{!e&&n.current&&n.current.focus()},[e]);function i(){const a=n.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,160)}px`)}function s(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),o())}function o(){const a=n.current;if(!a)return;const l=a.value.trim();l&&(t(l),a.value="",i())}return h.jsxs("div",{className:"flex items-end gap-2 px-3 py-2",style:{borderTop:"1px solid hsl(var(--border))"},children:[h.jsx("textarea",{ref:n,rows:1,disabled:e,placeholder:r,onKeyDown:s,onInput:i,className:"flex-1 resize-none bg-transparent text-sm outline-none font-mono leading-relaxed",style:{color:"hsl(var(--foreground))",caretColor:"hsl(var(--accent))",maxHeight:"160px",overflowY:"auto",opacity:e?.4:1,transition:"opacity 0.15s"}}),h.jsx("button",{onClick:o,disabled:e,title:"Send (Enter)",className:"shrink-0 rounded px-2 py-1 text-xs font-mono",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--accent))",border:"1px solid hsl(var(--accent) / 0.3)",cursor:e?"not-allowed":"pointer",opacity:e?.4:1,transition:"opacity 0.15s"},children:"↵"})]})}const ay="compose:verboseStream",Ll={verboseStream:!1};function ly(){return Ll.verboseStream}function q_(t,e){Ll.verboseStream=!!t;const r=typeof localStorage<"u"?localStorage:null;if(r)try{r.setItem(ay,String(Ll.verboseStream))}catch{}}function H_(t){const e=typeof localStorage<"u"?localStorage:null;if(e)try{const r=e.getItem(ay);r!==null&&(Ll.verboseStream=r==="true")}catch{}}function U_(t,e){return t.type==="stream_event"?{include:!1,msg:t}:t.type==="tool_progress"||t.type==="tool_use_summary"?e?{include:!0,msg:{...t,verbose:!0}}:{include:!1,msg:t}:{include:!0,msg:t}}function G_(t){var r,n;const e=[];for(let i=0;i<t.length;i++){const s=t[i],o=t[i+1],a=s.type==="assistant"&&((n=(r=s.message)==null?void 0:r.content)==null?void 0:n.some(c=>c.type==="tool_use")),l=o&&(o.type==="tool_use_summary"||o.type==="assistant"&&o.subtype==="tool_use_summary");a&&l?(e.push({...s,_toolResult:o}),i++):e.push(s)}return e}const cy=parseInt("4002",10),V_="compose-agent-session",Qp=500,Y_=8,X_=2e3,Jp={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"},K_={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking",waiting:"Waiting for gate approval"};H_();const ut={es:null,connected:!1,connecting:!1,reconnectTimer:null,reconnectAttempts:0,sessionId:null,messages:[],agentStatus:"idle",agentTool:null,agentCategory:null,currentActivity:null,activityLog:[],_idleTimer:null,sourceStatus:{build:null,interactive:null},parallelTasks:null,onConnectedChange:null,onMessagesChange:null,onAgentStatusChange:null};function Z_(t){var e,r;if(t._source==="build"){if(t.type==="system"){if(t.subtype==="build_step"||t.subtype==="build_step_done"||t.subtype==="build_gate_resolved")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.subtype==="build_gate")return{status:"working",tool:null,category:"waiting",_source:"build"};if(t.subtype==="build_end")return{status:"idle",tool:null,category:null,_source:"build"}}if(t.type==="error"&&t.source==="build")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.type==="assistant"){const n=((e=t.message)==null?void 0:e.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s,_source:"build"}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking",_source:"build"}}return null}if(t.type==="assistant"){const n=((r=t.message)==null?void 0:r.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking"}}return t.type==="result"?{status:"idle",tool:null,category:null}:null}function mh(t,e,r){const n=Date.now(),i=ut.agentStatus,s=ut.agentTool;if(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),i==="working"&&(t==="idle"||e!==s)){const a=ut.currentActivity;a&&(a.endTime=n,a.duration=n-a.startTime,ut.activityLog.push(a),ut.activityLog.length>Y_&&ut.activityLog.shift())}t==="working"&&e!==s?ut.currentActivity={tool:e,category:r,startTime:n,endTime:null,duration:null}:t==="idle"&&(ut.currentActivity=null),ut.agentStatus=t,ut.agentTool=e,ut.agentCategory=r;const o={status:t,tool:e,category:r,activityLog:ut.activityLog,currentActivity:ut.currentActivity,parallelTasks:ut.parallelTasks};ut.onAgentStatusChange&&ut.onAgentStatusChange({...o}),window.dispatchEvent(new CustomEvent("compose:agent-status",{detail:o}))}function tm(){const t=ut.sourceStatus.build,e=ut.sourceStatus.interactive;(e==null?void 0:e.status)==="working"?mh(e.status,e.tool,e.category):(t==null?void 0:t.status)==="working"?mh(t.status,t.tool,t.category):ut._idleTimer=setTimeout(()=>{ut._idleTimer=null,mh("idle",null,null)},X_)}function ju(t){var i,s,o,a,l,c;t._source==="build"&&t.type==="system"&&t.parallel&&(t.subtype==="build_step"&&((i=t.stepNum)!=null&&i.toString().startsWith("∥"))?(ut.parallelTasks||(ut.parallelTasks={total:0,completed:0,failed:0,active:0,tasks:{}}),ut.parallelTasks.total++,ut.parallelTasks.active++,ut.parallelTasks.tasks[t.stepId]="working"):t.subtype==="build_step_done"&&((o=(s=ut.parallelTasks)==null?void 0:s.tasks)!=null&&o[t.stepId])?(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.completed++,ut.parallelTasks.tasks[t.stepId]="complete"):t.subtype==="build_step_done"&&ut.parallelTasks&&!((a=t.stepNum)!=null&&a.toString().startsWith("∥"))&&(ut.parallelTasks=null)),t._source==="build"&&t.type==="error"&&((c=(l=ut.parallelTasks)==null?void 0:l.tasks)!=null&&c[t.stepId])&&(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.failed++,ut.parallelTasks.tasks[t.stepId]="failed");const e=Z_(t);if(e){const u=e._source==="build"?"build":"interactive";ut.sourceStatus[u]=e,e.status==="idle"?(ut.parallelTasks=null,tm()):(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),tm())}t.type==="system"&&t.subtype==="init"&&t.session_id&&(ut.sessionId=t.session_id,sessionStorage.setItem(V_,t.session_id));const{include:r,msg:n}=U_(t,ly());r&&(ut.messages=[...ut.messages,n],ut.messages.length>Qp&&(ut.messages=ut.messages.slice(-Qp)),ut.onMessagesChange&&ut.onMessagesChange(ut.messages))}function Q_(){if(ut.es)return;const t=`${window.location.protocol}//${window.location.hostname}:${cy}/api/agent/stream`,e=d_({url:t,namedEvents:["hydrate"],onOpen:()=>{ut.connected=!0,ut.sourceStatus.build=null,ut.onConnectedChange&&ut.onConnectedChange(!0)},onClose:()=>{ut.connected=!1,ut.onConnectedChange&&ut.onConnectedChange(!1)},onEvent:(r,n)=>{if(n==="hydrate"){if(Array.isArray(r))for(const i of r)ju(i);return}ju(r)},maxBackoffMs:8e3});ut.es=e}async function gh(t,e){const r=await fetch(`${window.location.protocol}//${window.location.hostname}:${cy}${t}`,{method:"POST",headers:{"Content-Type":"application/json","x-compose-token":""},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||r.statusText)}return r.json()}function em(t){if(!t)return"";if(t<1e3)return"<1s";const e=Math.floor(t/1e3);return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}function hy(){var k;const[t,e]=C.useState(ut.connected),[r,n]=C.useState(ut.messages),[i,s]=C.useState({status:ut.agentStatus,tool:ut.agentTool,category:ut.agentCategory,activityLog:ut.activityLog,currentActivity:ut.currentActivity}),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=C.useRef(null),d=r.length===0||r.every(T=>T.type==="system"&&(T.subtype==="init"||T.subtype==="connected"));C.useEffect(()=>(ut.onConnectedChange=e,ut.onMessagesChange=n,ut.onAgentStatusChange=s,()=>{ut.onConnectedChange=null,ut.onMessagesChange=null,ut.onAgentStatusChange=null}),[]),C.useEffect(()=>{Q_()},[]),C.useEffect(()=>{var T;(T=u.current)==null||T.scrollIntoView({behavior:"smooth"})},[r.length]),C.useEffect(()=>{if(i.status!=="working"||!i.currentActivity){c(null);return}const T=i.currentActivity.startTime,_=()=>c(Date.now()-T);_();const w=setInterval(_,1e3);return()=>clearInterval(w)},[i.status,(k=i.currentActivity)==null?void 0:k.startTime]);const p=C.useCallback(async T=>{a(!0);const _=T.match(/[A-Z]+-\d+/);_&&window.dispatchEvent(new CustomEvent("compose:select-feature",{detail:{featureCode:_[0]}}));try{d||!ut.sessionId?await gh("/api/agent/session",{prompt:T}):await gh("/api/agent/message",{prompt:T})}catch(w){ju({type:"error",message:`Failed to send: ${w.message}`})}finally{a(!1)}},[d]),f=C.useCallback(async()=>{try{await gh("/api/agent/interrupt",{})}catch{}},[]),m=t&&(i.status==="working"||o),x=t?m?"#fbbf24":"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))",g=i.category?K_[i.category]:null,y=t?m?g||"working":"idle":"offline",b=i.activityLog||[];return h.jsxs("div",{className:"relative w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("div",{className:"flex items-center gap-0.5",children:t&&b.length>0&&b.slice(-5).map((T,_)=>h.jsx("div",{className:"h-1 rounded-full",title:`${T.tool||"thinking"} — ${em(T.duration)}`,style:{width:Math.max(6,Math.min(20,(T.duration||0)/1e3*2)),background:"hsl(var(--muted-foreground))",opacity:.25+_/5*.5}},_))}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[m&&h.jsx("button",{onClick:f,title:"Interrupt",className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))",border:"1px solid hsl(var(--destructive) / 0.3)",cursor:"pointer"},children:"stop"}),h.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:x,animation:m?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider",style:{color:m?"#fbbf24":"hsl(var(--muted-foreground))"},children:y}),m&&i.tool&&h.jsx("span",{className:"text-[10px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:i.tool}),m&&l!=null&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:em(l)})]})]}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 py-2",style:{scrollBehavior:"smooth"},children:[r.length===0&&h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 opacity-40",children:[h.jsx("span",{className:"text-2xl",children:"⬡"}),h.jsx("span",{className:"text-xs uppercase tracking-widest",style:{color:"hsl(var(--muted-foreground))"},children:t?"ready":"connecting…"})]}),G_(r).map((T,_)=>h.jsx(z_,{msg:T},T.uuid||_)),h.jsx("div",{ref:u})]}),!t&&h.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none",style:{background:"hsl(var(--background) / 0.7)",backdropFilter:"blur(2px)"},children:h.jsxs("div",{className:"flex flex-col items-center gap-3",children:[h.jsx("div",{className:"w-5 h-5 rounded-full animate-spin",style:{border:"2px solid hsl(var(--accent) / 0.2)",borderTopColor:"hsl(var(--accent))"}}),h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:"connecting to agent server…"})]})}),h.jsx(W_,{onSend:p,disabled:m||!t,placeholder:m?"Working…":"Message Claude…"})]})}function J_(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const tE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rE={};function rm(t,e){return(rE.jsx?eE:tE).test(t)}const nE=/[ \t\n\f\r]/g;function iE(t){return typeof t=="object"?t.type==="text"?nm(t.value):!1:nm(t)}function nm(t){return t.replace(nE,"")===""}class ca{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}}ca.prototype.normal={};ca.prototype.property={};ca.prototype.space=void 0;function uy(t,e){const r={},n={};for(const i of t)Object.assign(r,i.property),Object.assign(n,i.normal);return new ca(r,n,e)}function Lu(t){return t.toLowerCase()}class yr{constructor(e,r){this.attribute=r,this.property=e}}yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let sE=0;const Ht=_i(),je=_i(),Bu=_i(),ot=_i(),he=_i(),as=_i(),Sr=_i();function _i(){return 2**++sE}const Au=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ht,booleanish:je,commaOrSpaceSeparated:Sr,commaSeparated:as,number:ot,overloadedBoolean:Bu,spaceSeparated:he},Symbol.toStringTag,{value:"Module"})),xh=Object.keys(Au);class rf extends yr{constructor(e,r,n,i){let s=-1;if(super(e,r),im(this,"space",i),typeof n=="number")for(;++s<xh.length;){const o=xh[s];im(this,xh[s],(n&Au[o])===Au[o])}}}rf.prototype.defined=!0;function im(t,e,r){r&&(t[e]=r)}function zs(t){const e={},r={};for(const[n,i]of Object.entries(t.properties)){const s=new rf(n,t.transform(t.attributes||{},n),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),e[n]=s,r[Lu(n)]=n,r[Lu(s.attribute)]=n}return new ca(e,r,t.space)}const dy=zs({properties:{ariaActiveDescendant:null,ariaAtomic:je,ariaAutoComplete:null,ariaBusy:je,ariaChecked:je,ariaColCount:ot,ariaColIndex:ot,ariaColSpan:ot,ariaControls:he,ariaCurrent:null,ariaDescribedBy:he,ariaDetails:null,ariaDisabled:je,ariaDropEffect:he,ariaErrorMessage:null,ariaExpanded:je,ariaFlowTo:he,ariaGrabbed:je,ariaHasPopup:null,ariaHidden:je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:he,ariaLevel:ot,ariaLive:null,ariaModal:je,ariaMultiLine:je,ariaMultiSelectable:je,ariaOrientation:null,ariaOwns:he,ariaPlaceholder:null,ariaPosInSet:ot,ariaPressed:je,ariaReadOnly:je,ariaRelevant:null,ariaRequired:je,ariaRoleDescription:he,ariaRowCount:ot,ariaRowIndex:ot,ariaRowSpan:ot,ariaSelected:je,ariaSetSize:ot,ariaSort:null,ariaValueMax:ot,ariaValueMin:ot,ariaValueNow:ot,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function fy(t,e){return e in t?t[e]:e}function py(t,e){return fy(t,e.toLowerCase())}const oE=zs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:as,acceptCharset:he,accessKey:he,action:null,allow:null,allowFullScreen:Ht,allowPaymentRequest:Ht,allowUserMedia:Ht,alt:null,as:null,async:Ht,autoCapitalize:null,autoComplete:he,autoFocus:Ht,autoPlay:Ht,blocking:he,capture:null,charSet:null,checked:Ht,cite:null,className:he,cols:ot,colSpan:null,content:null,contentEditable:je,controls:Ht,controlsList:he,coords:ot|as,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ht,defer:Ht,dir:null,dirName:null,disabled:Ht,download:Bu,draggable:je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ht,formTarget:null,headers:he,height:ot,hidden:Bu,high:ot,href:null,hrefLang:null,htmlFor:he,httpEquiv:he,id:null,imageSizes:null,imageSrcSet:null,inert:Ht,inputMode:null,integrity:null,is:null,isMap:Ht,itemId:null,itemProp:he,itemRef:he,itemScope:Ht,itemType:he,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ht,low:ot,manifest:null,max:null,maxLength:ot,media:null,method:null,min:null,minLength:ot,multiple:Ht,muted:Ht,name:null,nonce:null,noModule:Ht,noValidate:Ht,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:Ht,optimum:ot,pattern:null,ping:he,placeholder:null,playsInline:Ht,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ht,referrerPolicy:null,rel:he,required:Ht,reversed:Ht,rows:ot,rowSpan:ot,sandbox:he,scope:null,scoped:Ht,seamless:Ht,selected:Ht,shadowRootClonable:Ht,shadowRootDelegatesFocus:Ht,shadowRootMode:null,shape:null,size:ot,sizes:null,slot:null,span:ot,spellCheck:je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ot,step:null,style:null,tabIndex:ot,target:null,title:null,translate:null,type:null,typeMustMatch:Ht,useMap:null,value:je,width:ot,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:he,axis:null,background:null,bgColor:null,border:ot,borderColor:null,bottomMargin:ot,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ht,declare:Ht,event:null,face:null,frame:null,frameBorder:null,hSpace:ot,leftMargin:ot,link:null,longDesc:null,lowSrc:null,marginHeight:ot,marginWidth:ot,noResize:Ht,noHref:Ht,noShade:Ht,noWrap:Ht,object:null,profile:null,prompt:null,rev:null,rightMargin:ot,rules:null,scheme:null,scrolling:je,standby:null,summary:null,text:null,topMargin:ot,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ot,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ht,disableRemotePlayback:Ht,prefix:null,property:null,results:ot,security:null,unselectable:null},space:"html",transform:py}),aE=zs({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:Sr,accentHeight:ot,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ot,amplitude:ot,arabicForm:null,ascent:ot,attributeName:null,attributeType:null,azimuth:ot,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ot,by:null,calcMode:null,capHeight:ot,className:he,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:ot,diffuseConstant:ot,direction:null,display:null,dur:null,divisor:ot,dominantBaseline:null,download:Ht,dx:null,dy:null,edgeMode:null,editable:null,elevation:ot,enableBackground:null,end:null,event:null,exponent:ot,externalResourcesRequired:null,fill:null,fillOpacity:ot,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:as,g2:as,glyphName:as,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ot,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ot,horizOriginX:ot,horizOriginY:ot,id:null,ideographic:ot,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ot,k:ot,k1:ot,k2:ot,k3:ot,k4:ot,kernelMatrix:Sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ot,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:ot,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:ot,overlineThickness:ot,paintOrder:null,panose1:null,path:null,pathLength:ot,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:he,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ot,pointsAtY:ot,pointsAtZ:ot,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Sr,rev:Sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Sr,requiredFeatures:Sr,requiredFonts:Sr,requiredFormats:Sr,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:ot,specularExponent:ot,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ot,strikethroughThickness:ot,string:null,stroke:null,strokeDashArray:Sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ot,strokeOpacity:ot,strokeWidth:null,style:null,surfaceScale:ot,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Sr,tabIndex:ot,tableValues:null,target:null,targetX:ot,targetY:ot,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ot,underlineThickness:ot,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ot,values:null,vAlphabetic:ot,vMathematical:ot,vectorEffect:null,vHanging:ot,vIdeographic:ot,version:null,vertAdvY:ot,vertOriginX:ot,vertOriginY:ot,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ot,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fy}),my=zs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),gy=zs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:py}),xy=zs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),lE={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"},cE=/[A-Z]/g,sm=/-[a-z]/g,hE=/^data[-\w.:]+$/i;function uE(t,e){const r=Lu(e);let n=e,i=yr;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&hE.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(sm,fE);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!sm.test(s)){let o=s.replace(cE,dE);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=rf}return new i(n,e)}function dE(t){return"-"+t.toLowerCase()}function fE(t){return t.charAt(1).toUpperCase()}const pE=uy([dy,oE,my,gy,xy],"html"),nf=uy([dy,aE,my,gy,xy],"svg");function mE(t){return t.join(" ").trim()}var Pi={},yh,om;function gE(){if(om)return yh;om=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,r=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
5
+ `,h.jsxs("span",{onClick:p=>{p.stopPropagation(),s(!0)},style:{color:"hsl(var(--accent))",cursor:"pointer",textDecoration:"underline",fontSize:"10px"},children:["Show all (",l.length," lines)"]})]})]})]}):h.jsx("div",{style:{marginLeft:8,opacity:.6,fontSize:"10px",padding:"2px 0",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:t})}const A_={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"};function M_(t){return y_[A_[t]||"thinking"]}function I_(t){return t?t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`:""}function F_(t){return t==null?"":t<.001?"<$0.001":`$${t.toFixed(3)}`}function P_({input:t}){const[e,r]=C.useState(!1);if(!t||Object.keys(t).length===0)return null;const n=Object.keys(t)[0],i=String(t[n]??""),s=i.length>60?i.slice(0,57)+"…":i;return h.jsxs("div",{className:"mt-1",children:[h.jsxs("button",{onClick:()=>r(o=>!o),className:"text-[10px] font-mono flex items-center gap-1",style:{color:"hsl(var(--muted-foreground))",background:"none",border:"none",cursor:"pointer",padding:0},children:[h.jsx("span",{style:{opacity:.6},children:e?"▾":"▸"}),!e&&h.jsxs("span",{style:{opacity:.6},children:[n,": ",s]}),e&&h.jsx("span",{style:{opacity:.6},children:"collapse"})]}),e&&h.jsx("pre",{className:"mt-1 text-[10px] font-mono rounded p-2 overflow-x-auto",style:{background:"hsl(var(--muted) / 0.4)",color:"hsl(var(--muted-foreground))",maxHeight:"200px",overflowY:"auto"},children:JSON.stringify(t,null,2)})]})}function D_({block:t}){const e=M_(t.name);return h.jsxs("div",{className:"rounded px-2 py-1.5 my-1",style:{background:"hsl(var(--muted) / 0.3)",borderLeft:`2px solid ${e}`},children:[h.jsx("div",{className:"flex items-center gap-1.5",children:h.jsx("span",{className:"text-[11px] font-semibold font-mono",style:{color:e},children:t.name})}),h.jsx(P_,{input:t.input})]})}function O_({msg:t}){var r;const e=((r=t.message)==null?void 0:r.content)??[];return h.jsx("div",{className:"flex flex-col gap-1 py-1",children:e.map((n,i)=>{if(n.type==="text")return h.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"hsl(var(--foreground))"},children:n.text},i);if(n.type==="tool_use"){const s=!e.slice(i+1).some(o=>o.type==="tool_use");return h.jsxs(Yt.Fragment,{children:[h.jsx(D_,{block:n}),s&&t._toolResult&&h.jsx(B_,{summary:t._toolResult.summary,output:t._toolResult.output})]},i)}return null})})}function R_({msg:t}){const e=t.subtype!=="success",r=e?"hsl(var(--destructive))":"hsl(var(--success, 142 60% 50%))";return h.jsxs("div",{className:"rounded px-3 py-2 text-xs font-mono flex items-center gap-3 flex-wrap",style:{background:"hsl(var(--muted) / 0.4)",borderLeft:`2px solid ${r}`,color:r},children:[h.jsx("span",{children:e?"✗ error":"✓ done"}),!e&&t.num_turns!=null&&h.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[t.num_turns," turn",t.num_turns!==1?"s":""]}),t.duration_ms!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:I_(t.duration_ms)}),t.total_cost_usd!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:F_(t.total_cost_usd)}),e&&t.errors&&h.jsx("span",{style:{color:"hsl(var(--destructive))"},children:t.errors.join("; ")})]})}function $_({msg:t}){var r,n,i,s;const e=typeof((r=t.message)==null?void 0:r.content)=="string"?t.message.content:((s=(i=(n=t.message)==null?void 0:n.content)==null?void 0:i[0])==null?void 0:s.text)??"";return!e||t.isSynthetic?null:h.jsx("div",{className:"flex justify-end py-1",children:h.jsx("div",{className:"rounded-lg px-3 py-2 text-sm max-w-[80%] whitespace-pre-wrap",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--accent) / 0.3)"},children:e})})}function z_({msg:t}){var e,r;if(t.type==="stream_event"||!t.verbose&&t.type==="tool_progress"||!t.verbose&&t.type==="tool_use_summary")return null;if(t.verbose){const n=t.type==="tool_progress"?`${t.tool||"tool"} · ${t.elapsed!=null?t.elapsed+"s":""}`:t.summary||"summary",i=t.type==="tool_progress"?"progress":"summary";return h.jsxs("div",{style:{opacity:.6,fontSize:"10px",padding:"2px 0",paddingLeft:4,borderLeft:"1px solid hsl(215 20% 20%)",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:[h.jsx("span",{style:{color:"hsl(210 40% 45%)",background:"hsl(210 40% 45% / 0.1)",padding:"0 4px",borderRadius:2,fontSize:"10px"},children:i})," ",n]})}if(t.type==="system"&&t.subtype==="init")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-3 flex-wrap",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:[h.jsxs("span",{children:["session ",(e=t.session_id)==null?void 0:e.slice(0,8)]}),h.jsx("span",{children:t.model}),h.jsx("span",{children:t.permissionMode})]});if(t.type==="system"&&t.subtype==="connected")return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))",opacity:.5},children:["reconnected · session ",(r=t.sessionId)==null?void 0:r.slice(0,8)]});if(t.type==="system"&&(t.subtype==="build_start"||t.subtype==="build_resume")){const n=t.subtype==="build_resume"?"build resumed":"build started";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(var(--accent))",opacity:.8},children:[n," -- ",t.featureCode]})}if(t.type==="system"&&t.subtype==="build_step")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-2",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{children:["step ",t.stepNum,"/",t.totalSteps]}),h.jsx("span",{className:"font-mono",children:t.stepId}),h.jsx("span",{style:{opacity:.5},children:t.agent})]});if(t.type==="system"&&t.subtype==="build_step_done")return h.jsx(j_,{msg:t,mode:"stream"});if(t.type==="system"&&t.subtype==="build_gate")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(38 90% 60%)"},children:["gate -- ",t.stepId]});if(t.type==="system"&&t.subtype==="build_gate_resolved"){const n=t.outcome==="approved"||t.outcome==="approve"?"hsl(var(--success, 142 60% 50%))":t.outcome==="revise"?"hsl(38 90% 60%)":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:n,opacity:.8},children:["gate ",t.outcome," -- ",t.stepId]})}if(t.type==="system"&&t.subtype==="build_end"){const n=t.status==="complete"?"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:n},children:["build ",t.status," -- ",t.featureCode]})}return t.type==="assistant"?h.jsx(O_,{msg:t}):t.type==="user"?h.jsx($_,{msg:t}):t.type==="result"?h.jsx(R_,{msg:t}):t.type==="error"?h.jsx("div",{className:"text-xs rounded px-2 py-1.5 font-mono",style:{background:"hsl(var(--destructive) / 0.1)",color:"hsl(var(--destructive))",borderLeft:"2px solid hsl(var(--destructive))"},children:t.message}):null}function W_({onSend:t,disabled:e=!1,placeholder:r="Message Claude…"}){const n=C.useRef(null);C.useEffect(()=>{!e&&n.current&&n.current.focus()},[e]);function i(){const a=n.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,160)}px`)}function s(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),o())}function o(){const a=n.current;if(!a)return;const l=a.value.trim();l&&(t(l),a.value="",i())}return h.jsxs("div",{className:"flex items-end gap-2 px-3 py-2",style:{borderTop:"1px solid hsl(var(--border))"},children:[h.jsx("textarea",{ref:n,rows:1,disabled:e,placeholder:r,onKeyDown:s,onInput:i,className:"flex-1 resize-none bg-transparent text-sm outline-none font-mono leading-relaxed",style:{color:"hsl(var(--foreground))",caretColor:"hsl(var(--accent))",maxHeight:"160px",overflowY:"auto",opacity:e?.4:1,transition:"opacity 0.15s"}}),h.jsx("button",{onClick:o,disabled:e,title:"Send (Enter)",className:"shrink-0 rounded px-2 py-1 text-xs font-mono",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--accent))",border:"1px solid hsl(var(--accent) / 0.3)",cursor:e?"not-allowed":"pointer",opacity:e?.4:1,transition:"opacity 0.15s"},children:"↵"})]})}const ay="compose:verboseStream",Ll={verboseStream:!1};function ly(){return Ll.verboseStream}function q_(t,e){Ll.verboseStream=!!t;const r=typeof localStorage<"u"?localStorage:null;if(r)try{r.setItem(ay,String(Ll.verboseStream))}catch{}}function H_(t){const e=typeof localStorage<"u"?localStorage:null;if(e)try{const r=e.getItem(ay);r!==null&&(Ll.verboseStream=r==="true")}catch{}}function U_(t,e){return t.type==="stream_event"?{include:!1,msg:t}:t.type==="tool_progress"||t.type==="tool_use_summary"?e?{include:!0,msg:{...t,verbose:!0}}:{include:!1,msg:t}:{include:!0,msg:t}}function G_(t){var r,n;const e=[];for(let i=0;i<t.length;i++){const s=t[i],o=t[i+1],a=s.type==="assistant"&&((n=(r=s.message)==null?void 0:r.content)==null?void 0:n.some(c=>c.type==="tool_use")),l=o&&(o.type==="tool_use_summary"||o.type==="assistant"&&o.subtype==="tool_use_summary");a&&l?(e.push({...s,_toolResult:o}),i++):e.push(s)}return e}const cy=parseInt("4002",10),V_="compose-agent-session",Qp=500,Y_=8,X_=2e3,Jp={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"},K_={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking",waiting:"Waiting for gate approval"};H_();const ut={es:null,connected:!1,connecting:!1,reconnectTimer:null,reconnectAttempts:0,sessionId:null,messages:[],agentStatus:"idle",agentTool:null,agentCategory:null,currentActivity:null,activityLog:[],_idleTimer:null,sourceStatus:{build:null,interactive:null},parallelTasks:null,onConnectedChange:null,onMessagesChange:null,onAgentStatusChange:null};function Z_(t){var e,r;if(t._source==="build"){if(t.type==="system"){if(t.subtype==="build_step"||t.subtype==="build_step_done"||t.subtype==="build_gate_resolved")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.subtype==="build_gate")return{status:"working",tool:null,category:"waiting",_source:"build"};if(t.subtype==="build_end")return{status:"idle",tool:null,category:null,_source:"build"}}if(t.type==="error"&&t.source==="build")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.type==="assistant"){const n=((e=t.message)==null?void 0:e.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s,_source:"build"}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking",_source:"build"}}return null}if(t.type==="assistant"){const n=((r=t.message)==null?void 0:r.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking"}}return t.type==="result"?{status:"idle",tool:null,category:null}:null}function mh(t,e,r){const n=Date.now(),i=ut.agentStatus,s=ut.agentTool;if(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),i==="working"&&(t==="idle"||e!==s)){const a=ut.currentActivity;a&&(a.endTime=n,a.duration=n-a.startTime,ut.activityLog.push(a),ut.activityLog.length>Y_&&ut.activityLog.shift())}t==="working"&&e!==s?ut.currentActivity={tool:e,category:r,startTime:n,endTime:null,duration:null}:t==="idle"&&(ut.currentActivity=null),ut.agentStatus=t,ut.agentTool=e,ut.agentCategory=r;const o={status:t,tool:e,category:r,activityLog:ut.activityLog,currentActivity:ut.currentActivity,parallelTasks:ut.parallelTasks};ut.onAgentStatusChange&&ut.onAgentStatusChange({...o}),window.dispatchEvent(new CustomEvent("compose:agent-status",{detail:o}))}function tm(){const t=ut.sourceStatus.build,e=ut.sourceStatus.interactive;(e==null?void 0:e.status)==="working"?mh(e.status,e.tool,e.category):(t==null?void 0:t.status)==="working"?mh(t.status,t.tool,t.category):ut._idleTimer=setTimeout(()=>{ut._idleTimer=null,mh("idle",null,null)},X_)}function ju(t){var i,s,o,a,l,c;t._source==="build"&&t.type==="system"&&t.parallel&&(t.subtype==="build_step"&&((i=t.stepNum)!=null&&i.toString().startsWith("∥"))?(ut.parallelTasks||(ut.parallelTasks={total:0,completed:0,failed:0,active:0,tasks:{}}),ut.parallelTasks.total++,ut.parallelTasks.active++,ut.parallelTasks.tasks[t.stepId]="working"):t.subtype==="build_step_done"&&((o=(s=ut.parallelTasks)==null?void 0:s.tasks)!=null&&o[t.stepId])?(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.completed++,ut.parallelTasks.tasks[t.stepId]="complete"):t.subtype==="build_step_done"&&ut.parallelTasks&&!((a=t.stepNum)!=null&&a.toString().startsWith("∥"))&&(ut.parallelTasks=null)),t._source==="build"&&t.type==="error"&&((c=(l=ut.parallelTasks)==null?void 0:l.tasks)!=null&&c[t.stepId])&&(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.failed++,ut.parallelTasks.tasks[t.stepId]="failed");const e=Z_(t);if(e){const u=e._source==="build"?"build":"interactive";ut.sourceStatus[u]=e,e.status==="idle"?(ut.parallelTasks=null,tm()):(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),tm())}t.type==="system"&&t.subtype==="init"&&t.session_id&&(ut.sessionId=t.session_id,sessionStorage.setItem(V_,t.session_id));const{include:r,msg:n}=U_(t,ly());r&&(ut.messages=[...ut.messages,n],ut.messages.length>Qp&&(ut.messages=ut.messages.slice(-Qp)),ut.onMessagesChange&&ut.onMessagesChange(ut.messages))}function Q_(){if(ut.es)return;const t=`${window.location.protocol}//${window.location.hostname}:${cy}/api/agent/stream`,e=d_({url:t,namedEvents:["hydrate"],onOpen:()=>{ut.connected=!0,ut.sourceStatus.build=null,ut.onConnectedChange&&ut.onConnectedChange(!0)},onClose:()=>{ut.connected=!1,ut.onConnectedChange&&ut.onConnectedChange(!1)},onEvent:(r,n)=>{if(n==="hydrate"){if(Array.isArray(r))for(const i of r)ju(i);return}ju(r)},maxBackoffMs:8e3});ut.es=e}async function gh(t,e){const r=await fetch(`${window.location.protocol}//${window.location.hostname}:${cy}${t}`,{method:"POST",headers:{"Content-Type":"application/json","x-compose-token":""},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||r.statusText)}return r.json()}function em(t){if(!t)return"";if(t<1e3)return"<1s";const e=Math.floor(t/1e3);return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}function hy(){var k;const[t,e]=C.useState(ut.connected),[r,n]=C.useState(ut.messages),[i,s]=C.useState({status:ut.agentStatus,tool:ut.agentTool,category:ut.agentCategory,activityLog:ut.activityLog,currentActivity:ut.currentActivity}),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=C.useRef(null),d=r.length===0||r.every(T=>T.type==="system"&&(T.subtype==="init"||T.subtype==="connected"));C.useEffect(()=>(ut.onConnectedChange=e,ut.onMessagesChange=n,ut.onAgentStatusChange=s,()=>{ut.onConnectedChange=null,ut.onMessagesChange=null,ut.onAgentStatusChange=null}),[]),C.useEffect(()=>{Q_()},[]),C.useEffect(()=>{var T;(T=u.current)==null||T.scrollIntoView({behavior:"smooth"})},[r.length]),C.useEffect(()=>{if(i.status!=="working"||!i.currentActivity){c(null);return}const T=i.currentActivity.startTime,_=()=>c(Date.now()-T);_();const w=setInterval(_,1e3);return()=>clearInterval(w)},[i.status,(k=i.currentActivity)==null?void 0:k.startTime]);const p=C.useCallback(async T=>{a(!0);const _=T.match(/[A-Z]+-\d+/);_&&window.dispatchEvent(new CustomEvent("compose:select-feature",{detail:{featureCode:_[0]}}));try{d||!ut.sessionId?await gh("/api/agent/session",{prompt:T}):await gh("/api/agent/message",{prompt:T})}catch(w){ju({type:"error",message:`Failed to send: ${w.message}`})}finally{a(!1)}},[d]),f=C.useCallback(async()=>{try{await gh("/api/agent/interrupt",{})}catch{}},[]),m=t&&(i.status==="working"||o),x=t?m?"#fbbf24":"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))",g=i.category?K_[i.category]:null,y=t?m?g||"working":"ready":"offline",b=i.activityLog||[];return h.jsxs("div",{className:"relative w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("div",{className:"flex items-center gap-0.5",children:t&&b.length>0&&b.slice(-5).map((T,_)=>h.jsx("div",{className:"h-1 rounded-full",title:`${T.tool||"thinking"} — ${em(T.duration)}`,style:{width:Math.max(6,Math.min(20,(T.duration||0)/1e3*2)),background:"hsl(var(--muted-foreground))",opacity:.25+_/5*.5}},_))}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[m&&h.jsx("button",{onClick:f,title:"Interrupt",className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))",border:"1px solid hsl(var(--destructive) / 0.3)",cursor:"pointer"},children:"stop"}),h.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:x,animation:m?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider",style:{color:m?"#fbbf24":"hsl(var(--muted-foreground))"},children:y}),m&&i.tool&&h.jsx("span",{className:"text-[10px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:i.tool}),m&&l!=null&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:em(l)})]})]}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 py-2",style:{scrollBehavior:"smooth"},children:[r.length===0&&h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 opacity-40",children:[h.jsx("span",{className:"text-2xl",children:"⬡"}),h.jsx("span",{className:"text-xs uppercase tracking-widest",style:{color:"hsl(var(--muted-foreground))"},children:t?"ready":"connecting…"})]}),G_(r).map((T,_)=>h.jsx(z_,{msg:T},T.uuid||_)),h.jsx("div",{ref:u})]}),!t&&h.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none",style:{background:"hsl(var(--background) / 0.7)",backdropFilter:"blur(2px)"},children:h.jsxs("div",{className:"flex flex-col items-center gap-3",children:[h.jsx("div",{className:"w-5 h-5 rounded-full animate-spin",style:{border:"2px solid hsl(var(--accent) / 0.2)",borderTopColor:"hsl(var(--accent))"}}),h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:"connecting to agent server…"})]})}),h.jsx(W_,{onSend:p,disabled:m||!t,placeholder:m?"Working…":"Message Claude…"})]})}function J_(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const tE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rE={};function rm(t,e){return(rE.jsx?eE:tE).test(t)}const nE=/[ \t\n\f\r]/g;function iE(t){return typeof t=="object"?t.type==="text"?nm(t.value):!1:nm(t)}function nm(t){return t.replace(nE,"")===""}class ca{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}}ca.prototype.normal={};ca.prototype.property={};ca.prototype.space=void 0;function uy(t,e){const r={},n={};for(const i of t)Object.assign(r,i.property),Object.assign(n,i.normal);return new ca(r,n,e)}function Lu(t){return t.toLowerCase()}class yr{constructor(e,r){this.attribute=r,this.property=e}}yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let sE=0;const Ht=_i(),je=_i(),Bu=_i(),ot=_i(),he=_i(),as=_i(),Sr=_i();function _i(){return 2**++sE}const Au=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ht,booleanish:je,commaOrSpaceSeparated:Sr,commaSeparated:as,number:ot,overloadedBoolean:Bu,spaceSeparated:he},Symbol.toStringTag,{value:"Module"})),xh=Object.keys(Au);class rf extends yr{constructor(e,r,n,i){let s=-1;if(super(e,r),im(this,"space",i),typeof n=="number")for(;++s<xh.length;){const o=xh[s];im(this,xh[s],(n&Au[o])===Au[o])}}}rf.prototype.defined=!0;function im(t,e,r){r&&(t[e]=r)}function zs(t){const e={},r={};for(const[n,i]of Object.entries(t.properties)){const s=new rf(n,t.transform(t.attributes||{},n),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),e[n]=s,r[Lu(n)]=n,r[Lu(s.attribute)]=n}return new ca(e,r,t.space)}const dy=zs({properties:{ariaActiveDescendant:null,ariaAtomic:je,ariaAutoComplete:null,ariaBusy:je,ariaChecked:je,ariaColCount:ot,ariaColIndex:ot,ariaColSpan:ot,ariaControls:he,ariaCurrent:null,ariaDescribedBy:he,ariaDetails:null,ariaDisabled:je,ariaDropEffect:he,ariaErrorMessage:null,ariaExpanded:je,ariaFlowTo:he,ariaGrabbed:je,ariaHasPopup:null,ariaHidden:je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:he,ariaLevel:ot,ariaLive:null,ariaModal:je,ariaMultiLine:je,ariaMultiSelectable:je,ariaOrientation:null,ariaOwns:he,ariaPlaceholder:null,ariaPosInSet:ot,ariaPressed:je,ariaReadOnly:je,ariaRelevant:null,ariaRequired:je,ariaRoleDescription:he,ariaRowCount:ot,ariaRowIndex:ot,ariaRowSpan:ot,ariaSelected:je,ariaSetSize:ot,ariaSort:null,ariaValueMax:ot,ariaValueMin:ot,ariaValueNow:ot,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function fy(t,e){return e in t?t[e]:e}function py(t,e){return fy(t,e.toLowerCase())}const oE=zs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:as,acceptCharset:he,accessKey:he,action:null,allow:null,allowFullScreen:Ht,allowPaymentRequest:Ht,allowUserMedia:Ht,alt:null,as:null,async:Ht,autoCapitalize:null,autoComplete:he,autoFocus:Ht,autoPlay:Ht,blocking:he,capture:null,charSet:null,checked:Ht,cite:null,className:he,cols:ot,colSpan:null,content:null,contentEditable:je,controls:Ht,controlsList:he,coords:ot|as,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ht,defer:Ht,dir:null,dirName:null,disabled:Ht,download:Bu,draggable:je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ht,formTarget:null,headers:he,height:ot,hidden:Bu,high:ot,href:null,hrefLang:null,htmlFor:he,httpEquiv:he,id:null,imageSizes:null,imageSrcSet:null,inert:Ht,inputMode:null,integrity:null,is:null,isMap:Ht,itemId:null,itemProp:he,itemRef:he,itemScope:Ht,itemType:he,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ht,low:ot,manifest:null,max:null,maxLength:ot,media:null,method:null,min:null,minLength:ot,multiple:Ht,muted:Ht,name:null,nonce:null,noModule:Ht,noValidate:Ht,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:Ht,optimum:ot,pattern:null,ping:he,placeholder:null,playsInline:Ht,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ht,referrerPolicy:null,rel:he,required:Ht,reversed:Ht,rows:ot,rowSpan:ot,sandbox:he,scope:null,scoped:Ht,seamless:Ht,selected:Ht,shadowRootClonable:Ht,shadowRootDelegatesFocus:Ht,shadowRootMode:null,shape:null,size:ot,sizes:null,slot:null,span:ot,spellCheck:je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ot,step:null,style:null,tabIndex:ot,target:null,title:null,translate:null,type:null,typeMustMatch:Ht,useMap:null,value:je,width:ot,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:he,axis:null,background:null,bgColor:null,border:ot,borderColor:null,bottomMargin:ot,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ht,declare:Ht,event:null,face:null,frame:null,frameBorder:null,hSpace:ot,leftMargin:ot,link:null,longDesc:null,lowSrc:null,marginHeight:ot,marginWidth:ot,noResize:Ht,noHref:Ht,noShade:Ht,noWrap:Ht,object:null,profile:null,prompt:null,rev:null,rightMargin:ot,rules:null,scheme:null,scrolling:je,standby:null,summary:null,text:null,topMargin:ot,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ot,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ht,disableRemotePlayback:Ht,prefix:null,property:null,results:ot,security:null,unselectable:null},space:"html",transform:py}),aE=zs({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:Sr,accentHeight:ot,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ot,amplitude:ot,arabicForm:null,ascent:ot,attributeName:null,attributeType:null,azimuth:ot,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ot,by:null,calcMode:null,capHeight:ot,className:he,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:ot,diffuseConstant:ot,direction:null,display:null,dur:null,divisor:ot,dominantBaseline:null,download:Ht,dx:null,dy:null,edgeMode:null,editable:null,elevation:ot,enableBackground:null,end:null,event:null,exponent:ot,externalResourcesRequired:null,fill:null,fillOpacity:ot,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:as,g2:as,glyphName:as,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ot,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ot,horizOriginX:ot,horizOriginY:ot,id:null,ideographic:ot,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ot,k:ot,k1:ot,k2:ot,k3:ot,k4:ot,kernelMatrix:Sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ot,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:ot,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:ot,overlineThickness:ot,paintOrder:null,panose1:null,path:null,pathLength:ot,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:he,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ot,pointsAtY:ot,pointsAtZ:ot,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Sr,rev:Sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Sr,requiredFeatures:Sr,requiredFonts:Sr,requiredFormats:Sr,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:ot,specularExponent:ot,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ot,strikethroughThickness:ot,string:null,stroke:null,strokeDashArray:Sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ot,strokeOpacity:ot,strokeWidth:null,style:null,surfaceScale:ot,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Sr,tabIndex:ot,tableValues:null,target:null,targetX:ot,targetY:ot,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ot,underlineThickness:ot,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ot,values:null,vAlphabetic:ot,vMathematical:ot,vectorEffect:null,vHanging:ot,vIdeographic:ot,version:null,vertAdvY:ot,vertOriginX:ot,vertOriginY:ot,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ot,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fy}),my=zs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),gy=zs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:py}),xy=zs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),lE={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"},cE=/[A-Z]/g,sm=/-[a-z]/g,hE=/^data[-\w.:]+$/i;function uE(t,e){const r=Lu(e);let n=e,i=yr;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&hE.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(sm,fE);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!sm.test(s)){let o=s.replace(cE,dE);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=rf}return new i(n,e)}function dE(t){return"-"+t.toLowerCase()}function fE(t){return t.charAt(1).toUpperCase()}const pE=uy([dy,oE,my,gy,xy],"html"),nf=uy([dy,aE,my,gy,xy],"svg");function mE(t){return t.join(" ").trim()}var Pi={},yh,om;function gE(){if(om)return yh;om=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,r=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
6
6
  `,c="/",u="*",d="",p="comment",f="declaration";function m(g,y){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];y=y||{};var b=1,k=1;function T(O){var I=O.match(e);I&&(b+=I.length);var A=O.lastIndexOf(l);k=~A?O.length-A:k+O.length}function _(){var O={line:b,column:k};return function(I){return I.position=new w(O),P(),I}}function w(O){this.start=O,this.end={line:b,column:k},this.source=y.source}w.prototype.content=g;function E(O){var I=new Error(y.source+":"+b+":"+k+": "+O);if(I.reason=O,I.filename=y.source,I.line=b,I.column=k,I.source=g,!y.silent)throw I}function B(O){var I=O.exec(g);if(I){var A=I[0];return T(A),g=g.slice(A.length),I}}function P(){B(r)}function N(O){var I;for(O=O||[];I=M();)I!==!1&&O.push(I);return O}function M(){var O=_();if(!(c!=g.charAt(0)||u!=g.charAt(1))){for(var I=2;d!=g.charAt(I)&&(u!=g.charAt(I)||c!=g.charAt(I+1));)++I;if(I+=2,d===g.charAt(I-1))return E("End of comment missing");var A=g.slice(2,I-2);return k+=2,T(A),g=g.slice(I),k+=2,O({type:p,comment:A})}}function $(){var O=_(),I=B(n);if(I){if(M(),!B(i))return E("property missing ':'");var A=B(s),D=O({type:f,property:x(I[0].replace(t,d)),value:A?x(A[0].replace(t,d)):d});return B(o),D}}function q(){var O=[];N(O);for(var I;I=$();)I!==!1&&(O.push(I),N(O));return O}return P(),q()}function x(g){return g?g.replace(a,d):d}return yh=m,yh}var am;function xE(){if(am)return Pi;am=1;var t=Pi&&Pi.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Pi,"__esModule",{value:!0}),Pi.default=r;const e=t(gE());function r(n,i){let s=null;if(!n||typeof n!="string")return s;const o=(0,e.default)(n),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;a?i(c,u,l):u&&(s=s||{},s[c]=u)}),s}return Pi}var no={},lm;function yE(){if(lm)return no;lm=1,Object.defineProperty(no,"__esModule",{value:!0}),no.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,r=/^[^-]+$/,n=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||r.test(c)||t.test(c)},o=function(c,u){return u.toUpperCase()},a=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,a):c=c.replace(n,a),c.replace(e,o))};return no.camelCase=l,no}var io,cm;function bE(){if(cm)return io;cm=1;var t=io&&io.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=t(xE()),r=yE();function n(i,s){var o={};return!i||typeof i!="string"||(0,e.default)(i,function(a,l){a&&l&&(o[(0,r.camelCase)(a,s)]=l)}),o}return n.default=n,io=n,io}var CE=bE();const kE=Tc(CE),yy=by("end"),sf=by("start");function by(t){return e;function e(r){const n=r&&r.position&&r.position[t]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function vE(t){const e=sf(t),r=yy(t);if(e&&r)return{start:e,end:r}}function Io(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?hm(t.position):"start"in t||"end"in t?hm(t):"line"in t||"column"in t?Mu(t):""}function Mu(t){return um(t&&t.line)+":"+um(t&&t.column)}function hm(t){return Mu(t&&t.start)+"-"+Mu(t&&t.end)}function um(t){return t&&typeof t=="number"?t:1}class Ke extends Error{constructor(e,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let i="",s={},o=!1;if(r&&("line"in r&&"column"in r?s={place:r}:"start"in r&&"end"in r?s={place:r}:"type"in r?s={ancestors:[r],place:r.position}:s={...r}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof n=="string"){const l=n.indexOf(":");l===-1?s.ruleId=n:(s.source=n.slice(0,l),s.ruleId=n.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Io(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ke.prototype.file="";Ke.prototype.name="";Ke.prototype.reason="";Ke.prototype.message="";Ke.prototype.stack="";Ke.prototype.column=void 0;Ke.prototype.line=void 0;Ke.prototype.ancestors=void 0;Ke.prototype.cause=void 0;Ke.prototype.fatal=void 0;Ke.prototype.place=void 0;Ke.prototype.ruleId=void 0;Ke.prototype.source=void 0;const of={}.hasOwnProperty,wE=new Map,SE=/[A-Z]/g,TE=new Set(["table","tbody","thead","tfoot","tr"]),_E=new Set(["td","th"]),Cy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function EE(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=e.filePath||void 0;let n;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=FE(r,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=IE(r,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:n,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?nf:pE,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=ky(i,t,void 0);return s&&typeof s!="string"?s:i.create(t,i.Fragment,{children:s||void 0},void 0)}function ky(t,e,r){if(e.type==="element")return NE(t,e,r);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return jE(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return BE(t,e,r);if(e.type==="mdxjsEsm")return LE(t,e);if(e.type==="root")return AE(t,e,r);if(e.type==="text")return ME(t,e)}function NE(t,e,r){const n=t.schema;let i=n;e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=nf,t.schema=i),t.ancestors.push(e);const s=wy(t,e.tagName,!1),o=PE(t,e);let a=lf(t,e);return TE.has(e.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!iE(l):!0})),vy(t,o,s,e),af(o,a),t.ancestors.pop(),t.schema=n,t.create(e,s,o,r)}function jE(t,e){if(e.data&&e.data.estree&&t.evaluater){const n=e.data.estree.body[0];return n.type,t.evaluater.evaluateExpression(n.expression)}Vo(t,e.position)}function LE(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);Vo(t,e.position)}function BE(t,e,r){const n=t.schema;let i=n;e.name==="svg"&&n.space==="html"&&(i=nf,t.schema=i),t.ancestors.push(e);const s=e.name===null?t.Fragment:wy(t,e.name,!0),o=DE(t,e),a=lf(t,e);return vy(t,o,s,e),af(o,a),t.ancestors.pop(),t.schema=n,t.create(e,s,o,r)}function AE(t,e,r){const n={};return af(n,lf(t,e)),t.create(e,t.Fragment,n,r)}function ME(t,e){return e.value}function vy(t,e,r,n){typeof r!="string"&&r!==t.Fragment&&t.passNode&&(e.node=n)}function af(t,e){if(e.length>0){const r=e.length>1?e:e[0];r&&(t.children=r)}}function IE(t,e,r){return n;function n(i,s,o,a){const c=Array.isArray(o.children)?r:e;return a?c(s,o,a):c(s,o)}}function FE(t,e){return r;function r(n,i,s,o){const a=Array.isArray(s.children),l=sf(n);return e(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:t,lineNumber:l?l.line:void 0},void 0)}}function PE(t,e){const r={};let n,i;for(i in e.properties)if(i!=="children"&&of.call(e.properties,i)){const s=OE(t,i,e.properties[i]);if(s){const[o,a]=s;t.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&_E.has(e.tagName)?n=a:r[o]=a}}if(n){const s=r.style||(r.style={});s[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function DE(t,e){const r={};for(const n of e.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&t.evaluater){const s=n.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(r,t.evaluater.evaluateExpression(a.argument))}else Vo(t,e.position);else{const i=n.name;let s;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&t.evaluater){const a=n.value.data.estree.body[0];a.type,s=t.evaluater.evaluateExpression(a.expression)}else Vo(t,e.position);else s=n.value===null?!0:n.value;r[i]=s}return r}function lf(t,e){const r=[];let n=-1;const i=t.passKeys?new Map:wE;for(;++n<e.children.length;){const s=e.children[n];let o;if(t.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=ky(t,s,o);a!==void 0&&r.push(a)}return r}function OE(t,e,r){const n=uE(t.schema,e);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?J_(r):mE(r)),n.property==="style"){let i=typeof r=="object"?r:RE(t,String(r));return t.stylePropertyNameCase==="css"&&(i=$E(i)),["style",i]}return[t.elementAttributeNameCase==="react"&&n.space?lE[n.property]||n.property:n.attribute,r]}}function RE(t,e){try{return kE(e,{reactCompat:!0})}catch(r){if(t.ignoreInvalidStyle)return{};const n=r,i=new Ke("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=t.filePath||void 0,i.url=Cy+"#cannot-parse-style-attribute",i}}function wy(t,e,r){let n;if(!r)n={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let s=-1,o;for(;++s<i.length;){const a=rm(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}n=o}else n=rm(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(n.type==="Literal"){const i=n.value;return of.call(t.components,i)?t.components[i]:i}if(t.evaluater)return t.evaluater.evaluateExpression(n);Vo(t)}function Vo(t,e){const r=new Ke("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=t.filePath||void 0,r.url=Cy+"#cannot-handle-mdx-estrees-without-createevaluater",r}function $E(t){const e={};let r;for(r in t)of.call(t,r)&&(e[zE(r)]=t[r]);return e}function zE(t){let e=t.replace(SE,WE);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function WE(t){return"-"+t.toLowerCase()}const bh={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"]},qE={};function cf(t,e){const r=qE,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Sy(t,n,i)}function Sy(t,e,r){if(HE(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return dm(t.children,e,r)}return Array.isArray(t)?dm(t,e,r):""}function dm(t,e,r){const n=[];let i=-1;for(;++i<t.length;)n[i]=Sy(t[i],e,r);return n.join("")}function HE(t){return!!(t&&typeof t=="object")}const fm=document.createElement("i");function hf(t){const e="&"+t+";";fm.innerHTML=e;const r=fm.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function Tr(t,e,r,n){const i=t.length;let s=0,o;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,r=r>0?r:0,n.length<1e4)o=Array.from(n),o.unshift(e,r),t.splice(...o);else for(r&&t.splice(e,r);s<n.length;)o=n.slice(s,s+1e4),o.unshift(e,0),t.splice(...o),s+=1e4,e+=1e4}function Lr(t,e){return t.length>0?(Tr(t,t.length,0,e),t):e}const pm={}.hasOwnProperty;function Ty(t){const e={};let r=-1;for(;++r<t.length;)UE(e,t[r]);return e}function UE(t,e){let r;for(r in e){const i=(pm.call(t,r)?t[r]:void 0)||(t[r]={}),s=e[r];let o;if(s)for(o in s){pm.call(i,o)||(i[o]=[]);const a=s[o];GE(i[o],Array.isArray(a)?a:a?[a]:[])}}}function GE(t,e){let r=-1;const n=[];for(;++r<e.length;)(e[r].add==="after"?t:n).push(e[r]);Tr(t,0,0,n)}function _y(t,e){const r=Number.parseInt(t,e);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Ur(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const tr=Kn(/[A-Za-z]/),Ye=Kn(/[\dA-Za-z]/),VE=Kn(/[#-'*+\--9=?A-Z^-~]/);function Bl(t){return t!==null&&(t<32||t===127)}const Iu=Kn(/\d/),YE=Kn(/[\dA-Fa-f]/),XE=Kn(/[!-/:-@[-`{-~]/);function Lt(t){return t!==null&&t<-2}function le(t){return t!==null&&(t<0||t===32)}function Xt(t){return t===-2||t===-1||t===32}const _c=Kn(new RegExp("\\p{P}|\\p{S}","u")),gi=Kn(/\s/);function Kn(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Ws(t){const e=[];let r=-1,n=0,i=0;for(;++r<t.length;){const s=t.charCodeAt(r);let o="";if(s===37&&Ye(t.charCodeAt(r+1))&&Ye(t.charCodeAt(r+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=t.charCodeAt(r+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(e.push(t.slice(n,r),encodeURIComponent(o)),n=r+i+1,o=""),i&&(r+=i,i=0)}return e.join("")+t.slice(n)}function Jt(t,e,r,n){const i=n?n-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Xt(l)?(t.enter(r),a(l)):e(l)}function a(l){return Xt(l)&&s++<i?(t.consume(l),a):(t.exit(r),e(l))}}const KE={tokenize:ZE};function ZE(t){const e=t.attempt(this.parser.constructs.contentInitial,n,i);let r;return e;function n(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Jt(t,e,"linePrefix")}function i(a){return t.enter("paragraph"),s(a)}function s(a){const l=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return Lt(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}const QE={tokenize:JE},mm={tokenize:tN};function JE(t){const e=this,r=[];let n=0,i,s,o;return a;function a(k){if(n<r.length){const T=r[n];return e.containerState=T[1],t.attempt(T[0].continuation,l,c)(k)}return c(k)}function l(k){if(n++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&b();const T=e.events.length;let _=T,w;for(;_--;)if(e.events[_][0]==="exit"&&e.events[_][1].type==="chunkFlow"){w=e.events[_][1].end;break}y(n);let E=T;for(;E<e.events.length;)e.events[E][1].end={...w},E++;return Tr(e.events,_+1,0,e.events.slice(T)),e.events.length=E,c(k)}return a(k)}function c(k){if(n===r.length){if(!i)return p(k);if(i.currentConstruct&&i.currentConstruct.concrete)return m(k);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(mm,u,d)(k)}function u(k){return i&&b(),y(n),p(k)}function d(k){return e.parser.lazy[e.now().line]=n!==r.length,o=e.now().offset,m(k)}function p(k){return e.containerState={},t.attempt(mm,f,m)(k)}function f(k){return n++,r.push([e.currentConstruct,e.containerState]),p(k)}function m(k){if(k===null){i&&b(),y(0),t.consume(k);return}return i=i||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(k)}function x(k){if(k===null){g(t.exit("chunkFlow"),!0),y(0),t.consume(k);return}return Lt(k)?(t.consume(k),g(t.exit("chunkFlow")),n=0,e.interrupt=void 0,a):(t.consume(k),x)}function g(k,T){const _=e.sliceStream(k);if(T&&_.push(null),k.previous=s,s&&(s.next=k),s=k,i.defineSkip(k.start),i.write(_),e.parser.lazy[k.start.line]){let w=i.events.length;for(;w--;)if(i.events[w][1].start.offset<o&&(!i.events[w][1].end||i.events[w][1].end.offset>o))return;const E=e.events.length;let B=E,P,N;for(;B--;)if(e.events[B][0]==="exit"&&e.events[B][1].type==="chunkFlow"){if(P){N=e.events[B][1].end;break}P=!0}for(y(n),w=E;w<e.events.length;)e.events[w][1].end={...N},w++;Tr(e.events,B+1,0,e.events.slice(E)),e.events.length=w}}function y(k){let T=r.length;for(;T-- >k;){const _=r[T];e.containerState=_[1],_[0].exit.call(e,t)}r.length=k}function b(){i.write([null]),s=void 0,i=void 0,e.containerState._closeFlow=void 0}}function tN(t,e,r){return Jt(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ns(t){if(t===null||le(t)||gi(t))return 1;if(_c(t))return 2}function Ec(t,e,r){const n=[];let i=-1;for(;++i<t.length;){const s=t[i].resolveAll;s&&!n.includes(s)&&(e=s(e,r),n.push(s))}return e}const Fu={name:"attention",resolveAll:eN,tokenize:rN};function eN(t,e){let r=-1,n,i,s,o,a,l,c,u;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(n=r;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[n][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;l=t[n][1].end.offset-t[n][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;const d={...t[n][1].end},p={...t[r][1].start};gm(d,-l),gm(p,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...t[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[r][1].start},end:p},s={type:l>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[r][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[n][1].end={...o.start},t[r][1].start={...a.end},c=[],t[n][1].end.offset-t[n][1].start.offset&&(c=Lr(c,[["enter",t[n][1],e],["exit",t[n][1],e]])),c=Lr(c,[["enter",i,e],["enter",o,e],["exit",o,e],["enter",s,e]]),c=Lr(c,Ec(e.parser.constructs.insideSpan.null,t.slice(n+1,r),e)),c=Lr(c,[["exit",s,e],["enter",a,e],["exit",a,e],["exit",i,e]]),t[r][1].end.offset-t[r][1].start.offset?(u=2,c=Lr(c,[["enter",t[r][1],e],["exit",t[r][1],e]])):u=0,Tr(t,n-1,r-n+3,c),r=n+c.length-u-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function rN(t,e){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,i=Ns(n);let s;return o;function o(l){return s=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===s)return t.consume(l),a;const c=t.exit("attentionSequence"),u=Ns(l),d=!u||u===2&&i||r.includes(l),p=!i||i===2&&u||r.includes(n);return c._open=!!(s===42?d:d&&(i||!p)),c._close=!!(s===42?p:p&&(u||!d)),e(l)}}function gm(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const nN={name:"autolink",tokenize:iN};function iN(t,e,r){let n=0;return i;function i(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(f){return tr(f)?(t.consume(f),o):f===64?r(f):c(f)}function o(f){return f===43||f===45||f===46||Ye(f)?(n=1,a(f)):c(f)}function a(f){return f===58?(t.consume(f),n=0,l):(f===43||f===45||f===46||Ye(f))&&n++<32?(t.consume(f),a):(n=0,c(f))}function l(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||Bl(f)?r(f):(t.consume(f),l)}function c(f){return f===64?(t.consume(f),u):VE(f)?(t.consume(f),c):r(f)}function u(f){return Ye(f)?d(f):r(f)}function d(f){return f===46?(t.consume(f),n=0,u):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):p(f)}function p(f){if((f===45||Ye(f))&&n++<63){const m=f===45?p:d;return t.consume(f),m}return r(f)}}const ha={partial:!0,tokenize:sN};function sN(t,e,r){return n;function n(s){return Xt(s)?Jt(t,i,"linePrefix")(s):i(s)}function i(s){return s===null||Lt(s)?e(s):r(s)}}const Ey={continuation:{tokenize:aN},exit:lN,name:"blockQuote",tokenize:oN};function oN(t,e,r){const n=this;return i;function i(o){if(o===62){const a=n.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),s}return r(o)}function s(o){return Xt(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function aN(t,e,r){const n=this;return i;function i(o){return Xt(o)?Jt(t,s,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return t.attempt(Ey,e,r)(o)}}function lN(t){t.exit("blockQuote")}const Ny={name:"characterEscape",tokenize:cN};function cN(t,e,r){return n;function n(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),i}function i(s){return XE(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(s)}}const jy={name:"characterReference",tokenize:hN};function hN(t,e,r){const n=this;let i=0,s,o;return a;function a(d){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),l}function l(d){return d===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(d),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),s=31,o=Ye,u(d))}function c(d){return d===88||d===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(d),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,o=YE,u):(t.enter("characterReferenceValue"),s=7,o=Iu,u(d))}function u(d){if(d===59&&i){const p=t.exit("characterReferenceValue");return o===Ye&&!hf(n.sliceSerialize(p))?r(d):(t.enter("characterReferenceMarker"),t.consume(d),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(d)&&i++<s?(t.consume(d),u):r(d)}}const xm={partial:!0,tokenize:dN},ym={concrete:!0,name:"codeFenced",tokenize:uN};function uN(t,e,r){const n=this,i={partial:!0,tokenize:_};let s=0,o=0,a;return l;function l(w){return c(w)}function c(w){const E=n.events[n.events.length-1];return s=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,a=w,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),u(w)}function u(w){return w===a?(o++,t.consume(w),u):o<3?r(w):(t.exit("codeFencedFenceSequence"),Xt(w)?Jt(t,d,"whitespace")(w):d(w))}function d(w){return w===null||Lt(w)?(t.exit("codeFencedFence"),n.interrupt?e(w):t.check(xm,x,T)(w)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),p(w))}function p(w){return w===null||Lt(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(w)):Xt(w)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Jt(t,f,"whitespace")(w)):w===96&&w===a?r(w):(t.consume(w),p)}function f(w){return w===null||Lt(w)?d(w):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(w))}function m(w){return w===null||Lt(w)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(w)):w===96&&w===a?r(w):(t.consume(w),m)}function x(w){return t.attempt(i,T,g)(w)}function g(w){return t.enter("lineEnding"),t.consume(w),t.exit("lineEnding"),y}function y(w){return s>0&&Xt(w)?Jt(t,b,"linePrefix",s+1)(w):b(w)}function b(w){return w===null||Lt(w)?t.check(xm,x,T)(w):(t.enter("codeFlowValue"),k(w))}function k(w){return w===null||Lt(w)?(t.exit("codeFlowValue"),b(w)):(t.consume(w),k)}function T(w){return t.exit("codeFenced"),e(w)}function _(w,E,B){let P=0;return N;function N(I){return w.enter("lineEnding"),w.consume(I),w.exit("lineEnding"),M}function M(I){return w.enter("codeFencedFence"),Xt(I)?Jt(w,$,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):$(I)}function $(I){return I===a?(w.enter("codeFencedFenceSequence"),q(I)):B(I)}function q(I){return I===a?(P++,w.consume(I),q):P>=o?(w.exit("codeFencedFenceSequence"),Xt(I)?Jt(w,O,"whitespace")(I):O(I)):B(I)}function O(I){return I===null||Lt(I)?(w.exit("codeFencedFence"),E(I)):B(I)}}}function dN(t,e,r){const n=this;return i;function i(o){return o===null?r(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return n.parser.lazy[n.now().line]?r(o):e(o)}}const Ch={name:"codeIndented",tokenize:pN},fN={partial:!0,tokenize:mN};function pN(t,e,r){const n=this;return i;function i(c){return t.enter("codeIndented"),Jt(t,s,"linePrefix",5)(c)}function s(c){const u=n.events[n.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):r(c)}function o(c){return c===null?l(c):Lt(c)?t.attempt(fN,o,l)(c):(t.enter("codeFlowValue"),a(c))}function a(c){return c===null||Lt(c)?(t.exit("codeFlowValue"),o(c)):(t.consume(c),a)}function l(c){return t.exit("codeIndented"),e(c)}}function mN(t,e,r){const n=this;return i;function i(o){return n.parser.lazy[n.now().line]?r(o):Lt(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),i):Jt(t,s,"linePrefix",5)(o)}function s(o){const a=n.events[n.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):Lt(o)?i(o):r(o)}}const gN={name:"codeText",previous:yN,resolve:xN,tokenize:bN};function xN(t){let e=t.length-4,r=3,n,i;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(n=r;++n<e;)if(t[n][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[e][1].type="codeTextPadding",r+=2,e-=2;break}}for(n=r-1,e++;++n<=e;)i===void 0?n!==e&&t[n][1].type!=="lineEnding"&&(i=n):(n===e||t[n][1].type==="lineEnding")&&(t[i][1].type="codeTextData",n!==i+2&&(t[i][1].end=t[n-1][1].end,t.splice(i+2,n-i-2),e-=n-i-2,n=i+2),i=void 0);return t}function yN(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function bN(t,e,r){let n=0,i,s;return o;function o(d){return t.enter("codeText"),t.enter("codeTextSequence"),a(d)}function a(d){return d===96?(t.consume(d),n++,a):(t.exit("codeTextSequence"),l(d))}function l(d){return d===null?r(d):d===32?(t.enter("space"),t.consume(d),t.exit("space"),l):d===96?(s=t.enter("codeTextSequence"),i=0,u(d)):Lt(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),l):(t.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||Lt(d)?(t.exit("codeTextData"),l(d)):(t.consume(d),c)}function u(d){return d===96?(t.consume(d),i++,u):i===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(d)):(s.type="codeTextData",c(d))}}class CN{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,r){const n=r??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,r,n){const i=r||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&so(this.left,n),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),so(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),so(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const r=this.left.splice(e,Number.POSITIVE_INFINITY);so(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);so(this.left,r.reverse())}}}function so(t,e){let r=0;if(e.length<1e4)t.push(...e);else for(;r<e.length;)t.push(...e.slice(r,r+1e4)),r+=1e4}function Ly(t){const e={};let r=-1,n,i,s,o,a,l,c;const u=new CN(t);for(;++r<u.length;){for(;r in e;)r=e[r];if(n=u.get(r),r&&n[1].type==="chunkFlow"&&u.get(r-1)[1].type==="listItemPrefix"&&(l=n[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,kN(u,r)),r=e[r],c=!0);else if(n[1]._container){for(s=r,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(n[1].end={...u.get(i)[1].start},a=u.slice(i,r),a.unshift(n),u.splice(i,r-i+1,a))}}return Tr(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function kN(t,e){const r=t.get(e)[1],n=t.get(e)[2];let i=e-1;const s=[];let o=r._tokenizer;o||(o=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,p=-1,f=r,m=0,x=0;const g=[x];for(;f;){for(;t.get(++i)[1]!==f;);s.push(i),f._tokenizer||(u=n.sliceStream(f),f.next||u.push(null),d&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=f,f=f.next}for(f=r;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(x=p+1,g.push(x),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),p=g.length;p--;){const y=a.slice(g[p],g[p+1]),b=s.pop();l.push([b,b+y.length-1]),t.splice(b,2,y)}for(l.reverse(),p=-1;++p<l.length;)c[m+l[p][0]]=m+l[p][1],m+=l[p][1]-l[p][0]-1;return c}const vN={resolve:SN,tokenize:TN},wN={partial:!0,tokenize:_N};function SN(t){return Ly(t),t}function TN(t,e){let r;return n;function n(a){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Lt(a)?t.check(wN,o,s)(a):(t.consume(a),i)}function s(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function _N(t,e,r){const n=this;return i;function i(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),Jt(t,s,"linePrefix")}function s(o){if(o===null||Lt(o))return r(o);const a=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(n.parser.constructs.flow,r,e)(o)}}function By(t,e,r,n,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(y){return y===60?(t.enter(n),t.enter(i),t.enter(s),t.consume(y),t.exit(s),p):y===null||y===32||y===41||Bl(y)?r(y):(t.enter(n),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),x(y))}function p(y){return y===62?(t.enter(s),t.consume(y),t.exit(s),t.exit(i),t.exit(n),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),f(y))}function f(y){return y===62?(t.exit("chunkString"),t.exit(a),p(y)):y===null||y===60||Lt(y)?r(y):(t.consume(y),y===92?m:f)}function m(y){return y===60||y===62||y===92?(t.consume(y),f):f(y)}function x(y){return!u&&(y===null||y===41||le(y))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(n),e(y)):u<c&&y===40?(t.consume(y),u++,x):y===41?(t.consume(y),u--,x):y===null||y===32||y===40||Bl(y)?r(y):(t.consume(y),y===92?g:x)}function g(y){return y===40||y===41||y===92?(t.consume(y),x):x(y)}}function Ay(t,e,r,n,i,s){const o=this;let a=0,l;return c;function c(f){return t.enter(n),t.enter(i),t.consume(f),t.exit(i),t.enter(s),u}function u(f){return a>999||f===null||f===91||f===93&&!l||f===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?r(f):f===93?(t.exit(s),t.enter(i),t.consume(f),t.exit(i),t.exit(n),e):Lt(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),u):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===null||f===91||f===93||Lt(f)||a++>999?(t.exit("chunkString"),u(f)):(t.consume(f),l||(l=!Xt(f)),f===92?p:d)}function p(f){return f===91||f===92||f===93?(t.consume(f),a++,d):d(f)}}function My(t,e,r,n,i,s){let o;return a;function a(p){return p===34||p===39||p===40?(t.enter(n),t.enter(i),t.consume(p),t.exit(i),o=p===40?41:p,l):r(p)}function l(p){return p===o?(t.enter(i),t.consume(p),t.exit(i),t.exit(n),e):(t.enter(s),c(p))}function c(p){return p===o?(t.exit(s),l(o)):p===null?r(p):Lt(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),Jt(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===o||p===null||Lt(p)?(t.exit("chunkString"),c(p)):(t.consume(p),p===92?d:u)}function d(p){return p===o||p===92?(t.consume(p),u):u(p)}}function Fo(t,e){let r;return n;function n(i){return Lt(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),r=!0,n):Xt(i)?Jt(t,n,r?"linePrefix":"lineSuffix")(i):e(i)}}const EN={name:"definition",tokenize:jN},NN={partial:!0,tokenize:LN};function jN(t,e,r){const n=this;let i;return s;function s(f){return t.enter("definition"),o(f)}function o(f){return Ay.call(n,t,a,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(f){return i=Ur(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),f===58?(t.enter("definitionMarker"),t.consume(f),t.exit("definitionMarker"),l):r(f)}function l(f){return le(f)?Fo(t,c)(f):c(f)}function c(f){return By(t,u,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return t.attempt(NN,d,d)(f)}function d(f){return Xt(f)?Jt(t,p,"whitespace")(f):p(f)}function p(f){return f===null||Lt(f)?(t.exit("definition"),n.parser.defined.push(i),e(f)):r(f)}}function LN(t,e,r){return n;function n(a){return le(a)?Fo(t,i)(a):r(a)}function i(a){return My(t,s,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Xt(a)?Jt(t,o,"whitespace")(a):o(a)}function o(a){return a===null||Lt(a)?e(a):r(a)}}const BN={name:"hardBreakEscape",tokenize:AN};function AN(t,e,r){return n;function n(s){return t.enter("hardBreakEscape"),t.consume(s),i}function i(s){return Lt(s)?(t.exit("hardBreakEscape"),e(s)):r(s)}}const MN={name:"headingAtx",resolve:IN,tokenize:FN};function IN(t,e){let r=t.length-2,n=3,i,s;return t[n][1].type==="whitespace"&&(n+=2),r-2>n&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&t[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(i={type:"atxHeadingText",start:t[n][1].start,end:t[r][1].end},s={type:"chunkText",start:t[n][1].start,end:t[r][1].end,contentType:"text"},Tr(t,n,r-n+1,[["enter",i,e],["enter",s,e],["exit",s,e],["exit",i,e]])),t}function FN(t,e,r){let n=0;return i;function i(u){return t.enter("atxHeading"),s(u)}function s(u){return t.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&n++<6?(t.consume(u),o):u===null||le(u)?(t.exit("atxHeadingSequence"),a(u)):r(u)}function a(u){return u===35?(t.enter("atxHeadingSequence"),l(u)):u===null||Lt(u)?(t.exit("atxHeading"),e(u)):Xt(u)?Jt(t,a,"whitespace")(u):(t.enter("atxHeadingText"),c(u))}function l(u){return u===35?(t.consume(u),l):(t.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||le(u)?(t.exit("atxHeadingText"),a(u)):(t.consume(u),c)}}const PN=["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"],bm=["pre","script","style","textarea"],DN={concrete:!0,name:"htmlFlow",resolveTo:$N,tokenize:zN},ON={partial:!0,tokenize:qN},RN={partial:!0,tokenize:WN};function $N(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function zN(t,e,r){const n=this;let i,s,o,a,l;return c;function c(F){return u(F)}function u(F){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(F),d}function d(F){return F===33?(t.consume(F),p):F===47?(t.consume(F),s=!0,x):F===63?(t.consume(F),i=3,n.interrupt?e:S):tr(F)?(t.consume(F),o=String.fromCharCode(F),g):r(F)}function p(F){return F===45?(t.consume(F),i=2,f):F===91?(t.consume(F),i=5,a=0,m):tr(F)?(t.consume(F),i=4,n.interrupt?e:S):r(F)}function f(F){return F===45?(t.consume(F),n.interrupt?e:S):r(F)}function m(F){const ht="CDATA[";return F===ht.charCodeAt(a++)?(t.consume(F),a===ht.length?n.interrupt?e:$:m):r(F)}function x(F){return tr(F)?(t.consume(F),o=String.fromCharCode(F),g):r(F)}function g(F){if(F===null||F===47||F===62||le(F)){const ht=F===47,st=o.toLowerCase();return!ht&&!s&&bm.includes(st)?(i=1,n.interrupt?e(F):$(F)):PN.includes(o.toLowerCase())?(i=6,ht?(t.consume(F),y):n.interrupt?e(F):$(F)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(F):s?b(F):k(F))}return F===45||Ye(F)?(t.consume(F),o+=String.fromCharCode(F),g):r(F)}function y(F){return F===62?(t.consume(F),n.interrupt?e:$):r(F)}function b(F){return Xt(F)?(t.consume(F),b):N(F)}function k(F){return F===47?(t.consume(F),N):F===58||F===95||tr(F)?(t.consume(F),T):Xt(F)?(t.consume(F),k):N(F)}function T(F){return F===45||F===46||F===58||F===95||Ye(F)?(t.consume(F),T):_(F)}function _(F){return F===61?(t.consume(F),w):Xt(F)?(t.consume(F),_):k(F)}function w(F){return F===null||F===60||F===61||F===62||F===96?r(F):F===34||F===39?(t.consume(F),l=F,E):Xt(F)?(t.consume(F),w):B(F)}function E(F){return F===l?(t.consume(F),l=null,P):F===null||Lt(F)?r(F):(t.consume(F),E)}function B(F){return F===null||F===34||F===39||F===47||F===60||F===61||F===62||F===96||le(F)?_(F):(t.consume(F),B)}function P(F){return F===47||F===62||Xt(F)?k(F):r(F)}function N(F){return F===62?(t.consume(F),M):r(F)}function M(F){return F===null||Lt(F)?$(F):Xt(F)?(t.consume(F),M):r(F)}function $(F){return F===45&&i===2?(t.consume(F),A):F===60&&i===1?(t.consume(F),D):F===62&&i===4?(t.consume(F),W):F===63&&i===3?(t.consume(F),S):F===93&&i===5?(t.consume(F),j):Lt(F)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(ON,K,q)(F)):F===null||Lt(F)?(t.exit("htmlFlowData"),q(F)):(t.consume(F),$)}function q(F){return t.check(RN,O,K)(F)}function O(F){return t.enter("lineEnding"),t.consume(F),t.exit("lineEnding"),I}function I(F){return F===null||Lt(F)?q(F):(t.enter("htmlFlowData"),$(F))}function A(F){return F===45?(t.consume(F),S):$(F)}function D(F){return F===47?(t.consume(F),o="",R):$(F)}function R(F){if(F===62){const ht=o.toLowerCase();return bm.includes(ht)?(t.consume(F),W):$(F)}return tr(F)&&o.length<8?(t.consume(F),o+=String.fromCharCode(F),R):$(F)}function j(F){return F===93?(t.consume(F),S):$(F)}function S(F){return F===62?(t.consume(F),W):F===45&&i===2?(t.consume(F),S):$(F)}function W(F){return F===null||Lt(F)?(t.exit("htmlFlowData"),K(F)):(t.consume(F),W)}function K(F){return t.exit("htmlFlow"),e(F)}}function WN(t,e,r){const n=this;return i;function i(o){return Lt(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):r(o)}function s(o){return n.parser.lazy[n.now().line]?r(o):e(o)}}function qN(t,e,r){return n;function n(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(ha,e,r)}}const HN={name:"htmlText",tokenize:UN};function UN(t,e,r){const n=this;let i,s,o;return a;function a(S){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(S),l}function l(S){return S===33?(t.consume(S),c):S===47?(t.consume(S),_):S===63?(t.consume(S),k):tr(S)?(t.consume(S),B):r(S)}function c(S){return S===45?(t.consume(S),u):S===91?(t.consume(S),s=0,m):tr(S)?(t.consume(S),b):r(S)}function u(S){return S===45?(t.consume(S),f):r(S)}function d(S){return S===null?r(S):S===45?(t.consume(S),p):Lt(S)?(o=d,D(S)):(t.consume(S),d)}function p(S){return S===45?(t.consume(S),f):d(S)}function f(S){return S===62?A(S):S===45?p(S):d(S)}function m(S){const W="CDATA[";return S===W.charCodeAt(s++)?(t.consume(S),s===W.length?x:m):r(S)}function x(S){return S===null?r(S):S===93?(t.consume(S),g):Lt(S)?(o=x,D(S)):(t.consume(S),x)}function g(S){return S===93?(t.consume(S),y):x(S)}function y(S){return S===62?A(S):S===93?(t.consume(S),y):x(S)}function b(S){return S===null||S===62?A(S):Lt(S)?(o=b,D(S)):(t.consume(S),b)}function k(S){return S===null?r(S):S===63?(t.consume(S),T):Lt(S)?(o=k,D(S)):(t.consume(S),k)}function T(S){return S===62?A(S):k(S)}function _(S){return tr(S)?(t.consume(S),w):r(S)}function w(S){return S===45||Ye(S)?(t.consume(S),w):E(S)}function E(S){return Lt(S)?(o=E,D(S)):Xt(S)?(t.consume(S),E):A(S)}function B(S){return S===45||Ye(S)?(t.consume(S),B):S===47||S===62||le(S)?P(S):r(S)}function P(S){return S===47?(t.consume(S),A):S===58||S===95||tr(S)?(t.consume(S),N):Lt(S)?(o=P,D(S)):Xt(S)?(t.consume(S),P):A(S)}function N(S){return S===45||S===46||S===58||S===95||Ye(S)?(t.consume(S),N):M(S)}function M(S){return S===61?(t.consume(S),$):Lt(S)?(o=M,D(S)):Xt(S)?(t.consume(S),M):P(S)}function $(S){return S===null||S===60||S===61||S===62||S===96?r(S):S===34||S===39?(t.consume(S),i=S,q):Lt(S)?(o=$,D(S)):Xt(S)?(t.consume(S),$):(t.consume(S),O)}function q(S){return S===i?(t.consume(S),i=void 0,I):S===null?r(S):Lt(S)?(o=q,D(S)):(t.consume(S),q)}function O(S){return S===null||S===34||S===39||S===60||S===61||S===96?r(S):S===47||S===62||le(S)?P(S):(t.consume(S),O)}function I(S){return S===47||S===62||le(S)?P(S):r(S)}function A(S){return S===62?(t.consume(S),t.exit("htmlTextData"),t.exit("htmlText"),e):r(S)}function D(S){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),R}function R(S){return Xt(S)?Jt(t,j,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):j(S)}function j(S){return t.enter("htmlTextData"),o(S)}}const uf={name:"labelEnd",resolveAll:XN,resolveTo:KN,tokenize:ZN},GN={tokenize:QN},VN={tokenize:JN},YN={tokenize:tj};function XN(t){let e=-1;const r=[];for(;++e<t.length;){const n=t[e][1];if(r.push(t[e]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",e+=i}}return t.length!==r.length&&Tr(t,0,t.length,r),t}function KN(t,e){let r=t.length,n=0,i,s,o,a;for(;r--;)if(i=t[r][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;t[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(t[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=r,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(o=r);const l={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},c={type:"label",start:{...t[s][1].start},end:{...t[o][1].end}},u={type:"labelText",start:{...t[s+n+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",l,e],["enter",c,e]],a=Lr(a,t.slice(s+1,s+n+3)),a=Lr(a,[["enter",u,e]]),a=Lr(a,Ec(e.parser.constructs.insideSpan.null,t.slice(s+n+4,o-3),e)),a=Lr(a,[["exit",u,e],t[o-2],t[o-1],["exit",c,e]]),a=Lr(a,t.slice(o+1)),a=Lr(a,[["exit",l,e]]),Tr(t,s,t.length,a),t}function ZN(t,e,r){const n=this;let i=n.events.length,s,o;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){s=n.events[i][1];break}return a;function a(p){return s?s._inactive?d(p):(o=n.parser.defined.includes(Ur(n.sliceSerialize({start:s.end,end:n.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelEnd"),l):r(p)}function l(p){return p===40?t.attempt(GN,u,o?u:d)(p):p===91?t.attempt(VN,u,o?c:d)(p):o?u(p):d(p)}function c(p){return t.attempt(YN,u,d)(p)}function u(p){return e(p)}function d(p){return s._balanced=!0,r(p)}}function QN(t,e,r){return n;function n(d){return t.enter("resource"),t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),i}function i(d){return le(d)?Fo(t,s)(d):s(d)}function s(d){return d===41?u(d):By(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return le(d)?Fo(t,l)(d):u(d)}function a(d){return r(d)}function l(d){return d===34||d===39||d===40?My(t,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return le(d)?Fo(t,u)(d):u(d)}function u(d){return d===41?(t.enter("resourceMarker"),t.consume(d),t.exit("resourceMarker"),t.exit("resource"),e):r(d)}}function JN(t,e,r){const n=this;return i;function i(a){return Ay.call(n,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return n.parser.defined.includes(Ur(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(a):r(a)}function o(a){return r(a)}}function tj(t,e,r){return n;function n(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),i}function i(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):r(s)}}const ej={name:"labelStartImage",resolveAll:uf.resolveAll,tokenize:rj};function rj(t,e,r){const n=this;return i;function i(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),s}function s(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):r(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):e(a)}}const nj={name:"labelStartLink",resolveAll:uf.resolveAll,tokenize:ij};function ij(t,e,r){const n=this;return i;function i(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):e(o)}}const kh={name:"lineEnding",tokenize:sj};function sj(t,e){return r;function r(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),Jt(t,e,"linePrefix")}}const ul={name:"thematicBreak",tokenize:oj};function oj(t,e,r){let n=0,i;return s;function s(c){return t.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(t.enter("thematicBreakSequence"),l(c)):n>=3&&(c===null||Lt(c))?(t.exit("thematicBreak"),e(c)):r(c)}function l(c){return c===i?(t.consume(c),n++,l):(t.exit("thematicBreakSequence"),Xt(c)?Jt(t,a,"whitespace")(c):a(c))}}const ur={continuation:{tokenize:hj},exit:dj,name:"list",tokenize:cj},aj={partial:!0,tokenize:fj},lj={partial:!0,tokenize:uj};function cj(t,e,r){const n=this,i=n.events[n.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(f){const m=n.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!n.containerState.marker||f===n.containerState.marker:Iu(f)){if(n.containerState.type||(n.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(ul,r,c)(f):c(f);if(!n.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(f)}return r(f)}function l(f){return Iu(f)&&++o<10?(t.consume(f),l):(!n.interrupt||o<2)&&(n.containerState.marker?f===n.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),c(f)):r(f)}function c(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||f,t.check(ha,n.interrupt?r:u,t.attempt(aj,p,d))}function u(f){return n.containerState.initialBlankLine=!0,s++,p(f)}function d(f){return Xt(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),p):r(f)}function p(f){return n.containerState.size=s+n.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}function hj(t,e,r){const n=this;return n.containerState._closeFlow=void 0,t.check(ha,i,s);function i(a){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Jt(t,e,"listItemIndent",n.containerState.size+1)(a)}function s(a){return n.containerState.furtherBlankLines||!Xt(a)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,o(a)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,t.attempt(lj,e,o)(a))}function o(a){return n.containerState._closeFlow=!0,n.interrupt=void 0,Jt(t,t.attempt(ur,e,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function uj(t,e,r){const n=this;return Jt(t,i,"listItemIndent",n.containerState.size+1);function i(s){const o=n.events[n.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===n.containerState.size?e(s):r(s)}}function dj(t){t.exit(this.containerState.type)}function fj(t,e,r){const n=this;return Jt(t,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=n.events[n.events.length-1];return!Xt(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):r(s)}}const Cm={name:"setextUnderline",resolveTo:pj,tokenize:mj};function pj(t,e){let r=t.length,n,i,s;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){n=r;break}t[r][1].type==="paragraph"&&(i=r)}else t[r][1].type==="content"&&t.splice(r,1),!s&&t[r][1].type==="definition"&&(s=r);const o={type:"setextHeading",start:{...t[n][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",s?(t.splice(i,0,["enter",o,e]),t.splice(s+1,0,["exit",t[n][1],e]),t[n][1].end={...t[s][1].end}):t[n][1]=o,t.push(["exit",o,e]),t}function mj(t,e,r){const n=this;let i;return s;function s(c){let u=n.events.length,d;for(;u--;)if(n.events[u][1].type!=="lineEnding"&&n.events[u][1].type!=="linePrefix"&&n.events[u][1].type!=="content"){d=n.events[u][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||d)?(t.enter("setextHeadingLine"),i=c,o(c)):r(c)}function o(c){return t.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(t.consume(c),a):(t.exit("setextHeadingLineSequence"),Xt(c)?Jt(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Lt(c)?(t.exit("setextHeadingLine"),e(c)):r(c)}}const gj={tokenize:xj};function xj(t){const e=this,r=t.attempt(ha,n,t.attempt(this.parser.constructs.flowInitial,i,Jt(t,t.attempt(this.parser.constructs.flow,i,t.attempt(vN,i)),"linePrefix")));return r;function n(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,r}function i(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,r}}const yj={resolveAll:Fy()},bj=Iy("string"),Cj=Iy("text");function Iy(t){return{resolveAll:Fy(t==="text"?kj:void 0),tokenize:e};function e(r){const n=this,i=this.parser.constructs[t],s=r.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),l}function l(u){return c(u)?(r.exit("data"),s(u)):(r.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let p=-1;if(d)for(;++p<d.length;){const f=d[p];if(!f.previous||f.previous.call(n,n.previous))return!0}return!1}}}function Fy(t){return e;function e(r,n){let i=-1,s;for(;++i<=r.length;)s===void 0?r[i]&&r[i][1].type==="data"&&(s=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==s+2&&(r[s][1].end=r[i-1][1].end,r.splice(s+2,i-s-2),i=s+2),s=void 0);return t?t(r,n):r}}function kj(t,e){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){const n=t[r-1][1],i=e.sliceStream(n);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(e._contentTypeTextTrailing&&r===t.length&&(a=0),a){const c={type:r===t.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:n.start._bufferIndex+o,_index:n.start._index+s,line:n.end.line,column:n.end.column-a,offset:n.end.offset-a},end:{...n.end}};n.end={...c.start},n.start.offset===n.end.offset?Object.assign(n,c):(t.splice(r,0,["enter",c,e],["exit",c,e]),r+=2)}r++}return t}const vj={42:ur,43:ur,45:ur,48:ur,49:ur,50:ur,51:ur,52:ur,53:ur,54:ur,55:ur,56:ur,57:ur,62:Ey},wj={91:EN},Sj={[-2]:Ch,[-1]:Ch,32:Ch},Tj={35:MN,42:ul,45:[Cm,ul],60:DN,61:Cm,95:ul,96:ym,126:ym},_j={38:jy,92:Ny},Ej={[-5]:kh,[-4]:kh,[-3]:kh,33:ej,38:jy,42:Fu,60:[nN,HN],91:nj,92:[BN,Ny],93:uf,95:Fu,96:gN},Nj={null:[Fu,yj]},jj={null:[42,95]},Lj={null:[]},Bj=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jj,contentInitial:wj,disable:Lj,document:vj,flow:Tj,flowInitial:Sj,insideSpan:Nj,string:_j,text:Ej},Symbol.toStringTag,{value:"Module"}));function Aj(t,e,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:E(_),check:E(w),consume:b,enter:k,exit:T,interrupt:E(w,{interrupt:!0})},c={code:null,containerState:{},defineSkip:x,events:[],now:m,parser:t,previous:null,sliceSerialize:p,sliceStream:f,write:d};let u=e.tokenize.call(c,l);return e.resolveAll&&s.push(e),c;function d(M){return o=Lr(o,M),g(),o[o.length-1]!==null?[]:(B(e,0),c.events=Ec(s,c.events,c),c.events)}function p(M,$){return Ij(f(M),$)}function f(M){return Mj(o,M)}function m(){const{_bufferIndex:M,_index:$,line:q,column:O,offset:I}=n;return{_bufferIndex:M,_index:$,line:q,column:O,offset:I}}function x(M){i[M.line]=M.column,N()}function g(){let M;for(;n._index<o.length;){const $=o[n._index];if(typeof $=="string")for(M=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===M&&n._bufferIndex<$.length;)y($.charCodeAt(n._bufferIndex));else y($)}}function y(M){u=u(M)}function b(M){Lt(M)?(n.line++,n.column=1,n.offset+=M===-3?2:1,N()):M!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),c.previous=M}function k(M,$){const q=$||{};return q.type=M,q.start=m(),c.events.push(["enter",q,c]),a.push(q),q}function T(M){const $=a.pop();return $.end=m(),c.events.push(["exit",$,c]),$}function _(M,$){B(M,$.from)}function w(M,$){$.restore()}function E(M,$){return q;function q(O,I,A){let D,R,j,S;return Array.isArray(O)?K(O):"tokenize"in O?K([O]):W(O);function W(J){return ct;function ct(zt){const at=zt!==null&&J[zt],Z=zt!==null&&J.null,lt=[...Array.isArray(at)?at:at?[at]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return K(lt)(zt)}}function K(J){return D=J,R=0,J.length===0?A:F(J[R])}function F(J){return ct;function ct(zt){return S=P(),j=J,J.partial||(c.currentConstruct=J),J.name&&c.parser.constructs.disable.null.includes(J.name)?st():J.tokenize.call($?Object.assign(Object.create(c),$):c,l,ht,st)(zt)}}function ht(J){return M(j,S),I}function st(J){return S.restore(),++R<D.length?F(D[R]):A}}}function B(M,$){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&Tr(c.events,$,c.events.length-$,M.resolve(c.events.slice($),c)),M.resolveTo&&(c.events=M.resolveTo(c.events,c))}function P(){const M=m(),$=c.previous,q=c.currentConstruct,O=c.events.length,I=Array.from(a);return{from:O,restore:A};function A(){n=M,c.previous=$,c.currentConstruct=q,c.events.length=O,a=I,N()}}function N(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function Mj(t,e){const r=e.start._index,n=e.start._bufferIndex,i=e.end._index,s=e.end._bufferIndex;let o;if(r===i)o=[t[r].slice(n,s)];else{if(o=t.slice(r,i),n>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(n):o.shift()}s>0&&o.push(t[i].slice(0,s))}return o}function Ij(t,e){let r=-1;const n=[];let i;for(;++r<t.length;){const s=t[r];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
7
7
  `;break}case-3:{o=`\r
8
8
  `;break}case-2:{o=e?" ":" ";break}case-1:{if(!e&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,n.push(o)}return n.join("")}function Fj(t){const n={constructs:Ty([Bj,...(t||{}).extensions||[]]),content:i(KE),defined:[],document:i(QE),flow:i(gj),lazy:{},string:i(bj),text:i(Cj)};return n;function i(s){return o;function o(a){return Aj(n,s,a)}}}function Pj(t){for(;!Ly(t););return t}const km=/[\0\t\n\r]/g;function Dj(){let t=1,e="",r=!0,n;return i;function i(s,o,a){const l=[];let c,u,d,p,f;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,e="",r&&(s.charCodeAt(0)===65279&&d++,r=void 0);d<s.length;){if(km.lastIndex=d,c=km.exec(s),p=c&&c.index!==void 0?c.index:s.length,f=s.charCodeAt(p),!c){e=s.slice(d);break}if(f===10&&d===p&&n)l.push(-3),n=void 0;else switch(n&&(l.push(-5),n=void 0),d<p&&(l.push(s.slice(d,p)),t+=p-d),f){case 0:{l.push(65533),t++;break}case 9:{for(u=Math.ceil(t/4)*4,l.push(-2);t++<u;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:n=!0,t=1}d=p+1}return a&&(n&&l.push(-5),e&&l.push(e),l.push(null)),l}}const Oj=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Rj(t){return t.replace(Oj,$j)}function $j(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return _y(r.slice(s?2:1),s?16:10)}return hf(r)||t}const Py={}.hasOwnProperty;function zj(t,e,r){return e&&typeof e=="object"&&(r=e,e=void 0),Wj(r)(Pj(Fj(r).document().write(Dj()(t,e,!0))))}function Wj(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Ae),autolinkProtocol:P,autolinkEmail:P,atxHeading:s(ne),blockQuote:s(Z),characterEscape:P,characterReference:P,codeFenced:s(lt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(lt,o),codeText:s(Ct,o),codeTextData:P,data:P,codeFlowValue:P,definition:s(Mt),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Dt),hardBreakEscape:s(ue),hardBreakTrailing:s(ue),htmlFlow:s(Se,o),htmlFlowData:P,htmlText:s(Se,o),htmlTextData:P,image:s(te),label:o,link:s(Ae),listItem:s(it),listItemValue:p,listOrdered:s(V,d),listUnordered:s(V),paragraph:s(dt),reference:F,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(ne),strong:s(Nt),thematicBreak:s(kt)},exit:{atxHeading:l(),atxHeadingSequence:_,autolink:l(),autolinkEmail:at,autolinkProtocol:zt,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:st,characterReferenceMarkerNumeric:st,characterReferenceValue:J,characterReference:ct,codeFenced:l(g),codeFencedFence:x,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:N,codeIndented:l(y),codeText:l(I),codeTextData:N,data:N,definition:l(),definitionDestinationString:T,definitionLabelString:b,definitionTitleString:k,emphasis:l(),hardBreakEscape:l($),hardBreakTrailing:l($),htmlFlow:l(q),htmlFlowData:N,htmlText:l(O),htmlTextData:N,image:l(D),label:j,labelText:R,lineEnding:M,link:l(A),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ht,resourceDestinationString:S,resourceTitleString:W,resource:K,setextHeading:l(B),setextHeadingLineSequence:E,setextHeadingText:w,strong:l(),thematicBreak:l()}};Dy(e,(t||{}).mdastExtensions||[]);const r={};return n;function n(G){let nt={type:"root",children:[]};const wt={stack:[nt],tokenStack:[],config:e,enter:a,exit:c,buffer:o,resume:u,data:r},At=[];let Gt=-1;for(;++Gt<G.length;)if(G[Gt][1].type==="listOrdered"||G[Gt][1].type==="listUnordered")if(G[Gt][0]==="enter")At.push(Gt);else{const Te=At.pop();Gt=i(G,Te,Gt)}for(Gt=-1;++Gt<G.length;){const Te=e[G[Gt][0]];Py.call(Te,G[Gt][1].type)&&Te[G[Gt][1].type].call(Object.assign({sliceSerialize:G[Gt][2].sliceSerialize},wt),G[Gt][1])}if(wt.tokenStack.length>0){const Te=wt.tokenStack[wt.tokenStack.length-1];(Te[1]||vm).call(wt,void 0,Te[0])}for(nt.position={start:Ln(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:Ln(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},Gt=-1;++Gt<e.transforms.length;)nt=e.transforms[Gt](nt)||nt;return nt}function i(G,nt,wt){let At=nt-1,Gt=-1,Te=!1,ar,ce,Fr,Me;for(;++At<=wt;){const ge=G[At];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?Gt++:Gt--,Me=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(ar&&!Me&&!Gt&&!Fr&&(Fr=At),Me=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Me=void 0}if(!Gt&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||Gt===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(ar){let _e=At;for(ce=void 0;_e--;){const Oe=G[_e];if(Oe[1].type==="lineEnding"||Oe[1].type==="lineEndingBlank"){if(Oe[0]==="exit")continue;ce&&(G[ce][1].type="lineEndingBlank",Te=!0),Oe[1].type="lineEnding",ce=_e}else if(!(Oe[1].type==="linePrefix"||Oe[1].type==="blockQuotePrefix"||Oe[1].type==="blockQuotePrefixWhitespace"||Oe[1].type==="blockQuoteMarker"||Oe[1].type==="listItemIndent"))break}Fr&&(!ce||Fr<ce)&&(ar._spread=!0),ar.end=Object.assign({},ce?G[ce][1].start:ge[1].end),G.splice(ce||At,0,["exit",ar,ge[2]]),At++,wt++}if(ge[1].type==="listItemPrefix"){const _e={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};ar=_e,G.splice(At,0,["enter",_e,ge[2]]),At++,wt++,Fr=void 0,Me=!0}}}return G[nt][1]._spread=Te,wt}function s(G,nt){return wt;function wt(At){a.call(this,G(At),At),nt&&nt.call(this,At)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(G,nt,wt){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([nt,wt||void 0]),G.position={start:Ln(nt.start),end:void 0}}function l(G){return nt;function nt(wt){G&&G.call(this,wt),c.call(this,wt)}}function c(G,nt){const wt=this.stack.pop(),At=this.tokenStack.pop();if(At)At[0].type!==G.type&&(nt?nt.call(this,G,At[0]):(At[1]||vm).call(this,G,At[0]));else throw new Error("Cannot close `"+G.type+"` ("+Io({start:G.start,end:G.end})+"): it’s not open");wt.position.end=Ln(G.end)}function u(){return cf(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function p(G){if(this.data.expectingFirstListItemValue){const nt=this.stack[this.stack.length-2];nt.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function f(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.lang=G}function m(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.meta=G}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.value=G.replace(/(\r?\n|\r)$/g,"")}function b(G){const nt=this.resume(),wt=this.stack[this.stack.length-1];wt.label=nt,wt.identifier=Ur(this.sliceSerialize(G)).toLowerCase()}function k(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.title=G}function T(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.url=G}function _(G){const nt=this.stack[this.stack.length-1];if(!nt.depth){const wt=this.sliceSerialize(G).length;nt.depth=wt}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function E(G){const nt=this.stack[this.stack.length-1];nt.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function B(){this.data.setextHeadingSlurpLineEnding=void 0}function P(G){const wt=this.stack[this.stack.length-1].children;let At=wt[wt.length-1];(!At||At.type!=="text")&&(At=tt(),At.position={start:Ln(G.start),end:void 0},wt.push(At)),this.stack.push(At)}function N(G){const nt=this.stack.pop();nt.value+=this.sliceSerialize(G),nt.position.end=Ln(G.end)}function M(G){const nt=this.stack[this.stack.length-1];if(this.data.atHardBreak){const wt=nt.children[nt.children.length-1];wt.position.end=Ln(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(nt.type)&&(P.call(this,G),N.call(this,G))}function $(){this.data.atHardBreak=!0}function q(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.value=G}function O(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.value=G}function I(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.value=G}function A(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const nt=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=nt,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function D(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const nt=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=nt,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function R(G){const nt=this.sliceSerialize(G),wt=this.stack[this.stack.length-2];wt.label=Rj(nt),wt.identifier=Ur(nt).toLowerCase()}function j(){const G=this.stack[this.stack.length-1],nt=this.resume(),wt=this.stack[this.stack.length-1];if(this.data.inReference=!0,wt.type==="link"){const At=G.children;wt.children=At}else wt.alt=nt}function S(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.url=G}function W(){const G=this.resume(),nt=this.stack[this.stack.length-1];nt.title=G}function K(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function ht(G){const nt=this.resume(),wt=this.stack[this.stack.length-1];wt.label=nt,wt.identifier=Ur(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function st(G){this.data.characterReferenceType=G.type}function J(G){const nt=this.sliceSerialize(G),wt=this.data.characterReferenceType;let At;wt?(At=_y(nt,wt==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):At=hf(nt);const Gt=this.stack[this.stack.length-1];Gt.value+=At}function ct(G){const nt=this.stack.pop();nt.position.end=Ln(G.end)}function zt(G){N.call(this,G);const nt=this.stack[this.stack.length-1];nt.url=this.sliceSerialize(G)}function at(G){N.call(this,G);const nt=this.stack[this.stack.length-1];nt.url="mailto:"+this.sliceSerialize(G)}function Z(){return{type:"blockquote",children:[]}}function lt(){return{type:"code",lang:null,meta:null,value:""}}function Ct(){return{type:"inlineCode",value:""}}function Mt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Dt(){return{type:"emphasis",children:[]}}function ne(){return{type:"heading",depth:0,children:[]}}function ue(){return{type:"break"}}function Se(){return{type:"html",value:""}}function te(){return{type:"image",title:null,url:"",alt:null}}function Ae(){return{type:"link",title:null,url:"",children:[]}}function V(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function it(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function dt(){return{type:"paragraph",children:[]}}function Nt(){return{type:"strong",children:[]}}function tt(){return{type:"text",value:""}}function kt(){return{type:"thematicBreak"}}}function Ln(t){return{line:t.line,column:t.column,offset:t.offset}}function Dy(t,e){let r=-1;for(;++r<e.length;){const n=e[r];Array.isArray(n)?Dy(t,n):qj(t,n)}}function qj(t,e){let r;for(r in e)if(Py.call(e,r))switch(r){case"canContainEols":{const n=e[r];n&&t[r].push(...n);break}case"transforms":{const n=e[r];n&&t[r].push(...n);break}case"enter":case"exit":{const n=e[r];n&&Object.assign(t[r],n);break}}}function vm(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+Io({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+Io({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+Io({start:e.start,end:e.end})+") is still open")}function Hj(t){const e=this;e.parser=r;function r(n){return zj(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function Uj(t,e){const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,r),t.applyData(e,r)}function Gj(t,e){const r={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,r),[t.applyData(e,r),{type:"text",value:`
@@ -335,7 +335,7 @@ var h_=Object.defineProperty;var u_=(t,e,r)=>e in t?h_(t,e,{enumerable:!0,config
335
335
  *
336
336
  * This source code is licensed under the ISC license.
337
337
  * See the LICENSE file in the root directory of this source tree.
338
- */const VM=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Pl=jt("zap",VM),Mc=C.createContext({newIds:new Set,changedIds:new Set}),Ym=t=>{let e;const r=new Set,n=(c,u)=>{const d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){const p=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),r.forEach(f=>f(e,p))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(r.add(c),()=>r.delete(c))},l=e=t(n,i,a);return a},YM=(t=>t?Ym(t):Ym),XM=t=>t;function KM(t,e=XM){const r=Yt.useSyncExternalStore(t.subscribe,Yt.useCallback(()=>e(t.getState()),[t,e]),Yt.useCallback(()=>e(t.getInitialState()),[t,e]));return Yt.useDebugValue(r),r}const Xm=t=>{const e=YM(t),r=n=>KM(e,n);return Object.assign(r,e),r},Nf=(t=>t?Xm(t):Xm),ao=new Map;function ZM(t,e,r){var D,R;const{prevItemMapRef:n,snapshotProviderRef:i,gatesRef:s,pendingResolveIdsRef:o,changeTimerRef:a,sessionEndTimerRef:l,wsRef:c}=e,{setItems:u,setConnections:d,setGates:p,setGateEvent:f,setRecentChanges:m,setUICommand:x,setAgentActivity:g,setAgentErrors:y,setSessionState:b,setSpawnedAgents:k,setAgentRelays:T,setSettings:_,setPipelineDraft:w,setActiveBuild:E,setSessions:B,setIterationStates:P,setFeatureTimeline:N,EMPTY_CHANGES:M,appendDecisionEvent:$,setDecisionEventsSnapshot:q,setStatusSnapshot:O,clearStatusSnapshots:I}=r,A=N?j=>{N(S=>S.some(W=>W.id===j.id)?S:[...S,j])}:null;if(t.type==="visionState"||t.type==="hydrate"){const j=t.items||[];if(n.current){const S=n.current,W=new Set,K=new Set;for(const F of j){const ht=S.get(F.id);ht?(ht.status!==F.status||ht.confidence!==F.confidence||ht.title!==F.title)&&K.add(F.id):W.add(F.id)}(W.size>0||K.size>0)&&(m({newIds:W,changedIds:K}),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>m(M),800))}n.current=new Map(j.map(S=>[S.id,S])),u(j),d(t.connections||[]),p(t.gates||[]),B&&B(t.sessions||[]),q&&Array.isArray(t.decisionEventsSnapshot)&&q(t.decisionEventsSnapshot),I&&I()}else if(t.type==="decisionEvent")$&&t.event&&$(t.event);else if(t.type==="decisionEventsSnapshot")q&&Array.isArray(t.events)&&q(t.events);else if(t.type==="statusSnapshot")O&&t.featureCode&&t.snapshot&&O(t.featureCode,t.snapshot);else if(t.type==="visionUI")x(t);else if(t.type==="agentActivity")g(j=>{const S=[...j,{tool:t.tool,category:t.category||null,detail:t.detail,items:t.items||[],error:t.error||null,timestamp:t.timestamp}];return S.length>20?S.slice(-20):S}),b(j=>j!=null&&j.active?{...j,toolCount:(j.toolCount||0)+1}:j);else if(t.type==="agentSpawned")k(j=>[...j,{agentId:t.agentId,parentSessionId:t.parentSessionId,agentType:t.agentType,status:"running",startedAt:t.startedAt,prompt:t.prompt}]);else if(t.type==="agentSilent")k(j=>j.map(S=>S.agentId===t.agentId?{...S,silent:!0,silentSinceMs:t.silentSinceMs}:S));else if(t.type==="agentKilled")k(j=>j.map(S=>S.agentId===t.agentId?{...S,status:"killed",terminalReason:t.reason,completedAt:new Date().toISOString()}:S));else if(t.type==="agentGC")((D=t.removed)==null?void 0:D.length)>0&&g(j=>{const S=[...j,{tool:"gc",category:"executing",detail:`Cleaned ${t.removed.length} orphan worktree(s)`,items:[],timestamp:t.timestamp}];return S.length>20?S.slice(-20):S});else if(t.type==="agentComplete")k(j=>j.map(S=>S.agentId===t.agentId?S.status==="killed"?S:{...S,status:t.status,completedAt:new Date().toISOString()}:S));else if(t.type==="agentRelay")T(j=>[...j,t].slice(-50));else if(t.type==="sessionStart")l.current&&(clearTimeout(l.current),l.current=null),k(()=>[]),T(()=>[]),b(j=>j&&j.id===t.sessionId?{...j,active:!0}:{id:t.sessionId,active:!0,startedAt:t.timestamp,source:t.source,toolCount:0,errorCount:0,summaries:[],featureCode:null,featureItemId:null,phaseAtBind:null,boundAt:null}),A&&A({id:`session-start-${t.sessionId}`,timestamp:t.timestamp,category:"session",title:"Session started",detail:t.source?`Source: ${t.source}`:null,severity:"info",sessionId:t.sessionId,meta:{source:t.source}});else if(t.type==="sessionEnd")l.current&&(clearTimeout(l.current),l.current=null),b(j=>j?{...j,active:!1,endedAt:t.timestamp,toolCount:t.toolCount,duration:t.duration,journalSpawned:t.journalSpawned,featureCode:t.featureCode||(j==null?void 0:j.featureCode)||null,phaseAtEnd:t.phaseAtEnd||null}:null),l.current=setTimeout(()=>{b(null),l.current=null},3e3),A&&A({id:`session-end-${t.sessionId||Date.now()}`,timestamp:t.timestamp,category:"session",title:`Session ended (${t.toolCount??0} tools)`,detail:null,severity:"info",sessionId:t.sessionId||null,meta:{toolCount:t.toolCount,duration:t.duration}});else if(t.type==="sessionSummary")b(j=>j&&{...j,summaries:[...j.summaries||[],{summary:t.summary,intent:t.intent,component:t.component,timestamp:t.timestamp}].slice(-5)});else if(t.type==="sessionBound")b(j=>j&&{...j,featureCode:t.featureCode,featureItemId:t.itemId,phaseAtBind:t.phase,boundAt:t.timestamp});else if(t.type==="agentError")y(j=>{const S=[...j,{errorType:t.errorType,severity:t.severity,message:t.message,tool:t.tool,detail:t.detail,items:t.items||[],timestamp:t.timestamp||new Date().toISOString()}];return S.length>10?S.slice(-10):S}),b(j=>j!=null&&j.active?{...j,errorCount:(j.errorCount||0)+1}:j),A&&A({id:`error-${t.timestamp}-${Math.random().toString(36).slice(2,6)}`,timestamp:t.timestamp||new Date().toISOString(),category:"error",title:t.message||`${t.errorType} error`,detail:t.tool?`Tool: ${t.tool}`:null,severity:t.severity==="error"?"error":"warning",sessionId:null,meta:{type:t.errorType,tool:t.tool}});else if(t.type==="gateCreated"||t.type==="gatePending")f({type:"pending",gateId:t.gateId,itemId:t.itemId,fromPhase:t.fromPhase,toPhase:t.toPhase}),A&&A({id:`gate-created-${t.gateId}`,timestamp:t.timestamp||new Date().toISOString(),category:"gate",title:t.fromPhase&&t.toPhase?`Gate: ${t.fromPhase} → ${t.toPhase}`:"Gate created",detail:null,severity:"info",sessionId:null,meta:{gateId:t.gateId,itemId:t.itemId,fromPhase:t.fromPhase,toPhase:t.toPhase}});else if(t.type==="gateResolved"){if(p(W=>W.map(K=>K.id===t.gateId?{...K,status:"resolved",outcome:t.outcome,resolvedAt:t.timestamp}:K)),o.current.has(t.gateId))o.current.delete(t.gateId);else{const W=t.itemId??((R=s.current.find(K=>K.id===t.gateId))==null?void 0:R.itemId)??t.gateId;f({type:"resolved",gateId:t.gateId,outcome:t.outcome,itemId:W})}const j=t.outcome==="approve"?"approved":t.outcome==="revise"?"revised":t.outcome==="kill"?"killed":t.outcome,S={approve:"success",revise:"warning",kill:"error"};A&&A({id:`gate-resolved-${t.gateId}`,timestamp:t.timestamp||new Date().toISOString(),category:"gate",title:`Gate ${j}`,detail:null,severity:S[t.outcome]||"info",sessionId:null,meta:{gateId:t.gateId,itemId:t.itemId,outcome:t.outcome}})}else if(t.type==="iterationStarted"||t.type==="iterationUpdate"||t.type==="iterationComplete"){if(g(j=>{let S;t.type==="iterationStarted"?S=`${t.loopType} loop started (0/${t.maxIterations})`:t.type==="iterationComplete"?S=`${t.loopType??"loop"} loop complete (${t.outcome} after ${t.finalCount} iterations)`:S=`${t.loopType??"loop"} iteration ${t.count}/${t.maxIterations}`;const W=[...j,{tool:"iteration",category:t.loopType||"iteration",detail:S,items:[],timestamp:t.timestamp}];return W.length>20?W.slice(-20):W}),t.type==="iterationStarted")ao.has(t.loopId)&&(clearTimeout(ao.get(t.loopId)),ao.delete(t.loopId)),P(j=>{const S=new Map(j);return S.set(t.loopId,{loopId:t.loopId,itemId:t.itemId,loopType:t.loopType,count:0,maxIterations:t.maxIterations,status:"running",outcome:null,startedAt:t.startedAt??t.timestamp,wallClockTimeout:t.wallClockTimeout??null,maxActions:t.maxActions??null}),S});else if(t.type==="iterationUpdate")P(j=>{const S=j.get(t.loopId);if(!S)return j;const W=new Map(j);return W.set(t.loopId,{...S,count:t.count,maxIterations:t.maxIterations}),W});else if(t.type==="iterationComplete"){P(S=>{const W=S.get(t.loopId);if(!W)return S;const K=new Map(S);return K.set(t.loopId,{...W,status:"complete",outcome:t.outcome,count:t.finalCount??W.count}),K});const j=setTimeout(()=>{P(S=>{const W=new Map(S);return W.delete(t.loopId),W}),ao.delete(t.loopId)},5e3);ao.set(t.loopId,j)}if(t.type==="iterationComplete"&&(t.outcome==="max_reached"||t.outcome==="timeout"||t.outcome==="action_limit")){const j={max_reached:`${t.loopType??"Loop"} hit max iterations (${t.finalCount}) — problem may be in the spec`,timeout:`${t.loopType??"Loop"} timed out after ${t.elapsedMinutes??"?"} minutes (${t.finalCount} iterations)`,action_limit:`${t.loopType??"Loop"} hit action count ceiling (${t.finalCount} iterations)`};y(S=>{const W=[...S,{errorType:"iteration_limit",severity:"warning",message:j[t.outcome]??`${t.loopType??"Loop"} stopped: ${t.outcome}`,timestamp:t.timestamp}];return W.length>10?W.slice(-10):W}),b(S=>S!=null&&S.active?{...S,errorCount:(S.errorCount||0)+1}:S)}if(A&&(t.type==="iterationStarted"||t.type==="iterationComplete")){const j=t.type==="iterationStarted"?`${t.loopType} loop started (0/${t.maxIterations})`:`${t.loopType??"loop"} loop ${t.outcome} (${t.finalCount} iterations)`;A({id:`iteration-${t.loopId}-${t.type}`,timestamp:t.timestamp,category:"iteration",title:j,detail:null,severity:t.outcome==="max_reached"||t.outcome==="timeout"||t.outcome==="action_limit"?"warning":t.type==="iterationComplete"?"success":"info",sessionId:null,meta:{loopId:t.loopId,loopType:t.loopType}})}}else if(t.type==="lifecycleStarted")A&&A({id:`lifecycle-started-${t.itemId}`,timestamp:t.timestamp,category:"phase",title:`Lifecycle started: ${t.phase}`,detail:t.featureCode?`Feature: ${t.featureCode}`:null,severity:"success",sessionId:null,meta:{itemId:t.itemId,phase:t.phase,featureCode:t.featureCode}});else if(t.type==="lifecycleTransition"){const j=t.outcome==="skipped"?" (skipped)":t.outcome==="killed"?" (killed)":"",S=t.outcome==="killed"?"error":t.outcome==="skipped"?"info":"success";A&&A({id:`lifecycle-${t.itemId}-${t.from}-${t.to}`,timestamp:t.timestamp,category:"phase",title:`Phase: ${t.from} → ${t.to}${j}`,detail:null,severity:S,sessionId:null,meta:{itemId:t.itemId,from:t.from,to:t.to,outcome:t.outcome}})}else if(t.type==="openLoopsUpdate")u&&t.itemId&&Array.isArray(t.loops)&&u(j=>j.map(S=>{if(S.id!==t.itemId)return S;const W=S.lifecycle?{...S.lifecycle}:{};return W.lifecycle_ext={...W.lifecycle_ext||{},open_loops:t.loops},{...S,lifecycle:W}}));else if(t.type==="driftAxesUpdate")u&&t.itemId&&Array.isArray(t.drift_axes)&&u(j=>j.map(S=>{if(S.id!==t.itemId)return S;const W=S.lifecycle?{...S.lifecycle}:{};return W.lifecycle_ext={...W.lifecycle_ext||{},drift_axes:t.drift_axes},{...S,lifecycle:W}}));else if(t.type==="branchLineageUpdate"){if(u&&t.itemId){const{type:j,itemId:S,...W}=t;u(K=>K.map(F=>{if(F.id!==S)return F;const ht=F.lifecycle?{...F.lifecycle}:{};return ht.lifecycle_ext={...ht.lifecycle_ext||{},branch_lineage:W},{...F,lifecycle:ht}}))}}else if(t.type==="settingsState"||t.type==="settingsUpdated")_&&_(t.settings||null);else if(t.type==="buildState")E&&E(j=>{const S=(j==null?void 0:j.flowId)&&t.flowId&&j.flowId===t.flowId;return{...t,tierEvents:S?j.tierEvents??[]:[],capabilityEvents:S?j.capabilityEvents??[]:[],...S&&(j==null?void 0:j.health_score)!=null?{health_score:j.health_score,health_breakdown:j.health_breakdown,health_missing:j.health_missing}:{}}});else if(t.type==="pipelineDraft")w&&w(t);else if(t.type==="pipelineDraftResolved")w&&w(null);else if(t.type==="system"&&t.subtype==="health_score")E&&E(j=>j&&{...j,health_score:t.score,health_breakdown:t.breakdown,health_missing:t.missing});else if(t.type==="system"&&(t.subtype==="gate_tier_result"||t.subtype==="gate_tier_failed"||t.subtype==="gate_tier_summary"))E&&E(j=>j&&{...j,tierEvents:[...j.tierEvents||[],t].slice(-50)});else if(t.type==="system"&&t.subtype==="capability_violation")E&&E(j=>j&&{...j,capabilityEvents:[...j.capabilityEvents||[],t].slice(-200)});else if(t.type==="snapshotRequest"&&t.requestId){const{collectDOMSnapshot:j}=e,S=i.current?i.current():{},W=j?j():{},K=c.current;K&&K.send(JSON.stringify({type:"snapshotResponse",requestId:t.requestId,snapshot:{...S,dom:W,timestamp:new Date().toISOString()}}))}}function QM(){const t=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT"]),e=12,r=120;function n(s,o){if(!s||o>e)return null;if(s.nodeType===Node.TEXT_NODE){const p=s.textContent.trim();return p?p.slice(0,r):null}if(s.nodeType!==Node.ELEMENT_NODE||t.has(s.tagName))return null;const a=window.getComputedStyle(s);if(a.display==="none"||a.visibility==="hidden")return null;const l={},c=s.getAttribute("role")||s.getAttribute("aria-label"),u=s.tagName.toLowerCase();if(c?l.role=c:l.tag=u,s.className&&typeof s.className=="string"){const p=s.className.trim();p.length<80&&(l.class=p)}const d=[];for(const p of s.childNodes){const f=n(p,o+1);f&&d.push(f)}return d.length===1&&typeof d[0]=="string"?l.text=d[0]:d.length>0&&(l.children=d),!c&&(u==="div"||u==="span")&&!l.text&&d.length===1&&typeof d[0]=="object"?d[0]:l}const i=document.querySelector("[data-snapshot-root]")||document.body;return n(i,0)}const pe={ws:null,snapshotProvider:null,prevItemMap:null,changeTimer:null,sessionEndTimer:null,gates:[],pendingResolveIds:new Set,buildPollInterval:null,recentErrorsInterval:null,connected:!1},Km={newIds:new Set,changedIds:new Set},gr=Nf((t,e)=>{async function r(o,a){const l=await Rt(o,a),c=await l.json();return l.ok?c:(console.error(`[vision] API error ${l.status}:`,c.error||c),{error:c.error||`HTTP ${l.status}`})}function n(){t({connected:!0}),Rt("/api/build/state").then(o=>o.json()).then(o=>t({activeBuild:o.state??null})).catch(()=>{}),Rt("/api/pipeline/draft").then(o=>o.json()).then(o=>t({pipelineDraft:o.draft??null})).catch(()=>{}),Rt("/api/agents/tree").then(o=>o.json()).then(o=>{e().spawnedAgents.length===0&&t({spawnedAgents:(o.agents||[]).map(l=>({agentId:l.agentId,parentSessionId:l.parentSessionId,agentType:l.agentType,status:l.status||"running",startedAt:l.startedAt,prompt:l.prompt}))})}).catch(()=>{})}function i(o){try{const a=JSON.parse(o.data);ZM(a,{prevItemMapRef:{get current(){return pe.prevItemMap},set current(l){pe.prevItemMap=l}},snapshotProviderRef:{get current(){return pe.snapshotProvider},set current(l){pe.snapshotProvider=l}},gatesRef:{get current(){return pe.gates},set current(l){pe.gates=l}},pendingResolveIdsRef:{get current(){return pe.pendingResolveIds},set current(l){pe.pendingResolveIds=l}},changeTimerRef:{get current(){return pe.changeTimer},set current(l){pe.changeTimer=l}},sessionEndTimerRef:{get current(){return pe.sessionEndTimer},set current(l){pe.sessionEndTimer=l}},wsRef:{get current(){var l;return((l=pe.ws)==null?void 0:l.socket)||null},set current(l){}},collectDOMSnapshot:QM},{setItems:l=>t(c=>({items:typeof l=="function"?l(c.items):l})),setConnections:l=>t(c=>({connections:typeof l=="function"?l(c.connections):l})),setGates:l=>{t(c=>{const u=typeof l=="function"?l(c.gates):l;return pe.gates=u,{gates:u}})},setGateEvent:l=>t({gateEvent:l}),setRecentChanges:l=>t(c=>({recentChanges:typeof l=="function"?l(c.recentChanges):l})),setUICommand:l=>t({uiCommand:l}),setAgentActivity:l=>t(c=>({agentActivity:typeof l=="function"?l(c.agentActivity):l})),setAgentErrors:l=>{t(c=>{const u=typeof l=="function"?l(c.agentErrors):l,d=Date.now()-6e4,p=u.filter(f=>new Date(f.timestamp).getTime()>d).slice(-5);return{agentErrors:u,recentErrors:p}})},setSessionState:l=>t(c=>({sessionState:typeof l=="function"?l(c.sessionState):l})),setSpawnedAgents:l=>t(c=>({spawnedAgents:typeof l=="function"?l(c.spawnedAgents):l})),setAgentRelays:l=>t(c=>({agentRelays:typeof l=="function"?l(c.agentRelays):l})),setSettings:l=>t({settings:l}),setPipelineDraft:l=>t({pipelineDraft:l}),setActiveBuild:l=>t(c=>({activeBuild:typeof l=="function"?l(c.activeBuild):l})),setSessions:l=>t(c=>({sessions:typeof l=="function"?l(c.sessions):l})),setFeatureTimeline:l=>t(c=>({featureTimeline:typeof l=="function"?l(c.featureTimeline):l})),setIterationStates:l=>t(c=>({iterationStates:typeof l=="function"?l(c.iterationStates):l})),appendDecisionEvent:l=>t(c=>!(l!=null&&l.id)||c.decisionEvents.some(u=>u.id===l.id)?c:{decisionEvents:[...c.decisionEvents,l]}),setDecisionEventsSnapshot:l=>t({decisionEvents:Array.isArray(l)?l:[]}),setStatusSnapshot:(l,c)=>t(u=>({statusSnapshots:{...u.statusSnapshots,[l]:c}})),clearStatusSnapshots:()=>t({statusSnapshots:{}}),EMPTY_CHANGES:Km})}catch{}}function s(){if(pe.disposed||pe.ws)return;const a=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/vision`;pe.ws=f_({url:a,onOpen:n,onMessage:i,onClose:()=>t({connected:!1})})}return Rt("/api/session/current").then(o=>o.json()).then(o=>{o.session&&t(a=>a.sessionState?{}:{sessionState:{id:o.session.id,active:!0,startedAt:o.session.startedAt,source:o.session.source||"hydrated",toolCount:o.session.toolCount||0,errorCount:o.session.errorCount||0,summaries:o.session.summaries||[],featureCode:o.session.featureCode||null,featureItemId:o.session.featureItemId||null,phaseAtBind:o.session.phaseAtBind||null,boundAt:o.session.boundAt||null}})}).catch(()=>console.warn("[vision] Failed to hydrate session state")),pe.buildPollInterval=setInterval(()=>{Rt("/api/build/state").then(o=>o.json()).then(o=>t({activeBuild:o.state??null})).catch(()=>{})},5e3),pe.recentErrorsInterval=setInterval(()=>{const{agentErrors:o}=e(),a=Date.now()-6e4,l=o.filter(c=>new Date(c.timestamp).getTime()>a).slice(-5);t({recentErrors:l})},1e4),s(),{items:[],connections:[],connected:!1,uiCommand:null,recentChanges:Km,agentActivity:[],agentErrors:[],recentErrors:[],spawnedAgents:[],agentRelays:[],sessionState:null,gates:[],gateEvent:null,settings:null,pipelineDraft:null,activeBuild:null,iterationStates:new Map,sessions:[],featureTimeline:[],selectedPhase:(()=>{try{return localStorage.getItem("compose:selectedPhase")||null}catch{return null}})(),selectedBranches:{},decisionEvents:[],statusSnapshots:{},clearUICommand:()=>t({uiCommand:null}),setSelectedBranches:(o,a)=>t(l=>({selectedBranches:{...l.selectedBranches,[o]:a}})),setStatusSnapshot:(o,a)=>t(l=>({statusSnapshots:{...l.statusSnapshots,[o]:a}})),clearStatusSnapshots:()=>t({statusSnapshots:{}}),setDecisionEventsSnapshot:o=>t({decisionEvents:Array.isArray(o)?o:[]}),appendDecisionEvent:o=>t(a=>!(o!=null&&o.id)||a.decisionEvents.some(l=>l.id===o.id)?a:{decisionEvents:[...a.decisionEvents,o]}),registerSnapshotProvider:o=>{pe.snapshotProvider=o},setActiveBuild:o=>t({activeBuild:o}),setPipelineDraft:o=>t({pipelineDraft:o}),setFeatureTimeline:o=>t(a=>({featureTimeline:typeof o=="function"?o(a.featureTimeline):o})),setSelectedPhase:o=>{t({selectedPhase:o});try{o?localStorage.setItem("compose:selectedPhase",o):localStorage.removeItem("compose:selectedPhase")}catch{}},updateItemPosition:(o,a)=>{t(l=>({items:l.items.map(c=>c.id===o?{...c,position:a}:c)}))},createItem:o=>r("/api/vision/items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),updateItem:(o,a)=>r(`/api/vision/items/${o}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),deleteItem:o=>r(`/api/vision/items/${o}`,{method:"DELETE"}),createConnection:o=>r("/api/vision/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),deleteConnection:o=>r(`/api/vision/connections/${o}`,{method:"DELETE"}),resolveGate:async(o,a,l)=>{pe.pendingResolveIds.add(o);try{const c=await r(`/api/vision/gates/${o}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({outcome:a,comment:l})});return c.error&&pe.pendingResolveIds.delete(o),c}catch{return pe.pendingResolveIds.delete(o),{error:"Network error"}}},updateSettings:o=>r("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),resetSettings:o=>r("/api/settings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o?{section:o}:{})})}});function Eb(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=Eb(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function Nb(){for(var t,e,r=0,n="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=Eb(t))&&(n&&(n+=" "),n+=e);return n}const Zm=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Qm=Nb,jb=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return Qm(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(c=>{const u=r==null?void 0:r[c],d=s==null?void 0:s[c];if(u===null)return null;const p=Zm(u)||Zm(d);return i[c][p]}),a=r&&Object.entries(r).reduce((c,u)=>{let[d,p]=u;return p===void 0||(c[d]=p),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:p,...f}=u;return Object.entries(f).every(m=>{let[x,g]=m;return Array.isArray(g)?g.includes({...s,...a}[x]):{...s,...a}[x]===g})?[...c,d,p]:c},[]);return Qm(t,o,l,r==null?void 0:r.class,r==null?void 0:r.className)},JM=(t,e)=>{const r=new Array(t.length+e.length);for(let n=0;n<t.length;n++)r[n]=t[n];for(let n=0;n<e.length;n++)r[t.length+n]=e[n];return r},tI=(t,e)=>({classGroupId:t,validator:e}),Lb=(t=new Map,e=null,r)=>({nextPart:t,validators:e,classGroupId:r}),Dl="-",Jm=[],eI="arbitrary..",rI=t=>{const e=iI(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return nI(o);const a=o.split(Dl),l=a[0]===""&&a.length>1?1:0;return Bb(a,l,e)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=n[o],c=r[o];return l?c?JM(c,l):l:c||Jm}return r[o]||Jm}}},Bb=(t,e,r)=>{if(t.length-e===0)return r.classGroupId;const i=t[e],s=r.nextPart.get(i);if(s){const c=Bb(t,e+1,s);if(c)return c}const o=r.validators;if(o===null)return;const a=e===0?t.join(Dl):t.slice(e).join(Dl),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},nI=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),r=e.indexOf(":"),n=e.slice(0,r);return n?eI+n:void 0})(),iI=t=>{const{theme:e,classGroups:r}=t;return sI(r,e)},sI=(t,e)=>{const r=Lb();for(const n in t){const i=t[n];jf(i,r,n,e)}return r},jf=(t,e,r,n)=>{const i=t.length;for(let s=0;s<i;s++){const o=t[s];oI(o,e,r,n)}},oI=(t,e,r,n)=>{if(typeof t=="string"){aI(t,e,r);return}if(typeof t=="function"){lI(t,e,r,n);return}cI(t,e,r,n)},aI=(t,e,r)=>{const n=t===""?e:Ab(e,t);n.classGroupId=r},lI=(t,e,r,n)=>{if(hI(t)){jf(t(n),e,r,n);return}e.validators===null&&(e.validators=[]),e.validators.push(tI(r,t))},cI=(t,e,r,n)=>{const i=Object.entries(t),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];jf(l,Ab(e,a),r,n)}},Ab=(t,e)=>{let r=t;const n=e.split(Dl),i=n.length;for(let s=0;s<i;s++){const o=n[s];let a=r.nextPart.get(o);a||(a=Lb(),r.nextPart.set(o,a)),r=a}return r},hI=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,uI=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,e++,e>t&&(e=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},zu="!",tg=":",dI=[],eg=(t,e,r,n,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),fI=t=>{const{prefix:e,experimentalParseClassName:r}=t;let n=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let x=0;x<u;x++){const g=i[x];if(o===0&&a===0){if(g===tg){s.push(i.slice(l,x)),l=x+1;continue}if(g==="/"){c=x;continue}}g==="["?o++:g==="]"?o--:g==="("?a++:g===")"&&a--}const d=s.length===0?i:i.slice(l);let p=d,f=!1;d.endsWith(zu)?(p=d.slice(0,-1),f=!0):d.startsWith(zu)&&(p=d.slice(1),f=!0);const m=c&&c>l?c-l:void 0;return eg(s,f,p,m)};if(e){const i=e+tg,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):eg(dI,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},pI=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((r,n)=>{e.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],a=o[0]==="[",l=e.has(o);a||l?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},mI=t=>({cache:uI(t.cacheSize),parseClassName:fI(t),sortModifiers:pI(t),postfixLookupClassGroupIds:gI(t),...rI(t)}),gI=t=>{const e=Object.create(null),r=t.postfixLookupClassGroups;if(r)for(let n=0;n<r.length;n++)e[r[n]]=!0;return e},xI=/\s+/,yI=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s,postfixLookupClassGroupIds:o}=e,a=[],l=t.trim().split(xI);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:f,hasImportantModifier:m,baseClassName:x,maybePostfixModifierPosition:g}=r(d);if(p){c=d+(c.length>0?" "+c:c);continue}let y=!!g,b;if(y){const E=x.substring(0,g);b=n(E);const B=b&&o[b]?n(x):void 0;B&&B!==b&&(b=B,y=!1)}else b=n(x);if(!b){if(!y){c=d+(c.length>0?" "+c:c);continue}if(b=n(x),!b){c=d+(c.length>0?" "+c:c);continue}y=!1}const k=f.length===0?"":f.length===1?f[0]:s(f).join(":"),T=m?k+zu:k,_=T+b;if(a.indexOf(_)>-1)continue;a.push(_);const w=i(b,y);for(let E=0;E<w.length;++E){const B=w[E];a.push(T+B)}c=d+(c.length>0?" "+c:c)}return c},bI=(...t)=>{let e=0,r,n,i="";for(;e<t.length;)(r=t[e++])&&(n=Mb(r))&&(i&&(i+=" "),i+=n);return i},Mb=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=Mb(t[n]))&&(r&&(r+=" "),r+=e);return r},CI=(t,...e)=>{let r,n,i,s;const o=l=>{const c=e.reduce((u,d)=>d(u),t());return r=mI(c),n=r.cache.get,i=r.cache.set,s=a,a(l)},a=l=>{const c=n(l);if(c)return c;const u=yI(l,r);return i(l,u),u};return s=o,(...l)=>s(bI(...l))},kI=[],Ie=t=>{const e=r=>r[t]||kI;return e.isThemeGetter=!0,e},Ib=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vI=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,wI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,SI=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,TI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_I=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,EI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=t=>vI.test(t),Vt=t=>!!t&&!Number.isNaN(Number(t)),Qr=t=>!!t&&Number.isInteger(Number(t)),Ih=t=>t.endsWith("%")&&Vt(t.slice(0,-1)),mn=t=>wI.test(t),Pb=()=>!0,NI=t=>SI.test(t)&&!TI.test(t),Lf=()=>!1,jI=t=>_I.test(t),LI=t=>EI.test(t),BI=t=>!mt(t)&&!gt(t),AI=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),MI=t=>Qn(t,Rb,Lf),mt=t=>Ib.test(t),ii=t=>Qn(t,$b,NI),rg=t=>Qn(t,zI,Vt),II=t=>Qn(t,Wb,Pb),FI=t=>Qn(t,zb,Lf),ng=t=>Qn(t,Db,Lf),PI=t=>Qn(t,Ob,LI),Fa=t=>Qn(t,qb,jI),gt=t=>Fb.test(t),lo=t=>Ni(t,$b),DI=t=>Ni(t,zb),ig=t=>Ni(t,Db),OI=t=>Ni(t,Rb),RI=t=>Ni(t,Ob),Pa=t=>Ni(t,qb,!0),$I=t=>Ni(t,Wb,!0),Qn=(t,e,r)=>{const n=Ib.exec(t);return n?n[1]?e(n[1]):r(n[2]):!1},Ni=(t,e,r=!1)=>{const n=Fb.exec(t);return n?n[1]?e(n[1]):r:!1},Db=t=>t==="position"||t==="percentage",Ob=t=>t==="image"||t==="url",Rb=t=>t==="length"||t==="size"||t==="bg-size",$b=t=>t==="length",zI=t=>t==="number",zb=t=>t==="family-name",Wb=t=>t==="number"||t==="weight",qb=t=>t==="shadow",WI=()=>{const t=Ie("color"),e=Ie("font"),r=Ie("text"),n=Ie("font-weight"),i=Ie("tracking"),s=Ie("leading"),o=Ie("breakpoint"),a=Ie("container"),l=Ie("spacing"),c=Ie("radius"),u=Ie("shadow"),d=Ie("inset-shadow"),p=Ie("text-shadow"),f=Ie("drop-shadow"),m=Ie("blur"),x=Ie("perspective"),g=Ie("aspect"),y=Ie("ease"),b=Ie("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...T(),gt,mt],w=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],B=()=>[gt,mt,l],P=()=>[Bn,"full","auto",...B()],N=()=>[Qr,"none","subgrid",gt,mt],M=()=>["auto",{span:["full",Qr,gt,mt]},Qr,gt,mt],$=()=>[Qr,"auto",gt,mt],q=()=>["auto","min","max","fr",gt,mt],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],I=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...B()],D=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],R=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...B()],j=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...B()],S=()=>[t,gt,mt],W=()=>[...T(),ig,ng,{position:[gt,mt]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",OI,MI,{size:[gt,mt]}],ht=()=>[Ih,lo,ii],st=()=>["","none","full",c,gt,mt],J=()=>["",Vt,lo,ii],ct=()=>["solid","dashed","dotted","double"],zt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],at=()=>[Vt,Ih,ig,ng],Z=()=>["","none",m,gt,mt],lt=()=>["none",Vt,gt,mt],Ct=()=>["none",Vt,gt,mt],Mt=()=>[Vt,gt,mt],Dt=()=>[Bn,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[mn],breakpoint:[mn],color:[Pb],container:[mn],"drop-shadow":[mn],ease:["in","out","in-out"],font:[BI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[mn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[mn],shadow:[mn],spacing:["px",Vt],text:[mn],"text-shadow":[mn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,mt,gt,g]}],container:["container"],"container-type":[{"@container":["","normal","size",gt,mt]}],"container-named":[AI],columns:[{columns:[Vt,mt,gt,a]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Qr,"auto",gt,mt]}],basis:[{basis:[Bn,"full","auto",a,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Vt,Bn,"auto","initial","none",mt]}],grow:[{grow:["",Vt,gt,mt]}],shrink:[{shrink:["",Vt,gt,mt]}],order:[{order:[Qr,"first","last","none",gt,mt]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:M()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":q()}],"auto-rows":[{"auto-rows":q()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...I(),"normal"]}],"justify-self":[{"justify-self":["auto",...I()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...I(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...I(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...I(),"baseline"]}],"place-self":[{"place-self":["auto",...I()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pbs:[{pbs:B()}],pbe:[{pbe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...R()]}],"min-inline-size":[{"min-inline":["auto",...R()]}],"max-inline-size":[{"max-inline":["none",...R()]}],"block-size":[{block:["auto",...j()]}],"min-block-size":[{"min-block":["auto",...j()]}],"max-block-size":[{"max-block":["none",...j()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,lo,ii]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,$I,II]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ih,mt]}],"font-family":[{font:[DI,FI,e]}],"font-features":[{"font-features":[mt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,gt,mt]}],"line-clamp":[{"line-clamp":[Vt,"none",gt,rg]}],leading:[{leading:[s,...B()]}],"list-image":[{"list-image":["none",gt,mt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",gt,mt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:S()}],"text-color":[{text:S()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ct(),"wavy"]}],"text-decoration-thickness":[{decoration:[Vt,"from-font","auto",gt,ii]}],"text-decoration-color":[{decoration:S()}],"underline-offset":[{"underline-offset":[Vt,"auto",gt,mt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"tab-size":[{tab:[Qr,gt,mt]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",gt,mt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",gt,mt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qr,gt,mt],radial:["",gt,mt],conic:[Qr,gt,mt]},RI,PI]}],"bg-color":[{bg:S()}],"gradient-from-pos":[{from:ht()}],"gradient-via-pos":[{via:ht()}],"gradient-to-pos":[{to:ht()}],"gradient-from":[{from:S()}],"gradient-via":[{via:S()}],"gradient-to":[{to:S()}],rounded:[{rounded:st()}],"rounded-s":[{"rounded-s":st()}],"rounded-e":[{"rounded-e":st()}],"rounded-t":[{"rounded-t":st()}],"rounded-r":[{"rounded-r":st()}],"rounded-b":[{"rounded-b":st()}],"rounded-l":[{"rounded-l":st()}],"rounded-ss":[{"rounded-ss":st()}],"rounded-se":[{"rounded-se":st()}],"rounded-ee":[{"rounded-ee":st()}],"rounded-es":[{"rounded-es":st()}],"rounded-tl":[{"rounded-tl":st()}],"rounded-tr":[{"rounded-tr":st()}],"rounded-br":[{"rounded-br":st()}],"rounded-bl":[{"rounded-bl":st()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ct(),"hidden","none"]}],"divide-style":[{divide:[...ct(),"hidden","none"]}],"border-color":[{border:S()}],"border-color-x":[{"border-x":S()}],"border-color-y":[{"border-y":S()}],"border-color-s":[{"border-s":S()}],"border-color-e":[{"border-e":S()}],"border-color-bs":[{"border-bs":S()}],"border-color-be":[{"border-be":S()}],"border-color-t":[{"border-t":S()}],"border-color-r":[{"border-r":S()}],"border-color-b":[{"border-b":S()}],"border-color-l":[{"border-l":S()}],"divide-color":[{divide:S()}],"outline-style":[{outline:[...ct(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Vt,gt,mt]}],"outline-w":[{outline:["",Vt,lo,ii]}],"outline-color":[{outline:S()}],shadow:[{shadow:["","none",u,Pa,Fa]}],"shadow-color":[{shadow:S()}],"inset-shadow":[{"inset-shadow":["none",d,Pa,Fa]}],"inset-shadow-color":[{"inset-shadow":S()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:S()}],"ring-offset-w":[{"ring-offset":[Vt,ii]}],"ring-offset-color":[{"ring-offset":S()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":S()}],"text-shadow":[{"text-shadow":["none",p,Pa,Fa]}],"text-shadow-color":[{"text-shadow":S()}],opacity:[{opacity:[Vt,gt,mt]}],"mix-blend":[{"mix-blend":[...zt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":zt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":at()}],"mask-image-linear-to-pos":[{"mask-linear-to":at()}],"mask-image-linear-from-color":[{"mask-linear-from":S()}],"mask-image-linear-to-color":[{"mask-linear-to":S()}],"mask-image-t-from-pos":[{"mask-t-from":at()}],"mask-image-t-to-pos":[{"mask-t-to":at()}],"mask-image-t-from-color":[{"mask-t-from":S()}],"mask-image-t-to-color":[{"mask-t-to":S()}],"mask-image-r-from-pos":[{"mask-r-from":at()}],"mask-image-r-to-pos":[{"mask-r-to":at()}],"mask-image-r-from-color":[{"mask-r-from":S()}],"mask-image-r-to-color":[{"mask-r-to":S()}],"mask-image-b-from-pos":[{"mask-b-from":at()}],"mask-image-b-to-pos":[{"mask-b-to":at()}],"mask-image-b-from-color":[{"mask-b-from":S()}],"mask-image-b-to-color":[{"mask-b-to":S()}],"mask-image-l-from-pos":[{"mask-l-from":at()}],"mask-image-l-to-pos":[{"mask-l-to":at()}],"mask-image-l-from-color":[{"mask-l-from":S()}],"mask-image-l-to-color":[{"mask-l-to":S()}],"mask-image-x-from-pos":[{"mask-x-from":at()}],"mask-image-x-to-pos":[{"mask-x-to":at()}],"mask-image-x-from-color":[{"mask-x-from":S()}],"mask-image-x-to-color":[{"mask-x-to":S()}],"mask-image-y-from-pos":[{"mask-y-from":at()}],"mask-image-y-to-pos":[{"mask-y-to":at()}],"mask-image-y-from-color":[{"mask-y-from":S()}],"mask-image-y-to-color":[{"mask-y-to":S()}],"mask-image-radial":[{"mask-radial":[gt,mt]}],"mask-image-radial-from-pos":[{"mask-radial-from":at()}],"mask-image-radial-to-pos":[{"mask-radial-to":at()}],"mask-image-radial-from-color":[{"mask-radial-from":S()}],"mask-image-radial-to-color":[{"mask-radial-to":S()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":at()}],"mask-image-conic-to-pos":[{"mask-conic-to":at()}],"mask-image-conic-from-color":[{"mask-conic-from":S()}],"mask-image-conic-to-color":[{"mask-conic-to":S()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",gt,mt]}],filter:[{filter:["","none",gt,mt]}],blur:[{blur:Z()}],brightness:[{brightness:[Vt,gt,mt]}],contrast:[{contrast:[Vt,gt,mt]}],"drop-shadow":[{"drop-shadow":["","none",f,Pa,Fa]}],"drop-shadow-color":[{"drop-shadow":S()}],grayscale:[{grayscale:["",Vt,gt,mt]}],"hue-rotate":[{"hue-rotate":[Vt,gt,mt]}],invert:[{invert:["",Vt,gt,mt]}],saturate:[{saturate:[Vt,gt,mt]}],sepia:[{sepia:["",Vt,gt,mt]}],"backdrop-filter":[{"backdrop-filter":["","none",gt,mt]}],"backdrop-blur":[{"backdrop-blur":Z()}],"backdrop-brightness":[{"backdrop-brightness":[Vt,gt,mt]}],"backdrop-contrast":[{"backdrop-contrast":[Vt,gt,mt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Vt,gt,mt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Vt,gt,mt]}],"backdrop-invert":[{"backdrop-invert":["",Vt,gt,mt]}],"backdrop-opacity":[{"backdrop-opacity":[Vt,gt,mt]}],"backdrop-saturate":[{"backdrop-saturate":[Vt,gt,mt]}],"backdrop-sepia":[{"backdrop-sepia":["",Vt,gt,mt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",gt,mt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Vt,"initial",gt,mt]}],ease:[{ease:["linear","initial",y,gt,mt]}],delay:[{delay:[Vt,gt,mt]}],animate:[{animate:["none",b,gt,mt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,gt,mt]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:lt()}],"rotate-x":[{"rotate-x":lt()}],"rotate-y":[{"rotate-y":lt()}],"rotate-z":[{"rotate-z":lt()}],scale:[{scale:Ct()}],"scale-x":[{"scale-x":Ct()}],"scale-y":[{"scale-y":Ct()}],"scale-z":[{"scale-z":Ct()}],"scale-3d":["scale-3d"],skew:[{skew:Mt()}],"skew-x":[{"skew-x":Mt()}],"skew-y":[{"skew-y":Mt()}],transform:[{transform:[gt,mt,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Dt()}],"translate-x":[{"translate-x":Dt()}],"translate-y":[{"translate-y":Dt()}],"translate-z":[{"translate-z":Dt()}],"translate-none":["translate-none"],zoom:[{zoom:[Qr,gt,mt]}],accent:[{accent:S()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:S()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",gt,mt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":S()}],"scrollbar-track-color":[{"scrollbar-track":S()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mbs":[{"scroll-mbs":B()}],"scroll-mbe":[{"scroll-mbe":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pbs":[{"scroll-pbs":B()}],"scroll-pbe":[{"scroll-pbe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",gt,mt]}],fill:[{fill:["none",...S()]}],"stroke-w":[{stroke:[Vt,lo,ii,rg]}],stroke:[{stroke:["none",...S()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},qI=CI(WI);function rt(...t){return qI(Nb(t))}const HI=jb("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function nr({className:t,variant:e,...r}){return h.jsx("div",{className:rt(HI({variant:e}),t),...r})}const Ic=C.forwardRef(({className:t,type:e,...r},n)=>h.jsx("input",{type:e,className:rt("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Ic.displayName="Input";var Bf=p_();const UI=Tc(Bf);function sg(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Fc(...t){return e=>{let r=!1;const n=t.map(i=>{const s=sg(i,e);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let i=0;i<n.length;i++){const s=n[i];typeof s=="function"?s():sg(t[i],null)}}}}function Nr(...t){return C.useCallback(Fc(...t),t)}function GI(t){const e=VI(t),r=C.forwardRef((n,i)=>{const{children:s,...o}=n,a=C.Children.toArray(s),l=a.find(XI);if(l){const c=l.props.children,u=a.map(d=>d===l?C.Children.count(c)>1?C.Children.only(null):C.isValidElement(c)?c.props.children:null:d);return h.jsx(e,{...o,ref:i,children:C.isValidElement(c)?C.cloneElement(c,void 0,u):null})}return h.jsx(e,{...o,ref:i,children:s})});return r.displayName=`${t}.Slot`,r}function VI(t){const e=C.forwardRef((r,n)=>{const{children:i,...s}=r;if(C.isValidElement(i)){const o=ZI(i),a=KI(s,i.props);return i.type!==C.Fragment&&(a.ref=n?Fc(n,o):o),C.cloneElement(i,a)}return C.Children.count(i)>1?C.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var YI=Symbol("radix.slottable");function XI(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===YI}function KI(t,e){const r={...e};for(const n in e){const i=t[n],s=e[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...t,...r}}function ZI(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var QI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],br=QI.reduce((t,e)=>{const r=GI(`Primitive.${e}`),n=C.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function JI(t,e){t&&Bf.flushSync(()=>t.dispatchEvent(e))}var Ls=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{};function t3(t,e){return C.useReducer((r,n)=>e[r][n]??r,t)}var Jn=t=>{const{present:e,children:r}=t,n=e3(e),i=typeof r=="function"?r({present:n.isPresent}):C.Children.only(r),s=Nr(n.ref,r3(i));return typeof r=="function"||n.isPresent?C.cloneElement(i,{ref:s}):null};Jn.displayName="Presence";function e3(t){const[e,r]=C.useState(),n=C.useRef(null),i=C.useRef(t),s=C.useRef("none"),o=t?"mounted":"unmounted",[a,l]=t3(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const c=Da(n.current);s.current=a==="mounted"?c:"none"},[a]),Ls(()=>{const c=n.current,u=i.current;if(u!==t){const p=s.current,f=Da(c);t?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,l]),Ls(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=f=>{const x=Da(n.current).includes(CSS.escape(f.animationName));if(f.target===e&&x&&(l("ANIMATION_END"),!i.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},p=f=>{f.target===e&&(s.current=Da(n.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:C.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function Da(t){return(t==null?void 0:t.animationName)||"none"}function r3(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function n3(t,e){const r=C.createContext(e),n=s=>{const{children:o,...a}=s,l=C.useMemo(()=>a,Object.values(a));return h.jsx(r.Provider,{value:l,children:o})};n.displayName=t+"Provider";function i(s){const o=C.useContext(r);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[n,i]}function Hb(t,e=[]){let r=[];function n(s,o){const a=C.createContext(o),l=r.length;r=[...r,o];const c=d=>{var y;const{scope:p,children:f,...m}=d,x=((y=p==null?void 0:p[t])==null?void 0:y[l])||a,g=C.useMemo(()=>m,Object.values(m));return h.jsx(x.Provider,{value:g,children:f})};c.displayName=s+"Provider";function u(d,p){var x;const f=((x=p==null?void 0:p[t])==null?void 0:x[l])||a,m=C.useContext(f);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=r.map(o=>C.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return C.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[n,i3(i,...e)]}function i3(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=n.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return C.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return r.scopeName=e.scopeName,r}function Br(t){const e=C.useRef(t);return C.useEffect(()=>{e.current=t}),C.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}var s3=C.createContext(void 0);function o3(t){const e=C.useContext(s3);return t||e||"ltr"}function a3(t,[e,r]){return Math.min(r,Math.max(e,t))}function ir(t,e,{checkForDefaultPrevented:r=!0}={}){return function(i){if(t==null||t(i),r===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function l3(t,e){return C.useReducer((r,n)=>e[r][n]??r,t)}var Af="ScrollArea",[Ub]=Hb(Af),[c3,Ir]=Ub(Af),Gb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:i,scrollHideDelay:s=600,...o}=t,[a,l]=C.useState(null),[c,u]=C.useState(null),[d,p]=C.useState(null),[f,m]=C.useState(null),[x,g]=C.useState(null),[y,b]=C.useState(0),[k,T]=C.useState(0),[_,w]=C.useState(!1),[E,B]=C.useState(!1),P=Nr(e,M=>l(M)),N=o3(i);return h.jsx(c3,{scope:r,type:n,dir:N,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:d,onContentChange:p,scrollbarX:f,onScrollbarXChange:m,scrollbarXEnabled:_,onScrollbarXEnabledChange:w,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:B,onCornerWidthChange:b,onCornerHeightChange:T,children:h.jsx(br.div,{dir:N,...o,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...t.style}})})});Gb.displayName=Af;var Vb="ScrollAreaViewport",Yb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:i,...s}=t,o=Ir(Vb,r),a=C.useRef(null),l=Nr(e,a,o.onViewportChange);return h.jsxs(h.Fragment,{children:[h.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),h.jsx(br.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t.style},children:h.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Yb.displayName=Vb;var hn="ScrollAreaScrollbar",Mf=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:o}=i,a=t.orientation==="horizontal";return C.useEffect(()=>(a?s(!0):o(!0),()=>{a?s(!1):o(!1)}),[a,s,o]),i.type==="hover"?h.jsx(h3,{...n,ref:e,forceMount:r}):i.type==="scroll"?h.jsx(u3,{...n,ref:e,forceMount:r}):i.type==="auto"?h.jsx(Xb,{...n,ref:e,forceMount:r}):i.type==="always"?h.jsx(If,{...n,ref:e}):null});Mf.displayName=hn;var h3=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),[s,o]=C.useState(!1);return C.useEffect(()=>{const a=i.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),o(!0)},u=()=>{l=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[i.scrollArea,i.scrollHideDelay]),h.jsx(Jn,{present:r||s,children:h.jsx(Xb,{"data-state":s?"visible":"hidden",...n,ref:e})})}),u3=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),s=t.orientation==="horizontal",o=Dc(()=>l("SCROLL_END"),100),[a,l]=l3("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return C.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,i.scrollHideDelay,l]),C.useEffect(()=>{const c=i.viewport,u=s?"scrollLeft":"scrollTop";if(c){let d=c[u];const p=()=>{const f=c[u];d!==f&&(l("SCROLL"),o()),d=f};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[i.viewport,s,l,o]),h.jsx(Jn,{present:r||a!=="hidden",children:h.jsx(If,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:ir(t.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ir(t.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Xb=C.forwardRef((t,e)=>{const r=Ir(hn,t.__scopeScrollArea),{forceMount:n,...i}=t,[s,o]=C.useState(!1),a=t.orientation==="horizontal",l=Dc(()=>{if(r.viewport){const c=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;o(a?c:u)}},10);return Bs(r.viewport,l),Bs(r.content,l),h.jsx(Jn,{present:n||s,children:h.jsx(If,{"data-state":s?"visible":"hidden",...i,ref:e})})}),If=C.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,i=Ir(hn,t.__scopeScrollArea),s=C.useRef(null),o=C.useRef(0),[a,l]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=t1(a.viewport,a.content),u={...n,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:p=>o.current=p};function d(p,f){return x3(p,o.current,a,f)}return r==="horizontal"?h.jsx(d3,{...u,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const p=i.viewport.scrollLeft,f=og(p,a,i.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:p=>{i.viewport&&(i.viewport.scrollLeft=p)},onDragScroll:p=>{i.viewport&&(i.viewport.scrollLeft=d(p,i.dir))}}):r==="vertical"?h.jsx(f3,{...u,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const p=i.viewport.scrollTop,f=og(p,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:p=>{i.viewport&&(i.viewport.scrollTop=p)},onDragScroll:p=>{i.viewport&&(i.viewport.scrollTop=d(p))}}):null}),d3=C.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...i}=t,s=Ir(hn,t.__scopeScrollArea),[o,a]=C.useState(),l=C.useRef(null),c=Nr(e,l,s.onScrollbarXChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),h.jsx(Zb,{"data-orientation":"horizontal",...i,ref:c,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Pc(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.x),onDragScroll:u=>t.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollLeft+u.deltaX;t.onWheelScroll(p),r1(p,d)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Rl(o.paddingLeft),paddingEnd:Rl(o.paddingRight)}})}})}),f3=C.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...i}=t,s=Ir(hn,t.__scopeScrollArea),[o,a]=C.useState(),l=C.useRef(null),c=Nr(e,l,s.onScrollbarYChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),h.jsx(Zb,{"data-orientation":"vertical",...i,ref:c,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Pc(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.y),onDragScroll:u=>t.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollTop+u.deltaY;t.onWheelScroll(p),r1(p,d)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Rl(o.paddingTop),paddingEnd:Rl(o.paddingBottom)}})}})}),[p3,Kb]=Ub(hn),Zb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:i,onThumbChange:s,onThumbPointerUp:o,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:d,...p}=t,f=Ir(hn,r),[m,x]=C.useState(null),g=Nr(e,P=>x(P)),y=C.useRef(null),b=C.useRef(""),k=f.viewport,T=n.content-n.viewport,_=Br(u),w=Br(l),E=Dc(d,10);function B(P){if(y.current){const N=P.clientX-y.current.left,M=P.clientY-y.current.top;c({x:N,y:M})}}return C.useEffect(()=>{const P=N=>{const M=N.target;(m==null?void 0:m.contains(M))&&_(N,T)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[k,m,T,_]),C.useEffect(w,[n,w]),Bs(m,E),Bs(f.content,E),h.jsx(p3,{scope:r,scrollbar:m,hasThumb:i,onThumbChange:Br(s),onThumbPointerUp:Br(o),onThumbPositionChange:w,onThumbPointerDown:Br(a),children:h.jsx(br.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:ir(t.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),B(P))}),onPointerMove:ir(t.onPointerMove,B),onPointerUp:ir(t.onPointerUp,P=>{const N=P.target;N.hasPointerCapture(P.pointerId)&&N.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Ol="ScrollAreaThumb",Qb=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Kb(Ol,t.__scopeScrollArea);return h.jsx(Jn,{present:r||i.hasThumb,children:h.jsx(m3,{ref:e,...n})})}),m3=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...i}=t,s=Ir(Ol,r),o=Kb(Ol,r),{onThumbPositionChange:a}=o,l=Nr(e,d=>o.onThumbChange(d)),c=C.useRef(void 0),u=Dc(()=>{c.current&&(c.current(),c.current=void 0)},100);return C.useEffect(()=>{const d=s.viewport;if(d){const p=()=>{if(u(),!c.current){const f=y3(d,a);c.current=f,a()}};return a(),d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[s.viewport,u,a]),h.jsx(br.div,{"data-state":o.hasThumb?"visible":"hidden",...i,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:ir(t.onPointerDownCapture,d=>{const f=d.target.getBoundingClientRect(),m=d.clientX-f.left,x=d.clientY-f.top;o.onThumbPointerDown({x:m,y:x})}),onPointerUp:ir(t.onPointerUp,o.onThumbPointerUp)})});Qb.displayName=Ol;var Ff="ScrollAreaCorner",Jb=C.forwardRef((t,e)=>{const r=Ir(Ff,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?h.jsx(g3,{...t,ref:e}):null});Jb.displayName=Ff;var g3=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,i=Ir(Ff,r),[s,o]=C.useState(0),[a,l]=C.useState(0),c=!!(s&&a);return Bs(i.scrollbarX,()=>{var d;const u=((d=i.scrollbarX)==null?void 0:d.offsetHeight)||0;i.onCornerHeightChange(u),l(u)}),Bs(i.scrollbarY,()=>{var d;const u=((d=i.scrollbarY)==null?void 0:d.offsetWidth)||0;i.onCornerWidthChange(u),o(u)}),c?h.jsx(br.div,{...n,ref:e,style:{width:s,height:a,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Rl(t){return t?parseInt(t,10):0}function t1(t,e){const r=t/e;return isNaN(r)?0:r}function Pc(t){const e=t1(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function x3(t,e,r,n="ltr"){const i=Pc(r),s=i/2,o=e||s,a=i-o,l=r.scrollbar.paddingStart+o,c=r.scrollbar.size-r.scrollbar.paddingEnd-a,u=r.content-r.viewport,d=n==="ltr"?[0,u]:[u*-1,0];return e1([l,c],d)(t)}function og(t,e,r="ltr"){const n=Pc(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-i,o=e.content-e.viewport,a=s-n,l=r==="ltr"?[0,o]:[o*-1,0],c=a3(t,l);return e1([0,o],[0,a])(c)}function e1(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function r1(t,e){return t>0&&t<e}var y3=(t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return(function i(){const s={left:t.scrollLeft,top:t.scrollTop},o=r.left!==s.left,a=r.top!==s.top;(o||a)&&e(),r=s,n=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(n)};function Dc(t,e){const r=Br(t),n=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),C.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function Bs(t,e){const r=Br(e);Ls(()=>{let n=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return i.observe(t),()=>{window.cancelAnimationFrame(n),i.unobserve(t)}}},[t,r])}var n1=Gb,b3=Yb,C3=Jb;const Hn=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(n1,{ref:n,className:rt("relative overflow-hidden",t),...r,children:[h.jsx(b3,{className:"h-full w-full rounded-[inherit]",children:e}),h.jsx(i1,{}),h.jsx(C3,{})]}));Hn.displayName=n1.displayName;const i1=C.forwardRef(({className:t,orientation:e="vertical",...r},n)=>h.jsx(Mf,{ref:n,orientation:e,className:rt("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:h.jsx(Qb,{className:"relative flex-1 rounded-full bg-border"})}));i1.displayName=Mf.displayName;var k3=Symbol.for("react.lazy"),$l=tf[" use ".trim().toString()];function v3(t){return typeof t=="object"&&t!==null&&"then"in t}function s1(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===k3&&"_payload"in t&&v3(t._payload)}function o1(t){const e=S3(t),r=C.forwardRef((n,i)=>{let{children:s,...o}=n;s1(s)&&typeof $l=="function"&&(s=$l(s._payload));const a=C.Children.toArray(s),l=a.find(_3);if(l){const c=l.props.children,u=a.map(d=>d===l?C.Children.count(c)>1?C.Children.only(null):C.isValidElement(c)?c.props.children:null:d);return h.jsx(e,{...o,ref:i,children:C.isValidElement(c)?C.cloneElement(c,void 0,u):null})}return h.jsx(e,{...o,ref:i,children:s})});return r.displayName=`${t}.Slot`,r}var w3=o1("Slot");function S3(t){const e=C.forwardRef((r,n)=>{let{children:i,...s}=r;if(s1(i)&&typeof $l=="function"&&(i=$l(i._payload)),C.isValidElement(i)){const o=N3(i),a=E3(s,i.props);return i.type!==C.Fragment&&(a.ref=n?Fc(n,o):o),C.cloneElement(i,a)}return C.Children.count(i)>1?C.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var T3=Symbol("radix.slottable");function _3(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===T3}function E3(t,e){const r={...e};for(const n in e){const i=t[n],s=e[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...t,...r}}function N3(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var j3=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],L3=j3.reduce((t,e)=>{const r=o1(`Primitive.${e}`),n=C.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{}),B3="Separator",ag="horizontal",A3=["horizontal","vertical"],a1=C.forwardRef((t,e)=>{const{decorative:r,orientation:n=ag,...i}=t,s=M3(n)?n:ag,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return h.jsx(L3.div,{"data-orientation":s,...a,...i,ref:e})});a1.displayName=B3;function M3(t){return A3.includes(t)}var l1=a1;const zl=C.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},i)=>h.jsx(l1,{ref:i,decorative:r,orientation:e,className:rt("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));zl.displayName=l1.displayName;function I3({agentId:t,status:e}){const[r,n]=C.useState(""),[i,s]=C.useState(""),o=C.useRef(null),a=C.useRef(!1),l=C.useCallback(()=>{const d=o.current;d&&(a.current=d.scrollTop+d.clientHeight<d.scrollHeight-20)},[]);C.useEffect(()=>{const d=o.current;d&&!a.current&&(d.scrollTop=d.scrollHeight)},[r,i]),C.useEffect(()=>{if(!t)return;const d=async()=>{try{const p=await Rt(`/api/agent/${t}`);if(!p.ok)return;const f=await p.json();f.output!=null&&n(f.output),f.stderr!=null&&s(f.stderr)}catch{}};if(d(),e==="running"){const p=setInterval(d,2e3);return()=>clearInterval(p)}},[t,e]);const c=!r&&!i,u=e==="running";return h.jsx("div",{children:h.jsx("div",{ref:o,onScroll:l,className:"overflow-auto max-h-[300px] rounded bg-muted/30 p-2",children:c?h.jsx("p",{className:"text-[10px] font-mono text-muted-foreground italic",children:u?"Waiting for output...":"No output"}):h.jsxs(h.Fragment,{children:[r&&h.jsx("pre",{className:"text-[10px] font-mono text-muted-foreground whitespace-pre-wrap break-all m-0",children:r}),i&&h.jsxs("div",{className:"mt-2",children:[h.jsx("span",{className:"text-[10px] font-mono font-medium text-destructive",children:"stderr"}),h.jsx("pre",{className:"text-[10px] font-mono text-destructive whitespace-pre-wrap break-all m-0 mt-0.5",children:i})]})]})})})}const F3=Yt.memo(I3);function P3(t){if(!t)return"";const e=Math.floor((Date.now()-new Date(t).getTime())/1e3);return e<5?"now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}function D3({agentId:t,relays:e}){const r=C.useMemo(()=>!e||!t?[]:e.filter(n=>n.fromAgentId===t||n.toAgentId===t),[e,t]);return r.length===0?null:h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Relays"}),h.jsx("div",{className:"space-y-0.5",children:r.map((n,i)=>{const s=n.direction==="result";return h.jsxs("div",{className:"flex items-start gap-1 text-[10px] font-mono",children:[h.jsx("span",{className:s?"text-foreground shrink-0":"text-muted-foreground shrink-0",children:s?"→":"←"}),h.jsx("span",{className:s?"text-foreground truncate":"text-muted-foreground truncate",title:n.messagePreview,children:n.messagePreview}),h.jsx("span",{className:"text-muted-foreground opacity-50 ml-auto shrink-0 tabular-nums",children:P3(n.timestamp)})]},n.id||i)})})]})}const O3=Yt.memo(D3),R3={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking"},lg={build_error:"Build",test_failure:"Test",lint_error:"Lint",git_conflict:"Conflict",permission_error:"Permission",not_found:"Not Found",runtime_error:"Error"};function Fh(t){if(!t||t<1e3)return"<1s";const e=Math.floor(t/1e3);return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}const $3=Yt.memo(function({startedAt:e,active:r,duration:n}){const[,i]=Yt.useState(0);Yt.useEffect(()=>{if(!r)return;const l=setInterval(()=>i(c=>c+1),1e3);return()=>clearInterval(l)},[r]);const s=r?Math.floor((Date.now()-new Date(e).getTime())/1e3):n||0,o=Math.floor(s/60),a=s%60;return h.jsxs("span",{className:"tabular-nums",children:[o,"m ",String(a).padStart(2,"0"),"s"]})});function z3({agentActivity:t,agentErrors:e,sessionState:r,onSelectItem:n,spawnedAgents:i,agentRelays:s,onStopAgent:o}){var x,g,y,b;const[a,l]=Yt.useState(null),[c,u]=Yt.useState({status:"idle",tool:null,category:null,activityLog:[],currentActivity:null}),[,d]=Yt.useState(0),[p,f]=Yt.useState([]),m=Yt.useRef(null);return Yt.useEffect(()=>{const k=T=>u(T.detail);return window.addEventListener("compose:agent-status",k),()=>window.removeEventListener("compose:agent-status",k)},[]),Yt.useEffect(()=>{if(c.status!=="working")return;const k=setInterval(()=>d(T=>T+1),1e3);return()=>clearInterval(k)},[c.status]),Yt.useEffect(()=>{if(!t||t.length===0)return;const k=t[t.length-1];Array.isArray(k.items)&&k.items.length>0&&(f(k.items),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>f([]),3e4))},[t]),Yt.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.jsxs(h.Fragment,{children:[i&&i.length>0&&h.jsxs("div",{className:"flex items-center gap-0.5 mb-1.5 overflow-x-auto px-3",children:[h.jsx("button",{onClick:()=>l(null),className:rt("text-[10px] px-2 py-0.5 rounded cursor-pointer transition-colors border shrink-0",a?"bg-transparent text-muted-foreground border-border hover:text-foreground":"bg-primary text-primary-foreground border-primary"),children:"Session"}),i.map(k=>h.jsxs("span",{className:"flex items-center gap-0 shrink-0",children:[h.jsxs("button",{onClick:()=>l(k.agentId),className:rt("text-[10px] px-2 py-0.5 rounded-l cursor-pointer transition-colors border flex items-center gap-1 shrink-0",a===k.agentId?"bg-primary text-primary-foreground border-primary":"bg-transparent text-muted-foreground border-border hover:text-foreground"),children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:k.status==="killed"?"hsl(var(--destructive))":k.silent?"hsl(45 93% 47%)":k.status==="running"?"hsl(var(--success))":k.status==="complete"?"hsl(142 71% 45%)":"hsl(var(--destructive))",animation:k.status==="running"&&!k.silent?"phase-active-pulse 2s ease-in-out infinite":"none"}}),k.agentType,k.silent&&h.jsx("span",{className:"text-[8px] text-yellow-500 ml-0.5",title:"Agent silent",children:"!"})]}),k.status==="running"&&o&&h.jsx("button",{onClick:T=>{T.stopPropagation(),o(k.agentId)},className:"text-[10px] px-1 py-0.5 rounded-r border border-l-0 border-border hover:bg-destructive/20 hover:text-destructive cursor-pointer transition-colors",title:"Stop agent",children:"x"})]},k.agentId))]}),a?h.jsxs("div",{className:"px-3 pb-2 space-y-2",children:[h.jsx(F3,{agentId:a,status:(x=i.find(k=>k.agentId===a))==null?void 0:x.status}),h.jsx(O3,{agentId:a,relays:s})]}):h.jsxs(h.Fragment,{children:[(r==null?void 0:r.featureCode)&&h.jsxs("div",{className:"px-3 py-1.5 mb-1 rounded bg-muted/50",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Working on"}),h.jsx("button",{className:"font-medium text-foreground hover:underline",onClick:()=>r.featureItemId&&(n==null?void 0:n(r.featureItemId)),children:r.featureCode})]}),r.phaseAtBind&&h.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Phase: ",r.phaseAtBind.replace(/_/g," ")]})]}),r&&h.jsxs("div",{className:"px-3 pb-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:r.active?"hsl(var(--primary))":"hsl(var(--success))"}}),h.jsx($3,{startedAt:r.startedAt,active:r.active,duration:r.duration}),h.jsxs("span",{className:"tabular-nums",children:[r.toolCount||0," tools"]}),r.errorCount>0&&h.jsxs("span",{style:{color:"hsl(var(--destructive))"},children:[r.errorCount," err"]}),!r.active&&r.journalSpawned&&h.jsx("span",{style:{color:"hsl(var(--primary))"},children:"journal"})]}),((g=r.summaries)==null?void 0:g.length)>0&&h.jsx("p",{className:"text-[10px] mt-0.5 truncate",style:{color:"hsl(var(--muted-foreground))",opacity:.7},title:(y=r.summaries[r.summaries.length-1])==null?void 0:y.summary,children:(b=r.summaries[r.summaries.length-1])==null?void 0:b.summary})]}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("div",{className:"rounded-md p-2",style:{background:"hsl(var(--accent))"},children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:c.status==="working"?"var(--color-category-writing)":"hsl(var(--success))",animation:c.status==="working"?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider",style:{color:c.status==="working"?"var(--color-category-writing)":"hsl(var(--muted-foreground))"},children:c.status==="working"?R3[c.category]||"Working":"Idle"}),c.status==="working"&&c.tool&&h.jsx("span",{className:"text-[10px] tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:c.tool}),c.status==="working"&&c.currentActivity&&h.jsx("span",{className:"text-[10px] tabular-nums ml-auto",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:Fh(Date.now()-c.currentActivity.startTime)})]}),c.activityLog&&c.activityLog.length>0&&h.jsx("div",{className:"flex items-center gap-0.5 mt-1",children:c.activityLog.slice(-6).map((k,T,_)=>h.jsx("div",{className:"h-1 rounded-full",title:`${k.tool||"thinking"} — ${Fh(k.duration)}`,style:{width:Math.max(4,Math.min(16,(k.duration||0)/1e3*2)),background:Kp[k.category]||(c.status==="working"?"var(--color-category-writing)":"hsl(var(--success))"),opacity:.2+T/_.length*.6}},T))}),t&&t.length>0&&h.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.slice(-4).map((k,T)=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px]",style:{color:k.error?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"},children:[k.error&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"font-medium shrink-0",children:k.tool}),k.category&&!k.error&&h.jsx("span",{className:"shrink-0 opacity-50",style:{color:Kp[k.category]},children:k.category}),k.error?h.jsx("span",{className:"truncate",title:k.error.type,children:lg[k.error.type]||k.error.type}):k.detail?h.jsx("span",{className:"truncate opacity-60",title:k.detail,children:k.detail.split("/").pop()}):null]},T))}),p.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Working on"}),p.slice(0,3).map(k=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{children:k.status==="in_progress"?"◆":"◇"}),h.jsx("span",{className:"truncate",children:k.title})]},k.id))]}),e&&e.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--destructive))"},children:"Errors"}),e.slice(-3).map((k,T)=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px] py-0.5",style:{color:"hsl(var(--destructive))"},children:[h.jsx("span",{className:"font-medium shrink-0",children:lg[k.errorType]||k.errorType}),h.jsx("span",{className:"truncate opacity-70",title:k.message,children:k.message})]},T))]}),i&&i.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Subagents"}),i.map(k=>h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:k.status==="running"?"var(--color-category-executing)":k.status==="complete"?"hsl(var(--success))":"hsl(var(--destructive))",animation:k.status==="running"?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"font-medium shrink-0",children:k.agentType}),h.jsx("span",{className:"truncate opacity-60",children:k.status}),h.jsx("span",{className:"tabular-nums ml-auto opacity-50",children:Fh(Date.now()-new Date(k.startedAt).getTime())})]},k.agentId))]})]})})]})]})}const W3=Yt.memo(z3),Do={DECISION:1,PENDING_GATE:2,BLOCKED:3};function c1(t,e){const r=new Set((e||[]).filter(s=>s.status==="pending").map(s=>s.itemId)),n=new Map,i=(s,o,a)=>{const l=n.get(s.id);(!l||o>l.priority)&&n.set(s.id,{item:s,priority:o,reason:a})};for(const s of t||[])s.status==="blocked"&&i(s,Do.BLOCKED,"Blocked"),r.has(s.id)&&i(s,Do.PENDING_GATE,"Pending gate"),s.type==="decision"&&s.status!=="complete"&&s.status!=="killed"&&s.status!=="parked"&&i(s,Do.DECISION,"Open decision");return Array.from(n.values()).sort((s,o)=>o.priority-s.priority)}function q3(t){if(!t)return{isRunning:!1,pct:0,stepLabel:"",featureCode:"",stepNum:0,totalSteps:0,status:""};const{currentStepId:e,stepNum:r,totalSteps:n,status:i,featureCode:s}=t,o=i==="running",a=n>0?r/n*100:0,l=Math.min(100,Math.max(0,Math.round(a))),c=e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g," "):"";return{isRunning:o,pct:l,stepLabel:c,featureCode:s||"",stepNum:r??0,totalSteps:n??0,status:i||""}}function h1(t,e){const r=t||[],n=e||[];let i=0,s=0,o=0;for(const l of r)l.status==="in_progress"&&i++,l.status==="blocked"&&s++;const a=n.filter(l=>l.status==="pending"||l.status==="awaiting").length;return o=c1(r,n).length,{total:r.length,inProgress:i,blocked:s,pendingGates:a,attentionCount:o}}function H3(t,e){return t&&t===e?null:e}const U3={planned:{bg:"bg-slate-500/15",text:"text-slate-400",dot:"bg-slate-400"},ready:{bg:"bg-sky-500/15",text:"text-sky-400",dot:"bg-sky-400"},in_progress:{bg:"bg-blue-500/15",text:"text-blue-400",dot:"bg-blue-400"},review:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"},complete:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},blocked:{bg:"bg-rose-500/15",text:"text-rose-400",dot:"bg-rose-400"},parked:{bg:"bg-slate-500/15",text:"text-slate-500",dot:"bg-slate-500"},killed:{bg:"bg-slate-500/15",text:"text-slate-600",dot:"bg-slate-600"},pending:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"},resolved:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},active:{bg:"bg-blue-500/15",text:"text-blue-400",dot:"bg-blue-400"},completed:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},failed:{bg:"bg-rose-500/15",text:"text-rose-400",dot:"bg-rose-400"},paused:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"}},G3={bg:"bg-slate-500/10",text:"text-slate-400",dot:"bg-slate-400"};function Pf({status:t,className:e}){const r=U3[t]||G3,n=t?t.replace(/_/g," "):"—";return h.jsxs("span",{className:rt("inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium",r.bg,r.text,e),children:[h.jsx("span",{className:rt("w-1 h-1 rounded-full shrink-0",r.dot)}),n]})}const V3={vision:"text-violet-400 bg-violet-500/10 border-violet-500/20",specification:"text-purple-400 bg-purple-500/10 border-purple-500/20",planning:"text-cyan-400 bg-cyan-500/10 border-cyan-500/20",implementation:"text-amber-400 bg-amber-500/10 border-amber-500/20",verification:"text-emerald-400 bg-emerald-500/10 border-emerald-500/20",release:"text-green-400 bg-green-500/10 border-green-500/20"},Y3="text-slate-400 bg-slate-500/10 border-slate-500/20";function X3({phase:t,className:e}){const r=V3[t]||Y3;return h.jsx("span",{className:rt("inline-flex items-center px-2 py-0.5 rounded-full border text-xs font-mono",r,e),children:t||"—"})}async function An(t,e={}){const r=await Rt(t,e),n=await r.json();if(!r.ok)throw new Error(n.error||`HTTP ${r.status}`);return n}let Ph=null;function u1(t){if(Ph)return;const e=window.location.protocol==="https:"?"wss:":"ws:",r=new WebSocket(`${e}//${window.location.host}/ws/vision`);Ph=r,r.onmessage=n=>{try{const i=JSON.parse(n.data);i.type==="ideaboxUpdated"&&t(i)}catch{}},r.onclose=()=>{Ph=null,setTimeout(()=>{u1(t)},3e3)},r.onerror=()=>{}}const As=Nf((t,e)=>(setTimeout(()=>e().hydrate(),0),setTimeout(()=>{u1(()=>{e().hydrate()})},500),{ideas:[],killed:[],loading:!1,error:null,selectedIdeaId:null,filters:{tag:"",status:"",priority:"",search:""},hydrate:async()=>{t({loading:!0,error:null});try{const r=await An("/api/ideabox");t({ideas:r.ideas||[],killed:r.killed||[],loading:!1})}catch(r){t({error:r.message,loading:!1})}},addIdea:async r=>{const n=await An("/api/ideabox/ideas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});return await e().hydrate(),n},promoteIdea:async(r,n="")=>{const i=await An(`/api/ideabox/ideas/${r}/promote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({featureCode:n})});return await e().hydrate(),i},killIdea:async(r,n="")=>{const i=await An(`/api/ideabox/ideas/${r}/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:n})});return await e().hydrate(),i},setPriority:async(r,n)=>{const i=await An(`/api/ideabox/ideas/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:n})});return t(s=>({ideas:s.ideas.map(o=>o.id===r?{...o,priority:n}:o)})),i},resurrectIdea:async r=>{const n=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}/resurrect`,{method:"POST"});return await e().hydrate(),n},addDiscussion:async(r,n,i)=>{const s=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}/discuss`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({author:n,text:i})});return await e().hydrate(),s},updateIdea:async(r,n)=>{const i=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e().hydrate(),i},setSelectedIdea:r=>t({selectedIdeaId:r}),updateFilters:r=>t(n=>({filters:{...n.filters,...r}})),clearFilters:()=>t({filters:{tag:"",status:"",priority:"",search:""}})}));function K3({activeBuild:t}){const e=q3(t);if(!t)return null;const r=e.isRunning?"hsl(var(--primary))":e.status==="complete"?"hsl(var(--success))":e.status==="failed"||e.status==="killed"?"hsl(var(--destructive))":"hsl(var(--muted-foreground))";return h.jsxs("div",{className:"mx-3 mb-2 rounded-md p-2",style:{background:"hsl(var(--accent))"},children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Pl,{className:"h-3 w-3 shrink-0",style:{color:r}}),h.jsx("span",{className:"text-[10px] font-medium truncate max-w-[100px]",style:{color:"hsl(var(--foreground))"},children:e.featureCode||"Build"})]}),h.jsxs("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))"},children:[e.stepNum,"/",e.totalSteps]})]}),h.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${e.pct}%`,background:r}})}),h.jsxs("div",{className:"flex items-center justify-between mt-1",children:[h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:e.stepLabel}),e.isRunning&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--primary))",animation:"pulse 1.5s ease-in-out infinite"}})]})]})}function Z3({items:t,gates:e,onSelectItem:r,onViewChange:n}){const i=Yt.useMemo(()=>c1(t,e),[t,e]);if(i.length===0)return null;const s=i.slice(0,5),o=i.length-s.length,a=l=>l===Do.BLOCKED?h.jsx(Ac,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--destructive))"}}):l===Do.PENDING_GATE?h.jsx(AM,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--warning))"}}):h.jsx(IA,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--muted-foreground))"}});return h.jsxs("div",{className:"px-2 mb-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Needs Attention"}),s.map(({item:l,priority:c,reason:u})=>h.jsxs("button",{onClick:()=>r==null?void 0:r(l.id),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))"},title:u,children:[a(c),h.jsx("span",{className:"truncate flex-1 text-left",children:l.title}),l.phase&&h.jsx(X3,{phase:l.phase,className:"shrink-0 text-[9px] px-1.5 py-0 h-4"}),h.jsx(Pf,{status:l.status,className:"shrink-0"})]},l.id)),o>0&&h.jsxs("button",{onClick:()=>n==null?void 0:n("attention"),className:"flex w-full items-center px-2 py-0.5 text-[10px] rounded-md hover:bg-sidebar-accent/50 transition-colors",style:{color:"hsl(var(--muted-foreground))"},children:["+",o," more"]})]})}function Q3({items:t,gates:e}){const r=Yt.useMemo(()=>h1(t,e),[t,e]);return r.total===0?null:h.jsxs("div",{className:"flex items-center gap-2 flex-wrap px-3 pb-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.total," items"]}),r.inProgress>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--primary))"},children:[r.inProgress," active"]}),r.blocked>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--destructive))"},children:[r.blocked," blocked"]}),r.pendingGates>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--warning))"},children:[r.pendingGates," ",r.pendingGates===1?"gate":"gates"]})]})}const J3=new Set(["planned","ready","in_progress","review","blocked","parked"]);function tF({items:t,hiddenGroups:e,onToggleGroup:r}){const n=Yt.useMemo(()=>{const i={},s={};for(const o of t){const a=o.title||"";if(a.startsWith("`docs/")||a.startsWith("docs/")||!J3.has(o.status))continue;const l=o.group||"other";i[l]=(i[l]||0)+1,["in_progress","review","ready"].includes(o.status)&&(s[l]=(s[l]||0)+1)}return Object.entries(i).sort((o,a)=>(s[a[0]]||0)-(s[o[0]]||0)||a[1]-o[1]||o[0].localeCompare(a[0])).map(([o,a])=>({group:o,count:a,active:s[o]||0}))},[t]);return n.length<=1?null:h.jsx(h.Fragment,{children:n.map(({group:i,count:s,active:o})=>{const a=e==null?void 0:e.has(i);return h.jsxs("button",{onClick:()=>r==null?void 0:r(i),className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))",opacity:a?.4:1,fontWeight:o>0?500:400},children:[h.jsx("span",{className:"truncate flex-1 text-left",children:i}),o>0&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--primary))"},children:o}),h.jsx("span",{className:"text-[10px] tabular-nums shrink-0",style:{color:"hsl(var(--muted-foreground))"},children:s})]},i)})})}function eF({onViewChange:t}){const e=As(n=>n.ideas),r=Yt.useMemo(()=>e.filter(n=>!n.priority||n.priority==="—").length,[e]);return r===0?null:h.jsxs("div",{className:"px-2 mb-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Ideas"}),h.jsxs("button",{onClick:()=>t==null?void 0:t("ideabox"),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))"},title:"View untriaged ideas",children:[h.jsx(xi,{className:"h-3 w-3 shrink-0 text-amber-400"}),h.jsxs("span",{className:"flex-1 text-left",children:[r," untriaged"]})]})]})}function d1({items:t,gates:e,activeBuild:r,onViewChange:n,selectedPhase:i,onPhaseSelect:s,selectedTrack:o,onTrackSelect:a,visibleTracks:l,onToggleVisibleTrack:c,onShowAllTracks:u,hiddenGroups:d,onToggleGroup:p,searchQuery:f,onSearchChange:m,connected:x,agentActivity:g,agentErrors:y,spawnedAgents:b,agentRelays:k,sessionState:T,onSelectItem:_,onStopAgent:w,onThemeChange:E,onNewItem:B,widthPx:P}){const N=t||[],M=e||[],$=Yt.useMemo(()=>h1(N,M),[N,M]),[q,O]=Yt.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));Yt.useEffect(()=>{if(typeof document>"u")return;const A=new MutationObserver(()=>{O(document.documentElement.classList.contains("dark"))});return A.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>A.disconnect()},[]);const I=Yt.useCallback(()=>{const A=!q,D=A?"dark":"light";typeof document<"u"&&document.documentElement.classList.toggle("dark",A);try{localStorage.setItem("compose:theme",D)}catch{}E&&E({ui:{theme:D}})},[q,E]);return Yt.useCallback(A=>{s&&s(H3(i,A))},[s,i]),h.jsxs("aside",{className:"shrink-0 flex flex-col bg-sidebar border-r border-sidebar-border",style:{width:P??208},children:[h.jsxs("div",{className:"p-3 pb-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:"Compose"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[!x&&h.jsx("span",{className:"text-[10px] text-destructive",children:"disconnected"}),B&&h.jsx("button",{onClick:B,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-sidebar-accent transition-colors",title:"New item (⌘N)",children:h.jsx(Tb,{className:"h-3.5 w-3.5"})}),h.jsx("button",{onClick:I,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-sidebar-accent transition-colors",title:q?"Switch to light mode":"Switch to dark mode",children:q?h.jsx(OM,{className:"h-3.5 w-3.5"}):h.jsx(CM,{className:"h-3.5 w-3.5"})})]})]}),h.jsx(Q3,{items:N,gates:M})]}),h.jsx(K3,{activeBuild:r}),h.jsx(W3,{agentActivity:g,agentErrors:y,sessionState:T,onSelectItem:_,onStopAgent:w,spawnedAgents:b,agentRelays:k}),$.attentionCount>0&&h.jsxs(h.Fragment,{children:[h.jsx(zl,{className:"bg-sidebar-border"}),h.jsx(Z3,{items:N,gates:M,onSelectItem:_,onViewChange:n})]}),h.jsx(eF,{onViewChange:n}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),h.jsx(Ic,{placeholder:"Search...",value:f,onChange:A=>m(A.target.value),className:"h-7 pl-7 text-xs bg-sidebar"})]})}),h.jsx(zl,{className:"bg-sidebar-border"}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Groups"}),h.jsx(tF,{items:N,hiddenGroups:d,onToggleGroup:p})]})})]})}function rF({level:t,size:e=4}){return h.jsx("div",{className:"flex items-center gap-px",children:[0,1,2,3].map(r=>h.jsx("div",{className:"rounded-full",style:{width:e,height:e,background:r<t?t>=3?"hsl(var(--success))":t>=2?"hsl(var(--accent))":"hsl(var(--destructive))":"transparent",border:`1px solid ${r<t?t>=3?"hsl(var(--success))":t>=2?"hsl(var(--accent))":"hsl(var(--destructive))":"hsl(var(--border))"}`}},r))})}function pa({featureCode:t,active:e,onToggle:r}){return t?h.jsxs("button",{onClick:r,style:{fontSize:11,padding:"3px 9px",borderRadius:4,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${e?"#f59e0b":"#334155"}`,background:e?"#f59e0b20":"#1e293b",color:e?"#f59e0b":"#94a3b8"},children:["Focus: ",t]}):null}const cg=[{key:"all",label:"All",statuses:null},{key:"active",label:"Active",statuses:["planned","ready","in_progress","review"]},{key:"done",label:"Done",statuses:["complete"]},{key:"blocked",label:"Blocked",statuses:["blocked","parked"]}],nF=[{key:"all",label:"All"},{key:"feature",label:"Feature"},{key:"task",label:"Task"},{key:"track",label:"Track"}];function hg({active:t,onClick:e,children:r}){return h.jsx("button",{onClick:e,style:{fontSize:11,padding:"2px 7px",borderRadius:4,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${t?"#3b82f6":"#334155"}`,background:t?"#3b82f6":"#1e293b",color:t?"#fff":"#94a3b8"},children:r})}function f1({item:t,children:e,depth:r,selectedItemId:n,onSelect:i,onToggle:s,expandedIds:o}){const a=e.length>0,l=o.has(t.id),c=n===t.id,u=xr[t.type]||xr.task,d=qn[t.status]||qn.planned,{newIds:p,changedIds:f}=C.useContext(Mc),m=p.has(t.id),x=f.has(t.id);return h.jsxs("div",{children:[h.jsxs("div",{"data-item-id":t.id,onClick:()=>i(t.id),className:rt("flex items-center gap-1.5 py-1 px-2 cursor-pointer transition-colors rounded-md","hover:bg-accent/5",c&&"bg-accent/10",m&&"bg-green-500/5 border-l-2 border-l-green-500",x&&!m&&"bg-amber-500/5 border-l-2 border-l-amber-500"),style:{paddingLeft:`${r*20+8}px`},children:[h.jsx("button",{onClick:g=>{g.stopPropagation(),a&&s(t.id)},className:rt("shrink-0 w-4 h-4 flex items-center justify-center rounded",a?"text-muted-foreground hover:text-foreground":"invisible"),children:a&&(l?h.jsx(fa,{className:"h-3.5 w-3.5"}):h.jsx(js,{className:"h-3.5 w-3.5"}))}),h.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:d}}),h.jsx("span",{className:"text-[9px] uppercase tracking-wider shrink-0 w-12",style:{color:u},children:t.type}),h.jsx("span",{className:rt("text-sm text-foreground truncate flex-1",t.status==="killed"&&"line-through opacity-50"),children:t.title}),h.jsx(rF,{level:t.confidence||0}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-3.5 shrink-0",children:t.phase})]}),a&&l&&h.jsx("div",{children:e.map(g=>h.jsx(f1,{item:g,children:g._children||[],depth:r+1,selectedItemId:n,onSelect:i,onToggle:s,expandedIds:o},g.id))})]})}function p1({items:t,connections:e,selectedItemId:r,onSelect:n,onCreate:i,featureCode:s,focusActive:o,onToggleFocus:a}){const[l,c]=C.useState(()=>new Set),[u,d]=C.useState(""),[p,f]=C.useState("all"),[m,x]=C.useState("all"),g=C.useCallback(_=>{c(w=>{const E=new Set(w);return E.has(_)?E.delete(_):E.add(_),E})},[]),y=C.useMemo(()=>{let _=t;const w=cg.find(E=>E.key===p);if(w!=null&&w.statuses&&(_=_.filter(E=>w.statuses.includes(E.status||"planned"))),m!=="all"&&(_=_.filter(E=>E.type===m)),u){const E=u.toLowerCase();_=_.filter(B=>(B.title||"").toLowerCase().includes(E)||(B.description||"").toLowerCase().includes(E)||(B.type||"").toLowerCase().includes(E)||(B.phase||"").toLowerCase().includes(E))}return o&&s&&(_=_.filter(E=>{var B;return E.featureCode===s||((B=E.lifecycle)==null?void 0:B.featureCode)===s||(E.title||"").includes(s)})),_},[t,u,p,m,o,s]),b=C.useMemo(()=>{const _=new Set(y.map(N=>N.id)),w=new Map;for(const N of y)w.set(N.id,{...N,_children:[]});const E=new Map;for(const N of e)!_.has(N.fromId)||!_.has(N.toId)||(N.type==="informs"?E.has(N.toId)||E.set(N.toId,N.fromId):(N.type==="supports"||N.type==="blocks")&&(E.has(N.fromId)||E.set(N.fromId,N.toId)));for(const N of t)N.parentId&&w.has(N.parentId)&&E.set(N.id,N.parentId);for(const[N]of E){const M=new Set;let $=N;for(;$&&E.has($);){if(M.has($)){E.delete($);break}M.add($),$=E.get($)}}const B=[];for(const N of w.values()){const M=E.get(N.id);M&&w.has(M)?w.get(M)._children.push(N):B.push(N)}const P=N=>{N.sort((M,$)=>(M.confidence||0)-($.confidence||0));for(const M of N)M._children.length>0&&P(M._children)};return P(B),B},[y,e]);Yt.useEffect(()=>{if(u){const _=new Set,w=E=>{for(const B of E)B._children.length>0&&(_.add(B.id),w(B._children))};w(b),c(_)}else l.size===0&&b.length>0&&c(new Set(b.map(_=>_.id)))},[b,u]),Yt.useEffect(()=>{if(!r||b.length===0)return;const _=[],w=(E,B)=>{for(const P of E){if(P.id===B)return!0;if(P._children.length>0&&w(P._children,B))return _.push(P.id),!0}return!1};w(b,r),_.length>0&&c(E=>{const B=new Set(E);for(const P of _)B.add(P);return B}),requestAnimationFrame(()=>{const E=document.querySelector(`[data-item-id="${r}"]`);E&&E.scrollIntoView({block:"center",behavior:"smooth"})})},[r,b]);const k=C.useCallback(()=>{const _=new Set,w=E=>{for(const B of E)B._children.length>0&&(_.add(B.id),w(B._children))};w(b),c(_)},[b]),T=C.useCallback(()=>{c(new Set)},[]);return b.filter(_=>_._children.length>0).length,h.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[h.jsx(pa,{featureCode:s,active:o,onToggle:a}),h.jsxs("div",{className:"relative flex-1 max-w-[180px]",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),h.jsx(Ic,{placeholder:"Search items...",value:u,onChange:_=>d(_.target.value),className:"h-7 pl-7 pr-7 text-xs"}),u&&h.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:h.jsx(cn,{className:"h-3 w-3"})})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground mr-0.5",children:"Status:"}),cg.map(_=>h.jsx(hg,{active:p===_.key,onClick:()=>f(_.key),children:_.label},_.key))]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground mr-0.5",children:"Type:"}),nF.map(_=>h.jsx(hg,{active:m===_.key,onClick:()=>x(_.key),children:_.label},_.key))]}),h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[y.length,u||p!=="all"||m!=="all"?`/${t.length}`:""]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:k,className:"text-[10px] px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent/10 transition-colors",children:"Expand"}),h.jsx("button",{onClick:T,className:"text-[10px] px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent/10 transition-colors",children:"Collapse"}),i&&h.jsx("button",{onClick:i,title:"Create item",style:{width:24,height:24,borderRadius:4,border:"1px solid #334155",background:"#1e293b",color:"#94a3b8",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s"},className:"hover:border-blue-500 hover:text-white",children:h.jsx(Tb,{className:"h-3.5 w-3.5"})})]}),h.jsx(Hn,{className:"flex-1",children:h.jsx("div",{className:"py-1",children:b.length===0?h.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No items to display"}):b.map(_=>h.jsx(f1,{item:_,children:_._children,depth:0,selectedItemId:r,onSelect:n,onToggle:g,expandedIds:l},_.id))})})]})}try{la.use(ry)}catch{}try{la.use(g_)}catch{}const Wl={planned:"#64748b",ready:"#3b82f6",in_progress:"#fbbf24",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#6b7280",killed:"#475569"},iF=Object.fromEntries(Object.entries(xr).map(([t,e])=>{const r=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16),s=[15,23,42],o=.15,a=[Math.round(s[0]*(1-o)+r*o),Math.round(s[1]*(1-o)+n*o),Math.round(s[2]*(1-o)+i*o)];return[t,`#${a.map(l=>l.toString(16).padStart(2,"0")).join("")}`]})),sF=[1,1.5,2,2.5,3],Wu={informs:{color:"#64748b",style:"solid"},supports:{color:"#22c55e",style:"solid"},blocks:{color:"#ef4444",style:"solid"},contradicts:{color:"#f472b6",style:"dashed"},implements:{color:"#a78bfa",style:"solid"}},ug=[{key:"all",label:"All",statuses:null},{key:"active",label:"Active",statuses:["planned","ready","in_progress","review"]},{key:"complete",label:"Done",statuses:["complete"]},{key:"blocked",label:"Blocked",statuses:["blocked","parked"]}];function wo(t){return t.group||"other"}const dg=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*[a-z]?$/,Dh=24;function oF(t){if(!t||t.length<=Dh)return t;const e=t.split("-");let r="";for(const n of e){const i=r?r+"-"+n:n;if(i.length>Dh-1)break;r=i}return(r||t.slice(0,Dh-1))+"…"}function aF(t){var i;const e=((i=t.lifecycle)==null?void 0:i.featureCode)||t.featureCode;if(e&&dg.test(e))return e;if(t.id&&dg.test(t.id)&&t.id.length<=32)return t.id;const n=(t.title||"").replace(/`/g,"").trim().match(/^([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*[a-z]?)\b/);return n&&n[1].length>=3?n[1]:t.slug?oF(t.slug):t.id?t.id.slice(0,12):"item"}function fg(t,e=18){const r=t.split("-"),n=[];let i="";for(const s of r){const o=i?i+"-"+s:s;o.length>e&&i?(n.push(i),i=s):i=o}return i&&n.push(i),n.join(`
338
+ */const VM=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Pl=jt("zap",VM),Mc=C.createContext({newIds:new Set,changedIds:new Set}),Ym=t=>{let e;const r=new Set,n=(c,u)=>{const d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){const p=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),r.forEach(f=>f(e,p))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(r.add(c),()=>r.delete(c))},l=e=t(n,i,a);return a},YM=(t=>t?Ym(t):Ym),XM=t=>t;function KM(t,e=XM){const r=Yt.useSyncExternalStore(t.subscribe,Yt.useCallback(()=>e(t.getState()),[t,e]),Yt.useCallback(()=>e(t.getInitialState()),[t,e]));return Yt.useDebugValue(r),r}const Xm=t=>{const e=YM(t),r=n=>KM(e,n);return Object.assign(r,e),r},Nf=(t=>t?Xm(t):Xm),ao=new Map;function ZM(t,e,r){var D,R;const{prevItemMapRef:n,snapshotProviderRef:i,gatesRef:s,pendingResolveIdsRef:o,changeTimerRef:a,sessionEndTimerRef:l,wsRef:c}=e,{setItems:u,setConnections:d,setGates:p,setGateEvent:f,setRecentChanges:m,setUICommand:x,setAgentActivity:g,setAgentErrors:y,setSessionState:b,setSpawnedAgents:k,setAgentRelays:T,setSettings:_,setPipelineDraft:w,setActiveBuild:E,setSessions:B,setIterationStates:P,setFeatureTimeline:N,EMPTY_CHANGES:M,appendDecisionEvent:$,setDecisionEventsSnapshot:q,setStatusSnapshot:O,clearStatusSnapshots:I}=r,A=N?j=>{N(S=>S.some(W=>W.id===j.id)?S:[...S,j])}:null;if(t.type==="visionState"||t.type==="hydrate"){const j=t.items||[];if(n.current){const S=n.current,W=new Set,K=new Set;for(const F of j){const ht=S.get(F.id);ht?(ht.status!==F.status||ht.confidence!==F.confidence||ht.title!==F.title)&&K.add(F.id):W.add(F.id)}(W.size>0||K.size>0)&&(m({newIds:W,changedIds:K}),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>m(M),800))}n.current=new Map(j.map(S=>[S.id,S])),u(j),d(t.connections||[]),p(t.gates||[]),B&&B(t.sessions||[]),q&&Array.isArray(t.decisionEventsSnapshot)&&q(t.decisionEventsSnapshot),I&&I()}else if(t.type==="decisionEvent")$&&t.event&&$(t.event);else if(t.type==="decisionEventsSnapshot")q&&Array.isArray(t.events)&&q(t.events);else if(t.type==="statusSnapshot")O&&t.featureCode&&t.snapshot&&O(t.featureCode,t.snapshot);else if(t.type==="visionUI")x(t);else if(t.type==="agentActivity")g(j=>{const S=[...j,{tool:t.tool,category:t.category||null,detail:t.detail,items:t.items||[],error:t.error||null,timestamp:t.timestamp}];return S.length>20?S.slice(-20):S}),b(j=>j!=null&&j.active?{...j,toolCount:(j.toolCount||0)+1}:j);else if(t.type==="agentSpawned")k(j=>[...j,{agentId:t.agentId,parentSessionId:t.parentSessionId,agentType:t.agentType,status:"running",startedAt:t.startedAt,prompt:t.prompt}]);else if(t.type==="agentSilent")k(j=>j.map(S=>S.agentId===t.agentId?{...S,silent:!0,silentSinceMs:t.silentSinceMs}:S));else if(t.type==="agentKilled")k(j=>j.map(S=>S.agentId===t.agentId?{...S,status:"killed",terminalReason:t.reason,completedAt:new Date().toISOString()}:S));else if(t.type==="agentGC")((D=t.removed)==null?void 0:D.length)>0&&g(j=>{const S=[...j,{tool:"gc",category:"executing",detail:`Cleaned ${t.removed.length} orphan worktree(s)`,items:[],timestamp:t.timestamp}];return S.length>20?S.slice(-20):S});else if(t.type==="agentComplete")k(j=>j.map(S=>S.agentId===t.agentId?S.status==="killed"?S:{...S,status:t.status,completedAt:new Date().toISOString()}:S));else if(t.type==="agentRelay")T(j=>[...j,t].slice(-50));else if(t.type==="sessionStart")l.current&&(clearTimeout(l.current),l.current=null),k(()=>[]),T(()=>[]),b(j=>j&&j.id===t.sessionId?{...j,active:!0}:{id:t.sessionId,active:!0,startedAt:t.timestamp,source:t.source,toolCount:0,errorCount:0,summaries:[],featureCode:null,featureItemId:null,phaseAtBind:null,boundAt:null}),A&&A({id:`session-start-${t.sessionId}`,timestamp:t.timestamp,category:"session",title:"Session started",detail:t.source?`Source: ${t.source}`:null,severity:"info",sessionId:t.sessionId,meta:{source:t.source}});else if(t.type==="sessionEnd")l.current&&(clearTimeout(l.current),l.current=null),b(j=>j?{...j,active:!1,endedAt:t.timestamp,toolCount:t.toolCount,duration:t.duration,journalSpawned:t.journalSpawned,featureCode:t.featureCode||(j==null?void 0:j.featureCode)||null,phaseAtEnd:t.phaseAtEnd||null}:null),l.current=setTimeout(()=>{b(null),l.current=null},3e3),A&&A({id:`session-end-${t.sessionId||Date.now()}`,timestamp:t.timestamp,category:"session",title:`Session ended (${t.toolCount??0} tools)`,detail:null,severity:"info",sessionId:t.sessionId||null,meta:{toolCount:t.toolCount,duration:t.duration}});else if(t.type==="sessionSummary")b(j=>j&&{...j,summaries:[...j.summaries||[],{summary:t.summary,intent:t.intent,component:t.component,timestamp:t.timestamp}].slice(-5)});else if(t.type==="sessionBound")b(j=>j&&{...j,featureCode:t.featureCode,featureItemId:t.itemId,phaseAtBind:t.phase,boundAt:t.timestamp});else if(t.type==="agentError")y(j=>{const S=[...j,{errorType:t.errorType,severity:t.severity,message:t.message,tool:t.tool,detail:t.detail,items:t.items||[],timestamp:t.timestamp||new Date().toISOString()}];return S.length>10?S.slice(-10):S}),b(j=>j!=null&&j.active?{...j,errorCount:(j.errorCount||0)+1}:j),A&&A({id:`error-${t.timestamp}-${Math.random().toString(36).slice(2,6)}`,timestamp:t.timestamp||new Date().toISOString(),category:"error",title:t.message||`${t.errorType} error`,detail:t.tool?`Tool: ${t.tool}`:null,severity:t.severity==="error"?"error":"warning",sessionId:null,meta:{type:t.errorType,tool:t.tool}});else if(t.type==="gateCreated"||t.type==="gatePending")f({type:"pending",gateId:t.gateId,itemId:t.itemId,fromPhase:t.fromPhase,toPhase:t.toPhase}),A&&A({id:`gate-created-${t.gateId}`,timestamp:t.timestamp||new Date().toISOString(),category:"gate",title:t.fromPhase&&t.toPhase?`Gate: ${t.fromPhase} → ${t.toPhase}`:"Gate created",detail:null,severity:"info",sessionId:null,meta:{gateId:t.gateId,itemId:t.itemId,fromPhase:t.fromPhase,toPhase:t.toPhase}});else if(t.type==="gateResolved"){if(p(W=>W.map(K=>K.id===t.gateId?{...K,status:"resolved",outcome:t.outcome,resolvedAt:t.timestamp}:K)),o.current.has(t.gateId))o.current.delete(t.gateId);else{const W=t.itemId??((R=s.current.find(K=>K.id===t.gateId))==null?void 0:R.itemId)??t.gateId;f({type:"resolved",gateId:t.gateId,outcome:t.outcome,itemId:W})}const j=t.outcome==="approve"?"approved":t.outcome==="revise"?"revised":t.outcome==="kill"?"killed":t.outcome,S={approve:"success",revise:"warning",kill:"error"};A&&A({id:`gate-resolved-${t.gateId}`,timestamp:t.timestamp||new Date().toISOString(),category:"gate",title:`Gate ${j}`,detail:null,severity:S[t.outcome]||"info",sessionId:null,meta:{gateId:t.gateId,itemId:t.itemId,outcome:t.outcome}})}else if(t.type==="iterationStarted"||t.type==="iterationUpdate"||t.type==="iterationComplete"){if(g(j=>{let S;t.type==="iterationStarted"?S=`${t.loopType} loop started (0/${t.maxIterations})`:t.type==="iterationComplete"?S=`${t.loopType??"loop"} loop complete (${t.outcome} after ${t.finalCount} iterations)`:S=`${t.loopType??"loop"} iteration ${t.count}/${t.maxIterations}`;const W=[...j,{tool:"iteration",category:t.loopType||"iteration",detail:S,items:[],timestamp:t.timestamp}];return W.length>20?W.slice(-20):W}),t.type==="iterationStarted")ao.has(t.loopId)&&(clearTimeout(ao.get(t.loopId)),ao.delete(t.loopId)),P(j=>{const S=new Map(j);return S.set(t.loopId,{loopId:t.loopId,itemId:t.itemId,loopType:t.loopType,count:0,maxIterations:t.maxIterations,status:"running",outcome:null,startedAt:t.startedAt??t.timestamp,wallClockTimeout:t.wallClockTimeout??null,maxActions:t.maxActions??null}),S});else if(t.type==="iterationUpdate")P(j=>{const S=j.get(t.loopId);if(!S)return j;const W=new Map(j);return W.set(t.loopId,{...S,count:t.count,maxIterations:t.maxIterations}),W});else if(t.type==="iterationComplete"){P(S=>{const W=S.get(t.loopId);if(!W)return S;const K=new Map(S);return K.set(t.loopId,{...W,status:"complete",outcome:t.outcome,count:t.finalCount??W.count}),K});const j=setTimeout(()=>{P(S=>{const W=new Map(S);return W.delete(t.loopId),W}),ao.delete(t.loopId)},5e3);ao.set(t.loopId,j)}if(t.type==="iterationComplete"&&(t.outcome==="max_reached"||t.outcome==="timeout"||t.outcome==="action_limit")){const j={max_reached:`${t.loopType??"Loop"} hit max iterations (${t.finalCount}) — problem may be in the spec`,timeout:`${t.loopType??"Loop"} timed out after ${t.elapsedMinutes??"?"} minutes (${t.finalCount} iterations)`,action_limit:`${t.loopType??"Loop"} hit action count ceiling (${t.finalCount} iterations)`};y(S=>{const W=[...S,{errorType:"iteration_limit",severity:"warning",message:j[t.outcome]??`${t.loopType??"Loop"} stopped: ${t.outcome}`,timestamp:t.timestamp}];return W.length>10?W.slice(-10):W}),b(S=>S!=null&&S.active?{...S,errorCount:(S.errorCount||0)+1}:S)}if(A&&(t.type==="iterationStarted"||t.type==="iterationComplete")){const j=t.type==="iterationStarted"?`${t.loopType} loop started (0/${t.maxIterations})`:`${t.loopType??"loop"} loop ${t.outcome} (${t.finalCount} iterations)`;A({id:`iteration-${t.loopId}-${t.type}`,timestamp:t.timestamp,category:"iteration",title:j,detail:null,severity:t.outcome==="max_reached"||t.outcome==="timeout"||t.outcome==="action_limit"?"warning":t.type==="iterationComplete"?"success":"info",sessionId:null,meta:{loopId:t.loopId,loopType:t.loopType}})}}else if(t.type==="lifecycleStarted")A&&A({id:`lifecycle-started-${t.itemId}`,timestamp:t.timestamp,category:"phase",title:`Lifecycle started: ${t.phase}`,detail:t.featureCode?`Feature: ${t.featureCode}`:null,severity:"success",sessionId:null,meta:{itemId:t.itemId,phase:t.phase,featureCode:t.featureCode}});else if(t.type==="lifecycleTransition"){const j=t.outcome==="skipped"?" (skipped)":t.outcome==="killed"?" (killed)":"",S=t.outcome==="killed"?"error":t.outcome==="skipped"?"info":"success";A&&A({id:`lifecycle-${t.itemId}-${t.from}-${t.to}`,timestamp:t.timestamp,category:"phase",title:`Phase: ${t.from} → ${t.to}${j}`,detail:null,severity:S,sessionId:null,meta:{itemId:t.itemId,from:t.from,to:t.to,outcome:t.outcome}})}else if(t.type==="openLoopsUpdate")u&&t.itemId&&Array.isArray(t.loops)&&u(j=>j.map(S=>{if(S.id!==t.itemId)return S;const W=S.lifecycle?{...S.lifecycle}:{};return W.lifecycle_ext={...W.lifecycle_ext||{},open_loops:t.loops},{...S,lifecycle:W}}));else if(t.type==="driftAxesUpdate")u&&t.itemId&&Array.isArray(t.drift_axes)&&u(j=>j.map(S=>{if(S.id!==t.itemId)return S;const W=S.lifecycle?{...S.lifecycle}:{};return W.lifecycle_ext={...W.lifecycle_ext||{},drift_axes:t.drift_axes},{...S,lifecycle:W}}));else if(t.type==="branchLineageUpdate"){if(u&&t.itemId){const{type:j,itemId:S,...W}=t;u(K=>K.map(F=>{if(F.id!==S)return F;const ht=F.lifecycle?{...F.lifecycle}:{};return ht.lifecycle_ext={...ht.lifecycle_ext||{},branch_lineage:W},{...F,lifecycle:ht}}))}}else if(t.type==="settingsState"||t.type==="settingsUpdated")_&&_(t.settings||null);else if(t.type==="buildState")E&&E(j=>{const S=(j==null?void 0:j.flowId)&&t.flowId&&j.flowId===t.flowId;return{...t,tierEvents:S?j.tierEvents??[]:[],capabilityEvents:S?j.capabilityEvents??[]:[],...S&&(j==null?void 0:j.health_score)!=null?{health_score:j.health_score,health_breakdown:j.health_breakdown,health_missing:j.health_missing}:{}}});else if(t.type==="pipelineDraft")w&&w(t);else if(t.type==="pipelineDraftResolved")w&&w(null);else if(t.type==="system"&&t.subtype==="health_score")E&&E(j=>j&&{...j,health_score:t.score,health_breakdown:t.breakdown,health_missing:t.missing});else if(t.type==="system"&&(t.subtype==="gate_tier_result"||t.subtype==="gate_tier_failed"||t.subtype==="gate_tier_summary"))E&&E(j=>j&&{...j,tierEvents:[...j.tierEvents||[],t].slice(-50)});else if(t.type==="system"&&t.subtype==="capability_violation")E&&E(j=>j&&{...j,capabilityEvents:[...j.capabilityEvents||[],t].slice(-200)});else if(t.type==="snapshotRequest"&&t.requestId){const{collectDOMSnapshot:j}=e,S=i.current?i.current():{},W=j?j():{},K=c.current;K&&K.send(JSON.stringify({type:"snapshotResponse",requestId:t.requestId,snapshot:{...S,dom:W,timestamp:new Date().toISOString()}}))}}function QM(){const t=new Set(["SCRIPT","STYLE","LINK","META","NOSCRIPT"]),e=12,r=120;function n(s,o){if(!s||o>e)return null;if(s.nodeType===Node.TEXT_NODE){const p=s.textContent.trim();return p?p.slice(0,r):null}if(s.nodeType!==Node.ELEMENT_NODE||t.has(s.tagName))return null;const a=window.getComputedStyle(s);if(a.display==="none"||a.visibility==="hidden")return null;const l={},c=s.getAttribute("role")||s.getAttribute("aria-label"),u=s.tagName.toLowerCase();if(c?l.role=c:l.tag=u,s.className&&typeof s.className=="string"){const p=s.className.trim();p.length<80&&(l.class=p)}const d=[];for(const p of s.childNodes){const f=n(p,o+1);f&&d.push(f)}return d.length===1&&typeof d[0]=="string"?l.text=d[0]:d.length>0&&(l.children=d),!c&&(u==="div"||u==="span")&&!l.text&&d.length===1&&typeof d[0]=="object"?d[0]:l}const i=document.querySelector("[data-snapshot-root]")||document.body;return n(i,0)}const pe={ws:null,snapshotProvider:null,prevItemMap:null,changeTimer:null,sessionEndTimer:null,gates:[],pendingResolveIds:new Set,buildPollInterval:null,recentErrorsInterval:null,connected:!1},Km={newIds:new Set,changedIds:new Set},gr=Nf((t,e)=>{async function r(o,a){const l=await Rt(o,a),c=await l.json();return l.ok?c:(console.error(`[vision] API error ${l.status}:`,c.error||c),{error:c.error||`HTTP ${l.status}`})}function n(){t({connected:!0}),Rt("/api/build/state").then(o=>o.json()).then(o=>t({activeBuild:o.state??null})).catch(()=>{}),Rt("/api/pipeline/draft").then(o=>o.json()).then(o=>t({pipelineDraft:o.draft??null})).catch(()=>{}),Rt("/api/agents/tree").then(o=>o.json()).then(o=>{e().spawnedAgents.length===0&&t({spawnedAgents:(o.agents||[]).map(l=>({agentId:l.agentId,parentSessionId:l.parentSessionId,agentType:l.agentType,status:l.status||"running",startedAt:l.startedAt,prompt:l.prompt}))})}).catch(()=>{})}function i(o){try{const a=JSON.parse(o.data);ZM(a,{prevItemMapRef:{get current(){return pe.prevItemMap},set current(l){pe.prevItemMap=l}},snapshotProviderRef:{get current(){return pe.snapshotProvider},set current(l){pe.snapshotProvider=l}},gatesRef:{get current(){return pe.gates},set current(l){pe.gates=l}},pendingResolveIdsRef:{get current(){return pe.pendingResolveIds},set current(l){pe.pendingResolveIds=l}},changeTimerRef:{get current(){return pe.changeTimer},set current(l){pe.changeTimer=l}},sessionEndTimerRef:{get current(){return pe.sessionEndTimer},set current(l){pe.sessionEndTimer=l}},wsRef:{get current(){var l;return((l=pe.ws)==null?void 0:l.socket)||null},set current(l){}},collectDOMSnapshot:QM},{setItems:l=>t(c=>({items:typeof l=="function"?l(c.items):l})),setConnections:l=>t(c=>({connections:typeof l=="function"?l(c.connections):l})),setGates:l=>{t(c=>{const u=typeof l=="function"?l(c.gates):l;return pe.gates=u,{gates:u}})},setGateEvent:l=>t({gateEvent:l}),setRecentChanges:l=>t(c=>({recentChanges:typeof l=="function"?l(c.recentChanges):l})),setUICommand:l=>t({uiCommand:l}),setAgentActivity:l=>t(c=>({agentActivity:typeof l=="function"?l(c.agentActivity):l})),setAgentErrors:l=>{t(c=>{const u=typeof l=="function"?l(c.agentErrors):l,d=Date.now()-6e4,p=u.filter(f=>new Date(f.timestamp).getTime()>d).slice(-5);return{agentErrors:u,recentErrors:p}})},setSessionState:l=>t(c=>({sessionState:typeof l=="function"?l(c.sessionState):l})),setSpawnedAgents:l=>t(c=>({spawnedAgents:typeof l=="function"?l(c.spawnedAgents):l})),setAgentRelays:l=>t(c=>({agentRelays:typeof l=="function"?l(c.agentRelays):l})),setSettings:l=>t({settings:l}),setPipelineDraft:l=>t({pipelineDraft:l}),setActiveBuild:l=>t(c=>({activeBuild:typeof l=="function"?l(c.activeBuild):l})),setSessions:l=>t(c=>({sessions:typeof l=="function"?l(c.sessions):l})),setFeatureTimeline:l=>t(c=>({featureTimeline:typeof l=="function"?l(c.featureTimeline):l})),setIterationStates:l=>t(c=>({iterationStates:typeof l=="function"?l(c.iterationStates):l})),appendDecisionEvent:l=>t(c=>!(l!=null&&l.id)||c.decisionEvents.some(u=>u.id===l.id)?c:{decisionEvents:[...c.decisionEvents,l]}),setDecisionEventsSnapshot:l=>t({decisionEvents:Array.isArray(l)?l:[]}),setStatusSnapshot:(l,c)=>t(u=>({statusSnapshots:{...u.statusSnapshots,[l]:c}})),clearStatusSnapshots:()=>t({statusSnapshots:{}}),EMPTY_CHANGES:Km})}catch{}}function s(){if(pe.disposed||pe.ws)return;const a=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/vision`;pe.ws=f_({url:a,onOpen:n,onMessage:i,onClose:()=>t({connected:!1})})}return Rt("/api/session/current").then(o=>o.json()).then(o=>{o.session&&t(a=>a.sessionState?{}:{sessionState:{id:o.session.id,active:!0,startedAt:o.session.startedAt,source:o.session.source||"hydrated",toolCount:o.session.toolCount||0,errorCount:o.session.errorCount||0,summaries:o.session.summaries||[],featureCode:o.session.featureCode||null,featureItemId:o.session.featureItemId||null,phaseAtBind:o.session.phaseAtBind||null,boundAt:o.session.boundAt||null}})}).catch(()=>console.warn("[vision] Failed to hydrate session state")),pe.buildPollInterval=setInterval(()=>{Rt("/api/build/state").then(o=>o.json()).then(o=>t({activeBuild:o.state??null})).catch(()=>{})},5e3),pe.recentErrorsInterval=setInterval(()=>{const{agentErrors:o}=e(),a=Date.now()-6e4,l=o.filter(c=>new Date(c.timestamp).getTime()>a).slice(-5);t({recentErrors:l})},1e4),s(),{items:[],connections:[],connected:!1,uiCommand:null,recentChanges:Km,agentActivity:[],agentErrors:[],recentErrors:[],spawnedAgents:[],agentRelays:[],sessionState:null,gates:[],gateEvent:null,settings:null,pipelineDraft:null,activeBuild:null,iterationStates:new Map,sessions:[],featureTimeline:[],selectedPhase:(()=>{try{return localStorage.getItem("compose:selectedPhase")||null}catch{return null}})(),selectedBranches:{},decisionEvents:[],statusSnapshots:{},clearUICommand:()=>t({uiCommand:null}),setSelectedBranches:(o,a)=>t(l=>({selectedBranches:{...l.selectedBranches,[o]:a}})),setStatusSnapshot:(o,a)=>t(l=>({statusSnapshots:{...l.statusSnapshots,[o]:a}})),clearStatusSnapshots:()=>t({statusSnapshots:{}}),setDecisionEventsSnapshot:o=>t({decisionEvents:Array.isArray(o)?o:[]}),appendDecisionEvent:o=>t(a=>!(o!=null&&o.id)||a.decisionEvents.some(l=>l.id===o.id)?a:{decisionEvents:[...a.decisionEvents,o]}),registerSnapshotProvider:o=>{pe.snapshotProvider=o},setActiveBuild:o=>t({activeBuild:o}),setPipelineDraft:o=>t({pipelineDraft:o}),setFeatureTimeline:o=>t(a=>({featureTimeline:typeof o=="function"?o(a.featureTimeline):o})),setSelectedPhase:o=>{t({selectedPhase:o});try{o?localStorage.setItem("compose:selectedPhase",o):localStorage.removeItem("compose:selectedPhase")}catch{}},updateItemPosition:(o,a)=>{t(l=>({items:l.items.map(c=>c.id===o?{...c,position:a}:c)}))},createItem:o=>r("/api/vision/items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),updateItem:(o,a)=>r(`/api/vision/items/${o}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),deleteItem:o=>r(`/api/vision/items/${o}`,{method:"DELETE"}),createConnection:o=>r("/api/vision/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),deleteConnection:o=>r(`/api/vision/connections/${o}`,{method:"DELETE"}),resolveGate:async(o,a,l)=>{pe.pendingResolveIds.add(o);try{const c=await r(`/api/vision/gates/${o}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({outcome:a,comment:l})});return c.error&&pe.pendingResolveIds.delete(o),c}catch{return pe.pendingResolveIds.delete(o),{error:"Network error"}}},updateSettings:o=>r("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),resetSettings:o=>r("/api/settings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o?{section:o}:{})})}});function Eb(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=Eb(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function Nb(){for(var t,e,r=0,n="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=Eb(t))&&(n&&(n+=" "),n+=e);return n}const Zm=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Qm=Nb,jb=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return Qm(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:i,defaultVariants:s}=e,o=Object.keys(i).map(c=>{const u=r==null?void 0:r[c],d=s==null?void 0:s[c];if(u===null)return null;const p=Zm(u)||Zm(d);return i[c][p]}),a=r&&Object.entries(r).reduce((c,u)=>{let[d,p]=u;return p===void 0||(c[d]=p),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:p,...f}=u;return Object.entries(f).every(m=>{let[x,g]=m;return Array.isArray(g)?g.includes({...s,...a}[x]):{...s,...a}[x]===g})?[...c,d,p]:c},[]);return Qm(t,o,l,r==null?void 0:r.class,r==null?void 0:r.className)},JM=(t,e)=>{const r=new Array(t.length+e.length);for(let n=0;n<t.length;n++)r[n]=t[n];for(let n=0;n<e.length;n++)r[t.length+n]=e[n];return r},tI=(t,e)=>({classGroupId:t,validator:e}),Lb=(t=new Map,e=null,r)=>({nextPart:t,validators:e,classGroupId:r}),Dl="-",Jm=[],eI="arbitrary..",rI=t=>{const e=iI(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return nI(o);const a=o.split(Dl),l=a[0]===""&&a.length>1?1:0;return Bb(a,l,e)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=n[o],c=r[o];return l?c?JM(c,l):l:c||Jm}return r[o]||Jm}}},Bb=(t,e,r)=>{if(t.length-e===0)return r.classGroupId;const i=t[e],s=r.nextPart.get(i);if(s){const c=Bb(t,e+1,s);if(c)return c}const o=r.validators;if(o===null)return;const a=e===0?t.join(Dl):t.slice(e).join(Dl),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},nI=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),r=e.indexOf(":"),n=e.slice(0,r);return n?eI+n:void 0})(),iI=t=>{const{theme:e,classGroups:r}=t;return sI(r,e)},sI=(t,e)=>{const r=Lb();for(const n in t){const i=t[n];jf(i,r,n,e)}return r},jf=(t,e,r,n)=>{const i=t.length;for(let s=0;s<i;s++){const o=t[s];oI(o,e,r,n)}},oI=(t,e,r,n)=>{if(typeof t=="string"){aI(t,e,r);return}if(typeof t=="function"){lI(t,e,r,n);return}cI(t,e,r,n)},aI=(t,e,r)=>{const n=t===""?e:Ab(e,t);n.classGroupId=r},lI=(t,e,r,n)=>{if(hI(t)){jf(t(n),e,r,n);return}e.validators===null&&(e.validators=[]),e.validators.push(tI(r,t))},cI=(t,e,r,n)=>{const i=Object.entries(t),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];jf(l,Ab(e,a),r,n)}},Ab=(t,e)=>{let r=t;const n=e.split(Dl),i=n.length;for(let s=0;s<i;s++){const o=n[s];let a=r.nextPart.get(o);a||(a=Lb(),r.nextPart.set(o,a)),r=a}return r},hI=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,uI=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=Object.create(null),n=Object.create(null);const i=(s,o)=>{r[s]=o,e++,e>t&&(e=0,n=r,r=Object.create(null))};return{get(s){let o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set(s,o){s in r?r[s]=o:i(s,o)}}},zu="!",tg=":",dI=[],eg=(t,e,r,n,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),fI=t=>{const{prefix:e,experimentalParseClassName:r}=t;let n=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let x=0;x<u;x++){const g=i[x];if(o===0&&a===0){if(g===tg){s.push(i.slice(l,x)),l=x+1;continue}if(g==="/"){c=x;continue}}g==="["?o++:g==="]"?o--:g==="("?a++:g===")"&&a--}const d=s.length===0?i:i.slice(l);let p=d,f=!1;d.endsWith(zu)?(p=d.slice(0,-1),f=!0):d.startsWith(zu)&&(p=d.slice(1),f=!0);const m=c&&c>l?c-l:void 0;return eg(s,f,p,m)};if(e){const i=e+tg,s=n;n=o=>o.startsWith(i)?s(o.slice(i.length)):eg(dI,!1,o,void 0,!0)}if(r){const i=n;n=s=>r({className:s,parseClassName:i})}return n},pI=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((r,n)=>{e.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let s=0;s<r.length;s++){const o=r[s],a=o[0]==="[",l=e.has(o);a||l?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(o)):i.push(o)}return i.length>0&&(i.sort(),n.push(...i)),n}},mI=t=>({cache:uI(t.cacheSize),parseClassName:fI(t),sortModifiers:pI(t),postfixLookupClassGroupIds:gI(t),...rI(t)}),gI=t=>{const e=Object.create(null),r=t.postfixLookupClassGroups;if(r)for(let n=0;n<r.length;n++)e[r[n]]=!0;return e},xI=/\s+/,yI=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:s,postfixLookupClassGroupIds:o}=e,a=[],l=t.trim().split(xI);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:f,hasImportantModifier:m,baseClassName:x,maybePostfixModifierPosition:g}=r(d);if(p){c=d+(c.length>0?" "+c:c);continue}let y=!!g,b;if(y){const E=x.substring(0,g);b=n(E);const B=b&&o[b]?n(x):void 0;B&&B!==b&&(b=B,y=!1)}else b=n(x);if(!b){if(!y){c=d+(c.length>0?" "+c:c);continue}if(b=n(x),!b){c=d+(c.length>0?" "+c:c);continue}y=!1}const k=f.length===0?"":f.length===1?f[0]:s(f).join(":"),T=m?k+zu:k,_=T+b;if(a.indexOf(_)>-1)continue;a.push(_);const w=i(b,y);for(let E=0;E<w.length;++E){const B=w[E];a.push(T+B)}c=d+(c.length>0?" "+c:c)}return c},bI=(...t)=>{let e=0,r,n,i="";for(;e<t.length;)(r=t[e++])&&(n=Mb(r))&&(i&&(i+=" "),i+=n);return i},Mb=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=Mb(t[n]))&&(r&&(r+=" "),r+=e);return r},CI=(t,...e)=>{let r,n,i,s;const o=l=>{const c=e.reduce((u,d)=>d(u),t());return r=mI(c),n=r.cache.get,i=r.cache.set,s=a,a(l)},a=l=>{const c=n(l);if(c)return c;const u=yI(l,r);return i(l,u),u};return s=o,(...l)=>s(bI(...l))},kI=[],Ie=t=>{const e=r=>r[t]||kI;return e.isThemeGetter=!0,e},Ib=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vI=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,wI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,SI=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,TI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_I=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,EI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bn=t=>vI.test(t),Vt=t=>!!t&&!Number.isNaN(Number(t)),Qr=t=>!!t&&Number.isInteger(Number(t)),Ih=t=>t.endsWith("%")&&Vt(t.slice(0,-1)),mn=t=>wI.test(t),Pb=()=>!0,NI=t=>SI.test(t)&&!TI.test(t),Lf=()=>!1,jI=t=>_I.test(t),LI=t=>EI.test(t),BI=t=>!mt(t)&&!gt(t),AI=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),MI=t=>Qn(t,Rb,Lf),mt=t=>Ib.test(t),ii=t=>Qn(t,$b,NI),rg=t=>Qn(t,zI,Vt),II=t=>Qn(t,Wb,Pb),FI=t=>Qn(t,zb,Lf),ng=t=>Qn(t,Db,Lf),PI=t=>Qn(t,Ob,LI),Fa=t=>Qn(t,qb,jI),gt=t=>Fb.test(t),lo=t=>Ni(t,$b),DI=t=>Ni(t,zb),ig=t=>Ni(t,Db),OI=t=>Ni(t,Rb),RI=t=>Ni(t,Ob),Pa=t=>Ni(t,qb,!0),$I=t=>Ni(t,Wb,!0),Qn=(t,e,r)=>{const n=Ib.exec(t);return n?n[1]?e(n[1]):r(n[2]):!1},Ni=(t,e,r=!1)=>{const n=Fb.exec(t);return n?n[1]?e(n[1]):r:!1},Db=t=>t==="position"||t==="percentage",Ob=t=>t==="image"||t==="url",Rb=t=>t==="length"||t==="size"||t==="bg-size",$b=t=>t==="length",zI=t=>t==="number",zb=t=>t==="family-name",Wb=t=>t==="number"||t==="weight",qb=t=>t==="shadow",WI=()=>{const t=Ie("color"),e=Ie("font"),r=Ie("text"),n=Ie("font-weight"),i=Ie("tracking"),s=Ie("leading"),o=Ie("breakpoint"),a=Ie("container"),l=Ie("spacing"),c=Ie("radius"),u=Ie("shadow"),d=Ie("inset-shadow"),p=Ie("text-shadow"),f=Ie("drop-shadow"),m=Ie("blur"),x=Ie("perspective"),g=Ie("aspect"),y=Ie("ease"),b=Ie("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...T(),gt,mt],w=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],B=()=>[gt,mt,l],P=()=>[Bn,"full","auto",...B()],N=()=>[Qr,"none","subgrid",gt,mt],M=()=>["auto",{span:["full",Qr,gt,mt]},Qr,gt,mt],$=()=>[Qr,"auto",gt,mt],q=()=>["auto","min","max","fr",gt,mt],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],I=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...B()],D=()=>[Bn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],R=()=>[Bn,"screen","full","dvw","lvw","svw","min","max","fit",...B()],j=()=>[Bn,"screen","full","lh","dvh","lvh","svh","min","max","fit",...B()],S=()=>[t,gt,mt],W=()=>[...T(),ig,ng,{position:[gt,mt]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",OI,MI,{size:[gt,mt]}],ht=()=>[Ih,lo,ii],st=()=>["","none","full",c,gt,mt],J=()=>["",Vt,lo,ii],ct=()=>["solid","dashed","dotted","double"],zt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],at=()=>[Vt,Ih,ig,ng],Z=()=>["","none",m,gt,mt],lt=()=>["none",Vt,gt,mt],Ct=()=>["none",Vt,gt,mt],Mt=()=>[Vt,gt,mt],Dt=()=>[Bn,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[mn],breakpoint:[mn],color:[Pb],container:[mn],"drop-shadow":[mn],ease:["in","out","in-out"],font:[BI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[mn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[mn],shadow:[mn],spacing:["px",Vt],text:[mn],"text-shadow":[mn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bn,mt,gt,g]}],container:["container"],"container-type":[{"@container":["","normal","size",gt,mt]}],"container-named":[AI],columns:[{columns:[Vt,mt,gt,a]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[Qr,"auto",gt,mt]}],basis:[{basis:[Bn,"full","auto",a,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Vt,Bn,"auto","initial","none",mt]}],grow:[{grow:["",Vt,gt,mt]}],shrink:[{shrink:["",Vt,gt,mt]}],order:[{order:[Qr,"first","last","none",gt,mt]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:M()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":q()}],"auto-rows":[{"auto-rows":q()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...I(),"normal"]}],"justify-self":[{"justify-self":["auto",...I()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...I(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...I(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...I(),"baseline"]}],"place-self":[{"place-self":["auto",...I()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pbs:[{pbs:B()}],pbe:[{pbe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:D()}],"inline-size":[{inline:["auto",...R()]}],"min-inline-size":[{"min-inline":["auto",...R()]}],"max-inline-size":[{"max-inline":["none",...R()]}],"block-size":[{block:["auto",...j()]}],"min-block-size":[{"min-block":["auto",...j()]}],"max-block-size":[{"max-block":["none",...j()]}],w:[{w:[a,"screen",...D()]}],"min-w":[{"min-w":[a,"screen","none",...D()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...D()]}],h:[{h:["screen","lh",...D()]}],"min-h":[{"min-h":["screen","lh","none",...D()]}],"max-h":[{"max-h":["screen","lh",...D()]}],"font-size":[{text:["base",r,lo,ii]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,$I,II]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ih,mt]}],"font-family":[{font:[DI,FI,e]}],"font-features":[{"font-features":[mt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,gt,mt]}],"line-clamp":[{"line-clamp":[Vt,"none",gt,rg]}],leading:[{leading:[s,...B()]}],"list-image":[{"list-image":["none",gt,mt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",gt,mt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:S()}],"text-color":[{text:S()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ct(),"wavy"]}],"text-decoration-thickness":[{decoration:[Vt,"from-font","auto",gt,ii]}],"text-decoration-color":[{decoration:S()}],"underline-offset":[{"underline-offset":[Vt,"auto",gt,mt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"tab-size":[{tab:[Qr,gt,mt]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",gt,mt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",gt,mt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:W()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Qr,gt,mt],radial:["",gt,mt],conic:[Qr,gt,mt]},RI,PI]}],"bg-color":[{bg:S()}],"gradient-from-pos":[{from:ht()}],"gradient-via-pos":[{via:ht()}],"gradient-to-pos":[{to:ht()}],"gradient-from":[{from:S()}],"gradient-via":[{via:S()}],"gradient-to":[{to:S()}],rounded:[{rounded:st()}],"rounded-s":[{"rounded-s":st()}],"rounded-e":[{"rounded-e":st()}],"rounded-t":[{"rounded-t":st()}],"rounded-r":[{"rounded-r":st()}],"rounded-b":[{"rounded-b":st()}],"rounded-l":[{"rounded-l":st()}],"rounded-ss":[{"rounded-ss":st()}],"rounded-se":[{"rounded-se":st()}],"rounded-ee":[{"rounded-ee":st()}],"rounded-es":[{"rounded-es":st()}],"rounded-tl":[{"rounded-tl":st()}],"rounded-tr":[{"rounded-tr":st()}],"rounded-br":[{"rounded-br":st()}],"rounded-bl":[{"rounded-bl":st()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ct(),"hidden","none"]}],"divide-style":[{divide:[...ct(),"hidden","none"]}],"border-color":[{border:S()}],"border-color-x":[{"border-x":S()}],"border-color-y":[{"border-y":S()}],"border-color-s":[{"border-s":S()}],"border-color-e":[{"border-e":S()}],"border-color-bs":[{"border-bs":S()}],"border-color-be":[{"border-be":S()}],"border-color-t":[{"border-t":S()}],"border-color-r":[{"border-r":S()}],"border-color-b":[{"border-b":S()}],"border-color-l":[{"border-l":S()}],"divide-color":[{divide:S()}],"outline-style":[{outline:[...ct(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Vt,gt,mt]}],"outline-w":[{outline:["",Vt,lo,ii]}],"outline-color":[{outline:S()}],shadow:[{shadow:["","none",u,Pa,Fa]}],"shadow-color":[{shadow:S()}],"inset-shadow":[{"inset-shadow":["none",d,Pa,Fa]}],"inset-shadow-color":[{"inset-shadow":S()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:S()}],"ring-offset-w":[{"ring-offset":[Vt,ii]}],"ring-offset-color":[{"ring-offset":S()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":S()}],"text-shadow":[{"text-shadow":["none",p,Pa,Fa]}],"text-shadow-color":[{"text-shadow":S()}],opacity:[{opacity:[Vt,gt,mt]}],"mix-blend":[{"mix-blend":[...zt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":zt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":at()}],"mask-image-linear-to-pos":[{"mask-linear-to":at()}],"mask-image-linear-from-color":[{"mask-linear-from":S()}],"mask-image-linear-to-color":[{"mask-linear-to":S()}],"mask-image-t-from-pos":[{"mask-t-from":at()}],"mask-image-t-to-pos":[{"mask-t-to":at()}],"mask-image-t-from-color":[{"mask-t-from":S()}],"mask-image-t-to-color":[{"mask-t-to":S()}],"mask-image-r-from-pos":[{"mask-r-from":at()}],"mask-image-r-to-pos":[{"mask-r-to":at()}],"mask-image-r-from-color":[{"mask-r-from":S()}],"mask-image-r-to-color":[{"mask-r-to":S()}],"mask-image-b-from-pos":[{"mask-b-from":at()}],"mask-image-b-to-pos":[{"mask-b-to":at()}],"mask-image-b-from-color":[{"mask-b-from":S()}],"mask-image-b-to-color":[{"mask-b-to":S()}],"mask-image-l-from-pos":[{"mask-l-from":at()}],"mask-image-l-to-pos":[{"mask-l-to":at()}],"mask-image-l-from-color":[{"mask-l-from":S()}],"mask-image-l-to-color":[{"mask-l-to":S()}],"mask-image-x-from-pos":[{"mask-x-from":at()}],"mask-image-x-to-pos":[{"mask-x-to":at()}],"mask-image-x-from-color":[{"mask-x-from":S()}],"mask-image-x-to-color":[{"mask-x-to":S()}],"mask-image-y-from-pos":[{"mask-y-from":at()}],"mask-image-y-to-pos":[{"mask-y-to":at()}],"mask-image-y-from-color":[{"mask-y-from":S()}],"mask-image-y-to-color":[{"mask-y-to":S()}],"mask-image-radial":[{"mask-radial":[gt,mt]}],"mask-image-radial-from-pos":[{"mask-radial-from":at()}],"mask-image-radial-to-pos":[{"mask-radial-to":at()}],"mask-image-radial-from-color":[{"mask-radial-from":S()}],"mask-image-radial-to-color":[{"mask-radial-to":S()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[Vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":at()}],"mask-image-conic-to-pos":[{"mask-conic-to":at()}],"mask-image-conic-from-color":[{"mask-conic-from":S()}],"mask-image-conic-to-color":[{"mask-conic-to":S()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:W()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",gt,mt]}],filter:[{filter:["","none",gt,mt]}],blur:[{blur:Z()}],brightness:[{brightness:[Vt,gt,mt]}],contrast:[{contrast:[Vt,gt,mt]}],"drop-shadow":[{"drop-shadow":["","none",f,Pa,Fa]}],"drop-shadow-color":[{"drop-shadow":S()}],grayscale:[{grayscale:["",Vt,gt,mt]}],"hue-rotate":[{"hue-rotate":[Vt,gt,mt]}],invert:[{invert:["",Vt,gt,mt]}],saturate:[{saturate:[Vt,gt,mt]}],sepia:[{sepia:["",Vt,gt,mt]}],"backdrop-filter":[{"backdrop-filter":["","none",gt,mt]}],"backdrop-blur":[{"backdrop-blur":Z()}],"backdrop-brightness":[{"backdrop-brightness":[Vt,gt,mt]}],"backdrop-contrast":[{"backdrop-contrast":[Vt,gt,mt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Vt,gt,mt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Vt,gt,mt]}],"backdrop-invert":[{"backdrop-invert":["",Vt,gt,mt]}],"backdrop-opacity":[{"backdrop-opacity":[Vt,gt,mt]}],"backdrop-saturate":[{"backdrop-saturate":[Vt,gt,mt]}],"backdrop-sepia":[{"backdrop-sepia":["",Vt,gt,mt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",gt,mt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Vt,"initial",gt,mt]}],ease:[{ease:["linear","initial",y,gt,mt]}],delay:[{delay:[Vt,gt,mt]}],animate:[{animate:["none",b,gt,mt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,gt,mt]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:lt()}],"rotate-x":[{"rotate-x":lt()}],"rotate-y":[{"rotate-y":lt()}],"rotate-z":[{"rotate-z":lt()}],scale:[{scale:Ct()}],"scale-x":[{"scale-x":Ct()}],"scale-y":[{"scale-y":Ct()}],"scale-z":[{"scale-z":Ct()}],"scale-3d":["scale-3d"],skew:[{skew:Mt()}],"skew-x":[{"skew-x":Mt()}],"skew-y":[{"skew-y":Mt()}],transform:[{transform:[gt,mt,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Dt()}],"translate-x":[{"translate-x":Dt()}],"translate-y":[{"translate-y":Dt()}],"translate-z":[{"translate-z":Dt()}],"translate-none":["translate-none"],zoom:[{zoom:[Qr,gt,mt]}],accent:[{accent:S()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:S()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",gt,mt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":S()}],"scrollbar-track-color":[{"scrollbar-track":S()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mbs":[{"scroll-mbs":B()}],"scroll-mbe":[{"scroll-mbe":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pbs":[{"scroll-pbs":B()}],"scroll-pbe":[{"scroll-pbe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",gt,mt]}],fill:[{fill:["none",...S()]}],"stroke-w":[{stroke:[Vt,lo,ii,rg]}],stroke:[{stroke:["none",...S()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},qI=CI(WI);function rt(...t){return qI(Nb(t))}const HI=jb("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function nr({className:t,variant:e,...r}){return h.jsx("div",{className:rt(HI({variant:e}),t),...r})}const Ic=C.forwardRef(({className:t,type:e,...r},n)=>h.jsx("input",{type:e,className:rt("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:n,...r}));Ic.displayName="Input";var Bf=p_();const UI=Tc(Bf);function sg(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Fc(...t){return e=>{let r=!1;const n=t.map(i=>{const s=sg(i,e);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let i=0;i<n.length;i++){const s=n[i];typeof s=="function"?s():sg(t[i],null)}}}}function Nr(...t){return C.useCallback(Fc(...t),t)}function GI(t){const e=VI(t),r=C.forwardRef((n,i)=>{const{children:s,...o}=n,a=C.Children.toArray(s),l=a.find(XI);if(l){const c=l.props.children,u=a.map(d=>d===l?C.Children.count(c)>1?C.Children.only(null):C.isValidElement(c)?c.props.children:null:d);return h.jsx(e,{...o,ref:i,children:C.isValidElement(c)?C.cloneElement(c,void 0,u):null})}return h.jsx(e,{...o,ref:i,children:s})});return r.displayName=`${t}.Slot`,r}function VI(t){const e=C.forwardRef((r,n)=>{const{children:i,...s}=r;if(C.isValidElement(i)){const o=ZI(i),a=KI(s,i.props);return i.type!==C.Fragment&&(a.ref=n?Fc(n,o):o),C.cloneElement(i,a)}return C.Children.count(i)>1?C.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var YI=Symbol("radix.slottable");function XI(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===YI}function KI(t,e){const r={...e};for(const n in e){const i=t[n],s=e[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...t,...r}}function ZI(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var QI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],br=QI.reduce((t,e)=>{const r=GI(`Primitive.${e}`),n=C.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function JI(t,e){t&&Bf.flushSync(()=>t.dispatchEvent(e))}var Ls=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{};function t3(t,e){return C.useReducer((r,n)=>e[r][n]??r,t)}var Jn=t=>{const{present:e,children:r}=t,n=e3(e),i=typeof r=="function"?r({present:n.isPresent}):C.Children.only(r),s=Nr(n.ref,r3(i));return typeof r=="function"||n.isPresent?C.cloneElement(i,{ref:s}):null};Jn.displayName="Presence";function e3(t){const[e,r]=C.useState(),n=C.useRef(null),i=C.useRef(t),s=C.useRef("none"),o=t?"mounted":"unmounted",[a,l]=t3(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const c=Da(n.current);s.current=a==="mounted"?c:"none"},[a]),Ls(()=>{const c=n.current,u=i.current;if(u!==t){const p=s.current,f=Da(c);t?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,l]),Ls(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=f=>{const x=Da(n.current).includes(CSS.escape(f.animationName));if(f.target===e&&x&&(l("ANIMATION_END"),!i.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},p=f=>{f.target===e&&(s.current=Da(n.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:C.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function Da(t){return(t==null?void 0:t.animationName)||"none"}function r3(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function n3(t,e){const r=C.createContext(e),n=s=>{const{children:o,...a}=s,l=C.useMemo(()=>a,Object.values(a));return h.jsx(r.Provider,{value:l,children:o})};n.displayName=t+"Provider";function i(s){const o=C.useContext(r);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[n,i]}function Hb(t,e=[]){let r=[];function n(s,o){const a=C.createContext(o),l=r.length;r=[...r,o];const c=d=>{var y;const{scope:p,children:f,...m}=d,x=((y=p==null?void 0:p[t])==null?void 0:y[l])||a,g=C.useMemo(()=>m,Object.values(m));return h.jsx(x.Provider,{value:g,children:f})};c.displayName=s+"Provider";function u(d,p){var x;const f=((x=p==null?void 0:p[t])==null?void 0:x[l])||a,m=C.useContext(f);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=r.map(o=>C.createContext(o));return function(a){const l=(a==null?void 0:a[t])||s;return C.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return i.scopeName=t,[n,i3(i,...e)]}function i3(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=n.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return C.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return r.scopeName=e.scopeName,r}function Br(t){const e=C.useRef(t);return C.useEffect(()=>{e.current=t}),C.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}var s3=C.createContext(void 0);function o3(t){const e=C.useContext(s3);return t||e||"ltr"}function a3(t,[e,r]){return Math.min(r,Math.max(e,t))}function ir(t,e,{checkForDefaultPrevented:r=!0}={}){return function(i){if(t==null||t(i),r===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function l3(t,e){return C.useReducer((r,n)=>e[r][n]??r,t)}var Af="ScrollArea",[Ub]=Hb(Af),[c3,Ir]=Ub(Af),Gb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:i,scrollHideDelay:s=600,...o}=t,[a,l]=C.useState(null),[c,u]=C.useState(null),[d,p]=C.useState(null),[f,m]=C.useState(null),[x,g]=C.useState(null),[y,b]=C.useState(0),[k,T]=C.useState(0),[_,w]=C.useState(!1),[E,B]=C.useState(!1),P=Nr(e,M=>l(M)),N=o3(i);return h.jsx(c3,{scope:r,type:n,dir:N,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:d,onContentChange:p,scrollbarX:f,onScrollbarXChange:m,scrollbarXEnabled:_,onScrollbarXEnabledChange:w,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:B,onCornerWidthChange:b,onCornerHeightChange:T,children:h.jsx(br.div,{dir:N,...o,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":k+"px",...t.style}})})});Gb.displayName=Af;var Vb="ScrollAreaViewport",Yb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:i,...s}=t,o=Ir(Vb,r),a=C.useRef(null),l=Nr(e,a,o.onViewportChange);return h.jsxs(h.Fragment,{children:[h.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),h.jsx(br.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t.style},children:h.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Yb.displayName=Vb;var hn="ScrollAreaScrollbar",Mf=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:o}=i,a=t.orientation==="horizontal";return C.useEffect(()=>(a?s(!0):o(!0),()=>{a?s(!1):o(!1)}),[a,s,o]),i.type==="hover"?h.jsx(h3,{...n,ref:e,forceMount:r}):i.type==="scroll"?h.jsx(u3,{...n,ref:e,forceMount:r}):i.type==="auto"?h.jsx(Xb,{...n,ref:e,forceMount:r}):i.type==="always"?h.jsx(If,{...n,ref:e}):null});Mf.displayName=hn;var h3=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),[s,o]=C.useState(!1);return C.useEffect(()=>{const a=i.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),o(!0)},u=()=>{l=window.setTimeout(()=>o(!1),i.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[i.scrollArea,i.scrollHideDelay]),h.jsx(Jn,{present:r||s,children:h.jsx(Xb,{"data-state":s?"visible":"hidden",...n,ref:e})})}),u3=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Ir(hn,t.__scopeScrollArea),s=t.orientation==="horizontal",o=Dc(()=>l("SCROLL_END"),100),[a,l]=l3("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return C.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,i.scrollHideDelay,l]),C.useEffect(()=>{const c=i.viewport,u=s?"scrollLeft":"scrollTop";if(c){let d=c[u];const p=()=>{const f=c[u];d!==f&&(l("SCROLL"),o()),d=f};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[i.viewport,s,l,o]),h.jsx(Jn,{present:r||a!=="hidden",children:h.jsx(If,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:ir(t.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ir(t.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Xb=C.forwardRef((t,e)=>{const r=Ir(hn,t.__scopeScrollArea),{forceMount:n,...i}=t,[s,o]=C.useState(!1),a=t.orientation==="horizontal",l=Dc(()=>{if(r.viewport){const c=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;o(a?c:u)}},10);return Bs(r.viewport,l),Bs(r.content,l),h.jsx(Jn,{present:n||s,children:h.jsx(If,{"data-state":s?"visible":"hidden",...i,ref:e})})}),If=C.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,i=Ir(hn,t.__scopeScrollArea),s=C.useRef(null),o=C.useRef(0),[a,l]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=t1(a.viewport,a.content),u={...n,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:p=>o.current=p};function d(p,f){return x3(p,o.current,a,f)}return r==="horizontal"?h.jsx(d3,{...u,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const p=i.viewport.scrollLeft,f=og(p,a,i.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:p=>{i.viewport&&(i.viewport.scrollLeft=p)},onDragScroll:p=>{i.viewport&&(i.viewport.scrollLeft=d(p,i.dir))}}):r==="vertical"?h.jsx(f3,{...u,ref:e,onThumbPositionChange:()=>{if(i.viewport&&s.current){const p=i.viewport.scrollTop,f=og(p,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:p=>{i.viewport&&(i.viewport.scrollTop=p)},onDragScroll:p=>{i.viewport&&(i.viewport.scrollTop=d(p))}}):null}),d3=C.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...i}=t,s=Ir(hn,t.__scopeScrollArea),[o,a]=C.useState(),l=C.useRef(null),c=Nr(e,l,s.onScrollbarXChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),h.jsx(Zb,{"data-orientation":"horizontal",...i,ref:c,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Pc(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.x),onDragScroll:u=>t.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollLeft+u.deltaX;t.onWheelScroll(p),r1(p,d)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Rl(o.paddingLeft),paddingEnd:Rl(o.paddingRight)}})}})}),f3=C.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...i}=t,s=Ir(hn,t.__scopeScrollArea),[o,a]=C.useState(),l=C.useRef(null),c=Nr(e,l,s.onScrollbarYChange);return C.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),h.jsx(Zb,{"data-orientation":"vertical",...i,ref:c,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Pc(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.y),onDragScroll:u=>t.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(s.viewport){const p=s.viewport.scrollTop+u.deltaY;t.onWheelScroll(p),r1(p,d)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&o&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Rl(o.paddingTop),paddingEnd:Rl(o.paddingBottom)}})}})}),[p3,Kb]=Ub(hn),Zb=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:i,onThumbChange:s,onThumbPointerUp:o,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:d,...p}=t,f=Ir(hn,r),[m,x]=C.useState(null),g=Nr(e,P=>x(P)),y=C.useRef(null),b=C.useRef(""),k=f.viewport,T=n.content-n.viewport,_=Br(u),w=Br(l),E=Dc(d,10);function B(P){if(y.current){const N=P.clientX-y.current.left,M=P.clientY-y.current.top;c({x:N,y:M})}}return C.useEffect(()=>{const P=N=>{const M=N.target;(m==null?void 0:m.contains(M))&&_(N,T)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[k,m,T,_]),C.useEffect(w,[n,w]),Bs(m,E),Bs(f.content,E),h.jsx(p3,{scope:r,scrollbar:m,hasThumb:i,onThumbChange:Br(s),onThumbPointerUp:Br(o),onThumbPositionChange:w,onThumbPointerDown:Br(a),children:h.jsx(br.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:ir(t.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=m.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),B(P))}),onPointerMove:ir(t.onPointerMove,B),onPointerUp:ir(t.onPointerUp,P=>{const N=P.target;N.hasPointerCapture(P.pointerId)&&N.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Ol="ScrollAreaThumb",Qb=C.forwardRef((t,e)=>{const{forceMount:r,...n}=t,i=Kb(Ol,t.__scopeScrollArea);return h.jsx(Jn,{present:r||i.hasThumb,children:h.jsx(m3,{ref:e,...n})})}),m3=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...i}=t,s=Ir(Ol,r),o=Kb(Ol,r),{onThumbPositionChange:a}=o,l=Nr(e,d=>o.onThumbChange(d)),c=C.useRef(void 0),u=Dc(()=>{c.current&&(c.current(),c.current=void 0)},100);return C.useEffect(()=>{const d=s.viewport;if(d){const p=()=>{if(u(),!c.current){const f=y3(d,a);c.current=f,a()}};return a(),d.addEventListener("scroll",p),()=>d.removeEventListener("scroll",p)}},[s.viewport,u,a]),h.jsx(br.div,{"data-state":o.hasThumb?"visible":"hidden",...i,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:ir(t.onPointerDownCapture,d=>{const f=d.target.getBoundingClientRect(),m=d.clientX-f.left,x=d.clientY-f.top;o.onThumbPointerDown({x:m,y:x})}),onPointerUp:ir(t.onPointerUp,o.onThumbPointerUp)})});Qb.displayName=Ol;var Ff="ScrollAreaCorner",Jb=C.forwardRef((t,e)=>{const r=Ir(Ff,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?h.jsx(g3,{...t,ref:e}):null});Jb.displayName=Ff;var g3=C.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,i=Ir(Ff,r),[s,o]=C.useState(0),[a,l]=C.useState(0),c=!!(s&&a);return Bs(i.scrollbarX,()=>{var d;const u=((d=i.scrollbarX)==null?void 0:d.offsetHeight)||0;i.onCornerHeightChange(u),l(u)}),Bs(i.scrollbarY,()=>{var d;const u=((d=i.scrollbarY)==null?void 0:d.offsetWidth)||0;i.onCornerWidthChange(u),o(u)}),c?h.jsx(br.div,{...n,ref:e,style:{width:s,height:a,position:"absolute",right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Rl(t){return t?parseInt(t,10):0}function t1(t,e){const r=t/e;return isNaN(r)?0:r}function Pc(t){const e=t1(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function x3(t,e,r,n="ltr"){const i=Pc(r),s=i/2,o=e||s,a=i-o,l=r.scrollbar.paddingStart+o,c=r.scrollbar.size-r.scrollbar.paddingEnd-a,u=r.content-r.viewport,d=n==="ltr"?[0,u]:[u*-1,0];return e1([l,c],d)(t)}function og(t,e,r="ltr"){const n=Pc(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-i,o=e.content-e.viewport,a=s-n,l=r==="ltr"?[0,o]:[o*-1,0],c=a3(t,l);return e1([0,o],[0,a])(c)}function e1(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function r1(t,e){return t>0&&t<e}var y3=(t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return(function i(){const s={left:t.scrollLeft,top:t.scrollTop},o=r.left!==s.left,a=r.top!==s.top;(o||a)&&e(),r=s,n=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(n)};function Dc(t,e){const r=Br(t),n=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),C.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function Bs(t,e){const r=Br(e);Ls(()=>{let n=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return i.observe(t),()=>{window.cancelAnimationFrame(n),i.unobserve(t)}}},[t,r])}var n1=Gb,b3=Yb,C3=Jb;const Hn=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(n1,{ref:n,className:rt("relative overflow-hidden",t),...r,children:[h.jsx(b3,{className:"h-full w-full rounded-[inherit]",children:e}),h.jsx(i1,{}),h.jsx(C3,{})]}));Hn.displayName=n1.displayName;const i1=C.forwardRef(({className:t,orientation:e="vertical",...r},n)=>h.jsx(Mf,{ref:n,orientation:e,className:rt("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:h.jsx(Qb,{className:"relative flex-1 rounded-full bg-border"})}));i1.displayName=Mf.displayName;var k3=Symbol.for("react.lazy"),$l=tf[" use ".trim().toString()];function v3(t){return typeof t=="object"&&t!==null&&"then"in t}function s1(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===k3&&"_payload"in t&&v3(t._payload)}function o1(t){const e=S3(t),r=C.forwardRef((n,i)=>{let{children:s,...o}=n;s1(s)&&typeof $l=="function"&&(s=$l(s._payload));const a=C.Children.toArray(s),l=a.find(_3);if(l){const c=l.props.children,u=a.map(d=>d===l?C.Children.count(c)>1?C.Children.only(null):C.isValidElement(c)?c.props.children:null:d);return h.jsx(e,{...o,ref:i,children:C.isValidElement(c)?C.cloneElement(c,void 0,u):null})}return h.jsx(e,{...o,ref:i,children:s})});return r.displayName=`${t}.Slot`,r}var w3=o1("Slot");function S3(t){const e=C.forwardRef((r,n)=>{let{children:i,...s}=r;if(s1(i)&&typeof $l=="function"&&(i=$l(i._payload)),C.isValidElement(i)){const o=N3(i),a=E3(s,i.props);return i.type!==C.Fragment&&(a.ref=n?Fc(n,o):o),C.cloneElement(i,a)}return C.Children.count(i)>1?C.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var T3=Symbol("radix.slottable");function _3(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===T3}function E3(t,e){const r={...e};for(const n in e){const i=t[n],s=e[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(r[n]=i):n==="style"?r[n]={...i,...s}:n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return{...t,...r}}function N3(t){var n,i;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var j3=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],L3=j3.reduce((t,e)=>{const r=o1(`Primitive.${e}`),n=C.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{}),B3="Separator",ag="horizontal",A3=["horizontal","vertical"],a1=C.forwardRef((t,e)=>{const{decorative:r,orientation:n=ag,...i}=t,s=M3(n)?n:ag,a=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return h.jsx(L3.div,{"data-orientation":s,...a,...i,ref:e})});a1.displayName=B3;function M3(t){return A3.includes(t)}var l1=a1;const zl=C.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},i)=>h.jsx(l1,{ref:i,decorative:r,orientation:e,className:rt("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));zl.displayName=l1.displayName;function I3({agentId:t,status:e}){const[r,n]=C.useState(""),[i,s]=C.useState(""),o=C.useRef(null),a=C.useRef(!1),l=C.useCallback(()=>{const d=o.current;d&&(a.current=d.scrollTop+d.clientHeight<d.scrollHeight-20)},[]);C.useEffect(()=>{const d=o.current;d&&!a.current&&(d.scrollTop=d.scrollHeight)},[r,i]),C.useEffect(()=>{if(!t)return;const d=async()=>{try{const p=await Rt(`/api/agent/${t}`);if(!p.ok)return;const f=await p.json();f.output!=null&&n(f.output),f.stderr!=null&&s(f.stderr)}catch{}};if(d(),e==="running"){const p=setInterval(d,2e3);return()=>clearInterval(p)}},[t,e]);const c=!r&&!i,u=e==="running";return h.jsx("div",{children:h.jsx("div",{ref:o,onScroll:l,className:"overflow-auto max-h-[300px] rounded bg-muted/30 p-2",children:c?h.jsx("p",{className:"text-[10px] font-mono text-muted-foreground italic",children:u?"Waiting for output...":"No output"}):h.jsxs(h.Fragment,{children:[r&&h.jsx("pre",{className:"text-[10px] font-mono text-muted-foreground whitespace-pre-wrap break-all m-0",children:r}),i&&h.jsxs("div",{className:"mt-2",children:[h.jsx("span",{className:"text-[10px] font-mono font-medium text-destructive",children:"stderr"}),h.jsx("pre",{className:"text-[10px] font-mono text-destructive whitespace-pre-wrap break-all m-0 mt-0.5",children:i})]})]})})})}const F3=Yt.memo(I3);function P3(t){if(!t)return"";const e=Math.floor((Date.now()-new Date(t).getTime())/1e3);return e<5?"now":e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:`${Math.floor(e/3600)}h ago`}function D3({agentId:t,relays:e}){const r=C.useMemo(()=>!e||!t?[]:e.filter(n=>n.fromAgentId===t||n.toAgentId===t),[e,t]);return r.length===0?null:h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Relays"}),h.jsx("div",{className:"space-y-0.5",children:r.map((n,i)=>{const s=n.direction==="result";return h.jsxs("div",{className:"flex items-start gap-1 text-[10px] font-mono",children:[h.jsx("span",{className:s?"text-foreground shrink-0":"text-muted-foreground shrink-0",children:s?"→":"←"}),h.jsx("span",{className:s?"text-foreground truncate":"text-muted-foreground truncate",title:n.messagePreview,children:n.messagePreview}),h.jsx("span",{className:"text-muted-foreground opacity-50 ml-auto shrink-0 tabular-nums",children:P3(n.timestamp)})]},n.id||i)})})]})}const O3=Yt.memo(D3),R3={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking"},lg={build_error:"Build",test_failure:"Test",lint_error:"Lint",git_conflict:"Conflict",permission_error:"Permission",not_found:"Not Found",runtime_error:"Error"};function Fh(t){if(!t||t<1e3)return"<1s";const e=Math.floor(t/1e3);return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}const $3=Yt.memo(function({startedAt:e,active:r,duration:n}){const[,i]=Yt.useState(0);Yt.useEffect(()=>{if(!r)return;const l=setInterval(()=>i(c=>c+1),1e3);return()=>clearInterval(l)},[r]);const s=r?Math.floor((Date.now()-new Date(e).getTime())/1e3):n||0,o=Math.floor(s/60),a=s%60;return h.jsxs("span",{className:"tabular-nums",children:[o,"m ",String(a).padStart(2,"0"),"s"]})});function z3({agentActivity:t,agentErrors:e,sessionState:r,onSelectItem:n,spawnedAgents:i,agentRelays:s,onStopAgent:o}){var x,g,y,b;const[a,l]=Yt.useState(null),[c,u]=Yt.useState({status:"idle",tool:null,category:null,activityLog:[],currentActivity:null}),[,d]=Yt.useState(0),[p,f]=Yt.useState([]),m=Yt.useRef(null);return Yt.useEffect(()=>{const k=T=>u(T.detail);return window.addEventListener("compose:agent-status",k),()=>window.removeEventListener("compose:agent-status",k)},[]),Yt.useEffect(()=>{if(c.status!=="working")return;const k=setInterval(()=>d(T=>T+1),1e3);return()=>clearInterval(k)},[c.status]),Yt.useEffect(()=>{if(!t||t.length===0)return;const k=t[t.length-1];Array.isArray(k.items)&&k.items.length>0&&(f(k.items),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>f([]),3e4))},[t]),Yt.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),h.jsxs(h.Fragment,{children:[i&&i.length>0&&h.jsxs("div",{className:"flex items-center gap-0.5 mb-1.5 overflow-x-auto px-3",children:[h.jsx("button",{onClick:()=>l(null),className:rt("text-[10px] px-2 py-0.5 rounded cursor-pointer transition-colors border shrink-0",a?"bg-transparent text-muted-foreground border-border hover:text-foreground":"bg-primary text-primary-foreground border-primary"),children:"Session"}),i.map(k=>h.jsxs("span",{className:"flex items-center gap-0 shrink-0",children:[h.jsxs("button",{onClick:()=>l(k.agentId),className:rt("text-[10px] px-2 py-0.5 rounded-l cursor-pointer transition-colors border flex items-center gap-1 shrink-0",a===k.agentId?"bg-primary text-primary-foreground border-primary":"bg-transparent text-muted-foreground border-border hover:text-foreground"),children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:k.status==="killed"?"hsl(var(--destructive))":k.silent?"hsl(45 93% 47%)":k.status==="running"?"hsl(var(--success))":k.status==="complete"?"hsl(142 71% 45%)":"hsl(var(--destructive))",animation:k.status==="running"&&!k.silent?"phase-active-pulse 2s ease-in-out infinite":"none"}}),k.agentType,k.silent&&h.jsx("span",{className:"text-[8px] text-yellow-500 ml-0.5",title:"Agent silent",children:"!"})]}),k.status==="running"&&o&&h.jsx("button",{onClick:T=>{T.stopPropagation(),o(k.agentId)},className:"text-[10px] px-1 py-0.5 rounded-r border border-l-0 border-border hover:bg-destructive/20 hover:text-destructive cursor-pointer transition-colors",title:"Stop agent",children:"x"})]},k.agentId))]}),a?h.jsxs("div",{className:"px-3 pb-2 space-y-2",children:[h.jsx(F3,{agentId:a,status:(x=i.find(k=>k.agentId===a))==null?void 0:x.status}),h.jsx(O3,{agentId:a,relays:s})]}):h.jsxs(h.Fragment,{children:[(r==null?void 0:r.featureCode)&&h.jsxs("div",{className:"px-3 py-1.5 mb-1 rounded bg-muted/50",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Working on"}),h.jsx("button",{className:"font-medium text-foreground hover:underline",onClick:()=>r.featureItemId&&(n==null?void 0:n(r.featureItemId)),children:r.featureCode})]}),r.phaseAtBind&&h.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Phase: ",r.phaseAtBind.replace(/_/g," ")]})]}),r&&h.jsxs("div",{className:"px-3 pb-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:r.active?"hsl(var(--primary))":"hsl(var(--success))"}}),h.jsx($3,{startedAt:r.startedAt,active:r.active,duration:r.duration}),h.jsxs("span",{className:"tabular-nums",children:[r.toolCount||0," tools"]}),r.errorCount>0&&h.jsxs("span",{style:{color:"hsl(var(--destructive))"},children:[r.errorCount," err"]}),!r.active&&r.journalSpawned&&h.jsx("span",{style:{color:"hsl(var(--primary))"},children:"journal"})]}),((g=r.summaries)==null?void 0:g.length)>0&&h.jsx("p",{className:"text-[10px] mt-0.5 truncate",style:{color:"hsl(var(--muted-foreground))",opacity:.7},title:(y=r.summaries[r.summaries.length-1])==null?void 0:y.summary,children:(b=r.summaries[r.summaries.length-1])==null?void 0:b.summary})]}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("div",{className:"rounded-md p-2",style:{background:"hsl(var(--accent))"},children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:c.status==="working"?"var(--color-category-writing)":"hsl(var(--success))",animation:c.status==="working"?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider",style:{color:c.status==="working"?"var(--color-category-writing)":"hsl(var(--muted-foreground))"},children:c.status==="working"?R3[c.category]||"Working":"Idle"}),c.status==="working"&&c.tool&&h.jsx("span",{className:"text-[10px] tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:c.tool}),c.status==="working"&&c.currentActivity&&h.jsx("span",{className:"text-[10px] tabular-nums ml-auto",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:Fh(Date.now()-c.currentActivity.startTime)})]}),c.activityLog&&c.activityLog.length>0&&h.jsx("div",{className:"flex items-center gap-0.5 mt-1",children:c.activityLog.slice(-6).map((k,T,_)=>h.jsx("div",{className:"h-1 rounded-full",title:`${k.tool||"thinking"} — ${Fh(k.duration)}`,style:{width:Math.max(4,Math.min(16,(k.duration||0)/1e3*2)),background:Kp[k.category]||(c.status==="working"?"var(--color-category-writing)":"hsl(var(--success))"),opacity:.2+T/_.length*.6}},T))}),t&&t.length>0&&h.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.slice(-4).map((k,T)=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px]",style:{color:k.error?"hsl(var(--destructive))":"hsl(var(--muted-foreground))"},children:[k.error&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"font-medium shrink-0",children:k.tool}),k.category&&!k.error&&h.jsx("span",{className:"shrink-0 opacity-50",style:{color:Kp[k.category]},children:k.category}),k.error?h.jsx("span",{className:"truncate",title:k.error.type,children:lg[k.error.type]||k.error.type}):k.detail?h.jsx("span",{className:"truncate opacity-60",title:k.detail,children:k.detail.split("/").pop()}):null]},T))}),p.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Working on"}),p.slice(0,3).map(k=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{children:k.status==="in_progress"?"◆":"◇"}),h.jsx("span",{className:"truncate",children:k.title})]},k.id))]}),e&&e.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--destructive))"},children:"Errors"}),e.slice(-3).map((k,T)=>h.jsxs("div",{className:"flex items-center gap-1 text-[10px] py-0.5",style:{color:"hsl(var(--destructive))"},children:[h.jsx("span",{className:"font-medium shrink-0",children:lg[k.errorType]||k.errorType}),h.jsx("span",{className:"truncate opacity-70",title:k.message,children:k.message})]},T))]}),i&&i.length>0&&h.jsxs("div",{className:"mt-1.5",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider mb-0.5",style:{color:"hsl(var(--muted-foreground))"},children:"Subagents"}),i.map(k=>h.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:k.status==="running"?"var(--color-category-executing)":k.status==="complete"?"hsl(var(--success))":"hsl(var(--destructive))",animation:k.status==="running"?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"font-medium shrink-0",children:k.agentType}),h.jsx("span",{className:"truncate opacity-60",children:k.status}),h.jsx("span",{className:"tabular-nums ml-auto opacity-50",children:Fh(Date.now()-new Date(k.startedAt).getTime())})]},k.agentId))]})]})})]})]})}const W3=Yt.memo(z3),Do={DECISION:1,PENDING_GATE:2,BLOCKED:3};function c1(t,e){const r=new Set((e||[]).filter(s=>s.status==="pending").map(s=>s.itemId)),n=new Map,i=(s,o,a)=>{const l=n.get(s.id);(!l||o>l.priority)&&n.set(s.id,{item:s,priority:o,reason:a})};for(const s of t||[])s.status==="blocked"&&i(s,Do.BLOCKED,"Blocked"),r.has(s.id)&&i(s,Do.PENDING_GATE,"Pending gate"),s.type==="decision"&&s.status!=="complete"&&s.status!=="killed"&&s.status!=="parked"&&i(s,Do.DECISION,"Open decision");return Array.from(n.values()).sort((s,o)=>o.priority-s.priority)}function q3(t){if(!t)return{isRunning:!1,pct:0,stepLabel:"",featureCode:"",stepNum:0,totalSteps:0,status:""};const{currentStepId:e,stepNum:r,totalSteps:n,status:i,featureCode:s}=t,o=i==="running",a=n>0?r/n*100:0,l=Math.min(100,Math.max(0,Math.round(a))),c=e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g," "):"";return{isRunning:o,pct:l,stepLabel:c,featureCode:s||"",stepNum:r??0,totalSteps:n??0,status:i||""}}function h1(t,e){const r=t||[],n=e||[];let i=0,s=0,o=0;for(const l of r)l.status==="in_progress"&&i++,l.status==="blocked"&&s++;const a=n.filter(l=>l.status==="pending"||l.status==="awaiting").length;return o=c1(r,n).length,{total:r.length,inProgress:i,blocked:s,pendingGates:a,attentionCount:o}}function H3(t,e){return t&&t===e?null:e}const U3={planned:{bg:"bg-slate-500/15",text:"text-slate-400",dot:"bg-slate-400"},ready:{bg:"bg-sky-500/15",text:"text-sky-400",dot:"bg-sky-400"},in_progress:{bg:"bg-blue-500/15",text:"text-blue-400",dot:"bg-blue-400"},review:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"},complete:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},blocked:{bg:"bg-rose-500/15",text:"text-rose-400",dot:"bg-rose-400"},parked:{bg:"bg-slate-500/15",text:"text-slate-500",dot:"bg-slate-500"},killed:{bg:"bg-slate-500/15",text:"text-slate-600",dot:"bg-slate-600"},pending:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"},resolved:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},active:{bg:"bg-blue-500/15",text:"text-blue-400",dot:"bg-blue-400"},completed:{bg:"bg-emerald-500/15",text:"text-emerald-400",dot:"bg-emerald-400"},failed:{bg:"bg-rose-500/15",text:"text-rose-400",dot:"bg-rose-400"},paused:{bg:"bg-amber-500/15",text:"text-amber-400",dot:"bg-amber-400"}},G3={bg:"bg-slate-500/10",text:"text-slate-400",dot:"bg-slate-400"};function Pf({status:t,className:e}){const r=U3[t]||G3,n=t?t.replace(/_/g," "):"—";return h.jsxs("span",{className:rt("inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium",r.bg,r.text,e),children:[h.jsx("span",{className:rt("w-1 h-1 rounded-full shrink-0",r.dot)}),n]})}const V3={vision:"text-violet-400 bg-violet-500/10 border-violet-500/20",specification:"text-purple-400 bg-purple-500/10 border-purple-500/20",planning:"text-cyan-400 bg-cyan-500/10 border-cyan-500/20",implementation:"text-amber-400 bg-amber-500/10 border-amber-500/20",verification:"text-emerald-400 bg-emerald-500/10 border-emerald-500/20",release:"text-green-400 bg-green-500/10 border-green-500/20"},Y3="text-slate-400 bg-slate-500/10 border-slate-500/20";function X3({phase:t,className:e}){const r=V3[t]||Y3;return h.jsx("span",{className:rt("inline-flex items-center px-2 py-0.5 rounded-full border text-xs font-mono",r,e),children:t||"—"})}async function An(t,e={}){const r=await Rt(t,e),n=await r.json();if(!r.ok)throw new Error(n.error||`HTTP ${r.status}`);return n}let Ph=null;function u1(t){if(Ph)return;const e=window.location.protocol==="https:"?"wss:":"ws:",r=new WebSocket(`${e}//${window.location.host}/ws/vision`);Ph=r,r.onmessage=n=>{try{const i=JSON.parse(n.data);i.type==="ideaboxUpdated"&&t(i)}catch{}},r.onclose=()=>{Ph=null,setTimeout(()=>{u1(t)},3e3)},r.onerror=()=>{}}const As=Nf((t,e)=>(setTimeout(()=>e().hydrate(),0),setTimeout(()=>{u1(()=>{e().hydrate()})},500),{ideas:[],killed:[],loading:!1,error:null,selectedIdeaId:null,filters:{tag:"",status:"",priority:"",search:""},hydrate:async()=>{t({loading:!0,error:null});try{const r=await An("/api/ideabox");t({ideas:r.ideas||[],killed:r.killed||[],loading:!1})}catch(r){t({error:r.message,loading:!1})}},addIdea:async r=>{const n=await An("/api/ideabox/ideas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});return await e().hydrate(),n},promoteIdea:async(r,n="")=>{const i=await An(`/api/ideabox/ideas/${r}/promote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({featureCode:n})});return await e().hydrate(),i},killIdea:async(r,n="")=>{const i=await An(`/api/ideabox/ideas/${r}/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:n})});return await e().hydrate(),i},setPriority:async(r,n)=>{const i=await An(`/api/ideabox/ideas/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:n})});return t(s=>({ideas:s.ideas.map(o=>o.id===r?{...o,priority:n}:o)})),i},resurrectIdea:async r=>{const n=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}/resurrect`,{method:"POST"});return await e().hydrate(),n},addDiscussion:async(r,n,i)=>{const s=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}/discuss`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({author:n,text:i})});return await e().hydrate(),s},updateIdea:async(r,n)=>{const i=await An(`/api/ideabox/ideas/${encodeURIComponent(r)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await e().hydrate(),i},setSelectedIdea:r=>t({selectedIdeaId:r}),updateFilters:r=>t(n=>({filters:{...n.filters,...r}})),clearFilters:()=>t({filters:{tag:"",status:"",priority:"",search:""}})}));function K3({activeBuild:t}){const e=q3(t);if(!t)return null;const r=e.isRunning?"hsl(var(--primary))":e.status==="complete"?"hsl(var(--success))":e.status==="failed"||e.status==="killed"?"hsl(var(--destructive))":"hsl(var(--muted-foreground))";return h.jsxs("div",{className:"mx-3 mb-2 rounded-md p-2",style:{background:"hsl(var(--accent))"},children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Pl,{className:"h-3 w-3 shrink-0",style:{color:r}}),h.jsx("span",{className:"text-[10px] font-medium truncate max-w-[100px]",style:{color:"hsl(var(--foreground))"},children:e.featureCode||"Build"})]}),h.jsxs("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))"},children:[e.stepNum,"/",e.totalSteps]})]}),h.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${e.pct}%`,background:r}})}),h.jsxs("div",{className:"flex items-center justify-between mt-1",children:[h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:e.stepLabel}),e.isRunning&&h.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--primary))",animation:"pulse 1.5s ease-in-out infinite"}})]})]})}function Z3({items:t,gates:e,onSelectItem:r,onViewChange:n}){const i=Yt.useMemo(()=>c1(t,e),[t,e]);if(i.length===0)return null;const s=i.slice(0,5),o=i.length-s.length,a=l=>l===Do.BLOCKED?h.jsx(Ac,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--destructive))"}}):l===Do.PENDING_GATE?h.jsx(AM,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--warning))"}}):h.jsx(IA,{className:"h-3 w-3 shrink-0",style:{color:"hsl(var(--muted-foreground))"}});return h.jsxs("div",{className:"px-2 mb-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Needs Attention"}),s.map(({item:l,priority:c,reason:u})=>h.jsxs("button",{onClick:()=>r==null?void 0:r(l.id),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))"},title:u,children:[a(c),h.jsx("span",{className:"truncate flex-1 text-left",children:l.title}),l.phase&&h.jsx(X3,{phase:l.phase,className:"shrink-0 text-[9px] px-1.5 py-0 h-4"}),h.jsx(Pf,{status:l.status,className:"shrink-0"})]},l.id)),o>0&&h.jsxs("button",{onClick:()=>n==null?void 0:n("attention"),className:"flex w-full items-center px-2 py-0.5 text-[10px] rounded-md hover:bg-sidebar-accent/50 transition-colors",style:{color:"hsl(var(--muted-foreground))"},children:["+",o," more"]})]})}function Q3({items:t,gates:e}){const r=Yt.useMemo(()=>h1(t,e),[t,e]);return r.total===0?null:h.jsxs("div",{className:"flex items-center gap-2 flex-wrap px-3 pb-1",children:[h.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.total," items"]}),r.inProgress>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--primary))"},children:[r.inProgress," active"]}),r.blocked>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--destructive))"},children:[r.blocked," blocked"]}),r.pendingGates>0&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--warning))"},children:[r.pendingGates," ",r.pendingGates===1?"gate":"gates"]})]})}const J3=new Set(["planned","ready","in_progress","review","blocked","parked"]);function tF({items:t,hiddenGroups:e,onToggleGroup:r}){const n=Yt.useMemo(()=>{const i={},s={};for(const o of t){const a=o.title||"";if(a.startsWith("`docs/")||a.startsWith("docs/")||!J3.has(o.status))continue;const l=o.group||"other";i[l]=(i[l]||0)+1,["in_progress","review","ready"].includes(o.status)&&(s[l]=(s[l]||0)+1)}return Object.entries(i).sort((o,a)=>(s[a[0]]||0)-(s[o[0]]||0)||a[1]-o[1]||o[0].localeCompare(a[0])).map(([o,a])=>({group:o,count:a,active:s[o]||0}))},[t]);return n.length<=1?null:h.jsx(h.Fragment,{children:n.map(({group:i,count:s,active:o})=>{const a=e==null?void 0:e.has(i);return h.jsxs("button",{onClick:()=>r==null?void 0:r(i),className:"flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))",opacity:a?.4:1,fontWeight:o>0?500:400},children:[h.jsx("span",{className:"truncate flex-1 text-left",children:i}),o>0&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--primary))"},children:o}),h.jsx("span",{className:"text-[10px] tabular-nums shrink-0",style:{color:"hsl(var(--muted-foreground))"},children:s})]},i)})})}function eF({onViewChange:t}){const e=As(n=>n.ideas),r=Yt.useMemo(()=>e.filter(n=>!n.priority||n.priority==="—").length,[e]);return r===0?null:h.jsxs("div",{className:"px-2 mb-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Ideas"}),h.jsxs("button",{onClick:()=>t==null?void 0:t("ideabox"),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-sidebar-accent/50",style:{color:"hsl(var(--muted-foreground))"},title:"View untriaged ideas",children:[h.jsx(xi,{className:"h-3 w-3 shrink-0 text-amber-400"}),h.jsxs("span",{className:"flex-1 text-left",children:[r," untriaged"]})]})]})}function d1({items:t,gates:e,activeBuild:r,onViewChange:n,selectedPhase:i,onPhaseSelect:s,selectedTrack:o,onTrackSelect:a,visibleTracks:l,onToggleVisibleTrack:c,onShowAllTracks:u,hiddenGroups:d,onToggleGroup:p,searchQuery:f,onSearchChange:m,connected:x,agentActivity:g,agentErrors:y,spawnedAgents:b,agentRelays:k,sessionState:T,onSelectItem:_,onStopAgent:w,onThemeChange:E,onNewItem:B,widthPx:P}){const N=t||[],M=e||[],$=Yt.useMemo(()=>h1(N,M),[N,M]),[q,O]=Yt.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("dark"));Yt.useEffect(()=>{if(typeof document>"u")return;const A=new MutationObserver(()=>{O(document.documentElement.classList.contains("dark"))});return A.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>A.disconnect()},[]);const I=Yt.useCallback(()=>{const A=!q,D=A?"dark":"light";typeof document<"u"&&document.documentElement.classList.toggle("dark",A);try{localStorage.setItem("compose:theme",D)}catch{}E&&E({ui:{theme:D}})},[q,E]);return Yt.useCallback(A=>{s&&s(H3(i,A))},[s,i]),h.jsxs("aside",{className:"shrink-0 flex flex-col bg-sidebar border-r border-sidebar-border",style:{width:P??208},children:[h.jsxs("div",{className:"p-3 pb-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:"Compose"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[!x&&h.jsx("span",{className:"text-[10px] text-destructive",children:"disconnected"}),B&&h.jsxs("button",{onClick:B,className:"flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs text-muted-foreground hover:text-foreground bg-sidebar-accent/50 hover:bg-sidebar-accent transition-colors",title:"New item (⌘N)",children:[h.jsx(Tb,{className:"h-3.5 w-3.5"}),h.jsx("span",{children:"New"})]}),h.jsx("button",{onClick:I,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-sidebar-accent transition-colors",title:q?"Switch to light mode":"Switch to dark mode",children:q?h.jsx(OM,{className:"h-3.5 w-3.5"}):h.jsx(CM,{className:"h-3.5 w-3.5"})})]})]}),h.jsx(Q3,{items:N,gates:M})]}),h.jsx(K3,{activeBuild:r}),h.jsx(W3,{agentActivity:g,agentErrors:y,sessionState:T,onSelectItem:_,onStopAgent:w,spawnedAgents:b,agentRelays:k}),$.attentionCount>0&&h.jsxs(h.Fragment,{children:[h.jsx(zl,{className:"bg-sidebar-border"}),h.jsx(Z3,{items:N,gates:M,onSelectItem:_,onViewChange:n})]}),h.jsx(eF,{onViewChange:n}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),h.jsx(Ic,{placeholder:"Search...",value:f,onChange:A=>m(A.target.value),className:"h-7 pl-7 text-xs bg-sidebar"})]})}),h.jsx(zl,{className:"bg-sidebar-border"}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider px-2 mb-1",style:{color:"hsl(var(--muted-foreground))"},children:"Groups"}),h.jsx(tF,{items:N,hiddenGroups:d,onToggleGroup:p})]})})]})}function rF({level:t,size:e=4}){return h.jsx("div",{className:"flex items-center gap-px",children:[0,1,2,3].map(r=>h.jsx("div",{className:"rounded-full",style:{width:e,height:e,background:r<t?t>=3?"hsl(var(--success))":t>=2?"hsl(var(--accent))":"hsl(var(--destructive))":"transparent",border:`1px solid ${r<t?t>=3?"hsl(var(--success))":t>=2?"hsl(var(--accent))":"hsl(var(--destructive))":"hsl(var(--border))"}`}},r))})}function pa({featureCode:t,active:e,onToggle:r}){return t?h.jsxs("button",{onClick:r,style:{fontSize:11,padding:"3px 9px",borderRadius:4,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${e?"#f59e0b":"#334155"}`,background:e?"#f59e0b20":"#1e293b",color:e?"#f59e0b":"#94a3b8"},children:["Focus: ",t]}):null}const cg=[{key:"all",label:"All",statuses:null},{key:"active",label:"Active",statuses:["planned","ready","in_progress","review"]},{key:"done",label:"Done",statuses:["complete"]},{key:"blocked",label:"Blocked",statuses:["blocked","parked"]}],nF=[{key:"all",label:"All"},{key:"feature",label:"Feature"},{key:"task",label:"Task"},{key:"track",label:"Track"}];function hg({active:t,onClick:e,children:r}){return h.jsx("button",{onClick:e,style:{fontSize:11,padding:"2px 7px",borderRadius:4,cursor:"pointer",transition:"all 0.15s",border:`1px solid ${t?"#3b82f6":"#334155"}`,background:t?"#3b82f6":"#1e293b",color:t?"#fff":"#94a3b8"},children:r})}function f1({item:t,children:e,depth:r,selectedItemId:n,onSelect:i,onToggle:s,expandedIds:o}){const a=e.length>0,l=o.has(t.id),c=n===t.id,u=xr[t.type]||xr.task,d=qn[t.status]||qn.planned,{newIds:p,changedIds:f}=C.useContext(Mc),m=p.has(t.id),x=f.has(t.id);return h.jsxs("div",{children:[h.jsxs("div",{"data-item-id":t.id,onClick:()=>i(t.id),className:rt("flex items-center gap-1.5 py-1 px-2 cursor-pointer transition-colors rounded-md","hover:bg-accent/5",c&&"bg-accent/10",m&&"bg-green-500/5 border-l-2 border-l-green-500",x&&!m&&"bg-amber-500/5 border-l-2 border-l-amber-500"),style:{paddingLeft:`${r*20+8}px`},children:[h.jsx("button",{onClick:g=>{g.stopPropagation(),a&&s(t.id)},className:rt("shrink-0 w-4 h-4 flex items-center justify-center rounded",a?"text-muted-foreground hover:text-foreground":"invisible"),children:a&&(l?h.jsx(fa,{className:"h-3.5 w-3.5"}):h.jsx(js,{className:"h-3.5 w-3.5"}))}),h.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:d}}),h.jsx("span",{className:"text-[9px] uppercase tracking-wider shrink-0 w-12",style:{color:u},children:t.type}),h.jsx("span",{className:rt("text-sm text-foreground truncate flex-1",t.status==="killed"&&"line-through opacity-50"),children:t.title}),h.jsx(rF,{level:t.confidence||0}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-3.5 shrink-0",children:t.phase})]}),a&&l&&h.jsx("div",{children:e.map(g=>h.jsx(f1,{item:g,children:g._children||[],depth:r+1,selectedItemId:n,onSelect:i,onToggle:s,expandedIds:o},g.id))})]})}function p1({items:t,connections:e,selectedItemId:r,onSelect:n,onCreate:i,featureCode:s,focusActive:o,onToggleFocus:a}){const[l,c]=C.useState(()=>new Set),[u,d]=C.useState(""),[p,f]=C.useState("all"),[m,x]=C.useState("all"),g=C.useCallback(_=>{c(w=>{const E=new Set(w);return E.has(_)?E.delete(_):E.add(_),E})},[]),y=C.useMemo(()=>{let _=t;const w=cg.find(E=>E.key===p);if(w!=null&&w.statuses&&(_=_.filter(E=>w.statuses.includes(E.status||"planned"))),m!=="all"&&(_=_.filter(E=>E.type===m)),u){const E=u.toLowerCase();_=_.filter(B=>(B.title||"").toLowerCase().includes(E)||(B.description||"").toLowerCase().includes(E)||(B.type||"").toLowerCase().includes(E)||(B.phase||"").toLowerCase().includes(E))}return o&&s&&(_=_.filter(E=>{var B;return E.featureCode===s||((B=E.lifecycle)==null?void 0:B.featureCode)===s||(E.title||"").includes(s)})),_},[t,u,p,m,o,s]),b=C.useMemo(()=>{const _=new Set(y.map(N=>N.id)),w=new Map;for(const N of y)w.set(N.id,{...N,_children:[]});const E=new Map;for(const N of e)!_.has(N.fromId)||!_.has(N.toId)||(N.type==="informs"?E.has(N.toId)||E.set(N.toId,N.fromId):(N.type==="supports"||N.type==="blocks")&&(E.has(N.fromId)||E.set(N.fromId,N.toId)));for(const N of t)N.parentId&&w.has(N.parentId)&&E.set(N.id,N.parentId);for(const[N]of E){const M=new Set;let $=N;for(;$&&E.has($);){if(M.has($)){E.delete($);break}M.add($),$=E.get($)}}const B=[];for(const N of w.values()){const M=E.get(N.id);M&&w.has(M)?w.get(M)._children.push(N):B.push(N)}const P=N=>{N.sort((M,$)=>(M.confidence||0)-($.confidence||0));for(const M of N)M._children.length>0&&P(M._children)};return P(B),B},[y,e]);Yt.useEffect(()=>{if(u){const _=new Set,w=E=>{for(const B of E)B._children.length>0&&(_.add(B.id),w(B._children))};w(b),c(_)}else l.size===0&&b.length>0&&c(new Set(b.map(_=>_.id)))},[b,u]),Yt.useEffect(()=>{if(!r||b.length===0)return;const _=[],w=(E,B)=>{for(const P of E){if(P.id===B)return!0;if(P._children.length>0&&w(P._children,B))return _.push(P.id),!0}return!1};w(b,r),_.length>0&&c(E=>{const B=new Set(E);for(const P of _)B.add(P);return B}),requestAnimationFrame(()=>{const E=document.querySelector(`[data-item-id="${r}"]`);E&&E.scrollIntoView({block:"center",behavior:"smooth"})})},[r,b]);const k=C.useCallback(()=>{const _=new Set,w=E=>{for(const B of E)B._children.length>0&&(_.add(B.id),w(B._children))};w(b),c(_)},[b]),T=C.useCallback(()=>{c(new Set)},[]);return b.filter(_=>_._children.length>0).length,h.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[h.jsx(pa,{featureCode:s,active:o,onToggle:a}),h.jsxs("div",{className:"relative flex-1 max-w-[180px]",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),h.jsx(Ic,{placeholder:"Search items...",value:u,onChange:_=>d(_.target.value),className:"h-7 pl-7 pr-7 text-xs"}),u&&h.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:h.jsx(cn,{className:"h-3 w-3"})})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground mr-0.5",children:"Status:"}),cg.map(_=>h.jsx(hg,{active:p===_.key,onClick:()=>f(_.key),children:_.label},_.key))]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground mr-0.5",children:"Type:"}),nF.map(_=>h.jsx(hg,{active:m===_.key,onClick:()=>x(_.key),children:_.label},_.key))]}),h.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[y.length,u||p!=="all"||m!=="all"?`/${t.length}`:""]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:k,className:"text-[10px] px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent/10 transition-colors",children:"Expand"}),h.jsx("button",{onClick:T,className:"text-[10px] px-1.5 py-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent/10 transition-colors",children:"Collapse"}),i&&h.jsx("button",{onClick:i,title:"Create item",style:{width:24,height:24,borderRadius:4,border:"1px solid #334155",background:"#1e293b",color:"#94a3b8",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s"},className:"hover:border-blue-500 hover:text-white",children:h.jsx(Tb,{className:"h-3.5 w-3.5"})})]}),h.jsx(Hn,{className:"flex-1",children:h.jsx("div",{className:"py-1",children:b.length===0?h.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No items to display"}):b.map(_=>h.jsx(f1,{item:_,children:_._children,depth:0,selectedItemId:r,onSelect:n,onToggle:g,expandedIds:l},_.id))})})]})}try{la.use(ry)}catch{}try{la.use(g_)}catch{}const Wl={planned:"#64748b",ready:"#3b82f6",in_progress:"#fbbf24",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#6b7280",killed:"#475569"},iF=Object.fromEntries(Object.entries(xr).map(([t,e])=>{const r=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16),s=[15,23,42],o=.15,a=[Math.round(s[0]*(1-o)+r*o),Math.round(s[1]*(1-o)+n*o),Math.round(s[2]*(1-o)+i*o)];return[t,`#${a.map(l=>l.toString(16).padStart(2,"0")).join("")}`]})),sF=[1,1.5,2,2.5,3],Wu={informs:{color:"#64748b",style:"solid"},supports:{color:"#22c55e",style:"solid"},blocks:{color:"#ef4444",style:"solid"},contradicts:{color:"#f472b6",style:"dashed"},implements:{color:"#a78bfa",style:"solid"}},ug=[{key:"all",label:"All",statuses:null},{key:"active",label:"Active",statuses:["planned","ready","in_progress","review"]},{key:"complete",label:"Done",statuses:["complete"]},{key:"blocked",label:"Blocked",statuses:["blocked","parked"]}];function wo(t){return t.group||"other"}const dg=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*[a-z]?$/,Dh=24;function oF(t){if(!t||t.length<=Dh)return t;const e=t.split("-");let r="";for(const n of e){const i=r?r+"-"+n:n;if(i.length>Dh-1)break;r=i}return(r||t.slice(0,Dh-1))+"…"}function aF(t){var i;const e=((i=t.lifecycle)==null?void 0:i.featureCode)||t.featureCode;if(e&&dg.test(e))return e;if(t.id&&dg.test(t.id)&&t.id.length<=32)return t.id;const n=(t.title||"").replace(/`/g,"").trim().match(/^([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*[a-z]?)\b/);return n&&n[1].length>=3?n[1]:t.slug?oF(t.slug):t.id?t.id.slice(0,12):"item"}function fg(t,e=18){const r=t.split("-"),n=[];let i="";for(const s of r){const o=i?i+"-"+s:s;o.length>e&&i?(n.push(i),i=s):i=o}return i&&n.push(i),n.join(`
339
339
  `)}function lF(t,e,r,n,i){var c;const s=[],o=new Set(t.map(u=>u.id));let a=null;if(n&&i){a=new Set(t.filter(u=>{var d;return u.featureCode===i||((d=u.lifecycle)==null?void 0:d.featureCode)===i||(u.title||"").startsWith(i)}).map(u=>u.id));for(const u of e)a.has(u.fromId)&&o.has(u.toId)&&a.add(u.toId),a.has(u.toId)&&o.has(u.fromId)&&a.add(u.fromId)}const l=new Set;if(r){const d=[...new Set(t.map(p=>wo(p)).filter(Boolean))].map(p=>{const f=t.filter(y=>wo(y)===p),m=f.filter(y=>["blocked","parked"].includes(y.status)).length,x=f.filter(y=>["in_progress","review","ready"].includes(y.status)).length,g=f.filter(y=>y.status==="planned").length;return{group:p,blocked:m,active:x,planned:g,total:f.length}});d.sort((p,f)=>f.active-p.active||f.blocked-p.blocked||f.planned-p.planned||p.group.localeCompare(f.group));for(const{group:p,active:f,total:m}of d){if(m<2)continue;l.add(p);const x=a&&t.some(g=>wo(g)===p&&a.has(g.id));s.push({data:{id:`group-${p}`,label:`${fg(p)}
340
340
  (${f} active, ${m} total)`,isGroup:!0,groupType:p},...a&&!x?{classes:"focus-dimmed"}:{}})}}for(const u of t){const d=u.slug||u.id.slice(0,8),p=fg(aF(u),14),f=wo(u),m=a&&!a.has(u.id);s.push({data:{id:u.id,label:p,itemType:u.type||"task",status:u.status||"planned",phase:u.phase||"vision",confidence:u.confidence??0,title:u.title,description:u.description,slug:d,featureCode:((c=u.lifecycle)==null?void 0:c.featureCode)||u.featureCode||null,group:f||null,...r&&f&&l.has(f)?{parent:`group-${f}`}:{}},...m?{classes:"focus-dimmed"}:{}})}for(const u of e){if(!o.has(u.fromId)||!o.has(u.toId))continue;let d,p;u.type==="supports"||u.type==="blocks"?(d=u.toId,p=u.fromId):(d=u.fromId,p=u.toId);const f=Wu[u.type]||Wu.informs;s.push({data:{id:u.id||`${u.fromId}-${u.toId}`,source:d,target:p,edgeType:u.type,edgeColor:f.color,edgeStyle:f.style}})}return s}function cF(){return[{selector:"[?isGroup]",style:{label:"data(label)","text-valign":"top","text-halign":"center","font-size":"10px","font-weight":600,color:"#64748b","text-transform":"uppercase","letter-spacing":"0.08em","text-wrap":"wrap","text-max-width":"160px","background-color":"#1a2537","border-width":1,"border-color":"#283548","border-style":"solid",padding:"24px","text-margin-y":-4}},{selector:"node[status]",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"9px","font-family":'-apple-system, BlinkMacSystemFont, "Segoe UI", monospace',"font-weight":500,color:"#e2e8f0","text-wrap":"wrap","text-max-width":"130px",width:"150px",height:"60px",shape:"round-rectangle","background-color":"#1e293b","border-style":"solid","border-width":2,"border-color":"#3b82f6"}},...Object.entries(Wl).map(([t,e])=>({selector:`node[status="${t}"]`,style:{"border-color":e,...t==="parked"||t==="killed"?{opacity:.7}:{}}})),...Object.entries(iF).map(([t,e])=>({selector:`node[itemType="${t}"]`,style:{"background-color":e}})),...sF.map((t,e)=>({selector:`node[confidence=${e}]`,style:{"border-width":t}})),{selector:"node:selected",style:{"background-color":"#1e3a5f","border-width":3,"border-color":"#60a5fa"}},{selector:"edge",style:{width:1.5,"line-color":"data(edgeColor)","target-arrow-color":"data(edgeColor)","target-arrow-shape":"triangle","arrow-scale":.8,"curve-style":"bezier",opacity:.6}},{selector:'edge[edgeStyle="dashed"]',style:{"line-style":"dashed","line-dash-pattern":[6,3],"target-arrow-shape":"diamond"}},{selector:'edge[edgeType="blocks"]',style:{"target-arrow-shape":"tee"}},{selector:".dimmed",style:{opacity:.35}},{selector:".focus-dimmed",style:{opacity:.15,events:"no"}},{selector:".highlighted",style:{"border-width":3,"border-color":"#60a5fa"}},{selector:".build-building",style:{"border-color":"#3b82f6","border-width":3,"shadow-color":"#3b82f6","shadow-opacity":.6,"shadow-blur":12}},{selector:".build-gate-pending",style:{"border-color":"#f59e0b","border-width":3,"shadow-color":"#f59e0b","shadow-opacity":.5,"shadow-blur":8}},{selector:".build-blocked-downstream",style:{opacity:.35,"border-color":"#94a3b8"}},{selector:".build-error",style:{"border-color":"#ef4444","border-width":3,"shadow-color":"#ef4444","shadow-opacity":.5,"shadow-blur":8}},{selector:"[?isAgentGroup]",style:{label:"data(label)","text-valign":"top","text-halign":"center","font-size":"9px",color:"#64748b","text-transform":"uppercase","background-color":"#0f1a2b","border-width":1,"border-color":"#1e3050","border-style":"dashed",padding:"14px"}},{selector:"[?isAgentNode]",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"8px","font-family":"monospace",color:"#e2e8f0","text-wrap":"wrap","text-max-width":"70px",width:"80px",height:"40px",shape:"diamond","background-color":"#1e293b","border-style":"solid","border-width":2,"border-color":"data(agentColor)"}},{selector:'[agentStatus="complete"]',style:{"border-style":"dashed",opacity:.6}},{selector:'[agentStatus="failed"]',style:{"border-color":"#ef4444","border-style":"dashed",opacity:.6}},{selector:"[?isRelayEdge]",style:{width:1,"line-color":"#475569","line-style":"dashed","line-dash-pattern":[8,4],"target-arrow-color":"#475569","target-arrow-shape":"triangle","arrow-scale":.6,"curve-style":"bezier",opacity:.4}},{selector:".relay-active",style:{width:2,"line-color":"#3b82f6",opacity:.8,"target-arrow-color":"#3b82f6"}},{selector:".relay-result",style:{width:2,"line-color":"#10b981",opacity:.8,"target-arrow-color":"#10b981"}},{selector:".idea-node",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"8px","font-family":"monospace",color:"#fbbf24","text-wrap":"wrap","text-max-width":"70px",width:"70px",height:"70px",shape:"ellipse","background-color":"#451a0310","border-style":"dashed","border-width":1.5,"border-color":"#f59e0b",opacity:.85}},{selector:'edge[edgeType="idea"]',style:{width:1,"line-color":"#f59e0b","line-style":"dashed","line-dash-pattern":[6,3],"target-arrow-color":"#f59e0b","target-arrow-shape":"triangle","arrow-scale":.7,"curve-style":"bezier",opacity:.5}}]}function hF({data:t}){if(!t)return null;const{x:e,y:r,item:n}=t,i=Wl[n.status]||Wl.planned,s=xr[n.itemType]||"#94a3b8",o=e+300>window.innerWidth?e-294:e+14,a=Math.min(r-10,window.innerHeight-200);return h.jsxs("div",{style:{position:"fixed",left:o,top:a,zIndex:9999,pointerEvents:"none",maxWidth:280,background:"#1e293b",border:"1px solid #475569",borderRadius:8,padding:"10px 13px",fontSize:12,boxShadow:"0 8px 24px rgba(0,0,0,0.5)"},children:[h.jsx("div",{style:{fontWeight:700,fontSize:13,color:"#f8fafc",marginBottom:3},children:n.slug}),h.jsx("div",{style:{color:"#94a3b8",marginBottom:6,lineHeight:1.4},children:n.title}),h.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[h.jsx(Oh,{color:i,children:(n.status||"planned").replace("_"," ")}),h.jsx(Oh,{color:s,children:n.itemType}),n.phase&&h.jsx(Oh,{color:"#94a3b8",children:jl[n.phase]||n.phase})]}),n.description&&h.jsx("div",{style:{marginTop:8,color:"#94a3b8",fontSize:11,lineHeight:1.4},children:n.description.length>140?n.description.slice(0,140)+"…":n.description}),h.jsxs("div",{style:{marginTop:6,color:"#64748b",fontSize:10},children:[ef[n.confidence||0]," confidence"]})]})}function uF({data:t,onApply:e,onClose:r}){const{x:n,y:i,currentGroup:s}=t,[o,a]=C.useState(s||""),l=C.useRef(null);C.useEffect(()=>{var p,f;(p=l.current)==null||p.focus(),(f=l.current)==null||f.select()},[]),C.useEffect(()=>{const p=f=>{f.key==="Escape"&&r()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]),C.useEffect(()=>{const p=m=>{const x=document.getElementById("group-change-popover-root");x&&!x.contains(m.target)&&r()},f=setTimeout(()=>window.addEventListener("mousedown",p),0);return()=>{clearTimeout(f),window.removeEventListener("mousedown",p)}},[r]);const c=n+240>window.innerWidth?n-234:n+14,u=Math.min(i-10,window.innerHeight-120),d=()=>e(o.trim());return h.jsxs("div",{id:"group-change-popover-root","data-testid":"group-change-popover",style:{position:"fixed",left:c,top:u,zIndex:1e4,width:220,background:"#1e293b",border:"1px solid #475569",borderRadius:8,padding:"10px 12px",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"},children:[h.jsx("div",{style:{fontSize:11,color:"#94a3b8",marginBottom:6,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Change group"}),h.jsx("input",{ref:l,type:"text",value:o,onChange:p=>a(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),d())},placeholder:"(no group)",style:{width:"100%",boxSizing:"border-box",fontSize:12,padding:"5px 7px",background:"#0f172a",color:"#f8fafc",border:"1px solid #334155",borderRadius:4,outline:"none"}}),h.jsxs("div",{style:{display:"flex",gap:6,marginTop:8,justifyContent:"flex-end"},children:[h.jsx("button",{onClick:r,style:{fontSize:11,padding:"3px 9px",borderRadius:4,cursor:"pointer",background:"transparent",color:"#94a3b8",border:"1px solid #334155"},children:"Cancel"}),h.jsx("button",{onClick:d,"data-testid":"group-change-apply",style:{fontSize:11,padding:"3px 9px",borderRadius:4,cursor:"pointer",background:"#2563eb",color:"#f8fafc",border:"1px solid #2563eb"},children:"Apply"})]})]})}function Oh({color:t,children:e}){return h.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,fontWeight:600,background:`${t}20`,color:t,border:`1px solid ${t}40`,textTransform:"uppercase",letterSpacing:"0.03em"},children:e})}const m1={fontSize:11,padding:"3px 9px",borderRadius:4,cursor:"pointer",transition:"all 0.15s"};function co({active:t,onClick:e,children:r}){return h.jsx("button",{onClick:e,style:{...m1,border:`1px solid ${t?"#3b82f6":"#334155"}`,background:t?"#3b82f6":"#1e293b",color:t?"#fff":"#94a3b8"},children:r})}function Rh({onClick:t,children:e,title:r}){return h.jsx("button",{onClick:t,title:r,style:{...m1,border:"1px solid #334155",background:"#1e293b",color:"#94a3b8"},children:e})}function Oa(){return h.jsx("div",{style:{width:1,height:20,background:"#334155",margin:"0 2px"}})}const dF=["build-building","build-gate-pending","build-blocked-downstream","build-error"],fF={building:{bg:"#3b82f620",border:"#3b82f6",color:"#3b82f6",label:"⚙"},gate_pending:{bg:"#f59e0b20",border:"#f59e0b",color:"#f59e0b",label:"⚠"},error:{bg:"#ef444420",border:"#ef4444",color:"#ef4444",label:"✖"}};function pF({badge:t,onClick:e}){const r=fF[t.state];return r?h.jsx("div",{onClick:e,style:{position:"absolute",left:t.x,top:t.y,width:16,height:16,borderRadius:"50%",background:r.bg,border:`1.5px solid ${r.border}`,color:r.color,fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",cursor:e?"pointer":"default",zIndex:100,pointerEvents:e?"auto":"none"},title:t.state.replace(/_/g," "),children:r.label}):null}function mF({featureCode:t,gates:e,items:r,badgePositions:n,onResolve:i,onClose:s}){const o=n.find(u=>u.featureCode===t);if(!o)return null;const a=r.find(u=>{var d;return((d=u.lifecycle)==null?void 0:d.featureCode)===t||u.featureCode===t||u.title===t}),l=a&&(e==null?void 0:e.find(u=>u.itemId===a.id&&!u.resolvedAt));if(!l)return null;const c=l.stepId?l.stepId.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()):"Gate";return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:{position:"fixed",inset:0,zIndex:199},onClick:s}),h.jsxs("div",{style:{position:"absolute",left:o.x-80,top:o.y+22,zIndex:200,width:200,background:"#1e293b",border:"1px solid #475569",borderRadius:8,padding:"10px 12px",boxShadow:"0 8px 24px rgba(0,0,0,0.5)"},children:[h.jsx("div",{style:{fontSize:10,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:c}),h.jsx("div",{style:{fontSize:12,color:"#f8fafc",fontWeight:600,marginBottom:8},children:t}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx("button",{onClick:()=>i(l.id,"approve"),style:{flex:1,padding:"4px 0",fontSize:10,fontWeight:600,borderRadius:4,background:"#22c55e20",color:"#22c55e",border:"1px solid #22c55e40",cursor:"pointer"},children:"Approve"}),h.jsx("button",{onClick:()=>i(l.id,"revise"),style:{flex:1,padding:"4px 0",fontSize:10,fontWeight:600,borderRadius:4,background:"#f59e0b20",color:"#f59e0b",border:"1px solid #f59e0b40",cursor:"pointer"},children:"Revise"}),h.jsx("button",{onClick:()=>i(l.id,"kill"),style:{flex:1,padding:"4px 0",fontSize:10,fontWeight:600,borderRadius:4,background:"#ef444420",color:"#ef4444",border:"1px solid #ef444440",cursor:"pointer"},children:"Kill"})]})]})]})}function g1({items:t,connections:e,selectedItemId:r,onSelect:n,visibleTracks:i,hiddenGroups:s,buildStateMap:o,resolveGate:a,gates:l,spawnedAgents:c,agentRelays:u,agentOverlay:d,featureCode:p,focusActive:f,onToggleFocus:m}){const x=C.useRef(null),g=C.useRef(null),y=C.useRef({}),b=C.useRef(!1),k=C.useRef({}),T=C.useRef(null),[_,w]=C.useState(null),[E,B]=C.useState("active"),[P,N]=C.useState(!0),[M,$]=C.useState(!1),[q,O]=C.useState(null),[I,A]=C.useState(null),[D,R]=C.useState([]),[j,S]=C.useState(!1),[W,K]=C.useState(!1),F=As(V=>V.ideas);C.useEffect(()=>{let V=!1;return Rt("/api/graph/layout").then(it=>it.ok?it.json():{positions:{}}).then(it=>{if(V)return;y.current=it.positions||{},b.current=!0;const dt=g.current;dt&&J(dt)}).catch(()=>{b.current=!0}),()=>{V=!0}},[]);const ht=C.useCallback(()=>{const V=k.current;k.current={},T.current=null,Object.keys(V).length&&Rt("/api/graph/layout",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({positions:V})}).catch(it=>console.warn("[graph-layout] save failed:",it))},[]),st=C.useCallback(V=>{Object.assign(k.current,V),Object.assign(y.current,V),T.current&&clearTimeout(T.current),T.current=setTimeout(ht,500)},[ht]),J=C.useCallback(V=>{const it=y.current,dt={};V.nodes("node[status]").forEach(Nt=>{const tt=Nt.data();if(tt.isAgentNode||tt.isIdeaNode)return;const kt=Nt.id(),G=it[kt];if(G&&Number.isFinite(G.x)&&Number.isFinite(G.y))Nt.position({x:G.x,y:G.y});else{const nt=Nt.position();Number.isFinite(nt.x)&&Number.isFinite(nt.y)&&(dt[kt]={x:nt.x,y:nt.y})}}),Object.keys(dt).length&&st(dt)},[st]),ct=C.useRef(!1);C.useEffect(()=>{const V=c==null?void 0:c.some(it=>it.status==="running");V&&!ct.current?S(!0):!V&&ct.current&&(c==null?void 0:c.length)>0&&S(!1),ct.current=!!V},[c]);const zt=C.useMemo(()=>t.filter(V=>{const it=V.title||"";return!it.startsWith("`docs/")&&!it.startsWith("docs/")}),[t]),at=C.useMemo(()=>{let V=zt;const it=ug.find(dt=>dt.key===E);if(it!=null&&it.statuses&&(V=V.filter(dt=>it.statuses.includes(dt.status||"planned"))),i){const dt=Nt=>{const tt=(Nt.description||"").match(/Track:\s*(\w+)/i);return tt?tt[1].toLowerCase():Nt.type||"other"};V=V.filter(Nt=>i.has(dt(Nt)))}return(s==null?void 0:s.size)>0&&(V=V.filter(dt=>!s.has(wo(dt)))),V},[zt,E,i,s]),Z=C.useMemo(()=>{const V=new Set(at.map(it=>it.id));return e.filter(it=>V.has(it.fromId)&&V.has(it.toId))},[e,at]),lt=C.useMemo(()=>!d||!d.nodes.length?[]:[...d.nodes,...d.edges],[c]),Ct=C.useMemo(()=>{if(!W)return[];new Set(at.map(it=>it.id));const V=[];for(const it of F){if(!it.mapsTo)continue;const dt=`idea-${it.id}`;V.push({data:{id:dt,label:`${it.id}
341
341
  ${it.title.slice(0,20)}${it.title.length>20?"…":""}`,isIdeaNode:!0,status:"idea",ideaId:it.id},classes:"idea-node"});const Nt=it.mapsTo.split(",").map(tt=>tt.trim()).filter(Boolean);for(const tt of Nt){const kt=at.find(G=>{var nt;return((nt=G.lifecycle)==null?void 0:nt.featureCode)===tt||G.featureCode===tt||(G.title||"").startsWith(tt)});kt&&V.push({data:{id:`idea-edge-${it.id}-${kt.id}`,source:dt,target:kt.id,edgeType:"idea",edgeColor:"#f59e0b",edgeStyle:"dashed"}})}}return V},[W,F,at]),Mt=C.useMemo(()=>{let it=lF(at,Z,P,f,p);return j&&lt.length>0&&(it=[...it,...lt]),W&&Ct.length>0&&(it=[...it,...Ct]),it},[at,Z,P,j,lt,W,Ct,f,p]),Dt=C.useMemo(()=>cF(),[]);C.useEffect(()=>{if(!x.current)return;g.current&&(g.current.destroy(),g.current=null);const V=la({container:x.current,elements:Mt,style:Dt,layout:{name:"fcose",quality:"proof",animate:!1,fit:!1,padding:20,nodeSeparation:80,idealEdgeLength:120,nodeRepulsion:6e3,gravity:.3,gravityRange:1.5,tilingPaddingVertical:12,tilingPaddingHorizontal:12},minZoom:.1,maxZoom:4,wheelSensitivity:.3,boxSelectionEnabled:!1});if(g.current=V,V.one("layoutstop",()=>{b.current&&J(V),V.fit(void 0,30)}),V.fit(void 0,30),V.on("dragfree","node[status]",it=>{const dt=it.target,Nt=dt.data();if(Nt.isAgentNode||Nt.isIdeaNode)return;const tt=dt.position();!Number.isFinite(tt.x)||!Number.isFinite(tt.y)||st({[dt.id()]:{x:tt.x,y:tt.y}})}),r){const it=V.$id(r);it.length&&$h(V,it)}return V.on("mouseover","node[status]",it=>{const dt=it.renderedPosition||it.position,Nt=V.container().getBoundingClientRect();w({x:Nt.left+dt.x,y:Nt.top+dt.y,item:it.target.data()})}),V.on("mousemove","node[status]",it=>{const dt=it.renderedPosition||it.position,Nt=V.container().getBoundingClientRect();w(tt=>tt?{x:Nt.left+dt.x,y:Nt.top+dt.y,item:tt.item}:null)}),V.on("mouseout","node[status]",()=>w(null)),V.on("tap","node[status]",it=>{ne.current=!0,$h(V,it.target),n(it.target.id())}),V.on("tap",it=>{it.target===V&&V.elements().removeClass("dimmed highlighted")}),V.on("cxttap","node[status]",it=>{var kt;const dt=it.target.data();if(dt.isAgentNode||dt.isIdeaNode||dt.isGroup)return;try{(kt=it.originalEvent)==null||kt.preventDefault()}catch{}const Nt=it.renderedPosition||it.position,tt=V.container().getBoundingClientRect();A({x:tt.left+Nt.x,y:tt.top+Nt.y,itemId:it.target.id(),currentGroup:dt.group||""}),w(null)}),V.container().addEventListener("contextmenu",it=>it.preventDefault()),()=>{T.current&&(clearTimeout(T.current),ht()),V.destroy(),g.current=null}},[Mt,Dt]);const ne=C.useRef(!1);C.useEffect(()=>{const V=g.current;if(!V||!r)return;const it=V.$id(r);it.length&&(V.elements().removeClass("dimmed highlighted"),$h(V,it),ne.current||V.animate({center:{eles:it},duration:200}),ne.current=!1)},[r]),C.useEffect(()=>{const V=g.current;if(V&&(V.nodes().removeClass(dF.join(" ")),!(!o||Object.keys(o).length===0)))for(const[it,dt]of Object.entries(o)){const Nt=`build-${dt.replace(/_/g,"-")}`,tt=V.nodes().filter(kt=>{const G=kt.data();return G.slug===it||G.title===it||G.featureCode===it});tt.length&&tt.addClass(Nt)}},[o]),C.useEffect(()=>{const V=g.current;if(!V||!o||!Object.values(o).includes("building"))return;let dt=!0;const Nt=setInterval(()=>{const tt=V.nodes(".build-building");tt.length&&(dt=!dt,tt.style("shadow-blur",dt?12:4),tt.style("shadow-opacity",dt?.6:.2))},800);return()=>clearInterval(Nt)},[o]),C.useEffect(()=>{var tt;const V=g.current;if(!V||(V.edges("[?isRelayEdge]").removeClass("relay-active relay-result"),!j||!((tt=d==null?void 0:d.activeEdgeIds)!=null&&tt.size)))return;const it=new Set((c||[]).map(kt=>kt.agentId)),dt=kt=>kt==="session"?"agent-session":it.has(kt)?`agent-${kt}`:"agent-session";for(const kt of d.activeEdgeIds){const G=V.getElementById(kt);if(G.length){const nt=u==null?void 0:u.findLast(wt=>{const At=dt(wt.fromAgentId),Gt=dt(wt.toAgentId);return(wt.direction==="dispatch"?`relay-${At}-${Gt}`:`relay-${Gt}-${At}`)===kt});G.addClass((nt==null?void 0:nt.direction)==="result"?"relay-result":"relay-active")}}const Nt=setInterval(()=>{const kt=V.edges(".relay-active, .relay-result");if(!kt.length)return;const G=Date.now()/20%100;kt.style("line-dash-offset",-G)},50);return()=>clearInterval(Nt)},[j,d==null?void 0:d.activeEdgeIds,u]);const ue=C.useCallback(()=>{const V=g.current;if(!V||!o||Object.keys(o).length===0){R([]);return}const it=[];for(const[dt,Nt]of Object.entries(o)){if(Nt!=="gate_pending"&&Nt!=="error"&&Nt!=="building")continue;const tt=V.nodes().filter(nt=>{const wt=nt.data();return wt.slug===dt||wt.title===dt||wt.featureCode===dt});if(!tt.length)continue;const kt=tt.renderedPosition(),G=tt.renderedOuterWidth();it.push({featureCode:dt,state:Nt,x:kt.x+G/2-6,y:kt.y-tt.renderedOuterHeight()/2-6,nodeId:tt.id()})}R(it)},[o]);C.useEffect(()=>{const V=g.current;if(V)return V.on("render pan zoom",ue),ue(),()=>{V.removeListener("render pan zoom",ue)}},[ue]);const Se=C.useCallback(()=>{var V;return(V=g.current)==null?void 0:V.fit(void 0,40)},[]),te=C.useCallback(()=>{const V=g.current;V&&V.zoom({level:V.zoom()*1.3,renderedPosition:{x:V.width()/2,y:V.height()/2}})},[]),Ae=C.useCallback(()=>{const V=g.current;V&&V.zoom({level:V.zoom()/1.3,renderedPosition:{x:V.width()/2,y:V.height()/2}})},[]);return h.jsxs("div",{className:"flex-1 flex flex-col min-h-0",style:{background:"#0f172a"},children:[h.jsx("div",{className:"shrink-0",style:{background:"#1e293b",borderBottom:"1px solid #334155"},children:h.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(pa,{featureCode:p,active:f,onToggle:m}),p&&h.jsx(Oa,{}),h.jsx("span",{style:{fontSize:11,color:"#64748b"},children:"Status:"}),ug.map(V=>h.jsx(co,{active:E===V.key,onClick:()=>B(V.key),children:V.label},V.key)),h.jsx(Oa,{}),h.jsxs("span",{style:{fontSize:10,color:"#475569"},children:[at.length," items · ",Z.length," edges"]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(co,{active:P,onClick:()=>N(!P),children:"Group"}),h.jsx(co,{active:j,onClick:()=>S(V=>!V),title:"Show/hide agent topology",children:"Agents"}),h.jsx(co,{active:W,onClick:()=>K(V=>!V),title:"Show/hide idea nodes (connected to features via mapsTo)",children:"Ideas"}),h.jsx(Oa,{}),h.jsx(Rh,{onClick:Ae,title:"Zoom out",children:"−"}),h.jsx(Rh,{onClick:Se,title:"Fit to view",children:"Fit"}),h.jsx(Rh,{onClick:te,title:"Zoom in",children:"+"}),h.jsx(Oa,{}),h.jsx(co,{active:M,onClick:()=>$(!M),children:"Legend"})]})]})}),at.length===0&&!j?h.jsx("div",{className:"flex-1 flex items-center justify-center",children:h.jsxs("div",{style:{textAlign:"center"},children:[h.jsx("div",{style:{fontSize:12,color:"#64748b",marginBottom:6},children:"No items match the current filters"}),h.jsx("div",{style:{fontSize:11,color:"#475569"},children:"Try adjusting the status or group filters"})]})}):h.jsxs("div",{className:"flex-1 relative min-h-0",children:[h.jsx("div",{ref:x,className:"w-full h-full"}),M&&h.jsxs("div",{style:{position:"absolute",bottom:16,left:16,zIndex:10,background:"#1e293b",border:"1px solid #334155",borderRadius:8,padding:"10px 13px",fontSize:11,maxHeight:"calc(100% - 32px)",overflowY:"auto"},children:[h.jsx(zh,{title:"Types",children:Object.entries(xr).map(([V,it])=>h.jsxs(qh,{children:[h.jsx(pg,{color:it}),V]},V))}),h.jsx(Wh,{}),h.jsx(zh,{title:"Status",children:Object.entries(Wl).map(([V,it])=>h.jsxs(qh,{children:[h.jsx(pg,{color:it}),V.replace("_"," ")]},V))}),h.jsx(Wh,{}),h.jsx(zh,{title:"Edges",children:Object.entries(Wu).map(([V,it])=>h.jsxs(qh,{children:[h.jsx("svg",{width:"22",height:"6",style:{flexShrink:0},children:h.jsx("line",{x1:"0",y1:"3",x2:"22",y2:"3",stroke:it.color,strokeWidth:"1.5",strokeDasharray:it.style==="dashed"?"6,3":"none"})}),V]},V))}),h.jsx(Wh,{}),h.jsxs("div",{style:{fontSize:10,color:"#475569"},children:["Border weight = confidence",h.jsx("br",{}),"Click node to trace deps"]})]}),h.jsx(hF,{data:_}),I&&h.jsx(uF,{data:I,onClose:()=>A(null),onApply:V=>{const it=I.itemId;A(null),Rt(`/api/vision/items/${it}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({group:V||null})}).catch(dt=>console.warn("[graph] group update failed:",dt))}}),D.map(V=>h.jsx(pF,{badge:V,onClick:V.state==="gate_pending"?()=>O(q===V.featureCode?null:V.featureCode):V.state==="error"?()=>n(V.nodeId):void 0},V.featureCode)),q&&h.jsx(mF,{featureCode:q,gates:l,items:t,badgePositions:D,onResolve:(V,it)=>{a&&a(V,it),O(null)},onClose:()=>O(null)})]})]})}function $h(t,e){t.elements().removeClass("dimmed highlighted");const r=e.union(e.predecessors("node[status]")).union(e.successors("node[status]")),n=r.edgesWith(r);t.nodes("[status]").not(r).addClass("dimmed"),t.edges().not(n).addClass("dimmed"),e.addClass("highlighted")}function zh({title:t,children:e}){return h.jsxs(h.Fragment,{children:[h.jsx("div",{style:{fontSize:10,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:5,fontWeight:700},children:t}),e]})}function Wh(){return h.jsx("div",{style:{height:1,background:"#334155",margin:"6px 0"}})}function qh({children:t}){return h.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:3,color:"#94a3b8"},children:t})}function pg({color:t}){return h.jsx("div",{style:{width:10,height:10,borderRadius:2,background:t,flexShrink:0}})}var dl={exports:{}},gF=dl.exports,mg;function xF(){return mg||(mg=1,(function(t,e){(function(r,n){t.exports=n()})(gF,(function(){var r=1e3,n=6e4,i=36e5,s="millisecond",o="second",a="minute",l="hour",c="day",u="week",d="month",p="quarter",f="year",m="date",x="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(O){var I=["th","st","nd","rd"],A=O%100;return"["+O+(I[(A-20)%10]||I[A]||I[0])+"]"}},k=function(O,I,A){var D=String(O);return!D||D.length>=I?O:""+Array(I+1-D.length).join(A)+O},T={s:k,z:function(O){var I=-O.utcOffset(),A=Math.abs(I),D=Math.floor(A/60),R=A%60;return(I<=0?"+":"-")+k(D,2,"0")+":"+k(R,2,"0")},m:function O(I,A){if(I.date()<A.date())return-O(A,I);var D=12*(A.year()-I.year())+(A.month()-I.month()),R=I.clone().add(D,d),j=A-R<0,S=I.clone().add(D+(j?-1:1),d);return+(-(D+(A-R)/(j?R-S:S-R))||0)},a:function(O){return O<0?Math.ceil(O)||0:Math.floor(O)},p:function(O){return{M:d,y:f,w:u,d:c,D:m,h:l,m:a,s:o,ms:s,Q:p}[O]||String(O||"").toLowerCase().replace(/s$/,"")},u:function(O){return O===void 0}},_="en",w={};w[_]=b;var E="$isDayjsObject",B=function(O){return O instanceof $||!(!O||!O[E])},P=function O(I,A,D){var R;if(!I)return _;if(typeof I=="string"){var j=I.toLowerCase();w[j]&&(R=j),A&&(w[j]=A,R=j);var S=I.split("-");if(!R&&S.length>1)return O(S[0])}else{var W=I.name;w[W]=I,R=W}return!D&&R&&(_=R),R||!D&&_},N=function(O,I){if(B(O))return O.clone();var A=typeof I=="object"?I:{};return A.date=O,A.args=arguments,new $(A)},M=T;M.l=P,M.i=B,M.w=function(O,I){return N(O,{locale:I.$L,utc:I.$u,x:I.$x,$offset:I.$offset})};var $=(function(){function O(A){this.$L=P(A.locale,null,!0),this.parse(A),this.$x=this.$x||A.x||{},this[E]=!0}var I=O.prototype;return I.parse=function(A){this.$d=(function(D){var R=D.date,j=D.utc;if(R===null)return new Date(NaN);if(M.u(R))return new Date;if(R instanceof Date)return new Date(R);if(typeof R=="string"&&!/Z$/i.test(R)){var S=R.match(g);if(S){var W=S[2]-1||0,K=(S[7]||"0").substring(0,3);return j?new Date(Date.UTC(S[1],W,S[3]||1,S[4]||0,S[5]||0,S[6]||0,K)):new Date(S[1],W,S[3]||1,S[4]||0,S[5]||0,S[6]||0,K)}}return new Date(R)})(A),this.init()},I.init=function(){var A=this.$d;this.$y=A.getFullYear(),this.$M=A.getMonth(),this.$D=A.getDate(),this.$W=A.getDay(),this.$H=A.getHours(),this.$m=A.getMinutes(),this.$s=A.getSeconds(),this.$ms=A.getMilliseconds()},I.$utils=function(){return M},I.isValid=function(){return this.$d.toString()!==x},I.isSame=function(A,D){var R=N(A);return this.startOf(D)<=R&&R<=this.endOf(D)},I.isAfter=function(A,D){return N(A)<this.startOf(D)},I.isBefore=function(A,D){return this.endOf(D)<N(A)},I.$g=function(A,D,R){return M.u(A)?this[D]:this.set(R,A)},I.unix=function(){return Math.floor(this.valueOf()/1e3)},I.valueOf=function(){return this.$d.getTime()},I.startOf=function(A,D){var R=this,j=!!M.u(D)||D,S=M.p(A),W=function(at,Z){var lt=M.w(R.$u?Date.UTC(R.$y,Z,at):new Date(R.$y,Z,at),R);return j?lt:lt.endOf(c)},K=function(at,Z){return M.w(R.toDate()[at].apply(R.toDate("s"),(j?[0,0,0,0]:[23,59,59,999]).slice(Z)),R)},F=this.$W,ht=this.$M,st=this.$D,J="set"+(this.$u?"UTC":"");switch(S){case f:return j?W(1,0):W(31,11);case d:return j?W(1,ht):W(0,ht+1);case u:var ct=this.$locale().weekStart||0,zt=(F<ct?F+7:F)-ct;return W(j?st-zt:st+(6-zt),ht);case c:case m:return K(J+"Hours",0);case l:return K(J+"Minutes",1);case a:return K(J+"Seconds",2);case o:return K(J+"Milliseconds",3);default:return this.clone()}},I.endOf=function(A){return this.startOf(A,!1)},I.$set=function(A,D){var R,j=M.p(A),S="set"+(this.$u?"UTC":""),W=(R={},R[c]=S+"Date",R[m]=S+"Date",R[d]=S+"Month",R[f]=S+"FullYear",R[l]=S+"Hours",R[a]=S+"Minutes",R[o]=S+"Seconds",R[s]=S+"Milliseconds",R)[j],K=j===c?this.$D+(D-this.$W):D;if(j===d||j===f){var F=this.clone().set(m,1);F.$d[W](K),F.init(),this.$d=F.set(m,Math.min(this.$D,F.daysInMonth())).$d}else W&&this.$d[W](K);return this.init(),this},I.set=function(A,D){return this.clone().$set(A,D)},I.get=function(A){return this[M.p(A)]()},I.add=function(A,D){var R,j=this;A=Number(A);var S=M.p(D),W=function(ht){var st=N(j);return M.w(st.date(st.date()+Math.round(ht*A)),j)};if(S===d)return this.set(d,this.$M+A);if(S===f)return this.set(f,this.$y+A);if(S===c)return W(1);if(S===u)return W(7);var K=(R={},R[a]=n,R[l]=i,R[o]=r,R)[S]||1,F=this.$d.getTime()+A*K;return M.w(F,this)},I.subtract=function(A,D){return this.add(-1*A,D)},I.format=function(A){var D=this,R=this.$locale();if(!this.isValid())return R.invalidDate||x;var j=A||"YYYY-MM-DDTHH:mm:ssZ",S=M.z(this),W=this.$H,K=this.$m,F=this.$M,ht=R.weekdays,st=R.months,J=R.meridiem,ct=function(Z,lt,Ct,Mt){return Z&&(Z[lt]||Z(D,j))||Ct[lt].slice(0,Mt)},zt=function(Z){return M.s(W%12||12,Z,"0")},at=J||function(Z,lt,Ct){var Mt=Z<12?"AM":"PM";return Ct?Mt.toLowerCase():Mt};return j.replace(y,(function(Z,lt){return lt||(function(Ct){switch(Ct){case"YY":return String(D.$y).slice(-2);case"YYYY":return M.s(D.$y,4,"0");case"M":return F+1;case"MM":return M.s(F+1,2,"0");case"MMM":return ct(R.monthsShort,F,st,3);case"MMMM":return ct(st,F);case"D":return D.$D;case"DD":return M.s(D.$D,2,"0");case"d":return String(D.$W);case"dd":return ct(R.weekdaysMin,D.$W,ht,2);case"ddd":return ct(R.weekdaysShort,D.$W,ht,3);case"dddd":return ht[D.$W];case"H":return String(W);case"HH":return M.s(W,2,"0");case"h":return zt(1);case"hh":return zt(2);case"a":return at(W,K,!0);case"A":return at(W,K,!1);case"m":return String(K);case"mm":return M.s(K,2,"0");case"s":return String(D.$s);case"ss":return M.s(D.$s,2,"0");case"SSS":return M.s(D.$ms,3,"0");case"Z":return S}return null})(Z)||S.replace(":","")}))},I.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},I.diff=function(A,D,R){var j,S=this,W=M.p(D),K=N(A),F=(K.utcOffset()-this.utcOffset())*n,ht=this-K,st=function(){return M.m(S,K)};switch(W){case f:j=st()/12;break;case d:j=st();break;case p:j=st()/3;break;case u:j=(ht-F)/6048e5;break;case c:j=(ht-F)/864e5;break;case l:j=ht/i;break;case a:j=ht/n;break;case o:j=ht/r;break;default:j=ht}return R?j:M.a(j)},I.daysInMonth=function(){return this.endOf(d).$D},I.$locale=function(){return w[this.$L]},I.locale=function(A,D){if(!A)return this.$L;var R=this.clone(),j=P(A,D,!0);return j&&(R.$L=j),R},I.clone=function(){return M.w(this.$d,this)},I.toDate=function(){return new Date(this.valueOf())},I.toJSON=function(){return this.isValid()?this.toISOString():null},I.toISOString=function(){return this.$d.toISOString()},I.toString=function(){return this.$d.toUTCString()},O})(),q=$.prototype;return N.prototype=q,[["$ms",s],["$s",o],["$m",a],["$H",l],["$W",c],["$M",d],["$y",f],["$D",m]].forEach((function(O){q[O[1]]=function(I){return this.$g(I,O[0],O[1])}})),N.extend=function(O,I){return O.$i||(O(I,$,N),O.$i=!0),N},N.locale=P,N.isDayjs=B,N.unix=function(O){return N(1e3*O)},N.en=w[_],N.Ls=w,N.p={},N}))})(dl)),dl.exports}var yF=xF();const bF=Tc(yF);var x1=Object.defineProperty,v=(t,e)=>x1(t,"name",{value:e,configurable:!0}),CF=(t,e)=>{for(var r in e)x1(t,r,{get:e[r],enumerable:!0})},gn={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},Q={trace:v((...t)=>{},"trace"),debug:v((...t)=>{},"debug"),info:v((...t)=>{},"info"),warn:v((...t)=>{},"warn"),error:v((...t)=>{},"error"),fatal:v((...t)=>{},"fatal")},Df=v(function(t="fatal"){let e=gn.fatal;typeof t=="string"?t.toLowerCase()in gn&&(e=gn[t]):typeof t=="number"&&(e=t),Q.trace=()=>{},Q.debug=()=>{},Q.info=()=>{},Q.warn=()=>{},Q.error=()=>{},Q.fatal=()=>{},e<=gn.fatal&&(Q.fatal=console.error?console.error.bind(console,jr("FATAL"),"color: orange"):console.log.bind(console,"\x1B[35m",jr("FATAL"))),e<=gn.error&&(Q.error=console.error?console.error.bind(console,jr("ERROR"),"color: orange"):console.log.bind(console,"\x1B[31m",jr("ERROR"))),e<=gn.warn&&(Q.warn=console.warn?console.warn.bind(console,jr("WARN"),"color: orange"):console.log.bind(console,"\x1B[33m",jr("WARN"))),e<=gn.info&&(Q.info=console.info?console.info.bind(console,jr("INFO"),"color: lightblue"):console.log.bind(console,"\x1B[34m",jr("INFO"))),e<=gn.debug&&(Q.debug=console.debug?console.debug.bind(console,jr("DEBUG"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",jr("DEBUG"))),e<=gn.trace&&(Q.trace=console.debug?console.debug.bind(console,jr("TRACE"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",jr("TRACE")))},"setLogLevel"),jr=v(t=>`%c${bF().format("ss.SSS")} : ${t} : `,"format");const fl={min:{r:0,g:0,b:0,s:0,l:0,a:0},max:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},clamp:{r:t=>t>=255?255:t<0?0:t,g:t=>t>=255?255:t<0?0:t,b:t=>t>=255?255:t<0?0:t,h:t=>t%360,s:t=>t>=100?100:t<0?0:t,l:t=>t>=100?100:t<0?0:t,a:t=>t>=1?1:t<0?0:t},toLinear:t=>{const e=t/255;return t>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92},hue2rgb:(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t),hsl2rgb:({h:t,s:e,l:r},n)=>{if(!e)return r*2.55;t/=360,e/=100,r/=100;const i=r<.5?r*(1+e):r+e-r*e,s=2*r-i;switch(n){case"r":return fl.hue2rgb(s,i,t+1/3)*255;case"g":return fl.hue2rgb(s,i,t)*255;case"b":return fl.hue2rgb(s,i,t-1/3)*255}},rgb2hsl:({r:t,g:e,b:r},n)=>{t/=255,e/=255,r/=255;const i=Math.max(t,e,r),s=Math.min(t,e,r),o=(i+s)/2;if(n==="l")return o*100;if(i===s)return 0;const a=i-s,l=o>.5?a/(2-i-s):a/(i+s);if(n==="s")return l*100;switch(i){case t:return((e-r)/a+(e<r?6:0))*60;case e:return((r-t)/a+2)*60;case r:return((t-e)/a+4)*60;default:return-1}}},kF={clamp:(t,e,r)=>e>r?Math.min(e,Math.max(r,t)):Math.min(r,Math.max(e,t)),round:t=>Math.round(t*1e10)/1e10},vF={dec2hex:t=>{const e=Math.round(t).toString(16);return e.length>1?e:`0${e}`}},Ot={channel:fl,lang:kF,unit:vF},Fn={};for(let t=0;t<=255;t++)Fn[t]=Ot.unit.dec2hex(t);const Ue={ALL:0,RGB:1,HSL:2};class wF{constructor(){this.type=Ue.ALL}get(){return this.type}set(e){if(this.type&&this.type!==e)throw new Error("Cannot change both RGB and HSL channels at the same time");this.type=e}reset(){this.type=Ue.ALL}is(e){return this.type===e}}class SF{constructor(e,r){this.color=r,this.changed=!1,this.data=e,this.type=new wF}set(e,r){return this.color=r,this.changed=!1,this.data=e,this.type.type=Ue.ALL,this}_ensureHSL(){const e=this.data,{h:r,s:n,l:i}=e;r===void 0&&(e.h=Ot.channel.rgb2hsl(e,"h")),n===void 0&&(e.s=Ot.channel.rgb2hsl(e,"s")),i===void 0&&(e.l=Ot.channel.rgb2hsl(e,"l"))}_ensureRGB(){const e=this.data,{r,g:n,b:i}=e;r===void 0&&(e.r=Ot.channel.hsl2rgb(e,"r")),n===void 0&&(e.g=Ot.channel.hsl2rgb(e,"g")),i===void 0&&(e.b=Ot.channel.hsl2rgb(e,"b"))}get r(){const e=this.data,r=e.r;return!this.type.is(Ue.HSL)&&r!==void 0?r:(this._ensureHSL(),Ot.channel.hsl2rgb(e,"r"))}get g(){const e=this.data,r=e.g;return!this.type.is(Ue.HSL)&&r!==void 0?r:(this._ensureHSL(),Ot.channel.hsl2rgb(e,"g"))}get b(){const e=this.data,r=e.b;return!this.type.is(Ue.HSL)&&r!==void 0?r:(this._ensureHSL(),Ot.channel.hsl2rgb(e,"b"))}get h(){const e=this.data,r=e.h;return!this.type.is(Ue.RGB)&&r!==void 0?r:(this._ensureRGB(),Ot.channel.rgb2hsl(e,"h"))}get s(){const e=this.data,r=e.s;return!this.type.is(Ue.RGB)&&r!==void 0?r:(this._ensureRGB(),Ot.channel.rgb2hsl(e,"s"))}get l(){const e=this.data,r=e.l;return!this.type.is(Ue.RGB)&&r!==void 0?r:(this._ensureRGB(),Ot.channel.rgb2hsl(e,"l"))}get a(){return this.data.a}set r(e){this.type.set(Ue.RGB),this.changed=!0,this.data.r=e}set g(e){this.type.set(Ue.RGB),this.changed=!0,this.data.g=e}set b(e){this.type.set(Ue.RGB),this.changed=!0,this.data.b=e}set h(e){this.type.set(Ue.HSL),this.changed=!0,this.data.h=e}set s(e){this.type.set(Ue.HSL),this.changed=!0,this.data.s=e}set l(e){this.type.set(Ue.HSL),this.changed=!0,this.data.l=e}set a(e){this.changed=!0,this.data.a=e}}const Oc=new SF({r:0,g:0,b:0,a:0},"transparent"),cs={re:/^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i,parse:t=>{if(t.charCodeAt(0)!==35)return;const e=t.match(cs.re);if(!e)return;const r=e[1],n=parseInt(r,16),i=r.length,s=i%4===0,o=i>4,a=o?1:17,l=o?8:4,c=s?0:-1,u=o?255:15;return Oc.set({r:(n>>l*(c+3)&u)*a,g:(n>>l*(c+2)&u)*a,b:(n>>l*(c+1)&u)*a,a:s?(n&u)*a/255:1},t)},stringify:t=>{const{r:e,g:r,b:n,a:i}=t;return i<1?`#${Fn[Math.round(e)]}${Fn[Math.round(r)]}${Fn[Math.round(n)]}${Fn[Math.round(i*255)]}`:`#${Fn[Math.round(e)]}${Fn[Math.round(r)]}${Fn[Math.round(n)]}`}},hi={re:/^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i,hueRe:/^(.+?)(deg|grad|rad|turn)$/i,_hue2deg:t=>{const e=t.match(hi.hueRe);if(e){const[,r,n]=e;switch(n){case"grad":return Ot.channel.clamp.h(parseFloat(r)*.9);case"rad":return Ot.channel.clamp.h(parseFloat(r)*180/Math.PI);case"turn":return Ot.channel.clamp.h(parseFloat(r)*360)}}return Ot.channel.clamp.h(parseFloat(t))},parse:t=>{const e=t.charCodeAt(0);if(e!==104&&e!==72)return;const r=t.match(hi.re);if(!r)return;const[,n,i,s,o,a]=r;return Oc.set({h:hi._hue2deg(n),s:Ot.channel.clamp.s(parseFloat(i)),l:Ot.channel.clamp.l(parseFloat(s)),a:o?Ot.channel.clamp.a(a?parseFloat(o)/100:parseFloat(o)):1},t)},stringify:t=>{const{h:e,s:r,l:n,a:i}=t;return i<1?`hsla(${Ot.lang.round(e)}, ${Ot.lang.round(r)}%, ${Ot.lang.round(n)}%, ${i})`:`hsl(${Ot.lang.round(e)}, ${Ot.lang.round(r)}%, ${Ot.lang.round(n)}%)`}},Oo={colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyanaqua:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",transparent:"#00000000",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},parse:t=>{t=t.toLowerCase();const e=Oo.colors[t];if(e)return cs.parse(e)},stringify:t=>{const e=cs.stringify(t);for(const r in Oo.colors)if(Oo.colors[r]===e)return r}},So={re:/^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i,parse:t=>{const e=t.charCodeAt(0);if(e!==114&&e!==82)return;const r=t.match(So.re);if(!r)return;const[,n,i,s,o,a,l,c,u]=r;return Oc.set({r:Ot.channel.clamp.r(i?parseFloat(n)*2.55:parseFloat(n)),g:Ot.channel.clamp.g(o?parseFloat(s)*2.55:parseFloat(s)),b:Ot.channel.clamp.b(l?parseFloat(a)*2.55:parseFloat(a)),a:c?Ot.channel.clamp.a(u?parseFloat(c)/100:parseFloat(c)):1},t)},stringify:t=>{const{r:e,g:r,b:n,a:i}=t;return i<1?`rgba(${Ot.lang.round(e)}, ${Ot.lang.round(r)}, ${Ot.lang.round(n)}, ${Ot.lang.round(i)})`:`rgb(${Ot.lang.round(e)}, ${Ot.lang.round(r)}, ${Ot.lang.round(n)})`}},on={format:{keyword:Oo,hex:cs,rgb:So,rgba:So,hsl:hi,hsla:hi},parse:t=>{if(typeof t!="string")return t;const e=cs.parse(t)||So.parse(t)||hi.parse(t)||Oo.parse(t);if(e)return e;throw new Error(`Unsupported color format: "${t}"`)},stringify:t=>!t.changed&&t.color?t.color:t.type.is(Ue.HSL)||t.data.r===void 0?hi.stringify(t):t.a<1||!Number.isInteger(t.r)||!Number.isInteger(t.g)||!Number.isInteger(t.b)?So.stringify(t):cs.stringify(t)},y1=(t,e)=>{const r=on.parse(t);for(const n in e)r[n]=Ot.channel.clamp[n](e[n]);return on.stringify(r)},$n=(t,e,r=0,n=1)=>{if(typeof t!="number")return y1(t,{a:e});const i=Oc.set({r:Ot.channel.clamp.r(t),g:Ot.channel.clamp.g(e),b:Ot.channel.clamp.b(r),a:Ot.channel.clamp.a(n)});return on.stringify(i)},TF=t=>{const{r:e,g:r,b:n}=on.parse(t),i=.2126*Ot.channel.toLinear(e)+.7152*Ot.channel.toLinear(r)+.0722*Ot.channel.toLinear(n);return Ot.lang.round(i)},_F=t=>TF(t)>=.5,Xr=t=>!_F(t),b1=(t,e,r)=>{const n=on.parse(t),i=n[e],s=Ot.channel.clamp[e](i+r);return i!==s&&(n[e]=s),on.stringify(n)},Y=(t,e)=>b1(t,"l",e),X=(t,e)=>b1(t,"l",-e),L=(t,e)=>{const r=on.parse(t),n={};for(const i in e)e[i]&&(n[i]=r[i]+e[i]);return y1(t,n)},EF=(t,e,r=50)=>{const{r:n,g:i,b:s,a:o}=on.parse(t),{r:a,g:l,b:c,a:u}=on.parse(e),d=r/100,p=d*2-1,f=o-u,x=((p*f===-1?p:(p+f)/(1+p*f))+1)/2,g=1-x,y=n*x+a*g,b=i*x+l*g,k=s*x+c*g,T=o*d+u*(1-d);return $n(y,b,k,T)},U=(t,e=100)=>{const r=on.parse(t);return r.r=255-r.r,r.g=255-r.g,r.b=255-r.b,EF(r,t,e)};/*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */function gg(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function NF(t){if(Array.isArray(t))return t}function jF(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,s,o,a=[],l=!0,c=!1;try{if(s=(r=r.call(t)).next,e!==0)for(;!(l=(n=s.call(r)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function LF(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
@@ -636,8 +636,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
636
636
  L0,20`)},"requirement_arrow"),C9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i;t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").attr("stroke-width",`${s}`).attr("viewBox","0 0 25 20").append("path").attr("d",`M0,0
637
637
  L20,10
638
638
  M20,10
639
- L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),k9=v((t,e,r)=>{const n=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),v9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i,o=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),w9={extension:e9,composition:r9,aggregation:n9,dependency:i9,lollipop:s9,point:o9,circle:a9,cross:l9,barb:c9,barbNeo:h9,only_one:u9,zero_or_one:d9,one_or_more:f9,zero_or_more:p9,only_one_neo:m9,zero_or_one_neo:g9,one_or_more_neo:x9,zero_or_more_neo:y9,requirement_arrow:b9,requirement_contains:k9,requirement_arrow_neo:C9,requirement_contains_neo:v9},S9=t9,T9={common:ga,getConfig:me,insertCluster:vz,insertEdge:Jz,insertEdgeLabel:Vz,insertMarkers:S9,insertNode:F2,interpolateToCurve:pp,labelHelper:It,log:Q,positionEdgeLabel:Yz},sa={},R2=v(t=>{for(const e of t)sa[e.name]=e},"registerLayoutLoaders"),_9=v(()=>{R2([{name:"dagre",loader:v(async()=>await Qt(()=>import("./dagre-BM42HDAG-Drkta_n5.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Qt(()=>import("./cose-bilkent-S5V4N54A-CdyvK5N2.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");_9();var IZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in sa))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);if(t.diagramId)for(const u of t.nodes){const d=u.domId||u.id;u.domId=`${t.diagramId}-${d}`}const r=sa[t.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=t.config,{useGradient:o,gradientStart:a,gradientStop:l}=s,c=e.attr("id");if(e.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),e.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),o){const u=e.append("linearGradient").attr("id",e.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");u.append("svg:stop").attr("offset","0%").attr("stop-color",a).attr("stop-opacity",1),u.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(t,e,T9,{algorithm:r.algorithm})},"render"),FZ=v((t="",{fallback:e="dagre"}={})=>{if(t in sa)return t;if(e in sa)return Q.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Fp="comm",$2="rule",z2="decl",E9="@media",N9="@import",j9="@supports",L9="@namespace",Dd="@keyframes",W2="@layer",B9="@scope",A9=Math.abs,qo=String.fromCharCode;function q2(t){return t.trim()}function Od(t,e,r){return t.replace(e,r)}function us(t,e){return t.charCodeAt(e)|0}function Rs(t,e,r){return t.slice(e,r)}function rn(t){return t.length}function H2(t){return t.length}function Za(t,e){return e.push(t),t}var th=1,$s=1,U2=0,Mr=0,Le=0,Vs="";function Pp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:th,column:$s,length:o,return:"",siblings:a}}function M9(){return Le}function I9(){return Le=Mr>0?us(Vs,--Mr):0,$s--,Le===10&&($s=1,th--),Le}function Vr(){return Le=Mr<U2?us(Vs,Mr++):0,$s++,Le===10&&($s=1,th++),Le}function Rn(){return us(Vs,Mr)}function Sl(){return Mr}function eh(t,e){return Rs(Vs,t,e)}function oa(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F9(t){return th=$s=1,U2=rn(Vs=t),Mr=0,[]}function P9(t){return Vs="",t}function lu(t){return q2(eh(Mr-1,Rd(t===91?t+2:t===40?t+1:t)))}function D9(t){for(;(Le=Rn())&&Le<33;)Vr();return oa(t)>2||oa(Le)>3?"":" "}function O9(t,e){for(;--e&&Vr()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return eh(t,Sl()+(e<6&&Rn()==32&&Vr()==32))}function Rd(t){for(;Vr();)switch(Le){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Rd(Le);break;case 40:t===41&&Rd(t);break;case 92:Vr();break}return Mr}function R9(t,e){for(;Vr()&&t+Le!==57;)if(t+Le===84&&Rn()===47)break;return"/*"+eh(e,Mr-1)+"*"+qo(t===47?t:Vr())}function $9(t){for(;!oa(Rn());)Vr();return eh(t,Mr)}function z9(t){return P9(Tl("",null,null,null,[""],t=F9(t),0,[0],t))}function Tl(t,e,r,n,i,s,o,a,l){for(var c=0,u=0,d=o,p=0,f=0,m=0,x=1,g=1,y=1,b=0,k=0,T="",_=i,w=s,E=n,B=T;g;)switch(m=k,k=Vr()){case 40:m!=108&&us(B,d-1)==58?(b++,B+="("):B+=lu(k);break;case 41:b--,B+=")";break;case 34:case 39:case 91:B+=lu(k);break;case 9:case 10:case 13:case 32:if(b>0){B+=qo(k);break}B+=D9(m);break;case 92:B+=O9(Sl()-1,7);continue;case 47:switch(Rn()){case 42:case 47:Za(W9(R9(Vr(),Sl()),e,r,l),l),(oa(m||1)==5||oa(Rn()||1)==5)&&rn(B)&&Rs(B,-1,void 0)!==" "&&(B+=" ");break;default:B+="/"}break;case 123*x:a[c++]=rn(B)*y;case 125*x:case 59:case 0:if(b>0&&k){B+=qo(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(B=Od(B,/\f/g,"")),f>0&&(rn(B)-d||x===0)&&Za(f>32?Gx(B+";",n,r,d-1,l):Gx(Od(B," ","")+";",n,r,d-2,l),l);break;case 59:B+=";";default:if(Za(E=Ux(B,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Tl(B,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(us(B,3)===110)break;case 108:if(us(B,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Tl(t,E,E,n&&Za(Ux(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Tl(B,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=B="",d=o;break;case 58:d=1+rn(B),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&I9()==125)continue}switch(B+=qo(k),k*x){case 38:y=u>0?1:(B+="\f",-1);break;case 44:if(b>0)break;a[c++]=(rn(B)-1)*y,y=1;break;case 64:Rn()===45&&(B+=lu(Vr())),p=Rn(),u=d=rn(T=B+=$9(Sl())),k++;break;case 45:m===45&&rn(B)==2&&(x=0)}}return s}function Ux(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=H2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Rs(t,p+1,p=A9(g=o[x])),T=t;b<m;++b)(T=q2(g>0?f[b]+" "+k:Od(k,/&\f/g,f[b])))&&(l[y++]=T);return Pp(t,e,r,i===0?$2:a,l,c,u,d)}function W9(t,e,r,n){return Pp(t,e,r,Fp,qo(M9()),Rs(t,2,-2),0,n)}function Gx(t,e,r,n,i){return Pp(t,e,r,z2,Rs(t,0,n),Rs(t,n+1,-1),n,i)}function $d(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function q9(t,e,r,n){switch(t.type){case W2:if(t.children.length)break;case N9:case L9:case z2:return t.return=t.return||t.value;case Fp:return"";case Dd:return t.return=t.value+"{"+$d(t.children,n)+"}";case $2:if(!rn(t.value=t.props.join(",")))return""}return rn(r=$d(t.children,n))?t.return=t.value+"{"+r+"}":""}function H9(t){var e=H2(t);return function(r,n,i,s){for(var o="",a=0;a<e;a++)o+=t[a](r,n,i,s)||"";return o}}var G2="c4",U9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),G9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-CPSXghc8.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:G2,diagram:t}},"loader"),V9={id:G2,detector:U9,loader:G9},Y9=V9,V2="flowchart",X9=v((t,e)=>{var r,n;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(t)},"detector"),K9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DiwEgd9q.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:V2,diagram:t}},"loader"),Z9={id:V2,detector:X9,loader:K9},Q9=Z9,Y2="flowchart-v2",J9=v((t,e)=>{var r,n,i;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&((i=e==null?void 0:e.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(t))},"detector"),t7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DiwEgd9q.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Y2,diagram:t}},"loader"),e7={id:Y2,detector:J9,loader:t7},r7=e7,X2="er",n7=v(t=>/^\s*erDiagram/.test(t),"detector"),i7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-CXSf-i6t.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:X2,diagram:t}},"loader"),s7={id:X2,detector:n7,loader:i7},o7=s7,K2="gitGraph",a7=v(t=>/^\s*gitGraph/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-CWNWantF.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:K2,diagram:t}},"loader"),c7={id:K2,detector:a7,loader:l7},h7=c7,Z2="gantt",u7=v(t=>/^\s*gantt/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-zQ94YEl2.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:Z2,diagram:t}},"loader"),f7={id:Z2,detector:u7,loader:d7},p7=f7,Q2="info",m7=v(t=>/^\s*info/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-BcnrgEm6.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:Q2,diagram:t}},"loader"),x7={id:Q2,detector:m7,loader:g7},J2="pie",y7=v(t=>/^\s*pie/.test(t),"detector"),b7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-C9qGrfV0.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:J2,diagram:t}},"loader"),C7={id:J2,detector:y7,loader:b7},tS="quadrantChart",k7=v(t=>/^\s*quadrantChart/.test(t),"detector"),v7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-COA0Z2JV.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),w7={id:tS,detector:k7,loader:v7},S7=w7,eS="xychart",T7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-CKxMIB7j.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:eS,diagram:t}},"loader"),E7={id:eS,detector:T7,loader:_7},N7=E7,rS="requirement",j7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-BJCU8yFE.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:rS,diagram:t}},"loader"),B7={id:rS,detector:j7,loader:L7},A7=B7,nS="sequence",M7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-Bkh_RWpN.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:nS,diagram:t}},"loader"),F7={id:nS,detector:M7,loader:I7},P7=F7,iS="class",D7=v((t,e)=>{var r;return((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t)},"detector"),O7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-DZsvwI1V.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:iS,diagram:t}},"loader"),R7={id:iS,detector:D7,loader:O7},$7=R7,sS="classDiagram",z7=v((t,e)=>{var r;return/^\s*classDiagram/.test(t)&&((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t)},"detector"),W7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-DZsvwI1V.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),q7={id:sS,detector:z7,loader:W7},H7=q7,oS="state",U7=v((t,e)=>{var r;return((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t)},"detector"),G7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-BlUsbYTW.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),V7={id:oS,detector:U7,loader:G7},Y7=V7,aS="stateDiagram",X7=v((t,e)=>{var r;return!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),K7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-_AUWPuja.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),Z7={id:aS,detector:X7,loader:K7},Q7=Z7,lS="journey",J7=v(t=>/^\s*journey/.test(t),"detector"),tW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-CdwMwMPo.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),eW={id:lS,detector:J7,loader:tW},rW=eW,nW=v((t,e,r)=>{Q.debug(`rendering svg for syntax error
640
- `);const n=RR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),R1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),cS={draw:nW},iW=cS,sW={db:{},renderer:cS,parser:{parse:v(()=>{},"parse")}},oW=sW,hS="flowchart-elk",aW=v((t,e={})=>{var r;return/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(e.layout="elk",!0):!1},"detector"),lW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DiwEgd9q.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:hS,diagram:t}},"loader"),cW={id:hS,detector:aW,loader:lW},hW=cW,uS="timeline",uW=v(t=>/^\s*timeline/.test(t),"detector"),dW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./timeline-definition-PNZ67QCA-DuYEZwxg.js");return{diagram:e}},__vite__mapDeps([40,27,3,4,5,6,7]));return{id:uS,diagram:t}},"loader"),fW={id:uS,detector:uW,loader:dW},pW=fW,dS="mindmap",mW=v(t=>/^\s*mindmap/.test(t),"detector"),gW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./mindmap-definition-RKZ34NQL-C2aCD1L4.js");return{diagram:e}},__vite__mapDeps([41,13,14,3,4,5,6,7]));return{id:dS,diagram:t}},"loader"),xW={id:dS,detector:mW,loader:gW},yW=xW,fS="kanban",bW=v(t=>/^\s*kanban/.test(t),"detector"),CW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./kanban-definition-UN3LZRKU-Difj4Zd-.js");return{diagram:e}},__vite__mapDeps([42,12,3,4,5,6,7]));return{id:fS,diagram:t}},"loader"),kW={id:fS,detector:bW,loader:CW},vW=kW,pS="sankey",wW=v(t=>/^\s*sankey(-beta)?/.test(t),"detector"),SW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sankeyDiagram-5OEKKPKP-vYzK7FJ6.js");return{diagram:e}},__vite__mapDeps([43,28,23,3,4,5,6,7]));return{id:pS,diagram:t}},"loader"),TW={id:pS,detector:wW,loader:SW},_W=TW,mS="packet",EW=v(t=>/^\s*packet(-beta)?/.test(t),"detector"),NW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-LMA3HP47-B5erGOiF.js");return{diagram:e}},__vite__mapDeps([44,18,20,5,3,4,6,7]));return{id:mS,diagram:t}},"loader"),jW={id:mS,detector:EW,loader:NW},gS="radar",LW=v(t=>/^\s*radar-beta/.test(t),"detector"),BW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-2AECGRRQ-BRiBkuu5.js");return{diagram:e}},__vite__mapDeps([45,18,20,5,3,4,6,7]));return{id:gS,diagram:t}},"loader"),AW={id:gS,detector:LW,loader:BW},xS="block",MW=v(t=>/^\s*block(-beta)?/.test(t),"detector"),IW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./blockDiagram-GPEHLZMM-HwB_eL3_.js");return{diagram:e}},__vite__mapDeps([46,12,1,15,3,4,5,6,7]));return{id:xS,diagram:t}},"loader"),FW={id:xS,detector:MW,loader:IW},PW=FW,yS="treeView",DW=v(t=>/^\s*treeView-beta/.test(t),"detector"),OW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-5GNKFQAL-IrSBDK26.js");return{diagram:e}},__vite__mapDeps([47,18,19,20,5,3,4,6,7]));return{id:yS,diagram:t}},"loader"),RW={id:yS,detector:DW,loader:OW},$W=RW,bS="architecture",zW=v(t=>/^\s*architecture/.test(t),"detector"),WW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./architectureDiagram-3BPJPVTR-BaBYippI.js");return{diagram:e}},__vite__mapDeps([48,18,20,5,3,4,6,7]));return{id:bS,diagram:t}},"loader"),qW={id:bS,detector:zW,loader:WW},HW=qW,CS="eventmodeling",UW=v(t=>/^\s*eventmodeling/.test(t),"detector"),GW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-KO2AKTUF-BUktYepH.js");return{diagram:e}},__vite__mapDeps([49,18,20,5,3,4,6,7]));return{id:CS,diagram:t}},"loader"),VW={id:CS,detector:UW,loader:GW},YW=VW,kS="ishikawa",XW=v(t=>/^\s*ishikawa(-beta)?\b/i.test(t),"detector"),KW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ishikawaDiagram-YF4QCWOH-BRzURsJQ.js");return{diagram:e}},__vite__mapDeps([50,3,4,5,6,7]));return{id:kS,diagram:t}},"loader"),ZW={id:kS,detector:XW,loader:KW},vS="venn",QW=v(t=>/^\s*venn-beta/.test(t),"detector"),JW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./vennDiagram-CIIHVFJN-D9a3Q3Ni.js");return{diagram:e}},__vite__mapDeps([51,3,4,5,6,7]));return{id:vS,diagram:t}},"loader"),tq={id:vS,detector:QW,loader:JW},eq=tq,wS="treemap",rq=v(t=>/^\s*treemap/.test(t),"detector"),nq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-OG6HWLK6-5KoSfwod.js");return{diagram:e}},__vite__mapDeps([52,14,18,20,5,3,4,6,24,28,23,7]));return{id:wS,diagram:t}},"loader"),iq={id:wS,detector:rq,loader:nq},SS="wardley-beta",sq=v(t=>/^\s*wardley-beta/i.test(t),"detector"),oq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./wardleyDiagram-YWT4CUSO-C-_dzSY5.js");return{diagram:e}},__vite__mapDeps([53,18,20,5,3,4,6,7]));return{id:SS,diagram:t}},"loader"),aq={id:SS,detector:sq,loader:oq},lq=aq,Vx=!1,rh=v(()=>{Vx||(Vx=!0,Vl("error",oW,t=>t.toLowerCase().trim()==="error"),Vl("---",{db:{clear:v(()=>{},"clear")},styles:{},renderer:{draw:v(()=>{},"draw")},parser:{parse:v(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:v(()=>null,"init")},t=>t.toLowerCase().trimStart().startsWith("---")),Uu(hW,yW,HW),Uu(Y9,vW,H7,$7,o7,p7,x7,C7,A7,P7,r7,Q9,pW,h7,Q7,Y7,rW,S7,_W,jW,N7,PW,YW,$W,AW,ZW,iq,eq,lq))},"addDiagrams"),cq=v(async()=>{Q.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(yi).map(async([r,{detector:n,loader:i}])=>{if(i)try{Ku(r)}catch{try{const{diagram:s,id:o}=await i();Vl(o,s,n)}catch(s){throw Q.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete yi[r],s}}}))).filter(r=>r.status==="rejected");if(e.length>0){Q.error(`Failed to load ${e.length} external diagrams`);for(const r of e)Q.error(r);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),hq="graphics-document document";function TS(t,e){t.attr("role",hq),e!==""&&t.attr("aria-roledescription",e)}v(TS,"setA11yDiagramInfo");function _S(t,e,r,n){if(t.insert!==void 0){if(r){const i=`chart-desc-${n}`;t.attr("aria-describedby",i),t.insert("desc",":first-child").attr("id",i).text(r)}if(e){const i=`chart-title-${n}`;t.attr("aria-labelledby",i),t.insert("title",":first-child").attr("id",i).text(e)}}}v(_S,"addSVGa11yTitleDescription");var mi,zd=(mi=class{constructor(e,r,n,i,s){this.type=e,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(e,r={}){var c,u;const n=me(),i=Of(e,n);e=W6(e)+`
639
+ L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),k9=v((t,e,r)=>{const n=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),v9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i,o=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),w9={extension:e9,composition:r9,aggregation:n9,dependency:i9,lollipop:s9,point:o9,circle:a9,cross:l9,barb:c9,barbNeo:h9,only_one:u9,zero_or_one:d9,one_or_more:f9,zero_or_more:p9,only_one_neo:m9,zero_or_one_neo:g9,one_or_more_neo:x9,zero_or_more_neo:y9,requirement_arrow:b9,requirement_contains:k9,requirement_arrow_neo:C9,requirement_contains_neo:v9},S9=t9,T9={common:ga,getConfig:me,insertCluster:vz,insertEdge:Jz,insertEdgeLabel:Vz,insertMarkers:S9,insertNode:F2,interpolateToCurve:pp,labelHelper:It,log:Q,positionEdgeLabel:Yz},sa={},R2=v(t=>{for(const e of t)sa[e.name]=e},"registerLayoutLoaders"),_9=v(()=>{R2([{name:"dagre",loader:v(async()=>await Qt(()=>import("./dagre-BM42HDAG-BWNVctIO.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Qt(()=>import("./cose-bilkent-S5V4N54A-CknvjYWn.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");_9();var IZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in sa))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);if(t.diagramId)for(const u of t.nodes){const d=u.domId||u.id;u.domId=`${t.diagramId}-${d}`}const r=sa[t.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=t.config,{useGradient:o,gradientStart:a,gradientStop:l}=s,c=e.attr("id");if(e.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),e.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),o){const u=e.append("linearGradient").attr("id",e.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");u.append("svg:stop").attr("offset","0%").attr("stop-color",a).attr("stop-opacity",1),u.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(t,e,T9,{algorithm:r.algorithm})},"render"),FZ=v((t="",{fallback:e="dagre"}={})=>{if(t in sa)return t;if(e in sa)return Q.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Fp="comm",$2="rule",z2="decl",E9="@media",N9="@import",j9="@supports",L9="@namespace",Dd="@keyframes",W2="@layer",B9="@scope",A9=Math.abs,qo=String.fromCharCode;function q2(t){return t.trim()}function Od(t,e,r){return t.replace(e,r)}function us(t,e){return t.charCodeAt(e)|0}function Rs(t,e,r){return t.slice(e,r)}function rn(t){return t.length}function H2(t){return t.length}function Za(t,e){return e.push(t),t}var th=1,$s=1,U2=0,Mr=0,Le=0,Vs="";function Pp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:th,column:$s,length:o,return:"",siblings:a}}function M9(){return Le}function I9(){return Le=Mr>0?us(Vs,--Mr):0,$s--,Le===10&&($s=1,th--),Le}function Vr(){return Le=Mr<U2?us(Vs,Mr++):0,$s++,Le===10&&($s=1,th++),Le}function Rn(){return us(Vs,Mr)}function Sl(){return Mr}function eh(t,e){return Rs(Vs,t,e)}function oa(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F9(t){return th=$s=1,U2=rn(Vs=t),Mr=0,[]}function P9(t){return Vs="",t}function lu(t){return q2(eh(Mr-1,Rd(t===91?t+2:t===40?t+1:t)))}function D9(t){for(;(Le=Rn())&&Le<33;)Vr();return oa(t)>2||oa(Le)>3?"":" "}function O9(t,e){for(;--e&&Vr()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return eh(t,Sl()+(e<6&&Rn()==32&&Vr()==32))}function Rd(t){for(;Vr();)switch(Le){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Rd(Le);break;case 40:t===41&&Rd(t);break;case 92:Vr();break}return Mr}function R9(t,e){for(;Vr()&&t+Le!==57;)if(t+Le===84&&Rn()===47)break;return"/*"+eh(e,Mr-1)+"*"+qo(t===47?t:Vr())}function $9(t){for(;!oa(Rn());)Vr();return eh(t,Mr)}function z9(t){return P9(Tl("",null,null,null,[""],t=F9(t),0,[0],t))}function Tl(t,e,r,n,i,s,o,a,l){for(var c=0,u=0,d=o,p=0,f=0,m=0,x=1,g=1,y=1,b=0,k=0,T="",_=i,w=s,E=n,B=T;g;)switch(m=k,k=Vr()){case 40:m!=108&&us(B,d-1)==58?(b++,B+="("):B+=lu(k);break;case 41:b--,B+=")";break;case 34:case 39:case 91:B+=lu(k);break;case 9:case 10:case 13:case 32:if(b>0){B+=qo(k);break}B+=D9(m);break;case 92:B+=O9(Sl()-1,7);continue;case 47:switch(Rn()){case 42:case 47:Za(W9(R9(Vr(),Sl()),e,r,l),l),(oa(m||1)==5||oa(Rn()||1)==5)&&rn(B)&&Rs(B,-1,void 0)!==" "&&(B+=" ");break;default:B+="/"}break;case 123*x:a[c++]=rn(B)*y;case 125*x:case 59:case 0:if(b>0&&k){B+=qo(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(B=Od(B,/\f/g,"")),f>0&&(rn(B)-d||x===0)&&Za(f>32?Gx(B+";",n,r,d-1,l):Gx(Od(B," ","")+";",n,r,d-2,l),l);break;case 59:B+=";";default:if(Za(E=Ux(B,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Tl(B,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(us(B,3)===110)break;case 108:if(us(B,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Tl(t,E,E,n&&Za(Ux(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Tl(B,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=B="",d=o;break;case 58:d=1+rn(B),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&I9()==125)continue}switch(B+=qo(k),k*x){case 38:y=u>0?1:(B+="\f",-1);break;case 44:if(b>0)break;a[c++]=(rn(B)-1)*y,y=1;break;case 64:Rn()===45&&(B+=lu(Vr())),p=Rn(),u=d=rn(T=B+=$9(Sl())),k++;break;case 45:m===45&&rn(B)==2&&(x=0)}}return s}function Ux(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=H2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Rs(t,p+1,p=A9(g=o[x])),T=t;b<m;++b)(T=q2(g>0?f[b]+" "+k:Od(k,/&\f/g,f[b])))&&(l[y++]=T);return Pp(t,e,r,i===0?$2:a,l,c,u,d)}function W9(t,e,r,n){return Pp(t,e,r,Fp,qo(M9()),Rs(t,2,-2),0,n)}function Gx(t,e,r,n,i){return Pp(t,e,r,z2,Rs(t,0,n),Rs(t,n+1,-1),n,i)}function $d(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function q9(t,e,r,n){switch(t.type){case W2:if(t.children.length)break;case N9:case L9:case z2:return t.return=t.return||t.value;case Fp:return"";case Dd:return t.return=t.value+"{"+$d(t.children,n)+"}";case $2:if(!rn(t.value=t.props.join(",")))return""}return rn(r=$d(t.children,n))?t.return=t.value+"{"+r+"}":""}function H9(t){var e=H2(t);return function(r,n,i,s){for(var o="",a=0;a<e;a++)o+=t[a](r,n,i,s)||"";return o}}var G2="c4",U9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),G9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-CWZPV6Gi.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:G2,diagram:t}},"loader"),V9={id:G2,detector:U9,loader:G9},Y9=V9,V2="flowchart",X9=v((t,e)=>{var r,n;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(t)},"detector"),K9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:V2,diagram:t}},"loader"),Z9={id:V2,detector:X9,loader:K9},Q9=Z9,Y2="flowchart-v2",J9=v((t,e)=>{var r,n,i;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&((i=e==null?void 0:e.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(t))},"detector"),t7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Y2,diagram:t}},"loader"),e7={id:Y2,detector:J9,loader:t7},r7=e7,X2="er",n7=v(t=>/^\s*erDiagram/.test(t),"detector"),i7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-BDTpNyUZ.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:X2,diagram:t}},"loader"),s7={id:X2,detector:n7,loader:i7},o7=s7,K2="gitGraph",a7=v(t=>/^\s*gitGraph/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-BmIOl3oN.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:K2,diagram:t}},"loader"),c7={id:K2,detector:a7,loader:l7},h7=c7,Z2="gantt",u7=v(t=>/^\s*gantt/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-CJI3ZQCl.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:Z2,diagram:t}},"loader"),f7={id:Z2,detector:u7,loader:d7},p7=f7,Q2="info",m7=v(t=>/^\s*info/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-BiJXa7xo.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:Q2,diagram:t}},"loader"),x7={id:Q2,detector:m7,loader:g7},J2="pie",y7=v(t=>/^\s*pie/.test(t),"detector"),b7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-BGGc2f7U.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:J2,diagram:t}},"loader"),C7={id:J2,detector:y7,loader:b7},tS="quadrantChart",k7=v(t=>/^\s*quadrantChart/.test(t),"detector"),v7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-DN8kBgF9.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),w7={id:tS,detector:k7,loader:v7},S7=w7,eS="xychart",T7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-Cpcj31O3.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:eS,diagram:t}},"loader"),E7={id:eS,detector:T7,loader:_7},N7=E7,rS="requirement",j7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-CqTXzyF-.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:rS,diagram:t}},"loader"),B7={id:rS,detector:j7,loader:L7},A7=B7,nS="sequence",M7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-B5mMGwpr.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:nS,diagram:t}},"loader"),F7={id:nS,detector:M7,loader:I7},P7=F7,iS="class",D7=v((t,e)=>{var r;return((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t)},"detector"),O7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-DV6SPGMl.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:iS,diagram:t}},"loader"),R7={id:iS,detector:D7,loader:O7},$7=R7,sS="classDiagram",z7=v((t,e)=>{var r;return/^\s*classDiagram/.test(t)&&((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t)},"detector"),W7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-DV6SPGMl.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),q7={id:sS,detector:z7,loader:W7},H7=q7,oS="state",U7=v((t,e)=>{var r;return((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t)},"detector"),G7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-B8yZRkdR.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),V7={id:oS,detector:U7,loader:G7},Y7=V7,aS="stateDiagram",X7=v((t,e)=>{var r;return!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),K7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-BK-1uf4O.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),Z7={id:aS,detector:X7,loader:K7},Q7=Z7,lS="journey",J7=v(t=>/^\s*journey/.test(t),"detector"),tW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-Dk6NJYdI.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),eW={id:lS,detector:J7,loader:tW},rW=eW,nW=v((t,e,r)=>{Q.debug(`rendering svg for syntax error
640
+ `);const n=RR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),R1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),cS={draw:nW},iW=cS,sW={db:{},renderer:cS,parser:{parse:v(()=>{},"parse")}},oW=sW,hS="flowchart-elk",aW=v((t,e={})=>{var r;return/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(e.layout="elk",!0):!1},"detector"),lW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:hS,diagram:t}},"loader"),cW={id:hS,detector:aW,loader:lW},hW=cW,uS="timeline",uW=v(t=>/^\s*timeline/.test(t),"detector"),dW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./timeline-definition-PNZ67QCA-uc4a9RNG.js");return{diagram:e}},__vite__mapDeps([40,27,3,4,5,6,7]));return{id:uS,diagram:t}},"loader"),fW={id:uS,detector:uW,loader:dW},pW=fW,dS="mindmap",mW=v(t=>/^\s*mindmap/.test(t),"detector"),gW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./mindmap-definition-RKZ34NQL-lzCtbkrz.js");return{diagram:e}},__vite__mapDeps([41,13,14,3,4,5,6,7]));return{id:dS,diagram:t}},"loader"),xW={id:dS,detector:mW,loader:gW},yW=xW,fS="kanban",bW=v(t=>/^\s*kanban/.test(t),"detector"),CW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./kanban-definition-UN3LZRKU-DrTme_f5.js");return{diagram:e}},__vite__mapDeps([42,12,3,4,5,6,7]));return{id:fS,diagram:t}},"loader"),kW={id:fS,detector:bW,loader:CW},vW=kW,pS="sankey",wW=v(t=>/^\s*sankey(-beta)?/.test(t),"detector"),SW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sankeyDiagram-5OEKKPKP-l5oIrkxp.js");return{diagram:e}},__vite__mapDeps([43,28,23,3,4,5,6,7]));return{id:pS,diagram:t}},"loader"),TW={id:pS,detector:wW,loader:SW},_W=TW,mS="packet",EW=v(t=>/^\s*packet(-beta)?/.test(t),"detector"),NW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-LMA3HP47-CCyEuSkM.js");return{diagram:e}},__vite__mapDeps([44,18,20,5,3,4,6,7]));return{id:mS,diagram:t}},"loader"),jW={id:mS,detector:EW,loader:NW},gS="radar",LW=v(t=>/^\s*radar-beta/.test(t),"detector"),BW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-2AECGRRQ-DhPeu8mD.js");return{diagram:e}},__vite__mapDeps([45,18,20,5,3,4,6,7]));return{id:gS,diagram:t}},"loader"),AW={id:gS,detector:LW,loader:BW},xS="block",MW=v(t=>/^\s*block(-beta)?/.test(t),"detector"),IW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./blockDiagram-GPEHLZMM-DfiOIWI5.js");return{diagram:e}},__vite__mapDeps([46,12,1,15,3,4,5,6,7]));return{id:xS,diagram:t}},"loader"),FW={id:xS,detector:MW,loader:IW},PW=FW,yS="treeView",DW=v(t=>/^\s*treeView-beta/.test(t),"detector"),OW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-5GNKFQAL-B8e2ppCQ.js");return{diagram:e}},__vite__mapDeps([47,18,19,20,5,3,4,6,7]));return{id:yS,diagram:t}},"loader"),RW={id:yS,detector:DW,loader:OW},$W=RW,bS="architecture",zW=v(t=>/^\s*architecture/.test(t),"detector"),WW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./architectureDiagram-3BPJPVTR-Dr1TLm4n.js");return{diagram:e}},__vite__mapDeps([48,18,20,5,3,4,6,7]));return{id:bS,diagram:t}},"loader"),qW={id:bS,detector:zW,loader:WW},HW=qW,CS="eventmodeling",UW=v(t=>/^\s*eventmodeling/.test(t),"detector"),GW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-KO2AKTUF-CJ2bkC5P.js");return{diagram:e}},__vite__mapDeps([49,18,20,5,3,4,6,7]));return{id:CS,diagram:t}},"loader"),VW={id:CS,detector:UW,loader:GW},YW=VW,kS="ishikawa",XW=v(t=>/^\s*ishikawa(-beta)?\b/i.test(t),"detector"),KW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ishikawaDiagram-YF4QCWOH-D2S-R9bH.js");return{diagram:e}},__vite__mapDeps([50,3,4,5,6,7]));return{id:kS,diagram:t}},"loader"),ZW={id:kS,detector:XW,loader:KW},vS="venn",QW=v(t=>/^\s*venn-beta/.test(t),"detector"),JW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./vennDiagram-CIIHVFJN-Dxp9IL4U.js");return{diagram:e}},__vite__mapDeps([51,3,4,5,6,7]));return{id:vS,diagram:t}},"loader"),tq={id:vS,detector:QW,loader:JW},eq=tq,wS="treemap",rq=v(t=>/^\s*treemap/.test(t),"detector"),nq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-OG6HWLK6-CDe7c8Ym.js");return{diagram:e}},__vite__mapDeps([52,14,18,20,5,3,4,6,24,28,23,7]));return{id:wS,diagram:t}},"loader"),iq={id:wS,detector:rq,loader:nq},SS="wardley-beta",sq=v(t=>/^\s*wardley-beta/i.test(t),"detector"),oq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./wardleyDiagram-YWT4CUSO-DWpWWd1b.js");return{diagram:e}},__vite__mapDeps([53,18,20,5,3,4,6,7]));return{id:SS,diagram:t}},"loader"),aq={id:SS,detector:sq,loader:oq},lq=aq,Vx=!1,rh=v(()=>{Vx||(Vx=!0,Vl("error",oW,t=>t.toLowerCase().trim()==="error"),Vl("---",{db:{clear:v(()=>{},"clear")},styles:{},renderer:{draw:v(()=>{},"draw")},parser:{parse:v(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:v(()=>null,"init")},t=>t.toLowerCase().trimStart().startsWith("---")),Uu(hW,yW,HW),Uu(Y9,vW,H7,$7,o7,p7,x7,C7,A7,P7,r7,Q9,pW,h7,Q7,Y7,rW,S7,_W,jW,N7,PW,YW,$W,AW,ZW,iq,eq,lq))},"addDiagrams"),cq=v(async()=>{Q.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(yi).map(async([r,{detector:n,loader:i}])=>{if(i)try{Ku(r)}catch{try{const{diagram:s,id:o}=await i();Vl(o,s,n)}catch(s){throw Q.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete yi[r],s}}}))).filter(r=>r.status==="rejected");if(e.length>0){Q.error(`Failed to load ${e.length} external diagrams`);for(const r of e)Q.error(r);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),hq="graphics-document document";function TS(t,e){t.attr("role",hq),e!==""&&t.attr("aria-roledescription",e)}v(TS,"setA11yDiagramInfo");function _S(t,e,r,n){if(t.insert!==void 0){if(r){const i=`chart-desc-${n}`;t.attr("aria-describedby",i),t.insert("desc",":first-child").attr("id",i).text(r)}if(e){const i=`chart-title-${n}`;t.attr("aria-labelledby",i),t.insert("title",":first-child").attr("id",i).text(e)}}}v(_S,"addSVGa11yTitleDescription");var mi,zd=(mi=class{constructor(e,r,n,i,s){this.type=e,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(e,r={}){var c,u;const n=me(),i=Of(e,n);e=W6(e)+`
641
641
  `;try{Ku(i)}catch{const d=s4(i);if(!d)throw new S1(`Diagram ${i} not found.`);const{id:p,diagram:f}=await d();Vl(p,f)}const{db:s,parser:o,renderer:a,init:l}=Ku(i);return o.parser&&(o.parser.yy=s),(c=s.clear)==null||c.call(s),l==null||l(n),r.title&&((u=s.setDiagramTitle)==null||u.call(s,r.title)),await o.parse(e),new mi(i,e,s,o,a)}async render(e,r){await this.renderer.draw(this.text,e,r,this)}getParser(){return this.parser}getType(){return this.type}},v(mi,"Diagram"),mi),Yx=[],uq=v(()=>{Yx.forEach(t=>{t()}),Yx=[]},"attachFunctions"),dq=v(t=>t.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function ES(t){const e=t.match(w1);if(!e)return{text:t,metadata:{}};let r=G$(e[1],{schema:U$})??{};r=typeof r=="object"&&!Array.isArray(r)?r:{};const n={};return r.displayMode&&(n.displayMode=r.displayMode.toString()),r.title&&(n.title=r.title.toString()),r.config&&(n.config=r.config),{text:t.slice(e[0].length),metadata:n}}v(ES,"extractFrontMatter");var fq=v(t=>t.replace(/\r\n?/g,`
642
642
  `).replace(/<(\w+)([^>]*)>/g,(e,r,n)=>"<"+r+n.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),pq=v(t=>{const{text:e,metadata:r}=ES(t),{displayMode:n,title:i,config:s={}}=r;return n&&(s.gantt||(s.gantt={}),s.gantt.displayMode=n),{title:i,config:s,text:e}},"processFrontmatter"),mq=v(t=>{const e=Hr.detectInit(t)??{},r=Hr.detectDirective(t,"wrap");return Array.isArray(r)?e.wrap=r.some(({type:n})=>n==="wrap"):(r==null?void 0:r.type)==="wrap"&&(e.wrap=!0),{text:j6(t),directive:e}},"processDirectives");function Dp(t){const e=fq(t),r=pq(e),n=mq(r.text),i=bp(r.config,n.directive);return t=dq(n.text),{code:t,title:r.title,config:i}}v(Dp,"preprocessDiagram");function NS(t){const e=new TextEncoder().encode(t),r=Array.from(e,n=>String.fromCodePoint(n)).join("");return btoa(r)}v(NS,"toBase64");var gq=5e4,xq="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",yq="sandbox",bq="loose",Cq="http://www.w3.org/2000/svg",kq="http://www.w3.org/1999/xlink",vq="http://www.w3.org/1999/xhtml",wq="100%",Sq="100%",Tq="border:0;margin:0;",_q="margin:0",Eq="allow-top-navigation-by-user-activation allow-popups",Nq='The "iframe" tag is not supported by your browser.',jq=["foreignobject"],Lq=["dominant-baseline"];function Op(t){const e=Dp(t);return Ul(),A4(e.config??{}),e}v(Op,"processAndSetConfigs");async function jS(t,e){rh();try{const{code:r,config:n}=Op(t);return{diagramType:(await BS(r)).type,config:n}}catch(r){if(e!=null&&e.suppressErrors)return!1;throw r}}v(jS,"parse");var Xx=v((t,e,r=[])=>{const n=j1(`{ ${r.join(" !important; ")} !important; }`);return`.${t} ${e} ${n}`},"cssImportantStyles"),Bq=v((t,e=new Map)=>{const r=new CSSStyleSheet;if(t.fontFamily!==void 0&&r.insertRule(`:root { --mermaid-font-family: ${t.fontFamily}}`,r.cssRules.length),t.altFontFamily!==void 0&&r.insertRule(`:root { --mermaid-alt-font-family: ${t.altFontFamily}}`,r.cssRules.length),e instanceof Map){const a=or(t)?["> *","span"]:["rect","polygon","ellipse","circle","path"];e.forEach(l=>{cx(l.styles)||a.forEach(c=>{r.insertRule(Xx(l.id,c,l.styles),r.cssRules.length)}),cx(l.textStyles)||r.insertRule(Xx(l.id,"tspan",((l==null?void 0:l.textStyles)||[]).map(c=>c.replace("color","fill"))),r.cssRules.length)})}let n="";if(t.themeCSS!==void 0)if(typeof r.replaceSync=="function"){const i=new CSSStyleSheet;i.replaceSync(t.themeCSS),n=Xu(i)+`
643
643
  `}else n+=`${t.themeCSS}
@@ -714,7 +714,7 @@ Description: ${t.description}`:"",g=["Challenge the assumptions of this item and
714
714
 
715
715
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
716
716
 
717
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},lV="DialogDescriptionWarning",cV=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AT(lV).contentName}}.`;return C.useEffect(()=>{var s;const i=(s=t.current)==null?void 0:s.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},hV=bT,uV=vT,MT=wT,IT=ST,FT=_T,PT=NT,dV=LT;const qp=hV,fV=uV,DT=C.forwardRef(({className:t,...e},r)=>h.jsx(MT,{ref:r,className:rt("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));DT.displayName=MT.displayName;const sh=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(fV,{children:[h.jsx(DT,{}),h.jsxs(IT,{ref:n,className:rt("fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]","w-full max-w-lg rounded-lg border border-slate-700 bg-card shadow-xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]","data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r,children:[e,h.jsxs(dV,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(cn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));sh.displayName=IT.displayName;const oh=({className:t,...e})=>h.jsx("div",{className:rt("flex flex-col space-y-1.5 p-6 pb-4",t),...e});oh.displayName="DialogHeader";const Hp=({className:t,...e})=>h.jsx("div",{className:rt("flex items-center justify-end gap-2 p-6 pt-4",t),...e});Hp.displayName="DialogFooter";const ah=C.forwardRef(({className:t,...e},r)=>h.jsx(FT,{ref:r,className:rt("text-sm font-semibold text-foreground leading-none tracking-tight",t),...e}));ah.displayName=FT.displayName;const pV=C.forwardRef(({className:t,...e},r)=>h.jsx(PT,{ref:r,className:rt("text-sm text-muted-foreground",t),...e}));pV.displayName=PT.displayName;const k0=[{id:"task",label:"Task",defaults:{type:"task",phase:"planning",priority:1,governance:"flag"}},{id:"decision",label:"Decision",defaults:{type:"decision",phase:"specification",priority:2,governance:"gate"}},{id:"question",label:"Question",defaults:{type:"question",phase:"specification",priority:1,governance:"flag"}},{id:"idea",label:"Idea",defaults:{type:"idea",phase:"vision",priority:0,governance:"skip"}},{id:"spec",label:"Spec",defaults:{type:"spec",phase:"specification",priority:2,governance:"gate"}}],mV=["gate","flag","skip"];function v0(t){return{type:"task",title:"",description:"",phase:(t==null?void 0:t.phase)??"planning",priority:1,assignedTo:"unassigned",governance:"flag",featureCode:""}}function OT({open:t,onClose:e,parentItem:r}){const n=gr(b=>b.createItem),[i,s]=C.useState(()=>v0(r)),[o,a]=C.useState("task"),[l,c]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(""),m=C.useRef(null);C.useEffect(()=>{if(t){const b=v0(r);s(b),a("task"),c(!1),f(""),setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},50)}},[t,r]);const x=b=>{const k=k0.find(T=>T.id===b);k&&(a(b),s(T=>({...T,type:k.defaults.type,phase:(r==null?void 0:r.phase)??k.defaults.phase,priority:k.defaults.priority,governance:k.defaults.governance})))},g=async()=>{if(!i.title.trim()){f("Title is required");return}d(!0),f("");try{const b={type:i.type,title:i.title.trim(),description:i.description.trim()||void 0,phase:i.phase||void 0,status:"planned",confidence:0,priority:i.priority,assignedTo:i.assignedTo!=="unassigned"?i.assignedTo:void 0,governance:i.governance!=="flag"?i.governance:void 0,featureCode:i.featureCode.trim()||void 0};await n(b),e()}catch{f("Failed to create item")}finally{d(!1)}},y=b=>{b.key==="Enter"&&!b.shiftKey&&b.target.tagName!=="TEXTAREA"&&(b.preventDefault(),g())};return h.jsx(qp,{open:t,onOpenChange:b=>!b&&e(),children:h.jsxs(sh,{className:"max-w-md",onKeyDown:y,children:[h.jsx(oh,{children:h.jsx(ah,{children:"New Item"})}),h.jsxs("div",{className:"px-6 pb-2 space-y-4",children:[h.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:k0.map(b=>h.jsx("button",{type:"button",onClick:()=>x(b.id),className:rt("rounded-md px-2 py-1.5 text-[11px] font-medium border transition-colors",o===b.id?"bg-accent/10 border-accent/60 text-accent":"border-border/40 text-muted-foreground hover:border-border hover:text-foreground"),children:b.label},b.id))}),h.jsx("input",{ref:m,type:"text",placeholder:"Item title…",value:i.title,onChange:b=>s(k=>({...k,title:b.target.value})),className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring"}),h.jsx("textarea",{placeholder:"Description (optional)…",value:i.description,onChange:b=>s(k=>({...k,description:b.target.value})),rows:2,className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring resize-none"}),h.jsxs("button",{type:"button",onClick:()=>c(b=>!b),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[l?h.jsx(yb,{className:"h-3 w-3"}):h.jsx(fa,{className:"h-3 w-3"}),"Advanced"]}),l&&h.jsxs("div",{className:"space-y-3 border border-border/40 rounded-md p-3 bg-muted/20",children:[h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Feature Code"}),h.jsx("input",{type:"text",placeholder:"e.g. COMP-UI-5",value:i.featureCode,onChange:b=>s(k=>({...k,featureCode:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none"})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Phase"}),h.jsx("select",{value:i.phase,onChange:b=>s(k=>({...k,phase:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:ny.map(b=>h.jsx("option",{value:b,children:jl[b]??b},b))})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Priority"}),h.jsxs("select",{value:i.priority,onChange:b=>s(k=>({...k,priority:Number(b.target.value)})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:[h.jsx("option",{value:0,children:"Low (0)"}),h.jsx("option",{value:1,children:"Normal (1)"}),h.jsx("option",{value:2,children:"High (2)"}),h.jsx("option",{value:3,children:"Critical (3)"})]})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Assign to"}),h.jsx("select",{value:i.assignedTo,onChange:b=>s(k=>({...k,assignedTo:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:sy.map(b=>h.jsx("option",{value:b,children:b},b))})]}),h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Governance"}),h.jsx("div",{className:"flex gap-1.5",children:mV.map(b=>h.jsx("button",{type:"button",onClick:()=>s(k=>({...k,governance:b})),className:rt("flex-1 text-[11px] px-2 py-1 rounded border transition-colors",i.governance===b?b==="gate"?"bg-amber-500/20 text-amber-300 border-amber-500/40":b==="flag"?"bg-blue-500/20 text-blue-300 border-blue-500/40":"bg-slate-700 text-slate-400 border-slate-600":"border-border/40 text-muted-foreground hover:border-border"),children:b},b))})]})]}),p&&h.jsx("p",{className:"text-xs text-destructive",children:p})]}),h.jsxs(Hp,{children:[h.jsx($t,{variant:"ghost",size:"sm",onClick:e,disabled:u,children:"Cancel"}),h.jsx($t,{size:"sm",onClick:g,disabled:u||!i.title.trim(),children:u?"Creating…":"Create"})]})]})})}const gV=["explore_design","prd","architecture","blueprint","verification","plan","execute","report","docs","ship"],xV=[{id:"gate",Icon:qs,label:"Gate",active:"bg-amber-500/20 text-amber-300 border-amber-500/40"},{id:"flag",Icon:kb,label:"Flag",active:"bg-blue-500/20 text-blue-300 border-blue-500/40"},{id:"skip",Icon:_b,label:"Skip",active:"bg-slate-700 text-slate-400 border-slate-600"}];function yV(t,e){var r,n;return((n=(r=t==null?void 0:t.governance)==null?void 0:r.phases)==null?void 0:n[e])??"flag"}function RT({open:t,onClose:e,settings:r,onSettingsChange:n}){const[i,s]=C.useState(!1),o=C.useRef(null),a=C.useCallback((l,c)=>{n==null||n({governance:{phases:{[l]:c}}}),clearTimeout(o.current),s(!0),o.current=setTimeout(()=>s(!1),1500)},[n]);return h.jsx(qp,{open:t,onOpenChange:l=>!l&&e(),children:h.jsxs(sh,{className:"max-w-sm",children:[h.jsx(oh,{children:h.jsxs("div",{className:"flex items-center justify-between pr-6",children:[h.jsx(ah,{children:"Governance Settings"}),i&&h.jsx("span",{className:"text-[11px] text-emerald-400 font-medium",children:"Saved ✓"})]})}),h.jsx("div",{className:"px-6 pb-6 space-y-1 max-h-96 overflow-y-auto",children:gV.map(l=>{const c=l==="explore_design",u=yV(r,l),d=ve[l]??l;return h.jsxs("div",{className:rt("flex items-center gap-3 rounded-md px-2 py-1.5",c&&"opacity-40"),children:[h.jsx("span",{className:rt("text-xs flex-1 min-w-0 truncate",c?"text-muted-foreground":"text-foreground"),children:d}),c?h.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"no policy"}):h.jsx("div",{className:"flex gap-1 shrink-0",children:xV.map(p=>{const f=u===p.id,{Icon:m}=p;return h.jsxs("button",{onClick:()=>a(l,p.id),title:p.label,className:rt("flex items-center gap-1 px-2 py-0.5 text-[10px] rounded border transition-colors",f?p.active:"border-border/30 text-muted-foreground hover:border-border hover:text-foreground"),children:[h.jsx(m,{className:"h-2.5 w-2.5"}),p.label]},p.id)})})]},l)})}),h.jsx("div",{className:"px-6 pb-4 text-[10px] text-muted-foreground border-t border-border/30 pt-3",children:"Agent config via Compose CLI"})]})})}function $T({onOpenGate:t}){const{gates:e,items:r}=gr(Li(g=>({gates:g.gates,items:g.items}))),[n,i]=C.useState(new Set),[s,o]=C.useState(0),a=e.filter(g=>g.status==="pending"&&!n.has(g.id));if(a.length===0)return null;const l=Math.min(s,a.length-1),c=a[l],u=r.find(g=>g.id===c.itemId)||r.find(g=>{var y;return((y=g.lifecycle)==null?void 0:y.featureCode)&&c.featureCode&&g.lifecycle.featureCode===c.featureCode}),d=Go(c,u),p=C_[c.fromPhase]??k_,f=()=>{i(g=>new Set([...g,c.id])),l>=a.length-1&&l>0&&o(l-1)},m=()=>o(Math.max(0,l-1)),x=()=>o(Math.min(a.length-1,l+1));return h.jsxs("div",{className:rt("shrink-0 h-10 border-t flex items-center gap-2 px-3",p.bg,p.border),children:[h.jsx(qs,{className:rt("h-3.5 w-3.5 shrink-0",p.text)}),h.jsx("span",{className:rt("text-[11px] font-medium truncate flex-1 min-w-0",p.text),children:d}),a.length>1&&h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx("button",{onClick:m,disabled:l===0,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(xb,{className:"h-3 w-3"})}),h.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[l+1,"/",a.length]}),h.jsx("button",{onClick:x,disabled:l===a.length-1,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(js,{className:"h-3 w-3"})})]}),h.jsx("button",{onClick:()=>t==null?void 0:t(c.id),className:rt("shrink-0 text-[10px] px-2 py-0.5 rounded border transition-colors hover:opacity-80",p.border,p.text),children:"Review"}),h.jsx("button",{onClick:f,className:"shrink-0 p-0.5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Dismiss (page session only)",children:h.jsx(cn,{className:"h-3 w-3"})})]})}const bV="●",CV="text-zinc-400";function kV(t,e){if(!t)return"";const n=(e??Date.now())-new Date(t).getTime(),i=Math.floor(n/6e4);if(i<1)return"now";if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function vV(t){var e;return((e=oy[t])==null?void 0:e.icon)??bV}function wV(t){var e;return((e=oy[t])==null?void 0:e.color)??CV}const SV={IMPLEMENTER:"bg-blue-500/15 text-blue-300 border border-blue-500/25",REVIEWER:"bg-emerald-500/15 text-emerald-300 border border-emerald-500/25",PRODUCER:"bg-purple-500/15 text-purple-300 border border-purple-500/25"};function TV(t){return SV[t]??"bg-zinc-500/15 text-zinc-300 border border-zinc-500/25"}function _V(t,e){return t.filter(r=>r.feature_code===e).slice().sort((r,n)=>r.timestamp.localeCompare(n.timestamp))}function EV(t){if(!t)return"";try{return new Date(t).toISOString().slice(11,16)}catch{return""}}function NV({event:t,now:e}){const r=vV(t.kind),n=wV(t.kind),i=kV(t.timestamp,e);return h.jsxs("div",{"data-decision-card":!0,className:"inline-flex flex-col gap-0.5 w-40 shrink-0 rounded border border-border/40 bg-muted/20 px-2 py-1.5 text-left",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1",children:[h.jsx("span",{className:rt("text-[11px] shrink-0",n),children:r}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",children:i||EV(t.timestamp)})]}),h.jsx("p",{className:"text-[11px] text-foreground/80 truncate leading-tight",children:t.title}),t.roles&&t.roles.length>0&&h.jsx("div",{className:"flex flex-wrap gap-0.5 mt-0.5",children:t.roles.map((s,o)=>h.jsx("span",{"data-role-chip":!0,className:rt("text-[9px] px-1 py-px rounded-full leading-tight",TV(s.name)),children:s.name},o))})]})}function zT({events:t=[],currentFeatureCode:e,now:r}){const n=_V(t,e);return n.length===0?null:h.jsx("div",{className:"w-full overflow-x-auto whitespace-nowrap border-b border-border/30 bg-background/95 backdrop-blur-sm",style:{height:72,minHeight:72,maxHeight:72,position:"sticky",top:32,zIndex:20},"data-decision-timeline-strip":!0,children:h.jsx("div",{className:"flex items-center gap-2 px-3 h-full",children:n.map(i=>h.jsx(NV,{event:i,now:r},i.id))})})}function jV(t){if(!t)return[];const e=[];t.active_phase!=null&&e.push({label:"Phase",value:t.active_phase});const r=t.pending_gates??[];e.push({label:"Pending gates",value:r.length===0?"none":r.join(", ")}),e.push({label:"Open loops",value:t.open_loops_count??0}),e.push({label:"Gate load (24h)",value:t.gate_load_24h??0});const n=t.drift_alerts??[];return n.length>0?e.push({label:"Drift alerts",value:n.map(i=>i.axis_id||i.name||"unknown").join(", ")}):e.push({label:"Drift alerts",value:"none"}),t.computed_at&&e.push({label:"Updated",value:t.computed_at}),e}const LV="Select a feature to see status.";function WT({featureCode:t,snapshot:e}){const[r,n]=C.useState(!1),i=C.useCallback(()=>{n(a=>!a)},[]),s=(e==null?void 0:e.sentence)??LV,o=jV(e);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-status-band":!0,onClick:i,style:{position:"sticky",top:"0px",zIndex:30,height:"32px",minHeight:"32px",maxHeight:"32px",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"12px",paddingRight:"12px",userSelect:"none",overflow:"hidden"},className:"w-full bg-background/95 backdrop-blur-sm border-b border-border/30 text-sm text-foreground/80",title:s,"aria-expanded":r,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&i()},children:[h.jsx("span",{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1},children:s}),h.jsx("span",{style:{marginLeft:8,opacity:.5,fontSize:10},"aria-hidden":"true",children:r?"▲":"▼"})]}),r&&h.jsx("div",{"data-status-band-expansion":!0,style:{position:"relative",width:"100%",zIndex:29,maxHeight:200,overflowY:"auto"},className:"bg-background/98 border-b border-border/50 text-xs text-foreground/70",children:h.jsx("div",{style:{padding:"8px 12px"},children:o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"No details available."}):h.jsx("table",{style:{width:"100%",borderCollapse:"collapse"},children:h.jsx("tbody",{children:o.map((a,l)=>h.jsxs("tr",{children:[h.jsx("td",{style:{paddingRight:16,paddingBottom:2,fontWeight:500,whiteSpace:"nowrap"},className:"text-foreground/60",children:a.label}),h.jsx("td",{style:{paddingBottom:2},children:String(a.value)})]},l))})})})})]})}function BV({onContextSelect:t,sidebarOpen:e=!0,onToggleSidebar:r}){const{items:n,connections:i,connected:s,uiCommand:o,clearUICommand:a,recentChanges:l,createItem:c,updateItem:u,deleteItem:d,createConnection:p,deleteConnection:f,agentActivity:m,agentErrors:x,sessionState:g,registerSnapshotProvider:y,gates:b,gateEvent:k,resolveGate:T,settings:_,updateSettings:w,resetSettings:E,activeBuild:B,setActiveBuild:P,pipelineDraft:N,sessions:M,selectedPhase:$,setSelectedPhase:q,decisionEvents:O,statusSnapshots:I,setStatusSnapshot:A}=gr(),[D,R]=C.useState(()=>sessionStorage.getItem("vision-selectedItemId")||null),j=C.useRef(!!sessionStorage.getItem("vision-activeView")),[S,W]=C.useState(()=>sessionStorage.getItem("vision-activeView")||"roadmap"),[K,F]=C.useState(""),[ht,st]=C.useState(null),[J,ct]=C.useState(!1),[zt,at]=C.useState(!1),[Z,lt]=C.useState(!1);C.useEffect(()=>{sessionStorage.setItem("vision-activeView",S)},[S]),C.useEffect(()=>{D?sessionStorage.setItem("vision-selectedItemId",D):sessionStorage.removeItem("vision-selectedItemId")},[D]);const Ct=C.useRef(!1);C.useEffect(()=>{var tt;(tt=_==null?void 0:_.ui)!=null&&tt.defaultView&&!Ct.current&&!j.current&&(W(_.ui.defaultView),Ct.current=!0)},[_]),C.useEffect(()=>{o&&(o.view&&W(o.view),o.phase!==void 0&&q(o.phase),o.select!==void 0&&R(o.select),a())},[o,a]),C.useEffect(()=>{const tt=()=>{var G;return["INPUT","TEXTAREA","SELECT"].includes((G=document.activeElement)==null?void 0:G.tagName)},kt=G=>{(G.metaKey||G.ctrlKey)&&G.key==="k"&&(G.preventDefault(),ct(nt=>!nt)),(G.metaKey||G.ctrlKey)&&G.key==="n"&&(G.preventDefault(),at(!0)),G.key===","&&!G.metaKey&&!G.ctrlKey&&!tt()&&lt(!0)};return window.addEventListener("keydown",kt),()=>window.removeEventListener("keydown",kt)},[]);const Mt=C.useMemo(()=>{let tt=n;if($&&(tt=tt.filter(kt=>kt.phase===$)),K){const kt=K.toLowerCase();tt=tt.filter(G=>G.title.toLowerCase().includes(kt)||(G.description||"").toLowerCase().includes(kt))}return tt},[n,$,K]),Dt=C.useMemo(()=>$?n.filter(tt=>tt.phase===$):n,[n,$]),ne=C.useMemo(()=>new Set(Dt.map(tt=>tt.id)),[Dt]),ue=C.useMemo(()=>$?b.filter(tt=>ne.has(tt.itemId)):b,[b,ne,$]),Se=C.useMemo(()=>{if(!$&&!K)return i;const tt=new Set(Mt.map(kt=>kt.id));return i.filter(kt=>tt.has(kt.fromId)&&tt.has(kt.toId))},[i,Mt,$,K]);C.useEffect(()=>{y(()=>({activeView:S,selectedPhase:$,searchQuery:K,selectedItemId:D,totalItems:n.length,filteredCount:Mt.length,connected:s}))},[y,S,$,K,D,n.length,Mt.length,s]);const te=C.useCallback(tt=>{R(tt),t&&t({type:"item",id:tt})},[t]),Ae=C.useCallback((tt,kt)=>{u(tt,kt)},[u]);C.useCallback(async()=>{const kt=await c({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:$||"vision"});kt&&kt.id&&R(kt.id)},[c,$]),C.useCallback(async tt=>{await d(tt),D===tt&&(R(null),t&&t(null))},[d,D,t]);const V=C.useCallback(tt=>{const kt=b.find(G=>G.id===tt);kt&&(R(kt.itemId),t&&t({type:"item",id:kt.itemId}))},[b,t]);C.useCallback(async tt=>p(tt),[p]),C.useCallback(async tt=>f(tt),[f]);const it=C.useCallback(()=>{Rt("/api/build/state").then(tt=>tt.json()).then(tt=>P(tt.state??null)).catch(()=>{})},[P]),dt=C.useCallback(tt=>{t&&t({type:"step",id:tt})},[t]),Nt=C.useMemo(()=>{var kt;if(!D)return null;const tt=n.find(G=>G.id===D);return((kt=tt==null?void 0:tt.lifecycle)==null?void 0:kt.featureCode)||null},[D,n]);return C.useEffect(()=>{Nt&&(I&&I[Nt]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(Nt)}`).then(tt=>tt.json()).then(tt=>{tt.snapshot&&A&&A(Nt,tt.snapshot)}).catch(()=>{}))},[Nt]),h.jsx(Mc.Provider,{value:l,children:h.jsxs("div",{className:"h-full flex flex-col bg-background","data-snapshot-root":!0,children:[h.jsx(WT,{featureCode:Nt,snapshot:Nt?(I==null?void 0:I[Nt])??null:null}),Nt&&h.jsx(zT,{events:O,currentFeatureCode:Nt}),h.jsxs("div",{className:"flex-1 flex min-h-0",children:[h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[r&&h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:r,title:e?"Collapse sidebar":"Expand sidebar","aria-expanded":e,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:e?"‹":"›"}),e&&h.jsx(d1,{items:n,gates:b,activeBuild:B,activeView:S,onViewChange:W,selectedPhase:$,onPhaseSelect:q,searchQuery:K,onSearchChange:F,connected:s,agentActivity:m,agentErrors:x,sessionState:g,onSelectItem:te,onThemeChange:w,onNewItem:()=>at(!0)})]}),h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[!s&&h.jsx("div",{className:"text-center text-[10px] py-0.5 bg-destructive text-destructive-foreground",children:"Disconnected — reconnecting..."}),S==="tree"&&h.jsx(p1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="graph"&&h.jsx(g1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="pipeline"&&h.jsx(XS,{activeBuild:B,pipelineDraft:N,onSelectStep:dt,onRefresh:it}),S==="sessions"&&h.jsx(eT,{sessions:M,items:n,onSelectItem:te}),S==="docs"&&h.jsx(qS,{items:Dt}),S==="gates"&&h.jsx(US,{gates:ue,items:Dt,onResolve:T,onSelect:te}),S==="settings"&&h.jsx(YS,{settings:_,onSettingsChange:w,onReset:E})]}),h.jsx($T,{onOpenGate:V}),ht&&(()=>{const tt=n.find(kt=>kt.id===ht);return tt?h.jsx(VS,{item:tt,items:n,connections:i,onUpdate:Ae,onClose:()=>st(null)}):null})(),h.jsx(GS,{event:k,items:n,onNavigate:()=>W("gates")}),h.jsx(rT,{open:J,onClose:()=>ct(!1),onSelectItem:tt=>{te(tt),ct(!1)},onSelectGate:tt=>{V(tt),ct(!1)}}),h.jsx(OT,{open:zt,onClose:()=>at(!1)}),h.jsx(RT,{open:Z,onClose:()=>lt(!1),settings:_,onSettingsChange:w})]})]})})}la.use(ry);const AV={background:"#0b0b14",overlay:"#161625",textPrimary:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",textMuted:"#475569",accent:"#FBBF24"},MV={background:"#FFFFFF",overlay:"#F5F5F5",textPrimary:"#0a0a0a",textSecondary:"#404040",textTertiary:"#737373",textMuted:"#a3a3a3",accent:"#FBBF24"};function IV(t){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"11px","font-weight":600,"font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textPrimary,"text-wrap":"wrap","text-max-width":"110px","background-color":t.overlay,"border-width":1,"border-color":"data(color)","border-opacity":.5,width:140,height:52,shape:"round-rectangle","text-outline-width":0,"overlay-padding":4,"overlay-opacity":0}},{selector:'node[shape = "diamond"]',style:{shape:"diamond",width:160,height:80,"font-size":"10px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":t.accent}},{selector:"edge",style:{width:1,"line-color":t.textMuted,"target-arrow-color":t.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.7,opacity:.5}},{selector:"edge[label]",style:{label:"data(label)","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textSecondary,"text-rotation":"autorotate","text-margin-y":-8,"text-outline-width":3,"text-outline-color":t.background}},{selector:"edge[color]",style:{"line-color":"data(color)","target-arrow-color":"data(color)"}},{selector:'edge[lineStyle = "dashed"]',style:{"line-style":"dashed"}},{selector:'edge[lineStyle = "dotted"]',style:{"line-style":"dotted"}},{selector:":parent",style:{"background-color":t.overlay,"background-opacity":.3,"border-width":1,"border-color":"data(color)","border-opacity":.3,"text-valign":"top","text-halign":"center","font-size":"10px",color:t.textTertiary,padding:"16px"}}]}function FV(){const[t,e]=C.useState(()=>document.documentElement.classList.contains("dark"));return C.useEffect(()=>{const r=new MutationObserver(()=>e(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}const PV={"dagre-tb":{name:"dagre",rankDir:"LR",rankSep:80,nodeSep:50,padding:40},"dagre-lr":{name:"dagre",rankDir:"TB",rankSep:100,nodeSep:40,padding:40},circle:{name:"circle",padding:40},grid:{name:"grid",padding:40,rows:3},concentric:{name:"concentric",padding:40,minNodeSpacing:60},breadthfirst:{name:"breadthfirst",padding:40,spacingFactor:1.2}},DV={"dagre-tb":"Top → Down","dagre-lr":"Left → Right",circle:"Circle",grid:"Grid",concentric:"Concentric",breadthfirst:"Breadthfirst"};function OV(t,e){const r=[];for(const n of t)r.push({data:{id:n.id,label:n.label,sublabel:n.sublabel||void 0,color:n.color||CY.textMuted,parent:n.parent||void 0,shape:n.shape||void 0},...n.position?{position:n.position}:{}});for(const n of e)r.push({data:{id:n.id||`${n.from}-${n.to}-${n.label||""}`,source:n.from,target:n.to,label:n.label||void 0,color:n.color||void 0,lineStyle:n.style||"solid",edgeType:n.type||void 0}});return r}const wc="compose:graph:";function RV(t){try{const e=localStorage.getItem(wc+t);return e?JSON.parse(e):null}catch{return null}}function $V(t,e){try{localStorage.setItem(wc+t,JSON.stringify(e))}catch{}}const zV=[{style:"solid",label:"Structural / hard",dash:null},{style:"dashed",label:"Informational / weak",dash:"4,3"},{style:"dotted",label:"Soft dependency",dash:"1.5,3"}];function os({onClick:t,active:e,children:r,title:n}){return h.jsx("button",{onClick:t,title:n,className:"text-xs rounded cursor-pointer transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground))"},children:r})}function il({mode:t,active:e,onClick:r}){return h.jsx("button",{onClick:r,className:"text-xs rounded cursor-pointer capitalize transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:t})}function bu(){return h.jsx("div",{className:"w-px h-4 mx-0.5",style:{background:"hsl(var(--border))"}})}function w0({arrow:t,label:e,edgeStyle:r,color:n,targetLabel:i,targetColor:s,suffix:o}){return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:t}),h.jsx("span",{style:{color:n||"hsl(var(--muted-foreground))",fontStyle:r==="dashed"?"italic":"normal"},children:e||"connects"}),i?h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:s||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:i})]})]}):o?h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:o}):null,r&&r!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",r,")"]})]})}function WV({nodes:t,edges:e,graphKey:r}){const[n,i]=C.useState(()=>{try{const l=localStorage.getItem(wc+r+":tree-collapsed");return l?new Set(JSON.parse(l)):new Set}catch{return new Set}});C.useEffect(()=>{try{localStorage.setItem(wc+r+":tree-collapsed",JSON.stringify([...n]))}catch{}},[n,r]);const s=C.useMemo(()=>{const l={};for(const c of t)l[c.id]=c;return l},[t]),o=C.useMemo(()=>{var u,d;const l={},c={};for(const p of t)l[p.id]=[],c[p.id]=[];for(const p of e)(u=l[p.from])==null||u.push(p),(d=c[p.to])==null||d.push(p);return{out:l,inc:c}},[t,e]),a=l=>i(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u});return h.jsxs("div",{className:"w-full h-full overflow-y-auto",style:{background:"hsl(var(--background))",padding:"1rem"},children:[h.jsxs("div",{className:"flex items-center mb-4",style:{gap:"8px"},children:[h.jsx(os,{onClick:()=>i(new Set),children:"Expand all"}),h.jsx(os,{onClick:()=>i(new Set(t.map(l=>l.id))),children:"Collapse all"}),h.jsxs("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground))"},children:[t.length," entities · ",e.length," relations"]})]}),t.map(l=>{const c=n.has(l.id),u=o.out[l.id]||[],d=o.inc[l.id]||[],p=u.filter(g=>g.from===g.to),f=u.filter(g=>g.from!==g.to),m=d.filter(g=>g.from!==g.to),x=f.length+m.length+p.length;return h.jsxs("div",{className:"mb-0.5",children:[h.jsxs("button",{onClick:()=>a(l.id),className:"flex items-center w-full text-left bg-transparent border-none cursor-pointer rounded-md transition-colors hover:bg-[hsl(var(--accent))]",style:{gap:"8px",padding:"8px"},children:[h.jsx("span",{className:"text-xs w-4 text-center inline-block transition-transform",style:{color:"hsl(var(--muted-foreground))",transform:c?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),h.jsx("span",{className:"w-3 h-3 shrink-0",style:{borderRadius:l.shape==="diamond"?0:3,background:l.color,transform:l.shape==="diamond"?"rotate(45deg) scale(0.8)":"none"}}),h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:l.label}),l.sublabel&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:["— ",l.sublabel]}),h.jsx("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:x})]}),!c&&h.jsxs("div",{style:{paddingLeft:"32px",paddingBottom:"4px"},children:[f.map((g,y)=>{var b,k;return h.jsx(w0,{arrow:"→",label:g.label,edgeStyle:g.style,color:g.color,targetLabel:((b=s[g.to])==null?void 0:b.label)||g.to,targetColor:(k=s[g.to])==null?void 0:k.color},`out-${y}`)}),p.map((g,y)=>h.jsx(w0,{arrow:"↻",label:g.label,edgeStyle:g.style,color:g.color,suffix:"(self)"},`self-${y}`)),m.map((g,y)=>{var b,k;return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:((b=s[g.from])==null?void 0:b.color)||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:((k=s[g.from])==null?void 0:k.label)||g.from})]}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsx("span",{style:{color:g.color||"hsl(var(--muted-foreground))",fontStyle:g.style==="dashed"?"italic":"normal"},children:g.label||"connects"}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→ this"}),g.style&&g.style!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",g.style,")"]})]},`in-${y}`)}),x===0&&h.jsx("div",{className:"text-xs italic",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground) / 0.6)"},children:"no relations"})]})]},l.id)})]})}function qV({elements:t,nodes:e,edges:r,layout:n,style:i,title:s,subtitle:o,graphKey:a="default",onNodeClick:l}){const c=C.useRef(null),u=C.useRef(null),[d,p]=C.useState(null),f=FV(),m=f?AV:MV,x=C.useMemo(()=>RV(a),[a]),[g,y]=C.useState((x==null?void 0:x.layoutKey)||"dagre-tb"),[b,k]=C.useState((x==null?void 0:x.showEdgeLabels)??!0),[T,_]=C.useState(()=>new Set((x==null?void 0:x.hiddenNodes)||[])),[w,E]=C.useState((x==null?void 0:x.showLegend)??!0),[B,P]=C.useState((x==null?void 0:x.viewMode)||"graph");C.useEffect(()=>{$V(a,{layoutKey:g,showEdgeLabels:b,hiddenNodes:[...T],showLegend:w,viewMode:B})},[a,g,b,T,w,B]);const N=t||(e&&r?OV(e,r):[]),M=C.useMemo(()=>i||IV(m),[i,f]),$=n||PV[g],q=C.useMemo(()=>N.filter(S=>!S.data.source).map(S=>({id:S.data.id,label:S.data.label,color:S.data.color})),[JSON.stringify(N)]),O=C.useMemo(()=>T.size===0?N:N.filter(S=>S.data.source?!T.has(S.data.source)&&!T.has(S.data.target):!T.has(S.data.id)),[N,T]);C.useEffect(()=>{if(!c.current)return;const S=la({container:c.current,elements:O,style:M,layout:$,minZoom:.2,maxZoom:4,wheelSensitivity:.3,boxSelectionEnabled:!1});return u.current=S,S.on("mouseover","node",W=>{const K=W.target;K.style("border-width",2),K.style("border-opacity",1);const F=K.renderedPosition();p({x:F.x,y:F.y-K.renderedHeight()/2-12,label:K.data("label"),sublabel:K.data("sublabel"),id:K.id(),color:K.data("color")})}),S.on("mouseout","node",W=>{W.target.style("border-width",1),W.target.style("border-opacity",.5),p(null)}),l&&S.on("tap","node",W=>l(W.target.id())),S.on("layoutstop",()=>S.fit(void 0,40)),()=>{S.destroy(),u.current=null}},[JSON.stringify(O),JSON.stringify($),f,B]),C.useEffect(()=>{const S=u.current;S&&S.edges().forEach(W=>{W.data("label")&&W.style("label",b?W.data("label"):"")})},[b]);const I=C.useCallback(()=>{var S;return(S=u.current)==null?void 0:S.fit(void 0,40)},[]),A=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()*1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),D=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()/1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),R=C.useCallback(S=>{_(W=>{const K=new Set(W);return K.has(S)?K.delete(S):K.add(S),K})},[]),j=C.useCallback(()=>_(new Set),[]);return B==="tree"?h.jsxs("div",{className:"w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"flex items-center justify-between shrink-0",style:{padding:"8px 16px",borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center",style:{gap:"8px"},children:[s&&h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"flex",style:{gap:"4px"},children:[h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(WV,{nodes:e||[],edges:r||[],graphKey:a})})]}):h.jsxs("div",{className:"w-full h-full relative",style:{background:"hsl(var(--background))"},children:[(s||o)&&h.jsxs("div",{className:"absolute top-0 left-0 right-0 z-[2] pointer-events-none",style:{padding:"8px 16px",background:"linear-gradient(to bottom, hsl(var(--background)) 0%, transparent 100%)"},children:[s&&h.jsx("div",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"absolute top-2 right-3 z-[2] flex items-center",style:{gap:"4px"},children:[h.jsx("select",{value:g,onChange:S=>y(S.target.value),className:"text-xs rounded cursor-pointer appearance-none",style:{padding:"4px 8px",borderRadius:"0.375rem",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",color:"hsl(var(--muted-foreground))"},title:"Graph layout",children:Object.entries(DV).map(([S,W])=>h.jsx("option",{value:S,style:{background:"hsl(var(--accent))",color:"hsl(var(--foreground))"},children:W},S))}),h.jsx(bu,{}),h.jsx(os,{onClick:D,title:"Zoom out",children:"−"}),h.jsx(os,{onClick:I,title:"Fit to view",children:"Fit"}),h.jsx(os,{onClick:A,title:"Zoom in",children:"+"}),h.jsx(bu,{}),h.jsx(os,{onClick:()=>E(!w),active:w,title:w?"Hide legend":"Show legend",children:"Legend"}),h.jsx(bu,{}),h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]}),w&&h.jsxs("div",{className:"absolute bottom-3 left-3 z-[2]",style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"8px 16px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:150,maxWidth:210},children:[h.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Entities"}),T.size>0&&h.jsx("button",{onClick:j,className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:"hsl(var(--primary))"},children:"Show all"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:q.map(S=>{const W=T.has(S.id);return h.jsxs("button",{onClick:()=>R(S.id),className:"flex items-center gap-1.5 bg-transparent border-none py-0.5 cursor-pointer transition-opacity",style:{opacity:W?.35:1},title:W?`Show ${S.label}`:`Hide ${S.label}`,children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0 transition-colors",style:{background:W?"transparent":S.color,border:`1.5px solid ${S.color}`}}),h.jsx("span",{className:"text-xs",style:{color:W?"hsl(var(--muted-foreground) / 0.6)":"hsl(var(--muted-foreground))",textDecoration:W?"line-through":"none"},children:S.label})]},S.id)})}),h.jsxs("div",{className:"flex justify-between items-center mt-2.5 mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Edges"}),h.jsx("button",{onClick:()=>k(!b),className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:b?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:b?"Hide labels":"Show labels"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:zV.map(S=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("svg",{width:"20",height:"6",className:"shrink-0",children:h.jsx("line",{x1:"0",y1:"3",x2:"20",y2:"3",stroke:"hsl(var(--muted-foreground))",strokeWidth:"1.5",strokeDasharray:S.dash||"none"})}),h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:S.label})]},S.style))})]}),d&&h.jsxs("div",{className:"absolute z-10 text-center pointer-events-none backdrop-blur-sm",style:{left:d.x,top:d.y,transform:"translate(-50%, -100%)",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"4px 8px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:110,maxWidth:200},children:[h.jsx("div",{className:"text-sm font-semibold",style:{color:d.color||"hsl(var(--foreground))"},children:d.label}),d.sublabel&&h.jsx("div",{className:"text-xs mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:d.sublabel}),h.jsx("div",{className:"text-[10px] mt-1 font-mono",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:d.id})]}),h.jsx("div",{ref:c,className:"w-full h-full"})]})}const Wt={discovery:"#a78bfa",feature:"#3b82f6",track:"#06b6d4",task:"#94a3b8",spec:"#a78bfa",idea:"#fbbf24",question:"#f472b6",evaluation:"#f59e0b",thread:"#64748b",decision:"#22c55e",artifact:"#a87cb8",informs:"#64748b",pipeline:"#6366f1"},HV=[{id:"discovery",label:"Discovery",sublabel:"orthogonal process",color:Wt.discovery,shape:"diamond"},{id:"pipeline",label:"Feature Development Pipeline",color:Wt.pipeline},{id:"p-vision",label:"Vision",parent:"pipeline",color:Wt.pipeline},{id:"p-specification",label:"Specification",parent:"pipeline",color:Wt.pipeline},{id:"p-planning",label:"Planning",parent:"pipeline",color:Wt.pipeline},{id:"p-implementation",label:"Implementation",parent:"pipeline",color:Wt.pipeline},{id:"p-verification",label:"Verification",parent:"pipeline",color:Wt.pipeline},{id:"p-release",label:"Release",parent:"pipeline",color:Wt.pipeline},{id:"feature",label:"Feature",sublabel:"strategic container",color:Wt.feature},{id:"track",label:"Track",sublabel:"deliverable unit",color:Wt.track},{id:"task",label:"Task",sublabel:"planned → doing → done",color:Wt.task},{id:"spec",label:"Spec",sublabel:"behavioral specification",color:Wt.spec},{id:"evaluation",label:"Evaluation",sublabel:"assessment / gap analysis",color:Wt.evaluation},{id:"idea",label:"Idea",sublabel:"can float free",color:Wt.idea},{id:"thread",label:"Thread",sublabel:"deliberation",color:Wt.thread},{id:"decision",label:"Decision",sublabel:"resolved choice",color:Wt.decision},{id:"question",label:"Question",sublabel:"may block progress",color:Wt.question},{id:"artifact",label:"Artifact",sublabel:"journal / doc / output",color:Wt.artifact}],UV=[{from:"p-vision",to:"p-specification",color:Wt.pipeline},{from:"p-specification",to:"p-planning",color:Wt.pipeline},{from:"p-planning",to:"p-implementation",color:Wt.pipeline},{from:"p-implementation",to:"p-verification",color:Wt.pipeline},{from:"p-verification",to:"p-release",color:Wt.pipeline},{from:"idea",to:"p-vision",label:"lives in",color:Wt.idea,style:"dotted"},{from:"spec",to:"p-specification",label:"lives in",color:Wt.spec,style:"dotted"},{from:"task",to:"p-implementation",label:"lives in",color:Wt.task,style:"dotted"},{from:"evaluation",to:"p-verification",label:"lives in",color:Wt.evaluation,style:"dotted"},{from:"discovery",to:"feature",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"idea",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"thread",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"decision",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"question",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"spec",label:"produces",color:Wt.discovery,style:"dashed"},{from:"track",to:"feature",label:"implements",color:Wt.track},{from:"task",to:"feature",label:"implements",color:Wt.task},{from:"spec",to:"feature",label:"implements",color:Wt.spec},{from:"feature",to:"feature",label:"blocks",color:Wt.question,id:"feat-blocks"},{from:"idea",to:"feature",label:"informs",color:Wt.informs,style:"dashed"},{from:"thread",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"evaluation",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"artifact",to:"feature",label:"supports",color:Wt.artifact},{from:"question",to:"decision",label:"contradicts",color:Wt.question},{from:"feature",to:"p-vision",label:"enters",color:Wt.feature,style:"dashed"}];function GV(){return h.jsx(qV,{graphKey:"product",nodes:HV,edges:UV,title:"Compose Product Ontology",subtitle:"10 entity types · 6 phases · 5 edge types · Discovery orthogonal"})}const VV="compose-popout";function qT(t){if(t==="vision://surface")return"Vision Tracker";if(t.startsWith("graph://")){const r=t.replace("graph://","");return r.charAt(0).toUpperCase()+r.slice(1)+" Graph"}const e=t.split("/");return e.length>1?e.slice(-2).join("/"):e[e.length-1]}function sl({path:t,onDock:e}){return h.jsxs("div",{className:"flex items-center justify-between px-3 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--background))"},children:[h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:qT(t)}),h.jsxs("button",{onClick:e,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] uppercase tracking-wider",style:{color:"hsl(var(--primary))",background:"none",border:"none",cursor:"pointer"},title:"Pop back into main window",children:[h.jsx(jA,{style:{width:11,height:11}}),"pop in"]})]})}function YV({path:t}){const[e,r]=C.useState(null),[n,i]=C.useState(!0),s=C.useRef(null),o=C.useRef(null),a=t.startsWith("vision://")?"vision":t.startsWith("graph://")?"graph":t.endsWith(".html")||t.endsWith(".htm")?"html":"markdown";C.useEffect(()=>{document.title=qT(t)+" — Compose"},[t]),C.useEffect(()=>{const c=new BroadcastChannel(VV);s.current=c,c.postMessage({type:"popout-mounted",path:t});const u=()=>{c.postMessage({type:"popout-closed",path:t})};return window.addEventListener("beforeunload",u),()=>{u(),c.close(),window.removeEventListener("beforeunload",u)}},[t]);const l=C.useCallback(()=>{var c;(c=s.current)==null||c.postMessage({type:"popout-dock",path:t}),window.close()},[t]);return C.useEffect(()=>{if(a==="vision"||a==="graph"){i(!1);return}Rt(`/api/file?path=${encodeURIComponent(t)}`).then(c=>c.json()).then(c=>{c.content!==void 0&&r(c.content),i(!1)}).catch(()=>i(!1))},[t,a]),C.useEffect(()=>{if(a==="vision"||a==="graph")return;const c=window.location.protocol==="https:"?"wss:":"ws:",u=new WebSocket(`${c}//${window.location.host}/ws/files`);return o.current=u,u.onmessage=d=>{try{const p=JSON.parse(d.data);p.type==="fileChanged"&&p.path===t&&r(p.content)}catch{}},()=>u.close()},[t,a]),n?h.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):a==="vision"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(BV,{})})]}):a==="graph"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(GV,{})})]}):a==="html"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx("iframe",{srcDoc:e,className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin",title:t})})]}):h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:h.jsx("div",{className:"canvas-markdown max-w-4xl mx-auto",children:h.jsx(yf,{remarkPlugins:[vf],children:e||""})})})]})}const XV="/api/stratum";async function lh(t,e={}){return(await Rt(`${XV}${t}`,{headers:{"Content-Type":"application/json",...e.headers||{}},...e})).json()}function KV(t,e){return lh(t,{method:"POST",body:JSON.stringify(e)})}function HT({status:t}){const e={running:"hsl(var(--background))",awaiting_gate:"#7c3aed",complete:"#166534",killed:"#7f1d1d",blocked:"#7f1d1d"},r={running:"running",awaiting_gate:"gate pending",complete:"complete",killed:"killed",blocked:"blocked"};return h.jsx("span",{style:{fontSize:"0.72em",padding:"2px 6px",borderRadius:4,background:e[t]||"#333",color:"#e5e7eb",textTransform:"uppercase",letterSpacing:"0.05em"},children:r[t]||t})}function Up(){return h.jsx("span",{style:{opacity:.5,fontSize:"0.85em"},children:"loading…"})}function ZV({onAction:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState({}),[a,l]=C.useState({}),c=C.useCallback(()=>{lh("/gates").then(d=>{r(Array.isArray(d)?d:[]),i(null)}).catch(d=>i(d.message))},[]);C.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[c]);async function u(d,p,f){const m=`${d}/${p}/${f}`;o(g=>({...g,[m]:!0}));const x=a[`${d}/${p}`]||"";try{const g=await KV(`/gates/${d}/${p}/${f}`,{note:x});g.conflict?i(`Gate already resolved (${d}/${p})`):g.error?i(g.error.message):(t==null||t(),c())}catch(g){i(g.message)}finally{o(g=>({...g,[m]:!1}))}}return e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsxs("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:["Pending Gates ",(e==null?void 0:e.length)>0&&h.jsxs("span",{style:{opacity:1,color:"#f59e0b"},children:["(",e.length,")"]})]}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em",margin:"0 0 8px"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No pending gates."}),e==null?void 0:e.map(d=>{const p=`${d.flow_id}/${d.step_id}`,f=m=>s[`${p}/${m}`];return h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",marginBottom:8,background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:d.flow_name||d.flow_id}),h.jsx("span",{style:{opacity:.4,fontSize:"0.8em"},children:"›"}),h.jsx("span",{style:{fontFamily:"monospace",fontSize:"0.82em",opacity:.7},children:d.step_id}),d.function&&h.jsxs("span",{style:{opacity:.4,fontSize:"0.78em"},children:["fn:",d.function]})]}),h.jsx("input",{type:"text",placeholder:"Note (optional)",value:a[p]||"",onChange:m=>l(x=>({...x,[p]:m.target.value})),style:{width:"100%",boxSizing:"border-box",marginBottom:8,background:"#27272a",border:"1px solid #3f3f46",borderRadius:4,color:"#e4e4e7",padding:"4px 8px",fontSize:"0.82em"}}),h.jsx("div",{style:{display:"flex",gap:6},children:[{a:"approve",label:"Approve",color:"#166534",hover:"#15803d"},{a:"reject",label:"Reject",color:"#7f1d1d",hover:"#b91c1c"},{a:"revise",label:"Revise",color:"#1e3a5f",hover:"#1d4ed8"}].map(({a:m,label:x,color:g})=>h.jsx("button",{disabled:f(m),onClick:()=>u(d.flow_id,d.step_id,m),style:{padding:"4px 12px",fontSize:"0.8em",borderRadius:4,border:"none",background:g,color:"#e5e7eb",cursor:f(m)?"not-allowed":"pointer",opacity:f(m)?.5:1},children:f(m)?"…":x},m))})]},p)})]})}function QV({flowId:t,onClose:e}){const[r,n]=C.useState(null),[i,s]=C.useState(null);return C.useEffect(()=>{lh(`/flows/${t}`).then(o=>{o.error?s(o.error.message):n(o)}).catch(o=>s(o.message))},[t]),h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:(r==null?void 0:r.flow_name)||t}),h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"1.1em"},children:"✕"})]}),i&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:i}),!r&&!i&&h.jsx(Up,{}),r&&h.jsx("div",{style:{fontSize:"0.82em",opacity:.8},children:(()=>{const o=new Set(Array.isArray(r.completed_steps)?r.completed_steps:[]),a=new Set(Array.isArray(r.active_steps)?r.active_steps:[]),l=o.size,c=r.step_count??"?";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:[h.jsx("span",{children:h.jsx(HT,{status:r.status})}),h.jsxs("span",{children:["steps ",l,"/",c,a.size>0&&h.jsxs("span",{style:{marginLeft:6,color:"#34d399",fontSize:"0.85em"},children:["∥ ",a.size," running"]})]}),r.round>0&&h.jsxs("span",{children:["round ",r.round]})]}),Array.isArray(r.ordered_steps)&&r.ordered_steps.length>0&&h.jsx("ol",{style:{margin:0,padding:"0 0 0 18px",lineHeight:1.7},children:r.ordered_steps.map(u=>h.jsxs("li",{style:{opacity:o.has(u.id)?.4:1,fontWeight:a.has(u.id)?700:"normal",color:a.has(u.id)?"#34d399":"inherit"},children:[h.jsx("span",{style:{fontFamily:"monospace"},children:u.id}),u.mode==="gate"&&h.jsx("span",{style:{marginLeft:6,color:"#f59e0b",fontSize:"0.9em"},children:"gate"}),a.has(u.id)&&h.jsx("span",{style:{marginLeft:6,fontSize:"0.85em"},children:"∥ running"})]},u.id))})]})})()})]})}function JV({activeBuild:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState(null),a=C.useCallback(()=>{lh("/flows").then(l=>{r(Array.isArray(l)?l:[]),i(null)}).catch(l=>i(l.message))},[]);return C.useEffect(()=>{a();const l=setInterval(a,15e3);return()=>clearInterval(l)},[a]),C.useEffect(()=>{t&&a()},[t,a]),e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsx("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:"Flows"}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No flows found."}),e==null?void 0:e.map(l=>h.jsx("div",{onClick:()=>o(s===l.flow_id?null:l.flow_id),style:{border:`1px solid ${s===l.flow_id?"#6366f1":"#3f3f46"}`,borderRadius:6,padding:"8px 12px",marginBottom:6,background:s===l.flow_id?"#1e1b4b":"#18181b",cursor:"pointer"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("span",{style:{fontSize:"0.88em",fontWeight:500},children:l.flow_name||l.flow_id}),h.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsxs("span",{style:{fontSize:"0.78em",opacity:.5},children:[Array.isArray(l.completed_steps)?l.completed_steps.length:l.completed_steps??0,"/",l.step_count??"?"]}),h.jsx(HT,{status:l.status})]})]})},l.flow_id)),s&&h.jsx("div",{style:{marginTop:8},children:h.jsx(QV,{flowId:s,onClose:()=>o(null)})})]})}const tY={display:"inline-block",width:8,height:8,borderRadius:"50%",background:"#22c55e",marginRight:8,animation:"pulse-dot 1.5s ease-in-out infinite"};if(typeof document<"u"&&!document.getElementById("pulse-dot-style")){const t=document.createElement("style");t.id="pulse-dot-style",t.textContent="@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }",document.head.appendChild(t)}function eY({build:t,onDismiss:e}){const r=t.status==="running",n=["complete","failed","aborted"].includes(t.status);C.useEffect(()=>{if(t.status==="complete"){const s=setTimeout(()=>e==null?void 0:e(),5e3);return()=>clearTimeout(s)}},[t.status,e]);const i={running:"#166534",complete:"#14532d",failed:"#7f1d1d",aborted:"#78350f"};return h.jsxs("div",{style:{border:`1px solid ${r?"#22c55e33":"#3f3f46"}`,borderRadius:6,padding:"10px 12px",marginBottom:12,background:i[t.status]||"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&h.jsx("span",{style:tY}),h.jsx("span",{style:{fontWeight:600,fontSize:"0.88em"},children:t.featureCode}),h.jsx("span",{style:{opacity:.5,fontSize:"0.78em"},children:r?"building":t.status})]}),n&&t.status!=="complete"&&h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"0.9em"},children:"✕"})]}),h.jsxs("div",{style:{fontSize:"0.8em",opacity:.7,marginTop:4,fontFamily:"monospace"},children:[t.currentStepId,t.stepNum!=null&&t.totalSteps!=null&&h.jsxs("span",{style:{marginLeft:8,opacity:.5},children:["(",t.stepNum,"/",t.totalSteps,")"]}),t.retries>0&&h.jsxs("span",{style:{marginLeft:8,color:"#f59e0b"},children:["retry ",t.retries]})]})]})}function rY(){const t=gr(s=>s.activeBuild),[e,r]=C.useState(null),n=C.useCallback(()=>{t&&r(`${t.flowId}:${t.completedAt}`)},[t]);C.useEffect(()=>{(t==null?void 0:t.status)==="running"&&r(null)},[t==null?void 0:t.status]);const i=t&&!(e&&e===`${t.flowId}:${t.completedAt}`);return h.jsxs("div",{style:{padding:"12px 14px",color:"#e4e4e7",fontSize:"0.9em",overflowY:"auto",height:"100%"},children:[i&&h.jsx(eY,{build:t,onDismiss:n}),h.jsx(ZV,{}),h.jsx("div",{style:{marginTop:20},children:h.jsx(JV,{activeBuild:t})})]})}function nY({projectName:t,projectRoot:e,onSwitch:r}){const[n,i]=C.useState(!1),[s,o]=C.useState(e||""),a=C.useRef(null);return C.useEffect(()=>{o(e||"")},[e]),C.useEffect(()=>{if(!n)return;const l=c=>{var u;(u=a.current)!=null&&u.contains(c.target)||i(!1)};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[n]),C.useEffect(()=>{if(!n)return;const l=c=>{c.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n]),h.jsxs("div",{ref:a,className:"flex items-center shrink-0 gap-2 relative",children:[h.jsx("span",{className:"text-xs font-semibold tracking-widest uppercase text-accent",children:"Compose"}),h.jsx("button",{"data-testid":"project-btn",className:"text-[10px] uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(l=>!l),title:e||"Switch project","aria-label":"Switch project","aria-haspopup":"dialog","aria-expanded":n,children:t||"no project"}),n&&h.jsxs("div",{"data-testid":"project-popover",role:"dialog","aria-label":"Switch project",className:"absolute top-full left-0 mt-1 z-50 p-2 rounded-md shadow-lg",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:"280px"},children:[h.jsxs("div",{className:"text-[10px] text-muted-foreground mb-1 px-1",children:["Current: ",e]}),h.jsx("input",{autoFocus:!0,"data-testid":"project-input",className:"w-full px-2 py-1 text-xs rounded border bg-background text-foreground",style:{borderColor:"hsl(var(--border))"},placeholder:"Absolute path to project...",value:s,onChange:l=>o(l.target.value),onKeyDown:async l=>{l.key==="Enter"&&await r(s)&&i(!1),l.key==="Escape"&&i(!1)}})]})]})}const iY={dashboard:{label:"Dashboard",icon:uM},tree:{label:"Items",icon:vb},graph:{label:"Graph",icon:vM},pipeline:{label:"Pipeline",icon:UM},sessions:{label:"Sessions",icon:wf},gates:{label:"Gates",icon:qs},docs:{label:"Docs",icon:Ei},design:{label:"Design",icon:Bc},ideabox:{label:"Ideabox",icon:xi}};function sY({tabs:t=[],activeTab:e,onTabChange:r,onOpenPalette:n,badges:i={}}){return h.jsxs("div",{className:"flex items-center gap-0.5 h-full",role:"tablist","aria-label":"Main views",children:[t.map(s=>{const o=iY[s],a=s===e,l=o==null?void 0:o.icon,c=(o==null?void 0:o.label)||s,u=i[s];return h.jsxs("button",{role:"tab","aria-selected":a,className:["flex items-center gap-1.5 px-3 h-full text-[11px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",a?"border-accent text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>r==null?void 0:r(s),children:[l&&h.jsx(l,{style:{width:12,height:12}}),c,u>0&&h.jsx("span",{className:"text-[9px] min-w-[16px] h-4 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:u})]},s)}),h.jsx("div",{className:"flex-1"}),n&&h.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 h-full text-[11px] text-muted-foreground hover:text-foreground transition-colors",title:"Search (⌘K)",children:[h.jsx(Zn,{style:{width:12,height:12}}),h.jsx("kbd",{className:"text-[9px] font-mono opacity-50 bg-muted px-1 py-0.5 rounded",children:"⌘K"})]})]})}function oY(){const[t,e]=C.useState(ly);function r(){const n=!t;q_(n),e(n)}return h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:r,title:t?"Hide verbose events":"Show verbose events","aria-label":"Toggle verbose stream",style:t?{background:"hsl(210 60% 60% / 0.15)",color:"hsl(210 60% 60%)",borderRadius:"3px",padding:"1px 4px",fontSize:"10px"}:{fontSize:"10px"},children:"{ }"})}const Ve={COLLAPSED:"collapsed",EXPANDED:"expanded",MAXIMIZED:"maximized"},aY={[Ve.COLLAPSED]:Ve.EXPANDED,[Ve.EXPANDED]:Ve.MAXIMIZED,[Ve.MAXIMIZED]:Ve.COLLAPSED};function lY(t){return aY[t]??Ve.COLLAPSED}function cY(t){return Ve.COLLAPSED}function hY(t){return Ve.MAXIMIZED}const uY=new Set(Object.values(Ve));function dY(t){return uY.has(t)}function fY(t){switch(t){case Ve.COLLAPSED:return"h-7";case Ve.EXPANDED:return"h-[40vh]";case Ve.MAXIMIZED:return"flex-1";default:return"h-7"}}const UT="compose:agentBarState";function pY(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(UT);return dY(e)?e:Ve.COLLAPSED}catch{return Ve.COLLAPSED}}function mY(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(UT,t)}catch{}}const S0="▾",gY="▴",xY="⤢";function yY({barState:t="collapsed",onStateChange:e}){const[r,n]=C.useState("idle"),[i,s]=C.useState(null);C.useEffect(()=>{function u(d){const{status:p,tool:f,category:m,parallelTasks:x}=d.detail??{};if(s(x??null),x){const{total:g,completed:y,failed:b,active:k}=x;n(`∥ ${y}/${g} tasks${b?` (${b} failed)`:""}${k?` • ${k} active`:""}`)}else n(p==="idle"?"idle":f?`${f} — ${m??p}`:m||(p??"idle"))}return window.addEventListener("compose:agent-status",u),()=>window.removeEventListener("compose:agent-status",u)},[]);const o=C.useCallback(()=>{e==null||e(lY(t))},[t,e]),a=C.useCallback(()=>{e==null||e(cY())},[t,e]);C.useCallback(()=>{e==null||e(hY())},[t,e]);const l=t==="collapsed",c=t==="expanded";return h.jsxs("div",{className:"flex flex-col shrink-0 overflow-hidden",style:{borderTop:"1px solid hsl(var(--border))"},"data-agent-bar-state":t,children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 h-7 shrink-0 select-none",style:{borderBottom:l?"none":"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:o,title:l?"Expand agent bar":c?"Maximize agent bar":"Collapse agent bar","aria-label":"Toggle agent bar",children:l?gY:c?xY:S0}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold shrink-0",style:{color:"hsl(var(--accent))"},children:"Agent"}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-[11px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:r}),h.jsx(oY,{}),i&&i.total>0&&h.jsx("div",{className:"shrink-0 flex items-center gap-1",title:`${i.completed}/${i.total} tasks complete`,children:h.jsx("div",{style:{width:48,height:4,borderRadius:2,background:"hsl(var(--muted))",overflow:"hidden"},children:h.jsx("div",{style:{width:`${i.completed/i.total*100}%`,height:"100%",borderRadius:2,background:i.failed?"hsl(var(--destructive))":"hsl(var(--accent))",transition:"width 300ms ease"}})})}),!l&&h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:a,title:"Collapse agent bar","aria-label":"Collapse agent bar",children:S0})]}),!l&&h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(hy,{})})]})}const bY=280,kY=.6;function vY({isOpen:t=!1,onToggle:e,widthPx:r=380,onResizePx:n,children:i,activeBuild:s,gates:o=[],agentErrors:a=[],items:l=[]}){const c=C.useRef(!1),u=C.useCallback(p=>{p.preventDefault(),c.current=!0;const f=x=>{if(!c.current)return;const g=window.innerWidth-x.clientX,y=window.innerWidth*kY,b=Math.max(bY,Math.min(y,g));n==null||n(b)},m=()=>{c.current=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)},[n]),d=o.filter(p=>p.status==="pending"||p.status==="awaiting");return h.jsxs("div",{className:"flex shrink-0 h-full",style:{borderLeft:"1px solid hsl(var(--border))"},"data-context-panel-open":t,children:[t&&n&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0",onMouseDown:u}),h.jsx("button",{className:["w-4 h-full flex items-center justify-center","text-[10px] text-muted-foreground hover:text-foreground","transition-colors select-none"].join(" "),onClick:e,title:t?"Close context panel":"Open context panel","aria-expanded":t,"aria-label":"Toggle context panel",style:{background:"hsl(var(--muted) / 0.3)"},children:t?"›":"‹"}),t&&h.jsx("div",{className:"flex flex-col h-full overflow-hidden",style:{width:`${r}px`},children:Yt.Children.toArray(i).length>0?h.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:i}):h.jsx(SY,{activeBuild:s,pendingGates:d,agentErrors:a,items:l})})]})}const wY={implementation:"#3b82f6",vision:"#a855f7",planning:"#f59e0b",specification:"#06b6d4",verification:"#22c55e",design:"#f43f5e"};function T0(t){return wY[t]||"#6b7280"}function SY({activeBuild:t,pendingGates:e,agentErrors:r,items:n}){const i={};for(const a of n){const l=a.phase||"unknown";i[l]=(i[l]||0)+1}const s=n.length||1,o=r.slice(-5);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-7 flex items-center px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Project Overview"})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-4",children:[t?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Active Build"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-accent font-mono",children:t.featureCode||"—"}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"·"}),h.jsx("span",{className:"text-[10px] text-foreground",children:t.currentStep||t.step||"—"})]})]}):h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Status"}),h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No active build"})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Pending Gates (",e.length,")"]}),e.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:e.slice(0,5).map((a,l)=>h.jsx("p",{className:"text-[10px] text-amber-400 truncate",children:Go(a,n.find(c=>c.id===a.itemId))},l))})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Recent Errors (",o.length,")"]}),o.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:o.map((a,l)=>h.jsx("p",{className:"text-[10px] text-destructive truncate",children:a.message||a.error||"Error"},l))})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase Distribution"}),h.jsx("div",{className:"flex h-2 rounded overflow-hidden gap-px",children:Object.entries(i).map(([a,l])=>h.jsx("div",{className:"h-full",style:{width:`${l/s*100}%`,background:T0(a),opacity:.75,minWidth:"2px"},title:`${a}: ${l}`},a))}),h.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1",children:Object.entries(i).map(([a,l])=>h.jsxs("span",{className:"text-[9px] text-muted-foreground flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:T0(a)}}),a,": ",l]},a))})]})]})]})}const In=60,Rr=24,ol=80,Cu=28,ku=48,_0=8,fs=5,Sc=9;function TY(t,e){return t?t.length>e?t.slice(0,e)+"…":t:""}function _Y(t,e,r){const n=new Map(e.map(a=>[a.id,a])),i=[],s=[],o=new Map;for(const a of r){if(a.toId===t.id){const l=n.get(a.fromId);l&&i.push(l)}if(a.fromId===t.id){const l=n.get(a.toId);l&&s.push(l)}}for(const a of s){const l=[];for(const c of r)if(c.fromId===a.id&&c.toId!==t.id){const u=n.get(c.toId);u&&l.push(u)}l.length>0&&o.set(a.id,l)}return{parents:i,children:s,grandchildren:o}}function vu(t,e,r,n,i){const s=Math.min(t,fs),o=s*n+(s-1)*_0,a=(r-o)/2,l=[];for(let c=0;c<s;c++)l.push({x:a+c*(n+_0),y:e,w:n,h:i});return{positions:l,overflow:t>fs?t-fs+1:0}}function al({item:t,x:e,y:r,w:n,h:i,isSelected:s,isDashed:o,onSelect:a,onHover:l,onLeave:c}){const u=xr[t.type]||xr.task,d=s?.2:.08;return h.jsxs("g",{style:{cursor:"pointer"},onClick:()=>a(t.id),onMouseEnter:p=>l(t,p),onMouseLeave:c,children:[h.jsx("rect",{x:e,y:r,width:n,height:i,rx:4,fill:u,fillOpacity:d,stroke:u,strokeWidth:s?2:1.5,strokeDasharray:o?"4 2":void 0}),h.jsx("text",{x:e+n/2,y:r+i/2,textAnchor:"middle",dominantBaseline:"central",fontSize:s?Sc+1:Sc,fontWeight:s?600:400,fill:"hsl(var(--foreground))",children:TY(t.title,s?10:8)})]})}function EY({item:t,pos:e}){if(!t||!e)return null;const r=xr[t.type]||xr.task,n=qn[t.status]||qn.planned;return h.jsxs("div",{className:"absolute z-50 pointer-events-none px-2 py-1.5 rounded bg-popover border border-border shadow-md",style:{left:e.x,top:e.y,transform:"translate(-50%, -100%)"},children:[h.jsx("p",{className:"text-xs font-medium text-foreground whitespace-nowrap",children:t.title}),h.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[h.jsx("span",{className:"text-[10px]",style:{color:r},children:t.type}),h.jsxs("span",{className:"text-[10px] flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:n}}),t.status]}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:ef[t.confidence||0]})]})]})}function NY({item:t,items:e,connections:r,onSelect:n}){const[i,s]=C.useState(null),[o,a]=C.useState(null),{parents:l,children:c,grandchildren:u}=C.useMemo(()=>_Y(t,e,r),[t,e,r]),d=C.useCallback((I,A)=>{const D=A.currentTarget.closest(".connection-graph-wrap").getBoundingClientRect(),R=A.currentTarget.getBoundingClientRect();s(I),a({x:R.x+R.width/2-D.x,y:R.y-D.y-4})},[]),p=C.useCallback(()=>{s(null),a(null)},[]);if(!(l.length>0||c.length>0))return null;const m=288,x=[];let g=12,y=[],b=0;if(l.length>0){const I=vu(l.length,g,m,In,Rr);y=I.positions,b=I.overflow,g+=Rr+ku}const k=(m-ol)/2,T=g;g+=Cu+ku;let _=[],w=0;if(c.length>0){const I=vu(c.length,g,m,In,Rr);_=I.positions,w=I.overflow,g+=Rr}let E=new Map,B=new Map;const P=[...u.entries()];let N=[];if(P.length>0){g+=ku;for(const[D,R]of P)for(const j of R)N.push({...j,_parentChildId:D});const I=vu(N.length,g,m,In,Rr);let A=0;for(const[D,R]of P){const j=[];for(let S=0;S<R.length&&A<I.positions.length;S++,A++)j.push(I.positions[A]);E.set(D,j)}I.overflow>0&&B.set("all",I.overflow),g+=Rr}const M=g+12;for(let I=0;I<y.length;I++){const A=y[I];x.push({x1:A.x+A.w/2,y1:A.y+A.h,x2:k+ol/2,y2:T})}for(let I=0;I<_.length;I++){const A=_[I];x.push({x1:k+ol/2,y1:T+Cu,x2:A.x+A.w/2,y2:A.y})}for(const[I,A]of E){const D=c.findIndex(R=>R.id===I);if(D>=0&&D<_.length){const R=_[D];for(const j of A)x.push({x1:R.x+R.w/2,y1:R.y+R.h,x2:j.x+j.w/2,y2:j.y})}}const $=l.slice(0,fs-(b>0?1:0)),q=c.slice(0,fs-(w>0?1:0)),O=N.slice(0,fs-(B.size>0?1:0));return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Graph"}),h.jsxs("div",{className:"relative connection-graph-wrap",children:[h.jsxs("svg",{width:m,height:M,className:"w-full",viewBox:`0 0 ${m} ${M}`,children:[x.map((I,A)=>h.jsx("line",{x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,stroke:"hsl(var(--muted-foreground))",strokeOpacity:.3,strokeWidth:1},A)),$.map((I,A)=>h.jsx(al,{item:I,x:y[A].x,y:y[A].y,w:In,h:Rr,isSelected:!1,isDashed:!0,onSelect:n,onHover:d,onLeave:p},I.id)),b>0&&h.jsxs("text",{x:y[y.length-1].x+In/2,y:y[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",b," more"]}),h.jsx(al,{item:t,x:k,y:T,w:ol,h:Cu,isSelected:!0,isDashed:!1,onSelect:n,onHover:d,onLeave:p}),q.map((I,A)=>h.jsx(al,{item:I,x:_[A].x,y:_[A].y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id)),w>0&&h.jsxs("text",{x:_[_.length-1].x+In/2,y:_[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",w," more"]}),O.map((I,A)=>{const R=[...E.values()].flat()[A];return R?h.jsx(al,{item:I,x:R.x,y:R.y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id):null})]}),h.jsx(EY,{item:i,pos:o})]})]})}const jY=["Untested","Low","Moderate","High","Crystallized"];function LY({level:t=0,className:e}){const r=Math.max(0,Math.min(4,t||0)),n=jY[r]??"Untested",i=r===0?Xp[0]:Xp[r];return h.jsxs("span",{className:rt("inline-flex items-center gap-1",e),children:[h.jsx("span",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(s=>h.jsx("span",{className:rt("h-2.5 w-1.5 rounded-sm",s<=r?i:"bg-slate-600")},s))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:n})]})}function BY(t,e=Date.now()){if(!t)return null;const r=Date.parse(t);if(Number.isNaN(r))return null;const n=e-r,i=Math.floor(n/36e5);return i<1?"<1h ago":i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function E0(t){return t==null?"—":t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function AY(t){return t==null?"—":`$${Number(t).toFixed(t<1?3:2)}`}function MY(t){if(t==null)return"—";const e=Math.round(t/1e3);if(e<60)return`${e}s`;const r=Math.round(e/60);if(r<60)return`${r}m`;const n=Math.floor(r/60),i=r%60;return`${n}h${i?` ${i}m`:""}`}function IY(t,e=Date.now()){const r=(t||[]).filter(i=>i==null?void 0:i.started_at);if(!r.length)return null;let n=null;for(const i of r){const s=Date.parse(i.started_at);!Number.isNaN(s)&&(n==null||s>n)&&(n=s)}return n==null?null:BY(new Date(n).toISOString(),e)}function FY(t,e=Date.now()){const r=(t==null?void 0:t.branches)||[],n=r.filter(c=>c.state==="complete"),i=r.filter(c=>c.state==="running"),s=r.length,o=IY(r,e),a=n.length>=2;return{summary:i.length>0&&n.length<2?`${n.length} of ${s} branches ready`:`${s} branch${s===1?"":"es"}${o?` · last fork ${o}`:""}`,canCompare:a,completeBranches:n,runningCount:i.length,totalCount:s}}function PY(t,e=[]){const r=new Map(t.map(s=>[s.branch_id,s])),n=e[0]&&r.has(e[0])?r.get(e[0]):t[0]||null,i=e[1]&&r.has(e[1])?r.get(e[1]):t[1]||null;return[n,i]}function N0({branch:t,extraRows:e=[]}){var o;const r=t.files_touched||[],n=t.tests||{},i=t.cost||{},s=[{label:"Files touched",value:r.length},{label:"Tests",value:`${n.passed??0} / ${n.failed??0} / ${n.skipped??0}`},{label:"Tokens in / out",value:`${E0(i.tokens_in)} / ${E0(i.tokens_out)}`},{label:"USD",value:AY(i.usd)},{label:"Wall clock",value:MY(i.wall_clock_ms)},{label:"Final artifact",value:((o=t.final_artifact)==null?void 0:o.path)||"—"},...e];return h.jsx("div",{className:"space-y-1",children:s.map((a,l)=>h.jsxs("div",{className:"flex justify-between gap-2 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:a.label}),h.jsx("span",{className:"font-mono text-right truncate",title:typeof a.value=="string"?a.value:void 0,children:a.value})]},l))})}function DY({lineage:t,selectedPair:e=[],onSelectPair:r=()=>{},extraMetricsForBranch:n=()=>[],now:i=Date.now()}){var g,y;const[s,o]=C.useState(!1),{summary:a,canCompare:l,completeBranches:c}=FY(t,i),[u,d]=PY(c,e),p=()=>{l&&(o(b=>!b),!s&&u&&d&&r([u.branch_id,d.branch_id]))};if(!s)return h.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[h.jsx("span",{children:a}),h.jsx("button",{disabled:!l,onClick:p,className:"text-[10px] px-2 py-0.5 rounded border border-border "+(l?"hover:bg-muted/40 text-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),"data-testid":"branch-compare-toggle",children:"Compare"})]});const f=(g=u==null?void 0:u.final_artifact)==null?void 0:g.snapshot,m=(y=d==null?void 0:d.final_artifact)==null?void 0:y.snapshot,x=!!f&&!!m;return h.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:a}),h.jsx("button",{onClick:()=>o(!1),className:"text-[10px] text-muted-foreground hover:text-foreground",children:"Collapse"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:u==null?void 0:u.branch_id,children:u?`A: ${u.branch_id.slice(0,8)}…`:"A: (none)"}),u&&h.jsx(N0,{branch:u,extraRows:n(u)})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:d==null?void 0:d.branch_id,children:d?`B: ${d.branch_id.slice(0,8)}…`:"B: (none)"}),d&&h.jsx(N0,{branch:d,extraRows:n(d)})]})]}),h.jsx("div",{className:"col-span-2",children:x?h.jsx(Rp,{oldText:f,newText:m}):h.jsxs("div",{className:"text-[10px] italic text-muted-foreground",children:["No artifact produced on ",!f&&!m?"either branch":f?"branch B":"branch A","."]})})]})}const OY={path_drift:"Path drift",contract_drift:"Contract drift",review_debt_drift:"Review debt"};function RY(t){return OY[t]??t}function j0(t){return t==null||typeof t!="number"||isNaN(t)?"—":`${Math.round(t*100)}%`}function $Y(t){var r,n;return(((n=(r=t==null?void 0:t.lifecycle)==null?void 0:r.lifecycle_ext)==null?void 0:n.drift_axes)??[]).filter(i=>i.breached===!0)}function zY({item:t}){const[e,r]=C.useState(!1),n=$Y(t);if(n.length===0)return null;const i=n.length;return h.jsxs("div",{className:"drift-ribbon",style:{background:"hsl(var(--destructive) / 0.12)",borderLeft:"3px solid hsl(var(--destructive))",minHeight:"28px",padding:e?"6px 10px 8px":"0 10px",display:"flex",flexDirection:"column",justifyContent:"center",gap:0,borderRadius:"4px",marginBottom:"4px"},children:[h.jsxs("button",{onClick:()=>r(s=>!s),style:{display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",color:"hsl(var(--destructive))",fontSize:"12px",fontWeight:600,width:"100%",textAlign:"left"},"aria-expanded":e,"data-testid":"drift-ribbon-toggle",children:[h.jsx(Ac,{size:13}),h.jsxs("span",{children:[i," drift alert",i!==1?"s":""," — click to ",e?"collapse":"expand"]}),e?h.jsx(yb,{size:13,style:{marginLeft:"auto"}}):h.jsx(fa,{size:13,style:{marginLeft:"auto"}})]}),e&&h.jsxs("table",{style:{width:"100%",fontSize:"11px",borderCollapse:"collapse",marginTop:"4px"},"data-testid":"drift-ribbon-table",children:[h.jsx("thead",{children:h.jsxs("tr",{style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Axis"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Ratio"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Threshold"}),h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Explanation"})]})}),h.jsx("tbody",{children:n.map(s=>h.jsxs("tr",{"data-testid":`drift-axis-row-${s.axis_id}`,children:[h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--foreground))",fontWeight:500},children:RY(s.axis_id)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--destructive))"},children:j0(s.ratio)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--muted-foreground))"},children:j0(s.threshold)}),h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--muted-foreground))",maxWidth:"200px",wordBreak:"break-word"},children:s.explanation??""})]},s.axis_id))})]})]})}function WY({level:t,onChange:e}){const r=["hsl(var(--muted-foreground))","hsl(var(--destructive))","hsl(var(--accent))","hsl(var(--success))","hsl(var(--success))"],n=r[t]||r[0];return h.jsxs("button",{onClick:()=>e((t+1)%5),className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted hover:bg-muted/80 transition-colors",title:"Click to cycle confidence",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:ef[t]}),h.jsx("div",{className:"flex items-center gap-0.5",children:[0,1,2,3].map(i=>h.jsx("div",{className:"rounded-full transition-all",style:{width:6,height:6,background:i<t?n:"transparent",border:`1.5px solid ${i<t?n:"hsl(var(--border))"}`}},i))})]})}function qY({item:t,connections:e,items:r,onSelect:n,onDeleteConnection:i}){const s=new Map(r.map(l=>[l.id,l])),o=[];for(const l of e)if(l.type!=="contradicts"){if(l.fromId===t.id){const c=s.get(l.toId);c&&o.push({item:c,type:l.type,direction:"outgoing",connId:l.id})}if(l.toId===t.id){const c=s.get(l.fromId);c&&o.push({item:c,type:l.type,direction:"incoming",connId:l.id})}}if(o.length===0)return null;const a={};for(const l of o){const c=`${l.type}-${l.direction}`;a[c]||(a[c]={type:l.type,direction:l.direction,items:[]}),a[c].items.push({item:l.item,connId:l.connId})}return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Connections"}),Object.values(a).map(l=>h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:l.direction==="incoming"?`${l.type} from`:`${l.type} to`}),h.jsx("div",{className:"space-y-0.5",children:l.items.map(({item:c,connId:u})=>h.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors group/conn",children:[h.jsxs("button",{onClick:()=>n(c.id),className:"flex flex-1 items-center gap-2 min-w-0",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[c.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:c.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[c.type]},children:c.type})]}),i&&h.jsx("button",{onClick:()=>i(u),className:"opacity-0 group-hover/conn:opacity-100 p-0.5 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-all shrink-0",title:"Remove connection",children:h.jsx(cn,{className:"h-3 w-3"})})]},u))})]},`${l.type}-${l.direction}`))]})}function ll(t){if(!t)return"";const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function HY({featureCode:t,lineage:e}){const r=gr(i=>i.selectedBranches),n=gr(i=>i.setSelectedBranches);return h.jsx(DY,{lineage:e,selectedPair:(r==null?void 0:r[t])||[],onSelectPair:i=>n(t,i)})}function UY({featureCode:t}){const[e,r]=C.useState([]),[n,i]=C.useState(!0);return C.useEffect(()=>{const s=new AbortController;return i(!0),Rt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=10`,{signal:s.signal}).then(o=>o.json()).then(o=>{s.signal.aborted||r(o.sessions||[])}).catch(o=>{s.signal.aborted||r([])}).finally(()=>{s.signal.aborted||i(!1)}),()=>s.abort()},[t]),n||e.length===0?null:h.jsxs("div",{children:[h.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Sessions (",e.length,")"]}),h.jsx("div",{className:"space-y-2",children:e.map(s=>{var o;return h.jsxs("div",{className:"text-xs text-muted-foreground border-l-2 border-border pl-2",children:[h.jsxs("div",{className:"font-medium text-foreground",children:[((o=s.phaseAtBind)==null?void 0:o.replace(/_/g," "))||"—",s.phaseAtEnd&&s.phaseAtEnd!==s.phaseAtBind&&` → ${s.phaseAtEnd.replace(/_/g," ")}`]}),h.jsxs("div",{children:[s.toolCount," tools · ",Math.round((new Date(s.endedAt)-new Date(s.startedAt))/6e4),"m"]})]},s.id)})})]})}const GY=["informs","supports","blocks","contradicts"];function VY({item:t,items:e,onCreateConnection:r,onDismiss:n}){const[i,s]=C.useState(""),[o,a]=C.useState("informs"),l=e.filter(u=>u.id===t.id?!1:i?u.title.toLowerCase().includes(i.toLowerCase()):!0).slice(0,8),c=C.useCallback(async u=>{await r({fromId:t.id,toId:u,type:o}),n()},[t.id,o,r,n]);return h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:h.jsxs("div",{className:"p-2 space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("select",{className:"text-[10px] px-1.5 py-1 rounded bg-muted text-foreground border border-border cursor-pointer",value:o,onChange:u=>a(u.target.value),children:GY.map(u=>h.jsx("option",{value:u,children:u},u))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"to..."})]}),h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),h.jsx("input",{className:"w-full text-xs bg-muted text-foreground pl-7 pr-2 py-1.5 rounded border border-border outline-none",placeholder:"Search items...",value:i,onChange:u=>s(u.target.value),autoFocus:!0})]}),h.jsx("div",{className:"max-h-40 overflow-auto space-y-0.5",children:l.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No items found"}):l.map(u=>h.jsxs("button",{onClick:()=>c(u.id),className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[u.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:u.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[u.type]},children:u.type})]},u.id))})]})})}function YY({gate:t,onResolveGate:e}){const[r,n]=C.useState(null),[i,s]=C.useState(""),o=()=>{e(t.id,"revised",i||void 0),n(null),s("")},a=()=>{i.trim()&&(e(t.id,"killed",i),n(null),s(""))};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>e(t.id,"approved"),children:"Approve"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",r==="revise"&&"bg-amber-400/10"),onClick:()=>{n(r==="revise"?null:"revise"),s("")},children:"Revise"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",r==="kill"&&"bg-destructive/10"),onClick:()=>{n(r==="kill"?null:"kill"),s("")},children:"Kill"})]}),r&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("input",{className:"flex-1 text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none",placeholder:r==="revise"?"Feedback (optional)...":"Kill reason (required)...",value:i,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(r==="revise"?o():a()),l.key==="Escape"&&n(null)},autoFocus:!0}),h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px]",disabled:r==="kill"&&!i.trim(),onClick:r==="revise"?o:a,children:r==="revise"?"Submit":"Confirm Kill"})]})]})}function XY({item:t,items:e,connections:r,gates:n,onUpdate:i,onDelete:s,onCreateConnection:o,onDeleteConnection:a,onSelect:l,onClose:c,onPressureTest:u,onResolveGate:d}){var I,A,D,R,j,S;const[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(""),[T,_]=C.useState(!1),[w,E]=C.useState("");C.useEffect(()=>{E((t==null?void 0:t.group)||"")},[t==null?void 0:t.id,t==null?void 0:t.group]);const B=C.useCallback(()=>{const W=w.trim(),K=(t==null?void 0:t.group)||"";W!==K&&i(t.id,{group:W||null})},[w,t==null?void 0:t.id,t==null?void 0:t.group,i]),P=C.useCallback(()=>{x(t.title),f(!0)},[t==null?void 0:t.title]),N=C.useCallback(()=>{m.trim()&&m!==t.title&&i(t.id,{title:m.trim()}),f(!1)},[m,t==null?void 0:t.id,t==null?void 0:t.title,i]),M=C.useCallback(()=>{k(t.description||""),y(!0)},[t==null?void 0:t.description]),$=C.useCallback(()=>{b!==(t.description||"")&&i(t.id,{description:b}),y(!1)},[b,t==null?void 0:t.id,t==null?void 0:t.description,i]),q=C.useMemo(()=>{if(!t)return 0;let W=0;for(const K of r)K.type==="contradicts"&&(K.fromId===t.id||K.toId===t.id)&&W++;return W},[t==null?void 0:t.id,r]);if(!t)return null;const O=xr[t.type]||xr.task;return h.jsxs("div",{className:"w-full bg-card flex flex-col h-full",children:[h.jsxs("div",{className:"p-3 pb-2 flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",style:{color:O,borderColor:O},children:t.type}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",children:jl[t.phase]||t.phase})]}),p?h.jsx("input",{className:"w-full text-sm font-semibold bg-muted text-foreground px-1.5 py-0.5 rounded border border-ring outline-none",value:m,onChange:W=>x(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&N(),W.key==="Escape"&&f(!1)},autoFocus:!0}):h.jsx("h3",{className:"text-sm font-semibold text-foreground cursor-pointer hover:text-accent transition-colors",onDoubleClick:P,title:"Double-click to edit",children:t.title})]}),h.jsx($t,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:c,children:h.jsx(cn,{className:"h-3.5 w-3.5"})})]}),h.jsx(zl,{}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-3 space-y-4",children:[h.jsx(zY,{item:t}),((I=t.lifecycle)==null?void 0:I.featureCode)&&h.jsx(HY,{featureCode:t.lifecycle.featureCode,lineage:(A=t.lifecycle.lifecycle_ext)==null?void 0:A.branch_lineage}),h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer",value:t.status||"planned",onChange:W=>i(t.id,{status:W.target.value}),children:x_.map(W=>h.jsx("option",{value:W,children:W.replace("_"," ")},W))}),h.jsx(WY,{level:t.confidence||0,onChange:W=>i(t.id,{confidence:W})})]}),h.jsx(LY,{level:t.confidence||0}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase"}),h.jsxs("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer w-full",value:t.phase||"",onChange:W=>i(t.id,{phase:W.target.value||null}),children:[h.jsx("option",{value:"",children:"No phase"}),ny.map(W=>h.jsx("option",{value:W,children:jl[W]},W))]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Group"}),h.jsx("input",{type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1 rounded-md border border-border outline-none focus:border-ring",value:w,placeholder:"(none)",onChange:W=>E(W.target.value),onBlur:B,onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),W.currentTarget.blur()),W.key==="Escape"&&(E(t.group||""),W.currentTarget.blur())},"data-testid":"item-detail-group-input"})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Description"}),g?h.jsx("textarea",{className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-ring outline-none resize-none",rows:4,value:b,onChange:W=>k(W.target.value),onBlur:$,onKeyDown:W=>{W.key==="Escape"&&y(!1)},autoFocus:!0}):h.jsx("p",{className:rt("text-xs leading-relaxed cursor-pointer rounded px-2 py-1.5 hover:bg-muted/50 transition-colors",t.description?"text-muted-foreground":"text-muted-foreground/50 italic"),onClick:M,children:t.description||"Click to add description..."})]}),h.jsx(qY,{item:t,connections:r,items:e,onSelect:l,onDeleteConnection:a}),h.jsx(NY,{item:t,items:e,connections:r,onSelect:l}),((D=t.lifecycle)==null?void 0:D.featureCode)&&h.jsx(UY,{featureCode:t.lifecycle.featureCode}),(t.lifecycle||n&&n.some(W=>W.itemId===t.id))&&(()=>{var st;const W=t.lifecycle,K=n?n.filter(J=>J.itemId===t.id):[],F=K.filter(J=>J.status==="pending"),ht=K.filter(J=>J.status!=="pending");return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Lifecycle"}),h.jsxs("div",{className:"space-y-1.5",children:[W&&h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Phase:"}),h.jsx("span",{className:"text-[10px] text-foreground font-medium",children:ve[W.currentPhase]??W.currentPhase}),W.featureCode&&h.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto font-mono",children:W.featureCode})]}),((st=W==null?void 0:W.phaseHistory)==null?void 0:st.length)>1&&h.jsxs("div",{className:"px-2 py-1 rounded bg-muted/30",children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-0.5",children:"History"}),h.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5",children:W.phaseHistory.map((J,ct)=>h.jsxs("span",{className:rt("text-[10px]",J.phase===W.currentPhase?"text-foreground font-medium":"text-muted-foreground"),children:[ve[J.phase]??J.phase,J.outcome&&J.outcome!=="approved"&&h.jsxs("span",{className:"text-amber-400",children:[" (",J.outcome,")"]}),ct<W.phaseHistory.length-1&&" → "]},ct))})]}),F.map(J=>{var at,Z;const ct=J.artifactAssessment,zt=iy[J.fromPhase];return h.jsxs("div",{className:"rounded bg-amber-400/10 border border-amber-400/20 px-2 py-1.5",children:[h.jsxs("p",{className:"text-[10px] text-amber-400 font-medium mb-1",children:["Pending: ",vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`]}),ct&&ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt&&h.jsx("span",{className:"font-mono",children:zt}),zt&&": ",Math.round(ct.completeness*100),"% complete"," · ",ct.wordCount," words",((Z=(at=ct.sections)==null?void 0:at.missing)==null?void 0:Z.length)>0&&h.jsxs("span",{className:"text-amber-400",children:[" (missing: ",ct.sections.missing.join(", "),")"]}),!ct.meetsMinWordCount&&h.jsx("span",{className:"text-amber-400",children:" (below min word count)"})]}),ct&&!ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt??"Artifact"," not found"]}),d&&h.jsx(YY,{gate:J,onResolveGate:d})]},J.id)}),ht.map(J=>{const ct={approved:"text-success",revised:"text-amber-400",killed:"text-destructive"};return h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`}),h.jsx(nr,{variant:"outline",className:rt("text-[10px] px-1.5 py-0 h-4 ml-auto",ct[J.outcome]||""),children:J.outcome})]},J.id)})]})]})})(),((j=(R=t.evidence)==null?void 0:R.stratumViolations)==null?void 0:j.length)>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1.5",children:["Blocked — Ensure Violations",t.evidence.violatedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case text-muted-foreground",children:ll(t.evidence.violatedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:t.evidence.stratumViolations.map((W,K)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:W})]},K))})]}),((S=t.evidence)==null?void 0:S.stratumTrace)&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Stratum Trace",t.evidence.tracedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case",children:ll(t.evidence.tracedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:(t.evidence.stratumTrace.trace||[]).map(W=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--success))"}}),h.jsx("span",{className:"text-[10px] font-mono text-foreground truncate flex-1",children:W.step_id}),W.attempts>1&&h.jsxs("span",{className:"text-[10px] text-amber-400 shrink-0",children:[W.attempts,"x"]}),W.duration_ms!=null&&h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:W.duration_ms<1e3?`${W.duration_ms}ms`:`${(W.duration_ms/1e3).toFixed(1)}s`})]},W.step_id))})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Created ",ll(t.createdAt)]}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Updated ",ll(t.updatedAt)]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("div",{className:"relative",children:[h.jsxs($t,{variant:"outline",size:"sm",className:rt("h-7 text-xs gap-1",T&&"bg-accent/10 border-accent"),onClick:()=>_(!T),children:[h.jsx(pM,{className:"h-3 w-3"})," Connect"]}),T&&h.jsx(VY,{item:t,items:e,onCreateConnection:o,onDismiss:()=>_(!1)})]}),h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:P,children:[h.jsx(Sb,{className:"h-3 w-3"})," Rename"]}),t.type!=="question"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>u(t.id),title:"Challenge this item's assumptions",children:[h.jsx(Pl,{className:"h-3 w-3"})," Pressure Test",q>0&&h.jsx("span",{className:"ml-0.5 text-[10px] px-1 py-0 rounded-full bg-amber-500/20 text-amber-400",children:q})]}),t.status!=="killed"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:async()=>{if(t.lifecycle)try{const W=await Rt(`/api/vision/items/${t.id}/lifecycle/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Killed via UI"})});if(!W.ok){const K=await W.json();console.error("[vision] Lifecycle kill failed:",K.error)}}catch(W){console.error("[vision] Lifecycle kill failed:",W.message)}else i(t.id,{status:"killed"})},children:[h.jsx(Vm,{className:"h-3 w-3"})," Kill"]}),s&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>{window.confirm(`Delete "${t.title}" permanently? This cannot be undone.`)&&s(t.id)},title:"Permanently delete this item",children:[h.jsx(Vm,{className:"h-3 w-3"})," Delete"]})]})]})})]})}const GT=[{id:"overview",label:"Overview"},{id:"pipeline",label:"Pipeline"},{id:"sessions",label:"Sessions"},{id:"errors",label:"Errors"},{id:"files",label:"Files"}];GT.map(t=>t.id);const KY={overview:Ei,pipeline:vb,sessions:Cb,errors:Ac,files:Tf};function ZY({activeTab:t="overview",onTabChange:e,errorCount:r=0}){return h.jsx("div",{className:"flex items-center gap-0 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--muted) / 0.3)"},role:"tablist","aria-label":"Detail sections",children:GT.map(({id:n,label:i})=>{const s=KY[n],o=n===t,a=n==="errors"?r:0;return h.jsxs("button",{role:"tab","aria-selected":o,className:["flex items-center gap-1 px-2 h-full text-[10px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",o?"border-accent text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>e==null?void 0:e(n),children:[h.jsx(s,{style:{width:10,height:10}}),i,a>0&&h.jsx("span",{className:"text-[8px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-0.5 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:a})]},n)})})}const L0=[{id:"design",label:"Design"},{id:"blueprint",label:"Blueprint"},{id:"execute",label:"Execute"},{id:"review",label:"Review"},{id:"coverage",label:"Coverage"},{id:"ship",label:"Ship"}];function Ud(t,e,r,n){if(r&&r.featureCode===n&&r.currentStep===t)return"active";if(e&&Array.isArray(e)){const i=e.find(s=>s.phase===t||s.step===t);if(i)return i.status==="failed"?"failed":"complete"}return"pending"}function QY({item:t,activeBuild:e}){const[r,n]=C.useState(null),i=(t==null?void 0:t.phaseHistory)||[],s=(t==null?void 0:t.featureCode)||(t==null?void 0:t.text)||"";return h.jsxs("div",{className:"p-3",children:[h.jsx("div",{className:"flex items-center gap-0 mb-3",children:L0.map((o,a)=>{const l=Ud(o.id,i,e,s),c=Yp[l],u=r===o.id;return h.jsxs(Yt.Fragment,{children:[a>0&&h.jsx("div",{className:"flex-1 h-px",style:{background:l==="pending"?"hsl(var(--muted-foreground) / 0.2)":c,minWidth:"8px"}}),h.jsxs("button",{onClick:()=>n(u?null:o.id),className:"relative flex flex-col items-center group",title:o.label,children:[h.jsx("div",{className:["w-3 h-3 rounded-full border-2 transition-all",l==="active"?"animate-pulse":"",u?"ring-2 ring-accent/30":""].join(" "),style:{borderColor:c,background:l==="complete"||l==="failed"?c:"transparent"}}),h.jsx("span",{className:"text-[8px] text-muted-foreground mt-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:o.label})]})]},o.id)})}),h.jsx("div",{className:"flex justify-between px-0.5",children:L0.map(o=>{const a=Ud(o.id,i,e,s);return h.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider",style:{color:a==="pending"?"hsl(var(--muted-foreground) / 0.4)":Yp[a]},children:o.label},o.id)})}),r&&h.jsx("div",{className:"mt-3 p-2 rounded border border-border/50 bg-muted/20",children:h.jsx(JY,{stepId:r,phaseHistory:i,activeBuild:e,featureCode:s})})]})}function JY({stepId:t,phaseHistory:e,activeBuild:r,featureCode:n}){const i=Ud(t,e,r,n),s=e==null?void 0:e.find(a=>a.phase===t||a.step===t),o={complete:"text-success",active:"text-accent",failed:"text-destructive",pending:"text-muted-foreground"};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs font-semibold text-foreground capitalize",children:t}),h.jsx("span",{className:`text-[10px] font-medium ${o[i]}`,children:i})]}),(s==null?void 0:s.summary)&&h.jsx("p",{className:"text-[10px] text-muted-foreground",children:s.summary}),(s==null?void 0:s.durationMs)!=null&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Duration: ",s.durationMs<1e3?`${s.durationMs}ms`:`${(s.durationMs/1e3).toFixed(1)}s`]}),(s==null?void 0:s.agent)&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Agent: ",s.agent]}),i==="active"&&r&&h.jsx("p",{className:"text-[10px] text-accent",children:"Running..."}),i==="pending"&&h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Not started"})]})}function tX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function eX(t){return t?t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(0)}s`:`${(t/6e4).toFixed(1)}m`:"—"}function rX({featureCode:t,sessions:e=[],items:r=[]}){const[n,i]=C.useState(null),s=C.useMemo(()=>t?new Set(r.filter(a=>{var l;return((l=a.lifecycle)==null?void 0:l.featureCode)===t||a.featureCode===t||a.feature_code===t}).map(a=>a.id)):new Set,[t,r]),o=C.useMemo(()=>s.size===0?e.slice(0,20):e.filter(a=>!!(a.featureCode===t||a.itemsWorked&&a.itemsWorked.some(l=>s.has(l))||a.summary&&a.summary.includes(t))),[e,t,s]);return o.length===0?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"No sessions for this feature."}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Sessions (",o.length,")"]}),o.map(a=>{const l=n===a.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>i(l?null:a.id),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-muted/30 transition-colors",children:[h.jsx("span",{className:"text-[10px] font-mono text-accent shrink-0 w-12 truncate",children:a.source||"agent"}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 w-16 truncate",children:a.classification||a.workType||"—"}),h.jsxs("span",{className:"text-[9px] text-muted-foreground tabular-nums flex gap-1.5 shrink-0",children:[h.jsxs("span",{title:"reads",children:[a.reads||0,"r"]}),h.jsxs("span",{title:"writes",children:[a.writes||0,"w"]}),h.jsxs("span",{title:"errors",style:a.errors>0?{color:"hsl(var(--destructive))"}:{},children:[a.errors||0,"e"]})]}),h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:eX(a.durationMs)}),h.jsx("span",{className:"text-[9px] text-muted-foreground ml-auto shrink-0",children:tX(a.startedAt||a.createdAt)})]}),l&&a.summary&&h.jsx("div",{className:"px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/10 rounded mx-1 mb-1",children:a.summary})]},a.id)})]})}function nX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}const wu=10;function iX({featureCode:t,errors:e=[],items:r=[]}){const[n,i]=C.useState(null),[s,o]=C.useState(!1),a=C.useMemo(()=>t?new Set(r.filter(u=>{var d;return((d=u.lifecycle)==null?void 0:d.featureCode)===t||u.featureCode===t||u.feature_code===t}).map(u=>u.id)):new Set,[t,r]),l=C.useMemo(()=>!t&&a.size===0?[]:e.filter(u=>!!(t&&u.featureCode===t||u.itemId&&a.has(u.itemId)||t&&u.message&&u.message.includes(t))),[e,t,a]);if(l.length===0)return h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(HA,{style:{width:20,height:20,color:"hsl(var(--success, 160 60% 45%))"}}),h.jsx("span",{className:"text-[11px] italic",children:"No errors for this feature."})]});const c=s?l:l.slice(0,wu);return h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Errors (",l.length,")"]}),c.map((u,d)=>{const p=n===d;return h.jsxs("button",{onClick:()=>i(p?null:d),className:"flex flex-col w-full px-2 py-1.5 text-left rounded hover:bg-destructive/5 transition-colors",children:[h.jsxs("div",{className:"flex items-center gap-2 w-full",children:[h.jsx("span",{className:"text-[10px] text-destructive shrink-0",children:"✕"}),h.jsx("span",{className:"text-[10px] font-mono text-muted-foreground shrink-0 w-16 truncate",children:u.tool||u.toolName||"unknown"}),h.jsx("span",{className:`text-[10px] text-foreground flex-1 ${p?"":"line-clamp-2"} truncate`,children:u.message||u.error||"Unknown error"}),h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0 ml-auto",children:nX(u.timestamp||u.createdAt)})]}),p&&h.jsx("div",{className:"mt-1.5 px-5 py-1.5 text-[10px] text-foreground font-mono bg-muted/10 rounded whitespace-pre-wrap break-all",children:u.message||u.error||u.stack||"No additional details"})]},d)}),!s&&l.length>wu&&h.jsxs("button",{onClick:()=>o(!0),className:"w-full text-center text-[10px] text-accent hover:underline py-1",children:["Show ",l.length-wu," more"]})]})}function sX(t){return t?t<1024?`${t}B`:t<1048576?`${(t/1024).toFixed(1)}KB`:`${(t/1048576).toFixed(1)}MB`:"—"}function oX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function aX({featureCode:t,onOpenFile:e}){const[r,n]=C.useState([]),[i,s]=C.useState(!0);C.useEffect(()=>{const l=new AbortController;return s(!0),Rt("/api/files",{signal:l.signal}).then(c=>c.json()).then(c=>{l.signal.aborted||(n(Array.isArray(c)?c:c.files||[]),s(!1))}).catch(c=>{l.signal.aborted||(n([]),s(!1))}),()=>l.abort()},[t]);const o=`docs/features/${t}/`,a=C.useMemo(()=>r.filter(l=>(typeof l=="string"?l:l.path||l.name||"").startsWith(o)),[r,o]);return i?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Loading files..."}):a.length===0?h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(Tf,{style:{width:20,height:20,opacity:.5}}),h.jsx("span",{className:"text-[11px] italic",children:"No files in feature folder."})]}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Files (",a.length,")"]}),a.map((l,c)=>{const u=typeof l=="string"?l:l.path||l.name||"",d=u.split("/").pop(),p=typeof l=="object"?l.size:null,f=typeof l=="object"?l.modified||l.mtime:null;return h.jsxs("button",{onClick:()=>e==null?void 0:e(u),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-accent/10 transition-colors",children:[h.jsx(Ei,{className:"h-3 w-3 shrink-0 text-accent"}),h.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:d}),p!=null&&h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:sX(p)}),f&&h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0",children:oX(f)})]},c)})]})}function lX({itemId:t,onSelect:e,onClose:r,onOpenFile:n,onViewInGraph:i,onViewInTree:s}){var w;const{items:o,connections:a,gates:l,updateItem:c,deleteItem:u,createConnection:d,deleteConnection:p,resolveGate:f,activeBuild:m,sessions:x,agentErrors:g}=gr(Li(E=>({items:E.items,connections:E.connections,gates:E.gates,updateItem:E.updateItem,deleteItem:E.deleteItem,createConnection:E.createConnection,deleteConnection:E.deleteConnection,resolveGate:E.resolveGate,activeBuild:E.activeBuild,sessions:E.sessions,agentErrors:E.agentErrors}))),y=o.find(E=>E.id===t)||null,[b,k]=C.useState("overview"),T=((w=y==null?void 0:y.lifecycle)==null?void 0:w.featureCode)||(y==null?void 0:y.featureCode)||(y==null?void 0:y.feature_code)||"",_=C.useMemo(()=>T?g.filter(E=>E.featureCode===T||T&&E.message&&E.message.includes(T)):[],[g,T]);return y?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx(ZY,{activeTab:b,onTabChange:k,errorCount:_.length}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[b==="overview"&&h.jsxs(h.Fragment,{children:[h.jsx(XY,{item:y,items:o,connections:a,gates:l,onUpdate:(E,B)=>c(E,B),onDelete:E=>{u(E),r()},onCreateConnection:d,onDeleteConnection:p,onSelect:e,onClose:r,onPressureTest:()=>{},onResolveGate:f}),h.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 mt-1",style:{borderTop:"1px solid hsl(var(--border))"},children:[i&&h.jsxs("button",{onClick:()=>i(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↑"})," View in Graph"]}),s&&h.jsxs("button",{onClick:()=>s(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↓"})," View in Tree"]})]})]}),b==="pipeline"&&h.jsx(QY,{item:y,activeBuild:m}),b==="sessions"&&h.jsx(rX,{featureCode:T,sessions:x,items:o}),b==="errors"&&h.jsx(iX,{featureCode:T,errors:g,items:o}),b==="files"&&h.jsx(aX,{featureCode:T,onOpenFile:n})]})]}):h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Item not found."})}function cX(t){if(!t)return null;const{retries:e}=t;return e==null?null:Array.isArray(e)?e.length===0?null:{count:e.length,isArray:!0,items:e}:typeof e=="number"&&e>0?{count:e,isArray:!1,items:[]}:null}function hX(t){var e;return(e=t==null?void 0:t.violations)!=null&&e.length?t.violations:[]}function uX(t,e){if(!t)return null;for(const r of t.values())if(r.stepId===e)return r;return null}function dX(t,e,r){var c;if(!t||t.status!=="running")return null;const n=t.startedAt?Date.parse(t.startedAt):r,i=r-n,s=t.wallClockTimeout!=null?t.wallClockTimeout*60*1e3:null,o=(c=e==null?void 0:e.per_loop_type)==null?void 0:c[t.loopType],a=(o==null?void 0:o.maxTotal)!=null?o.usedIterations:null,l=(o==null?void 0:o.maxTotal)??null;return{count:t.count??0,maxIterations:t.maxIterations??null,loopType:t.loopType,elapsedMs:i,timeoutMs:s,usedIterations:a,maxTotal:l}}function fX(t){if(!(t!=null&&t.per_loop_type))return"";const e={review:"r",coverage:"c"},r=[];for(const[n,i]of Object.entries(e)){const s=t.per_loop_type[n];!s||s.maxTotal==null||r.push(`${i} ${s.usedIterations}/${s.maxTotal}`)}return r.join(" · ")}function B0(t){return!t||t<=0?"$0.00":`$${t.toFixed(4)}`}const A0=[{id:"T0",name:"schema",label:"T0"},{id:"T1",name:"lint",label:"T1"},{id:"T2",name:"tests",label:"T2"},{id:"T3",name:"review",label:"T3"},{id:"T4",name:"codex",label:"T4"}];function pX({tierMap:t,tierSummary:e}){const[r,n]=C.useState(null),i=s=>n(o=>o===s?null:s);return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Tier Pipeline"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[A0.map((s,o)=>{var d;const a=t[s.id],l=(d=e==null?void 0:e.tiersSkipped)==null?void 0:d.includes(s.id);let c,u;return l?(c="bg-muted-foreground/40",u=`${s.id} (${s.name}): skipped`):a===!0?(c="bg-success",u=`${s.id} (${s.name}): passed`):a===!1?(c="bg-destructive",u=`${s.id} (${s.name}): failed`):(c="bg-muted-foreground/20",u=`${s.id} (${s.name}): not run`),h.jsxs(Yt.Fragment,{children:[o>0&&h.jsx("div",{className:"h-px w-3 bg-muted-foreground/20 shrink-0"}),h.jsxs("button",{className:"flex flex-col items-center gap-0.5 group",onClick:()=>i(s.id),title:u,children:[h.jsx("div",{className:`w-2.5 h-2.5 rounded-full transition-all group-hover:scale-125 ${c} ${r===s.id?"ring-1 ring-foreground/40":""}`}),h.jsx("span",{className:"text-[8px] text-muted-foreground leading-none",children:s.label})]})]},s.id)}),(e==null?void 0:e.costSaved)>0&&h.jsxs("span",{className:"ml-2 text-[9px] text-success/80",children:["saved ~$",e.costSaved.toFixed(2)]})]}),r&&h.jsx("div",{className:"mt-1.5 px-2 py-1 rounded bg-muted/20 text-[9px] text-muted-foreground",children:(()=>{var l;const s=t[r],o=(l=e==null?void 0:e.tiersSkipped)==null?void 0:l.includes(r),a=A0.find(c=>c.id===r);return o?`${r} (${a==null?void 0:a.name}): skipped — short-circuited by earlier failure`:s===!0?`${r} (${a==null?void 0:a.name}): passed`:s===!1?`${r} (${a==null?void 0:a.name}): failed`:`${r} (${a==null?void 0:a.name}): not run this build`})()})]})}function Su(t){return t>=80?"text-success":t>=60?"text-amber-400":"text-destructive"}function mX(t){return t==="improving"?"↑":t==="declining"?"↓":"→"}const M0={test_coverage:"Tests",review_findings:"Review",contract_compliance:"Contracts",runtime_errors:"Runtime",doc_freshness:"Docs",plan_completion:"Plan"};function I0(t){if(t==null)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function gX({loopState:t,budget:e}){const[r,n]=C.useState(()=>Date.now());C.useEffect(()=>{if(!t||t.status!=="running")return;const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[t]);const i=dX(t,e,r);return i?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Live Counters"}),h.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("span",{className:"text-foreground font-mono font-medium",children:["attempt ",i.count,"/",i.maxIterations??"?"]}),h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:[I0(i.elapsedMs),i.timeoutMs!=null&&h.jsxs("span",{className:"text-muted-foreground",children:[" / ",I0(i.timeoutMs)]})]}),i.usedIterations!=null&&i.maxTotal!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:["cumulative ",i.usedIterations,"/",i.maxTotal]})]})]}),h.jsxs("div",{className:"text-muted-foreground/70 text-[9px]",children:["loop: ",i.loopType]})]})]}):null}function xX({stepId:t,tierEvents:e=[],healthEvents:r=[],capabilityEvents:n=[]}){const{activeBuild:i,iterationStates:s}=gr(Li(P=>({activeBuild:P.activeBuild,iterationStates:P.iterationStates}))),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=(i==null?void 0:i.featureCode)??null,d=C.useRef(null);C.useEffect(()=>{if(!u){c(null);return}u!==d.current&&(d.current=u,Rt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(u)}`).then(P=>P.json()).then(P=>c(P)).catch(()=>{}))},[u]);const{step:p,allSteps:f}=C.useMemo(()=>i!=null&&i.steps?{step:i.steps.find(N=>N.id===t||N.step_id===t)||null,allSteps:i.steps}:{step:null,allSteps:[]},[i,t]),m=C.useMemo(()=>{if(!r||r.length===0)return null;for(let P=r.length-1;P>=0;P--){const N=r[P];if(N.subtype==="health_score"&&typeof N.score=="number")return N}return null},[r]),{tierMap:x,tierSummary:g}=C.useMemo(()=>{if(!e||e.length===0)return{tierMap:{},tierSummary:null};const P={};let N=null;for(const M of e)M.subtype==="gate_tier_result"?P[M.tierId]=M.passed:M.subtype==="gate_tier_summary"&&(N=M);return{tierMap:P,tierSummary:N}},[e]),y=Object.keys(x).length>0||g!==null,b=C.useMemo(()=>{const P=f.filter(N=>N.cost_usd!=null);return P.length===0?[]:[...P].sort((N,M)=>o?(N.cost_usd??0)-(M.cost_usd??0):(M.cost_usd??0)-(N.cost_usd??0))},[f,o]),k=b.length>0?b[0].id:null,T=C.useMemo(()=>cX(p),[p]),_=C.useMemo(()=>hX(p),[p]),w=C.useMemo(()=>uX(s,t),[s,t]),E=C.useMemo(()=>{if(!n||n.length===0)return null;const P=n.filter($=>$.stepId===t);if(P.length===0)return null;const N=P.filter($=>$.severity==="violation").length,M=P.filter($=>$.severity==="warning").length;return{total:P.length,hardViolations:N,warnings:M}},[n,t]);if(!p)return h.jsxs("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:["Step “",t,"” not found in active build."]});const B={done:"text-success",running:"text-accent",failed:"text-destructive",pending:"text-muted-foreground",skipped:"text-muted-foreground"};return h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Step"}),h.jsx("p",{className:"text-sm font-semibold text-foreground font-mono",children:p.id||p.step_id})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Status:"}),h.jsx("span",{className:`text-xs font-medium ${B[p.status]||"text-foreground"}`,children:p.status||"unknown"})]}),T&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Retries"}),h.jsxs("p",{className:"text-xs text-amber-400",children:["Retried ",T.count," ",T.count===1?"time":"times"]}),T.isArray&&T.items.length>0&&h.jsx("div",{className:"mt-1 space-y-0.5",children:T.items.map((P,N)=>h.jsxs("div",{className:"text-[10px] text-muted-foreground pl-2",children:["#",N+1,P.reason?`: ${P.reason}`:""]},N))})]}),p.durationMs!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Duration:"}),h.jsx("span",{className:"text-xs text-foreground",children:p.durationMs<1e3?`${p.durationMs}ms`:p.durationMs<6e4?`${(p.durationMs/1e3).toFixed(1)}s`:`${(p.durationMs/6e4).toFixed(1)}m`})]}),p.summary&&h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Summary:"}),h.jsx("p",{className:"text-xs text-foreground mt-0.5",children:p.summary})]}),p.artifact&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Artifact:"}),h.jsx("span",{className:"text-xs text-foreground font-mono truncate",children:p.artifact})]}),p.agent&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Agent:"}),h.jsx("span",{className:"text-xs text-foreground font-mono",children:p.agent})]}),p.filesChanged&&p.filesChanged.length>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Files Changed (",p.filesChanged.length,")"]}),h.jsx("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:p.filesChanged.map((P,N)=>h.jsx("p",{className:"text-[10px] text-foreground font-mono truncate",children:P},N))})]}),(p.input_tokens>0||p.output_tokens>0||p.cost_usd>0)&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Tokens & Cost"}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Input"}),h.jsx("span",{className:"text-muted-foreground",children:"Output"}),h.jsx("span",{className:"text-muted-foreground",children:"Cost"}),h.jsx("span",{className:"text-foreground font-mono",children:(p.input_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:(p.output_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:B0(p.cost_usd)})]})]}),y&&h.jsx("div",{children:h.jsx(pX,{tierMap:x,tierSummary:g})}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1",children:"Postcondition Violations"}),h.jsx("div",{className:"space-y-0.5",children:_.map((P,N)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:typeof P=="string"?P:P.message||JSON.stringify(P)})]},N))})]}),E&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Capability Findings"}),h.jsxs("p",{className:"text-xs text-amber-400",children:[E.total," ",E.total===1?"finding":"findings"," ","(",E.hardViolations," ",E.hardViolations===1?"violation":"violations",","," ",E.warnings," ",E.warnings===1?"warning":"warnings",")"]})]}),(w==null?void 0:w.status)==="running"&&h.jsx(gX,{loopState:w,budget:l}),m!=null&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Health Score"}),h.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[h.jsx("span",{className:`text-2xl font-bold font-mono tabular-nums ${Su(m.score)}`,children:m.score}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"/100"}),m.trend&&h.jsxs("span",{className:`text-sm font-mono ${Su(m.score)}`,children:[mX(m.trend.direction),m.trend.delta!=null&&h.jsxs("span",{className:"text-[10px] ml-0.5",children:[m.trend.delta>0?"+":"",Math.round(m.trend.delta)]})]})]}),m.breakdown&&Object.keys(m.breakdown).length>0&&h.jsxs("div",{className:"space-y-1",children:[Object.entries(m.breakdown).map(([P,N])=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[9px] text-muted-foreground w-16 shrink-0",children:M0[P]??P}),h.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted-foreground/20 overflow-hidden",children:h.jsx("div",{className:`h-full rounded-full transition-all ${N>=80?"bg-success":N>=60?"bg-amber-400":"bg-destructive"}`,style:{width:`${N}%`}})}),h.jsx("span",{className:`text-[9px] font-mono w-6 text-right ${Su(N)}`,children:N})]},P)),m.missing&&m.missing.length>0&&h.jsxs("p",{className:"text-[9px] text-muted-foreground/60 mt-0.5",children:["No data: ",m.missing.map(P=>M0[P]??P).join(", ")]})]})]}),b.length>1&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Build Cost Breakdown"}),h.jsx("button",{className:"text-[9px] text-muted-foreground hover:text-foreground transition-colors",onClick:()=>a(P=>!P),children:o?"cost asc":"cost desc"})]}),h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-[10px] border-collapse",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-muted-foreground",children:[h.jsx("th",{className:"text-left pr-2 pb-0.5 font-medium",children:"Step"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"In"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"Out"}),h.jsx("th",{className:"text-right pb-0.5 font-medium",children:"Cost"}),h.jsx("th",{className:"text-right pb-0.5 pl-2 font-medium",children:"Dur"})]})}),h.jsx("tbody",{children:b.map(P=>{const N=P.id===k,M=P.id===t,$=P.durationMs!=null?P.durationMs<1e3?`${P.durationMs}ms`:P.durationMs<6e4?`${(P.durationMs/1e3).toFixed(1)}s`:`${(P.durationMs/6e4).toFixed(1)}m`:"—";return h.jsxs("tr",{className:`${N?"text-amber-400":"text-foreground"} ${M?"font-semibold":""}`,children:[h.jsx("td",{className:"pr-2 py-0.5 font-mono truncate max-w-[80px]",children:P.id}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.input_tokens??0)/1e3).toFixed(1),"k"]}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.output_tokens??0)/1e3).toFixed(1),"k"]}),h.jsx("td",{className:"text-right py-0.5 font-mono",children:B0(P.cost_usd)}),h.jsx("td",{className:"text-right pl-2 py-0.5 text-muted-foreground",children:$})]},P.id)})})]})})]})]})}function VT(t){const e=[],r=/```decision\n([\s\S]*?)```/g;let n=0,i;for(;(i=r.exec(t))!==null;){i.index>n&&e.push({type:"text",content:t.slice(n,i.index)});const s=i[1].trim();try{e.push({type:"decision",content:JSON.parse(s)})}catch{e.push({type:"text",content:s})}n=i.index+i[0].length}return n<t.length&&e.push({type:"text",content:t.slice(n)}),e.length===0&&e.push({type:"text",content:t}),{parts:e}}function F0(t,e){var l;const r=(e||[]).filter(c=>!c.superseded);if(r.length===0)return"";let n=`# Design Document
717
+ For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},lV="DialogDescriptionWarning",cV=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AT(lV).contentName}}.`;return C.useEffect(()=>{var s;const i=(s=t.current)==null?void 0:s.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},hV=bT,uV=vT,MT=wT,IT=ST,FT=_T,PT=NT,dV=LT;const qp=hV,fV=uV,DT=C.forwardRef(({className:t,...e},r)=>h.jsx(MT,{ref:r,className:rt("fixed inset-0 z-50 bg-black/60 backdrop-blur-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));DT.displayName=MT.displayName;const sh=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(fV,{children:[h.jsx(DT,{}),h.jsxs(IT,{ref:n,className:rt("fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]","w-full max-w-lg rounded-lg border border-slate-700 bg-card shadow-xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]","data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r,children:[e,h.jsxs(dV,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(cn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));sh.displayName=IT.displayName;const oh=({className:t,...e})=>h.jsx("div",{className:rt("flex flex-col space-y-1.5 p-6 pb-4",t),...e});oh.displayName="DialogHeader";const Hp=({className:t,...e})=>h.jsx("div",{className:rt("flex items-center justify-end gap-2 p-6 pt-4",t),...e});Hp.displayName="DialogFooter";const ah=C.forwardRef(({className:t,...e},r)=>h.jsx(FT,{ref:r,className:rt("text-sm font-semibold text-foreground leading-none tracking-tight",t),...e}));ah.displayName=FT.displayName;const pV=C.forwardRef(({className:t,...e},r)=>h.jsx(PT,{ref:r,className:rt("text-sm text-muted-foreground",t),...e}));pV.displayName=PT.displayName;const k0=[{id:"task",label:"Task",defaults:{type:"task",phase:"planning",priority:1,governance:"flag"}},{id:"decision",label:"Decision",defaults:{type:"decision",phase:"specification",priority:2,governance:"gate"}},{id:"question",label:"Question",defaults:{type:"question",phase:"specification",priority:1,governance:"flag"}},{id:"idea",label:"Idea",defaults:{type:"idea",phase:"vision",priority:0,governance:"skip"}},{id:"spec",label:"Spec",defaults:{type:"spec",phase:"specification",priority:2,governance:"gate"}}],mV=["gate","flag","skip"];function v0(t){return{type:"task",title:"",description:"",phase:(t==null?void 0:t.phase)??"planning",priority:1,assignedTo:"unassigned",governance:"flag",featureCode:""}}function OT({open:t,onClose:e,parentItem:r}){const n=gr(b=>b.createItem),[i,s]=C.useState(()=>v0(r)),[o,a]=C.useState("task"),[l,c]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(""),m=C.useRef(null);C.useEffect(()=>{if(t){const b=v0(r);s(b),a("task"),c(!1),f(""),setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},50)}},[t,r]);const x=b=>{const k=k0.find(T=>T.id===b);k&&(a(b),s(T=>({...T,type:k.defaults.type,phase:(r==null?void 0:r.phase)??k.defaults.phase,priority:k.defaults.priority,governance:k.defaults.governance})))},g=async()=>{if(!i.title.trim()){f("Title is required");return}d(!0),f("");try{const b={type:i.type,title:i.title.trim(),description:i.description.trim()||void 0,phase:i.phase||void 0,status:"planned",confidence:0,priority:i.priority,assignedTo:i.assignedTo!=="unassigned"?i.assignedTo:void 0,governance:i.governance!=="flag"?i.governance:void 0,featureCode:i.featureCode.trim()||void 0};await n(b),e()}catch{f("Failed to create item")}finally{d(!1)}},y=b=>{b.key==="Enter"&&!b.shiftKey&&b.target.tagName!=="TEXTAREA"&&(b.preventDefault(),g())};return h.jsx(qp,{open:t,onOpenChange:b=>!b&&e(),children:h.jsxs(sh,{className:"max-w-md",onKeyDown:y,children:[h.jsx(oh,{children:h.jsx(ah,{children:"New Item"})}),h.jsxs("div",{className:"px-6 pb-2 space-y-4",children:[h.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:k0.map(b=>h.jsx("button",{type:"button",onClick:()=>x(b.id),className:rt("rounded-md px-2 py-1.5 text-[11px] font-medium border transition-colors",o===b.id?"bg-accent/10 border-accent/60 text-accent":"border-border/40 text-muted-foreground hover:border-border hover:text-foreground"),children:b.label},b.id))}),h.jsx("input",{ref:m,type:"text",placeholder:"Item title…",value:i.title,onChange:b=>s(k=>({...k,title:b.target.value})),className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring"}),h.jsx("textarea",{placeholder:"Description (optional)…",value:i.description,onChange:b=>s(k=>({...k,description:b.target.value})),rows:2,className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring resize-none"}),h.jsxs("button",{type:"button",onClick:()=>c(b=>!b),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[l?h.jsx(yb,{className:"h-3 w-3"}):h.jsx(fa,{className:"h-3 w-3"}),"Advanced"]}),l&&h.jsxs("div",{className:"space-y-3 border border-border/40 rounded-md p-3 bg-muted/20",children:[h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Feature Code"}),h.jsx("input",{type:"text",placeholder:"e.g. COMP-UI-5",value:i.featureCode,onChange:b=>s(k=>({...k,featureCode:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none"})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Phase"}),h.jsx("select",{value:i.phase,onChange:b=>s(k=>({...k,phase:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:ny.map(b=>h.jsx("option",{value:b,children:jl[b]??b},b))})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Priority"}),h.jsxs("select",{value:i.priority,onChange:b=>s(k=>({...k,priority:Number(b.target.value)})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:[h.jsx("option",{value:0,children:"Low (0)"}),h.jsx("option",{value:1,children:"Normal (1)"}),h.jsx("option",{value:2,children:"High (2)"}),h.jsx("option",{value:3,children:"Critical (3)"})]})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Assign to"}),h.jsx("select",{value:i.assignedTo,onChange:b=>s(k=>({...k,assignedTo:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:sy.map(b=>h.jsx("option",{value:b,children:b},b))})]}),h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Governance"}),h.jsx("div",{className:"flex gap-1.5",children:mV.map(b=>h.jsx("button",{type:"button",onClick:()=>s(k=>({...k,governance:b})),className:rt("flex-1 text-[11px] px-2 py-1 rounded border transition-colors",i.governance===b?b==="gate"?"bg-amber-500/20 text-amber-300 border-amber-500/40":b==="flag"?"bg-blue-500/20 text-blue-300 border-blue-500/40":"bg-slate-700 text-slate-400 border-slate-600":"border-border/40 text-muted-foreground hover:border-border"),children:b},b))})]})]}),p&&h.jsx("p",{className:"text-xs text-destructive",children:p})]}),h.jsxs(Hp,{children:[h.jsx($t,{variant:"ghost",size:"sm",onClick:e,disabled:u,children:"Cancel"}),h.jsx($t,{size:"sm",onClick:g,disabled:u||!i.title.trim(),children:u?"Creating…":"Create"})]})]})})}const gV=["explore_design","prd","architecture","blueprint","verification","plan","execute","report","docs","ship"],xV=[{id:"gate",Icon:qs,label:"Gate",active:"bg-amber-500/20 text-amber-300 border-amber-500/40"},{id:"flag",Icon:kb,label:"Flag",active:"bg-blue-500/20 text-blue-300 border-blue-500/40"},{id:"skip",Icon:_b,label:"Skip",active:"bg-slate-700 text-slate-400 border-slate-600"}];function yV(t,e){var r,n;return((n=(r=t==null?void 0:t.governance)==null?void 0:r.phases)==null?void 0:n[e])??"flag"}function RT({open:t,onClose:e,settings:r,onSettingsChange:n}){const[i,s]=C.useState(!1),o=C.useRef(null),a=C.useCallback((l,c)=>{n==null||n({governance:{phases:{[l]:c}}}),clearTimeout(o.current),s(!0),o.current=setTimeout(()=>s(!1),1500)},[n]);return h.jsx(qp,{open:t,onOpenChange:l=>!l&&e(),children:h.jsxs(sh,{className:"max-w-sm",children:[h.jsx(oh,{children:h.jsxs("div",{className:"flex items-center justify-between pr-6",children:[h.jsx(ah,{children:"Governance Settings"}),i&&h.jsx("span",{className:"text-[11px] text-emerald-400 font-medium",children:"Saved ✓"})]})}),h.jsx("div",{className:"px-6 pb-6 space-y-1 max-h-96 overflow-y-auto",children:gV.map(l=>{const c=l==="explore_design",u=yV(r,l),d=ve[l]??l;return h.jsxs("div",{className:rt("flex items-center gap-3 rounded-md px-2 py-1.5",c&&"opacity-40"),children:[h.jsx("span",{className:rt("text-xs flex-1 min-w-0 truncate",c?"text-muted-foreground":"text-foreground"),children:d}),c?h.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"no policy"}):h.jsx("div",{className:"flex gap-1 shrink-0",children:xV.map(p=>{const f=u===p.id,{Icon:m}=p;return h.jsxs("button",{onClick:()=>a(l,p.id),title:p.label,className:rt("flex items-center gap-1 px-2 py-0.5 text-[10px] rounded border transition-colors",f?p.active:"border-border/30 text-muted-foreground hover:border-border hover:text-foreground"),children:[h.jsx(m,{className:"h-2.5 w-2.5"}),p.label]},p.id)})})]},l)})}),h.jsx("div",{className:"px-6 pb-4 text-[10px] text-muted-foreground border-t border-border/30 pt-3",children:"Agent config via Compose CLI"})]})})}function $T({onOpenGate:t}){const{gates:e,items:r}=gr(Li(g=>({gates:g.gates,items:g.items}))),[n,i]=C.useState(new Set),[s,o]=C.useState(0),a=e.filter(g=>g.status==="pending"&&!n.has(g.id));if(a.length===0)return null;const l=Math.min(s,a.length-1),c=a[l],u=r.find(g=>g.id===c.itemId)||r.find(g=>{var y;return((y=g.lifecycle)==null?void 0:y.featureCode)&&c.featureCode&&g.lifecycle.featureCode===c.featureCode}),d=Go(c,u),p=C_[c.fromPhase]??k_,f=()=>{i(g=>new Set([...g,c.id])),l>=a.length-1&&l>0&&o(l-1)},m=()=>o(Math.max(0,l-1)),x=()=>o(Math.min(a.length-1,l+1));return h.jsxs("div",{className:rt("shrink-0 h-10 border-t flex items-center gap-2 px-3",p.bg,p.border),children:[h.jsx(qs,{className:rt("h-3.5 w-3.5 shrink-0",p.text)}),h.jsx("span",{className:rt("text-[11px] font-medium truncate flex-1 min-w-0",p.text),children:d}),a.length>1&&h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx("button",{onClick:m,disabled:l===0,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(xb,{className:"h-3 w-3"})}),h.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[l+1,"/",a.length]}),h.jsx("button",{onClick:x,disabled:l===a.length-1,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(js,{className:"h-3 w-3"})})]}),h.jsx("button",{onClick:()=>t==null?void 0:t(c.id),className:rt("shrink-0 text-[10px] px-2 py-0.5 rounded border transition-colors hover:opacity-80",p.border,p.text),children:"Review"}),h.jsx("button",{onClick:f,className:"shrink-0 p-0.5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Dismiss (page session only)",children:h.jsx(cn,{className:"h-3 w-3"})})]})}const bV="●",CV="text-zinc-400";function kV(t,e){if(!t)return"";const n=(e??Date.now())-new Date(t).getTime(),i=Math.floor(n/6e4);if(i<1)return"now";if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function vV(t){var e;return((e=oy[t])==null?void 0:e.icon)??bV}function wV(t){var e;return((e=oy[t])==null?void 0:e.color)??CV}const SV={IMPLEMENTER:"bg-blue-500/15 text-blue-300 border border-blue-500/25",REVIEWER:"bg-emerald-500/15 text-emerald-300 border border-emerald-500/25",PRODUCER:"bg-purple-500/15 text-purple-300 border border-purple-500/25"};function TV(t){return SV[t]??"bg-zinc-500/15 text-zinc-300 border border-zinc-500/25"}function _V(t,e){return t.filter(r=>r.feature_code===e).slice().sort((r,n)=>r.timestamp.localeCompare(n.timestamp))}function EV(t){if(!t)return"";try{return new Date(t).toISOString().slice(11,16)}catch{return""}}function NV({event:t,now:e}){const r=vV(t.kind),n=wV(t.kind),i=kV(t.timestamp,e);return h.jsxs("div",{"data-decision-card":!0,className:"inline-flex flex-col gap-0.5 w-40 shrink-0 rounded border border-border/40 bg-muted/20 px-2 py-1.5 text-left",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1",children:[h.jsx("span",{className:rt("text-[11px] shrink-0",n),children:r}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",children:i||EV(t.timestamp)})]}),h.jsx("p",{className:"text-[11px] text-foreground/80 truncate leading-tight",children:t.title}),t.roles&&t.roles.length>0&&h.jsx("div",{className:"flex flex-wrap gap-0.5 mt-0.5",children:t.roles.map((s,o)=>h.jsx("span",{"data-role-chip":!0,className:rt("text-[9px] px-1 py-px rounded-full leading-tight",TV(s.name)),children:s.name},o))})]})}function zT({events:t=[],currentFeatureCode:e,now:r}){const n=_V(t,e);return n.length===0?null:h.jsx("div",{className:"w-full overflow-x-auto whitespace-nowrap border-b border-border/30 bg-background/95 backdrop-blur-sm",style:{height:72,minHeight:72,maxHeight:72,position:"sticky",top:32,zIndex:20},"data-decision-timeline-strip":!0,children:h.jsx("div",{className:"flex items-center gap-2 px-3 h-full",children:n.map(i=>h.jsx(NV,{event:i,now:r},i.id))})})}function jV(t){if(!t)return[];const e=[];t.active_phase!=null&&e.push({label:"Phase",value:t.active_phase});const r=t.pending_gates??[];e.push({label:"Pending gates",value:r.length===0?"none":r.join(", ")}),e.push({label:"Open loops",value:t.open_loops_count??0}),e.push({label:"Gate load (24h)",value:t.gate_load_24h??0});const n=t.drift_alerts??[];return n.length>0?e.push({label:"Drift alerts",value:n.map(i=>i.axis_id||i.name||"unknown").join(", ")}):e.push({label:"Drift alerts",value:"none"}),t.computed_at&&e.push({label:"Updated",value:t.computed_at}),e}const LV="Select a feature to see status.";function WT({featureCode:t,snapshot:e}){const[r,n]=C.useState(!1),i=C.useCallback(()=>{n(a=>!a)},[]),s=(e==null?void 0:e.sentence)??LV,o=jV(e);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-status-band":!0,onClick:i,style:{position:"sticky",top:"0px",zIndex:30,height:"32px",minHeight:"32px",maxHeight:"32px",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"12px",paddingRight:"12px",userSelect:"none",overflow:"hidden"},className:"w-full bg-background/95 backdrop-blur-sm border-b border-border/30 text-sm text-foreground/80",title:s,"aria-expanded":r,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&i()},children:[h.jsx("span",{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1},children:s}),h.jsx("span",{style:{marginLeft:8,opacity:.5,fontSize:10},"aria-hidden":"true",children:r?"▲":"▼"})]}),r&&h.jsx("div",{"data-status-band-expansion":!0,style:{position:"relative",width:"100%",zIndex:29,maxHeight:200,overflowY:"auto"},className:"bg-background/98 border-b border-border/50 text-xs text-foreground/70",children:h.jsx("div",{style:{padding:"8px 12px"},children:o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"No details available."}):h.jsx("table",{style:{width:"100%",borderCollapse:"collapse"},children:h.jsx("tbody",{children:o.map((a,l)=>h.jsxs("tr",{children:[h.jsx("td",{style:{paddingRight:16,paddingBottom:2,fontWeight:500,whiteSpace:"nowrap"},className:"text-foreground/60",children:a.label}),h.jsx("td",{style:{paddingBottom:2},children:String(a.value)})]},l))})})})})]})}function BV({onContextSelect:t,sidebarOpen:e=!0,onToggleSidebar:r}){const{items:n,connections:i,connected:s,uiCommand:o,clearUICommand:a,recentChanges:l,createItem:c,updateItem:u,deleteItem:d,createConnection:p,deleteConnection:f,agentActivity:m,agentErrors:x,sessionState:g,registerSnapshotProvider:y,gates:b,gateEvent:k,resolveGate:T,settings:_,updateSettings:w,resetSettings:E,activeBuild:B,setActiveBuild:P,pipelineDraft:N,sessions:M,selectedPhase:$,setSelectedPhase:q,decisionEvents:O,statusSnapshots:I,setStatusSnapshot:A}=gr(),[D,R]=C.useState(()=>sessionStorage.getItem("vision-selectedItemId")||null),j=C.useRef(!!sessionStorage.getItem("vision-activeView")),[S,W]=C.useState(()=>sessionStorage.getItem("vision-activeView")||"roadmap"),[K,F]=C.useState(""),[ht,st]=C.useState(null),[J,ct]=C.useState(!1),[zt,at]=C.useState(!1),[Z,lt]=C.useState(!1);C.useEffect(()=>{sessionStorage.setItem("vision-activeView",S)},[S]),C.useEffect(()=>{D?sessionStorage.setItem("vision-selectedItemId",D):sessionStorage.removeItem("vision-selectedItemId")},[D]);const Ct=C.useRef(!1);C.useEffect(()=>{var tt;(tt=_==null?void 0:_.ui)!=null&&tt.defaultView&&!Ct.current&&!j.current&&(W(_.ui.defaultView),Ct.current=!0)},[_]),C.useEffect(()=>{o&&(o.view&&W(o.view),o.phase!==void 0&&q(o.phase),o.select!==void 0&&R(o.select),a())},[o,a]),C.useEffect(()=>{const tt=()=>{var G;return["INPUT","TEXTAREA","SELECT"].includes((G=document.activeElement)==null?void 0:G.tagName)},kt=G=>{(G.metaKey||G.ctrlKey)&&G.key==="k"&&(G.preventDefault(),ct(nt=>!nt)),(G.metaKey||G.ctrlKey)&&G.key==="n"&&(G.preventDefault(),at(!0)),G.key===","&&!G.metaKey&&!G.ctrlKey&&!tt()&&lt(!0)};return window.addEventListener("keydown",kt),()=>window.removeEventListener("keydown",kt)},[]);const Mt=C.useMemo(()=>{let tt=n;if($&&(tt=tt.filter(kt=>kt.phase===$)),K){const kt=K.toLowerCase();tt=tt.filter(G=>G.title.toLowerCase().includes(kt)||(G.description||"").toLowerCase().includes(kt))}return tt},[n,$,K]),Dt=C.useMemo(()=>$?n.filter(tt=>tt.phase===$):n,[n,$]),ne=C.useMemo(()=>new Set(Dt.map(tt=>tt.id)),[Dt]),ue=C.useMemo(()=>$?b.filter(tt=>ne.has(tt.itemId)):b,[b,ne,$]),Se=C.useMemo(()=>{if(!$&&!K)return i;const tt=new Set(Mt.map(kt=>kt.id));return i.filter(kt=>tt.has(kt.fromId)&&tt.has(kt.toId))},[i,Mt,$,K]);C.useEffect(()=>{y(()=>({activeView:S,selectedPhase:$,searchQuery:K,selectedItemId:D,totalItems:n.length,filteredCount:Mt.length,connected:s}))},[y,S,$,K,D,n.length,Mt.length,s]);const te=C.useCallback(tt=>{R(tt),t&&t({type:"item",id:tt})},[t]),Ae=C.useCallback((tt,kt)=>{u(tt,kt)},[u]);C.useCallback(async()=>{const kt=await c({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:$||"vision"});kt&&kt.id&&R(kt.id)},[c,$]),C.useCallback(async tt=>{await d(tt),D===tt&&(R(null),t&&t(null))},[d,D,t]);const V=C.useCallback(tt=>{const kt=b.find(G=>G.id===tt);kt&&(R(kt.itemId),t&&t({type:"item",id:kt.itemId}))},[b,t]);C.useCallback(async tt=>p(tt),[p]),C.useCallback(async tt=>f(tt),[f]);const it=C.useCallback(()=>{Rt("/api/build/state").then(tt=>tt.json()).then(tt=>P(tt.state??null)).catch(()=>{})},[P]),dt=C.useCallback(tt=>{t&&t({type:"step",id:tt})},[t]),Nt=C.useMemo(()=>{var kt;if(!D)return null;const tt=n.find(G=>G.id===D);return((kt=tt==null?void 0:tt.lifecycle)==null?void 0:kt.featureCode)||null},[D,n]);return C.useEffect(()=>{Nt&&(I&&I[Nt]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(Nt)}`).then(tt=>tt.json()).then(tt=>{tt.snapshot&&A&&A(Nt,tt.snapshot)}).catch(()=>{}))},[Nt]),h.jsx(Mc.Provider,{value:l,children:h.jsxs("div",{className:"h-full flex flex-col bg-background","data-snapshot-root":!0,children:[h.jsx(WT,{featureCode:Nt,snapshot:Nt?(I==null?void 0:I[Nt])??null:null}),Nt&&h.jsx(zT,{events:O,currentFeatureCode:Nt}),h.jsxs("div",{className:"flex-1 flex min-h-0",children:[h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[r&&h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:r,title:e?"Collapse sidebar":"Expand sidebar","aria-expanded":e,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:e?"‹":"›"}),e&&h.jsx(d1,{items:n,gates:b,activeBuild:B,activeView:S,onViewChange:W,selectedPhase:$,onPhaseSelect:q,searchQuery:K,onSearchChange:F,connected:s,agentActivity:m,agentErrors:x,sessionState:g,onSelectItem:te,onThemeChange:w,onNewItem:()=>at(!0)})]}),h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[!s&&h.jsx("div",{className:"text-center text-[10px] py-0.5 bg-destructive text-destructive-foreground",children:"Disconnected — reconnecting..."}),S==="tree"&&h.jsx(p1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="graph"&&h.jsx(g1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="pipeline"&&h.jsx(XS,{activeBuild:B,pipelineDraft:N,onSelectStep:dt,onRefresh:it}),S==="sessions"&&h.jsx(eT,{sessions:M,items:n,onSelectItem:te}),S==="docs"&&h.jsx(qS,{items:Dt}),S==="gates"&&h.jsx(US,{gates:ue,items:Dt,onResolve:T,onSelect:te}),S==="settings"&&h.jsx(YS,{settings:_,onSettingsChange:w,onReset:E})]}),h.jsx($T,{onOpenGate:V}),ht&&(()=>{const tt=n.find(kt=>kt.id===ht);return tt?h.jsx(VS,{item:tt,items:n,connections:i,onUpdate:Ae,onClose:()=>st(null)}):null})(),h.jsx(GS,{event:k,items:n,onNavigate:()=>W("gates")}),h.jsx(rT,{open:J,onClose:()=>ct(!1),onSelectItem:tt=>{te(tt),ct(!1)},onSelectGate:tt=>{V(tt),ct(!1)}}),h.jsx(OT,{open:zt,onClose:()=>at(!1)}),h.jsx(RT,{open:Z,onClose:()=>lt(!1),settings:_,onSettingsChange:w})]})]})})}la.use(ry);const AV={background:"#0b0b14",overlay:"#161625",textPrimary:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",textMuted:"#475569",accent:"#FBBF24"},MV={background:"#FFFFFF",overlay:"#F5F5F5",textPrimary:"#0a0a0a",textSecondary:"#404040",textTertiary:"#737373",textMuted:"#a3a3a3",accent:"#FBBF24"};function IV(t){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"11px","font-weight":600,"font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textPrimary,"text-wrap":"wrap","text-max-width":"110px","background-color":t.overlay,"border-width":1,"border-color":"data(color)","border-opacity":.5,width:140,height:52,shape:"round-rectangle","text-outline-width":0,"overlay-padding":4,"overlay-opacity":0}},{selector:'node[shape = "diamond"]',style:{shape:"diamond",width:160,height:80,"font-size":"10px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":t.accent}},{selector:"edge",style:{width:1,"line-color":t.textMuted,"target-arrow-color":t.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.7,opacity:.5}},{selector:"edge[label]",style:{label:"data(label)","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textSecondary,"text-rotation":"autorotate","text-margin-y":-8,"text-outline-width":3,"text-outline-color":t.background}},{selector:"edge[color]",style:{"line-color":"data(color)","target-arrow-color":"data(color)"}},{selector:'edge[lineStyle = "dashed"]',style:{"line-style":"dashed"}},{selector:'edge[lineStyle = "dotted"]',style:{"line-style":"dotted"}},{selector:":parent",style:{"background-color":t.overlay,"background-opacity":.3,"border-width":1,"border-color":"data(color)","border-opacity":.3,"text-valign":"top","text-halign":"center","font-size":"10px",color:t.textTertiary,padding:"16px"}}]}function FV(){const[t,e]=C.useState(()=>document.documentElement.classList.contains("dark"));return C.useEffect(()=>{const r=new MutationObserver(()=>e(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}const PV={"dagre-tb":{name:"dagre",rankDir:"LR",rankSep:80,nodeSep:50,padding:40},"dagre-lr":{name:"dagre",rankDir:"TB",rankSep:100,nodeSep:40,padding:40},circle:{name:"circle",padding:40},grid:{name:"grid",padding:40,rows:3},concentric:{name:"concentric",padding:40,minNodeSpacing:60},breadthfirst:{name:"breadthfirst",padding:40,spacingFactor:1.2}},DV={"dagre-tb":"Top → Down","dagre-lr":"Left → Right",circle:"Circle",grid:"Grid",concentric:"Concentric",breadthfirst:"Breadthfirst"};function OV(t,e){const r=[];for(const n of t)r.push({data:{id:n.id,label:n.label,sublabel:n.sublabel||void 0,color:n.color||CY.textMuted,parent:n.parent||void 0,shape:n.shape||void 0},...n.position?{position:n.position}:{}});for(const n of e)r.push({data:{id:n.id||`${n.from}-${n.to}-${n.label||""}`,source:n.from,target:n.to,label:n.label||void 0,color:n.color||void 0,lineStyle:n.style||"solid",edgeType:n.type||void 0}});return r}const wc="compose:graph:";function RV(t){try{const e=localStorage.getItem(wc+t);return e?JSON.parse(e):null}catch{return null}}function $V(t,e){try{localStorage.setItem(wc+t,JSON.stringify(e))}catch{}}const zV=[{style:"solid",label:"Structural / hard",dash:null},{style:"dashed",label:"Informational / weak",dash:"4,3"},{style:"dotted",label:"Soft dependency",dash:"1.5,3"}];function os({onClick:t,active:e,children:r,title:n}){return h.jsx("button",{onClick:t,title:n,className:"text-xs rounded cursor-pointer transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground))"},children:r})}function il({mode:t,active:e,onClick:r}){return h.jsx("button",{onClick:r,className:"text-xs rounded cursor-pointer capitalize transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:t})}function bu(){return h.jsx("div",{className:"w-px h-4 mx-0.5",style:{background:"hsl(var(--border))"}})}function w0({arrow:t,label:e,edgeStyle:r,color:n,targetLabel:i,targetColor:s,suffix:o}){return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:t}),h.jsx("span",{style:{color:n||"hsl(var(--muted-foreground))",fontStyle:r==="dashed"?"italic":"normal"},children:e||"connects"}),i?h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:s||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:i})]})]}):o?h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:o}):null,r&&r!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",r,")"]})]})}function WV({nodes:t,edges:e,graphKey:r}){const[n,i]=C.useState(()=>{try{const l=localStorage.getItem(wc+r+":tree-collapsed");return l?new Set(JSON.parse(l)):new Set}catch{return new Set}});C.useEffect(()=>{try{localStorage.setItem(wc+r+":tree-collapsed",JSON.stringify([...n]))}catch{}},[n,r]);const s=C.useMemo(()=>{const l={};for(const c of t)l[c.id]=c;return l},[t]),o=C.useMemo(()=>{var u,d;const l={},c={};for(const p of t)l[p.id]=[],c[p.id]=[];for(const p of e)(u=l[p.from])==null||u.push(p),(d=c[p.to])==null||d.push(p);return{out:l,inc:c}},[t,e]),a=l=>i(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u});return h.jsxs("div",{className:"w-full h-full overflow-y-auto",style:{background:"hsl(var(--background))",padding:"1rem"},children:[h.jsxs("div",{className:"flex items-center mb-4",style:{gap:"8px"},children:[h.jsx(os,{onClick:()=>i(new Set),children:"Expand all"}),h.jsx(os,{onClick:()=>i(new Set(t.map(l=>l.id))),children:"Collapse all"}),h.jsxs("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground))"},children:[t.length," entities · ",e.length," relations"]})]}),t.map(l=>{const c=n.has(l.id),u=o.out[l.id]||[],d=o.inc[l.id]||[],p=u.filter(g=>g.from===g.to),f=u.filter(g=>g.from!==g.to),m=d.filter(g=>g.from!==g.to),x=f.length+m.length+p.length;return h.jsxs("div",{className:"mb-0.5",children:[h.jsxs("button",{onClick:()=>a(l.id),className:"flex items-center w-full text-left bg-transparent border-none cursor-pointer rounded-md transition-colors hover:bg-[hsl(var(--accent))]",style:{gap:"8px",padding:"8px"},children:[h.jsx("span",{className:"text-xs w-4 text-center inline-block transition-transform",style:{color:"hsl(var(--muted-foreground))",transform:c?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),h.jsx("span",{className:"w-3 h-3 shrink-0",style:{borderRadius:l.shape==="diamond"?0:3,background:l.color,transform:l.shape==="diamond"?"rotate(45deg) scale(0.8)":"none"}}),h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:l.label}),l.sublabel&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:["— ",l.sublabel]}),h.jsx("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:x})]}),!c&&h.jsxs("div",{style:{paddingLeft:"32px",paddingBottom:"4px"},children:[f.map((g,y)=>{var b,k;return h.jsx(w0,{arrow:"→",label:g.label,edgeStyle:g.style,color:g.color,targetLabel:((b=s[g.to])==null?void 0:b.label)||g.to,targetColor:(k=s[g.to])==null?void 0:k.color},`out-${y}`)}),p.map((g,y)=>h.jsx(w0,{arrow:"↻",label:g.label,edgeStyle:g.style,color:g.color,suffix:"(self)"},`self-${y}`)),m.map((g,y)=>{var b,k;return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:((b=s[g.from])==null?void 0:b.color)||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:((k=s[g.from])==null?void 0:k.label)||g.from})]}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsx("span",{style:{color:g.color||"hsl(var(--muted-foreground))",fontStyle:g.style==="dashed"?"italic":"normal"},children:g.label||"connects"}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→ this"}),g.style&&g.style!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",g.style,")"]})]},`in-${y}`)}),x===0&&h.jsx("div",{className:"text-xs italic",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground) / 0.6)"},children:"no relations"})]})]},l.id)})]})}function qV({elements:t,nodes:e,edges:r,layout:n,style:i,title:s,subtitle:o,graphKey:a="default",onNodeClick:l}){const c=C.useRef(null),u=C.useRef(null),[d,p]=C.useState(null),f=FV(),m=f?AV:MV,x=C.useMemo(()=>RV(a),[a]),[g,y]=C.useState((x==null?void 0:x.layoutKey)||"dagre-tb"),[b,k]=C.useState((x==null?void 0:x.showEdgeLabels)??!0),[T,_]=C.useState(()=>new Set((x==null?void 0:x.hiddenNodes)||[])),[w,E]=C.useState((x==null?void 0:x.showLegend)??!0),[B,P]=C.useState((x==null?void 0:x.viewMode)||"graph");C.useEffect(()=>{$V(a,{layoutKey:g,showEdgeLabels:b,hiddenNodes:[...T],showLegend:w,viewMode:B})},[a,g,b,T,w,B]);const N=t||(e&&r?OV(e,r):[]),M=C.useMemo(()=>i||IV(m),[i,f]),$=n||PV[g],q=C.useMemo(()=>N.filter(S=>!S.data.source).map(S=>({id:S.data.id,label:S.data.label,color:S.data.color})),[JSON.stringify(N)]),O=C.useMemo(()=>T.size===0?N:N.filter(S=>S.data.source?!T.has(S.data.source)&&!T.has(S.data.target):!T.has(S.data.id)),[N,T]);C.useEffect(()=>{if(!c.current)return;const S=la({container:c.current,elements:O,style:M,layout:$,minZoom:.2,maxZoom:4,wheelSensitivity:.3,boxSelectionEnabled:!1});return u.current=S,S.on("mouseover","node",W=>{const K=W.target;K.style("border-width",2),K.style("border-opacity",1);const F=K.renderedPosition();p({x:F.x,y:F.y-K.renderedHeight()/2-12,label:K.data("label"),sublabel:K.data("sublabel"),id:K.id(),color:K.data("color")})}),S.on("mouseout","node",W=>{W.target.style("border-width",1),W.target.style("border-opacity",.5),p(null)}),l&&S.on("tap","node",W=>l(W.target.id())),S.on("layoutstop",()=>S.fit(void 0,40)),()=>{S.destroy(),u.current=null}},[JSON.stringify(O),JSON.stringify($),f,B]),C.useEffect(()=>{const S=u.current;S&&S.edges().forEach(W=>{W.data("label")&&W.style("label",b?W.data("label"):"")})},[b]);const I=C.useCallback(()=>{var S;return(S=u.current)==null?void 0:S.fit(void 0,40)},[]),A=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()*1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),D=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()/1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),R=C.useCallback(S=>{_(W=>{const K=new Set(W);return K.has(S)?K.delete(S):K.add(S),K})},[]),j=C.useCallback(()=>_(new Set),[]);return B==="tree"?h.jsxs("div",{className:"w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"flex items-center justify-between shrink-0",style:{padding:"8px 16px",borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center",style:{gap:"8px"},children:[s&&h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"flex",style:{gap:"4px"},children:[h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(WV,{nodes:e||[],edges:r||[],graphKey:a})})]}):h.jsxs("div",{className:"w-full h-full relative",style:{background:"hsl(var(--background))"},children:[(s||o)&&h.jsxs("div",{className:"absolute top-0 left-0 right-0 z-[2] pointer-events-none",style:{padding:"8px 16px",background:"linear-gradient(to bottom, hsl(var(--background)) 0%, transparent 100%)"},children:[s&&h.jsx("div",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"absolute top-2 right-3 z-[2] flex items-center",style:{gap:"4px"},children:[h.jsx("select",{value:g,onChange:S=>y(S.target.value),className:"text-xs rounded cursor-pointer appearance-none",style:{padding:"4px 8px",borderRadius:"0.375rem",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",color:"hsl(var(--muted-foreground))"},title:"Graph layout",children:Object.entries(DV).map(([S,W])=>h.jsx("option",{value:S,style:{background:"hsl(var(--accent))",color:"hsl(var(--foreground))"},children:W},S))}),h.jsx(bu,{}),h.jsx(os,{onClick:D,title:"Zoom out",children:"−"}),h.jsx(os,{onClick:I,title:"Fit to view",children:"Fit"}),h.jsx(os,{onClick:A,title:"Zoom in",children:"+"}),h.jsx(bu,{}),h.jsx(os,{onClick:()=>E(!w),active:w,title:w?"Hide legend":"Show legend",children:"Legend"}),h.jsx(bu,{}),h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]}),w&&h.jsxs("div",{className:"absolute bottom-3 left-3 z-[2]",style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"8px 16px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:150,maxWidth:210},children:[h.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Entities"}),T.size>0&&h.jsx("button",{onClick:j,className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:"hsl(var(--primary))"},children:"Show all"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:q.map(S=>{const W=T.has(S.id);return h.jsxs("button",{onClick:()=>R(S.id),className:"flex items-center gap-1.5 bg-transparent border-none py-0.5 cursor-pointer transition-opacity",style:{opacity:W?.35:1},title:W?`Show ${S.label}`:`Hide ${S.label}`,children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0 transition-colors",style:{background:W?"transparent":S.color,border:`1.5px solid ${S.color}`}}),h.jsx("span",{className:"text-xs",style:{color:W?"hsl(var(--muted-foreground) / 0.6)":"hsl(var(--muted-foreground))",textDecoration:W?"line-through":"none"},children:S.label})]},S.id)})}),h.jsxs("div",{className:"flex justify-between items-center mt-2.5 mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Edges"}),h.jsx("button",{onClick:()=>k(!b),className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:b?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:b?"Hide labels":"Show labels"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:zV.map(S=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("svg",{width:"20",height:"6",className:"shrink-0",children:h.jsx("line",{x1:"0",y1:"3",x2:"20",y2:"3",stroke:"hsl(var(--muted-foreground))",strokeWidth:"1.5",strokeDasharray:S.dash||"none"})}),h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:S.label})]},S.style))})]}),d&&h.jsxs("div",{className:"absolute z-10 text-center pointer-events-none backdrop-blur-sm",style:{left:d.x,top:d.y,transform:"translate(-50%, -100%)",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"4px 8px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:110,maxWidth:200},children:[h.jsx("div",{className:"text-sm font-semibold",style:{color:d.color||"hsl(var(--foreground))"},children:d.label}),d.sublabel&&h.jsx("div",{className:"text-xs mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:d.sublabel}),h.jsx("div",{className:"text-[10px] mt-1 font-mono",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:d.id})]}),h.jsx("div",{ref:c,className:"w-full h-full"})]})}const Wt={discovery:"#a78bfa",feature:"#3b82f6",track:"#06b6d4",task:"#94a3b8",spec:"#a78bfa",idea:"#fbbf24",question:"#f472b6",evaluation:"#f59e0b",thread:"#64748b",decision:"#22c55e",artifact:"#a87cb8",informs:"#64748b",pipeline:"#6366f1"},HV=[{id:"discovery",label:"Discovery",sublabel:"orthogonal process",color:Wt.discovery,shape:"diamond"},{id:"pipeline",label:"Feature Development Pipeline",color:Wt.pipeline},{id:"p-vision",label:"Vision",parent:"pipeline",color:Wt.pipeline},{id:"p-specification",label:"Specification",parent:"pipeline",color:Wt.pipeline},{id:"p-planning",label:"Planning",parent:"pipeline",color:Wt.pipeline},{id:"p-implementation",label:"Implementation",parent:"pipeline",color:Wt.pipeline},{id:"p-verification",label:"Verification",parent:"pipeline",color:Wt.pipeline},{id:"p-release",label:"Release",parent:"pipeline",color:Wt.pipeline},{id:"feature",label:"Feature",sublabel:"strategic container",color:Wt.feature},{id:"track",label:"Track",sublabel:"deliverable unit",color:Wt.track},{id:"task",label:"Task",sublabel:"planned → doing → done",color:Wt.task},{id:"spec",label:"Spec",sublabel:"behavioral specification",color:Wt.spec},{id:"evaluation",label:"Evaluation",sublabel:"assessment / gap analysis",color:Wt.evaluation},{id:"idea",label:"Idea",sublabel:"can float free",color:Wt.idea},{id:"thread",label:"Thread",sublabel:"deliberation",color:Wt.thread},{id:"decision",label:"Decision",sublabel:"resolved choice",color:Wt.decision},{id:"question",label:"Question",sublabel:"may block progress",color:Wt.question},{id:"artifact",label:"Artifact",sublabel:"journal / doc / output",color:Wt.artifact}],UV=[{from:"p-vision",to:"p-specification",color:Wt.pipeline},{from:"p-specification",to:"p-planning",color:Wt.pipeline},{from:"p-planning",to:"p-implementation",color:Wt.pipeline},{from:"p-implementation",to:"p-verification",color:Wt.pipeline},{from:"p-verification",to:"p-release",color:Wt.pipeline},{from:"idea",to:"p-vision",label:"lives in",color:Wt.idea,style:"dotted"},{from:"spec",to:"p-specification",label:"lives in",color:Wt.spec,style:"dotted"},{from:"task",to:"p-implementation",label:"lives in",color:Wt.task,style:"dotted"},{from:"evaluation",to:"p-verification",label:"lives in",color:Wt.evaluation,style:"dotted"},{from:"discovery",to:"feature",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"idea",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"thread",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"decision",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"question",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"spec",label:"produces",color:Wt.discovery,style:"dashed"},{from:"track",to:"feature",label:"implements",color:Wt.track},{from:"task",to:"feature",label:"implements",color:Wt.task},{from:"spec",to:"feature",label:"implements",color:Wt.spec},{from:"feature",to:"feature",label:"blocks",color:Wt.question,id:"feat-blocks"},{from:"idea",to:"feature",label:"informs",color:Wt.informs,style:"dashed"},{from:"thread",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"evaluation",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"artifact",to:"feature",label:"supports",color:Wt.artifact},{from:"question",to:"decision",label:"contradicts",color:Wt.question},{from:"feature",to:"p-vision",label:"enters",color:Wt.feature,style:"dashed"}];function GV(){return h.jsx(qV,{graphKey:"product",nodes:HV,edges:UV,title:"Compose Product Ontology",subtitle:"10 entity types · 6 phases · 5 edge types · Discovery orthogonal"})}const VV="compose-popout";function qT(t){if(t==="vision://surface")return"Vision Tracker";if(t.startsWith("graph://")){const r=t.replace("graph://","");return r.charAt(0).toUpperCase()+r.slice(1)+" Graph"}const e=t.split("/");return e.length>1?e.slice(-2).join("/"):e[e.length-1]}function sl({path:t,onDock:e}){return h.jsxs("div",{className:"flex items-center justify-between px-3 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--background))"},children:[h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:qT(t)}),h.jsxs("button",{onClick:e,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] uppercase tracking-wider",style:{color:"hsl(var(--primary))",background:"none",border:"none",cursor:"pointer"},title:"Pop back into main window",children:[h.jsx(jA,{style:{width:11,height:11}}),"pop in"]})]})}function YV({path:t}){const[e,r]=C.useState(null),[n,i]=C.useState(!0),s=C.useRef(null),o=C.useRef(null),a=t.startsWith("vision://")?"vision":t.startsWith("graph://")?"graph":t.endsWith(".html")||t.endsWith(".htm")?"html":"markdown";C.useEffect(()=>{document.title=qT(t)+" — Compose"},[t]),C.useEffect(()=>{const c=new BroadcastChannel(VV);s.current=c,c.postMessage({type:"popout-mounted",path:t});const u=()=>{c.postMessage({type:"popout-closed",path:t})};return window.addEventListener("beforeunload",u),()=>{u(),c.close(),window.removeEventListener("beforeunload",u)}},[t]);const l=C.useCallback(()=>{var c;(c=s.current)==null||c.postMessage({type:"popout-dock",path:t}),window.close()},[t]);return C.useEffect(()=>{if(a==="vision"||a==="graph"){i(!1);return}Rt(`/api/file?path=${encodeURIComponent(t)}`).then(c=>c.json()).then(c=>{c.content!==void 0&&r(c.content),i(!1)}).catch(()=>i(!1))},[t,a]),C.useEffect(()=>{if(a==="vision"||a==="graph")return;const c=window.location.protocol==="https:"?"wss:":"ws:",u=new WebSocket(`${c}//${window.location.host}/ws/files`);return o.current=u,u.onmessage=d=>{try{const p=JSON.parse(d.data);p.type==="fileChanged"&&p.path===t&&r(p.content)}catch{}},()=>u.close()},[t,a]),n?h.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):a==="vision"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(BV,{})})]}):a==="graph"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(GV,{})})]}):a==="html"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx("iframe",{srcDoc:e,className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin",title:t})})]}):h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:h.jsx("div",{className:"canvas-markdown max-w-4xl mx-auto",children:h.jsx(yf,{remarkPlugins:[vf],children:e||""})})})]})}const XV="/api/stratum";async function lh(t,e={}){return(await Rt(`${XV}${t}`,{headers:{"Content-Type":"application/json",...e.headers||{}},...e})).json()}function KV(t,e){return lh(t,{method:"POST",body:JSON.stringify(e)})}function HT({status:t}){const e={running:"hsl(var(--background))",awaiting_gate:"#7c3aed",complete:"#166534",killed:"#7f1d1d",blocked:"#7f1d1d"},r={running:"running",awaiting_gate:"gate pending",complete:"complete",killed:"killed",blocked:"blocked"};return h.jsx("span",{style:{fontSize:"0.72em",padding:"2px 6px",borderRadius:4,background:e[t]||"#333",color:"#e5e7eb",textTransform:"uppercase",letterSpacing:"0.05em"},children:r[t]||t})}function Up(){return h.jsx("span",{style:{opacity:.5,fontSize:"0.85em"},children:"loading…"})}function ZV({onAction:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState({}),[a,l]=C.useState({}),c=C.useCallback(()=>{lh("/gates").then(d=>{r(Array.isArray(d)?d:[]),i(null)}).catch(d=>i(d.message))},[]);C.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[c]);async function u(d,p,f){const m=`${d}/${p}/${f}`;o(g=>({...g,[m]:!0}));const x=a[`${d}/${p}`]||"";try{const g=await KV(`/gates/${d}/${p}/${f}`,{note:x});g.conflict?i(`Gate already resolved (${d}/${p})`):g.error?i(g.error.message):(t==null||t(),c())}catch(g){i(g.message)}finally{o(g=>({...g,[m]:!1}))}}return e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsxs("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:["Pending Gates ",(e==null?void 0:e.length)>0&&h.jsxs("span",{style:{opacity:1,color:"#f59e0b"},children:["(",e.length,")"]})]}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em",margin:"0 0 8px"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No pending gates."}),e==null?void 0:e.map(d=>{const p=`${d.flow_id}/${d.step_id}`,f=m=>s[`${p}/${m}`];return h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",marginBottom:8,background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:d.flow_name||d.flow_id}),h.jsx("span",{style:{opacity:.4,fontSize:"0.8em"},children:"›"}),h.jsx("span",{style:{fontFamily:"monospace",fontSize:"0.82em",opacity:.7},children:d.step_id}),d.function&&h.jsxs("span",{style:{opacity:.4,fontSize:"0.78em"},children:["fn:",d.function]})]}),h.jsx("input",{type:"text",placeholder:"Note (optional)",value:a[p]||"",onChange:m=>l(x=>({...x,[p]:m.target.value})),style:{width:"100%",boxSizing:"border-box",marginBottom:8,background:"#27272a",border:"1px solid #3f3f46",borderRadius:4,color:"#e4e4e7",padding:"4px 8px",fontSize:"0.82em"}}),h.jsx("div",{style:{display:"flex",gap:6},children:[{a:"approve",label:"Approve",color:"#166534",hover:"#15803d"},{a:"reject",label:"Reject",color:"#7f1d1d",hover:"#b91c1c"},{a:"revise",label:"Revise",color:"#1e3a5f",hover:"#1d4ed8"}].map(({a:m,label:x,color:g})=>h.jsx("button",{disabled:f(m),onClick:()=>u(d.flow_id,d.step_id,m),style:{padding:"4px 12px",fontSize:"0.8em",borderRadius:4,border:"none",background:g,color:"#e5e7eb",cursor:f(m)?"not-allowed":"pointer",opacity:f(m)?.5:1},children:f(m)?"…":x},m))})]},p)})]})}function QV({flowId:t,onClose:e}){const[r,n]=C.useState(null),[i,s]=C.useState(null);return C.useEffect(()=>{lh(`/flows/${t}`).then(o=>{o.error?s(o.error.message):n(o)}).catch(o=>s(o.message))},[t]),h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:(r==null?void 0:r.flow_name)||t}),h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"1.1em"},children:"✕"})]}),i&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:i}),!r&&!i&&h.jsx(Up,{}),r&&h.jsx("div",{style:{fontSize:"0.82em",opacity:.8},children:(()=>{const o=new Set(Array.isArray(r.completed_steps)?r.completed_steps:[]),a=new Set(Array.isArray(r.active_steps)?r.active_steps:[]),l=o.size,c=r.step_count??"?";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:[h.jsx("span",{children:h.jsx(HT,{status:r.status})}),h.jsxs("span",{children:["steps ",l,"/",c,a.size>0&&h.jsxs("span",{style:{marginLeft:6,color:"#34d399",fontSize:"0.85em"},children:["∥ ",a.size," running"]})]}),r.round>0&&h.jsxs("span",{children:["round ",r.round]})]}),Array.isArray(r.ordered_steps)&&r.ordered_steps.length>0&&h.jsx("ol",{style:{margin:0,padding:"0 0 0 18px",lineHeight:1.7},children:r.ordered_steps.map(u=>h.jsxs("li",{style:{opacity:o.has(u.id)?.4:1,fontWeight:a.has(u.id)?700:"normal",color:a.has(u.id)?"#34d399":"inherit"},children:[h.jsx("span",{style:{fontFamily:"monospace"},children:u.id}),u.mode==="gate"&&h.jsx("span",{style:{marginLeft:6,color:"#f59e0b",fontSize:"0.9em"},children:"gate"}),a.has(u.id)&&h.jsx("span",{style:{marginLeft:6,fontSize:"0.85em"},children:"∥ running"})]},u.id))})]})})()})]})}function JV({activeBuild:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState(null),a=C.useCallback(()=>{lh("/flows").then(l=>{r(Array.isArray(l)?l:[]),i(null)}).catch(l=>i(l.message))},[]);return C.useEffect(()=>{a();const l=setInterval(a,15e3);return()=>clearInterval(l)},[a]),C.useEffect(()=>{t&&a()},[t,a]),e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsx("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:"Flows"}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No flows found."}),e==null?void 0:e.map(l=>h.jsx("div",{onClick:()=>o(s===l.flow_id?null:l.flow_id),style:{border:`1px solid ${s===l.flow_id?"#6366f1":"#3f3f46"}`,borderRadius:6,padding:"8px 12px",marginBottom:6,background:s===l.flow_id?"#1e1b4b":"#18181b",cursor:"pointer"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("span",{style:{fontSize:"0.88em",fontWeight:500},children:l.flow_name||l.flow_id}),h.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsxs("span",{style:{fontSize:"0.78em",opacity:.5},children:[Array.isArray(l.completed_steps)?l.completed_steps.length:l.completed_steps??0,"/",l.step_count??"?"]}),h.jsx(HT,{status:l.status})]})]})},l.flow_id)),s&&h.jsx("div",{style:{marginTop:8},children:h.jsx(QV,{flowId:s,onClose:()=>o(null)})})]})}const tY={display:"inline-block",width:8,height:8,borderRadius:"50%",background:"#22c55e",marginRight:8,animation:"pulse-dot 1.5s ease-in-out infinite"};if(typeof document<"u"&&!document.getElementById("pulse-dot-style")){const t=document.createElement("style");t.id="pulse-dot-style",t.textContent="@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }",document.head.appendChild(t)}function eY({build:t,onDismiss:e}){const r=t.status==="running",n=["complete","failed","aborted"].includes(t.status);C.useEffect(()=>{if(t.status==="complete"){const s=setTimeout(()=>e==null?void 0:e(),5e3);return()=>clearTimeout(s)}},[t.status,e]);const i={running:"#166534",complete:"#14532d",failed:"#7f1d1d",aborted:"#78350f"};return h.jsxs("div",{style:{border:`1px solid ${r?"#22c55e33":"#3f3f46"}`,borderRadius:6,padding:"10px 12px",marginBottom:12,background:i[t.status]||"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&h.jsx("span",{style:tY}),h.jsx("span",{style:{fontWeight:600,fontSize:"0.88em"},children:t.featureCode}),h.jsx("span",{style:{opacity:.5,fontSize:"0.78em"},children:r?"building":t.status})]}),n&&t.status!=="complete"&&h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"0.9em"},children:"✕"})]}),h.jsxs("div",{style:{fontSize:"0.8em",opacity:.7,marginTop:4,fontFamily:"monospace"},children:[t.currentStepId,t.stepNum!=null&&t.totalSteps!=null&&h.jsxs("span",{style:{marginLeft:8,opacity:.5},children:["(",t.stepNum,"/",t.totalSteps,")"]}),t.retries>0&&h.jsxs("span",{style:{marginLeft:8,color:"#f59e0b"},children:["retry ",t.retries]})]})]})}function rY(){const t=gr(s=>s.activeBuild),[e,r]=C.useState(null),n=C.useCallback(()=>{t&&r(`${t.flowId}:${t.completedAt}`)},[t]);C.useEffect(()=>{(t==null?void 0:t.status)==="running"&&r(null)},[t==null?void 0:t.status]);const i=t&&!(e&&e===`${t.flowId}:${t.completedAt}`);return h.jsxs("div",{style:{padding:"12px 14px",color:"#e4e4e7",fontSize:"0.9em",overflowY:"auto",height:"100%"},children:[i&&h.jsx(eY,{build:t,onDismiss:n}),h.jsx(ZV,{}),h.jsx("div",{style:{marginTop:20},children:h.jsx(JV,{activeBuild:t})})]})}function nY({projectName:t,projectRoot:e,onSwitch:r}){const[n,i]=C.useState(!1),[s,o]=C.useState(e||""),a=C.useRef(null);return C.useEffect(()=>{o(e||"")},[e]),C.useEffect(()=>{if(!n)return;const l=c=>{var u;(u=a.current)!=null&&u.contains(c.target)||i(!1)};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[n]),C.useEffect(()=>{if(!n)return;const l=c=>{c.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n]),h.jsxs("div",{ref:a,className:"flex items-center shrink-0 gap-2 relative",children:[h.jsx("span",{className:"text-xs font-semibold tracking-widest uppercase text-blue-600 dark:text-accent",children:"Compose"}),h.jsx("button",{"data-testid":"project-btn",className:"text-[10px] uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(l=>!l),title:e||"Switch project","aria-label":"Switch project","aria-haspopup":"dialog","aria-expanded":n,children:t||"no project"}),n&&h.jsxs("div",{"data-testid":"project-popover",role:"dialog","aria-label":"Switch project",className:"absolute top-full left-0 mt-1 z-50 p-2 rounded-md shadow-lg",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:"280px"},children:[h.jsxs("div",{className:"text-[10px] text-muted-foreground mb-1 px-1",children:["Current: ",e]}),h.jsx("input",{autoFocus:!0,"data-testid":"project-input",className:"w-full px-2 py-1 text-xs rounded border bg-background text-foreground",style:{borderColor:"hsl(var(--border))"},placeholder:"Absolute path to project...",value:s,onChange:l=>o(l.target.value),onKeyDown:async l=>{l.key==="Enter"&&await r(s)&&i(!1),l.key==="Escape"&&i(!1)}})]})]})}const iY={dashboard:{label:"Dashboard",icon:uM,tip:"Overview of project status and activity"},tree:{label:"Items",icon:vb,tip:"Hierarchical list of all items and features"},graph:{label:"Graph",icon:vM,tip:"Visual dependency graph of items"},pipeline:{label:"Pipeline",icon:UM,tip:"Build pipeline stages and progress"},sessions:{label:"Sessions",icon:wf,tip:"Active and past agent sessions"},gates:{label:"Gates",icon:qs,tip:"Quality gates and approval checkpoints"},docs:{label:"Docs",icon:Ei,tip:"Project documentation and specs"},design:{label:"Design",icon:Bc,tip:"Design agent conversations and decisions"},ideabox:{label:"Ideabox",icon:xi,tip:"Captured ideas and suggestions"}};function sY({tabs:t=[],activeTab:e,onTabChange:r,onOpenPalette:n,badges:i={}}){return h.jsxs("div",{className:"flex items-center gap-0.5 h-full",role:"tablist","aria-label":"Main views",children:[t.map(s=>{const o=iY[s],a=s===e,l=o==null?void 0:o.icon,c=(o==null?void 0:o.label)||s,u=i[s];return h.jsxs("button",{role:"tab","aria-selected":a,title:o==null?void 0:o.tip,className:["flex items-center gap-1.5 px-3 h-full text-[11px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",a?"border-blue-600 text-blue-600 dark:border-accent dark:text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>r==null?void 0:r(s),children:[l&&h.jsx(l,{style:{width:12,height:12}}),c,u>0&&h.jsx("span",{className:"text-[9px] min-w-[16px] h-4 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:u})]},s)}),h.jsx("div",{className:"flex-1"}),n&&h.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 h-full text-[11px] text-muted-foreground hover:text-foreground transition-colors",title:"Search (⌘K)",children:[h.jsx(Zn,{style:{width:12,height:12}}),h.jsx("kbd",{className:"text-[9px] font-mono opacity-50 bg-muted px-1 py-0.5 rounded",children:"⌘K"})]})]})}function oY(){const[t,e]=C.useState(ly);function r(){const n=!t;q_(n),e(n)}return h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:r,title:t?"Hide verbose events":"Show verbose events","aria-label":"Toggle verbose stream",style:t?{background:"hsl(210 60% 60% / 0.15)",color:"hsl(210 60% 60%)",borderRadius:"3px",padding:"1px 4px",fontSize:"10px"}:{fontSize:"10px"},children:"{ }"})}const Ve={COLLAPSED:"collapsed",EXPANDED:"expanded",MAXIMIZED:"maximized"},aY={[Ve.COLLAPSED]:Ve.EXPANDED,[Ve.EXPANDED]:Ve.MAXIMIZED,[Ve.MAXIMIZED]:Ve.COLLAPSED};function lY(t){return aY[t]??Ve.COLLAPSED}function cY(t){return Ve.COLLAPSED}function hY(t){return Ve.MAXIMIZED}const uY=new Set(Object.values(Ve));function dY(t){return uY.has(t)}function fY(t){switch(t){case Ve.COLLAPSED:return"h-7";case Ve.EXPANDED:return"h-[40vh]";case Ve.MAXIMIZED:return"flex-1";default:return"h-7"}}const UT="compose:agentBarState";function pY(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(UT);return dY(e)?e:Ve.COLLAPSED}catch{return Ve.COLLAPSED}}function mY(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(UT,t)}catch{}}const S0="▾",gY="▴",xY="⤢";function yY({barState:t="collapsed",onStateChange:e}){const[r,n]=C.useState("ready"),[i,s]=C.useState(null);C.useEffect(()=>{function u(d){const{status:p,tool:f,category:m,parallelTasks:x}=d.detail??{};if(s(x??null),x){const{total:g,completed:y,failed:b,active:k}=x;n(`∥ ${y}/${g} tasks${b?` (${b} failed)`:""}${k?` • ${k} active`:""}`)}else n(p==="idle"?"ready":f?`${f} — ${m??p}`:m||(p==="idle"?"ready":p??"ready"))}return window.addEventListener("compose:agent-status",u),()=>window.removeEventListener("compose:agent-status",u)},[]);const o=C.useCallback(()=>{e==null||e(lY(t))},[t,e]),a=C.useCallback(()=>{e==null||e(cY())},[t,e]);C.useCallback(()=>{e==null||e(hY())},[t,e]);const l=t==="collapsed",c=t==="expanded";return h.jsxs("div",{className:"flex flex-col shrink-0 overflow-hidden",style:{borderTop:"1px solid hsl(var(--border))"},"data-agent-bar-state":t,children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 h-7 shrink-0 select-none",style:{borderBottom:l?"none":"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:o,title:l?"Expand agent bar":c?"Maximize agent bar":"Collapse agent bar","aria-label":"Toggle agent bar",children:l?gY:c?xY:S0}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold shrink-0",style:{color:"hsl(var(--accent))"},children:"Agent"}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-[11px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:r}),h.jsx(oY,{}),i&&i.total>0&&h.jsx("div",{className:"shrink-0 flex items-center gap-1",title:`${i.completed}/${i.total} tasks complete`,children:h.jsx("div",{style:{width:48,height:4,borderRadius:2,background:"hsl(var(--muted))",overflow:"hidden"},children:h.jsx("div",{style:{width:`${i.completed/i.total*100}%`,height:"100%",borderRadius:2,background:i.failed?"hsl(var(--destructive))":"hsl(var(--accent))",transition:"width 300ms ease"}})})}),!l&&h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:a,title:"Collapse agent bar","aria-label":"Collapse agent bar",children:S0})]}),!l&&h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(hy,{})})]})}const bY=280,kY=.6;function vY({isOpen:t=!1,onToggle:e,widthPx:r=380,onResizePx:n,children:i,activeBuild:s,gates:o=[],agentErrors:a=[],items:l=[]}){const c=C.useRef(!1),u=C.useCallback(p=>{p.preventDefault(),c.current=!0;const f=x=>{if(!c.current)return;const g=window.innerWidth-x.clientX,y=window.innerWidth*kY,b=Math.max(bY,Math.min(y,g));n==null||n(b)},m=()=>{c.current=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)},[n]),d=o.filter(p=>p.status==="pending"||p.status==="awaiting");return h.jsxs("div",{className:"flex shrink-0 h-full",style:{borderLeft:"1px solid hsl(var(--border))"},"data-context-panel-open":t,children:[t&&n&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0",onMouseDown:u}),h.jsx("button",{className:["w-4 h-full flex items-center justify-center","text-[10px] text-muted-foreground hover:text-foreground","transition-colors select-none"].join(" "),onClick:e,title:t?"Close context panel":"Open context panel","aria-expanded":t,"aria-label":"Toggle context panel",style:{background:"hsl(var(--muted) / 0.3)"},children:t?"›":"‹"}),t&&h.jsx("div",{className:"flex flex-col h-full overflow-hidden",style:{width:`${r}px`},children:Yt.Children.toArray(i).length>0?h.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:i}):h.jsx(SY,{activeBuild:s,pendingGates:d,agentErrors:a,items:l})})]})}const wY={implementation:"#3b82f6",vision:"#a855f7",planning:"#f59e0b",specification:"#06b6d4",verification:"#22c55e",design:"#f43f5e"};function T0(t){return wY[t]||"#6b7280"}function SY({activeBuild:t,pendingGates:e,agentErrors:r,items:n}){const i={};for(const a of n){const l=a.phase||"unknown";i[l]=(i[l]||0)+1}const s=n.length||1,o=r.slice(-5);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-7 flex items-center px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Project Overview"})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-4",children:[t?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Active Build"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-accent font-mono",children:t.featureCode||"—"}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"·"}),h.jsx("span",{className:"text-[10px] text-foreground",children:t.currentStep||t.step||"—"})]})]}):h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Status"}),h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No active build"})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Pending Gates (",e.length,")"]}),e.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:e.slice(0,5).map((a,l)=>h.jsx("p",{className:"text-[10px] text-amber-400 truncate",children:Go(a,n.find(c=>c.id===a.itemId))},l))})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Recent Errors (",o.length,")"]}),o.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:o.map((a,l)=>h.jsx("p",{className:"text-[10px] text-destructive truncate",children:a.message||a.error||"Error"},l))})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase Distribution"}),h.jsx("div",{className:"flex h-2 rounded overflow-hidden gap-px",children:Object.entries(i).map(([a,l])=>h.jsx("div",{className:"h-full",style:{width:`${l/s*100}%`,background:T0(a),opacity:.75,minWidth:"2px"},title:`${a}: ${l}`},a))}),h.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1",children:Object.entries(i).map(([a,l])=>h.jsxs("span",{className:"text-[9px] text-muted-foreground flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:T0(a)}}),a,": ",l]},a))})]})]})]})}const In=60,Rr=24,ol=80,Cu=28,ku=48,_0=8,fs=5,Sc=9;function TY(t,e){return t?t.length>e?t.slice(0,e)+"…":t:""}function _Y(t,e,r){const n=new Map(e.map(a=>[a.id,a])),i=[],s=[],o=new Map;for(const a of r){if(a.toId===t.id){const l=n.get(a.fromId);l&&i.push(l)}if(a.fromId===t.id){const l=n.get(a.toId);l&&s.push(l)}}for(const a of s){const l=[];for(const c of r)if(c.fromId===a.id&&c.toId!==t.id){const u=n.get(c.toId);u&&l.push(u)}l.length>0&&o.set(a.id,l)}return{parents:i,children:s,grandchildren:o}}function vu(t,e,r,n,i){const s=Math.min(t,fs),o=s*n+(s-1)*_0,a=(r-o)/2,l=[];for(let c=0;c<s;c++)l.push({x:a+c*(n+_0),y:e,w:n,h:i});return{positions:l,overflow:t>fs?t-fs+1:0}}function al({item:t,x:e,y:r,w:n,h:i,isSelected:s,isDashed:o,onSelect:a,onHover:l,onLeave:c}){const u=xr[t.type]||xr.task,d=s?.2:.08;return h.jsxs("g",{style:{cursor:"pointer"},onClick:()=>a(t.id),onMouseEnter:p=>l(t,p),onMouseLeave:c,children:[h.jsx("rect",{x:e,y:r,width:n,height:i,rx:4,fill:u,fillOpacity:d,stroke:u,strokeWidth:s?2:1.5,strokeDasharray:o?"4 2":void 0}),h.jsx("text",{x:e+n/2,y:r+i/2,textAnchor:"middle",dominantBaseline:"central",fontSize:s?Sc+1:Sc,fontWeight:s?600:400,fill:"hsl(var(--foreground))",children:TY(t.title,s?10:8)})]})}function EY({item:t,pos:e}){if(!t||!e)return null;const r=xr[t.type]||xr.task,n=qn[t.status]||qn.planned;return h.jsxs("div",{className:"absolute z-50 pointer-events-none px-2 py-1.5 rounded bg-popover border border-border shadow-md",style:{left:e.x,top:e.y,transform:"translate(-50%, -100%)"},children:[h.jsx("p",{className:"text-xs font-medium text-foreground whitespace-nowrap",children:t.title}),h.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[h.jsx("span",{className:"text-[10px]",style:{color:r},children:t.type}),h.jsxs("span",{className:"text-[10px] flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:n}}),t.status]}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:ef[t.confidence||0]})]})]})}function NY({item:t,items:e,connections:r,onSelect:n}){const[i,s]=C.useState(null),[o,a]=C.useState(null),{parents:l,children:c,grandchildren:u}=C.useMemo(()=>_Y(t,e,r),[t,e,r]),d=C.useCallback((I,A)=>{const D=A.currentTarget.closest(".connection-graph-wrap").getBoundingClientRect(),R=A.currentTarget.getBoundingClientRect();s(I),a({x:R.x+R.width/2-D.x,y:R.y-D.y-4})},[]),p=C.useCallback(()=>{s(null),a(null)},[]);if(!(l.length>0||c.length>0))return null;const m=288,x=[];let g=12,y=[],b=0;if(l.length>0){const I=vu(l.length,g,m,In,Rr);y=I.positions,b=I.overflow,g+=Rr+ku}const k=(m-ol)/2,T=g;g+=Cu+ku;let _=[],w=0;if(c.length>0){const I=vu(c.length,g,m,In,Rr);_=I.positions,w=I.overflow,g+=Rr}let E=new Map,B=new Map;const P=[...u.entries()];let N=[];if(P.length>0){g+=ku;for(const[D,R]of P)for(const j of R)N.push({...j,_parentChildId:D});const I=vu(N.length,g,m,In,Rr);let A=0;for(const[D,R]of P){const j=[];for(let S=0;S<R.length&&A<I.positions.length;S++,A++)j.push(I.positions[A]);E.set(D,j)}I.overflow>0&&B.set("all",I.overflow),g+=Rr}const M=g+12;for(let I=0;I<y.length;I++){const A=y[I];x.push({x1:A.x+A.w/2,y1:A.y+A.h,x2:k+ol/2,y2:T})}for(let I=0;I<_.length;I++){const A=_[I];x.push({x1:k+ol/2,y1:T+Cu,x2:A.x+A.w/2,y2:A.y})}for(const[I,A]of E){const D=c.findIndex(R=>R.id===I);if(D>=0&&D<_.length){const R=_[D];for(const j of A)x.push({x1:R.x+R.w/2,y1:R.y+R.h,x2:j.x+j.w/2,y2:j.y})}}const $=l.slice(0,fs-(b>0?1:0)),q=c.slice(0,fs-(w>0?1:0)),O=N.slice(0,fs-(B.size>0?1:0));return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Graph"}),h.jsxs("div",{className:"relative connection-graph-wrap",children:[h.jsxs("svg",{width:m,height:M,className:"w-full",viewBox:`0 0 ${m} ${M}`,children:[x.map((I,A)=>h.jsx("line",{x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,stroke:"hsl(var(--muted-foreground))",strokeOpacity:.3,strokeWidth:1},A)),$.map((I,A)=>h.jsx(al,{item:I,x:y[A].x,y:y[A].y,w:In,h:Rr,isSelected:!1,isDashed:!0,onSelect:n,onHover:d,onLeave:p},I.id)),b>0&&h.jsxs("text",{x:y[y.length-1].x+In/2,y:y[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",b," more"]}),h.jsx(al,{item:t,x:k,y:T,w:ol,h:Cu,isSelected:!0,isDashed:!1,onSelect:n,onHover:d,onLeave:p}),q.map((I,A)=>h.jsx(al,{item:I,x:_[A].x,y:_[A].y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id)),w>0&&h.jsxs("text",{x:_[_.length-1].x+In/2,y:_[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",w," more"]}),O.map((I,A)=>{const R=[...E.values()].flat()[A];return R?h.jsx(al,{item:I,x:R.x,y:R.y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id):null})]}),h.jsx(EY,{item:i,pos:o})]})]})}const jY=["Untested","Low","Moderate","High","Crystallized"];function LY({level:t=0,className:e}){const r=Math.max(0,Math.min(4,t||0)),n=jY[r]??"Untested",i=r===0?Xp[0]:Xp[r];return h.jsxs("span",{className:rt("inline-flex items-center gap-1",e),children:[h.jsx("span",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(s=>h.jsx("span",{className:rt("h-2.5 w-1.5 rounded-sm",s<=r?i:"bg-slate-600")},s))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:n})]})}function BY(t,e=Date.now()){if(!t)return null;const r=Date.parse(t);if(Number.isNaN(r))return null;const n=e-r,i=Math.floor(n/36e5);return i<1?"<1h ago":i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function E0(t){return t==null?"—":t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function AY(t){return t==null?"—":`$${Number(t).toFixed(t<1?3:2)}`}function MY(t){if(t==null)return"—";const e=Math.round(t/1e3);if(e<60)return`${e}s`;const r=Math.round(e/60);if(r<60)return`${r}m`;const n=Math.floor(r/60),i=r%60;return`${n}h${i?` ${i}m`:""}`}function IY(t,e=Date.now()){const r=(t||[]).filter(i=>i==null?void 0:i.started_at);if(!r.length)return null;let n=null;for(const i of r){const s=Date.parse(i.started_at);!Number.isNaN(s)&&(n==null||s>n)&&(n=s)}return n==null?null:BY(new Date(n).toISOString(),e)}function FY(t,e=Date.now()){const r=(t==null?void 0:t.branches)||[],n=r.filter(c=>c.state==="complete"),i=r.filter(c=>c.state==="running"),s=r.length,o=IY(r,e),a=n.length>=2;return{summary:i.length>0&&n.length<2?`${n.length} of ${s} branches ready`:`${s} branch${s===1?"":"es"}${o?` · last fork ${o}`:""}`,canCompare:a,completeBranches:n,runningCount:i.length,totalCount:s}}function PY(t,e=[]){const r=new Map(t.map(s=>[s.branch_id,s])),n=e[0]&&r.has(e[0])?r.get(e[0]):t[0]||null,i=e[1]&&r.has(e[1])?r.get(e[1]):t[1]||null;return[n,i]}function N0({branch:t,extraRows:e=[]}){var o;const r=t.files_touched||[],n=t.tests||{},i=t.cost||{},s=[{label:"Files touched",value:r.length},{label:"Tests",value:`${n.passed??0} / ${n.failed??0} / ${n.skipped??0}`},{label:"Tokens in / out",value:`${E0(i.tokens_in)} / ${E0(i.tokens_out)}`},{label:"USD",value:AY(i.usd)},{label:"Wall clock",value:MY(i.wall_clock_ms)},{label:"Final artifact",value:((o=t.final_artifact)==null?void 0:o.path)||"—"},...e];return h.jsx("div",{className:"space-y-1",children:s.map((a,l)=>h.jsxs("div",{className:"flex justify-between gap-2 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:a.label}),h.jsx("span",{className:"font-mono text-right truncate",title:typeof a.value=="string"?a.value:void 0,children:a.value})]},l))})}function DY({lineage:t,selectedPair:e=[],onSelectPair:r=()=>{},extraMetricsForBranch:n=()=>[],now:i=Date.now()}){var g,y;const[s,o]=C.useState(!1),{summary:a,canCompare:l,completeBranches:c}=FY(t,i),[u,d]=PY(c,e),p=()=>{l&&(o(b=>!b),!s&&u&&d&&r([u.branch_id,d.branch_id]))};if(!s)return h.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[h.jsx("span",{children:a}),h.jsx("button",{disabled:!l,onClick:p,className:"text-[10px] px-2 py-0.5 rounded border border-border "+(l?"hover:bg-muted/40 text-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),"data-testid":"branch-compare-toggle",children:"Compare"})]});const f=(g=u==null?void 0:u.final_artifact)==null?void 0:g.snapshot,m=(y=d==null?void 0:d.final_artifact)==null?void 0:y.snapshot,x=!!f&&!!m;return h.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:a}),h.jsx("button",{onClick:()=>o(!1),className:"text-[10px] text-muted-foreground hover:text-foreground",children:"Collapse"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:u==null?void 0:u.branch_id,children:u?`A: ${u.branch_id.slice(0,8)}…`:"A: (none)"}),u&&h.jsx(N0,{branch:u,extraRows:n(u)})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:d==null?void 0:d.branch_id,children:d?`B: ${d.branch_id.slice(0,8)}…`:"B: (none)"}),d&&h.jsx(N0,{branch:d,extraRows:n(d)})]})]}),h.jsx("div",{className:"col-span-2",children:x?h.jsx(Rp,{oldText:f,newText:m}):h.jsxs("div",{className:"text-[10px] italic text-muted-foreground",children:["No artifact produced on ",!f&&!m?"either branch":f?"branch B":"branch A","."]})})]})}const OY={path_drift:"Path drift",contract_drift:"Contract drift",review_debt_drift:"Review debt"};function RY(t){return OY[t]??t}function j0(t){return t==null||typeof t!="number"||isNaN(t)?"—":`${Math.round(t*100)}%`}function $Y(t){var r,n;return(((n=(r=t==null?void 0:t.lifecycle)==null?void 0:r.lifecycle_ext)==null?void 0:n.drift_axes)??[]).filter(i=>i.breached===!0)}function zY({item:t}){const[e,r]=C.useState(!1),n=$Y(t);if(n.length===0)return null;const i=n.length;return h.jsxs("div",{className:"drift-ribbon",style:{background:"hsl(var(--destructive) / 0.12)",borderLeft:"3px solid hsl(var(--destructive))",minHeight:"28px",padding:e?"6px 10px 8px":"0 10px",display:"flex",flexDirection:"column",justifyContent:"center",gap:0,borderRadius:"4px",marginBottom:"4px"},children:[h.jsxs("button",{onClick:()=>r(s=>!s),style:{display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",color:"hsl(var(--destructive))",fontSize:"12px",fontWeight:600,width:"100%",textAlign:"left"},"aria-expanded":e,"data-testid":"drift-ribbon-toggle",children:[h.jsx(Ac,{size:13}),h.jsxs("span",{children:[i," drift alert",i!==1?"s":""," — click to ",e?"collapse":"expand"]}),e?h.jsx(yb,{size:13,style:{marginLeft:"auto"}}):h.jsx(fa,{size:13,style:{marginLeft:"auto"}})]}),e&&h.jsxs("table",{style:{width:"100%",fontSize:"11px",borderCollapse:"collapse",marginTop:"4px"},"data-testid":"drift-ribbon-table",children:[h.jsx("thead",{children:h.jsxs("tr",{style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Axis"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Ratio"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Threshold"}),h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Explanation"})]})}),h.jsx("tbody",{children:n.map(s=>h.jsxs("tr",{"data-testid":`drift-axis-row-${s.axis_id}`,children:[h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--foreground))",fontWeight:500},children:RY(s.axis_id)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--destructive))"},children:j0(s.ratio)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--muted-foreground))"},children:j0(s.threshold)}),h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--muted-foreground))",maxWidth:"200px",wordBreak:"break-word"},children:s.explanation??""})]},s.axis_id))})]})]})}function WY({level:t,onChange:e}){const r=["hsl(var(--muted-foreground))","hsl(var(--destructive))","hsl(var(--accent))","hsl(var(--success))","hsl(var(--success))"],n=r[t]||r[0];return h.jsxs("button",{onClick:()=>e((t+1)%5),className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted hover:bg-muted/80 transition-colors",title:"Click to cycle confidence",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:ef[t]}),h.jsx("div",{className:"flex items-center gap-0.5",children:[0,1,2,3].map(i=>h.jsx("div",{className:"rounded-full transition-all",style:{width:6,height:6,background:i<t?n:"transparent",border:`1.5px solid ${i<t?n:"hsl(var(--border))"}`}},i))})]})}function qY({item:t,connections:e,items:r,onSelect:n,onDeleteConnection:i}){const s=new Map(r.map(l=>[l.id,l])),o=[];for(const l of e)if(l.type!=="contradicts"){if(l.fromId===t.id){const c=s.get(l.toId);c&&o.push({item:c,type:l.type,direction:"outgoing",connId:l.id})}if(l.toId===t.id){const c=s.get(l.fromId);c&&o.push({item:c,type:l.type,direction:"incoming",connId:l.id})}}if(o.length===0)return null;const a={};for(const l of o){const c=`${l.type}-${l.direction}`;a[c]||(a[c]={type:l.type,direction:l.direction,items:[]}),a[c].items.push({item:l.item,connId:l.connId})}return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Connections"}),Object.values(a).map(l=>h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:l.direction==="incoming"?`${l.type} from`:`${l.type} to`}),h.jsx("div",{className:"space-y-0.5",children:l.items.map(({item:c,connId:u})=>h.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors group/conn",children:[h.jsxs("button",{onClick:()=>n(c.id),className:"flex flex-1 items-center gap-2 min-w-0",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[c.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:c.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[c.type]},children:c.type})]}),i&&h.jsx("button",{onClick:()=>i(u),className:"opacity-0 group-hover/conn:opacity-100 p-0.5 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-all shrink-0",title:"Remove connection",children:h.jsx(cn,{className:"h-3 w-3"})})]},u))})]},`${l.type}-${l.direction}`))]})}function ll(t){if(!t)return"";const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function HY({featureCode:t,lineage:e}){const r=gr(i=>i.selectedBranches),n=gr(i=>i.setSelectedBranches);return h.jsx(DY,{lineage:e,selectedPair:(r==null?void 0:r[t])||[],onSelectPair:i=>n(t,i)})}function UY({featureCode:t}){const[e,r]=C.useState([]),[n,i]=C.useState(!0);return C.useEffect(()=>{const s=new AbortController;return i(!0),Rt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=10`,{signal:s.signal}).then(o=>o.json()).then(o=>{s.signal.aborted||r(o.sessions||[])}).catch(o=>{s.signal.aborted||r([])}).finally(()=>{s.signal.aborted||i(!1)}),()=>s.abort()},[t]),n||e.length===0?null:h.jsxs("div",{children:[h.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Sessions (",e.length,")"]}),h.jsx("div",{className:"space-y-2",children:e.map(s=>{var o;return h.jsxs("div",{className:"text-xs text-muted-foreground border-l-2 border-border pl-2",children:[h.jsxs("div",{className:"font-medium text-foreground",children:[((o=s.phaseAtBind)==null?void 0:o.replace(/_/g," "))||"—",s.phaseAtEnd&&s.phaseAtEnd!==s.phaseAtBind&&` → ${s.phaseAtEnd.replace(/_/g," ")}`]}),h.jsxs("div",{children:[s.toolCount," tools · ",Math.round((new Date(s.endedAt)-new Date(s.startedAt))/6e4),"m"]})]},s.id)})})]})}const GY=["informs","supports","blocks","contradicts"];function VY({item:t,items:e,onCreateConnection:r,onDismiss:n}){const[i,s]=C.useState(""),[o,a]=C.useState("informs"),l=e.filter(u=>u.id===t.id?!1:i?u.title.toLowerCase().includes(i.toLowerCase()):!0).slice(0,8),c=C.useCallback(async u=>{await r({fromId:t.id,toId:u,type:o}),n()},[t.id,o,r,n]);return h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:h.jsxs("div",{className:"p-2 space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("select",{className:"text-[10px] px-1.5 py-1 rounded bg-muted text-foreground border border-border cursor-pointer",value:o,onChange:u=>a(u.target.value),children:GY.map(u=>h.jsx("option",{value:u,children:u},u))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"to..."})]}),h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),h.jsx("input",{className:"w-full text-xs bg-muted text-foreground pl-7 pr-2 py-1.5 rounded border border-border outline-none",placeholder:"Search items...",value:i,onChange:u=>s(u.target.value),autoFocus:!0})]}),h.jsx("div",{className:"max-h-40 overflow-auto space-y-0.5",children:l.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No items found"}):l.map(u=>h.jsxs("button",{onClick:()=>c(u.id),className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[u.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:u.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[u.type]},children:u.type})]},u.id))})]})})}function YY({gate:t,onResolveGate:e}){const[r,n]=C.useState(null),[i,s]=C.useState(""),o=()=>{e(t.id,"revised",i||void 0),n(null),s("")},a=()=>{i.trim()&&(e(t.id,"killed",i),n(null),s(""))};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>e(t.id,"approved"),children:"Approve"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",r==="revise"&&"bg-amber-400/10"),onClick:()=>{n(r==="revise"?null:"revise"),s("")},children:"Revise"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",r==="kill"&&"bg-destructive/10"),onClick:()=>{n(r==="kill"?null:"kill"),s("")},children:"Kill"})]}),r&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("input",{className:"flex-1 text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none",placeholder:r==="revise"?"Feedback (optional)...":"Kill reason (required)...",value:i,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(r==="revise"?o():a()),l.key==="Escape"&&n(null)},autoFocus:!0}),h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px]",disabled:r==="kill"&&!i.trim(),onClick:r==="revise"?o:a,children:r==="revise"?"Submit":"Confirm Kill"})]})]})}function XY({item:t,items:e,connections:r,gates:n,onUpdate:i,onDelete:s,onCreateConnection:o,onDeleteConnection:a,onSelect:l,onClose:c,onPressureTest:u,onResolveGate:d}){var I,A,D,R,j,S;const[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(""),[T,_]=C.useState(!1),[w,E]=C.useState("");C.useEffect(()=>{E((t==null?void 0:t.group)||"")},[t==null?void 0:t.id,t==null?void 0:t.group]);const B=C.useCallback(()=>{const W=w.trim(),K=(t==null?void 0:t.group)||"";W!==K&&i(t.id,{group:W||null})},[w,t==null?void 0:t.id,t==null?void 0:t.group,i]),P=C.useCallback(()=>{x(t.title),f(!0)},[t==null?void 0:t.title]),N=C.useCallback(()=>{m.trim()&&m!==t.title&&i(t.id,{title:m.trim()}),f(!1)},[m,t==null?void 0:t.id,t==null?void 0:t.title,i]),M=C.useCallback(()=>{k(t.description||""),y(!0)},[t==null?void 0:t.description]),$=C.useCallback(()=>{b!==(t.description||"")&&i(t.id,{description:b}),y(!1)},[b,t==null?void 0:t.id,t==null?void 0:t.description,i]),q=C.useMemo(()=>{if(!t)return 0;let W=0;for(const K of r)K.type==="contradicts"&&(K.fromId===t.id||K.toId===t.id)&&W++;return W},[t==null?void 0:t.id,r]);if(!t)return null;const O=xr[t.type]||xr.task;return h.jsxs("div",{className:"w-full bg-card flex flex-col h-full",children:[h.jsxs("div",{className:"p-3 pb-2 flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",style:{color:O,borderColor:O},children:t.type}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",children:jl[t.phase]||t.phase})]}),p?h.jsx("input",{className:"w-full text-sm font-semibold bg-muted text-foreground px-1.5 py-0.5 rounded border border-ring outline-none",value:m,onChange:W=>x(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&N(),W.key==="Escape"&&f(!1)},autoFocus:!0}):h.jsx("h3",{className:"text-sm font-semibold text-foreground cursor-pointer hover:text-accent transition-colors",onDoubleClick:P,title:"Double-click to edit",children:t.title})]}),h.jsx($t,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:c,children:h.jsx(cn,{className:"h-3.5 w-3.5"})})]}),h.jsx(zl,{}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-3 space-y-4",children:[h.jsx(zY,{item:t}),((I=t.lifecycle)==null?void 0:I.featureCode)&&h.jsx(HY,{featureCode:t.lifecycle.featureCode,lineage:(A=t.lifecycle.lifecycle_ext)==null?void 0:A.branch_lineage}),h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer",value:t.status||"planned",onChange:W=>i(t.id,{status:W.target.value}),children:x_.map(W=>h.jsx("option",{value:W,children:W.replace("_"," ")},W))}),h.jsx(WY,{level:t.confidence||0,onChange:W=>i(t.id,{confidence:W})})]}),h.jsx(LY,{level:t.confidence||0}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase"}),h.jsxs("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer w-full",value:t.phase||"",onChange:W=>i(t.id,{phase:W.target.value||null}),children:[h.jsx("option",{value:"",children:"No phase"}),ny.map(W=>h.jsx("option",{value:W,children:jl[W]},W))]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Group"}),h.jsx("input",{type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1 rounded-md border border-border outline-none focus:border-ring",value:w,placeholder:"(none)",onChange:W=>E(W.target.value),onBlur:B,onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),W.currentTarget.blur()),W.key==="Escape"&&(E(t.group||""),W.currentTarget.blur())},"data-testid":"item-detail-group-input"})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Description"}),g?h.jsx("textarea",{className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-ring outline-none resize-none",rows:4,value:b,onChange:W=>k(W.target.value),onBlur:$,onKeyDown:W=>{W.key==="Escape"&&y(!1)},autoFocus:!0}):h.jsx("p",{className:rt("text-xs leading-relaxed cursor-pointer rounded px-2 py-1.5 hover:bg-muted/50 transition-colors",t.description?"text-muted-foreground":"text-muted-foreground/50 italic"),onClick:M,children:t.description||"Click to add description..."})]}),h.jsx(qY,{item:t,connections:r,items:e,onSelect:l,onDeleteConnection:a}),h.jsx(NY,{item:t,items:e,connections:r,onSelect:l}),((D=t.lifecycle)==null?void 0:D.featureCode)&&h.jsx(UY,{featureCode:t.lifecycle.featureCode}),(t.lifecycle||n&&n.some(W=>W.itemId===t.id))&&(()=>{var st;const W=t.lifecycle,K=n?n.filter(J=>J.itemId===t.id):[],F=K.filter(J=>J.status==="pending"),ht=K.filter(J=>J.status!=="pending");return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Lifecycle"}),h.jsxs("div",{className:"space-y-1.5",children:[W&&h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Phase:"}),h.jsx("span",{className:"text-[10px] text-foreground font-medium",children:ve[W.currentPhase]??W.currentPhase}),W.featureCode&&h.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto font-mono",children:W.featureCode})]}),((st=W==null?void 0:W.phaseHistory)==null?void 0:st.length)>1&&h.jsxs("div",{className:"px-2 py-1 rounded bg-muted/30",children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-0.5",children:"History"}),h.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5",children:W.phaseHistory.map((J,ct)=>h.jsxs("span",{className:rt("text-[10px]",J.phase===W.currentPhase?"text-foreground font-medium":"text-muted-foreground"),children:[ve[J.phase]??J.phase,J.outcome&&J.outcome!=="approved"&&h.jsxs("span",{className:"text-amber-400",children:[" (",J.outcome,")"]}),ct<W.phaseHistory.length-1&&" → "]},ct))})]}),F.map(J=>{var at,Z;const ct=J.artifactAssessment,zt=iy[J.fromPhase];return h.jsxs("div",{className:"rounded bg-amber-400/10 border border-amber-400/20 px-2 py-1.5",children:[h.jsxs("p",{className:"text-[10px] text-amber-400 font-medium mb-1",children:["Pending: ",vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`]}),ct&&ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt&&h.jsx("span",{className:"font-mono",children:zt}),zt&&": ",Math.round(ct.completeness*100),"% complete"," · ",ct.wordCount," words",((Z=(at=ct.sections)==null?void 0:at.missing)==null?void 0:Z.length)>0&&h.jsxs("span",{className:"text-amber-400",children:[" (missing: ",ct.sections.missing.join(", "),")"]}),!ct.meetsMinWordCount&&h.jsx("span",{className:"text-amber-400",children:" (below min word count)"})]}),ct&&!ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt??"Artifact"," not found"]}),d&&h.jsx(YY,{gate:J,onResolveGate:d})]},J.id)}),ht.map(J=>{const ct={approved:"text-success",revised:"text-amber-400",killed:"text-destructive"};return h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`}),h.jsx(nr,{variant:"outline",className:rt("text-[10px] px-1.5 py-0 h-4 ml-auto",ct[J.outcome]||""),children:J.outcome})]},J.id)})]})]})})(),((j=(R=t.evidence)==null?void 0:R.stratumViolations)==null?void 0:j.length)>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1.5",children:["Blocked — Ensure Violations",t.evidence.violatedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case text-muted-foreground",children:ll(t.evidence.violatedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:t.evidence.stratumViolations.map((W,K)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:W})]},K))})]}),((S=t.evidence)==null?void 0:S.stratumTrace)&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Stratum Trace",t.evidence.tracedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case",children:ll(t.evidence.tracedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:(t.evidence.stratumTrace.trace||[]).map(W=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--success))"}}),h.jsx("span",{className:"text-[10px] font-mono text-foreground truncate flex-1",children:W.step_id}),W.attempts>1&&h.jsxs("span",{className:"text-[10px] text-amber-400 shrink-0",children:[W.attempts,"x"]}),W.duration_ms!=null&&h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:W.duration_ms<1e3?`${W.duration_ms}ms`:`${(W.duration_ms/1e3).toFixed(1)}s`})]},W.step_id))})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Created ",ll(t.createdAt)]}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Updated ",ll(t.updatedAt)]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("div",{className:"relative",children:[h.jsxs($t,{variant:"outline",size:"sm",className:rt("h-7 text-xs gap-1",T&&"bg-accent/10 border-accent"),onClick:()=>_(!T),children:[h.jsx(pM,{className:"h-3 w-3"})," Connect"]}),T&&h.jsx(VY,{item:t,items:e,onCreateConnection:o,onDismiss:()=>_(!1)})]}),h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:P,children:[h.jsx(Sb,{className:"h-3 w-3"})," Rename"]}),t.type!=="question"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>u(t.id),title:"Challenge this item's assumptions",children:[h.jsx(Pl,{className:"h-3 w-3"})," Pressure Test",q>0&&h.jsx("span",{className:"ml-0.5 text-[10px] px-1 py-0 rounded-full bg-amber-500/20 text-amber-400",children:q})]}),t.status!=="killed"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:async()=>{if(t.lifecycle)try{const W=await Rt(`/api/vision/items/${t.id}/lifecycle/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Killed via UI"})});if(!W.ok){const K=await W.json();console.error("[vision] Lifecycle kill failed:",K.error)}}catch(W){console.error("[vision] Lifecycle kill failed:",W.message)}else i(t.id,{status:"killed"})},children:[h.jsx(Vm,{className:"h-3 w-3"})," Kill"]}),s&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>{window.confirm(`Delete "${t.title}" permanently? This cannot be undone.`)&&s(t.id)},title:"Permanently delete this item",children:[h.jsx(Vm,{className:"h-3 w-3"})," Delete"]})]})]})})]})}const GT=[{id:"overview",label:"Overview"},{id:"pipeline",label:"Pipeline"},{id:"sessions",label:"Sessions"},{id:"errors",label:"Errors"},{id:"files",label:"Files"}];GT.map(t=>t.id);const KY={overview:Ei,pipeline:vb,sessions:Cb,errors:Ac,files:Tf};function ZY({activeTab:t="overview",onTabChange:e,errorCount:r=0}){return h.jsx("div",{className:"flex items-center gap-0 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--muted) / 0.3)"},role:"tablist","aria-label":"Detail sections",children:GT.map(({id:n,label:i})=>{const s=KY[n],o=n===t,a=n==="errors"?r:0;return h.jsxs("button",{role:"tab","aria-selected":o,className:["flex items-center gap-1 px-2 h-full text-[10px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",o?"border-accent text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>e==null?void 0:e(n),children:[h.jsx(s,{style:{width:10,height:10}}),i,a>0&&h.jsx("span",{className:"text-[8px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-0.5 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:a})]},n)})})}const L0=[{id:"design",label:"Design"},{id:"blueprint",label:"Blueprint"},{id:"execute",label:"Execute"},{id:"review",label:"Review"},{id:"coverage",label:"Coverage"},{id:"ship",label:"Ship"}];function Ud(t,e,r,n){if(r&&r.featureCode===n&&r.currentStep===t)return"active";if(e&&Array.isArray(e)){const i=e.find(s=>s.phase===t||s.step===t);if(i)return i.status==="failed"?"failed":"complete"}return"pending"}function QY({item:t,activeBuild:e}){const[r,n]=C.useState(null),i=(t==null?void 0:t.phaseHistory)||[],s=(t==null?void 0:t.featureCode)||(t==null?void 0:t.text)||"";return h.jsxs("div",{className:"p-3",children:[h.jsx("div",{className:"flex items-center gap-0 mb-3",children:L0.map((o,a)=>{const l=Ud(o.id,i,e,s),c=Yp[l],u=r===o.id;return h.jsxs(Yt.Fragment,{children:[a>0&&h.jsx("div",{className:"flex-1 h-px",style:{background:l==="pending"?"hsl(var(--muted-foreground) / 0.2)":c,minWidth:"8px"}}),h.jsxs("button",{onClick:()=>n(u?null:o.id),className:"relative flex flex-col items-center group",title:o.label,children:[h.jsx("div",{className:["w-3 h-3 rounded-full border-2 transition-all",l==="active"?"animate-pulse":"",u?"ring-2 ring-accent/30":""].join(" "),style:{borderColor:c,background:l==="complete"||l==="failed"?c:"transparent"}}),h.jsx("span",{className:"text-[8px] text-muted-foreground mt-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:o.label})]})]},o.id)})}),h.jsx("div",{className:"flex justify-between px-0.5",children:L0.map(o=>{const a=Ud(o.id,i,e,s);return h.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider",style:{color:a==="pending"?"hsl(var(--muted-foreground) / 0.4)":Yp[a]},children:o.label},o.id)})}),r&&h.jsx("div",{className:"mt-3 p-2 rounded border border-border/50 bg-muted/20",children:h.jsx(JY,{stepId:r,phaseHistory:i,activeBuild:e,featureCode:s})})]})}function JY({stepId:t,phaseHistory:e,activeBuild:r,featureCode:n}){const i=Ud(t,e,r,n),s=e==null?void 0:e.find(a=>a.phase===t||a.step===t),o={complete:"text-success",active:"text-accent",failed:"text-destructive",pending:"text-muted-foreground"};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs font-semibold text-foreground capitalize",children:t}),h.jsx("span",{className:`text-[10px] font-medium ${o[i]}`,children:i})]}),(s==null?void 0:s.summary)&&h.jsx("p",{className:"text-[10px] text-muted-foreground",children:s.summary}),(s==null?void 0:s.durationMs)!=null&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Duration: ",s.durationMs<1e3?`${s.durationMs}ms`:`${(s.durationMs/1e3).toFixed(1)}s`]}),(s==null?void 0:s.agent)&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Agent: ",s.agent]}),i==="active"&&r&&h.jsx("p",{className:"text-[10px] text-accent",children:"Running..."}),i==="pending"&&h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Not started"})]})}function tX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function eX(t){return t?t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(0)}s`:`${(t/6e4).toFixed(1)}m`:"—"}function rX({featureCode:t,sessions:e=[],items:r=[]}){const[n,i]=C.useState(null),s=C.useMemo(()=>t?new Set(r.filter(a=>{var l;return((l=a.lifecycle)==null?void 0:l.featureCode)===t||a.featureCode===t||a.feature_code===t}).map(a=>a.id)):new Set,[t,r]),o=C.useMemo(()=>s.size===0?e.slice(0,20):e.filter(a=>!!(a.featureCode===t||a.itemsWorked&&a.itemsWorked.some(l=>s.has(l))||a.summary&&a.summary.includes(t))),[e,t,s]);return o.length===0?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"No sessions for this feature."}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Sessions (",o.length,")"]}),o.map(a=>{const l=n===a.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>i(l?null:a.id),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-muted/30 transition-colors",children:[h.jsx("span",{className:"text-[10px] font-mono text-accent shrink-0 w-12 truncate",children:a.source||"agent"}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 w-16 truncate",children:a.classification||a.workType||"—"}),h.jsxs("span",{className:"text-[9px] text-muted-foreground tabular-nums flex gap-1.5 shrink-0",children:[h.jsxs("span",{title:"reads",children:[a.reads||0,"r"]}),h.jsxs("span",{title:"writes",children:[a.writes||0,"w"]}),h.jsxs("span",{title:"errors",style:a.errors>0?{color:"hsl(var(--destructive))"}:{},children:[a.errors||0,"e"]})]}),h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:eX(a.durationMs)}),h.jsx("span",{className:"text-[9px] text-muted-foreground ml-auto shrink-0",children:tX(a.startedAt||a.createdAt)})]}),l&&a.summary&&h.jsx("div",{className:"px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/10 rounded mx-1 mb-1",children:a.summary})]},a.id)})]})}function nX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}const wu=10;function iX({featureCode:t,errors:e=[],items:r=[]}){const[n,i]=C.useState(null),[s,o]=C.useState(!1),a=C.useMemo(()=>t?new Set(r.filter(u=>{var d;return((d=u.lifecycle)==null?void 0:d.featureCode)===t||u.featureCode===t||u.feature_code===t}).map(u=>u.id)):new Set,[t,r]),l=C.useMemo(()=>!t&&a.size===0?[]:e.filter(u=>!!(t&&u.featureCode===t||u.itemId&&a.has(u.itemId)||t&&u.message&&u.message.includes(t))),[e,t,a]);if(l.length===0)return h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(HA,{style:{width:20,height:20,color:"hsl(var(--success, 160 60% 45%))"}}),h.jsx("span",{className:"text-[11px] italic",children:"No errors for this feature."})]});const c=s?l:l.slice(0,wu);return h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Errors (",l.length,")"]}),c.map((u,d)=>{const p=n===d;return h.jsxs("button",{onClick:()=>i(p?null:d),className:"flex flex-col w-full px-2 py-1.5 text-left rounded hover:bg-destructive/5 transition-colors",children:[h.jsxs("div",{className:"flex items-center gap-2 w-full",children:[h.jsx("span",{className:"text-[10px] text-destructive shrink-0",children:"✕"}),h.jsx("span",{className:"text-[10px] font-mono text-muted-foreground shrink-0 w-16 truncate",children:u.tool||u.toolName||"unknown"}),h.jsx("span",{className:`text-[10px] text-foreground flex-1 ${p?"":"line-clamp-2"} truncate`,children:u.message||u.error||"Unknown error"}),h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0 ml-auto",children:nX(u.timestamp||u.createdAt)})]}),p&&h.jsx("div",{className:"mt-1.5 px-5 py-1.5 text-[10px] text-foreground font-mono bg-muted/10 rounded whitespace-pre-wrap break-all",children:u.message||u.error||u.stack||"No additional details"})]},d)}),!s&&l.length>wu&&h.jsxs("button",{onClick:()=>o(!0),className:"w-full text-center text-[10px] text-accent hover:underline py-1",children:["Show ",l.length-wu," more"]})]})}function sX(t){return t?t<1024?`${t}B`:t<1048576?`${(t/1024).toFixed(1)}KB`:`${(t/1048576).toFixed(1)}MB`:"—"}function oX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function aX({featureCode:t,onOpenFile:e}){const[r,n]=C.useState([]),[i,s]=C.useState(!0);C.useEffect(()=>{const l=new AbortController;return s(!0),Rt("/api/files",{signal:l.signal}).then(c=>c.json()).then(c=>{l.signal.aborted||(n(Array.isArray(c)?c:c.files||[]),s(!1))}).catch(c=>{l.signal.aborted||(n([]),s(!1))}),()=>l.abort()},[t]);const o=`docs/features/${t}/`,a=C.useMemo(()=>r.filter(l=>(typeof l=="string"?l:l.path||l.name||"").startsWith(o)),[r,o]);return i?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Loading files..."}):a.length===0?h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(Tf,{style:{width:20,height:20,opacity:.5}}),h.jsx("span",{className:"text-[11px] italic",children:"No files in feature folder."})]}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Files (",a.length,")"]}),a.map((l,c)=>{const u=typeof l=="string"?l:l.path||l.name||"",d=u.split("/").pop(),p=typeof l=="object"?l.size:null,f=typeof l=="object"?l.modified||l.mtime:null;return h.jsxs("button",{onClick:()=>e==null?void 0:e(u),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-accent/10 transition-colors",children:[h.jsx(Ei,{className:"h-3 w-3 shrink-0 text-accent"}),h.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:d}),p!=null&&h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:sX(p)}),f&&h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0",children:oX(f)})]},c)})]})}function lX({itemId:t,onSelect:e,onClose:r,onOpenFile:n,onViewInGraph:i,onViewInTree:s}){var w;const{items:o,connections:a,gates:l,updateItem:c,deleteItem:u,createConnection:d,deleteConnection:p,resolveGate:f,activeBuild:m,sessions:x,agentErrors:g}=gr(Li(E=>({items:E.items,connections:E.connections,gates:E.gates,updateItem:E.updateItem,deleteItem:E.deleteItem,createConnection:E.createConnection,deleteConnection:E.deleteConnection,resolveGate:E.resolveGate,activeBuild:E.activeBuild,sessions:E.sessions,agentErrors:E.agentErrors}))),y=o.find(E=>E.id===t)||null,[b,k]=C.useState("overview"),T=((w=y==null?void 0:y.lifecycle)==null?void 0:w.featureCode)||(y==null?void 0:y.featureCode)||(y==null?void 0:y.feature_code)||"",_=C.useMemo(()=>T?g.filter(E=>E.featureCode===T||T&&E.message&&E.message.includes(T)):[],[g,T]);return y?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx(ZY,{activeTab:b,onTabChange:k,errorCount:_.length}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[b==="overview"&&h.jsxs(h.Fragment,{children:[h.jsx(XY,{item:y,items:o,connections:a,gates:l,onUpdate:(E,B)=>c(E,B),onDelete:E=>{u(E),r()},onCreateConnection:d,onDeleteConnection:p,onSelect:e,onClose:r,onPressureTest:()=>{},onResolveGate:f}),h.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 mt-1",style:{borderTop:"1px solid hsl(var(--border))"},children:[i&&h.jsxs("button",{onClick:()=>i(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↑"})," View in Graph"]}),s&&h.jsxs("button",{onClick:()=>s(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↓"})," View in Tree"]})]})]}),b==="pipeline"&&h.jsx(QY,{item:y,activeBuild:m}),b==="sessions"&&h.jsx(rX,{featureCode:T,sessions:x,items:o}),b==="errors"&&h.jsx(iX,{featureCode:T,errors:g,items:o}),b==="files"&&h.jsx(aX,{featureCode:T,onOpenFile:n})]})]}):h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Item not found."})}function cX(t){if(!t)return null;const{retries:e}=t;return e==null?null:Array.isArray(e)?e.length===0?null:{count:e.length,isArray:!0,items:e}:typeof e=="number"&&e>0?{count:e,isArray:!1,items:[]}:null}function hX(t){var e;return(e=t==null?void 0:t.violations)!=null&&e.length?t.violations:[]}function uX(t,e){if(!t)return null;for(const r of t.values())if(r.stepId===e)return r;return null}function dX(t,e,r){var c;if(!t||t.status!=="running")return null;const n=t.startedAt?Date.parse(t.startedAt):r,i=r-n,s=t.wallClockTimeout!=null?t.wallClockTimeout*60*1e3:null,o=(c=e==null?void 0:e.per_loop_type)==null?void 0:c[t.loopType],a=(o==null?void 0:o.maxTotal)!=null?o.usedIterations:null,l=(o==null?void 0:o.maxTotal)??null;return{count:t.count??0,maxIterations:t.maxIterations??null,loopType:t.loopType,elapsedMs:i,timeoutMs:s,usedIterations:a,maxTotal:l}}function fX(t){if(!(t!=null&&t.per_loop_type))return"";const e={review:"r",coverage:"c"},r=[];for(const[n,i]of Object.entries(e)){const s=t.per_loop_type[n];!s||s.maxTotal==null||r.push(`${i} ${s.usedIterations}/${s.maxTotal}`)}return r.join(" · ")}function B0(t){return!t||t<=0?"$0.00":`$${t.toFixed(4)}`}const A0=[{id:"T0",name:"schema",label:"T0"},{id:"T1",name:"lint",label:"T1"},{id:"T2",name:"tests",label:"T2"},{id:"T3",name:"review",label:"T3"},{id:"T4",name:"codex",label:"T4"}];function pX({tierMap:t,tierSummary:e}){const[r,n]=C.useState(null),i=s=>n(o=>o===s?null:s);return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Tier Pipeline"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[A0.map((s,o)=>{var d;const a=t[s.id],l=(d=e==null?void 0:e.tiersSkipped)==null?void 0:d.includes(s.id);let c,u;return l?(c="bg-muted-foreground/40",u=`${s.id} (${s.name}): skipped`):a===!0?(c="bg-success",u=`${s.id} (${s.name}): passed`):a===!1?(c="bg-destructive",u=`${s.id} (${s.name}): failed`):(c="bg-muted-foreground/20",u=`${s.id} (${s.name}): not run`),h.jsxs(Yt.Fragment,{children:[o>0&&h.jsx("div",{className:"h-px w-3 bg-muted-foreground/20 shrink-0"}),h.jsxs("button",{className:"flex flex-col items-center gap-0.5 group",onClick:()=>i(s.id),title:u,children:[h.jsx("div",{className:`w-2.5 h-2.5 rounded-full transition-all group-hover:scale-125 ${c} ${r===s.id?"ring-1 ring-foreground/40":""}`}),h.jsx("span",{className:"text-[8px] text-muted-foreground leading-none",children:s.label})]})]},s.id)}),(e==null?void 0:e.costSaved)>0&&h.jsxs("span",{className:"ml-2 text-[9px] text-success/80",children:["saved ~$",e.costSaved.toFixed(2)]})]}),r&&h.jsx("div",{className:"mt-1.5 px-2 py-1 rounded bg-muted/20 text-[9px] text-muted-foreground",children:(()=>{var l;const s=t[r],o=(l=e==null?void 0:e.tiersSkipped)==null?void 0:l.includes(r),a=A0.find(c=>c.id===r);return o?`${r} (${a==null?void 0:a.name}): skipped — short-circuited by earlier failure`:s===!0?`${r} (${a==null?void 0:a.name}): passed`:s===!1?`${r} (${a==null?void 0:a.name}): failed`:`${r} (${a==null?void 0:a.name}): not run this build`})()})]})}function Su(t){return t>=80?"text-success":t>=60?"text-amber-400":"text-destructive"}function mX(t){return t==="improving"?"↑":t==="declining"?"↓":"→"}const M0={test_coverage:"Tests",review_findings:"Review",contract_compliance:"Contracts",runtime_errors:"Runtime",doc_freshness:"Docs",plan_completion:"Plan"};function I0(t){if(t==null)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function gX({loopState:t,budget:e}){const[r,n]=C.useState(()=>Date.now());C.useEffect(()=>{if(!t||t.status!=="running")return;const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[t]);const i=dX(t,e,r);return i?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Live Counters"}),h.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("span",{className:"text-foreground font-mono font-medium",children:["attempt ",i.count,"/",i.maxIterations??"?"]}),h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:[I0(i.elapsedMs),i.timeoutMs!=null&&h.jsxs("span",{className:"text-muted-foreground",children:[" / ",I0(i.timeoutMs)]})]}),i.usedIterations!=null&&i.maxTotal!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:["cumulative ",i.usedIterations,"/",i.maxTotal]})]})]}),h.jsxs("div",{className:"text-muted-foreground/70 text-[9px]",children:["loop: ",i.loopType]})]})]}):null}function xX({stepId:t,tierEvents:e=[],healthEvents:r=[],capabilityEvents:n=[]}){const{activeBuild:i,iterationStates:s}=gr(Li(P=>({activeBuild:P.activeBuild,iterationStates:P.iterationStates}))),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=(i==null?void 0:i.featureCode)??null,d=C.useRef(null);C.useEffect(()=>{if(!u){c(null);return}u!==d.current&&(d.current=u,Rt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(u)}`).then(P=>P.json()).then(P=>c(P)).catch(()=>{}))},[u]);const{step:p,allSteps:f}=C.useMemo(()=>i!=null&&i.steps?{step:i.steps.find(N=>N.id===t||N.step_id===t)||null,allSteps:i.steps}:{step:null,allSteps:[]},[i,t]),m=C.useMemo(()=>{if(!r||r.length===0)return null;for(let P=r.length-1;P>=0;P--){const N=r[P];if(N.subtype==="health_score"&&typeof N.score=="number")return N}return null},[r]),{tierMap:x,tierSummary:g}=C.useMemo(()=>{if(!e||e.length===0)return{tierMap:{},tierSummary:null};const P={};let N=null;for(const M of e)M.subtype==="gate_tier_result"?P[M.tierId]=M.passed:M.subtype==="gate_tier_summary"&&(N=M);return{tierMap:P,tierSummary:N}},[e]),y=Object.keys(x).length>0||g!==null,b=C.useMemo(()=>{const P=f.filter(N=>N.cost_usd!=null);return P.length===0?[]:[...P].sort((N,M)=>o?(N.cost_usd??0)-(M.cost_usd??0):(M.cost_usd??0)-(N.cost_usd??0))},[f,o]),k=b.length>0?b[0].id:null,T=C.useMemo(()=>cX(p),[p]),_=C.useMemo(()=>hX(p),[p]),w=C.useMemo(()=>uX(s,t),[s,t]),E=C.useMemo(()=>{if(!n||n.length===0)return null;const P=n.filter($=>$.stepId===t);if(P.length===0)return null;const N=P.filter($=>$.severity==="violation").length,M=P.filter($=>$.severity==="warning").length;return{total:P.length,hardViolations:N,warnings:M}},[n,t]);if(!p)return h.jsxs("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:["Step “",t,"” not found in active build."]});const B={done:"text-success",running:"text-accent",failed:"text-destructive",pending:"text-muted-foreground",skipped:"text-muted-foreground"};return h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Step"}),h.jsx("p",{className:"text-sm font-semibold text-foreground font-mono",children:p.id||p.step_id})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Status:"}),h.jsx("span",{className:`text-xs font-medium ${B[p.status]||"text-foreground"}`,children:p.status||"unknown"})]}),T&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Retries"}),h.jsxs("p",{className:"text-xs text-amber-400",children:["Retried ",T.count," ",T.count===1?"time":"times"]}),T.isArray&&T.items.length>0&&h.jsx("div",{className:"mt-1 space-y-0.5",children:T.items.map((P,N)=>h.jsxs("div",{className:"text-[10px] text-muted-foreground pl-2",children:["#",N+1,P.reason?`: ${P.reason}`:""]},N))})]}),p.durationMs!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Duration:"}),h.jsx("span",{className:"text-xs text-foreground",children:p.durationMs<1e3?`${p.durationMs}ms`:p.durationMs<6e4?`${(p.durationMs/1e3).toFixed(1)}s`:`${(p.durationMs/6e4).toFixed(1)}m`})]}),p.summary&&h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Summary:"}),h.jsx("p",{className:"text-xs text-foreground mt-0.5",children:p.summary})]}),p.artifact&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Artifact:"}),h.jsx("span",{className:"text-xs text-foreground font-mono truncate",children:p.artifact})]}),p.agent&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Agent:"}),h.jsx("span",{className:"text-xs text-foreground font-mono",children:p.agent})]}),p.filesChanged&&p.filesChanged.length>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Files Changed (",p.filesChanged.length,")"]}),h.jsx("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:p.filesChanged.map((P,N)=>h.jsx("p",{className:"text-[10px] text-foreground font-mono truncate",children:P},N))})]}),(p.input_tokens>0||p.output_tokens>0||p.cost_usd>0)&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Tokens & Cost"}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Input"}),h.jsx("span",{className:"text-muted-foreground",children:"Output"}),h.jsx("span",{className:"text-muted-foreground",children:"Cost"}),h.jsx("span",{className:"text-foreground font-mono",children:(p.input_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:(p.output_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:B0(p.cost_usd)})]})]}),y&&h.jsx("div",{children:h.jsx(pX,{tierMap:x,tierSummary:g})}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1",children:"Postcondition Violations"}),h.jsx("div",{className:"space-y-0.5",children:_.map((P,N)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:typeof P=="string"?P:P.message||JSON.stringify(P)})]},N))})]}),E&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Capability Findings"}),h.jsxs("p",{className:"text-xs text-amber-400",children:[E.total," ",E.total===1?"finding":"findings"," ","(",E.hardViolations," ",E.hardViolations===1?"violation":"violations",","," ",E.warnings," ",E.warnings===1?"warning":"warnings",")"]})]}),(w==null?void 0:w.status)==="running"&&h.jsx(gX,{loopState:w,budget:l}),m!=null&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Health Score"}),h.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[h.jsx("span",{className:`text-2xl font-bold font-mono tabular-nums ${Su(m.score)}`,children:m.score}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"/100"}),m.trend&&h.jsxs("span",{className:`text-sm font-mono ${Su(m.score)}`,children:[mX(m.trend.direction),m.trend.delta!=null&&h.jsxs("span",{className:"text-[10px] ml-0.5",children:[m.trend.delta>0?"+":"",Math.round(m.trend.delta)]})]})]}),m.breakdown&&Object.keys(m.breakdown).length>0&&h.jsxs("div",{className:"space-y-1",children:[Object.entries(m.breakdown).map(([P,N])=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[9px] text-muted-foreground w-16 shrink-0",children:M0[P]??P}),h.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted-foreground/20 overflow-hidden",children:h.jsx("div",{className:`h-full rounded-full transition-all ${N>=80?"bg-success":N>=60?"bg-amber-400":"bg-destructive"}`,style:{width:`${N}%`}})}),h.jsx("span",{className:`text-[9px] font-mono w-6 text-right ${Su(N)}`,children:N})]},P)),m.missing&&m.missing.length>0&&h.jsxs("p",{className:"text-[9px] text-muted-foreground/60 mt-0.5",children:["No data: ",m.missing.map(P=>M0[P]??P).join(", ")]})]})]}),b.length>1&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Build Cost Breakdown"}),h.jsx("button",{className:"text-[9px] text-muted-foreground hover:text-foreground transition-colors",onClick:()=>a(P=>!P),children:o?"cost asc":"cost desc"})]}),h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-[10px] border-collapse",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-muted-foreground",children:[h.jsx("th",{className:"text-left pr-2 pb-0.5 font-medium",children:"Step"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"In"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"Out"}),h.jsx("th",{className:"text-right pb-0.5 font-medium",children:"Cost"}),h.jsx("th",{className:"text-right pb-0.5 pl-2 font-medium",children:"Dur"})]})}),h.jsx("tbody",{children:b.map(P=>{const N=P.id===k,M=P.id===t,$=P.durationMs!=null?P.durationMs<1e3?`${P.durationMs}ms`:P.durationMs<6e4?`${(P.durationMs/1e3).toFixed(1)}s`:`${(P.durationMs/6e4).toFixed(1)}m`:"—";return h.jsxs("tr",{className:`${N?"text-amber-400":"text-foreground"} ${M?"font-semibold":""}`,children:[h.jsx("td",{className:"pr-2 py-0.5 font-mono truncate max-w-[80px]",children:P.id}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.input_tokens??0)/1e3).toFixed(1),"k"]}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.output_tokens??0)/1e3).toFixed(1),"k"]}),h.jsx("td",{className:"text-right py-0.5 font-mono",children:B0(P.cost_usd)}),h.jsx("td",{className:"text-right pl-2 py-0.5 text-muted-foreground",children:$})]},P.id)})})]})})]})]})}function VT(t){const e=[],r=/```decision\n([\s\S]*?)```/g;let n=0,i;for(;(i=r.exec(t))!==null;){i.index>n&&e.push({type:"text",content:t.slice(n,i.index)});const s=i[1].trim();try{e.push({type:"decision",content:JSON.parse(s)})}catch{e.push({type:"text",content:s})}n=i.index+i[0].length}return n<t.length&&e.push({type:"text",content:t.slice(n)}),e.length===0&&e.push({type:"text",content:t}),{parts:e}}function F0(t,e){var l;const r=(e||[]).filter(c=>!c.superseded);if(r.length===0)return"";let n=`# Design Document
718
718
 
719
719
  `;const i=(t||[]).filter(c=>c.role==="human"&&c.type==="text").slice(0,3);i.length>0&&(n+=`## Problem
720
720
 
@@ -765,4 +765,4 @@ ${t.source||"Internal idea"}
765
765
 
766
766
  ${t.mapsTo?`- Maps to: ${t.mapsTo}`:"- TBD"}
767
767
  `.trimStart()}function pK({step:t,current:e}){const r=e>t,n=e===t;return h.jsx("div",{className:"flex items-center gap-1.5",children:h.jsx("div",{className:rt("w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-semibold border transition-colors",r?"bg-emerald-400/20 border-emerald-400/60 text-emerald-400":n?"bg-accent/20 border-accent/60 text-accent":"bg-muted border-border/40 text-muted-foreground/40"),children:r?h.jsx(da,{className:"w-3 h-3"}):t})})}function mK({idea:t,onClose:e}){var _;const{promoteIdea:r}=As(),[n,i]=C.useState(1),[s,o]=C.useState(()=>V0(t)),[a,l]=C.useState(""),[c,u]=C.useState(""),[d,p]=C.useState(!1),[f,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>{u(fK(t,s||"FEAT-?"))},[t,s]),C.useEffect(()=>{n===1&&setTimeout(()=>{var w;return(w=x.current)==null?void 0:w.focus()},50)},[n]);const g=()=>s.trim()?/^[A-Z0-9][A-Z0-9-]*[A-Z0-9]$/i.test(s.trim())?(l(""),!0):(l("Use format like FEAT-1 or COMP-UI-5"),!1):(l("Feature code is required"),!1),y=()=>{n===1&&!g()||i(w=>w+1)},b=()=>i(w=>w-1),k=async()=>{if(!d){p(!0);try{await r(t.id,s.trim().toUpperCase()),m({featureCode:s.trim().toUpperCase()}),i(4)}catch(w){l(w.message||"Failed to promote"),i(1)}finally{p(!1)}}},T=["Feature ID","Preview","Confirm"];return h.jsx(qp,{open:!0,onOpenChange:w=>!w&&e(),children:h.jsxs(sh,{className:"max-w-lg",children:[h.jsx(oh,{children:h.jsxs(ah,{className:"flex items-center gap-2",children:[h.jsx(xi,{className:"w-4 h-4 text-amber-400"}),"Promote to Feature"]})}),n<4&&h.jsx("div",{className:"px-6 -mt-1 mb-1",children:h.jsx("div",{className:"flex items-center gap-2",children:[1,2,3].map((w,E)=>h.jsxs(Yt.Fragment,{children:[h.jsx(pK,{step:w,current:n}),h.jsx("span",{className:rt("text-[10px] transition-colors",n===w?"text-foreground font-medium":"text-muted-foreground/60"),children:T[E]}),E<2&&h.jsx(js,{className:"w-3 h-3 text-muted-foreground/30 mx-0.5"})]},w))})}),h.jsxs("div",{className:"px-6 pb-2",children:[n<4&&h.jsxs("div",{className:"mb-4 px-3 py-2 rounded border border-border/50 bg-muted/20",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono opacity-70",children:t.id}),t.priority&&t.priority!=="—"&&h.jsx("span",{className:rt("text-[9px] px-1 py-0.5 rounded font-mono font-semibold",t.priority==="P0"?"text-red-400":t.priority==="P1"?"text-amber-400":"text-blue-400"),children:t.priority})]}),h.jsx("p",{className:"text-[12px] text-foreground font-medium leading-snug",children:t.title})]}),n===1&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("label",{className:"block",children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold block mb-1.5",children:"Feature Code"}),h.jsx("input",{ref:x,type:"text",value:s,onChange:w=>{o(w.target.value.toUpperCase()),l("")},onKeyDown:w=>{w.key==="Enter"&&y()},placeholder:"e.g. COMP-UI-5",className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring font-mono"}),a&&h.jsx("p",{className:"text-[11px] text-destructive mt-1",children:a})]}),t.cluster&&h.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:["Suggested from cluster: ",h.jsx("span",{className:"text-muted-foreground",children:t.cluster})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold mb-1.5",children:"Suggestions"}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:[V0(t),`COMP-${(((_=t.tags)==null?void 0:_[0])||"FEAT").replace("#","").toUpperCase()}-1`].filter((w,E,B)=>B.indexOf(w)===E).map(w=>h.jsx("button",{onClick:()=>{o(w),l("")},className:rt("text-[10px] px-2 py-1 rounded border font-mono transition-colors",s===w?"bg-accent/10 border-accent/60 text-accent":"border-border/40 text-muted-foreground hover:border-border hover:text-foreground"),children:w},w))})]})]}),n===2&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Generated plan.md stub"}),h.jsx("pre",{className:"text-[10px] font-mono text-muted-foreground bg-muted/40 border border-border/40 rounded p-3 overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed",children:c}),h.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:"This stub will be created when you run the promote workflow from the CLI."})]}),n===3&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["Promote ",h.jsx("span",{className:"text-foreground font-medium",children:t.id})," to feature"," ",h.jsx("span",{className:"font-mono text-accent font-semibold",children:s}),"?"]}),h.jsxs("p",{className:"text-[11px] text-muted-foreground/70",children:["The idea will be marked ",h.jsxs("span",{className:"font-mono",children:["PROMOTED (",s,")"]})," in the ideabox."]})]}),n===4&&f&&h.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-center",children:[h.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-400/20 flex items-center justify-center",children:h.jsx(da,{className:"w-5 h-5 text-emerald-400"})}),h.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Promoted!"}),h.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[t.id," is now linked to feature"," ",h.jsx("span",{className:"font-mono text-accent font-semibold",children:f.featureCode})]}),h.jsx($t,{size:"sm",onClick:e,className:"mt-1",children:"Close"})]})]}),n<4&&h.jsxs(Hp,{children:[n>1&&h.jsxs($t,{variant:"ghost",size:"sm",onClick:b,disabled:d,children:[h.jsx(xb,{className:"w-3 h-3 mr-1"}),"Back"]}),h.jsx($t,{variant:"ghost",size:"sm",onClick:e,disabled:d,children:"Cancel"}),n<3?h.jsxs($t,{size:"sm",onClick:y,children:["Next",h.jsx(js,{className:"w-3 h-3 ml-1"})]}):h.jsx($t,{size:"sm",onClick:k,disabled:d,children:d?"Promoting…":"Promote"})]})]})})}const Kd=["S","M","L"],gK=["high","medium","low"],xK={"high-S":"Quick Wins","high-M":"Quick Wins","high-L":"Big Bets","medium-S":"Fill-ins","medium-M":"Fill-ins","medium-L":"Money Pits","low-S":"Fill-ins","low-M":"Fill-ins","low-L":"Money Pits"},Y0={"Quick Wins":"bg-emerald-400/8 border-emerald-400/20","Big Bets":"bg-blue-400/8 border-blue-400/20","Fill-ins":"bg-amber-400/8 border-amber-400/20","Money Pits":"bg-red-400/8 border-red-400/20"},X0=["bg-blue-400","bg-violet-400","bg-emerald-400","bg-amber-400","bg-rose-400","bg-cyan-400","bg-orange-400","bg-pink-400"];function yK({idea:t,onSubmit:e,onCancel:r}){const[n,i]=C.useState(t.effort||""),[s,o]=C.useState(t.impact||"");return h.jsxs("div",{className:"p-2 bg-card border border-border rounded-lg shadow-md w-52",children:[h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-2 truncate font-medium",children:[t.id,": ",t.title]}),h.jsxs("div",{className:"mb-2",children:[h.jsx("p",{className:"text-[9px] uppercase tracking-wider text-muted-foreground mb-1",children:"Effort"}),h.jsx("div",{className:"flex gap-1",children:Kd.map(a=>h.jsx("button",{onClick:()=>i(a),className:rt("flex-1 text-[10px] py-0.5 rounded border transition-colors",n===a?"bg-primary/20 border-primary/50 text-primary":"border-border/40 text-muted-foreground hover:border-border"),children:a},a))})]}),h.jsxs("div",{className:"mb-2.5",children:[h.jsx("p",{className:"text-[9px] uppercase tracking-wider text-muted-foreground mb-1",children:"Impact"}),h.jsx("div",{className:"flex gap-1",children:["high","medium","low"].map(a=>h.jsx("button",{onClick:()=>o(a),className:rt("flex-1 text-[9px] py-0.5 rounded border transition-colors capitalize",s===a?"bg-primary/20 border-primary/50 text-primary":"border-border/40 text-muted-foreground hover:border-border"),children:a},a))})]}),h.jsxs("div",{className:"flex gap-1",children:[h.jsx("button",{onClick:r,className:"flex-1 text-[10px] py-1 rounded border border-border/40 text-muted-foreground hover:border-border transition-colors",children:"Cancel"}),h.jsx("button",{onClick:()=>n&&s&&e(t.id,{effort:n,impact:s}),disabled:!n||!s,className:"flex-1 text-[10px] py-1 rounded border border-primary/50 bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-40 transition-colors",children:"Save"})]})]})}function bK({ideas:t,selectedIdeaId:e,onSelectIdea:r,onUpdateIdea:n}){const[i,s]=C.useState(null),o=C.useMemo(()=>{const u=[...new Set(t.map(p=>p.cluster||"__none__"))],d={};return u.forEach((p,f)=>{d[p]=X0[f%X0.length]}),d},[t]),a=C.useMemo(()=>t.filter(u=>u.effort&&u.impact),[t]),l=C.useMemo(()=>t.filter(u=>!u.effort||!u.impact),[t]),c=C.useCallback(async(u,d)=>{await n(u,d),s(null)},[n]);return h.jsxs("div",{className:"flex flex-col gap-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"flex mb-1 ml-12",children:Kd.map(u=>h.jsx("div",{className:"flex-1 text-center text-[10px] text-muted-foreground font-medium uppercase tracking-wider",children:u},u))}),gK.map(u=>h.jsxs("div",{className:"flex mb-1",children:[h.jsx("div",{className:"w-12 shrink-0 flex items-center justify-end pr-2",children:h.jsx("span",{className:"text-[9px] text-muted-foreground capitalize",children:u})}),Kd.map(d=>{const p=`${u}-${d}`,f=xK[p],m=a.filter(x=>x.impact===u&&x.effort===d);return h.jsxs("div",{className:rt("flex-1 min-h-[90px] rounded border p-1.5 mr-1 relative transition-colors",Y0[f]||"border-border/30"),children:[h.jsx("span",{className:"absolute top-1 right-1 text-[8px] text-muted-foreground/50 italic",children:f}),h.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:m.map(x=>{const g=o[x.cluster||"__none__"]||"bg-muted-foreground",y=x.id===e;return h.jsx("button",{onClick:()=>r==null?void 0:r(x.id),title:`${x.id}: ${x.title}`,className:rt("w-5 h-5 rounded-full border-2 transition-all hover:scale-110 flex items-center justify-center",g,y?"border-foreground ring-1 ring-foreground":"border-transparent")},x.id)})})]},d)})]},u)),h.jsx("div",{className:"flex ml-12",children:h.jsx("div",{className:"flex-1 text-center text-[9px] text-muted-foreground/60 mt-0.5",children:"Effort (S = small, M = medium, L = large)"})})]}),h.jsx("div",{className:"flex flex-wrap gap-3 text-[10px]",children:Object.entries(Y0).map(([u,d])=>h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("div",{className:rt("w-2.5 h-2.5 rounded-sm border",d)}),h.jsx("span",{className:"text-muted-foreground",children:u})]},u))}),l.length>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-2",children:["Unassigned (",l.length,") — click to assign effort/impact"]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(u=>h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>s((i==null?void 0:i.id)===u.id?null:u),className:rt("text-[10px] px-2 py-1 rounded border transition-colors",(i==null?void 0:i.id)===u.id?"border-accent bg-accent/10 text-foreground":"border-border/50 text-muted-foreground hover:border-border hover:text-foreground"),children:[h.jsx("span",{className:"font-mono text-[9px] mr-1 opacity-60",children:u.id}),u.title.slice(0,30),u.title.length>30?"…":""]}),(i==null?void 0:i.id)===u.id&&h.jsx("div",{className:"absolute left-0 top-full mt-1 z-10",children:h.jsx(yK,{idea:u,onSubmit:c,onCancel:()=>s(null)})})]},u.id))})]})]})}function Eu({value:t,max:e,color:r="bg-primary/60"}){const n=e>0?Math.round(t/e*100):0;return h.jsx("div",{className:"flex-1 h-1.5 bg-muted/50 rounded-full overflow-hidden",children:h.jsx("div",{className:rt("h-full rounded-full transition-all",r),style:{width:`${n}%`}})})}function CK({ideas:t,killed:e}){const[r,n]=C.useState(!1),i=C.useMemo(()=>{var b,k,T,_;const s=[...t,...e||[]],o={};for(const w of s){const E=((b=w.source)==null?void 0:b.trim())||"(no source)",B=E.length>30?E.slice(0,30)+"…":E;o[B]=(o[B]||0)+1}const a=Object.entries(o).sort((w,E)=>E[1]-w[1]).slice(0,6),l=((k=a[0])==null?void 0:k[1])||1,c=s.filter(w=>w.status==="NEW").length,u=s.filter(w=>w.status==="DISCUSSING").length,d=s.filter(w=>{var E;return(E=w.status)==null?void 0:E.startsWith("PROMOTED")}).length,p=(e||[]).length,f=t.length,m=s.length>0?Math.round(p/s.length*100):0,x={};for(const w of s){const E=w.cluster||"(unclustered)";x[E]||(x[E]={total:0,promoted:0}),x[E].total+=1,(T=w.status)!=null&&T.startsWith("PROMOTED")&&(x[E].promoted+=1)}const g=Object.entries(x).sort((w,E)=>E[1].total-w[1].total).slice(0,5),y=((_=g[0])==null?void 0:_[1].total)||1;return{sourceEntries:a,maxSourceCount:l,newCount:c,discussingCount:u,promotedCount:d,killedCount:p,killRate:m,totalActive:f,clusterEntries:g,maxClusterTotal:y}},[t,e]);return t.length===0&&(!e||e.length===0)?null:h.jsxs("div",{className:"mt-1.5",children:[h.jsxs("button",{onClick:()=>n(s=>!s),className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[r?h.jsx(fa,{className:"w-3 h-3"}):h.jsx(js,{className:"w-3 h-3"}),h.jsx(DA,{className:"w-3 h-3"}),h.jsx("span",{children:"Analytics"})]}),r&&h.jsxs("div",{className:"mt-2 space-y-3 border border-border/30 rounded-lg p-3 bg-muted/10",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] uppercase tracking-wider text-muted-foreground mb-1.5 font-semibold",children:"Status Funnel"}),h.jsx("div",{className:"space-y-1",children:[{label:"NEW",count:i.newCount,color:"bg-emerald-400/60"},{label:"DISCUSSING",count:i.discussingCount,color:"bg-amber-400/60"},{label:"PROMOTED",count:i.promotedCount,color:"bg-blue-400/60"},{label:"KILLED",count:i.killedCount,color:"bg-muted-foreground/40"}].map(({label:s,count:o,color:a})=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-16 text-[9px] text-muted-foreground shrink-0",children:s}),h.jsx(Eu,{value:o,max:Math.max(i.newCount,i.discussingCount,i.promotedCount,i.killedCount,1),color:a}),h.jsx("span",{className:"w-5 text-right text-[9px] text-muted-foreground shrink-0",children:o})]},s))}),i.killRate>0&&h.jsxs("p",{className:"text-[9px] text-muted-foreground/60 mt-1",children:["Kill rate: ",i.killRate,"%"]})]}),i.sourceEntries.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] uppercase tracking-wider text-muted-foreground mb-1.5 font-semibold",children:"By Source"}),h.jsx("div",{className:"space-y-1",children:i.sourceEntries.map(([s,o])=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-24 text-[9px] text-muted-foreground truncate shrink-0",title:s,children:s}),h.jsx(Eu,{value:o,max:i.maxSourceCount,color:"bg-violet-400/50"}),h.jsx("span",{className:"w-5 text-right text-[9px] text-muted-foreground shrink-0",children:o})]},s))})]}),i.clusterEntries.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] uppercase tracking-wider text-muted-foreground mb-1.5 font-semibold",children:"Cluster Health"}),h.jsx("div",{className:"space-y-1",children:i.clusterEntries.map(([s,{total:o,promoted:a}])=>{const l=o>0?Math.round(a/o*100):0;return h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-24 text-[9px] text-muted-foreground truncate shrink-0",title:s,children:s}),h.jsx(Eu,{value:o,max:i.maxClusterTotal,color:"bg-cyan-400/50"}),h.jsx("span",{className:"w-5 text-right text-[9px] text-muted-foreground shrink-0",children:o}),l>0&&h.jsxs("span",{className:"text-[9px] text-blue-400 shrink-0",children:[l,"%"]})]},s)})})]})]})]})}const kK=[{key:"—",label:"Untriaged",color:"text-muted-foreground",bg:"bg-muted/20",border:"border-border/50"},{key:"P0",label:"P0",color:"text-red-400",bg:"bg-red-400/10",border:"border-red-400/30"},{key:"P1",label:"P1",color:"text-amber-400",bg:"bg-amber-400/10",border:"border-amber-400/30"},{key:"P2",label:"P2",color:"text-blue-400",bg:"bg-blue-400/10",border:"border-blue-400/30"}];function K0(t){return t==="P0"?0:t==="P1"?1:t==="P2"?2:3}function t_({status:t}){const e=t==="NEW"?"bg-emerald-400":t==="DISCUSSING"?"bg-amber-400":t!=null&&t.startsWith("PROMOTED")?"bg-blue-400":"bg-muted-foreground/40";return h.jsx("span",{className:rt("inline-block w-2 h-2 rounded-full shrink-0",e),title:t})}function vK({priority:t}){if(!t||t==="—")return h.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded border border-border/40 text-muted-foreground/60",children:"untriaged"});const e={P0:"bg-red-400/15 text-red-400 border-red-400/30",P1:"bg-amber-400/15 text-amber-400 border-amber-400/30",P2:"bg-blue-400/15 text-blue-400 border-blue-400/30"};return h.jsx("span",{className:rt("text-[9px] px-1.5 py-0.5 rounded border font-mono font-semibold",e[t]||"border-border/40 text-muted-foreground"),children:t})}function wK({idea:t,selected:e,onClick:r,onDragStart:n,onDragEnd:i}){var s;return h.jsxs("div",{draggable:!0,onDragStart:o=>n==null?void 0:n(o,t.id),onDragEnd:i,onClick:()=>r==null?void 0:r(t.id),className:rt("group px-3 py-2.5 rounded border cursor-pointer transition-colors select-none","hover:border-accent/50",e?"border-accent/60 bg-accent/5":"border-border/50 bg-card/60"),children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono shrink-0",children:t.id}),h.jsx(t_,{status:t.status}),h.jsx("div",{className:"flex-1"}),h.jsx(vK,{priority:t.priority})]}),h.jsx("p",{className:"text-[12px] text-foreground font-medium leading-snug mb-1 line-clamp-2",children:t.title}),((s=t.tags)==null?void 0:s.length)>0&&h.jsxs("div",{className:"flex flex-wrap gap-1 mb-1",children:[t.tags.slice(0,4).map(o=>h.jsx("span",{className:"text-[9px] text-muted-foreground/70 font-mono",children:o},o)),t.tags.length>4&&h.jsxs("span",{className:"text-[9px] text-muted-foreground/50",children:["+",t.tags.length-4]})]}),t.source&&h.jsx("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:t.source})]})}function SK({idea:t,onClose:e,onPromote:r,onKill:n,onSetPriority:i,onAddDiscussion:s}){var y,b,k,T;const[o,a]=C.useState(""),[l,c]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(""),[m,x]=C.useState(!1);if(!t)return null;const g=async()=>{const _=p.trim();if(_){x(!0);try{await s(t.id,"human",_),f("")}finally{x(!1)}}};return h.jsxs("div",{className:"w-80 border-l border-border flex flex-col shrink-0 overflow-hidden",children:[h.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:t.id}),h.jsx(t_,{status:t.status}),h.jsx("span",{className:"text-[11px] text-muted-foreground flex-1 truncate",children:t.status}),h.jsx("button",{onClick:e,className:"text-muted-foreground/60 hover:text-foreground text-xs px-1",children:"x"})]}),h.jsxs("div",{className:"flex-1 overflow-auto p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Title"}),h.jsx("p",{className:"text-[13px] text-foreground font-medium leading-snug",children:t.title})]}),t.description&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Description"}),h.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:t.description})]}),t.source&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Source"}),h.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.source})]}),t.cluster&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Cluster"}),h.jsx("p",{className:"text-[11px] text-muted-foreground",children:t.cluster})]}),((y=t.tags)==null?void 0:y.length)>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Tags"}),h.jsx("div",{className:"flex flex-wrap gap-1",children:t.tags.map(_=>h.jsx("span",{className:"text-[10px] bg-muted/50 px-1.5 py-0.5 rounded font-mono text-muted-foreground",children:_},_))})]}),t.mapsTo&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Maps To"}),h.jsx("p",{className:"text-[11px] text-muted-foreground font-mono",children:t.mapsTo})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5 flex items-center gap-1",children:[h.jsx(Bc,{className:"w-3 h-3"}),"Discussion",((b=t.discussion)==null?void 0:b.length)>0&&h.jsxs("span",{className:"text-muted-foreground/50",children:["(",t.discussion.length,")"]})]}),((k=t.discussion)==null?void 0:k.length)>0&&h.jsx("div",{className:"space-y-1.5 mb-2",children:t.discussion.map((_,w)=>h.jsxs("div",{className:"px-2 py-1.5 rounded bg-muted/30 border border-border/30",children:[h.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[h.jsx("span",{className:rt("text-[9px] font-mono font-semibold",_.author==="agent"?"text-blue-400":"text-emerald-400"),children:_.author}),h.jsx("span",{className:"text-[9px] text-muted-foreground/50",children:_.date})]}),h.jsx("p",{className:"text-[10px] text-muted-foreground leading-relaxed",children:_.text})]},w))}),h.jsxs("div",{className:"flex gap-1.5 items-end",children:[h.jsx("input",{type:"text",placeholder:"Add comment…",value:p,onChange:_=>f(_.target.value),onKeyDown:_=>_.key==="Enter"&&!_.shiftKey&&g(),className:"flex-1 text-[11px] bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none focus:border-ring",disabled:m}),h.jsx("button",{onClick:g,disabled:!p.trim()||m,className:"shrink-0 p-1.5 rounded border border-border/50 text-muted-foreground hover:text-foreground disabled:opacity-40 transition-colors",children:h.jsx(_f,{className:"w-3 h-3"})})]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1.5",children:"Priority"}),h.jsx("div",{className:"flex gap-1.5",children:["P0","P1","P2","—"].map(_=>h.jsx("button",{onClick:()=>i(t.id,_),className:rt("flex-1 text-[10px] px-1.5 py-1 rounded border transition-colors",t.priority===_?_==="P0"?"bg-red-400/20 text-red-400 border-red-400/50":_==="P1"?"bg-amber-400/20 text-amber-400 border-amber-400/50":_==="P2"?"bg-blue-400/20 text-blue-400 border-blue-400/50":"bg-muted text-muted-foreground border-border":"border-border/40 text-muted-foreground hover:border-border"),children:_==="—"?"none":_},_))})]})]}),!((T=t.status)!=null&&T.startsWith("PROMOTED"))&&t.status!=="KILLED"&&h.jsxs("div",{className:"p-3 border-t border-border space-y-2",children:[h.jsx($t,{size:"sm",className:"w-full h-7 text-[11px]",onClick:()=>r(t),children:"Promote to Feature"}),l?h.jsxs("div",{className:"space-y-1.5",children:[h.jsx("input",{autoFocus:!0,type:"text",placeholder:"Reason for killing…",value:o,onChange:_=>a(_.target.value),className:"w-full text-[11px] bg-muted text-foreground px-2 py-1.5 rounded border border-border outline-none focus:border-ring"}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsx($t,{size:"sm",variant:"outline",className:"flex-1 h-7 text-[10px]",onClick:()=>{c(!1),a("")},children:"Cancel"}),h.jsx($t,{size:"sm",className:"flex-1 h-7 text-[10px] bg-destructive/80 hover:bg-destructive text-destructive-foreground",onClick:()=>{n(t.id,o),c(!1),a("")},children:"Confirm Kill"})]})]}):h.jsx($t,{size:"sm",variant:"outline",className:"w-full h-7 text-[11px] text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>c(!0),children:"Kill"})]})]})}function TK({killed:t,onResurrect:e}){const[r,n]=C.useState(!1);return t.length===0?null:h.jsxs("div",{className:"mt-4 border border-border/40 rounded-lg overflow-hidden",children:[h.jsxs("button",{onClick:()=>n(i=>!i),className:"w-full flex items-center gap-2 px-4 py-2.5 bg-muted/30 hover:bg-muted/50 transition-colors text-left",children:[r?h.jsx(fa,{className:"w-3 h-3 text-muted-foreground"}):h.jsx(js,{className:"w-3 h-3 text-muted-foreground"}),h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Graveyard"}),h.jsxs("span",{className:"text-[10px] text-muted-foreground/60 ml-1",children:["(",t.length,")"]})]}),r&&h.jsx("div",{className:"p-3 grid grid-cols-1 gap-2 bg-muted/10",children:t.map(i=>h.jsx("div",{className:"px-3 py-2 rounded border border-border/40 bg-card/40",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono shrink-0 opacity-60",children:i.id}),h.jsx("p",{className:"text-[11px] text-muted-foreground/70 line-clamp-1 font-medium",children:i.title})]}),i.killedDate&&h.jsxs("p",{className:"text-[10px] text-muted-foreground/50",children:["Killed ",i.killedDate,i.killedReason?` — ${i.killedReason}`:""]})]}),h.jsx("button",{onClick:()=>e(i.id),className:"shrink-0 text-[10px] text-muted-foreground/60 hover:text-foreground border border-border/40 px-1.5 py-0.5 rounded transition-colors",title:"Resurrect",children:"Resurrect"})]})},i.id))})]})}function _K(){const{ideas:t,killed:e,loading:r,error:n,selectedIdeaId:i,filters:s,hydrate:o,setPriority:a,killIdea:l,resurrectIdea:c,setSelectedIdea:u,updateFilters:d,addDiscussion:p,updateIdea:f}=As(),[m,x]=C.useState(!1),[g,y]=C.useState(null),[b,k]=C.useState(null),[T,_]=C.useState(null),[w,E]=C.useState("cards"),B=C.useMemo(()=>{var K;const D=t.filter(F=>F.status==="NEW").length,R=t.filter(F=>!F.priority||F.priority==="—").length,j=t.filter(F=>F.priority==="P0").length,S={};t.filter(F=>F.priority==="P0"&&F.cluster).forEach(F=>{S[F.cluster]=(S[F.cluster]||0)+1});const W=((K=Object.entries(S).sort((F,ht)=>ht[1]-F[1])[0])==null?void 0:K[0])??null;return{newCount:D,untriaged:R,p0Count:j,topCluster:W}},[t]),P=C.useMemo(()=>{const D=new Set;return t.forEach(R=>(R.tags||[]).forEach(j=>D.add(j))),[...D].sort()},[t]),N=C.useMemo(()=>t.filter(D=>{var R;if(s.tag&&!((R=D.tags)!=null&&R.includes(s.tag))||s.status&&(D.status||"").split(/\s+/)[0]!==s.status||s.priority&&D.priority!==s.priority)return!1;if(s.search){const j=s.search.toLowerCase();if(!`${D.title} ${D.description} ${D.id} ${(D.tags||[]).join(" ")}`.toLowerCase().includes(j))return!1}return!0}),[t,s]),M=C.useMemo(()=>{const D=new Map,R=[];N.forEach(W=>{W.cluster?(D.has(W.cluster)||D.set(W.cluster,[]),D.get(W.cluster).push(W)):R.push(W)});const j=W=>[...W].sort((K,F)=>K0(K.priority)-K0(F.priority)),S=[];for(const[W,K]of D)S.push({cluster:W,ideas:j(K)});return R.length>0&&S.push({cluster:null,ideas:j(R)}),S},[N]),$=C.useMemo(()=>t.find(D=>D.id===i)||e.find(D=>D.id===i)||null,[t,e,i]),q=C.useCallback((D,R)=>{k(R),D.dataTransfer.effectAllowed="move"},[]),O=C.useCallback(()=>{k(null),_(null)},[]),I=C.useCallback((D,R)=>{D.preventDefault(),D.dataTransfer.dropEffect="move",_(R)},[]),A=C.useCallback(async(D,R)=>{D.preventDefault(),b&&await a(b,R),k(null),_(null)},[b,a]);return h.jsxs("div",{className:"flex-1 flex flex-row overflow-hidden",children:[h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[h.jsxs("div",{className:"px-4 py-2.5 border-b border-border shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx(xi,{className:"w-4 h-4 text-amber-400 shrink-0"}),h.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Ideabox"}),r&&h.jsx(Fl,{className:"w-3 h-3 text-muted-foreground animate-spin"}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center gap-0.5 border border-border/50 rounded-md p-0.5",children:[h.jsx("button",{onClick:()=>E("cards"),className:rt("text-[10px] px-2 py-0.5 rounded transition-colors",w==="cards"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:"Cards"}),h.jsx("button",{onClick:()=>E("matrix"),className:rt("text-[10px] px-2 py-0.5 rounded transition-colors",w==="matrix"?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),children:"Matrix"})]}),h.jsx("button",{onClick:()=>o(),className:"text-[10px] text-muted-foreground/60 hover:text-muted-foreground transition-colors",title:"Refresh",children:h.jsx(Fl,{className:"w-3 h-3"})}),h.jsxs($t,{size:"sm",variant:"outline",className:"h-6 text-[10px] gap-1",onClick:()=>x(!0),disabled:B.untriaged===0,children:["Triage (",B.untriaged,")"]})]}),h.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-muted-foreground",children:[B.newCount>0&&h.jsxs("span",{className:"text-emerald-400",children:[B.newCount," new"]}),h.jsxs("span",{children:[B.untriaged," untriaged"]}),B.p0Count>0&&h.jsxs("span",{className:"text-red-400",children:[B.p0Count," P0"]}),B.topCluster&&h.jsxs("span",{children:["top cluster: ",h.jsx("span",{className:"text-foreground",children:B.topCluster})]}),h.jsxs("span",{className:"text-muted-foreground/40",children:[t.length," total"]})]}),h.jsx(CK,{ideas:t,killed:e})]}),h.jsxs("div",{className:"px-4 py-2 border-b border-border shrink-0 flex items-center gap-2 flex-wrap",children:[h.jsx(iM,{className:"w-3 h-3 text-muted-foreground/60 shrink-0"}),h.jsxs("select",{value:s.tag,onChange:D=>d({tag:D.target.value}),className:"text-[11px] bg-muted text-foreground px-2 py-1 rounded border border-border/50 cursor-pointer h-6",children:[h.jsx("option",{value:"",children:"All tags"}),P.map(D=>h.jsx("option",{value:D,children:D},D))]}),h.jsxs("select",{value:s.status,onChange:D=>d({status:D.target.value}),className:"text-[11px] bg-muted text-foreground px-2 py-1 rounded border border-border/50 cursor-pointer h-6",children:[h.jsx("option",{value:"",children:"All statuses"}),h.jsx("option",{value:"NEW",children:"New"}),h.jsx("option",{value:"DISCUSSING",children:"Discussing"}),h.jsx("option",{value:"PROMOTED",children:"Promoted"})]}),h.jsxs("select",{value:s.priority,onChange:D=>d({priority:D.target.value}),className:"text-[11px] bg-muted text-foreground px-2 py-1 rounded border border-border/50 cursor-pointer h-6",children:[h.jsx("option",{value:"",children:"All priorities"}),h.jsx("option",{value:"P0",children:"P0"}),h.jsx("option",{value:"P1",children:"P1"}),h.jsx("option",{value:"P2",children:"P2"}),h.jsx("option",{value:"—",children:"Untriaged"})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-[120px]",children:[h.jsx(Zn,{className:"w-3 h-3 text-muted-foreground/60 shrink-0"}),h.jsx("input",{type:"text",placeholder:"Search…",value:s.search,onChange:D=>d({search:D.target.value}),className:"flex-1 text-[11px] bg-transparent text-foreground outline-none placeholder:text-muted-foreground/40 min-w-0"})]}),(s.tag||s.status||s.priority||s.search)&&h.jsx("button",{onClick:()=>As.getState().clearFilters(),className:"text-[10px] text-muted-foreground/60 hover:text-foreground transition-colors",children:"Clear"})]}),h.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[n&&h.jsx("div",{className:"mb-4 px-3 py-2 rounded border border-destructive/30 bg-destructive/10",children:h.jsx("p",{className:"text-[11px] text-destructive",children:n})}),w==="matrix"&&h.jsx(bK,{ideas:N,selectedIdeaId:i,onSelectIdea:u,onUpdateIdea:f}),w==="cards"&&N.length===0&&!r&&h.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[h.jsx(xi,{className:"w-8 h-8 text-muted-foreground/30"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"No ideas yet."}),h.jsxs("p",{className:"text-[11px] text-muted-foreground/60",children:["Use the CLI: ",h.jsx("span",{className:"font-mono",children:'compose idea "Your idea title"'})]})]}),w==="cards"&&M.map(({cluster:D,ideas:R})=>h.jsxs("div",{className:"mb-6",children:[D&&h.jsxs("h3",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold mb-3 flex items-center gap-2",children:[h.jsx("span",{children:D}),h.jsxs("span",{className:"text-muted-foreground/40 normal-case tracking-normal font-normal",children:["(",R.length,")"]})]}),h.jsx("div",{className:"grid grid-cols-4 gap-3",children:kK.map(j=>{const S=R.filter(K=>K.priority===j.key),W=T===j.key&&b;return h.jsxs("div",{className:rt("rounded-lg border p-2 min-h-[80px] transition-colors",j.bg,j.border,W&&"ring-1 ring-accent"),onDragOver:K=>I(K,j.key),onDrop:K=>A(K,j.key),children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[h.jsx("span",{className:rt("text-[10px] font-semibold uppercase tracking-wider",j.color),children:j.label}),h.jsxs("span",{className:"text-[9px] text-muted-foreground/50",children:["(",S.length,")"]})]}),h.jsxs("div",{className:"space-y-1.5",children:[S.map(K=>h.jsx(wK,{idea:K,selected:i===K.id,onClick:u,onDragStart:q,onDragEnd:O},K.id)),S.length===0&&h.jsx("p",{className:"text-[10px] text-muted-foreground/30 text-center py-2",children:"Drop here"})]})]},j.key)})})]},D||"__unclustered__")),w==="cards"&&h.jsx(TK,{killed:e,onResurrect:c})]})]}),$&&h.jsx(SK,{idea:$,onClose:()=>u(null),onPromote:D=>y(D),onKill:l,onSetPriority:a,onAddDiscussion:p}),m&&h.jsx(dK,{ideas:t.filter(D=>!D.priority||D.priority==="—"),onClose:()=>x(!1)}),g&&h.jsx(mK,{idea:g,onClose:()=>y(null)})]})}const EK=["A","B","C","D","E","F","G","H"];function NK({card:t,recommended:e=!1,selected:r=!1,disabled:n=!1,onSelect:i}){var a;const s=parseInt(t.id,10),o=Number.isFinite(s)?EK[s]??t.id:t.id;return h.jsxs("button",{type:"button",disabled:n,onClick:()=>i==null?void 0:i(t.id),className:["relative w-full text-left rounded-lg border p-3 transition-colors cursor-pointer","bg-card",r?"border-accent":"border-border hover:border-foreground",n&&"opacity-50 pointer-events-none"].filter(Boolean).join(" "),children:[(r||e)&&h.jsx("span",{className:"absolute top-2 right-2 text-accent",children:r?h.jsx(da,{style:{width:14,height:14}}):h.jsx(PM,{style:{width:14,height:14}})}),h.jsxs("span",{className:"block text-[12px] font-bold text-foreground",children:[o,". ",t.title]}),((a=t.bullets)==null?void 0:a.length)>0&&h.jsx("ul",{className:"mt-1.5 space-y-0.5 list-none pl-0",children:t.bullets.map((l,c)=>h.jsxs("li",{className:"text-[11px] text-muted-foreground leading-snug",children:[h.jsx("span",{className:"mr-1",children:"•"}),l]},c))})]})}function jK(){const{session:t,messages:e,decisions:r,status:n,error:i,streamingMessage:s,designDocPath:o,hydrate:a,startSession:l,sendMessage:c,selectCard:u,completeDesign:d,connectSSE:p,disconnectSSE:f,reset:m}=Wn(),[x,g]=C.useState(""),[y,b]=C.useState(null),[k,T]=C.useState(""),_=C.useRef(null);C.useEffect(()=>(Wn.setState({scope:null,featureCode:null}),a(),()=>f()),[]),C.useEffect(()=>{var M;(M=_.current)==null||M.scrollIntoView({behavior:"smooth"})},[e,s]);const w=C.useCallback(()=>{x.trim()&&(c(x.trim()),g(""))},[x,c]),E=C.useCallback((M,$)=>{b({messageIndex:$,cardId:M})},[]),B=C.useCallback(()=>{y&&(u(y.cardId,k||null,y.messageIndex),b(null),T(""))},[y,k,u]),P=n==="streaming"||n==="summarizing",N=e.reduce((M,$,q)=>$.role==="assistant"&&$.content&&VT($.content).parts.some(O=>O.type==="decision")?q:M,-1);return t?h.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[i&&h.jsx("div",{className:"px-3 py-1.5 text-[11px] text-red-400 bg-red-500/10 border-b border-red-500/20 shrink-0",children:i}),n==="complete"&&h.jsxs("div",{className:"px-3 py-2 text-[11px] bg-green-500/10 border-b border-green-500/20 shrink-0 flex items-center gap-2",children:[h.jsx(Gm,{style:{width:12,height:12},className:"text-green-400"}),h.jsx("span",{className:"text-green-400 font-medium",children:"Design complete."}),o&&h.jsxs("span",{className:"text-muted-foreground",children:["Document written to ",h.jsx("code",{className:"text-foreground",children:o})]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:()=>{m()},className:"px-2 py-1 text-[10px] font-medium rounded border border-border text-muted-foreground hover:text-foreground hover:border-foreground transition-colors",children:"New Session"})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[e.map((M,$)=>h.jsx(Z0,{messageIndex:$,message:M,onCardSelect:E,selectedCard:y,isStreaming:P,cardsDisabled:P||$!==N},$)),s&&h.jsx(Z0,{message:s,onCardSelect:E,selectedCard:y,isStreaming:P}),h.jsx("div",{ref:_})]}),n!=="complete"&&h.jsxs("div",{className:"border-t border-border p-3 shrink-0",children:[y?h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Selected: ",h.jsx("span",{className:"font-semibold text-foreground",children:y.cardId})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",value:k,onChange:M=>T(M.target.value),onKeyDown:M=>M.key==="Enter"&&B(),placeholder:"Add a comment (optional)...",className:"flex-1 bg-muted border border-border rounded px-3 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent"}),h.jsx("button",{onClick:B,disabled:P,className:"px-3 py-1.5 text-[11px] font-medium rounded bg-accent text-accent-foreground hover:opacity-90 transition-opacity disabled:opacity-50",children:"Send"}),h.jsx("button",{onClick:()=>{b(null),T("")},className:"px-3 py-1.5 text-[11px] rounded border border-border text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]})]}):h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",value:x,onChange:M=>g(M.target.value),onKeyDown:M=>M.key==="Enter"&&!M.shiftKey&&w(),placeholder:P?"Waiting for response...":"Type a response...",disabled:P,className:"flex-1 bg-muted border border-border rounded px-3 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent disabled:opacity-50"}),h.jsx("button",{onClick:w,disabled:P||!x.trim(),className:"px-3 py-1.5 rounded bg-accent text-accent-foreground disabled:opacity-50 transition-opacity",children:h.jsx(_f,{style:{width:14,height:14}})})]}),n==="active"&&r.length>=2&&h.jsxs("button",{onClick:d,className:"mt-2 w-full py-1.5 text-[11px] font-medium rounded border border-border text-muted-foreground hover:text-foreground hover:border-foreground transition-colors flex items-center justify-center gap-1.5",children:[h.jsx(Gm,{style:{width:12,height:12}}),"Complete Design"]})]})]}):h.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8",children:[h.jsx(Bc,{className:"text-muted-foreground",style:{width:48,height:48}}),h.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:"Start a Design Conversation"}),h.jsx("p",{className:"text-[12px] text-muted-foreground text-center max-w-md",children:"Have an interactive design conversation with the AI. It will ask questions, present options with trade-offs, and build a design document from your decisions."}),i&&h.jsx("p",{className:"text-[11px] text-red-400 text-center max-w-md",children:i}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:()=>l("product"),className:"px-4 py-2 text-[11px] font-medium rounded bg-accent text-accent-foreground hover:opacity-90 transition-opacity",children:"Product Design"}),h.jsx("button",{onClick:()=>{const M=prompt("Feature code:");M&&l("feature",M)},className:"px-4 py-2 text-[11px] font-medium rounded border border-border text-foreground hover:bg-muted transition-colors",children:"Feature Design"})]})]})}function Z0({message:t,messageIndex:e,onCardSelect:r,selectedCard:n,isStreaming:i,cardsDisabled:s}){var l,c;const o=t.role==="human",a=!o&&t.content?VT(t.content):null;return h.jsx("div",{className:rt("flex",o?"justify-end":"justify-start"),children:h.jsx("div",{className:rt("max-w-[85%] rounded-lg px-3 py-2 text-[12px]",o?"bg-accent/20 text-foreground":"bg-muted text-foreground"),children:o?h.jsx("div",{children:t.type==="card_select"?h.jsxs("span",{children:["Selected ",h.jsx("strong",{children:(l=t.content)==null?void 0:l.cardId}),(c=t.content)!=null&&c.comment?`: ${t.content.comment}`:""]}):h.jsx("span",{children:t.content})}):a?h.jsx("div",{className:"space-y-3",children:a.parts.map((u,d)=>{var p,f;return u.type==="text"?h.jsx("div",{className:"whitespace-pre-wrap",children:u.content},d):h.jsxs("div",{className:"space-y-2",children:[h.jsx("div",{className:"flex flex-col gap-2 mt-2",children:(p=u.content.options)==null?void 0:p.map(m=>{var x;return h.jsx(NK,{card:m,recommended:((x=u.content.recommendation)==null?void 0:x.id)===m.id,selected:(n==null?void 0:n.messageIndex)===e&&(n==null?void 0:n.cardId)===m.id,disabled:s,onSelect:g=>r(g,e)},m.id)})}),((f=u.content.recommendation)==null?void 0:f.rationale)&&h.jsx("div",{className:"text-[11px] text-muted-foreground italic mt-1",children:u.content.recommendation.rationale})]},d)})}):h.jsx("div",{className:"whitespace-pre-wrap",children:t.content})})})}const LK=new Set(["Read","Grep","Glob","read_file","search_files","list_directory"]),BK=new Set(["WebSearch","web_search"]);function AK({expanded:t}){return h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 150ms ease",flexShrink:0},children:h.jsx("path",{d:"M3 2L7 5L3 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function MK(){return h.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:[h.jsx("circle",{cx:"5",cy:"5",r:"4",stroke:"hsl(var(--accent))",strokeWidth:"1.2"}),h.jsx("path",{d:"M3 5l1.5 1.5L7 3.5",stroke:"hsl(var(--accent))",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function IK(){return h.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",style:{flexShrink:0},children:h.jsx("circle",{cx:"5",cy:"5",r:"4",stroke:"hsl(var(--muted-foreground))",strokeWidth:"1.2"})})}function Nu({title:t,count:e,defaultExpanded:r,children:n}){const[i,s]=C.useState(r);return h.jsxs("div",{className:"border-b",style:{borderColor:"hsl(var(--sidebar-border))"},children:[h.jsxs("button",{onClick:()=>s(o=>!o),className:"flex items-center gap-1.5 w-full px-3 py-2 text-left transition-colors hover:bg-sidebar-accent/30",children:[h.jsx(AK,{expanded:i}),h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider flex-1",style:{color:"hsl(var(--muted-foreground))"},children:t}),e>0&&h.jsx("span",{className:"text-[9px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--accent) / 0.12)",color:"hsl(var(--accent))"},children:e})]}),i&&h.jsx("div",{className:"pb-1",children:n})]})}function cl(t,e=80){return t?t.length>e?t.slice(0,e)+"…":t:""}function Q0(t,e){return e?typeof e=="string"?e:e.path||e.pattern||e.query||e.file_path||JSON.stringify(e).slice(0,60):""}function FK({researchItems:t=[],topicOutline:e=[]}){const r=t.filter(o=>LK.has(o.tool)),n=t.filter(o=>BK.has(o.tool)),i=[...r].reverse(),s=[...n].reverse();return h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{children:[h.jsx(Nu,{title:"Topic Outline",count:e.length,defaultExpanded:e.length>0,children:e.length===0?h.jsx("p",{className:"px-3 py-2 text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:"No topics yet"}):h.jsx("ul",{className:"px-3 space-y-1 pt-0.5",children:e.map((o,a)=>h.jsxs("li",{className:"flex items-start gap-1.5 py-0.5",children:[h.jsx("span",{className:"mt-0.5",children:o.decided?h.jsx(MK,{}):h.jsx(IK,{})}),h.jsx("span",{className:"text-[11px] leading-snug",style:{color:o.decided?"hsl(var(--foreground))":"hsl(var(--muted-foreground))"},children:o.title})]},a))})}),h.jsx(Nu,{title:"Codebase Refs",count:r.length,defaultExpanded:r.length>0,children:r.length===0?h.jsx("p",{className:"px-3 py-2 text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:"No file references yet"}):h.jsx("ul",{className:"px-2 space-y-1 pt-0.5",children:i.map((o,a)=>h.jsxs("li",{className:"px-2 py-1.5 rounded-md",style:{background:"hsl(var(--sidebar-accent) / 0.3)"},children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"text-[9px] font-medium uppercase tracking-wider px-1 rounded",style:{background:"hsl(var(--accent) / 0.12)",color:"hsl(var(--accent))"},children:o.tool}),h.jsx("span",{className:"text-[10px] font-mono leading-tight truncate flex-1",style:{color:"hsl(var(--foreground))"},title:typeof o.input=="string"?o.input:JSON.stringify(o.input),children:cl(Q0(o.tool,o.input),50)})]}),o.summary&&h.jsx("p",{className:"text-[10px] leading-snug mt-1",style:{color:"hsl(var(--muted-foreground))"},children:cl(o.summary,100)})]},a))})}),h.jsx(Nu,{title:"Web Searches",count:n.length,defaultExpanded:n.length>0,children:n.length===0?h.jsx("p",{className:"px-3 py-2 text-[10px]",style:{color:"hsl(var(--muted-foreground))"},children:"No web searches yet"}):h.jsx("ul",{className:"px-2 space-y-1 pt-0.5",children:s.map((o,a)=>h.jsxs("li",{className:"px-2 py-1.5 rounded-md",style:{background:"hsl(var(--sidebar-accent) / 0.3)"},children:[h.jsx("p",{className:"text-[10px] font-medium leading-snug",style:{color:"hsl(var(--foreground))"},children:cl(Q0(o.tool,o.input),80)}),o.summary&&h.jsx("p",{className:"text-[10px] leading-snug mt-1",style:{color:"hsl(var(--muted-foreground))"},children:cl(o.summary,100)})]},a))})})]})})}function PK({decisions:t=[],onReviseDecision:e,sessionComplete:r=!1,widthPx:n}){const[i,s]=C.useState("decisions"),o=t.filter(c=>!c.superseded).length,a=Wn(c=>c.researchItems)||[],l=Wn(c=>c.topicOutline)||[];return h.jsxs("aside",{className:"shrink-0 flex flex-col bg-sidebar border-r border-sidebar-border",style:{width:n??208},children:[h.jsx("div",{className:"p-3 pb-0",children:h.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--foreground))"},children:"Design"})}),h.jsxs("div",{className:"flex px-2 pt-2 gap-1",style:{borderBottom:"1px solid hsl(var(--sidebar-border))"},children:[h.jsxs("button",{onClick:()=>s("decisions"),className:"flex items-center gap-1 px-2 py-1.5 text-[11px] font-medium transition-colors",style:{color:i==="decisions"?"hsl(var(--foreground))":"hsl(var(--muted-foreground))",borderBottom:i==="decisions"?"2px solid hsl(var(--accent))":"2px solid transparent",marginBottom:"-1px"},children:["Decisions",o>0&&h.jsx("span",{className:"text-[9px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--accent))"},children:o})]}),h.jsxs("button",{onClick:()=>s("research"),className:"flex items-center gap-1 px-2 py-1.5 text-[11px] font-medium transition-colors",style:{color:i==="research"?"hsl(var(--foreground))":"hsl(var(--muted-foreground))",borderBottom:i==="research"?"2px solid hsl(var(--accent))":"2px solid transparent",marginBottom:"-1px"},children:["Research",a.length>0&&h.jsx("span",{className:"text-[9px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--accent))"},children:a.length})]})]}),i==="decisions"&&h.jsx(Hn,{className:"flex-1",children:t.length===0?h.jsx("div",{className:"px-3 py-6 text-center text-[11px]",style:{color:"hsl(var(--muted-foreground))"},children:"No decisions yet"}):h.jsx("div",{className:"px-2 pb-2 pt-1",children:t.map((c,u)=>{var d;return h.jsxs("button",{disabled:c.superseded||r,onClick:()=>!c.superseded&&!r&&(e==null?void 0:e(u)),className:`flex flex-col w-full text-left rounded-md px-2 py-1.5 transition-colors ${c.superseded||r?"cursor-not-allowed opacity-40":"cursor-pointer hover:bg-sidebar-accent/50"}`,children:[h.jsx("span",{className:"text-[11px] font-medium leading-tight",style:{color:"hsl(var(--foreground))",textDecoration:c.superseded?"line-through":void 0},children:((d=c.selectedOption)==null?void 0:d.title)||c.question}),c.comment&&h.jsx("span",{className:"text-[10px] leading-snug mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:c.comment}),c.superseded&&h.jsx("span",{className:"text-[9px] mt-0.5 uppercase tracking-wider font-medium",style:{color:"hsl(var(--muted-foreground))"},children:"superseded"})]},u)})})}),i==="research"&&h.jsx(FK,{researchItems:a,topicOutline:l})]})}function DK(t){return[...t].sort((e,r)=>Date.parse(e.created_at)-Date.parse(r.created_at))}function OK(t,e){const r=(e??Date.now())-Date.parse(t);if(r<0)return"0m";const n=Math.floor(r/6e4);if(n<60)return`${n}m`;const i=Math.floor(r/36e5);return i<24?`${i}h`:`${Math.floor(r/864e5)}d`}function RK(t,e){if(t.resolution)return!1;const r=t.ttl_days??90;return(e??Date.now())-Date.parse(t.created_at)>r*24*60*60*1e3}const $K=320,zK=40,WK={deferred:"Deferred",blocked:"Blocked",open_question:"Question"};function e_(t){return t?`compose:${t}:openLoopsCollapsed`:null}function J0(t){const e=e_(t);if(!e)return!1;try{return localStorage.getItem(e)==="true"}catch{return!1}}function qK(t,e){const r=e_(t);if(r)try{localStorage.setItem(r,e?"true":"false")}catch{}}function HK({onConfirm:t,onCancel:e}){const[r,n]=C.useState("deferred"),[i,s]=C.useState(""),[o,a]=C.useState(""),l=c=>{c.preventDefault(),i.trim()&&t({kind:r,summary:i.trim(),ttl_days:o?parseInt(o,10):void 0})};return h.jsx("div",{"data-testid":"add-loop-modal",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:c=>{c.target===c.currentTarget&&e()},children:h.jsxs("form",{onSubmit:l,style:{background:"#1e1e2e",borderRadius:8,padding:24,width:360,display:"flex",flexDirection:"column",gap:12},children:[h.jsx("h3",{style:{margin:0,color:"#cdd6f4",fontSize:14},children:"Add Open Loop"}),h.jsxs("label",{style:{color:"#a6adc8",fontSize:12},children:["Kind",h.jsxs("select",{value:r,onChange:c=>n(c.target.value),style:{display:"block",width:"100%",marginTop:4,background:"#313244",color:"#cdd6f4",border:"1px solid #45475a",borderRadius:4,padding:"4px 8px"},children:[h.jsx("option",{value:"deferred",children:"Deferred"}),h.jsx("option",{value:"blocked",children:"Blocked"}),h.jsx("option",{value:"open_question",children:"Open Question"})]})]}),h.jsxs("label",{style:{color:"#a6adc8",fontSize:12},children:["Summary (max 280 chars)",h.jsx("textarea",{"data-testid":"add-loop-summary",value:i,onChange:c=>s(c.target.value),maxLength:280,rows:3,required:!0,style:{display:"block",width:"100%",marginTop:4,background:"#313244",color:"#cdd6f4",border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",resize:"vertical",boxSizing:"border-box"}})]}),h.jsxs("label",{style:{color:"#a6adc8",fontSize:12},children:["TTL days (optional, default 90)",h.jsx("input",{type:"number",value:o,onChange:c=>a(c.target.value),min:1,style:{display:"block",width:"100%",marginTop:4,background:"#313244",color:"#cdd6f4",border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",boxSizing:"border-box"}})]}),h.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:4},children:[h.jsx("button",{type:"button",onClick:e,style:{padding:"6px 16px",background:"#313244",color:"#cdd6f4",border:"1px solid #45475a",borderRadius:4,cursor:"pointer"},children:"Cancel"}),h.jsx("button",{type:"submit","data-testid":"add-loop-submit",style:{padding:"6px 16px",background:"#89b4fa",color:"#1e1e2e",border:"none",borderRadius:4,cursor:"pointer",fontWeight:600},children:"Add"})]})]})})}function UK({loop:t,onResolve:e,nowMs:r}){const n=RK(t,r),i=!!t.resolution;return h.jsxs("div",{"data-testid":`loop-row-${t.id}`,style:{padding:"8px 12px",borderBottom:"1px solid #313244",opacity:i?.5:1},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[h.jsx("span",{style:{fontSize:10,color:"#6c7086",background:"#313244",borderRadius:3,padding:"1px 5px"},children:WK[t.kind]||t.kind}),n&&!i&&h.jsx("span",{"data-testid":`stale-badge-${t.id}`,style:{fontSize:10,color:"#f38ba8",background:"#3e1111",borderRadius:3,padding:"1px 5px"},children:">TTL"}),h.jsx("span",{style:{fontSize:10,color:"#6c7086",marginLeft:"auto"},children:OK(t.created_at,r)})]}),h.jsx("p",{style:{margin:"4px 0 6px",fontSize:12,color:n&&!i?"#f38ba8":"#cdd6f4",lineHeight:1.4},children:t.summary}),!i&&h.jsx("button",{"data-testid":`resolve-btn-${t.id}`,onClick:()=>e(t.id),style:{fontSize:11,padding:"3px 10px",background:"#313244",color:"#a6e3a1",border:"1px solid #a6e3a1",borderRadius:3,cursor:"pointer"},children:"Resolve"}),i&&h.jsx("span",{style:{fontSize:11,color:"#a6e3a1"},children:"Resolved"})]})}function GK({featureCode:t,items:e=[],onAddLoop:r,onResolveLoop:n}){var g,y;const[i,s]=C.useState(()=>J0(t)),[o,a]=C.useState(!1),[l,c]=C.useState(()=>Date.now());C.useEffect(()=>{const b=setInterval(()=>c(Date.now()),6e4);return()=>clearInterval(b)},[]),C.useEffect(()=>{s(J0(t))},[t]);const u=C.useCallback(()=>{s(b=>{const k=!b;return qK(t,k),k})},[t]),d=C.useMemo(()=>!t||!e?null:e.find(b=>{var k;return((k=b.lifecycle)==null?void 0:k.featureCode)===t})??null,[t,e]),p=((y=(g=d==null?void 0:d.lifecycle)==null?void 0:g.lifecycle_ext)==null?void 0:y.open_loops)??[],f=C.useMemo(()=>DK(p.filter(b=>b.resolution==null)),[p]),m=C.useCallback(async b=>{if(a(!1),r)try{await r(t,b)}catch(k){console.error("[OpenLoopsPanel] addLoop failed:",k.message)}},[t,r]),x=C.useCallback(async b=>{if(n){const k=window.prompt("Resolve note (optional):")||"";try{await n(t,b,{note:k})}catch(T){console.error("[OpenLoopsPanel] resolveLoop failed:",T.message)}}},[t,n]);return t?i?h.jsxs("div",{"data-testid":"open-loops-panel-collapsed",style:{width:zK,background:"#181825",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:12,borderLeft:"1px solid #313244",flexShrink:0},children:[h.jsx("button",{"data-testid":"open-loops-expand-btn",onClick:u,title:`Open loops (${f.length})`,style:{background:"none",border:"none",cursor:"pointer",color:"#a6adc8",fontSize:18},children:"↺"}),f.length>0&&h.jsx("span",{style:{fontSize:10,color:"#f5c2e7",marginTop:4},children:f.length})]}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"open-loops-panel",style:{width:$K,background:"#181825",display:"flex",flexDirection:"column",borderLeft:"1px solid #313244",flexShrink:0,overflow:"hidden"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderBottom:"1px solid #313244",gap:8},children:[h.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"#cdd6f4",flex:1},children:["Open Loops ",f.length>0&&h.jsxs("span",{style:{color:"#a6adc8"},children:["(",f.length,")"]})]}),h.jsx("button",{"data-testid":"add-loop-btn",onClick:()=>a(!0),title:"Add open loop",style:{background:"none",border:"1px solid #45475a",color:"#a6e3a1",borderRadius:4,padding:"2px 8px",cursor:"pointer",fontSize:12},children:"+"}),h.jsx("button",{"data-testid":"open-loops-collapse-btn",onClick:u,title:"Collapse",style:{background:"none",border:"none",cursor:"pointer",color:"#6c7086",fontSize:16},children:"›"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:f.length===0?h.jsxs("div",{"data-testid":"open-loops-empty",style:{padding:"16px 12px",color:"#6c7086",fontSize:12,textAlign:"center"},children:["No open loops for this feature",h.jsx("br",{}),h.jsx("button",{onClick:()=>a(!0),style:{marginTop:8,background:"none",border:"1px solid #45475a",color:"#a6adc8",borderRadius:4,padding:"3px 10px",cursor:"pointer",fontSize:11},children:"+ Add loop"})]}):f.map(b=>h.jsx(UK,{loop:b,onResolve:x,nowMs:l},b.id))})]}),o&&h.jsx(HK,{onConfirm:m,onCancel:()=>a(!1)})]}):null}const Zi={building:"building",gate_pending:"gate_pending",blocked_downstream:"blocked_downstream",error:"error"},VK=new Set(["blocks","informs"]);function ty(t,e){return t.find(r=>r.featureCode===e)||t.find(r=>r.title===e)||t.find(r=>r.title&&r.title.startsWith(e+":"))}function YK(t){return t.featureCode?t.featureCode:t.title&&t.title.includes(":")?t.title.split(":")[0].trim():t.title||t.id}function XK(t,e,r,n){if(!t)return{};const i={},{featureCode:s,status:o,currentStepId:a}=t;if(!s)return{};if(o==="failed")i[s]=Zi.error;else if(o==="running"){const c=a&&a.endsWith("_gate"),u=ty(e,s);c&&u&&n.some(p=>p.itemId===u.id&&!p.resolvedAt)?i[s]=Zi.gate_pending:i[s]=Zi.building}const l=ty(e,s);if(l&&(i[s]===Zi.building||i[s]===Zi.gate_pending)){const c=new Set([l.id]),u=KK(c,r),d=new Map(e.map(p=>[p.id,YK(p)]));for(const p of u){const f=d.get(p);f&&!i[f]&&(i[f]=Zi.blocked_downstream)}}return i}function KK(t,e){if(!t.size||!e.length)return new Set;const r=new Map;for(const o of e)VK.has(o.type)&&(r.has(o.fromId)||r.set(o.fromId,[]),r.get(o.fromId).push(o.toId));const n=new Set(t),i=[...t],s=new Set;for(;i.length>0;){const o=i.shift(),a=r.get(o)||[];for(const l of a)n.has(l)||(n.add(l),s.add(l),i.push(l))}return s}function ZK(t,e){if(!t||!t.length)return{nodes:[],edges:[],activeEdgeIds:new Set};const r=[],n=new Map;r.push({data:{id:"agent-topology",label:"Agent Topology",isAgentGroup:!0}}),r.push({data:{id:"agent-session",label:"Session",isAgentNode:!0,agentType:"session",agentStatus:"running",agentColor:"#64748b",parent:"agent-topology"}});const i=new Set(t.map(l=>l.agentId));for(const l of t){const c=l.agentType||"claude",u=S_[c]||"#3b82f6";r.push({data:{id:`agent-${l.agentId}`,label:`${c}
768
- ${l.agentId.slice(0,6)}`,isAgentNode:!0,agentType:c,agentStatus:l.status||"running",agentColor:u,parent:"agent-topology"}});const p=l.parentSessionId&&i.has(l.parentSessionId)?`agent-${l.parentSessionId}`:"agent-session",f=`relay-${p}-agent-${l.agentId}`;n.has(f)||n.set(f,{data:{id:f,source:p,target:`agent-${l.agentId}`,isRelayEdge:!0}})}const s=Date.now()-3e4,o=new Set,a=l=>l==="session"?"agent-session":i.has(l)?`agent-${l}`:"agent-session";for(const l of e||[]){if(new Date(l.timestamp).getTime()<s)continue;const c=a(l.fromAgentId),u=a(l.toAgentId),d=l.direction==="dispatch"?`relay-${c}-${u}`:`relay-${u}-${c}`;o.add(d)}return{nodes:r,edges:[...n.values()],activeEdgeIds:o}}class wr extends Yt.Component{constructor(){super(...arguments);ie(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}render(){var r,n;return this.state.error?h.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-3 p-4",style:{background:"hsl(var(--background))",color:"hsl(var(--muted-foreground))"},children:[h.jsx("div",{className:"text-xs uppercase tracking-wider font-semibold",style:{color:"hsl(var(--destructive))"},children:this.props.zone?`${this.props.zone} crashed`:"panel crashed"}),h.jsx("div",{className:"text-[11px] max-w-[300px] text-center opacity-70 font-mono",children:(n=(r=this.state.error)==null?void 0:r.message)==null?void 0:n.substring(0,120)}),h.jsx("button",{className:"mt-2 px-3 py-1 text-xs rounded border",style:{borderColor:"hsl(var(--border))",color:"hsl(var(--foreground))"},onClick:()=>this.setState({error:null}),children:"retry"})]}):this.props.children}}class QK extends Yt.Component{constructor(){super(...arguments);ie(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}render(){var r,n;return this.state.error?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsxs("div",{className:"h-8 flex items-center justify-between px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--destructive) / 0.1)"},children:[h.jsxs("span",{className:"text-[10px] uppercase tracking-wider font-semibold",style:{color:"hsl(var(--destructive))"},children:["safe mode — UI crashed: ",(n=(r=this.state.error)==null?void 0:r.message)==null?void 0:n.substring(0,80)]}),h.jsx("button",{className:"px-2 py-0.5 text-[10px] rounded border",style:{borderColor:"hsl(var(--border))",color:"hsl(var(--foreground))"},onClick:()=>this.setState({error:null}),children:"retry"})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(hy,{})})]}):this.props.children}}const Zd="compose:fontSize",JK="compose:theme",Uo=13,Qd=10,Jd=20;function tZ(){try{const t=parseInt(localStorage.getItem(Zd),10);return t>=Qd&&t<=Jd?t:Uo}catch{return Uo}}const ey=new URLSearchParams(window.location.search).get("popout");function eZ(){return ey?h.jsx(YV,{path:ey}):h.jsx(QK,{children:h.jsx(nZ,{})})}function rZ({activeView:t,items:e,filteredItems:r,phaseFilteredItems:n,phaseFilteredGates:i,connections:s,filteredConnections:o,sessions:a,activeBuild:l,pipelineDraft:c,gates:u,settings:d,selectedPhase:p,selectedItemId:f,buildStateMap:m,agentOverlay:x,spawnedAgents:g,agentRelays:y,docsSelectedFile:b,onDocsSelectedFileChange:k,docsPreviousView:T,onDocsBack:_,visibleTracks:w,hiddenGroups:E,onSelect:B,onUpdate:P,onCreate:N,onDelete:M,onOpenGate:$,onCreateConnection:q,onDeleteConnection:O,onRefreshBuild:I,onSelectStep:A,onResolveGate:D,onUpdateSettings:R,onResetSettings:j,projectRoot:S,featureCode:W,focusActive:K,onToggleFocus:F,sessionState:ht,agentActivity:st,iterationStates:J}){switch(t){case"dashboard":return h.jsx(lK,{items:n,gates:i,sessions:a,activeBuild:l,spawnedAgents:g,featureCode:W,sessionState:ht,agentActivity:st,iterationStates:J,onSelect:B,onResolveGate:D,onOpenGate:$});case"tree":return h.jsx(p1,{items:r,connections:o,selectedItemId:f,onSelect:B,onCreate:N,featureCode:W,focusActive:K,onToggleFocus:F});case"graph":return h.jsx(g1,{items:e,connections:s,selectedItemId:f,onSelect:B,visibleTracks:w,hiddenGroups:E,buildStateMap:m,resolveGate:D,gates:u,spawnedAgents:g,agentRelays:y,agentOverlay:x,featureCode:W,focusActive:K,onToggleFocus:F});case"pipeline":return h.jsx(XS,{activeBuild:l,pipelineDraft:c,onSelectStep:A,onRefresh:I});case"sessions":return h.jsx(eT,{sessions:a,items:e,onSelectItem:B,featureCode:W,focusActive:K,onToggleFocus:F});case"gates":return h.jsx(US,{gates:i,items:n,onResolve:D,onSelect:B,featureCode:W,focusActive:K,onToggleFocus:F});case"docs":return h.jsx(qS,{items:n,selectedFile:b,onSelectedFileChange:k,previousView:T,onBack:_,featureCode:W,focusActive:K,onToggleFocus:F});case"design":return h.jsx(jK,{},S);case"ideabox":return h.jsx(_K,{});case"settings":return h.jsx(YS,{settings:d,onSettingsChange:R,onReset:j});case"stratum":return h.jsx(rY,{});default:return h.jsxs("div",{className:"flex-1 flex items-center justify-center text-[12px] text-muted-foreground italic",children:["View “",t,"” not found."]})}}function nZ(){const{refresh:t}=m_(),e=Wn(H=>H.decisions),r=Wn(H=>H.status),[n,i]=C.useState(tZ),[s,o]=C.useState(()=>document.documentElement.classList.contains("dark")),[a]=C.useState(BX),[l,c]=C.useState(()=>AX(a)),[u,d]=C.useState(pY),[p,f]=C.useState(MX),[m,x]=C.useState(FX),[g,y]=C.useState(null),[b,k]=C.useState(()=>{try{return parseInt(localStorage.getItem("compose:contextWidthPx"),10)||420}catch{return 420}}),[T,_]=C.useState(()=>{try{return parseInt(localStorage.getItem("compose:sidebarWidthPx"),10)||220}catch{return 220}}),{items:w,connections:E,connected:B,uiCommand:P,clearUICommand:N,recentChanges:M,createItem:$,updateItem:q,deleteItem:O,createConnection:I,deleteConnection:A,agentActivity:D,agentErrors:R,spawnedAgents:j,agentRelays:S,sessionState:W,registerSnapshotProvider:K,gates:F,gateEvent:ht,resolveGate:st,settings:J,updateSettings:ct,resetSettings:zt,activeBuild:at,setActiveBuild:Z,pipelineDraft:lt,sessions:Ct,iterationStates:Mt,selectedPhase:Dt,setSelectedPhase:ne,statusSnapshots:ue,setStatusSnapshot:Se}=gr(Li(H=>({items:H.items,connections:H.connections,connected:H.connected,uiCommand:H.uiCommand,clearUICommand:H.clearUICommand,recentChanges:H.recentChanges,createItem:H.createItem,updateItem:H.updateItem,deleteItem:H.deleteItem,createConnection:H.createConnection,deleteConnection:H.deleteConnection,agentActivity:H.agentActivity,agentErrors:H.agentErrors,spawnedAgents:H.spawnedAgents,agentRelays:H.agentRelays,sessionState:H.sessionState,registerSnapshotProvider:H.registerSnapshotProvider,gates:H.gates,gateEvent:H.gateEvent,resolveGate:H.resolveGate,settings:H.settings,updateSettings:H.updateSettings,resetSettings:H.resetSettings,activeBuild:H.activeBuild,setActiveBuild:H.setActiveBuild,pipelineDraft:H.pipelineDraft,sessions:H.sessions,iterationStates:H.iterationStates,selectedPhase:H.selectedPhase,setSelectedPhase:H.setSelectedPhase,statusSnapshots:H.statusSnapshots,setStatusSnapshot:H.setStatusSnapshot}))),te=(W==null?void 0:W.featureCode)||null;C.useEffect(()=>{te&&(ue&&ue[te]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(te)}`).then(H=>H.json()).then(H=>{H!=null&&H.snapshot&&Se&&Se(te,H.snapshot)}).catch(()=>{}))},[te,ue,Se]);const[Ae,V]=C.useState(null),it=C.useRef(!!localStorage.getItem("compose:activeView")),[dt,Nt]=C.useState(()=>localStorage.getItem("compose:activeView")||"dashboard"),[tt,kt]=C.useState(""),G=C.useCallback(H=>{k(H),localStorage.setItem("compose:contextWidthPx",String(Math.round(H)))},[]),nt=C.useRef(!1),wt=C.useCallback(H=>{H.preventDefault(),nt.current=!0;const _t=de=>{if(!nt.current)return;const cr=de.clientX-16,ro=Math.max(160,Math.min(window.innerWidth*.4,cr));_(ro),localStorage.setItem("compose:sidebarWidthPx",String(Math.round(ro)))},St=()=>{nt.current=!1,document.removeEventListener("mousemove",_t),document.removeEventListener("mouseup",St)};document.addEventListener("mousemove",_t),document.addEventListener("mouseup",St)},[]),[At,Gt]=C.useState(null),[Te,ar]=C.useState(null),[ce,Fr]=C.useState(()=>localStorage.getItem("compose:selectedTrack")||null),[Me,ge]=C.useState(()=>{try{const H=localStorage.getItem("compose:visibleTracks");if(H){const _t=JSON.parse(H);return new Set(_t)}}catch{}return null}),[_e,Oe]=C.useState(new Set),[Ys,Xs]=C.useState(!1),ch=C.useCallback(H=>{Oe(_t=>{const St=new Set(_t);return St.has(H)?St.delete(H):St.add(H),St})},[]),[Bi,Ks]=C.useState(null),[hh,Pr]=C.useState(!1),[uh,Zs]=C.useState(!1),[Ce,pn]=C.useState(!1),[dh,Qs]=C.useState(""),[Ai,Js]=C.useState("");C.useEffect(()=>{Rt("/api/project").then(H=>H.json()).then(H=>{Qs(H.name||""),Js(H.targetRoot||"")}).catch(()=>{})},[]);const Ta=C.useCallback(async H=>{try{const St=await(await Rt("/api/project/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:H})})).json();return St.ok?(await t(),Qs(St.name),Js(St.targetRoot),!0):!1}catch{return!1}},[t]),_a=u===Ve.MAXIMIZED,Cr=C.useCallback(H=>{c(H),O0(H),Nt(H)},[]),Ee=C.useCallback(H=>{Nt(H),c(H),O0(H)},[]);C.useEffect(()=>{localStorage.setItem("compose:activeView",dt),dt!=="docs"&&(ar(null),Gt(null))},[dt]),C.useEffect(()=>{ce?localStorage.setItem("compose:selectedTrack",ce):localStorage.removeItem("compose:selectedTrack")},[ce]),C.useEffect(()=>{Ae?sessionStorage.setItem("vision-selectedItemId",Ae):sessionStorage.removeItem("vision-selectedItemId")},[Ae]),C.useEffect(()=>{try{Me?localStorage.setItem("compose:visibleTracks",JSON.stringify([...Me])):localStorage.removeItem("compose:visibleTracks")}catch{}},[Me]);const to=C.useRef(!1);C.useEffect(()=>{var H;to.current||it.current||(H=J==null?void 0:J.ui)!=null&&H.defaultView&&(Ee(J.ui.defaultView),to.current=!0)},[J]),C.useEffect(()=>{P&&(P.view&&Ee(P.view),P.phase!==void 0&&ne(P.phase),P.select!==void 0&&Or(P.select),N())},[P,N]),C.useEffect(()=>{const H=()=>{var St;return["INPUT","TEXTAREA","SELECT"].includes((St=document.activeElement)==null?void 0:St.tagName)},_t=St=>{(St.metaKey||St.ctrlKey)&&St.key==="k"&&(St.preventDefault(),Pr(de=>!de)),(St.metaKey||St.ctrlKey)&&St.key==="n"&&(St.preventDefault(),Zs(!0)),St.key===","&&!St.metaKey&&!St.ctrlKey&&!H()&&pn(!0)};return window.addEventListener("keydown",_t),()=>window.removeEventListener("keydown",_t)},[]);const jn=C.useMemo(()=>{let H=w;if(Dt&&(H=H.filter(_t=>_t.phase===Dt)),ce&&(H=H.filter(_t=>{const St=(_t.description||"").match(/Track:\s*(\w+)/i);return St&&St[1].toLowerCase()===ce})),tt){const _t=tt.toLowerCase();H=H.filter(St=>St.title.toLowerCase().includes(_t)||(St.description||"").toLowerCase().includes(_t))}return H},[w,Dt,ce,tt]),ei=C.useMemo(()=>Dt?w.filter(H=>H.phase===Dt):w,[w,Dt]),Mi=C.useMemo(()=>new Set(ei.map(H=>H.id)),[ei]),Dr=C.useMemo(()=>Dt?F.filter(H=>Mi.has(H.itemId)):F,[F,Mi,Dt]),Ea=C.useMemo(()=>{if(!Dt&&!ce&&!tt)return E;const H=new Set(jn.map(_t=>_t.id));return E.filter(_t=>H.has(_t.fromId)&&H.has(_t.toId))},[E,jn,Dt,ce,tt]),Na=C.useMemo(()=>XK(at,w,E,F),[at,w,E,F]),fh=C.useMemo(()=>ZK(j,S),[j,S]),qe=C.useCallback(H=>{y(H)},[]),Or=C.useCallback(H=>{V(_t=>_t===H?(qe(null),null):(qe({type:"item",id:H}),H))},[qe]),eo=C.useCallback(async H=>{try{await Rt(`/api/agent/${H}/stop`,{method:"POST",headers:Mo({"Content-Type":"application/json"})})}catch(_t){console.error(`[App] Failed to stop agent ${H}:`,_t.message)}},[]),ri=C.useRef(at);C.useEffect(()=>{!ri.current&&at&&at.featureItemId&&Or(at.featureItemId),ri.current=at},[at]);const Tt=C.useCallback(H=>{if(!H)return;const _t=w.find(St=>{var de,cr;return((de=St.lifecycle)==null?void 0:de.featureCode)===H||St.featureCode===H||St.feature_code===H||((cr=St.title)==null?void 0:cr.includes(H))});_t&&Or(_t.id)},[w,Or]);C.useEffect(()=>{const H=_t=>{const{featureCode:St}=_t.detail||{};St&&Tt(St)};return window.addEventListener("compose:select-feature",H),()=>window.removeEventListener("compose:select-feature",H)},[Tt]);const z=C.useCallback(H=>w.find(_t=>{var St;return((St=_t.lifecycle)==null?void 0:St.featureCode)===H})||null,[w]),et=C.useCallback(async(H,_t)=>{const St=z(H);if(!St)throw new Error(`No item found for feature ${H}`);const de=await Rt(`/api/vision/items/${St.id}/loops`,{method:"POST",headers:Mo({"Content-Type":"application/json"}),body:JSON.stringify(_t)});if(!de.ok)throw new Error(`Add loop failed: ${de.status}`)},[z]),pt=C.useCallback(async(H,_t,{note:St})=>{const de=z(H);if(!de)throw new Error(`No item found for feature ${H}`);const cr=await Rt(`/api/vision/items/${de.id}/loops/${_t}/resolve`,{method:"POST",headers:Mo({"Content-Type":"application/json"}),body:JSON.stringify({note:St})});if(!cr.ok)throw new Error(`Resolve loop failed: ${cr.status}`)},[z]);C.useEffect(()=>{K(()=>({activeView:dt,selectedPhase:Dt,searchQuery:tt,selectedItemId:Ae,totalItems:w.length,filteredCount:jn.length,connected:B}))},[K,dt,Dt,tt,Ae,w.length,jn.length,B]),C.useEffect(()=>{const H=new MutationObserver(()=>{o(document.documentElement.classList.contains("dark"))});return H.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>H.disconnect()},[]),C.useEffect(()=>{g&&!m&&(x(!0),R0(!0))},[g]),C.useEffect(()=>{dt==="design"?y({type:"design-doc"}):(g==null?void 0:g.type)==="design-doc"&&y(null)},[dt]);const Kt=C.useCallback(()=>{const H=s?"light":"dark";document.documentElement.classList.toggle("dark",H==="dark"),localStorage.setItem(JK,H),Rt("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ui:{theme:H}})}).catch(()=>{})},[s]),ke=C.useCallback(H=>{i(_t=>{const St=Math.min(Math.max(_t+H,Qd),Jd);return localStorage.setItem(Zd,St),St})},[]),xe=C.useCallback(()=>{i(Uo),localStorage.setItem(Zd,Uo)},[]),He=C.useCallback(H=>{d(H),mY(H)},[]),lr=C.useCallback(()=>{f(H=>(IX(!H),!H))},[]),kr=C.useCallback(()=>{x(H=>(R0(!H),!H))},[]),Ii=C.useCallback((H,_t)=>{q(H,_t)},[q]),Ne=C.useCallback(async()=>{const _t=await $({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:Dt||"vision"});_t&&_t.id&&Or(_t.id)},[$,Dt]),ja=C.useCallback(async H=>{await O(H),Ae===H&&(V(null),qe(null))},[O,Ae,qe]),Fi=C.useCallback(H=>{const _t=F.find(St=>St.id===H);_t&&(V(_t.itemId),qe({type:"item",id:_t.itemId}))},[F,qe]),r_=C.useCallback(async H=>I(H),[I]),n_=C.useCallback(async H=>A(H),[A]),i_=C.useCallback(()=>{Rt("/api/build/state").then(H=>H.json()).then(H=>Z(H.state??null)).catch(()=>{})},[Z]),s_=C.useCallback(H=>{qe({type:"step",id:H})},[qe]),La=C.useCallback(H=>{const _t=w.find(cr=>cr.id===H);if(!_t)return;const St=(_t.description||"").match(/Track:\s*(\w+)/i),de=St?St[1].toLowerCase():null;ce&&de&&ce!==de&&Fr(null),de&&Me&&!Me.has(de)&&ge(cr=>{const ro=new Set(cr);return ro.add(de),ro})},[w,ce,Me]),o_=C.useCallback(H=>{La(H),V(H),qe({type:"item",id:H}),Ee("graph")},[Ee,qe,La]),a_=C.useCallback(H=>{La(H),V(H),qe({type:"item",id:H}),Ee("tree")},[Ee,qe,La]),l_=C.useCallback(H=>{ar(dt),Gt(H),Ee("docs")},[dt,Ee]),c_=C.useCallback(()=>{Te&&(Ee(Te),ar(null),Gt(null))},[Te,Ee]);return h.jsx(Mc.Provider,{value:M,children:h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background overflow-hidden",style:{fontSize:`${n}px`},children:[h.jsx(wr,{zone:"header",children:h.jsxs("header",{className:"h-9 flex items-center px-3 gap-3 shrink-0 justify-between",style:{borderBottom:"1px solid hsl(var(--border))"},children:[h.jsx(nY,{projectName:dh,projectRoot:Ai,onSwitch:Ta}),h.jsx("div",{className:"flex-1 min-w-0 h-full flex items-center",children:h.jsx(sY,{tabs:a,activeTab:l,onTabChange:Cr,onOpenPalette:()=>Pr(H=>!H),badges:{gates:F.filter(H=>!H.resolvedAt).length}})}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!B&&h.jsx("span",{className:"text-[9px] uppercase tracking-wider text-destructive animate-pulse",children:"disconnected"}),h.jsx("button",{className:"compose-btn-icon",onClick:Kt,title:s?"Switch to light mode":"Switch to dark mode",children:s?"☀":"☾"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{className:"compose-btn-icon",onClick:()=>ke(-1),disabled:n<=Qd,title:"Decrease font size",children:"A−"}),h.jsx("span",{className:"text-[10px] tabular-nums min-w-[20px] text-center text-muted-foreground",children:n}),h.jsx("button",{className:"compose-btn-icon",onClick:()=>ke(1),disabled:n>=Jd,title:"Increase font size",children:"A+"})]}),h.jsx("button",{className:"compose-btn-icon",onClick:xe,disabled:n===Uo,title:"Reset font size",children:"1:1"})]})]})}),h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[!_a&&h.jsxs("div",{className:"flex-1 min-h-0 flex overflow-hidden",children:[h.jsx(wr,{zone:"sidebar",children:h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:lr,title:p?"Collapse sidebar":"Expand sidebar","aria-expanded":p,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:p?"‹":"›"}),p&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0 order-last",onMouseDown:wt}),p&&(dt==="design"?h.jsx(PK,{decisions:e,sessionComplete:r==="complete",onReviseDecision:H=>Wn.getState().reviseDecision(H),widthPx:T}):h.jsx(d1,{items:w,gates:F,activeBuild:at,onViewChange:Ee,selectedPhase:Dt,onPhaseSelect:ne,selectedTrack:ce,onTrackSelect:Fr,visibleTracks:Me,onToggleVisibleTrack:(H,_t)=>ge(St=>{if(!St){const cr=new Set(_t);return cr.delete(H),cr}const de=new Set(St);return de.has(H)?de.delete(H):de.add(H),_t&&de.size>=_t.length?null:de}),onShowAllTracks:()=>ge(null),hiddenGroups:_e,onToggleGroup:ch,searchQuery:tt,onSearchChange:kt,connected:B,agentActivity:D,agentErrors:R,spawnedAgents:j,agentRelays:S,sessionState:W,onSelectItem:Or,onStopAgent:eo,onThemeChange:ct,onNewItem:()=>Zs(!0),widthPx:T}))]})}),h.jsxs("main",{className:"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[h.jsx(WT,{featureCode:te,snapshot:te?(ue==null?void 0:ue[te])??null:null}),te&&h.jsx(zT,{currentFeatureCode:te}),h.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:h.jsx(wr,{children:h.jsx(rZ,{activeView:dt,items:w,filteredItems:jn,phaseFilteredItems:ei,phaseFilteredGates:Dr,connections:E,filteredConnections:Ea,sessions:Ct,activeBuild:at,pipelineDraft:lt,gates:F,settings:J,selectedPhase:Dt,selectedItemId:Ae,onSelect:Or,onUpdate:Ii,onCreate:Ne,onDelete:ja,onOpenGate:Fi,onCreateConnection:r_,onDeleteConnection:n_,onRefreshBuild:i_,onSelectStep:s_,onResolveGate:st,onUpdateSettings:ct,onResetSettings:zt,visibleTracks:Me,hiddenGroups:_e,buildStateMap:Na,agentOverlay:fh,spawnedAgents:j,agentRelays:S,docsSelectedFile:At,onDocsSelectedFileChange:Gt,docsPreviousView:Te,onDocsBack:c_,projectRoot:Ai,featureCode:te,focusActive:Ys,onToggleFocus:()=>Xs(H=>!H),sessionState:W,agentActivity:D,iterationStates:Mt})})})]}),dt!=="docs"&&h.jsx(wr,{children:h.jsxs(vY,{isOpen:m,onToggle:kr,widthPx:b,onResizePx:G,activeBuild:at,gates:F,agentErrors:R,items:w,children:[(g==null?void 0:g.type)==="item"&&h.jsx(lX,{itemId:g.id,onSelect:H=>{y({type:"item",id:H}),V(H)},onClose:()=>{y(null),V(null)},onOpenFile:l_,onViewInGraph:o_,onViewInTree:a_}),(g==null?void 0:g.type)==="step"&&h.jsx(xX,{stepId:g.id,tierEvents:at==null?void 0:at.tierEvents,healthEvents:(at==null?void 0:at.health_score)!=null?[{score:at.health_score,breakdown:at.health_breakdown,missing:at.health_missing}]:void 0,capabilityEvents:at==null?void 0:at.capabilityEvents}),(g==null?void 0:g.type)==="design-doc"&&h.jsx(bX,{})]})}),te&&dt!=="docs"&&h.jsx(wr,{zone:"open loops panel",children:h.jsx(GK,{featureCode:te,items:w,onAddLoop:et,onResolveLoop:pt})})]}),h.jsx(wr,{zone:"ops strip",children:h.jsx(EX,{activeView:dt,onSelectFeature:Tt})}),h.jsx(wr,{zone:"agent bar",children:h.jsx("div",{className:["shrink-0 flex flex-col overflow-hidden",_a?"flex-1 min-h-0":fY(u)].join(" "),children:h.jsx(yY,{barState:u,onStateChange:He})})})]}),h.jsx(wr,{zone:"notifications",children:h.jsx(kX,{})}),h.jsx(wr,{zone:"gate notifications",children:h.jsx($T,{onOpenGate:Fi})}),h.jsx(wr,{zone:"challenge modal",children:Bi&&(()=>{const H=w.find(_t=>_t.id===Bi);return H?h.jsx(VS,{item:H,items:w,connections:E,onUpdate:Ii,onClose:()=>Ks(null)}):null})()}),h.jsx(GS,{event:ht,items:w,onNavigate:()=>Ee("gates")}),h.jsx(wr,{zone:"command palette",children:h.jsx(rT,{open:hh,onClose:()=>Pr(!1),onSelectItem:H=>{Or(H),Pr(!1)},onSelectGate:H=>{Fi(H),Pr(!1)}})}),h.jsx(wr,{zone:"item form",children:h.jsx(OT,{open:uh,onClose:()=>Zs(!1)})}),h.jsx(wr,{zone:"settings",children:h.jsx(RT,{open:Ce,onClose:()=>pn(!1),settings:J,onSettingsChange:ct})})]})})}const DZ=Object.freeze(Object.defineProperty({__proto__:null,default:eZ},Symbol.toStringTag,{value:"Module"}));export{p6 as $,DZ as A,Z8 as B,on as C,fo as D,Mv as E,R1 as F,Wi as G,Vf as H,mZ as I,U$ as J,En as K,od as L,X as M,o6 as N,e6 as O,bF as P,vi as Q,mr as R,uZ as S,N1 as T,Ot as U,Gf as V,K$ as W,Kg as X,tC as Y,T6 as Z,CF as _,ya as a,RR as a$,m6 as a0,M6 as a1,rP as a2,tP as a3,me as a4,ee as a5,iP as a6,wZ as a7,or as a8,va as a9,Y as aA,LR as aB,ma as aC,G$ as aD,Q as aE,r6 as aF,S9 as aG,gZ as aH,xZ as aI,nC as aJ,Cv as aK,wv as aL,Vc as aM,Bg as aN,Zf as aO,Yz as aP,AZ as aQ,Ms as aR,I6 as aS,J$ as aT,X8 as aU,IZ as aV,O1 as aW,JD as aX,$n as aY,Yr as aZ,Ut as a_,V$ as aa,FZ as ab,jv as ac,Cp as ad,up as ae,u4 as af,$4 as ag,lZ as ah,Zg as ai,Xo as aj,dZ as ak,vz as al,Jz as am,Vz as an,F2 as ao,d6 as ap,f6 as aq,u6 as ar,Dn as as,Hg as at,oO as au,Xr as av,Iv as aw,hp as ax,Cl as ay,Wz as az,v as b,eP as b0,J4 as b1,hZ as b2,nP as b3,LZ as b4,n6 as b5,Y4 as b6,oP as b7,yZ as b8,bZ as b9,bv as ba,bt as bb,t6 as bc,CZ as bd,c6 as be,h6 as bf,a6 as bg,l6 as bh,Y8 as bi,vt as bj,Hr as bk,_R as bl,D6 as bm,fZ as c,kZ as d,b1 as e,vv as f,ER as g,s6 as h,i6 as i,vZ as j,Pe as k,xt as l,pZ as m,kv as n,cZ as o,xp as p,Bv as q,Sn as r,bp as s,Q4 as t,MZ as u,jZ as v,BZ as w,Qo as x,$1 as y,ga as z};
768
+ ${l.agentId.slice(0,6)}`,isAgentNode:!0,agentType:c,agentStatus:l.status||"running",agentColor:u,parent:"agent-topology"}});const p=l.parentSessionId&&i.has(l.parentSessionId)?`agent-${l.parentSessionId}`:"agent-session",f=`relay-${p}-agent-${l.agentId}`;n.has(f)||n.set(f,{data:{id:f,source:p,target:`agent-${l.agentId}`,isRelayEdge:!0}})}const s=Date.now()-3e4,o=new Set,a=l=>l==="session"?"agent-session":i.has(l)?`agent-${l}`:"agent-session";for(const l of e||[]){if(new Date(l.timestamp).getTime()<s)continue;const c=a(l.fromAgentId),u=a(l.toAgentId),d=l.direction==="dispatch"?`relay-${c}-${u}`:`relay-${u}-${c}`;o.add(d)}return{nodes:r,edges:[...n.values()],activeEdgeIds:o}}class wr extends Yt.Component{constructor(){super(...arguments);ie(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}render(){var r,n;return this.state.error?h.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-3 p-4",style:{background:"hsl(var(--background))",color:"hsl(var(--muted-foreground))"},children:[h.jsx("div",{className:"text-xs uppercase tracking-wider font-semibold",style:{color:"hsl(var(--destructive))"},children:this.props.zone?`${this.props.zone} crashed`:"panel crashed"}),h.jsx("div",{className:"text-[11px] max-w-[300px] text-center opacity-70 font-mono",children:(n=(r=this.state.error)==null?void 0:r.message)==null?void 0:n.substring(0,120)}),h.jsx("button",{className:"mt-2 px-3 py-1 text-xs rounded border",style:{borderColor:"hsl(var(--border))",color:"hsl(var(--foreground))"},onClick:()=>this.setState({error:null}),children:"retry"})]}):this.props.children}}class QK extends Yt.Component{constructor(){super(...arguments);ie(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}render(){var r,n;return this.state.error?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsxs("div",{className:"h-8 flex items-center justify-between px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--destructive) / 0.1)"},children:[h.jsxs("span",{className:"text-[10px] uppercase tracking-wider font-semibold",style:{color:"hsl(var(--destructive))"},children:["safe mode — UI crashed: ",(n=(r=this.state.error)==null?void 0:r.message)==null?void 0:n.substring(0,80)]}),h.jsx("button",{className:"px-2 py-0.5 text-[10px] rounded border",style:{borderColor:"hsl(var(--border))",color:"hsl(var(--foreground))"},onClick:()=>this.setState({error:null}),children:"retry"})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(hy,{})})]}):this.props.children}}const Zd="compose:fontSize",JK="compose:theme",Uo=13,Qd=10,Jd=20;function tZ(){try{const t=parseInt(localStorage.getItem(Zd),10);return t>=Qd&&t<=Jd?t:Uo}catch{return Uo}}const ey=new URLSearchParams(window.location.search).get("popout");function eZ(){return ey?h.jsx(YV,{path:ey}):h.jsx(QK,{children:h.jsx(nZ,{})})}function rZ({activeView:t,items:e,filteredItems:r,phaseFilteredItems:n,phaseFilteredGates:i,connections:s,filteredConnections:o,sessions:a,activeBuild:l,pipelineDraft:c,gates:u,settings:d,selectedPhase:p,selectedItemId:f,buildStateMap:m,agentOverlay:x,spawnedAgents:g,agentRelays:y,docsSelectedFile:b,onDocsSelectedFileChange:k,docsPreviousView:T,onDocsBack:_,visibleTracks:w,hiddenGroups:E,onSelect:B,onUpdate:P,onCreate:N,onDelete:M,onOpenGate:$,onCreateConnection:q,onDeleteConnection:O,onRefreshBuild:I,onSelectStep:A,onResolveGate:D,onUpdateSettings:R,onResetSettings:j,projectRoot:S,featureCode:W,focusActive:K,onToggleFocus:F,sessionState:ht,agentActivity:st,iterationStates:J}){switch(t){case"dashboard":return h.jsx(lK,{items:n,gates:i,sessions:a,activeBuild:l,spawnedAgents:g,featureCode:W,sessionState:ht,agentActivity:st,iterationStates:J,onSelect:B,onResolveGate:D,onOpenGate:$});case"tree":return h.jsx(p1,{items:r,connections:o,selectedItemId:f,onSelect:B,onCreate:N,featureCode:W,focusActive:K,onToggleFocus:F});case"graph":return h.jsx(g1,{items:e,connections:s,selectedItemId:f,onSelect:B,visibleTracks:w,hiddenGroups:E,buildStateMap:m,resolveGate:D,gates:u,spawnedAgents:g,agentRelays:y,agentOverlay:x,featureCode:W,focusActive:K,onToggleFocus:F});case"pipeline":return h.jsx(XS,{activeBuild:l,pipelineDraft:c,onSelectStep:A,onRefresh:I});case"sessions":return h.jsx(eT,{sessions:a,items:e,onSelectItem:B,featureCode:W,focusActive:K,onToggleFocus:F});case"gates":return h.jsx(US,{gates:i,items:n,onResolve:D,onSelect:B,featureCode:W,focusActive:K,onToggleFocus:F});case"docs":return h.jsx(qS,{items:n,selectedFile:b,onSelectedFileChange:k,previousView:T,onBack:_,featureCode:W,focusActive:K,onToggleFocus:F});case"design":return h.jsx(jK,{},S);case"ideabox":return h.jsx(_K,{});case"settings":return h.jsx(YS,{settings:d,onSettingsChange:R,onReset:j});case"stratum":return h.jsx(rY,{});default:return h.jsxs("div",{className:"flex-1 flex items-center justify-center text-[12px] text-muted-foreground italic",children:["View “",t,"” not found."]})}}function nZ(){const{refresh:t}=m_(),e=Wn(H=>H.decisions),r=Wn(H=>H.status),[n,i]=C.useState(tZ),[s,o]=C.useState(()=>document.documentElement.classList.contains("dark")),[a]=C.useState(BX),[l,c]=C.useState(()=>AX(a)),[u,d]=C.useState(pY),[p,f]=C.useState(MX),[m,x]=C.useState(FX),[g,y]=C.useState(null),[b,k]=C.useState(()=>{try{return parseInt(localStorage.getItem("compose:contextWidthPx"),10)||420}catch{return 420}}),[T,_]=C.useState(()=>{try{return parseInt(localStorage.getItem("compose:sidebarWidthPx"),10)||220}catch{return 220}}),{items:w,connections:E,connected:B,uiCommand:P,clearUICommand:N,recentChanges:M,createItem:$,updateItem:q,deleteItem:O,createConnection:I,deleteConnection:A,agentActivity:D,agentErrors:R,spawnedAgents:j,agentRelays:S,sessionState:W,registerSnapshotProvider:K,gates:F,gateEvent:ht,resolveGate:st,settings:J,updateSettings:ct,resetSettings:zt,activeBuild:at,setActiveBuild:Z,pipelineDraft:lt,sessions:Ct,iterationStates:Mt,selectedPhase:Dt,setSelectedPhase:ne,statusSnapshots:ue,setStatusSnapshot:Se}=gr(Li(H=>({items:H.items,connections:H.connections,connected:H.connected,uiCommand:H.uiCommand,clearUICommand:H.clearUICommand,recentChanges:H.recentChanges,createItem:H.createItem,updateItem:H.updateItem,deleteItem:H.deleteItem,createConnection:H.createConnection,deleteConnection:H.deleteConnection,agentActivity:H.agentActivity,agentErrors:H.agentErrors,spawnedAgents:H.spawnedAgents,agentRelays:H.agentRelays,sessionState:H.sessionState,registerSnapshotProvider:H.registerSnapshotProvider,gates:H.gates,gateEvent:H.gateEvent,resolveGate:H.resolveGate,settings:H.settings,updateSettings:H.updateSettings,resetSettings:H.resetSettings,activeBuild:H.activeBuild,setActiveBuild:H.setActiveBuild,pipelineDraft:H.pipelineDraft,sessions:H.sessions,iterationStates:H.iterationStates,selectedPhase:H.selectedPhase,setSelectedPhase:H.setSelectedPhase,statusSnapshots:H.statusSnapshots,setStatusSnapshot:H.setStatusSnapshot}))),te=(W==null?void 0:W.featureCode)||null;C.useEffect(()=>{te&&(ue&&ue[te]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(te)}`).then(H=>H.json()).then(H=>{H!=null&&H.snapshot&&Se&&Se(te,H.snapshot)}).catch(()=>{}))},[te,ue,Se]);const[Ae,V]=C.useState(null),it=C.useRef(!!localStorage.getItem("compose:activeView")),[dt,Nt]=C.useState(()=>localStorage.getItem("compose:activeView")||"dashboard"),[tt,kt]=C.useState(""),G=C.useCallback(H=>{k(H),localStorage.setItem("compose:contextWidthPx",String(Math.round(H)))},[]),nt=C.useRef(!1),wt=C.useCallback(H=>{H.preventDefault(),nt.current=!0;const _t=de=>{if(!nt.current)return;const cr=de.clientX-16,ro=Math.max(160,Math.min(window.innerWidth*.4,cr));_(ro),localStorage.setItem("compose:sidebarWidthPx",String(Math.round(ro)))},St=()=>{nt.current=!1,document.removeEventListener("mousemove",_t),document.removeEventListener("mouseup",St)};document.addEventListener("mousemove",_t),document.addEventListener("mouseup",St)},[]),[At,Gt]=C.useState(null),[Te,ar]=C.useState(null),[ce,Fr]=C.useState(()=>localStorage.getItem("compose:selectedTrack")||null),[Me,ge]=C.useState(()=>{try{const H=localStorage.getItem("compose:visibleTracks");if(H){const _t=JSON.parse(H);return new Set(_t)}}catch{}return null}),[_e,Oe]=C.useState(new Set),[Ys,Xs]=C.useState(!1),ch=C.useCallback(H=>{Oe(_t=>{const St=new Set(_t);return St.has(H)?St.delete(H):St.add(H),St})},[]),[Bi,Ks]=C.useState(null),[hh,Pr]=C.useState(!1),[uh,Zs]=C.useState(!1),[Ce,pn]=C.useState(!1),[dh,Qs]=C.useState(""),[Ai,Js]=C.useState("");C.useEffect(()=>{Rt("/api/project").then(H=>H.json()).then(H=>{Qs(H.name||""),Js(H.targetRoot||"")}).catch(()=>{})},[]);const Ta=C.useCallback(async H=>{try{const St=await(await Rt("/api/project/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:H})})).json();return St.ok?(await t(),Qs(St.name),Js(St.targetRoot),!0):!1}catch{return!1}},[t]),_a=u===Ve.MAXIMIZED,Cr=C.useCallback(H=>{c(H),O0(H),Nt(H)},[]),Ee=C.useCallback(H=>{Nt(H),c(H),O0(H)},[]);C.useEffect(()=>{localStorage.setItem("compose:activeView",dt),dt!=="docs"&&(ar(null),Gt(null))},[dt]),C.useEffect(()=>{ce?localStorage.setItem("compose:selectedTrack",ce):localStorage.removeItem("compose:selectedTrack")},[ce]),C.useEffect(()=>{Ae?sessionStorage.setItem("vision-selectedItemId",Ae):sessionStorage.removeItem("vision-selectedItemId")},[Ae]),C.useEffect(()=>{try{Me?localStorage.setItem("compose:visibleTracks",JSON.stringify([...Me])):localStorage.removeItem("compose:visibleTracks")}catch{}},[Me]);const to=C.useRef(!1);C.useEffect(()=>{var H;to.current||it.current||(H=J==null?void 0:J.ui)!=null&&H.defaultView&&(Ee(J.ui.defaultView),to.current=!0)},[J]),C.useEffect(()=>{P&&(P.view&&Ee(P.view),P.phase!==void 0&&ne(P.phase),P.select!==void 0&&Or(P.select),N())},[P,N]),C.useEffect(()=>{const H=()=>{var St;return["INPUT","TEXTAREA","SELECT"].includes((St=document.activeElement)==null?void 0:St.tagName)},_t=St=>{(St.metaKey||St.ctrlKey)&&St.key==="k"&&(St.preventDefault(),Pr(de=>!de)),(St.metaKey||St.ctrlKey)&&St.key==="n"&&(St.preventDefault(),Zs(!0)),St.key===","&&!St.metaKey&&!St.ctrlKey&&!H()&&pn(!0)};return window.addEventListener("keydown",_t),()=>window.removeEventListener("keydown",_t)},[]);const jn=C.useMemo(()=>{let H=w;if(Dt&&(H=H.filter(_t=>_t.phase===Dt)),ce&&(H=H.filter(_t=>{const St=(_t.description||"").match(/Track:\s*(\w+)/i);return St&&St[1].toLowerCase()===ce})),tt){const _t=tt.toLowerCase();H=H.filter(St=>St.title.toLowerCase().includes(_t)||(St.description||"").toLowerCase().includes(_t))}return H},[w,Dt,ce,tt]),ei=C.useMemo(()=>Dt?w.filter(H=>H.phase===Dt):w,[w,Dt]),Mi=C.useMemo(()=>new Set(ei.map(H=>H.id)),[ei]),Dr=C.useMemo(()=>Dt?F.filter(H=>Mi.has(H.itemId)):F,[F,Mi,Dt]),Ea=C.useMemo(()=>{if(!Dt&&!ce&&!tt)return E;const H=new Set(jn.map(_t=>_t.id));return E.filter(_t=>H.has(_t.fromId)&&H.has(_t.toId))},[E,jn,Dt,ce,tt]),Na=C.useMemo(()=>XK(at,w,E,F),[at,w,E,F]),fh=C.useMemo(()=>ZK(j,S),[j,S]),qe=C.useCallback(H=>{y(H)},[]),Or=C.useCallback(H=>{V(_t=>_t===H?(qe(null),null):(qe({type:"item",id:H}),H))},[qe]),eo=C.useCallback(async H=>{try{await Rt(`/api/agent/${H}/stop`,{method:"POST",headers:Mo({"Content-Type":"application/json"})})}catch(_t){console.error(`[App] Failed to stop agent ${H}:`,_t.message)}},[]),ri=C.useRef(at);C.useEffect(()=>{!ri.current&&at&&at.featureItemId&&Or(at.featureItemId),ri.current=at},[at]);const Tt=C.useCallback(H=>{if(!H)return;const _t=w.find(St=>{var de,cr;return((de=St.lifecycle)==null?void 0:de.featureCode)===H||St.featureCode===H||St.feature_code===H||((cr=St.title)==null?void 0:cr.includes(H))});_t&&Or(_t.id)},[w,Or]);C.useEffect(()=>{const H=_t=>{const{featureCode:St}=_t.detail||{};St&&Tt(St)};return window.addEventListener("compose:select-feature",H),()=>window.removeEventListener("compose:select-feature",H)},[Tt]);const z=C.useCallback(H=>w.find(_t=>{var St;return((St=_t.lifecycle)==null?void 0:St.featureCode)===H})||null,[w]),et=C.useCallback(async(H,_t)=>{const St=z(H);if(!St)throw new Error(`No item found for feature ${H}`);const de=await Rt(`/api/vision/items/${St.id}/loops`,{method:"POST",headers:Mo({"Content-Type":"application/json"}),body:JSON.stringify(_t)});if(!de.ok)throw new Error(`Add loop failed: ${de.status}`)},[z]),pt=C.useCallback(async(H,_t,{note:St})=>{const de=z(H);if(!de)throw new Error(`No item found for feature ${H}`);const cr=await Rt(`/api/vision/items/${de.id}/loops/${_t}/resolve`,{method:"POST",headers:Mo({"Content-Type":"application/json"}),body:JSON.stringify({note:St})});if(!cr.ok)throw new Error(`Resolve loop failed: ${cr.status}`)},[z]);C.useEffect(()=>{K(()=>({activeView:dt,selectedPhase:Dt,searchQuery:tt,selectedItemId:Ae,totalItems:w.length,filteredCount:jn.length,connected:B}))},[K,dt,Dt,tt,Ae,w.length,jn.length,B]),C.useEffect(()=>{const H=new MutationObserver(()=>{o(document.documentElement.classList.contains("dark"))});return H.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>H.disconnect()},[]),C.useEffect(()=>{g&&!m&&(x(!0),R0(!0))},[g]),C.useEffect(()=>{dt==="design"?y({type:"design-doc"}):(g==null?void 0:g.type)==="design-doc"&&y(null)},[dt]);const Kt=C.useCallback(()=>{const H=s?"light":"dark";document.documentElement.classList.toggle("dark",H==="dark"),localStorage.setItem(JK,H),Rt("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ui:{theme:H}})}).catch(()=>{})},[s]),ke=C.useCallback(H=>{i(_t=>{const St=Math.min(Math.max(_t+H,Qd),Jd);return localStorage.setItem(Zd,St),St})},[]),xe=C.useCallback(()=>{i(Uo),localStorage.setItem(Zd,Uo)},[]),He=C.useCallback(H=>{d(H),mY(H)},[]),lr=C.useCallback(()=>{f(H=>(IX(!H),!H))},[]),kr=C.useCallback(()=>{x(H=>(R0(!H),!H))},[]),Ii=C.useCallback((H,_t)=>{q(H,_t)},[q]),Ne=C.useCallback(async()=>{const _t=await $({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:Dt||"vision"});_t&&_t.id&&Or(_t.id)},[$,Dt]),ja=C.useCallback(async H=>{await O(H),Ae===H&&(V(null),qe(null))},[O,Ae,qe]),Fi=C.useCallback(H=>{const _t=F.find(St=>St.id===H);_t&&(V(_t.itemId),qe({type:"item",id:_t.itemId}))},[F,qe]),r_=C.useCallback(async H=>I(H),[I]),n_=C.useCallback(async H=>A(H),[A]),i_=C.useCallback(()=>{Rt("/api/build/state").then(H=>H.json()).then(H=>Z(H.state??null)).catch(()=>{})},[Z]),s_=C.useCallback(H=>{qe({type:"step",id:H})},[qe]),La=C.useCallback(H=>{const _t=w.find(cr=>cr.id===H);if(!_t)return;const St=(_t.description||"").match(/Track:\s*(\w+)/i),de=St?St[1].toLowerCase():null;ce&&de&&ce!==de&&Fr(null),de&&Me&&!Me.has(de)&&ge(cr=>{const ro=new Set(cr);return ro.add(de),ro})},[w,ce,Me]),o_=C.useCallback(H=>{La(H),V(H),qe({type:"item",id:H}),Ee("graph")},[Ee,qe,La]),a_=C.useCallback(H=>{La(H),V(H),qe({type:"item",id:H}),Ee("tree")},[Ee,qe,La]),l_=C.useCallback(H=>{ar(dt),Gt(H),Ee("docs")},[dt,Ee]),c_=C.useCallback(()=>{Te&&(Ee(Te),ar(null),Gt(null))},[Te,Ee]);return h.jsx(Mc.Provider,{value:M,children:h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background overflow-hidden",style:{fontSize:`${n}px`},children:[h.jsx(wr,{zone:"header",children:h.jsxs("header",{className:"h-9 flex items-center px-3 gap-3 shrink-0 justify-between",style:{borderBottom:"1px solid hsl(var(--border))"},children:[h.jsx(nY,{projectName:dh,projectRoot:Ai,onSwitch:Ta}),h.jsx("div",{className:"flex-1 min-w-0 h-full flex items-center",children:h.jsx(sY,{tabs:a,activeTab:l,onTabChange:Cr,onOpenPalette:()=>Pr(H=>!H),badges:{gates:F.filter(H=>!H.resolvedAt).length}})}),h.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!B&&h.jsx("span",{className:"text-[9px] uppercase tracking-wider text-destructive animate-pulse",children:"disconnected"}),h.jsx("button",{className:"compose-btn-icon",onClick:Kt,title:s?"Switch to light mode":"Switch to dark mode",children:s?"☀":"☾"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{className:"compose-btn-icon",onClick:()=>ke(-1),disabled:n<=Qd,title:"Decrease font size",children:"A−"}),h.jsx("span",{className:"text-[10px] tabular-nums min-w-[20px] text-center text-muted-foreground",children:n}),h.jsx("button",{className:"compose-btn-icon",onClick:()=>ke(1),disabled:n>=Jd,title:"Increase font size",children:"A+"})]}),h.jsx("button",{className:"compose-btn-icon",onClick:xe,disabled:n===Uo,title:"Reset to default size",children:"100%"})]})]})}),h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[!_a&&h.jsxs("div",{className:"flex-1 min-h-0 flex overflow-hidden",children:[h.jsx(wr,{zone:"sidebar",children:h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:lr,title:p?"Collapse sidebar":"Expand sidebar","aria-expanded":p,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:p?"‹":"›"}),p&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0 order-last",onMouseDown:wt}),p&&(dt==="design"?h.jsx(PK,{decisions:e,sessionComplete:r==="complete",onReviseDecision:H=>Wn.getState().reviseDecision(H),widthPx:T}):h.jsx(d1,{items:w,gates:F,activeBuild:at,onViewChange:Ee,selectedPhase:Dt,onPhaseSelect:ne,selectedTrack:ce,onTrackSelect:Fr,visibleTracks:Me,onToggleVisibleTrack:(H,_t)=>ge(St=>{if(!St){const cr=new Set(_t);return cr.delete(H),cr}const de=new Set(St);return de.has(H)?de.delete(H):de.add(H),_t&&de.size>=_t.length?null:de}),onShowAllTracks:()=>ge(null),hiddenGroups:_e,onToggleGroup:ch,searchQuery:tt,onSearchChange:kt,connected:B,agentActivity:D,agentErrors:R,spawnedAgents:j,agentRelays:S,sessionState:W,onSelectItem:Or,onStopAgent:eo,onThemeChange:ct,onNewItem:()=>Zs(!0),widthPx:T}))]})}),h.jsxs("main",{className:"flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden",children:[h.jsx(WT,{featureCode:te,snapshot:te?(ue==null?void 0:ue[te])??null:null}),te&&h.jsx(zT,{currentFeatureCode:te}),h.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:h.jsx(wr,{children:h.jsx(rZ,{activeView:dt,items:w,filteredItems:jn,phaseFilteredItems:ei,phaseFilteredGates:Dr,connections:E,filteredConnections:Ea,sessions:Ct,activeBuild:at,pipelineDraft:lt,gates:F,settings:J,selectedPhase:Dt,selectedItemId:Ae,onSelect:Or,onUpdate:Ii,onCreate:Ne,onDelete:ja,onOpenGate:Fi,onCreateConnection:r_,onDeleteConnection:n_,onRefreshBuild:i_,onSelectStep:s_,onResolveGate:st,onUpdateSettings:ct,onResetSettings:zt,visibleTracks:Me,hiddenGroups:_e,buildStateMap:Na,agentOverlay:fh,spawnedAgents:j,agentRelays:S,docsSelectedFile:At,onDocsSelectedFileChange:Gt,docsPreviousView:Te,onDocsBack:c_,projectRoot:Ai,featureCode:te,focusActive:Ys,onToggleFocus:()=>Xs(H=>!H),sessionState:W,agentActivity:D,iterationStates:Mt})})})]}),dt!=="docs"&&h.jsx(wr,{children:h.jsxs(vY,{isOpen:m,onToggle:kr,widthPx:b,onResizePx:G,activeBuild:at,gates:F,agentErrors:R,items:w,children:[(g==null?void 0:g.type)==="item"&&h.jsx(lX,{itemId:g.id,onSelect:H=>{y({type:"item",id:H}),V(H)},onClose:()=>{y(null),V(null)},onOpenFile:l_,onViewInGraph:o_,onViewInTree:a_}),(g==null?void 0:g.type)==="step"&&h.jsx(xX,{stepId:g.id,tierEvents:at==null?void 0:at.tierEvents,healthEvents:(at==null?void 0:at.health_score)!=null?[{score:at.health_score,breakdown:at.health_breakdown,missing:at.health_missing}]:void 0,capabilityEvents:at==null?void 0:at.capabilityEvents}),(g==null?void 0:g.type)==="design-doc"&&h.jsx(bX,{})]})}),te&&dt!=="docs"&&h.jsx(wr,{zone:"open loops panel",children:h.jsx(GK,{featureCode:te,items:w,onAddLoop:et,onResolveLoop:pt})})]}),h.jsx(wr,{zone:"ops strip",children:h.jsx(EX,{activeView:dt,onSelectFeature:Tt})}),h.jsx(wr,{zone:"agent bar",children:h.jsx("div",{className:["shrink-0 flex flex-col overflow-hidden",_a?"flex-1 min-h-0":fY(u)].join(" "),children:h.jsx(yY,{barState:u,onStateChange:He})})})]}),h.jsx(wr,{zone:"notifications",children:h.jsx(kX,{})}),h.jsx(wr,{zone:"gate notifications",children:h.jsx($T,{onOpenGate:Fi})}),h.jsx(wr,{zone:"challenge modal",children:Bi&&(()=>{const H=w.find(_t=>_t.id===Bi);return H?h.jsx(VS,{item:H,items:w,connections:E,onUpdate:Ii,onClose:()=>Ks(null)}):null})()}),h.jsx(GS,{event:ht,items:w,onNavigate:()=>Ee("gates")}),h.jsx(wr,{zone:"command palette",children:h.jsx(rT,{open:hh,onClose:()=>Pr(!1),onSelectItem:H=>{Or(H),Pr(!1)},onSelectGate:H=>{Fi(H),Pr(!1)}})}),h.jsx(wr,{zone:"item form",children:h.jsx(OT,{open:uh,onClose:()=>Zs(!1)})}),h.jsx(wr,{zone:"settings",children:h.jsx(RT,{open:Ce,onClose:()=>pn(!1),settings:J,onSettingsChange:ct})})]})})}const DZ=Object.freeze(Object.defineProperty({__proto__:null,default:eZ},Symbol.toStringTag,{value:"Module"}));export{p6 as $,DZ as A,Z8 as B,on as C,fo as D,Mv as E,R1 as F,Wi as G,Vf as H,mZ as I,U$ as J,En as K,od as L,X as M,o6 as N,e6 as O,bF as P,vi as Q,mr as R,uZ as S,N1 as T,Ot as U,Gf as V,K$ as W,Kg as X,tC as Y,T6 as Z,CF as _,ya as a,RR as a$,m6 as a0,M6 as a1,rP as a2,tP as a3,me as a4,ee as a5,iP as a6,wZ as a7,or as a8,va as a9,Y as aA,LR as aB,ma as aC,G$ as aD,Q as aE,r6 as aF,S9 as aG,gZ as aH,xZ as aI,nC as aJ,Cv as aK,wv as aL,Vc as aM,Bg as aN,Zf as aO,Yz as aP,AZ as aQ,Ms as aR,I6 as aS,J$ as aT,X8 as aU,IZ as aV,O1 as aW,JD as aX,$n as aY,Yr as aZ,Ut as a_,V$ as aa,FZ as ab,jv as ac,Cp as ad,up as ae,u4 as af,$4 as ag,lZ as ah,Zg as ai,Xo as aj,dZ as ak,vz as al,Jz as am,Vz as an,F2 as ao,d6 as ap,f6 as aq,u6 as ar,Dn as as,Hg as at,oO as au,Xr as av,Iv as aw,hp as ax,Cl as ay,Wz as az,v as b,eP as b0,J4 as b1,hZ as b2,nP as b3,LZ as b4,n6 as b5,Y4 as b6,oP as b7,yZ as b8,bZ as b9,bv as ba,bt as bb,t6 as bc,CZ as bd,c6 as be,h6 as bf,a6 as bg,l6 as bh,Y8 as bi,vt as bj,Hr as bk,_R as bl,D6 as bm,fZ as c,kZ as d,b1 as e,vv as f,ER as g,s6 as h,i6 as i,vZ as j,Pe as k,xt as l,pZ as m,kv as n,cZ as o,xp as p,Bv as q,Sn as r,bp as s,Q4 as t,MZ as u,jZ as v,BZ as w,Qo as x,$1 as y,ga as z};