forge-openclaw-plugin 0.2.102 → 0.2.103

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 (174) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/{ai-surface-workspace-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
  3. package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
  4. package/dist/assets/{board-DqHzdCPQ.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/{calendar-week-toolbar-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
  8. package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
  15. package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-CmLAyGqz.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/{insight-flow-dialog-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
  32. package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
  35. package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
  39. package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
  40. package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-DogvVNEn.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/{psyche-behaviors-page-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
  50. package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
  51. package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
  52. package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
  53. package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
  55. package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
  56. package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
  57. package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
  58. package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
  59. package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
  60. package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
  61. package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
  62. package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
  63. package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
  64. package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
  65. package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
  67. package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
  68. package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
  69. package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
  70. package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
  74. package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
  75. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  76. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  77. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  78. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  79. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  80. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  81. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  82. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  83. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  84. package/dist/assets/{settings-section-nav-Dc4IeVBt.js → settings-section-nav-DP9o4peU.js} +1 -1
  85. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  86. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  87. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  88. package/dist/assets/sports-page-BldIiclr.js +1 -0
  89. package/dist/assets/{state-VYvD1QVP.js → state-vCcAT5Hq.js} +1 -1
  90. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  91. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  92. package/dist/assets/{strategy-dialog-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
  93. package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
  94. package/dist/assets/{table-C0VTeqw0.js → table-BNqMG3_S.js} +1 -1
  95. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  96. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  97. package/dist/assets/today-page-BjDijtn8.js +1 -0
  98. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  99. package/dist/assets/{ui-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
  100. package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
  101. package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
  102. package/dist/assets/{vitals-page-Dz1Jt5H8.js → vitals-page-CE9zdGLF.js} +1 -1
  103. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  104. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  105. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  106. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  107. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  108. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  109. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  110. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  111. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  112. package/dist/assets/{workout-detail-page-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
  113. package/dist/index.html +9 -9
  114. package/dist/server/server/src/app.js +22 -3
  115. package/dist/server/server/src/health-weight-loss.js +114 -39
  116. package/dist/server/server/src/repositories/model-settings.js +9 -3
  117. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  118. package/dist/server/src/lib/api.js +10 -1
  119. package/openclaw.plugin.json +1 -1
  120. package/package.json +1 -1
  121. package/dist/assets/activity-page-CgF7K2ww.js +0 -1
  122. package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
  123. package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
  124. package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
  125. package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
  126. package/dist/assets/execution-board-CpO2ch6v.js +0 -1
  127. package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
  128. package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
  129. package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
  130. package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
  131. package/dist/assets/index-BHIKoiZ6.js +0 -19
  132. package/dist/assets/index-H8R-ABM3.css +0 -1
  133. package/dist/assets/insights-page-CujrosD_.js +0 -8
  134. package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
  135. package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
  136. package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
  137. package/dist/assets/movement-page-ClaoTNuX.js +0 -1
  138. package/dist/assets/notes-page-DYI8s3NN.js +0 -1
  139. package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
  140. package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
  141. package/dist/assets/project-collections-CZagCmeH.js +0 -1
  142. package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
  143. package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
  144. package/dist/assets/projects-page-UKrby_5-.js +0 -1
  145. package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
  146. package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
  147. package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
  148. package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
  149. package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
  150. package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
  151. package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
  152. package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
  153. package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
  154. package/dist/assets/settings-page-B4u5TR5g.js +0 -1
  155. package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
  156. package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
  157. package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
  158. package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
  159. package/dist/assets/sports-page-l1RqXzA_.js +0 -1
  160. package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
  161. package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
  162. package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
  163. package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
  164. package/dist/assets/today-page-CIuFHMi1.js +0 -1
  165. package/dist/assets/training-load-page-BIwc648i.js +0 -1
  166. package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
  167. package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
  168. package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
  169. package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
  170. package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
  171. package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
  172. package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
  173. package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
  174. package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as p,j as e,cA as W,cx as K,cE as V,cC as Z,aC as B,cc as J,b5 as X}from"./vendor-Dnkkx2co.js";import{j as Y,i as ee,k as A}from"./state-vCcAT5Hq.js";import{O as se}from"./open-in-graph-button-BFPKfyK3.js";import{P as te}from"./preference-entity-handoff-button-Dj3V6VxL.js";import{a as ae,i as re,b as ie,S as ne}from"./strategy-dialog-7X7peRzu.js";import{i as le,C as oe,B as de,M as ce}from"./graph-DDUZNRsO.js";import{c as m,U as _,u as ue,s as xe,bZ as F,b$ as me,L as ge,E as G,B as L,C as k,W as pe,bq as he,c0 as fe}from"./index-EqQsXoat.js";import{P as ve}from"./page-hero-ffKzgyW3.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";function Q(a){const i=new Map;for(const r of a.nodes)i.set(r.id,[]);for(const r of a.edges)i.set(r.to,[...i.get(r.to)??[],r.from]);const o=new Map,d=r=>{const c=o.get(r);if(c!==void 0)return c;const j=i.get(r)??[],h=j.length===0?0:Math.max(...j.map(l=>d(l)))+1;return o.set(r,h),h};for(const r of a.nodes)d(r.id);return o}function be(a){const i=Q(a),o=new Map;for(const d of a.nodes){const r=i.get(d.id)??0;o.set(r,[...o.get(r)??[],d.id])}return Array.from(o.entries()).sort((d,r)=>d[0]-r[0]).map(([d,r])=>({level:d,nodeIds:r}))}function je(a,i){const o=Q(a.graph),d=new Map;for(const r of a.graph.nodes){const c=o.get(r.id)??0;d.set(c,[...d.get(c)??[],r.id])}return a.graph.nodes.map(r=>{const c=o.get(r.id)??0,j=(d.get(c)??[]).indexOf(r.id),h=a.metrics.activeNodeIds.includes(r.id),l=a.metrics.blockedNodeIds.includes(r.id),x=a.metrics.outOfOrderNodeIds.includes(r.id),v=!h&&!l&&!x,s=(i==null?void 0:i.get(r.id))??null;let g="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",n="bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]";return h?(g="border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle))] bg-[var(--ui-success-soft)]",n="bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]"):l?(g="border-[color-mix(in_srgb,var(--danger)_32%,var(--ui-border-subtle))] bg-[var(--ui-danger-soft)]",n="bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_78%,var(--ui-ink-strong)_22%)]"):x?(g="border-[color-mix(in_srgb,var(--warning)_34%,var(--ui-border-subtle))] bg-[var(--ui-warning-soft)]",n="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"):a.metrics.completedNodeCount>0&&(g="border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle))] bg-[var(--ui-info-soft)]",n="bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]"),{id:r.id,position:{x:72+c*308,y:56+j*168},draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`w-[min(17rem,calc(100vw-5rem))] min-w-0 max-w-[17rem] rounded-[22px] border px-4 py-4 shadow-[var(--ui-shadow-soft)] ${g}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(m,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:r.entityType}),h?e.jsx(m,{className:n,children:"Active"}):null,l?e.jsx(m,{className:n,children:"Blocked"}):null,x?e.jsx(m,{className:n,children:"Out of order"}):null,v&&!l&&!x?e.jsx(m,{className:n,children:"In plan"}):null]}),e.jsx("div",{className:"mt-3 break-words text-base font-medium leading-6 text-[var(--ui-ink-strong)]",children:r.title}),r.branchLabel?e.jsx("div",{className:"mt-2 break-words text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:r.branchLabel}):null,r.notes?e.jsx("div",{className:"mt-2 break-words text-sm leading-5 text-[var(--ui-ink-soft)]",children:r.notes}):null,s?e.jsxs("div",{className:"mt-3 flex min-w-0 items-center gap-2 text-xs text-[var(--ui-ink-faint)]",children:[e.jsx("span",{className:"inline-block size-2.5 rounded-full",style:{backgroundColor:s.color}}),e.jsx("span",{className:"min-w-0 break-words",children:s.label})]}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function ye(a){return a.graph.edges.map(i=>{const o=a.metrics.activeNodeIds.includes(i.to),d=a.metrics.blockedNodeIds.includes(i.to),r=a.metrics.outOfOrderNodeIds.includes(i.to);let c="var(--ui-border-strong)";return o?c="var(--success)":d?c="var(--danger)":r&&(c="var(--warning)"),{id:`${i.from}->${i.to}`,source:i.from,target:i.to,label:i.label||void 0,animated:o,markerEnd:{type:ce.ArrowClosed,color:c},style:{stroke:c,strokeWidth:o?2.4:1.5},labelStyle:{fill:"var(--ui-ink-soft)",fontSize:11,fontWeight:600}}})}function we({strategy:a,ownerByNodeId:i,heightClassName:o="h-[540px]"}){const d=p.useMemo(()=>je(a,i),[i,a]),r=p.useMemo(()=>ye(a),[a]);return e.jsx("div",{className:`${o} min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]`,children:e.jsxs(le,{fitView:!0,nodes:d,edges:r,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",children:[e.jsx(oe,{showInteractive:!1}),e.jsx(de,{gap:28,size:1,color:"var(--ui-border-subtle)"})]})})}function Ne(a,i){const o=a.metrics.activeNodeIds.includes(i),d=a.metrics.blockedNodeIds.includes(i),r=a.metrics.outOfOrderNodeIds.includes(i);return d?{label:"Blocked",className:"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_78%,var(--ui-ink-strong)_22%)]"}:r?{label:"Out of order",className:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}:o?{label:"Ready now",className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]"}:{label:"In plan",className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]"}}function ke({strategy:a,projectsById:i,tasksById:o,className:d}){const r=p.useMemo(()=>be(a.graph),[a.graph]),c=p.useMemo(()=>{const l=new Map;for(const x of a.graph.nodes)l.set(x.id,[]);for(const x of a.graph.edges)l.set(x.to,[...l.get(x.to)??[],x.from]);return l},[a.graph]),[j,h]=p.useState([]);return e.jsxs("div",{className:d??"grid gap-3",children:[r.map(l=>{const x=j.includes(l.level),v=l.level===0?"Launch phase":`Phase ${l.level+1}`,s=l.nodeIds.length>1;return e.jsxs("div",{className:"min-w-0 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-4",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-3 text-left",onClick:()=>h(g=>x?g.filter(n=>n!==l.level):[...g,l.level]),children:[e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-3)] p-2 text-[var(--ui-ink-soft)]",children:x?e.jsx(W,{className:"size-4"}):e.jsx(K,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:v}),e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)]",children:s?"These branches can progress in parallel once the previous phase is complete.":"This phase advances as one focused step in the strategy."})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(m,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:[l.nodeIds.length," node",l.nodeIds.length===1?"":"s"]}),e.jsx(m,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:s?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"mr-1 size-3.5"}),"Parallel"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"mr-1 size-3.5"}),"Sequential"]})})]})]}),x?null:e.jsx("div",{className:"grid min-w-0 gap-3 border-t border-[var(--ui-border-subtle)] px-4 py-4 lg:grid-cols-2",children:l.nodeIds.map(g=>{var T,N,O;const n=a.graph.nodes.find(f=>f.id===g);if(!n)return null;const w=n.entityType==="project"?i.get(n.entityId):o.get(n.entityId),M=n.entityType==="project"?`/projects/${n.entityId}`:`/tasks/${n.entityId}`,I=n.entityType==="project"?(T=i.get(n.entityId))==null?void 0:T.user:(N=o.get(n.entityId))==null?void 0:N.user,b=((O=c.get(n.id))==null?void 0:O.map(f=>{var P;return((P=a.graph.nodes.find($=>$.id===f))==null?void 0:P.title)??f}))??[],y=Ne(a,n.id);return e.jsxs("div",{className:"min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(m,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:n.entityType}),e.jsx(m,{className:y.className,children:y.label})]}),e.jsx(B,{to:M,className:"mt-3 block break-words text-lg font-medium text-[var(--ui-ink-strong)] transition hover:text-[var(--primary)]",children:n.title}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:n.notes||("description"in(w??{})?w==null?void 0:w.description:"")||"No extra step note attached yet."})]}),e.jsx(_,{user:I,compact:!0})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[n.branchLabel?e.jsx(m,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:n.branchLabel}):null,b.length===0?e.jsx(m,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",children:"Start node"}):b.map(f=>e.jsxs(m,{className:"max-w-full break-words bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:["Depends on ",f]},`${n.id}:${f}`))]})]},n.id)})})]},l.level)}),r.length===0?e.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No phases mapped yet."}):null]})}function De(){var $;const a=ue(),{strategyId:i}=J(),o=X(),d=Y(),[r,c]=p.useState(!1),[j,h]=p.useState(),l=xe(a.selectedUserIds),x=a.snapshot.strategies.find(t=>t.id===i)??null,v=ee({queryKey:["strategy-detail",i],queryFn:async()=>(await fe(i)).strategy,enabled:!!(i&&!x)}),s=x??v.data??null,g=async()=>{await Promise.all([d.invalidateQueries({queryKey:["strategy-detail",i]}),a.refresh()])},n=A({mutationFn:async({input:t,currentStrategyId:u})=>(await F(u,t)).strategy,onSuccess:g}),w=A({mutationFn:async t=>me(t),onSuccess:async()=>{await g(),o("/strategies")}}),M=A({mutationFn:async t=>(await F(i,{isLocked:t,lockedByUserId:t?l??(s==null?void 0:s.userId)??"user_operator":null})).strategy,onSuccess:g}),I=p.useMemo(()=>new Map(a.snapshot.goals.map(t=>[t.id,t])),[a.snapshot.goals]),b=p.useMemo(()=>new Map(a.snapshot.dashboard.projects.map(t=>[t.id,t])),[a.snapshot.dashboard.projects]),y=p.useMemo(()=>new Map(a.snapshot.tasks.map(t=>[t.id,t])),[a.snapshot.tasks]),T=p.useMemo(()=>s?new Map(s.graph.nodes.map(t=>{var S,C;const u=t.entityType==="project"?(S=b.get(t.entityId))==null?void 0:S.user:(C=y.get(t.entityId))==null?void 0:C.user;return[t.id,u?{label:`${u.displayName} (${u.kind})`,color:u.accentColor}:null]})):new Map,[b,s,y]),N=s??{title:"",overview:"",endStateDescription:"",targetGoalIds:[],targetProjectIds:[],graph:{nodes:[],edges:[]}},O=p.useMemo(()=>ae(N),[N]),f=p.useMemo(()=>re(N),[N]),P=p.useMemo(()=>ie((s==null?void 0:s.metrics)??{planCoverageScore:0,sequencingScore:0,scopeDisciplineScore:0,qualityScore:0,targetProgressScore:0,startedNodeCount:0,totalNodeCount:1,offPlanEntityCount:0,offPlanActiveEntityCount:0,blockedNodeIds:[],outOfOrderNodeIds:[]}),[s==null?void 0:s.metrics]);return v.isLoading&&!s?e.jsx(ge,{eyebrow:"Strategy",title:"Loading strategy",description:"Resolving the directed plan, targets, and current alignment."}):v.isError?e.jsx(G,{eyebrow:"Strategy",error:v.error,onRetry:()=>void v.refetch()}):s?e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ve,{title:s.title,titleText:s.title,description:s.overview||s.endStateDescription,badge:`${s.metrics.alignmentScore}% aligned`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(te,{userId:l,domain:"strategies",entityType:"strategy",entityId:s.id,label:s.title,description:s.overview||s.endStateDescription}),e.jsx(se,{entityType:"strategy",entityId:s.id}),s.isLocked?null:e.jsx(L,{variant:"secondary",onClick:()=>{h(void 0),c(!0)},children:"Edit strategy"}),e.jsx(L,{variant:"secondary",disabled:!s.isLocked&&!f,pending:M.isPending,pendingLabel:s.isLocked?"Unlocking contract":"Locking contract",onClick:()=>{M.mutateAsync(!s.isLocked)},children:s.isLocked?"Unlock contract":"Lock as contract"}),e.jsx(L,{variant:"secondary",pending:w.isPending,pendingLabel:"Deleting strategy",onClick:()=>{window.confirm(`Delete strategy "${s.title}"?`)&&w.mutateAsync(s.id)},children:"Delete"})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_,{user:s.user}),e.jsx(m,{className:s.isLocked?"bg-amber-500/12 text-amber-200":"bg-emerald-500/12 text-emerald-200",children:s.isLocked?"Contract locked":"Editable draft"}),e.jsx(m,{className:"bg-white/[0.08] text-white/76",children:s.status}),e.jsxs(m,{className:"bg-white/[0.08] text-white/76",children:[s.graph.nodes.length," nodes"]}),e.jsxs(m,{className:"bg-white/[0.08] text-white/76",children:[s.graph.edges.length," edges"]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(18rem,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(k,{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"End state"}),e.jsx("div",{className:"text-sm leading-7 text-white/64",children:s.endStateDescription||"No end-state description yet."})]}),e.jsxs(k,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Directed execution graph"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"The graph is the contract surface for this strategy. It shows which branches are available now, where work is blocked, and whether any node is moving out of sequence."})]}),s.isLocked?null:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(L,{variant:"secondary",onClick:()=>{h("sequence"),c(!0)},children:"Refine sequence"}),e.jsx(L,{onClick:()=>{h("sequence"),c(!0)},children:"Add parallel work"})]})]}),e.jsx(we,{strategy:s,ownerByNodeId:T}),e.jsx(ke,{strategy:s,projectsById:b,tasksById:y})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Contract state"}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:s.isLocked?"This strategy is currently locked as a contract. The graph, targets, and descriptive plan stay frozen until you explicitly unlock it.":"This strategy is still a draft. Agents and users can keep refining the plan until you lock it."}),s.isLocked?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-sm text-white/60",children:[e.jsxs("span",{children:["Locked by"," ",(($=s.lockedByUser)==null?void 0:$.displayName)??"Unknown user"]}),s.lockedAt?e.jsxs("span",{children:["· ",new Date(s.lockedAt).toLocaleString()]}):null]}):null,s.isLocked?null:e.jsx("div",{className:"mt-4 grid gap-2",children:O.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-white/[0.03] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-white/64",children:t.label}),e.jsx(m,{className:t.satisfied?"bg-emerald-500/12 text-emerald-200":"bg-amber-500/12 text-amber-200",children:t.satisfied?"Ready":"Missing"})]},t.id))})]}),!s.isLocked&&!f?e.jsx("div",{className:"rounded-[18px] border border-amber-400/18 bg-amber-500/[0.08] px-4 py-3 text-sm leading-6 text-amber-100/86",children:"Add a target goal or project plus an overview or end state before locking this draft as the execution contract."}):null,s.isLocked?null:e.jsx("div",{className:"mt-4 text-xs leading-5 text-white/46",children:"Drafts may stay incomplete while humans and agents negotiate the plan. Only the lock action requires the contract checks to pass."})]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Alignment metrics"}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/56",children:"Alignment score"}),e.jsxs("div",{className:"mt-2 font-display text-3xl text-[var(--primary)]",children:[s.metrics.alignmentScore,"%"]}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-white/48",children:[s.metrics.startedNodeCount,"/",s.metrics.totalNodeCount," planned nodes started,"," ",s.metrics.completedNodeCount," completed,"," ",s.metrics.readyNodeCount," ready now."]})]}),P.map(t=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm text-white/56",children:t.label}),e.jsxs("div",{className:"text-sm font-medium text-white",children:[t.value,"%"]})]}),e.jsx(pe,{value:t.value,className:"mt-3"}),e.jsx("div",{className:"mt-3 text-xs leading-5 text-white/48",children:t.detail})]},t.id))]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"End targets"}),s.targetGoalIds.map(t=>{const u=I.get(t);return u?e.jsx(B,{to:`/goals/${u.id}`,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{children:["Goal: ",u.title]}),e.jsx(_,{user:u.user,compact:!0})]})},u.id):null}),s.targetProjectIds.map(t=>{const u=b.get(t);return u?e.jsx(B,{to:`/projects/${u.id}`,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{children:["Project: ",u.title]}),e.jsx(_,{user:u.user,compact:!0})]})},u.id):null}),s.targetGoalIds.length===0&&s.targetProjectIds.length===0?e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:"No end targets linked yet."}):null]}),e.jsxs(k,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Linked entities"}),s.linkedEntities.length===0?e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:"No additional linked entities."}):s.linkedEntities.map(t=>{var C,D,E,q,R,U,z;const u=he(t.entityType,t.entityId),S=t.entityType==="goal"?(C=I.get(t.entityId))==null?void 0:C.title:t.entityType==="project"?(D=b.get(t.entityId))==null?void 0:D.title:t.entityType==="task"?(E=y.get(t.entityId))==null?void 0:E.title:`${t.entityType}:${t.entityId}`;return u?e.jsx(B,{to:u,className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/78 transition hover:bg-white/[0.08]",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:S}),e.jsx(_,{user:t.entityType==="goal"?(q=I.get(t.entityId))==null?void 0:q.user:t.entityType==="project"?(R=b.get(t.entityId))==null?void 0:R.user:t.entityType==="task"?(U=y.get(t.entityId))==null?void 0:U.user:t.entityType==="strategy"?(z=a.snapshot.strategies.find(H=>H.id===t.entityId))==null?void 0:z.user:null,compact:!0})]})},`${t.entityType}:${t.entityId}`):e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/52",children:S},`${t.entityType}:${t.entityId}`)})]})]})]}),e.jsx(ne,{open:r,pending:n.isPending,editingStrategy:s,goals:a.snapshot.dashboard.goals,projects:a.snapshot.dashboard.projects,tasks:a.snapshot.tasks,habits:a.snapshot.habits,strategies:a.snapshot.strategies,users:a.snapshot.users,defaultUserId:l,initialStepId:j,onOpenChange:t=>{c(t),t||h(void 0)},onSubmit:async t=>{await n.mutateAsync({input:t,currentStrategyId:s.id})}})]}):e.jsx(G,{eyebrow:"Strategy",error:new Error("Strategy not found."),onRetry:()=>o("/strategies")})}export{De as StrategyDetailPage};
@@ -1 +1 @@
1
- import{j as e,bJ as gt,c7 as ht,b3 as ye,b4 as We,r as p,cb as xt}from"./vendor-kIz9EZnX.js";import{b as vt,C as ft,u as bt,a as yt,P as jt,D as It,c as Nt,S as wt,v as kt,d as St}from"./board-DqHzdCPQ.js";import{c as G,b as R,U as H,B as Q,F as T,j as Je,I as Y,T as ue,Z as ce,W as Ct,bl as ae,Q as Mt,bk as Tt,a0 as Pt,a1 as Et,V as Re,al as Gt}from"./index-BHIKoiZ6.js";function Ye(s){return[{id:"title",label:"Strategy title is set",satisfied:s.title.trim().length>0},{id:"graph",label:"Graph contains at least one linked project or task",satisfied:s.graph.nodes.length>0},{id:"targets",label:"At least one target goal or project is selected",satisfied:s.targetGoalIds.length>0||s.targetProjectIds.length>0},{id:"narrative",label:"The plan already names an overview or end state",satisfied:s.overview.trim().length>0||s.endStateDescription.trim().length>0}]}function $t(s){return Ye(s).every(d=>d.satisfied)}function qt(s){return[{id:"coverage",label:"Agreed work moving",value:s.planCoverageScore,detail:`${s.startedNodeCount}/${s.totalNodeCount} agreed steps have started or finished.`},{id:"order",label:"Order respected",value:s.sequencingScore,detail:`${s.outOfOrderNodeIds.length} step${s.outOfOrderNodeIds.length===1?"":"s"} started before prerequisites were complete.`},{id:"scope",label:"Scope held",value:s.scopeDisciplineScore,detail:`${s.offPlanEntityCount} unagreed item${s.offPlanEntityCount===1?"":"s"} are inside the strategy scope, ${s.offPlanActiveEntityCount} still active.`},{id:"satisfaction",label:"End-state satisfaction",value:s.qualityScore,detail:`${s.targetProgressScore}% target progress with ${s.blockedNodeIds.length} blocked step${s.blockedNodeIds.length===1?"":"s"}.`}]}function Dt(s){return s.trim().toLowerCase()}function ee(s,d){return s.includes(d)?s.filter(n=>n!==d):[...s,d]}function Ze(s,d){return s.some(n=>n.entityType===d.entityType&&n.entityId===d.entityId)?s.filter(n=>!(n.entityType===d.entityType&&n.entityId===d.entityId)):[...s,d]}function Oe(s,d){if(s.length!==d.length)return!1;const n=new Set(d);return s.every(m=>n.has(m))}function pe(s="project",d){return{id:`strategy_node_${Math.random().toString(36).slice(2,10)}`,entityType:s,entityId:"",branchLabel:"",notes:"",dependencyMode:"after_previous",customPredecessorIds:[],...d}}function _t(s){const d=new Map(s.graph.nodes.map(g=>[g.id,g])),n=new Map(s.graph.nodes.map(g=>[g.id,0])),m=new Map,c=new Map(s.graph.nodes.map((g,y)=>[g.id,y]));for(const g of s.graph.nodes)m.set(g.id,[]);for(const g of s.graph.edges)n.set(g.to,(n.get(g.to)??0)+1),m.set(g.from,[...m.get(g.from)??[],g.to]);const o=s.graph.nodes.filter(g=>(n.get(g.id)??0)===0).sort((g,y)=>(c.get(g.id)??0)-(c.get(y.id)??0)).map(g=>g.id),x=[];for(;o.length>0;){o.sort((j,S)=>(c.get(j)??0)-(c.get(S)??0));const g=o.shift();if(!g)continue;const y=d.get(g);if(y){x.push(y);for(const j of m.get(g)??[]){const S=(n.get(j)??0)-1;n.set(j,S),S===0&&o.push(j)}}}return x.length===s.graph.nodes.length?x:s.graph.nodes}function Lt(s){const d=new Map;for(const m of s.graph.nodes)d.set(m.id,[]);for(const m of s.graph.edges)d.set(m.to,[...d.get(m.to)??[],m.from]);const n=_t(s);return{title:s.title,overview:s.overview,endStateDescription:s.endStateDescription,status:s.status,userId:s.userId??null,targetGoalIds:s.targetGoalIds,targetProjectIds:s.targetProjectIds,linkedEntities:s.linkedEntities,nodes:n.map((m,c)=>{const o=d.get(m.id)??[],x=n[c-1],g=x?d.get(x.id)??[]:[];let y="custom";return o.length===0?y="start":x&&Oe(o,[x.id])?y="after_previous":x&&o.length>0&&Oe(o,g)&&(y="parallel_with_previous"),pe(m.entityType,{id:m.id,entityId:m.entityId,branchLabel:m.branchLabel,notes:m.notes,dependencyMode:y,customPredecessorIds:o})})}}function Ue(s){const d=new Map,n=new Set;for(const[m,c]of s.entries()){const o=s[m-1];let x;switch(c.dependencyMode){case"after_previous":x=o?[o.id]:[];break;case"parallel_with_previous":x=o?[...d.get(o.id)??[]]:[];break;case"custom":x=c.customPredecessorIds.filter(g=>n.has(g));break;case"start":default:x=[];break}d.set(c.id,x),n.add(c.id)}return d}function ze(s){const d=Ue(s),n=new Set,m=new Set;function c(o){if(m.has(o))return!0;if(n.has(o))return!1;n.add(o),m.add(o);for(const x of d.get(o)??[])if(c(x))return!0;return m.delete(o),!1}return s.some(o=>c(o.id))}const Qe={title:"",overview:"",endStateDescription:"",status:"active",userId:null,targetGoalIds:[],targetProjectIds:[],linkedEntities:[],nodes:[pe("project",{dependencyMode:"start"})]};function V(s,d){const n=d[0];return{title:"",description:"",goalId:(n==null?void 0:n.goalId)??"",projectId:(n==null?void 0:n.id)??"",userId:(n==null?void 0:n.userId)??s,priority:"medium",effort:"deep",energy:"steady",points:60}}function At(s,d,n){const m=Ue(s.nodes),c=new Set(s.nodes.filter(o=>o.entityId).map(o=>o.id));return{nodes:s.nodes.filter(o=>o.entityId).map(o=>{var x,g;return{id:o.id,entityType:o.entityType,entityId:o.entityId,title:o.entityType==="project"?((x=d.get(o.entityId))==null?void 0:x.title)??o.entityId:((g=n.get(o.entityId))==null?void 0:g.title)??o.entityId,branchLabel:o.branchLabel.trim(),notes:o.notes.trim()}}),edges:s.nodes.flatMap(o=>c.has(o.id)?(m.get(o.id)??[]).filter(x=>c.has(x)).map(x=>({from:x,to:o.id,label:"",condition:""})):[])}}function Fe(s){return((s==null?void 0:s.progress)??0)/100}function Bt(s){switch(s==null?void 0:s.status){case"done":return 1;case"in_progress":return .66;case"focus":return .5;case"blocked":return .25;default:return 0}}function Rt(s){const{draft:d,graph:n,goals:m,projects:c,projectsById:o,tasks:x,tasksById:g}=s,y=new Map(n.nodes.map(l=>[l.id,l.entityType==="project"?Fe(o.get(l.entityId)):Bt(g.get(l.entityId))])),j=new Map;for(const l of n.nodes)j.set(l.id,[]);for(const l of n.edges)j.set(l.to,[...j.get(l.to)??[],l.from]);const S=n.nodes.filter(l=>(y.get(l.id)??0)>=1).map(l=>l.id),b=n.nodes.filter(l=>(y.get(l.id)??0)>0).map(l=>l.id),P=n.nodes.filter(l=>{var u,f;return l.entityType==="project"?((u=o.get(l.entityId))==null?void 0:u.status)==="paused":((f=g.get(l.entityId))==null?void 0:f.status)==="blocked"}).map(l=>l.id),a=n.nodes.filter(l=>(y.get(l.id)??0)<=0?!1:(j.get(l.id)??[]).some(f=>(y.get(f)??0)<1)).map(l=>l.id),h=n.nodes.filter(l=>(y.get(l.id)??0)>=1?!1:(j.get(l.id)??[]).every(f=>(y.get(f)??0)>=1)).map(l=>l.id),N=new Map(m.map(l=>[l.id,l])),M=d.targetGoalIds.map(l=>{var f;const u=x.filter(C=>C.goalId===l);return u.length===0?((f=N.get(l))==null?void 0:f.status)==="completed"?1:0:u.filter(C=>C.status==="done").length/u.length}),_=d.targetProjectIds.map(l=>Fe(o.get(l))),w=[...M,..._],$=n.nodes.length===0?0:n.nodes.reduce((l,u)=>l+(y.get(u.id)??0),0)/n.nodes.length,F=w.length===0?$:w.reduce((l,u)=>l+u,0)/w.length,te=new Set(n.nodes.filter(l=>l.entityType==="project").map(l=>l.entityId)),O=new Set(n.nodes.filter(l=>l.entityType==="task").map(l=>l.entityId)),A=new Set,z=new Set,k=new Set;for(const l of d.targetProjectIds){const u=c.find(f=>f.id===l);if(u&&!te.has(u.id)&&u.status!=="completed"){const f=`project:${u.id}`;A.add(f),z.add(f)}for(const f of x.filter(C=>C.projectId===l))if(!O.has(f.id)&&["focus","in_progress","done","blocked"].includes(f.status)){const C=`task:${f.id}`;A.add(C),f.status==="done"?k.add(C):z.add(C)}}for(const l of d.targetGoalIds)for(const u of x.filter(f=>f.goalId===l))if(!O.has(u.id)&&["focus","in_progress","done","blocked"].includes(u.status)){const f=`task:${u.id}`;A.add(f),u.status==="done"?k.add(f):z.add(f)}const L=Math.max(1,n.nodes.length),Z=A.size,K=P.length/L,U=Math.max(0,Math.min(100,Math.round($*100))),q=Math.max(0,Math.min(100,Math.round(100-a.length/L*100))),X=Math.max(0,Math.min(100,Math.round(100-Z/L*100))),W=Math.max(0,Math.min(100,Math.round(Math.max(0,Math.min(1,F*.8+(1-K)*.2))*100))),D=Math.max(0,Math.min(100,Math.round(F*100)));return{alignmentScore:Math.max(0,Math.min(100,Math.round(U*.35+q*.3+X*.2+W*.15))),planCoverageScore:U,sequencingScore:q,scopeDisciplineScore:X,qualityScore:W,targetProgressScore:D,completedNodeCount:S.length,startedNodeCount:b.length,readyNodeCount:h.length,totalNodeCount:L,completedTargetCount:w.filter(l=>l>=1).length,totalTargetCount:w.length,offPlanEntityCount:Z,offPlanActiveEntityCount:z.size,offPlanCompletedEntityCount:k.size,activeNodeIds:h.slice(0,8),nextNodeIds:h.slice(0,5),blockedNodeIds:P,outOfOrderNodeIds:a}}function Ot({node:s,index:d,total:n,projectsById:m,tasksById:c,usersById:o,allNodes:x,onUpdate:g,onRemove:y}){const{attributes:j,listeners:S,setNodeRef:b,transform:P,transition:a,isDragging:h}=vt({id:s.id}),N=s.entityType==="project"?m.get(s.entityId):c.get(s.entityId),M=N&&"userId"in N&&N.userId?o.get(N.userId)??N.user??null:null,_=x.slice(0,d);return e.jsxs("div",{ref:b,style:{transform:ft.Transform.toString(P),transition:a},className:ce("min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)]",h&&"opacity-70"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("button",{type:"button",className:"mt-1 rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",...j,...S,children:e.jsx(gt,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Step ",d+1]}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.entityType}),N?e.jsx(R,{kind:s.entityType,label:N.title,compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-3 text-base font-medium text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)||"Select an entity for this step"}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.notes||(N&&"description"in N?N.description:"")||"Add an optional note if this phase needs intent or setup context."}),M?e.jsx("div",{className:"mt-3",children:e.jsx(H,{user:M,compact:!0})}):null]})]}),e.jsxs(Q,{type:"button",variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:n===1,onClick:()=>y(s.id),children:[e.jsx(ht,{className:"size-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsx(T,{label:"Relationship to the flow",labelHelp:"Keep the sequence mostly linear in the form. Use parallel when this step should open beside the previous one, or custom only when the dependency is special.",children:e.jsx(Je,{value:s.dependencyMode,columns:2,onChange:w=>g(s.id,{dependencyMode:w}),options:[{value:"start",label:"Start here",description:"This step opens immediately."},{value:"after_previous",label:"After previous",description:"Use the prior step as the gate."},{value:"parallel_with_previous",label:"Parallel with previous",description:"Open beside the prior branch."},{value:"custom",label:"Custom dependency",description:"Pick earlier steps manually."}]})}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Branch label",children:e.jsx(Y,{value:s.branchLabel,onChange:w=>g(s.id,{branchLabel:w.target.value}),placeholder:"Core path, fallback lane, support branch"})}),e.jsx(T,{label:"Step note",children:e.jsx(ue,{value:s.notes,onChange:w=>g(s.id,{notes:w.target.value}),placeholder:"Explain what has to be true before or after this step."})})]})]}),s.dependencyMode==="custom"?e.jsxs("div",{className:"mt-4 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Depends on"}),e.jsx("div",{className:"mt-3 grid gap-2",children:_.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No earlier steps available yet."}):_.map(w=>{const $=w.entityType==="project"?m.get(w.entityId):c.get(w.entityId);return e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:($==null?void 0:$.title)||`Step ${x.indexOf(w)+1}`}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:w.branchLabel||w.entityType})]}),e.jsx("input",{type:"checkbox",checked:s.customPredecessorIds.includes(w.id),onChange:()=>g(s.id,{customPredecessorIds:ee(s.customPredecessorIds,w.id)})})]},w.id)})})]}):null]})}const ie="min-h-10 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_34%,transparent)]";function zt({draft:s,setDraft:d,sequenceSearchQuery:n,setSequenceSearchQuery:m,openInlineTaskComposer:c,showInlineTaskComposer:o,setShowInlineTaskComposer:x,inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,submitInlineTask:P,defaultUserId:a,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,tasksById:w,usersById:$,goalsById:F,sequenceEntityKeys:te,hasSequenceQuery:O,hasSequenceResults:A,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Z,limitedSuggestedTasks:K,appendSequenceNode:U,updateNode:q,removeNode:X,reorderNodes:W,contractChecks:D,alignmentBreakdown:E}){const l=bt(yt(jt,{activationConstraint:{distance:6}}));return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Search and add"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, humans, and bots."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:n,onChange:u=>m(u.target.value),placeholder:"Search goals, projects, tasks, owners, humans, or bots"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs(Q,{type:"button",className:"w-full justify-start",variant:"secondary",onClick:c,children:[e.jsx(We,{className:"size-4"}),"Create new task"]}),o?e.jsx(Qt,{inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,setShowInlineTaskComposer:x,submitInlineTask:P,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,defaultUserId:a}):null,e.jsx(Ft,{draft:s,setDraft:d,hasSequenceQuery:O,hasSequenceResults:A,sequenceEntityKeys:te,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Z,limitedSuggestedTasks:K,appendSequenceNode:U})]})]}),e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Sequence"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the flow mostly linear here. When a step should open beside the previous one, switch it to parallel. Use custom only for special joins."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.targetGoalIds.map(u=>{const f=F.get(u);return f?e.jsx(R,{kind:"goal",label:f.title,compact:!0,gradient:!1},u):null}),s.targetProjectIds.map(u=>{const f=_.get(u);return f?e.jsx(R,{kind:"project",label:f.title,compact:!0,gradient:!1},u):null})]})]}),e.jsx(It,{sensors:l,collisionDetection:Nt,onDragEnd:u=>{!u.over||u.active.id===u.over.id||W(String(u.active.id),String(u.over.id))},children:e.jsx(wt,{items:s.nodes.map(u=>u.id),strategy:kt,children:e.jsx("div",{className:"grid gap-3",children:s.nodes.map((u,f)=>e.jsx(Ot,{node:u,index:f,total:s.nodes.length,projectsById:_,tasksById:w,usersById:$,allNodes:s.nodes,onUpdate:q,onRemove:X},u.id))})})})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Contract readiness"}),e.jsx("div",{className:"mt-3 grid gap-2",children:D.map(u=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:u.label}),e.jsx(G,{className:u.satisfied?"bg-[var(--ui-success-soft)] text-[var(--success)]":"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:u.satisfied?"Ready":"Missing"})]},u.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Alignment preview"}),e.jsx("div",{className:"mt-3 grid gap-3",children:E.map(u=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:u.label}),e.jsxs("span",{children:[u.value,"%"]})]}),e.jsx(Ct,{value:u.value,className:"mt-2"})]},u.id))})]})]})]})}function Qt({inlineTaskDraft:s,setInlineTaskDraft:d,inlineTaskError:n,setInlineTaskError:m,inlineTaskPending:c,setShowInlineTaskComposer:o,submitInlineTask:x,goals:g,projects:y,inlineTaskProjects:j,projectsById:S,defaultUserId:b}){const P=()=>{o(!1),m(null)};return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"New task"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add the task and place it in the sequence."})]}),e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Close"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(T,{label:"Task title",children:e.jsx(Y,{value:s.title,onChange:a=>d(h=>({...h,title:a.target.value})),placeholder:"Draft the shared strategy hierarchy view"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Goal",children:e.jsxs("select",{value:s.goalId,onChange:a=>{const h=a.target.value,N=y.find(M=>M.goalId===h)??null;d(M=>({...M,goalId:h,projectId:(N==null?void 0:N.id)??"",userId:(N==null?void 0:N.userId)??M.userId??b}))},className:ie,children:[e.jsx("option",{value:"",children:"Select goal"}),g.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})}),e.jsx(T,{label:"Project",children:e.jsxs("select",{value:s.projectId,onChange:a=>d(h=>{var N,M;return{...h,projectId:a.target.value,goalId:((N=S.get(a.target.value))==null?void 0:N.goalId)??h.goalId,userId:((M=S.get(a.target.value))==null?void 0:M.userId)??h.userId}}),className:ie,children:[e.jsx("option",{value:"",children:"Select project"}),j.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})})]}),e.jsx(T,{label:"Notes",children:e.jsx(ue,{value:s.description,onChange:a=>d(h=>({...h,description:a.target.value})),placeholder:"Optional detail or acceptance note."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Priority",children:e.jsxs("select",{value:s.priority,onChange:a=>d(h=>({...h,priority:a.target.value})),className:ie,children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})}),e.jsx(T,{label:"Points",children:e.jsx(Y,{type:"number",value:s.points,onChange:a=>d(h=>({...h,points:Number(a.target.value)||0}))})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Effort",children:e.jsxs("select",{value:s.effort,onChange:a=>d(h=>({...h,effort:a.target.value})),className:ie,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"deep",children:"Deep"}),e.jsx("option",{value:"extended",children:"Extended"})]})}),e.jsx(T,{label:"Energy",children:e.jsxs("select",{value:s.energy,onChange:a=>d(h=>({...h,energy:a.target.value})),className:ie,children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"steady",children:"Steady"}),e.jsx("option",{value:"intense",children:"Intense"})]})})]}),n?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Cancel"}),e.jsxs(Q,{type:"button",className:"w-full sm:w-auto",pending:c,pendingLabel:"Creating task",onClick:x,children:[e.jsx(We,{className:"size-4"}),"Create task"]})]})]})]})}function Ft({draft:s,setDraft:d,hasSequenceQuery:n,hasSequenceResults:m,sequenceEntityKeys:c,limitedSequenceGoals:o,limitedSequenceProjects:x,limitedSequenceTasks:g,limitedSuggestedProjects:y,limitedSuggestedTasks:j,appendSequenceNode:S}){return n?m?e.jsxs("div",{className:"grid gap-3",children:[o.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goals"}):null,o.map(b=>{const P=s.targetGoalIds.includes(b.id),a=s.linkedEntities.some(h=>h.entityType==="goal"&&h.entityId===b.id);return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"goal",label:b.title,compact:!0,gradient:!1}),e.jsx(H,{user:b.user,compact:!0})]}),b.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:b.description}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:P?"secondary":"primary",onClick:()=>d(h=>({...h,targetGoalIds:ee(h.targetGoalIds,b.id)})),children:P?"Targeted":"Add target"}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:"secondary",onClick:()=>d(h=>({...h,linkedEntities:Ze(h.linkedEntities,{entityType:"goal",entityId:b.id})})),children:a?"Unlink":"Link"})]})]})},b.id)}),x.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Projects"}):null,x.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`sequence-project:${b.id}`)),g.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Tasks"}):null,g.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`sequence-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals, projects, or tasks match this search."}):y.length>0||j.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Suggested from targets"}),y.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`suggested-project:${b.id}`)),j.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`suggested-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Type to search."})}function Ke({project:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"project",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.goalTitle}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||s.goalTitle})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("project",s.id),children:d?"In sequence":"Add step"})]})})}function He({task:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"task",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||`${s.owner} · ${s.status}`})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("task",s.id),children:d?"In sequence":"Add step"})]})})}function Jt({open:s,pending:d=!1,editingStrategy:n,goals:m,projects:c,tasks:o,habits:x,strategies:g,users:y,defaultUserId:j=null,initialStepId:S,onOpenChange:b,onSubmit:P}){const[a,h]=p.useState(Qe),[N,M]=p.useState(""),[_,w]=p.useState(""),[$,F]=p.useState(""),[te,O]=p.useState(null),[A,z]=p.useState([]),[k,L]=p.useState(V(j,c)),[Z,K]=p.useState(!1),[U,q]=p.useState(null),[X,W]=p.useState(!1);p.useEffect(()=>{var r,i,v;if(!s)return;const t=n?Lt(n):{...Qe,userId:j,nodes:[pe("project",{dependencyMode:"start"})]};h(t),M(""),w(""),F(""),z([]),K(!1),L(V(j,c).projectId&&t.targetProjectIds[0]?{...V(j,c),goalId:((r=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:r.goalId)??"",projectId:t.targetProjectIds[0]??((i=c[0])==null?void 0:i.id)??"",userId:((v=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:v.userId)??j}:V(j,c)),q(null),O(null)},[j,n,s,c]);const D=p.useDeferredValue(N),E=p.useDeferredValue(_),l=p.useDeferredValue($),u=p.useMemo(()=>{const t=new Set(A.map(r=>r.id));return[...A,...o.filter(r=>!t.has(r.id))]},[A,o]),f=p.useMemo(()=>new Map(m.map(t=>[t.id,t])),[m]),C=p.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),se=p.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),je=p.useMemo(()=>new Map(y.map(t=>[t.id,t])),[y]),me=y.find(t=>t.id===j)??null,ge=y.find(t=>t.id===a.userId)??me,B=(t,r,i)=>{const v=Dt(t);return v.length===0||Tt(r,i).includes(v)},Ie=p.useMemo(()=>m.filter(t=>B(E,[t.title,t.description],t.user)),[E,m]),he=p.useMemo(()=>m.filter(t=>B(D,[t.title,t.description],t.user)),[m,D]),xe=p.useMemo(()=>c.filter(t=>B(D,[t.title,t.description,t.goalTitle,t.status],t.user)),[D,c]),Ne=p.useMemo(()=>c.filter(t=>B(E,[t.title,t.description,t.goalTitle,t.status],t.user)),[E,c]),we=p.useMemo(()=>u.filter(t=>B(E,[t.title,t.description,t.owner,t.status],t.user)),[u,E]),ke=p.useMemo(()=>x.filter(t=>B(E,[t.title,t.description,t.frequency,t.status],t.user)),[E,x]),Se=p.useMemo(()=>g.filter(t=>t.id!==(n==null?void 0:n.id)&&B(E,[t.title,t.overview,t.endStateDescription,t.status],t.user)),[E,n==null?void 0:n.id,g]),ve=p.useMemo(()=>[...Ie.map(r=>({key:`goal:${r.id}`,entityType:"goal",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Goal"),user:r.user??null})),...Ne.map(r=>({key:`project:${r.id}`,entityType:"project",entityId:r.id,label:r.title,description:ae(`${r.goalTitle}${r.goalTitle?" · ":""}${r.status}`,r.user,`Project · ${r.goalTitle}`),user:r.user??null})),...we.map(r=>({key:`task:${r.id}`,entityType:"task",entityId:r.id,label:r.title,description:ae(`${r.status} · ${r.owner}`,r.user,`Task · ${r.owner}`),user:r.user??null})),...ke.map(r=>({key:`habit:${r.id}`,entityType:"habit",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Habit"),user:r.user??null})),...Se.map(r=>({key:`strategy:${r.id}`,entityType:"strategy",entityId:r.id,label:r.title,description:ae(r.overview,r.user,"Strategy"),user:r.user??null}))].sort((r,i)=>r.label.localeCompare(i.label)),[Ie,ke,Ne,Se,we]),J=p.useMemo(()=>At(a,C,se),[a,C,se]),Ce=p.useMemo(()=>Rt({draft:a,graph:J,goals:m,projects:c,projectsById:C,tasks:u,tasksById:se}),[u,a,J,m,c,C,se]),Xe=p.useMemo(()=>[...Ye({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:J}),{id:"acyclic",label:"Graph stays directed and non-looping",satisfied:!ze(a.nodes)}],[a.endStateDescription,a.nodes,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,J]),fe=p.useMemo(()=>$t({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:J}),[a.endStateDescription,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,J]),Ve=p.useMemo(()=>qt(Ce),[Ce]),be=p.useMemo(()=>{if(!a.title.trim())return"Strategy title is required.";if(a.nodes.length===0)return"Add at least one project or task step.";const t=new Set;for(const r of a.nodes){if(!r.entityId)return"Every step needs a linked project or task.";const i=`${r.entityType}:${r.entityId}`;if(t.has(i))return"Each project or task should appear only once in the sequence.";t.add(i)}return ze(a.nodes)?"Strategy graph must stay directed and non-loopy.":null},[a.nodes,a.title]),et=t=>t==="sequence"?te??be??(fe?null:"This can still be saved as a draft. Add the target plus the overview or end state later, then lock it as the contract from the strategy detail page."):null,Me=p.useMemo(()=>m.filter(t=>B(l,[t.title,t.description],t.user)),[m,l]),ne=p.useMemo(()=>c.filter(t=>B(l,[t.title,t.description,t.goalTitle,t.status],t.user)),[c,l]),le=p.useMemo(()=>u.filter(t=>B(l,[t.title,t.description,t.owner,t.status],t.user)),[u,l]),de=p.useMemo(()=>new Set(a.targetGoalIds),[a.targetGoalIds]),oe=p.useMemo(()=>new Set(a.targetProjectIds),[a.targetProjectIds]),tt=p.useMemo(()=>new Set(a.nodes.map(t=>`${t.entityType}:${t.entityId}`)),[a.nodes]),Te=p.useMemo(()=>a.targetGoalIds.map(t=>f.get(t)).filter(t=>!!t),[a.targetGoalIds,f]),Pe=p.useMemo(()=>a.targetProjectIds.map(t=>C.get(t)).filter(t=>!!t),[a.targetProjectIds,C]),Ee=p.useMemo(()=>ne.filter(t=>oe.has(t.id)||de.has(t.goalId)),[ne,de,oe]),Ge=p.useMemo(()=>le.filter(t=>oe.has(t.projectId??"")||de.has(t.goalId??"")),[le,de,oe]),$e=p.useMemo(()=>he.slice(0,8),[he]),qe=p.useMemo(()=>xe.slice(0,8),[xe]),De=p.useMemo(()=>ve.slice(0,12),[ve]),_e=p.useMemo(()=>Me.slice(0,6),[Me]),Le=p.useMemo(()=>ne.slice(0,8),[ne]),Ae=p.useMemo(()=>le.slice(0,10),[le]),st=p.useMemo(()=>Ee.slice(0,4),[Ee]),rt=p.useMemo(()=>Ge.slice(0,6),[Ge]),at=p.useMemo(()=>{if(!k.goalId)return c;const t=c.filter(r=>r.goalId===k.goalId);return t.length>0?t:c},[k.goalId,c]),it=l.length>0,nt=_e.length>0||Le.length>0||Ae.length>0,lt=(t,r)=>{h(i=>({...i,nodes:i.nodes.map(v=>v.id===t?{...v,...r}:v)}))},Be=(t,r)=>{a.nodes.some(i=>i.entityType===t&&i.entityId===r)||h(i=>({...i,nodes:[...i.nodes,pe(t,{entityId:r,dependencyMode:i.nodes.length===0?"start":"after_previous"})]}))},dt=t=>{h(r=>{const i=r.nodes.filter(v=>v.id!==t);return{...r,nodes:i.map((v,I)=>({...v,dependencyMode:I===0&&v.dependencyMode==="after_previous"?"start":v.dependencyMode,customPredecessorIds:v.customPredecessorIds.filter(re=>re!==t)}))}})},ot=(t,r)=>{h(i=>{const v=i.nodes.findIndex(re=>re.id===t),I=i.nodes.findIndex(re=>re.id===r);return v<0||I<0?i:{...i,nodes:St(i.nodes,v,I)}})},ct=()=>{const t=$.trim(),r=a.targetProjectIds.map(I=>C.get(I)).find(I=>!!I)??C.get(k.projectId)??c[0]??null,i=(r==null?void 0:r.goalId)??a.targetGoalIds[0]??"",v=c.find(I=>I.goalId===i&&(r?I.id===r.id:!0))??c.find(I=>I.goalId===i)??r;L(I=>({...V(j,c),title:t||I.title,description:I.description,goalId:i,projectId:(v==null?void 0:v.id)??I.projectId,userId:(v==null?void 0:v.userId)??I.userId??j})),q(null),K(!0)},ut=async()=>{const t=C.get(k.projectId);if(!k.title.trim()){q("Task title is required.");return}if(!t){q("Pick a project for the new task.");return}W(!0),q(null);try{const r=je.get(k.userId??t.userId??"")??t.user??ge??me,i=(await Gt({title:k.title.trim(),description:k.description.trim(),level:"task",owner:(r==null?void 0:r.displayName)??"Albert",userId:k.userId??t.userId??a.userId,assigneeUserIds:[],goalId:t.goalId,projectId:t.id,parentWorkItemId:null,priority:k.priority,status:"focus",effort:k.effort,energy:k.energy,dueDate:"",points:k.points,plannedDurationSeconds:86400,aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]})).task;z(v=>[i,...v]),Be("task",i.id),L({...V(j,c),goalId:t.goalId,projectId:t.id,userId:i.userId??t.userId??a.userId}),F(""),K(!1)}catch(r){q(r instanceof Error?r.message:"Task creation failed.")}finally{W(!1)}},pt=async()=>{if(be){O(be);return}try{await P({title:a.title.trim(),overview:a.overview.trim(),endStateDescription:a.endStateDescription.trim(),status:a.status,userId:a.userId,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,linkedEntities:a.linkedEntities,graph:J},n==null?void 0:n.id),O(null),b(!1)}catch(t){O(t instanceof Error?t.message:"Strategy save failed.")}},mt=[{id:"foundation",eyebrow:"Foundation",title:"Set the owner and the strategic frame",description:"Start with who owns the strategy, what the plan is called, and whether this should open as active, paused, or already landed.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(16rem,0.8fr)]",children:[e.jsx(T,{label:"Strategy title",children:e.jsx(Y,{value:t.title,onChange:i=>r({title:i.target.value}),placeholder:"Land the multi-user planning system"})}),e.jsx(T,{label:"Status",children:e.jsx(Je,{value:t.status,onChange:i=>r({status:i}),options:[{value:"active",label:"Active",description:"Use this when the plan should drive work now."},{value:"paused",label:"Paused",description:"Keep the strategy visible without active pressure."},{value:"completed",label:"Completed",description:"The end state is already landed."}]})})]}),e.jsx(Pt,{value:t.userId,users:y,onChange:i=>r({userId:i}),label:"Owner user",defaultLabel:Et(me),help:"Strategies can belong to a human or a bot even when the sequence spans multiple owners."}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-accent-soft)] px-5 py-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Live posture"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"strategy",label:t.title.trim()||"Untitled strategy",compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]",children:t.status}),ge?e.jsx(H,{user:ge,compact:!0}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This flow is built to keep strategy creation as guided as the other major entities in Forge: clear questions first, then a focused sequence stage at the end."})]})]})},{id:"objective",eyebrow:"Objective",title:"Define the objective and the end targets",description:"Capture what this strategy is coordinating, what done looks like, and which goals or projects are the real targets.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Overview",children:e.jsx(ue,{value:t.overview,onChange:i=>r({overview:i.target.value}),placeholder:"Explain what this strategy is coordinating and why it matters right now."})}),e.jsx(T,{label:"End state",children:e.jsx(ue,{value:t.endStateDescription,onChange:i=>r({endStateDescription:i.target.value}),placeholder:"Describe what reality should look like when this strategy lands."})})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsx(T,{label:"Search goals or projects",description:"Keep this page search-first. Add only the targets that truly define what this strategy is trying to land.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:N,onChange:i=>M(i.target.value),placeholder:"Search goals, projects, owners, humans, or bots"})]})}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected goals"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Te.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target goals yet"}):Te.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsx(R,{kind:"goal",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected projects"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Pe.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target projects yet"}):Pe.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsx(R,{kind:"project",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[he.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?$e.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals match this search yet."}):$e.map(i=>{const v=t.targetGoalIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",v?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"goal",label:i.title,className:"max-w-full min-w-0"}),e.jsx(H,{user:i.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No strategic note attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the goal this strategy is meant to land."})})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Project matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[xe.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?qe.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No projects match this search yet."}):qe.map(i=>{const v=t.targetProjectIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",v?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"project",label:i.title,className:"max-w-full min-w-0",showIcon:!1}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.goalTitle}),e.jsx(H,{user:i.user,compact:!0})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No project summary attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the concrete project this strategy should land or organize."})})]})]})]})},{id:"context",eyebrow:"Context",title:"Keep the right supporting entities in view",description:"Linked entities stay visible in the strategy context without becoming part of the main execution sequence.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"Search supporting context",description:"Search across goals, projects, tasks, habits, and other strategies.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:_,onChange:i=>w(i.target.value),placeholder:"Search by title, owner, @handle, human, or bot"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.linkedEntities.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No extra linked context yet"}):t.linkedEntities.map(i=>{const v=ve.find(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({linkedEntities:t.linkedEntities.filter(I=>!(I.entityType===i.entityType&&I.entityId===i.entityId))}),children:[e.jsx(xt,{className:"mr-1 size-3.5"}),(v==null?void 0:v.label)??`${i.entityType}:${i.entityId}`,e.jsx("span",{children:"Remove"})]},`${i.entityType}:${i.entityId}`)})}),e.jsx("div",{className:"grid gap-3",children:E?De.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No supporting entities match this search yet."}):De.map(i=>{const v=t.linkedEntities.some(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("label",{className:ce("flex items-start justify-between gap-3 rounded-[20px] border px-4 py-4",v?"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:i.entityType,label:i.label,compact:!0,gradient:!1}),i.user?e.jsx(H,{user:i.user,compact:!0}):null]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description})]}),e.jsx("input",{type:"checkbox",checked:v,onChange:()=>r({linkedEntities:Ze(t.linkedEntities,{entityType:i.entityType,entityId:i.entityId})})})]},i.key)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search when you want to pull another entity into the background context. This keeps the page focused instead of dumping every record into one long list."})})]})},{id:"sequence",eyebrow:"Sequence",title:"Build the execution sequence",description:"Search, add steps, and create missing tasks.",render:()=>e.jsx(zt,{draft:a,setDraft:h,sequenceSearchQuery:$,setSequenceSearchQuery:F,openInlineTaskComposer:ct,showInlineTaskComposer:Z,setShowInlineTaskComposer:K,inlineTaskDraft:k,setInlineTaskDraft:L,inlineTaskError:U,setInlineTaskError:q,inlineTaskPending:X,submitInlineTask:()=>void ut(),defaultUserId:j,goals:m,projects:c,inlineTaskProjects:at,projectsById:C,tasksById:se,usersById:je,goalsById:f,sequenceEntityKeys:tt,hasSequenceQuery:it,hasSequenceResults:nt,limitedSequenceGoals:_e,limitedSequenceProjects:Le,limitedSequenceTasks:Ae,limitedSuggestedProjects:st,limitedSuggestedTasks:rt,appendSequenceNode:Be,updateNode:lt,removeNode:dt,reorderNodes:ot,contractChecks:Xe,alignmentBreakdown:Ve})}];return e.jsx(Mt,{open:s,onOpenChange:b,eyebrow:"Strategy",title:n?"Edit strategy":"Create strategy",description:"Strategies connect goals, projects, and tasks into a guided multi-step plan with a focused sequence builder at the end.",value:a,onChange:h,draftPersistenceKey:n?`strategy.${n.id}`:"strategy.new",steps:mt,initialStepId:S,contentClassName:"lg:h-[min(56rem,calc(100vh-1rem))] lg:w-[min(78rem,calc(100vw-1.5rem))]",submitLabel:n?fe?"Save strategy":"Save draft":fe?"Create strategy":"Create draft",pending:d,pendingLabel:"Saving strategy",resolveError:et,onSubmit:pt})}export{Jt as S,Ye as a,qt as b,$t as i};
1
+ import{j as e,bJ as gt,c7 as ht,b3 as ye,b4 as We,r as p,cb as xt}from"./vendor-Dnkkx2co.js";import{b as vt,C as ft,u as bt,a as yt,P as jt,D as It,c as Nt,S as wt,v as kt,d as St}from"./board-dIX6etHh.js";import{c as G,b as R,U as H,B as Q,F as T,j as Je,I as Y,T as ue,Z as ce,W as Ct,bl as ae,Q as Mt,bk as Tt,a0 as Pt,a1 as Et,V as Re,al as Gt}from"./index-EqQsXoat.js";function Ye(s){return[{id:"title",label:"Strategy title is set",satisfied:s.title.trim().length>0},{id:"graph",label:"Graph contains at least one linked project or task",satisfied:s.graph.nodes.length>0},{id:"targets",label:"At least one target goal or project is selected",satisfied:s.targetGoalIds.length>0||s.targetProjectIds.length>0},{id:"narrative",label:"The plan already names an overview or end state",satisfied:s.overview.trim().length>0||s.endStateDescription.trim().length>0}]}function $t(s){return Ye(s).every(d=>d.satisfied)}function qt(s){return[{id:"coverage",label:"Agreed work moving",value:s.planCoverageScore,detail:`${s.startedNodeCount}/${s.totalNodeCount} agreed steps have started or finished.`},{id:"order",label:"Order respected",value:s.sequencingScore,detail:`${s.outOfOrderNodeIds.length} step${s.outOfOrderNodeIds.length===1?"":"s"} started before prerequisites were complete.`},{id:"scope",label:"Scope held",value:s.scopeDisciplineScore,detail:`${s.offPlanEntityCount} unagreed item${s.offPlanEntityCount===1?"":"s"} are inside the strategy scope, ${s.offPlanActiveEntityCount} still active.`},{id:"satisfaction",label:"End-state satisfaction",value:s.qualityScore,detail:`${s.targetProgressScore}% target progress with ${s.blockedNodeIds.length} blocked step${s.blockedNodeIds.length===1?"":"s"}.`}]}function Dt(s){return s.trim().toLowerCase()}function ee(s,d){return s.includes(d)?s.filter(n=>n!==d):[...s,d]}function Ze(s,d){return s.some(n=>n.entityType===d.entityType&&n.entityId===d.entityId)?s.filter(n=>!(n.entityType===d.entityType&&n.entityId===d.entityId)):[...s,d]}function Oe(s,d){if(s.length!==d.length)return!1;const n=new Set(d);return s.every(m=>n.has(m))}function pe(s="project",d){return{id:`strategy_node_${Math.random().toString(36).slice(2,10)}`,entityType:s,entityId:"",branchLabel:"",notes:"",dependencyMode:"after_previous",customPredecessorIds:[],...d}}function _t(s){const d=new Map(s.graph.nodes.map(g=>[g.id,g])),n=new Map(s.graph.nodes.map(g=>[g.id,0])),m=new Map,c=new Map(s.graph.nodes.map((g,y)=>[g.id,y]));for(const g of s.graph.nodes)m.set(g.id,[]);for(const g of s.graph.edges)n.set(g.to,(n.get(g.to)??0)+1),m.set(g.from,[...m.get(g.from)??[],g.to]);const o=s.graph.nodes.filter(g=>(n.get(g.id)??0)===0).sort((g,y)=>(c.get(g.id)??0)-(c.get(y.id)??0)).map(g=>g.id),x=[];for(;o.length>0;){o.sort((j,S)=>(c.get(j)??0)-(c.get(S)??0));const g=o.shift();if(!g)continue;const y=d.get(g);if(y){x.push(y);for(const j of m.get(g)??[]){const S=(n.get(j)??0)-1;n.set(j,S),S===0&&o.push(j)}}}return x.length===s.graph.nodes.length?x:s.graph.nodes}function Lt(s){const d=new Map;for(const m of s.graph.nodes)d.set(m.id,[]);for(const m of s.graph.edges)d.set(m.to,[...d.get(m.to)??[],m.from]);const n=_t(s);return{title:s.title,overview:s.overview,endStateDescription:s.endStateDescription,status:s.status,userId:s.userId??null,targetGoalIds:s.targetGoalIds,targetProjectIds:s.targetProjectIds,linkedEntities:s.linkedEntities,nodes:n.map((m,c)=>{const o=d.get(m.id)??[],x=n[c-1],g=x?d.get(x.id)??[]:[];let y="custom";return o.length===0?y="start":x&&Oe(o,[x.id])?y="after_previous":x&&o.length>0&&Oe(o,g)&&(y="parallel_with_previous"),pe(m.entityType,{id:m.id,entityId:m.entityId,branchLabel:m.branchLabel,notes:m.notes,dependencyMode:y,customPredecessorIds:o})})}}function Ue(s){const d=new Map,n=new Set;for(const[m,c]of s.entries()){const o=s[m-1];let x;switch(c.dependencyMode){case"after_previous":x=o?[o.id]:[];break;case"parallel_with_previous":x=o?[...d.get(o.id)??[]]:[];break;case"custom":x=c.customPredecessorIds.filter(g=>n.has(g));break;case"start":default:x=[];break}d.set(c.id,x),n.add(c.id)}return d}function ze(s){const d=Ue(s),n=new Set,m=new Set;function c(o){if(m.has(o))return!0;if(n.has(o))return!1;n.add(o),m.add(o);for(const x of d.get(o)??[])if(c(x))return!0;return m.delete(o),!1}return s.some(o=>c(o.id))}const Qe={title:"",overview:"",endStateDescription:"",status:"active",userId:null,targetGoalIds:[],targetProjectIds:[],linkedEntities:[],nodes:[pe("project",{dependencyMode:"start"})]};function V(s,d){const n=d[0];return{title:"",description:"",goalId:(n==null?void 0:n.goalId)??"",projectId:(n==null?void 0:n.id)??"",userId:(n==null?void 0:n.userId)??s,priority:"medium",effort:"deep",energy:"steady",points:60}}function At(s,d,n){const m=Ue(s.nodes),c=new Set(s.nodes.filter(o=>o.entityId).map(o=>o.id));return{nodes:s.nodes.filter(o=>o.entityId).map(o=>{var x,g;return{id:o.id,entityType:o.entityType,entityId:o.entityId,title:o.entityType==="project"?((x=d.get(o.entityId))==null?void 0:x.title)??o.entityId:((g=n.get(o.entityId))==null?void 0:g.title)??o.entityId,branchLabel:o.branchLabel.trim(),notes:o.notes.trim()}}),edges:s.nodes.flatMap(o=>c.has(o.id)?(m.get(o.id)??[]).filter(x=>c.has(x)).map(x=>({from:x,to:o.id,label:"",condition:""})):[])}}function Fe(s){return((s==null?void 0:s.progress)??0)/100}function Bt(s){switch(s==null?void 0:s.status){case"done":return 1;case"in_progress":return .66;case"focus":return .5;case"blocked":return .25;default:return 0}}function Rt(s){const{draft:d,graph:n,goals:m,projects:c,projectsById:o,tasks:x,tasksById:g}=s,y=new Map(n.nodes.map(l=>[l.id,l.entityType==="project"?Fe(o.get(l.entityId)):Bt(g.get(l.entityId))])),j=new Map;for(const l of n.nodes)j.set(l.id,[]);for(const l of n.edges)j.set(l.to,[...j.get(l.to)??[],l.from]);const S=n.nodes.filter(l=>(y.get(l.id)??0)>=1).map(l=>l.id),b=n.nodes.filter(l=>(y.get(l.id)??0)>0).map(l=>l.id),P=n.nodes.filter(l=>{var u,f;return l.entityType==="project"?((u=o.get(l.entityId))==null?void 0:u.status)==="paused":((f=g.get(l.entityId))==null?void 0:f.status)==="blocked"}).map(l=>l.id),a=n.nodes.filter(l=>(y.get(l.id)??0)<=0?!1:(j.get(l.id)??[]).some(f=>(y.get(f)??0)<1)).map(l=>l.id),h=n.nodes.filter(l=>(y.get(l.id)??0)>=1?!1:(j.get(l.id)??[]).every(f=>(y.get(f)??0)>=1)).map(l=>l.id),N=new Map(m.map(l=>[l.id,l])),M=d.targetGoalIds.map(l=>{var f;const u=x.filter(C=>C.goalId===l);return u.length===0?((f=N.get(l))==null?void 0:f.status)==="completed"?1:0:u.filter(C=>C.status==="done").length/u.length}),_=d.targetProjectIds.map(l=>Fe(o.get(l))),w=[...M,..._],$=n.nodes.length===0?0:n.nodes.reduce((l,u)=>l+(y.get(u.id)??0),0)/n.nodes.length,F=w.length===0?$:w.reduce((l,u)=>l+u,0)/w.length,te=new Set(n.nodes.filter(l=>l.entityType==="project").map(l=>l.entityId)),O=new Set(n.nodes.filter(l=>l.entityType==="task").map(l=>l.entityId)),A=new Set,z=new Set,k=new Set;for(const l of d.targetProjectIds){const u=c.find(f=>f.id===l);if(u&&!te.has(u.id)&&u.status!=="completed"){const f=`project:${u.id}`;A.add(f),z.add(f)}for(const f of x.filter(C=>C.projectId===l))if(!O.has(f.id)&&["focus","in_progress","done","blocked"].includes(f.status)){const C=`task:${f.id}`;A.add(C),f.status==="done"?k.add(C):z.add(C)}}for(const l of d.targetGoalIds)for(const u of x.filter(f=>f.goalId===l))if(!O.has(u.id)&&["focus","in_progress","done","blocked"].includes(u.status)){const f=`task:${u.id}`;A.add(f),u.status==="done"?k.add(f):z.add(f)}const L=Math.max(1,n.nodes.length),Z=A.size,K=P.length/L,U=Math.max(0,Math.min(100,Math.round($*100))),q=Math.max(0,Math.min(100,Math.round(100-a.length/L*100))),X=Math.max(0,Math.min(100,Math.round(100-Z/L*100))),W=Math.max(0,Math.min(100,Math.round(Math.max(0,Math.min(1,F*.8+(1-K)*.2))*100))),D=Math.max(0,Math.min(100,Math.round(F*100)));return{alignmentScore:Math.max(0,Math.min(100,Math.round(U*.35+q*.3+X*.2+W*.15))),planCoverageScore:U,sequencingScore:q,scopeDisciplineScore:X,qualityScore:W,targetProgressScore:D,completedNodeCount:S.length,startedNodeCount:b.length,readyNodeCount:h.length,totalNodeCount:L,completedTargetCount:w.filter(l=>l>=1).length,totalTargetCount:w.length,offPlanEntityCount:Z,offPlanActiveEntityCount:z.size,offPlanCompletedEntityCount:k.size,activeNodeIds:h.slice(0,8),nextNodeIds:h.slice(0,5),blockedNodeIds:P,outOfOrderNodeIds:a}}function Ot({node:s,index:d,total:n,projectsById:m,tasksById:c,usersById:o,allNodes:x,onUpdate:g,onRemove:y}){const{attributes:j,listeners:S,setNodeRef:b,transform:P,transition:a,isDragging:h}=vt({id:s.id}),N=s.entityType==="project"?m.get(s.entityId):c.get(s.entityId),M=N&&"userId"in N&&N.userId?o.get(N.userId)??N.user??null:null,_=x.slice(0,d);return e.jsxs("div",{ref:b,style:{transform:ft.Transform.toString(P),transition:a},className:ce("min-w-0 overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)]",h&&"opacity-70"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("button",{type:"button",className:"mt-1 rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",...j,...S,children:e.jsx(gt,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Step ",d+1]}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.entityType}),N?e.jsx(R,{kind:s.entityType,label:N.title,compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-3 text-base font-medium text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)||"Select an entity for this step"}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.notes||(N&&"description"in N?N.description:"")||"Add an optional note if this phase needs intent or setup context."}),M?e.jsx("div",{className:"mt-3",children:e.jsx(H,{user:M,compact:!0})}):null]})]}),e.jsxs(Q,{type:"button",variant:"secondary",size:"sm",className:"w-full sm:w-auto",disabled:n===1,onClick:()=>y(s.id),children:[e.jsx(ht,{className:"size-4"}),"Remove"]})]}),e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsx(T,{label:"Relationship to the flow",labelHelp:"Keep the sequence mostly linear in the form. Use parallel when this step should open beside the previous one, or custom only when the dependency is special.",children:e.jsx(Je,{value:s.dependencyMode,columns:2,onChange:w=>g(s.id,{dependencyMode:w}),options:[{value:"start",label:"Start here",description:"This step opens immediately."},{value:"after_previous",label:"After previous",description:"Use the prior step as the gate."},{value:"parallel_with_previous",label:"Parallel with previous",description:"Open beside the prior branch."},{value:"custom",label:"Custom dependency",description:"Pick earlier steps manually."}]})}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Branch label",children:e.jsx(Y,{value:s.branchLabel,onChange:w=>g(s.id,{branchLabel:w.target.value}),placeholder:"Core path, fallback lane, support branch"})}),e.jsx(T,{label:"Step note",children:e.jsx(ue,{value:s.notes,onChange:w=>g(s.id,{notes:w.target.value}),placeholder:"Explain what has to be true before or after this step."})})]})]}),s.dependencyMode==="custom"?e.jsxs("div",{className:"mt-4 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Depends on"}),e.jsx("div",{className:"mt-3 grid gap-2",children:_.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"No earlier steps available yet."}):_.map(w=>{const $=w.entityType==="project"?m.get(w.entityId):c.get(w.entityId);return e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:($==null?void 0:$.title)||`Step ${x.indexOf(w)+1}`}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:w.branchLabel||w.entityType})]}),e.jsx("input",{type:"checkbox",checked:s.customPredecessorIds.includes(w.id),onChange:()=>g(s.id,{customPredecessorIds:ee(s.customPredecessorIds,w.id)})})]},w.id)})})]}):null]})}const ie="min-h-10 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_34%,transparent)]";function zt({draft:s,setDraft:d,sequenceSearchQuery:n,setSequenceSearchQuery:m,openInlineTaskComposer:c,showInlineTaskComposer:o,setShowInlineTaskComposer:x,inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,submitInlineTask:P,defaultUserId:a,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,tasksById:w,usersById:$,goalsById:F,sequenceEntityKeys:te,hasSequenceQuery:O,hasSequenceResults:A,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Z,limitedSuggestedTasks:K,appendSequenceNode:U,updateNode:q,removeNode:X,reorderNodes:W,contractChecks:D,alignmentBreakdown:E}){const l=bt(yt(jt,{activationConstraint:{distance:6}}));return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Search and add"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, humans, and bots."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:n,onChange:u=>m(u.target.value),placeholder:"Search goals, projects, tasks, owners, humans, or bots"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs(Q,{type:"button",className:"w-full justify-start",variant:"secondary",onClick:c,children:[e.jsx(We,{className:"size-4"}),"Create new task"]}),o?e.jsx(Qt,{inlineTaskDraft:g,setInlineTaskDraft:y,inlineTaskError:j,setInlineTaskError:S,inlineTaskPending:b,setShowInlineTaskComposer:x,submitInlineTask:P,goals:h,projects:N,inlineTaskProjects:M,projectsById:_,defaultUserId:a}):null,e.jsx(Ft,{draft:s,setDraft:d,hasSequenceQuery:O,hasSequenceResults:A,sequenceEntityKeys:te,limitedSequenceGoals:z,limitedSequenceProjects:k,limitedSequenceTasks:L,limitedSuggestedProjects:Z,limitedSuggestedTasks:K,appendSequenceNode:U})]})]}),e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Sequence"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Keep the flow mostly linear here. When a step should open beside the previous one, switch it to parallel. Use custom only for special joins."})]}),e.jsxs(G,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.nodes.length," planned steps"]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.targetGoalIds.map(u=>{const f=F.get(u);return f?e.jsx(R,{kind:"goal",label:f.title,compact:!0,gradient:!1},u):null}),s.targetProjectIds.map(u=>{const f=_.get(u);return f?e.jsx(R,{kind:"project",label:f.title,compact:!0,gradient:!1},u):null})]})]}),e.jsx(It,{sensors:l,collisionDetection:Nt,onDragEnd:u=>{!u.over||u.active.id===u.over.id||W(String(u.active.id),String(u.over.id))},children:e.jsx(wt,{items:s.nodes.map(u=>u.id),strategy:kt,children:e.jsx("div",{className:"grid gap-3",children:s.nodes.map((u,f)=>e.jsx(Ot,{node:u,index:f,total:s.nodes.length,projectsById:_,tasksById:w,usersById:$,allNodes:s.nodes,onUpdate:q,onRemove:X},u.id))})})})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Contract readiness"}),e.jsx("div",{className:"mt-3 grid gap-2",children:D.map(u=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[14px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:u.label}),e.jsx(G,{className:u.satisfied?"bg-[var(--ui-success-soft)] text-[var(--success)]":"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:u.satisfied?"Ready":"Missing"})]},u.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Alignment preview"}),e.jsx("div",{className:"mt-3 grid gap-3",children:E.map(u=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:u.label}),e.jsxs("span",{children:[u.value,"%"]})]}),e.jsx(Ct,{value:u.value,className:"mt-2"})]},u.id))})]})]})]})}function Qt({inlineTaskDraft:s,setInlineTaskDraft:d,inlineTaskError:n,setInlineTaskError:m,inlineTaskPending:c,setShowInlineTaskComposer:o,submitInlineTask:x,goals:g,projects:y,inlineTaskProjects:j,projectsById:S,defaultUserId:b}){const P=()=>{o(!1),m(null)};return e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"New task"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add the task and place it in the sequence."})]}),e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Close"})]}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(T,{label:"Task title",children:e.jsx(Y,{value:s.title,onChange:a=>d(h=>({...h,title:a.target.value})),placeholder:"Draft the shared strategy hierarchy view"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Goal",children:e.jsxs("select",{value:s.goalId,onChange:a=>{const h=a.target.value,N=y.find(M=>M.goalId===h)??null;d(M=>({...M,goalId:h,projectId:(N==null?void 0:N.id)??"",userId:(N==null?void 0:N.userId)??M.userId??b}))},className:ie,children:[e.jsx("option",{value:"",children:"Select goal"}),g.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})}),e.jsx(T,{label:"Project",children:e.jsxs("select",{value:s.projectId,onChange:a=>d(h=>{var N,M;return{...h,projectId:a.target.value,goalId:((N=S.get(a.target.value))==null?void 0:N.goalId)??h.goalId,userId:((M=S.get(a.target.value))==null?void 0:M.userId)??h.userId}}),className:ie,children:[e.jsx("option",{value:"",children:"Select project"}),j.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})})]}),e.jsx(T,{label:"Notes",children:e.jsx(ue,{value:s.description,onChange:a=>d(h=>({...h,description:a.target.value})),placeholder:"Optional detail or acceptance note."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Priority",children:e.jsxs("select",{value:s.priority,onChange:a=>d(h=>({...h,priority:a.target.value})),className:ie,children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})}),e.jsx(T,{label:"Points",children:e.jsx(Y,{type:"number",value:s.points,onChange:a=>d(h=>({...h,points:Number(a.target.value)||0}))})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(T,{label:"Effort",children:e.jsxs("select",{value:s.effort,onChange:a=>d(h=>({...h,effort:a.target.value})),className:ie,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"deep",children:"Deep"}),e.jsx("option",{value:"extended",children:"Extended"})]})}),e.jsx(T,{label:"Energy",children:e.jsxs("select",{value:s.energy,onChange:a=>d(h=>({...h,energy:a.target.value})),className:ie,children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"steady",children:"Steady"}),e.jsx("option",{value:"intense",children:"Intense"})]})})]}),n?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{type:"button",variant:"secondary",className:"w-full sm:w-auto",onClick:P,children:"Cancel"}),e.jsxs(Q,{type:"button",className:"w-full sm:w-auto",pending:c,pendingLabel:"Creating task",onClick:x,children:[e.jsx(We,{className:"size-4"}),"Create task"]})]})]})]})}function Ft({draft:s,setDraft:d,hasSequenceQuery:n,hasSequenceResults:m,sequenceEntityKeys:c,limitedSequenceGoals:o,limitedSequenceProjects:x,limitedSequenceTasks:g,limitedSuggestedProjects:y,limitedSuggestedTasks:j,appendSequenceNode:S}){return n?m?e.jsxs("div",{className:"grid gap-3",children:[o.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goals"}):null,o.map(b=>{const P=s.targetGoalIds.includes(b.id),a=s.linkedEntities.some(h=>h.entityType==="goal"&&h.entityId===b.id);return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"goal",label:b.title,compact:!0,gradient:!1}),e.jsx(H,{user:b.user,compact:!0})]}),b.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:b.description}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:P?"secondary":"primary",onClick:()=>d(h=>({...h,targetGoalIds:ee(h.targetGoalIds,b.id)})),children:P?"Targeted":"Add target"}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:"secondary",onClick:()=>d(h=>({...h,linkedEntities:Ze(h.linkedEntities,{entityType:"goal",entityId:b.id})})),children:a?"Unlink":"Link"})]})]})},b.id)}),x.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Projects"}):null,x.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`sequence-project:${b.id}`)),g.length>0?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Tasks"}):null,g.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`sequence-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals, projects, or tasks match this search."}):y.length>0||j.length>0?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Suggested from targets"}),y.map(b=>e.jsx(Ke,{project:b,inSequence:c.has(`project:${b.id}`),appendSequenceNode:S},`suggested-project:${b.id}`)),j.map(b=>e.jsx(He,{task:b,inSequence:c.has(`task:${b.id}`),appendSequenceNode:S},`suggested-task:${b.id}`))]}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Type to search."})}function Ke({project:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"project",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.goalTitle}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||s.goalTitle})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("project",s.id),children:d?"In sequence":"Add step"})]})})}function He({task:s,inSequence:d,appendSequenceNode:n}){return e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"task",label:s.title,compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(H,{user:s.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description||`${s.owner} · ${s.status}`})]}),e.jsx(Q,{type:"button",className:"w-full sm:w-auto",variant:d?"secondary":"primary",disabled:d,onClick:()=>n("task",s.id),children:d?"In sequence":"Add step"})]})})}function Jt({open:s,pending:d=!1,editingStrategy:n,goals:m,projects:c,tasks:o,habits:x,strategies:g,users:y,defaultUserId:j=null,initialStepId:S,onOpenChange:b,onSubmit:P}){const[a,h]=p.useState(Qe),[N,M]=p.useState(""),[_,w]=p.useState(""),[$,F]=p.useState(""),[te,O]=p.useState(null),[A,z]=p.useState([]),[k,L]=p.useState(V(j,c)),[Z,K]=p.useState(!1),[U,q]=p.useState(null),[X,W]=p.useState(!1);p.useEffect(()=>{var r,i,v;if(!s)return;const t=n?Lt(n):{...Qe,userId:j,nodes:[pe("project",{dependencyMode:"start"})]};h(t),M(""),w(""),F(""),z([]),K(!1),L(V(j,c).projectId&&t.targetProjectIds[0]?{...V(j,c),goalId:((r=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:r.goalId)??"",projectId:t.targetProjectIds[0]??((i=c[0])==null?void 0:i.id)??"",userId:((v=c.find(I=>I.id===t.targetProjectIds[0]))==null?void 0:v.userId)??j}:V(j,c)),q(null),O(null)},[j,n,s,c]);const D=p.useDeferredValue(N),E=p.useDeferredValue(_),l=p.useDeferredValue($),u=p.useMemo(()=>{const t=new Set(A.map(r=>r.id));return[...A,...o.filter(r=>!t.has(r.id))]},[A,o]),f=p.useMemo(()=>new Map(m.map(t=>[t.id,t])),[m]),C=p.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),se=p.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),je=p.useMemo(()=>new Map(y.map(t=>[t.id,t])),[y]),me=y.find(t=>t.id===j)??null,ge=y.find(t=>t.id===a.userId)??me,B=(t,r,i)=>{const v=Dt(t);return v.length===0||Tt(r,i).includes(v)},Ie=p.useMemo(()=>m.filter(t=>B(E,[t.title,t.description],t.user)),[E,m]),he=p.useMemo(()=>m.filter(t=>B(D,[t.title,t.description],t.user)),[m,D]),xe=p.useMemo(()=>c.filter(t=>B(D,[t.title,t.description,t.goalTitle,t.status],t.user)),[D,c]),Ne=p.useMemo(()=>c.filter(t=>B(E,[t.title,t.description,t.goalTitle,t.status],t.user)),[E,c]),we=p.useMemo(()=>u.filter(t=>B(E,[t.title,t.description,t.owner,t.status],t.user)),[u,E]),ke=p.useMemo(()=>x.filter(t=>B(E,[t.title,t.description,t.frequency,t.status],t.user)),[E,x]),Se=p.useMemo(()=>g.filter(t=>t.id!==(n==null?void 0:n.id)&&B(E,[t.title,t.overview,t.endStateDescription,t.status],t.user)),[E,n==null?void 0:n.id,g]),ve=p.useMemo(()=>[...Ie.map(r=>({key:`goal:${r.id}`,entityType:"goal",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Goal"),user:r.user??null})),...Ne.map(r=>({key:`project:${r.id}`,entityType:"project",entityId:r.id,label:r.title,description:ae(`${r.goalTitle}${r.goalTitle?" · ":""}${r.status}`,r.user,`Project · ${r.goalTitle}`),user:r.user??null})),...we.map(r=>({key:`task:${r.id}`,entityType:"task",entityId:r.id,label:r.title,description:ae(`${r.status} · ${r.owner}`,r.user,`Task · ${r.owner}`),user:r.user??null})),...ke.map(r=>({key:`habit:${r.id}`,entityType:"habit",entityId:r.id,label:r.title,description:ae(r.description,r.user,"Habit"),user:r.user??null})),...Se.map(r=>({key:`strategy:${r.id}`,entityType:"strategy",entityId:r.id,label:r.title,description:ae(r.overview,r.user,"Strategy"),user:r.user??null}))].sort((r,i)=>r.label.localeCompare(i.label)),[Ie,ke,Ne,Se,we]),J=p.useMemo(()=>At(a,C,se),[a,C,se]),Ce=p.useMemo(()=>Rt({draft:a,graph:J,goals:m,projects:c,projectsById:C,tasks:u,tasksById:se}),[u,a,J,m,c,C,se]),Xe=p.useMemo(()=>[...Ye({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:J}),{id:"acyclic",label:"Graph stays directed and non-looping",satisfied:!ze(a.nodes)}],[a.endStateDescription,a.nodes,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,J]),fe=p.useMemo(()=>$t({title:a.title,overview:a.overview,endStateDescription:a.endStateDescription,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,graph:J}),[a.endStateDescription,a.overview,a.targetGoalIds,a.targetProjectIds,a.title,J]),Ve=p.useMemo(()=>qt(Ce),[Ce]),be=p.useMemo(()=>{if(!a.title.trim())return"Strategy title is required.";if(a.nodes.length===0)return"Add at least one project or task step.";const t=new Set;for(const r of a.nodes){if(!r.entityId)return"Every step needs a linked project or task.";const i=`${r.entityType}:${r.entityId}`;if(t.has(i))return"Each project or task should appear only once in the sequence.";t.add(i)}return ze(a.nodes)?"Strategy graph must stay directed and non-loopy.":null},[a.nodes,a.title]),et=t=>t==="sequence"?te??be??(fe?null:"This can still be saved as a draft. Add the target plus the overview or end state later, then lock it as the contract from the strategy detail page."):null,Me=p.useMemo(()=>m.filter(t=>B(l,[t.title,t.description],t.user)),[m,l]),ne=p.useMemo(()=>c.filter(t=>B(l,[t.title,t.description,t.goalTitle,t.status],t.user)),[c,l]),le=p.useMemo(()=>u.filter(t=>B(l,[t.title,t.description,t.owner,t.status],t.user)),[u,l]),de=p.useMemo(()=>new Set(a.targetGoalIds),[a.targetGoalIds]),oe=p.useMemo(()=>new Set(a.targetProjectIds),[a.targetProjectIds]),tt=p.useMemo(()=>new Set(a.nodes.map(t=>`${t.entityType}:${t.entityId}`)),[a.nodes]),Te=p.useMemo(()=>a.targetGoalIds.map(t=>f.get(t)).filter(t=>!!t),[a.targetGoalIds,f]),Pe=p.useMemo(()=>a.targetProjectIds.map(t=>C.get(t)).filter(t=>!!t),[a.targetProjectIds,C]),Ee=p.useMemo(()=>ne.filter(t=>oe.has(t.id)||de.has(t.goalId)),[ne,de,oe]),Ge=p.useMemo(()=>le.filter(t=>oe.has(t.projectId??"")||de.has(t.goalId??"")),[le,de,oe]),$e=p.useMemo(()=>he.slice(0,8),[he]),qe=p.useMemo(()=>xe.slice(0,8),[xe]),De=p.useMemo(()=>ve.slice(0,12),[ve]),_e=p.useMemo(()=>Me.slice(0,6),[Me]),Le=p.useMemo(()=>ne.slice(0,8),[ne]),Ae=p.useMemo(()=>le.slice(0,10),[le]),st=p.useMemo(()=>Ee.slice(0,4),[Ee]),rt=p.useMemo(()=>Ge.slice(0,6),[Ge]),at=p.useMemo(()=>{if(!k.goalId)return c;const t=c.filter(r=>r.goalId===k.goalId);return t.length>0?t:c},[k.goalId,c]),it=l.length>0,nt=_e.length>0||Le.length>0||Ae.length>0,lt=(t,r)=>{h(i=>({...i,nodes:i.nodes.map(v=>v.id===t?{...v,...r}:v)}))},Be=(t,r)=>{a.nodes.some(i=>i.entityType===t&&i.entityId===r)||h(i=>({...i,nodes:[...i.nodes,pe(t,{entityId:r,dependencyMode:i.nodes.length===0?"start":"after_previous"})]}))},dt=t=>{h(r=>{const i=r.nodes.filter(v=>v.id!==t);return{...r,nodes:i.map((v,I)=>({...v,dependencyMode:I===0&&v.dependencyMode==="after_previous"?"start":v.dependencyMode,customPredecessorIds:v.customPredecessorIds.filter(re=>re!==t)}))}})},ot=(t,r)=>{h(i=>{const v=i.nodes.findIndex(re=>re.id===t),I=i.nodes.findIndex(re=>re.id===r);return v<0||I<0?i:{...i,nodes:St(i.nodes,v,I)}})},ct=()=>{const t=$.trim(),r=a.targetProjectIds.map(I=>C.get(I)).find(I=>!!I)??C.get(k.projectId)??c[0]??null,i=(r==null?void 0:r.goalId)??a.targetGoalIds[0]??"",v=c.find(I=>I.goalId===i&&(r?I.id===r.id:!0))??c.find(I=>I.goalId===i)??r;L(I=>({...V(j,c),title:t||I.title,description:I.description,goalId:i,projectId:(v==null?void 0:v.id)??I.projectId,userId:(v==null?void 0:v.userId)??I.userId??j})),q(null),K(!0)},ut=async()=>{const t=C.get(k.projectId);if(!k.title.trim()){q("Task title is required.");return}if(!t){q("Pick a project for the new task.");return}W(!0),q(null);try{const r=je.get(k.userId??t.userId??"")??t.user??ge??me,i=(await Gt({title:k.title.trim(),description:k.description.trim(),level:"task",owner:(r==null?void 0:r.displayName)??"Albert",userId:k.userId??t.userId??a.userId,assigneeUserIds:[],goalId:t.goalId,projectId:t.id,parentWorkItemId:null,priority:k.priority,status:"focus",effort:k.effort,energy:k.energy,dueDate:"",points:k.points,plannedDurationSeconds:86400,aiInstructions:"",executionMode:null,acceptanceCriteria:[],blockerLinks:[],completionReport:null,gitRefs:[],tagIds:[],notes:[]})).task;z(v=>[i,...v]),Be("task",i.id),L({...V(j,c),goalId:t.goalId,projectId:t.id,userId:i.userId??t.userId??a.userId}),F(""),K(!1)}catch(r){q(r instanceof Error?r.message:"Task creation failed.")}finally{W(!1)}},pt=async()=>{if(be){O(be);return}try{await P({title:a.title.trim(),overview:a.overview.trim(),endStateDescription:a.endStateDescription.trim(),status:a.status,userId:a.userId,targetGoalIds:a.targetGoalIds,targetProjectIds:a.targetProjectIds,linkedEntities:a.linkedEntities,graph:J},n==null?void 0:n.id),O(null),b(!1)}catch(t){O(t instanceof Error?t.message:"Strategy save failed.")}},mt=[{id:"foundation",eyebrow:"Foundation",title:"Set the owner and the strategic frame",description:"Start with who owns the strategy, what the plan is called, and whether this should open as active, paused, or already landed.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(16rem,0.8fr)]",children:[e.jsx(T,{label:"Strategy title",children:e.jsx(Y,{value:t.title,onChange:i=>r({title:i.target.value}),placeholder:"Land the multi-user planning system"})}),e.jsx(T,{label:"Status",children:e.jsx(Je,{value:t.status,onChange:i=>r({status:i}),options:[{value:"active",label:"Active",description:"Use this when the plan should drive work now."},{value:"paused",label:"Paused",description:"Keep the strategy visible without active pressure."},{value:"completed",label:"Completed",description:"The end state is already landed."}]})})]}),e.jsx(Pt,{value:t.userId,users:y,onChange:i=>r({userId:i}),label:"Owner user",defaultLabel:Et(me),help:"Strategies can belong to a human or a bot even when the sequence spans multiple owners."}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-accent-soft)] px-5 py-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Live posture"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:"strategy",label:t.title.trim()||"Untitled strategy",compact:!0,gradient:!1}),e.jsx(G,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]",children:t.status}),ge?e.jsx(H,{user:ge,compact:!0}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This flow is built to keep strategy creation as guided as the other major entities in Forge: clear questions first, then a focused sequence stage at the end."})]})]})},{id:"objective",eyebrow:"Objective",title:"Define the objective and the end targets",description:"Capture what this strategy is coordinating, what done looks like, and which goals or projects are the real targets.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(T,{label:"Overview",children:e.jsx(ue,{value:t.overview,onChange:i=>r({overview:i.target.value}),placeholder:"Explain what this strategy is coordinating and why it matters right now."})}),e.jsx(T,{label:"End state",children:e.jsx(ue,{value:t.endStateDescription,onChange:i=>r({endStateDescription:i.target.value}),placeholder:"Describe what reality should look like when this strategy lands."})})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-5 py-5",children:[e.jsx(T,{label:"Search goals or projects",description:"Keep this page search-first. Add only the targets that truly define what this strategy is trying to land.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:N,onChange:i=>M(i.target.value),placeholder:"Search goals, projects, owners, humans, or bots"})]})}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected goals"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Te.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target goals yet"}):Te.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsx(R,{kind:"goal",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Selected projects"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Pe.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No target projects yet"}):Pe.map(i=>e.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsx(R,{kind:"project",label:i.title,compact:!0,gradient:!1}),e.jsx("span",{children:"Remove"})]},i.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Goal matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[he.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?$e.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No goals match this search yet."}):$e.map(i=>{const v=t.targetGoalIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",v?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetGoalIds:ee(t.targetGoalIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"goal",label:i.title,className:"max-w-full min-w-0"}),e.jsx(H,{user:i.user,compact:!0})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No strategic note attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the goal this strategy is meant to land."})})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Project matches"}),D?e.jsxs(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[xe.length," found"]}):null]}),e.jsx("div",{className:"mt-3 grid gap-3",children:D?qe.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No projects match this search yet."}):qe.map(i=>{const v=t.targetProjectIds.includes(i.id);return e.jsxs("button",{type:"button",className:ce("rounded-[22px] border px-4 py-4 text-left transition",v?"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r({targetProjectIds:ee(t.targetProjectIds,i.id)}),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsx(Re,{kind:"project",label:i.title,className:"max-w-full min-w-0",showIcon:!1}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.goalTitle}),e.jsx(H,{user:i.user,compact:!0})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description||"No project summary attached yet."})]},i.id)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search for the concrete project this strategy should land or organize."})})]})]})]})},{id:"context",eyebrow:"Context",title:"Keep the right supporting entities in view",description:"Linked entities stay visible in the strategy context without becoming part of the main execution sequence.",render:(t,r)=>e.jsxs(e.Fragment,{children:[e.jsx(T,{label:"Search supporting context",description:"Search across goals, projects, tasks, habits, and other strategies.",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx(ye,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(Y,{className:"border-none bg-transparent px-0 py-0",value:_,onChange:i=>w(i.target.value),placeholder:"Search by title, owner, @handle, human, or bot"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.linkedEntities.length===0?e.jsx(G,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:"No extra linked context yet"}):t.linkedEntities.map(i=>{const v=ve.find(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full bg-[var(--ui-accent-soft)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:()=>r({linkedEntities:t.linkedEntities.filter(I=>!(I.entityType===i.entityType&&I.entityId===i.entityId))}),children:[e.jsx(xt,{className:"mr-1 size-3.5"}),(v==null?void 0:v.label)??`${i.entityType}:${i.entityId}`,e.jsx("span",{children:"Remove"})]},`${i.entityType}:${i.entityId}`)})}),e.jsx("div",{className:"grid gap-3",children:E?De.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"No supporting entities match this search yet."}):De.map(i=>{const v=t.linkedEntities.some(I=>I.entityType===i.entityType&&I.entityId===i.entityId);return e.jsxs("label",{className:ce("flex items-start justify-between gap-3 rounded-[20px] border px-4 py-4",v?"border-[color-mix(in_srgb,var(--primary)_28%,transparent)] bg-[var(--ui-accent-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"),children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(R,{kind:i.entityType,label:i.label,compact:!0,gradient:!1}),i.user?e.jsx(H,{user:i.user,compact:!0}):null]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i.description})]}),e.jsx("input",{type:"checkbox",checked:v,onChange:()=>r({linkedEntities:Ze(t.linkedEntities,{entityType:i.entityType,entityId:i.entityId})})})]},i.key)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search when you want to pull another entity into the background context. This keeps the page focused instead of dumping every record into one long list."})})]})},{id:"sequence",eyebrow:"Sequence",title:"Build the execution sequence",description:"Search, add steps, and create missing tasks.",render:()=>e.jsx(zt,{draft:a,setDraft:h,sequenceSearchQuery:$,setSequenceSearchQuery:F,openInlineTaskComposer:ct,showInlineTaskComposer:Z,setShowInlineTaskComposer:K,inlineTaskDraft:k,setInlineTaskDraft:L,inlineTaskError:U,setInlineTaskError:q,inlineTaskPending:X,submitInlineTask:()=>void ut(),defaultUserId:j,goals:m,projects:c,inlineTaskProjects:at,projectsById:C,tasksById:se,usersById:je,goalsById:f,sequenceEntityKeys:tt,hasSequenceQuery:it,hasSequenceResults:nt,limitedSequenceGoals:_e,limitedSequenceProjects:Le,limitedSequenceTasks:Ae,limitedSuggestedProjects:st,limitedSuggestedTasks:rt,appendSequenceNode:Be,updateNode:lt,removeNode:dt,reorderNodes:ot,contractChecks:Xe,alignmentBreakdown:Ve})}];return e.jsx(Mt,{open:s,onOpenChange:b,eyebrow:"Strategy",title:n?"Edit strategy":"Create strategy",description:"Strategies connect goals, projects, and tasks into a guided multi-step plan with a focused sequence builder at the end.",value:a,onChange:h,draftPersistenceKey:n?`strategy.${n.id}`:"strategy.new",steps:mt,initialStepId:S,contentClassName:"lg:h-[min(56rem,calc(100vh-1rem))] lg:w-[min(78rem,calc(100vw-1.5rem))]",submitLabel:n?fe?"Save strategy":"Save draft":fe?"Create strategy":"Create draft",pending:d,pendingLabel:"Saving strategy",resolveError:et,onSubmit:pt})}export{Jt as S,Ye as a,qt as b,$t as i};
@@ -1 +1 @@
1
- import{j as r}from"./vendor-kIz9EZnX.js";import{Z as t}from"./index-BHIKoiZ6.js";function n({className:e,interactive:a=!1,muted:s=!1,...i}){return r.jsx("div",{className:t("rounded-[22px] border border-[var(--ui-border-subtle)] p-4",s?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]",a&&"transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",e),...i})}function c({label:e,value:a,className:s}){return r.jsxs(n,{className:t("rounded-[18px] p-3",s),children:[r.jsx("div",{className:"text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:a})]})}export{n as S,c as a};
1
+ import{j as r}from"./vendor-Dnkkx2co.js";import{Z as t}from"./index-EqQsXoat.js";function n({className:e,interactive:a=!1,muted:s=!1,...i}){return r.jsx("div",{className:t("rounded-[22px] border border-[var(--ui-border-subtle)] p-4",s?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]",a&&"transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",e),...i})}function c({label:e,value:a,className:s}){return r.jsxs(n,{className:t("rounded-[18px] p-3",s),children:[r.jsx("div",{className:"text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:a})]})}export{n as S,c as a};
@@ -1,4 +1,4 @@
1
- import{r as j}from"./vendor-kIz9EZnX.js";/**
1
+ import{r as j}from"./vendor-Dnkkx2co.js";/**
2
2
  * table-core
3
3
  *
4
4
  * Copyright (c) TanStack
@@ -0,0 +1 @@
1
+ import{bc as xe,aL as ze,br as Ke,cd as is,bO as rs,j as e,aC as A,b2 as De,cc as ns,b5 as ls,r as y,ce as cs,aV as ue,aG as ds,be as os,cy as us,aP as Ee,bg as ms,bo as xs}from"./vendor-Dnkkx2co.js";import{j as gs,i as Z,k as w}from"./state-vCcAT5Hq.js";import{Z as q,aq as Ue,b as J,c as i,U as Me,P as ps,u as hs,s as vs,ay as fs,r as ks,eO as bs,eP as js,at as Ns,as as ys,x as ws,y as Ss,z as Ts,S as As,E as Re,a8 as Cs,V as Oe,C as Is,B as k,h as T,d as me,K as Fe,az as $s,aT as Ps,i as _s,eQ as Ds,N as Le,O as Es}from"./index-EqQsXoat.js";import{a as Ms,T as Rs}from"./timebox-planning-dialog-ByojN0AN.js";import{O as Os}from"./open-in-graph-button-BFPKfyK3.js";import{N as X}from"./note-markdown-BzK2Qlgr.js";import{E as Fs}from"./entity-notes-surface-Djz50HvD.js";import{P as Ls}from"./preference-entity-handoff-button-Dj3V6VxL.js";import{g as Bs,e as qs,W as zs}from"./calendar-rules-DPFsfiRl.js";import{P as Ks}from"./page-hero-ffKzgyW3.js";import{g as Us,a as Ws}from"./activity-copy-Bj4h9OcF.js";import{g as Be,a as qe}from"./entity-links-DwpxhW2H.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./scheduling-rules-editor-D40AC2jR.js";import"./calendar-ui-Cy1XRwzV.js";import"./note-tags-input-CZzqJMLc.js";const Y=[{status:"backlog",label:"Backlog",description:"Not started yet.",icon:xe},{status:"focus",label:"Focus",description:"Ready to start soon.",icon:ze},{status:"in_progress",label:"In progress",description:"Work is active now.",icon:Ke},{status:"blocked",label:"Blocked",description:"Something is stopping progress.",icon:is},{status:"done",label:"Done",description:"The task is completed.",icon:rs}],Qs={issue:{label:"Issue",noun:"issue",descriptor:"Vertical slice issue",heroDescription:"Track the vertical slice, keep the acceptance bar explicit, and surface the execution context without losing the product-level story."},task:{label:"Task",noun:"task",descriptor:"AI session task",heroDescription:"Drive one focused AI execution session, keep the work contract crisp, and show the concrete evidence of what changed."},subtask:{label:"Subtask",noun:"subtask",descriptor:"Granular child step",heroDescription:"Keep the child step sharply scoped, trace its parent chain, and make the work evidence visible without opening the editor."}},Gs={commit:{label:"Commit",className:"bg-emerald-500/12 text-emerald-100"},branch:{label:"Branch",className:"bg-sky-500/12 text-sky-100"},pull_request:{label:"Pull request",className:"bg-fuchsia-500/12 text-fuchsia-100"}};function ge(a){return a==="issue"?"issue":"task"}function Hs(a,o){switch(a){case"goal":return`/goals/${o}`;case"project":return`/projects/${o}`;case"task":return`/tasks/${o}`;case"strategy":return`/strategies/${o}`;case"habit":return"/habits";default:return null}}function _(a){if(!a||a<=0)return"0 min";if(a<3600)return`${Math.max(1,Math.round(a/60))} min`;const o=Math.floor(a/3600),u=Math.round(a%3600/60);return u===0?`${o} h`:`${o} h ${u} min`}function x({label:a,help:o}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:a}),o?e.jsx(Ue,{content:o,label:`Explain ${a}`}):null]})}function D({eyebrow:a,title:o,description:u,children:c,className:g}){return e.jsxs("div",{className:q("min-w-0 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 sm:p-5",g),children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-2 text-lg font-medium text-[var(--ui-ink-strong)]",children:o}),u?e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u}):null,e.jsx("div",{className:"mt-4",children:c})]})}function h({label:a,value:o,hint:u,className:c}){return e.jsxs("div",{className:q("min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",c),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-2 text-base font-medium text-[var(--ui-ink-strong)]",children:o}),u?e.jsx("div",{className:"mt-1 text-sm leading-5 text-[var(--ui-ink-faint)]",children:u}):null]})}function Vs({payload:a,relatedWorkItems:o,availableTags:u,workItemMeta:c,taskLevel:g,hasAiBrief:v,botOwner:ee,formatDate:b,formatDateTime:C}){const E=a.task.parentWorkItemId?o.find(l=>l.id===a.task.parentWorkItemId)??null:null,M=o.filter(l=>l.parentWorkItemId===a.task.id).sort((l,j)=>l.sortOrder-j.sortOrder),z=(a.task.tagIds??[]).map(l=>u.find(j=>j.id===l)??null).filter(l=>!!l),R=a.task.blockerLinks??[];return e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx(D,{eyebrow:"Hierarchy",title:"Context map",description:`See where this ${c.noun} sits in the larger planning ladder without opening the board.`,children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(x,{label:"Project",help:`The project is the main work stream this ${c.noun} belongs to.`}),e.jsx("div",{className:"mt-2",children:a.project?e.jsx(A,{to:`/projects/${a.project.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:"project",label:a.project.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No project linked"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Goal",help:"The goal shows the longer-term result this work supports."}),e.jsx("div",{className:"mt-2",children:a.goal?e.jsx(A,{to:`/goals/${a.goal.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:"goal",label:a.goal.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No goal linked"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Parent item",help:"Issues parent tasks, tasks parent subtasks, and split child items stay legible here."}),e.jsx("div",{className:"mt-2",children:E?e.jsx(A,{to:`/tasks/${E.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:ge(E.level),label:E.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No parent work item"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Child items",help:"Child work items let you scan the next layer down without leaving the detail view."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:M.length>0?M.map(l=>e.jsx(A,{to:`/tasks/${l.id}`,className:"inline-flex max-w-full",children:e.jsx(J,{kind:ge(l.level),label:l.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No child work items"})})]})]})}),e.jsx(D,{eyebrow:"Execution",title:"Execution profile",description:"Surface the operating mode, AI posture, tags, and blockers as a single readable brief.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(h,{label:"Work-item type",value:c.descriptor,hint:g==="task"?"Tasks are meant to fit one focused AI session.":g==="issue"?"Issues hold the vertical slice and its delivery contract.":"Subtasks stay intentionally small and concrete."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Execution mode",value:a.task.executionMode?a.task.executionMode.toUpperCase():"Not set"}),e.jsx(h,{label:"AI posture",value:v?"AI brief ready":g==="issue"?"Issue narrative only":"Needs AI brief"})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Tags",help:"Tags shape filtering and fast scanning across the board and hierarchy views."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:z.length>0?z.map(l=>e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:l.name},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No tags"})})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Blockers",help:"Blockers tie this work item to the entities that currently constrain it."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:R.length>0?R.map(l=>{const j=Hs(l.entityType,l.entityId),K=e.jsx(i,{wrap:!0,className:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:l.label??`${l.entityType} · ${l.entityId}`},`${l.entityType}:${l.entityId}`);return j?e.jsx(A,{to:j,className:"inline-flex max-w-full",children:K},`${l.entityType}:${l.entityId}`):K}):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No blockers linked"})})]})]})}),e.jsx(D,{eyebrow:"People and timing",title:"Accountability surface",description:"Show who owns the work, who is helping, and when the record moved.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(h,{label:"Owner",value:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.task.user?e.jsx(Me,{user:a.task.user,compact:!0}):null,e.jsx("span",{children:a.task.owner}),ee?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:[e.jsx(De,{className:"mr-1 size-3.5"}),"Bot owner"]}):null]})}),e.jsxs("div",{children:[e.jsx(x,{label:"Assignees"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:a.task.assignees&&a.task.assignees.length>0?a.task.assignees.map(l=>e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(Me,{user:l,compact:!0}),e.jsx("span",{children:l.displayName}),l.kind==="bot"?e.jsx(De,{className:"size-3.5 text-[var(--tertiary)]"}):null]},l.id)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No assignees"})})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Due date",value:b(a.task.dueDate),hint:`Use due dates only when timing materially matters for this ${c.noun}.`}),e.jsx(h,{label:"Completed",value:a.task.completedAt?C(a.task.completedAt):"Not completed"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Created",value:C(a.task.createdAt)}),e.jsx(h,{label:"Updated",value:C(a.task.updatedAt)})]})]})})]})}function ht(){var Se,Te,Ae,Ce,Ie,$e,Pe;const{t:a,formatDate:o,formatDateTime:u}=ps(),c=hs(),g=Array.isArray(c.selectedUserIds)?c.selectedUserIds:[],v=ns(),ee=ls(),b=gs(),C=vs(g),[E,M]=y.useState(!1),[z,R]=y.useState(!1),[l,j]=y.useState(!1),[K,pe]=y.useState(!1),[We,se]=y.useState(!1),[Qe,U]=y.useState(null),[W,Ge]=y.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[te]=y.useState(()=>{const s=new Date,r=new Date(s);r.setHours(0,0,0,0);const n=new Date(s);return n.setHours(23,59,59,999),{from:r.toISOString(),to:n.toISOString()}}),[O]=y.useState(()=>{const s=new Date,r=new Date(s);r.setHours(0,0,0,0);const n=new Date(r);return n.setDate(n.getDate()+7),n.setHours(23,59,59,999),{from:r.toISOString(),to:n.toISOString()}});y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(max-width: 1023px)"),r=n=>Ge(n?n.matches:s.matches);return r(),typeof s.addEventListener=="function"?(s.addEventListener("change",r),()=>s.removeEventListener("change",r)):(s.addListener(r),()=>s.removeListener(r))},[]);const $=Z({queryKey:["task-context",v.taskId],queryFn:()=>Ds(v.taskId),enabled:!!v.taskId}),He=Z({queryKey:["task-calendar-overview",v.taskId,te.from,te.to,...g],queryFn:()=>Le({...te,userIds:g}),enabled:!!v.taskId}),I=Z({queryKey:["forge-life-force",...g],queryFn:async()=>(await Es(g)).lifeForce}),Ve=Z({queryKey:["task-calendar-overview",v.taskId,O.from,O.to,...g],queryFn:()=>Le({...O,userIds:g}),enabled:!!v.taskId}),N=async()=>{await Promise.all([_s(b),b.invalidateQueries({queryKey:["task-context",v.taskId]}),b.invalidateQueries({queryKey:["activity-archive"]}),b.invalidateQueries({queryKey:["project-board"]}),b.invalidateQueries({queryKey:["forge-xp-metrics"]}),b.invalidateQueries({queryKey:["forge-reward-ledger"]}),b.invalidateQueries({queryKey:["forge-operator-context"]}),b.invalidateQueries({queryKey:["task-calendar-overview",v.taskId]}),b.invalidateQueries({queryKey:["forge-calendar-overview"]})])},Q=w({mutationFn:({taskId:s,patch:r})=>c.patchTask(s,r),onSuccess:N}),Ze=w({mutationFn:s=>fs(s),onSuccess:N}),Je=w({mutationFn:s=>ks(s),onSuccess:N}),he=w({mutationFn:({runId:s,actor:r,note:n})=>bs(s,{actor:r,note:n??""}),onSuccess:N}),ve=w({mutationFn:({runId:s,actor:r,note:n})=>js(s,{actor:r,note:n??""}),onSuccess:N}),ae=w({mutationFn:Ns,onSuccess:N}),fe=w({mutationFn:s=>ys(s),onSuccess:N}),ie=w({mutationFn:ws,onSuccess:N}),ke=w({mutationFn:({timeboxId:s,patch:r})=>Ss(s,r),onSuccess:N}),Xe=w({mutationFn:Ts,onSuccess:N}),t=$.data;if($.isLoading)return e.jsx(As,{});if($.isError)return e.jsx(Re,{eyebrow:a("common.taskDetail.errorEyebrow"),error:$.error,onRetry:()=>void $.refetch()});if(!t)return e.jsx(Re,{eyebrow:a("common.taskDetail.errorEyebrow"),error:new Error(a("common.taskDetail.emptyPayload")),onRetry:()=>void $.refetch()});const f=t.activeTaskRun??null,m=t.task.actionPointSummary??null,be=Y.find(s=>s.status===t.task.status)??Y[0],re=t.task.level??"task",je=t.task.aiInstructions??"",Ye=Bs(t.task,(Se=t.project)==null?void 0:Se.schedulingRules),P=qs({rules:Ye,overview:(Te=He.data)==null?void 0:Te.calendar}),G=(((Ae=Ve.data)==null?void 0:Ae.calendar.timeboxes)??[]).filter(s=>s.taskId===t.task.id).sort((s,r)=>Date.parse(s.startsAt)-Date.parse(r.startsAt)),ne=G[0]??null,p=Qs[re],le=ge(re),es=c.snapshot.workItems??c.snapshot.tasks??[],ss=c.snapshot.tags??[],ce=t.task.acceptanceCriteria??[],H=t.task.gitRefs??[],d=t.task.completionReport,Ne=new Set((d==null?void 0:d.linkedGitRefIds)??[]),de=H.filter(s=>Ne.has(s.id)),ye=H.filter(s=>!Ne.has(s.id)),oe=((Ce=t.task.user)==null?void 0:Ce.kind)==="bot"||((Ie=t.task.ownerUser)==null?void 0:Ie.kind)==="bot",F=(t.task.assignees??[]).filter(s=>s.kind==="bot"),V=je.trim().length>0,S=W?"w-full justify-start":"",ts=s=>{switch(s){case"active":return"Active";case"completed":return"Completed";case"released":return"Paused";case"timed_out":return"Timed out";default:return s}},we=async s=>{await c.patchTaskStatus(t.task.id,s),await N(),se(!1)},as=async()=>{window.confirm(`Delete ${p.noun} "${t.task.title}"?`)&&(await fe.mutateAsync(t.task.id),ee(t.project?`/projects/${t.project.id}`:t.goal?`/goals/${t.goal.id}`:"/kanban"))};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ks,{entityKind:le,title:e.jsx(Oe,{kind:le,label:t.task.title,variant:"heading",size:"lg",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),titleText:t.task.title,description:t.task.description?e.jsx(X,{markdown:t.task.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):p.heroDescription,badge:m?`${t.task.points} xp · ${Math.round(m.totalCostAp)} AP`:`${t.task.points} xp`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Cs,{metrics:c.snapshot.metrics}),e.jsx(Ls,{userId:C,domain:"tasks",entityType:"task",entityId:t.task.id,label:t.task.title,description:t.task.description}),e.jsx(Os,{entityType:"task",entityId:t.task.id})]})}),e.jsxs(Is,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:p.label}),e.jsx("div",{className:"mt-2",children:e.jsx(Oe,{kind:le,label:t.task.title,variant:"heading",size:"xl",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.task.description?e.jsx(X,{markdown:t.task.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`This page shows the ${p.noun}, where it belongs, what is driving it, and the concrete evidence of what has happened on it so far.`})]}),e.jsx("div",{className:q("shrink-0",W?"w-full":""),children:e.jsxs("div",{className:q("flex flex-wrap items-center gap-2",W&&"grid w-full grid-cols-1"),children:[e.jsxs(k,{className:S,pending:$.isFetching,pendingLabel:f?"Opening":"Starting",onClick:async()=>{await c.startTaskNow(t.task.id),await N()},children:[e.jsx(Ke,{className:"size-4 fill-current"}),f?"Focus work":"Start work"]}),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:S,variant:"secondary",pending:he.isPending,pendingLabel:"Pausing",onClick:async()=>{await he.mutateAsync({runId:f.id,actor:f.actor,note:f.note})},children:"Pause"}),e.jsx(k,{className:S,variant:"secondary",pending:ve.isPending,pendingLabel:"Completing",onClick:async()=>{await ve.mutateAsync({runId:f.id,actor:f.actor,note:f.note})},children:"Complete"})]}):null,e.jsxs(k,{className:S,variant:"secondary",onClick:()=>se(!0),children:[e.jsx(be.icon,{className:"size-4"}),"Change status"]}),e.jsxs(k,{className:S,variant:"secondary",onClick:()=>M(!0),children:[e.jsx(cs,{className:"size-4"}),"Edit ",p.noun]}),e.jsxs(k,{className:S,variant:"secondary",onClick:()=>R(!0),children:[e.jsx(xe,{className:"size-4"}),"Adjust work"]}),e.jsxs(k,{className:S,variant:"secondary",pending:ie.isPending,pendingLabel:"Planning",onClick:()=>j(!0),children:[e.jsx(ue,{className:"size-4"}),"Time Box"]}),t.task.status==="done"?e.jsx(k,{className:S,variant:"secondary",onClick:async()=>{await Ze.mutateAsync(t.task.id)},children:"Mark as not done"}):null,e.jsxs(k,{className:q(S,"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[var(--ui-danger-soft)]"),variant:"ghost",pending:fe.isPending,pendingLabel:a("common.taskDetail.deleting"),onClick:()=>void as(),children:["Delete ",p.noun]})]})})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:p.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:p.descriptor}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:be.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.priority.${t.task.priority}`)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.effort.${t.task.effort}`)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:a(`common.enums.energy.${t.task.energy}`)}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[t.task.points," xp"]}),t.task.time.totalCreditedSeconds>0?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[Math.floor(t.task.time.totalCreditedSeconds/60)," min tracked"]}):null,f?e.jsx(i,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:"Timer active"}):null,t.task.executionMode?e.jsx(i,{className:t.task.executionMode==="afk"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:t.task.executionMode.toUpperCase()}):null,V?e.jsx(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:"AI brief ready"}):null,oe||F.length>0?e.jsx(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:"Bot collaboration live"}):null,ne?e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(ne.id)}`,className:"inline-flex",children:e.jsxs(i,{className:"cursor-pointer bg-[var(--primary)]/16 text-[var(--primary)] transition hover:bg-[var(--primary)]/24",children:["Timeboxed · ",u(ne.startsAt)]})}):null]}),W?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Status"}),e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-5",children:Y.map(s=>{const r=s.icon,n=s.status===t.task.status;return e.jsxs("button",{type:"button",disabled:n||Q.isPending,className:`rounded-[18px] border px-3.5 py-3 text-left transition ${n?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-3)]"}`,onClick:()=>void we(s.status),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"font-medium",children:s.label})]}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.description})]},s.status)})})]}),e.jsx(Vs,{payload:t,relatedWorkItems:es,availableTags:ss,workItemMeta:p,taskLevel:re,hasAiBrief:V,botOwner:oe,formatDate:o,formatDateTime:u}),V||ce.length>0||d||H.length>0?e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,1fr)]",children:[e.jsx(D,{eyebrow:"Execution brief",title:"AI and delivery instructions",description:"The narrative, criteria, and execution intent live together so the detail view can stand on its own.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(ds,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:"AI instructions"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:V?e.jsx(X,{markdown:je,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):`No AI instructions have been written for this ${p.noun} yet.`})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(ze,{className:"size-4 text-[var(--success)]"}),e.jsx("span",{children:"Acceptance criteria"})]}),ce.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:ce.map((s,r)=>e.jsx("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:s},`${t.task.id}-criterion-${r}`))}):e.jsx("div",{className:"mt-3 rounded-[16px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-3 text-sm text-[var(--ui-ink-faint)]",children:"No acceptance criteria captured yet."})]})]})}),e.jsx(D,{eyebrow:"Evidence",title:"Work done, changed files, and git traceability",description:"Show the work summary, file footprint, and linked refs directly in the detail view.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(os,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{children:"Work summary"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:d!=null&&d.workSummary?e.jsx(X,{markdown:d.workSummary,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No work summary yet."})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(us,{className:"size-4 text-[var(--warning)]"}),e.jsx("span",{children:"Changed files"})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:d!=null&&d.modifiedFiles&&d.modifiedFiles.length>0?d.modifiedFiles.map(s=>e.jsx(i,{wrap:!0,className:"bg-[var(--ui-surface-3)] font-mono text-[11px] text-[var(--ui-ink-medium)]",children:s},s)):e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No changed files listed"})})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(Ee,{className:"size-4 text-[var(--tertiary)]"}),e.jsx("span",{children:"Git refs"})]}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[[de,ye].filter(s=>s.length>0).map((s,r)=>e.jsxs("div",{className:"grid gap-2",children:[de.length>0&&ye.length>0?e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:r===0?"Linked in completion report":"Other recorded refs"}):null,s.map(n=>{const L=Gs[n.refType],B=e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(i,{className:L.className,children:L.label}),e.jsx("div",{className:"font-mono text-sm text-[var(--ui-ink-strong)]",children:n.refValue})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:n.displayTitle||n.repository||n.provider})]});return n.url?e.jsxs("a",{href:n.url,target:"_blank",rel:"noreferrer",className:"group block",children:[B,e.jsxs("div",{className:"mt-2 inline-flex items-center gap-1 text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:["Open ref",e.jsx(ms,{className:"size-3.5 transition group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})]},n.id):e.jsx("div",{children:B},n.id)})]},`git-group-${r}`)),H.length===0?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:"No git refs recorded"}):null]})]})]})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(D,{eyebrow:"Work done",title:"Execution ledger",description:"Surface tracked work, credited work, and manual adjustments without opening the timer history.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(h,{label:"Tracked total",value:_(t.task.time.totalTrackedSeconds)}),e.jsx(h,{label:"Credited total",value:_(t.task.time.totalCreditedSeconds)}),e.jsx(h,{label:"Live work",value:_(t.task.time.liveCreditedSeconds)}),e.jsx(h,{label:"Manual adjustments",value:_(t.task.time.manualAdjustedSeconds)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Today credited"," ",_(t.task.time.todayCreditedSeconds??0)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Live tracked"," ",_(t.task.time.liveTrackedSeconds)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Active runs ",t.task.time.activeRunCount]})]})]}),e.jsxs(D,{eyebrow:"Workflow health",title:"Signal scan",description:"A fast read on how ready this work item is for execution and closeout.",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Closeout readiness",value:d!=null&&d.workSummary||de.length>0?"Evidence present":"Needs closeout evidence",hint:($e=d==null?void 0:d.modifiedFiles)!=null&&$e.length?`${d.modifiedFiles.length} changed file${d.modifiedFiles.length===1?"":"s"} listed`:"No changed-file evidence captured yet."}),e.jsx(h,{label:"Collaboration model",value:oe||F.length>0?"Human + bot":t.task.assignees&&t.task.assignees.length>0?"Shared human work":"Single owner",hint:F.length>0?`${F.length} bot assignee${F.length===1?"":"s"} attached`:"No bot assignee attached."})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Priority ",a(`common.enums.priority.${t.task.priority}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Effort ",a(`common.enums.effort.${t.task.effort}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Energy ",a(`common.enums.energy.${t.task.energy}`)]}),e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Duration"," ",_(t.task.plannedDurationSeconds)]})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Action Point load"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Total cost"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?T(m.totalCostAp):"Not calibrated"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Today debit"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?T(m.spentTodayAp):"0 AP"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Sustain rate"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?me(m.sustainRateApPerHour):"0 AP/h"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Expected duration"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:m?`${Math.round(m.expectedDurationSeconds/3600)} h`:"No target"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(Pe=t.task.splitSuggestion)!=null&&Pe.shouldSplit?e.jsx(i,{className:"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",children:"Split it"}):null,m?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Remaining ",T(m.remainingAp)]}):null,m?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:["Spent total ",T(m.spentTotalAp)]}):null,m?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:m.costBand}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This task only debits the Action Points you actually worked today. Marking it done does not consume the full estimate by itself."})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Today's Life Force context"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Daily AP"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?`${T(I.data.spentTodayAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Instant headroom"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?me(I.data.instantFreeApPerHour):"Loading..."})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Forecast"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:I.data?`${T(I.data.forecastAp)} / ${T(I.data.dailyBudgetAp)}`:"Loading..."})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:"Current timer"}),e.jsx(Ue,{content:"This shows whether work is running on the task right now and how much time has been credited.",label:"Explain current timer"})]}),e.jsx("div",{className:"mt-3 text-[var(--ui-ink-strong)]",children:f?`${f.timerMode==="planned"?"Planned":"Unlimited"} timer active with ${Math.floor(f.creditedSeconds/60)} credited minutes.`:"No timer is running on this task right now."})]}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Task scheduling"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Rule source"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:t.task.schedulingRules?"Task-specific override":"Uses project defaults"})]}),e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3.5 py-3",children:[e.jsx(x,{label:"Planned duration"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:t.task.plannedDurationSeconds?`${Math.round(t.task.plannedDurationSeconds/60)} min`:"No duration target"})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Scheduling rules now live behind the guided modal flow instead of an inline editor. Use it to change eligible blocks, blocked contexts, and the planning duration without overcrowding the task page."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(k,{onClick:()=>pe(!0),children:[e.jsx(ue,{className:"size-4"}),"Edit task scheduling"]}),e.jsx(A,{to:"/calendar",children:e.jsx(k,{variant:"secondary",children:"Open calendar workspace"})})]})]}),e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Calendar status"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:P.tone==="blocked"?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":P.tone==="waiting"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:P.label}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:t.task.schedulingRules?"Task override":"Using project defaults"}),t.task.plannedDurationSeconds?e.jsxs(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:[Math.round(t.task.plannedDurationSeconds/60)," min target"]}):null]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge checks these rules before a live run starts. If the current calendar context is blocked, you can still override with an explicit reason."}),P.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:P.context.map(s=>e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s},s))})]}):null,P.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:P.conflicts.map(s=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-danger-soft)] px-3 py-2 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:s},s))}):null,e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:e.jsxs(k,{pending:ie.isPending||ke.isPending,pendingLabel:"Planning",onClick:()=>{U(null),j(!0)},children:[e.jsx(ue,{className:"size-4"}),"Time Box"]})})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Scheduled blocks"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Open a scheduled block to edit the day, the hour range, or the AP profile tied to this task."})]}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:G.length})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[G.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-4 text-sm text-[var(--ui-ink-faint)]",children:"No future timeboxes are attached to this task yet."}):null,G.map(s=>e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{U(s),j(!0)},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),U(s),j(!0))},className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-6 text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(xe,{className:"size-3.5 shrink-0"}),u(s.startsAt)," to"," ",u(s.endsAt)]})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.source}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.status}),e.jsx(i,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:me(Fe(s).rateApPerHour)}),e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:T(Fe(s).totalAp)}),s.overrideReason?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:s.overrideReason}):null]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx("span",{className:"rounded-[999px] bg-[var(--ui-surface-3)] px-3 py-1 text-xs text-[var(--ui-ink-medium)]",children:"Edit in guide"}),e.jsx(A,{to:`/calendar?timeboxId=${encodeURIComponent(s.id)}`,onClick:r=>r.stopPropagation(),className:"rounded-[999px] bg-[var(--ui-surface-3)] px-3 py-1 text-xs text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open in calendar"})]})]},s.id))]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(Fs,{entityType:"task",entityId:t.task.id,title:`${p.label} notes`,description:`Capture real progress, blockers, and context in Markdown so the ${p.noun} keeps a durable work log.`,invalidateQueryKeys:[["task-context",v.taskId],...t.task.projectId?[["project-board",t.task.projectId]]:[]]})}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Activity"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[t.activity.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-faint)]",children:"No activity has been recorded for this task yet."}):null,t.activity.map(s=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:Us(s)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:Ws(s)}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:u(s.createdAt)})]}),e.jsx(k,{variant:"ghost",className:"shrink-0",onClick:async()=>{await Je.mutateAsync(s.id)},children:"Remove"})]}),Be(s)&&qe(s)?e.jsx(A,{to:Be(s),className:"mt-3 inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:qe(s)}):null]},s.id))]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Timer sessions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[t.taskRuns.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-faint)]",children:"No timer sessions have been recorded for this task yet."}):null,t.taskRuns.map(s=>{var r,n,L,B,_e;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.actor}),e.jsx(i,{children:ts(s.status)})]}),(r=s.gitContext)!=null&&r.branch||(n=s.gitContext)!=null&&n.pullRequestNumber?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(L=s.gitContext)!=null&&L.branch?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[e.jsx(Ee,{className:"mr-1 size-3"}),s.gitContext.branch]}):null,(B=s.gitContext)!=null&&B.pullRequestNumber?e.jsxs(i,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:[e.jsx(xs,{className:"mr-1 size-3"}),"PR #",s.gitContext.pullRequestNumber]}):null,(_e=s.gitContext)!=null&&_e.repository?e.jsx(i,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",children:s.gitContext.repository}):null]}):null,e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:s.note||a("common.labels.noRunNote")}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:u(s.updatedAt)})]},s.id)})]})]})]}),e.jsx($s,{open:E,goals:c.snapshot.goals,projects:c.snapshot.dashboard.projects,workItems:c.snapshot.workItems,tags:c.snapshot.tags,users:c.snapshot.users,editingTask:t.task,defaultUserId:t.task.userId??C,onRefreshEntities:c.refresh,currentCreditedSeconds:t.task.time.totalCreditedSeconds,onOpenChange:M,onAdjustTrackedTime:async s=>{await ae.mutateAsync(s)},onSubmit:async(s,r)=>{r&&await Q.mutateAsync({taskId:r,patch:s})}}),e.jsx(zs,{open:z,onOpenChange:R,entityType:"task",entityId:t.task.id,targetLabel:t.task.title,currentCreditedSeconds:t.task.time.totalCreditedSeconds,pending:ae.isPending,onSubmit:async s=>{await ae.mutateAsync(s)}}),e.jsx(Ms,{open:l,onOpenChange:s=>{j(s),s||U(null)},tasks:[t.task],initialTaskId:t.task.id,lockedTaskId:t.task.id,editingTimebox:Qe,from:O.from,to:O.to,userIds:g,onCreateTimebox:async s=>{await ie.mutateAsync({...s,userId:C??void 0})},onUpdateTimebox:async(s,r)=>{await ke.mutateAsync({timeboxId:s,patch:{...r,userId:C??void 0}})},onDeleteTimebox:async s=>{await Xe.mutateAsync(s)}}),e.jsx(Rs,{open:K,onOpenChange:pe,tasks:[t.task],onSave:async({taskId:s,schedulingRules:r,plannedDurationSeconds:n})=>{await Q.mutateAsync({taskId:s,patch:{schedulingRules:r,plannedDurationSeconds:n}}),await b.invalidateQueries({queryKey:["task-calendar-overview",v.taskId]})}}),e.jsx(Ps,{open:We,onOpenChange:se,eyebrow:`${p.label} status`,title:"Change status",description:`Pick the state that best matches where this ${p.noun} is right now.`,children:e.jsx("div",{className:"grid gap-3",children:Y.map(s=>{const r=s.icon,n=s.status===t.task.status;return e.jsx("button",{type:"button",disabled:n||Q.isPending,className:`rounded-[22px] border px-4 py-4 text-left transition ${n?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-3)]"}`,onClick:()=>void we(s.status),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(r,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:s.description})]})]})},s.status)})})})]})}export{ht as TaskDetailPage};
@@ -0,0 +1 @@
1
+ import{r as j,j as e,aG as Ie}from"./vendor-Dnkkx2co.js";import{S as Re}from"./scheduling-rules-editor-D40AC2jR.js";import{aT as _e,C as ye,B as Y,K as ae,k as q,F as y,c as h,h as z,I as C,j as Ee,d as se,Q as Le,cJ as Me,N as Fe}from"./index-EqQsXoat.js";import{i as je}from"./state-vCcAT5Hq.js";import{f as $e}from"./calendar-ui-Cy1XRwzV.js";function ze({open:s,onOpenChange:o,tasks:m,onSave:v}){const c=j.useMemo(()=>m.filter(f=>f.status!=="done"),[m]),[I,k]=j.useState("");j.useEffect(()=>{if(s){if(c.length===0){k("");return}k(f=>f&&c.some(g=>g.id===f)?f:c[0].id)}},[c,s]);const N=c.find(f=>f.id===I)??null;return e.jsx(_e,{open:s,onOpenChange:o,eyebrow:"Calendar",title:"Adjust task scheduling rules",description:"Choose a task, then tell Forge which work blocks, calendar conditions, or keywords should allow or block that work.",children:e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Ie,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Guided rule editing"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Use this when a task should only run in certain blocks such as Secondary Activity, or should stay blocked during clinic, rest, or other provider events."})]})]})}),c.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"grid min-w-0 gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Task"}),e.jsx("select",{value:I,onChange:f=>k(f.target.value),className:"w-full min-w-0 max-w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20",children:c.map(f=>e.jsx("option",{value:f.id,children:f.title},f.id))})]}),N?e.jsx(Re,{title:"Task rules",subtitle:"These rules are saved directly on the task. They drive blocked-now checks and future timebox recommendations.",initialRules:N.schedulingRules,initialPlannedDurationSeconds:N.plannedDurationSeconds,allowPlannedDuration:!0,saveLabel:"Save task rules",onSave:async({schedulingRules:f,plannedDurationSeconds:g})=>{await v({taskId:N.id,schedulingRules:f,plannedDurationSeconds:g===void 0?N.plannedDurationSeconds:g??null}),o(!1)}}):null]}):e.jsxs(ye,{className:"min-w-0 overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] !bg-[var(--ui-surface-1)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"No schedulable tasks yet"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create or reopen a task first, then come back here to define work-block and calendar eligibility."}),e.jsx("div",{className:"mt-4",children:e.jsx(Y,{variant:"secondary",onClick:()=>o(!1),children:"Close"})})]})]})})}function E(s){return s.slice(0,10)}function Ke(s){return new Date(`${s}T00:00:00`).toISOString()}function He(s){return new Date(`${s}T23:59:59.999`).toISOString()}function re(s,o,m){return s<o?o:s>m?m:s}function we(s,o){const m=E(s),v=E(o),c=new Date(`${m}T12:00:00`);return c.setDate(c.getDate()+1),re(E(c.toISOString()),m,v)}function be(s){return String(s).padStart(2,"0")}function G(s){return`${be(s.getHours())}:${be(s.getMinutes())}`}function ke(s,o){if(!s||!o)return null;const m=new Date(`${s}T${o}:00`);return Number.isNaN(m.getTime())?null:m}function U(s,o,m){if(m){const k=new Date(m.startsAt),N=new Date(m.endsAt);return{startTime:G(k),endTime:G(N)}}const v=new Date(`${s}T09:00:00`),c=Math.max(1800,Math.min(o??3600,360*60)),I=new Date(v.getTime()+c*1e3);return{startTime:G(v),endTime:G(I)}}function Ne(s,o){return`${new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})} - ${new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function J(s,o){return`${$e(new Date(s))} · ${Ne(s,o)}`}const Se="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",ne="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",p="bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",ee="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-[15px] text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)] focus:ring-2 focus:ring-[var(--primary)]/20";function te({title:s,subtitle:o,emptyLabel:m,children:v}){const c=Array.isArray(v)?v:v?[v]:[];return e.jsxs("div",{className:`${Se} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:o})]}),e.jsx(h,{className:p,children:c.length})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:c.length>0?c:e.jsx("div",{className:"rounded-[18px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-muted)]",children:m})})]})}function Be({event:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.availability})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function Oe({block:s}){return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.blockingState})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startAt,s.endAt)})]})}function We({timebox:s}){const o=ae(s);return e.jsxs("div",{className:`${ne} px-3 py-3`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsx(h,{className:p,children:s.source})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:J(s.startsAt,s.endsAt)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(o.rateApPerHour)}),e.jsx(h,{className:p,children:z(o.totalAp)})]})]})}function Je({open:s,onOpenChange:o,tasks:m,from:v,to:c,onCreateTimebox:I,onUpdateTimebox:k,onDeleteTimebox:N,initialTaskId:f,lockedTaskId:g,editingTimebox:t,userIds:le}){var he,pe,fe,ve,ge,xe;const L=!!t,w=j.useMemo(()=>{const a=g??(t==null?void 0:t.taskId)??null,d=m.filter(u=>u.status!=="done"||u.id===a);if(!a)return d;const r=d.find(u=>u.id===a);return r?[r]:[]},[t==null?void 0:t.taskId,g,m]),M=E(v),F=E(c),ie=t?re(E(t.startsAt),M,F):we(v,c),oe=g??(t==null?void 0:t.taskId)??f??((he=w[0])==null?void 0:he.id)??"",$=w.find(a=>a.id===oe)??w[0]??null,de=U(ie,$==null?void 0:$.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null),[i,O]=j.useState({taskId:oe,preferredDate:ie,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((pe=t==null?void 0:t.actionProfile)==null?void 0:pe.profileKey)??"task_inherited",customSustainRateApPerHour:((fe=t==null?void 0:t.actionProfile)==null?void 0:fe.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:de.startTime,manualEndTime:de.endTime,manualTitle:(t==null?void 0:t.title)??($==null?void 0:$.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""}),[Ae,b]=j.useState(null),[Pe,W]=j.useState(!1),[De,ce]=j.useState(!1);j.useEffect(()=>{var _,H,B;if(!s)return;const a=g??f??((_=w[0])==null?void 0:_.id)??"",d=(t==null?void 0:t.taskId)??a,r=w.find(x=>x.id===d)??w[0]??null,u=t?re(E(t.startsAt),M,F):we(v,c),n=U(u,r==null?void 0:r.plannedDurationSeconds,t?{startsAt:t.startsAt,endsAt:t.endsAt}:null);b(null),O({taskId:d,preferredDate:u,plannerMode:t?"manual":"suggested",selectedTimeboxId:"",activityPresetKey:((H=t==null?void 0:t.actionProfile)==null?void 0:H.profileKey)??"task_inherited",customSustainRateApPerHour:((B=t==null?void 0:t.actionProfile)==null?void 0:B.sourceMethod)==="manual"?t.actionProfile.sustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(t==null?void 0:t.title)??(r==null?void 0:r.title)??"",overrideReason:(t==null?void 0:t.overrideReason)??""})},[w,t,v,f,g,F,M,s,c]);const l=w.find(a=>a.id===i.taskId)??null,P=j.useMemo(()=>({from:Ke(i.preferredDate),to:He(i.preferredDate)}),[i.preferredDate]),D=je({queryKey:["forge-calendar-suggestions-dialog",i.taskId,P.from,P.to],queryFn:()=>Me({taskId:i.taskId,from:P.from,to:P.to,limit:8}),enabled:s&&i.taskId.length>0}),X=je({queryKey:["forge-calendar-timebox-dialog-day",P.from,P.to,...le??[]],queryFn:()=>Fe({from:P.from,to:P.to,userIds:le}),enabled:s});j.useEffect(()=>{var d;if(!s)return;const a=((d=D.data)==null?void 0:d.timeboxes)??[];if(!a.length){O(r=>r.selectedTimeboxId?{...r,selectedTimeboxId:""}:r);return}O(r=>r.selectedTimeboxId&&a.some(u=>u.id===r.selectedTimeboxId)?r:{...r,selectedTimeboxId:a[0].id})},[s,D.data]);const A=(ve=X.data)==null?void 0:ve.calendar,Z=(A==null?void 0:A.events)??[],V=(A==null?void 0:A.workBlockInstances)??[],T=(A==null?void 0:A.timeboxes)??[],K=(((ge=D.data)==null?void 0:ge.timeboxes)??[]).find(a=>a.id===i.selectedTimeboxId),S=ke(i.preferredDate,i.manualStartTime),R=ke(i.preferredDate,i.manualEndTime),Q=S&&R?ae({startsAt:S.toISOString(),endsAt:R.toISOString(),actionProfile:i.customSustainRateApPerHour!==null||i.activityPresetKey!=="task_inherited"?{id:"manual-preview",profileKey:"manual-preview",title:i.manualTitle||(l==null?void 0:l.title)||"Manual timebox",entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:i.customSustainRateApPerHour??((xe=q().find(a=>a.key===i.activityPresetKey))==null?void 0:xe.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:S.toISOString(),updatedAt:S.toISOString()}:null}):null,ue=L?"Review the task tied to this scheduled block":g?"Review the task you are planning":"Choose the task you want to place into the calendar",me=L?"The timebox stays linked to this task. Update the day, hours, title, or AP profile without leaving the planning flow.":g?"Forge will use this task's current duration target and scheduling rules while it looks for viable slots.":"Forge will use the task's current planned duration and scheduling rules when it searches for valid slots.",Ce=j.useMemo(()=>[{id:"task",eyebrow:"Planning",title:ue,description:me,render:(a,d)=>e.jsxs("div",{className:"grid min-w-0 max-w-full gap-4 overflow-hidden",children:[g?null:e.jsx(y,{label:"Task",children:e.jsx("select",{value:a.taskId,onChange:r=>(()=>{const u=w.find(_=>_.id===r.target.value),n=U(a.preferredDate,u==null?void 0:u.plannedDurationSeconds);d({taskId:r.target.value,selectedTimeboxId:"",activityPresetKey:"task_inherited",customSustainRateApPerHour:null,manualStartTime:n.startTime,manualEndTime:n.endTime,manualTitle:(u==null?void 0:u.title)??a.manualTitle})})(),className:ee,children:w.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))})}),l?e.jsxs("div",{className:"min-w-0 max-w-full overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Time Box"}),e.jsx("div",{className:"mt-2 break-words font-display text-[1.4rem] leading-tight text-[var(--ui-ink-strong)]",children:l.title})]}),e.jsx(h,{className:p,children:l.status})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:l.plannedDurationSeconds?`${Math.round(l.plannedDurationSeconds/60)} min target`:"No duration yet"}),e.jsx(h,{className:p,children:l.schedulingRules?"Task-specific rules":"Uses project rules"}),e.jsxs(h,{className:p,children:[l.points," xp"]}),l.plannedDurationSeconds?e.jsxs(h,{className:p,children:[z(l.plannedDurationSeconds/3600/24*100)," ","target load"]}):null]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Pick a day first, then either accept one of Forge's suggested slots or set the block manually."}),L&&t&&N?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-danger-soft)] px-4 py-3",children:[e.jsx("div",{className:"text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"Remove this planned timebox if you no longer want it in the calendar."}),e.jsx(Y,{type:"button",variant:"ghost",className:"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[var(--ui-danger-soft)]",pending:De,pendingLabel:"Deleting",onClick:()=>void(async()=>{b(null),ce(!0);try{await N(t.id),o(!1)}catch(r){b(r instanceof Error?r.message:"Forge could not delete this timebox.")}finally{ce(!1)}})(),children:"Delete timebox"})]}):null]}):null]})},{id:"day",eyebrow:"Calendar",title:"Choose the day and review what is already there",description:"Forge reads the real day first so the timebox stays grounded in your provider events, work blocks, and already-planned work.",render:(a,d)=>e.jsx("div",{className:"grid gap-5",children:e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{label:"Date",description:"Choose the day you want to protect for this task.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:r=>{const u=U(r.target.value,l==null?void 0:l.plannedDurationSeconds,t?{startsAt:`${r.target.value}T${a.manualStartTime}:00`,endsAt:`${r.target.value}T${a.manualEndTime}:00`}:null);d({preferredDate:r.target.value,selectedTimeboxId:"",manualStartTime:u.startTime,manualEndTime:u.endTime})}})}),e.jsx(y,{label:"Planning style",description:"Take Forge's slot recommendation when it fits, or set the block yourself.",children:e.jsx(Ee,{value:a.plannerMode,onChange:r=>d({plannerMode:r}),options:[{value:"suggested",label:"Use suggestions",description:"Forge proposes slots that fit the task rules and the selected day."},{value:"manual",label:"Set it manually",description:"You choose the exact start and end time yourself."}]})})]}),e.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Selected day"}),e.jsx("div",{className:"mt-2 font-display text-[1.3rem] leading-tight text-[var(--ui-ink-strong)]",children:a.preferredDate?new Date(`${a.preferredDate}T12:00:00`).toLocaleDateString([],{weekday:"long",month:"long",day:"numeric"}):"Choose a day"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(h,{className:p,children:[Z.length," events"]}),e.jsxs(h,{className:p,children:[V.length," work blocks"]}),e.jsxs(h,{className:p,children:[T.length," timeboxes"]})]})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the context Forge will use while recommending a slot. You can still place the block manually if you want something more exact."}),X.isLoading?e.jsx("div",{className:"mt-4 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"Loading the selected day…"}):e.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-3",children:[e.jsx(te,{title:"Provider events",subtitle:"Busy or free events already on the day.",emptyLabel:"No mirrored events on this day.",children:Z.slice(0,4).map(r=>e.jsx(Be,{event:r},r.id))}),e.jsx(te,{title:"Work blocks",subtitle:"Recurring allowed or blocked containers.",emptyLabel:"No work blocks land on this day.",children:V.slice(0,4).map(r=>e.jsx(Oe,{block:r},r.id))}),e.jsx(te,{title:"Planned timeboxes",subtitle:"Existing owned work already placed there.",emptyLabel:"No other planned timeboxes yet.",children:T.slice(0,4).map(r=>e.jsx(We,{timebox:r},r.id))})]})]})]})})},{id:"slot",eyebrow:i.plannerMode==="suggested"?"Suggestion":"Manual",title:i.plannerMode==="suggested"?"Choose one of Forge's suggested slots":"Set the exact timebox yourself",description:i.plannerMode==="suggested"?"Forge proposes slots that fit the selected day, the task rules, and the current calendar picture.":"Use manual mode when the right block is obvious to you or when you want to place the timebox despite imperfect recommendations.",render:(a,d)=>{var u;if(a.plannerMode==="manual")return e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(y,{label:"Day",description:"Pick the day for the block. Forge defaults to a future day, but you can move it.",children:e.jsx(C,{type:"date",min:M,max:F,value:a.preferredDate,onChange:n=>d({preferredDate:n.target.value})})}),e.jsx(y,{label:"Start time",description:"Choose when the protected work block should begin.",children:e.jsx(C,{type:"time",step:300,value:a.manualStartTime,onChange:n=>d({manualStartTime:n.target.value})})}),e.jsx(y,{label:"End time",description:"Choose when the work block should end.",children:e.jsx(C,{type:"time",step:300,value:a.manualEndTime,onChange:n=>d({manualEndTime:n.target.value})})})]}),e.jsx(y,{label:"Title",description:"By default Forge uses the task title. Tighten it only if a shorter calendar label would help.",children:e.jsx(C,{value:a.manualTitle,onChange:n=>d({manualTitle:n.target.value}),placeholder:(l==null?void 0:l.title)??"Task timebox"})}),e.jsx(y,{label:"Override reason",description:"Optional. Add a short reason only if you are intentionally placing the block despite the normal rules or calendar shape.",children:e.jsx(C,{value:a.overrideReason,onChange:n=>d({overrideReason:n.target.value}),placeholder:"Protected writing block before clinic."})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:n=>d({activityPresetKey:n.target.value}),className:ee,children:q().map(n=>e.jsx("option",{value:n.key,children:n.label},n.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:n=>d({customSustainRateApPerHour:n.target.value.trim()===""?null:Number(n.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}),e.jsxs("div",{className:`${Se} p-4`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.manualTitle||(l==null?void 0:l.title)||"Manual timebox"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:S&&R?`${S.toLocaleDateString([],{weekday:"long",month:"short",day:"numeric"})} · ${Ne(S.toISOString(),R.toISOString())}`:"Choose a start and end time."})]}),e.jsx(h,{className:p,children:"manual"})]}),Q?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(Q.rateApPerHour)}),e.jsx(h,{className:p,children:z(Q.totalAp)})]}):null]})]});const r=((u=D.data)==null?void 0:u.timeboxes)??[];return D.isLoading?e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Looking for valid slots on the selected day…"}):r.length?e.jsx("div",{className:"grid gap-3",children:r.map(n=>{var B;const _=a.selectedTimeboxId===n.id,H=ae({...n,actionProfile:a.customSustainRateApPerHour!==null||a.activityPresetKey!=="task_inherited"?{id:"suggested-preview",profileKey:"suggested-preview",title:n.title,entityType:"task_timebox",mode:"container",startupAp:0,totalCostAp:0,expectedDurationSeconds:null,sustainRateApPerHour:a.customSustainRateApPerHour??((B=q().find(x=>x.key===a.activityPresetKey))==null?void 0:B.defaultRateApPerHour)??100/24,demandWeights:{activation:.1,focus:.3,vigor:.1,composure:.1,flow:.4},doubleCountPolicy:"container_only",sourceMethod:"manual",costBand:"light",recoveryEffect:0,metadata:{},createdAt:n.startsAt,updatedAt:n.startsAt}:null});return e.jsxs("button",{type:"button",onClick:()=>d({selectedTimeboxId:n.id}),className:`rounded-[24px] border px-4 py-4 text-left transition ${_?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium",children:n.title}),e.jsx(h,{className:p,children:n.source})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:J(n.startsAt,n.endsAt)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:p,children:se(H.rateApPerHour)}),e.jsx(h,{className:p,children:z(H.totalAp)})]}),_?e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[e.jsx(y,{label:"Activity profile",children:e.jsx("select",{value:a.activityPresetKey??"task_inherited",onChange:x=>d({activityPresetKey:x.target.value}),className:ee,children:q().map(x=>e.jsx("option",{value:x.key,children:x.label},x.key))})}),e.jsx(y,{label:"Custom AP per hour",children:e.jsx(C,{type:"number",min:0,step:.5,value:a.customSustainRateApPerHour??"",onChange:x=>d({customSustainRateApPerHour:x.target.value.trim()===""?null:Number(x.target.value)}),placeholder:"Leave empty to use the activity profile"})})]}):null]},n.id)})}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"rounded-[24px] border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-warning-soft)] px-4 py-4 text-sm leading-6 text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]",children:"Forge could not find a valid slot on this day. Try another day, adjust the task rules, or switch to manual placement if you already know the right block."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Y,{variant:"secondary",onClick:()=>void D.refetch(),children:"Refresh suggestions"}),e.jsx(Y,{variant:"secondary",onClick:()=>d({plannerMode:"manual"}),children:"Switch to manual"})]})]})}}],[w,X.isLoading,V,Z,T,i.plannerMode,t,v,g,F,Q,M,l,D.data,D.isLoading,me,ue,c]);return e.jsx(Le,{open:s,onOpenChange:o,eyebrow:"Calendar",title:L?"Edit timebox":"Plan work",description:L?"Update the day, hour range, title, and AP profile for this scheduled block without leaving the task or calendar view.":"Review the day, let Forge recommend valid slots, and place a real timebox on the task without leaving the detail view.",value:i,onChange:O,draftPersistenceKey:t?`calendar.timebox.${t.id}`:`calendar.timebox.new.${(l==null?void 0:l.id)??"unscoped"}`,steps:Ce,submitLabel:L?"Save timebox":"Schedule timebox",pending:Pe,pendingLabel:"Scheduling",error:Ae,contentClassName:"md:w-[min(70rem,calc(100vw-1.5rem))]",onSubmit:async()=>{if(!l){b("Choose a task before scheduling a timebox.");return}if(i.plannerMode==="manual"){if(!S||!R){b("Choose a valid manual start and end time.");return}if(R<=S){b("The manual timebox needs an end time after the start time.");return}b(null),W(!0);try{const a={title:i.manualTitle.trim()||l.title,startsAt:S.toISOString(),endsAt:R.toISOString(),overrideReason:i.overrideReason.trim()||null,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:"manual"}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the manual timebox.")}finally{W(!1)}return}if(!K){b("Pick one suggested slot before scheduling the timebox.");return}b(null),W(!0);try{const a={title:K.title,startsAt:K.startsAt,endsAt:K.endsAt,activityPresetKey:i.activityPresetKey,customSustainRateApPerHour:i.customSustainRateApPerHour};t&&k?await k(t.id,a):await I({taskId:l.id,projectId:l.projectId,...a,source:K.source}),o(!1)}catch(a){b(a instanceof Error?a.message:"Forge could not create the selected timebox.")}finally{W(!1)}}})}export{ze as T,Je as a};
@@ -0,0 +1 @@
1
+ import{j as e,aC as b,b8 as L,br as C,bO as X,b5 as O,r as D,aV as F,cA as U}from"./vendor-Dnkkx2co.js";import{i as M}from"./state-vCcAT5Hq.js";import{A as V}from"./ai-surface-workspace-CutiG6uS.js";import{P as H,aq as W,c as x,_ as z,b as S,V as P,B as q,Z as K,u as Q,a as G,eR as J,eS as Y,C as k,W as Z,eT as ee,eU as te,eV as se,bG as ae,bH as ie,bI as ne,bJ as re,bK as le,N as oe}from"./index-EqQsXoat.js";import{E as _}from"./entity-note-count-link-RzBB6ujx.js";import{S as $}from"./surface-CJI17F3n.js";import{a as de}from"./life-force-workspace-BJ4N1I78.js";import{P as A}from"./page-hero-ffKzgyW3.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";import"./floating-action-menu-CKQRhff9.js";import"./charts-DFnEuIMB.js";function E(s,t){return t.find(c=>c.id===s.goalId)??null}function ce(s,t){return s.tagIds.map(c=>t.find(d=>d.id===c)).filter(Boolean)}function me(s,t){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),t())}function ue(s,t){switch(s.status){case"backlog":return{label:t.backlog,action:"start",icon:C};case"focus":return{label:t.focus,action:"start",icon:C};case"in_progress":return{label:t.in_progress,nextStatus:"done",action:"move",icon:X};case"blocked":return{label:t.blocked,action:"start",icon:C};default:return null}}function xe({tasks:s,timeline:t,goals:c,tags:d,notesSummaryByEntity:N,selectedTaskId:j,onSelectTask:r,onMove:p,onStartTask:f}){const{t:l,formatDate:w}=H(),T={backlog:l("common.dailyRunway.actionBacklog"),focus:l("common.dailyRunway.actionFocus"),in_progress:l("common.dailyRunway.actionProgress"),blocked:l("common.dailyRunway.actionBlocked")};return e.jsxs("div",{className:"grid min-w-0 gap-4 2xl:grid-cols-[minmax(0,1.3fr)_minmax(17rem,0.9fr)]",children:[e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayEyebrow")}),e.jsx(W,{content:"These are the tasks that matter most for today. Click a card to open the task details. Use Start to begin work immediately."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.runwayTitle")})]}),e.jsx(x,{className:"shrink-0 text-[var(--primary)]",children:l(s.length===1?"common.dailyRunway.prioritiesOne":"common.dailyRunway.prioritiesOther",{count:s.length})})]}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.map((a,y)=>{const o=ue(a,T),i=ce(a,d).slice(0,2),n=E(a,c),h=j===a.id,B=z(N,"task",a.id).count;return e.jsxs("article",{role:"button",tabIndex:0,"aria-pressed":h,className:K("grid w-full gap-3 rounded-[22px] border px-4 py-4 text-left transition",h?"border-[var(--primary)]/28 bg-[var(--ui-accent-soft)] shadow-[var(--ui-shadow-soft)]":"border-transparent bg-[var(--ui-surface-1)] hover:border-[var(--ui-border-subtle)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>r(a.id),onKeyDown:m=>me(m,()=>r(a.id)),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.runwayItem",{index:y+1})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n?e.jsx(b,{to:`/goals/${n.id}`,className:"min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(S,{kind:"goal",label:n.title,compact:!0,gradient:!1})}):e.jsx(S,{kind:"goal",label:l("common.dailyRunway.unassigned"),compact:!0,gradient:!1}),a.time.activeRunCount>0?e.jsx(x,{className:"border-[color-mix(in_srgb,#10b981_24%,transparent)] bg-[color-mix(in_srgb,#10b981_16%,var(--ui-surface-1))] text-[color-mix(in_srgb,#10b981_80%,var(--ui-ink-strong)_20%)]",children:"Live"}):null]}),e.jsx("div",{className:"mt-2",children:e.jsx(b,{to:`/tasks/${a.id}`,className:"block min-w-0 max-w-full transition hover:opacity-85",onClick:m=>m.stopPropagation(),children:e.jsx(P,{kind:"task",label:a.title,variant:"heading",size:"md"})})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description||l("common.dailyRunway.noNote")})]}),e.jsx(x,{className:"shrink-0 self-start",children:a.status.replaceAll("_"," ")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(x,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[a.points," xp"]}),e.jsx(_,{entityType:"task",entityId:a.id,count:B}),a.time.totalCreditedSeconds>0?e.jsxs(x,{tone:"meta",children:[Math.floor(a.time.totalCreditedSeconds/60)," min tracked"]}):null,e.jsx(x,{tone:"meta",children:a.effort}),e.jsx(x,{tone:"meta",children:w(a.dueDate)}),i.map(m=>e.jsx(x,{className:"bg-[var(--ui-surface-2)]",style:{color:m.color},children:m.name},m.id))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.owner}),o?e.jsxs(q,{variant:o.action==="start"?"primary":"secondary",className:"px-3 py-2 text-[11px] uppercase tracking-[0.16em]",onClick:async m=>{if(m.stopPropagation(),o.action==="start"){await f(a.id);return}o.nextStatus&&await p(a.id,o.nextStatus)},children:[e.jsx(o.icon,{className:"mr-2 size-3.5"}),o.label]}):null]})]},a.id)})})]}),e.jsxs($,{className:"min-w-0 rounded-[24px]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.timelineEyebrow")}),e.jsx(W,{content:"This groups today's tasks by status, so you can see what is already moving, what is ready to start, what is blocked, and what is done."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:l("common.dailyRunway.timelineTitle")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:t.map(a=>e.jsxs($,{muted:!0,className:"min-w-0 overflow-hidden rounded-[20px]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(x,{tone:"meta",children:a.tasks.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[a.tasks.slice(0,3).map(y=>{const o=E(y,c);return e.jsxs(b,{to:`/tasks/${y.id}`,className:"flex min-w-0 items-center justify-between gap-3 overflow-hidden rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(P,{kind:"task",label:y.title,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),e.jsx("div",{className:"mt-2",children:e.jsx(S,{kind:"goal",label:(o==null?void 0:o.title)??l("common.dailyRunway.unassigned"),compact:!0,gradient:!1})})]}),e.jsx(L,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"})]},y.id)}),a.tasks.length===0?e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:l("common.dailyRunway.emptyBucket")}):null]})]},a.id))})]})]})}const he=5,g="text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",u="text-[var(--ui-ink-soft)]",v="text-[var(--ui-ink-strong)]",R="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] shadow-[var(--ui-shadow-soft)]",I="min-w-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",pe="inline-flex min-h-10 max-w-full shrink-0 items-center justify-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs font-medium text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]";function fe(){const s=new Date;s.setHours(0,0,0,0);const t=new Date(s);return t.setDate(t.getDate()+1),{start:s,end:t,from:s.toISOString(),to:t.toISOString()}}function ye(s,t){const c=new Date(s.startAt),d=new Date(s.endAt);return c<t.end&&d>t.start}function ge(s){if(s.isAllDay)return"All day";const t=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"});return`${t.format(new Date(s.startAt))} - ${t.format(new Date(s.endAt))}`}function Ae(){var o;const{t:s}=H(),t=Q(),c=O(),d=D.useMemo(()=>fe(),[]),N=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],j=M({queryKey:["forge-calendar-overview",d.from,d.to,...N],queryFn:()=>oe({from:d.from,to:d.to,userIds:N})}),r=t.snapshot.today.directive.task,p=t.snapshot.today.milestoneRewards.find(i=>!i.completed)??t.snapshot.today.milestoneRewards[0]??null,f=t.snapshot.risk.blockedTasks[0]??t.snapshot.risk.overdueTasks[0]??null,l=Math.max(0,t.snapshot.metrics.nextLevelXp-t.snapshot.metrics.currentLevelXp),w=D.useMemo(()=>{var i;return(((i=j.data)==null?void 0:i.calendar.events)??[]).filter(n=>!n.deletedAt&&n.status!=="cancelled"&&ye(n,d)).sort((n,h)=>new Date(n.startAt).getTime()-new Date(h.startAt).getTime())},[(o=j.data)==null?void 0:o.calendar.events,d]),T=w.slice(0,he);if(!(t.snapshot.lifeForce!==void 0||r!==null||t.snapshot.overview.topTasks.length>0||t.snapshot.today.dueHabits.length>0||t.snapshot.today.dailyQuests.length>0||t.snapshot.today.milestoneRewards.length>0||w.length>0)&&!j.isLoading)return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(A,{title:"Today",titleText:"Today",description:"Start a task, earn XP, and keep today's work clear.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`}),e.jsx(G,{eyebrow:s("common.todayPage.heroEyebrow"),title:s("common.todayPage.emptyTitle"),description:s("common.todayPage.emptyDescription"),action:e.jsx(b,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-on-accent)] transition hover:opacity-90",children:s("common.todayPage.emptyAction")})})]});const y=[{id:"hero",title:"Today",description:"Compact page header.",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(J,{children:e.jsx(A,{title:"Today",titleText:"Today",description:(r==null?void 0:r.description)??"Start one real task, collect XP, and keep today's work moving.",badge:`${t.snapshot.metrics.weeklyXp} weekly xp`})})},{id:"life-force",title:"Life Force",description:"Instant headroom, AP use today, and tiredness signals.",defaultWidth:12,defaultHeight:3,minWidth:5,render:()=>e.jsx(de,{selectedUserIds:t.selectedUserIds,fallbackLifeForce:t.snapshot.lifeForce,onRefresh:t.refresh})},{id:"metrics",title:"Live metrics",description:"XP, level, and momentum stay visible but lighter than before.",defaultWidth:5,defaultHeight:4,minWidth:4,render:({compact:i})=>e.jsx(Y,{children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Weekly XP"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--primary)]",children:t.snapshot.metrics.weeklyXp}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.totalXp," total XP"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Level"}),e.jsx("div",{className:`mt-2 font-display text-4xl ${v}`,children:t.snapshot.metrics.level}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[l," xp to the next level"]}),i?null:e.jsx("div",{className:"mt-3",children:e.jsx(Z,{value:t.snapshot.metrics.currentLevelXp/t.snapshot.metrics.nextLevelXp*100,tone:"tertiary"})})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Momentum"}),e.jsxs("div",{className:`mt-2 font-display text-4xl ${v}`,children:[t.snapshot.metrics.momentumScore,"%"]}),e.jsxs("div",{className:`mt-1 text-sm ${u}`,children:[t.snapshot.metrics.streakDays," day streak"]})]}),e.jsxs(k,{className:"min-w-0 p-4",children:[e.jsx("div",{className:g,children:"Next reward"}),e.jsx("div",{className:`mt-2 break-words text-base font-semibold ${v}`,children:(p==null?void 0:p.title)??"Keep showing up"}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:(p==null?void 0:p.progressLabel)??"The next visible win comes from a task completion or aligned habit check-in."})]})]})})},{id:"runway",title:"Runway",description:"The execution lane itself can be widened or narrowed.",defaultWidth:7,defaultHeight:6,minWidth:5,render:()=>e.jsx(ee,{children:e.jsx(xe,{tasks:t.snapshot.overview.topTasks,timeline:t.snapshot.today.timeline,goals:t.snapshot.goals,tags:t.snapshot.tags,notesSummaryByEntity:t.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:(r==null?void 0:r.id)??null,onSelectTask:i=>c(`/tasks/${i}`),onStartTask:async i=>{await t.startTaskNow(i)},onMove:async(i,n)=>{await t.patchTaskStatus(i,n)}})})},{id:"calendar",title:"Calendar",description:"Today's events stay grouped with their results instead of splitting search from outcome.",defaultWidth:5,defaultHeight:5,minWidth:4,render:({compact:i})=>e.jsx(te,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"inline-flex size-10 shrink-0 items-center justify-center rounded-2xl bg-[var(--primary)]/14 text-[var(--primary)]",children:e.jsx(F,{className:"size-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:g,children:"Today's calendar"}),e.jsx("div",{className:`text-sm font-semibold ${v}`,children:new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}).format(d.start)}),e.jsxs("div",{className:`text-sm ${u}`,children:[w.length," event",w.length===1?"":"s"]})]})]}),e.jsxs(b,{to:"/calendar",className:pe,children:["Open calendar",e.jsx(U,{className:"size-3.5"})]})]}),w.length===0?e.jsx("div",{className:`${I} px-4 py-4 text-sm ${u}`,children:"Nothing is scheduled yet for today."}):T.map(n=>e.jsxs("button",{type:"button",className:`${I} grid gap-2 px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]`,onClick:()=>c("/calendar"),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:n.title}),e.jsx("div",{className:`mt-1 text-sm ${u}`,children:ge(n)})]}),e.jsx(x,{className:"shrink-0 bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:n.originType==="native"?"Forge":n.originType})]}),!i&&n.description?e.jsx("div",{className:`line-clamp-2 text-sm leading-6 ${u}`,children:n.description}):null]},n.id))]})})},{id:"focus",title:"Current focus",description:"Current task, comeback task, and due habits stay in one movable stack.",defaultWidth:12,defaultHeight:4,minWidth:6,render:({compact:i})=>{var n;return e.jsx(se,{children:e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:g,children:"Current task"}),r?e.jsx(_,{entityType:"task",entityId:r.id,count:((n=t.snapshot.dashboard.notesSummaryByEntity[`task:${r.id}`])==null?void 0:n.count)??0}):null]}),e.jsx("div",{className:`mt-3 break-words text-base font-semibold ${v}`,children:(r==null?void 0:r.title)??"Pick a task from the runway"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(r==null?void 0:r.description)??"Once a task is active, the timer rail and this panel stay aligned."}),r?e.jsx("button",{type:"button",className:"mt-4 inline-flex min-h-10 max-w-full items-center justify-center rounded-2xl border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] px-3.5 py-2 text-sm font-medium text-[var(--primary)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",onClick:async()=>{await t.startTaskNow(r.id)},children:"Start work"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Recovery task"}),e.jsx("div",{className:`mt-3 break-words text-sm font-semibold ${v}`,children:(f==null?void 0:f.title)??"No blocked or overdue task is dominating today"}),i?null:e.jsx("div",{className:`mt-2 text-sm leading-6 ${u}`,children:(f==null?void 0:f.description)??"If something slips, it will surface here as the clean comeback move."})]}),e.jsxs("div",{className:`${R} p-4`,children:[e.jsx("div",{className:g,children:"Due habits"}),e.jsx("div",{className:"mt-3 grid gap-2",children:t.snapshot.today.dueHabits.slice(0,i?2:3).map(h=>e.jsxs("div",{className:`${I} flex items-center justify-between gap-3 px-3 py-2.5`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`truncate text-sm font-medium ${v}`,children:h.title}),i?null:e.jsx("div",{className:`text-sm ${u}`,children:h.frequency})]}),e.jsxs(x,{className:"shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_78%,var(--ui-ink-strong)_22%)]",children:[h.rewardXp," xp"]})]},h.id))})]})]})]})})}},{id:"time",title:"Clock",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(ie,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ne,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{surfaceId:"today"})},{id:"quick-capture",title:"Quick capture",description:"Save a note or wiki draft without leaving Today.",defaultWidth:5,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>{var n;return e.jsx(le,{compact:i,defaultUserId:t.selectedUserIds[0]??((n=t.snapshot.users[0])==null?void 0:n.id)??null})}}];return e.jsx(V,{surfaceId:"today",baseWidgets:y})}export{Ae as TodayPage};