forge-openclaw-plugin 0.2.102 → 0.2.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/{ai-surface-workspace-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
  3. package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
  4. package/dist/assets/{board-DqHzdCPQ.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/{calendar-week-toolbar-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
  8. package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
  15. package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-CmLAyGqz.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/{insight-flow-dialog-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
  32. package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
  35. package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
  39. package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
  40. package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-DogvVNEn.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/{psyche-behaviors-page-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
  50. package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
  51. package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
  52. package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
  53. package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
  55. package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
  56. package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
  57. package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
  58. package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
  59. package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
  60. package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
  61. package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
  62. package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
  63. package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
  64. package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
  65. package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
  67. package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
  68. package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
  69. package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
  70. package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
  74. package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
  75. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  76. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  77. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  78. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  79. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  80. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  81. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  82. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  83. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  84. package/dist/assets/{settings-section-nav-Dc4IeVBt.js → settings-section-nav-DP9o4peU.js} +1 -1
  85. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  86. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  87. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  88. package/dist/assets/sports-page-BldIiclr.js +1 -0
  89. package/dist/assets/{state-VYvD1QVP.js → state-vCcAT5Hq.js} +1 -1
  90. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  91. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  92. package/dist/assets/{strategy-dialog-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
  93. package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
  94. package/dist/assets/{table-C0VTeqw0.js → table-BNqMG3_S.js} +1 -1
  95. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  96. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  97. package/dist/assets/today-page-BjDijtn8.js +1 -0
  98. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  99. package/dist/assets/{ui-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
  100. package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
  101. package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
  102. package/dist/assets/{vitals-page-Dz1Jt5H8.js → vitals-page-CE9zdGLF.js} +1 -1
  103. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  104. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  105. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  106. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  107. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  108. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  109. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  110. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  111. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  112. package/dist/assets/{workout-detail-page-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
  113. package/dist/index.html +9 -9
  114. package/dist/server/server/src/app.js +22 -3
  115. package/dist/server/server/src/health-weight-loss.js +114 -39
  116. package/dist/server/server/src/repositories/model-settings.js +9 -3
  117. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  118. package/dist/server/src/lib/api.js +10 -1
  119. package/openclaw.plugin.json +1 -1
  120. package/package.json +1 -1
  121. package/dist/assets/activity-page-CgF7K2ww.js +0 -1
  122. package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
  123. package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
  124. package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
  125. package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
  126. package/dist/assets/execution-board-CpO2ch6v.js +0 -1
  127. package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
  128. package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
  129. package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
  130. package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
  131. package/dist/assets/index-BHIKoiZ6.js +0 -19
  132. package/dist/assets/index-H8R-ABM3.css +0 -1
  133. package/dist/assets/insights-page-CujrosD_.js +0 -8
  134. package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
  135. package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
  136. package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
  137. package/dist/assets/movement-page-ClaoTNuX.js +0 -1
  138. package/dist/assets/notes-page-DYI8s3NN.js +0 -1
  139. package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
  140. package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
  141. package/dist/assets/project-collections-CZagCmeH.js +0 -1
  142. package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
  143. package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
  144. package/dist/assets/projects-page-UKrby_5-.js +0 -1
  145. package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
  146. package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
  147. package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
  148. package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
  149. package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
  150. package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
  151. package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
  152. package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
  153. package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
  154. package/dist/assets/settings-page-B4u5TR5g.js +0 -1
  155. package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
  156. package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
  157. package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
  158. package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
  159. package/dist/assets/sports-page-l1RqXzA_.js +0 -1
  160. package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
  161. package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
  162. package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
  163. package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
  164. package/dist/assets/today-page-CIuFHMi1.js +0 -1
  165. package/dist/assets/training-load-page-BIwc648i.js +0 -1
  166. package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
  167. package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
  168. package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
  169. package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
  170. package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
  171. package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
  172. package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
  173. package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
  174. package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
@@ -1 +1 @@
1
- import{r as E,j as e,aC as S}from"./vendor-kIz9EZnX.js";import{A as U}from"./ai-surface-workspace-xtB5RFQu.js";import{i as $}from"./state-VYvD1QVP.js";import{P as B,u as Q,bE as z,h as R,d as L,bF as D,c as p,aq as G,Z as J,C as M,b as Y,V as Z,W as ee,_ as te,bG as ie,bH as se,bI as ae,bJ as re,bK as ne,bL as le,bM as oe,be as de,bN as ce}from"./index-BHIKoiZ6.js";import{F as ue}from"./flagship-signal-deck-BEFKOhvx.js";import{L as me}from"./life-force-workspace-CLVexVnb.js";import{E as pe}from"./entity-note-count-link-BrS1-O0o.js";import{P as fe}from"./page-hero-oFHaAjtL.js";import{a as ve,g as xe}from"./activity-copy-Bj4h9OcF.js";import"./board-DqHzdCPQ.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./graph-BTa79qum.js";import"./floating-action-menu-zzC2r0Ob.js";import"./charts-FcU0F3XV.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 y=t.indexOf(v);y!==-1&&t.splice(y,1)}const b=t.indexOf("goals");return t.splice(b===-1?0:b,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 be(a){return a>=1e3?`${(a/1e3).toFixed(1)} km`:`${Math.round(a)} m`}function ye(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 Ee(){var X,C;const{t:a}=B(),n=Q(),t=n.snapshot,r=Array.isArray(n.selectedUserIds)?n.selectedUserIds:[],j=r.join("|"),[c,x]=E.useState(!1);E.useEffect(()=>{x(!1);const i=window.setTimeout(()=>{x(!0)},650);return()=>window.clearTimeout(i)},[j]);const g=ge(),b=$({queryKey:["forge-overview-sleep",...r],queryFn:async()=>(await le(r)).sleep,enabled:c,staleTime:6e4})??{},v=$({queryKey:["forge-overview-fitness",...r],queryFn:async()=>(await oe(r)).fitness,enabled:c,staleTime:6e4})??{},y=$({queryKey:["forge-overview-movement-day",g,...r],queryFn:async()=>(await de({date:g,userIds:r})).movement,enabled:c,staleTime:6e4})??{},H=$({queryKey:["forge-overview-vitals",...r],queryFn:async()=>(await ce(r)).vitals,enabled:c,staleTime:6e4})??{},I=z(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=b.data)==null?void 0:X.summary)??null,h=((C=v.data)==null?void 0:C.summary)??null,l=y.data,F=H.data??null,A=ke(F??void 0),O=ye(l),T=k!==null||h!==null||F!==null,W=l!==void 0&&(l.summary.tripCount>0||l.summary.stayCount>0||l.summary.totalMovingSeconds>0||O.length>0),K=t.lifeForce?[{label:"Life Force",value:`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP`,detail:`Remaining ${R(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 _(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 q=[{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:J("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(G,{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 ${R(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:T?"Recovery, training, and vitals":"No health data yet"})]}),F?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[F.summary.metricCount," metrics"]}):null]}),b.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…"}):T?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]}),y.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:[O.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"," ",be((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(ue,{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?_(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(S,{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(Y,{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(Z,{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(ee,{value:s.progress})})]}),e.jsx("div",{className:"relative z-20 mt-3",children:e.jsx(pe,{entityType:"goal",entityId:s.id,count:te(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(S,{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(S,{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(S,{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(ie,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(se,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{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(ne,{compact:i,defaultUserId:r[0]??((s=t.users[0])==null?void 0:s.id)??null})}}];return e.jsx(U,{surfaceId:"overview",baseWidgets:q,normalizeLayout:he})}export{Ee as OverviewPage};
1
+ import{r as E,j as e,aC as S}from"./vendor-Dnkkx2co.js";import{A as U}from"./ai-surface-workspace-CutiG6uS.js";import{i as $}from"./state-vCcAT5Hq.js";import{P as B,u as Q,bE as z,h as R,d as L,bF as D,c as p,aq as G,Z as J,C as M,b as Y,V as Z,W as ee,_ as te,bG as ie,bH as se,bI as ae,bJ as re,bK as ne,bL as le,bM as oe,be as de,bN as ce}from"./index-EqQsXoat.js";import{F as ue}from"./flagship-signal-deck-CtHC3mql.js";import{L as me}from"./life-force-workspace-BJ4N1I78.js";import{E as pe}from"./entity-note-count-link-RzBB6ujx.js";import{P as fe}from"./page-hero-ffKzgyW3.js";import{a as ve,g as xe}from"./activity-copy-Bj4h9OcF.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";import"./floating-action-menu-CKQRhff9.js";import"./charts-DFnEuIMB.js";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 y=t.indexOf(v);y!==-1&&t.splice(y,1)}const b=t.indexOf("goals");return t.splice(b===-1?0:b,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 be(a){return a>=1e3?`${(a/1e3).toFixed(1)} km`:`${Math.round(a)} m`}function ye(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 Ee(){var X,C;const{t:a}=B(),n=Q(),t=n.snapshot,r=Array.isArray(n.selectedUserIds)?n.selectedUserIds:[],j=r.join("|"),[c,x]=E.useState(!1);E.useEffect(()=>{x(!1);const i=window.setTimeout(()=>{x(!0)},650);return()=>window.clearTimeout(i)},[j]);const g=ge(),b=$({queryKey:["forge-overview-sleep",...r],queryFn:async()=>(await le(r)).sleep,enabled:c,staleTime:6e4})??{},v=$({queryKey:["forge-overview-fitness",...r],queryFn:async()=>(await oe(r)).fitness,enabled:c,staleTime:6e4})??{},y=$({queryKey:["forge-overview-movement-day",g,...r],queryFn:async()=>(await de({date:g,userIds:r})).movement,enabled:c,staleTime:6e4})??{},H=$({queryKey:["forge-overview-vitals",...r],queryFn:async()=>(await ce(r)).vitals,enabled:c,staleTime:6e4})??{},I=z(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=b.data)==null?void 0:X.summary)??null,h=((C=v.data)==null?void 0:C.summary)??null,l=y.data,F=H.data??null,A=ke(F??void 0),O=ye(l),T=k!==null||h!==null||F!==null,W=l!==void 0&&(l.summary.tripCount>0||l.summary.stayCount>0||l.summary.totalMovingSeconds>0||O.length>0),K=t.lifeForce?[{label:"Life Force",value:`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP`,detail:`Remaining ${R(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 _(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 q=[{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:J("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(G,{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 ${R(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:T?"Recovery, training, and vitals":"No health data yet"})]}),F?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[F.summary.metricCount," metrics"]}):null]}),b.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…"}):T?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]}),y.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:[O.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"," ",be((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(ue,{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?_(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(S,{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(Y,{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(Z,{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(ee,{value:s.progress})})]}),e.jsx("div",{className:"relative z-20 mt-3",children:e.jsx(pe,{entityType:"goal",entityId:s.id,count:te(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(S,{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(S,{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(S,{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(ie,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(se,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{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(ne,{compact:i,defaultUserId:r[0]??((s=t.users[0])==null?void 0:s.id)??null})}}];return e.jsx(U,{surfaceId:"overview",baseWidgets:q,normalizeLayout:he})}export{Ee as OverviewPage};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-kIz9EZnX.js";import{aS as h,Z as v,c as y,aq as j}from"./index-BHIKoiZ6.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
+ import{j as e}from"./vendor-Dnkkx2co.js";import{aS as h,Z as v,c as y,aq as j}from"./index-EqQsXoat.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};
@@ -0,0 +1 @@
1
+ import{j as t}from"./vendor-Dnkkx2co.js";import{Z as a}from"./index-EqQsXoat.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 +1 @@
1
- import{b5 as p,j as s,b0 as l}from"./vendor-kIz9EZnX.js";import{j as g,k as y}from"./state-VYvD1QVP.js";import{c1 as P,B as C}from"./index-BHIKoiZ6.js";function v({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c,size:f="sm"}){const u=p(),d=g(),t=y({mutationFn:async()=>{if(!e)throw new Error("Select a single owner before sending entities to Preferences.");return P({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c})},onSuccess:async({item:m})=>{await d.invalidateQueries({queryKey:["forge-preferences"]}),u(`/preferences?userId=${encodeURIComponent(e??"")}&domain=${encodeURIComponent(n)}&focusItem=${encodeURIComponent(m.id)}`)}});return s.jsxs(C,{variant:"secondary",size:f,disabled:!e,pending:t.isPending,pendingLabel:"Sending to Preferences",onClick:()=>void t.mutateAsync(),title:e?"Add this entity to the Preferences compare queue.":"Select a single user scope before sending entities to Preferences.",children:[s.jsx(l,{className:"size-4"}),"Send to Preferences"]})}export{v as P};
1
+ import{b5 as p,j as s,b0 as l}from"./vendor-Dnkkx2co.js";import{j as g,k as y}from"./state-vCcAT5Hq.js";import{c1 as P,B as C}from"./index-EqQsXoat.js";function v({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c,size:f="sm"}){const u=p(),d=g(),t=y({mutationFn:async()=>{if(!e)throw new Error("Select a single owner before sending entities to Preferences.");return P({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c})},onSuccess:async({item:m})=>{await d.invalidateQueries({queryKey:["forge-preferences"]}),u(`/preferences?userId=${encodeURIComponent(e??"")}&domain=${encodeURIComponent(n)}&focusItem=${encodeURIComponent(m.id)}`)}});return s.jsxs(C,{variant:"secondary",size:f,disabled:!e,pending:t.isPending,pendingLabel:"Sending to Preferences",onClick:()=>void t.mutateAsync(),title:e?"Add this entity to the Preferences compare queue.":"Select a single user scope before sending entities to Preferences.",children:[s.jsx(l,{className:"size-4"}),"Send to Preferences"]})}export{v as P};
@@ -0,0 +1 @@
1
+ import{b0 as ht,bD as vt,cF as ft,cG as bt,bf as jt,aG as yt,j as e,aK as Nt,b3 as de,c2 as kt,r as x,aC as ve,c7 as Ct,b4 as It}from"./vendor-Dnkkx2co.js";import{j as St,i as Ke,k as N}from"./state-vCcAT5Hq.js";import{bk as Z,Z as U,c as I,I as v,L as Je,a as et,B as u,C as j,U as tt,H as wt,u as Pt,s as Ft,c1 as Ye,c2 as Lt,c3 as Tt,c4 as Mt,c5 as Dt,c6 as At,c7 as Et,c8 as zt,c9 as _t,ca as Gt,cb as Ot,cc as $t,cd as Bt,ce as qt,cf as Qt,cg as Rt,E as Ut,ch as Wt,T as E,ci as Xe}from"./index-EqQsXoat.js";import{P as Ht}from"./page-hero-ffKzgyW3.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-C1iwpj2-.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{value:"projects",label:"Projects",description:"Goals and projects already living in Forge.",mode:"forge"},{value:"tasks",label:"Tasks",description:"Execution-level work choices inside Forge.",mode:"forge"},{value:"strategies",label:"Strategies",description:"Plan shapes and sequencing choices in Forge.",mode:"forge"},{value:"habits",label:"Habits",description:"Recurring behaviors and routines from Forge.",mode:"forge"},{value:"activities",label:"Activities",description:"Movement, leisure, and social setting concepts.",mode:"concept"},{value:"food",label:"Food",description:"Cuisine, meal mood, and drink preferences.",mode:"concept"},{value:"places",label:"Places",description:"Living environments, venues, and trip shapes.",mode:"concept"},{value:"countries",label:"Countries",description:"Country-level attraction and lifestyle fit.",mode:"concept"},{value:"fashion",label:"Fashion",description:"Silhouette, material, and palette preferences.",mode:"concept"},{value:"people",label:"People",description:"Presence, body-type, and conversation preferences.",mode:"concept"},{value:"media",label:"Media",description:"Film, reading, and music taste.",mode:"concept"},{value:"tools",label:"Tools",description:"Workflow and capture preferences.",mode:"concept"},{value:"custom",label:"Custom",description:"General-purpose concept libraries you control.",mode:"concept"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{signalType:"favorite",label:"Favorite"},{signalType:"must_have",label:"Must-have"},{signalType:"bookmark",label:"Bookmark"},{signalType:"compare_later",label:"Later"},{signalType:"neutral",label:"Neutral"},{signalType:"veto",label:"Veto"}];function le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.dashboard.projects.map(a=>({entityType:"project",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/projects/${a.id}`,searchText:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.strategies.map(a=>({entityType:"strategy",entityId:a.id,domain:"strategies",label:a.title,description:a.overview||a.endStateDescription,user:a.user,href:`/strategies/${a.id}`,searchText:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function ce(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.summary.totalItems<2?{title:"Forge does not know enough yet.",description:"Start the game so Forge can ask a few clean comparisons and build a real preference model."}:i.summary.averageConfidence<.28?{title:"Forge has a rough sketch, not a stable read.",description:"There is some signal, but the model still needs more rounds before its preferences are trustworthy."}:{title:"This is what Forge currently thinks.",description:"The summary below is the current best model for this user, this domain, and the active context."}}function ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(a+1)/2*100;return e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:a||"Choose the one that feels more right."}),e.jsx("div",{className:"mt-auto text-sm text-[var(--primary)]",children:"Click this card"})]})}function cs({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:G,onJudge:J,onSignal:O}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] md:inset-x-10 lg:left-1/2 lg:right-auto lg:w-[min(72rem,calc(100vw-3rem))] lg:-translate-x-1/2",children:[e.jsx(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{className:"sr-only",children:"Start comparison rounds from a Forge domain or concept list."}),e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(ds,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:G}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:O}):null]})]})]})})}function ds({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Pick the concept list Forge should draw from. You do not need to assemble the items yourself."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),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:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.id))})]}):e.jsx(et,{eyebrow:"Preference game",title:"No pair is ready yet",description:"Forge needs more items in this domain before it can keep asking comparisons."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] 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:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] 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(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function ks(){var qe,Qe,Re;const i=Pt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[G,J]=x.useState(""),[O,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.useState({label:"",description:"",tags:"",manualStatus:"",manualScore:"",confidenceLock:"",bookmarked:!1,compareLater:!1,frozen:!1,featureWeights:{novelty:"0",simplicity:"0",rigor:"0",aesthetics:"0",depth:"0",structure:"0",familiarity:"0",surprise:"0"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ft(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(c=>c.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(c=>c&&r.scores.some(n=>n.itemId===c)?c:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var c,n,l;return[((c=s.item)==null?void 0:c.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),d=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,c,n,l,y,X,Q,Ue,We,He;d&&F({label:((t=d.item)==null?void 0:t.label)??"",description:((s=d.item)==null?void 0:s.description)??"",tags:((c=d.item)==null?void 0:c.tags.join(", "))??"",manualStatus:d.manualStatus??"",manualScore:typeof d.manualScore=="number"?String(d.manualScore):"",confidenceLock:typeof d.confidenceLock=="number"?String(d.confidenceLock):"",bookmarked:d.bookmarked,compareLater:d.compareLater,frozen:d.frozen,featureWeights:{novelty:String(((n=d.item)==null?void 0:n.featureWeights.novelty)??0),simplicity:String(((l=d.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=d.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=d.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=d.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=d.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=d.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=d.item)==null?void 0:He.featureWeights.surprise)??0)}})},[d]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],c=le(S);return c?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(c)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Lt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:Tt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>Mt(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Dt,onSuccess:b}),Le=N({mutationFn:At,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Et(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:zt,onSuccess:b}),ct=N({mutationFn:_t,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),dt=N({mutationFn:Gt,onSuccess:b}),ot=N({mutationFn:Ot,onSuccess:b}),De=N({mutationFn:async()=>{!(d!=null&&d.item)||!m||!r||(await $t(d.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Bt(d.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:qt,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const c=new URLSearchParams(s);return c.set("contextId",t.id),c.set("tab","contexts"),c})}}),Ee=N({mutationFn:Qt,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Rt(t,s),onSuccess:b}),A=t=>{g(s=>{const c=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?c.set(n,l):c.delete(n);return c})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),c=re.filter(l=>l.domain===t),n=(s.length>0?s:c).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await ct.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(c){D(c instanceof Error?c.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const c=P.compare.nextPair;await dt.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:c.left.id,rightItemId:c.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,itemId:t,signalType:s,strength:1})};if(!m)return e.jsx(et,{eyebrow:"Preferences",title:"No Forge user available",description:"Forge needs at least one human or bot user before it can learn preferences."});if(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Ut,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Ge=r.scores.filter(t=>ce(t)==="liked"||ce(t)==="favorite").slice(0,4),Oe=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=d==null?void 0:d.item)==null?void 0:Qe.sourceEntityType)??null,((Re=d==null?void 0:d.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ht,{title:"Preferences",titleText:"Preferences",description:"Forge keeps an explicit, editable model of what one user prefers in one domain. The first job of this page is to show what Forge currently knows.",badge:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Wt,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="overview"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will ask a small number of pairwise questions. You choose a domain, Forge supplies the candidates, and the model tightens from there."}),e.jsx(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center 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:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{to:"?tab=map",className:"text-sm text-[var(--primary)]",children:"Open full map"})]}),e.jsxs("div",{className:"relative min-h-[340px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{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:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{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:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-3 py-1 text-xs transition hover:scale-[1.04]",t.itemId===(d==null?void 0:d.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(t.target.value),placeholder:"Search learned items, explanations, tags, or dominant dimensions"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Item"}),e.jsx("th",{className:"px-3 py-2",children:"Score"}),e.jsx("th",{className:"px-3 py-2",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Evidence"})]})}),e.jsx("tbody",{children:he.map(t=>{var s,c;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(d==null?void 0:d.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((c=t.item)==null?void 0:c.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[ce(t)],children:ce(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),d!=null&&d.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{value:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).map(t=>e.jsxs("div",{className:"grid grid-cols-[110px_minmax(0,1fr)] items-center gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(c=>({...c,featureWeights:{...c.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[["bookmarked","Bookmarked"],["compareLater","Compare later"],["frozen","Frozen"]].map(([t,s])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:f[t],onChange:c=>F(n=>({...n,[t]:c.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,c=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",c]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var c,n;const s=((n=(c=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:c.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="contexts"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_360px]",children:[e.jsx("div",{className:"grid gap-4",children:r.contexts.map(t=>e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{description:s.target.value}}),className:"min-h-20"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:G,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:O,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!G||!O||G===O,onClick:()=>void Ee.mutateAsync({sourceContextId:G,targetContextId:O}),children:"Merge into target"})]})]})]}):null,T==="concepts"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_380px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"These are the lists Forge can use when you start the game in a concept domain. Seeded lists are editable, and custom lists are fully yours."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Lists",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},c=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,description:n.target.value})),className:"min-h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:c.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(null),children:"Cancel"})]})]}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(cs,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{ks as PreferencesPage};
@@ -0,0 +1 @@
1
+ import{j as a}from"./vendor-Dnkkx2co.js";import{Z as n}from"./index-EqQsXoat.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(e){return{active:e.filter(t=>t.status==="active").length,paused:e.filter(t=>t.status==="paused").length,completed:e.filter(t=>t.status==="completed").length,all:e.length}}function f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
@@ -1 +1 @@
1
- import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-kIz9EZnX.js";import{j as se,i as F,k as w}from"./state-VYvD1QVP.js";import{S as ae}from"./scheduling-rules-editor-B9KNKsQz.js";import{P as ie,u as re,s as oe,i as v,ay as ne,at as ce,bO as le,bP as de,as as pe,E as me,S as xe,a8 as je,b as y,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ve}from"./index-BHIKoiZ6.js";import{O as ye}from"./open-in-graph-button-C0TGev7c.js";import{P as fe}from"./project-management-section-nav-BLdAgTge.js";import{e as be,W as ke}from"./calendar-rules-CaZXtlxt.js";import{E as Ne}from"./execution-board-CpO2ch6v.js";import{N as H}from"./note-markdown-CsGQhQXF.js";import{E as Ie}from"./entity-notes-surface-CBylYDwy.js";import{P as De}from"./preference-entity-handoff-button-DOKV9bZc.js";import{P as Se}from"./page-hero-oFHaAjtL.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./entity-note-count-link-BrS1-O0o.js";import"./floating-action-menu-zzC2r0Ob.js";import"./note-tags-input-DdZi93tj.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function et(){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=oe(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,O=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],B=new Set(O.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||B.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&B.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>we(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>ve({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([v(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=>le(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([v(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:()=>de(o.projectId),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:O,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(me,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(xe,{});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 X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=be({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(fe,{}),e.jsx(Se,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(H,{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(y,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{metrics:i.snapshot.metrics}),e.jsx(De,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ye,{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(U,{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(U,{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(H,{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(y,{kind:"project",compact:!0,gradient:!1}),e.jsx(y,{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(y,{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(y,{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(Ne,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,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 Y.mutateAsync(t)},onDeleteTask:async t=>{await J.mutateAsync(t)}}),n?null:e.jsx(Ie,{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:Pe(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:qe(t)})]},t.id))})]}),e.jsx(he,{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(ge,{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(ke,{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{et as ProjectDetailPage};
1
+ import{cc as ee,b5 as te,r as k,j as e,aC as j}from"./vendor-Dnkkx2co.js";import{j as se,i as F,k as w}from"./state-vCcAT5Hq.js";import{S as ae}from"./scheduling-rules-editor-D40AC2jR.js";import{P as ie,u as re,s as oe,i as v,ay as ne,at as ce,bO as le,bP as de,as as pe,E as me,S as xe,a8 as je,b as y,V as ue,U,C as u,B as m,c as h,Y as he,az as ge,bQ as we,N as ve}from"./index-EqQsXoat.js";import{O as ye}from"./open-in-graph-button-BFPKfyK3.js";import{P as fe}from"./project-management-section-nav-BImLCVvf.js";import{e as be,W as ke}from"./calendar-rules-DPFsfiRl.js";import{E as Ne}from"./execution-board-CtPhI-58.js";import{N as H}from"./note-markdown-BzK2Qlgr.js";import{E as Ie}from"./entity-notes-surface-Djz50HvD.js";import{P as De}from"./preference-entity-handoff-button-Dj3V6VxL.js";import{P as Se}from"./page-hero-ffKzgyW3.js";import{g as Pe,a as qe}from"./activity-copy-Bj4h9OcF.js";import{g as Qe}from"./entity-links-DwpxhW2H.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./entity-note-count-link-RzBB6ujx.js";import"./floating-action-menu-CKQRhff9.js";import"./note-tags-input-CZzqJMLc.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function et(){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=oe(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,O=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],B=new Set(O.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||B.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&B.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>we(o.projectId),enabled:!!o.projectId&&!n}),V=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>ve({...I,userIds:N}),enabled:!!o.projectId&&!n}),Y=w({mutationFn:t=>ne(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:ce,onSuccess:async()=>{await Promise.all([v(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=>le(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([v(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:()=>de(o.projectId),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),J=w({mutationFn:t=>pe(t),onSuccess:async()=>{await Promise.all([v(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:O,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(me,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(xe,{});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 X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=be({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(fe,{}),e.jsx(Se,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(H,{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(y,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(je,{metrics:i.snapshot.metrics}),e.jsx(De,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ye,{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(U,{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(U,{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(H,{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(y,{kind:"project",compact:!0,gradient:!1}),e.jsx(y,{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(y,{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(y,{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(Ne,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,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 Y.mutateAsync(t)},onDeleteTask:async t=>{await J.mutateAsync(t)}}),n?null:e.jsx(Ie,{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:Pe(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:qe(t)})]},t.id))})]}),e.jsx(he,{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(ge,{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(ke,{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{et as ProjectDetailPage};
@@ -0,0 +1 @@
1
+ import{r as x,j as s,cz as X,cx as Y,cA as Z,aC as J,aK as ee,b3 as se}from"./vendor-Dnkkx2co.js";import{i as re}from"./state-vCcAT5Hq.js";import{u as te,c as j,U as R,b as D,L as ae,E as ie,C as O,B as C,m as A,a as ne,aS as le,Z as F,bR as oe}from"./index-EqQsXoat.js";import{P as ce}from"./project-management-section-nav-BImLCVvf.js";import{P as de}from"./page-hero-ffKzgyW3.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.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 z(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 Se(){const r=te(),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:()=>oe({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(R,{user:u,compact:!0}),menuBadge:s.jsx(R,{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:z(t.value),children:t.label}),menuBadge:s.jsx(j,{className:z(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(ae,{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(ie,{eyebrow:"Hierarchy",error:a.error,onRetry:()=>void a.refetch()}):s.jsxs("div",{className:"grid min-w-0 gap-5",children:[s.jsx(ce,{}),s.jsx(de,{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(O,{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(A,{options:p,selectedValues:m,onChange:t=>b(t),placeholder:"Visible states",emptyMessage:"No states available.",variant:"action-bar"}),s.jsx(A,{options:o,selectedValues:f,onChange:t=>e(t),placeholder:"Visible levels",emptyMessage:"No hierarchy levels.",className:"min-w-0",variant:"action-bar"}),s.jsx(A,{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(ne,{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(O,{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=le(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(Z,{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:z(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(R,{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(J,{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{Se as ProjectManagementHierarchyPage};
@@ -0,0 +1 @@
1
+ import{aJ as v,r as l,cB as b,cC as f,aU as p,j as e,bB as m,F as h,aK as g}from"./vendor-Dnkkx2co.js";import{C as j,Z as c}from"./index-EqQsXoat.js";const i=[{to:"/projects",label:"Projects",icon:b},{to:"/kanban",label:"Board",icon:f},{to:"/projects/hierarchy",label:"Hierarchy",icon:p}];function d(t,s){return s==="/projects"?t==="/projects"||/^\/projects\/[^/]+$/.test(t):t===s||t.startsWith(`${s}/`)}function y({className:t}){const s=v(),[o,n]=l.useState(!1),u=l.useMemo(()=>[...i].sort((r,a)=>a.to.length-r.to.length).find(r=>d(s.pathname,r.to))??i[0],[s.pathname]);return l.useEffect(()=>{if(!o)return;const r=document.body.style.overflow,a=x=>{x.key==="Escape"&&n(!1)};return document.body.style.overflow="hidden",window.addEventListener("keydown",a),()=>{document.body.style.overflow=r,window.removeEventListener("keydown",a)}},[o]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:c("overflow-hidden bg-[var(--card-gradient)] p-2",t),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(r=>e.jsxs(m,{to:r.to,end:r.to==="/projects",className:({isActive:a})=>c("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",a||d(s.pathname,r.to)?"border border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"border 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)]"),children:[e.jsx(r.icon,{className:"size-3.5"}),e.jsx("span",{children:r.label})]},r.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsx("button",{type:"button",className:"inline-flex min-w-0 flex-1 items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-2.5 text-left shadow-[var(--ui-shadow-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",onClick:()=>n(!0),children:e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-2xl border border-[color-mix(in_srgb,var(--info)_24%,var(--ui-border-subtle)_76%)] bg-[var(--ui-info-soft)]",children:e.jsx(u.icon,{className:"size-4 text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Project management"}),e.jsx("span",{className:"mt-0.5 block truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:u.label})]})]})})})]}),o&&typeof document<"u"?h.createPortal(e.jsxs("div",{className:"lg:hidden",children:[e.jsx("div",{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"fixed inset-0 z-[51]",onClick:()=>n(!1)}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[52] flex items-end justify-center px-3 pt-3 sm:px-4 sm:pt-4",style:{paddingBottom:"calc(var(--forge-mobile-nav-clearance) - 0.25rem)"},children:e.jsxs("div",{className:"surface-modal-panel pointer-events-auto flex max-h-[min(34rem,calc(100dvh-var(--forge-mobile-nav-clearance)-1rem))] w-full max-w-xl min-h-0 flex-col overflow-hidden rounded-[30px] border shadow-[var(--ui-shadow-strong)]",children:[e.jsx("div",{className:"shrink-0 border-b border-[var(--ui-border-subtle)] px-4 pb-2.5 pt-3 sm:px-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.22em] text-[var(--ui-ink-muted)]",children:"Forge PM"}),e.jsx("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-2",children:e.jsx("div",{className:"truncate text-[1.05rem] font-semibold text-[var(--ui-ink-strong)]",children:"Browse the hierarchy"})})]}),e.jsx("button",{type:"button","aria-label":"Close project management sections",className:"inline-flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>n(!1),children:e.jsx(g,{className:"size-4"})})]})}),e.jsx("div",{className:"min-h-0 overflow-y-auto p-3 overscroll-contain sm:p-4",children:e.jsx("div",{className:"grid gap-2",children:i.map(r=>{const a=d(s.pathname,r.to);return e.jsx(m,{to:r.to,end:r.to==="/projects",onClick:()=>n(!1),className:c("group flex items-center justify-between gap-3 rounded-[22px] border px-3.5 py-3 transition hover:-translate-y-[1px] hover:text-[var(--ui-ink-strong)]",a?"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%)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),children:e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-10 items-center justify-center rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:e.jsx(r.icon,{className:"size-4"})}),e.jsx("span",{className:"text-sm font-medium",children:r.label})]})},r.to)})})})]})})]}),document.body):null]})}export{y as P};
@@ -0,0 +1 @@
1
+ import{j as e,r as g,aK as X,b3 as J,aC as A}from"./vendor-Dnkkx2co.js";import{A as Y}from"./ai-surface-workspace-CutiG6uS.js";import{P as Z}from"./pill-cluster-C2D0h3lx.js";import{Z as Q,c as T,b as D,u as U,bk as F,bl as R,_ as q,C as M,U as ee,V as W,W as H,B as O,a as se,bS as te,bT as ae,bU as ie}from"./index-EqQsXoat.js";import{P as re}from"./page-hero-ffKzgyW3.js";import{E as ne}from"./entity-note-count-link-RzBB6ujx.js";import{b as le,f as oe,P as ce}from"./project-collections-qSqp90HN.js";import{P as de}from"./project-management-section-nav-BImLCVvf.js";import"./board-dIX6etHh.js";import"./state-vCcAT5Hq.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";function ue({children:t,columns:d="single",className:w}){return e.jsx("section",{className:Q("grid gap-4",d==="two"&&"lg:grid-cols-2",d==="sidebar"&&"xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",w),children:t})}function me(t){return t.trim().toLowerCase()}function V(t,d=!1){switch(t.kind){case"goal":return e.jsx(D,{kind:"goal",label:t.label,compact:!0,gradient:!1});case"task":return e.jsx(D,{kind:"task",label:t.label,compact:!0,gradient:!1});case"tag":return e.jsx(T,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.label});case"status":return e.jsx(T,{className:"bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]",children:t.label});case"type":return e.jsx(T,{className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",children:t.label});case"user":return e.jsx(T,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:t.label});default:return t.label}}function he({query:t,onQueryChange:d,options:w,selectedOptionIds:m,onSelectedOptionIdsChange:I,resultSummary:C}){const[L,j]=g.useState(!1),[P,p]=g.useState(0),N=g.useMemo(()=>m.map(n=>w.find(o=>o.id===n)).filter(Boolean),[w,m]),S=me(t),b=g.useMemo(()=>{const n=w.filter(o=>!m.includes(o.id));return S?n.filter(o=>`${o.label} ${o.description??""} ${o.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(o=>o!==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."})]}),t.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:[V(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:t,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"&&!t&&m.length>0){B(m[m.length-1]);return}if(n.key==="ArrowDown"){n.preventDefault(),j(!0),p(o=>b.length===0?0:Math.min(b.length-1,o+1));return}if(n.key==="ArrowUp"){n.preventDefault(),p(o=>Math.max(0,o-1));return}if(n.key==="Escape"){j(!1);return}n.key==="Enter"&&b[P]&&(n.preventDefault(),k(b[P].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,o)=>e.jsx("button",{type:"button",className:Q("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",o===P?"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(o),onMouseDown:_=>_.preventDefault(),onClick:()=>k(n.id),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:V(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(t){return t.trim().toLowerCase()}function Ie(){const t=U(),[d,w]=g.useState("active"),[m,I]=g.useState(""),[C,L]=g.useState([]),[j,P]=g.useState(null),p=g.useMemo(()=>le(t.snapshot.dashboard.projects),[t.snapshot.dashboard.projects]),N=g.useMemo(()=>{const a=new Map(t.snapshot.dashboard.goals.map(r=>[r.id,r])),l=new Map(t.snapshot.tags.map(r=>[r.id,r])),u=new Map(t.snapshot.users.map(r=>[r.id,r])),f=new Map;for(const r of t.snapshot.tasks){if(!r.projectId)continue;const x=f.get(r.projectId)??[];x.push(r),f.set(r.projectId,x)}return new Map(t.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 s of c.tagIds){const i=l.get(s);i&&y.set(i.id,{id:i.id,name:i.name,kind:i.kind})}const E=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:E,userId:r.userId,searchText:z}]}))},[t.snapshot.dashboard.goals,t.snapshot.dashboard.projects,t.snapshot.tags,t.snapshot.tasks,t.snapshot.users]),S=g.useMemo(()=>{var v,y,E,z,c;const a=new Map,l=new Map,u=new Map,f=new Map,r=new Map,x=new Map,$=new Map;for(const s of t.snapshot.dashboard.projects){const i=N.get(s.id);if(i){l.has(s.goalId)||l.set(s.goalId,new Set),l.get(s.goalId).add(s.id),r.has(s.status)||r.set(s.status,new Set),r.get(s.status).add(s.id);for(const h of i.taskIds)u.has(h)||u.set(h,new Set),u.get(h).add(s.id);for(const h of i.tags)f.has(h.id)||f.set(h.id,new Set),f.get(h.id).add(s.id);for(const h of i.typeKeys)x.has(h)||x.set(h,new Set),x.get(h).add(s.id);i.userId&&($.has(i.userId)||$.set(i.userId,new Set),$.get(i.userId).add(s.id))}}for(const s of t.snapshot.dashboard.goals){const i=((v=l.get(s.id))==null?void 0:v.size)??0;i!==0&&a.set(`goal:${s.id}`,{id:`goal:${s.id}`,kind:"goal",value:s.id,label:s.title,description:R(`${i} project${i===1?"":"s"} linked to this goal`,s.user,`${i} project${i===1?"":"s"} linked to this goal`),searchText:F([s.title,s.description],s)})}for(const s of t.snapshot.tasks){const i=((y=u.get(s.id))==null?void 0:y.size)??0;i!==0&&a.set(`task:${s.id}`,{id:`task:${s.id}`,kind:"task",value:s.id,label:s.title,description:R(`${i} project${i===1?"":"s"} linked to this task`,s.user,`${i} project${i===1?"":"s"} linked to this task`),searchText:F([s.title,s.description],s)})}for(const s of t.snapshot.tags){const i=((E=f.get(s.id))==null?void 0:E.size)??0;i!==0&&a.set(`tag:${s.id}`,{id:`tag:${s.id}`,kind:"tag",value:s.id,label:s.name,description:R(`${i} project${i===1?"":"s"} touching this tag`,s.user,`${i} project${i===1?"":"s"} touching this tag`),searchText:F([s.name,s.kind,s.description],s)})}for(const[s,i]of Object.entries(p))s==="all"||i===0||a.set(`status:${s}`,{id:`status:${s}`,kind:"status",value:s,label:s==="paused"?"Suspended":s==="completed"?"Finished":"Active",description:`${i} project${i===1?"":"s"} currently ${s==="paused"?"suspended":s==="completed"?"finished":"active"}`,searchText:`${s} ${s==="paused"?"suspended":""} ${s==="completed"?"finished":""}`});for(const[s,i]of Object.entries(pe)){const h=((z=x.get(s))==null?void 0:z.size)??0;h!==0&&a.set(`type:${s}`,{id:`type:${s}`,kind:"type",value:s,label:i,description:`${h} project${h===1?"":"s"} linked to ${i.toLowerCase()} tags`,searchText:`${i} ${s} project type`})}for(const s of t.snapshot.users){const i=((c=$.get(s.id))==null?void 0:c.size)??0;i!==0&&a.set(`user:${s.id}`,{id:`user:${s.id}`,kind:"user",value:s.id,label:s.displayName,description:`${i} project${i===1?"":"s"} owned by this ${s.kind}`,searchText:`${s.displayName} ${s.handle} ${s.kind} ${s.description}`})}return Array.from(a.values()).sort((s,i)=>s.label.localeCompare(i.label))},[p,N,t.snapshot.dashboard.goals,t.snapshot.dashboard.projects,t.snapshot.tags,t.snapshot.tasks,t.snapshot.users]),b=g.useMemo(()=>C.map(a=>S.find(l=>l.id===a)).filter(Boolean),[S,C]),k=g.useMemo(()=>{const a=xe(m);return oe(t.snapshot.dashboard.projects,d).filter(l=>{const u=N.get(l.id);return!u||!b.every(r=>{switch(r.kind){case"goal":return l.goalId===r.value;case"task":return u.taskIds.includes(r.value);case"tag":return u.tagIds.includes(r.value);case"status":return l.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,t.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"}`,o=async a=>{P(a);try{await t.patchProject(a,{status:"active"})}finally{P(null)}},_=e.jsx(ue,{columns:"two",className:"2xl:grid-cols-3",children:k.map(a=>{const l=q(t.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(ee,{user:a.user,compact:!0})]}),e.jsx(T,{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(T,{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(ne,{entityType:"project",entityId:a.id,count:l.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 o(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(re,{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:`${t.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(ae,{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(ce,{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(l=>e.jsx(A,{to:`/projects/${l.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:l.title}),e.jsx("div",{className:"truncate text-sm text-[var(--ui-ink-soft)]",children:l.goalTitle})]}),e.jsxs(T,{wrap:!0,className:"max-w-[7rem] shrink-0 bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[l.earnedPoints," xp"]})]})},l.id))}):_]})})},{id:"summary",title:"Collection summary",description:"Counts and spotlight cards.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>{const a=k[0]??t.snapshot.dashboard.projects[0]??null;return e.jsx(ie,{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(de,{}),t.snapshot.dashboard.projects.length===0?e.jsx(se,{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{Ie as ProjectsPage};