@wrongstack/webui 0.303.0 → 0.305.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/assets/AgentRosterView-D21dmPj3.js +9 -0
  2. package/dist/assets/{AnalyticsDashboard-CMs176Dp.js → AnalyticsDashboard-BKW5jxN7.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-BRXM47H1.js → AudienceMemoryPanel-DvdyvikT.js} +2 -2
  4. package/dist/assets/ChangesView-BFv5V-2K.js +1 -0
  5. package/dist/assets/{ChronicleDashboard-DPI_5S2R.js → ChronicleDashboard-BgFFTJ9c.js} +1 -1
  6. package/dist/assets/CodeEditor-BcB3ieu2.js +1 -0
  7. package/dist/assets/CodeMap-CnlnHM8P.js +1 -0
  8. package/dist/assets/{ConfirmModal-DXy17_uy.js → ConfirmModal-BD6pUkAB.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-C_bGieGQ.js → CronJobsPanel-DzRNjwf_.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-hkBvamWn.js → DeadCodeScanPanel-Dp6vW6pV.js} +2 -2
  11. package/dist/assets/{DebugDashboard-CDWJ9nLR.js → DebugDashboard-BvX4wPHr.js} +1 -1
  12. package/dist/assets/DesignGalleryView-BtH9po91.js +1 -0
  13. package/dist/assets/GoalView-Dt18_qkp.js +1 -0
  14. package/dist/assets/KanbanView-CmXysTwU.js +3 -0
  15. package/dist/assets/MailboxDetailView-B7Rpq-q5.js +1 -0
  16. package/dist/assets/{MemoryDrawer-D2Yq9oba.js → MemoryDrawer-CQifV69f.js} +1 -1
  17. package/dist/assets/MemoryManager-52A6Porm.js +1 -0
  18. package/dist/assets/{ModelPicker-BazB-GbH.js → ModelPicker-BzO5YWvC.js} +1 -1
  19. package/dist/assets/OfficeMapPanel-B_r043GV.js +4 -0
  20. package/dist/assets/{ProcessMonitor-BTjaxnO-.js → ProcessMonitor-BXLvlOm5.js} +1 -1
  21. package/dist/assets/{QueuePanel-BOD9qtHp.js → QueuePanel-BnslTb01.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-DfbZ-vgF.js → RefreshDebugView-DTO6YlTY.js} +1 -1
  23. package/dist/assets/RequirementIntakeView-CjEUqwkC.js +1 -0
  24. package/dist/assets/SageTabs-CZAYUZRL.js +2 -0
  25. package/dist/assets/{SddFlowGraph-DWphr6Tr.js → SddFlowGraph-B-5J7zOV.js} +1 -1
  26. package/dist/assets/SddHub-B8uS39mj.js +2 -0
  27. package/dist/assets/{SessionInspectView-DqrSHseG.js → SessionInspectView-C9f4pdyH.js} +1 -1
  28. package/dist/assets/SessionList-CiUBVr04.js +1 -0
  29. package/dist/assets/{SessionsDashboard-CUj2WSYM.js → SessionsDashboard-D-jy0eZl.js} +1 -1
  30. package/dist/assets/SetupScreen-CfFpbarK.js +1 -0
  31. package/dist/assets/SkillDetailView-W220T6zf.js +3 -0
  32. package/dist/assets/{SpecsView-Cl4vpAoL.js → SpecsView-DOTFvg9y.js} +1 -1
  33. package/dist/assets/{TechStackView-DsFV85XT.js → TechStackView-Bar55FH0.js} +1 -1
  34. package/dist/assets/{TerminalPanel-GraS3zw1.js → TerminalPanel-BAg6jaIM.js} +1 -1
  35. package/dist/assets/{Toaster-D76T-Ld4.js → Toaster-Dic3369l.js} +1 -1
  36. package/dist/assets/{activity-CZIixoel.js → activity-BI4XyF_x.js} +3 -3
  37. package/dist/assets/{activity-BwEBEQ51.js → activity-Dg9Q9kwt.js} +3 -3
  38. package/dist/assets/{activity-BnTQWNPX.js → activity-Dr_u3dOm.js} +3 -3
  39. package/dist/assets/{activity-CRMLR4a3.js → activity-Dzgvt4Nh.js} +3 -3
  40. package/dist/assets/{activity-Xqrt9v4z.js → activity-IttuV5ar.js} +3 -3
  41. package/dist/assets/{activity-BLSyJfTr.js → activity-L2_b8Uan.js} +3 -3
  42. package/dist/assets/{activity-C-9I3_s4.js → activity-gB90peLu.js} +3 -3
  43. package/dist/assets/{button-ELs5xgtQ.js → button-DvHe5h9X.js} +1 -1
  44. package/dist/assets/{chat-store-CBJ1gc8n.js → chat-store-RzAVkc8a.js} +2 -2
  45. package/dist/assets/{codemap-activity-store-D67-genN.js → codemap-activity-store-DBdfN0ix.js} +1 -1
  46. package/dist/assets/codemap-index-store-45CkVCxN.js +1 -0
  47. package/dist/assets/{dialog-CfAoIH8P.js → dialog-jbs7gu-q.js} +1 -1
  48. package/dist/assets/{empty-state-BDwjdvMh.js → empty-state-D-ojp6Gp.js} +1 -1
  49. package/dist/assets/i18n-nlW2iAya.js +2 -0
  50. package/dist/assets/{index-DHsJniTZ.css → index-mNf-KFcC.css} +1 -1
  51. package/dist/assets/index-o8LMiiBK.js +132 -0
  52. package/dist/assets/{input-DSTQkMEh.js → input-oJ0Gehqp.js} +1 -1
  53. package/dist/assets/{mailbox-store-CKpkM0H1.js → mailbox-store-BuLRsYu3.js} +1 -1
  54. package/dist/assets/{roster-ws-a3-SO1Yb.js → roster-ws-DobwmzEj.js} +1 -1
  55. package/dist/assets/{session-store-Ce4Dck2K.js → session-store-DkPaOIhe.js} +1 -1
  56. package/dist/assets/{settings-Orwkg3lH.js → settings-4A6zNjep.js} +1 -1
  57. package/dist/assets/{settings-BlMNd_AC.js → settings-Bq1PPj3V.js} +1 -1
  58. package/dist/assets/{settings-DyIEVRJT.js → settings-BxL8m0v6.js} +1 -1
  59. package/dist/assets/{settings-ClpzPWKE.js → settings-CZR4viP9.js} +1 -1
  60. package/dist/assets/{settings-CyYYbmdR.js → settings-L8hBHrGD.js} +1 -1
  61. package/dist/assets/{settings-BUtmAZBV.js → settings-t7_uBgp_.js} +1 -1
  62. package/dist/assets/{settings-XRC0dC9D.js → settings-uLdezc9e.js} +1 -1
  63. package/dist/assets/{shared-D368RBth.js → shared-CiaNczO0.js} +1 -1
  64. package/dist/assets/{stores-BATHCuMN.js → stores-liE4mt_C.js} +2 -2
  65. package/dist/assets/{ui-store-BGNdg1e4.js → ui-store-FVcXVdRC.js} +1 -1
  66. package/dist/assets/useWebSocket-DZ-NnXn0.js +29 -0
  67. package/dist/assets/utils-D1fGupR8.js +1 -0
  68. package/dist/assets/{vendor-GiKfK4Iw.js → vendor-AeHpGMaG.js} +30 -30
  69. package/dist/assets/{view-navigation-FdnvQSOv.js → view-navigation-D-afwlSZ.js} +1 -1
  70. package/dist/assets/ws-client-B7j8isQb.js +1 -0
  71. package/dist/components/KanbanContractGraphPanel.d.ts +6 -1
  72. package/dist/components/KanbanTaskInspectorChrome.d.ts +62 -0
  73. package/dist/components/MemoryManager/MemoryDetail.d.ts +1 -1
  74. package/dist/components/MemoryManager/ReviewQueue.d.ts +25 -0
  75. package/dist/components/SettingsPanel/ToolsSection.d.ts +1 -0
  76. package/dist/components/agent-roster-data.d.ts +12 -0
  77. package/dist/hooks/useWebSocket.d.ts +3 -0
  78. package/dist/index.html +23 -23
  79. package/dist/index.js +5488 -4370
  80. package/dist/lib/kanban-cleaner.d.ts +20 -1
  81. package/dist/lib/ws-client-actions.d.ts +3 -0
  82. package/dist/lib/ws-client-utils.d.ts +12 -1
  83. package/dist/lib/ws-client.d.ts +27 -0
  84. package/dist/stores/kanban-store.d.ts +4 -1
  85. package/dist/stores/local-prefs.d.ts +1 -1
  86. package/dist/stores/session-store.d.ts +2 -0
  87. package/dist/stores/ui-store.d.ts +3 -3
  88. package/dist/types/client-message.d.ts +5 -0
  89. package/dist/types/sage.d.ts +13 -0
  90. package/dist/types/server-message.d.ts +2 -2
  91. package/dist/types/system.d.ts +2 -0
  92. package/package.json +9 -9
  93. package/dist/assets/AgentRosterView-BnnhSRau.js +0 -9
  94. package/dist/assets/ChangesView-DxAQY4v4.js +0 -1
  95. package/dist/assets/CodeEditor-9Fu9hRrw.js +0 -1
  96. package/dist/assets/CodeMap-B7YGx2G0.js +0 -1
  97. package/dist/assets/DesignGalleryView-BG-p6kFX.js +0 -1
  98. package/dist/assets/GoalView-CCklBpTx.js +0 -1
  99. package/dist/assets/KanbanView-Dzvn9y79.js +0 -3
  100. package/dist/assets/MailboxDetailView-7dtt5joR.js +0 -1
  101. package/dist/assets/MemoryManager-CL5AiyKr.js +0 -1
  102. package/dist/assets/OfficeMapPanel-Dtb75DlY.js +0 -4
  103. package/dist/assets/RequirementIntakeView-CeZFJlrn.js +0 -1
  104. package/dist/assets/SageTabs-BlK58zgb.js +0 -2
  105. package/dist/assets/SddHub-ZRkMmA7e.js +0 -2
  106. package/dist/assets/SessionList-DLoIKc1b.js +0 -1
  107. package/dist/assets/SetupScreen-B_2CuLeR.js +0 -1
  108. package/dist/assets/SkillDetailView-ChspOaAw.js +0 -3
  109. package/dist/assets/codemap-index-store-ByAYIzQA.js +0 -1
  110. package/dist/assets/i18n-BvFgJYE2.js +0 -2
  111. package/dist/assets/index-BTRQG7C5.js +0 -132
  112. package/dist/assets/useWebSocket-B2opfRwA.js +0 -29
  113. package/dist/assets/utils-CUCQrODG.js +0 -1
  114. package/dist/assets/ws-client-CGEB75Dy.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ba as n,Bn as r,Br as i,Da as a,Fa as o,Ft as s,Mn as c,Ni as l,Nn as u,On as d,Ot as f,Pr as p,Sa as m,Vt as h,Wi as g,Wt as _,Zi as v,Zt as y,_ as b,a as x,an as ee,ar as S,dt as te,ea as ne,f as re,fr as ie,i as ae,jt as C,lt as w,n as T,pa as E,pi as D,r as oe,s as O,sa as k,si as se,un as ce,vn as le,wn as ue,yi as de}from"./vendor-GiKfK4Iw.js";import"./i18n-BvFgJYE2.js";import{t as fe}from"./useWebSocket-B2opfRwA.js";import{t as A}from"./utils-CUCQrODG.js";import{I as pe}from"./stores-BATHCuMN.js";import{n as me}from"./ui-store-BGNdg1e4.js";import{a as he,i as ge,n as j,o as _e,r as M,t as N}from"./dialog-CfAoIH8P.js";import{t as P}from"./button-ELs5xgtQ.js";import{t as F}from"./input-DSTQkMEh.js";import{c as ve}from"./index-BTRQG7C5.js";import{t as I}from"./roster-ws-a3-SO1Yb.js";import{_ as ye,a as be,b as xe,c as Se,d as Ce,f as we,g as L,h as R,i as z,l as B,m as V,n as Te,o as Ee,p as De,r as H,s as Oe,t as ke,u as Ae,v as je,y as U}from"./shared-D368RBth.js";import{t as Me}from"./MemoryDrawer-D2Yq9oba.js";var W=e(n(),1),G=w();function Ne({busyAction:e,deletingId:t,memories:n,onCancel:r,onConfirm:i,onOpenChange:a}){let{t:s}=o();return(0,G.jsx)(N,{open:!!t,onOpenChange:a,children:(0,G.jsxs)(j,{className:`max-w-md`,children:[(0,G.jsxs)(he,{children:[(0,G.jsx)(`span`,{className:`mb-2 flex size-10 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(C,{className:`size-4`})}),(0,G.jsx)(_e,{children:s(`activity:memoryManager.deleteTitle`)}),(0,G.jsx)(M,{className:`leading-6`,children:s(`activity:deleteMemoryDialog.sageWillMarkTheRecordDeleted`)})]}),(0,G.jsx)(`div`,{className:`border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:L(n.find(e=>e.id===t)?.text??``,180)}),(0,G.jsxs)(ge,{children:[(0,G.jsx)(P,{variant:`outline`,onClick:r,disabled:e===`delete`,children:s(`common:action.cancel`)}),(0,G.jsxs)(P,{variant:`destructive`,onClick:i,disabled:e===`delete`,children:[e===`delete`?(0,G.jsx)(S,{className:`size-4 animate-spin`}):(0,G.jsx)(C,{className:`size-4`}),s(e===`delete`?`activity:memoryManager.deletingLabel`:`activity:memoryManager.actionDeleteMemory`)]})]})]})})}var K=212,Pe=188;function q(e){return e.length>14?`${e.slice(0,11)}…`:e}function Fe(e,t=58){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Ie(e){return e.type===`symbol`?[e.path,e.symbol?`#${e.symbol}`:``].filter(Boolean).join(``):e.path??e.command??e.symbol??e.role??e.type}function Le(e){return e===`active`?`border-success/45 bg-success/10 text-success`:e===`stale`?`border-warning/45 bg-warning/10 text-warning`:e===`contradicted`?`border-destructive/45 bg-destructive/10 text-destructive`:e===`superseded`?`border-warning/35 bg-warning/5 text-warning`:`border-border bg-muted/55 text-muted-foreground`}function Re({data:e}){let{entry:t,center:n}=e;return(0,G.jsxs)(`div`,{className:n?`border border-primary/70 bg-card px-3 py-2.5 text-card-foreground shadow-[0_0_0_1px_hsl(var(--primary)/0.2),0_0_24px_hsl(var(--primary)/0.12)]`:`border border-border/80 bg-card/95 px-3 py-2.5 text-card-foreground shadow-lg`,style:{width:K},title:t.text,children:[(0,G.jsx)(O,{type:`target`,position:b.Top,className:`!border-background !bg-muted-foreground`}),(0,G.jsx)(O,{type:`source`,position:b.Bottom,className:`!border-background !bg-primary`}),(0,G.jsx)(O,{type:`source`,position:b.Right,className:`!border-background !bg-primary`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[9px] font-bold uppercase ${Le(t.status)}`,children:t.status}),(0,G.jsx)(`span`,{className:`ml-auto truncate font-mono text-[9px] text-muted-foreground`,children:q(t.id)})]}),(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-[11px] leading-4 text-foreground/90`,children:Fe(t.text)}),(0,G.jsx)(`p`,{className:`mt-1 font-mono text-[9px] uppercase text-muted-foreground`,children:t.kind})]})}function ze({data:e}){return(0,G.jsxs)(`div`,{className:`border border-info/40 bg-info/8 px-2.5 py-2 text-card-foreground shadow-lg`,style:{width:Pe},title:e.label,children:[(0,G.jsx)(O,{type:`target`,position:b.Left,className:`!border-background !bg-info`}),(0,G.jsx)(`p`,{className:`font-mono text-[9px] font-bold uppercase text-info`,children:e.anchor.type}),(0,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-foreground/85`,children:e.label})]})}var Be={memoryNode:Re,anchorNode:ze};function Ve(e,t){return{id:e,revision:0,scope:`project`,kind:`fact`,status:`deleted`,text:t(`activity:memoryManager.memoryUnavailable`),importance:0,confidence:0,freshness:0,tags:[],anchors:[],createdAt:``,updatedAt:``}}function He({nodes:e,edges:t,className:n}){return(0,G.jsx)(`div`,{className:A(`w-full`,n),children:(0,G.jsxs)(re,{nodes:e,edges:t,nodeTypes:Be,fitView:!0,fitViewOptions:{padding:.24,maxZoom:1.05},minZoom:.4,maxZoom:1.5,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!1,zoomOnScroll:!1,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(oe,{variant:ae.Dots,gap:18,size:1,color:`hsl(var(--muted-foreground) / 0.18)`}),(0,G.jsx)(x,{showInteractive:!1,className:`!border-border !bg-card !shadow-lg`})]})})}function Ue({centerMemory:e,allMemories:t,graphEdges:n,loading:r=!1,error:i=null}){let{t:a}=o(),[s,c]=(0,W.useState)(!1),l=`mem:${e.id}`,u=(0,W.useMemo)(()=>n.filter(e=>e.from===l&&e.to.startsWith(`mem:`)||e.to===l&&e.from.startsWith(`mem:`)).slice(0,24),[l,n]),{nodes:d,edges:f}=(0,W.useMemo)(()=>{let n=[],r=[],i=new Map(t.map(e=>[e.id,e]));n.push({id:e.id,type:`memoryNode`,position:{x:320-K/2,y:120},data:{entry:e,center:!0}});let o=[...e.supersededBy?[{id:e.supersededBy,relation:`superseded by`}]:[],...(e.supersedes??[]).map(e=>({id:e,relation:`supersedes`})),...(e.contradicts??[]).map(e=>({id:e,relation:`contradicts`}))];for(let e of u){let t=(e.from===l?e.to:e.from).slice(4);o.some(n=>n.id===t&&n.relation===e.relation)||o.push({id:t,relation:e.relation,weight:e.weight,evidence:e.evidence})}let s=320-(o.length-1)*220/2;return o.forEach((t,o)=>{let c=i.get(t.id)??Ve(t.id,a),l=t.relation===`superseded by`,u=l?0:280+Math.floor(o/3)*130,d=l?320-K/2:s+o*220-K/2;n.push({id:`memory:${t.id}:${o}`,type:`memoryNode`,position:{x:d,y:u},data:{entry:c,center:!1}});let f=t.relation===`contradicts`,p=l?`memory:${t.id}:${o}`:e.id,m=l?e.id:`memory:${t.id}:${o}`;r.push({id:`relation:${t.relation}:${t.id}:${o}`,source:p,target:m,type:`smoothstep`,animated:!f,label:t.weight===void 0?t.relation:`${t.relation} ${t.weight.toFixed(2)}`,data:{evidence:t.evidence??[]},style:{stroke:f?`hsl(var(--destructive))`:`hsl(var(--primary))`,strokeWidth:1.7,...f?{strokeDasharray:`5 4`}:{}},labelStyle:{fill:f?`hsl(var(--destructive))`:`hsl(var(--muted-foreground))`,fontSize:9,fontWeight:700},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.9}})}),e.anchors.forEach((t,i)=>{let a=`anchor:${i}`;n.push({id:a,type:`anchorNode`,position:{x:540,y:120+(i-(e.anchors.length-1)/2)*66},data:{anchor:t,label:Ie(t)}}),r.push({id:`anchor-edge:${i}`,source:e.id,target:a,type:`smoothstep`,style:{stroke:`hsl(var(--info))`,strokeWidth:1.3}})}),{nodes:n,edges:r}},[t,e,l,u]);return d.length<=1&&!r&&!i?null:(0,G.jsxs)(`section`,{className:`overflow-hidden border border-border/75 bg-background/35`,"aria-label":a(`activity:memoryManager.graphAria`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeading`)}),d.length>1&&(0,G.jsxs)(P,{variant:`ghost`,size:`sm`,onClick:()=>c(!0),className:`h-6 gap-1 px-2 text-[9px] font-bold uppercase tracking-[0.12em]`,"aria-label":a(`activity:memoryManager.graphFullscreenAria`),children:[(0,G.jsx)(D,{className:`size-3`}),a(`activity:memoryManager.graphOpenFullscreen`)]})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:r?a(`activity:memoryManager.loadingGraph`):a(`activity:memoryManager.graphStats`,{nodes:d.length,edges:f.length})})]}),i&&(0,G.jsx)(`p`,{className:`border-b border-destructive/25 bg-destructive/5 px-3 py-2 text-[10px] text-destructive`,children:i}),d.length>1&&(0,G.jsx)(He,{nodes:d,edges:f,className:`h-[320px]`}),u.some(e=>e.evidence?.length)&&(0,G.jsx)(`div`,{className:`grid gap-1 border-t border-border/70 bg-card/35 px-3 py-2`,children:u.filter(e=>e.evidence?.length).slice(0,12).map(e=>{let t=(e.from===l?e.to:e.from).slice(4);return(0,G.jsxs)(`p`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`text-info`,children:e.relation}),` `,q(t),` · why:`,` `,e.evidence?.join(`, `)]},e.id)})}),s&&(0,G.jsx)(N,{open:s,onOpenChange:c,children:(0,G.jsxs)(j,{className:`flex max-h-[90dvh] max-w-[90vw] flex-col p-0`,showCloseButton:!1,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/55 px-4 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:a(`activity:memoryManager.graphHeadingFull`,{id:e.id})}),(0,G.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>c(!1),className:`h-7 gap-1 px-2 text-[10px]`,children:a(`common:action.close`)})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4`,children:(0,G.jsx)(He,{nodes:d,edges:f,className:`h-[65vh]`})})]})})]})}function We({memory:e,allMemories:t,relatedMemories:n,graphEdges:r,graphLoading:i,graphError:a,onClose:s,onOpenMemory:c,onEdit:u,onDelete:f,onTagSelect:p,onNotice:h}){let{t:g}=o();return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/65 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,className:`md:hidden`,onClick:s,"aria-label":g(`activity:memoryManager.backToList`),children:(0,G.jsx)(m,{className:`size-4`})}),(0,G.jsx)(`span`,{className:A(`text-[10px] font-bold uppercase tracking-[0.14em]`,R(e.kind)),children:H[e.kind]??e.kind}),(0,G.jsx)(B,{status:e.status}),(0,G.jsx)(`span`,{className:`border border-border/70 px-2 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 border border-primary/30 bg-primary/10 px-2 py-0.5 font-mono text-[9px] text-primary`,title:De(e.audience),children:[(0,G.jsx)(k,{className:`size-3`}),De(e.audience)]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,"aria-label":g(`activity:memoryManager.copyId`),title:g(`activity:memoryManager.copyId`),onClick:()=>{navigator.clipboard?.writeText(e.id),h(g(`activity:memoryManager.copiedNotice`))},children:(0,G.jsx)(l,{className:`size-4`})}),(0,G.jsxs)(P,{variant:`outline`,size:`sm`,onClick:u,disabled:e.status===`deleted`,children:[(0,G.jsx)(d,{className:`size-3.5`}),` `,g(`common:action.edit`)]}),(0,G.jsxs)(P,{variant:`destructive`,size:`sm`,onClick:f,disabled:e.status===`deleted`,children:[(0,G.jsx)(C,{className:`size-3.5`}),` `,g(`common:action.delete`)]})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-5`,children:[(0,G.jsx)(Ge,{memory:e}),(0,G.jsx)(Ke,{memory:e}),e.tags.length>0&&(0,G.jsx)(qe,{tags:e.tags,onTagSelect:p}),e.anchors.length>0&&(0,G.jsx)(Je,{anchors:e.anchors}),n.length>0&&(0,G.jsx)(Ye,{relatedMemories:n,allMemories:t,onOpenMemory:c}),(0,G.jsx)(Ue,{centerMemory:e,allMemories:t,graphEdges:r,loading:i,error:a}),(0,G.jsx)(J,{memory:e}),e.status===`deleted`&&(0,G.jsx)(Xe,{contextPolicy:e.contextPolicy})]})})]})}function Ge({memory:e}){let{t}=o();return(0,G.jsxs)(`div`,{className:`relative overflow-hidden border border-border/75 bg-card/55 p-5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.04)]`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-10 size-36 bg-[radial-gradient(circle,hsl(var(--info)/0.13),transparent_68%)]`}),(0,G.jsx)(`p`,{className:`relative whitespace-pre-wrap text-sm leading-7 text-foreground md:text-[15px]`,children:e.text}),e.summary&&(0,G.jsx)(`p`,{className:`relative mt-4 border-l-2 border-info/50 pl-3 text-xs italic leading-5 text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`relative mt-5 flex flex-wrap items-center gap-2 border-t border-border/60 pt-3`,children:[(0,G.jsx)(`code`,{className:`min-w-0 break-all font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,G.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground`,children:t(`activity:memoryManager.revisionSuffix`,{n:e.revision})})]})]})}function Ke({memory:e}){let{t}=o();return(0,G.jsx)(`div`,{className:`grid gap-px bg-border/60 sm:grid-cols-3`,children:[[t(`activity:memoryManager.editorImportance`),e.importance,y],[t(`activity:memoryManager.editorConfidence`),e.confidence,g],[t(`activity:memoryManager.editorFreshness`),e.freshness,le]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/60 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(n,{className:`size-3.5 text-info`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.13em] text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{className:`ml-auto font-mono text-xs font-bold tabular-nums`,children:[Math.round(t*100),`%`]})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 bg-muted`,children:(0,G.jsx)(`div`,{className:`h-full bg-info shadow-[0_0_8px_hsl(var(--info)/0.45)]`,style:{width:`${Math.round(t*100)}%`}})})]},e))})}function qe({tags:e,onTagSelect:t}){let{t:n}=o();return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h3`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(s,{className:`size-3.5 text-info`}),` `,n(`activity:memoryManager.tagsLabel`)]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`border border-info/25 bg-info/5 px-2 py-1 font-mono text-[10px] text-info hover:border-info/55 hover:bg-info/10`,children:[`#`,e]},e))})]})}function Je({anchors:e}){let{t}=o();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(se,{className:`size-3.5 text-info`}),` `,t(`activity:memoryManager.editorAnchors`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex min-w-0 items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center border border-info/25 bg-info/5 text-info`,children:e.type===`command`?(0,G.jsx)(h,{className:`size-3.5`}):(0,G.jsx)(se,{className:`size-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold uppercase text-muted-foreground`,children:e.type}),(0,G.jsxs)(`p`,{className:`mt-0.5 break-all font-mono text-[10px] leading-4 text-foreground/85`,children:[e.path??e.command??e.role??`—`,e.symbol?`#${e.symbol}`:``]})]}),(e.lineStart||e.lineEnd)&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`L`,e.lineStart??`?`,`–`,e.lineEnd??`?`]})]},`${e.type}:${e.path??e.command??e.symbol??e.role}:${t}`))})]})}function Ye({relatedMemories:e,allMemories:t,onOpenMemory:n}){let{t:r}=o();return(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/40`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/65 px-3 py-2.5`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsx)(p,{className:`size-3.5 text-info`}),` `,r(`activity:memoryManager.memoryRelationships`)]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.length})]}),(0,G.jsx)(`ul`,{className:`divide-y divide-border/55`,children:e.map(e=>{let i=t.find(t=>t.id===e.id);return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,disabled:!i,onClick:()=>i&&n(i.id),className:`group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left hover:bg-info/5 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,G.jsx)(`span`,{className:A(`w-24 shrink-0 text-[9px] font-bold uppercase`,e.relation===`Contradicts`?`text-destructive`:`text-info`),children:e.relation}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:i?L(i.text,95):r(`activity:memoryManager.referencedUnavailable`)}),(0,G.jsx)(`code`,{className:`hidden max-w-32 truncate font-mono text-[9px] text-muted-foreground sm:block`,children:e.id}),i&&(0,G.jsx)(v,{className:`size-3.5 shrink-0 text-muted-foreground group-hover:text-info`})]})},`${e.relation}:${e.id}`)})})]})}function J({memory:e}){let{t}=o();return(0,G.jsx)(`section`,{className:`grid gap-px bg-border/60 sm:grid-cols-2 lg:grid-cols-4`,children:[[t(`activity:memoryManager.metaCreated`),V(e.createdAt),E],[t(`activity:memoryManager.metaUpdated`),V(e.updatedAt),le],[t(`activity:memoryManager.metaLastAccessed`),V(e.lastAccessedAt),r],[t(`activity:memoryManager.metaLastVerified`),V(e.lastVerifiedAt),y]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`bg-card/50 p-3`,children:[(0,G.jsx)(n,{className:`size-3.5 text-muted-foreground`}),(0,G.jsx)(`p`,{className:`mt-2 text-[9px] font-bold uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 text-foreground/85`,children:t})]},e))})}function Xe({contextPolicy:e}){let{t}=o();return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 border border-border bg-muted/50 p-4 text-xs text-muted-foreground`,children:[(0,G.jsx)(a,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-foreground`,children:t(`activity:memoryManager.deletedMemory`)}),(0,G.jsx)(`p`,{className:`mt-1 leading-5`,children:t(e===`never`?`activity:memoryManager.deletedNeverPolicy`:`activity:memoryManager.deletedEligiblePolicy`)})]})]})}function Ze({mode:e,draft:t,busy:n,error:r,onChange:i,onCancel:a,onSubmit:s}){let{t:c}=o(),l=(0,W.useRef)(null),[u,p]=(0,W.useState)([]);(0,W.useEffect)(()=>{l.current?.focus();let e=new AbortController;return I(`agent-roster.list`,{},e.signal).then(e=>{let t=e.roles;Array.isArray(t)&&p(t.filter(e=>typeof e==`string`))}).catch(()=>void 0),()=>e.abort()},[]);let m=(e,n)=>{i({...t,[e]:n})},h=()=>{m(`anchors`,[...t.anchors,{type:`file`,path:``}])};return(0,G.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),s()},"aria-busy":n,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/70 bg-card/70 px-4 py-3 backdrop-blur-xl`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`flex size-8 items-center justify-center border border-info/35 bg-info/10 text-info`,children:e===`create`?(0,G.jsx)(_,{className:`size-4`}):(0,G.jsx)(d,{className:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-bold`,children:c(e===`create`?`activity:memoryManager.captureMemory`:`activity:memoryManager.editMemory`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:c(e===`create`?`activity:memoryManager.editorCreateHint`:`activity:memoryManager.editorEditHint`)})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:a,disabled:n,children:[(0,G.jsx)(te,{className:`size-3.5`}),` `,c(`common:action.cancel`)]}),(0,G.jsxs)(P,{type:`submit`,size:`sm`,disabled:n||!t.text.trim(),children:[n?(0,G.jsx)(S,{className:`size-3.5 animate-spin`}):e===`create`?(0,G.jsx)(ue,{className:`size-3.5`}):(0,G.jsx)(ce,{className:`size-3.5`}),c(n?`common:action.saving`:e===`create`?`activity:memoryManager.createMemory`:`activity:memoryManager.saveChanges`)]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 md:p-5`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[r&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 border border-destructive/40 bg-destructive/10 px-3 py-2.5 text-sm text-destructive`,children:[(0,G.jsx)(f,{className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`span`,{children:r})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorKnowledge`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memEditor.writeTheDurableFactOrDecision`)})]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground tabular-nums`,children:c(`activity:memoryManager.editorCharCount`,{count:t.text.length})})]}),(0,G.jsx)(`label`,{htmlFor:`memory-text`,className:`sr-only`,children:c(`activity:memoryManager.editorContentLabel`)}),(0,G.jsx)(`textarea`,{ref:l,id:`memory-text`,value:t.text,onChange:e=>m(`text`,e.target.value),rows:7,required:!0,placeholder:c(`activity:memoryManager.editorContentPlaceholder`),className:`min-h-36 w-full resize-y border border-input bg-background/75 px-3 py-3 text-sm leading-6 text-foreground shadow-inner placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-kind`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorKind`)}),(0,G.jsx)(`select`,{id:`memory-kind`,value:t.kind,onChange:e=>m(`kind`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:z.map(e=>(0,G.jsx)(`option`,{value:e,children:H[e]},e))})]}),e===`create`?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-scope`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorScope`)}),(0,G.jsx)(`select`,{id:`memory-scope`,value:t.scope,onChange:e=>m(`scope`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:be.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}):(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`label`,{htmlFor:`memory-status`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorLifecycleStatus`)}),(0,G.jsx)(`select`,{id:`memory-status`,value:t.status,onChange:e=>m(`status`,e.target.value),className:`h-10 w-full border border-input bg-background px-3 text-sm`,children:Te.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:A(`min-w-0`,e===`create`?`sm:col-span-2 lg:col-span-1`:``),children:[(0,G.jsx)(`label`,{htmlFor:`memory-tags`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(F,{id:`memory-tags`,value:t.tags,onChange:e=>m(`tags`,e.target.value),placeholder:c(`activity:memEditor.architectureWebuiWorkflow`),className:`h-10 bg-background`})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,G.jsx)(Se,{id:`memory-importance`,label:c(`activity:memoryManager.editorImportance`),value:t.importance,onChange:e=>m(`importance`,e)}),(0,G.jsx)(Se,{id:`memory-confidence`,label:c(`activity:memoryManager.editorConfidence`),value:t.confidence,onChange:e=>m(`confidence`,e)}),(0,G.jsx)(Se,{id:`memory-freshness`,label:c(`activity:memoryManager.editorFreshness`),value:t.freshness,onChange:e=>m(`freshness`,e)})]}),(0,G.jsxs)(`section`,{className:`border border-border/75 bg-card/45 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorAnchors`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memEditor.bindKnowledgeToFilesSymbolsPackages`)})]}),(0,G.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:h,children:[(0,G.jsx)(ue,{className:`size-3.5`}),` `,c(`activity:memoryManager.addAnchor`)]})]}),t.anchors.length===0?(0,G.jsxs)(`button`,{type:`button`,onClick:h,className:`mt-4 flex w-full items-center justify-center gap-2 border border-dashed border-border px-4 py-7 text-xs text-muted-foreground transition-colors hover:border-info/50 hover:bg-info/5 hover:text-info`,children:[(0,G.jsx)(ie,{className:`size-4`}),` `,c(`activity:memoryManager.noAnchors`)]}):(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:t.anchors.map((e,n)=>(0,G.jsxs)(`div`,{className:`grid gap-2 border border-border/65 bg-background/40 p-2 sm:grid-cols-[9rem_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-type-${n}`,children:[`Anchor `,n+1,` type`]}),(0,G.jsx)(`select`,{id:`anchor-type-${n}`,value:e.type,onChange:e=>{let r=e.target.value,i=r===`command`?{type:r,command:``}:r===`agent`?{type:r,role:``}:{type:r,path:``},a=t.anchors.map((e,t)=>t===n?i:e);m(`anchors`,a)},className:`h-10 border border-input bg-background px-2 text-xs`,children:ke.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:A(`grid min-w-0 gap-2`,e.type===`symbol`&&`sm:grid-cols-[minmax(0,1fr)_11rem]`),children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-value-${n}`,children:[`Anchor `,n+1,` value`]}),(0,G.jsx)(F,{id:`anchor-value-${n}`,list:e.type===`agent`?`memory-agent-role-options`:void 0,value:Ae(e),onChange:e=>{let r=t.anchors.map((t,r)=>r===n?xe(t,e.target.value):t);m(`anchors`,r)},placeholder:e.type===`command`?`pnpm test --filter webui`:e.type===`agent`?`reviewer`:`packages/webui/src/App.tsx`,className:`h-10 min-w-0 bg-background font-mono text-xs`}),e.type===`symbol`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`sr-only`,htmlFor:`anchor-symbol-${n}`,children:[`Anchor `,n+1,` symbol`]}),(0,G.jsx)(F,{id:`anchor-symbol-${n}`,value:e.symbol??``,onChange:e=>{let r=t.anchors.map((t,r)=>r===n?{...t,symbol:e.target.value}:t);m(`anchors`,r)},placeholder:c(`activity:memoryManager.editorSymbolPlaceholder`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Remove anchor ${n+1}`,onClick:()=>m(`anchors`,t.anchors.filter((e,t)=>t!==n)),children:(0,G.jsx)(C,{className:`size-4 text-destructive`})})]},`${e.type}:${n}`))}),(0,G.jsx)(`datalist`,{id:`memory-agent-role-options`,children:u.map(e=>(0,G.jsx)(`option`,{value:e},e))})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 border border-border/75 bg-card/45 p-4 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-[0.14em]`,children:c(`activity:memoryManager.editorRelationships`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:c(`activity:memoryManager.editorRelationshipsHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-supersedes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorSupersedes`)}),(0,G.jsx)(F,{id:`memory-supersedes`,value:t.supersedes,onChange:e=>m(`supersedes`,e.target.value),placeholder:c(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-contradicts`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorContradicts`)}),(0,G.jsx)(F,{id:`memory-contradicts`,value:t.contradicts,onChange:e=>m(`contradicts`,e.target.value),placeholder:c(`activity:memEditor.memIdMemId`),className:`h-10 bg-background font-mono text-xs`})]})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.audienceOptional`)}),(0,G.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:c(`activity:memEditor.targetThisMemoryToSpecificAgent`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-roles`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.roles`)}),(0,G.jsx)(F,{id:`memory-audience-roles`,value:t.audienceRoles,onChange:e=>m(`audienceRoles`,e.target.value),placeholder:c(`activity:memEditor.reviewerRefactorPlanner`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-task-types`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memoryManager.editorTaskTypes`)}),(0,G.jsx)(F,{id:`memory-audience-task-types`,value:t.audienceTaskTypes,onChange:e=>m(`audienceTaskTypes`,e.target.value),placeholder:c(`activity:memEditor.reviewRefactorBugfix`),className:`h-9 bg-background font-mono text-xs`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{htmlFor:`memory-audience-modes`,className:`mb-1.5 block text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:c(`activity:memEditor.modes`)}),(0,G.jsx)(F,{id:`memory-audience-modes`,value:t.audienceModes,onChange:e=>m(`audienceModes`,e.target.value),placeholder:c(`activity:memEditor.teachCodeReview`),className:`h-9 bg-background font-mono text-xs`})]})]})]})})]})}function Qe({searchQuery:e,statusFilter:n,kindFilter:r,audienceOnly:a,tagFilter:c,hasFilters:l,allTags:u,stats:d,onSearchChange:f,onStatusFilterChange:p,onKindFilterChange:m,onToggleAudienceOnly:h,onTagFilterChange:g,onClearFilters:_}){let{t:v}=o(),[y,b]=(0,W.useState)(!!c),x=y||!!c,S=u.length>0;return(0,G.jsxs)(`div`,{className:`shrink-0 space-y-2 overflow-hidden border-b border-border/70 bg-card/45 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,G.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,G.jsx)(F,{"aria-label":v(`activity:memoryManager.searchAria`),value:e,onChange:e=>f(e.target.value),placeholder:v(`activity:memoryManager.searchPlaceholder`),className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,G.jsx)(`button`,{type:`button`,"aria-label":v(`activity:memoryManager.clearSearchAria`),onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,G.jsx)(te,{className:`size-3.5`})})]}),(0,G.jsx)(P,{variant:a?`default`:`ghost`,size:`icon`,onClick:h,"aria-label":v(`activity:memoryManager.audienceFilterAria`),title:v(`activity:memoryManager.audienceFilterTitle`),className:`shrink-0`,children:(0,G.jsx)(k,{className:`size-4`})}),l&&(0,G.jsx)(P,{variant:`ghost`,size:`icon`,onClick:_,"aria-label":v(`activity:memoryManager.clearFiltersAria`),title:v(`activity:memoryManager.clearFiltersTitle`),children:(0,G.jsx)(i,{className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-status-filter`,children:v(`activity:memoryManager.filterByStatus`)}),(0,G.jsxs)(`select`,{id:`memory-status-filter`,value:n,onChange:e=>p(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allStatuses`)}),Ee.map(e=>(0,G.jsxs)(`option`,{value:e,children:[e,` · `,d?.byStatus[e]??0]},e))]}),(0,G.jsx)(`label`,{className:`sr-only`,htmlFor:`memory-kind-filter`,children:v(`activity:memoryManager.filterByKind`)}),(0,G.jsxs)(`select`,{id:`memory-kind-filter`,value:r,onChange:e=>m(e.target.value),className:`h-9 min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,G.jsx)(`option`,{value:`all`,children:v(`activity:memoryManager.allKinds`)}),z.map(e=>(0,G.jsxs)(`option`,{value:e,children:[H[e],` · `,d?.byKind[e]??0]},e))]})]}),S&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{c||b(e=>!e)},"aria-expanded":x,"aria-controls":`memory-tags-panel`,disabled:!!c,className:A(`flex items-center gap-1.5 px-1 py-0.5 text-[10px] uppercase tracking-wide transition-colors`,x?`text-foreground`:`text-muted-foreground hover:text-foreground`,!!c&&`cursor-default`),title:c?`Active filter: ${c} (click the chip to clear)`:x?`Hide tag filters`:`Show tag filters (${u.length})`,children:[(0,G.jsx)(t,{className:A(`size-3 transition-transform`,!x&&`-rotate-90`)}),(0,G.jsx)(s,{className:`size-3`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:v(`activity:memoryManager.tagsLabel`)}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:u.length})]}),c&&(0,G.jsx)(`span`,{role:`status`,"aria-label":`Active tag filter: ${c}`,className:`border border-info/55 bg-info/10 px-1 font-mono text-[9px] uppercase text-info`,children:c})]}),S&&x&&(0,G.jsxs)(`fieldset`,{id:`memory-tags-panel`,className:`min-w-0 border-0 p-0`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:v(`activity:memoryManager.popularTags`)}),(0,G.jsx)(`div`,{className:`no-scrollbar flex gap-1.5 overflow-x-auto pb-0.5`,children:u.slice(0,18).map(([e,t])=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":c===e,onClick:()=>g(c===e?null:e),className:A(`flex shrink-0 items-center gap-1 border px-2 py-1 text-[10px] transition-colors`,c===e?`border-info/55 bg-info/10 text-info`:`border-border/70 bg-background/45 text-muted-foreground hover:border-info/35 hover:text-foreground`),children:[(0,G.jsx)(s,{className:`size-2.5`}),` `,e,(0,G.jsx)(`span`,{className:`font-mono opacity-60`,children:t})]},e))})]})]})}var Y=100;function $e({memoryListRef:e,memories:t,filteredMemories:n,selectedId:r,onSelectMemory:i,onOpenCreate:a,onClearFilters:s}){let{t:c}=o(),l=n.length>Y,u=T({count:n.length,getScrollElement:()=>e.current,estimateSize:()=>100,overscan:8,enabled:l});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-2 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:c(`activity:memoryManager.memoryCountSummary`,{shown:n.length,total:t.length})}),(0,G.jsx)(`span`,{className:`font-mono uppercase`,children:c(`activity:memoryManager.updatedSortLabel`)})]}),(0,G.jsx)(`section`,{ref:e,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,"aria-label":c(`activity:memoryManager.listAria`),children:n.length===0?(0,G.jsx)(et,{hasMemories:t.length>0,onOpenCreate:a,onClearFilters:s}):l?(0,G.jsx)(`div`,{style:{height:`${u.getTotalSize()}px`,width:`100%`,position:`relative`},children:u.getVirtualItems().map(e=>{let t=n[e.index];return t?(0,G.jsx)(`div`,{"data-index":e.index,ref:u.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,G.jsx)(X,{memory:t,isSelected:r===t.id,onClick:()=>i(t.id)})},t.id):null})}):n.map(e=>(0,G.jsx)(X,{memory:e,isSelected:r===e.id,onClick:()=>i(e.id)},e.id))})]})}function et({hasMemories:e,onOpenCreate:t,onClearFilters:n}){let{t:r}=o();return(0,G.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(`span`,{className:`flex size-12 items-center justify-center border border-dashed border-border text-muted-foreground`,children:(0,G.jsx)(de,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-sm font-bold`,children:r(e?`activity:memoryManager.noMatching`:`activity:memoryManager.buildGraph`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-xs text-xs leading-5 text-muted-foreground`,children:r(e?`activity:memoryManager.emptyFiltered`:`activity:memoryManager.emptyCapture`)}),(0,G.jsxs)(P,{className:`mt-4`,variant:`outline`,size:`sm`,onClick:e?n:t,children:[e?(0,G.jsx)(i,{className:`size-3.5`}):(0,G.jsx)(ue,{className:`size-3.5`}),r(e?`activity:memoryManager.clearFilters`:`activity:memoryManager.createFirst`)]})]})}function X({memory:e,isSelected:t,onClick:n}){return(0,G.jsxs)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:n,className:A(`group relative block w-full border-b border-border/55 px-3 py-3 text-left transition-[background-color,border-color] hover:bg-info/5`,t&&`bg-info/8`),children:[t&&(0,G.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-0.5 bg-info shadow-[0_0_10px_hsl(var(--info)/0.7)]`}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:A(`truncate text-[10px] font-bold uppercase tracking-[0.1em]`,R(e.kind)),children:H[e.kind]??e.kind}),(0,G.jsx)(B,{status:e.status}),(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[9px] text-muted-foreground`,children:[`r`,e.revision]})]}),(0,G.jsx)(`p`,{className:A(`mt-2 line-clamp-2 text-xs leading-5 text-foreground/90`,e.status===`deleted`&&`line-through opacity-60`),children:L(e.text)}),(0,G.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`border border-border/60 bg-background/50 px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground`,children:e.scope}),e.audience&&(0,G.jsxs)(`span`,{className:`flex items-center gap-0.5 border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[9px] text-primary`,children:[(0,G.jsx)(k,{className:`size-2.5`}),(e.audience.roles??e.audience.taskTypes??e.audience.modes??[]).slice(0,1)[0]??`scoped`]}),e.tags.slice(0,2).map(e=>(0,G.jsxs)(`span`,{className:`max-w-24 truncate border border-border/60 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,e]},e)),e.tags.length>2&&(0,G.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[`+`,e.tags.length-2]}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 text-[9px] text-muted-foreground`,children:je(e.updatedAt)}),(0,G.jsx)(v,{className:`size-3 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5 group-hover:text-info`})]})]})}function tt({onCapture:e}){let{t}=o();return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center`,children:[(0,G.jsxs)(`div`,{className:`relative flex size-20 items-center justify-center border border-info/25 bg-info/5 text-info`,children:[(0,G.jsx)(k,{className:`size-8`}),(0,G.jsx)(`span`,{className:`absolute inset-2 border border-info/10`})]}),(0,G.jsx)(`h2`,{className:`mt-5 text-lg font-bold`,children:t(`activity:memoryManager.emptyTitle`)}),(0,G.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-muted-foreground`,children:t(`activity:memoryManager.emptyBody`)}),(0,G.jsxs)(`div`,{className:`mt-6 grid w-full max-w-lg gap-2 sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(ne,{className:`mx-auto size-4 text-success`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyVerifiedAnchors`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(k,{className:`mx-auto size-4 text-info`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyTypedRelations`)})]}),(0,G.jsxs)(`div`,{className:`border border-border/70 bg-card/45 p-3`,children:[(0,G.jsx)(ue,{className:`mx-auto size-4 text-warning`}),(0,G.jsx)(`p`,{className:`mt-2 text-[10px] font-bold uppercase`,children:t(`activity:memoryManager.emptyAgentRecall`)})]})]}),(0,G.jsxs)(P,{onClick:e,children:[(0,G.jsx)(ue,{className:`size-4`}),` `,t(`activity:memoryManager.captureButton`)]})]})}function nt(e,t){let n=t.searchQuery.trim().toLowerCase();return e.filter(e=>{if(t.statusFilter!==`all`&&e.status!==t.statusFilter||t.kindFilter!==`all`&&e.kind!==t.kindFilter||t.tagFilter&&!e.tags.includes(t.tagFilter)||t.audienceOnly&&!e.audience)return!1;if(!n)return!0;let r=e.anchors.map(e=>[e.path,e.symbol,e.command,e.role].filter(Boolean).join(` `)).join(` `),i=e.audience?[e.audience.roles?.join(` `)??``,e.audience.taskTypes?.join(` `)??``,e.audience.modes?.join(` `)??``].join(` `):``;return[e.id,e.text,e.summary??``,e.kind,e.scope,e.tags.join(` `),r,i].join(` `).toLowerCase().includes(n)})}function rt(e){let t=new Map;for(let n of e)for(let e of n.tags)t.set(e,(t.get(e)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function it(e){if(!e)return[];let t=[];e.supersededBy&&t.push({relation:`Superseded by`,id:e.supersededBy});for(let n of e.supersedes??[])t.push({relation:`Supersedes`,id:n});for(let n of e.contradicts??[])t.push({relation:`Contradicts`,id:n});return t}function at(){let{t:e}=o(),{client:t,listSageMemoriesPage:n,rememberSage:r,updateSage:i,deleteSage:a,getSageGraph:s,recoverSage:l,resolveMemoryCandidate:d}=fe(),p=pe(e=>e.wsConnected),h=me(e=>e.setCurrentView),g=ve(`memory`),[_,v]=(0,W.useState)([]),[y,b]=(0,W.useState)(null),[x,ee]=(0,W.useState)(!0),[S,te]=(0,W.useState)(!1),[re,ie]=(0,W.useState)(null),[ae,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[oe,O]=(0,W.useState)([]),[se,ce]=(0,W.useState)([]),[de,he]=(0,W.useState)(null),[ge,j]=(0,W.useState)(!1),[_e,M]=(0,W.useState)(!1),[N,F]=(0,W.useState)(!1),[I,be]=(0,W.useState)(we),[xe,Se]=(0,W.useState)(we),[L,R]=(0,W.useState)(null),[z,B]=(0,W.useState)(null),[V,Te]=(0,W.useState)(``),[Ee,De]=(0,W.useState)(`all`),[H,ke]=(0,W.useState)(`all`),[Ae,je]=(0,W.useState)(!1),[K,Pe]=(0,W.useState)(null),[q,Fe]=(0,W.useState)(!1),[Ie,Le]=(0,W.useState)(null),[Re,ze]=(0,W.useState)(!1),[Be,Ve]=(0,W.useState)(!1),[He,Ue]=(0,W.useState)({}),[Ge,Ke]=(0,W.useState)(!1),[qe,Je]=(0,W.useState)(null),Ye=(0,W.useRef)(!1),J=(0,W.useRef)(!0),Xe=(0,W.useRef)(0),Y=(0,W.useRef)(0),et=(0,W.useRef)(null),X=(0,W.useRef)(null),at=(0,W.useMemo)(()=>{let e=new Set;for(let t of _)for(let n of t.anchors??[])n.type===`file`&&n.path&&e.add(n.path);return e},[_]),ot=(0,W.useMemo)(()=>JSON.stringify(I)!==JSON.stringify(xe),[xe,I]),Z=(0,W.useMemo)(()=>_.find(e=>e.id===E)??null,[_,E]),st=(0,W.useCallback)(e=>{let r=e!==null,i=++Xe.current;et.current?.(),ie(null),r?Ve(!0):(te(!0),Ye.current||ee(!0));let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),et.current===c&&(et.current=null))};a=t.on(`memory.sage.listPage`,e=>{if(i!==Xe.current||!J.current){c();return}if(c(),e.payload.error)ie(e.payload.error);else{let t=e.payload.memories??[];v(e=>r?[...e,...t]:t),Le(e.payload.nextCursor??null),ze(!!e.payload.nextCursor);let n=e.payload.statusCounts??{};Ue(n);let i=Object.values(n).reduce((e,t)=>e+t,0);e.payload.stats?b(e.payload.stats):b(e=>({total:i,byStatus:n,byKind:e?.byKind??{},edges:e?.edges??0})),Ye.current=!0,r||D(e=>e&&t.some(t=>t.id===e)?e:null)}ee(!1),te(!1),Ve(!1)}),o=setTimeout(()=>{i!==Xe.current||!J.current||(c(),ie(`The memory store did not respond. Check the WebSocket connection and try again.`),ee(!1),te(!1),Ve(!1))},2e4),et.current=c,n({limit:100,...q?{statuses:[`deleted`]}:{},...e?{cursor:e}:{}},{echoToChat:!1})},[t,n,q]),Q=(0,W.useCallback)(()=>{Le(null),ze(!1),st(null)},[st]),ct=(0,W.useCallback)(()=>{Be||!Ie||st(Ie)},[st,Be,Ie]);(0,W.useEffect)(()=>(J.current=!0,Q(),()=>{J.current=!1,Xe.current+=1,Y.current+=1,et.current?.(),X.current?.()}),[Q]),(0,W.useEffect)(()=>{if(O([]),ce([]),he(null),!E){j(!1);return}let e=E;j(!0);let n=null,r=t.on(`memory.sage.graph`,t=>{t.payload.query===e&&(n!==null&&clearTimeout(n),O(t.payload.edges??[]),ce(t.payload.memories??[]),he(t.payload.error??null),j(!1))});return n=setTimeout(()=>{he(`Relationship graph did not respond in time.`),j(!1)},15e3),s(e,{maxDepth:1,limit:120},{echoToChat:!1}),()=>{n!==null&&clearTimeout(n),r()}},[t,s,E]);let lt=(0,W.useRef)(p);(0,W.useEffect)(()=>{p&&!lt.current&&Ye.current&&Q(),lt.current=p},[Q,p]),(0,W.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>T(null),4e3);return()=>clearTimeout(e)},[w]);let ut=(0,W.useCallback)(()=>!ot||!_e&&!N||window.confirm(`Discard the unsaved memory changes?`),[N,ot,_e]),dt=(0,W.useCallback)(()=>{if(!ut())return;let e=we();be(e),Se(e),F(!0),M(!1),D(null),C(null)},[ut]),ft=(0,W.useCallback)(e=>{ut()&&(D(e),F(!1),M(!1),C(null))},[ut]),pt=(0,W.useCallback)(e=>{let t=e===void 0?Z:_.find(t=>t.id===e)??null;if(!t||t.status===`deleted`)return;e!==void 0&&D(e);let n=Ce(t);be(n),Se(n),M(!0),F(!1),C(null)},[_,Z]),mt=(0,W.useCallback)(()=>{ut()&&(M(!1),F(!1),C(null))},[ut]),ht=(0,W.useCallback)((n,r,i)=>{if(!I.text.trim()){C(`Memory content is required.`);return}let a=++Y.current;X.current?.(),R(i),C(null),T(null);let o=()=>{},s=null,c=!1,l=()=>{c||(c=!0,s!==null&&clearTimeout(s),o(),X.current===l&&(X.current=null))},u=t=>{if(a!==Y.current||!J.current){l();return}if(l(),R(null),t.payload.error||!t.payload.memory){C(t.payload.error??`The server returned no memory record.`);return}let n=t.payload.memory;v(e=>{let t=e.filter(e=>e.id!==n.id);return[n,...t]}),D(n.id),F(!1),M(!1),T(e(i===`create`?`activity:memoryManager.memoryCaptured`:`activity:memoryManager.memoryUpdated`)),Q()};o=n===`memory.sage.remember`?t.on(`memory.sage.remember`,u):t.on(`memory.sage.update`,u),s=setTimeout(()=>{a!==Y.current||!J.current||(l(),R(null),C(e(`activity:memoryManager.mutationTimeout`,{verb:e(i===`create`?`activity:memoryManager.createAction`:`common:action.save`)})))},2e4),X.current=l,r()},[t,I.text,Q,e]),gt=(0,W.useCallback)(()=>{ht(`memory.sage.remember`,()=>r({text:I.text.trim(),kind:I.kind,scope:I.scope,tags:U(I.tags),importance:I.importance,confidence:I.confidence,freshness:I.freshness,anchors:ye(I.anchors),...U(I.audienceRoles).length||U(I.audienceTaskTypes).length||U(I.audienceModes).length?{audience:{roles:U(I.audienceRoles),taskTypes:U(I.audienceTaskTypes),modes:U(I.audienceModes)}}:{},supersedes:U(I.supersedes),contradicts:U(I.contradicts)},{echoToChat:!1}),`create`)},[I,r,ht]),_t=(0,W.useCallback)(()=>{Z&&ht(`memory.sage.update`,()=>i(Z.id,{text:I.text.trim(),kind:I.kind,status:I.status,tags:U(I.tags),importance:I.importance,confidence:I.confidence,freshness:I.freshness,anchors:ye(I.anchors),...U(I.audienceRoles).length||U(I.audienceTaskTypes).length||U(I.audienceModes).length?{audience:{roles:U(I.audienceRoles),taskTypes:U(I.audienceTaskTypes),modes:U(I.audienceModes)}}:{},supersedes:U(I.supersedes),contradicts:U(I.contradicts)},{echoToChat:!1}),`update`)},[I,ht,Z,i]),vt=(0,W.useCallback)(()=>{if(!z)return;let e=++Y.current;X.current?.(),R(`delete`),C(null);let n=()=>{},r=null,i=!1,o=()=>{i||(i=!0,r!==null&&clearTimeout(r),n(),X.current===o&&(X.current=null))};n=t.on(`memory.sage.delete`,t=>{if(e!==Y.current||!J.current){o();return}if(o(),R(null),!t.payload.success){C(t.payload.message||`Delete failed.`);return}B(null),D(null),M(!1),T(`Memory deleted and relationship edges cleaned up.`),Q()}),r=setTimeout(()=>{e!==Y.current||!J.current||(o(),R(null),C(`Delete timed out. The memory may still exist; refresh to confirm.`))},2e4),X.current=o,a(z,`Deleted from the WebUI Memory Manager.`)},[t,a,z,Q]),yt=(0,W.useCallback)((e,n,r)=>{let i=++Y.current;X.current?.(),C(null);let a=()=>{},o=null,s=!1,c=()=>{s||(s=!0,o!==null&&clearTimeout(o),a(),X.current===c&&(X.current=null))};a=t.on(e,e=>{if(i!==Y.current||!J.current){c();return}c(),r(e.payload)}),o=setTimeout(()=>{i!==Y.current||!J.current||(c(),C(`The memory store did not respond. Check the WebSocket connection and try again.`))},2e4),X.current=c,n()},[t]),bt=(0,W.useMemo)(()=>nt(_,{searchQuery:V,statusFilter:Ee,kindFilter:H,tagFilter:K,audienceOnly:Ae}),[Ae,H,_,V,Ee,K]),xt=(0,W.useMemo)(()=>rt(_),[_]),St=(0,W.useMemo)(()=>it(Z),[Z]),Ct=(0,W.useCallback)(()=>{Te(``),De(`all`),ke(`all`),je(!1),Pe(null)},[]),wt=!!(V||Ee!==`all`||H!==`all`||K||Ae),Tt=N||!!Z,$=Ge&&!!qe;return x&&_.length===0?(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-busy":`true`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/70 bg-card/70 px-5 py-4`,children:[(0,G.jsx)(`div`,{className:`h-3 w-28 animate-pulse bg-muted`}),(0,G.jsx)(`div`,{className:`mt-3 h-7 w-56 animate-pulse bg-muted`})]}),(0,G.jsxs)(`div`,{className:`grid flex-1 gap-px bg-border/60 md:grid-cols-[minmax(300px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-px bg-background p-4`,children:Array.from({length:7},(e,t)=>(0,G.jsx)(`div`,{className:`h-24 animate-pulse border border-border/60 bg-card/45`},t))}),(0,G.jsx)(`div`,{className:`hidden bg-background p-6 md:block`,children:(0,G.jsx)(`div`,{className:`h-full animate-pulse border border-border/60 bg-card/35`})})]}),(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:e(`activity:memoryManager.loadingSageContent`)})]}):re&&_.length===0?(0,G.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background p-6`,children:(0,G.jsxs)(`div`,{className:`max-w-md border border-destructive/35 bg-card p-6 shadow-2xl`,children:[(0,G.jsx)(`span`,{className:`flex size-11 items-center justify-center border border-destructive/35 bg-destructive/10 text-destructive`,children:(0,G.jsx)(f,{className:`size-5`})}),(0,G.jsx)(`h2`,{className:`mt-4 text-lg font-bold`,children:e(`activity:memoryManager.storeUnavailable`)}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-muted-foreground`,children:re}),(0,G.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,G.jsxs)(P,{onClick:Q,children:[(0,G.jsx)(le,{className:`size-4`}),` `,e(`common:action.retry`)]}),(0,G.jsxs)(P,{variant:`outline`,onClick:()=>h(`chat`),children:[(0,G.jsx)(m,{className:`size-4`}),` `,e(`activity:memoryManager.backToChat`)]})]})]})}):(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-background`,children:[(0,G.jsxs)(`header`,{className:`relative shrink-0 overflow-hidden border-b border-border/70 bg-card/72 px-4 py-3 backdrop-blur-xl sm:px-5`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 w-1/2 bg-[radial-gradient(circle_at_right,hsl(var(--info)/0.11),transparent_68%)]`}),(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(P,{variant:`ghost`,size:`icon`,onClick:()=>h(`chat`),"aria-label":e(`activity:memoryManager.backToChat`),title:e(`activity:memoryManager.backToChat`),children:(0,G.jsx)(m,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`flex size-10 items-center justify-center border border-info/40 bg-info/10 text-info shadow-[0_0_20px_hsl(var(--info)/0.12)]`,children:(0,G.jsx)(k,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:e(`activity:memoryManager.sageHeading`)}),(0,G.jsx)(`span`,{className:`border border-success/35 bg-success/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-success`,children:e(`activity:memoryManager.projectKnowledge`)})]}),(0,G.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-[10px] text-muted-foreground sm:text-xs`,children:e(`activity:memoryManager.sageSubtitle`)})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:A(`hidden items-center gap-1.5 border px-2 py-1 font-mono text-[9px] uppercase sm:flex`,p?`border-success/30 text-success`:`border-warning/30 text-warning`),children:[(0,G.jsx)(`span`,{className:`size-1.5 bg-current`}),` `,e(p?`activity:memoryManager.liveStore`:`activity:memoryManager.reconnecting`)]}),(0,G.jsxs)(P,{variant:`outline`,size:`sm`,onClick:Q,disabled:S,"aria-label":e(`activity:memoryManager.refreshAria`),children:[(0,G.jsx)(le,{className:A(`size-3.5`,S&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common:action.refresh`)})]}),(0,G.jsxs)(P,{size:`sm`,onClick:dt,children:[(0,G.jsx)(ue,{className:`size-3.5`}),` `,e(`activity:memoryManager.newMemory`)]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,G.jsx)(Oe,{label:e(`activity:memoryManager.tabMemories`),value:y?.total??_.length,hint:`${bt.length} visible`}),(0,G.jsx)(Oe,{label:e(`activity:memoryManager.tabActive`),value:y?.byStatus.active??_.filter(e=>e.status===`active`).length,hint:`retrievable`,tone:`success`}),(0,G.jsx)(Oe,{label:e(`activity:memoryManager.tabNeedsReview`),value:(y?.byStatus.stale??0)+(y?.byStatus.contradicted??0),hint:e(`activity:memoryManager.staleConflicts`),tone:`warning`}),(0,G.jsx)(`div`,{className:`hidden sm:block`,children:(0,G.jsx)(Oe,{label:e(`activity:memoryManager.tabGraphEdges`),value:y?.edges??0,hint:`${xt.length} tags`,tone:`info`})})]}),(()=>{let e=_.filter(e=>e.audience).length;if(e===0)return null;let t=new Set;for(let e of _)if(e.audience){for(let n of e.audience.roles??[])t.add(n);for(let n of e.audience.taskTypes??[])t.add(n);for(let n of e.audience.modes??[])t.add(n)}return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/70 bg-primary/5 px-4 py-1.5`,children:[(0,G.jsx)(k,{className:`size-3.5 text-primary`}),(0,G.jsxs)(`span`,{className:`text-[11px] font-medium text-primary`,children:[e,` audience-scoped memory`,e===1?``:`ies`]}),t.size>0&&(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,[...t].sort().join(`, `),`)`]})]})})(),(w||re||ae)&&(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[w&&(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-success`,children:[(0,G.jsx)(ne,{className:`size-3.5`}),` `,w]}),re&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-warning`,children:[(0,G.jsx)(f,{className:`size-3.5`}),` `,re,` Existing content remains available.`]}),ae&&!_e&&!N&&(0,G.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,G.jsx)(f,{className:`size-3.5`}),` `,ae]})]}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(320px,0.82fr)_minmax(0,1.35fr)]`,children:[(0,G.jsxs)(`section`,{className:A(`min-h-0 border-r border-border/70 bg-card/25`,Tt?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":e(`activity:memoryManager.libraryAria`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-border/60 px-3 pt-1`,role:`tablist`,"aria-label":e(`activity:memoryManager.viewAria`),children:[(0,G.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":!q,onClick:()=>{q&&Fe(!1)},className:A(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,q?`border-transparent text-muted-foreground`:`border-primary text-foreground`),children:e(`activity:memoryManager.tabActive`)}),(0,G.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":q,onClick:()=>{q||Fe(!0)},className:A(`h-7 rounded-b-none border-b-2 px-3 text-[11px]`,q?`border-primary text-foreground`:`border-transparent text-muted-foreground`),children:[e(`activity:memoryManager.tabDeleted`),typeof He.deleted==`number`?` (${He.deleted})`:``]})]}),(0,G.jsx)(Qe,{searchQuery:V,statusFilter:Ee,kindFilter:H,audienceOnly:Ae,tagFilter:K,hasFilters:wt,allTags:xt,stats:y,onSearchChange:Te,onStatusFilterChange:De,onKindFilterChange:ke,onToggleAudienceOnly:()=>je(e=>!e),onTagFilterChange:Pe,onClearFilters:Ct}),(0,G.jsx)($e,{memoryListRef:g,memories:_,filteredMemories:bt,selectedId:E,onSelectMemory:ft,onOpenCreate:dt,onClearFilters:Ct}),Re?(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/60 p-2`,children:(0,G.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:ct,disabled:Be,className:`h-7 w-full text-[11px]`,children:Be?e(`common:action.loading`):`Load more (${_.length} loaded)`})}):null]}),(0,G.jsxs)(`section`,{className:A(`min-h-0 bg-background`,Tt?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":e(`activity:memoryManager.detailAria`),children:[_.some(e=>(e.anchors??[]).some(e=>e.type===`file`&&e.path))&&(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border/60 bg-card/30 px-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e(`activity:memoryManager.fileDrawerLabel`)}),(0,G.jsx)(`input`,{type:`text`,list:`memory-drawer-file-list`,value:qe??``,onChange:e=>{let t=e.target.value.trim()||null;t&&at.has(t)?(Je(t),Ke(!0)):Je(t||null)},placeholder:e(`activity:memoryManager.selectFilePlaceholder`),className:`min-w-0 max-w-[260px] flex-1 truncate rounded-sm border border-border/60 bg-background px-1.5 py-0.5 text-[10px] font-mono`,"aria-label":e(`activity:memoryManager.fileForDrawerAria`),"data-testid":`memory-drawer-file-select`}),(0,G.jsx)(`datalist`,{id:`memory-drawer-file-list`,children:[...at].sort().map(e=>(0,G.jsx)(`option`,{value:e},e))}),(0,G.jsxs)(P,{type:`button`,size:`sm`,variant:$?`default`:`outline`,onClick:()=>{qe&&Ke(e=>!e)},disabled:!qe,className:`h-7 shrink-0 gap-1 px-2 text-[11px]`,"aria-pressed":$,title:e($?`activity:memoryManager.hideFileDrawer`:`activity:memoryManager.showFileDrawer`),children:[$?(0,G.jsx)(u,{className:`size-3`}):(0,G.jsx)(c,{className:`size-3`}),e($?`activity:memoryManager.hideDrawer`:`activity:memoryManager.showDrawer`)]})]}),N?(0,G.jsx)(Ze,{mode:`create`,draft:I,busy:L===`create`,error:ae,onChange:be,onCancel:mt,onSubmit:gt}):Z?_e?(0,G.jsx)(Ze,{mode:`edit`,draft:I,busy:L===`update`,error:ae,onChange:be,onCancel:mt,onSubmit:_t}):$?(0,G.jsx)(Me,{filePath:qe,open:$,onClose:()=>Ke(!1),onShowMemory:e=>D(e),onAcceptDeletion:(e,t)=>{yt(`memory.sage.candidateResolve`,()=>d({candidateId:e,action:`accept`}),n=>{if(n.error){C(n.error);return}T(`Accepted hygiene review for ${t.slice(0,12)}… (candidate ${e.slice(0,12)}…).`),Q()})},onKeep:(e,t)=>{yt(`memory.sage.candidateResolve`,()=>d({candidateId:e,action:`reject`}),n=>{if(n.error){C(n.error);return}T(`Kept ${t.slice(0,12)}… (candidate ${e.slice(0,12)}… rejected).`),Q()})},onUpdate:e=>{pt(e)},onMarkPermanent:e=>{yt(`memory.sage.update`,()=>i(e,{persistence:`permanent`}),t=>{if(t.error||!t.memory){C(t.error??`The server returned no memory record.`);return}T(`Memory ${e.slice(0,12)}… promoted to permanent.`),Q()})},onRecover:e=>{yt(`memory.sage.recover`,()=>l({id:e,reason:`recovered via file drawer`}),t=>{if(t.error){C(t.error);return}T(`Recovered ${e.slice(0,12)}…`),Q()})}}):(0,G.jsx)(We,{memory:Z,allMemories:[..._,...se],relatedMemories:St,graphEdges:oe,graphLoading:ge,graphError:de,onClose:()=>D(null),onOpenMemory:ft,onEdit:pt,onDelete:()=>B(Z.id),onTagSelect:e=>{Pe(e),D(null)},onNotice:T}):(0,G.jsx)(tt,{onCapture:dt})]})]}),(0,G.jsx)(Ne,{busyAction:L,deletingId:z,memories:_,onCancel:()=>B(null),onConfirm:vt,onOpenChange:e=>{!e&&L!==`delete`&&B(null)}})]})}export{at as MemoryManager};
@@ -1,4 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$n as t,Ba as n,Bn as r,Ea as i,Fa as a,Gi as o,Gr as s,Ma as c,Mi as l,Nt as u,Oi as d,Or as f,Qn as p,Ra as m,Sr as h,Vt as g,Wn as _,Wr as v,Xn as y,Yr as b,Zn as x,_ as S,a as C,aa as w,an as T,c as E,d as D,dt as O,ea as k,ei as A,f as ee,gi as j,gr as M,h as te,i as ne,in as N,ji as P,jn as re,ka as F,ki as ie,kr as ae,l as oe,lt as se,m as ce,mt as le,o as ue,p as de,pt as I,qi as fe,r as pe,rr as me,s as L,sn as he,sr as R,u as z,ua as B,ut as ge,v as _e,vi as ve,xi as ye,xt as be,yt as V}from"./vendor-GiKfK4Iw.js";import"./i18n-BvFgJYE2.js";import{s as xe}from"./ws-client-CGEB75Dy.js";import{t as H}from"./utils-CUCQrODG.js";import{t as Se}from"./session-store-Ce4Dck2K.js";import{T as Ce,d as U,f as we,x as Te}from"./stores-BATHCuMN.js";import{r as Ee}from"./mailbox-store-CKpkM0H1.js";import{d as De}from"./markdown-sSmz-Ua_.js";import{S as Oe,_ as ke,d as Ae,f as je,g as Me,l as Ne,u as Pe}from"./index-BTRQG7C5.js";var W=e(n(),1);function Fe(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Ie(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function G(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function K(e,t){for(let n of t){let t=G(e[n]);if(t)return t}}function q(e,t){for(let n of t){let t=Ie(e[n]);if(t!==void 0)return t}}function Le(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function Re(e){return e?e.split(/\r?\n/).length:0}function ze(e){let t=0,n=0;for(let r of e.split(/\r?\n/))r.startsWith(`+++`)||r.startsWith(`---`)||(r.startsWith(`+`)&&(t+=1),r.startsWith(`-`)&&(n+=1));return t||n?{added:t,removed:n}:null}function Be(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function Ve(e){let t=e.toLowerCase().replace(/[.:/-]+/g,`_`);return/^(read|view|open_file|read_file)|file_read/.test(t)?`read`:/^(write|create|save)|file_write/.test(t)?`write`:/edit|update|patch|replace|apply_patch/.test(t)?`edit`:/bash|shell|terminal|exec|command|powershell|cmd/.test(t)?`terminal`:/fetch|browser|browse|http|url|web/.test(t)?`web`:/search|grep|find|glob|query/.test(t)?`search`:/memory|recall|remember/.test(t)?`memory`:`other`}function He(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Fe(e),n=K(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:G(t.operation),line:q(t,[`line`,`startLine`,`start_line`]),endLine:q(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=K(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:q(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:q(t,[`end_line`,`endLine`])}]:[]}function Ue(e,t){let n=e?.line??q(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??q(t,[`end_line`,`endLine`]),i=q(t,[`limit`,`line_count`,`lineCount`]);return r===void 0&&n!==void 0&&i!==void 0&&i>0&&(r=n+i-1),n!==void 0&&r!==void 0?{start:n,end:r,label:`L${n}–${r}`}:n===void 0?{}:{start:n,label:`L${n}`}}function We(e,t,n,r,i,a){let o=Ue(a,n),s=a?.filePath??K(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Le(s):void 0;if(e===`read`)return{target:s,summary:i===void 0?o.label?`${o.label} queued to read`:`Reading file`:`${i.toLocaleString()} lines read`,lineLabel:o.label};if(e===`write`){let e=K(n,[`content`,`text`,`data`]),t=q(r,[`inputLines`])??(e?Re(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=K(n,[`patch`,`diff`]),t=e?ze(e):null,i=K(n,[`old_string`,`oldString`,`search`]),a=K(n,[`new_string`,`newString`,`replacement`]),c=q(r,[`addedLines`]),l=q(r,[`removedLines`]),u=q(r,[`oldLines`]),d=q(r,[`newLines`]);return{target:s,summary:t||c!==void 0||l!==void 0?`+${t?.added??c??0} / −${t?.removed??l??0} lines`:i!==void 0||a!==void 0||u!==void 0||d!==void 0?`${i?Re(i):u??0} → ${a?Re(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=K(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Be(e),target:e}}if(e===`web`){let e=K(n,[`url`,`href`,`uri`]),t=K(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=K(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=K(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ge(e,t){let n=G(t.name)??G(t.toolName);if(n)return n;if(e.kind===`agent:tool`)return e.target??void 0;if(e.kind.startsWith(`tool:`))return e.source}function Ke(e,t,n){return G(t.agentId)??G(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function qe(e){return G(e.parentSessionId)??G(e.sessionId)}function Je(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Ye(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Fe(e.data),n=Ge(e,t);if(!n)return null;let r=Ke(e,t,n),i=t.input,a=Fe(i),o=He(t,a),s=Ie(t.outputLines),c=Ve(n),l=We(c,n,a,t,s,o[0]),u=G(t.id),d=Math.floor(e.timestamp/2e3),f=Je(e,t),p=Ie(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:G(t.agentName),sessionId:qe(t),toolName:n,kind:c,status:f,startedAt:f===`running`?e.timestamp:Math.max(0,e.timestamp-(p??0)),...f===`running`?{}:{completedAt:e.timestamp},durationMs:p,target:l.target,summary:l.summary,lineLabel:l.lineLabel,outputLines:s,outputBytes:Ie(t.outputBytes),outputTokens:Ie(t.outputTokens),input:i,output:G(t.output),fileTargets:o,raw:e.raw??t}}function Xe(e,t,n){return e?.length?tt(e.map(e=>({id:`snapshot:${n??`session`}:${t}:${e.id}`,kind:`tool:executed`,timestamp:e.completedAt,source:t,target:e.name,label:e.name,data:{...e,agentId:t,sessionId:n},flowGroup:`agent:${t}`})),t,n):[]}function Ze(e){return e?.length?e.map(e=>({id:e.id,direction:e.direction,from:e.from,to:e.to,type:e.type,subject:e.subject,body:``,priority:`normal`,timestamp:new Date(e.at).toISOString(),timestampMs:e.at,unread:e.direction===`incoming`})).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12):[]}function Qe(e,t,n=3e4){let r=new Map;e.forEach((e,t)=>{for(let n of[e.agent.serverId,e.agent.mailboxId,e.agent.name]){let e=J(n);e&&!r.has(e)&&r.set(e,t)}});let i=new Set,a=[];for(let o of e){let e=o.mail[0];if(!e||i.has(e.id)||t-e.timestampMs>n)continue;let s=r.get(J(e.from)),c=r.get(J(e.to));s===void 0||c===void 0||s===c||(i.add(e.id),a.push({id:e.id,mail:e,fromIndex:s,toIndex:c}))}return a}function $e(e,t){return e.toLowerCase()===t.toLowerCase()}function J(e){return e?.trim().toLowerCase()??``}function et(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(J).filter(e=>e.length>0)),i=n?`@session:${J(n)}`:``,a=J(t.role),o=J(t.serverId)===`leader`||J(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=J(e.from),n=J(e.to),a=r.has(t),s=n===`*`||n===`all`||i.length>0&&n===i,c=(e.audience!==`leaders`||o)&&(r.has(n)||o&&s);if(!c&&!a)return[];let l=Date.parse(e.timestamp);return[{...e,direction:c?`incoming`:`outgoing`,timestampMs:Number.isFinite(l)?l:0,unread:c&&!Object.keys(e.readBy??{}).some(e=>r.has(J(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function tt(e,t,n){let r=new Map;for(let i=e.length-1;i>=0;--i){let a=e[i];if(!a)continue;let o=Ye(a);if(!o||!$e(o.agentId,t)||n&&o.sessionId&&o.sessionId!==n)continue;let s=r.get(o.id);r.set(o.id,s?{...s,...o,startedAt:Math.min(s.startedAt,o.startedAt),fileTargets:o.fileTargets.length>0?o.fileTargets:s.fileTargets,input:o.input??s.input,output:o.output??s.output,raw:o.raw??s.raw}:o)}let i=[...r.values()].sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt));return i.filter((e,t)=>e.input!==void 0||e.fileTargets.length>0||e.output!==void 0||!i.some((n,r)=>r!==t&&n.toolName===e.toolName&&(n.input!==void 0||n.fileTargets.length>0||n.output!==void 0)&&Math.abs((n.completedAt??n.startedAt)-(e.completedAt??e.startedAt))<2500))}function nt(e,t,n){let r=Ve(t),i={read:`Reading a file`,write:`Writing a file`,edit:`Updating code`,terminal:`Running a command`,web:`Working online`,search:`Searching project`,memory:`Checking memory`,other:t};return{id:`${e}:live:${t}`,agentId:e,sessionId:n,toolName:t,kind:r,status:`running`,startedAt:Date.now(),summary:i[r],fileTargets:[]}}var Y=se(),rt={read:T,write:A,edit:A,terminal:g,web:j,search:v,memory:x,other:d};function it(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function at(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function ot(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function X({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`strong`,{children:t})]})}function st({selected:e,onClose:t}){let{t:n}=a(),{call:r,agentName:i}=e,o=rt[r.kind],s=ot(r.input),c=ot(r.output);return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:H(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,Y.jsx)(o,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,Y.jsx)(`h2`,{children:r.toolName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeDetails`),children:(0,Y.jsx)(O,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,Y.jsx)(`strong`,{children:r.summary}),(0,Y.jsx)(`span`,{children:r.status})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.agent`),value:i}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,Y.jsx)(X,{label:n(`activity:agentOffice.duration`),value:at(r.durationMs)}),r.sessionId&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.session`),value:it(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,Y.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,Y.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,Y.jsx)(b,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,Y.jsxs)(`strong`,{children:[`L`,e.line??1,e.endLine?`–${e.endLine}`:``]})]},`${e.filePath}:${t}`))]}),(r.outputLines!==void 0||r.outputBytes!==void 0||r.outputTokens!==void 0)&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,Y.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),s&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:s})})]}),c&&(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,Y.jsx)(`pre`,{children:(0,Y.jsx)(`code`,{children:c})})]})]})}function ct({selected:e,onClose:n}){let{t:r}=a(),{mail:i,agentName:o}=e;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,Y.jsx)(t,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,Y.jsx)(`h2`,{children:i.subject})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,"aria-label":r(`activity:agentOffice.closeMailDetails`),children:(0,Y.jsx)(O,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,Y.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,Y.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(me,{className:`h-3 w-3`}),` `,r(`activity:mailbox.audienceLeaders`)]})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:r(`activity:mailbox.messages`)}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.agent`),value:o}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.priority`),value:i.priority}),(0,Y.jsx)(X,{label:r(`activity:agentOffice.route`),value:`${i.from} → ${i.to}`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:i.subject}),(0,Y.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function lt({selected:e,onClose:t}){let{t:n}=a();return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,Y.jsx)(R,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`h2`,{children:e.agentName})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeTaskDetails`),children:(0,Y.jsx)(O,{})})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,Y.jsx)(X,{label:`ID`,value:e.taskId}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function ut({selected:e,onClose:t}){let{t:n}=a(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,Y.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,Y.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,Y.jsx)(y,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,Y.jsx)(`h2`,{children:e.officeLabel})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:t,"aria-label":n(`activity:agentOffice.closeOfficeBriefing`),children:(0,Y.jsx)(O,{})})]}),(0,Y.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,Y.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,Y.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,Y.jsx)(X,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,Y.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,Y.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,Y.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,Y.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,Y.jsxs)(`div`,{className:H(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:e.content}),(0,Y.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function dt({selected:e,onClose:t}){return e.kind===`tool`?(0,Y.jsx)(st,{selected:e,onClose:t}):e.kind===`mail`?(0,Y.jsx)(ct,{selected:e,onClose:t}):e.kind===`task`?(0,Y.jsx)(lt,{selected:e,onClose:t}):(0,Y.jsx)(ut,{selected:e,onClose:t})}function ft(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function pt(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function mt(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function ht(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function gt(e,t=56){if(!e)return;let n=e.replace(/\s+/g,` `).trim();if(n)return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1).trimEnd()}…`}function _t(e,t){if(e.length===0)return{positions:new Map,columns:0,rows:0,columnWidth:380};let n=Math.max(1,...e.map(e=>e.agentCount)),r=Math.max(380,Math.min(3,n)*190+80),i=e=>270+Math.max(1,...e.map(e=>Math.ceil(Math.max(1,e.agentCount)/3)))*150,a=Math.max(320,t.width),o=Math.max(240,t.height),s=1,c=-1/0,l=1/0;for(let t=1;t<=e.length;t+=1){let n=[];for(let r=0;r<e.length;r+=t)n.push(i(e.slice(r,r+t)));let u=n.length,d=Math.max(660,Math.min(t,e.length)*r),f=320+n.reduce((e,t)=>e+t,0)+Math.max(0,u-1)*100,p=Math.min(a/d,o/f),m=Math.abs(Math.log(d/f/(a/o)));(p>c+1e-9||Math.abs(p-c)<=1e-9&&m<l)&&(s=t,c=p,l=m)}let u=new Map,d=370;for(let t=0;t<e.length;t+=s){let n=e.slice(t,t+s);n.forEach((e,t)=>{u.set(e.id,{x:600+(t-(n.length-1)/2)*r,y:d})}),d+=i(n)+100}return{positions:u,columns:s,rows:Math.ceil(e.length/s),columnWidth:r}}function vt(e,t,n,r=640){let i=Math.min(3,n),a=Math.floor(t/i),o=t%i;return{x:e-(Math.min(i,n-a*i)-1)*190/2+o*190,y:r+a*150}}function yt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function bt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function xt(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function St(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function Ct(e){let t=St(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function wt(e,t){let n=St(t);if(n)return e.find(e=>St(e.sessionId)===n)}function Tt(e,t){let n=xt(t.status);return{officeId:`${e}__agent-${t.id}`,serverId:t.id,name:t.name??t.id,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTool:t.currentTool,currentTask:t.description,taskId:t.taskId,presenceSource:`fleet`}}function Et(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:bt(t)}function Dt(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=yt(n.clientType),r=Et(n.clientType,e),i=`client-${n.pid??n.sessionId}`,s=[],c=!1;for(let e of n.agents){a.add(e.id);let n=t.get(e.id),r=xt(n?.status??e.status);(r===`active`||r===`streaming`)&&(c=!0),s.push({officeId:`${i}__agent-${e.id}`,serverId:e.id,name:n?.name??e.name??e.id,status:r,iteration:n?.iteration??e.iterations??0,toolCalls:n?.toolCalls??e.toolCalls??0,costUsd:n?.costUsd??e.costUsd??0,tokensIn:n?.tokensIn??e.tokensIn??0,tokensOut:n?.tokensOut??e.tokensOut??0,ctxPct:n?.ctxPct??e.ctxPct,model:n?.model??e.model,lastActivityAt:e.lastActivityAt,currentTool:n?.currentTool??e.currentTool,currentTask:e.currentTask??n?.description,taskId:e.taskId??n?.taskId,recentTools:e.recentTools,recentMail:e.recentMail,activity:e.activity,presenceSource:`registry`})}let l=n.status===`closing`||n.status===`stale`||n.status===`lost`?`offline`:c?`active`:`idle`,u=n.agents.find(e=>e.id===`leader`);o.push({id:i,type:e,label:`${r} · ${n.pid?`PID ${n.pid}`:Ct(n.sessionId)}`,sublabel:[`session ${Ct(n.sessionId)}`,n.gitBranch?`⎇ ${n.gitBranch}`:``,n.workingDir?n.workingDir.split(/[\\/]/).filter(Boolean).pop():``].filter(Boolean).join(` · `),status:l,sessionId:n.sessionId,pid:n.pid,branch:n.gitBranch,workingDir:n.workingDir,startedAt:n.startedAt,lastHeartbeatAt:n.lastHeartbeatAt,latestPrompt:u?.latestPrompt,latestPromptAt:u?.latestPromptAt,activeInstruction:u?.status===`running`||u?.status===`streaming`?u.latestPrompt??u.currentTask:void 0,todos:u?.todos,agents:s})}for(let e of n.filter(e=>e.online)){let t=wt(o,e.sessionId);if(!t)continue;let n=e.name.trim().toLowerCase(),r=t.agents.find(t=>t.serverId===e.agentId||t.name.trim().toLowerCase()===n);r&&(a.add(e.agentId),r.mailboxId=e.agentId,r.role=e.role,r.currentTask=r.currentTask??e.currentTask,r.currentTool=r.currentTool??e.currentTool)}let s=[...t.values()].filter(e=>!a.has(e.id)),c,l=()=>{if(c)return c;let e=o.find(e=>e.type===`webui`);return e?(c=e,e):(c={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},o.push(c),c)};for(let e of s){let t=wt(o,e.sessionId)??l(),n=Tt(t.id,e);(n.status===`active`||n.status===`streaming`)&&t.status!==`offline`&&(t.status=`active`),t.agents.push(n),a.add(e.id)}for(let[e,t]of r){if(a.has(e)||i-t.finishedAt>9e5)continue;let n=wt(o,t.agent.sessionId);n&&n.agents.push(Tt(n.id,t.agent))}return o.length===0&&o.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),o}function Ot(e){return e.startsWith(`tool`)?`hsl(var(--warning))`:e.startsWith(`mailbox`)?`hsl(var(--info))`:e.startsWith(`provider`)?`hsl(var(--primary))`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`hsl(var(--success))`:e.includes(`error`)?`hsl(var(--destructive))`:`hsl(var(--primary))`}var kt=new Set([`completed`,`failed`,`timeout`,`stopped`]);function At(e){let t=(0,W.useRef)(new Map).current;return(0,W.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),kt.has(i.status)){let e=t.get(i.id);e?e.agent=i:t.set(i.id,{agent:i,finishedAt:i.completedAt??n})}else t.delete(i.id);for(let[e,n]of[...t.entries()])!r.has(e)&&!kt.has(n.agent.status)&&t.set(e,{agent:{...n.agent,status:`stopped`},finishedAt:n.finishedAt});for(let[e,r]of t)n-r.finishedAt>9e5&&t.delete(e);return{map:t,now:n}},[e,t])}var jt=[`bot`,`cactus`,`duck`,`radio`],Mt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Nt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Pt={read:T,write:A,edit:A,terminal:g,web:j,search:v,memory:x,other:d},Ft={leader:w,builder:d,researcher:T,reviewer:k,planner:R,operator:g};function It(e){if(e.serverId===`leader`||e.serverId.startsWith(`leader@`))return`leader`;let t=[e.role,e.name,e.currentTask].filter(Boolean).join(` `).toLowerCase();return/review|critic|audit|security|test|qa|verify|checker/.test(t)?`reviewer`:/research|analyst|explor|investig|search|hunter|recon/.test(t)?`researcher`:/plan|architect|design|coordinat|strateg|spec/.test(t)?`planner`:/build|implement|code|develop|engineer|refactor|fix|frontend|backend/.test(t)?`builder`:`operator`}function Lt(e,t){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);let r=n>>>0;return{palette:Mt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Nt[t],motion:Math.floor(r/31)%4,charm:jt[Math.floor(r/47)%jt.length]}}function Rt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function zt(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function Bt(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function Vt(e,t){if(!e)return`—`;let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function Ht(e){let t=new Set,n=new Set,r=new Set,i=0,a=0,o={files:0,reads:0,writes:0,edits:0,linesAdded:0,linesRemoved:0,terminalCalls:0,incomingMail:0,outgoingMail:0};for(let s of e){let e=s.agent.activity;for(let n of e?.filesTouched??[])t.add(n);o.reads+=e?.reads??0,o.writes+=e?.writes??0,o.edits+=e?.edits??0,o.linesAdded+=e?.linesAdded??0,o.linesRemoved+=e?.linesRemoved??0,o.terminalCalls+=e?.terminalCalls??0,i+=e?.mailReceived??0,a+=e?.mailSent??0;for(let e of s.mail)(e.direction===`incoming`?n:r).add(e.id)}return o.files=t.size,o.incomingMail=Math.max(i,n.size),o.outgoingMail=Math.max(a,r.size),o}function Ut(e,t,n){return n.map((n,r)=>({...nt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:Ve(n.name),status:n.ok?`succeeded`:`failed`,startedAt:Math.max(0,n.at-n.durationMs),completedAt:n.at,durationMs:n.durationMs,summary:n.ok?`${n.name} completed`:`${n.name} failed`}))}function Wt(...e){let t=[];for(let n of e.flat()){let e=n.completedAt??n.startedAt;t.some(t=>(t.id===n.id||t.toolName===n.toolName)&&Math.abs((t.completedAt??t.startedAt)-e)<2500)||t.push(n)}return t.sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt))}function Gt(...e){let t=new Map;for(let n of e.flat())t.set(n.id,n);return[...t.values()].sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12)}function Kt({kind:e,active:t}){let n=Pt[e];return(0,Y.jsxs)(`span`,{className:H(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,Y.jsx)(b,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,Y.jsx)(n,{"aria-hidden":`true`})]})}function qt({active:e,failed:t,role:n,variant:r,motion:i}){let a=Ft[n];return(0,Y.jsxs)(`div`,{className:H(`agent-office__avatar`,`is-${n}`,`is-avatar-${r}`,`is-motion-${i}`,e&&`is-active`,!e&&!t&&`is-idle`,t&&`is-failed`),"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,Y.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,Y.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,Y.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,Y.jsx)(a,{})})]})}function Jt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,Y.jsx)(Kt,{kind:e.kind,active:r}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,Y.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,Y.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,Y.jsx)(`span`,{className:`agent-office__parcel-target`,children:zt(e.target)}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,Y.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,Y.jsx)(O,{}):(0,Y.jsx)(k,{})})]})}function Yt({mail:e,compact:n=!1,onSelect:r}){let i=e.direction===`incoming`;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__mail-parcel`,n&&`is-compact`,i?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:r,"aria-label":`${i?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,Y.jsx)(`span`,{className:`agent-office__mail-icon`,children:i?(0,Y.jsx)(h,{"aria-hidden":`true`}):(0,Y.jsx)(N,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:i?`${e.from} →`:`→ ${e.to}`}),(0,Y.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,Y.jsx)(t,{"aria-hidden":`true`})]})}function Xt({office:e,now:n}){let{t:r}=a(),{client:i,agents:o,stats:c}=e,u=i.lastHeartbeatAt?Date.parse(i.lastHeartbeatAt):NaN,d=Number.isFinite(u)&&n-u<2e4,f=Number.isFinite(u)&&!d,p=o.some(({agent:e})=>e.presenceSource===`registry`),m=d?`VERIFIED`:f?`DELAYED`:p?`REGISTRY`:`LOCAL`,h=o.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),_=o.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,Y.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,Y.jsx)(w,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,Y.jsx)(`strong`,{children:i.label}),(0,Y.jsx)(`span`,{children:i.sublabel||i.sessionId})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,Y.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[o.length,` `,r(`activity:agentOffice.agents`)]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__presence-chip`,!f&&`is-live`,f&&`is-legacy`),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),` `,m]}),(0,Y.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,Y.jsx)(l,{"aria-hidden":`true`}),` `,Vt(i.startedAt,n),` UP`]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__presence-chip`,_?`is-legacy`:h&&`is-telemetry`),children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),_?`RECONNECT`:h?`TOOLS LIVE`:`READY`]})]})]}),(0,Y.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":r(`activity:agentOffice.sessionActivityTotals`),children:[(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.uniqueFilesTouched`),children:[(0,Y.jsx)(s,{}),` `,(0,Y.jsx)(`strong`,{children:c.files}),` `,r(`activity:agentOffice.files`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.fileReads`),children:[(0,Y.jsx)(T,{}),` `,(0,Y.jsx)(`strong`,{children:c.reads}),` `,r(`activity:agentOffice.read`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.filesWritten`),children:[(0,Y.jsx)(A,{}),` `,(0,Y.jsx)(`strong`,{children:c.writes}),` `,r(`activity:agentOffice.write`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.filesEdited`),children:[(0,Y.jsx)(A,{}),` `,(0,Y.jsx)(`strong`,{children:c.edits}),` `,r(`activity:agentOffice.edit`)]}),(0,Y.jsxs)(`span`,{className:`agent-office__client-delta`,title:r(`activity:agentOffice.linesAddedAndRemoved`),children:[(0,Y.jsxs)(`strong`,{children:[`+`,c.linesAdded]}),` / `,(0,Y.jsxs)(`b`,{children:[`−`,c.linesRemoved]})]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.terminalCommands`),children:[(0,Y.jsx)(g,{}),` `,(0,Y.jsx)(`strong`,{children:c.terminalCalls}),` `,r(`activity:agentOffice.term`)]}),(0,Y.jsxs)(`span`,{title:r(`activity:agentOffice.incomingAndOutgoingMail`),children:[(0,Y.jsx)(t,{}),` `,(0,Y.jsx)(`strong`,{children:c.incomingMail}),`↓ `,(0,Y.jsx)(`strong`,{children:c.outgoingMail}),`↑`]})]})]})}function Zt({office:e,now:t,onSelect:n}){let{t:r}=a(),{client:i}=e,s=i.todos!==void 0,c=i.todos??[],l=c.filter(e=>e.status!==`completed`),u=c.length-l.length,d=!!i.activeInstruction,f=i.activeInstruction??i.latestPrompt,p=i.latestPromptAt!==void 0&&t-i.latestPromptAt<3e4,m=()=>n({kind:`briefing`,officeLabel:i.label,prompt:f,promptAt:i.latestPromptAt,instructionActive:d,telemetryConnected:s,todos:c});return(0,Y.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":r(`activity:agentOffice.officeBriefing`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__prompt-card`,d&&`is-active`,p&&`is-fresh`,!s&&`is-waiting`),onClick:m,children:[(0,Y.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,Y.jsx)(y,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,Y.jsx)(`span`,{children:r(d?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,Y.jsx)(`strong`,{children:f??r(s?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),d&&(0,Y.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.live`)]}),i.latestPromptAt!==void 0&&(0,Y.jsx)(`time`,{dateTime:new Date(i.latestPromptAt).toISOString(),children:Bt(i.latestPromptAt,t)})]}),(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__todo-board`,l.length>0&&`has-active`,!s&&`is-waiting`),onClick:m,children:[(0,Y.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),` `,r(`activity:agentOffice.activeTodos`)]}),(0,Y.jsx)(`strong`,{children:s?r(`activity:agentOffice.todoProgress`,{done:u,total:c.length}):r(`activity:agentOffice.syncWaiting`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[s?l.length>0?l.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:H(`agent-office__todo-line`,`is-${e.status}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,Y.jsx)(o,{"aria-hidden":`true`}),c.length>0?r(`activity:agentOffice.allTodosDone`):r(`activity:agentOffice.noActiveTodos`)]}):(0,Y.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),r(`activity:agentOffice.todoTelemetryWaiting`)]}),l.length>3&&(0,Y.jsx)(`span`,{className:`agent-office__todo-more`,children:r(`activity:agentOffice.moreTodos`,{count:l.length-3})})]})]})]})}function Qt({active:e}){let{t}=a();return(0,Y.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,Y.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,Y.jsx)(B,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,Y.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,Y.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function $t({model:e,now:n,onSelect:r,routedMailIds:i}){let{t:o}=a(),{agent:s,client:c,current:l,display:u,history:f,mail:p}=e,m=s.status===`active`||s.status===`streaming`,h=s.status===`error`,g=p[0],_=It(s),v=Lt(`${c.sessionId}:${s.serverId}:${s.name}`,_),y=g&&n-g.timestampMs<3e4&&!i?.has(g.id),b=f.slice(0,6),x=b[0]?.completedAt??b[0]?.startedAt??u?.completedAt??u?.startedAt,S=l?`is-tool-${l.kind}`:void 0;return(0,Y.jsxs)(`article`,{className:H(`agent-office__lane`,`is-desk-${v.palette}`,`is-layout-${v.layout}`,`is-clutter-${v.clutter}`,m&&`is-active`,h&&`is-failed`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,Y.jsx)(`span`,{className:H(`agent-office__status-dot`,m&&`is-active`,h&&`is-failed`)}),(0,Y.jsx)(`strong`,{title:s.name,children:s.name}),(0,Y.jsxs)(`span`,{className:`agent-office__agent-verified`,title:s.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,Y.jsx)(k,{"aria-hidden":`true`}),s.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,Y.jsx)(`span`,{className:`agent-office__role`,children:s.role??(s.serverId===`leader`||s.serverId.startsWith(`leader@`)?o(`activity:agentOffice.leadAgent`):o(`activity:agentOffice.agent`))}),(0,Y.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,Y.jsx)(`span`,{children:c.branch?`⎇ ${c.branch}`:c.type.toUpperCase()}),(0,Y.jsx)(`span`,{children:o(`activity:agentOffice.callsCount`,{count:s.toolCalls})}),s.model&&(0,Y.jsx)(`span`,{className:`agent-office__model-chip`,title:s.model,children:Rt(s.model)})]}),s.currentTask&&(0,Y.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>r({kind:`task`,task:s.currentTask??``,taskId:s.taskId,agentName:s.name}),children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:s.currentTask})]})]}),!s.currentTask&&m&&(0,Y.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,Y.jsx)(F,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`small`,{children:c.todos===void 0?o(`activity:agentOffice.telemetryWaiting`):o(`activity:agentOffice.taskNotReported`)})]})]}),g&&(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__identity-mail`,g.unread&&`is-unread`),onClick:()=>r({kind:`mail`,mail:g,agentName:s.name}),"aria-label":`${p.length} mail messages. Latest: ${g.subject}`,children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsxs)(`strong`,{children:[p.length,` MAIL`]}),(0,Y.jsx)(`small`,{children:g.subject})]})]})]}),(0,Y.jsxs)(`div`,{className:H(`agent-office__scene`,S),children:[(0,Y.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,Y.jsx)(qt,{active:m,failed:h,role:_,variant:v.avatar,motion:v.motion}),(0,Y.jsx)(`span`,{className:`agent-office__monitor`,children:u?(0,Y.jsx)(Kt,{kind:u.kind,active:l!==void 0}):(0,Y.jsx)(d,{})}),(0,Y.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsx)(`span`,{className:`agent-office__desk`}),(0,Y.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,Y.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__desk-charm`,`is-${v.charm}`),children:[(0,Y.jsx)(`i`,{}),(0,Y.jsx)(`b`,{})]}),(0,Y.jsxs)(`span`,{className:H(`agent-office__mug`,`is-${_}`),children:[(0,Y.jsx)(`i`,{"aria-hidden":`true`}),(0,Y.jsx)(`b`,{"aria-hidden":`true`})]})]}),y&&(0,Y.jsx)(`div`,{className:H(`agent-office__mail-flyby`,`is-${g.direction}`),children:(0,Y.jsx)(Yt,{mail:g,compact:!0,onSelect:()=>r({kind:`mail`,mail:g,agentName:s.name})},g.id)}),(0,Y.jsxs)(`div`,{className:H(`agent-office__conveyor`,l&&`is-moving`),children:[(0,Y.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`agent-office__current-action`,children:u?(0,Y.jsx)(Jt,{call:u,onSelect:()=>r({kind:`tool`,call:u,agentName:s.name})},u.id):(0,Y.jsx)(Qt,{active:m})})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__history`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,Y.jsx)(`span`,{children:o(`activity:agentOffice.recent`)}),x!==void 0&&(0,Y.jsx)(`span`,{children:Bt(x,n)})]}),(0,Y.jsx)(`div`,{className:`agent-office__history-list`,children:b.length>0?b.map(e=>(0,Y.jsx)(Jt,{call:e,compact:!0,onSelect:()=>r({kind:`tool`,call:e,agentName:s.name})},`tool:${e.id}`)):(0,Y.jsx)(`span`,{className:`agent-office__history-empty`,children:s.toolCalls>0&&s.recentTools===void 0&&s.activity===void 0?o(`activity:agentOffice.telemetryReconnect`):o(`activity:agentOffice.noCalls`)})})]})]})}function en(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function tn({agents:e,now:n,onSelect:r}){let{t:i}=a();return(0,Y.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":i(`activity:agentOffice.breakRoom`),children:[(0,Y.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,Y.jsx)(ie,{"aria-hidden":`true`}),(0,Y.jsx)(`strong`,{children:i(`activity:agentOffice.breakRoom`)}),(0,Y.jsx)(`span`,{children:i(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,Y.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:a,history:o,mail:s}=e,c=It(a),l=Ft[c],u=s.filter(e=>e.unread).length,d=o[0]?.completedAt??o[0]?.startedAt,f=s[0],p=()=>{a.currentTask?r({kind:`task`,task:a.currentTask,taskId:a.taskId,agentName:a.name}):f&&r({kind:`mail`,mail:f,agentName:a.name})},m=!!a.currentTask||!!f;return(0,Y.jsxs)(`button`,{type:`button`,className:H(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,Y.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,Y.jsx)(l,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,Y.jsx)(`strong`,{children:a.name}),(0,Y.jsx)(`small`,{children:a.role??i(`activity:agentOffice.agent`)})]}),(0,Y.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,Y.jsx)(`span`,{children:Bt(d,n)}),u>0&&(0,Y.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function nn(){let{t:e}=a(),n=we(e=>e.liveSessions),r=we(e=>e.aggregate),i=Ce(e=>e.agents),o=Ee(e=>e.agents),s=Ee(e=>e.messages),c=xe(e=>e.toolEvents),u=Se(e=>e.projectName),d=At(i),[f,p]=(0,W.useState)(null),m=(0,W.useMemo)(()=>Dt(n,i,o,d.map,d.now),[n,i,o,d]),h=(0,W.useMemo)(()=>m.flatMap(e=>e.agents.map(t=>{let n=Wt(tt(c,t.serverId,e.sessionId),Xe(t.recentTools,t.serverId,e.sessionId),Ut(t,e,i.get(t.serverId)?.toolLog??[])),r=t.status===`active`||t.status===`streaming`,a=n.find(e=>e.status===`running`);!a&&r&&t.currentTool&&(a=nt(t.serverId,t.currentTool,e.sessionId));let o=a??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Gt(Ze(t.recentMail),et(s,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:a,display:o,history:l,mail:u}})),[m,i,s,c]),g=(0,W.useMemo)(()=>m.map(e=>{let t=h.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ht(t)}}).filter(e=>e.agents.length>0),[m,h]),_=h.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,v=u||n.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),y=Date.now();return(0,Y.jsxs)(`div`,{className:`agent-office`,children:[(0,Y.jsxs)(`header`,{className:`agent-office__header`,children:[(0,Y.jsxs)(`div`,{className:`agent-office__title`,children:[(0,Y.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,Y.jsx)(w,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,Y.jsx)(`h1`,{children:v})]})]}),(0,Y.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,Y.jsx)(`span`,{}),` `,e(`activity:agentOffice.live`)]}),(0,Y.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(B,{}),(0,Y.jsx)(`strong`,{children:h.length}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(ge,{}),(0,Y.jsx)(`strong`,{children:_}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(F,{}),(0,Y.jsx)(`strong`,{children:r.toolCalls.toLocaleString()}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,Y.jsx)(`main`,{className:`agent-office__floor`,children:h.length>0?g.map(n=>{let r=n.agents.filter(en),i=n.agents.filter(e=>!en(e)),a=Qe(r,y),o=new Set(a.map(e=>e.id));return(0,Y.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,Y.jsx)(Xt,{office:n,now:y}),(0,Y.jsx)(Zt,{office:n,now:y,onSelect:p}),r.length>0&&(0,Y.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,Y.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,Y.jsxs)(`div`,{className:`agent-office__client-desks`,children:[r.map(e=>(0,Y.jsx)($t,{model:e,now:y,onSelect:p,routedMailIds:o},e.key)),a.length>0&&(0,Y.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:a.map(e=>(0,Y.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/r.length*100}%`,"--to":`${(e.toIndex+.5)/r.length*100}%`},children:(0,Y.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,Y.jsx)(t,{"aria-hidden":`true`})})},e.id))}),r.length===0&&(0,Y.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,Y.jsx)(ie,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),i.length>0&&(0,Y.jsx)(tn,{agents:i,now:y,onSelect:p})]},n.client.id)}):(0,Y.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(I,{"aria-hidden":`true`})}),(0,Y.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,Y.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,Y.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(ae,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:n.length})]}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(l,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),f&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>p(null),"aria-label":e(`activity:agentOffice.closeToolDetails`)}),(0,Y.jsx)(dt,{selected:f,onClose:()=>p(null)})]})]})}function rn(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var an={user:{Icon:be,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-transparent`,bubbleBorder:`border-primary/40`,textColor:`text-foreground`},assistant:{Icon:B,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:u,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:B,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:fe,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function on({entry:e}){let{t}=a();return e.role===`error`?(0,Y.jsx)(Ae,{text:e.text}):e.role===`tool`?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,Y.jsx)(u,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,Y.jsx)(P,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),rn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,Y.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,Y.jsx)(Ne,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.output}):(0,Y.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.text})}):null,e.isError&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,Y.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,Y.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,Y.jsx)(Pe,{remarkPlugins:[De],rehypePlugins:ke,components:Me,children:e.text})})}function sn({entry:e,isContinuation:t=!1}){let{t:n}=a(),r=an[e.role],i=r.Icon;return(0,Y.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,Y.jsx)(`div`,{className:H(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,Y.jsx)(i,{className:`h-4 w-4`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:H(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,rn(e.durationMs)]})]}),(0,Y.jsx)(`div`,{className:H(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,Y.jsx)(`div`,{className:H(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,Y.jsx)(on,{entry:e})})}),e.text&&e.role!==`error`&&(0,Y.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(je,{text:e.text,label:n(`common:action.copy`)})})]})]})}var cn=[`steer`,`ask`,`assign`,`note`],ln=2500;function un({sessionId:e,limit:t=200}){let[n,r]=(0,W.useState)(null),{t:i}=a(),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[h,g]=(0,W.useState)(`steer`),[_,v]=(0,W.useState)(`high`),[y,b]=(0,W.useState)([]),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),w=(0,W.useRef)(!0),T=(0,W.useRef)(!0),E=we(e=>e.liveSessions),D=(0,W.useMemo)(()=>E.find(t=>t.sessionId===e),[E,e]),O=(0,W.useMemo)(()=>{let e=D;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[D]),k=D?.status===`active`||(D?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),A=(0,W.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[D,i]),ee=(0,W.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??D.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[D,i]),j=(0,W.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();T.current&&(r(i),s(null))}catch(e){T.current&&s(e instanceof Error?e.message:String(e))}},[e,t]),M=(0,W.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();T.current&&Array.isArray(n.thread)&&b(n.thread)}catch{}},[e]);(0,W.useEffect)(()=>{T.current=!0,r(null),s(null),b([]),j(),M();let e=setInterval(()=>{document.hidden||(j(),M())},ln);return()=>{T.current=!1,clearInterval(e)}},[j,M]),(0,W.useEffect)(()=>{O&&j()},[O,j]),(0,W.useEffect)(()=>{w.current&&C.current&&(C.current.scrollTop=C.current.scrollHeight)},[n,ee]);let te=()=>{let e=C.current;e&&(w.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},ne=async()=>{let t=c.trim();if(!(!t||u)){d(!0),p(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:h,priority:_})});if(!n.ok)throw Error(`HTTP ${n.status}`);l(``),p(k?m.t(`activity:sessionWatch.sentRunning`):m.t(`activity:sessionWatch.sentIdle`)),M()}catch(e){p(m.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{d(!1)}}},N=async()=>{if(!x){S(!0),p(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:m.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);p(m.t(`activity:sessionWatch.interruptSent`)),M()}catch(e){p(m.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}}},P=n?.entries??[];return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:H(`h-1.5 w-1.5 rounded-full`,k?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),k&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:x,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(x?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),A&&(0,Y.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,A]}),o&&(0,Y.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,o]}),(0,Y.jsxs)(`div`,{ref:C,onScroll:te,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[P.length===0&&!o&&(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),P.map((e,t)=>(0,Y.jsx)(sn,{entry:e,isContinuation:t>0&&P[t-1].role===e.role},`${e.ts}-${t}`)),ee&&(0,Y.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,Y.jsx)(B,{className:`h-4 w-4 animate-pulse`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:ee.label}),(0,Y.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,Y.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[ee.text,(0,Y.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),y.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),y.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,Y.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,Y.jsx)(`span`,{className:H(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,Y.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,Y.jsx)(`span`,{className:H(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,Y.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`select`,{value:h,onChange:e=>g(e.target.value),title:i(`activity:sessionWatch.msgType.${h}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:cn.map(e=>(0,Y.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,Y.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,Y.jsx)(`option`,{value:`high`,children:`high`}),(0,Y.jsx)(`option`,{value:`normal`,children:`normal`}),(0,Y.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,Y.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ne())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${h}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void ne(),disabled:u||!c.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:u?`…`:i(`activity:sessionWatch.send`)})]}),f&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:f}),(0,Y.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var Z={primary:`hsl(var(--primary))`,info:`hsl(var(--info))`,success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,destructive:`hsl(var(--destructive))`,muted:`hsl(var(--muted-foreground))`},dn=.12;function fn(e){return Math.min(100,Math.max(0,e??0))}function pn({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6,a={idle:`bg-muted-foreground`,active:`bg-success`,streaming:`bg-primary`,completed:`bg-primary`,error:`bg-destructive`,offline:`bg-muted-foreground/60`},o={idle:Z.muted,active:Z.success,streaming:Z.primary,completed:Z.primary,error:Z.destructive,offline:Z.muted};return(0,Y.jsx)(`span`,{className:H(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function Q(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L,{type:`target`,position:S.Top,style:e,isConnectable:!1}),(0,Y.jsx)(L,{type:`source`,position:S.Bottom,style:e,isConnectable:!1})]})}function mn({data:e}){let{t}=a();return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border/60 pt-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,Y.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:mt(e.startedAt,Date.now())})})]})}function hn({data:e}){let{t}=a(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,o=e.color||Z.info;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-primary/15`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35 opacity-60`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(_,{className:`h-5 w-5`,style:{color:o}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:o},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(le,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(I,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,Y.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,Y.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,Y.jsx)(mn,{data:e})]})}function gn({data:e}){let{t}=a(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||Z.success;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-success/15`,r&&`border-destructive/50 bg-destructive/10`,!n&&!r&&`border-success/30 bg-success/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,Y.jsx)(u,{className:`h-5 w-5`,style:{color:i}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(u,{className:`h-3 w-3 text-success`}),(0,Y.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,Y.jsx)(mn,{data:e})]})}function _n({data:e}){let{t}=a(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.warning;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-warning/15`,!n&&`border-warning/30 bg-warning/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,Y.jsx)(u,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,Y.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,Y.jsx)(mn,{data:e})]})}function vn({data:e}){let{t}=a(),n=e.status===`active`||e.status===`streaming`,r=e.color||Z.primary;return(0,Y.jsxs)(`div`,{className:`relative min-w-[200px] rounded-xl border-2 border-border/70 bg-card/90 p-4 shadow-lg backdrop-blur-sm transition-all`,children:[(0,Y.jsx)(Q,{}),(0,Y.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground`,children:t(`activity:office.coordinator`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,Y.jsx)(ye,{className:`h-6 w-6`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,Y.jsx)(pn,{status:e.status,activity:e.vizActivity??0})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsx)(`div`,{className:`font-mono text-foreground`,children:ft(e.tokensIn)}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function yn({data:e}){let{t}=a(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,o=e.color||Z.primary,s=fn(e.ctxPct);return(0,Y.jsxs)(`div`,{className:H(`w-[170px] min-w-0 max-w-[170px] overflow-hidden rounded-lg border p-3 transition-all backdrop-blur-sm`,n&&`border-primary/50 bg-primary/10 shadow-lg shadow-primary/10`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 shrink-0`,style:{color:o}}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:o},children:e.label}),e.model&&(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:ht(e.model)})]}),(0,Y.jsx)(pn,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,Y.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,Y.jsx)(`span`,{className:H(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:gt(e.currentTask,72)})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground`,children:ft((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,Y.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),s>0&&(0,Y.jsxs)(`div`,{className:`mb-1`,children:[(0,Y.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:`ctx`}),(0,Y.jsxs)(`span`,{className:H(`font-mono`,s>=90?`text-destructive`:s>=70?`text-warning`:`text-muted-foreground`),children:[s,`%`]})]}),(0,Y.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:H(`h-full`,s>=90?`bg-destructive`:s>=70?`bg-warning`:`bg-primary`),style:{width:`${s}%`}})})]}),e.lastActivityAt&&(0,Y.jsxs)(`div`,{className:H(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,Y.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,Y.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,Y.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:pt(e.lastActivityAt,Date.now())})})]})]})}function bn({data:e}){let{t}=a();return(0,Y.jsxs)(`div`,{className:H(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(i,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,Y.jsx)(pn,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function xn({data:e}){let{t:n}=a(),r=e.color||Z.warning,i=(e.unreadCount||0)>0;return(0,Y.jsxs)(`div`,{className:H(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,i&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!i&&`border-warning/30 bg-warning/6`),children:[(0,Y.jsx)(Q,{}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,Y.jsx)(`div`,{className:H(`flex items-center justify-center w-10 h-10 rounded-lg`,i?`bg-warning/18`:`bg-warning/10`),children:(0,Y.jsx)(t,{className:`h-5 w-5`,style:{color:r}})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold`,style:{color:r},children:n(`activity:office.mailboxHub`)}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i?n(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):n(`activity:office.allClear`)})]}),i&&(0,Y.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-warning text-[10px] font-bold text-background`,children:e.unreadCount})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,Y.jsx)(N,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.messageCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:office.total`)})]}),(0,Y.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,Y.jsx)(h,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:e.unreadCount||0})]}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:n(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,Y.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var Sn={webui:hn,tui:gn,repl:_n,coordinator:vn,agent:yn,mailbox:xn,desk:bn};function Cn({broadcastOpen:e,labels:t,onArrange:n,onBroadcastToggle:r,onFeedToggle:i,showFeed:a}){return(0,Y.jsxs)(oe,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:n,title:t.arrangeTitle,className:`flex items-center gap-1.5 rounded-md border border-border/70 bg-card/90 px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:bg-accent`,children:[(0,Y.jsx)(M,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:H(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,a?`border-primary/35 bg-primary/10 text-primary`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(he,{className:`h-3.5 w-3.5`}),t.feed]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:H(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,e?`border-warning/35 bg-warning/10 text-warning`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,Y.jsx)(N,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function wn(){return(0,Y.jsx)(E,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return Z.primary;case`webui`:return Z.info;case`tui`:return Z.success;case`repl`:case`mailbox`:return Z.warning;default:return Z.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function Tn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:i}){return(0,Y.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(B,{className:`h-4 w-4 text-primary shrink-0`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:i})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,Y.jsx)(un,{sessionId:r,limit:500})})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||Z.primary,l=U(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=_e({sourceX:e,sourceY:t,sourcePosition:i??S.Bottom,targetX:n,targetY:r,targetPosition:a??S.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,Y.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,Y.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,Y.jsx)(ue,{children:(0,Y.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none max-w-[220px] truncate whitespace-nowrap rounded-full border border-border/70 bg-card/90 px-1.5 py-0.5 text-[8px] font-medium text-foreground backdrop-blur-sm`,children:o.label})})]})}};function Dn(){let{t:e}=a(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:o}=we(c(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),s=t.tui+t.webui+t.repl,l=e=>e?.toLocaleString()??`0`;return(0,Y.jsxs)(`div`,{className:`absolute left-4 top-20 z-10 rounded-xl border border-border/70 bg-card/90 p-3 text-foreground shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(F,{className:`h-3.5 w-3.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(V,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-success`,children:s})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(u,{className:`h-2.5 w-2.5 text-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.tui`)}),(0,Y.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(_,{className:`h-2.5 w-2.5 text-primary`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.webui`)}),(0,Y.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(u,{className:`h-2.5 w-2.5 text-warning`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:hud.repl`)}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(B,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,Y.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,Y.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ye,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ge,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,Y.jsx)(`span`,{className:H(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-primary/10 text-primary`,n.mode===`suggest`&&`bg-success/10 text-success`,n.mode===`off`&&`bg-muted text-muted-foreground`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-muted text-muted-foreground`),children:n.mode})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(f,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-warning`,children:l(o.toolCalls)})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensIn)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e(`activity:hud.out`)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:l(o.tokensOut)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(ve,{className:`h-3 w-3 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,Y.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(o.costUsd)})]})]})]})}function On({events:e,now:t}){let{t:n}=a(),r=e.slice(0,14);return(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,Y.jsxs)(`div`,{className:`pointer-events-auto mx-auto max-w-3xl rounded-lg border border-border/70 bg-card/90 px-3 py-2 shadow-xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,Y.jsx)(F,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:Ot(e.kind)}}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,Y.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function kn(){let{t:e}=a();return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,Y.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-success`,children:`●`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]})]})}function An({draft:e,isSending:t,result:n,onClose:r,onDraftChange:i,onSend:o}){let{t:s}=a();return(0,Y.jsxs)(`div`,{className:`absolute right-4 top-16 z-30 w-80 rounded-xl border border-warning/35 bg-card/95 p-3 shadow-2xl backdrop-blur`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,Y.jsx)(N,{className:`h-3.5 w-3.5`}),` `,s(`activity:office.broadcastToAll`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,Y.jsx)(`textarea`,{value:e,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o())},rows:3,placeholder:s(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-border/70 bg-background/70 px-2 py-1 text-[11px] text-foreground placeholder:text-muted-foreground focus:border-warning/45 focus:outline-none`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:s(`activity:office.broadcastSendHint`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:o,disabled:t||!e.trim(),className:`rounded-md border border-warning/35 bg-warning/12 px-2.5 py-1 text-[11px] text-warning transition-colors hover:bg-warning/18 disabled:cursor-not-allowed disabled:opacity-40`,children:t?`…`:s(`activity:office.broadcast`)})]}),n&&(0,Y.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n})]})}function $({k:e,v:t,accent:n}){return(0,Y.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,Y.jsx)(`span`,{className:H(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function jn({selectedNode:e,selectedAgentTranscript:n,mailboxMessages:r,onClose:i,onOpenWatch:o}){let{t:s}=a(),c=e.data,l=Date.now(),d=c.kind===`agent`,f=c.kind===`webui`||c.kind===`tui`||c.kind===`repl`,m=(c.tokensIn||0)+(c.tokensOut||0),h=fn(c.ctxPct);return(0,Y.jsxs)(`div`,{className:H(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,c.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:c.sessionId?`w-80`:`w-64`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.kind===`webui`&&(0,Y.jsx)(_,{className:`h-4 w-4 text-info`}),c.kind===`tui`&&(0,Y.jsx)(u,{className:`h-4 w-4 text-success`}),c.kind===`coordinator`&&(0,Y.jsx)(ye,{className:`h-4 w-4 text-primary`}),c.kind===`agent`&&(0,Y.jsx)(B,{className:`h-4 w-4 text-primary`}),c.kind===`mailbox`&&(0,Y.jsx)(t,{className:`h-4 w-4 text-warning`}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:c.label})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c.sessionId&&(0,Y.jsx)(`button`,{type:`button`,title:s(`activity:office.openFullView`),onClick:()=>o({sessionId:c.sessionId,label:c.label}),className:`text-muted-foreground hover:text-primary`,children:(0,Y.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:i,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)($,{k:`Status`,v:String(c.status).toUpperCase(),accent:H(c.status===`active`&&`text-success`,c.status===`streaming`&&`text-primary`,c.status===`error`&&`text-destructive`,c.status===`idle`&&`text-muted-foreground`,c.status===`offline`&&`text-muted-foreground/70`)}),d&&(0,Y.jsxs)(Y.Fragment,{children:[c.model&&(0,Y.jsx)($,{k:`Model`,v:ht(c.model),accent:`text-primary`}),c.currentTask&&(0,Y.jsxs)(`div`,{className:`pt-1`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:s(`activity:agentOffice.currentTask`)}),(0,Y.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:c.currentTask})]}),(0,Y.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`}),(0,Y.jsx)($,{k:`Tool calls`,v:c.toolCalls||0,accent:`text-warning`}),(0,Y.jsx)($,{k:`Tokens in`,v:ft(c.tokensIn)}),(0,Y.jsx)($,{k:`Tokens out`,v:ft(c.tokensOut)}),(0,Y.jsx)($,{k:`Tokens total`,v:ft(m)}),h>0&&(0,Y.jsx)($,{k:`Context`,v:`${h}%`,accent:h>=90?`text-destructive`:h>=70?`text-warning`:`text-foreground/70`}),(0,Y.jsx)($,{k:`Cost`,v:`$${(c.costUsd||0).toFixed(4)}`,accent:`text-success`}),c.lastActivityAt&&(0,Y.jsx)($,{k:`Last seen`,v:pt(c.lastActivityAt,l),accent:`text-muted-foreground`}),(0,Y.jsx)(`div`,{className:`pt-2`,children:(0,Y.jsx)(Oe,{entries:n,agentName:c.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),f&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Surface`,v:bt(c.kind),accent:`text-foreground/80`}),c.branch&&(0,Y.jsx)($,{k:`Branch`,v:`⎇ ${c.branch}`,accent:`text-foreground/70`}),c.pid!=null&&(0,Y.jsx)($,{k:`PID`,v:c.pid}),c.workingDir&&(0,Y.jsx)($,{k:`Dir`,v:c.workingDir,accent:`text-muted-foreground`}),(0,Y.jsx)($,{k:`Agents`,v:c.agentCount??0,accent:`text-primary`}),c.startedAt&&(0,Y.jsx)($,{k:`Uptime`,v:mt(c.startedAt,l),accent:`text-foreground/70`})]}),c.kind===`mailbox`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Total messages`,v:c.messageCount||0,accent:`text-warning`}),(0,Y.jsx)($,{k:`Unread`,v:c.unreadCount||0,accent:`text-warning`}),r.length>0&&(0,Y.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,Y.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:s(`activity:office.recent`)}),[...r].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,Y.jsx)(`span`,{className:H(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!e.completed&&(e.readByCount??0)===0?`bg-warning`:e.completed?`bg-success`:`bg-muted`)}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||s(`activity:office.noSubject`)}),(0,Y.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,pt(e.timestamp,l),e.audience===`leaders`?` · ${s(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),c.kind===`coordinator`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)($,{k:`Connections`,v:c.connections||0,accent:`text-primary`}),(0,Y.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`})]}),(d||f)&&c.sessionId&&(0,Y.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,Y.jsx)(un,{sessionId:c.sessionId})})]})]})}function Mn(){let{t:e}=a(),{fitView:t}=te(),n=(0,W.useRef)(null),[r,i]=(0,W.useState)({width:1280,height:720});(0,W.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let{width:t,height:n}=e.getBoundingClientRect();t<1||n<1||i(e=>Math.abs(e.width-t)<2&&Math.abs(e.height-n)<2?e:{width:t,height:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let o=xe(e=>e.events),s=Ce(e=>e.agents),c=Ce(e=>e.agentTranscripts),l=Ce(e=>e.leaderId),u=we(e=>e.liveSessions),d=Ee(e=>e.messages),f=Ee(e=>e.agents),p=Se(e=>e.session),m=At(s),h=(0,W.useMemo)(()=>Dt(u,s,f,m.map,m.now),[u,s,f,m]),g=U(e=>e.showHud),_=U(e=>e.showLegend),v=U(e=>e.showMinimap),y=U(e=>e.showControls),b=U(e=>e.showFeed),x=U(e=>e.setShowFeed),S=U(e=>e.background),[T,E,O]=ce([]),[k,A,j]=de([]),[M,N]=(0,W.useState)(null),[P,re]=(0,W.useState)(null),[F,ie]=(0,W.useState)(!1),[ae,oe]=(0,W.useState)(``),[se,le]=(0,W.useState)(!1),[ue,I]=(0,W.useState)(null),fe=(0,W.useMemo)(()=>{if(M?.data.kind!==`agent`)return Te;let e=M.data.serverId??(M.id.includes(`__agent-`)?M.id.split(`__agent-`).pop():M.id.replace(/^agent-/,``));return e?c.get(e)??Te:Te},[c,M]),me=(0,W.useCallback)(async()=>{let e=ae.trim();if(!(!e||se)){le(!0),I(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();oe(``),I(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){I(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{le(!1)}}},[ae,se]),L=(0,W.useRef)(new Map),he=4e3,R=(0,W.useRef)(new Map),z=(0,W.useRef)(new Map),B=(0,W.useRef)(new Map),ge=(0,W.useRef)(new Map),_e=(0,W.useRef)(``);(0,W.useEffect)(()=>{let n=[],i=[],a=Date.now(),o=_t(h.map(e=>({id:e.id,agentCount:e.agents.length})),r),c=d.filter(e=>!e.completed&&(e.readByCount??0)===0).length,u=d.length?[...d].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:c>0?`active`:`idle`,unreadCount:c,messageCount:d.length,sublabel:u?`${u.from} → ${u.to}: ${u.subject}`:void 0,color:Z.warning}});let f=0,p=0,m=0,g=0,_=0;for(let e of h)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),m+=t.toolCalls,g+=t.costUsd,_+=t.tokensIn+t.tokensOut;let v=l?s.get(l):null,y=f>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:h.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:h.length,agentsActive:f,agentsTotal:p,toolCalls:m,costUsd:g,tokensIn:_,color:Z.primary}});let b={tui:Z.success,webui:Z.info,repl:Z.warning};for(let t of h){let r=o.positions.get(t.id)??{x:600,y:370},s=r.x,l=r.y,u=b[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:s,y:l},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:u}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:d,data:{color:u,animated:d,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:c>0,data:{color:Z.warning,animated:c>0,label:c>0?`${c}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:s,y:l+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:Z.muted}});continue}t.agents.forEach((r,o)=>{let c=r.status===`active`||r.status===`streaming`,u=ge.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||c){L.current.set(r.officeId,a+he);let e=z.current.get(r.officeId)??0;z.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=R.current.get(e)??0;R.current.set(e,Math.min(1,t+.5))}}ge.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:vt(s,o,t.agents.length,l+270),data:{label:r.name,kind:`agent`,status:r.status,serverId:r.serverId,sessionId:t.sessionId,currentTask:r.currentTask,iteration:r.iteration,toolCalls:r.toolCalls,costUsd:r.costUsd,tokensIn:r.tokensIn,tokensOut:r.tokensOut,ctxPct:r.ctxPct,model:r.model,lastActivityAt:r.lastActivityAt,color:Z.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:c,data:{color:Z.primary,animated:c,label:c?gt(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(h.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...ge.current.keys()])x.has(e)||ge.current.delete(e);for(let[e,t]of[...L.current])t<=a&&L.current.delete(e);let S=n.map(e=>{let t=L.current.get(e.id),n=z.current.get(e.id)??0;return t&&t>a&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),C=i.map(e=>{let t=R.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});B.current=w,E(S),A(C);let T=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${o.columns}x${o.rows}`,h.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(T!==_e.current){_e.current=T;let e=setTimeout(()=>t({padding:dn,duration:300}),50);return()=>clearTimeout(e)}},[h,l,s,d,p,r,he,E,A,t]);let ve=h.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),ye=h.map(e=>e.id),be=new Map;for(let e of ve)(!be.has(e.serverId)||e.clientType===`webui`)&&be.set(e.serverId,e.officeId);function V(e){return be.get(e)??`agent-${e}`}function H(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function De(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?ye.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=V(e.target??e.source);return{nodes:[t],edges:[H(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:ve.map(e=>H(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=V(e.source);return{nodes:[t],edges:[H(t)],status:`streaming`}}case`agent:status`:{let t=V(e.source);return{nodes:[`coordinator`,t],edges:[H(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[V(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,V(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[V(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=V(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,W.useEffect)(()=>{if(o.length===0)return;let e=o[0];if(!e)return;let{nodes:t,edges:n,status:r}=De(e),i=Date.now();t.length>0&&(t.forEach(e=>{L.current.set(e,i+he);let t=z.current.get(e)??0;z.current.set(e,Math.min(1,t+(1-t)*.5))}),E(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:z.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=R.current.get(e)??0;R.current.set(e,Math.min(1,t+.5))}),A(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:R.current.get(e.id)??1}}:e)))},[o,E,A,he,s]),(0,W.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of R.current){let i=r*.85;i<.05?(R.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(R.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&A(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,animated:n.animated,data:{...t.data,animated:n.animated,intensity:n.intensity}}:t}));let n=new Map,r=!1;for(let[e,t]of z.current){let i=t*.9;i<.03?(z.current.delete(e),n.set(e,0),r=!0):(z.current.set(e,i),n.set(e,i),r=!0)}r&&E(e=>e.map(e=>{let t=n.get(e.id);return t===void 0?e:{...e,data:{...e.data,vizActivity:t}}}))},1e3);return()=>clearInterval(e)},[A,E]);let Oe=(0,W.useCallback)(e=>A(t=>D({...e,type:`wire`},t)),[A]),ke=(0,W.useCallback)((e,t)=>{N(t)},[]),Ae=(0,W.useCallback)(()=>{N(null)},[]);(0,W.useEffect)(()=>{if(!P)return;let e=e=>{e.key===`Escape`&&re(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P]);let je=(0,W.useCallback)(()=>{E(e=>e.map(e=>{let t=B.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:dn,duration:300}),50)},[E,t]),[,Me]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Me(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,Y.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
2
- linear-gradient(hsl(var(--foreground) / 0.1) 1px, transparent 1px),
3
- linear-gradient(90deg, hsl(var(--foreground) / 0.1) 1px, transparent 1px)
4
- `,backgroundSize:`40px 40px`}}),g&&(0,Y.jsx)(Dn,{}),(0,Y.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,Y.jsx)(w,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,Y.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),_&&(0,Y.jsx)(kn,{}),(0,Y.jsxs)(ee,{nodes:T,edges:k,onNodesChange:O,onEdgesChange:j,onConnect:Oe,onNodeClick:ke,onPaneClick:Ae,nodeTypes:Sn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:dn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(Cn,{broadcastOpen:F,labels:{arrange:e(`activity:office.arrange`),arrangeTitle:e(`activity:office.arrangeTitle`),broadcast:e(`activity:office.broadcast`),broadcastTitle:e(`activity:office.broadcastTitle`),feed:e(`activity:office.feed`),feedTitle:e(`activity:office.feedTitle`)},onArrange:je,onBroadcastToggle:()=>ie(e=>!e),onFeedToggle:()=>x(!b),showFeed:b}),S!==`none`&&(0,Y.jsx)(pe,{variant:S===`lines`?ne.Lines:S===`cross`?ne.Cross:ne.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),y&&(0,Y.jsx)(C,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),v&&(0,Y.jsx)(wn,{})]}),b&&(0,Y.jsx)(On,{events:o,now:Date.now()}),F&&(0,Y.jsx)(An,{draft:ae,isSending:se,result:ue,onClose:()=>ie(!1),onDraftChange:oe,onSend:()=>void me()}),M&&(0,Y.jsx)(jn,{selectedNode:M,selectedAgentTranscript:fe,mailboxMessages:d,onClose:Ae,onOpenWatch:re}),P&&(0,Y.jsx)(Tn,{closeTitle:e(`activity:office.closeEsc`),label:P.label,onClose:()=>re(null),sessionId:P.sessionId,streamTitle:e(`activity:office.fullOperationStream`)})]})}function Nn(){let{t:e}=a(),t=U(e=>e.viewMode),n=U(e=>e.setViewMode),i=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:re},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:r}],o=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+i.length)%i.length),e.key===`ArrowRight`&&(r=(t+1)%i.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=i.length-1),r===void 0)return;e.preventDefault();let a=i[r];a&&(n(a.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,Y.jsx)(`nav`,{"aria-label":`${e(`activity:agentOffice.office`)} / ${e(`activity:agentOffice.topology`)}`,className:`relative z-[60] shrink-0 border-b border-border bg-card/95 px-3 pt-2 shadow-[0_8px_28px_hsl(var(--shadow-color)/0.1)] backdrop-blur-xl sm:px-5`,children:(0,Y.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`mx-auto grid w-full max-w-3xl grid-cols-2 gap-1`,children:i.map((e,r)=>{let i=e.icon,a=t===e.id;return(0,Y.jsxs)(`button`,{id:`office-map-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`office-map-view-panel`,tabIndex:a?0:-1,onClick:()=>n(e.id),onKeyDown:e=>o(e,r),className:H(`group relative flex min-w-0 items-center gap-2.5 border-b-2 px-3 py-2.5 text-left transition-all duration-200 sm:gap-3 sm:px-5`,a?`border-primary bg-primary/[0.07] text-foreground`:`border-transparent text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground`),children:[(0,Y.jsx)(`span`,{className:H(`grid h-8 w-8 shrink-0 place-items-center rounded-lg border transition-colors`,a?`border-primary/35 bg-primary/15 text-primary`:`border-border bg-background/70 text-muted-foreground group-hover:text-foreground`),children:(0,Y.jsx)(i,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,Y.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:H(`ml-auto h-1.5 w-1.5 shrink-0 rounded-full transition-all`,a?`bg-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]`:`bg-border`)})]},e.id)})})}),(0,Y.jsx)(`div`,{id:`office-map-view-panel`,role:`tabpanel`,"aria-labelledby":`office-map-tab-${t}`,className:`relative min-h-0 flex-1`,children:t===`office`?(0,Y.jsx)(nn,{}):(0,Y.jsx)(z,{children:(0,Y.jsx)(Mn,{})})})]})}export{Nn as OfficeMapPanel};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ba as t,Fa as n,lt as r}from"./vendor-GiKfK4Iw.js";import"./i18n-BvFgJYE2.js";import{t as i}from"./utils-CUCQrODG.js";import{t as a}from"./button-ELs5xgtQ.js";import{t as o}from"./input-DSTQkMEh.js";import{o as s}from"./index-BTRQG7C5.js";var c=e(t(),1),l=r(),u=[`feature`,`bug_fix`,`refactor`,`performance`,`security`,`ui_change`,`api_change`,`infrastructure`,`migration`,`testing`,`documentation`,`maintenance`,`other`,`unspecified`],d=[`unspecified`,`low`,`medium`,`high`,`critical`],f={draft:`bg-muted text-muted-foreground`,collecting_information:`bg-warning/15 text-warning`,submitted:`bg-success/15 text-success`,cancelled:`bg-destructive/15 text-destructive`,archived:`bg-muted text-muted-foreground`};function p(e){let t=Date.now()-e;if(t<6e4)return`just now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function m(){let{t:e}=n(),[t,r]=(0,c.useState)(null),[m,h]=(0,c.useState)([]),[g,_]=(0,c.useState)(!0),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(``),[w,T]=(0,c.useState)(`unspecified`),[E,D]=(0,c.useState)(`unspecified`),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(null),[M,N]=(0,c.useState)(null),P=(0,c.useCallback)(async()=>{_(!0),y(null);try{let e=await fetch(`/api/requirement-intakes`);if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error?.message??`List failed (HTTP ${e.status})`)}let t=await e.json();r(t.projectId),h(t.intakes)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}},[]);(0,c.useEffect)(()=>{P()},[P]);let F=(0,c.useCallback)(async()=>{let e=b.trim();if(!e){j(`Describe the request first — it is preserved verbatim.`);return}if(!t){j(`No project identity available yet.`);return}k(!0),j(null),N(null);try{let n=await fetch(`/api/projects/${encodeURIComponent(t)}/requirement-intakes`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({originalRequest:e,...S.trim()?{title:S.trim()}:{},...w===`unspecified`?{}:{requestType:w},...E===`unspecified`?{}:{priority:E}})}),r=await n.json().catch(()=>null);if(!n.ok||!r?.record)throw Error(r?.error?.message??`Create failed (HTTP ${n.status})`);let i=await fetch(`/api/requirement-intakes/${r.record.id}/submit`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error?.message??`Submit failed (HTTP ${i.status})`)}N(`Intake recorded and submitted (${r.record.id}).`),x(``),C(``),T(`unspecified`),D(`unspecified`),await P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},[b,S,w,E,t,P]);return(0,l.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:[(0,l.jsxs)(`header`,{className:`border-b border-border/70 px-5 py-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:e(`activity:reqIntake.requirementsIntake`)}),(0,l.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:e(`activity:reqIntake.collectAndPreserveSoftwareDevelopmentRequests`)})]}),(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[v?(0,l.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[v,(0,l.jsx)(`button`,{type:`button`,className:`ml-2 underline underline-offset-2`,onClick:()=>void P(),children:e(`activity:reqIntake.retry`)})]}):null,(0,l.jsxs)(`section`,{"aria-label":e(`activity:reqIntake.fileANewIntake`),className:`mb-6 rounded-lg border border-border/70 bg-card/60 p-4`,children:[(0,l.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:reqIntake.fileANewRequest`)}),(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`label`,{htmlFor:`intake-request`,className:`mb-1 block text-xs text-foreground`,children:[e(`activity:reqIntake.requestText`),` `,(0,l.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,l.jsx)(`textarea`,{id:`intake-request`,value:b,onChange:e=>x(e.target.value),placeholder:e(`activity:reqIntake.describeTheFeatureBugFixRefactorOrChange`),rows:4,className:i(`w-full resize-y rounded-md border border-border/70 bg-background px-3 py-2`,`text-sm text-foreground placeholder:text-muted-foreground/70`,`focus:outline-none focus:ring-2 focus:ring-ring`)}),(0,l.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:e(`activity:reqIntake.storedVerbatimAsTheRecordApos`)})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-title`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.titleOptional`)}),(0,l.jsx)(o,{id:`intake-title`,value:S,onChange:e=>C(e.target.value),placeholder:e(`activity:reqIntake.shortDisplayTitle`)})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-type`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.type`)}),(0,l.jsx)(`select`,{id:`intake-type`,value:w,onChange:e=>T(e.target.value),className:i(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:u.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`intake-priority`,className:`mb-1 block text-xs text-foreground`,children:e(`activity:reqIntake.priority`)}),(0,l.jsx)(`select`,{id:`intake-priority`,value:E,onChange:e=>D(e.target.value),className:i(`w-full rounded-md border border-border/70 bg-background px-2 py-2`,`text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring`),children:d.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]})]}),A?(0,l.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:A}):null,M?(0,l.jsx)(`div`,{role:`status`,className:`rounded-md border border-success/30 bg-success/10 px-3 py-2 text-xs text-success`,children:M}):null,(0,l.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,l.jsx)(a,{variant:`secondary`,size:`sm`,disabled:O,onClick:()=>{x(``),j(null),N(null)},children:e(`activity:reqIntake.clear`)}),(0,l.jsx)(a,{size:`sm`,disabled:O||!b.trim(),onClick:()=>void F(),children:O?`Filing…`:`File + submit`})]})]})]}),(0,l.jsxs)(`section`,{"aria-label":e(`activity:reqIntake.intakeRecords`),className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,l.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:reqIntake.records`)}),(0,l.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[m.length,` total`]})]}),g?(0,l.jsx)(`div`,{className:`py-8 text-center text-xs text-muted-foreground`,children:e(`activity:reqIntake.loading`)}):m.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed border-border/70 py-10 text-center text-xs text-muted-foreground`,children:e(`activity:reqIntake.noIntakeRecordsYetFileThe`)}):(0,l.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,l.jsxs)(`li`,{className:`rounded-md border border-border/70 bg-card/60 p-3`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,title:e.title,children:e.title}),(0,l.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground`,children:e.id})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,l.jsx)(s,{variant:`secondary`,className:`text-[10px]`,children:e.requestType}),(0,l.jsx)(s,{className:i(`text-[10px]`,f[e.status]??`bg-muted text-muted-foreground`),children:e.status})]})]}),(0,l.jsxs)(`div`,{className:`mt-1.5 text-[11px] text-muted-foreground`,children:[e.priority,` · updated `,p(e.updatedAt)]})]},e.id))})]})]})]})}export{m as RequirementIntakeView};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryManager-CL5AiyKr.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-GiKfK4Iw.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-sSmz-Ua_.js","assets/vendor-BMdWcCR4.css","assets/i18n-BvFgJYE2.js","assets/activity-BwEBEQ51.js","assets/chat-CdiY7G6Z.js","assets/commandPalette-DpaemFux.js","assets/common-COVxQ0FV.js","assets/settings-BUtmAZBV.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/useWebSocket-B2opfRwA.js","assets/chat-store-CBJ1gc8n.js","assets/utils-CUCQrODG.js","assets/ws-client-CGEB75Dy.js","assets/session-store-Ce4Dck2K.js","assets/codemap-activity-store-D67-genN.js","assets/stores-BATHCuMN.js","assets/mailbox-store-CKpkM0H1.js","assets/ui-store-BGNdg1e4.js","assets/view-navigation-FdnvQSOv.js","assets/codemap-index-store-ByAYIzQA.js","assets/Toaster-D76T-Ld4.js","assets/dialog-CfAoIH8P.js","assets/button-ELs5xgtQ.js","assets/input-DSTQkMEh.js","assets/index-BTRQG7C5.js","assets/ConfirmModal-DXy17_uy.js","assets/ModelPicker-BazB-GbH.js","assets/index-DHsJniTZ.css","assets/roster-ws-a3-SO1Yb.js","assets/shared-D368RBth.js","assets/MemoryDrawer-D2Yq9oba.js","assets/AudienceMemoryPanel-BRXM47H1.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ba as t,Fa as n,bt as r,lt as i,ur as a}from"./vendor-GiKfK4Iw.js";import"./i18n-BvFgJYE2.js";import{s as o}from"./monaco-BLUV5g0U.js";import{t as s}from"./utils-CUCQrODG.js";import{C as c,E as l,T as u,w as d}from"./index-BTRQG7C5.js";var f=e(t(),1),p=i(),m=(0,f.lazy)(()=>o(()=>import(`./MemoryManager-CL5AiyKr.js`).then(e=>({default:e.MemoryManager})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]))),h=(0,f.lazy)(()=>o(()=>import(`./AudienceMemoryPanel-BRXM47H1.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([37,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35])));function g({label:e}){return(0,p.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background text-xs text-muted-foreground`,"aria-busy":`true`,children:(0,p.jsxs)(`span`,{className:`font-mono uppercase tracking-wide`,children:[e,`…`]})})}var _=[{value:`all`,label:`activity:memoryManager.tabAllMemories`,hint:`activity:memoryManager.tabAllMemoriesHint`,Icon:a},{value:`audience`,label:`activity:memoryManager.tabAudience`,hint:`activity:memoryManager.tabAudienceHint`,Icon:r}];function v({defaultValue:e=`all`}={}){let{t}=n();return(0,p.jsxs)(c,{defaultValue:e,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,p.jsx)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-border/70 bg-card/55 px-4 py-2 sm:px-5`,role:`presentation`,children:(0,p.jsx)(u,{"aria-label":t(`activity:memoryManager.lensesAria`),className:`h-9 bg-muted/40 p-1 shadow-none`,children:_.map(({value:e,label:n,hint:r,Icon:i})=>(0,p.jsxs)(l,{value:e,className:s(`h-7 gap-2 px-3 text-[11px] font-semibold uppercase tracking-wide`,`data-[state=active]:bg-background data-[state=active]:text-foreground`,`data-[state=active]:shadow-[0_0_0_1px_hsl(var(--border)/0.7)]`),children:[(0,p.jsx)(i,{className:`size-3.5`}),(0,p.jsx)(`span`,{children:t(n)}),(0,p.jsx)(`span`,{className:`hidden font-mono text-[9px] font-normal normal-case text-muted-foreground sm:inline`,children:t(r)})]},e))})}),(0,p.jsx)(d,{value:`all`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(g,{label:t(`activity:memoryManager.loadingSage`)}),children:(0,p.jsx)(m,{})})}),(0,p.jsx)(d,{value:`audience`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(g,{label:t(`activity:memoryManager.loadingAudience`)}),children:(0,p.jsx)(h,{})})})]})}export{v as SageTabs};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,An as n,Ba as r,Bn as i,Bt as a,Ct as o,Et as s,Fa as c,Gi as l,Gt as u,Kn as d,Li as f,Nt as p,Ot as ee,Pr as m,Pt as h,Qn as g,Ra as _,Sa as v,Tn as te,Ut as ne,Wt as y,Zi as b,Zr as x,ar as S,dt as C,ea as w,hn as T,in as re,ji as ie,jt as E,ka as D,lt as O,mi as ae,mn as k,ua as A,ut as j,xi as oe,xt as M}from"./vendor-GiKfK4Iw.js";import"./i18n-BvFgJYE2.js";import{t as N}from"./useWebSocket-B2opfRwA.js";import{t as P}from"./utils-CUCQrODG.js";import{c as F,p as I,s as L}from"./stores-BATHCuMN.js";import{n as R}from"./ui-store-BGNdg1e4.js";import{o as z}from"./view-navigation-FdnvQSOv.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./dialog-CfAoIH8P.js";import{t as K}from"./button-ELs5xgtQ.js";import{n as se,t as ce}from"./ModelPicker-BazB-GbH.js";import{c as le,s as ue}from"./index-BTRQG7C5.js";import{a as q,c as J,i as de,l as Y,n as fe,o as pe,r as me,s as X,t as he,u as ge}from"./SddFlowGraph-DWphr6Tr.js";import{SpecsView as _e}from"./SpecsView-Cl4vpAoL.js";var Z=e(r(),1),Q=O();function ve({feed:e,now:t}){let{t:n}=c();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-semibold text-foreground`,children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5 text-warning`}),n(`activity:sdd.activityHeading`)]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto overscroll-contain p-2`,children:e.length===0?(0,Q.jsx)(`p`,{className:`px-1 pt-4 text-center text-[11px] text-muted-foreground`,children:n(`activity:sdd.feedEmpty`)}):e.map((e,n)=>{let r=me[e.kind]??me.started,i=r.icon;return(0,Q.jsxs)(`div`,{className:P(`sdd-rise flex items-start gap-2 rounded-md px-2 py-1.5 text-[11px]`,n===0?`bg-muted`:`hover:bg-muted`),children:[(0,Q.jsx)(i,{className:P(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,Q.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:pe(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function ye({open:e,onOpenChange:t,snapshot:n,busy:r,onConfirm:i}){let{t:a}=c(),o=n?.mergedCommits?.length??0,s=n?.baseBranch,[l,u]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&u(!1)},[e]);let d=n?.status===`running`||n?.status===`paused`,f=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),p=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.add(t.agentName);return e.size},[n?.tasks]);return(0,Q.jsx)(G,{open:e,onOpenChange:e=>!r&&t(e),children:(0,Q.jsxs)(H,{className:`sm:max-w-lg border-destructive/50`,children:[(0,Q.jsxs)(B,{children:[(0,Q.jsxs)(U,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(E,{className:`h-5 w-5 text-destructive`}),a(`activity:sdd.destroyTitle`)]}),(0,Q.jsx)(W,{children:a(`activity:sdd.destroyDesc`)})]}),(0,Q.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[d&&(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:p>0?a(`activity:sdd.stopRunAgents`,{count:p}):a(`activity:sdd.stopRun`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:f>0?a(`activity:sdd.removeWorktreesCount`,{count:f}):a(`activity:sdd.removeWorktreesAll`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:a(`activity:sdd.deleteArtifacts`)})]})]}),o>0&&(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-warning/30 bg-warning/5 p-2.5 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),className:`mt-0.5 h-4 w-4 accent-warning`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:a(`activity:sdd.revertMerged`,{count:o})}),` `,`on `,(0,Q.jsx)(`code`,{className:`text-xs`,children:s??a(`activity:sdd.baseBranchFallback`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(`activity:sdd.revertHint`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(ee,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),a(o>0&&!l?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,Q.jsxs)(V,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(K,{variant:`outline`,size:`sm`,disabled:r,onClick:()=>t(!1),children:a(`common:action.cancel`)}),(0,Q.jsx)(K,{size:`sm`,disabled:r,onClick:()=>i(l),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,a(`activity:sdd.destroying`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{className:`mr-1 h-3.5 w-3.5`}),` `,a(`activity:sdd.destroyAll`)]})})]})]})})}var be=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-border/70`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-primary/35`,head:`text-primary`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-warning/45`,head:`text-warning`},{key:`review`,labelKey:`kanbanReview`,accent:`border-primary/35`,head:`text-primary`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-destructive/35`,head:`text-destructive`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-success/35`,head:`text-success`}];function xe({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=c(),i=(0,Z.useMemo)(()=>{let t=new Map;for(let e of be)t.set(e.key,[]);for(let n of e){let e=n.displayStatus===`blocked`?`pending`:n.displayStatus===`cancelled`?`failed`:n.displayStatus;(t.get(e)??t.get(`pending`))?.push(n)}return t},[e]);return(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:be.map(e=>{let a=i.get(e.key)??[];return(0,Q.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:P(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,Q.jsx)(`span`,{className:P(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`,children:[a.map(e=>(0,Q.jsx)(Se,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,Q.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-[10px] text-muted-foreground`,children:r(`activity:sdd.kanbanEmpty`)})]})]},e.key)})})}function Se({task:e,selected:t,onClick:n}){let r=e.displayStatus===`in_progress`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:P(`sdd-node-enter w-full rounded-lg border bg-card/85 p-2 text-left shadow-sm transition hover:border-primary/35 hover:bg-accent/35`,t?`border-primary/55 ring-1 ring-primary/35`:`border-border/70`,r&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,Q.jsx)(S,{className:`h-3 w-3 animate-spin text-warning`}),e.displayStatus===`completed`&&(0,Q.jsx)(w,{className:`h-3 w-3 text-success`}),e.displayStatus===`failed`&&(0,Q.jsx)(C,{className:`h-3 w-3 text-destructive`}),(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,Q.jsx)(`span`,{className:P(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,J(e.priority).chip),children:e.priority})]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:P(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,r?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:q(e.agentName)}),(0,Q.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,Q.jsx)(k,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,Q.jsx)(m,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function Ce({task:e,allTasks:t,feed:n,now:r,expanded:i,modelCandidates:s,defaultModel:l,onClose:u,onToggleExpanded:f,onRetry:p,onReassign:ee,onSetModel:h,onSetVerification:_,onCancel:te,onDelete:y,onSplit:b,onSelectTask:x}){let{t:S}=c(),T=Y(e.displayStatus),re=T.icon,D=e.displayStatus===`in_progress`,O=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[ae,A]=(0,Z.useState)(!1),[j,oe]=(0,Z.useState)(``),[M,N]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(e.verificationCommand??``),U=()=>{j.trim()&&(ee(e.id,j.trim()),A(!1),oe(``))},W=()=>{let t=L.split(`
2
- `).map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(`::`),r=(t??``).trim();return{title:r,description:n.join(`::`).trim()||r}}).filter(e=>e.title);t.length&&(b(e.id,t),I(!1),R(``))},G=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.shortId,e])),[t]),K=(0,Z.useMemo)(()=>t.filter(t=>t.deps.includes(e.shortId)),[t,e.shortId]),se=(0,Z.useMemo)(()=>n.filter(t=>t.taskId===e.id||t.taskShortId===e.shortId),[n,e.id,e.shortId]),le=e.startedAt&&!e.completedAt?X(r-e.startedAt):e.startedAt&&e.completedAt?X(e.completedAt-e.startedAt):null;return(0,Q.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:P(`flex items-center gap-2 border-b border-border/70 bg-card/70 px-3 py-2`,i&&`px-5 py-3`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`text-muted-foreground hover:text-foreground`,title:S(`activity:sddTask.backTitle`),children:(0,Q.jsx)(v,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),f&&(0,Q.jsx)(`button`,{type:`button`,onClick:f,className:`ml-1 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground`,title:S(i?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-label":S(i?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-pressed":i,children:i?(0,Q.jsx)(d,{className:`h-4 w-4`}):(0,Q.jsx)(g,{className:`h-4 w-4`})}),(0,Q.jsxs)(`span`,{className:P(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,T.ring,T.text),children:[(0,Q.jsx)(re,{className:P(`h-3 w-3`,D&&`animate-spin`)}),T.label]})]}),(0,Q.jsxs)(`div`,{className:P(`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,i?`grid grid-cols-2 content-start gap-4 p-5`:`space-y-3 p-3`),children:[(0,Q.jsx)(`h3`,{className:P(`text-sm font-semibold leading-snug text-foreground`,i&&`col-span-2 text-lg`),children:e.title}),e.agentName&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/70 bg-muted/45 p-2`,children:[(0,Q.jsx)(`span`,{className:P(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,D?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:q(e.agentName)}),(0,Q.jsxs)(`div`,{className:`leading-tight`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:S(D?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,Q.jsx)(Te,{label:S(`activity:sddTask.metaPriority`),children:(0,Q.jsx)(`span`,{className:P(`font-medium uppercase`,J(e.priority).text),children:e.priority})}),(0,Q.jsx)(Te,{label:S(`activity:sddTask.metaType`),children:e.type}),le&&(0,Q.jsx)(Te,{label:e.completedAt?S(`activity:sddTask.metaDuration`):S(`activity:sddTask.metaElapsed`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(ie,{className:`h-3 w-3 text-muted-foreground`}),le]})}),e.retries?(0,Q.jsx)(Te,{label:S(`activity:sddTask.metaRetries`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(k,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,Q.jsx)(Te,{label:S(`activity:sddTask.metaWorktree`),full:!0,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,Q.jsx)(m,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[S(`activity:sddTask.workerModel`),!e.model&&l&&(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,S(`activity:sddTask.runDefault`,{model:l})]})]}),(0,Q.jsx)(ce,{value:e.model,provider:e.provider,candidates:s,placeholder:l?S(`activity:sddTask.runDefaultPlaceholderModel`,{model:l}):S(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>h(e.id,t,n),onReset:e.model?()=>h(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map(e=>(0,Q.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[S(`activity:sddTask.verificationCmd`),(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,S(`activity:sddTask.gatesCompletion`)]})]}),z?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),onKeyDown:t=>{t.key===`Enter`?(_(e.id,V.trim()||void 0),B(!1)):t.key===`Escape`&&(H(e.verificationCommand??``),B(!1))},placeholder:S(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{_(e.id,V.trim()||void 0),B(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:S(`common:action.save`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{H(e.verificationCommand??``),B(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:S(`common:action.cancel`)})]})]}):e.verificationCommand?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.verificationState&&(0,Q.jsx)(`span`,{title:e.verificationDetail,className:e.verificationState===`passed`?`rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success`:`rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] text-destructive`,children:e.verificationState===`passed`?`✓ verified`:`✗ failed`}),(0,Q.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e.verificationCommand}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:S(`common:action.edit`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:S(`common:action.clear`)})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:S(`activity:sddTask.addVerify`)})]}),e.description&&(0,Q.jsxs)(`div`,{className:P(i&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:S(`activity:sddTask.description`)}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),(0,Q.jsx)(we,{events:se,expanded:i}),e.deps.length>0&&(0,Q.jsx)(Ee,{title:S(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:G,onSelectTask:x}),K.length>0&&(0,Q.jsx)(Ee,{title:S(`activity:sddTask.blocks`),shortIds:K.map(e=>e.shortId),byShort:G,onSelectTask:x})]}),(0,Q.jsxs)(`div`,{className:P(`border-t border-border p-2`,i&&`px-5 py-3`),children:[ae?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,Q.jsx)(`input`,{value:j,onChange:e=>oe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&U(),e.key===`Escape`&&A(!1)},placeholder:S(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs outline-none focus:border-primary/60`}),(0,Q.jsx)(`button`,{type:`button`,onClick:U,disabled:!j.trim(),className:`rounded-md bg-primary/10 px-2 py-1.5 text-xs font-medium text-primary hover:bg-primary/15 disabled:opacity-40`,children:(0,Q.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]}):M?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:S(M===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{M===`stop`?te(e.id):y(e.id),N(null)},className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(w,{className:`h-3.5 w-3.5`}),` `,S(M===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),title:S(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-warning/12 py-1.5 text-xs font-medium text-warning hover:bg-warning/18`,children:[(0,Q.jsx)(k,{className:`h-3.5 w-3.5`}),` `,S(`common:action.retry`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),` `,S(`activity:sddTask.reassign`)]}),D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(`stop`),title:S(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,S(`common:action.stop`)]}),!D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>I(!0),title:S(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,S(`activity:sddTask.split`)]}),O&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>N(`delete`),title:S(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,S(`common:action.delete`)]})]}),F&&(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:S(`activity:sddTask.splitHint`)}),(0,Q.jsx)(`textarea`,{id:`sdd-split-input`,rows:3,value:L,onChange:e=>R(e.target.value),placeholder:S(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:W,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,S(`activity:sddTask.splitInto`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{I(!1),R(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]})]})]})]})}function we({events:e,expanded:t}){let{t:n}=c();return(0,Q.jsxs)(`section`,{className:P(`rounded-lg border border-border/70 bg-background/45`,t&&`col-span-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2.5`,children:[(0,Q.jsx)(D,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`activity:sddTask.eventLog`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,children:e.length}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:sddTask.newestFirst`)})]}),e.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-5 text-center text-[11px] text-muted-foreground`,children:n(`activity:sddTask.noEvents`)}):(0,Q.jsx)(`div`,{className:P(`divide-y divide-border/45 overflow-auto`,t?`max-h-[32rem]`:`max-h-72`),children:e.map((e,t)=>{let n=e.kind===`file`,r=e.kind===`tool`,i=e.ok===!1||e.kind===`failed`||e.kind===`verification_failed`,a=n?x:r?p:D;return(0,Q.jsxs)(`div`,{className:P(`grid grid-cols-[4.75rem_1rem_minmax(0,1fr)] gap-2 px-3 py-2.5 text-[11px]`,i&&`bg-destructive/[0.035]`),children:[(0,Q.jsx)(`time`,{dateTime:new Date(e.ts).toISOString(),className:`font-mono text-[10px] text-muted-foreground`,title:new Date(e.ts).toLocaleString(),children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,Q.jsx)(a,{className:P(`mt-0.5 h-3.5 w-3.5`,i?`text-destructive`:n?`text-info`:r?`text-warning`:`text-primary`)}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.action&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium text-foreground`,children:e.action}),e.agentName&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.agentName}),e.durationMs!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.durationMs<1e3?`${Math.round(e.durationMs)}ms`:`${(e.durationMs/1e3).toFixed(1)}s`})]}),e.filePath?(0,Q.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[10px] leading-relaxed text-foreground`,children:e.filePath}):e.detail?(0,Q.jsx)(`code`,{className:`mt-1 block break-words font-mono text-[10px] leading-relaxed text-muted-foreground`,children:e.detail}):(0,Q.jsx)(`p`,{className:`mt-1 break-words leading-relaxed text-foreground`,children:e.text})]})]},`${e.ts}-${e.kind}-${t}`)})})]})}function Te({label:e,children:t,full:n}){return(0,Q.jsxs)(`div`,{className:P(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`text-foreground`,children:t})]})}function Ee({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:!t,onClick:()=>t&&r(t.id),className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-foreground hover:bg-muted disabled:opacity-50`,title:t?.title,children:[(0,Q.jsx)(`span`,{className:P(`h-1.5 w-1.5 rounded-full`,Y(t?.displayStatus??`pending`).dot)}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function De({onClose:e}){let{t}=c(),{client:r}=N(),i=F(e=>e.snapshot),o=F(e=>e.lifecycleResult),l=F(e=>e.destroying),u=F(e=>e.setDestroying),d=F(e=>e.setLifecycleResult),[f,p]=(0,Z.useState)(()=>Date.now()),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,ne]=(0,Z.useState)(`graph`),[y,b]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{r?.send?.({type:`sdd.board.get`})},[r]);let x=i&&(i.status===`running`||i.status===`paused`);(0,Z.useEffect)(()=>{if(!x)return;let e=setInterval(()=>p(Date.now()),1e3);return p(Date.now()),()=>clearInterval(e)},[x]);let S=(0,Z.useCallback)(e=>r?.send?.(e),[r]),w=(0,Z.useRef)(null),T=(0,Z.useCallback)(e=>{w.current=null,S({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[S]),re=(0,Z.useCallback)(e=>{b(!1),d(null),u(!0),x?(S({type:`sdd.board.stop`,payload:{}}),w.current={revertMerged:e,deadline:Date.now()+2e4}):T(e)},[x,S,T,u,d]);(0,Z.useEffect)(()=>{let e=w.current;if(!e)return;if(!x||Date.now()>=e.deadline){T(e.revertMerged);return}let t=setTimeout(()=>{let e=w.current;e&&T(e.revertMerged)},Math.max(0,e.deadline-Date.now()));return()=>clearTimeout(t)},[x,i,T]);let ie=(0,Z.useCallback)(()=>{d(null),S({type:`sdd.board.cleanup_worktrees`,payload:{}})},[S,d]),O=(0,Z.useCallback)(()=>{d(null),S({type:`sdd.board.rollback`,payload:{}})},[S,d]),A=(0,Z.useMemo)(()=>(i?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch})),[i?.tasks]),M=(0,Z.useMemo)(()=>{let e=new Map;for(let t of i?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[i?.tasks]),L=(0,Z.useCallback)(e=>h(e),[]),z=(0,Z.useCallback)(()=>{h(null),_(!1)},[]),B=(0,Z.useCallback)(e=>S({type:`sdd.board.retry`,payload:{taskId:e}}),[S]),V=(0,Z.useCallback)(()=>S({type:`sdd.board.retry_all_failed`,payload:{}}),[S]),H=(0,Z.useCallback)((e,t)=>{let n=t.trim();n&&S({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[S]),U=(0,Z.useCallback)((e,t,n)=>S({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[S]),W=(0,Z.useCallback)((e,t)=>S({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[S]),G=(0,Z.useCallback)(e=>S({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[S]),ce=(0,Z.useCallback)(e=>{S({type:`sdd.board.delete_task`,payload:{taskId:e}}),h(null),_(!1)},[S]),le=(0,Z.useCallback)((e,t)=>{S({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),h(null),_(!1)},[S]),ue=se(m!==null),J=(0,Z.useMemo)(()=>i?.tasks.find(e=>e.id===m)??null,[i?.tasks,m]),Y=i?.progress,pe=i?.diagnostics?.deadlockChains??[];return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(D,{className:`h-5 w-5 text-warning`}),(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:i?.title??t(`activity:sddBoard.titleFallback`)}),i&&(0,Q.jsx)(`span`,{className:P(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,de[i.status]??de.idle),children:i.status}),i?.defaultModel&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,title:t(`activity:sddBoard.defaultModelTitle`),children:[(0,Q.jsx)(oe,{className:`h-3 w-3 text-primary`}),i.defaultModel]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,Q.jsxs)(`button`,{type:`button`,title:t(`activity:sddBoardView.openTheMirroredKanbanBoardSForThisRunOnePerDependencyWave`),onClick:()=>{let e=`run:${i.runId}`,t=I.getState().boards.filter(t=>t.tags?.includes(e)),n=t.find(e=>e.tags?.includes(`phase:wave-0`))??t[0];n&&(I.getState().setActiveBoardId(n.id),r?.send?.({type:`kanban.get`,payload:{boardId:n.id}})),R.getState().setCurrentView(`kanban`)},className:`inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5`}),` Kanban`]}),i&&(0,Q.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ne(e),className:P(`rounded px-2 py-0.5 capitalize transition`,v===e?`bg-primary/12 text-primary`:`text-muted-foreground hover:text-foreground`),children:t(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),x&&(Y?.failed??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:V,title:t(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(k,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.retryFailed`,{count:Y?.failed??0})]}),x&&(0,Q.jsxs)(Q.Fragment,{children:[i?.status===`paused`?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(te,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.resume`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.pause`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/25`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.stop`)]})]}),i&&!x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:ie,title:t(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80`,children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.cleanWorktrees`)]}),(i.mergedCommits?.length??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:O,title:t(`activity:sddBoard.rollbackTitle`,{count:i.mergedCommits?.length??0,base:i.baseBranch??t(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(s,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.rollback`,{count:i.mergedCommits?.length??0})]})]}),i&&(l?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive`,children:[(0,Q.jsx)(k,{className:`h-3.5 w-3.5 animate-spin`}),` `,t(x?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),title:t(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-destructive px-2.5 py-1 text-xs font-medium text-destructive-foreground hover:bg-destructive/90`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,t(`activity:sddBoard.destroy`)]})),(0,Q.jsx)(K,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(C,{className:`h-4 w-4`})})]})]}),i&&Y&&(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,Q.jsx)(ge,{pct:Y.percentComplete}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statDone`),value:`${Y.completed}/${Y.total}`,color:`text-success`}),Y.inProgress>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statRunning`),value:Y.inProgress,color:`text-warning`}),Y.failed>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statFailed`),value:Y.failed,color:`text-destructive`}),(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statWave`),value:i.wave+1,color:`text-primary`}),x&&i.startedAt>0&&(0,Q.jsx)(Ae,{label:t(`activity:sddBoard.statElapsed`),value:X(f-i.startedAt),color:`text-foreground`})]}),(0,Q.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:M.length===0?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:sddBoard.noActiveWorkers`)}):M.map((e,t)=>(0,Q.jsxs)(`span`,{title:`${e.name} → ${e.task}`,className:`flex items-center gap-1 rounded-full bg-muted py-0.5 pl-0.5 pr-2`,children:[(0,Q.jsx)(`span`,{className:P(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,fe[t%fe.length]),children:q(e.name)}),(0,Q.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,Q.jsx)(ke,{result:o,onDismiss:()=>d(null)}),pe.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,Q.jsx)(ee,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-semibold`,children:t(`activity:sddBoard.deadlock`)}),pe.map(e=>(0,Q.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:i?v===`graph`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(he,{tasks:A,columns:i.columns,onTaskClick:L}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur`,children:t(`activity:sddBoard.clickTaskHint`)})]}):(0,Q.jsx)(xe,{tasks:i.tasks,selectedId:m,onTaskClick:L}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(j,{className:`h-10 w-10 text-primary/40`}),(0,Q.jsx)(`p`,{className:`text-foreground`,children:t(`activity:sddBoard.noRunTitle`)}),(0,Q.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:t(`activity:sddBoard.noRunBody`)})]})}),i&&(0,Q.jsx)(`aside`,{"data-testid":`sdd-task-panel`,"data-expanded":g&&J?`true`:`false`,className:P(`shrink-0 border-l border-border bg-card transition-[width] duration-200 ease-out`,g&&J?`w-[min(72rem,72vw)]`:`w-80`),children:J?(0,Q.jsx)(Ce,{task:J,allTasks:i.tasks,feed:i.taskEvents?.[J.id]??i.feed??[],now:f,expanded:g,modelCandidates:ue,defaultModel:i.defaultModel,onClose:z,onToggleExpanded:()=>_(e=>!e),onRetry:B,onReassign:H,onSetModel:U,onSetVerification:W,onCancel:G,onDelete:ce,onSplit:le,onSelectTask:h},J.id):(0,Q.jsx)(ve,{feed:i.feed??[],now:f})})]}),(0,Q.jsx)(ye,{open:y,onOpenChange:b,snapshot:i,busy:l,onConfirm:re})]})}function Oe(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=_.t(`activity:sddBoard.${t}`);if(!e.ok)return _.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??_.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(_.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(_.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(_.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):_.t(`activity:sddBoard.lcNothing`);return e.reason?_.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):_.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function ke({result:e,onDismiss:t}){let n=!e.ok||!!e.reason;return(0,Q.jsxs)(`div`,{className:P(`flex items-start gap-2 border-b px-4 py-2 text-xs`,n?`border-warning/30 bg-warning/5 text-warning`:`border-success/30 bg-success/5 text-success`),children:[n?(0,Q.jsx)(f,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,Q.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Oe(e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,Q.jsx)(C,{className:`h-3.5 w-3.5`})})]})}function Ae({label:e,value:t,color:n}){return(0,Q.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,Q.jsx)(`span`,{className:P(`font-semibold tabular-nums`,n),children:t}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}var je={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},Me=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function Ne({onClose:e,onRunStarted:n}){let{t:r}=c(),{client:a}=N(),o=L(e=>e.snapshot),s=L(e=>e.agentText),l=L(e=>e.error),d=L(e=>e.startedRunId),f=L(e=>e.setStartedRunId),[p,ee]=(0,Z.useState)(``),[m,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[te,ne]=(0,Z.useState)(!0),[x,ie]=(0,Z.useState)(!0),[E,D]=(0,Z.useState)(!1),[O,ae]=(0,Z.useState)(void 0),[k,A]=(0,Z.useState)(void 0),[j,oe]=(0,Z.useState)([]),[M,F]=(0,Z.useState)(4),[I,R]=(0,Z.useState)(!0),[z,B]=(0,Z.useState)(!1),V=se(E),H=(0,Z.useCallback)(e=>a?.send?.(e),[a]),U=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{H({type:`sdd.spec.get`})},[H]),(0,Z.useEffect)(()=>{U.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[o?.answers.length??0,s]),(0,Z.useEffect)(()=>{d&&(f(null),n?.())},[n,f,d]);let W=o?.busy??!1,G=o?.phase??`idle`,q=!!o?.sessionId,de=!!o?.resumed,Y=o?.lastRunId;(0,Z.useEffect)(()=>{q&&v(!1)},[q]);let fe=o?.answers[o.answers.length-1]?.question??``,pe=!!o&&(o.taskCount>0||!!o.graphId||G===`task_review`||G===`executing`),me=()=>{let e=p.trim();!e||W||_||(v(!0),H({type:`sdd.spec.start`,payload:{goal:e}}))},X=()=>{let e=m.trim();!e||W||(H({type:`sdd.spec.message`,payload:{text:e}}),g(``))},ge=()=>!W&&H({type:`sdd.spec.approve`,payload:{}}),_e=()=>{H({type:`sdd.run.start`,payload:{parallelSlots:M,worktrees:I,planDecompose:z,...O?{model:O,provider:k}:{},...j.length?{fallbackModels:j}:{}}}),D(!1)},ve=()=>{W||H({type:`sdd.spec.discard`,payload:{}})},ye=(0,Z.useMemo)(()=>(o?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[o?.board]),be=ye.length>0;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(y,{className:`h-5 w-5 text-primary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:o?.title||r(`activity:sddWizard.titleFallback`)}),q&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r(`activity:sddWizard.${je[G]??`phaseStart`}`),G===`questioning`&&` · ${r(`activity:sddWizard.questionsSuffix`,{cur:o?.questionCount??0,max:o?.maxQuestions??0})}`,o&&o.taskCount>0?` · ${r(`activity:sddWizard.tasksSuffix`,{count:o.taskCount})}`:``]})]}),W&&(0,Q.jsx)(S,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n?.(),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(T,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.openLiveBoard`)]}),q&&(0,Q.jsx)(`button`,{type:`button`,onClick:ve,disabled:W,title:r(`activity:sddWizard.discardTitle`),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-destructive disabled:opacity-50`,children:r(`activity:sddWizard.discardInterview`)}),pe&&(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>!e),title:r(`activity:sddWizard.runCfgTitle`),className:P(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,O||j.length||z?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(u,{className:`h-3.5 w-3.5`}),O||r(`activity:sddWizard.modelsLabel`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:_e,className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(T,{className:`h-3.5 w-3.5`}),` `,r(`activity:sddWizard.startRun`)]}),E&&(0,Q.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.defaultWorkerModel`)}),(0,Q.jsx)(ce,{value:O,provider:k,candidates:V,placeholder:r(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:r(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{ae(e),A(t)},onReset:O?()=>{ae(void 0),A(void 0)}:void 0}),(0,Q.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.fallbackChain`)}),(0,Q.jsx)(ue,{value:j,candidates:V,onChange:oe}),(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:r(`activity:sddWizard.appliesToAll`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.parallelAgents`)}),(0,Q.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:M,onChange:e=>{let t=Number.parseInt(e.target.value,10);F(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-primary`})]}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.isolateWorktrees`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:I,onChange:e=>R(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(I?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:r(`activity:sddWizard.planDecompose`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>B(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:r(z?`activity:sddWizard.planDecomposeOn`:`activity:sddWizard.planDecomposeOff`)})]})]}),(0,Q.jsx)(K,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(C,{className:`h-4 w-4`})})]})]}),q&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:Me.map((e,t)=>{let n=e===G,i=Me.indexOf(G)>t;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:P(`rounded-full px-2 py-0.5`,n?`bg-primary/15 text-primary`:i?`text-success`:`text-muted-foreground`),children:[i&&(0,Q.jsx)(w,{className:`mr-0.5 inline h-3 w-3`}),r(`activity:sddWizard.${je[e]}`)]}),t<Me.length-1&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65`,children:`→`})]},e)})}),(0,Q.jsxs)(`div`,{ref:le(`sdd-wizard`),className:`min-h-0 flex-1 overflow-auto overscroll-contain p-4`,children:[l&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:l}),de&&q&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-xs text-primary`,children:r(`activity:sddWizard.resumeBanner`)}),q?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[be&&(0,Q.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-primary/20 bg-[hsl(var(--surface-2)/0.85)]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ne(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-muted/40`,children:[te?(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(i,{className:`h-3.5 w-3.5`}),r(`activity:sddWizard.taskGraphSummary`,{count:o?.taskCount??0}),(0,Q.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:r(te?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),te&&(0,Q.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,Q.jsx)(he,{tasks:ye,columns:o?.board?.columns??[]})})]}),(0,Q.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[o?.goal&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(h,{className:`h-3 w-3`}),` `,r(`activity:sddWizard.goalLabel`)]}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:o.goal})]}),o?.answers.length||s&&G===`questioning`||W?(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[o?.answers.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Q.jsx)(Fe,{speaker:`assistant`,text:e.question}),(0,Q.jsx)(Fe,{speaker:`user`,text:e.answer})]},e.question.slice(0,64))),s&&G===`questioning`&&s!==fe&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:s}),W&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:``,thinking:!0})]}):null,o?.spec&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,Q.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),o.spec.title]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o.spec.overview}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:o.spec.requirements.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:P(`shrink-0 font-mono uppercase`,J(e.priority).text),children:e.priority[0]}),(0,Q.jsx)(`span`,{children:e.description})]},`${e.priority}-${e.description.slice(0,32)}`))})]}),s&&(G===`implementation`||G===`task_review`)&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[x?(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(b,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(y,{className:`h-3.5 w-3.5 text-primary`}),` `,r(`activity:sddWizard.implementationPlan`)]}),x&&(0,Q.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:Pe(s)})})]}),s&&G!==`questioning`&&G!==`implementation`&&G!==`task_review`&&!o?.spec&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:s}),(G===`spec_review`||G===`implementation`||G===`task_review`)&&(0,Q.jsxs)(K,{variant:`secondary`,onClick:ge,disabled:W,children:[(0,Q.jsx)(w,{className:`mr-1.5 h-4 w-4`}),r(G===`spec_review`?`activity:sddWizard.approveSpec`:G===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,Q.jsx)(`div`,{ref:U})]})]}):(0,Q.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,Q.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:r(`activity:sddWizard.goalPrompt`)}),(0,Q.jsx)(`textarea`,{id:`sdd-goal`,value:p,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&me()},rows:4,placeholder:r(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-primary`}),(0,Q.jsx)(K,{className:`mt-3`,onClick:me,disabled:!p.trim()||_,children:_?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,r(`activity:sddWizard.startingInterview`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{className:`mr-1.5 h-4 w-4`}),` `,r(`activity:sddWizard.startInterview`)]})}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:r(`activity:sddWizard.introBody`)})]})]}),q&&G!==`executing`&&G!==`done`&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,Q.jsx)(`textarea`,{value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),X())},rows:1,placeholder:r(G===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:W,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary disabled:opacity-50`}),(0,Q.jsx)(K,{size:`icon`,onClick:X,disabled:W||!m.trim(),children:(0,Q.jsx)(re,{className:`h-4 w-4`})})]})]})}function Pe(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function Fe({speaker:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,Q.jsxs)(`div`,{className:P(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,Q.jsx)(`span`,{className:P(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-info/15 text-info`:`bg-primary/15 text-primary`,(n||r)&&`sdd-agent-live`),children:i?(0,Q.jsx)(M,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(A,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:P(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-info/10`:`rounded-tl-sm bg-muted`),children:r?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}var $=[{id:`project`,labelKey:`activity:sddhub.tabProject`},{id:`board`,labelKey:`activity:sddhub.tabBoard`},{id:`specs`,labelKey:`activity:sddhub.tabSpecs`}];function Ie(){let{t:e}=c(),[t,n]=(0,Z.useState)(`project`),r=L(e=>e.startedRunId),i=L(e=>e.setStartedRunId),a=()=>z(`chat`),o=(0,Z.useCallback)(()=>n(`board`),[]);(0,Z.useEffect)(()=>{r&&(n(`board`),i(null))},[r,i]);let s=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+$.length)%$.length),e.key===`ArrowRight`&&(r=(t+1)%$.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=$.length-1),r===void 0)return;e.preventDefault();let i=$[r];i&&(n(i.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`flex shrink-0 items-end border-b border-border/70 bg-card px-4`,children:$.map((r,i)=>{let a=t===r.id;return(0,Q.jsxs)(`button`,{id:`sdd-hub-tab-${r.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`sdd-hub-panel-${r.id}`,tabIndex:a?0:-1,onClick:()=>n(r.id),onKeyDown:e=>s(e,i),className:P(`relative px-4 py-2.5 text-sm font-medium transition-colors`,a?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e(r.labelKey),a&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-0.5 bg-primary`})]},r.id)})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{id:`sdd-hub-panel-project`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-project`,hidden:t!==`project`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ne,{onClose:a,onRunStarted:o})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-board`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-board`,hidden:t!==`board`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(De,{onClose:a})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-specs`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-specs`,hidden:t!==`specs`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(_e,{onClose:a,onRunStarted:o})})]})]})}export{Ie as SddHub};