@smartmemory/compose 0.2.2-beta → 0.2.3-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 (67) hide show
  1. package/contracts/checkpoint.schema.json +85 -0
  2. package/dist/assets/{App-QGVt8tH2.js → App-j8fWZcGr.js} +5 -5
  3. package/dist/assets/{arc-yX1Dy9Ls.js → arc-BFqOo_jJ.js} +1 -1
  4. package/dist/assets/{architectureDiagram-3BPJPVTR-BhtVN7Go.js → architectureDiagram-3BPJPVTR-D722w0RE.js} +1 -1
  5. package/dist/assets/{blockDiagram-GPEHLZMM-Do_uWvAL.js → blockDiagram-GPEHLZMM-B4w0mOAJ.js} +1 -1
  6. package/dist/assets/{c4Diagram-AAUBKEIU-DhjfNEZ_.js → c4Diagram-AAUBKEIU-D6LE8-j8.js} +1 -1
  7. package/dist/assets/channel-BD-5_hPW.js +1 -0
  8. package/dist/assets/{chunk-2J33WTMH-ZLuzLSr5.js → chunk-2J33WTMH-CrazA7xu.js} +1 -1
  9. package/dist/assets/{chunk-4BX2VUAB-BkfYx42O.js → chunk-4BX2VUAB-Cp90GiCM.js} +1 -1
  10. package/dist/assets/{chunk-55IACEB6-UGWHui37.js → chunk-55IACEB6-Bnais1SK.js} +1 -1
  11. package/dist/assets/{chunk-727SXJPM-DENLKVEd.js → chunk-727SXJPM-kD07Sqp5.js} +1 -1
  12. package/dist/assets/{chunk-AQP2D5EJ-BV-AIq0h.js → chunk-AQP2D5EJ-DmIxhJc8.js} +1 -1
  13. package/dist/assets/{chunk-FMBD7UC4-BO5q1BN_.js → chunk-FMBD7UC4-Jti_und8.js} +1 -1
  14. package/dist/assets/{chunk-ND2GUHAM-rAAtIsqf.js → chunk-ND2GUHAM-Ipx3noKz.js} +1 -1
  15. package/dist/assets/{chunk-QZHKN3VN-DmZo3sCU.js → chunk-QZHKN3VN-CeblRnPF.js} +1 -1
  16. package/dist/assets/classDiagram-4FO5ZUOK-mSW5R7DY.js +1 -0
  17. package/dist/assets/classDiagram-v2-Q7XG4LA2-mSW5R7DY.js +1 -0
  18. package/dist/assets/{cose-bilkent-S5V4N54A-BlBShGhI.js → cose-bilkent-S5V4N54A-fNQlSmHt.js} +1 -1
  19. package/dist/assets/{dagre-BM42HDAG-urcL7_B8.js → dagre-BM42HDAG-D27D6YAL.js} +1 -1
  20. package/dist/assets/{diagram-2AECGRRQ-DlfCvqLR.js → diagram-2AECGRRQ-CtXeohzN.js} +1 -1
  21. package/dist/assets/{diagram-5GNKFQAL-h5gTsYDo.js → diagram-5GNKFQAL-C_BqZkx0.js} +1 -1
  22. package/dist/assets/{diagram-KO2AKTUF-BbEbRrVo.js → diagram-KO2AKTUF-B29ynQz4.js} +1 -1
  23. package/dist/assets/{diagram-LMA3HP47-jog00Zl2.js → diagram-LMA3HP47-DAYJMc2I.js} +1 -1
  24. package/dist/assets/{diagram-OG6HWLK6-B0JVsR6S.js → diagram-OG6HWLK6-CBJMis3l.js} +1 -1
  25. package/dist/assets/{erDiagram-TEJ5UH35-DkUnalKg.js → erDiagram-TEJ5UH35-nd3GWiPn.js} +1 -1
  26. package/dist/assets/{flowDiagram-I6XJVG4X-DewNd_kM.js → flowDiagram-I6XJVG4X-HFUno_nV.js} +1 -1
  27. package/dist/assets/{ganttDiagram-6RSMTGT7-DzDBcVj5.js → ganttDiagram-6RSMTGT7-CPPAAjwR.js} +1 -1
  28. package/dist/assets/{gitGraphDiagram-PVQCEYII-D0CX5WgP.js → gitGraphDiagram-PVQCEYII-NBq1F6K2.js} +1 -1
  29. package/dist/assets/{index-D4GJb_6L.js → index-uHKnp74B.js} +2 -2
  30. package/dist/assets/{infoDiagram-5YYISTIA-B1zzuW9l.js → infoDiagram-5YYISTIA-D-TOBtCq.js} +1 -1
  31. package/dist/assets/{ishikawaDiagram-YF4QCWOH-3hFmuv1F.js → ishikawaDiagram-YF4QCWOH-nXOztZiZ.js} +1 -1
  32. package/dist/assets/{journeyDiagram-JHISSGLW-w9c-l95A.js → journeyDiagram-JHISSGLW-Bko3tTdh.js} +1 -1
  33. package/dist/assets/{kanban-definition-UN3LZRKU-9cL90JL0.js → kanban-definition-UN3LZRKU-1e-7i8st.js} +1 -1
  34. package/dist/assets/{linear-DyDb5wz8.js → linear-Dx5ZJB7F.js} +1 -1
  35. package/dist/assets/{mindmap-definition-RKZ34NQL-DBQqsZiD.js → mindmap-definition-RKZ34NQL-CNwNkDqN.js} +1 -1
  36. package/dist/assets/{pieDiagram-4H26LBE5-BbIHZku5.js → pieDiagram-4H26LBE5-C5fvCej-.js} +1 -1
  37. package/dist/assets/{quadrantDiagram-W4KKPZXB-DEQSG_lM.js → quadrantDiagram-W4KKPZXB-4NoQsF61.js} +1 -1
  38. package/dist/assets/{requirementDiagram-4Y6WPE33-BeVnwIwF.js → requirementDiagram-4Y6WPE33-q5WxB9LO.js} +1 -1
  39. package/dist/assets/{sankeyDiagram-5OEKKPKP-Be-ROw_I.js → sankeyDiagram-5OEKKPKP-DlQNB367.js} +1 -1
  40. package/dist/assets/{sequenceDiagram-3UESZ5HK-E-tnxahu.js → sequenceDiagram-3UESZ5HK-BzHclOKt.js} +1 -1
  41. package/dist/assets/{stateDiagram-AJRCARHV-3rgFN7hL.js → stateDiagram-AJRCARHV-BvWRI9zK.js} +1 -1
  42. package/dist/assets/stateDiagram-v2-BHNVJYJU-CDlF0VA8.js +1 -0
  43. package/dist/assets/{timeline-definition-PNZ67QCA-Dcs4QFbE.js → timeline-definition-PNZ67QCA-j2wKjAti.js} +1 -1
  44. package/dist/assets/{vennDiagram-CIIHVFJN-BstUQ900.js → vennDiagram-CIIHVFJN-B77g7htC.js} +1 -1
  45. package/dist/assets/{wardley-L42UT6IY-CO77hXwj.js → wardley-L42UT6IY-83Im2mo2.js} +1 -1
  46. package/dist/assets/{wardleyDiagram-YWT4CUSO-BvrP3shF.js → wardleyDiagram-YWT4CUSO-CK-XB-bO.js} +1 -1
  47. package/dist/assets/{xychartDiagram-2RQKCTM6-Btu4JcQO.js → xychartDiagram-2RQKCTM6-D42FcVOY.js} +1 -1
  48. package/dist/index.html +1 -1
  49. package/lib/checkpoint/anchor.js +66 -0
  50. package/lib/checkpoint/atomic.js +83 -0
  51. package/lib/checkpoint/checkpoint-writer.js +131 -0
  52. package/lib/checkpoint/fingerprint.js +145 -0
  53. package/lib/checkpoint/git.js +58 -0
  54. package/lib/checkpoint/prompts.js +206 -0
  55. package/lib/checkpoint/reconciler.js +207 -0
  56. package/lib/checkpoint/render.js +107 -0
  57. package/lib/checkpoint/store/index.js +67 -0
  58. package/lib/checkpoint/store/jsonl.js +80 -0
  59. package/package.json +1 -1
  60. package/server/compose-mcp-tools.js +30 -0
  61. package/server/compose-mcp.js +40 -0
  62. package/server/session-routes.js +65 -0
  63. package/server/vision-routes.js +15 -0
  64. package/dist/assets/channel-D6hNrRZ2.js +0 -1
  65. package/dist/assets/classDiagram-4FO5ZUOK-DvsVLUph.js +0 -1
  66. package/dist/assets/classDiagram-v2-Q7XG4LA2-DvsVLUph.js +0 -1
  67. package/dist/assets/stateDiagram-v2-BHNVJYJU-DY_OtnIg.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-BM42HDAG-urcL7_B8.js","assets/graph-CAnANduQ.js","assets/layout-DGIYPm2g.js","assets/mobile-CG5tLa2S.js","assets/mobile-5PV1E6OC.css","assets/index-D4GJb_6L.js","assets/index-jqUffYBL.css","assets/graph-CJVNlri5.js","assets/cose-bilkent-S5V4N54A-BlBShGhI.js","assets/c4Diagram-AAUBKEIU-DhjfNEZ_.js","assets/chunk-ND2GUHAM-rAAtIsqf.js","assets/flowDiagram-I6XJVG4X-DewNd_kM.js","assets/chunk-FMBD7UC4-BO5q1BN_.js","assets/chunk-55IACEB6-UGWHui37.js","assets/chunk-2J33WTMH-ZLuzLSr5.js","assets/channel-D6hNrRZ2.js","assets/erDiagram-TEJ5UH35-DkUnalKg.js","assets/gitGraphDiagram-PVQCEYII-D0CX5WgP.js","assets/chunk-4BX2VUAB-BkfYx42O.js","assets/chunk-QZHKN3VN-DmZo3sCU.js","assets/wardley-L42UT6IY-CO77hXwj.js","assets/ganttDiagram-6RSMTGT7-DzDBcVj5.js","assets/linear-DyDb5wz8.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-DX6XiGOO.js","assets/infoDiagram-5YYISTIA-B1zzuW9l.js","assets/pieDiagram-4H26LBE5-BbIHZku5.js","assets/arc-yX1Dy9Ls.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-W4KKPZXB-DEQSG_lM.js","assets/xychartDiagram-2RQKCTM6-Btu4JcQO.js","assets/requirementDiagram-4Y6WPE33-BeVnwIwF.js","assets/sequenceDiagram-3UESZ5HK-E-tnxahu.js","assets/classDiagram-4FO5ZUOK-DvsVLUph.js","assets/chunk-727SXJPM-DENLKVEd.js","assets/classDiagram-v2-Q7XG4LA2-DvsVLUph.js","assets/stateDiagram-AJRCARHV-3rgFN7hL.js","assets/chunk-AQP2D5EJ-BV-AIq0h.js","assets/stateDiagram-v2-BHNVJYJU-DY_OtnIg.js","assets/journeyDiagram-JHISSGLW-w9c-l95A.js","assets/timeline-definition-PNZ67QCA-Dcs4QFbE.js","assets/mindmap-definition-RKZ34NQL-DBQqsZiD.js","assets/kanban-definition-UN3LZRKU-9cL90JL0.js","assets/sankeyDiagram-5OEKKPKP-Be-ROw_I.js","assets/diagram-LMA3HP47-jog00Zl2.js","assets/diagram-2AECGRRQ-DlfCvqLR.js","assets/blockDiagram-GPEHLZMM-Do_uWvAL.js","assets/diagram-5GNKFQAL-h5gTsYDo.js","assets/architectureDiagram-3BPJPVTR-BhtVN7Go.js","assets/diagram-KO2AKTUF-BbEbRrVo.js","assets/ishikawaDiagram-YF4QCWOH-3hFmuv1F.js","assets/vennDiagram-CIIHVFJN-BstUQ900.js","assets/diagram-OG6HWLK6-B0JVsR6S.js","assets/wardleyDiagram-YWT4CUSO-BvrP3shF.js"])))=>i.map(i=>d[i]);
2
- var d_=Object.defineProperty;var f_=(t,e,r)=>e in t?d_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>f_(t,typeof e!="symbol"?e+"":e,r);import{a as C,j as h,R as Yt,b as p_,g as Ac,w as zt,d as m_,e as cf,f as ds}from"./mobile-CG5tLa2S.js";import{r as g_,_ as Jt,u as x_}from"./index-D4GJb_6L.js";import{c as ma,b as ay,f as y_}from"./graph-CJVNlri5.js";const gr={feature:"#3b82f6",bug:"#ef4444",track:"#06b6d4",decision:"#22c55e",task:"#94a3b8",spec:"#8b5cf6",idea:"#f59e0b",question:"#ec4899",evaluation:"#f97316",thread:"#64748b",artifact:"#a855f7"},Vn={planned:"#64748b",ready:"#0ea5e9",in_progress:"#3b82f6",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#475569",killed:"#1e293b"},b_=["planned","ready","in_progress","review","complete","blocked","parked","killed"],ly=["vision","specification","planning","implementation","verification","release"],Fl={vision:"Vision",specification:"Specification",planning:"Planning",implementation:"Implementation",verification:"Verification",release:"Release"},hf=["Untested","Low","Moderate","High","Crystallized"],Te={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"},cy={explore_design:"design.md",prd:"prd.md",architecture:"architecture.md",blueprint:"blueprint.md",plan:"plan.md",report:"report.md"},hy=["claude","codex","gemini","human","unassigned"],tm={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"},bh=[{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}],wn={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 Jo(t,e){const r=wn[t.stepId]??(t.fromPhase&&t.toPhase?`${Te[t.fromPhase]??t.fromPhase} → ${Te[t.toPhase]??t.toPhase}`:"Gate"),n=(e==null?void 0:e.title)||t.featureCode||null;return n?`${r} — ${n}`:r}const em={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"}},C_={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%)"},rm={complete:"hsl(var(--success, 160 60% 45%))",active:"hsl(var(--accent))",failed:"hsl(var(--destructive))",pending:"hsl(var(--muted-foreground) / 0.3)"},k_={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"},v_={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"}},w_={bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground"},nm=["bg-slate-600","bg-rose-500","bg-amber-500","bg-emerald-500","bg-emerald-500"],S_={info:"text-zinc-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400"},T_={phase:"text-blue-400",gate:"text-purple-400",session:"text-zinc-400",iteration:"text-blue-300",error:"text-red-400"},__={"compose-explorer":"#06b6d4","compose-architect":"#a855f7",codex:"#10b981",claude:"#3b82f6"},im={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))"},uy={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 E_(t,e){return!Array.isArray(t)||t.length===0?"hidden":e?"expanded":"collapsed"}function N_(t){return`violations (${Array.isArray(t)?t.length:0})`}function j_(t){return t?"▾":"▸"}function L_({violations:t=[],expanded:e,onToggle:r}){const[n,i]=C.useState(!1),s=e!==void 0,o=s?e:n,a=E_(t,o);if(a==="hidden")return null;function l(){s?r==null||r():i(d=>!d)}const c=j_(o),u=N_(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 B_({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(L_,{violations:s,expanded:!0,onToggle:()=>n(!1)})]})}const A_=/\b(Error|error:|Traceback|FAILED|ENOENT|Cannot find)\b/,sm=20;function M_({summary:t,output:e}){const[r,n]=C.useState(!1),[i,s]=C.useState(!1),o=e?A_.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-D27D6YAL.js","assets/graph-CAnANduQ.js","assets/layout-DGIYPm2g.js","assets/mobile-CG5tLa2S.js","assets/mobile-5PV1E6OC.css","assets/index-uHKnp74B.js","assets/index-jqUffYBL.css","assets/graph-CJVNlri5.js","assets/cose-bilkent-S5V4N54A-fNQlSmHt.js","assets/c4Diagram-AAUBKEIU-D6LE8-j8.js","assets/chunk-ND2GUHAM-Ipx3noKz.js","assets/flowDiagram-I6XJVG4X-HFUno_nV.js","assets/chunk-FMBD7UC4-Jti_und8.js","assets/chunk-55IACEB6-Bnais1SK.js","assets/chunk-2J33WTMH-CrazA7xu.js","assets/channel-BD-5_hPW.js","assets/erDiagram-TEJ5UH35-nd3GWiPn.js","assets/gitGraphDiagram-PVQCEYII-NBq1F6K2.js","assets/chunk-4BX2VUAB-Cp90GiCM.js","assets/chunk-QZHKN3VN-CeblRnPF.js","assets/wardley-L42UT6IY-83Im2mo2.js","assets/ganttDiagram-6RSMTGT7-CPPAAjwR.js","assets/linear-Dx5ZJB7F.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-DX6XiGOO.js","assets/infoDiagram-5YYISTIA-D-TOBtCq.js","assets/pieDiagram-4H26LBE5-C5fvCej-.js","assets/arc-BFqOo_jJ.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-W4KKPZXB-4NoQsF61.js","assets/xychartDiagram-2RQKCTM6-D42FcVOY.js","assets/requirementDiagram-4Y6WPE33-q5WxB9LO.js","assets/sequenceDiagram-3UESZ5HK-BzHclOKt.js","assets/classDiagram-4FO5ZUOK-mSW5R7DY.js","assets/chunk-727SXJPM-kD07Sqp5.js","assets/classDiagram-v2-Q7XG4LA2-mSW5R7DY.js","assets/stateDiagram-AJRCARHV-BvWRI9zK.js","assets/chunk-AQP2D5EJ-DmIxhJc8.js","assets/stateDiagram-v2-BHNVJYJU-CDlF0VA8.js","assets/journeyDiagram-JHISSGLW-Bko3tTdh.js","assets/timeline-definition-PNZ67QCA-j2wKjAti.js","assets/mindmap-definition-RKZ34NQL-CNwNkDqN.js","assets/kanban-definition-UN3LZRKU-1e-7i8st.js","assets/sankeyDiagram-5OEKKPKP-DlQNB367.js","assets/diagram-LMA3HP47-DAYJMc2I.js","assets/diagram-2AECGRRQ-CtXeohzN.js","assets/blockDiagram-GPEHLZMM-B4w0mOAJ.js","assets/diagram-5GNKFQAL-C_BqZkx0.js","assets/architectureDiagram-3BPJPVTR-D722w0RE.js","assets/diagram-KO2AKTUF-B29ynQz4.js","assets/ishikawaDiagram-YF4QCWOH-nXOztZiZ.js","assets/vennDiagram-CIIHVFJN-B77g7htC.js","assets/diagram-OG6HWLK6-CBJMis3l.js","assets/wardleyDiagram-YWT4CUSO-CK-XB-bO.js"])))=>i.map(i=>d[i]);
2
+ var d_=Object.defineProperty;var f_=(t,e,r)=>e in t?d_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>f_(t,typeof e!="symbol"?e+"":e,r);import{a as C,j as h,R as Yt,b as p_,g as Ac,w as zt,d as m_,e as cf,f as ds}from"./mobile-CG5tLa2S.js";import{r as g_,_ as Jt,u as x_}from"./index-uHKnp74B.js";import{c as ma,b as ay,f as y_}from"./graph-CJVNlri5.js";const gr={feature:"#3b82f6",bug:"#ef4444",track:"#06b6d4",decision:"#22c55e",task:"#94a3b8",spec:"#8b5cf6",idea:"#f59e0b",question:"#ec4899",evaluation:"#f97316",thread:"#64748b",artifact:"#a855f7"},Vn={planned:"#64748b",ready:"#0ea5e9",in_progress:"#3b82f6",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#475569",killed:"#1e293b"},b_=["planned","ready","in_progress","review","complete","blocked","parked","killed"],ly=["vision","specification","planning","implementation","verification","release"],Fl={vision:"Vision",specification:"Specification",planning:"Planning",implementation:"Implementation",verification:"Verification",release:"Release"},hf=["Untested","Low","Moderate","High","Crystallized"],Te={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"},cy={explore_design:"design.md",prd:"prd.md",architecture:"architecture.md",blueprint:"blueprint.md",plan:"plan.md",report:"report.md"},hy=["claude","codex","gemini","human","unassigned"],tm={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"},bh=[{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}],wn={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 Jo(t,e){const r=wn[t.stepId]??(t.fromPhase&&t.toPhase?`${Te[t.fromPhase]??t.fromPhase} → ${Te[t.toPhase]??t.toPhase}`:"Gate"),n=(e==null?void 0:e.title)||t.featureCode||null;return n?`${r} — ${n}`:r}const em={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"}},C_={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%)"},rm={complete:"hsl(var(--success, 160 60% 45%))",active:"hsl(var(--accent))",failed:"hsl(var(--destructive))",pending:"hsl(var(--muted-foreground) / 0.3)"},k_={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"},v_={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"}},w_={bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground"},nm=["bg-slate-600","bg-rose-500","bg-amber-500","bg-emerald-500","bg-emerald-500"],S_={info:"text-zinc-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400"},T_={phase:"text-blue-400",gate:"text-purple-400",session:"text-zinc-400",iteration:"text-blue-300",error:"text-red-400"},__={"compose-explorer":"#06b6d4","compose-architect":"#a855f7",codex:"#10b981",claude:"#3b82f6"},im={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))"},uy={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 E_(t,e){return!Array.isArray(t)||t.length===0?"hidden":e?"expanded":"collapsed"}function N_(t){return`violations (${Array.isArray(t)?t.length:0})`}function j_(t){return t?"▾":"▸"}function L_({violations:t=[],expanded:e,onToggle:r}){const[n,i]=C.useState(!1),s=e!==void 0,o=s?e:n,a=E_(t,o);if(a==="hidden")return null;function l(){s?r==null||r():i(d=>!d)}const c=j_(o),u=N_(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 B_({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(L_,{violations:s,expanded:!0,onToggle:()=>n(!1)})]})}const A_=/\b(Error|error:|Traceback|FAILED|ENOENT|Cannot find)\b/,sm=20;function M_({summary:t,output:e}){const[r,n]=C.useState(!1),[i,s]=C.useState(!1),o=e?A_.test(e):!1,a=e!=null&&e.length>0,l=a?e.split(`
3
3
  `):[],c=l.length>sm,u=r&&!i&&c?l.slice(0,sm):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
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 I_={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 F_(t){return C_[I_[t]||"thinking"]}function P_(t){return t?t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`:""}function D_(t){return t==null?"":t<.001?"<$0.001":`$${t.toFixed(3)}`}function O_({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 R_({block:t}){const e=F_(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(O_,{input:t.input})]})}function $_({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(R_,{block:n}),s&&t._toolResult&&h.jsx(M_,{summary:t._toolResult.summary,output:t._toolResult.output})]},i)}return null})})}function z_({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:P_(t.duration_ms)}),t.total_cost_usd!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:D_(t.total_cost_usd)}),e&&t.errors&&h.jsx("span",{style:{color:"hsl(var(--destructive))"},children:t.errors.join("; ")})]})}function W_({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 q_({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(B_,{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($_,{msg:t}):t.type==="user"?h.jsx(W_,{msg:t}):t.type==="result"?h.jsx(z_,{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 H_({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 dy="compose:verboseStream",Pl={verboseStream:!1};function fy(){return Pl.verboseStream}function U_(t,e){Pl.verboseStream=!!t;const r=typeof localStorage<"u"?localStorage:null;if(r)try{r.setItem(dy,String(Pl.verboseStream))}catch{}}function G_(t){const e=typeof localStorage<"u"?localStorage:null;if(e)try{const r=e.getItem(dy);r!==null&&(Pl.verboseStream=r==="true")}catch{}}function V_(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 Y_(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 py=parseInt("4002",10),X_="compose-agent-session",om=500,K_=8,Z_=2e3,my=3e4,am={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"},Q_={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking",waiting:"Waiting for gate approval"};G_();const Z={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,streamError:null,retryInfo:null,stalled:!1,onConnectedChange:null,onMessagesChange:null,onAgentStatusChange:null,onStreamErrorChange:null};function J_(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=am[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=am[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 Ch(t,e,r){const n=Date.now(),i=Z.agentStatus,s=Z.agentTool;if(Z._idleTimer&&(clearTimeout(Z._idleTimer),Z._idleTimer=null),i==="working"&&(t==="idle"||e!==s)){const a=Z.currentActivity;a&&(a.endTime=n,a.duration=n-a.startTime,Z.activityLog.push(a),Z.activityLog.length>K_&&Z.activityLog.shift())}t==="working"&&e!==s?Z.currentActivity={tool:e,category:r,startTime:n,endTime:null,duration:null}:t==="idle"&&(Z.currentActivity=null),Z.agentStatus=t,Z.agentTool=e,Z.agentCategory=r;const o={status:t,tool:e,category:r,activityLog:Z.activityLog,currentActivity:Z.currentActivity,parallelTasks:Z.parallelTasks};Z.onAgentStatusChange&&Z.onAgentStatusChange({...o}),window.dispatchEvent(new CustomEvent("compose:agent-status",{detail:o}))}function lm(){const t=Z.sourceStatus.build,e=Z.sourceStatus.interactive;(e==null?void 0:e.status)==="working"?Ch(e.status,e.tool,e.category):(t==null?void 0:t.status)==="working"?Ch(t.status,t.tool,t.category):Z._idleTimer=setTimeout(()=>{Z._idleTimer=null,Ch("idle",null,null)},Z_)}function Du(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("∥"))?(Z.parallelTasks||(Z.parallelTasks={total:0,completed:0,failed:0,active:0,tasks:{}}),Z.parallelTasks.total++,Z.parallelTasks.active++,Z.parallelTasks.tasks[t.stepId]="working"):t.subtype==="build_step_done"&&((o=(s=Z.parallelTasks)==null?void 0:s.tasks)!=null&&o[t.stepId])?(Z.parallelTasks.active=Math.max(0,Z.parallelTasks.active-1),Z.parallelTasks.completed++,Z.parallelTasks.tasks[t.stepId]="complete"):t.subtype==="build_step_done"&&Z.parallelTasks&&!((a=t.stepNum)!=null&&a.toString().startsWith("∥"))&&(Z.parallelTasks=null)),t._source==="build"&&t.type==="error"&&((c=(l=Z.parallelTasks)==null?void 0:l.tasks)!=null&&c[t.stepId])&&(Z.parallelTasks.active=Math.max(0,Z.parallelTasks.active-1),Z.parallelTasks.failed++,Z.parallelTasks.tasks[t.stepId]="failed");const e=J_(t);if(e){const u=e._source==="build"?"build":"interactive";Z.sourceStatus[u]=e,e.status==="idle"?(Z.parallelTasks=null,lm()):(Z._idleTimer&&(clearTimeout(Z._idleTimer),Z._idleTimer=null),lm())}t.type==="system"&&t.subtype==="init"&&t.session_id&&(Z.sessionId=t.session_id,sessionStorage.setItem(X_,t.session_id));const{include:r,msg:n}=V_(t,fy());r&&(Z.messages=[...Z.messages,n],Z.messages.length>om&&(Z.messages=Z.messages.slice(-om)),Z.onMessagesChange&&Z.onMessagesChange(Z.messages))}function kh(){if(Z.es)return;const t=`${window.location.protocol}//${window.location.hostname}:${py}/api/agent/stream`,e=p_({url:t,namedEvents:["hydrate"],onOpen:()=>{Z.connected=!0,Z.streamError=null,Z.retryInfo=null,Z.stalled=!1,Z.sourceStatus.build=null,Z.onConnectedChange&&Z.onConnectedChange(!0),Z.onStreamErrorChange&&Z.onStreamErrorChange({error:null,retryInfo:null,stalled:!1})},onClose:()=>{Z.connected=!1,Z.onConnectedChange&&Z.onConnectedChange(!1)},onError:r=>{Z.streamError=(r==null?void 0:r.message)||"Connection error",Z.onStreamErrorChange&&Z.onStreamErrorChange({error:Z.streamError,retryInfo:Z.retryInfo,stalled:Z.stalled})},onRetry:r=>{Z.retryInfo=r,Z.onStreamErrorChange&&Z.onStreamErrorChange({error:Z.streamError,retryInfo:r,stalled:Z.stalled})},onStall:()=>{Z.stalled=!0,Z.onStreamErrorChange&&Z.onStreamErrorChange({error:Z.streamError,retryInfo:Z.retryInfo,stalled:!0})},onExhausted:()=>{Z.es=null,Z.retryInfo=null,Z.onStreamErrorChange&&Z.onStreamErrorChange({error:Z.streamError,retryInfo:null,stalled:Z.stalled})},onEvent:(r,n)=>{if((Z.stalled||Z.streamError)&&(Z.stalled=!1,Z.streamError=null,Z.retryInfo=null,Z.onStreamErrorChange&&Z.onStreamErrorChange({error:null,retryInfo:null,stalled:!1})),n==="hydrate"){if(Array.isArray(r))for(const i of r)Du(i);return}Du(r)},maxBackoffMs:8e3,maxRetries:5,stallTimeoutMs:my});Z.es=e}async function vh(t,e){const r=await fetch(`${window.location.protocol}//${window.location.hostname}:${py}${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 cm(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 gy(){var L;const[t,e]=C.useState(Z.connected),[r,n]=C.useState(Z.messages),[i,s]=C.useState({status:Z.agentStatus,tool:Z.agentTool,category:Z.agentCategory,activityLog:Z.activityLog,currentActivity:Z.currentActivity}),[o,a]=C.useState(!1),[l,c]=C.useState(null),[u,d]=C.useState({error:Z.streamError,retryInfo:Z.retryInfo,stalled:Z.stalled}),p=C.useRef(null),f=C.useRef(null),m=C.useRef(!1),x=r.length===0||r.every(M=>M.type==="system"&&(M.subtype==="init"||M.subtype==="connected"));C.useEffect(()=>(Z.onConnectedChange=e,Z.onMessagesChange=n,Z.onAgentStatusChange=s,Z.onStreamErrorChange=d,()=>{Z.onConnectedChange=null,Z.onMessagesChange=null,Z.onAgentStatusChange=null,Z.onStreamErrorChange=null}),[]),C.useEffect(()=>{kh()},[]);const g=C.useCallback(()=>{const M=f.current;if(!M)return;const N=M.scrollHeight-M.scrollTop-M.clientHeight<48;m.current=!N},[]);C.useEffect(()=>{var M;m.current||(M=p.current)==null||M.scrollIntoView({behavior:"smooth"})},[r.length]),C.useEffect(()=>{if(i.status!=="working"||!i.currentActivity){c(null);return}const M=i.currentActivity.startTime,N=()=>c(Date.now()-M);N();const P=setInterval(N,1e3);return()=>clearInterval(P)},[i.status,(L=i.currentActivity)==null?void 0:L.startTime]);const y=C.useCallback(async M=>{a(!0);const N=M.match(/[A-Z]+-\d+/);N&&window.dispatchEvent(new CustomEvent("compose:select-feature",{detail:{featureCode:N[0]}}));try{x||!Z.sessionId?await vh("/api/agent/session",{prompt:M}):await vh("/api/agent/message",{prompt:M})}catch(P){Du({type:"error",message:`Failed to send: ${P.message}`})}finally{a(!1)}},[x]),b=C.useCallback(async()=>{try{await vh("/api/agent/interrupt",{})}catch{}},[]),k=t&&(i.status==="working"||o),T=t?k?"#fbbf24":"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))",_=i.category?Q_[i.category]:null,w=t?k?_||"working":"ready":"offline",E=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&&E.length>0&&E.slice(-5).map((M,N)=>h.jsx("div",{className:"h-1 rounded-full",title:`${M.tool||"thinking"} — ${cm(M.duration)}`,style:{width:Math.max(6,Math.min(20,(M.duration||0)/1e3*2)),background:"hsl(var(--muted-foreground))",opacity:.25+N/5*.5}},N))}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[k&&h.jsx("button",{onClick:b,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:T,animation:k?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider",style:{color:k?"#fbbf24":"hsl(var(--muted-foreground))"},children:w}),k&&i.tool&&h.jsx("span",{className:"text-[10px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:i.tool}),k&&l!=null&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:cm(l)})]})]}),h.jsxs("div",{ref:f,onScroll:g,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…"})]}),Y_(r).map((M,N)=>h.jsx(q_,{msg:M},M.uuid||N)),h.jsx("div",{ref:p})]}),!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",role:"status","aria-live":"polite",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:u.retryInfo?`Retrying… ${u.retryInfo.attempt}/${u.retryInfo.maxRetries}`:"connecting to agent server…"}),u.error&&h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--destructive))"},children:u.error}),!Z.es&&u.error&&h.jsx("button",{onClick:()=>{Z.streamError=null,Z.retryInfo=null,Z.stalled=!1,d({error:null,retryInfo:null,stalled:!1}),kh()},className:"pointer-events-auto px-3 py-1 rounded text-[11px] font-medium",style:{background:"hsl(var(--accent) / 0.15)",border:"1px solid hsl(var(--accent) / 0.3)",color:"hsl(var(--accent-foreground))",cursor:"pointer"},children:"Reconnect"})]})}),t&&(u.error||u.stalled)&&h.jsx("div",{role:"status","aria-live":"polite",className:"shrink-0 flex items-center gap-2 px-3 py-1.5 text-[11px]",style:{background:u.stalled?"hsl(45 93% 47% / 0.1)":"hsl(var(--destructive) / 0.1)",borderBottom:`1px solid ${u.stalled?"hsl(45 93% 47% / 0.2)":"hsl(var(--destructive) / 0.2)"}`,color:u.stalled?"hsl(45 93% 47%)":"hsl(var(--destructive))"},children:u.stalled?h.jsxs(h.Fragment,{children:[h.jsxs("span",{children:["No data received for ",my/1e3,"s — connection may be stalled."]}),h.jsx("button",{onClick:()=>{Z.es&&(Z.es.close(),Z.es=null),Z.connected=!1,Z.onConnectedChange&&Z.onConnectedChange(!1),Z.streamError=null,Z.retryInfo=null,Z.stalled=!1,d({error:null,retryInfo:null,stalled:!1}),kh()},className:"ml-auto px-2 py-0.5 rounded text-[10px] font-medium",style:{background:"hsl(45 93% 47% / 0.15)",border:"1px solid hsl(45 93% 47% / 0.3)",cursor:"pointer"},children:"Reconnect"})]}):h.jsx("span",{children:u.error})}),h.jsx(H_,{onSend:y,disabled:k||!t,placeholder:k?"Working…":"Message Claude…"})]})}function tE(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const eE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nE={};function hm(t,e){return(nE.jsx?rE:eE).test(t)}const iE=/[ \t\n\f\r]/g;function sE(t){return typeof t=="object"?t.type==="text"?um(t.value):!1:um(t)}function um(t){return t.replace(iE,"")===""}class ga{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}}ga.prototype.normal={};ga.prototype.property={};ga.prototype.space=void 0;function xy(t,e){const r={},n={};for(const i of t)Object.assign(r,i.property),Object.assign(n,i.normal);return new ga(r,n,e)}function Ou(t){return t.toLowerCase()}class xr{constructor(e,r){this.attribute=r,this.property=e}}xr.prototype.attribute="";xr.prototype.booleanish=!1;xr.prototype.boolean=!1;xr.prototype.commaOrSpaceSeparated=!1;xr.prototype.commaSeparated=!1;xr.prototype.defined=!1;xr.prototype.mustUseProperty=!1;xr.prototype.number=!1;xr.prototype.overloadedBoolean=!1;xr.prototype.property="";xr.prototype.spaceSeparated=!1;xr.prototype.space=void 0;let oE=0;const Wt=Mi(),Ne=Mi(),Ru=Mi(),ct=Mi(),ce=Mi(),Ci=Mi(),vr=Mi();function Mi(){return 2**++oE}const $u=Object.freeze(Object.defineProperty({__proto__:null,boolean:Wt,booleanish:Ne,commaOrSpaceSeparated:vr,commaSeparated:Ci,number:ct,overloadedBoolean:Ru,spaceSeparated:ce},Symbol.toStringTag,{value:"Module"})),wh=Object.keys($u);class uf extends xr{constructor(e,r,n,i){let s=-1;if(super(e,r),dm(this,"space",i),typeof n=="number")for(;++s<wh.length;){const o=wh[s];dm(this,wh[s],(n&$u[o])===$u[o])}}}uf.prototype.defined=!0;function dm(t,e,r){r&&(t[e]=r)}function Gs(t){const e={},r={};for(const[n,i]of Object.entries(t.properties)){const s=new uf(n,t.transform(t.attributes||{},n),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),e[n]=s,r[Ou(n)]=n,r[Ou(s.attribute)]=n}return new ga(e,r,t.space)}const yy=Gs({properties:{ariaActiveDescendant:null,ariaAtomic:Ne,ariaAutoComplete:null,ariaBusy:Ne,ariaChecked:Ne,ariaColCount:ct,ariaColIndex:ct,ariaColSpan:ct,ariaControls:ce,ariaCurrent:null,ariaDescribedBy:ce,ariaDetails:null,ariaDisabled:Ne,ariaDropEffect:ce,ariaErrorMessage:null,ariaExpanded:Ne,ariaFlowTo:ce,ariaGrabbed:Ne,ariaHasPopup:null,ariaHidden:Ne,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ce,ariaLevel:ct,ariaLive:null,ariaModal:Ne,ariaMultiLine:Ne,ariaMultiSelectable:Ne,ariaOrientation:null,ariaOwns:ce,ariaPlaceholder:null,ariaPosInSet:ct,ariaPressed:Ne,ariaReadOnly:Ne,ariaRelevant:null,ariaRequired:Ne,ariaRoleDescription:ce,ariaRowCount:ct,ariaRowIndex:ct,ariaRowSpan:ct,ariaSelected:Ne,ariaSetSize:ct,ariaSort:null,ariaValueMax:ct,ariaValueMin:ct,ariaValueNow:ct,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function by(t,e){return e in t?t[e]:e}function Cy(t,e){return by(t,e.toLowerCase())}const aE=Gs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ci,acceptCharset:ce,accessKey:ce,action:null,allow:null,allowFullScreen:Wt,allowPaymentRequest:Wt,allowUserMedia:Wt,alpha:Wt,alt:null,as:null,async:Wt,autoCapitalize:null,autoComplete:ce,autoFocus:Wt,autoPlay:Wt,blocking:ce,capture:null,charSet:null,checked:Wt,cite:null,className:ce,closedBy:null,colorSpace:null,cols:ct,colSpan:ct,command:null,commandFor:null,content:null,contentEditable:Ne,controls:Wt,controlsList:ce,coords:ct|Ci,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Wt,defer:Wt,dir:null,dirName:null,disabled:Wt,download:Ru,draggable:Ne,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Wt,formTarget:null,headers:ce,height:ct,hidden:Ru,high:ct,href:null,hrefLang:null,htmlFor:ce,httpEquiv:ce,id:null,imageSizes:null,imageSrcSet:null,inert:Wt,inputMode:null,integrity:null,is:null,isMap:Wt,itemId:null,itemProp:ce,itemRef:ce,itemScope:Wt,itemType:ce,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Wt,low:ct,manifest:null,max:null,maxLength:ct,media:null,method:null,min:null,minLength:ct,multiple:Wt,muted:Wt,name:null,nonce:null,noModule:Wt,noValidate:Wt,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:Wt,optimum:ct,pattern:null,ping:ce,placeholder:null,playsInline:Wt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Wt,referrerPolicy:null,rel:ce,required:Wt,reversed:Wt,rows:ct,rowSpan:ct,sandbox:ce,scope:null,scoped:Wt,seamless:Wt,selected:Wt,shadowRootClonable:Wt,shadowRootCustomElementRegistry:Wt,shadowRootDelegatesFocus:Wt,shadowRootMode:null,shadowRootSerializable:Wt,shape:null,size:ct,sizes:null,slot:null,span:ct,spellCheck:Ne,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ct,step:null,style:null,tabIndex:ct,target:null,title:null,translate:null,type:null,typeMustMatch:Wt,useMap:null,value:Ne,width:ct,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ce,axis:null,background:null,bgColor:null,border:ct,borderColor:null,bottomMargin:ct,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Wt,declare:Wt,event:null,face:null,frame:null,frameBorder:null,hSpace:ct,leftMargin:ct,link:null,longDesc:null,lowSrc:null,marginHeight:ct,marginWidth:ct,noResize:Wt,noHref:Wt,noShade:Wt,noWrap:Wt,object:null,profile:null,prompt:null,rev:null,rightMargin:ct,rules:null,scheme:null,scrolling:Ne,standby:null,summary:null,text:null,topMargin:ct,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ct,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Wt,disablePictureInPicture:Wt,disableRemotePlayback:Wt,exportParts:Ci,part:ce,prefix:null,property:null,results:ct,security:null,unselectable:null},space:"html",transform:Cy}),lE=Gs({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",maskType:"mask-type",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:vr,accentHeight:ct,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ct,amplitude:ct,arabicForm:null,ascent:ct,attributeName:null,attributeType:null,azimuth:ct,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ct,by:null,calcMode:null,capHeight:ct,className:ce,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:ct,diffuseConstant:ct,direction:null,display:null,dur:null,divisor:ct,dominantBaseline:null,download:Wt,dx:null,dy:null,edgeMode:null,editable:null,elevation:ct,enableBackground:null,end:null,event:null,exponent:ct,externalResourcesRequired:null,fill:null,fillOpacity:ct,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:Ci,g2:Ci,glyphName:Ci,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ct,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ct,horizOriginX:ct,horizOriginY:ct,id:null,ideographic:ct,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ct,k:ct,k1:ct,k2:ct,k3:ct,k4:ct,kernelMatrix:vr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ct,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ct,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:ct,overlineThickness:ct,paintOrder:null,panose1:null,path:null,pathLength:ct,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ce,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ct,pointsAtY:ct,pointsAtZ:ct,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vr,rev:vr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vr,requiredFeatures:vr,requiredFonts:vr,requiredFormats:vr,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:ct,specularExponent:ct,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ct,strikethroughThickness:ct,string:null,stroke:null,strokeDashArray:vr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ct,strokeOpacity:ct,strokeWidth:null,style:null,surfaceScale:ct,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vr,tabIndex:ct,tableValues:null,target:null,targetX:ct,targetY:ct,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ct,underlineThickness:ct,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ct,values:null,vAlphabetic:ct,vMathematical:ct,vectorEffect:null,vHanging:ct,vIdeographic:ct,version:null,vertAdvY:ct,vertOriginX:ct,vertOriginY:ct,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ct,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:by}),ky=Gs({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()}}),vy=Gs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Cy}),wy=Gs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),cE={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"},hE=/[A-Z]/g,fm=/-[a-z]/g,uE=/^data[-\w.:]+$/i;function dE(t,e){const r=Ou(e);let n=e,i=xr;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&uE.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(fm,pE);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!fm.test(s)){let o=s.replace(hE,fE);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=uf}return new i(n,e)}function fE(t){return"-"+t.toLowerCase()}function pE(t){return t.charAt(1).toUpperCase()}const mE=xy([yy,aE,ky,vy,wy],"html"),df=xy([yy,lE,ky,vy,wy],"svg");function gE(t){return t.join(" ").trim()}var qi={},Sh,pm;function xE(){if(pm)return Sh;pm=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=`
@@ -641,8 +641,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
641
641
  L0,20`)},"requirement_arrow"),S9=v((t,e,r)=>{const n=be(),{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
642
642
  L20,10
643
643
  M20,10
644
- L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),T9=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"),_9=v((t,e,r)=>{const n=be(),{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"),E9={extension:s9,composition:o9,aggregation:a9,dependency:l9,lollipop:c9,point:h9,circle:u9,cross:d9,barb:f9,barbNeo:p9,only_one:m9,zero_or_one:g9,one_or_more:x9,zero_or_more:y9,only_one_neo:b9,zero_or_one_neo:C9,one_or_more_neo:k9,zero_or_more_neo:v9,requirement_arrow:w9,requirement_contains:T9,requirement_arrow_neo:S9,requirement_contains_neo:_9},N9=i9,j9={common:wa,getConfig:be,insertCluster:_8,insertEdge:n9,insertEdgeLabel:Z8,insertMarkers:N9,insertNode:$2,interpolateToCurve:vp,labelHelper:Mt,log:tt,positionEdgeLabel:Q8},da={},H2=v(t=>{for(const e of t)da[e.name]=e},"registerLayoutLoaders"),L9=v(()=>{H2([{name:"dagre",loader:v(async()=>await Jt(()=>import("./dagre-BM42HDAG-urcL7_B8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Jt(()=>import("./cose-bilkent-S5V4N54A-BlBShGhI.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");L9();var qZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in da))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=da[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,j9,{algorithm:r.algorithm})},"render"),HZ=v((t="",{fallback:e="dagre"}={})=>{if(t in da)return t;if(e in da)return tt.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"),qp="comm",U2="rule",G2="decl",B9="@media",A9="@import",M9="@supports",I9="@namespace",Ud="@keyframes",V2="@layer",F9="@scope",P9=Math.abs,Ko=String.fromCharCode;function Y2(t){return t.trim()}function Gd(t,e,r){return t.replace(e,r)}function gs(t,e){return t.charCodeAt(e)|0}function Hs(t,e,r){return t.slice(e,r)}function nn(t){return t.length}function X2(t){return t.length}function nl(t,e){return e.push(t),t}var ah=1,Us=1,K2=0,Mr=0,je=0,Qs="";function Hp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:ah,column:Us,length:o,return:"",siblings:a}}function D9(){return je}function O9(){return je=Mr>0?gs(Qs,--Mr):0,Us--,je===10&&(Us=1,ah--),je}function Ur(){return je=Mr<K2?gs(Qs,Mr++):0,Us++,je===10&&(Us=1,ah++),je}function qn(){return gs(Qs,Mr)}function Ll(){return Mr}function lh(t,e){return Hs(Qs,t,e)}function fa(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 R9(t){return ah=Us=1,K2=nn(Qs=t),Mr=0,[]}function $9(t){return Qs="",t}function pu(t){return Y2(lh(Mr-1,Vd(t===91?t+2:t===40?t+1:t)))}function z9(t){for(;(je=qn())&&je<33;)Ur();return fa(t)>2||fa(je)>3?"":" "}function W9(t,e){for(;--e&&Ur()&&!(je<48||je>102||je>57&&je<65||je>70&&je<97););return lh(t,Ll()+(e<6&&qn()==32&&Ur()==32))}function Vd(t){for(;Ur();)switch(je){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Vd(je);break;case 40:t===41&&Vd(t);break;case 92:Ur();break}return Mr}function q9(t,e){for(;Ur()&&t+je!==57;)if(t+je===84&&qn()===47)break;return"/*"+lh(e,Mr-1)+"*"+Ko(t===47?t:Ur())}function H9(t){for(;!fa(qn());)Ur();return lh(t,Mr)}function U9(t){return $9(Bl("",null,null,null,[""],t=R9(t),0,[0],t))}function Bl(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,L=T;g;)switch(m=k,k=Ur()){case 40:m!=108&&gs(L,d-1)==58?(b++,L+="("):L+=pu(k);break;case 41:b--,L+=")";break;case 34:case 39:case 91:L+=pu(k);break;case 9:case 10:case 13:case 32:if(b>0){L+=Ko(k);break}L+=z9(m);break;case 92:L+=W9(Ll()-1,7);continue;case 47:switch(qn()){case 42:case 47:nl(G9(q9(Ur(),Ll()),e,r,l),l),(fa(m||1)==5||fa(qn()||1)==5)&&nn(L)&&Hs(L,-1,void 0)!==" "&&(L+=" ");break;default:L+="/"}break;case 123*x:a[c++]=nn(L)*y;case 125*x:case 59:case 0:if(b>0&&k){L+=Ko(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(L=Gd(L,/\f/g,"")),f>0&&(nn(L)-d||x===0)&&nl(f>32?t0(L+";",n,r,d-1,l):t0(Gd(L," ","")+";",n,r,d-2,l),l);break;case 59:L+=";";default:if(nl(E=Jx(L,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Bl(L,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(gs(L,3)===110)break;case 108:if(gs(L,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Bl(t,E,E,n&&nl(Jx(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Bl(L,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=L="",d=o;break;case 58:d=1+nn(L),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&O9()==125)continue}switch(L+=Ko(k),k*x){case 38:y=u>0?1:(L+="\f",-1);break;case 44:if(b>0)break;a[c++]=(nn(L)-1)*y,y=1;break;case 64:qn()===45&&(L+=pu(Ur())),p=qn(),u=d=nn(T=L+=H9(Ll())),k++;break;case 45:m===45&&nn(L)==2&&(x=0)}}return s}function Jx(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=X2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Hs(t,p+1,p=P9(g=o[x])),T=t;b<m;++b)(T=Y2(g>0?f[b]+" "+k:Gd(k,/&\f/g,f[b])))&&(l[y++]=T);return Hp(t,e,r,i===0?U2:a,l,c,u,d)}function G9(t,e,r,n){return Hp(t,e,r,qp,Ko(D9()),Hs(t,2,-2),0,n)}function t0(t,e,r,n,i){return Hp(t,e,r,G2,Hs(t,0,n),Hs(t,n+1,-1),n,i)}function Yd(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function V9(t,e,r,n){switch(t.type){case V2:if(t.children.length)break;case A9:case I9:case G2:return t.return=t.return||t.value;case qp:return"";case Ud:return t.return=t.value+"{"+Yd(t.children,n)+"}";case U2:if(!nn(t.value=t.props.join(",")))return""}return nn(r=Yd(t.children,n))?t.return=t.value+"{"+r+"}":""}function Y9(t){var e=X2(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 Z2="c4",X9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),K9=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-DhjfNEZ_.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:Z2,diagram:t}},"loader"),Z9={id:Z2,detector:X9,loader:K9},Q9=Z9,Q2="flowchart",J9=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"),t7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DewNd_kM.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Q2,diagram:t}},"loader"),e7={id:Q2,detector:J9,loader:t7},r7=e7,J2="flowchart-v2",n7=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"),i7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DewNd_kM.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:J2,diagram:t}},"loader"),s7={id:J2,detector:n7,loader:i7},o7=s7,tS="er",a7=v(t=>/^\s*erDiagram/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-DkUnalKg.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),c7={id:tS,detector:a7,loader:l7},h7=c7,eS="gitGraph",u7=v(t=>/^\s*gitGraph/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-D0CX5WgP.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:eS,diagram:t}},"loader"),f7={id:eS,detector:u7,loader:d7},p7=f7,rS="gantt",m7=v(t=>/^\s*gantt/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-DzDBcVj5.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:rS,diagram:t}},"loader"),x7={id:rS,detector:m7,loader:g7},y7=x7,nS="info",b7=v(t=>/^\s*info/.test(t),"detector"),C7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-B1zzuW9l.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:nS,diagram:t}},"loader"),k7={id:nS,detector:b7,loader:C7},iS="pie",v7=v(t=>/^\s*pie/.test(t),"detector"),w7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-BbIHZku5.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:iS,diagram:t}},"loader"),S7={id:iS,detector:v7,loader:w7},sS="quadrantChart",T7=v(t=>/^\s*quadrantChart/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-DEQSG_lM.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),E7={id:sS,detector:T7,loader:_7},N7=E7,oS="xychart",j7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-Btu4JcQO.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),B7={id:oS,detector:j7,loader:L7},A7=B7,aS="requirement",M7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-BeVnwIwF.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),F7={id:aS,detector:M7,loader:I7},P7=F7,lS="sequence",D7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),O7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-E-tnxahu.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),R7={id:lS,detector:D7,loader:O7},$7=R7,cS="class",z7=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"),W7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-DvsVLUph.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:cS,diagram:t}},"loader"),q7={id:cS,detector:z7,loader:W7},H7=q7,hS="classDiagram",U7=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"),G7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-DvsVLUph.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:hS,diagram:t}},"loader"),V7={id:hS,detector:U7,loader:G7},Y7=V7,uS="state",X7=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"),K7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-3rgFN7hL.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:uS,diagram:t}},"loader"),Z7={id:uS,detector:X7,loader:K7},Q7=Z7,dS="stateDiagram",J7=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"),tW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-DY_OtnIg.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:dS,diagram:t}},"loader"),eW={id:dS,detector:J7,loader:tW},rW=eW,fS="journey",nW=v(t=>/^\s*journey/.test(t),"detector"),iW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-w9c-l95A.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:fS,diagram:t}},"loader"),sW={id:fS,detector:nW,loader:iW},oW=sW,aW=v((t,e,r)=>{tt.debug(`rendering svg for syntax error
645
- `);const n=WR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),U1(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"),pS={draw:aW},lW=pS,cW={db:{},renderer:pS,parser:{parse:v(()=>{},"parse")}},hW=cW,mS="flowchart-elk",uW=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"),dW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-DewNd_kM.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:mS,diagram:t}},"loader"),fW={id:mS,detector:uW,loader:dW},pW=fW,gS="timeline",mW=v(t=>/^\s*timeline/.test(t),"detector"),gW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./timeline-definition-PNZ67QCA-Dcs4QFbE.js");return{diagram:e}},__vite__mapDeps([40,27,3,4,5,6,7]));return{id:gS,diagram:t}},"loader"),xW={id:gS,detector:mW,loader:gW},yW=xW,xS="mindmap",bW=v(t=>/^\s*mindmap/.test(t),"detector"),CW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./mindmap-definition-RKZ34NQL-DBQqsZiD.js");return{diagram:e}},__vite__mapDeps([41,13,14,3,4,5,6,7]));return{id:xS,diagram:t}},"loader"),kW={id:xS,detector:bW,loader:CW},vW=kW,yS="kanban",wW=v(t=>/^\s*kanban/.test(t),"detector"),SW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./kanban-definition-UN3LZRKU-9cL90JL0.js");return{diagram:e}},__vite__mapDeps([42,12,3,4,5,6,7]));return{id:yS,diagram:t}},"loader"),TW={id:yS,detector:wW,loader:SW},_W=TW,bS="sankey",EW=v(t=>/^\s*sankey(-beta)?/.test(t),"detector"),NW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./sankeyDiagram-5OEKKPKP-Be-ROw_I.js");return{diagram:e}},__vite__mapDeps([43,28,23,3,4,5,6,7]));return{id:bS,diagram:t}},"loader"),jW={id:bS,detector:EW,loader:NW},LW=jW,CS="packet",BW=v(t=>/^\s*packet(-beta)?/.test(t),"detector"),AW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-LMA3HP47-jog00Zl2.js");return{diagram:e}},__vite__mapDeps([44,18,20,5,3,4,6,7]));return{id:CS,diagram:t}},"loader"),MW={id:CS,detector:BW,loader:AW},kS="radar",IW=v(t=>/^\s*radar-beta/.test(t),"detector"),FW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-2AECGRRQ-DlfCvqLR.js");return{diagram:e}},__vite__mapDeps([45,18,20,5,3,4,6,7]));return{id:kS,diagram:t}},"loader"),PW={id:kS,detector:IW,loader:FW},vS="block",DW=v(t=>/^\s*block(-beta)?/.test(t),"detector"),OW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./blockDiagram-GPEHLZMM-Do_uWvAL.js");return{diagram:e}},__vite__mapDeps([46,12,1,15,3,4,5,6,7]));return{id:vS,diagram:t}},"loader"),RW={id:vS,detector:DW,loader:OW},$W=RW,wS="treeView",zW=v(t=>/^\s*treeView-beta/.test(t),"detector"),WW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-5GNKFQAL-h5gTsYDo.js");return{diagram:e}},__vite__mapDeps([47,18,19,20,5,3,4,6,7]));return{id:wS,diagram:t}},"loader"),qW={id:wS,detector:zW,loader:WW},HW=qW,SS="architecture",UW=v(t=>/^\s*architecture/.test(t),"detector"),GW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./architectureDiagram-3BPJPVTR-BhtVN7Go.js");return{diagram:e}},__vite__mapDeps([48,18,20,5,3,4,6,7]));return{id:SS,diagram:t}},"loader"),VW={id:SS,detector:UW,loader:GW},YW=VW,TS="eventmodeling",XW=v(t=>/^\s*eventmodeling/.test(t),"detector"),KW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-KO2AKTUF-BbEbRrVo.js");return{diagram:e}},__vite__mapDeps([49,18,20,5,3,4,6,7]));return{id:TS,diagram:t}},"loader"),ZW={id:TS,detector:XW,loader:KW},QW=ZW,_S="ishikawa",JW=v(t=>/^\s*ishikawa(-beta)?\b/i.test(t),"detector"),tq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./ishikawaDiagram-YF4QCWOH-3hFmuv1F.js");return{diagram:e}},__vite__mapDeps([50,3,4,5,6,7]));return{id:_S,diagram:t}},"loader"),eq={id:_S,detector:JW,loader:tq},ES="venn",rq=v(t=>/^\s*venn-beta/.test(t),"detector"),nq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./vennDiagram-CIIHVFJN-BstUQ900.js");return{diagram:e}},__vite__mapDeps([51,3,4,5,6,7]));return{id:ES,diagram:t}},"loader"),iq={id:ES,detector:rq,loader:nq},sq=iq,NS="treemap",oq=v(t=>/^\s*treemap/.test(t),"detector"),aq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-OG6HWLK6-B0JVsR6S.js");return{diagram:e}},__vite__mapDeps([52,14,18,20,5,3,4,6,24,28,23,7]));return{id:NS,diagram:t}},"loader"),lq={id:NS,detector:oq,loader:aq},jS="wardley-beta",cq=v(t=>/^\s*wardley-beta/i.test(t),"detector"),hq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./wardleyDiagram-YWT4CUSO-BvrP3shF.js");return{diagram:e}},__vite__mapDeps([53,18,20,5,3,4,6,7]));return{id:jS,diagram:t}},"loader"),uq={id:jS,detector:cq,loader:hq},dq=uq,e0=!1,ch=v(()=>{e0||(e0=!0,Jl("error",hW,t=>t.toLowerCase().trim()==="error"),Jl("---",{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("---")),Ju(pW,vW,YW),Ju(Q9,_W,Y7,H7,h7,y7,k7,S7,P7,$7,o7,r7,yW,p7,rW,Q7,oW,N7,LW,MW,A7,$W,QW,HW,PW,eq,lq,sq,dq))},"addDiagrams"),fq=v(async()=>{tt.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(Ti).map(async([r,{detector:n,loader:i}])=>{if(i)try{id(r)}catch{try{const{diagram:s,id:o}=await i();Jl(o,s,n)}catch(s){throw tt.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete Ti[r],s}}}))).filter(r=>r.status==="rejected");if(e.length>0){tt.error(`Failed to load ${e.length} external diagrams`);for(const r of e)tt.error(r);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),pq="graphics-document document";function LS(t,e){t.attr("role",pq),e!==""&&t.attr("aria-roledescription",e)}v(LS,"setA11yDiagramInfo");function BS(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(BS,"addSVGa11yTitleDescription");var vi,Xd=(vi=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=be(),i=Gf(e,n);e=G6(e)+`
644
+ L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),T9=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"),_9=v((t,e,r)=>{const n=be(),{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"),E9={extension:s9,composition:o9,aggregation:a9,dependency:l9,lollipop:c9,point:h9,circle:u9,cross:d9,barb:f9,barbNeo:p9,only_one:m9,zero_or_one:g9,one_or_more:x9,zero_or_more:y9,only_one_neo:b9,zero_or_one_neo:C9,one_or_more_neo:k9,zero_or_more_neo:v9,requirement_arrow:w9,requirement_contains:T9,requirement_arrow_neo:S9,requirement_contains_neo:_9},N9=i9,j9={common:wa,getConfig:be,insertCluster:_8,insertEdge:n9,insertEdgeLabel:Z8,insertMarkers:N9,insertNode:$2,interpolateToCurve:vp,labelHelper:Mt,log:tt,positionEdgeLabel:Q8},da={},H2=v(t=>{for(const e of t)da[e.name]=e},"registerLayoutLoaders"),L9=v(()=>{H2([{name:"dagre",loader:v(async()=>await Jt(()=>import("./dagre-BM42HDAG-D27D6YAL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Jt(()=>import("./cose-bilkent-S5V4N54A-fNQlSmHt.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");L9();var qZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in da))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=da[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,j9,{algorithm:r.algorithm})},"render"),HZ=v((t="",{fallback:e="dagre"}={})=>{if(t in da)return t;if(e in da)return tt.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"),qp="comm",U2="rule",G2="decl",B9="@media",A9="@import",M9="@supports",I9="@namespace",Ud="@keyframes",V2="@layer",F9="@scope",P9=Math.abs,Ko=String.fromCharCode;function Y2(t){return t.trim()}function Gd(t,e,r){return t.replace(e,r)}function gs(t,e){return t.charCodeAt(e)|0}function Hs(t,e,r){return t.slice(e,r)}function nn(t){return t.length}function X2(t){return t.length}function nl(t,e){return e.push(t),t}var ah=1,Us=1,K2=0,Mr=0,je=0,Qs="";function Hp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:ah,column:Us,length:o,return:"",siblings:a}}function D9(){return je}function O9(){return je=Mr>0?gs(Qs,--Mr):0,Us--,je===10&&(Us=1,ah--),je}function Ur(){return je=Mr<K2?gs(Qs,Mr++):0,Us++,je===10&&(Us=1,ah++),je}function qn(){return gs(Qs,Mr)}function Ll(){return Mr}function lh(t,e){return Hs(Qs,t,e)}function fa(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 R9(t){return ah=Us=1,K2=nn(Qs=t),Mr=0,[]}function $9(t){return Qs="",t}function pu(t){return Y2(lh(Mr-1,Vd(t===91?t+2:t===40?t+1:t)))}function z9(t){for(;(je=qn())&&je<33;)Ur();return fa(t)>2||fa(je)>3?"":" "}function W9(t,e){for(;--e&&Ur()&&!(je<48||je>102||je>57&&je<65||je>70&&je<97););return lh(t,Ll()+(e<6&&qn()==32&&Ur()==32))}function Vd(t){for(;Ur();)switch(je){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Vd(je);break;case 40:t===41&&Vd(t);break;case 92:Ur();break}return Mr}function q9(t,e){for(;Ur()&&t+je!==57;)if(t+je===84&&qn()===47)break;return"/*"+lh(e,Mr-1)+"*"+Ko(t===47?t:Ur())}function H9(t){for(;!fa(qn());)Ur();return lh(t,Mr)}function U9(t){return $9(Bl("",null,null,null,[""],t=R9(t),0,[0],t))}function Bl(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,L=T;g;)switch(m=k,k=Ur()){case 40:m!=108&&gs(L,d-1)==58?(b++,L+="("):L+=pu(k);break;case 41:b--,L+=")";break;case 34:case 39:case 91:L+=pu(k);break;case 9:case 10:case 13:case 32:if(b>0){L+=Ko(k);break}L+=z9(m);break;case 92:L+=W9(Ll()-1,7);continue;case 47:switch(qn()){case 42:case 47:nl(G9(q9(Ur(),Ll()),e,r,l),l),(fa(m||1)==5||fa(qn()||1)==5)&&nn(L)&&Hs(L,-1,void 0)!==" "&&(L+=" ");break;default:L+="/"}break;case 123*x:a[c++]=nn(L)*y;case 125*x:case 59:case 0:if(b>0&&k){L+=Ko(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(L=Gd(L,/\f/g,"")),f>0&&(nn(L)-d||x===0)&&nl(f>32?t0(L+";",n,r,d-1,l):t0(Gd(L," ","")+";",n,r,d-2,l),l);break;case 59:L+=";";default:if(nl(E=Jx(L,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Bl(L,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(gs(L,3)===110)break;case 108:if(gs(L,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Bl(t,E,E,n&&nl(Jx(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Bl(L,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=L="",d=o;break;case 58:d=1+nn(L),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&O9()==125)continue}switch(L+=Ko(k),k*x){case 38:y=u>0?1:(L+="\f",-1);break;case 44:if(b>0)break;a[c++]=(nn(L)-1)*y,y=1;break;case 64:qn()===45&&(L+=pu(Ur())),p=qn(),u=d=nn(T=L+=H9(Ll())),k++;break;case 45:m===45&&nn(L)==2&&(x=0)}}return s}function Jx(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=X2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Hs(t,p+1,p=P9(g=o[x])),T=t;b<m;++b)(T=Y2(g>0?f[b]+" "+k:Gd(k,/&\f/g,f[b])))&&(l[y++]=T);return Hp(t,e,r,i===0?U2:a,l,c,u,d)}function G9(t,e,r,n){return Hp(t,e,r,qp,Ko(D9()),Hs(t,2,-2),0,n)}function t0(t,e,r,n,i){return Hp(t,e,r,G2,Hs(t,0,n),Hs(t,n+1,-1),n,i)}function Yd(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function V9(t,e,r,n){switch(t.type){case V2:if(t.children.length)break;case A9:case I9:case G2:return t.return=t.return||t.value;case qp:return"";case Ud:return t.return=t.value+"{"+Yd(t.children,n)+"}";case U2:if(!nn(t.value=t.props.join(",")))return""}return nn(r=Yd(t.children,n))?t.return=t.value+"{"+r+"}":""}function Y9(t){var e=X2(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 Z2="c4",X9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),K9=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-D6LE8-j8.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:Z2,diagram:t}},"loader"),Z9={id:Z2,detector:X9,loader:K9},Q9=Z9,Q2="flowchart",J9=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"),t7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-HFUno_nV.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Q2,diagram:t}},"loader"),e7={id:Q2,detector:J9,loader:t7},r7=e7,J2="flowchart-v2",n7=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"),i7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-HFUno_nV.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:J2,diagram:t}},"loader"),s7={id:J2,detector:n7,loader:i7},o7=s7,tS="er",a7=v(t=>/^\s*erDiagram/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-nd3GWiPn.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),c7={id:tS,detector:a7,loader:l7},h7=c7,eS="gitGraph",u7=v(t=>/^\s*gitGraph/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-NBq1F6K2.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:eS,diagram:t}},"loader"),f7={id:eS,detector:u7,loader:d7},p7=f7,rS="gantt",m7=v(t=>/^\s*gantt/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-CPPAAjwR.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:rS,diagram:t}},"loader"),x7={id:rS,detector:m7,loader:g7},y7=x7,nS="info",b7=v(t=>/^\s*info/.test(t),"detector"),C7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-D-TOBtCq.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:nS,diagram:t}},"loader"),k7={id:nS,detector:b7,loader:C7},iS="pie",v7=v(t=>/^\s*pie/.test(t),"detector"),w7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-C5fvCej-.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:iS,diagram:t}},"loader"),S7={id:iS,detector:v7,loader:w7},sS="quadrantChart",T7=v(t=>/^\s*quadrantChart/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-4NoQsF61.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),E7={id:sS,detector:T7,loader:_7},N7=E7,oS="xychart",j7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-D42FcVOY.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),B7={id:oS,detector:j7,loader:L7},A7=B7,aS="requirement",M7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-q5WxB9LO.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),F7={id:aS,detector:M7,loader:I7},P7=F7,lS="sequence",D7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),O7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-BzHclOKt.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),R7={id:lS,detector:D7,loader:O7},$7=R7,cS="class",z7=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"),W7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-mSW5R7DY.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:cS,diagram:t}},"loader"),q7={id:cS,detector:z7,loader:W7},H7=q7,hS="classDiagram",U7=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"),G7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-mSW5R7DY.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:hS,diagram:t}},"loader"),V7={id:hS,detector:U7,loader:G7},Y7=V7,uS="state",X7=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"),K7=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-BvWRI9zK.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:uS,diagram:t}},"loader"),Z7={id:uS,detector:X7,loader:K7},Q7=Z7,dS="stateDiagram",J7=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"),tW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-CDlF0VA8.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:dS,diagram:t}},"loader"),eW={id:dS,detector:J7,loader:tW},rW=eW,fS="journey",nW=v(t=>/^\s*journey/.test(t),"detector"),iW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-Bko3tTdh.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:fS,diagram:t}},"loader"),sW={id:fS,detector:nW,loader:iW},oW=sW,aW=v((t,e,r)=>{tt.debug(`rendering svg for syntax error
645
+ `);const n=WR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),U1(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"),pS={draw:aW},lW=pS,cW={db:{},renderer:pS,parser:{parse:v(()=>{},"parse")}},hW=cW,mS="flowchart-elk",uW=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"),dW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-HFUno_nV.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:mS,diagram:t}},"loader"),fW={id:mS,detector:uW,loader:dW},pW=fW,gS="timeline",mW=v(t=>/^\s*timeline/.test(t),"detector"),gW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./timeline-definition-PNZ67QCA-j2wKjAti.js");return{diagram:e}},__vite__mapDeps([40,27,3,4,5,6,7]));return{id:gS,diagram:t}},"loader"),xW={id:gS,detector:mW,loader:gW},yW=xW,xS="mindmap",bW=v(t=>/^\s*mindmap/.test(t),"detector"),CW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./mindmap-definition-RKZ34NQL-CNwNkDqN.js");return{diagram:e}},__vite__mapDeps([41,13,14,3,4,5,6,7]));return{id:xS,diagram:t}},"loader"),kW={id:xS,detector:bW,loader:CW},vW=kW,yS="kanban",wW=v(t=>/^\s*kanban/.test(t),"detector"),SW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./kanban-definition-UN3LZRKU-1e-7i8st.js");return{diagram:e}},__vite__mapDeps([42,12,3,4,5,6,7]));return{id:yS,diagram:t}},"loader"),TW={id:yS,detector:wW,loader:SW},_W=TW,bS="sankey",EW=v(t=>/^\s*sankey(-beta)?/.test(t),"detector"),NW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./sankeyDiagram-5OEKKPKP-DlQNB367.js");return{diagram:e}},__vite__mapDeps([43,28,23,3,4,5,6,7]));return{id:bS,diagram:t}},"loader"),jW={id:bS,detector:EW,loader:NW},LW=jW,CS="packet",BW=v(t=>/^\s*packet(-beta)?/.test(t),"detector"),AW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-LMA3HP47-DAYJMc2I.js");return{diagram:e}},__vite__mapDeps([44,18,20,5,3,4,6,7]));return{id:CS,diagram:t}},"loader"),MW={id:CS,detector:BW,loader:AW},kS="radar",IW=v(t=>/^\s*radar-beta/.test(t),"detector"),FW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-2AECGRRQ-CtXeohzN.js");return{diagram:e}},__vite__mapDeps([45,18,20,5,3,4,6,7]));return{id:kS,diagram:t}},"loader"),PW={id:kS,detector:IW,loader:FW},vS="block",DW=v(t=>/^\s*block(-beta)?/.test(t),"detector"),OW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./blockDiagram-GPEHLZMM-B4w0mOAJ.js");return{diagram:e}},__vite__mapDeps([46,12,1,15,3,4,5,6,7]));return{id:vS,diagram:t}},"loader"),RW={id:vS,detector:DW,loader:OW},$W=RW,wS="treeView",zW=v(t=>/^\s*treeView-beta/.test(t),"detector"),WW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-5GNKFQAL-C_BqZkx0.js");return{diagram:e}},__vite__mapDeps([47,18,19,20,5,3,4,6,7]));return{id:wS,diagram:t}},"loader"),qW={id:wS,detector:zW,loader:WW},HW=qW,SS="architecture",UW=v(t=>/^\s*architecture/.test(t),"detector"),GW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./architectureDiagram-3BPJPVTR-D722w0RE.js");return{diagram:e}},__vite__mapDeps([48,18,20,5,3,4,6,7]));return{id:SS,diagram:t}},"loader"),VW={id:SS,detector:UW,loader:GW},YW=VW,TS="eventmodeling",XW=v(t=>/^\s*eventmodeling/.test(t),"detector"),KW=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-KO2AKTUF-B29ynQz4.js");return{diagram:e}},__vite__mapDeps([49,18,20,5,3,4,6,7]));return{id:TS,diagram:t}},"loader"),ZW={id:TS,detector:XW,loader:KW},QW=ZW,_S="ishikawa",JW=v(t=>/^\s*ishikawa(-beta)?\b/i.test(t),"detector"),tq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./ishikawaDiagram-YF4QCWOH-nXOztZiZ.js");return{diagram:e}},__vite__mapDeps([50,3,4,5,6,7]));return{id:_S,diagram:t}},"loader"),eq={id:_S,detector:JW,loader:tq},ES="venn",rq=v(t=>/^\s*venn-beta/.test(t),"detector"),nq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./vennDiagram-CIIHVFJN-B77g7htC.js");return{diagram:e}},__vite__mapDeps([51,3,4,5,6,7]));return{id:ES,diagram:t}},"loader"),iq={id:ES,detector:rq,loader:nq},sq=iq,NS="treemap",oq=v(t=>/^\s*treemap/.test(t),"detector"),aq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./diagram-OG6HWLK6-CBJMis3l.js");return{diagram:e}},__vite__mapDeps([52,14,18,20,5,3,4,6,24,28,23,7]));return{id:NS,diagram:t}},"loader"),lq={id:NS,detector:oq,loader:aq},jS="wardley-beta",cq=v(t=>/^\s*wardley-beta/i.test(t),"detector"),hq=v(async()=>{const{diagram:t}=await Jt(async()=>{const{diagram:e}=await import("./wardleyDiagram-YWT4CUSO-CK-XB-bO.js");return{diagram:e}},__vite__mapDeps([53,18,20,5,3,4,6,7]));return{id:jS,diagram:t}},"loader"),uq={id:jS,detector:cq,loader:hq},dq=uq,e0=!1,ch=v(()=>{e0||(e0=!0,Jl("error",hW,t=>t.toLowerCase().trim()==="error"),Jl("---",{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("---")),Ju(pW,vW,YW),Ju(Q9,_W,Y7,H7,h7,y7,k7,S7,P7,$7,o7,r7,yW,p7,rW,Q7,oW,N7,LW,MW,A7,$W,QW,HW,PW,eq,lq,sq,dq))},"addDiagrams"),fq=v(async()=>{tt.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(Ti).map(async([r,{detector:n,loader:i}])=>{if(i)try{id(r)}catch{try{const{diagram:s,id:o}=await i();Jl(o,s,n)}catch(s){throw tt.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete Ti[r],s}}}))).filter(r=>r.status==="rejected");if(e.length>0){tt.error(`Failed to load ${e.length} external diagrams`);for(const r of e)tt.error(r);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),pq="graphics-document document";function LS(t,e){t.attr("role",pq),e!==""&&t.attr("aria-roledescription",e)}v(LS,"setA11yDiagramInfo");function BS(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(BS,"addSVGa11yTitleDescription");var vi,Xd=(vi=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=be(),i=Gf(e,n);e=G6(e)+`
646
646
  `;try{id(i)}catch{const d=l4(i);if(!d)throw new L1(`Diagram ${i} not found.`);const{id:p,diagram:f}=await d();Jl(p,f)}const{db:s,parser:o,renderer:a,init:l}=id(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 vi(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(vi,"Diagram"),vi),r0=[],mq=v(()=>{r0.forEach(t=>{t()}),r0=[]},"attachFunctions"),gq=v(t=>t.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function AS(t){const e=t.match(j1);if(!e)return{text:t,metadata:{}};let r=X$(e[1],{schema:Y$})??{};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(AS,"extractFrontMatter");var xq=v(t=>t.replace(/\r\n?/g,`
647
647
  `).replace(/<(\w+)([^>]*)>/g,(e,r,n)=>"<"+r+n.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),yq=v(t=>{const{text:e,metadata:r}=AS(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"),bq=v(t=>{const e=Wr.detectInit(t)??{},r=Wr.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:M6(t),directive:e}},"processDirectives");function Up(t){const e=xq(t),r=yq(e),n=bq(r.text),i=Ep(r.config,n.directive);return t=gq(n.text),{code:t,title:r.title,config:i}}v(Up,"preprocessDiagram");function MS(t){const e=new TextEncoder().encode(t),r=Array.from(e,n=>String.fromCodePoint(n)).join("");return btoa(r)}v(MS,"toBase64");var Cq=5e4,kq="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",vq="sandbox",wq="loose",Sq="http://www.w3.org/2000/svg",Tq="http://www.w3.org/1999/xlink",_q="http://www.w3.org/1999/xhtml",Eq="100%",Nq="100%",jq="border:0;margin:0;",Lq="margin:0",Bq="allow-top-navigation-by-user-activation allow-popups",Aq='The "iframe" tag is not supported by your browser.',Mq=["foreignobject"],Iq=["dominant-baseline"];function Gp(t){const e=Up(t);return Zl(),F4(e.config??{}),e}v(Gp,"processAndSetConfigs");async function IS(t,e){ch();try{const{code:r,config:n}=Gp(t);return{diagramType:(await PS(r)).type,config:n}}catch(r){if(e!=null&&e.suppressErrors)return!1;throw r}}v(IS,"parse");var n0=v((t,e,r=[])=>{const n=F1(`{ ${r.join(" !important; ")} !important; }`);return`.${t} ${e} ${n}`},"cssImportantStyles"),Fq=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=>{xx(l.styles)||a.forEach(c=>{r.insertRule(n0(l.id,c,l.styles),r.cssRules.length)}),xx(l.textStyles)||r.insertRule(n0(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=nd(i)+`
648
648
  `}else n+=`${t.themeCSS}
@@ -742,7 +742,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${e.do
742
742
  `,a.length>0?(n+=a.map(c=>`- ${c}`).join(`
743
743
  `),n+=`
744
744
  `):n+=`_No open threads._
745
- `,n}function wX(t,e){return(e||[]).filter(n=>!n.superseded).map(n=>({title:n.question,type:"decision",decided:!0}))}const jo={es:null},Gn=Pf((t,e)=>({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[],hydrate:async(r,n)=>{if(!r){const l=e().scope;if(l)r=l,n=e().featureCode||null;else try{const c=JSON.parse(localStorage.getItem("compose:designSession")||"{}");r=c.scope||"product",n=c.featureCode||null}catch{r="product"}}const i=e().docManuallyEdited,s=e().draftDoc,o=e().researchItems||[];t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,designDocPath:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]});const a=r==="feature"&&n?`?scope=feature&featureCode=${n}`:`?scope=${r}`;try{const l=await zt(`/api/design/session${a}`),{session:c}=await l.json();if(c){const u=c.messages||[],d=c.decisions||[],p=q0(u,d),f=wX(u,d);t({session:c,messages:u,decisions:d,status:c.status==="complete"?"complete":"active",scope:r,featureCode:n,draftDoc:i?s:p,docManuallyEdited:i,topicOutline:f,researchItems:o}),e().disconnectSSE(),e().connectSSE()}else t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]}),e().disconnectSSE()}catch(l){t({error:l.message})}},startSession:async(r="product",n=null)=>{try{const i=await zt("/api/design/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:r,featureCode:n})});if(!i.ok){const{error:o}=await i.json();t({error:o});return}const{session:s}=await i.json();try{localStorage.setItem("compose:designSession",JSON.stringify({scope:r,featureCode:n}))}catch{}t({session:s,messages:s.messages||[],decisions:s.decisions||[],status:"active",error:null,scope:r,featureCode:n}),e().connectSSE()}catch(i){t({error:i.message})}},sendMessage:async r=>{const{session:n,messages:i}=e();if(!n)return;const s=n.scope,o=n.featureCode,a={role:"human",type:"text",content:r,timestamp:new Date().toISOString()};t(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await zt("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s,featureCode:o,type:"text",content:r})});l.ok||t({messages:i,status:"active",error:`Failed to send message: ${l.status}`})}catch(l){t({messages:i,status:"active",error:l.message})}},selectCard:async(r,n=null,i=null)=>{const{session:s,messages:o}=e();if(!s)return;const a={role:"human",type:"card_select",content:{cardId:r,comment:n},timestamp:new Date().toISOString()};t(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await zt("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s.scope,featureCode:s.featureCode,type:"card_select",cardId:r,comment:n,messageIndex:i})});l.ok||t({messages:o,status:"active",error:`Failed to select card: ${l.status}`})}catch(l){t({messages:o,status:"active",error:l.message})}},reviseDecision:async r=>{const{session:n}=e();if(!n)return;const i=e().decisions[r];if(!(!i||i.superseded))try{const s=await zt("/api/design/revise",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:n.scope,featureCode:n.featureCode,decisionIndex:r})});if(!s.ok){const{error:o}=await s.json().catch(()=>({error:"Revision failed"}));t({error:o});return}e().hydrate(n.scope,n.featureCode)}catch(s){t({error:s.message})}},completeDesign:async()=>{const{session:r,draftDoc:n}=e();if(r){t({status:"summarizing"});try{const i={scope:r.scope,featureCode:r.featureCode};n&&(i.draftDoc=n);const s=await zt("/api/design/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const{error:l}=await s.json().catch(()=>({error:"Unknown error"}));t({error:l,status:"active"});return}const o=await s.json(),a={session:o.session,status:"complete",designDocPath:o.designDocPath||null};o.error&&(a.error=o.error),t(a)}catch(i){t({error:i.message,status:"active"})}}},connectSSE:()=>{if(jo.es)return;const{scope:r,featureCode:n}=e(),i=new URLSearchParams({scope:r||"product"});n&&i.set("featureCode",n);const s=new EventSource(`/api/design/stream?${i}`);jo.es=s,s.addEventListener("ack",()=>{t(o=>o.status!=="streaming"?{status:"streaming"}:{})}),s.addEventListener("text",o=>{const a=JSON.parse(o.data);t(l=>l.streamingMessage?{streamingMessage:{...l.streamingMessage,content:l.streamingMessage.content+a.content}}:{status:"streaming",streamingMessage:{role:"assistant",type:"text",content:a.content,timestamp:new Date().toISOString()}})}),s.addEventListener("decision",o=>{const a=JSON.parse(o.data);t(l=>({status:"streaming",streamingMessage:l.streamingMessage?{...l.streamingMessage,type:"decision",decisionData:a}:{role:"assistant",type:"decision",content:"",decisionData:a,timestamp:new Date().toISOString()}}))}),s.addEventListener("done",()=>{t(o=>({messages:o.streamingMessage?[...o.messages,o.streamingMessage]:o.messages,streamingMessage:null,status:"active"})),e().hydrate()}),s.addEventListener("research",o=>{const a=JSON.parse(o.data);t(l=>({researchItems:[...l.researchItems,{id:a.id,tool:a.tool,input:a.input,timestamp:a.timestamp,summary:null}]}))}),s.addEventListener("research_result",o=>{const a=JSON.parse(o.data);t(l=>{const c=[...l.researchItems],u=a.id?c.findIndex(d=>d.id===a.id):-1;return u!==-1&&(c[u]={...c[u],summary:a.summary}),{researchItems:c}})}),s.addEventListener("error",o=>{try{const a=JSON.parse(o.data);t(l=>({status:"active",streamingMessage:null,error:a.message||"Agent error",messages:l.messages}))}catch{t({status:"active",streamingMessage:null})}}),s.onerror=()=>{t({status:"active"})}},disconnectSSE:()=>{jo.es&&(jo.es.close(),jo.es=null)},reset:()=>{try{localStorage.removeItem("compose:designSession")}catch{}t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]})},updateDraftDoc:r=>{t({draftDoc:r,docManuallyEdited:!0})},resetDocEdited:()=>{const{messages:r,decisions:n}=e(),i=q0(r,n);t({draftDoc:i,docManuallyEdited:!1})}}));function SX(){const{draftDoc:t,docManuallyEdited:e,updateDraftDoc:r,resetDocEdited:n}=Gn(Di(c=>({draftDoc:c.draftDoc,docManuallyEdited:c.docManuallyEdited,updateDraftDoc:c.updateDraftDoc,resetDocEdited:c.resetDocEdited}))),[i,s]=C.useState(!1),o=!t;let a="empty",l={color:"hsl(var(--muted-foreground))"};return e?(a="edited",l={color:"hsl(var(--primary))"}):o||(a="draft",l={color:"hsl(var(--muted-foreground))"}),h.jsxs("div",{className:"h-full flex flex-col",style:{fontFamily:"inherit"},children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-2 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[12px] font-semibold",style:{color:"hsl(var(--foreground))"},children:"Design Document"}),h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{...l,background:"hsl(var(--muted))"},children:a})]}),!o&&h.jsx("button",{onClick:()=>s(c=>!c),className:"text-[11px] px-2 py-1 rounded transition-colors",style:{color:"hsl(var(--muted-foreground))",background:i?"hsl(var(--accent))":"transparent"},onMouseEnter:c=>{c.currentTarget.style.color="hsl(var(--foreground))"},onMouseLeave:c=>{c.currentTarget.style.color="hsl(var(--muted-foreground))"},children:i?"Preview":"Edit"})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o?h.jsx("div",{className:"p-4 text-[12px] italic",style:{color:"hsl(var(--muted-foreground))"},children:"Start the design conversation to see the document build here."}):i?h.jsxs("div",{className:"h-full flex flex-col p-2 gap-2",children:[h.jsx("textarea",{className:"flex-1 min-h-0 w-full resize-none rounded p-2 text-[12px]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",background:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",outline:"none"},value:t,onChange:c=>r(c.target.value),spellCheck:!1}),h.jsx("button",{onClick:()=>{n(),s(!1)},className:"shrink-0 text-[11px] px-3 py-1.5 rounded transition-colors self-start",style:{color:"hsl(var(--muted-foreground))",border:"1px solid hsl(var(--border))",background:"transparent"},onMouseEnter:c=>{c.currentTarget.style.color="hsl(var(--foreground))",c.currentTarget.style.borderColor="hsl(var(--foreground))"},onMouseLeave:c=>{c.currentTarget.style.color="hsl(var(--muted-foreground))",c.currentTarget.style.borderColor="hsl(var(--border))"},children:"Reset to auto-generated"})]}):h.jsx("div",{className:"p-4 prose prose-sm max-w-none",style:{color:"hsl(var(--foreground))","--tw-prose-body":"hsl(var(--foreground))","--tw-prose-headings":"hsl(var(--foreground))","--tw-prose-code":"hsl(var(--foreground))","--tw-prose-bold":"hsl(var(--foreground))","--tw-prose-links":"hsl(var(--primary))",fontSize:"12px"},children:h.jsx(_f,{remarkPlugins:[Lf],children:t})})})]})}const TX=4e3,H0={info:{color:"hsl(var(--foreground))",bg:"hsl(var(--muted))"},warn:{color:"hsl(var(--warning, 32 95% 52%))",bg:"hsl(var(--muted))"},error:{color:"hsl(var(--destructive))",bg:"hsl(var(--destructive) / 0.08)"}};function _X(){const[t,e]=C.useState(null),r=C.useRef(null);if(C.useEffect(()=>{function i(s){const{message:o,level:a="info",ttl:l=TX}=s.detail??{};o&&(clearTimeout(r.current),e({message:o,level:a}),l>0&&(r.current=setTimeout(()=>e(null),l)))}return window.addEventListener("compose:notify",i),()=>{window.removeEventListener("compose:notify",i),clearTimeout(r.current)}},[]),!t)return null;const n=H0[t.level]??H0.info;return h.jsxs("div",{className:"h-6 flex items-center justify-between px-3 gap-2 shrink-0 text-[11px] font-mono",style:{background:n.bg,color:n.color,borderTop:"1px solid hsl(var(--border))"},role:"status","aria-live":"polite",children:[h.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.message}),h.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100 text-[10px]",onClick:()=>{clearTimeout(r.current),e(null)},"aria-label":"Dismiss notification",children:"✕"})]})}const Bu={build:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(217 91% 60%)"},gate:{background:"hsl(38 92% 50% / 0.12)",borderColor:"hsl(38 92% 50% / 0.3)",color:"hsl(38 92% 50%)"},error:{background:"hsl(0 72% 51% / 0.12)",borderColor:"hsl(0 72% 51% / 0.3)",color:"hsl(0 72% 51%)"},done:{background:"hsl(160 60% 45% / 0.12)",borderColor:"hsl(160 60% 45% / 0.3)",color:"hsl(160 60% 45%)"},iteration:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(210 100% 66%)"}},U0={enter:{transform:"translateX(20px)",opacity:0},steady:{transform:"translateX(0)",opacity:1},flash:{transform:"translateX(0)",opacity:1},exit:{transform:"translateX(0)",opacity:0}};function EX({type:t="build",label:e,retries:r=0,onClick:n,onApprove:i,onDismiss:s,animationState:o="steady"}){const a=(o==="flash"?Bu.done:Bu[t])||Bu.build,l=U0[o]||U0.steady,c=o==="exit"?"200ms":o==="flash"?"300ms":"200ms";return h.jsxs("div",{className:"ops-strip-entry",style:{display:"inline-flex",alignItems:"center",gap:"4px",height:"24px",padding:"0 10px",borderRadius:"12px",border:`1px solid ${a.borderColor}`,background:a.background,color:a.color,fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",cursor:n?"pointer":"default",whiteSpace:"nowrap",transition:`transform ${c} ease, opacity ${c} ease, background 300ms ease, border-color 300ms ease, color 300ms ease`,...l},onClick:n,role:"button",tabIndex:0,onKeyDown:u=>{u.key==="Enter"&&n&&n()},children:[h.jsxs("span",{style:{fontSize:"12px",lineHeight:1},children:[t==="build"&&"▶",t==="gate"&&"⚠",t==="error"&&"✕",t==="done"&&"✓",t==="iteration"&&"↻"]}),h.jsx("span",{children:e}),r>0&&h.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:r}),t==="gate"&&i&&h.jsx("button",{className:"ops-strip-approve",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:`1px solid ${a.borderColor}`,background:"transparent",color:a.color,fontSize:"11px",cursor:"pointer",padding:0,marginLeft:"2px",lineHeight:1},onClick:u=>{u.stopPropagation(),i()},title:"Approve gate",children:"✓"}),t==="error"&&s&&h.jsx("button",{className:"ops-strip-dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:"none",background:"transparent",color:a.color,fontSize:"10px",cursor:"pointer",padding:0,marginLeft:"2px",opacity:.6,lineHeight:1},onClick:u=>{u.stopPropagation(),s()},title:"Dismiss error",children:"✕"})]})}function NX(t){return!t||t<=0?"":`$${t.toFixed(2)}`}function jX(t){const e=Math.floor(t/1e3),r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function LX(t){const e=Math.round(t*60),r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function BX({activeBuild:t,gates:e,items:r,recentErrors:n,iterationStates:i,now:s=Date.now()}){const o=[];if(t&&t.featureCode){const a=t.currentStep?`${t.currentStep}`:"building",l=t.totalSteps?` · step ${t.currentStepIndex??"?"}/${t.totalSteps}`:"",c=NX(t.cumulative_cost_usd),u=c?` · ${c}`:"",d=t.flowId||t.startedAt||t.featureCode;o.push({key:`build-${t.featureCode}-${d}`,type:t.status==="complete"?"done":"build",label:`${t.featureCode} · ${a}${l}${u}`,featureCode:t.featureCode,retries:t.retries??0})}if(Array.isArray(e)){for(const a of e)if(a.status==="pending"){const l=wn[a.stepId]??(a.fromPhase||a.toPhase||"Gate"),c=Array.isArray(r)?r.find(d=>d.id===a.itemId):null,u=(c==null?void 0:c.title)||a.featureCode||"";o.push({key:`gate-${a.id}`,type:"gate",label:u?`${l} — ${u}`:l,featureCode:a.featureCode||"",gateId:a.id})}}if(i){for(const[a,l]of i)if(l.status==="running"){const c=l.loopType==="review"?"review":"coverage",u=`${l.count}/${l.maxIterations}`;let d="";if(l.wallClockTimeout!=null&&l.startedAt){const p=s-new Date(l.startedAt).getTime();d=`, ${jX(p)}/${LX(l.wallClockTimeout)}`}o.push({key:`iter-${a}`,type:"iteration",label:`${c} ${u}${d}`})}}if(Array.isArray(n))for(const a of n){const l=a.featureCode||"system",c=(a.message||a.errorType||"error").substring(0,60);o.push({key:`error-${a.timestamp}-${c.substring(0,10)}`,type:"error",label:`${l} · ${c}`,featureCode:l,timestamp:a.timestamp})}return o}function AX({activeView:t,onSelectFeature:e}){const{activeBuild:r,gates:n,items:i,recentErrors:s,resolveGate:o,iterationStates:a}=mr(Di(O=>({activeBuild:O.activeBuild,gates:O.gates,items:O.items,recentErrors:O.recentErrors,resolveGate:O.resolveGate,iterationStates:O.iterationStates}))),[l,c]=C.useState(new Map),u=C.useRef([]),d=C.useRef(new Set),p=C.useRef(new Set),[f,m]=C.useState(null),x=C.useRef(null),g=(r==null?void 0:r.featureCode)??null;C.useEffect(()=>{if(!g){m(null),x.current=null;return}g!==x.current&&(x.current=g,zt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(g)}`).then(O=>O.json()).then(O=>m(O)).catch(()=>{}))},[g]);const y=C.useRef(0);C.useEffect(()=>{if(!g)return;const O=a?[...a.values()].reduce((I,F)=>I+(F.count??0),0):0;O!==y.current&&(y.current=O,zt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(g)}`).then(I=>I.json()).then(I=>m(I)).catch(()=>{}))},[a,g]);const b=C.useRef(r),[k,T]=C.useState(null);C.useEffect(()=>{const O=b.current;if(O&&O.featureCode&&!r){T({...O,status:"complete"});const I=setTimeout(()=>T(null),3e3);return b.current=r,()=>clearTimeout(I)}b.current=r},[r]);const _=r||k,[w,E]=C.useState(()=>Date.now()),L=a&&[...a.values()].some(O=>O.status==="running");C.useEffect(()=>{if(!L)return;const O=setInterval(()=>E(Date.now()),1e3);return()=>clearInterval(O)},[L]);const M=C.useMemo(()=>BX({activeBuild:_,gates:n,items:i,recentErrors:s,iterationStates:a,now:w}),[_,n,i,s,a,w]),N=C.useMemo(()=>M.filter(O=>!d.current.has(O.key)),[M]);C.useEffect(()=>{const O=new Set(u.current.map(F=>F.key)),I=N.filter(F=>!O.has(F.key)).map(F=>F.key);I.length>0&&(c(F=>{const D=new Map(F);for(const R of I)D.set(R,"enter");return D}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(F=>{const D=new Map(F);for(const R of I)D.get(R)==="enter"&&D.set(R,"steady");return D})})}));for(const F of N)F.type==="done"&&!p.current.has(F.key)&&(p.current.add(F.key),c(D=>{const R=new Map(D);return R.set(F.key,"flash"),R}),setTimeout(()=>{c(D=>{const R=new Map(D);return R.set(F.key,"exit"),R}),setTimeout(()=>{d.current.add(F.key),c(D=>{const R=new Map(D);return R.delete(F.key),R})},500)},2e3));u.current=N},[N]);const P=C.useCallback(O=>{c(I=>{const F=new Map(I);return F.set(O,"exit"),F}),setTimeout(()=>{d.current.add(O),c(I=>{const F=new Map(I);return F.delete(O),F})},200)},[]),$=C.useCallback(O=>{o&&o(O,"approve","Approved from ops strip")},[o]);if(t==="docs"||N.length===0)return null;const q=yX(f);return h.jsxs("div",{className:"ops-strip",style:{height:"36px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",overflowX:"auto",overflowY:"hidden",borderTop:"1px solid hsl(var(--border))",background:"hsl(var(--background))",flexShrink:0},children:[N.map(O=>h.jsx(EX,{type:O.type,label:O.label,retries:O.retries,animationState:l.get(O.key)||"steady",onClick:e?()=>e(O.featureCode):void 0,onApprove:O.type==="gate"&&O.gateId?()=>$(O.gateId):void 0,onDismiss:O.type==="error"?()=>P(O.key):void 0},O.key)),q&&h.jsx("span",{className:"ml-auto text-[9px] text-muted-foreground font-mono shrink-0 opacity-70",title:"Cumulative budget usage: review / coverage",children:q})]})}const Au=["dashboard","graph","tree","docs","design","gates","pipeline","sessions","ideabox"];function MX(t,e){return!e||!Array.isArray(t)?!1:t.includes(e)}function IX(t){return(t==null?void 0:t[0])??null}const FX="compose:mainTabs",JT="compose:activeTab";function PX(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(FX);if(!e)return[...Au];const r=JSON.parse(e);if(Array.isArray(r)&&r.length>=1){let n=r;for(const i of Au)if(!n.includes(i)){const s=n.indexOf("docs");s>=0?n=[...n.slice(0,s+1),i,...n.slice(s+1)]:n=[...n,i]}return n}}catch{}return[...Au]}function DX(t){var e;try{const r=(e=globalThis.localStorage)==null?void 0:e.getItem(JT);if(r&&MX(t,r))return r}catch{}return IX(t)}function G0(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(JT,t)}catch{}}function t_(t,e){var r;try{const n=(r=globalThis.localStorage)==null?void 0:r.getItem(t);return n==null?e:n!=="false"}catch{return e}}function e_(t,e){var r;try{(r=globalThis.localStorage)==null||r.setItem(t,String(!!e))}catch{}}const r_="compose:sidebarOpen",n_="compose:contextPanelOpen";function OX(){return t_(r_,!0)}function RX(t){return e_(r_,t)}function $X(){return t_(n_,!1)}function V0(t){return e_(n_,t)}const tf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));tf.displayName="Card";const ef=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("flex flex-col space-y-1.5 p-6",t),...e}));ef.displayName="CardHeader";const rf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("font-semibold leading-none tracking-tight",t),...e}));rf.displayName="CardTitle";const zX=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("text-sm text-muted-foreground",t),...e}));zX.displayName="CardDescription";const nf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("p-6 pt-0",t),...e}));nf.displayName="CardContent";const WX=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("flex items-center p-6 pt-0",t),...e}));WX.displayName="CardFooter";function qX(t){const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Y0({agent:t,toolCount:e,errorCount:r,currentTool:n,currentCategory:i,onStop:s}){const o=t.status==="running",a=t.status==="killed",l=t.status==="failed"||t.status==="error"||a,c=!o&&!l,u=t.silent,[d,p]=C.useState(()=>{const m=t.startedAt?new Date(t.startedAt).getTime():Date.now();return(t.completedAt?new Date(t.completedAt).getTime():Date.now())-m});C.useEffect(()=>{if(!o)return;const m=t.startedAt?new Date(t.startedAt).getTime():Date.now(),x=()=>p(Date.now()-m);x();const g=setInterval(x,1e3);return()=>clearInterval(g)},[o,t.startedAt]);const f=t.agentType||t.type||t.agent||"agent";return h.jsxs("div",{className:"px-3 py-2 rounded border border-border bg-muted/20",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"text-[11px] text-foreground font-medium truncate",children:f}),h.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[h.jsx("span",{className:nt("w-1.5 h-1.5 rounded-full inline-block",o&&!u&&"bg-green-400",o&&u&&"bg-yellow-400",c&&"bg-emerald-400",l&&"bg-red-400"),style:o&&!u?{animation:"phase-active-pulse 2s ease-in-out infinite"}:void 0}),h.jsx("span",{className:nt("text-[10px]",o&&!u&&"text-green-400",o&&u&&"text-yellow-400",c&&"text-emerald-400",l&&"text-red-400"),children:u?"silent":t.status}),h.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:qX(d)}),o&&s&&h.jsx("button",{onClick:m=>{m.stopPropagation(),s(t.agentId||t.id)},className:"text-[10px] text-muted-foreground hover:text-destructive cursor-pointer ml-0.5",title:"Stop agent",children:"x"})]})]}),h.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:e!=null&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{children:[e," tools"]}),h.jsx("span",{className:"mx-1",children:"·"}),h.jsxs("span",{className:nt(r>0&&"text-red-400"),children:[r??0," err"]}),o&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"mx-1",children:"·"}),h.jsxs("span",{children:[i||"working"," (",n,")"]})]})]})})]})}function HX(t,e,r){const n=new Array(t);return new Proxy(n,{get(i,s,o){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const l=+s;if(Number.isInteger(l)&&l>=0&&l<t){let c=i[l];if(!c){const u=e[l*2];c=i[l]={index:l,key:r(l),start:u,size:e[l*2+1],end:u+e[l*2+1],lane:0}}return c}}if(s==="length")return t}return Reflect.get(i,s,o)}})}function rs(t,e,r){let n=r.initialDeps??[],i,s=!0;function o(){const a=t();return(a.length!==n.length||a.some((c,u)=>n[u]!==c))&&(n=a,i=e(...a),r!=null&&r.onChange&&!(s&&r.skipInitialOnChange)&&r.onChange(i),s=!1),i}return o.updateDeps=a=>{n=a},o}function X0(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const UX=(t,e)=>Math.abs(t-e)<1.01,GX=(t,e,r)=>{let n;return function(...i){t.clearTimeout(n),n=t.setTimeout(()=>e.apply(this,i),r)}};let Lo;const Mu=()=>{if(Lo!==void 0)return Lo;if(typeof navigator>"u")return Lo=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Lo=!0;const t=navigator.maxTouchPoints;return Lo=navigator.platform==="MacIntel"&&t!==void 0&&t>0},K0=t=>{const{offsetWidth:e,offsetHeight:r}=t;return{width:e,height:r}},VX=t=>t,YX=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,i=new Array(n);for(let s=0;s<n;s++)i[s]=e+s;return i},XX=(t,e)=>{const r=t.scrollElement;if(!r)return;const n=t.targetWindow;if(!n)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(K0(r)),!n.ResizeObserver)return()=>{};const s=new n.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(K0(r))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(r,{box:"border-box"}),()=>{s.unobserve(r)}},Bc={passive:!0},KX=typeof window>"u"?!0:"onscrollend"in window,ZX=(t,e,r)=>{const n=t.scrollElement;if(!n)return;const i=t.targetWindow;if(!i)return;const s=t.options.useScrollendEvent&&KX;let o=0;const a=s?null:GX(i,()=>e(o,!1),t.options.isScrollingResetDelay),l=d=>()=>{o=r(n),a==null||a(),e(o,d)},c=l(!0),u=l(!1);return n.addEventListener("scroll",c,Bc),s&&n.addEventListener("scrollend",u,Bc),()=>{n.removeEventListener("scroll",c),s&&n.removeEventListener("scrollend",u)}},QX=(t,e)=>ZX(t,e,r=>{const{horizontal:n,isRtl:i}=t.options;return n?r.scrollLeft*(i&&-1||1):r.scrollTop}),JX=(t,e,r)=>{if(e!=null&&e.borderBoxSize){const n=e.borderBoxSize[0];if(n)return Math.round(n[r.options.horizontal?"inlineSize":"blockSize"])}return t[r.options.horizontal?"offsetWidth":"offsetHeight"]},tK=(t,{adjustments:e=0,behavior:r},n)=>{var i,s;(s=(i=n.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[n.options.horizontal?"left":"top"]:t+e,behavior:r})},eK=tK;class rK{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var r,n,i;return((i=(n=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:n.now)==null?void 0:i.call(n))??Date.now()},this.observer=(()=>{let r=null;const n=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[c,u]of this.elementsCache)if(u===a){this.elementsCache.delete(c);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=n())==null||i.disconnect(),r=null},observe:i=>{var s;return(s=n())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=n())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=r=>{var n,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:VX,rangeExtractor:YX,onChange:()=>{},measureElement:JX,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate"};for(const p in r){const f=r[p];f!==void 0&&(s[p]=f)}const o=this.options;let a=null,l=null,c=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const p=o.count,f=s.count,m=this.getMeasurements(),x=p>0?((n=m[0])==null?void 0:n.key)??o.getItemKey(0):null,g=p>0?((i=m[p-1])==null?void 0:i.key)??o.getItemKey(p-1):null;if(f!==p||p>0&&f>0&&(s.getItemKey(0)!==x||s.getItemKey(f-1)!==g)){c=!0;const k=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??m[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const T=s.followOnAppend===!0?"auto":s.followOnAppend||null;T&&f>p&&this.isAtEnd(o.scrollEndThreshold)&&(p===0||s.getItemKey(f-1)!==g)&&(l=T)}}this.options=s,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,d=0;if(a&&this.scrollOffset!==null){const[p,f]=a,m=this.getMeasurements(),{count:x,getItemKey:g}=this.options;let y=0;for(;y<x&&g(y)!==p;)y++;if(y<x){const b=m[y];if(b){const k=b.start+f;k!==this.scrollOffset&&(d=k-this.scrollOffset,this.scrollOffset=k,u=!0)}}}(u||l)&&(this.pendingScrollAnchor=[u?a[0]:null,u?a[1]:0,l,d])},this.notify=r=>{var n,i;(i=(n=this.options).onChange)==null||i.call(n,this,r)},this.maybeNotify=rs(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Mu()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Bc),s.addEventListener("touchend",a,Bc),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(Mu()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const r=this.getScrollOffset(),n=this.getMaxScrollOffset();if(r<0||r>n)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(r,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,n)=>{const i=new Map,s=new Map;for(let o=n-1;o>=0;o--){const a=r[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=rs(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(r,n,i,s,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=rs(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l},c)=>{const u=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const m of this.laneAssignments.keys())m>=r&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const d=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1),a===1){const m=this.options.gap,x=r*2;let g=this._flatMeasurements;if(!g||g.length<x){const k=new Float64Array(x);g&&d>0&&k.set(g.subarray(0,d*2)),g=k,this._flatMeasurements=g}let y;if(d===0)y=n+i;else{const k=d-1;y=g[k*2]+g[k*2+1]+m}for(let k=d;k<r;k++){const T=s(k),_=u.get(T),w=typeof _=="number"?_:this.options.estimateSize(k);g[k*2]=y,g[k*2+1]=w,y+=w+m}const b=HX(r,g,s);return this.measurementsCache=b,b}const p=this.measurementsCache.slice(0,d),f=new Array(a).fill(void 0);for(let m=0;m<d;m++){const x=p[m];x&&(f[x.lane]=m)}for(let m=d;m<r;m++){const x=s(m),g=this.laneAssignments.get(m);let y,b;const k=l==="estimate"||u.has(x);if(g!==void 0&&this.options.lanes>1){y=g;const E=f[y],L=E!==void 0?p[E]:void 0;b=L?L.end+this.options.gap:n+i}else{const E=this.options.lanes===1?p[m-1]:this.getFurthestMeasurement(p,m);b=E?E.end+this.options.gap:n+i,y=E?E.lane:m%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(m,y)}const T=u.get(x),_=typeof T=="number"?T:this.options.estimateSize(m),w=b+_;p[m]={index:m,start:b,size:_,end:w,key:x,lane:y},f[y]=m}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=rs(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,n,i,s)=>this.range=r.length>0&&n>0?nK({measurements:r,outerSize:n,scrollOffset:i,lanes:s,flat:s===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=rs(()=>{let r=null,n=null;const i=this.calculateRange();return i&&(r=i.startIndex,n=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,n]},(r,n,i,s,o)=>s===null||o===null?[]:r({startIndex:s,endIndex:o,overscan:n,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const n=this.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),a=Math.min(this.options.count-1,i+s);return r>=o&&r<=a}return!0},this.measureElement=r=>{if(!r){this.elementsCache.forEach((o,a)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(a))});return}const n=this.indexFromElement(r),i=this.options.getItemKey(n),s=this.elementsCache.get(i);s!==r&&(s&&this.observer.unobserve(s),this.observer.observe(r),this.elementsCache.set(i,r)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(r,void 0,this))},this.resizeItem=(r,n)=>{var i,s;if(r<0||r>=this.options.count)return;let o,a,l;const c=this._flatMeasurements;if(this.options.lanes===1&&c!==null)l=this.options.getItemKey(r),a=c[r*2],o=c[r*2+1];else{const p=this.measurementsCache[r];if(!p)return;l=p.key,a=p.start,o=p.size}const u=this.itemSizeCache.get(l)??o,d=n-u;if(d!==0){const p=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=p?this.getTotalSize():0,m=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[r]??{index:r,key:l,start:a,size:o,end:a+o,lane:0},d,this):a<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||r<this.pendingMin)&&(this.pendingMin=r),this.itemSizeCache.set(l,n),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-f):m&&this.applyScrollAdjustment(d),this.notify(!1)}},this.getVirtualItems=rs(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,n)=>{const i=[];for(let s=0,o=r.length;s<o;s++){const a=r[s],l=n[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const n=this.getMeasurements();if(n.length===0)return;const i=this._flatMeasurements,s=this.options.lanes===1&&i!=null,o=i_(0,n.length-1,s?a=>i[a*2]:a=>X0(n[a]).start,r);return X0(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(r=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=r,this.getOffsetForAlignment=(r,n,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=r>=o+s?"end":"start"),n==="center"?r+=(i-s)/2:n==="end"&&(r-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,r),0)},this.getOffsetForIndex=(r,n="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[r];if(!o)return;if(n==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)n="end";else if(o.start<=s+this.options.scrollPaddingStart)n="start";else return[s,n];if(n==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),n];const a=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,n,o.size),n]},this.scrollToOffset=(r,{align:n="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(r,n),o=this.now();this.scrollState={index:null,align:n,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:n="auto",behavior:i="auto"}={})=>{r=Math.max(0,Math.min(r,this.options.count-1));const s=this.getOffsetForIndex(r,n);if(!s)return;const[o,a]=s,l=this.now();this.scrollState={index:r,align:a,behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:n="auto"}={})=>{const i=this.getScrollOffset()+r,s=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:r="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:r});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:r})},this.getTotalSize=()=>{var r;const n=this.getMeasurements();let i;if(n.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=n.length-1,o=this._flatMeasurements;o!=null?i=o[s*2]+o[s*2+1]:i=((r=n[s])==null?void 0:r.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&s.some(a=>a===null);){const a=n[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const r=[];if(this.itemSizeCache.size===0)return r;const n=this.getMeasurements();for(const i of n)i&&this.itemSizeCache.has(i.key)&&r.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return r},this._scrollToOffset=(r,{adjustments:n,behavior:i})=>{this._intendedScrollOffset=r+(n??0),this.options.scrollToFn(r,{behavior:i,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,r){e!==0&&(Mu()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:r}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=n?n[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&UX(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const a=this.getSize()||600,l=Math.abs(i-this.getScrollOffset()),c=this.scrollState.behavior==="smooth"&&l>a;this.scrollState.lastTargetOffset=i,c||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:c?"smooth":"auto"})}this.scheduleScrollReconcile()}}const i_=(t,e,r,n)=>{for(;t<=e;){const i=(t+e)/2|0,s=r(i);if(s<n)t=i+1;else if(s>n)e=i-1;else return i}return t>0?t-1:0};function nK({measurements:t,outerSize:e,scrollOffset:r,lanes:n,flat:i}){const s=t.length-1,o=i?u=>i[u*2]:u=>t[u].start,a=i?u=>i[u*2]+i[u*2+1]:u=>t[u].end;if(t.length<=n)return{startIndex:0,endIndex:s};let l=i_(0,s,o,r),c=l;if(n===1)for(;c<s&&a(c)<r+e;)c++;else if(n>1){const u=Array(n).fill(0);for(;c<s&&u.some(p=>p<r+e);){const p=t[c];u[p.lane]=p.end,c++}const d=Array(n).fill(r+e);for(;l>=0&&d.some(p=>p>=r);){const p=t[l];d[p.lane]=p.start,l--}l=Math.max(0,l-l%n),c=Math.min(s,c+(n-1-c%n))}return{startIndex:l,endIndex:c}}const Iu=typeof document<"u"?C.useLayoutEffect:C.useEffect;function iK({useFlushSync:t=!0,directDomUpdates:e=!1,directDomUpdatesMode:r="transform",...n}){const i=C.useReducer(c=>c+1,0)[1],s=C.useRef({enabled:e,mode:r,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=e,s.current.mode=r;const o=c=>{const u=s.current;if(!u.enabled)return;const d=c.getTotalSize();if(u.container&&d!==u.lastSize){u.lastSize=d;const y=c.options.horizontal?"width":"height";u.container.style[y]=`${d}px`}const p=!!c.options.horizontal,f=u.mode==="transform",m=p?"left":"top",x=c.options.scrollMargin,g=c.getVirtualItems();for(const y of g){const b=y.start-x,k=c.elementsCache.get(y.key);k&&u.lastPositions.get(k)!==b&&(u.lastPositions.set(k,b),f?k.style.transform=p?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:k.style[m]=`${b}px`)}},a={...n,onChange:(c,u)=>{var d;const p=s.current;let f=!0;if(p.enabled){o(c);const m=c.range,x=p.prevRange;f=!x||x.isScrolling!==c.isScrolling||x.startIndex!==(m==null?void 0:m.startIndex)||x.endIndex!==(m==null?void 0:m.endIndex),f&&(p.prevRange=m?{startIndex:m.startIndex,endIndex:m.endIndex,isScrolling:c.isScrolling}:null)}f&&(t&&u?Rf.flushSync(i):i()),(d=n.onChange)==null||d.call(n,c,u)}},[l]=C.useState(()=>{const c=new rK(a);return Object.assign(c,{containerRef:u=>{const d=s.current;if(d.container=u,d.lastSize=null,u&&d.enabled){const p=c.getTotalSize();d.lastSize=p;const f=c.options.horizontal?"width":"height";u.style[f]=`${p}px`}}})});return l.setOptions(a),Iu(()=>l._didMount(),[]),Iu(()=>l._willUpdate()),Iu(()=>{o(l)}),l}function sK(t){return iK({observeElementRect:XX,observeElementOffset:QX,scrollToFn:eK,...t})}function oK(t,e,r){var a,l;const n=[],i=(r==null?void 0:r.id)??null;if(Array.isArray(t))for(const c of t){if(n.push({id:`session-start-${c.id}`,timestamp:c.startedAt,category:"session",title:"Session started",detail:c.source?`Source: ${c.source}`:null,severity:"info",sessionId:c.id,meta:{toolCount:c.toolCount,source:c.source}}),c.endedAt&&n.push({id:`session-end-${c.id}`,timestamp:c.endedAt,category:"session",title:`Session ended (${c.toolCount??0} tools${(a=c.errors)!=null&&a.length?`, ${c.errors.length} error${c.errors.length>1?"s":""}`:""})`,detail:null,severity:"info",sessionId:c.id,meta:{toolCount:c.toolCount,errorCount:((l=c.errors)==null?void 0:l.length)??0}}),Array.isArray(c.errors))for(let u=0;u<c.errors.length;u++){const d=c.errors[u];n.push({id:`error-${c.id}-${u}`,timestamp:d.timestamp||c.startedAt,category:"error",title:d.message||`${d.type} error`,detail:d.tool?`Tool: ${d.tool}`:null,severity:d.severity==="error"?"error":"warning",sessionId:c.id,meta:{type:d.type,tool:d.tool}})}if(c.phaseAtBind&&c.phaseAtEnd&&c.phaseAtBind!==c.phaseAtEnd){const u=new Date(c.startedAt).getTime(),d=c.endedAt?new Date(c.endedAt).getTime():u,p=new Date(u+(d-u)*.8).toISOString();n.push({id:`phase-${c.id}`,timestamp:p,category:"phase",title:`Phase: ${c.phaseAtBind} → ${c.phaseAtEnd}`,detail:null,severity:"success",sessionId:c.id,meta:{from:c.phaseAtBind,to:c.phaseAtEnd}})}}if(Array.isArray(e)){const c=i?e.filter(u=>u.itemId===i):e;for(const u of c){if(u.createdAt){const d=wn[u.stepId]??(u.fromPhase&&u.toPhase?`${Te[u.fromPhase]??u.fromPhase} → ${Te[u.toPhase]??u.toPhase}`:"Gate created");n.push({id:`gate-created-${u.id}`,timestamp:u.createdAt,category:"gate",title:d,detail:null,severity:"info",sessionId:null,meta:{gateId:u.id,fromPhase:u.fromPhase,toPhase:u.toPhase}})}if(u.resolvedAt&&u.outcome){const p={approve:"approve",approved:"approve",revise:"revise",revised:"revise",kill:"kill",killed:"kill"}[u.outcome]||u.outcome,f={approve:"success",revise:"warning",kill:"error"},m={approve:"approved",revise:"revised",kill:"killed"};n.push({id:`gate-resolved-${u.id}`,timestamp:u.resolvedAt,category:"gate",title:`Gate ${m[p]||u.outcome}`,detail:u.comment||null,severity:f[p]||"info",sessionId:null,meta:{gateId:u.id,outcome:u.outcome,comment:u.comment}})}}}const s=new Set,o=[];for(const c of n)s.has(c.id)||(s.add(c.id),o.push(c));return o.sort((c,u)=>c.timestamp.localeCompare(u.timestamp)),o}const aK={phase:"→",gate:"◈",session:"●",iteration:"↻",error:"⚠"};function lK(t){if(!t)return"";const e=Date.now()-new Date(t).getTime(),r=Math.floor(e/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const n=Math.floor(r/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function cK({event:t,onSelectItem:e,style:r}){const n=aK[t.category]||"●",i=T_[t.category]||"text-zinc-400",s=S_[t.severity]||"text-zinc-400";return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded",style:r,children:[h.jsx("span",{className:nt("text-[11px] shrink-0 w-4 text-center leading-4",i),children:n}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:nt("text-[11px] truncate",s),children:t.title}),t.detail&&h.jsx("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:t.detail})]}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0 leading-4",children:lK(t.timestamp)})]})}const hK=["all","phase","gate","session","iteration","error"],Z0={all:"All",phase:"Phase",gate:"Gate",session:"Session",iteration:"Iteration",error:"Error"};function uK({featureCode:t,itemId:e,onSelectItem:r}){const[n,i]=C.useState("all"),[s,o]=C.useState([]),a=C.useRef(null),l=mr(m=>m.gates),c=mr(m=>m.featureTimeline),u=mr(m=>m.setFeatureTimeline);C.useEffect(()=>{if(!t)return;let m=!1;return zt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=50`).then(x=>x.json()).then(x=>{if(m)return;const g=e?(l||[]).filter(b=>b.itemId===e):l||[],y=oK(x.sessions||[],g,{id:e});o(y)}).catch(()=>{m||o([])}),()=>{m=!0}},[t,e]);const d=C.useMemo(()=>{var g,y;const m=new Map;for(const b of s)m.set(b.id,b);for(const b of c){const k=(g=b.meta)==null?void 0:g.itemId,T=(y=b.meta)==null?void 0:y.featureCode;(!k&&!T||k===e||T===t)&&m.set(b.id,b)}const x=[...m.values()];return x.sort((b,k)=>b.timestamp.localeCompare(k.timestamp)),x},[s,c,e,t]),p=C.useMemo(()=>n==="all"?d:d.filter(m=>m.category===n),[d,n]),f=sK({count:p.length,getScrollElement:()=>a.current,estimateSize:()=>48,overscan:5});return C.useEffect(()=>{u&&u([])},[t]),t?h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsx("div",{className:"flex flex-wrap gap-1 px-2 py-2 border-b border-border",children:hK.map(m=>h.jsxs("button",{className:nt("px-2 py-0.5 rounded text-[10px] font-medium transition-colors",n===m?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:()=>i(m),children:[Z0[m],m!=="all"&&h.jsx("span",{className:"ml-1 text-[9px] opacity-60",children:d.filter(x=>x.category===m).length})]},m))}),h.jsx("div",{className:"px-2 py-1",children:h.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:[p.length," event",p.length!==1?"s":""]})}),h.jsx("div",{ref:a,className:"flex-1 overflow-auto",children:p.length===0?h.jsxs("p",{className:"text-[11px] text-muted-foreground/50 px-2 py-4 text-center",children:["No events",n!=="all"?` in "${Z0[n]}"`:"","."]}):h.jsx("div",{style:{height:`${f.getTotalSize()}px`,width:"100%",position:"relative"},children:f.getVirtualItems().map(m=>h.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${m.size}px`,transform:`translateY(${m.start}px)`},children:h.jsx(cK,{event:p[m.index],onSelectItem:r})},m.key))})})]}):h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsx("p",{className:"text-[11px] text-muted-foreground/50",children:"Select a feature to see its timeline."})})}const Zo=["explore_design","prd","architecture","blueprint","plan","execute","report"];function dK(t){if(!t)return"";const e=Date.now()-new Date(t).getTime(),r=Math.floor(e/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function fK({currentPhase:t}){const e=Zo.indexOf(t);return h.jsx("div",{className:"space-y-1.5",children:Zo.map((r,n)=>{const i=e>n,s=e===n,o=Te[r]??r;return h.jsxs("div",{className:"flex items-center gap-2",style:{animation:`phase-slide-in 300ms ease-out ${n*50}ms both`},children:[i?h.jsx(Tb,{className:"w-3.5 h-3.5 text-emerald-400 shrink-0",style:{animation:"phase-check-pop 400ms ease-out"}}):s?h.jsx(vb,{className:"w-3.5 h-3.5 text-blue-400 shrink-0",style:{animation:"phase-active-pulse 2s ease-in-out infinite"}}):h.jsx(KA,{className:"w-3.5 h-3.5 text-muted-foreground/40 shrink-0"}),h.jsx("span",{className:nt("text-[11px] transition-colors duration-500",i&&"text-emerald-400",s&&"text-blue-400 font-medium",!i&&!s&&"text-muted-foreground/50"),children:o})]},r)})})}function pK({spawnedAgents:t,activeBuild:e,sessionState:r,agentActivity:n}){const i=(t||[]).filter(a=>a.status==="running"),s=(t||[]).filter(a=>a.status!=="running").slice(-3).reverse(),o=C.useMemo(()=>{const a=["design.md","blueprint.md","plan.md","prd.md","architecture.md"],l=new Set(((e==null?void 0:e.steps)||[]).filter(c=>c.status==="done"||c.status==="completed").map(c=>c.id||c.name));return a.map(c=>({name:c,done:l.has(c)||((e==null?void 0:e.steps)||[]).some(u=>{var d,p;return(u.status==="done"||u.status==="completed")&&(((d=u.id)==null?void 0:d.includes(c.replace(".md","")))||((p=u.name)==null?void 0:p.includes(c.replace(".md",""))))})}))},[e]);return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents"}),i.length===0&&s.length===0&&h.jsx("p",{className:"text-[11px] text-muted-foreground/50 mt-1",children:"No agents active"}),h.jsxs("div",{className:"mt-1 space-y-1.5",children:[i.map((a,l)=>h.jsx(Y0,{agent:a,toolCount:(r==null?void 0:r.toolCount)||0,errorCount:(r==null?void 0:r.errorCount)||0,currentTool:n==null?void 0:n.tool,currentCategory:n==null?void 0:n.category},a.agentId||l)),s.map((a,l)=>h.jsx(Y0,{agent:a},a.agentId||`r-${l}`))]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Artifacts"}),h.jsx("div",{className:"mt-1 space-y-1",children:o.map(a=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Ii,{className:nt("w-3 h-3",a.done?"text-emerald-400":"text-muted-foreground/40")}),h.jsx("span",{className:nt("text-[11px] font-mono",a.done?"text-foreground":"text-muted-foreground/50"),children:a.name})]},a.name))})]})]})}function mK({gates:t,allGates:e,items:r,onResolveGate:n}){const i=C.useMemo(()=>{const s=new Map,o=(e||[]).filter(a=>a.resolvedAt&&(a.outcome==="revised"||a.outcome==="revise")).sort((a,l)=>new Date(l.resolvedAt)-new Date(a.resolvedAt));for(const a of t||[]){const l=o.find(c=>c.stepId===a.stepId&&c.itemId===a.itemId);l!=null&&l.artifactSnapshot&&a.artifactSnapshot&&s.set(a.id,{priorSnapshot:l.artifactSnapshot,currentSnapshot:a.artifactSnapshot})}return s},[t,e]);return!t||t.length===0?h.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No gates pending."}):h.jsx("div",{className:"space-y-2",children:t.map(s=>{var l;const o=r.find(c=>c.id===s.itemId),a=(l=s.artifactAssessment)==null?void 0:l.completeness;return h.jsx("div",{className:"px-3 py-2 rounded border border-border bg-muted/30",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-[11px] text-foreground truncate",children:(o==null?void 0:o.title)??"Unknown"}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[wn[s.stepId]??Te[s.fromPhase]??s.fromPhase??"Gate",a!=null&&` · ${Math.round(a*100)}% complete`]}),i.has(s.id)&&h.jsx("div",{className:"mt-1",children:h.jsx(Vp,{oldText:i.get(s.id).priorSnapshot,newText:i.get(s.id).currentSnapshot})})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>n(s.id,"approved"),children:"Approve"}),h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",onClick:()=>n(s.id,"revised"),children:"Revise"}),h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>n(s.id,"killed"),children:"Kill"})]})]})},s.id)})})}function gK({sessions:t,items:e,onSelect:r}){const n=(t||[]).slice(-5).reverse();return n.length===0?h.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No sessions yet."}):h.jsx("div",{className:"space-y-1",children:n.map(i=>{const s=i.featureCode||i.feature_code,o=s?e.find(l=>{var c;return l.featureCode===s||l.feature_code===s||((c=l.lifecycle)==null?void 0:c.featureCode)===s}):null,a=i.startedAt||i.created_date;return h.jsxs("div",{className:nt("flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors",o&&"cursor-pointer"),onClick:()=>o&&r(o.id),children:[h.jsx(qM,{className:"w-3 h-3 text-muted-foreground shrink-0"}),h.jsx("span",{className:"text-[11px] text-foreground",children:i.agent||"agent"}),s&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:s}),h.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground tabular-nums shrink-0",children:dK(a)}),h.jsx("span",{className:nt("w-1.5 h-1.5 rounded-full shrink-0",i.status==="active"?"bg-emerald-400":"bg-slate-600")})]},i.id)})})}function xK({items:t=[],gates:e=[],sessions:r=[],activeBuild:n,spawnedAgents:i=[],featureCode:s,sessionState:o,agentActivity:a,iterationStates:l,onSelect:c,onResolveGate:u,onOpenGate:d}){var T;const p=C.useMemo(()=>t.find(_=>{var w;return _.featureCode===s||((w=_.lifecycle)==null?void 0:w.featureCode)===s}),[t,s]),[f,m]=C.useState(()=>{try{return localStorage.getItem("compose:timeline-open")==="true"}catch{return!1}}),x=C.useCallback(()=>{m(_=>{const w=!_;try{localStorage.setItem("compose:timeline-open",String(w))}catch{}return w})},[]),g=((T=p==null?void 0:p.lifecycle)==null?void 0:T.currentPhase)||(p==null?void 0:p.phase)||(n==null?void 0:n.currentStepId)||(n==null?void 0:n.currentStep)||null,y=Zo.indexOf(g),b=g?Math.max(0,(y+1)/Zo.length):0,k=C.useMemo(()=>{let _=e.filter(w=>w.status==="pending"||!w.resolvedAt);if(s){const w=new Set(t.filter(E=>{var L;return E.featureCode===s||((L=E.lifecycle)==null?void 0:L.featureCode)===s}).map(E=>E.id));_=_.filter(E=>w.has(E.itemId))}return _},[e,t,s]);if(!s){const _=t.filter(w=>w.type==="feature"&&(w.status==="complete"||w.status==="done")).slice(-5);return h.jsx("div",{className:"flex-1 overflow-auto p-4",children:h.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-16 text-center",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"No feature in progress."}),h.jsx("p",{className:"text-[11px] text-muted-foreground/70 font-mono",children:"Run /compose <feature-code> in the terminal to start."}),_.length>0&&h.jsxs("div",{className:"mt-6 w-full max-w-sm",children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recently completed"}),h.jsx("div",{className:"mt-2 space-y-1",children:_.map(w=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>c(w.id),children:[h.jsx(Tb,{className:"w-3 h-3 text-emerald-400 shrink-0"}),h.jsx("span",{className:"text-[11px] text-foreground truncate",children:w.title}),w.featureCode&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-auto shrink-0",children:w.featureCode})]},w.id))})]})]})})}return h.jsxs("div",{className:"flex-1 flex flex-row overflow-hidden",children:[h.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4 min-w-0",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:(p==null?void 0:p.title)??s}),h.jsx(nr,{variant:"outline",className:"text-[9px] px-1.5 py-0 h-4 font-mono shrink-0",children:s}),g&&h.jsx(nr,{variant:"secondary",className:"text-[9px] px-1.5 py-0 h-4 shrink-0",children:Te[g]??g}),h.jsxs("button",{className:nt("ml-auto flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors shrink-0",f?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:x,children:[h.jsx(xM,{className:"w-3 h-3"}),"Timeline"]})]}),h.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-muted overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full bg-blue-500",style:{width:`${Math.round(b*100)}%`,transition:"width 800ms cubic-bezier(0.4, 0, 0.2, 1)"}})}),h.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:y>=0?`${y+1} of ${Zo.length} phases`:"Phase unknown"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs(tf,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out"},children:[h.jsx(ef,{className:"p-3 pb-2",children:h.jsx(rf,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Phase Timeline"})}),h.jsx(nf,{className:"p-3 pt-0",children:h.jsx(fK,{currentPhase:g})})]}),h.jsxs(tf,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out 100ms both"},children:[h.jsx(ef,{className:"p-3 pb-2",children:h.jsx(rf,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents & Artifacts"})}),h.jsx(nf,{className:"p-3 pt-0",children:h.jsx(pK,{spawnedAgents:i,activeBuild:n,sessionState:o,agentActivity:a})})]})]}),l&&l.size>0&&h.jsx("div",{className:"space-y-2",children:[...l.values()].map(_=>h.jsxs("div",{className:"px-3 py-2.5 rounded border border-blue-500/30 bg-blue-500/10",children:[h.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[h.jsxs("span",{className:"text-[11px] text-blue-400 font-medium",children:[_.status==="running"?"↻":_.outcome==="clean"?"✓":"✗"," ",_.loopType==="review"?"Review Loop":"Coverage Sweep"]}),h.jsxs("span",{className:"text-[11px] text-blue-300 font-mono",children:[_.count," of ",_.maxIterations]})]}),h.jsx("div",{className:"h-1.5 rounded-full bg-blue-500/20 overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(_.count/_.maxIterations*100)}%`,transition:"width 600ms cubic-bezier(0.4, 0, 0.2, 1)",backgroundColor:_.outcome==="clean"?"#22c55e":_.outcome==="max_reached"?"#ef4444":"#3b82f6"}})}),h.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:_.status==="running"?_.loopType==="review"?"Waiting for clean review...":"Waiting for tests passing...":_.outcome==="clean"?"Clean!":_.outcome==="max_reached"?"Max iterations reached":"Aborted"})]},_.loopId))}),h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Pending Gates"}),k.length>0&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-400/15 text-amber-400 font-medium",children:k.length})]}),h.jsx(mK,{gates:k,allGates:e,items:t,onResolveGate:u})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recent Sessions"}),h.jsx("div",{className:"mt-2",children:h.jsx(gK,{sessions:r,items:t,onSelect:c})})]})]}),f&&h.jsxs("div",{className:"w-80 border-l border-border flex flex-col shrink-0",children:[h.jsx("div",{className:"px-3 py-2 border-b border-border",children:h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Event Timeline"})}),h.jsx(uK,{featureCode:s,itemId:p==null?void 0:p.id,onSelectItem:c})]})]})}function yK(t,e){var i,s;if(!((i=t.tags)!=null&&i.length)||!((s=e.tags)!=null&&s.length))return 0;const r=new Set(t.tags);return e.tags.filter(o=>r.has(o)).length/Math.max(t.tags.length,e.tags.length)}function bK(t,e){return e.filter(r=>r.id!==t.id).map(r=>({idea:r,score:yK(t,r)})).filter(({score:r})=>r>.25).sort((r,n)=>n.score-r.score).slice(0,3).map(({idea:r})=>r)}function CK({results:t,onClose:e}){const r=C.useMemo(()=>{const i={P0:0,P1:0,P2:0,killed:0,promoted:0,skipped:0};for(const s of t)s.action==="skip"?i.skipped++:s.action==="kill"?i.killed++:s.action==="promote"?i.promoted++:s.priority==="P0"?i.P0++:s.priority==="P1"?i.P1++:s.priority==="P2"&&i.P2++;return i},[t]),n=t.filter(i=>i.action!=="skip").length;return h.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 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(Si,{className:"w-5 h-5 text-emerald-400"})}),h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Triage complete"}),h.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["Triaged ",n," of ",t.length," ideas"]}),h.jsxs("div",{className:"flex gap-3 text-[11px]",children:[r.P0>0&&h.jsxs("span",{className:"text-red-400",children:[r.P0," P0"]}),r.P1>0&&h.jsxs("span",{className:"text-amber-400",children:[r.P1," P1"]}),r.P2>0&&h.jsxs("span",{className:"text-blue-400",children:[r.P2," P2"]}),r.promoted>0&&h.jsxs("span",{className:"text-emerald-400",children:[r.promoted," promoted"]}),r.killed>0&&h.jsxs("span",{className:"text-muted-foreground",children:[r.killed," killed"]}),r.skipped>0&&h.jsxs("span",{className:"text-muted-foreground/60",children:[r.skipped," skipped"]})]}),h.jsx(qt,{size:"sm",onClick:e,className:"mt-2",children:"Done"})]})}function kK({ideas:t,onClose:e}){const{setPriority:r,killIdea:n,promoteIdea:i,ideas:s}=Ds(),[o,a]=C.useState(()=>[...t]),[l,c]=C.useState(0),[u,d]=C.useState([]),[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(!1),T=o[l]??null;o.length-l;const _=C.useMemo(()=>T?bK(T,s.filter(P=>P.id!==T.id)):[],[T,s]),w=C.useCallback(()=>{const P=l+1;P>=o.length?f(!0):(c(P),y(!1),x(""))},[l,o.length]),E=C.useCallback(async P=>{if(!(!T||b)){k(!0);try{await r(T.id,P),d($=>[...$,{id:T.id,action:"priority",priority:P}]),w()}finally{k(!1)}}},[T,b,r,w]),L=C.useCallback(async()=>{if(!(!T||b)){k(!0);try{await n(T.id,m),d(P=>[...P,{id:T.id,action:"kill"}]),y(!1),x(""),w()}finally{k(!1)}}},[T,b,n,m,w]),M=C.useCallback(()=>{T&&(d(P=>[...P,{id:T.id,action:"skip"}]),w())},[T,w]),N=C.useCallback(async()=>{if(!(!T||b)){k(!0);try{await i(T.id),d(P=>[...P,{id:T.id,action:"promote"}]),w()}finally{k(!1)}}},[T,b,i,w]);return C.useEffect(()=>{const P=$=>{if($.key==="Escape"){e();return}g||($.key==="0"&&E("P0"),$.key==="1"&&E("P1"),$.key==="2"&&E("P2"),($.key==="s"||$.key==="ArrowRight")&&M(),$.key==="k"&&y(!0))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[g,E,M,e]),h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"hsl(var(--background) / 0.8)",backdropFilter:"blur(4px)"},children:h.jsxs("div",{className:"w-full max-w-lg mx-4 rounded-xl border border-border bg-card shadow-2xl flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center gap-2",children:[h.jsx(Si,{className:"w-4 h-4 text-amber-400 shrink-0"}),h.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Triage"}),!p&&h.jsxs("span",{className:"text-[11px] text-muted-foreground ml-1",children:[l+1," of ",o.length," untriaged"]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:e,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:h.jsx(hn,{className:"w-4 h-4"})})]}),!p&&h.jsx("div",{className:"h-1 bg-muted",children:h.jsx("div",{className:"h-full bg-accent transition-all duration-300",style:{width:`${Math.round(l/o.length*100)}%`}})}),h.jsx("div",{className:"flex-1 p-4",children:p?h.jsx(CK,{results:u,onClose:e}):T?h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:T.id}),T.cluster&&h.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:T.cluster})]}),h.jsx("h3",{className:"text-[14px] text-foreground font-semibold leading-snug mb-2",children:T.title}),T.description&&h.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed mb-2",children:T.description}),h.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(T.tags||[]).map(P=>h.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded font-mono text-muted-foreground",children:P},P))}),T.source&&h.jsxs("p",{className:"text-[10px] text-muted-foreground/50 mt-2",children:["Source: ",T.source]})]}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold mb-1.5",children:"Similar to:"}),h.jsx("div",{className:"space-y-1",children:_.map(P=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded bg-muted/30 border border-border/40",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono opacity-70",children:P.id}),h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:P.title})]},P.id))})]}),g&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("input",{autoFocus:!0,type:"text",placeholder:"Reason for killing (optional)…",value:m,onChange:P=>x(P.target.value),onKeyDown:P=>{P.key==="Enter"&&L(),P.key==="Escape"&&y(!1)},className:"w-full text-[12px] bg-muted text-foreground px-3 py-2 rounded border border-border outline-none focus:border-ring"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(qt,{size:"sm",variant:"outline",className:"flex-1 h-7 text-[11px]",onClick:()=>{y(!1),x("")},children:"Cancel"}),h.jsx(qt,{size:"sm",className:"flex-1 h-7 text-[11px] bg-destructive/80 hover:bg-destructive text-destructive-foreground",onClick:L,disabled:b,children:"Confirm Kill"})]})]})]}):h.jsx("p",{className:"text-[12px] text-muted-foreground text-center py-8",children:"No more untriaged ideas."})}),!p&&T&&!g&&h.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[h.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-red-500/80 hover:bg-red-500 text-white border-0",onClick:()=>E("P0"),disabled:b,title:"Press 0",children:["P0 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"0"})]}),h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-amber-500/80 hover:bg-amber-500 text-white border-0",onClick:()=>E("P1"),disabled:b,title:"Press 1",children:["P1 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"1"})]}),h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-blue-500/80 hover:bg-blue-500 text-white border-0",onClick:()=>E("P2"),disabled:b,title:"Press 2",children:["P2 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"2"})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h.jsx(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-emerald-400 border-emerald-400/30 hover:bg-emerald-400/10",onClick:N,disabled:b,children:"Promote"}),h.jsxs(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>y(!0),title:"Press k",children:["Kill ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"k"})]}),h.jsxs(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-muted-foreground gap-1",onClick:M,title:"Press s or →",children:[h.jsx(Ab,{className:"w-3 h-3"}),"Skip ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"s"})]})]})]})]})})}function Q0(t){var n;if(!t)return"";const r=(t.cluster||"").toUpperCase().replace(/[^A-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,8);if(!r){const i=(((n=t.tags)==null?void 0:n[0])||"").replace("#","").toUpperCase().slice(0,6);return i?`${i}-1`:"FEAT-1"}return`${r}-1`}function vK(t,e){const r=new Date().toISOString().slice(0,10),n=(t.tags||[]).join(", ")||"N/A";return`# ${e}: ${t.title}
745
+ `,n}function wX(t,e){return(e||[]).filter(n=>!n.superseded).map(n=>({title:n.question,type:"decision",decided:!0}))}const jo={es:null},Gn=Pf((t,e)=>({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[],hydrate:async(r,n)=>{if(!r){const l=e().scope;if(l)r=l,n=e().featureCode||null;else try{const c=JSON.parse(localStorage.getItem("compose:designSession")||"{}");r=c.scope||"product",n=c.featureCode||null}catch{r="product"}}const i=e().docManuallyEdited,s=e().draftDoc,o=e().researchItems||[];t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,designDocPath:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]});const a=r==="feature"&&n?`?scope=feature&featureCode=${n}`:`?scope=${r}`;try{const l=await zt(`/api/design/session${a}`),{session:c}=await l.json();if(c){const u=c.messages||[],d=c.decisions||[],p=q0(u,d),f=wX(u,d);t({session:c,messages:u,decisions:d,status:c.status==="complete"?"complete":"active",scope:r,featureCode:n,draftDoc:i?s:p,docManuallyEdited:i,topicOutline:f,researchItems:o}),e().disconnectSSE(),e().connectSSE()}else t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:r,featureCode:n,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]}),e().disconnectSSE()}catch(l){t({error:l.message})}},startSession:async(r="product",n=null)=>{try{const i=await zt("/api/design/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:r,featureCode:n})});if(!i.ok){const{error:o}=await i.json();t({error:o});return}const{session:s}=await i.json();try{localStorage.setItem("compose:designSession",JSON.stringify({scope:r,featureCode:n}))}catch{}t({session:s,messages:s.messages||[],decisions:s.decisions||[],status:"active",error:null,scope:r,featureCode:n}),e().connectSSE()}catch(i){t({error:i.message})}},sendMessage:async r=>{const{session:n,messages:i}=e();if(!n)return;const s=n.scope,o=n.featureCode,a={role:"human",type:"text",content:r,timestamp:new Date().toISOString()};t(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await zt("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s,featureCode:o,type:"text",content:r})});l.ok||t({messages:i,status:"active",error:`Failed to send message: ${l.status}`})}catch(l){t({messages:i,status:"active",error:l.message})}},selectCard:async(r,n=null,i=null)=>{const{session:s,messages:o}=e();if(!s)return;const a={role:"human",type:"card_select",content:{cardId:r,comment:n},timestamp:new Date().toISOString()};t(l=>({messages:[...l.messages,a],status:"streaming"}));try{const l=await zt("/api/design/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:s.scope,featureCode:s.featureCode,type:"card_select",cardId:r,comment:n,messageIndex:i})});l.ok||t({messages:o,status:"active",error:`Failed to select card: ${l.status}`})}catch(l){t({messages:o,status:"active",error:l.message})}},reviseDecision:async r=>{const{session:n}=e();if(!n)return;const i=e().decisions[r];if(!(!i||i.superseded))try{const s=await zt("/api/design/revise",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:n.scope,featureCode:n.featureCode,decisionIndex:r})});if(!s.ok){const{error:o}=await s.json().catch(()=>({error:"Revision failed"}));t({error:o});return}e().hydrate(n.scope,n.featureCode)}catch(s){t({error:s.message})}},completeDesign:async()=>{const{session:r,draftDoc:n}=e();if(r){t({status:"summarizing"});try{const i={scope:r.scope,featureCode:r.featureCode};n&&(i.draftDoc=n);const s=await zt("/api/design/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!s.ok){const{error:l}=await s.json().catch(()=>({error:"Unknown error"}));t({error:l,status:"active"});return}const o=await s.json(),a={session:o.session,status:"complete",designDocPath:o.designDocPath||null};o.error&&(a.error=o.error),t(a)}catch(i){t({error:i.message,status:"active"})}}},connectSSE:()=>{if(jo.es)return;const{scope:r,featureCode:n}=e(),i=new URLSearchParams({scope:r||"product"});n&&i.set("featureCode",n);const s=new EventSource(`/api/design/stream?${i}`);jo.es=s,s.addEventListener("ack",()=>{t(o=>o.status!=="streaming"?{status:"streaming"}:{})}),s.addEventListener("text",o=>{const a=JSON.parse(o.data);t(l=>l.streamingMessage?{streamingMessage:{...l.streamingMessage,content:l.streamingMessage.content+a.content}}:{status:"streaming",streamingMessage:{role:"assistant",type:"text",content:a.content,timestamp:new Date().toISOString()}})}),s.addEventListener("decision",o=>{const a=JSON.parse(o.data);t(l=>({status:"streaming",streamingMessage:l.streamingMessage?{...l.streamingMessage,type:"decision",decisionData:a}:{role:"assistant",type:"decision",content:"",decisionData:a,timestamp:new Date().toISOString()}}))}),s.addEventListener("done",()=>{t(o=>({messages:o.streamingMessage?[...o.messages,o.streamingMessage]:o.messages,streamingMessage:null,status:"active"})),e().hydrate()}),s.addEventListener("research",o=>{const a=JSON.parse(o.data);t(l=>({researchItems:[...l.researchItems,{id:a.id,tool:a.tool,input:a.input,timestamp:a.timestamp,summary:null}]}))}),s.addEventListener("research_result",o=>{const a=JSON.parse(o.data);t(l=>{const c=[...l.researchItems],u=a.id?c.findIndex(d=>d.id===a.id):-1;return u!==-1&&(c[u]={...c[u],summary:a.summary}),{researchItems:c}})}),s.addEventListener("error",o=>{try{const a=JSON.parse(o.data);t(l=>({status:"active",streamingMessage:null,error:a.message||"Agent error",messages:l.messages}))}catch{t({status:"active",streamingMessage:null})}}),s.onerror=()=>{t({status:"active"})}},disconnectSSE:()=>{jo.es&&(jo.es.close(),jo.es=null)},reset:()=>{try{localStorage.removeItem("compose:designSession")}catch{}t({session:null,messages:[],decisions:[],status:"idle",error:null,streamingMessage:null,scope:null,featureCode:null,designDocPath:null,draftDoc:"",docManuallyEdited:!1,researchItems:[],topicOutline:[]})},updateDraftDoc:r=>{t({draftDoc:r,docManuallyEdited:!0})},resetDocEdited:()=>{const{messages:r,decisions:n}=e(),i=q0(r,n);t({draftDoc:i,docManuallyEdited:!1})}}));function SX(){const{draftDoc:t,docManuallyEdited:e,updateDraftDoc:r,resetDocEdited:n}=Gn(Di(c=>({draftDoc:c.draftDoc,docManuallyEdited:c.docManuallyEdited,updateDraftDoc:c.updateDraftDoc,resetDocEdited:c.resetDocEdited}))),[i,s]=C.useState(!1),o=!t;let a="empty",l={color:"hsl(var(--muted-foreground))"};return e?(a="edited",l={color:"hsl(var(--primary))"}):o||(a="draft",l={color:"hsl(var(--muted-foreground))"}),h.jsxs("div",{className:"h-full flex flex-col",style:{fontFamily:"inherit"},children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-2 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[12px] font-semibold",style:{color:"hsl(var(--foreground))"},children:"Design Document"}),h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{...l,background:"hsl(var(--muted))"},children:a})]}),!o&&h.jsx("button",{onClick:()=>s(c=>!c),className:"text-[11px] px-2 py-1 rounded transition-colors",style:{color:"hsl(var(--muted-foreground))",background:i?"hsl(var(--accent))":"transparent"},onMouseEnter:c=>{c.currentTarget.style.color="hsl(var(--foreground))"},onMouseLeave:c=>{c.currentTarget.style.color="hsl(var(--muted-foreground))"},children:i?"Preview":"Edit"})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o?h.jsx("div",{className:"p-4 text-[12px] italic",style:{color:"hsl(var(--muted-foreground))"},children:"Start the design conversation to see the document build here."}):i?h.jsxs("div",{className:"h-full flex flex-col p-2 gap-2",children:[h.jsx("textarea",{className:"flex-1 min-h-0 w-full resize-none rounded p-2 text-[12px]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",background:"hsl(var(--background))",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--border))",outline:"none"},value:t,onChange:c=>r(c.target.value),spellCheck:!1}),h.jsx("button",{onClick:()=>{n(),s(!1)},className:"shrink-0 text-[11px] px-3 py-1.5 rounded transition-colors self-start",style:{color:"hsl(var(--muted-foreground))",border:"1px solid hsl(var(--border))",background:"transparent"},onMouseEnter:c=>{c.currentTarget.style.color="hsl(var(--foreground))",c.currentTarget.style.borderColor="hsl(var(--foreground))"},onMouseLeave:c=>{c.currentTarget.style.color="hsl(var(--muted-foreground))",c.currentTarget.style.borderColor="hsl(var(--border))"},children:"Reset to auto-generated"})]}):h.jsx("div",{className:"p-4 prose prose-sm max-w-none",style:{color:"hsl(var(--foreground))","--tw-prose-body":"hsl(var(--foreground))","--tw-prose-headings":"hsl(var(--foreground))","--tw-prose-code":"hsl(var(--foreground))","--tw-prose-bold":"hsl(var(--foreground))","--tw-prose-links":"hsl(var(--primary))",fontSize:"12px"},children:h.jsx(_f,{remarkPlugins:[Lf],children:t})})})]})}const TX=4e3,H0={info:{color:"hsl(var(--foreground))",bg:"hsl(var(--muted))"},warn:{color:"hsl(var(--warning, 32 95% 52%))",bg:"hsl(var(--muted))"},error:{color:"hsl(var(--destructive))",bg:"hsl(var(--destructive) / 0.08)"}};function _X(){const[t,e]=C.useState(null),r=C.useRef(null);if(C.useEffect(()=>{function i(s){const{message:o,level:a="info",ttl:l=TX}=s.detail??{};o&&(clearTimeout(r.current),e({message:o,level:a}),l>0&&(r.current=setTimeout(()=>e(null),l)))}return window.addEventListener("compose:notify",i),()=>{window.removeEventListener("compose:notify",i),clearTimeout(r.current)}},[]),!t)return null;const n=H0[t.level]??H0.info;return h.jsxs("div",{className:"h-6 flex items-center justify-between px-3 gap-2 shrink-0 text-[11px] font-mono",style:{background:n.bg,color:n.color,borderTop:"1px solid hsl(var(--border))"},role:"status","aria-live":"polite",children:[h.jsx("span",{className:"flex-1 min-w-0 truncate",children:t.message}),h.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100 text-[10px]",onClick:()=>{clearTimeout(r.current),e(null)},"aria-label":"Dismiss notification",children:"✕"})]})}const Bu={build:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(217 91% 60%)"},gate:{background:"hsl(38 92% 50% / 0.12)",borderColor:"hsl(38 92% 50% / 0.3)",color:"hsl(38 92% 50%)"},error:{background:"hsl(0 72% 51% / 0.12)",borderColor:"hsl(0 72% 51% / 0.3)",color:"hsl(0 72% 51%)"},done:{background:"hsl(160 60% 45% / 0.12)",borderColor:"hsl(160 60% 45% / 0.3)",color:"hsl(160 60% 45%)"},iteration:{background:"hsl(217 91% 60% / 0.12)",borderColor:"hsl(217 91% 60% / 0.3)",color:"hsl(210 100% 66%)"}},U0={enter:{transform:"translateX(20px)",opacity:0},steady:{transform:"translateX(0)",opacity:1},flash:{transform:"translateX(0)",opacity:1},exit:{transform:"translateX(0)",opacity:0}};function EX({type:t="build",label:e,retries:r=0,onClick:n,onApprove:i,onDismiss:s,animationState:o="steady"}){const a=(o==="flash"?Bu.done:Bu[t])||Bu.build,l=U0[o]||U0.steady,c=o==="exit"?"200ms":o==="flash"?"300ms":"200ms";return h.jsxs("div",{className:"ops-strip-entry",style:{display:"inline-flex",alignItems:"center",gap:"4px",height:"24px",padding:"0 10px",borderRadius:"12px",border:`1px solid ${a.borderColor}`,background:a.background,color:a.color,fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",cursor:n?"pointer":"default",whiteSpace:"nowrap",transition:`transform ${c} ease, opacity ${c} ease, background 300ms ease, border-color 300ms ease, color 300ms ease`,...l},onClick:n,role:"button",tabIndex:0,onKeyDown:u=>{u.key==="Enter"&&n&&n()},children:[h.jsxs("span",{style:{fontSize:"12px",lineHeight:1},children:[t==="build"&&"▶",t==="gate"&&"⚠",t==="error"&&"✕",t==="done"&&"✓",t==="iteration"&&"↻"]}),h.jsx("span",{children:e}),r>0&&h.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:r}),t==="gate"&&i&&h.jsx("button",{className:"ops-strip-approve",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:`1px solid ${a.borderColor}`,background:"transparent",color:a.color,fontSize:"11px",cursor:"pointer",padding:0,marginLeft:"2px",lineHeight:1},onClick:u=>{u.stopPropagation(),i()},title:"Approve gate",children:"✓"}),t==="error"&&s&&h.jsx("button",{className:"ops-strip-dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",borderRadius:"9px",border:"none",background:"transparent",color:a.color,fontSize:"10px",cursor:"pointer",padding:0,marginLeft:"2px",opacity:.6,lineHeight:1},onClick:u=>{u.stopPropagation(),s()},title:"Dismiss error",children:"✕"})]})}function NX(t){return!t||t<=0?"":`$${t.toFixed(2)}`}function jX(t){const e=Math.floor(t/1e3),r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function LX(t){const e=Math.round(t*60),r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function BX({activeBuild:t,gates:e,items:r,recentErrors:n,iterationStates:i,now:s=Date.now()}){const o=[];if(t&&t.featureCode){const a=t.currentStep?`${t.currentStep}`:"building",l=t.totalSteps?` · step ${t.currentStepIndex??"?"}/${t.totalSteps}`:"",c=NX(t.cumulative_cost_usd),u=c?` · ${c}`:"",d=t.flowId||t.startedAt||t.featureCode;o.push({key:`build-${t.featureCode}-${d}`,type:t.status==="complete"?"done":"build",label:`${t.featureCode} · ${a}${l}${u}`,featureCode:t.featureCode,retries:t.retries??0})}if(Array.isArray(e)){for(const a of e)if(a.status==="pending"){const l=wn[a.stepId]??(a.fromPhase||a.toPhase||"Gate"),c=Array.isArray(r)?r.find(d=>d.id===a.itemId):null,u=(c==null?void 0:c.title)||a.featureCode||"";o.push({key:`gate-${a.id}`,type:"gate",label:u?`${l} — ${u}`:l,featureCode:a.featureCode||"",gateId:a.id})}}if(i){for(const[a,l]of i)if(l.status==="running"){const c=l.loopType==="review"?"review":"coverage",u=`${l.count}/${l.maxIterations}`;let d="";if(l.wallClockTimeout!=null&&l.startedAt){const p=s-new Date(l.startedAt).getTime();d=`, ${jX(p)}/${LX(l.wallClockTimeout)}`}o.push({key:`iter-${a}`,type:"iteration",label:`${c} ${u}${d}`})}}if(Array.isArray(n))for(const a of n){const l=a.featureCode||"system",c=(a.message||a.errorType||"error").substring(0,60);o.push({key:`error-${a.timestamp}-${c.substring(0,10)}`,type:"error",label:`${l} · ${c}`,featureCode:l,timestamp:a.timestamp})}return o}function AX({activeView:t,onSelectFeature:e}){const{activeBuild:r,gates:n,items:i,recentErrors:s,resolveGate:o,iterationStates:a}=mr(Di(O=>({activeBuild:O.activeBuild,gates:O.gates,items:O.items,recentErrors:O.recentErrors,resolveGate:O.resolveGate,iterationStates:O.iterationStates}))),[l,c]=C.useState(new Map),u=C.useRef([]),d=C.useRef(new Set),p=C.useRef(new Set),[f,m]=C.useState(null),x=C.useRef(null),g=(r==null?void 0:r.featureCode)??null;C.useEffect(()=>{if(!g){m(null),x.current=null;return}g!==x.current&&(x.current=g,zt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(g)}`).then(O=>O.json()).then(O=>m(O)).catch(()=>{}))},[g]);const y=C.useRef(0);C.useEffect(()=>{if(!g)return;const O=a?[...a.values()].reduce((I,F)=>I+(F.count??0),0):0;O!==y.current&&(y.current=O,zt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(g)}`).then(I=>I.json()).then(I=>m(I)).catch(()=>{}))},[a,g]);const b=C.useRef(r),[k,T]=C.useState(null);C.useEffect(()=>{const O=b.current;if(O&&O.featureCode&&!r){T({...O,status:"complete"});const I=setTimeout(()=>T(null),3e3);return b.current=r,()=>clearTimeout(I)}b.current=r},[r]);const _=r||k,[w,E]=C.useState(()=>Date.now()),L=a&&[...a.values()].some(O=>O.status==="running");C.useEffect(()=>{if(!L)return;const O=setInterval(()=>E(Date.now()),1e3);return()=>clearInterval(O)},[L]);const M=C.useMemo(()=>BX({activeBuild:_,gates:n,items:i,recentErrors:s,iterationStates:a,now:w}),[_,n,i,s,a,w]),N=C.useMemo(()=>M.filter(O=>!d.current.has(O.key)),[M]);C.useEffect(()=>{const O=new Set(u.current.map(F=>F.key)),I=N.filter(F=>!O.has(F.key)).map(F=>F.key);I.length>0&&(c(F=>{const D=new Map(F);for(const R of I)D.set(R,"enter");return D}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c(F=>{const D=new Map(F);for(const R of I)D.get(R)==="enter"&&D.set(R,"steady");return D})})}));for(const F of N)F.type==="done"&&!p.current.has(F.key)&&(p.current.add(F.key),c(D=>{const R=new Map(D);return R.set(F.key,"flash"),R}),setTimeout(()=>{c(D=>{const R=new Map(D);return R.set(F.key,"exit"),R}),setTimeout(()=>{d.current.add(F.key),c(D=>{const R=new Map(D);return R.delete(F.key),R})},500)},2e3));u.current=N},[N]);const P=C.useCallback(O=>{c(I=>{const F=new Map(I);return F.set(O,"exit"),F}),setTimeout(()=>{d.current.add(O),c(I=>{const F=new Map(I);return F.delete(O),F})},200)},[]),$=C.useCallback(O=>{o&&o(O,"approve","Approved from ops strip")},[o]);if(t==="docs"||N.length===0)return null;const q=yX(f);return h.jsxs("div",{className:"ops-strip",style:{height:"36px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",overflowX:"auto",overflowY:"hidden",borderTop:"1px solid hsl(var(--border))",background:"hsl(var(--background))",flexShrink:0},children:[N.map(O=>h.jsx(EX,{type:O.type,label:O.label,retries:O.retries,animationState:l.get(O.key)||"steady",onClick:e?()=>e(O.featureCode):void 0,onApprove:O.type==="gate"&&O.gateId?()=>$(O.gateId):void 0,onDismiss:O.type==="error"?()=>P(O.key):void 0},O.key)),q&&h.jsx("span",{className:"ml-auto text-[9px] text-muted-foreground font-mono shrink-0 opacity-70",title:"Cumulative budget usage: review / coverage",children:q})]})}const Au=["dashboard","graph","tree","docs","design","gates","pipeline","sessions","ideabox"];function MX(t,e){return!e||!Array.isArray(t)?!1:t.includes(e)}function IX(t){return(t==null?void 0:t[0])??null}const FX="compose:mainTabs",JT="compose:activeTab";function PX(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(FX);if(!e)return[...Au];const r=JSON.parse(e);if(Array.isArray(r)&&r.length>=1){let n=r;for(const i of Au)if(!n.includes(i)){const s=n.indexOf("docs");s>=0?n=[...n.slice(0,s+1),i,...n.slice(s+1)]:n=[...n,i]}return n}}catch{}return[...Au]}function DX(t){var e;try{const r=(e=globalThis.localStorage)==null?void 0:e.getItem(JT);if(r&&MX(t,r))return r}catch{}return IX(t)}function G0(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(JT,t)}catch{}}function t_(t,e){var r;try{const n=(r=globalThis.localStorage)==null?void 0:r.getItem(t);return n==null?e:n!=="false"}catch{return e}}function e_(t,e){var r;try{(r=globalThis.localStorage)==null||r.setItem(t,String(!!e))}catch{}}const r_="compose:sidebarOpen",n_="compose:contextPanelOpen";function OX(){return t_(r_,!0)}function RX(t){return e_(r_,t)}function $X(){return t_(n_,!1)}function V0(t){return e_(n_,t)}const tf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));tf.displayName="Card";const ef=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("flex flex-col space-y-1.5 p-6",t),...e}));ef.displayName="CardHeader";const rf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("font-semibold leading-none tracking-tight",t),...e}));rf.displayName="CardTitle";const zX=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("text-sm text-muted-foreground",t),...e}));zX.displayName="CardDescription";const nf=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("p-6 pt-0",t),...e}));nf.displayName="CardContent";const WX=C.forwardRef(({className:t,...e},r)=>h.jsx("div",{ref:r,className:nt("flex items-center p-6 pt-0",t),...e}));WX.displayName="CardFooter";function qX(t){const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m ${e%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function Y0({agent:t,toolCount:e,errorCount:r,currentTool:n,currentCategory:i,onStop:s}){const o=t.status==="running",a=t.status==="killed",l=t.status==="failed"||t.status==="error"||a,c=!o&&!l,u=t.silent,[d,p]=C.useState(()=>{const m=t.startedAt?new Date(t.startedAt).getTime():Date.now();return(t.completedAt?new Date(t.completedAt).getTime():Date.now())-m});C.useEffect(()=>{if(!o)return;const m=t.startedAt?new Date(t.startedAt).getTime():Date.now(),x=()=>p(Date.now()-m);x();const g=setInterval(x,1e3);return()=>clearInterval(g)},[o,t.startedAt]);const f=t.agentType||t.type||t.agent||"agent";return h.jsxs("div",{className:"px-3 py-2 rounded border border-border bg-muted/20",children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"text-[11px] text-foreground font-medium truncate",children:f}),h.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[h.jsx("span",{className:nt("w-1.5 h-1.5 rounded-full inline-block",o&&!u&&"bg-green-400",o&&u&&"bg-yellow-400",c&&"bg-emerald-400",l&&"bg-red-400"),style:o&&!u?{animation:"phase-active-pulse 2s ease-in-out infinite"}:void 0}),h.jsx("span",{className:nt("text-[10px]",o&&!u&&"text-green-400",o&&u&&"text-yellow-400",c&&"text-emerald-400",l&&"text-red-400"),children:u?"silent":t.status}),h.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:qX(d)}),o&&s&&h.jsx("button",{onClick:m=>{m.stopPropagation(),s(t.agentId||t.id)},className:"text-[10px] text-muted-foreground hover:text-destructive cursor-pointer ml-0.5",title:"Stop agent",children:"x"})]})]}),h.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:e!=null&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{children:[e," tools"]}),h.jsx("span",{className:"mx-1",children:"·"}),h.jsxs("span",{className:nt(r>0&&"text-red-400"),children:[r??0," err"]}),o&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"mx-1",children:"·"}),h.jsxs("span",{children:[i||"working"," (",n,")"]})]})]})})]})}function HX(t,e,r){const n=new Array(t);return new Proxy(n,{get(i,s,o){if(typeof s=="string"){const a=s.charCodeAt(0);if(a>=48&&a<=57){const l=+s;if(Number.isInteger(l)&&l>=0&&l<t){let c=i[l];if(!c){const u=e[l*2];c=i[l]={index:l,key:r(l),start:u,size:e[l*2+1],end:u+e[l*2+1],lane:0}}return c}}if(s==="length")return t}return Reflect.get(i,s,o)}})}function rs(t,e,r){let n=r.initialDeps??[],i,s=!0;function o(){const a=t();return(a.length!==n.length||a.some((c,u)=>n[u]!==c))&&(n=a,i=e(...a),r!=null&&r.onChange&&!(s&&r.skipInitialOnChange)&&r.onChange(i),s=!1),i}return o.updateDeps=a=>{n=a},o}function X0(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const UX=(t,e)=>Math.abs(t-e)<1.01,GX=(t,e,r)=>{let n;return function(...i){t.clearTimeout(n),n=t.setTimeout(()=>e.apply(this,i),r)}};let Lo;const Mu=()=>{if(Lo!==void 0)return Lo;if(typeof navigator>"u")return Lo=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Lo=!0;const t=navigator.maxTouchPoints;return Lo=navigator.platform==="MacIntel"&&t!==void 0&&t>0},K0=t=>{const{offsetWidth:e,offsetHeight:r}=t;return{width:e,height:r}},VX=t=>t,YX=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,i=new Array(n);for(let s=0;s<n;s++)i[s]=e+s;return i},XX=(t,e)=>{const r=t.scrollElement;if(!r)return;const n=t.targetWindow;if(!n)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(K0(r)),!n.ResizeObserver)return()=>{};const s=new n.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(K0(r))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(r,{box:"border-box"}),()=>{s.unobserve(r)}},Bc={passive:!0},KX=typeof window>"u"?!0:"onscrollend"in window,ZX=(t,e,r)=>{const n=t.scrollElement;if(!n)return;const i=t.targetWindow;if(!i)return;const s=t.options.useScrollendEvent&&KX;let o=0;const a=s?null:GX(i,()=>e(o,!1),t.options.isScrollingResetDelay),l=d=>()=>{o=r(n),a==null||a(),e(o,d)},c=l(!0),u=l(!1);return n.addEventListener("scroll",c,Bc),s&&n.addEventListener("scrollend",u,Bc),()=>{n.removeEventListener("scroll",c),s&&n.removeEventListener("scrollend",u)}},QX=(t,e)=>ZX(t,e,r=>{const{horizontal:n,isRtl:i}=t.options;return n?r.scrollLeft*(i&&-1||1):r.scrollTop}),JX=(t,e,r)=>{if(r.options.useCachedMeasurements){const n=r.indexFromElement(t),i=r.options.getItemKey(n);return r.itemSizeCache.get(i)??r.options.estimateSize(n)}if(e!=null&&e.borderBoxSize){const n=e.borderBoxSize[0];if(n)return Math.round(n[r.options.horizontal?"inlineSize":"blockSize"])}if(!e){const n=r.indexFromElement(t),i=r.options.getItemKey(n),s=r.itemSizeCache.get(i);if(s!==void 0)return s}return t[r.options.horizontal?"offsetWidth":"offsetHeight"]},tK=(t,{adjustments:e=0,behavior:r},n)=>{var i,s;(s=(i=n.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[n.options.horizontal?"left":"top"]:t+e,behavior:r})},eK=tK;class rK{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var r,n,i;return((i=(n=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:n.now)==null?void 0:i.call(n))??Date.now()},this.observer=(()=>{let r=null;const n=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const a=s.target,l=this.indexFromElement(a);if(!a.isConnected){this.observer.unobserve(a);for(const[c,u]of this.elementsCache)if(u===a){this.elementsCache.delete(c);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(a,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=n())==null||i.disconnect(),r=null},observe:i=>{var s;return(s=n())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=n())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=r=>{var n,i;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:VX,rangeExtractor:YX,onChange:()=>{},measureElement:JX,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const p in r){const f=r[p];f!==void 0&&(s[p]=f)}const o=this.options;let a=null,l=null,c=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const p=o.count,f=s.count,m=this.getMeasurements(),x=p>0?((n=m[0])==null?void 0:n.key)??o.getItemKey(0):null,g=p>0?((i=m[p-1])==null?void 0:i.key)??o.getItemKey(p-1):null;if(f!==p||p>0&&f>0&&(s.getItemKey(0)!==x||s.getItemKey(f-1)!==g)){c=!0;const k=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??m[0]:null;k&&(a=[k.key,this.getScrollOffset()-k.start]);const T=s.followOnAppend===!0?"auto":s.followOnAppend||null;T&&f>p&&this.isAtEnd(o.scrollEndThreshold)&&(p===0||s.getItemKey(f-1)!==g)&&(l=T)}}this.options=s,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,d=0;if(a&&this.scrollOffset!==null){const[p,f]=a,m=this.getMeasurements(),{count:x,getItemKey:g}=this.options;let y=0;for(;y<x&&g(y)!==p;)y++;if(y<x){const b=m[y];if(b){const k=b.start+f;k!==this.scrollOffset&&(d=k-this.scrollOffset,this.scrollOffset=k,u=!0)}}}(u||l)&&(this.pendingScrollAnchor=[u?a[0]:null,u?a[1]:0,l,d])},this.notify=r=>{var n,i;(i=(n=this.options).onChange)==null||i.call(n,this,r)},this.maybeNotify=rs(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const s=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},a=()=>{this._iosTouching=!1,!(!Mu()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Bc),s.addEventListener("touchend",a,Bc),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",a),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[s,o,a,l]=i;s!==null&&!a&&(Mu()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),a&&this.scrollToEnd({behavior:a})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const r=this.getScrollOffset(),n=this.getMaxScrollOffset();if(r<0||r>n)return;const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(r,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,n)=>{const i=new Map,s=new Map;for(let o=n-1;o>=0;o--){const a=r[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=rs(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(r,n,i,s,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=rs(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:r,paddingStart:n,scrollMargin:i,getItemKey:s,enabled:o,lanes:a,laneAssignmentMode:l},c)=>{const u=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const m of this.laneAssignments.keys())m>=r&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const d=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1),a===1){const m=this.options.gap,x=r*2;let g=this._flatMeasurements;if(!g||g.length<x){const k=new Float64Array(x);g&&d>0&&k.set(g.subarray(0,d*2)),g=k,this._flatMeasurements=g}let y;if(d===0)y=n+i;else{const k=d-1;y=g[k*2]+g[k*2+1]+m}for(let k=d;k<r;k++){const T=s(k),_=u.get(T),w=typeof _=="number"?_:this.options.estimateSize(k);g[k*2]=y,g[k*2+1]=w,y+=w+m}const b=HX(r,g,s);return this.measurementsCache=b,b}const p=this.measurementsCache.slice(0,d),f=new Array(a).fill(void 0);for(let m=0;m<d;m++){const x=p[m];x&&(f[x.lane]=m)}for(let m=d;m<r;m++){const x=s(m),g=this.laneAssignments.get(m);let y,b;const k=l==="estimate"||u.has(x);if(g!==void 0&&this.options.lanes>1){y=g;const E=f[y],L=E!==void 0?p[E]:void 0;b=L?L.end+this.options.gap:n+i}else{const E=this.options.lanes===1?p[m-1]:this.getFurthestMeasurement(p,m);b=E?E.end+this.options.gap:n+i,y=E?E.lane:m%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(m,y)}const T=u.get(x),_=typeof T=="number"?T:this.options.estimateSize(m),w=b+_;p[m]={index:m,start:b,size:_,end:w,key:x,lane:y},f[y]=m}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=rs(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,n,i,s)=>this.range=r.length>0&&n>0?nK({measurements:r,outerSize:n,scrollOffset:i,lanes:s,flat:s===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=rs(()=>{let r=null,n=null;const i=this.calculateRange();return i&&(r=i.startIndex,n=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,n]},(r,n,i,s,o)=>s===null||o===null?[]:r({startIndex:s,endIndex:o,overscan:n,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const n=this.options.indexAttribute,i=r.getAttribute(n);return i?parseInt(i,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),a=Math.min(this.options.count-1,i+s);return r>=o&&r<=a}return!0},this.measureElement=r=>{if(!r){this.elementsCache.forEach((o,a)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(a))});return}const n=this.indexFromElement(r),i=this.options.getItemKey(n),s=this.elementsCache.get(i);s!==r&&(s&&this.observer.unobserve(s),this.observer.observe(r),this.elementsCache.set(i,r)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(r,void 0,this))},this.resizeItem=(r,n)=>{var i,s;if(r<0||r>=this.options.count)return;let o,a,l;const c=this._flatMeasurements;if(this.options.lanes===1&&c!==null)l=this.options.getItemKey(r),a=c[r*2],o=c[r*2+1];else{const p=this.measurementsCache[r];if(!p)return;l=p.key,a=p.start,o=p.size}const u=this.itemSizeCache.get(l)??o,d=n-u;if(d!==0){const p=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,f=p?this.getTotalSize():0,m=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[r]??{index:r,key:l,start:a,size:o,end:a+o,lane:0},d,this):a<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!=="backward");(this.pendingMin===null||r<this.pendingMin)&&(this.pendingMin=r),this.itemSizeCache.set(l,n),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-f):m&&this.applyScrollAdjustment(d),this.notify(!1)}},this.getVirtualItems=rs(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,n)=>{const i=[];for(let s=0,o=r.length;s<o;s++){const a=r[s],l=n[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const n=this.getMeasurements();if(n.length===0)return;const i=this._flatMeasurements,s=this.options.lanes===1&&i!=null,o=i_(0,n.length-1,s?a=>i[a*2]:a=>X0(n[a]).start,r);return X0(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(r=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=r,this.getOffsetForAlignment=(r,n,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=r>=o+s?"end":"start"),n==="center"?r+=(i-s)/2:n==="end"&&(r-=s);const a=this.getMaxScrollOffset();return Math.max(Math.min(a,r),0)},this.getOffsetForIndex=(r,n="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[r];if(!o)return;if(n==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)n="end";else if(o.start<=s+this.options.scrollPaddingStart)n="start";else return[s,n];if(n==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),n];const a=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,n,o.size),n]},this.scrollToOffset=(r,{align:n="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(r,n),o=this.now();this.scrollState={index:null,align:n,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:n="auto",behavior:i="auto"}={})=>{r=Math.max(0,Math.min(r,this.options.count-1));const s=this.getOffsetForIndex(r,n);if(!s)return;const[o,a]=s,l=this.now();this.scrollState={index:r,align:a,behavior:i,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:n="auto"}={})=>{const i=this.getScrollOffset()+r,s=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:r="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:r});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:r})},this.getTotalSize=()=>{var r;const n=this.getMeasurements();let i;if(n.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const s=n.length-1,o=this._flatMeasurements;o!=null?i=o[s*2]+o[s*2+1]:i=((r=n[s])==null?void 0:r.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&s.some(a=>a===null);){const a=n[o];s[a.lane]===null&&(s[a.lane]=a.end),o--}i=Math.max(...s.filter(a=>a!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const r=[];if(this.itemSizeCache.size===0)return r;const n=this.getMeasurements();for(const i of n)i&&this.itemSizeCache.has(i.key)&&r.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return r},this._scrollToOffset=(r,{adjustments:n,behavior:i})=>{this._intendedScrollOffset=r+(n??0),this.options.scrollToFn(r,{behavior:i,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,r){e!==0&&(Mu()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:r}))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=n?n[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&UX(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const a=this.getSize()||600,l=Math.abs(i-this.getScrollOffset()),c=this.scrollState.behavior==="smooth"&&l>a;this.scrollState.lastTargetOffset=i,c||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:c?"smooth":"auto"})}this.scheduleScrollReconcile()}}const i_=(t,e,r,n)=>{for(;t<=e;){const i=(t+e)/2|0,s=r(i);if(s<n)t=i+1;else if(s>n)e=i-1;else return i}return t>0?t-1:0};function nK({measurements:t,outerSize:e,scrollOffset:r,lanes:n,flat:i}){const s=t.length-1,o=i?u=>i[u*2]:u=>t[u].start,a=i?u=>i[u*2]+i[u*2+1]:u=>t[u].end;if(t.length<=n)return{startIndex:0,endIndex:s};let l=i_(0,s,o,r),c=l;if(n===1)for(;c<s&&a(c)<r+e;)c++;else if(n>1){const u=Array(n).fill(0);for(;c<s&&u.some(p=>p<r+e);){const p=t[c];u[p.lane]=p.end,c++}const d=Array(n).fill(r+e);for(;l>=0&&d.some(p=>p>=r);){const p=t[l];d[p.lane]=p.start,l--}l=Math.max(0,l-l%n),c=Math.min(s,c+(n-1-c%n))}return{startIndex:l,endIndex:c}}const Iu=typeof document<"u"?C.useLayoutEffect:C.useEffect;function iK({useFlushSync:t=!0,directDomUpdates:e=!1,directDomUpdatesMode:r="transform",...n}){const i=C.useReducer(c=>c+1,0)[1],s=C.useRef({enabled:e,mode:r,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=e,s.current.mode=r;const o=c=>{const u=s.current;if(!u.enabled)return;const d=c.getTotalSize();if(u.container&&d!==u.lastSize){u.lastSize=d;const y=c.options.horizontal?"width":"height";u.container.style[y]=`${d}px`}const p=!!c.options.horizontal,f=u.mode==="transform",m=p?"left":"top",x=c.options.scrollMargin,g=c.getVirtualItems();for(const y of g){const b=y.start-x,k=c.elementsCache.get(y.key);k&&u.lastPositions.get(k)!==b&&(u.lastPositions.set(k,b),f?k.style.transform=p?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:k.style[m]=`${b}px`)}},a={...n,onChange:(c,u)=>{var d;const p=s.current;let f=!0;if(p.enabled){o(c);const m=c.range,x=p.prevRange;f=!x||x.isScrolling!==c.isScrolling||x.startIndex!==(m==null?void 0:m.startIndex)||x.endIndex!==(m==null?void 0:m.endIndex),f&&(p.prevRange=m?{startIndex:m.startIndex,endIndex:m.endIndex,isScrolling:c.isScrolling}:null)}f&&(t&&u?Rf.flushSync(i):i()),(d=n.onChange)==null||d.call(n,c,u)}},[l]=C.useState(()=>{const c=new rK(a);return Object.assign(c,{containerRef:u=>{const d=s.current;if(d.container=u,d.lastSize=null,u&&d.enabled){const p=c.getTotalSize();d.lastSize=p;const f=c.options.horizontal?"width":"height";u.style[f]=`${p}px`}}})});return l.setOptions(a),Iu(()=>l._didMount(),[]),Iu(()=>l._willUpdate()),Iu(()=>{o(l)}),l}function sK(t){return iK({observeElementRect:XX,observeElementOffset:QX,scrollToFn:eK,...t})}function oK(t,e,r){var a,l;const n=[],i=(r==null?void 0:r.id)??null;if(Array.isArray(t))for(const c of t){if(n.push({id:`session-start-${c.id}`,timestamp:c.startedAt,category:"session",title:"Session started",detail:c.source?`Source: ${c.source}`:null,severity:"info",sessionId:c.id,meta:{toolCount:c.toolCount,source:c.source}}),c.endedAt&&n.push({id:`session-end-${c.id}`,timestamp:c.endedAt,category:"session",title:`Session ended (${c.toolCount??0} tools${(a=c.errors)!=null&&a.length?`, ${c.errors.length} error${c.errors.length>1?"s":""}`:""})`,detail:null,severity:"info",sessionId:c.id,meta:{toolCount:c.toolCount,errorCount:((l=c.errors)==null?void 0:l.length)??0}}),Array.isArray(c.errors))for(let u=0;u<c.errors.length;u++){const d=c.errors[u];n.push({id:`error-${c.id}-${u}`,timestamp:d.timestamp||c.startedAt,category:"error",title:d.message||`${d.type} error`,detail:d.tool?`Tool: ${d.tool}`:null,severity:d.severity==="error"?"error":"warning",sessionId:c.id,meta:{type:d.type,tool:d.tool}})}if(c.phaseAtBind&&c.phaseAtEnd&&c.phaseAtBind!==c.phaseAtEnd){const u=new Date(c.startedAt).getTime(),d=c.endedAt?new Date(c.endedAt).getTime():u,p=new Date(u+(d-u)*.8).toISOString();n.push({id:`phase-${c.id}`,timestamp:p,category:"phase",title:`Phase: ${c.phaseAtBind} → ${c.phaseAtEnd}`,detail:null,severity:"success",sessionId:c.id,meta:{from:c.phaseAtBind,to:c.phaseAtEnd}})}}if(Array.isArray(e)){const c=i?e.filter(u=>u.itemId===i):e;for(const u of c){if(u.createdAt){const d=wn[u.stepId]??(u.fromPhase&&u.toPhase?`${Te[u.fromPhase]??u.fromPhase} → ${Te[u.toPhase]??u.toPhase}`:"Gate created");n.push({id:`gate-created-${u.id}`,timestamp:u.createdAt,category:"gate",title:d,detail:null,severity:"info",sessionId:null,meta:{gateId:u.id,fromPhase:u.fromPhase,toPhase:u.toPhase}})}if(u.resolvedAt&&u.outcome){const p={approve:"approve",approved:"approve",revise:"revise",revised:"revise",kill:"kill",killed:"kill"}[u.outcome]||u.outcome,f={approve:"success",revise:"warning",kill:"error"},m={approve:"approved",revise:"revised",kill:"killed"};n.push({id:`gate-resolved-${u.id}`,timestamp:u.resolvedAt,category:"gate",title:`Gate ${m[p]||u.outcome}`,detail:u.comment||null,severity:f[p]||"info",sessionId:null,meta:{gateId:u.id,outcome:u.outcome,comment:u.comment}})}}}const s=new Set,o=[];for(const c of n)s.has(c.id)||(s.add(c.id),o.push(c));return o.sort((c,u)=>c.timestamp.localeCompare(u.timestamp)),o}const aK={phase:"→",gate:"◈",session:"●",iteration:"↻",error:"⚠"};function lK(t){if(!t)return"";const e=Date.now()-new Date(t).getTime(),r=Math.floor(e/6e4);if(r<1)return"now";if(r<60)return`${r}m`;const n=Math.floor(r/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function cK({event:t,onSelectItem:e,style:r}){const n=aK[t.category]||"●",i=T_[t.category]||"text-zinc-400",s=S_[t.severity]||"text-zinc-400";return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5 rounded",style:r,children:[h.jsx("span",{className:nt("text-[11px] shrink-0 w-4 text-center leading-4",i),children:n}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:nt("text-[11px] truncate",s),children:t.title}),t.detail&&h.jsx("p",{className:"text-[10px] text-muted-foreground/60 truncate",children:t.detail})]}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums shrink-0 leading-4",children:lK(t.timestamp)})]})}const hK=["all","phase","gate","session","iteration","error"],Z0={all:"All",phase:"Phase",gate:"Gate",session:"Session",iteration:"Iteration",error:"Error"};function uK({featureCode:t,itemId:e,onSelectItem:r}){const[n,i]=C.useState("all"),[s,o]=C.useState([]),a=C.useRef(null),l=mr(m=>m.gates),c=mr(m=>m.featureTimeline),u=mr(m=>m.setFeatureTimeline);C.useEffect(()=>{if(!t)return;let m=!1;return zt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=50`).then(x=>x.json()).then(x=>{if(m)return;const g=e?(l||[]).filter(b=>b.itemId===e):l||[],y=oK(x.sessions||[],g,{id:e});o(y)}).catch(()=>{m||o([])}),()=>{m=!0}},[t,e]);const d=C.useMemo(()=>{var g,y;const m=new Map;for(const b of s)m.set(b.id,b);for(const b of c){const k=(g=b.meta)==null?void 0:g.itemId,T=(y=b.meta)==null?void 0:y.featureCode;(!k&&!T||k===e||T===t)&&m.set(b.id,b)}const x=[...m.values()];return x.sort((b,k)=>b.timestamp.localeCompare(k.timestamp)),x},[s,c,e,t]),p=C.useMemo(()=>n==="all"?d:d.filter(m=>m.category===n),[d,n]),f=sK({count:p.length,getScrollElement:()=>a.current,estimateSize:()=>48,overscan:5});return C.useEffect(()=>{u&&u([])},[t]),t?h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsx("div",{className:"flex flex-wrap gap-1 px-2 py-2 border-b border-border",children:hK.map(m=>h.jsxs("button",{className:nt("px-2 py-0.5 rounded text-[10px] font-medium transition-colors",n===m?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:()=>i(m),children:[Z0[m],m!=="all"&&h.jsx("span",{className:"ml-1 text-[9px] opacity-60",children:d.filter(x=>x.category===m).length})]},m))}),h.jsx("div",{className:"px-2 py-1",children:h.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:[p.length," event",p.length!==1?"s":""]})}),h.jsx("div",{ref:a,className:"flex-1 overflow-auto",children:p.length===0?h.jsxs("p",{className:"text-[11px] text-muted-foreground/50 px-2 py-4 text-center",children:["No events",n!=="all"?` in "${Z0[n]}"`:"","."]}):h.jsx("div",{style:{height:`${f.getTotalSize()}px`,width:"100%",position:"relative"},children:f.getVirtualItems().map(m=>h.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${m.size}px`,transform:`translateY(${m.start}px)`},children:h.jsx(cK,{event:p[m.index],onSelectItem:r})},m.key))})})]}):h.jsx("div",{className:"flex items-center justify-center h-full",children:h.jsx("p",{className:"text-[11px] text-muted-foreground/50",children:"Select a feature to see its timeline."})})}const Zo=["explore_design","prd","architecture","blueprint","plan","execute","report"];function dK(t){if(!t)return"";const e=Date.now()-new Date(t).getTime(),r=Math.floor(e/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function fK({currentPhase:t}){const e=Zo.indexOf(t);return h.jsx("div",{className:"space-y-1.5",children:Zo.map((r,n)=>{const i=e>n,s=e===n,o=Te[r]??r;return h.jsxs("div",{className:"flex items-center gap-2",style:{animation:`phase-slide-in 300ms ease-out ${n*50}ms both`},children:[i?h.jsx(Tb,{className:"w-3.5 h-3.5 text-emerald-400 shrink-0",style:{animation:"phase-check-pop 400ms ease-out"}}):s?h.jsx(vb,{className:"w-3.5 h-3.5 text-blue-400 shrink-0",style:{animation:"phase-active-pulse 2s ease-in-out infinite"}}):h.jsx(KA,{className:"w-3.5 h-3.5 text-muted-foreground/40 shrink-0"}),h.jsx("span",{className:nt("text-[11px] transition-colors duration-500",i&&"text-emerald-400",s&&"text-blue-400 font-medium",!i&&!s&&"text-muted-foreground/50"),children:o})]},r)})})}function pK({spawnedAgents:t,activeBuild:e,sessionState:r,agentActivity:n}){const i=(t||[]).filter(a=>a.status==="running"),s=(t||[]).filter(a=>a.status!=="running").slice(-3).reverse(),o=C.useMemo(()=>{const a=["design.md","blueprint.md","plan.md","prd.md","architecture.md"],l=new Set(((e==null?void 0:e.steps)||[]).filter(c=>c.status==="done"||c.status==="completed").map(c=>c.id||c.name));return a.map(c=>({name:c,done:l.has(c)||((e==null?void 0:e.steps)||[]).some(u=>{var d,p;return(u.status==="done"||u.status==="completed")&&(((d=u.id)==null?void 0:d.includes(c.replace(".md","")))||((p=u.name)==null?void 0:p.includes(c.replace(".md",""))))})}))},[e]);return h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents"}),i.length===0&&s.length===0&&h.jsx("p",{className:"text-[11px] text-muted-foreground/50 mt-1",children:"No agents active"}),h.jsxs("div",{className:"mt-1 space-y-1.5",children:[i.map((a,l)=>h.jsx(Y0,{agent:a,toolCount:(r==null?void 0:r.toolCount)||0,errorCount:(r==null?void 0:r.errorCount)||0,currentTool:n==null?void 0:n.tool,currentCategory:n==null?void 0:n.category},a.agentId||l)),s.map((a,l)=>h.jsx(Y0,{agent:a},a.agentId||`r-${l}`))]})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Artifacts"}),h.jsx("div",{className:"mt-1 space-y-1",children:o.map(a=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Ii,{className:nt("w-3 h-3",a.done?"text-emerald-400":"text-muted-foreground/40")}),h.jsx("span",{className:nt("text-[11px] font-mono",a.done?"text-foreground":"text-muted-foreground/50"),children:a.name})]},a.name))})]})]})}function mK({gates:t,allGates:e,items:r,onResolveGate:n}){const i=C.useMemo(()=>{const s=new Map,o=(e||[]).filter(a=>a.resolvedAt&&(a.outcome==="revised"||a.outcome==="revise")).sort((a,l)=>new Date(l.resolvedAt)-new Date(a.resolvedAt));for(const a of t||[]){const l=o.find(c=>c.stepId===a.stepId&&c.itemId===a.itemId);l!=null&&l.artifactSnapshot&&a.artifactSnapshot&&s.set(a.id,{priorSnapshot:l.artifactSnapshot,currentSnapshot:a.artifactSnapshot})}return s},[t,e]);return!t||t.length===0?h.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No gates pending."}):h.jsx("div",{className:"space-y-2",children:t.map(s=>{var l;const o=r.find(c=>c.id===s.itemId),a=(l=s.artifactAssessment)==null?void 0:l.completeness;return h.jsx("div",{className:"px-3 py-2 rounded border border-border bg-muted/30",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-[11px] text-foreground truncate",children:(o==null?void 0:o.title)??"Unknown"}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[wn[s.stepId]??Te[s.fromPhase]??s.fromPhase??"Gate",a!=null&&` · ${Math.round(a*100)}% complete`]}),i.has(s.id)&&h.jsx("div",{className:"mt-1",children:h.jsx(Vp,{oldText:i.get(s.id).priorSnapshot,newText:i.get(s.id).currentSnapshot})})]}),h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>n(s.id,"approved"),children:"Approve"}),h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",onClick:()=>n(s.id,"revised"),children:"Revise"}),h.jsx(qt,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>n(s.id,"killed"),children:"Kill"})]})]})},s.id)})})}function gK({sessions:t,items:e,onSelect:r}){const n=(t||[]).slice(-5).reverse();return n.length===0?h.jsx("p",{className:"text-[11px] text-muted-foreground/50 px-1",children:"No sessions yet."}):h.jsx("div",{className:"space-y-1",children:n.map(i=>{const s=i.featureCode||i.feature_code,o=s?e.find(l=>{var c;return l.featureCode===s||l.feature_code===s||((c=l.lifecycle)==null?void 0:c.featureCode)===s}):null,a=i.startedAt||i.created_date;return h.jsxs("div",{className:nt("flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 transition-colors",o&&"cursor-pointer"),onClick:()=>o&&r(o.id),children:[h.jsx(qM,{className:"w-3 h-3 text-muted-foreground shrink-0"}),h.jsx("span",{className:"text-[11px] text-foreground",children:i.agent||"agent"}),s&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:s}),h.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground tabular-nums shrink-0",children:dK(a)}),h.jsx("span",{className:nt("w-1.5 h-1.5 rounded-full shrink-0",i.status==="active"?"bg-emerald-400":"bg-slate-600")})]},i.id)})})}function xK({items:t=[],gates:e=[],sessions:r=[],activeBuild:n,spawnedAgents:i=[],featureCode:s,sessionState:o,agentActivity:a,iterationStates:l,onSelect:c,onResolveGate:u,onOpenGate:d}){var T;const p=C.useMemo(()=>t.find(_=>{var w;return _.featureCode===s||((w=_.lifecycle)==null?void 0:w.featureCode)===s}),[t,s]),[f,m]=C.useState(()=>{try{return localStorage.getItem("compose:timeline-open")==="true"}catch{return!1}}),x=C.useCallback(()=>{m(_=>{const w=!_;try{localStorage.setItem("compose:timeline-open",String(w))}catch{}return w})},[]),g=((T=p==null?void 0:p.lifecycle)==null?void 0:T.currentPhase)||(p==null?void 0:p.phase)||(n==null?void 0:n.currentStepId)||(n==null?void 0:n.currentStep)||null,y=Zo.indexOf(g),b=g?Math.max(0,(y+1)/Zo.length):0,k=C.useMemo(()=>{let _=e.filter(w=>w.status==="pending"||!w.resolvedAt);if(s){const w=new Set(t.filter(E=>{var L;return E.featureCode===s||((L=E.lifecycle)==null?void 0:L.featureCode)===s}).map(E=>E.id));_=_.filter(E=>w.has(E.itemId))}return _},[e,t,s]);if(!s){const _=t.filter(w=>w.type==="feature"&&(w.status==="complete"||w.status==="done")).slice(-5);return h.jsx("div",{className:"flex-1 overflow-auto p-4",children:h.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-16 text-center",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"No feature in progress."}),h.jsx("p",{className:"text-[11px] text-muted-foreground/70 font-mono",children:"Run /compose <feature-code> in the terminal to start."}),_.length>0&&h.jsxs("div",{className:"mt-6 w-full max-w-sm",children:[h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recently completed"}),h.jsx("div",{className:"mt-2 space-y-1",children:_.map(w=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>c(w.id),children:[h.jsx(Tb,{className:"w-3 h-3 text-emerald-400 shrink-0"}),h.jsx("span",{className:"text-[11px] text-foreground truncate",children:w.title}),w.featureCode&&h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-auto shrink-0",children:w.featureCode})]},w.id))})]})]})})}return h.jsxs("div",{className:"flex-1 flex flex-row overflow-hidden",children:[h.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4 min-w-0",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:(p==null?void 0:p.title)??s}),h.jsx(nr,{variant:"outline",className:"text-[9px] px-1.5 py-0 h-4 font-mono shrink-0",children:s}),g&&h.jsx(nr,{variant:"secondary",className:"text-[9px] px-1.5 py-0 h-4 shrink-0",children:Te[g]??g}),h.jsxs("button",{className:nt("ml-auto flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors shrink-0",f?"bg-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-muted-foreground hover:bg-muted/30"),onClick:x,children:[h.jsx(xM,{className:"w-3 h-3"}),"Timeline"]})]}),h.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-muted overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full bg-blue-500",style:{width:`${Math.round(b*100)}%`,transition:"width 800ms cubic-bezier(0.4, 0, 0.2, 1)"}})}),h.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:y>=0?`${y+1} of ${Zo.length} phases`:"Phase unknown"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs(tf,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out"},children:[h.jsx(ef,{className:"p-3 pb-2",children:h.jsx(rf,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Phase Timeline"})}),h.jsx(nf,{className:"p-3 pt-0",children:h.jsx(fK,{currentPhase:g})})]}),h.jsxs(tf,{className:"bg-card border-border",style:{animation:"phase-card-enter 400ms ease-out 100ms both"},children:[h.jsx(ef,{className:"p-3 pb-2",children:h.jsx(rf,{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Agents & Artifacts"})}),h.jsx(nf,{className:"p-3 pt-0",children:h.jsx(pK,{spawnedAgents:i,activeBuild:n,sessionState:o,agentActivity:a})})]})]}),l&&l.size>0&&h.jsx("div",{className:"space-y-2",children:[...l.values()].map(_=>h.jsxs("div",{className:"px-3 py-2.5 rounded border border-blue-500/30 bg-blue-500/10",children:[h.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[h.jsxs("span",{className:"text-[11px] text-blue-400 font-medium",children:[_.status==="running"?"↻":_.outcome==="clean"?"✓":"✗"," ",_.loopType==="review"?"Review Loop":"Coverage Sweep"]}),h.jsxs("span",{className:"text-[11px] text-blue-300 font-mono",children:[_.count," of ",_.maxIterations]})]}),h.jsx("div",{className:"h-1.5 rounded-full bg-blue-500/20 overflow-hidden",children:h.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.round(_.count/_.maxIterations*100)}%`,transition:"width 600ms cubic-bezier(0.4, 0, 0.2, 1)",backgroundColor:_.outcome==="clean"?"#22c55e":_.outcome==="max_reached"?"#ef4444":"#3b82f6"}})}),h.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:_.status==="running"?_.loopType==="review"?"Waiting for clean review...":"Waiting for tests passing...":_.outcome==="clean"?"Clean!":_.outcome==="max_reached"?"Max iterations reached":"Aborted"})]},_.loopId))}),h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Pending Gates"}),k.length>0&&h.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-amber-400/15 text-amber-400 font-medium",children:k.length})]}),h.jsx(mK,{gates:k,allGates:e,items:t,onResolveGate:u})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Recent Sessions"}),h.jsx("div",{className:"mt-2",children:h.jsx(gK,{sessions:r,items:t,onSelect:c})})]})]}),f&&h.jsxs("div",{className:"w-80 border-l border-border flex flex-col shrink-0",children:[h.jsx("div",{className:"px-3 py-2 border-b border-border",children:h.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Event Timeline"})}),h.jsx(uK,{featureCode:s,itemId:p==null?void 0:p.id,onSelectItem:c})]})]})}function yK(t,e){var i,s;if(!((i=t.tags)!=null&&i.length)||!((s=e.tags)!=null&&s.length))return 0;const r=new Set(t.tags);return e.tags.filter(o=>r.has(o)).length/Math.max(t.tags.length,e.tags.length)}function bK(t,e){return e.filter(r=>r.id!==t.id).map(r=>({idea:r,score:yK(t,r)})).filter(({score:r})=>r>.25).sort((r,n)=>n.score-r.score).slice(0,3).map(({idea:r})=>r)}function CK({results:t,onClose:e}){const r=C.useMemo(()=>{const i={P0:0,P1:0,P2:0,killed:0,promoted:0,skipped:0};for(const s of t)s.action==="skip"?i.skipped++:s.action==="kill"?i.killed++:s.action==="promote"?i.promoted++:s.priority==="P0"?i.P0++:s.priority==="P1"?i.P1++:s.priority==="P2"&&i.P2++;return i},[t]),n=t.filter(i=>i.action!=="skip").length;return h.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 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(Si,{className:"w-5 h-5 text-emerald-400"})}),h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Triage complete"}),h.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["Triaged ",n," of ",t.length," ideas"]}),h.jsxs("div",{className:"flex gap-3 text-[11px]",children:[r.P0>0&&h.jsxs("span",{className:"text-red-400",children:[r.P0," P0"]}),r.P1>0&&h.jsxs("span",{className:"text-amber-400",children:[r.P1," P1"]}),r.P2>0&&h.jsxs("span",{className:"text-blue-400",children:[r.P2," P2"]}),r.promoted>0&&h.jsxs("span",{className:"text-emerald-400",children:[r.promoted," promoted"]}),r.killed>0&&h.jsxs("span",{className:"text-muted-foreground",children:[r.killed," killed"]}),r.skipped>0&&h.jsxs("span",{className:"text-muted-foreground/60",children:[r.skipped," skipped"]})]}),h.jsx(qt,{size:"sm",onClick:e,className:"mt-2",children:"Done"})]})}function kK({ideas:t,onClose:e}){const{setPriority:r,killIdea:n,promoteIdea:i,ideas:s}=Ds(),[o,a]=C.useState(()=>[...t]),[l,c]=C.useState(0),[u,d]=C.useState([]),[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(!1),T=o[l]??null;o.length-l;const _=C.useMemo(()=>T?bK(T,s.filter(P=>P.id!==T.id)):[],[T,s]),w=C.useCallback(()=>{const P=l+1;P>=o.length?f(!0):(c(P),y(!1),x(""))},[l,o.length]),E=C.useCallback(async P=>{if(!(!T||b)){k(!0);try{await r(T.id,P),d($=>[...$,{id:T.id,action:"priority",priority:P}]),w()}finally{k(!1)}}},[T,b,r,w]),L=C.useCallback(async()=>{if(!(!T||b)){k(!0);try{await n(T.id,m),d(P=>[...P,{id:T.id,action:"kill"}]),y(!1),x(""),w()}finally{k(!1)}}},[T,b,n,m,w]),M=C.useCallback(()=>{T&&(d(P=>[...P,{id:T.id,action:"skip"}]),w())},[T,w]),N=C.useCallback(async()=>{if(!(!T||b)){k(!0);try{await i(T.id),d(P=>[...P,{id:T.id,action:"promote"}]),w()}finally{k(!1)}}},[T,b,i,w]);return C.useEffect(()=>{const P=$=>{if($.key==="Escape"){e();return}g||($.key==="0"&&E("P0"),$.key==="1"&&E("P1"),$.key==="2"&&E("P2"),($.key==="s"||$.key==="ArrowRight")&&M(),$.key==="k"&&y(!0))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[g,E,M,e]),h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"hsl(var(--background) / 0.8)",backdropFilter:"blur(4px)"},children:h.jsxs("div",{className:"w-full max-w-lg mx-4 rounded-xl border border-border bg-card shadow-2xl flex flex-col overflow-hidden",children:[h.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center gap-2",children:[h.jsx(Si,{className:"w-4 h-4 text-amber-400 shrink-0"}),h.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Triage"}),!p&&h.jsxs("span",{className:"text-[11px] text-muted-foreground ml-1",children:[l+1," of ",o.length," untriaged"]}),h.jsx("div",{className:"flex-1"}),h.jsx("button",{onClick:e,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:h.jsx(hn,{className:"w-4 h-4"})})]}),!p&&h.jsx("div",{className:"h-1 bg-muted",children:h.jsx("div",{className:"h-full bg-accent transition-all duration-300",style:{width:`${Math.round(l/o.length*100)}%`}})}),h.jsx("div",{className:"flex-1 p-4",children:p?h.jsx(CK,{results:u,onClose:e}):T?h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono",children:T.id}),T.cluster&&h.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:T.cluster})]}),h.jsx("h3",{className:"text-[14px] text-foreground font-semibold leading-snug mb-2",children:T.title}),T.description&&h.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed mb-2",children:T.description}),h.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(T.tags||[]).map(P=>h.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded font-mono text-muted-foreground",children:P},P))}),T.source&&h.jsxs("p",{className:"text-[10px] text-muted-foreground/50 mt-2",children:["Source: ",T.source]})]}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold mb-1.5",children:"Similar to:"}),h.jsx("div",{className:"space-y-1",children:_.map(P=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded bg-muted/30 border border-border/40",children:[h.jsx(nr,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono opacity-70",children:P.id}),h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:P.title})]},P.id))})]}),g&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("input",{autoFocus:!0,type:"text",placeholder:"Reason for killing (optional)…",value:m,onChange:P=>x(P.target.value),onKeyDown:P=>{P.key==="Enter"&&L(),P.key==="Escape"&&y(!1)},className:"w-full text-[12px] bg-muted text-foreground px-3 py-2 rounded border border-border outline-none focus:border-ring"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(qt,{size:"sm",variant:"outline",className:"flex-1 h-7 text-[11px]",onClick:()=>{y(!1),x("")},children:"Cancel"}),h.jsx(qt,{size:"sm",className:"flex-1 h-7 text-[11px] bg-destructive/80 hover:bg-destructive text-destructive-foreground",onClick:L,disabled:b,children:"Confirm Kill"})]})]})]}):h.jsx("p",{className:"text-[12px] text-muted-foreground text-center py-8",children:"No more untriaged ideas."})}),!p&&T&&!g&&h.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[h.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-red-500/80 hover:bg-red-500 text-white border-0",onClick:()=>E("P0"),disabled:b,title:"Press 0",children:["P0 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"0"})]}),h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-amber-500/80 hover:bg-amber-500 text-white border-0",onClick:()=>E("P1"),disabled:b,title:"Press 1",children:["P1 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"1"})]}),h.jsxs(qt,{size:"sm",className:"h-9 text-[12px] bg-blue-500/80 hover:bg-blue-500 text-white border-0",onClick:()=>E("P2"),disabled:b,title:"Press 2",children:["P2 ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"2"})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[h.jsx(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-emerald-400 border-emerald-400/30 hover:bg-emerald-400/10",onClick:N,disabled:b,children:"Promote"}),h.jsxs(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>y(!0),title:"Press k",children:["Kill ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"k"})]}),h.jsxs(qt,{size:"sm",variant:"outline",className:"h-7 text-[11px] text-muted-foreground gap-1",onClick:M,title:"Press s or →",children:[h.jsx(Ab,{className:"w-3 h-3"}),"Skip ",h.jsx("kbd",{className:"ml-1 text-[9px] opacity-60 font-mono",children:"s"})]})]})]})]})})}function Q0(t){var n;if(!t)return"";const r=(t.cluster||"").toUpperCase().replace(/[^A-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,8);if(!r){const i=(((n=t.tags)==null?void 0:n[0])||"").replace("#","").toUpperCase().slice(0,6);return i?`${i}-1`:"FEAT-1"}return`${r}-1`}function vK(t,e){const r=new Date().toISOString().slice(0,10),n=(t.tags||[]).join(", ")||"N/A";return`# ${e}: ${t.title}
746
746
 
747
747
  **Date:** ${r}
748
748
  **Promoted from:** ${t.id}