forge-openclaw-plugin 0.3.16 → 0.3.18

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 (188) hide show
  1. package/dist/assets/{action-bar-DgrmzFrI.js → action-bar-BAZevCEA.js} +1 -1
  2. package/dist/assets/{activity-page-CF451ueg.js → activity-page-CnT_hnCU.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-DtwybxJB.js → ai-surface-workspace-GPZzIIut.js} +1 -1
  4. package/dist/assets/artifacts-page-Bqjp0L-L.js +2 -0
  5. package/dist/assets/{atlas-panel-CB3uYk_K.js → atlas-panel-B95nrYpZ.js} +1 -1
  6. package/dist/assets/{board-CuxQRKPJ.js → board-CGgOvBP9.js} +1 -1
  7. package/dist/assets/{calendar-page-BYsDuLnh.js → calendar-page-mlr94wIS.js} +1 -1
  8. package/dist/assets/{calendar-rules-DXuOv2J-.js → calendar-rules-DdxPmBZJ.js} +1 -1
  9. package/dist/assets/{calendar-week-toolbar-8PJmiUE_.js → calendar-week-toolbar-Cu8V6zv1.js} +1 -1
  10. package/dist/assets/{charts-BzT4pUPg.js → charts-Cdtn55ol.js} +1 -1
  11. package/dist/assets/{companion-sync-lab-page-DzWNOaBh.js → companion-sync-lab-page-CJI5jf8W.js} +1 -1
  12. package/dist/assets/{daily-metrics-dashboard-CHcYxDhs.js → daily-metrics-dashboard-CXESx7bU.js} +1 -1
  13. package/dist/assets/{define-workbench-box-DcI0_QKW.js → define-workbench-box-Dbl9W7oE.js} +1 -1
  14. package/dist/assets/{entity-link-multiselect-C--AiCMb.js → entity-link-multiselect-DZ_jAjs4.js} +1 -1
  15. package/dist/assets/{entity-note-count-link-xne6mshj.js → entity-note-count-link-FOK_qhcC.js} +1 -1
  16. package/dist/assets/{entity-notes-surface-jy6Psist.js → entity-notes-surface-Dq9dFKjD.js} +1 -1
  17. package/dist/assets/execution-board-D9hkXKC2.js +1 -0
  18. package/dist/assets/{faceted-token-search-BMQ1Wwzt.js → faceted-token-search-BeShxjkc.js} +1 -1
  19. package/dist/assets/{flagship-signal-deck-DjcskRwF.js → flagship-signal-deck-DZx_HEH9.js} +1 -1
  20. package/dist/assets/{floating-action-menu-cGhbJ2tc.js → floating-action-menu-CFrgvQJi.js} +1 -1
  21. package/dist/assets/{forms-D1qJ3oOP.js → forms-DhEGHkFR.js} +1 -1
  22. package/dist/assets/{generic-node-view-DNVwfqqq.js → generic-node-view-C1kLClIm.js} +1 -1
  23. package/dist/assets/{goal-detail-page-dAbyCilO.js → goal-detail-page-BhMrnVQs.js} +1 -1
  24. package/dist/assets/{goal-dialog-DH50D0tP.js → goal-dialog-BlZHh3dw.js} +1 -1
  25. package/dist/assets/goals-page-CesC8IkZ.js +1 -0
  26. package/dist/assets/{graph-BF4IsheG.js → graph-U1J6VkbG.js} +1 -1
  27. package/dist/assets/habits-page-DHxZSThT.js +1 -0
  28. package/dist/assets/{health-boxes-BPTgGM6G.js → health-boxes-BZjIqiiG.js} +1 -1
  29. package/dist/assets/index-CHbe1sy1.css +1 -0
  30. package/dist/assets/index-Dj8q65se.js +2 -0
  31. package/dist/assets/{inline-note-fields-D4mCM1gO.js → inline-note-fields-DpmCMAJf.js} +1 -1
  32. package/dist/assets/{insight-flow-dialog-Btp6bkbV.js → insight-flow-dialog-DNIe0sts.js} +1 -1
  33. package/dist/assets/{insights-page-1qM4mxjS.js → insights-page-D_N_MWGu.js} +3 -3
  34. package/dist/assets/{kanban-boxes-u_A-UJG-.js → kanban-boxes-DTDG5UEJ.js} +1 -1
  35. package/dist/assets/{kanban-page-CKCa_3Qb.js → kanban-page-DEvIY5IW.js} +1 -1
  36. package/dist/assets/knowledge-graph-page-CvXSnnG5.js +1 -0
  37. package/dist/assets/{life-force-page-BZlyA144.js → life-force-page-CgvUrqQb.js} +1 -1
  38. package/dist/assets/{life-force-workspace-CtAWZXNw.js → life-force-workspace-BNeMbRHf.js} +1 -1
  39. package/dist/assets/{maps-BTVHALP8.js → maps-Dk9tZqTA.js} +1 -1
  40. package/dist/assets/{metric-tile-Bkx2btO2.js → metric-tile-DAhX60rg.js} +1 -1
  41. package/dist/assets/{motion-DcgUnXhY.js → motion-DeJZhOSA.js} +1 -1
  42. package/dist/assets/{movement-boxes-QZ2EIS9q.js → movement-boxes-BOqU18NH.js} +1 -1
  43. package/dist/assets/{movement-page-B-3ihggI.js → movement-page-DCDeUynh.js} +1 -1
  44. package/dist/assets/{note-markdown-BWedRE3c.js → note-markdown-Cxj84-0j.js} +1 -1
  45. package/dist/assets/{note-tags-input-DZkCqI1w.js → note-tags-input-CP0-EPpE.js} +1 -1
  46. package/dist/assets/{notes-boxes-DGFmt7Dp.js → notes-boxes-C7WPT7mf.js} +1 -1
  47. package/dist/assets/notes-page-Dll8PIks.js +1 -0
  48. package/dist/assets/{open-in-graph-button-CjvkEj1P.js → open-in-graph-button-BHl16hJP.js} +1 -1
  49. package/dist/assets/{orbit-map-CRHSPenk.js → orbit-map-De0qpMpY.js} +1 -1
  50. package/dist/assets/overview-page-C1RX7dcq.js +1 -0
  51. package/dist/assets/page-hero-DYmFM6-q.js +1 -0
  52. package/dist/assets/pill-cluster-ClkmFVFT.js +1 -0
  53. package/dist/assets/{preference-entity-handoff-button-CfCQl3cW.js → preference-entity-handoff-button-1XXtBsUF.js} +1 -1
  54. package/dist/assets/{preferences-page-OltGdsQ2.js → preferences-page-OwfPIQwe.js} +1 -1
  55. package/dist/assets/{project-collections-FfBIVwXu.js → project-collections-DfmkBk9d.js} +1 -1
  56. package/dist/assets/project-detail-page-BC_MNaca.js +1 -0
  57. package/dist/assets/{project-dialog-B_J1ESMk.js → project-dialog-BuZdXECa.js} +1 -1
  58. package/dist/assets/project-management-hierarchy-page-AhEHe60K.js +1 -0
  59. package/dist/assets/{project-management-section-nav-DBNHt9p5.js → project-management-section-nav-CnaseOqL.js} +1 -1
  60. package/dist/assets/{projects-boxes-BvlVsO5q.js → projects-boxes-D0zM8PfY.js} +1 -1
  61. package/dist/assets/projects-page-ltrWfLrA.js +1 -0
  62. package/dist/assets/psyche-behaviors-page-CPurgDg6.js +5 -0
  63. package/dist/assets/{psyche-flashcards-page-05606-97.js → psyche-flashcards-page-DnUSe-bb.js} +1 -1
  64. package/dist/assets/{psyche-goal-map-page-Cw-aqS3Y.js → psyche-goal-map-page-uWocO7kZ.js} +1 -1
  65. package/dist/assets/{psyche-graph-0E22QHPe.js → psyche-graph-BDszV3UN.js} +1 -1
  66. package/dist/assets/{psyche-metrics-page-DBFVPeMa.js → psyche-metrics-page-CIJLJTPy.js} +1 -1
  67. package/dist/assets/psyche-mode-guide-page-uC8L4WvH.js +1 -0
  68. package/dist/assets/psyche-modes-page-CtBeRA_3.js +1 -0
  69. package/dist/assets/psyche-page-Ds3QDsin.js +1 -0
  70. package/dist/assets/psyche-patterns-page-Cvq5WshW.js +5 -0
  71. package/dist/assets/{psyche-questionnaire-builder-page-DEt0UDsz.js → psyche-questionnaire-builder-page-Cg5Upe6z.js} +1 -1
  72. package/dist/assets/{psyche-questionnaire-detail-page-BXQbOE6A.js → psyche-questionnaire-detail-page-D4jEnNoh.js} +1 -1
  73. package/dist/assets/psyche-questionnaire-run-detail-page-CWoZEY31.js +1 -0
  74. package/dist/assets/{psyche-questionnaire-run-page-D_EokOQm.js → psyche-questionnaire-run-page-Yg_VG2vq.js} +1 -1
  75. package/dist/assets/{psyche-questionnaires-page-D1Ov2L4n.js → psyche-questionnaires-page-BqeOJRj7.js} +1 -1
  76. package/dist/assets/{psyche-report-detail-page-9HyPr8BJ.js → psyche-report-detail-page-BtcMQ7mk.js} +3 -3
  77. package/dist/assets/psyche-reports-page-tagvW0To.js +1 -0
  78. package/dist/assets/{psyche-schemas-DDol0j-g.js → psyche-schemas-CvRSkI_u.js} +1 -1
  79. package/dist/assets/psyche-schemas-beliefs-page-4NL3415v.js +9 -0
  80. package/dist/assets/{psyche-screen-time-page-DJMDR5oo.js → psyche-screen-time-page-Bc5AwZHQ.js} +1 -1
  81. package/dist/assets/{psyche-self-observation-page-DFKXG1Yv.js → psyche-self-observation-page-CUrUYbQ_.js} +1 -1
  82. package/dist/assets/{psyche-values-page-TWKth89J.js → psyche-values-page-BshT2sXE.js} +2 -2
  83. package/dist/assets/{question-flow-dialog-D-_EvoAt.js → question-flow-dialog-CPyXCqA-.js} +2 -2
  84. package/dist/assets/{report-chain-fields-Dy-jBQDn.js → report-chain-fields-C0UMLpze.js} +1 -1
  85. package/dist/assets/rewards-page-D9BzsNPW.js +1 -0
  86. package/dist/assets/{scheduling-rules-editor-CAd290IE.js → scheduling-rules-editor-DiA6KkQ4.js} +1 -1
  87. package/dist/assets/{schema-badge-BLaVI1D7.js → schema-badge-DURw2eYH.js} +1 -1
  88. package/dist/assets/{schemas-B0Pa-V-A.js → schemas-D_z2C8l1.js} +1 -1
  89. package/dist/assets/{select-menu-DcS4Ukjf.js → select-menu-BUB8__Nx.js} +1 -1
  90. package/dist/assets/{settings-agents-page-Bt38HhEJ.js → settings-agents-page-Kk98Whcf.js} +1 -1
  91. package/dist/assets/settings-bin-page-BnJ-mgy2.js +1 -0
  92. package/dist/assets/{settings-calendar-page-DPSSZV3s.js → settings-calendar-page-CdhlUnUW.js} +3 -3
  93. package/dist/assets/{settings-data-page-BdHsD1C_.js → settings-data-page-BvvuZNbb.js} +1 -1
  94. package/dist/assets/{settings-logs-page-D9OnWoFq.js → settings-logs-page-CrzkXxtZ.js} +1 -1
  95. package/dist/assets/{settings-mobile-page-DFpsXA4M.js → settings-mobile-page-Dl582NK6.js} +1 -1
  96. package/dist/assets/settings-models-page-COoBw28S.js +1 -0
  97. package/dist/assets/{settings-page-m_3iYPwU.js → settings-page-DqnlOCgo.js} +1 -1
  98. package/dist/assets/{settings-rewards-page-B2aBm-dA.js → settings-rewards-page-Cw5QSTjy.js} +1 -1
  99. package/dist/assets/{settings-section-nav-CMeU19Rx.js → settings-section-nav-C1NcWveT.js} +1 -1
  100. package/dist/assets/{settings-users-page-D8jyewJl.js → settings-users-page-0opvepcM.js} +1 -1
  101. package/dist/assets/{settings-wiki-page-DjOgQJAh.js → settings-wiki-page-CkpnUkiZ.js} +1 -1
  102. package/dist/assets/{sleep-page-D8-dA4bE.js → sleep-page-DrS1zs3B.js} +1 -1
  103. package/dist/assets/{sports-page-CK3PgPKB.js → sports-page-EVnB_zjB.js} +1 -1
  104. package/dist/assets/{state-Bpe5dF3T.js → state-DWw8Jay_.js} +1 -1
  105. package/dist/assets/{strategies-page-aFpJath-.js → strategies-page-COhyv_SH.js} +1 -1
  106. package/dist/assets/{strategy-detail-page-CobF5qLv.js → strategy-detail-page-BaCVkvIu.js} +1 -1
  107. package/dist/assets/{strategy-dialog-Fgoaoob5.js → strategy-dialog-DvlPo9WV.js} +1 -1
  108. package/dist/assets/{surface-D0dqgX-k.js → surface-Dg5fauKP.js} +1 -1
  109. package/dist/assets/{table-U7otr5go.js → table-CWVROEBP.js} +1 -1
  110. package/dist/assets/task-detail-page-3IeMYIXl.js +1 -0
  111. package/dist/assets/{task-dialog-eCDTF8xe.js → task-dialog-B7ZT4KE5.js} +5 -5
  112. package/dist/assets/timebox-planning-dialog-DoZzpEBp.js +1 -0
  113. package/dist/assets/{today-boxes-CYfskVrM.js → today-boxes-BbUNpb16.js} +1 -1
  114. package/dist/assets/today-page-adKXN2g1.js +1 -0
  115. package/dist/assets/training-load-page-DTYbu9f0.js +1 -0
  116. package/dist/assets/{ui-B9TWEtCx.js → ui-CdEDMtXF.js} +1 -1
  117. package/dist/assets/{use-anchored-overlay-position-BY4kNzPj.js → use-anchored-overlay-position-Cracjgo6.js} +1 -1
  118. package/dist/assets/{use-psyche-focus-target-BhNedCZB.js → use-psyche-focus-target-DvRgu-94.js} +1 -1
  119. package/dist/assets/{user-badge-MEZuJiir.js → user-badge-B8hYK6NU.js} +1 -1
  120. package/dist/assets/{user-select-field-fx129Uh6.js → user-select-field-akGHK-2t.js} +1 -1
  121. package/dist/assets/{utility-widgets-h5eG2jvc.js → utility-widgets-D4KsKxLT.js} +2 -2
  122. package/dist/assets/{vendor-BwL6m4SE.js → vendor-y_uz1Wft.js} +222 -212
  123. package/dist/assets/{vitals-page-eoFnQ3XL.js → vitals-page-Cjcxh-kO.js} +1 -1
  124. package/dist/assets/{weekly-review-page-C7BU1gkK.js → weekly-review-page-CR57efzH.js} +1 -1
  125. package/dist/assets/{weight-loss-page-Cc7Do3XY.js → weight-loss-page-Bk7YkB7b.js} +1 -1
  126. package/dist/assets/{wiki-article-markdown-CCKoSptz.js → wiki-article-markdown-um6gpmGQ.js} +2 -2
  127. package/dist/assets/{wiki-editor-page-BpbxZrgz.js → wiki-editor-page-DdP5hvjZ.js} +5 -5
  128. package/dist/assets/{wiki-ingest-history-page-D5Wfr8pc.js → wiki-ingest-history-page-DSTndduq.js} +1 -1
  129. package/dist/assets/{wiki-ingest-modal-DhRVsEwC.js → wiki-ingest-modal-PNW3CJ-o.js} +1 -1
  130. package/dist/assets/wiki-page-CsJlPyQ6.js +1 -0
  131. package/dist/assets/{workbench-flow-page-y9FxDbKO.js → workbench-flow-page-DFtIKgNe.js} +3 -3
  132. package/dist/assets/{workbench-page-Da16AZvN.js → workbench-page-DEpKjMEv.js} +1 -1
  133. package/dist/assets/workout-detail-page-BwfEhxA_.js +2 -0
  134. package/dist/index.html +8 -8
  135. package/dist/openclaw/parity.d.ts +1 -1
  136. package/dist/openclaw/parity.js +10 -0
  137. package/dist/openclaw/routes.js +78 -0
  138. package/dist/openclaw/tools.js +42 -0
  139. package/dist/server/apps/api/migrations/072_artifact_store.sql +106 -0
  140. package/dist/server/apps/api/migrations/073_artifact_entity_links_repair.sql +24 -0
  141. package/dist/server/apps/api/src/app.js +364 -3
  142. package/dist/server/apps/api/src/openapi.js +570 -1
  143. package/dist/server/apps/api/src/repositories/entity-links.js +66 -0
  144. package/dist/server/apps/api/src/services/artifacts.js +1059 -0
  145. package/dist/server/apps/api/src/services/entity-crud.js +22 -0
  146. package/dist/server/apps/api/src/services/knowledge-graph.js +45 -0
  147. package/dist/server/apps/api/src/services/psyche-observation-calendar.js +1 -0
  148. package/dist/server/apps/api/src/types.js +2 -0
  149. package/dist/server/apps/web/src/lib/api.js +69 -0
  150. package/dist/server/apps/web/src/lib/entity-visuals.js +10 -1
  151. package/dist/server/apps/web/src/lib/knowledge-graph-types.js +9 -0
  152. package/openclaw.plugin.json +2 -1
  153. package/package.json +1 -1
  154. package/server/migrations/072_artifact_store.sql +106 -0
  155. package/server/migrations/073_artifact_entity_links_repair.sql +24 -0
  156. package/skills/forge-openclaw/SKILL.md +57 -4
  157. package/skills/forge-openclaw/entity_conversation_playbooks.md +215 -14
  158. package/skills/forge-openclaw/psyche_entity_playbooks.md +20 -0
  159. package/dist/assets/execution-board-BSUZCIIx.js +0 -1
  160. package/dist/assets/goals-page-DkMy9mPD.js +0 -1
  161. package/dist/assets/habits-page-CCQR8rg6.js +0 -1
  162. package/dist/assets/index-VzCGTBS_.css +0 -1
  163. package/dist/assets/index-izRKx6JK.js +0 -2
  164. package/dist/assets/knowledge-graph-page-BZOxRv19.js +0 -1
  165. package/dist/assets/notes-page-DYkn04tz.js +0 -1
  166. package/dist/assets/overview-page-D6LsjPWe.js +0 -1
  167. package/dist/assets/page-hero-BLhM8FF3.js +0 -1
  168. package/dist/assets/pill-cluster-B5bYs_e2.js +0 -1
  169. package/dist/assets/project-detail-page-CCm3iZPQ.js +0 -1
  170. package/dist/assets/project-management-hierarchy-page-BNzvtNZj.js +0 -1
  171. package/dist/assets/projects-page-BUf7KV-_.js +0 -1
  172. package/dist/assets/psyche-behaviors-page-jtyhdpJ1.js +0 -5
  173. package/dist/assets/psyche-mode-guide-page-DI-LNEDT.js +0 -1
  174. package/dist/assets/psyche-modes-page-CaMupyfi.js +0 -1
  175. package/dist/assets/psyche-page-CFBq0YKf.js +0 -1
  176. package/dist/assets/psyche-patterns-page-sp4ikoef.js +0 -5
  177. package/dist/assets/psyche-questionnaire-run-detail-page-Cd3ClsSK.js +0 -1
  178. package/dist/assets/psyche-reports-page-BeyJg5fb.js +0 -1
  179. package/dist/assets/psyche-schemas-beliefs-page-DNmf-Vma.js +0 -9
  180. package/dist/assets/rewards-page-D3ymEd2X.js +0 -1
  181. package/dist/assets/settings-bin-page-DqyVI1i1.js +0 -1
  182. package/dist/assets/settings-models-page-DaFXLp-O.js +0 -1
  183. package/dist/assets/task-detail-page-CDK79bzk.js +0 -1
  184. package/dist/assets/timebox-planning-dialog-CNZIGSpd.js +0 -1
  185. package/dist/assets/today-page-Bnh8wopq.js +0 -1
  186. package/dist/assets/training-load-page-C7lq-jqy.js +0 -1
  187. package/dist/assets/wiki-page-1vf-HErs.js +0 -1
  188. package/dist/assets/workout-detail-page-Cq0YamXF.js +0 -2
@@ -1 +0,0 @@
1
- import{r as h,j as r,b6 as nr,bY as sr,ca as ir,cf as or,cg as gt,bj as ft,bX as cr,ch as lr,ci as ur,cj as dr}from"./vendor-BwL6m4SE.js";import{R as pr,P as hr,O as gr,C as fr,T as mr,D as xr,a as mt}from"./ui-B9TWEtCx.js";import{i as yr}from"./state-Bpe5dF3T.js";import{ai as br,aj as dt,ak as Ot,al as vr,am as wr,an as Nr,ao as ot,ap as Be,aq as Pt,ar as ct,as as Tt,at as Dt,au as Sr,av as Cr,b as at,E as Er,aw as jr,ax as _r,ab as Rr,d as Gr,ay as xt,az as Mr,L as kr,e as Fr,a as Kr,V as Ir,B as W,I as Ze,aA as yt,aB as Ar,aC as Or,aD as Pr}from"./index-izRKx6JK.js";import{G as Tr,S as Dr,i as zr,C as Lr,B as $r,M as Yr}from"./graph-BF4IsheG.js";import{E as ve}from"./entity-link-multiselect-C--AiCMb.js";import{F as bt}from"./faceted-token-search-BMQ1Wwzt.js";import{U as vt}from"./user-badge-MEZuJiir.js";import{A as Hr,m as Vr}from"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./use-anchored-overlay-position-BY4kNzPj.js";const Br=Math.PI*(3-Math.sqrt(5)),Xr=.48;function Xe(e,t,n){return Math.min(n,Math.max(t,e))}function Wr({positions:e,point:t}){const n=[...e.values()];if(n.length===0)return{x:.5,y:.5};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const N of n)s=Math.min(s,N.x),u=Math.max(u,N.x),o=Math.min(o,N.y),c=Math.max(c,N.y);const l=Math.max(u-s,0),i=Math.max(c-o,0),m=Math.max(l,i,1),g=(1-l/m)/2,b=(1-i/m)/2,G=l||1,f=i||1;return{x:Xe((t.x-s)/G*(l/m)+g,0,1),y:Xe((t.y-o)/f*(i/m)+b,0,1)}}function Ur(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function qr({nodes:e,cache:t}){const n=new Map,s=[...e].sort((l,i)=>i.importance-l.importance||l.title.localeCompare(i.title)||l.id.localeCompare(i.id));let u=0,o=0,c=0;if(s.forEach((l,i)=>{const m=t.get(l.id);if(m){n.set(l.id,m),u+=m.x,o+=m.y,c+=1;return}const g=(Ur(l.id)%1e3/1e3-.5)*.22,b=i*Br+g,G=Xr*Math.sqrt(i+1),f={x:Math.cos(b)*G,y:Math.sin(b)*G};n.set(l.id,f),u+=f.x,o+=f.y,c+=1}),c>0){const l=u/c,i=o/c;n.forEach((m,g)=>{n.set(g,{x:m.x-l,y:m.y-i})})}return n}function Qr(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ie(e,t){return`rgba(${e==="structural"?"125, 211, 252":e==="contextual"?"45, 212, 191":e==="taxonomy"?"192, 132, 252":e==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function wt(e,t){return!t.focusNodeId||e===t.focusNodeId?0:t.detailNodeIds.has(e)?1:t.relatedNodeIds.has(e)?2:3}function Zr({nodeId:e,attributes:t,node:n,focusNodeId:s,relatedNodeIds:u,detailNodeIds:o,hoveredNodeId:c,draggedNodeId:l}){const i=s===e,m=u.has(e),g=o.has(e),b=c===e,G=l===e,f=!s||m,N=t.color;return{...t,label:i||b||G||g?n.title:"",forceLabel:i||b||G||g,highlighted:i||b||G||g,color:f?N:Qr(N,.34),size:G?t.size*2:i?t.size*1.8:b?t.size*1.35:g?t.size*1.16:m?t.size*1.06:t.size,zIndex:G?4:i?3:g||b?2:1}}function Jr({attributes:e,edge:t,focusNodeId:n,detailNodeIds:s,relatedNodeIds:u,hoveredNodeId:o}){const c=!!n&&(t.source===n||t.target===n),l=!!o&&(t.source===o||t.target===o),i={focusNodeId:n,detailNodeIds:s,relatedNodeIds:u},m=n?Math.max(wt(t.source,i),wt(t.target,i)):0,g=c?Ie(t.family,.24):l?Ie(t.family,.14):n?m<=1?Ie(t.family,.09):m===2?Ie(t.family,.05):Ie(t.family,.016):Ie(t.family,.055);return{...e,color:g,size:c?e.size*1.18:l?e.size*1.08:e.size,zIndex:c?2:l?1:0}}function Nt(e,t){const n=new Set,s=new Set;for(const u of e)u.source===t?n.add(u.target):u.target===t&&n.add(u.source);for(const u of e)u.source!==t&&n.has(u.source)&&s.add(u.target),u.target!==t&&n.has(u.target)&&s.add(u.source);return s.delete(t),n.forEach(u=>s.delete(u)),{firstRing:[...n].sort(),secondRing:[...s].sort()}}function St(e,t,n){if(!n)return e.map(()=>-1);const s=new Set(e);if(!s.has(n))return e.map(()=>-1);const u=new Map;for(const l of t){if(!s.has(l.source)||!s.has(l.target))continue;const i=u.get(l.source)??new Set;i.add(l.target),u.set(l.source,i);const m=u.get(l.target)??new Set;m.add(l.source),u.set(l.target,m)}const o=new Map([[n,0]]);let c=[n];for(;c.length>0;){const l=[];for(const i of c){const m=o.get(i);for(const g of u.get(i)??[])o.has(g)||(o.set(g,m+1),l.push(g))}c=l}return e.map(l=>o.get(l)??-1)}function ea({positions:e,focusNodeId:t,firstRingNodeIds:n,secondRingNodeIds:s,currentRatio:u}){const o=e.get(t);if(!o)return null;const c=[t,...n,...s].filter((L,me,k)=>k.indexOf(L)===me),l=c.map(L=>e.get(L)).filter(Boolean);if(l.length===0)return null;let i=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,N=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY;for(const L of e.values())G=Math.min(G,L.x),f=Math.max(f,L.x),N=Math.min(N,L.y),F=Math.max(F,L.y);for(const L of l)i=Math.min(i,L.x),m=Math.max(m,L.x),g=Math.min(g,L.y),b=Math.max(b,L.y);const j=Math.max(m-i,b-g,.75),z=Math.max(f-G,F-N,j),M=l.length<=1?Xe(Math.max(u,.48),.38,.6):Xe(j/z*3.2,.42,Math.max(u,1.12));return{x:o.x,y:o.y,ratio:M,nodeIds:c}}function zt({positions:e,currentRatio:t=1}){const n=[...e.values()];if(n.length===0)return{x:0,y:0,ratio:t};let s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const m of n)s=Math.min(s,m.x),u=Math.max(u,m.x),o=Math.min(o,m.y),c=Math.max(c,m.y);const l=Math.max(u-s,c-o,1),i=Xe(l/6.4,.72,2.8);return{x:0,y:0,ratio:Math.max(t,i)}}let He=null;function ta(){if(He!==null)return He;if(typeof document>"u")return He=!1,!1;const e=document.createElement("canvas");return He=!!(e.getContext("webgl2")||e.getContext("webgl")||e.getContext("experimental-webgl")),He}function ra(e){if(!e||typeof window>"u")return"#c0c1ff";const t=document.body?getComputedStyle(document.body).getPropertyValue(e).trim():"",n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),s=t||n;return s?`rgb(${s})`:"#c0c1ff"}function aa(e,t){if(e.startsWith("rgb(")&&e.endsWith(")"))return e.replace("rgb(","rgba(").replace(")",`, ${t})`);if(e.startsWith("#")){const n=e.slice(1),s=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,u=parseInt(s.slice(0,2),16),o=parseInt(s.slice(2,4),16),c=parseInt(s.slice(4,6),16);return`rgba(${u}, ${o}, ${c}, ${t})`}return e}function Ve(e,t){e.forEachNode(n=>{const s=e.getNodeAttributes(n);Number.isFinite(s.x)&&Number.isFinite(s.y)&&t.set(n,{x:s.x,y:s.y})})}function na(e,t,n){const s=new Tr,u=[...e].sort((c,l)=>l.importance-c.importance||c.title.localeCompare(l.title)||c.id.localeCompare(l.id)),o=qr({nodes:u,cache:n});return u.forEach(c=>{const l=o.get(c.id);s.addNode(c.id,{x:(l==null?void 0:l.x)??0,y:(l==null?void 0:l.y)??0,size:Math.max(2.5,c.size/14),color:ra(c.accentToken),label:c.title,hidden:!1,forceLabel:!1,highlighted:!1,zIndex:0,data:c})}),t.forEach(c=>{!s.hasNode(c.source)||!s.hasNode(c.target)||s.addEdgeWithKey(c.id,c.source,c.target,{size:Math.max(.8,c.strength*1.6),color:c.family==="structural"?"rgba(125, 211, 252, 0.055)":c.family==="contextual"?"rgba(45, 212, 191, 0.055)":c.family==="taxonomy"?"rgba(192, 132, 252, 0.055)":c.family==="workspace"?"rgba(251, 191, 36, 0.055)":"rgba(148, 163, 184, 0.055)",label:c.label,hidden:!1,forceLabel:!1,zIndex:0,data:c})}),s}function Ct(e){if(e.order===0)return;let t=0,n=0,s=0;if(e.forEachNode(c=>{const l=e.getNodeAttributes(c);t+=l.x,n+=l.y,s+=1}),s===0)return;const u=t/s,o=n/s;Math.abs(u)<1e-4&&Math.abs(o)<1e-4||e.updateEachNodeAttributes((c,l)=>({...l,x:l.x-u,y:l.y-o}),{attributes:["x","y"]})}function Et(e){const t=new Map;return e.forEachNode(n=>{const s=e.getNodeAttributes(n);t.set(n,{x:s.x,y:s.y})}),t}function Ae(e,t){return{nodes:e.nodes().map(n=>({id:n,...e.getNodeAttributes(n)})),edges:t}}function sa(e){if(e.nodes.length===0)return{minX:-1,maxX:1,minY:-1,maxY:1};let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const o of e.nodes)t=Math.min(t,o.x),n=Math.max(n,o.x),s=Math.min(s,o.y),u=Math.max(u,o.y);return{minX:t,maxX:n,minY:s,maxY:u}}function ia(e){const t=zt({positions:new Map(e.nodes.map(n=>[n.id,{x:n.x,y:n.y}])),currentRatio:1});return{x:t.x,y:t.y,angle:0,ratio:t.ratio}}function oa({x:e,y:t}){const n=Array.from({length:e.length},(u,o)=>({x:e[o]??0,y:t[o]??0})),s=br(n);return s.changed?{changed:!0,offsetX:s.offset.x,offsetY:s.offset.y,x:new Float32Array(s.positions.map(u=>u.x)),y:new Float32Array(s.positions.map(u=>u.y))}:{changed:!1,offsetX:0,offsetY:0,x:new Float32Array(e),y:new Float32Array(t)}}function Lt({node:e,snapshot:t,camera:n,width:s,height:u}){const o=sa(t),c=Math.max(1,o.maxX-o.minX),l=Math.max(1,o.maxY-o.minY),i=28,g=Math.min(Math.max(1,s-i*2)/c,Math.max(1,u-i*2)/l)/Math.max(n.ratio,.08);return{x:s/2+(e.x-n.x)*g,y:u/2-(e.y-n.y)*g,size:Math.max(4,e.size*g*.12)}}function jt(e,t){if(!e)return!1;const n=e.clientWidth,s=e.clientHeight,u=e.getBoundingClientRect();return e.isConnected&&t.width>0&&t.height>0&&n>0&&s>0&&u.width>0&&u.height>0&&e.getClientRects().length>0}function ca({sigma:e,graph:t,viewportX:n,viewportY:s}){let u=null,o=Number.POSITIVE_INFINITY;return t.forEachNode(c=>{const l=t.getNodeAttributes(c),i=e.getNodeDisplayData(c);if(!i||l.hidden)return;const m=e.graphToViewport({x:l.x,y:l.y}),g=m.x-n,b=m.y-s,G=Math.hypot(g,b),f=Math.max(i.size*1.8,18);G<=f&&G<o&&(u=c,o=G)}),u}function Oe(e,t){return`rgba(${e.family==="structural"?"125, 211, 252":e.family==="contextual"?"45, 212, 191":e.family==="taxonomy"?"192, 132, 252":e.family==="workspace"?"251, 191, 36":"148, 163, 184"}, ${t})`}function $t({input:e,rendererMode:t,visibleNodeIds:n,focusPressureByNodeId:s,boundsCenter:u,focusedNodePosition:o,camera:c,nodeScreenPositions:l}){const i=Ot({centroid:e.centroid,boundsCenter:u,camera:c});window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__={datasetSignature:e.datasetSignature,visibleNodeIds:n,visibleNodeCount:n.length,focusedNodeId:e.focusNodeId,primaryFocusedNodeId:e.primaryFocusedNodeId,draggedNodeId:e.draggedNodeId,layoutGeneration:e.layoutGeneration,rendererMode:t,startupPhase:e.startupPhase,startupInvariantSatisfied:e.startupInvariantSatisfied,simulationPhase:e.simulationPhase,focusSources:e.focusSources,focusPressureByNodeId:s,graphCentroid:e.centroid,boundsCenter:u,focusedNodePosition:o,cameraTarget:e.cameraTarget,cameraFollowError:e.cameraTarget?{x:Number((c.x-e.cameraTarget.x).toFixed(4)),y:Number((c.y-e.cameraTarget.y).toFixed(4)),ratio:Number((c.ratio-e.cameraTarget.ratio).toFixed(4))}:null,camera:c,nodeScreenPositions:l,centroidDistanceFromOrigin:i.centroidDistanceFromOrigin,boundsCenterDistanceFromOrigin:i.boundsCenterDistanceFromOrigin,cameraDistanceFromOrigin:i.cameraDistanceFromOrigin,cameraToCentroidDistance:i.cameraToCentroidDistance,latestSnapshotAt:e.latestSnapshotAt,latestSnapshotNodeCount:e.latestSnapshotNodeCount}}function la(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function _t(){typeof window>"u"||(delete window.__FORGE_KNOWLEDGE_GRAPH_DIAGNOSTICS__,delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__)}function ua(e){const t=[],n={},s={};let u=null;e.graph.forEachNode(c=>{t.push(c);const l=e.sigma.getNodeDisplayData(c),i=e.graph.getNodeAttributes(c),m=e.sigma.graphToViewport({x:i.x,y:i.y});n[c]={x:m.x,y:m.y,size:(l==null?void 0:l.size)??i.size},s[c]=Number((e.focusPressure[t.length-1]??0).toFixed(4)),c===e.primaryFocusedNodeId&&(u={x:i.x,y:i.y})});const o=dt(t.map(c=>{const l=e.graph.getNodeAttributes(c);return{x:l.x,y:l.y}}));$t({input:e,rendererMode:"sigma",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:o,focusedNodePosition:u,camera:e.sigma.getCamera().getState(),nodeScreenPositions:n})}function Rt(e){const t=e.snapshot.nodes.map(o=>o.id),n={},s={};let u=null;e.snapshot.nodes.forEach((o,c)=>{n[o.id]=Lt({node:o,snapshot:e.snapshot,camera:e.camera,width:e.width,height:e.height}),s[o.id]=Number((e.focusPressure[c]??0).toFixed(4)),o.id===e.primaryFocusedNodeId&&(u={x:o.x,y:o.y})}),$t({input:e,rendererMode:"fallback",visibleNodeIds:t,focusPressureByNodeId:s,boundsCenter:dt(e.snapshot.nodes.map(o=>({x:o.x,y:o.y}))),focusedNodePosition:u,camera:e.camera,nodeScreenPositions:n})}function Gt(e){const t=ot.indexOf(e);return t>=0?t:ot.length-1}function da(e){const t=Be.find(n=>n.kinds.some(s=>s===e))??Be[Be.length-1];return{laneId:t.id,laneLabel:t.label,laneIndex:Be.findIndex(n=>n.id===t.id)}}function Je(){return{structural:0,contextual:0,taxonomy:0,workspace:0}}function pa(e){const t=new Map;for(const n of e){const s=t.get(n.source)??new Set;s.add(n.target),t.set(n.source,s);const u=t.get(n.target)??new Set;u.add(n.source),t.set(n.target,u)}return t}function ha(e,t){return t.strength-e.strength||e.relationKind.localeCompare(t.relationKind)||e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function Yt(e){const t=new Map;for(const n of e){const s=`${n.source}→${n.target}`,u=t.get(s)??[];u.push(n),t.set(s,u)}return Array.from(t.entries()).map(([n,s])=>{const u=[...s].sort(ha),o=u[0],c=u.length,l=Math.max(...u.map(i=>i.strength))*Math.min(1.45,1+(c-1)*.12);return{id:`${n}#${o.id}`,source:o.source,target:o.target,relationKind:o.relationKind,family:o.family,label:c>1?`${o.label} +${c-1}`:o.label,strength:l,directional:o.directional,structural:o.structural,parallelCount:c,data:u}}).sort((n,s)=>n.source.localeCompare(s.source)||n.target.localeCompare(s.target)||n.id.localeCompare(s.id))}function ga(e,t){const n=Yt(t),s=[...e].sort((o,c)=>{var l;return o.id.localeCompare(c.id)||((l=o.updatedAt)==null?void 0:l.localeCompare(c.updatedAt??""))||0}).map(o=>`${o.id}:${o.title}:${o.size}:${o.importance}:${o.updatedAt??""}`).join("|"),u=n.map(o=>`${o.source}:${o.target}:${o.parallelCount}:${o.label}:${o.strength.toFixed(3)}`).join("|");return`${e.length}/${n.length}/${s}::${u}`}function Ht(e,t){const n=[...e].sort((l,i)=>{const m=Gt(l.entityKind)-Gt(i.entityKind);return m!==0?m:i.importance-l.importance||l.title.localeCompare(i.title)}),s=new Map,u=n.map(l=>{const{laneId:i,laneIndex:m,laneLabel:g}=da(l.entityKind),b=s.get(m)??0;return s.set(m,b+1),{...l,layer:m,laneId:i,laneLabel:g,row:b}}),o=new Map(u.map(l=>[l.id,l])),c=t.map(l=>{const i=o.get(l.source),m=o.get(l.target),g=(i==null?void 0:i.layer)??0,b=(m==null?void 0:m.layer)??0;return{...l,secondary:b<=g||l.family!=="structural"&&l.family!=="taxonomy"}});return{nodes:u,edges:c}}function Mt(e,t,n){const s=new Map(e.map(f=>[f.id,f])),u=n?s.get(n)??null:null;if(!u)return{generatedAt:new Date().toISOString(),focusNode:null,firstRingNodes:[],neighborhoodEdges:[],familyGroups:[],relationCounts:Je(),secondRingCounts:Je()};const o=t.filter(f=>f.source===u.id||f.target===u.id),c=Array.from(new Set(o.flatMap(f=>f.source===u.id?[f.target]:[f.source]))),l=c.map(f=>s.get(f)??null).filter(f=>!!f),i=new Map,m=Je(),g=Je(),b=pa(t);for(const f of c){const N=b.get(f)??new Set;for(const F of N){if(F===u.id||c.includes(F))continue;const j=t.filter(z=>z.source===f&&z.target===F||z.target===f&&z.source===F);for(const z of j)g[z.family]+=1}}for(const f of o){const N=f.source===u.id?f.target:f.source,F=s.get(N);if(!F)continue;m[f.family]+=1;const j=i.get(f.relationKind);if(j){j.items.some(z=>z.id===F.id)||j.items.push(F);continue}i.set(f.relationKind,{relationKind:f.relationKind,family:f.family,label:vr[f.relationKind],items:[F]})}const G=new Map;for(const f of i.values()){const N=G.get(f.family);if(N){N.relations.push({...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}),N.itemCount+=f.items.length,N.relationCount+=1;continue}G.set(f.family,{family:f.family,label:wr[f.family],relationCount:1,itemCount:f.items.length,relations:[{...f,items:[...f.items].sort((F,j)=>F.title.localeCompare(j.title))}]})}return{generatedAt:new Date().toISOString(),focusNode:u,firstRingNodes:l.sort((f,N)=>f.title.localeCompare(N.title)),neighborhoodEdges:o,familyGroups:[...G.values()].map(f=>({...f,relations:f.relations.sort((N,F)=>N.label.localeCompare(F.label))})).sort((f,N)=>f.label.localeCompare(N.label)),relationCounts:m,secondRingCounts:g}}function fa(e,t){return Nr(e,t)}function ma(e,t){if(!e)return new Set;const n=new Set([e]);for(const s of t)s.source===e?n.add(s.target):s.target===e&&n.add(s.source);return n}const xa=h.forwardRef(function({nodes:t,edges:n,focusNodeId:s,physicsSettings:u,onSelectNode:o},c){Pt(),ct(d=>d.knowledgeGraphDiagnostics.panelOpen);const l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null),b=h.useRef(new Map),G=h.useRef(new Map),f=h.useRef(new Map),N=h.useRef(o),F=h.useRef(s),j=h.useRef(null),z=h.useRef(0),M=h.useRef(null),L=h.useRef(0),me=h.useRef(!0),k=h.useRef(null),ce=h.useRef(0),A=h.useRef("global"),xe=h.useRef(null),Pe=h.useRef([]),Me=h.useRef(new Float32Array(0)),we=h.useRef({x:0,y:0}),$=h.useRef("boot"),Ne=h.useRef(!1),Y=h.useRef(!1),P=h.useRef(!1),te=h.useRef(null),le=h.useRef(null),ke=h.useRef(0),Se=h.useRef(0);h.useRef(0),h.useRef(Tt("/knowledge-graph"));const[Q,ue]=h.useState(null),[ye,de]=h.useState(null),[pe,H]=h.useState(null),[he,V]=h.useState({x:0,y:0,angle:0,ratio:1}),[y,B]=h.useState(null),[w,We]=h.useState({width:0,height:0}),Fe=Dt(),re=(d=g.current)=>zt({positions:d?Et(d):new Map,currentRatio:1}).ratio,Te=(d=g.current)=>({x:.5,y:.5,angle:0,ratio:re(d)}),De=(d=g.current)=>({x:0,y:0,angle:0,ratio:re(d)}),ze=()=>i.current?"sigma":"fallback",T=h.useMemo(()=>Yt(n),[n]),ge=h.useMemo(()=>ga(t,n),[n,t]),q=h.useMemo(()=>s?Nt(T,s):null,[s,T]),ae=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[]]):new Set,[s,q]),ne=h.useMemo(()=>s?new Set([s,...(q==null?void 0:q.firstRing)??[],...(q==null?void 0:q.secondRing)??[]]):new Set,[s,q]),Ue=()=>jt(l.current,w),se=({resize:d=!1}={})=>{if(!i.current||!Ue())return!1;try{return d&&i.current.resize(),i.current.refresh(),!0}catch(x){if(x instanceof Error&&x.message.includes("Container has no width"))return!1;throw x}},Le=()=>Date.now()<L.current,D=({level:d,eventKey:x,message:v,details:E,publishBackend:C=!1})=>{},st=()=>i.current?{...i.current.getCamera().getState()}:{...he},be=({rendererMode:d})=>{if(!g.current||!j.current)return null;const x=g.current,v=x.nodes().map(S=>{const I=x.getNodeAttributes(S);return{id:S,x:I.x,y:I.y}}),E=Sr(v),C=dt(v),K=st(),O=d==="sigma"?{...K,x:Number((K.x-.5).toFixed(4)),y:Number((K.y-.5).toFixed(4))}:K,R=Ot({centroid:E,boundsCenter:C,camera:O});return{datasetSignature:j.current,route:"/knowledge-graph",rendererMode:d,startupPhase:$.current,startupInvariantSatisfied:Cr(R),visibleNodeCount:v.length,focusedNodeId:F.current,primaryFocusedNodeId:xe.current,graphCentroid:E,boundsCenter:C,camera:K,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,driftMetrics:R,latestSnapshotAt:te.current,lastVerifiedAt:new Date().toISOString()}},qe=(d,{mirrorToConsole:x=!1}={})=>{},Qe=({rendererMode:d,publishAnomaly:x})=>{},$e=()=>{const d=i.current?Te():De();if(i.current){i.current.getCamera().setState(d);return}V(d)},a=d=>{var C;if(!g.current)return!1;const x=be({rendererMode:ze()});if(!x)return!1;const v=x.graphCentroid.x,E=x.graphCentroid.y;return Math.abs(v)<1e-4&&Math.abs(E)<1e-4?!1:(Ct(g.current),Ve(g.current,b.current),(C=m.current)==null||C.postMessage({type:"recenter-graph",offsetX:v,offsetY:E}),B(Ae(g.current,T)),$e(),$.current="startup_corrected",D({level:"warning",eventKey:"startup_corrected",message:"Corrected the knowledge graph startup bias back to graph-space origin.",publishBackend:!0,details:{datasetSignature:j.current}}),!0)},p=({phase:d,allowCorrection:x,publishBackendOnFailure:v=!1})=>{if(!g.current||!j.current)return;$.current=d;const E=i.current?"sigma":"fallback",C=be({rendererMode:E});if(!C)return;if(C.startupInvariantSatisfied){$.current="startup_verified",qe({...C},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified",message:"Knowledge graph startup invariant passed.",details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics}});return}if(D({level:"warning",eventKey:"startup_invariant_failed",message:"Knowledge graph startup invariant failed before correction.",publishBackend:v,details:{datasetSignature:C.datasetSignature,driftMetrics:C.driftMetrics,centroid:C.graphCentroid,boundsCenter:C.boundsCenter,camera:C.camera}}),Ne.current||(Ne.current=!0,!a()))return;se();const O=be({rendererMode:E});if(O){if(O.startupInvariantSatisfied){$.current="startup_verified",qe({...O},{mirrorToConsole:!0}),D({level:"info",eventKey:"startup_verified_after_correction",message:"Knowledge graph startup invariant passed after correction.",details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics}});return}D({level:"error",eventKey:"startup_correction_failed",message:"Knowledge graph startup correction did not restore the origin invariant.",publishBackend:!0,details:{datasetSignature:O.datasetSignature,driftMetrics:O.driftMetrics,centroid:O.graphCentroid,boundsCenter:O.boundsCenter,camera:O.camera}})}},_=()=>{var x,v,E,C;if(!j.current||!g.current)return;const d=Date.now();if(!(d-Se.current<1500)){if(Se.current=d,i.current){ua({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((x=M.current)==null?void 0:x.nodeId)??null,graph:g.current,layoutGeneration:z.current,sigma:i.current,startupPhase:$.current,startupInvariantSatisfied:((v=be({rendererMode:"sigma"}))==null?void 0:v.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current});return}y&&Rt({datasetSignature:j.current,focusNodeId:F.current,primaryFocusedNodeId:xe.current,draggedNodeId:((E=M.current)==null?void 0:E.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((C=be({rendererMode:"fallback"}))==null?void 0:C.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current})}},Ye=()=>{if(!g.current||!F.current){k.current=null;return}const d=g.current;if(!d.hasNode(F.current)){k.current=null;return}const x=Et(d),v=Nt(T,F.current),E=i.current?i.current.getCamera().getState().ratio:he.ratio,C=ea({positions:x,focusNodeId:F.current,firstRingNodeIds:v.firstRing,secondRingNodeIds:v.secondRing,currentRatio:E}),K=i.current&&C?Wr({positions:x,point:{x:C.x,y:C.y}}):null;k.current=C?{x:(K==null?void 0:K.x)??C.x,y:(K==null?void 0:K.y)??C.y,angle:0,ratio:C.ratio,nodeIds:C.nodeIds}:null},pt=(d=220)=>{if(!k.current)return;const x=k.current;if(i.current){const v=i.current.getCamera(),E=v.getState(),C=Date.now()<ce.current;v.animate({x:x.x,y:x.y,ratio:C?E.ratio:x.ratio,angle:0},{duration:d});return}V(v=>({...v,x:x.x,y:x.y,ratio:Date.now()<ce.current?v.ratio:x.ratio}))};h.useEffect(()=>{N.current=o},[o]),h.useEffect(()=>{F.current=s,k.current=null},[s]),h.useEffect(()=>{_t()},[Fe]),h.useEffect(()=>{if(!(!la()||typeof window>"u"))return window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__={selectNode:d=>{var v;const x=d?f.current.get(d)??((v=g.current)!=null&&v.hasNode(d)?g.current.getNodeAttribute(d,"data")??null:null):null;N.current(x)},moveNodeBy:(d,x,v)=>{var O,R;if(!((O=g.current)!=null&&O.hasNode(d)))return;const E=g.current.getNodeAttributes(d),C=E.x+x,K=E.y+v;g.current.mergeNodeAttributes(d,{x:C,y:K}),b.current.set(d,{x:C,y:K}),(R=m.current)==null||R.postMessage({type:"nudge-node",nodeId:d,x:C,y:K}),se(),!i.current&&g.current&&B(Ae(g.current,T))},nudgeCameraBy:(d,x)=>{if(i.current){const v=i.current.getCamera(),E=v.getState();v.animate({x:E.x+d,y:E.y+x,ratio:E.ratio,angle:E.angle},{duration:140});return}V(v=>({...v,x:v.x+d,y:v.y+x}))}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_TEST_API__}},[T]),h.useEffect(()=>{if(!l.current||typeof ResizeObserver>"u")return;const d=()=>{l.current&&We({width:l.current.clientWidth,height:l.current.clientHeight})};d();const x=new ResizeObserver(()=>{d()});return x.observe(l.current),()=>x.disconnect()},[]),h.useImperativeHandle(c,()=>({zoomIn:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedZoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.max(.08,d.ratio*.82)}))},zoomOut:()=>{if(ce.current=Date.now()+1200,i.current){i.current.getCamera().animatedUnzoom({factor:1.25,duration:160});return}V(d=>({...d,ratio:Math.min(4,d.ratio*1.22)}))},fit:()=>{if(k.current=null,i.current){i.current.getCamera().animate(Te(),{duration:220});return}y&&V(ia(y))},recenterOnFocus:()=>{Ye(),k.current&&pt(220)}}),[y,T]),h.useEffect(()=>()=>{var d,x,v;g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState()),(d=m.current)==null||d.postMessage({type:"dispose"}),(x=m.current)==null||x.terminate(),m.current=null,(v=i.current)==null||v.kill(),i.current=null,_t()},[Fe]),h.useEffect(()=>{var K,O;if(!l.current||!jt(l.current,w))return;if(j.current===ge&&g.current!==null){se({resize:!0}),_();return}$.current="boot",Ne.current=!1,Y.current=!1,P.current=!1,te.current=null,le.current=null,ke.current=0,k.current=null,D({level:"info",eventKey:"graph_boot",message:"Bootstrapping a fresh knowledge graph dataset.",details:{nodeCount:t.length,edgeCount:T.length}}),g.current&&Ve(g.current,b.current),i.current&&j.current&&G.current.set(j.current,i.current.getCamera().getState());const x=na(t,T,b.current);if(Ct(x),Ve(x,b.current),g.current=x,f.current=new Map(t.map(R=>[R.id,R])),j.current=ge,z.current+=1,B(Ae(x,T)),$.current="graph_built",D({level:"info",eventKey:"graph_built",message:"Built and centered the knowledge graph structure.",details:{layoutGeneration:z.current}}),!ta())(K=i.current)==null||K.kill(),i.current=null,H("WebGL is unavailable in this browser context."),V(De(x)),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0});else try{if(i.current)i.current.setGraph(x),se();else{i.current=new Dr(x,l.current,{renderEdgeLabels:!1,hideEdgesOnMove:!0,hideLabelsOnMove:!0,labelRenderedSizeThreshold:20,labelDensity:.04,labelGridCellSize:120,defaultNodeColor:"#c0c1ff",defaultEdgeColor:"rgba(125, 211, 252, 0.1)",minCameraRatio:.08,maxCameraRatio:4,autoRescale:!1,autoCenter:!1,enableEdgeEvents:!1,enableCameraPanning:!0,zIndex:!0}),D({level:"info",eventKey:"sigma_initialized",message:"Initialized Sigma for the knowledge graph.",details:{datasetSignature:ge}}),i.current.on("clickNode",({node:S})=>{if(Le())return;const I=f.current.get(S)??null;N.current(I)}),i.current.on("clickStage",({event:S})=>{if(Le())return;if(!i.current||!g.current){N.current(null);return}const I=ca({sigma:i.current,graph:g.current,viewportX:S.x,viewportY:S.y});if(I){N.current(f.current.get(I)??null);return}N.current(null)}),i.current.on("downNode",({node:S,event:I,preventSigmaDefault:ie})=>{var oe,X;if(!i.current||!((oe=g.current)!=null&&oe.hasNode(S)))return;ie();const Ke=i.current.viewportToGraph({x:I.x,y:I.y}),Z=g.current.getNodeAttributes(S);M.current={nodeId:S,offsetX:Z.x-Ke.x,offsetY:Z.y-Ke.y,startViewportX:I.x,startViewportY:I.y,currentX:Z.x,currentY:Z.y,moved:!1},me.current=i.current.getSetting("enableCameraPanning")??!0,i.current.setSetting("enableCameraPanning",!1),de(S),ue(S),D({level:"debug",eventKey:"drag_start",message:"Started dragging a knowledge graph node.",details:{nodeId:S}}),(X=m.current)==null||X.postMessage({type:"drag-start",nodeId:S})}),i.current.on("moveBody",({event:S,preventSigmaDefault:I})=>{var X;if(!i.current||!g.current||!M.current)return;I();const ie=i.current.viewportToGraph({x:S.x,y:S.y});Math.hypot(S.x-M.current.startViewportX,S.y-M.current.startViewportY)>3&&(M.current={...M.current,moved:!0});const Z=ie.x+M.current.offsetX,oe=ie.y+M.current.offsetY;M.current={...M.current,currentX:Z,currentY:oe},g.current.mergeNodeAttributes(M.current.nodeId,{x:Z,y:oe}),b.current.set(M.current.nodeId,{x:Z,y:oe}),(X=m.current)==null||X.postMessage({type:"drag-move",nodeId:M.current.nodeId,x:Z,y:oe}),se()});const R=()=>{var ie;if(!i.current||!M.current){M.current=null,de(null);return}const S=M.current.nodeId,I=M.current.moved;i.current.setSetting("enableCameraPanning",me.current),(ie=m.current)==null||ie.postMessage({type:"drag-end",nodeId:S}),D({level:"debug",eventKey:"drag_end",message:"Released a dragged knowledge graph node.",details:{nodeId:S,moved:I}}),M.current=null,de(null),I&&(L.current=Date.now()+220,N.current(f.current.get(S)??null))};i.current.on("upNode",R),i.current.on("upStage",R),i.current.on("leaveStage",R),i.current.on("enterNode",({node:S})=>{ue(S)}),i.current.on("leaveNode",()=>{ue(null)}),i.current.on("afterRender",()=>{Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"first_frame",message:"Knowledge graph rendered its first frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0}),Qe({rendererMode:"sigma",publishAnomaly:!0})),_()})}H(null),B(Ae(x,T)),i.current.getCamera().setState(Te(x))}catch(R){(O=i.current)==null||O.kill(),i.current=null,H(R instanceof Error?R.message:"Graph renderer unavailable."),B(Ae(x,T)),V(De(x)),D({level:"error",eventKey:"sigma_fallback",message:"Fell back from Sigma to the SVG renderer.",publishBackend:!0,details:{reason:R instanceof Error?R.message:"unknown"}}),p({phase:"graph_built",allowCorrection:!0,publishBackendOnFailure:!0})}m.current||(m.current=new Worker(new URL("/forge/assets/knowledge-graph-layout.worker-DRvzPxhP.js",import.meta.url),{type:"module"}),m.current.onmessage=R=>{var oe;if(!g.current)return;const S=R.data;if(S.type==="stats"){A.current=S.phase,xe.current=S.primaryFocusedNodeId,Pe.current=S.focusSources,Me.current=S.focusPressure,we.current=S.centroid,P.current||(P.current=!0,$.current="worker_started",D({level:"info",eventKey:"worker_started",message:"Knowledge graph worker reported its first simulation stats.",details:{datasetSignature:j.current,phase:S.phase}}),p({phase:"worker_started",allowCorrection:!0,publishBackendOnFailure:!0}));return}const I=g.current;let ie=S.x,Ke=S.y;if($.current!=="startup_verified"){const X=oa({x:S.x,y:S.y});X.changed&&(ie=X.x,Ke=X.y,(oe=m.current)==null||oe.postMessage({type:"recenter-graph",offsetX:X.offsetX,offsetY:X.offsetY}),$e(),D({level:"warning",eventKey:"worker_startup_recenter",message:"Recentering worker positions during startup because the graph drifted away from origin.",details:{datasetSignature:j.current,startupPhase:$.current,offsetX:X.offsetX,offsetY:X.offsetY}}))}let Z=0;if(I.updateEachNodeAttributes((X,ar)=>({...ar,x:ie[Z],y:Ke[Z++]}),{attributes:["x","y"]}),M.current&&I.hasNode(M.current.nodeId)){const X=M.current.nodeId;I.mergeNodeAttributes(X,{x:M.current.currentX,y:M.current.currentY})}Ve(I,b.current),i.current?se():B(Ae(I,T))});const v=x.nodes(),E=new Map(v.map((R,S)=>[R,S])),C=St(v,T,s);m.current.postMessage({type:"init-graph",nodes:v.map(R=>{const S=x.getNodeAttributes(R);return{id:R,x:S.x,y:S.y,size:S.size,mass:Math.max(1,S.data.importance/42),importance:S.data.importance}}),edges:T.filter(R=>E.has(R.source)&&E.has(R.target)).map(R=>({source:E.get(R.source),target:E.get(R.target),weight:Math.max(.6,R.strength)})),focusNodeId:s,hopLevels:C,physics:u}),D({level:"debug",eventKey:"worker_init",message:"Posted the graph payload to the layout worker.",details:{nodeCount:v.length,edgeCount:T.length}})},[w.height,w.width,ge,s,t,u,T]),h.useEffect(()=>{if(!m.current||!g.current)return;const d=St(g.current.nodes(),T,s);m.current.postMessage({type:"set-focus",focusNodeId:s,hopLevels:d}),s||(k.current=null)},[s,T]),h.useEffect(()=>{m.current&&m.current.postMessage({type:"update-physics",physics:u})},[u]),h.useEffect(()=>{},[ge,Fe]),h.useEffect(()=>{!i.current||!g.current||(i.current.setSetting("nodeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getNodeAttribute(d,"data");return Zr({nodeId:d,attributes:x,node:v,focusNodeId:s,relatedNodeIds:ne,detailNodeIds:ae,hoveredNodeId:Q,draggedNodeId:ye})}),i.current.setSetting("edgeReducer",(d,x)=>{var E;const v=(E=g.current)==null?void 0:E.getEdgeAttribute(d,"data");return Jr({attributes:x,edge:v,focusNodeId:s,detailNodeIds:ae,relatedNodeIds:ne,hoveredNodeId:Q})}),se())},[ae,ye,s,Q,ne]),h.useEffect(()=>{var d,x;!y||!j.current||w.width<=0||w.height<=0||!pe&&i.current||(Y.current||(Y.current=!0,$.current="first_frame",D({level:"info",eventKey:"fallback_first_frame",message:"Knowledge graph rendered its first fallback frame.",details:{datasetSignature:j.current}}),p({phase:"first_frame",allowCorrection:!0,publishBackendOnFailure:!0})),Rt({datasetSignature:j.current,focusNodeId:s,primaryFocusedNodeId:xe.current,draggedNodeId:((d=M.current)==null?void 0:d.nodeId)??null,layoutGeneration:z.current,camera:he,snapshot:y,width:w.width,height:w.height,startupPhase:$.current,startupInvariantSatisfied:((x=be({rendererMode:"fallback"}))==null?void 0:x.startupInvariantSatisfied)??!1,simulationPhase:A.current,focusSources:Pe.current,focusPressure:Me.current,centroid:we.current,cameraTarget:k.current?{x:k.current.x,y:k.current.y,ratio:k.current.ratio}:null,latestSnapshotAt:te.current,latestSnapshotNodeCount:le.current}))},[w.height,w.width,he,pe,y,s]);const it=h.useMemo(()=>!y||w.width<=0||w.height<=0?[]:y.nodes.map(d=>{const x=Lt({node:d,snapshot:y,camera:he,width:w.width,height:w.height});return{...d,viewportX:x.x,viewportY:x.y,viewportSize:x.size}}),[w.height,w.width,he,y]),ht=h.useMemo(()=>new Map(it.map(d=>[d.id,d])),[it]);return r.jsx("div",{className:"relative h-full w-full overflow-hidden bg-[var(--ui-surface-0)]",children:r.jsx("div",{ref:l,className:"h-full w-full touch-none","aria-label":"Knowledge graph canvas",children:pe&&y?r.jsxs("svg",{className:"h-full w-full",viewBox:`0 0 ${Math.max(w.width,1)} ${Math.max(w.height,1)}`,"aria-hidden":"true",children:[r.jsx("title",{children:"Knowledge graph fallback canvas"}),r.jsx("rect",{x:"0",y:"0",width:Math.max(w.width,1),height:Math.max(w.height,1),fill:"transparent",onClick:()=>N.current(null)}),y.edges.map(d=>{const x=ht.get(d.source),v=ht.get(d.target);if(!x||!v)return null;const E=!!s&&(d.source===s||d.target===s),C=!!Q&&(d.source===Q||d.target===Q),K=s?d.source===s?0:ae.has(d.source)?1:ne.has(d.source)?2:3:0,O=s?d.target===s?0:ae.has(d.target)?1:ne.has(d.target)?2:3:0,R=s?Math.max(K,O):0;return r.jsx("line",{x1:x.viewportX,y1:x.viewportY,x2:v.viewportX,y2:v.viewportY,stroke:E?Oe(d,.24):C?Oe(d,.14):s?R<=1?Oe(d,.09):R===2?Oe(d,.05):Oe(d,.016):Oe(d,.055),strokeWidth:E?1.7:C?1.3:.95},d.id)}),it.map(d=>{const x=s===d.id,v=ne.has(d.id),E=ae.has(d.id),C=Q===d.id,K=!s||v;return r.jsxs("g",{transform:`translate(${d.viewportX}, ${d.viewportY})`,onMouseEnter:()=>ue(d.id),onMouseLeave:()=>ue(null),onClick:O=>{O.stopPropagation();const R=f.current.get(d.id)??null;N.current(R)},style:{cursor:"pointer"},children:[r.jsx("circle",{r:x?d.viewportSize*1.9:C?d.viewportSize*1.3:E?d.viewportSize*1.15:v?d.viewportSize*1.05:d.viewportSize,fill:K?d.color:aa(d.color,.3),stroke:x?"var(--ui-border-strong)":"var(--ui-border-subtle)",strokeWidth:x?2:1}),(x||C||E)&&r.jsx("text",{x:d.viewportSize*1.5,y:4,fill:"var(--ui-ink-strong)",fontSize:"12",children:d.data.title})]},d.id)})]}):null})})}),ya=300,ba=152;function Vt(e,t){return e?ma(e,t):new Set}function va(e,t,n){const s=Ht(e,t),u=Vt(n,t);return s.nodes.map(o=>{const c=o.id===n,l=!n||u.has(o.id);return{id:o.id,draggable:!1,selectable:!1,position:{x:72+o.layer*ya,y:88+o.row*ba},data:{label:r.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)] transition",style:{borderColor:c?"var(--ui-border-strong)":"var(--ui-border-subtle)",background:c?"var(--ui-surface-active)":"var(--ui-surface-1)",opacity:l?1:.28},children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(at,{kind:o.entityKind,label:o.entityKind.replaceAll("_"," "),compact:!0,gradient:c})}),r.jsx("div",{className:"mt-3",children:r.jsx(Er,{kind:o.entityKind,label:o.title,className:"max-w-full",lines:2})}),o.subtitle?r.jsx("div",{className:"mt-2 break-words text-sm leading-5 text-[var(--ui-ink-soft)]",children:o.subtitle}):null]})},style:{background:"transparent",border:"none",padding:0}}})}function wa(e,t,n,s){const u=Ht(e,t),o=Vt(n,t);return u.edges.filter(c=>s||!c.secondary).map(c=>{const l=!n||o.has(c.source)||o.has(c.target);return{id:c.id,source:c.source,target:c.target,animated:!c.secondary&&c.family==="structural"&&l,markerEnd:{type:Yr.ArrowClosed,color:c.secondary?"var(--ui-border-subtle)":"var(--ui-border-strong)"},style:{opacity:l?1:.18,stroke:c.secondary?"var(--ui-border-subtle)":c.family==="taxonomy"?"var(--success)":c.family==="structural"?"var(--ui-border-strong)":"var(--primary)",strokeDasharray:c.secondary?"8 6":void 0,strokeWidth:c.secondary?1:c.family==="structural"?1.7:1.2}}})}function Na({nodes:e,edges:t,focusNodeId:n,showSecondaryEdges:s,onSelectNode:u,onOpenNode:o,onNavigateNode:c,isMobile:l}){const i=h.useMemo(()=>va(e,t,n),[t,n,e]),m=h.useMemo(()=>wa(e,t,n,s),[t,n,e,s]),g=h.useMemo(()=>new Map(e.map(b=>[b.id,b])),[e]);return r.jsxs("div",{className:"knowledge-graph-canvas relative h-[44rem] rounded-[28px]",children:[r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex gap-4 overflow-x-auto px-6 py-4",children:Be.map(b=>r.jsx("div",{className:"min-w-[min(17rem,calc(100vw-5rem))] rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-center text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",children:b.label},b.id))}),r.jsxs(zr,{fitView:!0,fitViewOptions:n?{padding:.24,nodes:[{id:n}]}:{padding:.2},nodes:i,edges:m,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,attributionPosition:"bottom-left",onNodeClick:(b,G)=>{const f=g.get(G.id);f&&u(f)},onNodeDoubleClick:(b,G)=>{const f=g.get(G.id);if(f){if(l){o(f);return}c(f)}},children:[r.jsx(Lr,{showInteractive:!1}),r.jsx($r,{gap:28,size:1,color:"var(--ui-border-subtle)"})]},`${n??"all"}-${s?"all":"primary"}`)]})}const Bt=6,Xt=5,Wt=.92,Ut=5,qt=.15,Qt=2.4,Zt=2,Jt=.8,er=3,ee={focusRepulsion:2.25,focusDiffusion:1.95,focusSpringReductionMax:.34,focusSpringReductionDiffusion:1.85,edgeSpringStrength:1,gravityStrength:1,focusShellSpacing:1};function Ee(e,t,n){return Math.min(Math.max(e,t),n)}function tr(e){return{focusRepulsion:Ee((e==null?void 0:e.focusRepulsion)??ee.focusRepulsion,.6,Bt),focusDiffusion:Ee((e==null?void 0:e.focusDiffusion)??ee.focusDiffusion,.6,Xt),focusSpringReductionMax:Ee((e==null?void 0:e.focusSpringReductionMax)??ee.focusSpringReductionMax,0,Wt),focusSpringReductionDiffusion:Ee((e==null?void 0:e.focusSpringReductionDiffusion)??ee.focusSpringReductionDiffusion,.6,Ut),edgeSpringStrength:Ee((e==null?void 0:e.edgeSpringStrength)??ee.edgeSpringStrength,qt,Qt),gravityStrength:Ee((e==null?void 0:e.gravityStrength)??ee.gravityStrength,0,Zt),focusShellSpacing:Ee((e==null?void 0:e.focusShellSpacing)??ee.focusShellSpacing,Jt,er)}}const nt=2e3,lt=40,ut=2e3,rr="forge.knowledge-graph.physics";function Sa(){if(typeof window>"u")return!1;if(window.__FORGE_ENABLE_GRAPH_DIAGNOSTICS__)return!0;try{return new URLSearchParams(window.location.search).get("graphDiagnostics")==="1"}catch{return!1}}function et(e,t){return Array.from(new Set(e.getAll(t).flatMap(n=>n.split(",")).map(n=>n.trim()).filter(Boolean)))}function U(e,t,n){e.delete(t),n.forEach(s=>e.append(t,s))}function Ca(e){switch(e.entityType){case"workbench_flow":case"workbench_surface":case"wiki_space":return null;default:return Rr(e.entityType,e.entityId)}}function J(e){return e?e.slice(0,10):""}function Ea(){if(typeof window>"u")return ee;try{const e=window.localStorage.getItem(rr);return e?tr(JSON.parse(e)):ee}catch{return ee}}function ja(e){typeof window>"u"||window.localStorage.setItem(rr,JSON.stringify(e))}function _a(e,t,n,s,u){const o=e.find(c=>c.id===t);return o||(!t||!n?null:{id:t,displayName:n,kind:s??"human",accentColor:u??"",handle:n.toLowerCase().replace(/\s+/g,"-"),description:"",createdAt:"",updatedAt:""})}function Ra({entityKinds:e,relationKinds:t,tags:n,owners:s}){return[...e.map(u=>`entity:${u}`),...t.map(u=>`relation:${u}`),...n.map(u=>`tag:${u}`),...s.map(u=>`owner:${u}`)]}function kt(e){const t=[],n=[],s=[],u=[];for(const o of e){const[c,...l]=o.split(":"),i=l.join(":").trim();i&&(c==="entity"?t.push(i):c==="relation"?n.push(i):c==="tag"?s.push(i):c==="owner"&&u.push(i))}return{entityKinds:t,relationKinds:n,tags:s,owners:u}}function Ga(e){const t=new URLSearchParams(e),n=t.get("view")==="hierarchy"?"hierarchy":"graph",s=jr(t.get("focus")),u=s?fa(s.entityType,s.entityId):null,o=et(t,"entityKind"),c=et(t,"relationKind"),l=et(t,"tag"),i=et(t,"owner"),m=t.get("q")??"",g=t.get("updatedFrom"),b=t.get("updatedTo"),G=Number(t.get("limit")??nt),f=Number.isFinite(G)?Math.max(lt,Math.min(ut,G)):nt;return{selectedView:n,focusNodeId:u,selectedKinds:o,selectedRelations:c,selectedTags:l,selectedOwners:i,showHierarchyCrossLinks:t.get("cross")==="1",queryText:m,updatedFrom:g,updatedTo:b,maxNodes:f}}function Ma(e){return{q:e.queryText.trim()||null,entityKinds:[...e.selectedKinds].sort(),relationKinds:[...e.selectedRelations].sort(),tags:[...e.selectedTags].sort(),owners:[...e.selectedOwners].sort(),updatedFrom:e.updatedFrom,updatedTo:e.updatedTo,limit:e.maxNodes,focusNodeId:null}}function Ft(e,t){if(!t){e.delete("focus");return}e.set("focus",_r(t.entityType,t.entityId))}function ka({isMobile:e,currentFocusNodeId:t,nextNodeId:n}){return n?e?t===n?{nextFocusNodeId:n,nextMobileSheetOpen:!0,shouldUpdateFocus:!1}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:!0}:{nextFocusNodeId:n,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==n}:{nextFocusNodeId:null,nextMobileSheetOpen:!1,shouldUpdateFocus:t!==null}}const Kt="__clear__";function Fa({isMobile:e,focusNodeId:t,shellOverlayFocusNodeId:n,lastRequestedKey:s}){const u=e?null:t,o=u??Kt;return o===(n??Kt)?{action:"none",nextRequestedKey:o}:s===o?{action:"none",nextRequestedKey:o}:{action:u?"set":"clear",nextRequestedKey:o}}const It="shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2 py-0.5 text-[9px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] shadow-[var(--ui-shadow-soft)] backdrop-blur",At="flex shrink-0 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0.5 shadow-[var(--ui-shadow-soft)] backdrop-blur",tt="bg-[var(--ui-accent-soft)] text-[var(--primary)] shadow-[var(--ui-shadow-soft)]",rt="text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",fe="rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)] backdrop-blur hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",Ka="fixed inset-0 z-40 bg-[color-mix(in_srgb,var(--ui-scrim)_72%,transparent)] backdrop-blur-xl",Ia="fixed inset-x-4 top-[max(1rem,env(safe-area-inset-top))] z-50 max-h-[calc(100dvh-2rem)] overflow-y-auto rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] shadow-[var(--ui-shadow-floating)] md:left-1/2 md:right-auto md:-translate-x-1/2",Aa="sticky top-0 z-10 flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-4 backdrop-blur-xl",Oa="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",Pa="font-display text-2xl text-[var(--ui-ink-strong)]",Ta="text-sm leading-6 text-[var(--ui-ink-soft)]",je="grid min-w-0 gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",_e="text-sm font-medium text-[var(--ui-ink-strong)]",Re="text-xs leading-5 text-[var(--ui-ink-faint)]",Ge="rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1 text-xs text-[var(--ui-ink-soft)]",Da="rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-info-soft)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]";class za extends h.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}render(){return this.state.error?this.props.fallback(this.state.error):this.props.children}}function Ja(){var Qe,$e;const e=Gr(),t=Pt();ct(a=>a.knowledgeGraphDiagnostics);const n=ct(a=>{var p,_;return((_=(p=a.shell.knowledgeGraphOverlayFocus)==null?void 0:p.focusNode)==null?void 0:_.id)??null}),s=nr(),[u,o]=sr(),c=h.useRef(null),l=h.useRef(null),i=h.useRef(null),m=h.useRef(null),g=h.useRef(null);h.useRef(Tt("/knowledge-graph"));const[b,G]=h.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1),[f,N]=h.useState(!1),[F,j]=h.useState(!1),[z,M]=h.useState(!1),[L,me]=h.useState(!1),[k,ce]=h.useState(""),[A,xe]=h.useState(()=>Ea()),Me=Dt(),we=({level:a,eventKey:p,message:_,details:Ye,publishBackend:pt=!1})=>{};h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia("(max-width: 1023px)"),p=_=>G(_?_.matches:a.matches);return p(),typeof a.addEventListener=="function"?(a.addEventListener("change",p),()=>a.removeEventListener("change",p)):(a.addListener(p),()=>a.removeListener(p))},[]),h.useEffect(()=>{b||(N(!1),j(!1),l.current=null)},[b]),h.useEffect(()=>{ja(A)},[A]);const $=u.toString(),Ne=h.useMemo(()=>Ga($),[$]),{selectedView:Y,focusNodeId:P,selectedKinds:te,selectedRelations:le,selectedTags:ke,selectedOwners:Se,showHierarchyCrossLinks:Q,queryText:ue,updatedFrom:ye,updatedTo:de,maxNodes:pe}=Ne;h.useEffect(()=>{ce(ue)},[ue]);const H=h.useMemo(()=>Ma(Ne),[Ne]),he=h.useMemo(()=>["forge-knowledge-graph",...e.selectedUserIds,JSON.stringify(H)],[H,e.selectedUserIds]),V=yr({queryKey:he,queryFn:()=>Pr(e.selectedUserIds,H),placeholderData:a=>a,staleTime:6e4,refetchOnWindowFocus:!1}),y=V.data;h.useEffect(()=>{we({level:"info",eventKey:"route_arrival",message:"Arrived on the Knowledge Graph page.",details:{search:u.toString()}})},[]),h.useEffect(()=>{if(!V.isSuccess||!y)return;const a=JSON.stringify({q:H.q,entityKinds:H.entityKinds,relationKinds:H.relationKinds,tags:H.tags,owners:H.owners,updatedFrom:H.updatedFrom,updatedTo:H.updatedTo,limit:H.limit,nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited});g.current!==a&&(g.current=a,we({level:"info",eventKey:"graph_query_resolved",message:"Knowledge graph query resolved.",details:{nodeCount:y.counts.nodeCount,edgeCount:y.counts.edgeCount,filteredNodeCount:y.counts.filteredNodeCount,limited:y.counts.limited}}))},[y,V.isSuccess,H]),h.useEffect(()=>{!y||!P||y.nodes.some(a=>a.id===P)||(o(a=>{const p=new URLSearchParams(a);return p.delete("focus"),p},{replace:!0}),N(!1),l.current=null)},[P,y,o]),h.useEffect(()=>{if(b){if(!P){l.current=null,N(!1);return}l.current===P&&!f&&(N(!0),l.current=null)}},[P,b,f]);const B=h.useMemo(()=>!y||!P?Mt([],[],null):Mt(y.nodes,y.edges,P),[P,y]);h.useEffect(()=>{var p;const a=Fa({isMobile:b,focusNodeId:((p=B.focusNode)==null?void 0:p.id)??null,shellOverlayFocusNodeId:n,lastRequestedKey:m.current});if(m.current=a.nextRequestedKey,a.action!=="none"){if(a.action==="clear"){t(xt());return}t(Mr(B))}},[t,B,b,n]),h.useEffect(()=>{{i.current=null;return}},[Me,P,B,b]),h.useEffect(()=>()=>{t(xt())},[t]),h.useEffect(()=>{if(!(typeof window>"u")){if(!Sa()){delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__;return}return window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__={isMobile:b,mobileSheetOpen:f,focusNodeId:P,selectedView:Y,selectNodeById:a=>{if(!y)return;const p=a?y.nodes.find(_=>_.id===a)??null:null;Ce(p)},activateFocusedNode:()=>{if(!P||!y)return;const a=y.nodes.find(p=>p.id===P)??null;a&&Ce(a)}},()=>{delete window.__FORGE_KNOWLEDGE_GRAPH_PAGE_TEST__}}},[P,b,f,Y]);const w=a=>{o(p=>{const _=new URLSearchParams(p);return a(_),_},{replace:!0})},We=a=>{const p=a.trim();ce(a),w(_=>{p.length>0?_.set("q",p):_.delete("q")})},Ce=a=>{const p=ka({isMobile:b,currentFocusNodeId:P,nextNodeId:(a==null?void 0:a.id)??null});l.current=b&&p.nextMobileSheetOpen?(a==null?void 0:a.id)??null:null,N(p.nextMobileSheetOpen),p.shouldUpdateFocus&&(w(_=>{Ft(_,a)}),b&&j(!1))},Fe=a=>{a.href&&s(a.href)},re=(a,p)=>{xe(_=>tr({..._,[a]:p}))},Te=a=>{const p=Ca(a);p&&s(p)},De=a=>{w(p=>{p.set("view","hierarchy"),Ft(p,a)})},ze=()=>{w(a=>{["q","entityKind","relationKind","tag","owner","updatedFrom","updatedTo","focus"].forEach(p=>a.delete(p)),a.set("limit",String(nt))}),M(!1)};if(V.isLoading&&!y)return r.jsx(kr,{eyebrow:"Knowledge Graph",title:"Loading the Forge world model",description:"Gathering goals, projects, KarpaWiki pages, psyche entities, calendar context, and Workbench flows into one graph."});if(V.isError)return r.jsx(Fr,{eyebrow:"Knowledge Graph",error:V.error,onRetry:()=>void V.refetch()});if(!y)return null;const T=new Map(y.facets.entityKinds.map(a=>[a.value,a])),ge=ot.map(a=>{const p=Kr(a),_=T.get(a),Ye=(_==null?void 0:_.count)??0;return{value:a,label:(_==null?void 0:_.label)??p.label,description:Ye===1?"1 node":`${Ye} nodes`,kind:a}}),q=y.facets.relationKinds.map(a=>({value:a.value,label:a.label,description:`${a.count} links`})),ae=y.facets.tags.map(a=>({value:a.id,label:a.label,description:`${a.count} linked nodes`,badge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1}),menuBadge:r.jsx(at,{kind:"tag",label:a.label,compact:!0,gradient:!1})})),ne=y.facets.owners.map(a=>{const p=_a(e.snapshot.users,a.userId,a.displayName,a.kind,a.accentColor);return{value:a.userId,label:a.displayName,description:`${a.count} nodes`,badge:r.jsx(vt,{user:p,compact:!0}),menuBadge:r.jsx(vt,{user:p,compact:!0})}}),Ue=[...ge.map(a=>({id:`entity:${a.value}`,label:a.label,description:a.description,searchText:`entity kind ${a.label}`,badge:r.jsx(at,{kind:a.kind??"note",label:a.label,compact:!0,gradient:!1})})),...q.map(a=>({id:`relation:${a.value}`,label:a.label,description:a.description,searchText:`relation kind ${a.label}`})),...ae.map(a=>({id:`tag:${a.value}`,label:a.label,description:a.description,searchText:`tag ${a.label}`,badge:a.menuBadge??a.badge})),...ne.map(a=>({id:`owner:${a.value}`,label:a.label,description:a.description,searchText:`owner ${a.label}`,badge:a.menuBadge??a.badge}))],se=Ra({entityKinds:te,relationKinds:le,tags:ke,owners:Se}),Le=y.counts.limited?`${y.counts.nodeCount}/${y.counts.filteredNodeCount} nodes`:`${y.counts.nodeCount}n · ${y.counts.edgeCount}e`,D=y.counts.limited?`${y.counts.nodeCount} visible nodes from ${y.counts.filteredNodeCount} filtered matches`:`${y.counts.nodeCount} nodes and ${y.counts.edgeCount} edges`,st=ue.trim().length>0||te.length>0||le.length>0||ke.length>0||Se.length>0||!!ye||!!de||pe!==nt,be=!b,qe=`${Y}:${y.nodes.map(a=>a.id).join("|")}::${y.edges.map(a=>a.id).join("|")}`;return r.jsxs("div",{className:"h-[calc(100dvh-var(--forge-mobile-nav-clearance)-5.25rem)] overflow-hidden lg:-mt-3 lg:h-[calc(100dvh-10rem)]",children:[r.jsxs("div",{className:"relative h-full bg-[var(--ui-surface-0)]",children:[r.jsx("div",{className:"pointer-events-auto absolute right-3 top-3 z-30 hidden md:block",children:r.jsx(Ir,{metrics:e.snapshot.metrics})}),r.jsx(za,{resetKey:qe,fallback:a=>r.jsx("div",{className:"grid h-full place-items-center p-6 text-center",children:r.jsxs("div",{className:"grid max-w-lg gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-6 shadow-[var(--ui-shadow-floating)]",children:[r.jsx("div",{className:"mx-auto flex size-12 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:r.jsx(ir,{className:"size-5"})}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Graph renderer fallback"}),r.jsx("h2",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:"The graph renderer hit a display error."}),r.jsx("p",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Switch to the hierarchy view or reset the current graph filters. The graph will recover automatically when the dataset changes."}),r.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-left text-xs text-[var(--ui-ink-faint)]",children:a.message})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[r.jsxs(W,{variant:"primary",size:"sm",onClick:()=>w(p=>{p.set("view","hierarchy")}),children:[r.jsx(or,{className:"size-4"}),"Open hierarchy"]}),r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset graph filters"})]})]})}),children:Y==="graph"?r.jsx(xa,{ref:c,nodes:y.nodes,edges:y.edges,focusNodeId:P,physicsSettings:A,onSelectNode:Ce}):r.jsx("div",{className:"h-full overflow-y-auto px-4 py-4 lg:px-6",children:r.jsx(Na,{nodes:y.nodes,edges:y.edges,focusNodeId:P,showSecondaryEdges:Q,isMobile:b,onSelectNode:Ce,onOpenNode:Ce,onNavigateNode:Fe})})}),b?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-3 pt-2 lg:hidden",children:r.jsxs("div",{className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{title:D,className:It,children:Le}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsxs("div",{className:At,children:[r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2 py-1 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>me(!0),"aria-label":"Open graph appearance settings",title:"Graph appearance settings",children:r.jsx(gt,{className:"size-3"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>{N(!1),j(!0)},"aria-label":"Open graph filters",children:[r.jsx(ft,{className:"size-3"}),"Search"]})]})]})}):null,be?r.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-20 px-4 pt-3 lg:px-6",children:[r.jsxs("div",{"data-testid":"knowledge-graph-desktop-toolbar",className:"pointer-events-auto flex items-center gap-1.5",children:[r.jsx("div",{"data-testid":"knowledge-graph-count-pill",title:D,className:It,children:Le}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx(bt,{title:"",description:"",compact:!0,minimal:!0,hideSummary:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:"",placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:()=>M(a=>!a),children:[r.jsx(ft,{className:"size-3"}),"Advanced"]}),st?r.jsx(W,{variant:"secondary",size:"sm",className:`h-7 px-2 text-[10px] ${fe}`,onClick:ze,children:"Reset"}):null]}),r.jsx(Hr,{initial:!1,children:z?r.jsx(Vr.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-auto mt-2 ml-auto max-w-[min(54rem,calc(100%-3.5rem))] rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 shadow-[var(--ui-shadow-floating)] backdrop-blur",children:r.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.4fr)_minmax(17rem,1fr)]",children:[r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"The graph stays deterministic under the cap and focus mode redistributes the visible neighborhood around the selected node."})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),Y==="hierarchy"?r.jsx(W,{variant:Q?"primary":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-xs",onClick:()=>w(a=>{Q?a.delete("cross"):a.set("cross","1")}),children:Q?"Hide cross-links":"Show cross-links"}):null]})]})}):null})]}):null,b?null:r.jsx("div",{className:"pointer-events-none absolute bottom-5 left-4 z-20 lg:left-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:`pointer-events-auto ${At}`,children:[r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="graph"?tt:rt}`,onClick:()=>w(a=>{a.set("view","graph")}),children:"Graph"}),r.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1.5 text-[10px] transition ${Y==="hierarchy"?tt:rt}`,onClick:()=>w(a=>{a.set("view","hierarchy")}),children:"Hierarchy"})]}),Y==="graph"?r.jsxs(r.Fragment,{children:[r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>me(!0),title:"Graph appearance settings","aria-label":"Open graph appearance settings",children:r.jsx(gt,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomIn()},title:"Zoom in","aria-label":"Zoom in",children:r.jsx(cr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.zoomOut()},title:"Zoom out","aria-label":"Zoom out",children:r.jsx(lr,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.recenterOnFocus()},disabled:!B.focusNode,title:"Recenter","aria-label":"Recenter",children:r.jsx(ur,{className:"size-3.5"})}),r.jsx(W,{variant:"secondary",size:"sm",className:`pointer-events-auto size-8 p-0 ${fe}`,onClick:()=>{var a;return(a=c.current)==null?void 0:a.fit()},title:"Reset camera","aria-label":"Reset camera",children:r.jsx(dr,{className:"size-3.5"})}),null]}):null]})})]}),r.jsx(yt,{open:f&&!!B.focusNode,onOpenChange:N,eyebrow:"Knowledge Graph",title:((Qe=B.focusNode)==null?void 0:Qe.title)??"Focus node",description:(($e=B.focusNode)==null?void 0:$e.subtitle)??"Inspect the selected node and move deeper into the graph.",children:r.jsx(Ar,{focus:B,onOpenPage:a=>{N(!1),Fe(a)},onOpenNotes:a=>{N(!1),Te(a)},onOpenHierarchy:a=>{N(!1),De(a)},onSelectNode:Ce,className:"border-0 bg-transparent p-0 shadow-none"})}),r.jsx(yt,{open:F,onOpenChange:j,eyebrow:"Knowledge Graph",title:"Filter graph",description:"Search the visible graph and adjust the focus cap without covering the canvas all the time.",children:r.jsxs("div",{className:"grid gap-4 pb-2",children:[r.jsx("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:r.jsx(bt,{title:"",description:"",compact:!0,query:k,onQueryChange:ce,onQuerySubmit:We,submitLabel:"Search graph",options:Ue,selectedOptionIds:se,onSelectedOptionIdsChange:a=>{const p=kt(a);w(_=>{U(_,"entityKind",p.entityKinds),U(_,"relationKind",p.relationKinds),U(_,"tag",p.tags),U(_,"owner",p.owners)})},resultSummary:D,placeholder:"Type a graph search, then press Enter or the search button"})}),r.jsxs("div",{className:"grid gap-3",children:[r.jsx(ve,{options:ge,selectedValues:te,onChange:a=>w(p=>{U(p,"entityKind",a)}),placeholder:"Filter by entity type",emptyMessage:"No entity kinds match the current graph."}),r.jsx(ve,{options:q,selectedValues:le,onChange:a=>w(p=>{U(p,"relationKind",a)}),placeholder:"Filter by relation type",emptyMessage:"No relation kinds match the current graph."}),r.jsx(ve,{options:ae,selectedValues:ke,onChange:a=>w(p=>{U(p,"tag",a)}),placeholder:"Filter by tag",emptyMessage:"No tags are available in the current filtered graph."}),r.jsx(ve,{options:ne,selectedValues:Se,onChange:a=>w(p=>{U(p,"owner",a)}),placeholder:"Filter by owner",emptyMessage:"No owners match the current graph."})]}),r.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:"Max nodes shown"}),r.jsx("span",{children:pe})]}),r.jsx("input",{type:"range",min:lt,max:ut,step:20,value:pe,onChange:a=>w(p=>{p.set("limit",a.target.value)}),className:"w-full accent-[var(--secondary)]"}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated from"}),r.jsx(Ze,{type:"date",value:J(ye),min:J(y.facets.updatedAt.min),max:J(de??y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedFrom",a.target.value):p.delete("updatedFrom")})})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Updated to"}),r.jsx(Ze,{type:"date",value:J(de),min:J(ye??y.facets.updatedAt.min),max:J(y.facets.updatedAt.max),onChange:a=>w(p=>{a.target.value?p.set("updatedTo",a.target.value):p.delete("updatedTo")})})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(W,{variant:"secondary",size:"sm",onClick:ze,children:"Reset"}),r.jsx(W,{variant:"primary",size:"sm",onClick:()=>j(!1),children:"Done"})]})]})]})}),r.jsx(pr,{open:L,onOpenChange:me,children:r.jsxs(hr,{children:[r.jsx(gr,{className:Ka}),r.jsxs(fr,{className:`${Ia} md:w-[min(40rem,calc(100vw-3rem))]`,children:[r.jsx(mr,{className:"sr-only",children:"Knowledge Graph appearance settings"}),r.jsx(xr,{className:"sr-only",children:"Tune the graph focus physics and appearance response."}),r.jsxs("div",{className:Aa,children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx("div",{className:Oa,children:"Graph appearance"}),r.jsx("div",{className:Pa,children:"Tune the focus field"}),r.jsx("p",{className:`max-w-xl ${Ta}`,children:"Shape how strongly a focused node opens its neighborhood and how far that pressure diffuses through connected hops."})]}),r.jsx(mt,{asChild:!0,children:r.jsx(Or,{"aria-label":"Close graph appearance settings"})})]}),r.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focused repulsion"}),r.jsx("div",{className:Re,children:"Push nearby nodes apart more aggressively while the focused node stays anchored."})]}),r.jsx("div",{className:Ge,children:A.focusRepulsion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focused repulsion",type:"range",min:"0.6",max:String(Bt),step:"0.05",value:A.focusRepulsion,onChange:a=>re("focusRepulsion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus diffusion"}),r.jsx("div",{className:Re,children:"Extend the focus field further through multi-hop neighbors and lengthen the reversible transition."})]}),r.jsx("div",{className:Ge,children:A.focusDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus diffusion",type:"range",min:"0.6",max:String(Xt),step:"0.05",value:A.focusDiffusion,onChange:a=>re("focusDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction max"}),r.jsx("div",{className:Re,children:"Reduce edge spring constants most strongly around the focused node so its local neighborhood can open more freely."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionMax.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction max",type:"range",min:"0",max:String(Wt),step:"0.02",value:A.focusSpringReductionMax,onChange:a=>re("focusSpringReductionMax",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Spring reduction diffusion"}),r.jsx("div",{className:Re,children:"Spread that spring softening progressively through first-hop, second-hop, and more distant neighborhoods."})]}),r.jsx("div",{className:Ge,children:A.focusSpringReductionDiffusion.toFixed(2)})]}),r.jsx("input",{"aria-label":"Spring reduction diffusion",type:"range",min:"0.6",max:String(Ut),step:"0.05",value:A.focusSpringReductionDiffusion,onChange:a=>re("focusSpringReductionDiffusion",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Edge spring strength"}),r.jsx("div",{className:Re,children:"Lower this to loosen graph edges globally and let neighborhoods spread instead of snapping tightly inward."})]}),r.jsx("div",{className:Ge,children:A.edgeSpringStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Edge spring strength",type:"range",min:String(qt),max:String(Qt),step:"0.05",value:A.edgeSpringStrength,onChange:a=>re("edgeSpringStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Gravity strength"}),r.jsx("div",{className:Re,children:"Reduce this to weaken the global inward pull that compacts the whole graph toward the middle."})]}),r.jsx("div",{className:Ge,children:A.gravityStrength.toFixed(2)})]}),r.jsx("input",{"aria-label":"Gravity strength",type:"range",min:"0",max:String(Zt),step:"0.05",value:A.gravityStrength,onChange:a=>re("gravityStrength",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]}),r.jsxs("div",{className:je,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:_e,children:"Focus shell spacing"}),r.jsx("div",{className:Re,children:"Increase this to push focused rings farther outward and visibly open the local structure."})]}),r.jsx("div",{className:Ge,children:A.focusShellSpacing.toFixed(2)})]}),r.jsx("input",{"aria-label":"Focus shell spacing",type:"range",min:String(Jt),max:String(er),step:"0.05",value:A.focusShellSpacing,onChange:a=>re("focusShellSpacing",Number(a.target.value)),className:"w-full accent-[var(--secondary)]"})]})]}),r.jsx("div",{className:Da,children:"The main cramming forces are the edge springs and the inward gravity pull. Lower edge spring strength or gravity strength to let the whole graph breathe more, then raise focus shell spacing and spring-reduction controls when you want a selected neighborhood to open dramatically."}),r.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[r.jsx(W,{variant:"secondary",onClick:()=>xe(ee),children:"Reset defaults"}),r.jsx(mt,{asChild:!0,children:r.jsx(W,{variant:"primary",children:"Done"})})]})]})]})]})}),null]})}export{Ja as KnowledgeGraphPage};
@@ -1 +0,0 @@
1
- import{r as m,j as e,aK as Ae,cp as Ce,b7 as Qe,b6 as Re,bY as ze,b3 as He,c8 as Ye,c1 as Xe,bX as Ge,c4 as Je}from"./vendor-BwL6m4SE.js";import{j as We,i as F,k as ie}from"./state-Bpe5dF3T.js";import{E as Fe}from"./entity-link-multiselect-C--AiCMb.js";import{b as De,k as z,c as Ze,d as et,g as f,aY as J,aZ as _e,a_ as Ie,e as tt,B as Q,C as _,n as P,m as at,I as D,T as Le,h as st,a$ as it,b0 as nt,b1 as rt,aa as ot,b2 as lt,i as dt,b3 as ct,b4 as ut,b5 as mt,b6 as pt,b7 as xt,b8 as ht,b9 as gt,O as vt,ba as yt}from"./index-izRKx6JK.js";import{N as ne}from"./note-markdown-BWedRE3c.js";import{N as re,n as Z,f as ft,p as bt,b as kt}from"./note-tags-input-DZkCqI1w.js";import{P as jt}from"./page-hero-BLhM8FF3.js";import{N as Nt,a as wt,b as Tt}from"./notes-boxes-DGFmt7Dp.js";import{F as St}from"./floating-action-menu-cGhbJ2tc.js";import{b,d as k}from"./user-ownership-DJGl4rAj.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./generic-node-view-DNVwfqqq.js";import"./graph-BF4IsheG.js";import"./define-workbench-box-DcI0_QKW.js";function Mt(i){return i.trim().toLowerCase()}function At(i,o){return i.includes(o)?i:[...i,o]}function Ct({entityOptions:i,selectedEntityValues:o,onSelectedEntityValuesChange:d,selectedTextTerms:u,onSelectedTextTermsChange:I,placeholder:j="Filter by linked entity or add free text"}){const[S,M]=m.useState(""),[ee,g]=m.useState(!1),[H,v]=m.useState(0),B=Mt(S),A=m.useMemo(()=>o.map(s=>i.find(c=>c.value===s)).filter(Boolean),[i,o]),L=m.useMemo(()=>{const s=i.filter(c=>!o.includes(c.value));return B?s.filter(c=>`${c.label} ${c.description??""} ${c.searchText??""}`.toLowerCase().includes(B)).slice(0,8):s.slice(0,8)},[i,B,o]),N=S.trim().length>0&&!u.includes(S.trim()),Y=s=>{d(At(o,s)),M(""),v(0),g(!1)},K=(s=S)=>{const c=s.trim();!c||u.includes(c)||(I([...u,c]),M(""),v(0),g(!1))},$=s=>{d(o.filter(c=>c!==s))},p=s=>{I(u.filter(c=>c!==s))};return e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:"Search hints: entity chips match linked records, free-text chips match note body or author."}),e.jsx("button",{type:"button",onClick:()=>K(),disabled:!N,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] disabled:cursor-not-allowed disabled:opacity-40",children:"Free text"})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-4 py-3 shadow-[var(--ui-shadow-floating)]",children:[A.length>0||u.length>0?e.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[A.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[s.kind?e.jsx(De,{kind:s.kind,label:s.label,compact:!0,gradient:!1,className:"max-w-[16rem]"}):e.jsx(z,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.label}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-muted)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>$(s.value),"aria-label":`Remove ${s.label}`,children:e.jsx(Ae,{className:"size-3.5"})})]},s.value)),u.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-[color-mix(in_srgb,var(--info)_24%,transparent)] bg-[var(--ui-info-soft)] px-2.5 py-1.5 text-sm text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ce,{className:"size-3.5"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:s})]}),e.jsx("button",{type:"button",className:"rounded-full text-[color-mix(in_srgb,var(--info)_70%,var(--ui-ink-strong)_30%)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>p(s),"aria-label":`Remove free-text filter ${s}`,children:e.jsx(Ae,{className:"size-3.5"})})]},s))]}):null,u.length>1?e.jsx("div",{className:"mb-3 text-xs text-[var(--ui-ink-muted)]",children:"Free-text chips are combined with OR."}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qe,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx("input",{value:S,onChange:s=>{M(s.target.value),g(!0),v(0)},onFocus:()=>g(!0),onBlur:()=>{window.setTimeout(()=>g(!1),120)},onKeyDown:s=>{if(s.key==="Backspace"&&!S){if(u.length>0){p(u[u.length-1]);return}o.length>0&&$(o[o.length-1]);return}if(s.key==="ArrowDown"){s.preventDefault(),g(!0),v(w=>L.length===0?0:Math.min(L.length-1,w+1));return}if(s.key==="ArrowUp"){s.preventDefault(),v(w=>Math.max(0,w-1));return}if(s.key==="Escape"){g(!1);return}if(s.key!=="Enter")return;s.preventDefault();const c=L[H];if(c){Y(c.value);return}K()},placeholder:j,className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),ee?e.jsxs("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-2 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[L.map((s,c)=>e.jsx("button",{type:"button",className:Ze("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",c===H?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>v(c),onMouseDown:w=>w.preventDefault(),onClick:()=>Y(s.value),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.kind?e.jsx(De,{kind:s.kind,label:s.label,compact:!0,gradient:!1}):s.label}),s.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-muted)]",children:s.description}):null]})},s.value)),N?e.jsxs("button",{type:"button",className:"mt-1 flex w-full items-center gap-2 rounded-[18px] px-3 py-2.5 text-left text-sm text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)] transition hover:bg-[var(--ui-surface-2)]",onMouseDown:s=>s.preventDefault(),onClick:()=>K(),children:[e.jsx(Ce,{className:"size-4"}),e.jsxs("span",{className:"truncate",children:['Add free text "',S.trim(),'"']})]}):null,L.length===0&&!N?e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Keep typing to find a linked entity, or press Enter to add a free-text badge."}):null]}):null]})]})]})}const Ft=new Set(["goal","project","task","strategy","habit","tag","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","flashcard","trigger_report"]);function Pe(i){return Ft.has(i)}function x(i,o){return`${i}:${o}`}function W(i){const o=i.indexOf(":");if(o<=0||o>=i.length-1)return null;const d=i.slice(0,o);return Pe(d)?{entityType:d,entityId:i.slice(o+1)}:null}function Ee(i){return i!==null}function $e(i){const o=i.getAll("linkedTo"),d=i.get("entityType"),u=i.get("entityId");return d&&u&&Pe(d)&&o.unshift(x(d,u)),Array.from(new Set(o.map(I=>I.trim()).filter(Boolean)))}function Dt(i){return Array.from(new Set(i.getAll("textTerms").map(o=>o.trim()).filter(Boolean)))}function _t(i){return Z(i.getAll("tags"))}function R(i,o=[]){return{contentMarkdown:(i==null?void 0:i.contentMarkdown)??"",author:(i==null?void 0:i.author)??"",linkedValues:(i==null?void 0:i.links.map(d=>x(d.entityType,d.entityId)))??o,tags:Z((i==null?void 0:i.tags)??[]),destroyAtInput:ft((i==null?void 0:i.destroyAt)??null),destroyDelayValue:"",destroyDelayUnit:"days"}}function It(i){return[...i].sort((o,d)=>o.label.localeCompare(d.label))}function qe(i){return bt(i.destroyAtInput)??kt(i.destroyDelayValue,i.destroyDelayUnit)}function Zt(){var ye,fe,be,ke,je,Ne,we,Te;const i=Re(),o=We(),d=et(),[u,I]=ze(),[j,S]=m.useState(()=>$e(u)),[M,ee]=m.useState(()=>_t(u)),[g,H]=m.useState(()=>Dt(u)),[v,B]=m.useState(u.get("author")??""),[A,L]=m.useState(u.get("updatedFrom")??""),[N,Y]=m.useState(u.get("updatedTo")??""),[K,$]=m.useState(!1),[p,s]=m.useState(()=>R(null,$e(u))),[c,w]=m.useState(null),[y,T]=m.useState(null),[q,oe]=m.useState(null),le=F({queryKey:["forge-psyche-values"],queryFn:ct}),de=F({queryKey:["forge-psyche-patterns"],queryFn:ut}),ce=F({queryKey:["forge-psyche-behaviors"],queryFn:mt}),ue=F({queryKey:["forge-psyche-beliefs"],queryFn:pt}),me=F({queryKey:["forge-psyche-modes"],queryFn:xt}),pe=F({queryKey:["forge-psyche-flashcards"],queryFn:ht}),xe=F({queryKey:["forge-psyche-reports"],queryFn:gt}),he=Array.isArray(d.selectedUserIds)?d.selectedUserIds:[],U=F({queryKey:["forge-life-force",...he],queryFn:async()=>(await vt(he)).lifeForce});m.useEffect(()=>{const a=new URLSearchParams;for(const n of j)a.append("linkedTo",n);for(const n of M)a.append("tags",n);for(const n of g)a.append("textTerms",n);v.trim()&&a.set("author",v.trim()),A&&a.set("updatedFrom",A),N&&a.set("updatedTo",N),I(a,{replace:!0})},[v,j,M,g,I,A,N]);const X=m.useMemo(()=>{var n,h,G,l,r,Se,Me;const a=[...d.snapshot.goals.map(t=>({value:x("goal",t.id),label:t.title,description:k(t.description,t.user,"Goal"),searchText:b([t.title,t.description],t),kind:f("goal")??void 0})),...d.snapshot.dashboard.projects.map(t=>({value:x("project",t.id),label:t.title,description:k(`${t.description}${t.description?" · ":""}${t.goalTitle}`,t.user,t.goalTitle),searchText:b([t.title,t.description,t.goalTitle],t),kind:f("project")??void 0})),...d.snapshot.tasks.map(t=>({value:x("task",t.id),label:t.title,description:k(`${t.description}${t.description?" · ":""}${t.owner}`,t.user,t.owner),searchText:b([t.title,t.description,t.owner],t),kind:f("task")??void 0})),...d.snapshot.strategies.map(t=>({value:x("strategy",t.id),label:t.title,description:k(t.overview,t.user,"Strategy"),searchText:b([t.title,t.overview,t.endStateDescription],t),kind:f("strategy")??void 0})),...d.snapshot.habits.map(t=>({value:x("habit",t.id),label:t.title,description:k(t.description,t.user,"Habit"),searchText:b([t.title,t.description],t),kind:f("habit")??void 0})),...d.snapshot.tags.map(t=>({value:x("tag",t.id),label:t.name,description:k(t.description,t.user,t.kind),searchText:b([t.name,t.kind,t.description],t),kind:f("tag")??void 0})),...(((n=le.data)==null?void 0:n.values)??[]).map(t=>({value:x("psyche_value",t.id),label:t.title,description:k(t.description,t.user,"Psyche value"),searchText:b([t.title,t.description,t.valuedDirection],t),kind:f("psyche_value")??void 0})),...(((h=de.data)==null?void 0:h.patterns)??[]).map(t=>({value:x("behavior_pattern",t.id),label:t.title,description:k(t.description,t.user,"Behavior pattern"),searchText:b([t.title,t.description,t.targetBehavior],t),kind:f("behavior_pattern")??void 0})),...(((G=ce.data)==null?void 0:G.behaviors)??[]).map(t=>({value:x("behavior",t.id),label:t.title,description:k(t.description,t.user,"Behavior"),searchText:b([t.title,t.description,t.kind],t),kind:f("behavior")??void 0})),...(((l=ue.data)==null?void 0:l.beliefs)??[]).map(t=>({value:x("belief_entry",t.id),label:t.statement,description:k(t.flexibleAlternative||t.originNote,t.user,"Belief"),searchText:b([t.statement,t.flexibleAlternative,t.originNote],t),kind:f("belief_entry")??void 0})),...(((r=me.data)==null?void 0:r.modes)??[]).map(t=>({value:x("mode_profile",t.id),label:t.title,description:k(t.archetype||t.family,t.user,"Mode"),searchText:b([t.title,t.archetype,t.family,t.persona],t),kind:f("mode_profile")??void 0})),...(((Se=pe.data)==null?void 0:Se.flashcards)??[]).map(t=>({value:x("flashcard",t.id),label:t.title||t.message,description:k(t.triggerSentence||t.triggerSituation,t.user,"Flashcard"),searchText:b([t.title,t.message,t.triggerSentence,t.triggerSituation,...t.tags],t),kind:f("flashcard")??void 0})),...(((Me=xe.data)==null?void 0:Me.reports)??[]).map(t=>({value:x("trigger_report",t.id),label:t.title,description:k(t.eventSituation,t.user,"Trigger report"),searchText:b([t.title,t.eventSituation,t.customEventType??""],t),kind:f("trigger_report")??void 0}))];return It(a)},[(ye=ce.data)==null?void 0:ye.behaviors,(fe=ue.data)==null?void 0:fe.beliefs,(be=pe.data)==null?void 0:be.flashcards,(ke=me.data)==null?void 0:ke.modes,(je=de.data)==null?void 0:je.patterns,(Ne=xe.data)==null?void 0:Ne.reports,d.snapshot.dashboard.projects,d.snapshot.goals,d.snapshot.habits,d.snapshot.strategies,d.snapshot.tags,d.snapshot.tasks,(we=le.data)==null?void 0:we.values]),Be=m.useMemo(()=>X.map(a=>{const n=W(a.value);return{value:a.value,label:a.label,description:a.description,searchText:a.searchText,kind:a.kind,entityType:(n==null?void 0:n.entityType)??"goal",entityId:(n==null?void 0:n.entityId)??""}}),[X]),Ke=m.useMemo(()=>j.map(a=>W(a)).filter(Boolean),[j]),O=F({queryKey:["notes-index",j.join("|"),M.join("|"),g.join("|"),v.trim(),A,N],queryFn:()=>yt({linkedTo:Ke,tags:M,textTerms:g,author:v.trim()||void 0,updatedFrom:A||void 0,updatedTo:N||void 0,limit:200})}),te=async()=>{await Promise.all([o.invalidateQueries({queryKey:["notes-index"]}),dt(o)])},ge=ie({mutationFn:async a=>ot({contentMarkdown:a.contentMarkdown.trim(),author:a.author.trim()||null,tags:Z(a.tags),destroyAt:qe(a),links:a.linkedValues.map(n=>W(n)).filter(Ee).map(n=>({entityType:n.entityType,entityId:n.entityId}))}),onSuccess:async()=>{s(R(null,j)),$(!1),await te()}}),ve=ie({mutationFn:async({noteId:a,draft:n})=>lt(a,{contentMarkdown:n.contentMarkdown.trim(),author:n.author.trim()||null,tags:Z(n.tags),destroyAt:qe(n),links:n.linkedValues.map(h=>W(h)).filter(Ee).map(h=>({entityType:h.entityType,entityId:h.entityId}))}),onSuccess:async()=>{w(null),T(null),await te()}}),ae=ie({mutationFn:a=>rt(a),onSuccess:te}),V=((Te=O.data)==null?void 0:Te.notes)??[],Ue=new Date().toISOString().slice(0,10),Oe=V.filter(a=>a.createdAt.slice(0,10)===Ue).length*J().totalAp,C=q?V.find(a=>a.id===q.noteId)??null:null,se=C?_e(C):null,E=se?Ie(se.entityType,se.entityId):null,Ve=m.useMemo(()=>C?[{id:"open-linked",label:"Open linked record",description:E?"Jump back into the main entity this note is attached to.":"This note has no navigable linked record yet.",icon:He,disabled:!E,onSelect:()=>{E&&i(E.includes("#")?E:`${E}#notes`)}},{id:"edit-note",label:"Edit note",description:"Update the Markdown body, note tags, expiry, or connected entity links.",icon:Ye,onSelect:()=>{w(C.id),T(R(C))}},{id:"delete-note",label:"Delete note",description:"Soft-delete this note from the main workspace.",icon:Xe,tone:"danger",disabled:ae.isPending,onSelect:()=>{ae.mutateAsync(C.id)}}]:[],[E,C,ae,i]);return O.isError?e.jsx(tt,{eyebrow:"Notes",error:O.error,onRetry:()=>void O.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(jt,{title:"Notes",titleText:"Notes",description:"Notes are first-class Markdown entities in Forge. Search them by linked records, note tags, date, or free text, then create durable or ephemeral notes that stay connected to the rest of the graph.",badge:`${V.length} visible`,actions:e.jsxs(Q,{onClick:()=>{s(R(null,j)),$(!0)},children:[e.jsx(Ge,{className:"size-4"}),"New note"]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(_,{className:"border-[var(--primary)]/16 shadow-[var(--card-shadow)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Quick note default"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:P(J().totalAp)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Standalone notes count as a tiny Action Point impulse unless a richer active work context already covers them."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Notes created today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:P(Oe)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Visible notes created today in this workspace at the default quick note cost."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U.data?`${P(U.data.spentTodayAp)} / ${P(U.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Notes participate in the same Action Point ledger as tasks, habits, movement, and calendar work."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U.data?at(U.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Useful when deciding whether to just capture a quick note or stay inside a heavier work stream."})]})]}),e.jsx(Nt,{children:e.jsxs(_,{className:"grid gap-4",children:[e.jsx(Ct,{entityOptions:Be,selectedEntityValues:j,onSelectedEntityValuesChange:S,selectedTextTerms:g,onSelectedTextTermsChange:H}),e.jsx(re,{value:M,onChange:ee,placeholder:"Filter by memory tag or custom note tag"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(12rem,0.38fr)_minmax(12rem,0.38fr)]",children:[e.jsx(D,{value:v,onChange:a=>B(a.target.value),placeholder:"Filter by author"}),e.jsx(D,{type:"date",value:A,onChange:a=>L(a.target.value)}),e.jsx(D,{type:"date",value:N,onChange:a=>Y(a.target.value)})]})]})}),K?e.jsx(wt,{children:e.jsxs(_,{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.16em] text-[var(--ui-ink-faint)]",children:"New note"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Notes are independent Markdown entities. Link them to one or more real records, add memory-system or custom tags, and optionally make them ephemeral with an automatic destroy time. Standalone notes default to"," ",P(J().totalAp),"."]})]}),e.jsx(Q,{variant:"ghost",onClick:()=>{$(!1),s(R(null,j))},children:"Cancel"})]}),e.jsx(Le,{value:p.contentMarkdown,onChange:a=>s(n=>({...n,contentMarkdown:a.target.value})),className:"min-h-[16rem]",placeholder:"Write the note in Markdown. This can be as short as a handoff line or as long as a wiki page."}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[e.jsx(D,{value:p.author,onChange:a=>s(n=>({...n,author:a.target.value})),placeholder:"Optional author"}),e.jsx(Fe,{options:X,selectedValues:p.linkedValues,onChange:a=>s(n=>({...n,linkedValues:a})),placeholder:"Link this note to strategies, goals, projects, tasks, habits, or human/bot-owned records",emptyMessage:"No matching entities found yet."})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(re,{value:p.tags,onChange:a=>s(n=>({...n,tags:a}))}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Ephemeral auto-destroy"}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(D,{type:"datetime-local",value:p.destroyAtInput,onChange:a=>s(n=>({...n,destroyAtInput:a.target.value}))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(D,{type:"number",min:"1",value:p.destroyDelayValue,onChange:a=>s(n=>({...n,destroyDelayValue:a.target.value})),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)]",value:p.destroyDelayUnit,onChange:a=>s(n=>({...n,destroyDelayUnit:a.target.value})),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:p.contentMarkdown.trim()?e.jsx(ne,{markdown:p.contentMarkdown}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"Markdown preview appears here."})})]}),e.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:e.jsx(Q,{pending:ge.isPending,pendingLabel:"Saving",disabled:p.contentMarkdown.trim().length===0||p.linkedValues.length===0,onClick:()=>void ge.mutateAsync(p),children:"Save note"})})]})}):null,O.isLoading?e.jsx(_,{className:"text-sm text-[var(--ui-ink-soft)]",children:"Loading notes…"}):V.length===0?e.jsx(st,{eyebrow:"Notes",title:"No matching notes yet",description:"Try broader linked-entity filters, remove a date bound, or add the first durable note from the button above."}):e.jsx(Tt,{children:e.jsx("div",{className:"grid gap-3",children:V.map(a=>{const n=_e(a),h=n?Ie(n.entityType,n.entityId):null,G=c===a.id&&y!==null;return e.jsxs(_,{className:"min-w-0 overflow-hidden p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[(a.author??"Unknown author").toString()," •"," ",new Date(a.updatedAt).toLocaleString()]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(z,{className:"bg-[var(--primary)]/12 text-[var(--primary)]",wrap:!0,children:[P(J().totalAp)," ","quick note"]}),a.links.map(l=>e.jsxs(z,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",wrap:!0,children:[it(l.entityType),l.anchorKey?` · ${nt(l.anchorKey)}`:""]},`${a.id}-${l.entityType}-${l.entityId}-${l.anchorKey??""}`)),(a.tags??[]).map(l=>e.jsx(z,{className:"border-[var(--info)]/20 bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:l},`${a.id}-tag-${l}`)),a.destroyAt?e.jsxs(z,{className:"border-[var(--warning)]/20 bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:["Ephemeral · deletes"," ",new Date(a.destroyAt).toLocaleString()]}):null]})]}),e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",onClick:l=>{l.preventDefault(),l.stopPropagation();const r=l.currentTarget.getBoundingClientRect();oe({noteId:a.id,position:{x:r.right-8,y:r.bottom+8}})},"aria-label":`Open actions for note ${a.id}`,children:e.jsx(Je,{className:"size-4"})})]}),G?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(Le,{value:y.contentMarkdown,onChange:l=>T(r=>r&&{...r,contentMarkdown:l.target.value}),className:"min-h-[14rem]"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[e.jsx(D,{value:y.author,onChange:l=>T(r=>r&&{...r,author:l.target.value}),placeholder:"Optional author"}),e.jsx(Fe,{options:X,selectedValues:y.linkedValues,onChange:l=>T(r=>r&&{...r,linkedValues:l}),placeholder:"Update the linked entities",emptyMessage:"No matching entities found yet."})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(re,{value:y.tags,onChange:l=>T(r=>r&&{...r,tags:l})}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Ephemeral auto-destroy"}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(D,{type:"datetime-local",value:y.destroyAtInput,onChange:l=>T(r=>r&&{...r,destroyAtInput:l.target.value})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(D,{type:"number",min:"1",value:y.destroyDelayValue,onChange:l=>T(r=>r&&{...r,destroyDelayValue:l.target.value}),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)]",value:y.destroyDelayUnit,onChange:l=>T(r=>r&&{...r,destroyDelayUnit:l.target.value}),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:y.contentMarkdown.trim()?e.jsx(ne,{markdown:y.contentMarkdown}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"No content yet."})})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{variant:"ghost",onClick:()=>{w(null),T(null)},children:"Cancel"}),e.jsx(Q,{pending:ve.isPending,pendingLabel:"Saving",disabled:y.contentMarkdown.trim().length===0||y.linkedValues.length===0,onClick:()=>void ve.mutateAsync({noteId:a.id,draft:y}),children:"Save changes"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"mt-4 min-w-0 max-w-full overflow-hidden text-left",onClick:()=>{h&&i(h.includes("#")?h:`${h}#notes`)},disabled:!h,children:e.jsx(ne,{markdown:a.contentMarkdown,className:"line-clamp-none"})}),h?e.jsx("div",{className:"mt-4 inline-flex text-xs uppercase tracking-[0.16em] text-[var(--secondary)]",children:"Open linked record"}):null]})]},a.id)})})}),e.jsx(St,{open:!!q,title:"Note actions",subtitle:C?C.contentPlain.slice(0,80)||"Markdown note":void 0,items:Ve,position:(q==null?void 0:q.position)??null,onClose:()=>oe(null)})]})}export{Zt as NotesPage};
@@ -1 +0,0 @@
1
- import{r as R,j as e,aC as F}from"./vendor-BwL6m4SE.js";import{A as q}from"./ai-surface-workspace-DtwybxJB.js";import{i as $}from"./state-Bpe5dF3T.js";import{T as Q,W as B,M as z,S as G,Q as Y}from"./utility-widgets-h5eG2jvc.js";import{F as J}from"./flagship-signal-deck-DjcskRwF.js";import{u as Z,d as ee,bb as te,n as E,m as L,bc as D,k as p,a4 as ie,c as se,C as M,b as ae,E as re,P as ne,R as le,bd as oe,be as de,aS as ce,bf as ue}from"./index-izRKx6JK.js";import{L as me}from"./life-force-workspace-CtAWZXNw.js";import{E as pe}from"./entity-note-count-link-xne6mshj.js";import{P as fe}from"./page-hero-BLhM8FF3.js";import{a as ve,g as xe}from"./activity-copy-Bj4h9OcF.js";import"./board-CuxQRKPJ.js";import"./generic-node-view-DNVwfqqq.js";import"./graph-BF4IsheG.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./forms-D1qJ3oOP.js";import"./floating-action-menu-cGhbJ2tc.js";import"./charts-BzT4pUPg.js";const f={"Life Force":"Life Force compares today's spent Action Points with the modeled daily budget. It is Forge's local capacity planning layer, not a medical score.",Momentum:"Momentum summarizes recent execution, XP, streak context, and movement across Forge records. Use it as an attention signal.",Instant:"Instant AP/hour estimates current headroom from the Life Force drain model. Higher values mean Forge thinks the next block can absorb more effort.",Level:"Level comes from the XP ledger. It represents accumulated meaningful Forge activity for the selected user scope.","Weekly XP":"Weekly XP is recent reward-ledger movement. It helps separate a genuinely active week from old accumulated progress."};function he(a){const n=["gamification","summary","pipeline","body-signals","signals"],t=[...a.order];let r=!1;for(const v of n)t.includes(v)||(t.push(v),r=!0);const j=t.indexOf("summary"),c=t.indexOf("pipeline"),x=t.indexOf("body-signals"),g=t.indexOf("signals");if(j===-1||c===-1||x===-1||g===-1)return r?{...a,order:t}:a;if(j<c&&c<x&&x<g&&!r)return a;for(const v of n){const b=t.indexOf(v);b!==-1&&t.splice(b,1)}const y=t.indexOf("goals");return t.splice(y===-1?0:y,0,...n),{...a,order:t}}function ge(a=new Date){const n=a.getFullYear(),t=String(a.getMonth()+1).padStart(2,"0"),r=String(a.getDate()).padStart(2,"0");return`${n}-${t}-${r}`}function P(a){if(a>=3600){const n=a/3600;return n>=10||Number.isInteger(n)?`${Math.round(n)}h`:`${n.toFixed(1)}h`}return`${Math.max(1,Math.round(a/60))}m`}function ye(a){return a>=1e3?`${(a/1e3).toFixed(1)} km`:`${Math.round(a)} m`}function be(a){if(!a)return[];const n=new Map;for(const t of a.segments){if(t.kind!=="stay"||t.durationSeconds<=0)continue;const r=t.label.trim()||"Unlabeled stay";n.set(r,(n.get(r)??0)+t.durationSeconds)}return[...n.entries()].map(([t,r])=>({label:t,seconds:r})).sort((t,r)=>r.seconds-t.seconds).slice(0,3)}function ke(a){return a?["restingHeartRate","heartRateVariabilitySDNN","vo2Max","oxygenSaturation"].map(t=>a.metrics.find(r=>r.metric===t)).filter(t=>!!t).slice(0,3):[]}function we(a){if(a.latestValue==null)return"No reading";const n=a.unit==="steps"||a.unit==="flights"||a.unit==="kcal"||a.unit==="min"?0:1;return`${a.latestValue.toLocaleString(void 0,{maximumFractionDigits:n,minimumFractionDigits:n===0||a.latestValue>=100?0:1})} ${a.unit}`}function De(){var X,C;const{t:a}=Z(),n=ee(),t=n.snapshot,r=Array.isArray(n.selectedUserIds)?n.selectedUserIds:[],j=r.join("|"),[c,x]=R.useState(!1);R.useEffect(()=>{x(!1);const i=window.setTimeout(()=>{x(!0)},650);return()=>window.clearTimeout(i)},[j]);const g=ge(),y=$({queryKey:["forge-overview-sleep",...r],queryFn:async()=>(await oe(r)).sleep,enabled:c,staleTime:6e4})??{},v=$({queryKey:["forge-overview-fitness",...r],queryFn:async()=>(await de(r,{compact:!0})).fitness,enabled:c,staleTime:6e4})??{},b=$({queryKey:["forge-overview-movement-day",g,...r],queryFn:async()=>(await ce({date:g,userIds:r})).movement,enabled:c,staleTime:6e4})??{},H=$({queryKey:["forge-overview-vitals",...r],queryFn:async()=>(await ue(r)).vitals,enabled:c,staleTime:6e4})??{},I=te(r,{skip:!c}),u=t.dashboard.milestoneRewards.find(i=>!i.completed)??t.dashboard.milestoneRewards[0]??null,o=t.overview.topTasks[0]??null,d=t.overview.dueHabits[0]??null,m=t.overview.recentEvidence[0]??null,V=new Map(t.projects.map(i=>[i.id,i])),N=t.metrics.momentumScore>=80?"Strong":t.metrics.momentumScore>=60?"Steady":"Needs attention",k=((X=y.data)==null?void 0:X.summary)??null,h=((C=v.data)==null?void 0:C.summary)??null,l=b.data,S=H.data??null,A=ke(S??void 0),T=be(l),O=k!==null||h!==null||S!==null,W=l!==void 0&&(l.summary.tripCount>0||l.summary.stayCount>0||l.summary.totalMovingSeconds>0||T.length>0),K=t.lifeForce?[{label:"Life Force",value:`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP`,detail:`Remaining ${E(t.lifeForce.remainingAp)}`,help:f["Life Force"]},{label:"Momentum",value:`${t.metrics.momentumScore}`,detail:`${N} · ${t.metrics.streakDays} day streak`,help:f.Momentum},{label:"Instant",value:L(t.lifeForce.instantFreeApPerHour),detail:t.lifeForce.overloadApPerHour>0?`${L(t.lifeForce.overloadApPerHour)} overload`:"Headroom right now",help:f.Instant},{label:"Level",value:`L${t.metrics.level}`,detail:`${t.metrics.currentLevelXp} XP in level`,help:f.Level},{label:"Weekly XP",value:`${t.metrics.weeklyXp}`,detail:`${t.metrics.totalXp} total XP`,help:f["Weekly XP"]}]:[{label:"Level",value:`L${t.metrics.level}`,detail:`${t.metrics.currentLevelXp} XP in level`,help:f.Level},{label:"Weekly XP",value:`${t.metrics.weeklyXp}`,detail:`${t.metrics.totalXp} total XP`,help:f["Weekly XP"]},{label:"Momentum",value:`${t.metrics.momentumScore}`,detail:`${N} · ${t.metrics.streakDays} day streak`,help:f.Momentum}];function U(i){return i.entityType==="goal"?`/goals/${i.entityId}`:i.entityType==="project"?`/projects/${i.entityId}`:i.entityType==="task"?`/tasks/${i.entityId}`:i.entityType==="habit"?"/habits":i.entityType==="task_run"&&typeof i.metadata.taskId=="string"?`/tasks/${i.metadata.taskId}`:`/activity?eventId=${i.id}`}const _=[{id:"hero",title:"Overview",description:"The route header stays movable like any other surface block.",defaultWidth:12,defaultHeight:2,removable:!1,minHeight:2,maxHeight:3,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(fe,{title:"Overview",titleText:"Overview",description:`${N}. Life Force, momentum, XP, goals, active projects, and top tasks all start here.`,badge:`Momentum ${t.metrics.momentumScore}`})},{id:"gamification",title:"Forge Smith",description:"Selected-user level, XP, streak, trophy, and unlock state.",defaultWidth:12,defaultHeight:4,removable:!1,minHeight:3,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:({compact:i})=>{var s;return I.data?e.jsx(D,{metrics:I.data.metrics,compact:i}):e.jsx(D,{metrics:{scope:{mode:"operator_fallback",userIds:t.userScope.selectedUserIds,users:t.userScope.selectedUsers,label:((s=t.userScope.selectedUsers[0])==null?void 0:s.displayName)??"Forge"},profile:t.metrics,achievements:[],milestoneRewards:[],momentumPulse:{status:t.metrics.momentumScore>=80?"surging":t.metrics.momentumScore>=60?"steady":"recovering",headline:`${t.metrics.streakDays}-day streak`,detail:`${t.metrics.currentLevelXp}/${t.metrics.nextLevelXp} XP in level ${t.metrics.level}.`,celebrationLabel:"Forge Smith",nextMilestoneId:null,nextMilestoneLabel:"Next unlock"},catalogPreview:[],unlockedItemCount:0,totalItemCount:144,nextUnlock:null,newestUnlock:null,nextTargets:[],equipment:{selectedMascotSkin:null,selectedHudTreatment:null,selectedStreakEffect:null,selectedTrophyShelf:null,selectedCelebrationVariant:null,updatedAt:null},mascot:{mood:"wise",spriteKey:"mascot-state-014",streakSpriteKey:"mascot-state-017",headline:"Small heat still counts.",line:"Return to the anvil today.",pressureLevel:0,missedDays:0,lastActiveDateKey:null},celebrations:[],recentLedger:[],rules:[],dailyAmbientXp:0,dailyAmbientCap:12},compact:i})}},{id:"summary",title:"Momentum summary",description:"Smaller titles and denser metrics free space for the widgets themselves.",defaultWidth:12,defaultHeight:3,minWidth:6,render:({compact:i})=>e.jsxs("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Momentum summary"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Core live metrics"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Life Force, momentum, XP, and instant headroom stay grouped here."})]}),e.jsx(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:N})]}),e.jsx("div",{className:se("mt-4 grid gap-3",i?"grid-cols-2":"sm:grid-cols-2 xl:grid-cols-5"),children:K.map(s=>e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{children:s.label}),e.jsx(ie,{label:`Explain ${s.label}`,title:s.label,content:s.help,panelClassName:"normal-case tracking-normal"})]}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:s.value}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.detail})]},s.label))})]})},{id:"life-force",title:"Life Force",description:"Dynamic Action Points, the editable capacity curve, current drains, and stat growth all live here.",defaultWidth:12,defaultHeight:7,minWidth:6,render:()=>t.lifeForce?e.jsx(me,{selectedUserIds:r,fallbackLifeForce:t.lifeForce,onRefresh:n.refresh,showEditor:!1}):e.jsx(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Life Force is not configured for this user yet. Once a profile exists, the full capacity curve, drains, and recommendations will appear here."})},{id:"body-signals",title:"Life, health, movement",description:"Health imports and movement context make the overview feel like a real daily operating page.",defaultWidth:12,defaultHeight:4,minWidth:6,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-3",children:[e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t.lifeForce?`${Math.round(t.lifeForce.remainingAp)} AP remaining`:"No Life Force profile yet"})]}),t.lifeForce?e.jsx(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:L(t.lifeForce.instantFreeApPerHour)}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.lifeForce?`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP spent today. Remaining ${E(t.lifeForce.remainingAp)} with ${L(t.lifeForce.currentDrainApPerHour)} current drain.`:"Once Life Force is configured, this block will show today's budget, remaining headroom, and live drain."})]}),e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Body signals"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:O?"Recovery, training, and vitals":"No health data yet"})]}),S?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[S.summary.metricCount," metrics"]}):null]}),y.isLoading||v.isLoading||H.isLoading?e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Loading recent sleep, workout, and body-signal metrics…"}):O?e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[k?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Average sleep"}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:P(k.averageSleepSeconds)})]}):null,k?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Sleep score"}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:Math.round(k.averageSleepScore)})]}):null,h?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Exercise"}),e.jsxs("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:[Math.round(h.exerciseMinutes)," min"]})]}):null,h?e.jsx("div",{className:"text-xs leading-5 text-[var(--ui-ink-faint)]",children:h.topWorkoutType?`${h.topWorkoutType} is the top workout type right now.`:"Workout imports are available when Apple Health or habit-generated sessions exist."}):null,A.length>0?e.jsx("div",{className:"mt-1 grid gap-2",children:A.map(i=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:we(i)})]},i.metric))}):null]}):e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Sleep, workout, and vitals summaries appear here as soon as Forge has recent HealthKit records."})]}),e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Movement"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:W?"Today's place balance":"No movement timeline yet"})]}),W?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[P((l==null?void 0:l.summary.totalMovingSeconds)??0)," ","moving"]}):null]}),b.isLoading?e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Loading today's stays, trips, and place balance…"}):W?e.jsxs("div",{className:"mt-3 grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[T.map(i=>e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[P(i.seconds)," at ",i.label]},i.label)),((l==null?void 0:l.summary.totalMovingSeconds)??0)>0?e.jsxs(p,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[P((l==null?void 0:l.summary.totalMovingSeconds)??0)," ","moving"]}):null]}),e.jsxs("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:[(l==null?void 0:l.summary.tripCount)??0," trip",((l==null?void 0:l.summary.tripCount)??0)===1?"":"s"," and"," ",ye((l==null?void 0:l.summary.totalDistanceMeters)??0)," ","tracked today."]})]}):e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Movement summaries appear here once the companion has synced stays, trips, or known places."})]})]})},{id:"signals",title:"Action signals",description:"Direct links to the next things worth opening.",defaultWidth:7,defaultHeight:4,minWidth:4,render:()=>e.jsx(J,{eyebrow:"Actions",title:"Open what matters now",description:"These cards stay compact by default so the page can fit more live context at once.",items:[{id:"top-task",label:o?"Top task":d?"Due habit":"Recovery lane",title:(o==null?void 0:o.title)??(d==null?void 0:d.title)??"Get a real task moving",detail:(o==null?void 0:o.description)||(d==null?void 0:d.description)||"There is no single top task yet, so use this surface to choose one clean next move.",badge:o?`${o.points} xp`:d?`${d.rewardXp} xp`:`${t.metrics.weeklyXp} weekly xp`,href:o?`/tasks/${o.id}`:d?"/habits":"/today",actionLabel:o?"Open task":d?"Open habits":"Open today"},{id:"reward",label:"Next reward",title:(u==null?void 0:u.title)??"Keep the streak alive",detail:(u==null?void 0:u.progressLabel)??`Level ${t.metrics.level} is active. ${t.metrics.weeklyXp} weekly XP is already logged.`,badge:(u==null?void 0:u.rewardLabel)??`${t.metrics.comboMultiplier.toFixed(2)}x combo`,href:"/rewards",actionLabel:"Open rewards"},{id:"recent-activity",label:"Recent activity",title:m?xe(m):"No recent evidence",detail:m?ve(m):"The next work closeout or note will appear here.",badge:(m==null?void 0:m.source)??"activity",href:m?U(m):"/activity",actionLabel:"Open"}]})},{id:"goals",title:"Goals",description:"Long-range direction stays visible without taking over the whole page.",defaultWidth:8,defaultHeight:5,minWidth:4,render:({compact:i})=>e.jsx("div",{className:"grid gap-3",children:t.overview.activeGoals.slice(0,i?2:4).map(s=>{var w;return e.jsxs("div",{className:"group relative rounded-[20px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsx(F,{to:`/goals/${s.id}`,className:"absolute inset-0 rounded-[20px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--primary)]","aria-label":`Open goal ${s.title}`}),e.jsxs("div",{className:"pointer-events-none relative z-10",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsx(ae,{kind:"goal",label:((w=s.tags[0])==null?void 0:w.name)??s.horizon,compact:!0,gradient:!1}),e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[s.progress,"%"]})]}),e.jsx("div",{className:"mt-3",children:e.jsx(re,{kind:"goal",label:s.title,variant:"heading",size:i?"md":"lg",lines:2,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),i?null:e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description}),e.jsx("div",{className:"mt-3",children:e.jsx(ne,{value:s.progress})})]}),e.jsx("div",{className:"relative z-20 mt-3",children:e.jsx(pe,{entityType:"goal",entityId:s.id,count:le(t.dashboard.notesSummaryByEntity,"goal",s.id).count})})]},s.id)})})},{id:"pipeline",title:"Projects, habits, tasks",description:"Execution blocks can shrink while keeping the useful subtitles visible.",defaultWidth:12,defaultHeight:5,minWidth:6,render:({compact:i})=>e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-3",children:[e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Projects"}),t.overview.projects.slice(0,i?3:4).map(s=>{var w;return e.jsxs(F,{to:`/projects/${s.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:((w=V.get(s.id))==null?void 0:w.status)??"active"})]}),e.jsxs(p,{wrap:!0,className:"max-w-[7rem] shrink-0",children:[s.earnedPoints," xp"]})]}),i?null:e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description})]},s.id)})]}),e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Due habits"}),t.overview.dueHabits.slice(0,i?3:4).map(s=>e.jsx(F,{to:"/habits","aria-label":`Open habit ${s.title}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),i?null:e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:s.description})]}),e.jsxs(p,{wrap:!0,className:"max-w-[7rem] shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[s.rewardXp," xp"]})]})},s.id))]}),e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Top tasks"}),t.overview.topTasks.slice(0,i?3:4).map(s=>e.jsx(F,{to:`/tasks/${s.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:s.status.replaceAll("_"," ")})]}),e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.points," xp"]})]})},s.id))]})]})},{id:"time",title:"Clock",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(Q,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(B,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(z,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(G,{surfaceId:"overview"})},{id:"quick-capture",title:"Quick capture",description:"Save a standalone note or wiki draft from any dashboard.",defaultWidth:5,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>{var s;return e.jsx(Y,{compact:i,defaultUserId:r[0]??((s=t.users[0])==null?void 0:s.id)??null})}}];return e.jsx(q,{surfaceId:"overview",baseWidgets:_,normalizeLayout:he})}export{De as OverviewPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./vendor-BwL6m4SE.js";import{a as h,c as v,k as y,a4 as j}from"./index-izRKx6JK.js";function u(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g," ")}function N({eyebrow:r,titleText:t,entityKind:n,copyMode:i}){if(!r||i==="title_only"||typeof r!="string")return null;const l=u(r),s=t?u(t):null,o=n?u(h(n).label):null;return!l||s&&(l===s||s.includes(l)||l.includes(s))||o&&l===o?null:r}function E({eyebrow:r,entityKind:t,title:n,titleText:i,description:l,helpTitle:s,helpContent:o,helpLabel:b,badge:m,actions:p,copyMode:w="title_only"}){const a=t?h(t):null,d=a==null?void 0:a.icon,c=N({eyebrow:r,titleText:i,entityKind:t,copyMode:w}),x=i??(typeof n=="string"?n:"this page"),g=o??(typeof l=="string"?l:null),f=!!(a||c||m);return e.jsxs("header",{className:"relative min-w-0 w-full max-w-full overflow-visible border-b border-[var(--ui-border-subtle)] px-5 py-5 sm:px-6 lg:grid lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end lg:px-7 lg:py-6",style:{background:"var(--hero-gradient)",paddingTop:"var(--forge-shell-hero-padding-top)",paddingBottom:"var(--forge-shell-hero-padding-bottom)"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at top right, color-mix(in srgb, var(--forge-body-ambient-primary) 94%, transparent), transparent 34%)"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[var(--ui-border-strong)]"}),e.jsxs("div",{className:"relative min-w-0 w-full max-w-full",children:[f?e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-[11px] font-medium uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:[a&&d?e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--ui-ink-soft)]","aria-label":a.label,title:a.label,children:[e.jsx(d,{className:v("size-3.5",a.iconClassName)}),e.jsx("span",{children:a.label})]}):null,c?e.jsx("span",{className:"text-[var(--secondary)]/80",children:c}):null,m?e.jsx(y,{tone:"signal",className:"h-8 overflow-visible rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[11px] font-medium tracking-[0.14em] text-[var(--ui-ink-medium)] uppercase",children:m}):null]}):null,e.jsxs("div",{className:v("flex min-w-0 max-w-4xl items-start gap-2",f?"mt-3":""),children:[e.jsx("div",{className:"min-w-0 text-[clamp(1.85rem,3.5vw,4rem)] font-medium leading-[0.92] text-[var(--ui-ink-strong)]",style:{transform:"translateY(var(--forge-shell-hero-title-translate-y)) scale(var(--forge-shell-hero-title-scale))",transformOrigin:"top left",willChange:"transform"},children:n}),g?e.jsx(j,{className:"mt-2 shrink-0",label:b??`Explain what the ${x} page shows and how to interpret it`,title:s??`${x} explained`,content:g}):null]}),e.jsx("div",{className:"mt-2 min-w-0 max-w-3xl text-[14px] leading-6 text-[var(--ui-ink-soft)] sm:text-[15px]",style:{opacity:"var(--forge-shell-hero-description-opacity)",transform:"translateY(var(--forge-shell-hero-description-translate-y))",willChange:"opacity, transform"},children:l})]}),p?e.jsx("div",{className:"relative mt-4 flex min-w-0 w-full max-w-full flex-wrap items-center gap-2 lg:mt-0 lg:max-w-[26rem] lg:justify-end",children:p}):null]})}export{E as P};
@@ -1 +0,0 @@
1
- import{j as t}from"./vendor-BwL6m4SE.js";import{c as a}from"./index-izRKx6JK.js";function i({children:r,className:s}){return t.jsx("div",{className:a("flex flex-wrap gap-2",s),children:r})}export{i as P};
@@ -1 +0,0 @@
1
- import{c6 as ee,b6 as te,r as k,j as e,aC as j}from"./vendor-BwL6m4SE.js";import{j as se,i as F,k as w}from"./state-Bpe5dF3T.js";import{S as ae}from"./scheduling-rules-editor-CAd290IE.js";import{u as ie,d as re,e as oe,S as ne,V as ce,b as v,E as le,C as u,B as m,k as h,i as f,bg as de,bh as pe,af as me,ae as xe,ag as je,bi as ue,N as he}from"./index-izRKx6JK.js";import{O as ge}from"./open-in-graph-button-CjvkEj1P.js";import{ProjectDialog as we}from"./project-dialog-B_J1ESMk.js";import{P as ve}from"./project-management-section-nav-DBNHt9p5.js";import{TaskDialog as fe}from"./task-dialog-eCDTF8xe.js";import{e as ye,W as be}from"./calendar-rules-DXuOv2J-.js";import{E as ke}from"./execution-board-BSUZCIIx.js";import{N as U}from"./note-markdown-BWedRE3c.js";import{E as Ne}from"./entity-notes-surface-jy6Psist.js";import{P as Ie}from"./preference-entity-handoff-button-CfCQl3cW.js";import{P as De}from"./page-hero-BLhM8FF3.js";import{U as H}from"./user-badge-MEZuJiir.js";import{g as Se,a as Pe}from"./activity-copy-Bj4h9OcF.js";import{g as qe}from"./entity-links-DwpxhW2H.js";import{g as Qe}from"./user-ownership-DJGl4rAj.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./question-flow-dialog-D-_EvoAt.js";import"./inline-note-fields-D4mCM1gO.js";import"./user-select-field-fx129Uh6.js";import"./schemas-B0Pa-V-A.js";import"./goal-dialog-DH50D0tP.js";import"./entity-note-count-link-xne6mshj.js";import"./floating-action-menu-cGhbJ2tc.js";import"./note-tags-input-DZkCqI1w.js";import"./entity-link-multiselect-C--AiCMb.js";import"./use-anchored-overlay-position-BY4kNzPj.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function dt(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[G,E]=k.useState(!1),[_,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=Qe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,B=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],O=new Set(B.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||O.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&O.has(t.metadata.taskId)):[],n=Te(o.projectId),y=F({queryKey:["project-board",o.projectId],queryFn:()=>ue(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>he({...I,userIds:N}),enabled:!!o.projectId&&!n}),J=w({mutationFn:t=>xe(t),onSuccess:async()=>{await Promise.all([f(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:je,onSuccess:async()=>{await Promise.all([f(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>de(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([f(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>pe(o.projectId),onSuccess:async()=>{await Promise.all([f(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),X=w({mutationFn:t=>me(t),onSuccess:async()=>{await Promise.all([f(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=y.data??(c&&A?{project:c,goal:A,tasks:B,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(y.isError&&!n)return e.jsx(oe,{eyebrow:a("common.projectDetail.errorEyebrow"),error:y.error,onRetry:()=>void y.refetch()});if(!s)return e.jsx(ne,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const Y="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=ye({rules:s.project.schedulingRules,overview:(M=V.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ve,{}),e.jsx(De,{entityKind:"project",title:e.jsx(le,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(U,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ce,{metrics:i.snapshot.metrics}),e.jsx(Ie,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ge,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(H,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(H,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(U,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{kind:"project",compact:!0,gradient:!1}),e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",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-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",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-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(ke,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:Y,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await J.mutateAsync(t)},onDeleteTask:async t=>{await X.mutateAsync(t)}}),n?null:e.jsx(Ne,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:qe(t)??`/activity?eventId=${t.id}`,className:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Se(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:Pe(t)})]},t.id))})]}),e.jsx(we,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(fe,{open:G,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(be,{open:_,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{dt as ProjectDetailPage};
@@ -1 +0,0 @@
1
- import{r as x,j as s,cu as X,cs as Y,cv as J,aC as Z,aK as ee,b7 as se}from"./vendor-BwL6m4SE.js";import{i as re}from"./state-Bpe5dF3T.js";import{E as R}from"./entity-link-multiselect-C--AiCMb.js";import{P as te}from"./project-management-section-nav-DBNHt9p5.js";import{P as ae}from"./page-hero-BLhM8FF3.js";import{d as ie,k as j,b as D,L as ne,e as le,C as z,B as C,h as oe,a as ce,c as F,bj as de}from"./index-izRKx6JK.js";import{U as A}from"./user-badge-MEZuJiir.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const _={user:"user:",kind:"kind:"},q=["goal","strategy","project","issue","task","subtask"],T=[...q],L=["active","paused","completed","backlog","focus","in_progress","blocked","done"];function I(r){return r.trim().toLowerCase()}function ue(r){return r.reduce((i,n)=>{if(n.startsWith(_.user))i.userIds.push(n.slice(_.user.length));else if(n.startsWith(_.kind)){const d=n.slice(_.kind.length);(d==="human"||d==="bot")&&i.kinds.push(d)}return i},{userIds:[],kinds:[]})}function he(r,i){return`${i}:${I(r)}`}function ge(r){const i=r.trim();return i.length===0?[]:["any",...q].map(n=>({id:he(i,n),query:i,kind:n}))}function me(r){switch(r){case"done":case"completed":return 1;case"in_progress":case"active":return .66;case"focus":return .45;case"blocked":return .5;case"paused":return .28;default:return .08}}function P(r,i){const n=r.replace(/\s+/g," ").trim();return n.length===0?i:n}function S(r){const i=(r.children??[]).map(S);if(r.kind==="project")return{...r,children:i,progressPercent:r.progressPercent,progressLabel:r.progressLabel??(typeof r.progressPercent=="number"?`${r.progressPercent}% complete`:null)};if(i.length>0){const d=i.map(g=>g.progressPercent).filter(g=>typeof g=="number");if(d.length>0){const g=Math.round(d.reduce((y,h)=>y+h,0)/d.length);return{...r,children:i,progressPercent:g,progressLabel:`${i.length} child item${i.length===1?"":"s"}`}}}const n=Math.round(me(r.statusLabel)*100);return{...r,children:i,progressPercent:n,progressLabel:r.statusLabel?r.statusLabel.replaceAll("_"," "):null}}function V(r){const{goals:i,strategies:n,projects:d,workItems:g,tagNameById:y}=r,h=new Map,v=new Map,m=new Map;for(const e of g)if(e.parentWorkItemId){const a=h.get(e.parentWorkItemId)??[];a.push(e),h.set(e.parentWorkItemId,a)}else if(e.level==="issue"&&e.projectId){const a=v.get(e.projectId)??[];a.push(e),v.set(e.projectId,a)}else if(e.projectId){const a=m.get(e.projectId)??[];a.push(e),m.set(e.projectId,a)}const b=e=>{var a;return S({id:`${e.level}:${e.id}`,entityId:e.id,kind:e.level,label:e.title,description:P(e.description,e.level==="issue"?"Vertical slice issue":e.level==="subtask"?"Granular child step":"Focused AI session task"),searchText:I([e.title,e.description,e.aiInstructions,e.executionMode??"",e.status,((a=e.user)==null?void 0:a.displayName)??"",...(e.assignees??[]).map(c=>c.displayName),...e.tagIds.map(c=>y.get(c)??"")].join(" ")),href:`/tasks/${e.id}`,statusLabel:e.status,executionMode:e.executionMode,goalId:e.goalId,projectId:e.projectId,tagIds:e.tagIds,user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:null,progressLabel:null,children:(h.get(e.id)??[]).map(b)})},f=e=>{var c;const a=n.filter(o=>o.targetProjectIds.includes(e.id));return S({id:`project:${e.id}`,entityId:e.id,kind:"project",label:e.title,description:P(e.description||e.productRequirementsDocument,"PRD-backed initiative"),searchText:I([e.title,e.description,e.productRequirementsDocument,e.goalTitle,e.workflowStatus,e.status,((c=e.user)==null?void 0:c.displayName)??"",...(e.assignees??[]).map(o=>o.displayName)].join(" ")),href:`/projects/${e.id}`,statusLabel:e.workflowStatus,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:e.user,assignees:e.assignees??[],linkedUserIds:[...e.user?[e.user.id]:[],...e.assigneeUserIds??[]],progressPercent:e.progress,progressLabel:`${e.completedTaskCount}/${e.totalTasks} done`,children:[...a.map(o=>{var p;return S({id:`strategy:${o.id}`,entityId:o.id,kind:"strategy",label:o.title,description:P(o.overview||o.endStateDescription,"Execution strategy"),searchText:I([o.title,o.overview,o.endStateDescription,o.status,((p=o.user)==null?void 0:p.displayName)??""].join(" ")),href:`/strategies/${o.id}`,statusLabel:o.status,executionMode:null,goalId:e.goalId,projectId:e.id,tagIds:[],user:o.user,assignees:[],linkedUserIds:o.user?[o.user.id]:[],progressPercent:null,progressLabel:null,children:[]})}),...(v.get(e.id)??[]).map(b),...(m.get(e.id)??[]).map(b)]})};return i.map(e=>{var B,w;const a=d.filter(l=>l.goalId===e.id),c=n.filter(l=>l.targetGoalIds.includes(e.id)),o=new Map(c.map(l=>[l.id,[]])),p=new Set;for(const l of a){const N=c.find(U=>U.targetProjectIds.includes(l.id));N&&((B=o.get(N.id))==null||B.push(l),p.add(l.id))}const M=c.map(l=>{var N;return S({id:`strategy:${l.id}`,entityId:l.id,kind:"strategy",label:l.title,description:P(l.overview||l.endStateDescription,"High-level strategy"),searchText:I([l.title,l.overview,l.endStateDescription,l.status,((N=l.user)==null?void 0:N.displayName)??""].join(" ")),href:`/strategies/${l.id}`,statusLabel:l.status,executionMode:null,goalId:e.id,projectId:null,tagIds:[],user:l.user,assignees:[],linkedUserIds:l.user?[l.user.id]:[],progressPercent:null,progressLabel:null,children:(o.get(l.id)??[]).map(f)})}),$=a.filter(l=>!p.has(l.id)).map(f);return S({id:`goal:${e.id}`,entityId:e.id,kind:"goal",label:e.title,description:P(e.description,"Strategic goal"),searchText:I([e.title,e.description,e.status,((w=e.user)==null?void 0:w.displayName)??""].join(" ")),href:`/goals/${e.id}`,statusLabel:e.status,executionMode:null,goalId:e.id,projectId:null,tagIds:e.tagIds,user:e.user,assignees:[],linkedUserIds:e.user?[e.user.id]:[],progressPercent:null,progressLabel:null,children:[...M,...$]})})}function K(r){return r.reduce((i,n)=>i+1+K(n.children??[]),0)}function pe(r,i){return r.searchText.includes(I(i.query))&&(i.kind==="any"||i.kind===r.kind)}function G(r,i,n=!1){const{clauses:d,statusFilters:g,ownerUserIds:y,ownerKinds:h,selectedUserIds:v}=i,m=d.length===0||d.some(p=>pe(r,p)),b=g.length===0||r.statusLabel!==null&&g.includes(r.statusLabel),f=y.length===0&&v.length===0?!0:[...y,...v].some(p=>r.linkedUserIds.includes(p)),e=h.length===0||[r.user,...r.assignees].some(p=>p&&h.includes(p.kind)),a=b&&f&&e,c=d.length===0||n||m,o=(r.children??[]).map(p=>G(p,i,n||a&&m)).filter(p=>p!==null);return a&&c||o.length>0?{...r,children:o}:null}function Q(r,i){return r.flatMap(n=>{const d=Q(n.children??[],i);return i.includes(n.kind)?[{...n,children:d}]:d})}function xe(r){switch(r){case"goal":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]";case"strategy":return"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]";case"project":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"issue":return"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]";case"subtask":return"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}}function O(r){switch(r){case"done":case"completed":return"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]";case"blocked":return"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]";case"in_progress":case"active":return"bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"focus":return"bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]";default:return"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"}}function W(r){return r==="any"?s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Any"}):r==="subtask"?s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}):s.jsx(D,{kind:r==="issue"?"issue":r,label:r,compact:!0,gradient:!1})}function be({query:r,onQueryChange:i,clauses:n,onClausesChange:d,resultSummary:g}){const[y,h]=x.useState(!1),[v,m]=x.useState(0),b=x.useMemo(()=>ge(r).filter(a=>!n.some(c=>c.id===a.id)),[n,r]),f=a=>{d([...n,a]),i(""),m(0),h(!1)},e=a=>{d(n.filter(c=>c.id!==a))};return s.jsx("div",{className:"grid gap-3",children:s.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] sm:p-5",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:"Hierarchy search"}),s.jsxs("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Build OR clauses like"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Goal + "MD"'})," ","or"," ",s.jsx("span",{className:"text-[var(--ui-ink-strong)]",children:'Any + "Happy"'}),". Matching ancestors keep their branches visible so you can explore the hierarchy, not lose it."]})]}),n.length>0||r.trim().length>0?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{i(""),d([]),m(0),h(!1)},children:"Clear search"}):null]}),s.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[n.length>0?s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[W(a.kind),s.jsxs("span",{className:"max-w-[14rem] truncate text-sm text-[var(--ui-ink-medium)]",children:['"',a.query,'"']}),s.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>e(a.id),"aria-label":`Remove ${a.kind} ${a.query}`,children:s.jsx(ee,{className:"size-3.5"})})]},a.id))}):null,s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(se,{className:"size-4 text-[var(--ui-ink-muted)]"}),s.jsx("input",{value:r,onChange:a=>{i(a.target.value),h(!0),m(0)},onFocus:()=>h(!0),onBlur:()=>{window.setTimeout(()=>h(!1),120)},onKeyDown:a=>{if(a.key==="Backspace"&&!r&&n.length>0){e(n[n.length-1].id);return}if(a.key==="ArrowDown"){a.preventDefault(),h(!0),m(c=>b.length===0?0:Math.min(b.length-1,c+1));return}if(a.key==="ArrowUp"){a.preventDefault(),m(c=>Math.max(0,c-1));return}if(a.key==="Escape"){h(!1);return}a.key==="Enter"&&b[v]&&(a.preventDefault(),f(b[v]))},placeholder:'Type text, then pick a clause like Goal + "MD" or Any + "Happy"',className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),y?s.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((a,c)=>s.jsx("button",{type:"button",className:F("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",c===v?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>m(c),onMouseDown:o=>o.preventDefault(),onClick:()=>f(a),children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[W(a.kind),s.jsxs("span",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:['"',a.query,'"']})]}),s.jsxs("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:["Match ",a.kind==="any"?"any visible hierarchy node":`${a.kind} nodes`," that mention this text."]})]})},a.id)):s.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Type a word or phrase to create a new OR clause."})}):null]})]}),s.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:g})]})})}function Te(){const r=ie(),i=x.useRef(null),[n,d]=x.useState(""),[g,y]=x.useState([]),[h,v]=x.useState([]),[m,b]=x.useState([...L]),[f,e]=x.useState(T),a=re({queryKey:["work-items-hierarchy",...r.selectedUserIds],queryFn:()=>de({userIds:r.selectedUserIds})}),c=x.useMemo(()=>{const t=r.snapshot.users.filter(u=>u.kind==="bot"),k=r.snapshot.users.filter(u=>u.kind==="human");return[{value:`${_.kind}bot`,label:"Bots",description:`${t.length} bot collaborators`,searchText:`bots bot ai agents assistants ${t.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:"Bots"})},{value:`${_.kind}human`,label:"Humans",description:`${k.length} human collaborators`,searchText:`humans human people operators ${k.map(u=>`${u.displayName} ${u.handle}`).join(" ")}`,badge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"}),menuBadge:s.jsx(j,{className:"border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]",children:"Humans"})},...r.snapshot.users.map(u=>({value:`${_.user}${u.id}`,label:u.displayName,description:`${u.kind}${u.handle?` · @${u.handle}`:""}`,searchText:`${u.displayName} ${u.handle} ${u.kind} ${u.description}`,badge:s.jsx(A,{user:u,compact:!0}),menuBadge:s.jsx(A,{user:u,compact:!0})}))]},[r.snapshot.users]),o=x.useMemo(()=>[{value:"goal",label:"Goal",searchText:"goal direction objective",kind:"goal"},{value:"strategy",label:"Strategy",searchText:"strategy plan sequencing",kind:"strategy"},{value:"project",label:"Project",searchText:"project initiative prd",kind:"project"},{value:"issue",label:"Issue",searchText:"issue vertical slice tracer bullet",kind:"issue"},{value:"task",label:"Task",searchText:"task execution ai session",kind:"task"},{value:"subtask",label:"Subtask",searchText:"subtask child step",badge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"}),menuBadge:s.jsx(D,{kind:"task",label:"Subtask",compact:!0,gradient:!1,className:"border-[color-mix(in_srgb,var(--tertiary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-tertiary-soft)] text-[var(--tertiary)]"})}],[]),p=x.useMemo(()=>[{value:"active",label:"Active",searchText:"active in progress live"},{value:"paused",label:"Paused",searchText:"paused suspended"},{value:"completed",label:"Completed",searchText:"completed finished"},{value:"backlog",label:"Backlog",searchText:"backlog queued"},{value:"focus",label:"Focus",searchText:"focus ready"},{value:"in_progress",label:"In progress",searchText:"in progress active doing"},{value:"blocked",label:"Blocked",searchText:"blocked stuck"},{value:"done",label:"Done",searchText:"done complete finished"}].map(t=>({...t,badge:s.jsx(j,{className:O(t.value),children:t.label}),menuBadge:s.jsx(j,{className:O(t.value),children:t.label})})),[]),M=x.useMemo(()=>new Map(r.snapshot.tags.map(t=>[t.id,t.name])),[r.snapshot.tags]),$=x.useMemo(()=>a.data?V({...a.data,tagNameById:M}):V({goals:r.snapshot.goals,strategies:r.snapshot.strategies,projects:r.snapshot.dashboard.projects,tagNameById:M,workItems:r.snapshot.workItems&&r.snapshot.workItems.length>0?r.snapshot.workItems:r.snapshot.tasks}),[a.data,r.snapshot,M]),B=n.trim().length>0||g.length>0||h.length>0||m.length!==L.length||L.some(t=>!m.includes(t))||f.length!==T.length||T.some(t=>!f.includes(t)),w=x.useMemo(()=>ue(h),[h]),l=x.useMemo(()=>{const t=$.map(k=>G(k,{clauses:g,statusFilters:m,ownerUserIds:w.userIds,ownerKinds:w.kinds,selectedUserIds:r.selectedUserIds})).filter(k=>k!==null);return Q(t,f)},[$,w.kinds,w.userIds,g,m,r.selectedUserIds,f]),N=x.useMemo(()=>K(l),[l]),U=`${g.length>0?`${g.length} OR clause${g.length===1?"":"s"} active`:"Search across the full hierarchy"} · ${N} visible node${N===1?"":"s"}.`;return a.isLoading&&$.length===0?s.jsx(ne,{eyebrow:"Hierarchy",title:"Building Forge hierarchy",description:"Loading goals, strategies, projects, issues, tasks, and subtasks into the compact hierarchy view."}):a.isError&&$.length===0?s.jsx(le,{eyebrow:"Hierarchy",error:a.error,onRetry:()=>void a.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(te,{}),s.jsx(ae,{title:"Hierarchy",description:"Explore the full Forge stack from goal to subtask in one compact operational tree, with both strategy layers visible and the same control surfaces as the board.",badge:`${N} visible nodes`}),s.jsxs(z,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hierarchy controls"}),s.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Filter across goals, projects, tags, humans, bots, and work-item types, then expand or collapse the full tree without losing the hierarchy context."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.openAll)==null?void 0:k.call(t)},children:"Expand all"}),s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{var t,k;return(k=(t=i.current)==null?void 0:t.closeAll)==null?void 0:k.call(t)},children:"Collapse all"}),B?s.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset"}):null]})]}),s.jsxs("div",{className:"grid gap-4 px-5 py-5",children:[s.jsx(be,{query:n,onQueryChange:d,clauses:g,onClausesChange:y,resultSummary:U}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsx(R,{options:p,selectedValues:m,onChange:t=>b(t),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(R,{options:o,selectedValues:f,onChange:t=>e(t),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(R,{options:c,selectedValues:h,onChange:v,placeholder:"Filter by human, bot, or collaborator",emptyMessage:"No matching collaborators."})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[l.length," top-level nodes"]}),s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N," visible nodes"]}),s.jsx(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:f.join(" + ")})]})]})]}),l.length===0?s.jsx(oe,{eyebrow:"Hierarchy",title:"No hierarchy nodes match the current filters",description:"Clear some filters or broaden the search to bring the full planning ladder back into view.",action:s.jsx(C,{variant:"secondary",onClick:()=>{d(""),y([]),v([]),b([...L]),e(T)},children:"Reset hierarchy filters"})}):s.jsxs(z,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-0",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(0,1.8fr)_auto_auto_auto] gap-3 border-b border-[var(--ui-border-subtle)] px-5 py-3 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[s.jsx("div",{children:"Name"}),s.jsx("div",{className:"hidden lg:block",children:"State"}),s.jsx("div",{className:"hidden xl:block",children:"People"}),s.jsx("div",{className:"hidden lg:block",children:"Progress"})]}),s.jsx("div",{className:"p-2",children:s.jsx(X,{ref:i,data:l,width:"100%",height:760,rowHeight:64,overscanCount:10,childrenAccessor:t=>t.children??null,openByDefault:!0,paddingTop:8,paddingBottom:8,disableDrag:!0,className:"text-sm",children:({node:t,style:k})=>{const u=t.data.kind==="subtask"?"task":t.data.kind,E=ce(u),H=E.colorToken.rgb.join(", ");return s.jsx("div",{style:k,className:"px-2 py-1.5",children:s.jsxs("div",{className:F("grid min-w-0 items-center gap-3 rounded-[16px] border border-[var(--ui-border-subtle)] px-3 py-2 transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]","grid-cols-[minmax(0,1.8fr)_auto] lg:grid-cols-[minmax(0,1.8fr)_auto_auto] xl:grid-cols-[minmax(0,1.8fr)_auto_auto_auto]"),style:{marginLeft:`${t.level*14}px`,background:`color-mix(in srgb, rgb(${H}) 7%, var(--ui-surface-1))`},children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[s.jsx("button",{type:"button",className:"inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>t.toggle(),disabled:t.isLeaf,"aria-label":t.isOpen?`Collapse ${t.data.label}`:`Expand ${t.data.label}`,children:t.isLeaf?s.jsx("span",{className:"size-2 rounded-full bg-[var(--ui-ink-muted)]"}):t.isOpen?s.jsx(Y,{className:"size-4"}):s.jsx(J,{className:"size-4"})}),s.jsx("span",{className:F("inline-flex size-9 shrink-0 items-center justify-center rounded-[12px] border",E.subtleBadgeClassName),children:s.jsx(E.icon,{className:F("size-4",E.iconClassName)})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(j,{className:xe(t.data.kind),children:t.data.kind}),t.data.executionMode?s.jsx(j,{className:t.data.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)_76%,var(--ui-ink-strong)_24%)]",children:t.data.executionMode.toUpperCase()}):null,s.jsx("div",{className:"truncate text-[13px] font-medium text-[var(--ui-ink-strong)]",children:t.data.label})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:t.data.description})]})]}),s.jsx("div",{className:"hidden lg:flex justify-end",children:s.jsx(j,{className:O(t.data.statusLabel),children:t.data.statusLabel?t.data.statusLabel.replaceAll("_"," "):"linked"})}),s.jsxs("div",{className:"hidden xl:flex items-center justify-end gap-2",children:[t.data.user?s.jsx(A,{user:t.data.user,compact:!0}):null,t.data.assignees.length>0?s.jsxs(j,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["+",t.data.assignees.length]}):null]}),s.jsxs("div",{className:"hidden lg:flex min-w-[11rem] items-center justify-end gap-3",children:[s.jsxs("div",{className:"min-w-[7.5rem]",children:[s.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:s.jsx("div",{className:"h-full rounded-full",style:{width:`${t.data.progressPercent??0}%`,background:`linear-gradient(90deg, rgb(${H}), color-mix(in srgb, rgb(${H}) 72%, var(--ui-surface-1)))`}})}),s.jsx("div",{className:"mt-1 text-[11px] text-[var(--ui-ink-faint)]",children:t.data.progressLabel??`${t.data.progressPercent??0}% complete`})]}),t.data.href?s.jsx(Z,{to:t.data.href,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Open"}):s.jsx("span",{className:"w-[3.75rem]"})]})]})})}})})]})]})}export{Te as ProjectManagementHierarchyPage};
@@ -1 +0,0 @@
1
- import{j as e,r as g,aK as X,b7 as J,aC as A}from"./vendor-BwL6m4SE.js";import{A as Y}from"./ai-surface-workspace-DtwybxJB.js";import{P as Z}from"./pill-cluster-B5bYs_e2.js";import{c as V,k as P,b as D,d as U,R as q,C as M,E as W,P as H,B as O,h as ee}from"./index-izRKx6JK.js";import{P as te,a as se,b as ae}from"./projects-boxes-BvlVsO5q.js";import{P as ie}from"./page-hero-BLhM8FF3.js";import{E as re}from"./entity-note-count-link-xne6mshj.js";import{b as ne,f as oe,P as le}from"./project-collections-FfBIVwXu.js";import{P as ce}from"./project-management-section-nav-DBNHt9p5.js";import{U as de}from"./user-badge-MEZuJiir.js";import{b as R,d as F}from"./user-ownership-DJGl4rAj.js";import"./board-CuxQRKPJ.js";import"./state-Bpe5dF3T.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./forms-D1qJ3oOP.js";import"./generic-node-view-DNVwfqqq.js";import"./graph-BF4IsheG.js";import"./define-workbench-box-DcI0_QKW.js";function ue({children:s,columns:d="single",className:w}){return e.jsx("section",{className:V("grid gap-4",d==="two"&&"lg:grid-cols-2",d==="sidebar"&&"xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",w),children:s})}function me(s){return s.trim().toLowerCase()}function Q(s,d=!1){switch(s.kind){case"goal":return e.jsx(D,{kind:"goal",label:s.label,compact:!0,gradient:!1});case"task":return e.jsx(D,{kind:"task",label:s.label,compact:!0,gradient:!1});case"tag":return e.jsx(P,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.label});case"status":return e.jsx(P,{className:"bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]",children:s.label});case"type":return e.jsx(P,{className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:s.label});case"user":return e.jsx(P,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:s.label});default:return s.label}}function he({query:s,onQueryChange:d,options:w,selectedOptionIds:m,onSelectedOptionIdsChange:I,resultSummary:C}){const[L,j]=g.useState(!1),[T,p]=g.useState(0),N=g.useMemo(()=>m.map(n=>w.find(l=>l.id===n)).filter(Boolean),[w,m]),S=me(s),b=g.useMemo(()=>{const n=w.filter(l=>!m.includes(l.id));return S?n.filter(l=>`${l.label} ${l.description??""} ${l.searchText??""}`.toLowerCase().includes(S)).slice(0,10):n.slice(0,10)},[S,w,m]),k=n=>{m.includes(n)||(I([...m,n]),d(""),p(0),j(!1))},B=n=>{I(m.filter(l=>l!==n))},K=()=>{d(""),I([]),p(0),j(!1)};return e.jsx("div",{className:"grid gap-3",children:e.jsxs("div",{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 shadow-[var(--ui-shadow-soft)] sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Project search"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search with free text, then pin matching goals, tasks, tags, human users, bot users, statuses, or project-type chips as you narrow the list."})]}),s.trim().length>0||m.length>0?e.jsx("button",{type:"button",onClick:K,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:"Clear search"}):null]}),e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[N.length>0?e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:N.map(n=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[Q(n,!0),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>B(n.id),"aria-label":`Remove ${n.label}`,children:e.jsx(X,{className:"size-3.5"})})]},n.id))}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx("input",{value:s,onChange:n=>{d(n.target.value),j(!0),p(0)},onFocus:()=>j(!0),onBlur:()=>{window.setTimeout(()=>j(!1),120)},onKeyDown:n=>{if(n.key==="Backspace"&&!s&&m.length>0){B(m[m.length-1]);return}if(n.key==="ArrowDown"){n.preventDefault(),j(!0),p(l=>b.length===0?0:Math.min(b.length-1,l+1));return}if(n.key==="ArrowUp"){n.preventDefault(),p(l=>Math.max(0,l-1));return}if(n.key==="Escape"){j(!1);return}n.key==="Enter"&&b[T]&&(n.preventDefault(),k(b[T].id))},placeholder:"Type a project, goal, task, human, bot, user, or tag",className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),L?e.jsx("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-strong)] backdrop-blur-xl",children:b.length>0?b.map((n,l)=>e.jsx("button",{type:"button",className:V("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",l===T?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>p(l),onMouseDown:E=>E.preventDefault(),onClick:()=>k(n.id),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:Q(n)}),n.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-soft)]",children:n.description}):null]})},n.id)):e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Keep typing to search by free text, or select a suggested goal, task, human or bot owner, tag, status, or type chip when it appears."})}):null]})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:C})]})})}const pe={execution:"Execution",value:"Value",category:"Category"};function xe(s){return s.trim().toLowerCase()}function ze(){const s=U(),[d,w]=g.useState("active"),[m,I]=g.useState(""),[C,L]=g.useState([]),[j,T]=g.useState(null),p=g.useMemo(()=>ne(s.snapshot.dashboard.projects),[s.snapshot.dashboard.projects]),N=g.useMemo(()=>{const a=new Map(s.snapshot.dashboard.goals.map(r=>[r.id,r])),o=new Map(s.snapshot.tags.map(r=>[r.id,r])),u=new Map(s.snapshot.users.map(r=>[r.id,r])),f=new Map;for(const r of s.snapshot.tasks){if(!r.projectId)continue;const x=f.get(r.projectId)??[];x.push(r),f.set(r.projectId,x)}return new Map(s.snapshot.dashboard.projects.map(r=>{const x=a.get(r.goalId)??null,$=f.get(r.id)??[],v=r.userId?u.get(r.userId)??null:null,y=new Map;for(const c of(x==null?void 0:x.tags)??[])y.set(c.id,{id:c.id,name:c.name,kind:c.kind});for(const c of $)for(const t of c.tagIds){const i=o.get(t);i&&y.set(i.id,{id:i.id,name:i.name,kind:i.kind})}const _=Array.from(new Set(Array.from(y.values()).map(c=>c.kind))),z=[r.title,r.description,r.goalTitle,(v==null?void 0:v.displayName)??"",(v==null?void 0:v.handle)??"",(v==null?void 0:v.kind)??"",(x==null?void 0:x.description)??"",r.nextTaskTitle??"",r.momentumLabel,r.status,$.map(c=>c.title).join(" "),Array.from(y.values()).map(c=>`${c.name} ${c.kind}`).join(" ")].join(" ").toLowerCase();return[r.id,{tagIds:Array.from(y.keys()),tags:Array.from(y.values()),taskIds:$.map(c=>c.id),typeKeys:_,userId:r.userId,searchText:z}]}))},[s.snapshot.dashboard.goals,s.snapshot.dashboard.projects,s.snapshot.tags,s.snapshot.tasks,s.snapshot.users]),S=g.useMemo(()=>{var v,y,_,z,c;const a=new Map,o=new Map,u=new Map,f=new Map,r=new Map,x=new Map,$=new Map;for(const t of s.snapshot.dashboard.projects){const i=N.get(t.id);if(i){o.has(t.goalId)||o.set(t.goalId,new Set),o.get(t.goalId).add(t.id),r.has(t.status)||r.set(t.status,new Set),r.get(t.status).add(t.id);for(const h of i.taskIds)u.has(h)||u.set(h,new Set),u.get(h).add(t.id);for(const h of i.tags)f.has(h.id)||f.set(h.id,new Set),f.get(h.id).add(t.id);for(const h of i.typeKeys)x.has(h)||x.set(h,new Set),x.get(h).add(t.id);i.userId&&($.has(i.userId)||$.set(i.userId,new Set),$.get(i.userId).add(t.id))}}for(const t of s.snapshot.dashboard.goals){const i=((v=o.get(t.id))==null?void 0:v.size)??0;i!==0&&a.set(`goal:${t.id}`,{id:`goal:${t.id}`,kind:"goal",value:t.id,label:t.title,description:F(`${i} project${i===1?"":"s"} linked to this goal`,t.user,`${i} project${i===1?"":"s"} linked to this goal`),searchText:R([t.title,t.description],t)})}for(const t of s.snapshot.tasks){const i=((y=u.get(t.id))==null?void 0:y.size)??0;i!==0&&a.set(`task:${t.id}`,{id:`task:${t.id}`,kind:"task",value:t.id,label:t.title,description:F(`${i} project${i===1?"":"s"} linked to this task`,t.user,`${i} project${i===1?"":"s"} linked to this task`),searchText:R([t.title,t.description],t)})}for(const t of s.snapshot.tags){const i=((_=f.get(t.id))==null?void 0:_.size)??0;i!==0&&a.set(`tag:${t.id}`,{id:`tag:${t.id}`,kind:"tag",value:t.id,label:t.name,description:F(`${i} project${i===1?"":"s"} touching this tag`,t.user,`${i} project${i===1?"":"s"} touching this tag`),searchText:R([t.name,t.kind,t.description],t)})}for(const[t,i]of Object.entries(p))t==="all"||i===0||a.set(`status:${t}`,{id:`status:${t}`,kind:"status",value:t,label:t==="paused"?"Suspended":t==="completed"?"Finished":"Active",description:`${i} project${i===1?"":"s"} currently ${t==="paused"?"suspended":t==="completed"?"finished":"active"}`,searchText:`${t} ${t==="paused"?"suspended":""} ${t==="completed"?"finished":""}`});for(const[t,i]of Object.entries(pe)){const h=((z=x.get(t))==null?void 0:z.size)??0;h!==0&&a.set(`type:${t}`,{id:`type:${t}`,kind:"type",value:t,label:i,description:`${h} project${h===1?"":"s"} linked to ${i.toLowerCase()} tags`,searchText:`${i} ${t} project type`})}for(const t of s.snapshot.users){const i=((c=$.get(t.id))==null?void 0:c.size)??0;i!==0&&a.set(`user:${t.id}`,{id:`user:${t.id}`,kind:"user",value:t.id,label:t.displayName,description:`${i} project${i===1?"":"s"} owned by this ${t.kind}`,searchText:`${t.displayName} ${t.handle} ${t.kind} ${t.description}`})}return Array.from(a.values()).sort((t,i)=>t.label.localeCompare(i.label))},[p,N,s.snapshot.dashboard.goals,s.snapshot.dashboard.projects,s.snapshot.tags,s.snapshot.tasks,s.snapshot.users]),b=g.useMemo(()=>C.map(a=>S.find(o=>o.id===a)).filter(Boolean),[S,C]),k=g.useMemo(()=>{const a=xe(m);return oe(s.snapshot.dashboard.projects,d).filter(o=>{const u=N.get(o.id);return!u||!b.every(r=>{switch(r.kind){case"goal":return o.goalId===r.value;case"task":return u.taskIds.includes(r.value);case"tag":return u.tagIds.includes(r.value);case"status":return o.status===r.value;case"type":return u.typeKeys.includes(r.value);case"user":return u.userId===r.value;default:return!0}})?!1:a?u.searchText.includes(a):!0})},[d,N,m,b,s.snapshot.dashboard.projects]),B=d==="all"?p.all:p[d],n=m.trim().length>0||C.length>0?`${k.length} matching project${k.length===1?"":"s"} in the current collection view`:`${B} project${B===1?"":"s"} in ${d==="all"?"all project states":d==="paused"?"the suspended view":d==="completed"?"the finished view":"the active view"}`,l=async a=>{T(a);try{await s.patchProject(a,{status:"active"})}finally{T(null)}},E=e.jsx(ue,{columns:"two",className:"2xl:grid-cols-3",children:k.map(a=>{const o=q(s.snapshot.dashboard.notesSummaryByEntity,"project",a.id),u=N.get(a.id),f=(u==null?void 0:u.tags.slice(0,3))??[];return e.jsxs(M,{className:"flex h-full flex-col transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(D,{kind:"goal",label:a.goalTitle,compact:!0}),e.jsx(de,{user:a.user,compact:!0})]}),e.jsx(P,{className:a.status==="completed"?"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":a.status==="paused"?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:a.status==="paused"?"Suspended":a.status==="completed"?"Finished":"Active"})]}),e.jsx("div",{className:"mt-4",children:e.jsx(A,{to:`/projects/${a.id}`,className:"transition hover:opacity-90",children:e.jsx(W,{kind:"project",label:a.title,variant:"heading",size:"xl",lines:2})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),f.length>0?e.jsx(Z,{className:"mt-4",children:f.map(r=>e.jsx(P,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r.name},r.id))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(H,{value:a.progress,tone:a.status==="completed"?"secondary":"primary"})}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.activeTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Completed"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.completedTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP"}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-strong)]",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-5 break-words text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:a.nextTaskTitle?`Next move: ${a.nextTaskTitle}`:"Ready for the next task"}),e.jsx("div",{className:"mt-4",children:e.jsx(re,{entityType:"project",entityId:a.id,count:o.count})}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-3 pt-1",children:[e.jsx(A,{to:`/projects/${a.id}`,children:e.jsx(O,{variant:"ghost",children:"Open project"})}),d!=="active"&&a.status!=="active"?e.jsx(O,{variant:"secondary",pending:j===a.id,pendingLabel:"Restarting…",onClick:()=>void l(a.id),children:"Restart"}):null]})]},a.id)})}),G=[{id:"hero",title:"Projects",description:"Route header",defaultWidth:12,defaultHeight:2,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(te,{children:e.jsx(ie,{entityKind:"project",title:e.jsx(W,{kind:"project",label:"Projects",variant:"heading",size:"lg"}),titleText:"Projects",description:"Projects are the concrete paths that move a life goal forward.",badge:`${s.snapshot.dashboard.projects.length} total projects`})})},{id:"search-results",title:"Search and results",description:"Search stays grouped with its live result set.",defaultWidth:8,defaultHeight:6,minWidth:6,render:({compact:a})=>e.jsx(se,{children:e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(he,{query:m,onQueryChange:I,options:S,selectedOptionIds:C,onSelectedOptionIdsChange:L,resultSummary:n}),e.jsx(le,{value:d,counts:p,onChange:w}),k.length===0?e.jsxs(M,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"No matching projects"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Nothing in this project collection matches the current search and chips."})]}):a?e.jsx("div",{className:"grid min-w-0 gap-3",children:k.slice(0,5).map(o=>e.jsx(A,{to:`/projects/${o.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:o.title}),e.jsx("div",{className:"truncate text-sm text-[var(--ui-ink-soft)]",children:o.goalTitle})]}),e.jsxs(P,{wrap:!0,className:"max-w-[7rem] shrink-0 bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[o.earnedPoints," xp"]})]})},o.id))}):E]})})},{id:"summary",title:"Collection summary",description:"Counts and spotlight cards.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>{const a=k[0]??s.snapshot.dashboard.projects[0]??null;return e.jsx(ae,{children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-1",children:[e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:p.active})]}),e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Finished"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:p.completed})]})]}),a?e.jsxs(M,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spotlight"}),e.jsx("div",{className:"mt-3 text-base font-semibold text-[var(--ui-ink-strong)]",children:a.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),e.jsx("div",{className:"mt-3",children:e.jsx(H,{value:a.progress})})]}):null]})})}}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ce,{}),s.snapshot.dashboard.projects.length===0?e.jsx(ee,{eyebrow:"Projects",title:"No projects in flight",description:"Create the first practical path under a life goal so execution, kanban, and evidence all have a concrete home.",action:e.jsx(A,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-surface-2)] px-4 py-3 text-sm whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"})}):e.jsx(Y,{surfaceId:"projects",baseWidgets:G})]})}export{ze as ProjectsPage};
@@ -1,5 +0,0 @@
1
- import{j as t,aC as pe,bW as ye,bY as ve,r as v}from"./vendor-BwL6m4SE.js";import{j as ge,i as g,k as fe}from"./state-Bpe5dF3T.js";import{Q as be,F as i}from"./question-flow-dialog-D-_EvoAt.js";import{E as xe}from"./entity-note-count-link-xne6mshj.js";import{A as V}from"./atlas-panel-CB3uYk_K.js";import{E as S}from"./entity-link-multiselect-C--AiCMb.js";import{d as we,L as je,e as ke,B as P,E as Ce,bs as Ie,k as Se,R as Pe,c as G,bM as Ne,bN as Te,I as Be,T as d,bO as Le,bP as Me,bQ as Ee,b5 as Fe,b4 as Oe,b3 as qe,bR as Qe,b7 as Re}from"./index-izRKx6JK.js";import{S as H}from"./schema-badge-BLaVI1D7.js";import{u as Ae,p as De}from"./use-psyche-focus-target-BhNedCZB.js";import{P as Ue}from"./page-hero-BLhM8FF3.js";import{U as Ke}from"./user-badge-MEZuJiir.js";import{U as We}from"./user-select-field-fx129Uh6.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{b as J}from"./psyche-schemas-DDol0j-g.js";import{g as _e}from"./schema-visuals-CvC9a3i6.js";import{g as $e,b as T,d as B,e as L,a as ze}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function Ve({entries:s}){const n={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return t.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:s.map(o=>t.jsxs(pe,{to:o.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${n[o.tone]}`,children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:o.tone}),t.jsx("div",{className:"mt-2 font-medium text-white",children:o.title}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.summary}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",t.jsx(ye,{className:"size-3.5"})]})]},o.id))})}const f={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:null};function Ge(s){return{kind:s.kind,title:s.title,description:s.description,commonCues:s.commonCues,urgeStory:s.urgeStory,shortTermPayoff:s.shortTermPayoff,longTermCost:s.longTermCost,replacementMove:s.replacementMove,repairPlan:s.repairPlan,linkedPatternIds:s.linkedPatternIds,linkedValueIds:s.linkedValueIds,linkedSchemaIds:s.linkedSchemaIds,linkedModeIds:s.linkedModeIds,userId:s.userId??null}}const Y={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function vt(){var q,Q,R,A,D,U,K,W,_,$,z;const s=we(),n=ge(),[o,M]=ve(),[X,c]=v.useState(!1),[m,p]=v.useState(null),[y,h]=v.useState(f),[Z,b]=v.useState(null),x=g({queryKey:["forge-psyche-behaviors"],queryFn:Fe}),w=g({queryKey:["forge-psyche-patterns"],queryFn:Oe}),j=g({queryKey:["forge-psyche-values"],queryFn:qe}),k=g({queryKey:["forge-psyche-schema-catalog"],queryFn:Qe}),C=g({queryKey:["forge-psyche-modes"],queryFn:Re}),I=((q=x.data)==null?void 0:q.behaviors)??[],ee=((Q=w.data)==null?void 0:Q.patterns)??[],te=((R=j.data)==null?void 0:R.values)??[],ae=((A=k.data)==null?void 0:A.schemas)??[],re=((D=C.data)==null?void 0:D.modes)??[],u=$e(s.selectedUserIds),E=o.get("focus"),se=s.snapshot.dashboard.notesSummaryByEntity;Ae(E),v.useEffect(()=>{if(o.get("create")==="1"){c(!0),p(null),h({...f,userId:u});const e=new URLSearchParams(o);e.delete("create"),M(e,{replace:!0})}},[u,o,M]);const F=fe({mutationFn:async e=>{const a=J.parse(e);return m?Ne(m.id,a):Te(a)},onSuccess:async()=>{c(!1),p(null),h({...f,userId:u}),b(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),ie=ee.map(e=>({value:e.id,label:L(e.title,e.user),description:B(e.preferredResponse||e.targetBehavior,e.user),searchText:T([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),oe=te.map(e=>({value:e.id,label:L(e.title,e.user),description:B(e.valuedDirection,e.user),searchText:T([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=ae.map(e=>({value:e.id,label:e.title,description:`${e.description} ${_e(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0})})),le=re.map(e=>({value:e.id,label:L(e.title,e.user),description:B(e.archetype||e.family,e.user),searchText:T([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),de=async e=>{const{pattern:a}=await Le({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return N(n,["forge-psyche-patterns"],"patterns",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},ce=async e=>{const{value:a}=await Me({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return N(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},me=async e=>{const{mode:a}=await Ee({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:y.userId});return N(n,["forge-psyche-modes"],"modes",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.archetype||a.family,kind:"mode"}},he=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(We,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:ze(s.snapshot.users.find(r=>r.id===u)??null,"Choose behavior owner"),help:"Behaviors can belong to a human or bot user while still linking across shared patterns, schemas, and modes."}),t.jsx(i,{label:"Behavior title",children:t.jsx(Be,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"Scroll to numb the impact"})}),t.jsx(i,{label:"What does the move look like?",children:t.jsx(d,{value:e.description,onChange:r=>a({description:r.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Common cues",children:t.jsx(d,{value:e.commonCues.join(`
2
- `),onChange:r=>a({commonCues:r.target.value.split(`
3
- `).map(ue=>ue.trim()).filter(Boolean)}),placeholder:`One line per cue
4
- Late-night ambiguity
5
- Feedback after a hard week`})}),t.jsx(i,{label:"What inner push or story shows up?",children:t.jsx(d,{value:e.urgeStory,onChange:r=>a({urgeStory:r.target.value}),placeholder:"What inner push or justification tends to appear?"})}),t.jsx(i,{label:"What do you get right away from this move?",children:t.jsx(d,{value:e.shortTermPayoff,onChange:r=>a({shortTermPayoff:r.target.value}),placeholder:"What relief, certainty, distance, or control does it give in the short term?"})})]})},{id:"classification",eyebrow:"Classification",title:"Now classify the move and define the return path",description:"Once the move is clear, decide whether it is an away move, a committed action, or a recovery path.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Move type",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["away","committed","recovery"].map(r=>t.jsx("button",{type:"button",className:G("rounded-[8px] border px-4 py-4 text-left transition",e.kind===r?"border-[color-mix(in_srgb,var(--primary)_40%,var(--ui-border-subtle)_60%)] bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a({kind:r}),children:Y[r]},r))})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"What does it cost over time?",children:t.jsx(d,{value:e.longTermCost,onChange:r=>a({longTermCost:r.target.value}),placeholder:"What does this move cost over time?"})}),t.jsx(i,{label:"What move should replace or steady it?",children:t.jsx(d,{value:e.replacementMove,onChange:r=>a({replacementMove:r.target.value}),placeholder:"What move should replace this one when possible?"})})]}),t.jsx(i,{label:"If the slip happens, how do you repair and return?",children:t.jsx(d,{value:e.repairPlan,onChange:r=>a({repairPlan:r.target.value}),placeholder:"Describe the repair path without shame or collapse."})})]})},{id:"links",eyebrow:"Links",title:"Attach the move to patterns, values, schemas, and modes",description:"This turns the move into part of the full graphical psyche system.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Linked patterns",children:t.jsx(S,{options:ie,selectedValues:e.linkedPatternIds,onChange:r=>a({linkedPatternIds:r}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:de})}),t.jsx(i,{label:"Linked values",children:t.jsx(S,{options:oe,selectedValues:e.linkedValueIds,onChange:r=>a({linkedValueIds:r}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Linked schemas",children:t.jsx(S,{options:ne,selectedValues:e.linkedSchemaIds,onChange:r=>a({linkedSchemaIds:r}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),t.jsx(i,{label:"Linked modes",children:t.jsx(S,{options:le,selectedValues:e.linkedModeIds,onChange:r=>a({linkedModeIds:r}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]})]})}];if(x.isLoading||w.isLoading||j.isLoading||k.isLoading||C.isLoading)return t.jsx(je,{eyebrow:"Behaviors",title:"Loading behaviors",description:"Getting behaviors, patterns, values, schemas, and modes ready."});const O=x.error??w.error??j.error??k.error??C.error;if(O)return t.jsx(ke,{eyebrow:"Psyche behaviors",error:O,onRetry:()=>void Promise.all([x.refetch(),w.refetch(),j.refetch(),k.refetch(),C.refetch()])});const l={away:I.filter(e=>e.kind==="away"),committed:I.filter(e=>e.kind==="committed"),recovery:I.filter(e=>e.kind==="recovery")};return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Ue,{entityKind:"behavior",title:t.jsx(Ce,{kind:"behavior",label:"Behaviors",variant:"heading",size:"lg"}),description:"Group behaviors by what pulls you away, what moves you toward your values, and what helps you recover after a slip.",badge:`${I.length} mapped`,actions:t.jsx(P,{onClick:()=>{p(null),h({...f,userId:u}),c(!0)},children:"Add behavior"})}),t.jsx(Ie,{}),t.jsx(V,{eyebrow:"Overview",title:"Behavior summary",description:"This summary keeps the three behavior types visible together: away, committed, and recovery.",tone:"amber",children:t.jsx(Ve,{entries:[{id:"away",title:((U=l.away[0])==null?void 0:U.title)??"No away move mapped yet",summary:((K=l.away[0])==null?void 0:K.replacementMove)||"Map the move that tends to pull you away first.",href:"#behavior-columns",tone:"away"},{id:"committed",title:((W=l.committed[0])==null?void 0:W.title)??"No committed action mapped yet",summary:((_=l.committed[0])==null?void 0:_.replacementMove)||"Map the move you want to practice instead.",href:"#behavior-columns",tone:"committed"},{id:"recovery",title:(($=l.recovery[0])==null?void 0:$.title)??"No recovery move mapped yet",summary:((z=l.recovery[0])==null?void 0:z.repairPlan)||"Map how you return after a slip without turning it into collapse.",href:"#behavior-columns",tone:"recovery"}]})}),t.jsx(V,{eyebrow:"Behaviors",title:"Behaviors by type",description:"Use these columns to separate what pulls you off course, what helps you move toward your values, and what helps you recover.",tone:"default",children:t.jsx("div",{id:"behavior-columns",className:"grid gap-4 xl:grid-cols-3",children:["away","committed","recovery"].map(e=>t.jsxs("div",{className:"grid min-w-0 gap-3 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:Y[e]}),t.jsx(Se,{children:l[e].length})]}),l[e].length===0?t.jsx("div",{className:"flex",children:t.jsxs(P,{variant:"secondary",onClick:()=>{p(null),h({...f,userId:u}),c(!0)},children:["Add"," ",e==="away"?"away move":e==="committed"?"committed action":"recovery move"]})}):l[e].map(a=>t.jsxs("div",{"data-psyche-focus-id":a.id,className:G("min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-hover)]",De(E===a.id)),children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.title}),a.user?t.jsx(Ke,{user:a.user,compact:!0}):null]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(xe,{entityType:"behavior",entityId:a.id,count:Pe(se,"behavior",a.id).count}),t.jsx(P,{variant:"secondary",size:"sm",onClick:()=>{p(a),h(Ge(a)),c(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description}),t.jsx("div",{className:"mt-3 break-words text-sm text-[var(--ui-ink-faint)]",children:a.replacementMove||a.repairPlan||"No recovery step recorded yet."})]},a.id))]},e))})}),t.jsx(be,{open:X,onOpenChange:c,eyebrow:"Behavior",title:m?"Refine behavior path":"Create behavior",description:"Use this guided flow to describe the behavior, when it shows up, what it gives you, and what kind of move it is.",value:y,onChange:h,draftPersistenceKey:m?`psyche.behavior.${m.id}`:"psyche.behavior.new",steps:he,submitLabel:m?"Save behavior":"Create behavior",pending:F.isPending,error:Z,onSubmit:async()=>{b(null);const e=J.safeParse(y);if(!e.success){b("This behavior still needs a kind and a title before it can be saved.");return}try{await F.mutateAsync(e.data)}catch(a){b(a instanceof Error?a.message:"Unable to save this behavior right now.")}}})]})}export{vt as PsycheBehaviorsPage};
@@ -1 +0,0 @@
1
- import{j as e,aC as b}from"./vendor-BwL6m4SE.js";import{j as N,i as k,k as S}from"./state-Bpe5dF3T.js";import{u as w}from"./forms-D1qJ3oOP.js";import{L as C,e as _,B as d,bs as M,C as r,h as f,k as j,bW as P,bX as q}from"./index-izRKx6JK.js";import{P as L}from"./page-hero-BLhM8FF3.js";import{m as Q}from"./psyche-schemas-DDol0j-g.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";function R(s){return s instanceof Error?s:typeof s=="string"&&s.trim().length>0?new Error(s):new Error("Forge could not complete the requested query collection.")}function E(s){const t=s.find(i=>i.isError);return{isLoading:s.some(i=>i.isPending||i.isLoading),error:t?R(t.error):null}}async function F(s){await Promise.all(s.map(t=>t.refetch()))}const n={copingResponse:[{value:"fight",label:"Fight"},{value:"flight",label:"Flight"},{value:"freeze",label:"Freeze"},{value:"detach",label:"Detach"},{value:"comply",label:"Comply"},{value:"overcompensate",label:"Overcompensate"},{value:"none",label:"Mixed / unsure"}],childState:[{value:"vulnerable",label:"Vulnerable"},{value:"angry",label:"Angry"},{value:"impulsive",label:"Impulsive"},{value:"lonely",label:"Lonely"},{value:"ashamed",label:"Ashamed"},{value:"none",label:"Mixed / unsure"}],criticStyle:[{value:"demanding",label:"Demanding"},{value:"punitive",label:"Punitive"},{value:"none",label:"Neither / unclear"}],healthyContact:[{value:"healthy_adult",label:"Healthy adult"},{value:"happy_child",label:"Happy child"},{value:"none",label:"Hard to access right now"}]};function O(){var p,h,x,g,v,y;const s=N(),t=k({queryKey:["forge-psyche-mode-guide-sessions"],queryFn:q}),i=w({defaultValues:{summary:"What mode was most present in this moment?",copingResponse:"none",childState:"none",criticStyle:"none",healthyContact:"none"}}),o=S({mutationFn:async a=>{const l=Q.parse({summary:a.summary,answers:[{questionKey:"coping_response",value:a.copingResponse},{questionKey:"child_state",value:a.childState},{questionKey:"critic_style",value:a.criticStyle},{questionKey:"healthy_contact",value:a.healthyContact}]});return P(l)},onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-psyche-mode-guide-sessions"]})}}),u=[t],c=E(u),m=((p=o.data)==null?void 0:p.session)??((x=(h=t.data)==null?void 0:h.sessions)==null?void 0:x[0]);return c.isLoading?e.jsx(C,{eyebrow:"Mode guide",title:"Loading guided sessions",description:"Hydrating previous mode-guide runs and the latest stored readings."}):c.error?e.jsx(_,{eyebrow:"Mode guide",error:c.error,onRetry:()=>void F(u)}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(L,{eyebrow:"Mode guide",title:"Guided Mode Identification",description:"A short guided pass can help separate coping responses, child states, critic pressure, and whatever healthy contact is still available.",badge:`${((g=t.data)==null?void 0:g.sessions.length)??0} sessions`,actions:e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Back to mode map"})})}),e.jsx(M,{}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Guided questionnaire"}),e.jsxs("form",{className:"mt-4 grid gap-5",onSubmit:i.handleSubmit(async a=>o.mutateAsync(a)),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Prompt"}),e.jsx("input",{className:"w-full rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none placeholder:text-[var(--ui-ink-muted)]",...i.register("summary")})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-danger-soft)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"When the pressure rose, what coping move dominated?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.copingResponse.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("copingResponse")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[color-mix(in_srgb,var(--primary)_8%,var(--ui-surface-1)_92%)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Which child state felt closest?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.childState.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("childState")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What was the critic like?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.criticStyle.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("criticStyle")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What healthy contact was still reachable?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.healthyContact.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("healthyContact")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]})]}),e.jsx(d,{type:"submit",children:"Run guide"})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest reading"}),m?e.jsxs("div",{className:"mt-4 grid gap-3",children:[m.results.map(a=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] 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:a.label}),e.jsxs(j,{className:"text-[var(--ui-ink-medium)]",children:[Math.round(a.confidence*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:a.family.replaceAll("_"," ")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.reasoning})]},`${a.family}:${a.label}`)),e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Use this in the mode map"})})]}):e.jsx("div",{className:"mt-4",children:e.jsx(f,{eyebrow:"Guided reading",title:"No guided sessions yet",description:"Run the guide once to separate coping response, child state, critic pressure, and reachable healthy contact."})})]}),e.jsxs(r,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Session history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((v=t.data)==null?void 0:v.sessions)??[]).length===0?e.jsx(f,{eyebrow:"Session history",title:"No stored guide history",description:"Completed guide sessions will accumulate here so later mode-map work can build from real prior readings."}):(((y=t.data)==null?void 0:y.sessions)??[]).map(a=>e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.results.map(l=>e.jsx(j,{className:"text-[var(--ui-ink-medium)]",children:l.label},`${a.id}:${l.label}`))})]},a.id))})]})]})]})]})}export{O as PsycheModeGuidePage};