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,4 +1,4 @@
1
- import{j as t,aC as pe,b8 as ye,c2 as ve,r as v}from"./vendor-kIz9EZnX.js";import{j as ge,i as g,k as fe}from"./state-VYvD1QVP.js";import{u as be,s as xe,cl as we,cm as je,bk as P,bl as N,cn as T,L as ke,E as Ce,B,V as Ie,ch as Se,c as Pe,U as Ne,_ as Te,Z as V,Q as Be,a0 as Le,a1 as Me,F as i,I as Ee,T as d,m as S,co as Fe,cp as qe,cq as Oe,by as Ae,bx as Qe,bw as De,cr as Ke,bA as Re}from"./index-BHIKoiZ6.js";import{E as Ue}from"./entity-note-count-link-BrS1-O0o.js";import{A as G}from"./atlas-panel-B3dPHCmZ.js";import{S as H}from"./schema-badge-D93RcG36.js";import{u as We,p as _e}from"./use-psyche-focus-target-qxT5Oy_z.js";import{P as $e}from"./page-hero-oFHaAjtL.js";import{p as L}from"./query-cache-IQ8W-LNC.js";import{b as J}from"./psyche-schemas-RcZYaokx.js";import{g as ze}from"./schema-visuals-CvC9a3i6.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function Ve({entries:s}){const n={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return t.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:s.map(o=>t.jsxs(pe,{to:o.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${n[o.tone]}`,children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:o.tone}),t.jsx("div",{className:"mt-2 font-medium text-white",children:o.title}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.summary}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",t.jsx(ye,{className:"size-3.5"})]})]},o.id))})}const f={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:null};function Ge(s){return{kind:s.kind,title:s.title,description:s.description,commonCues:s.commonCues,urgeStory:s.urgeStory,shortTermPayoff:s.shortTermPayoff,longTermCost:s.longTermCost,replacementMove:s.replacementMove,repairPlan:s.repairPlan,linkedPatternIds:s.linkedPatternIds,linkedValueIds:s.linkedValueIds,linkedSchemaIds:s.linkedSchemaIds,linkedModeIds:s.linkedModeIds,userId:s.userId??null}}const Z={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function ht(){var O,A,Q,D,K,R,U,W,_,$,z;const s=be(),n=ge(),[o,M]=ve(),[X,c]=v.useState(!1),[h,p]=v.useState(null),[y,m]=v.useState(f),[Y,b]=v.useState(null),x=g({queryKey:["forge-psyche-behaviors"],queryFn:Ae}),w=g({queryKey:["forge-psyche-patterns"],queryFn:Qe}),j=g({queryKey:["forge-psyche-values"],queryFn:De}),k=g({queryKey:["forge-psyche-schema-catalog"],queryFn:Ke}),C=g({queryKey:["forge-psyche-modes"],queryFn:Re}),I=((O=x.data)==null?void 0:O.behaviors)??[],ee=((A=w.data)==null?void 0:A.patterns)??[],te=((Q=j.data)==null?void 0:Q.values)??[],ae=((D=k.data)==null?void 0:D.schemas)??[],re=((K=C.data)==null?void 0:K.modes)??[],u=xe(s.selectedUserIds),E=o.get("focus"),se=s.snapshot.dashboard.notesSummaryByEntity;We(E),v.useEffect(()=>{if(o.get("create")==="1"){c(!0),p(null),m({...f,userId:u});const e=new URLSearchParams(o);e.delete("create"),M(e,{replace:!0})}},[u,o,M]);const F=fe({mutationFn:async e=>{const a=J.parse(e);return h?we(h.id,a):je(a)},onSuccess:async()=>{c(!1),p(null),m({...f,userId:u}),b(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),ie=ee.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.preferredResponse||e.targetBehavior,e.user),searchText:P([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),oe=te.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=ae.map(e=>({value:e.id,label:e.title,description:`${e.description} ${ze(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0})})),le=re.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),de=async e=>{const{pattern:a}=await Fe({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return L(n,["forge-psyche-patterns"],"patterns",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},ce=async e=>{const{value:a}=await qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return L(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},he=async e=>{const{mode:a}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:y.userId});return L(n,["forge-psyche-modes"],"modes",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.archetype||a.family,kind:"mode"}},me=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(Le,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:Me(s.snapshot.users.find(r=>r.id===u)??null,"Choose behavior owner"),help:"Behaviors can belong to a human or bot user while still linking across shared patterns, schemas, and modes."}),t.jsx(i,{label:"Behavior title",children:t.jsx(Ee,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"Scroll to numb the impact"})}),t.jsx(i,{label:"What does the move look like?",children:t.jsx(d,{value:e.description,onChange:r=>a({description:r.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Common cues",children:t.jsx(d,{value:e.commonCues.join(`
1
+ import{j as t,aC as pe,b8 as ye,c2 as ve,r as v}from"./vendor-Dnkkx2co.js";import{j as ge,i as g,k as fe}from"./state-vCcAT5Hq.js";import{u as be,s as xe,cl as we,cm as je,bk as P,bl as N,cn as T,L as ke,E as Ce,B,V as Ie,ch as Se,c as Pe,U as Ne,_ as Te,Z as V,Q as Be,a0 as Le,a1 as Me,F as i,I as Ee,T as d,m as S,co as Fe,cp as qe,cq as Oe,by as Ae,bx as Qe,bw as De,cr as Ke,bA as Re}from"./index-EqQsXoat.js";import{E as Ue}from"./entity-note-count-link-RzBB6ujx.js";import{A as G}from"./atlas-panel-jgMRyaHn.js";import{S as H}from"./schema-badge-FY7818qB.js";import{u as We,p as _e}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as $e}from"./page-hero-ffKzgyW3.js";import{p as L}from"./query-cache-IQ8W-LNC.js";import{b as J}from"./psyche-schemas-Dxj554nU.js";import{g as ze}from"./schema-visuals-CvC9a3i6.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function Ve({entries:s}){const n={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return t.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:s.map(o=>t.jsxs(pe,{to:o.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${n[o.tone]}`,children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:o.tone}),t.jsx("div",{className:"mt-2 font-medium text-white",children:o.title}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.summary}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",t.jsx(ye,{className:"size-3.5"})]})]},o.id))})}const f={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:null};function Ge(s){return{kind:s.kind,title:s.title,description:s.description,commonCues:s.commonCues,urgeStory:s.urgeStory,shortTermPayoff:s.shortTermPayoff,longTermCost:s.longTermCost,replacementMove:s.replacementMove,repairPlan:s.repairPlan,linkedPatternIds:s.linkedPatternIds,linkedValueIds:s.linkedValueIds,linkedSchemaIds:s.linkedSchemaIds,linkedModeIds:s.linkedModeIds,userId:s.userId??null}}const Z={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function ht(){var O,A,Q,D,K,R,U,W,_,$,z;const s=be(),n=ge(),[o,M]=ve(),[X,c]=v.useState(!1),[h,p]=v.useState(null),[y,m]=v.useState(f),[Y,b]=v.useState(null),x=g({queryKey:["forge-psyche-behaviors"],queryFn:Ae}),w=g({queryKey:["forge-psyche-patterns"],queryFn:Qe}),j=g({queryKey:["forge-psyche-values"],queryFn:De}),k=g({queryKey:["forge-psyche-schema-catalog"],queryFn:Ke}),C=g({queryKey:["forge-psyche-modes"],queryFn:Re}),I=((O=x.data)==null?void 0:O.behaviors)??[],ee=((A=w.data)==null?void 0:A.patterns)??[],te=((Q=j.data)==null?void 0:Q.values)??[],ae=((D=k.data)==null?void 0:D.schemas)??[],re=((K=C.data)==null?void 0:K.modes)??[],u=xe(s.selectedUserIds),E=o.get("focus"),se=s.snapshot.dashboard.notesSummaryByEntity;We(E),v.useEffect(()=>{if(o.get("create")==="1"){c(!0),p(null),m({...f,userId:u});const e=new URLSearchParams(o);e.delete("create"),M(e,{replace:!0})}},[u,o,M]);const F=fe({mutationFn:async e=>{const a=J.parse(e);return h?we(h.id,a):je(a)},onSuccess:async()=>{c(!1),p(null),m({...f,userId:u}),b(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),ie=ee.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.preferredResponse||e.targetBehavior,e.user),searchText:P([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),oe=te.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.valuedDirection,e.user),searchText:P([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=ae.map(e=>({value:e.id,label:e.title,description:`${e.description} ${ze(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx(H,{label:e.title,schemaType:e.schemaType,compact:!0})})),le=re.map(e=>({value:e.id,label:T(e.title,e.user),description:N(e.archetype||e.family,e.user),searchText:P([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),de=async e=>{const{pattern:a}=await Fe({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return L(n,["forge-psyche-patterns"],"patterns",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},ce=async e=>{const{value:a}=await qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return L(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},he=async e=>{const{mode:a}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:y.userId});return L(n,["forge-psyche-modes"],"modes",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.archetype||a.family,kind:"mode"}},me=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(Le,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:Me(s.snapshot.users.find(r=>r.id===u)??null,"Choose behavior owner"),help:"Behaviors can belong to a human or bot user while still linking across shared patterns, schemas, and modes."}),t.jsx(i,{label:"Behavior title",children:t.jsx(Ee,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"Scroll to numb the impact"})}),t.jsx(i,{label:"What does the move look like?",children:t.jsx(d,{value:e.description,onChange:r=>a({description:r.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Common cues",children:t.jsx(d,{value:e.commonCues.join(`
2
2
  `),onChange:r=>a({commonCues:r.target.value.split(`
3
3
  `).map(ue=>ue.trim()).filter(Boolean)}),placeholder:`One line per cue
4
4
  Late-night ambiguity
@@ -1 +1 @@
1
- import{c2 as T,r as x,j as e,b4 as B,b3 as z,cH as M,aG as R,aK as q}from"./vendor-kIz9EZnX.js";import{j as Q,i as K,k as F}from"./state-VYvD1QVP.js";import{u as O,s as H,cs as Y,ct as V,cu as W,L as G,E as X,B as S,ch as Z,I as h,c as N,U as D,Z as y,T as J,a0 as $,a1 as ee,bB as se}from"./index-BHIKoiZ6.js";import{u as ae,p as te}from"./use-psyche-focus-target-qxT5Oy_z.js";import{P as re}from"./page-hero-oFHaAjtL.js";import{f as ie}from"./psyche-schemas-RcZYaokx.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const k={title:"",message:"",triggerSentence:"",triggerSituation:"",tags:[],backgroundColor:"#f8fafc",textColor:"#111827",accentColor:"#6ee7b7",typography:"serif",imageUrl:"",imageAlt:"",layout:"centered",visualStyle:"calm",linkedValueIds:[],linkedBehaviorIds:[],linkedPatternIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],userId:null},le={serif:"font-serif",sans:"font-sans",mono:"font-mono",display:"font-display"},ne={calm:"Calm",urgent:"Urgent",warm:"Warm",clinical:"Clinical",playful:"Playful"};function oe(s){return s.split(",").map(l=>l.trim()).filter(Boolean)}function L(s){return{title:s.title,message:s.message,triggerSentence:s.triggerSentence,triggerSituation:s.triggerSituation,tags:s.tags,backgroundColor:s.backgroundColor,textColor:s.textColor,accentColor:s.accentColor,typography:s.typography,imageUrl:s.imageUrl,imageAlt:s.imageAlt,layout:s.layout,visualStyle:s.visualStyle,linkedValueIds:s.linkedValueIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedPatternIds:s.linkedPatternIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,userId:s.userId??null}}function A({card:s,compact:l=!1,focused:a=!1,onClick:p}){const c=s.imageUrl.trim().length>0,n=s.layout,d=s.title.trim(),v=s.triggerSentence.trim()||s.triggerSituation.trim();return e.jsxs("button",{type:"button",className:y("group min-w-0 rounded-[26px] border p-2 text-left shadow-[var(--card-shadow)] transition hover:-translate-y-0.5 hover:border-[var(--ui-border-strong)]",a?"border-[color-mix(in_srgb,var(--tertiary)_72%,var(--ui-border-subtle)_28%)]":"border-[var(--ui-border-subtle)]"),onClick:p,children:[e.jsxs("div",{className:y("relative grid min-h-[18rem] overflow-hidden rounded-[20px] border",l?"min-h-[15rem]":"sm:min-h-[21rem]",n==="image_split"&&c?"md:grid-cols-[0.9fr_1.1fr]":""),style:{background:s.backgroundColor,color:s.textColor,borderColor:s.accentColor},children:[c&&n!=="image_split"?e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover opacity-30"}):null,c&&n==="image_split"?e.jsx("div",{className:"relative min-h-[10rem] overflow-hidden",children:e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover"})}):null,e.jsxs("div",{className:y("relative z-10 flex min-w-0 flex-col p-6",n==="top_left"?"items-start justify-start":"items-center justify-center text-center",n==="poster"?"min-h-[22rem] p-8":"",le[s.typography]),children:[e.jsx("div",{className:"mb-5 h-1.5 w-16 rounded-full",style:{backgroundColor:s.accentColor}}),e.jsx("div",{className:y("max-w-[24rem] text-balance leading-[1.12]",l?"text-2xl":"text-[clamp(1.9rem,4vw,3.45rem)]"),children:s.message||"Write the sentence that should meet you in the hard moment."}),v?e.jsx("div",{className:"mt-6 max-w-md rounded-full border px-3 py-1.5 text-xs font-medium opacity-75",style:{borderColor:s.accentColor},children:v}):null]})]}),e.jsxs("div",{className:"px-2 pt-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[d?e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:d}):null,e.jsx(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:ne[s.visualStyle]})]}),s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.slice(0,5).map(o=>e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-1)] px-2 py-1 text-[11px] text-[var(--ui-ink-soft)]",children:o},o))}):null]})]})}function ce({open:s,editingCard:l,draft:a,users:p,suggestedOwner:c,submitError:n,saving:d,onClose:v,onDelete:o,onDraftChange:i,onSubmit:u}){return s?e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-[var(--overlay)] px-3 py-4 backdrop-blur-xl sm:items-center sm:p-6",children:e.jsxs("div",{className:"max-h-[min(92dvh,58rem)] w-full max-w-6xl overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--tertiary)]",children:l?"Edit flashcard":"New flashcard"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Message first, retrieval second, styling last."})]}),e.jsx("button",{type:"button","aria-label":"Close flashcard editor",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)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:v,children:e.jsx(q,{className:"size-4"})})]}),e.jsxs("div",{className:"grid max-h-[calc(min(92dvh,58rem)-5rem)] min-h-0 overflow-y-auto p-4 md:grid-cols-[1fr_0.9fr] md:p-5",children:[e.jsxs("div",{className:"grid content-start gap-4 pr-0 md:pr-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Main message"}),e.jsx(J,{className:"mt-2 min-h-28",value:a.message,placeholder:"This urge is a wave. You do not have to obey it.",onChange:r=>i({...a,message:r.target.value})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger sentence"}),e.jsx(h,{className:"mt-2",value:a.triggerSentence,placeholder:"I feel the urge to…",onChange:r=>i({...a,triggerSentence:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Optional title"}),e.jsx(h,{className:"mt-2",value:a.title,placeholder:"Late-night urge card",onChange:r=>i({...a,title:r.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger situation"}),e.jsx(h,{className:"mt-2",value:a.triggerSituation,placeholder:"Late evening shame, loneliness, conflict, or boredom",onChange:r=>i({...a,triggerSituation:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Tags"}),e.jsx(h,{className:"mt-2",value:a.tags.join(", "),placeholder:"urge, sobriety, grounding",onChange:r=>i({...a,tags:oe(r.target.value)})})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:[["backgroundColor","Background"],["textColor","Text"],["accentColor","Accent"]].map(([r,m])=>e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[m,e.jsx("input",{type:"color",value:String(a[r]),className:"h-11 w-full rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1",onChange:w=>i({...a,[r]:w.target.value})})]},r))}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Typography",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.typography,onChange:r=>i({...a,typography:r.target.value}),children:[e.jsx("option",{value:"serif",children:"Serif"}),e.jsx("option",{value:"sans",children:"Sans"}),e.jsx("option",{value:"mono",children:"Mono"}),e.jsx("option",{value:"display",children:"Display"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Layout",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.layout,onChange:r=>i({...a,layout:r.target.value}),children:[e.jsx("option",{value:"centered",children:"Centered"}),e.jsx("option",{value:"top_left",children:"Top left"}),e.jsx("option",{value:"image_split",children:"Image split"}),e.jsx("option",{value:"poster",children:"Poster"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Tone",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.visualStyle,onChange:r=>i({...a,visualStyle:r.target.value}),children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"urgent",children:"Urgent"}),e.jsx("option",{value:"warm",children:"Warm"}),e.jsx("option",{value:"clinical",children:"Clinical"}),e.jsx("option",{value:"playful",children:"Playful"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image URL"}),e.jsx(h,{className:"mt-2",value:a.imageUrl,placeholder:"https://…",onChange:r=>i({...a,imageUrl:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image alt"}),e.jsx(h,{className:"mt-2",value:a.imageAlt,placeholder:"Describe the image",onChange:r=>i({...a,imageAlt:r.target.value})})]})]}),e.jsx($,{users:p,value:a.userId??null,defaultLabel:ee(c,"Choose flashcard owner"),onChange:r=>i({...a,userId:r}),help:"Flashcards can belong to a human or bot owner while still being searchable by trigger, tags, and linked Psyche records."}),n?e.jsx("div",{className:"rounded-[18px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[l?e.jsx(S,{type:"button",variant:"ghost",onClick:o,children:"Delete"}):e.jsx("span",{}),e.jsx(S,{type:"button",disabled:d,onClick:u,children:d?"Saving...":"Save flashcard"})]})]}),e.jsx("div",{className:"mt-5 min-w-0 md:mt-0",children:e.jsx(A,{card:a,compact:!0})})]})]})}):null}function ye(){var U;const s=O(),l=Q(),[a,p]=T(),c=a.get("focus"),[n,d]=x.useState(""),[v,o]=x.useState(!1),[i,u]=x.useState(null),[r,m]=x.useState(k),[w,C]=x.useState(null),f=H(s.selectedUserIds),E=s.snapshot.users.find(t=>t.id===f)??null;ae(c);const b=K({queryKey:["forge-psyche-flashcards",s.selectedUserIds],queryFn:()=>se(s.selectedUserIds)});x.useEffect(()=>{if(a.get("create")==="1"){u(null),m({...k,userId:f}),o(!0);const t=new URLSearchParams(a);t.delete("create"),p(t,{replace:!0})}},[f,a,p]);const P=F({mutationFn:async t=>{const g=ie.parse(t);return i?Y(i.id,g):V(g)},onSuccess:async()=>{o(!1),u(null),m({...k,userId:f}),C(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])},onError:t=>{C(t instanceof Error?t.message:String(t))}}),_=F({mutationFn:async t=>W(t.id),onSuccess:async()=>{o(!1),u(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),j=((U=b.data)==null?void 0:U.flashcards)??[],I=x.useMemo(()=>{const t=n.trim().toLowerCase();return t?j.filter(g=>[g.title,g.message,g.triggerSentence,g.triggerSituation,...g.tags].join(" ").toLowerCase().includes(t)):j},[j,n]);return b.isLoading?e.jsx(G,{title:"Loading Psyche flashcards"}):b.isError?e.jsx(X,{eyebrow:"Psyche",error:b.error,onRetry:()=>void b.refetch()}):e.jsxs("div",{className:"grid gap-6",children:[e.jsx(re,{title:"Flashcards",titleText:"Flashcards",description:"Small therapeutic reminder cards for urges, trigger moments, mode shifts, and values-based pivots.",actions:e.jsxs(S,{type:"button",onClick:()=>{u(null),m({...k,userId:f}),o(!0)},children:[e.jsx(B,{className:"mr-2 size-4"}),"New flashcard"]})}),e.jsx(Z,{}),e.jsxs("div",{className:"grid gap-4 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4 md:grid-cols-[1fr_auto] md:items-center",children:[e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(z,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-[var(--ui-ink-faint)]"}),e.jsx(h,{value:n,placeholder:"Search message, tags, trigger sentence, or situation",className:"pl-10",onChange:t=>d(t.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[j.length," saved"]}),e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[I.length," visible"]})]})]}),I.length>0?e.jsx("div",{className:"grid gap-5 lg:grid-cols-2 2xl:grid-cols-3",children:I.map(t=>e.jsxs("div",{className:te(c===t.id),children:[e.jsx(A,{card:t,focused:c===t.id,onClick:()=>{u(t),m(L(t)),o(!0)}}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.user?e.jsx(D,{user:t.user,compact:!0}):null,t.imageUrl?e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)]",children:[e.jsx(M,{className:"mr-1 size-3"}),"image"]}):null]}),e.jsx(S,{type:"button",variant:"ghost",onClick:()=>{u(t),m(L(t)),o(!0)},children:"Edit"})]})]},t.id))}):e.jsxs("div",{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[radial-gradient(circle_at_top_left,color-mix(in_srgb,var(--tertiary)_12%,transparent),transparent_46%),var(--ui-surface-section)] p-8 text-center",children:[e.jsx(R,{className:"mx-auto size-8 text-[var(--tertiary)]"}),e.jsx("div",{className:"mt-4 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"No flashcards match this view."}),e.jsx("div",{className:"mx-auto mt-2 max-w-xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create cards for the sentences you want available during urges, shame spirals, critic attacks, and values-based pivots."})]}),e.jsx(ce,{open:v,editingCard:i,draft:r,users:s.snapshot.users,suggestedOwner:E,submitError:w,saving:P.isPending||_.isPending,onClose:()=>{o(!1),u(null),C(null)},onDelete:()=>{i&&_.mutateAsync(i)},onDraftChange:m,onSubmit:()=>void P.mutateAsync(r)})]})}export{ye as PsycheFlashcardsPage};
1
+ import{c2 as T,r as x,j as e,b4 as B,b3 as z,cH as M,aG as R,aK as q}from"./vendor-Dnkkx2co.js";import{j as Q,i as K,k as F}from"./state-vCcAT5Hq.js";import{u as O,s as H,cs as Y,ct as V,cu as W,L as G,E as X,B as S,ch as Z,I as h,c as N,U as D,Z as y,T as J,a0 as $,a1 as ee,bB as se}from"./index-EqQsXoat.js";import{u as ae,p as te}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as re}from"./page-hero-ffKzgyW3.js";import{f as ie}from"./psyche-schemas-Dxj554nU.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const k={title:"",message:"",triggerSentence:"",triggerSituation:"",tags:[],backgroundColor:"#f8fafc",textColor:"#111827",accentColor:"#6ee7b7",typography:"serif",imageUrl:"",imageAlt:"",layout:"centered",visualStyle:"calm",linkedValueIds:[],linkedBehaviorIds:[],linkedPatternIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],userId:null},le={serif:"font-serif",sans:"font-sans",mono:"font-mono",display:"font-display"},ne={calm:"Calm",urgent:"Urgent",warm:"Warm",clinical:"Clinical",playful:"Playful"};function oe(s){return s.split(",").map(l=>l.trim()).filter(Boolean)}function L(s){return{title:s.title,message:s.message,triggerSentence:s.triggerSentence,triggerSituation:s.triggerSituation,tags:s.tags,backgroundColor:s.backgroundColor,textColor:s.textColor,accentColor:s.accentColor,typography:s.typography,imageUrl:s.imageUrl,imageAlt:s.imageAlt,layout:s.layout,visualStyle:s.visualStyle,linkedValueIds:s.linkedValueIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedPatternIds:s.linkedPatternIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,userId:s.userId??null}}function A({card:s,compact:l=!1,focused:a=!1,onClick:p}){const c=s.imageUrl.trim().length>0,n=s.layout,d=s.title.trim(),v=s.triggerSentence.trim()||s.triggerSituation.trim();return e.jsxs("button",{type:"button",className:y("group min-w-0 rounded-[26px] border p-2 text-left shadow-[var(--card-shadow)] transition hover:-translate-y-0.5 hover:border-[var(--ui-border-strong)]",a?"border-[color-mix(in_srgb,var(--tertiary)_72%,var(--ui-border-subtle)_28%)]":"border-[var(--ui-border-subtle)]"),onClick:p,children:[e.jsxs("div",{className:y("relative grid min-h-[18rem] overflow-hidden rounded-[20px] border",l?"min-h-[15rem]":"sm:min-h-[21rem]",n==="image_split"&&c?"md:grid-cols-[0.9fr_1.1fr]":""),style:{background:s.backgroundColor,color:s.textColor,borderColor:s.accentColor},children:[c&&n!=="image_split"?e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover opacity-30"}):null,c&&n==="image_split"?e.jsx("div",{className:"relative min-h-[10rem] overflow-hidden",children:e.jsx("img",{src:s.imageUrl,alt:s.imageAlt||d||"Flashcard image",className:"absolute inset-0 size-full object-cover"})}):null,e.jsxs("div",{className:y("relative z-10 flex min-w-0 flex-col p-6",n==="top_left"?"items-start justify-start":"items-center justify-center text-center",n==="poster"?"min-h-[22rem] p-8":"",le[s.typography]),children:[e.jsx("div",{className:"mb-5 h-1.5 w-16 rounded-full",style:{backgroundColor:s.accentColor}}),e.jsx("div",{className:y("max-w-[24rem] text-balance leading-[1.12]",l?"text-2xl":"text-[clamp(1.9rem,4vw,3.45rem)]"),children:s.message||"Write the sentence that should meet you in the hard moment."}),v?e.jsx("div",{className:"mt-6 max-w-md rounded-full border px-3 py-1.5 text-xs font-medium opacity-75",style:{borderColor:s.accentColor},children:v}):null]})]}),e.jsxs("div",{className:"px-2 pt-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[d?e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:d}):null,e.jsx(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:ne[s.visualStyle]})]}),s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.tags.slice(0,5).map(o=>e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-1)] px-2 py-1 text-[11px] text-[var(--ui-ink-soft)]",children:o},o))}):null]})]})}function ce({open:s,editingCard:l,draft:a,users:p,suggestedOwner:c,submitError:n,saving:d,onClose:v,onDelete:o,onDraftChange:i,onSubmit:u}){return s?e.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-[var(--overlay)] px-3 py-4 backdrop-blur-xl sm:items-center sm:p-6",children:e.jsxs("div",{className:"max-h-[min(92dvh,58rem)] w-full max-w-6xl overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--tertiary)]",children:l?"Edit flashcard":"New flashcard"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Message first, retrieval second, styling last."})]}),e.jsx("button",{type:"button","aria-label":"Close flashcard editor",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)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:v,children:e.jsx(q,{className:"size-4"})})]}),e.jsxs("div",{className:"grid max-h-[calc(min(92dvh,58rem)-5rem)] min-h-0 overflow-y-auto p-4 md:grid-cols-[1fr_0.9fr] md:p-5",children:[e.jsxs("div",{className:"grid content-start gap-4 pr-0 md:pr-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Main message"}),e.jsx(J,{className:"mt-2 min-h-28",value:a.message,placeholder:"This urge is a wave. You do not have to obey it.",onChange:r=>i({...a,message:r.target.value})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger sentence"}),e.jsx(h,{className:"mt-2",value:a.triggerSentence,placeholder:"I feel the urge to…",onChange:r=>i({...a,triggerSentence:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Optional title"}),e.jsx(h,{className:"mt-2",value:a.title,placeholder:"Late-night urge card",onChange:r=>i({...a,title:r.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Trigger situation"}),e.jsx(h,{className:"mt-2",value:a.triggerSituation,placeholder:"Late evening shame, loneliness, conflict, or boredom",onChange:r=>i({...a,triggerSituation:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Tags"}),e.jsx(h,{className:"mt-2",value:a.tags.join(", "),placeholder:"urge, sobriety, grounding",onChange:r=>i({...a,tags:oe(r.target.value)})})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:[["backgroundColor","Background"],["textColor","Text"],["accentColor","Accent"]].map(([r,m])=>e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[m,e.jsx("input",{type:"color",value:String(a[r]),className:"h-11 w-full rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-1",onChange:w=>i({...a,[r]:w.target.value})})]},r))}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Typography",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.typography,onChange:r=>i({...a,typography:r.target.value}),children:[e.jsx("option",{value:"serif",children:"Serif"}),e.jsx("option",{value:"sans",children:"Sans"}),e.jsx("option",{value:"mono",children:"Mono"}),e.jsx("option",{value:"display",children:"Display"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Layout",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.layout,onChange:r=>i({...a,layout:r.target.value}),children:[e.jsx("option",{value:"centered",children:"Centered"}),e.jsx("option",{value:"top_left",children:"Top left"}),e.jsx("option",{value:"image_split",children:"Image split"}),e.jsx("option",{value:"poster",children:"Poster"})]})]}),e.jsxs("label",{className:"grid gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:["Tone",e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm normal-case tracking-normal text-[var(--ui-ink-strong)]",value:a.visualStyle,onChange:r=>i({...a,visualStyle:r.target.value}),children:[e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"urgent",children:"Urgent"}),e.jsx("option",{value:"warm",children:"Warm"}),e.jsx("option",{value:"clinical",children:"Clinical"}),e.jsx("option",{value:"playful",children:"Playful"})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image URL"}),e.jsx(h,{className:"mt-2",value:a.imageUrl,placeholder:"https://…",onChange:r=>i({...a,imageUrl:r.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Image alt"}),e.jsx(h,{className:"mt-2",value:a.imageAlt,placeholder:"Describe the image",onChange:r=>i({...a,imageAlt:r.target.value})})]})]}),e.jsx($,{users:p,value:a.userId??null,defaultLabel:ee(c,"Choose flashcard owner"),onChange:r=>i({...a,userId:r}),help:"Flashcards can belong to a human or bot owner while still being searchable by trigger, tags, and linked Psyche records."}),n?e.jsx("div",{className:"rounded-[18px] border border-[var(--danger)]/20 bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:n}):null,e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[l?e.jsx(S,{type:"button",variant:"ghost",onClick:o,children:"Delete"}):e.jsx("span",{}),e.jsx(S,{type:"button",disabled:d,onClick:u,children:d?"Saving...":"Save flashcard"})]})]}),e.jsx("div",{className:"mt-5 min-w-0 md:mt-0",children:e.jsx(A,{card:a,compact:!0})})]})]})}):null}function ye(){var U;const s=O(),l=Q(),[a,p]=T(),c=a.get("focus"),[n,d]=x.useState(""),[v,o]=x.useState(!1),[i,u]=x.useState(null),[r,m]=x.useState(k),[w,C]=x.useState(null),f=H(s.selectedUserIds),E=s.snapshot.users.find(t=>t.id===f)??null;ae(c);const b=K({queryKey:["forge-psyche-flashcards",s.selectedUserIds],queryFn:()=>se(s.selectedUserIds)});x.useEffect(()=>{if(a.get("create")==="1"){u(null),m({...k,userId:f}),o(!0);const t=new URLSearchParams(a);t.delete("create"),p(t,{replace:!0})}},[f,a,p]);const P=F({mutationFn:async t=>{const g=ie.parse(t);return i?Y(i.id,g):V(g)},onSuccess:async()=>{o(!1),u(null),m({...k,userId:f}),C(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])},onError:t=>{C(t instanceof Error?t.message:String(t))}}),_=F({mutationFn:async t=>W(t.id),onSuccess:async()=>{o(!1),u(null),await Promise.all([l.invalidateQueries({queryKey:["forge-psyche-flashcards"]}),l.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),j=((U=b.data)==null?void 0:U.flashcards)??[],I=x.useMemo(()=>{const t=n.trim().toLowerCase();return t?j.filter(g=>[g.title,g.message,g.triggerSentence,g.triggerSituation,...g.tags].join(" ").toLowerCase().includes(t)):j},[j,n]);return b.isLoading?e.jsx(G,{title:"Loading Psyche flashcards"}):b.isError?e.jsx(X,{eyebrow:"Psyche",error:b.error,onRetry:()=>void b.refetch()}):e.jsxs("div",{className:"grid gap-6",children:[e.jsx(re,{title:"Flashcards",titleText:"Flashcards",description:"Small therapeutic reminder cards for urges, trigger moments, mode shifts, and values-based pivots.",actions:e.jsxs(S,{type:"button",onClick:()=>{u(null),m({...k,userId:f}),o(!0)},children:[e.jsx(B,{className:"mr-2 size-4"}),"New flashcard"]})}),e.jsx(Z,{}),e.jsxs("div",{className:"grid gap-4 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4 md:grid-cols-[1fr_auto] md:items-center",children:[e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(z,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-[var(--ui-ink-faint)]"}),e.jsx(h,{value:n,placeholder:"Search message, tags, trigger sentence, or situation",className:"pl-10",onChange:t=>d(t.target.value)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[j.length," saved"]}),e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)]",children:[I.length," visible"]})]})]}),I.length>0?e.jsx("div",{className:"grid gap-5 lg:grid-cols-2 2xl:grid-cols-3",children:I.map(t=>e.jsxs("div",{className:te(c===t.id),children:[e.jsx(A,{card:t,focused:c===t.id,onClick:()=>{u(t),m(L(t)),o(!0)}}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.user?e.jsx(D,{user:t.user,compact:!0}):null,t.imageUrl?e.jsxs(N,{className:"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)]",children:[e.jsx(M,{className:"mr-1 size-3"}),"image"]}):null]}),e.jsx(S,{type:"button",variant:"ghost",onClick:()=>{u(t),m(L(t)),o(!0)},children:"Edit"})]})]},t.id))}):e.jsxs("div",{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[radial-gradient(circle_at_top_left,color-mix(in_srgb,var(--tertiary)_12%,transparent),transparent_46%),var(--ui-surface-section)] p-8 text-center",children:[e.jsx(R,{className:"mx-auto size-8 text-[var(--tertiary)]"}),e.jsx("div",{className:"mt-4 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"No flashcards match this view."}),e.jsx("div",{className:"mx-auto mt-2 max-w-xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create cards for the sentences you want available during urges, shame spirals, critic attacks, and values-based pivots."})]}),e.jsx(ce,{open:v,editingCard:i,draft:r,users:s.snapshot.users,suggestedOwner:E,submitError:w,saving:P.isPending||_.isPending,onClose:()=>{o(!1),u(null),C(null)},onDelete:()=>{i&&_.mutateAsync(i)},onDraftChange:m,onSubmit:()=>void P.mutateAsync(r)})]})}export{ye as PsycheFlashcardsPage};
@@ -1 +1 @@
1
- import{r as h,j as e,aC as m}from"./vendor-kIz9EZnX.js";import{i as j}from"./state-VYvD1QVP.js";import{b as N,P as I}from"./psyche-graph-IkUQRaDK.js";import{u as S,L as G,E as P,ch as E,C as K,b as L,V as B,c as v,Z as V,cj as _,ad as C}from"./index-BHIKoiZ6.js";import{P as H}from"./page-hero-oFHaAjtL.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function T(){var x;const n=S(),[p,f]=h.useState(null),o=j({queryKey:["forge-psyche-overview"],queryFn:C}),r=(x=o.data)==null?void 0:x.overview,l=h.useMemo(()=>r?n.snapshot.goals.map(i=>{const u=r.values.filter(t=>t.linkedGoalIds.includes(i.id)),g=n.snapshot.dashboard.projects.filter(t=>t.goalId===i.id),b=n.snapshot.habits.filter(t=>t.linkedGoalIds.includes(i.id)||t.linkedValueIds.some(d=>u.some(c=>c.id===d))),w=r.reports.filter(t=>t.linkedGoalIds.includes(i.id)),y=r.behaviors.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d))),k=r.beliefs.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d)));return{goal:i,linkedValues:u,linkedProjects:g,linkedHabits:b,linkedReports:w,linkedBehaviors:y,linkedBeliefs:k}}):[],[r,n.snapshot.dashboard.projects,n.snapshot.goals,n.snapshot.habits]),a=h.useMemo(()=>N(l),[l]);if(h.useEffect(()=>{f(a.defaultSelectedId)},[a.defaultSelectedId]),o.isLoading)return e.jsx(G,{eyebrow:"Goal map",title:"Loading the gravity well",description:"Linking goals, values, reports, beliefs, behaviors, and projects back into execution."});if(o.isError||!r)return e.jsx(P,{eyebrow:"Goal map",error:o.error??new Error("Forge returned an empty Psyche overview payload."),onRetry:()=>void o.refetch()});const s=a.inspectors[p??a.defaultSelectedId]??a.inspectors[a.defaultSelectedId];return e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(H,{title:"Goal Map",titleText:"Goal Map",description:"Values orbit each goal. Habits, reports, beliefs, behaviors, and projects reveal where the orbit gets disrupted and how execution reconnects.",badge:`${l.length} goal${l.length===1?"":"s"}`,actions:e.jsxs(e.Fragment,{children:[e.jsx(m,{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-2 text-sm whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"}),e.jsx(m,{to:"/psyche/reports?create=1",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-info-soft)] px-4 py-2 text-sm whitespace-nowrap text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] transition hover:bg-[color-mix(in_srgb,var(--info)_18%,var(--ui-surface-hover)_82%)]",children:"Reflect"})]})}),e.jsx(E,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsx(I,{testId:"goal-gravity-graph",title:"Life direction, value orbit, and execution field",hint:"Drag to inspect the whole field. Select any goal, value, belief, behavior, project, or report to see what it means and where to act next.",nodes:a.nodes,edges:a.edges,fields:a.fields,selectedNodeId:p,onSelectNode:f,minHeightClassName:"min-h-[25rem] sm:min-h-[34rem] lg:min-h-[56rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Beliefs",kind:"belief"},{label:"Behaviors",kind:"behavior"},{label:"Habits",kind:"habit"},{label:"Projects",kind:"project"},{label:"Reports",kind:"report"}],action:l.length===0?e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-accent-soft)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)]",children:"Add first goal"}):e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"})}),e.jsxs(K,{className:"min-w-0 h-fit xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.entityKind?e.jsx(L,{kind:s.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s.eyebrow})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.entityKind?e.jsx(B,{kind:s.entityKind,label:s.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.35rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:s.title}),s.entityKind?null:e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.tone})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:s.summary}),s.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:s.stats.map(i=>e.jsx("div",{className:"break-words rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i},i))}):null,s.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.chips.map(i=>e.jsx(v,{className:"max-w-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i},i))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(m,{to:s.href,className:V("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",s.entityKind?_(s.entityKind,!0):"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"),children:s.ctaLabel})})]})]})]})}export{T as PsycheGoalMapPage};
1
+ import{r as h,j as e,aC as m}from"./vendor-Dnkkx2co.js";import{i as j}from"./state-vCcAT5Hq.js";import{b as N,P as I}from"./psyche-graph-EP5GL612.js";import{u as S,L as G,E as P,ch as E,C as K,b as L,V as B,c as v,Z as V,cj as _,ad as C}from"./index-EqQsXoat.js";import{P as H}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";function T(){var x;const n=S(),[p,f]=h.useState(null),o=j({queryKey:["forge-psyche-overview"],queryFn:C}),r=(x=o.data)==null?void 0:x.overview,l=h.useMemo(()=>r?n.snapshot.goals.map(i=>{const u=r.values.filter(t=>t.linkedGoalIds.includes(i.id)),g=n.snapshot.dashboard.projects.filter(t=>t.goalId===i.id),b=n.snapshot.habits.filter(t=>t.linkedGoalIds.includes(i.id)||t.linkedValueIds.some(d=>u.some(c=>c.id===d))),w=r.reports.filter(t=>t.linkedGoalIds.includes(i.id)),y=r.behaviors.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d))),k=r.beliefs.filter(t=>t.linkedValueIds.some(d=>u.some(c=>c.id===d)));return{goal:i,linkedValues:u,linkedProjects:g,linkedHabits:b,linkedReports:w,linkedBehaviors:y,linkedBeliefs:k}}):[],[r,n.snapshot.dashboard.projects,n.snapshot.goals,n.snapshot.habits]),a=h.useMemo(()=>N(l),[l]);if(h.useEffect(()=>{f(a.defaultSelectedId)},[a.defaultSelectedId]),o.isLoading)return e.jsx(G,{eyebrow:"Goal map",title:"Loading the gravity well",description:"Linking goals, values, reports, beliefs, behaviors, and projects back into execution."});if(o.isError||!r)return e.jsx(P,{eyebrow:"Goal map",error:o.error??new Error("Forge returned an empty Psyche overview payload."),onRetry:()=>void o.refetch()});const s=a.inspectors[p??a.defaultSelectedId]??a.inspectors[a.defaultSelectedId];return e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(H,{title:"Goal Map",titleText:"Goal Map",description:"Values orbit each goal. Habits, reports, beliefs, behaviors, and projects reveal where the orbit gets disrupted and how execution reconnects.",badge:`${l.length} goal${l.length===1?"":"s"}`,actions:e.jsxs(e.Fragment,{children:[e.jsx(m,{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-2 text-sm whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"}),e.jsx(m,{to:"/psyche/reports?create=1",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--ui-info-soft)] px-4 py-2 text-sm whitespace-nowrap text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] transition hover:bg-[color-mix(in_srgb,var(--info)_18%,var(--ui-surface-hover)_82%)]",children:"Reflect"})]})}),e.jsx(E,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsx(I,{testId:"goal-gravity-graph",title:"Life direction, value orbit, and execution field",hint:"Drag to inspect the whole field. Select any goal, value, belief, behavior, project, or report to see what it means and where to act next.",nodes:a.nodes,edges:a.edges,fields:a.fields,selectedNodeId:p,onSelectNode:f,minHeightClassName:"min-h-[25rem] sm:min-h-[34rem] lg:min-h-[56rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Beliefs",kind:"belief"},{label:"Behaviors",kind:"behavior"},{label:"Habits",kind:"habit"},{label:"Projects",kind:"project"},{label:"Reports",kind:"report"}],action:l.length===0?e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-accent-soft)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)]",children:"Add first goal"}):e.jsx(m,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[var(--ui-surface-2)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open goals"})}),e.jsxs(K,{className:"min-w-0 h-fit xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.entityKind?e.jsx(L,{kind:s.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s.eyebrow})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.entityKind?e.jsx(B,{kind:s.entityKind,label:s.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.35rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:s.title}),s.entityKind?null:e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.tone})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:s.summary}),s.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:s.stats.map(i=>e.jsx("div",{className:"break-words rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i},i))}):null,s.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.chips.map(i=>e.jsx(v,{className:"max-w-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i},i))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(m,{to:s.href,className:V("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",s.entityKind?_(s.entityKind,!0):"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]"),children:s.ctaLabel})})]})]})]})}export{T as PsycheGoalMapPage};
@@ -1 +1 @@
1
- import{r as $,b5 as Xt,j as c,cI as Rt,b4 as zt,cn as Ct,cJ as Pt,cK as Nt}from"./vendor-kIz9EZnX.js";import{Z as dt,B as ot,aS as gt}from"./index-BHIKoiZ6.js";function U(n,i,s){return`${i}:${n}:${s}`}function ft(n,i,s){return Math.min(Math.max(n,i),s)}function mt(n,i,s){return Math.min(s,Math.max(1,Math.ceil(n.trim().length/i)))}function _t(n,{compact:i}){const s=mt(n,i?13:14,4),p=(i?114:156)+(s-1)*(i?12:18)+Math.min(24,Math.max(0,n.trim().length-18))*(i?.7:1);return ft(p,i?118:164,i?154:210)}function Tt(n,{compact:i}){const s=mt(n,i?11:13,3),p=(i?40:48)+(s-1)*(i?6:8)+Math.min(i?18:26,Math.max(0,n.trim().length-(i?12:16)))*(i?.45:.55);return ft(p,i?42:50,i?56:68)}function tt(n,{compact:i,emphasis:s=!1}){const p=mt(n,i?16:s?22:20,s?3:2);return{width:ft((i?s?184:152:s?224:176)+Math.min(n.length,48)*(i?1.8:2.15),i?s?188:156:s?228:184,i?s?248:208:s?300:244),height:p===1?i?64:70:p===2?i?82:92:i?98:110}}function kt(n){if(n.kind==="goal"||n.kind==="value"||n.kind==="ghost"){const i=n.radius??(n.kind==="goal"?76:34);return{halfWidth:i,halfHeight:i}}return{halfWidth:(n.width??146)/2,halfHeight:(n.height??58)/2}}function Et(n,{compact:i}){const s=n.map(u=>({...u,homeX:u.x,homeY:u.y,locked:u.kind==="goal"||u.kind==="ghost"})),x=i?28:40,p=i?.08:.06;for(let u=0;u<180;u+=1){for(const r of s)r.locked||(r.x+=(r.homeX-r.x)*p,r.y+=(r.homeY-r.y)*p);for(let r=0;r<s.length;r+=1)for(let v=r+1;v<s.length;v+=1){const g=s[r],w=s[v],h=kt(g),L=kt(w),j=w.x-g.x,z=w.y-g.y,y=h.halfWidth+L.halfWidth+x-Math.abs(j),b=h.halfHeight+L.halfHeight+x-Math.abs(z);if(y<=0||b<=0)continue;const I=y<b?"x":"y",P=Math.sign(I==="x"?j||v-r||1:z||v-r||1),E=(I==="x"?y:b)/(g.locked||w.locked?1:2);g.locked||(I==="x"?g.x-=P*E:g.y-=P*E),w.locked||(I==="x"?w.x+=P*E:w.y+=P*E)}}return s.map(({homeX:u,homeY:r,locked:v,...g})=>g)}function St(){return{nodes:[{id:"ghost_goal_north",kind:"ghost",x:-250,y:-20,radius:68,label:"First goal",meta:"Goal",href:"/goals"},{id:"ghost_goal_center",kind:"ghost",x:0,y:34,radius:74,label:"Life goals",meta:"Goal",href:"/goals"},{id:"ghost_goal_south",kind:"ghost",x:250,y:-10,radius:68,label:"Direction",meta:"Goal",href:"/goals"}],edges:[],fields:[],inspectors:{ghost_goal_center:{id:"ghost_goal_center",eyebrow:"Goals",title:"Add the first life goal",summary:"The graph is already laid out. Once a goal exists, values, reports, beliefs, and behaviors will start orbiting it instead of staying fragmented.",href:"/goals",ctaLabel:"Open life goals",tone:"sky",entityKind:"goal",chips:["Goals","Values","Reports"],stats:["0 goals mapped yet"]}},defaultSelectedId:"ghost_goal_center"}}function Wt(n,{compact:i=!1}={}){var w;if(n.length===0)return St();const s=[],x=[],p=[],u={},r=i?560:840,v=-((n.length-1)*r)/2;n.forEach((h,L)=>{const j=v+L*r,z=L%2===0?92:146,y=h.linkedBehaviors.length+h.linkedBeliefs.length+h.linkedReports.length+h.linkedHabits.length,b=`goal:${h.goal.id}`;s.push({id:b,kind:"goal",x:j,y:z,radius:_t(h.goal.title,{compact:i}),tone:"amber",label:h.goal.title,href:`/goals/${h.goal.id}`}),u[b]={id:b,eyebrow:"Goal",title:h.goal.title,summary:h.goal.description,href:`/goals/${h.goal.id}`,ctaLabel:"Open goal",tone:"amber",entityKind:"goal",chips:h.linkedValues.slice(0,4).map(e=>e.title),stats:[`${h.linkedValues.length} linked value${h.linkedValues.length===1?"":"s"}`,`${h.linkedProjects.length} live project${h.linkedProjects.length===1?"":"s"}`,`${h.linkedHabits.length} linked habit${h.linkedHabits.length===1?"":"s"}`,`${y} friction signal${y===1?"":"s"}`]},y>0&&p.push({id:`field:${h.goal.id}`,x:j+18,y:z+20,radiusX:i?144:176,radiusY:i?104:132,tone:"rose",opacity:Math.min(.42,.14+y*.04)});const I=i?208:282;h.linkedValues.slice(0,i?4:5).forEach((e,d)=>{const m=(-95+d*(i?78:64))*(Math.PI/180),k=Tt(e.title,{compact:i}),G=j+Math.cos(m)*I,W=z+Math.sin(m)*I,K=U(h.goal.id,"value",e.id);s.push({id:K,kind:"value",x:G,y:W,radius:k,tone:"mint",label:e.title,meta:`${e.linkedGoalIds.length} goal${e.linkedGoalIds.length===1?"":"s"}`,href:`/psyche/values?focus=${e.id}#values-atlas`}),x.push({id:`${b}->${K}`,from:b,to:K,tone:"mint",strength:"medium"}),u[K]={id:K,eyebrow:"Value",title:e.title,summary:e.valuedDirection||e.whyItMatters||e.description,href:`/psyche/values?focus=${e.id}#values-atlas`,ctaLabel:"Open values",tone:"mint",entityKind:"value",chips:e.committedActions.slice(0,3),stats:[`${e.linkedProjectIds.length} linked project${e.linkedProjectIds.length===1?"":"s"}`,`${e.linkedTaskIds.length} linked task${e.linkedTaskIds.length===1?"":"s"}`]}});const P=h.linkedProjects.slice(0,i?2:3).map(e=>({project:e,size:tt(e.title,{compact:i,emphasis:!0})})),E=i?24:30;let N=-(P.reduce((e,d)=>e+d.size.width,0)+Math.max(0,P.length-1)*E)/2;P.forEach(({project:e,size:d},m)=>{const k=U(h.goal.id,"project",e.id),G=j+N+d.width/2,W=z-(i?330:434)-m*(i?16:20);N+=d.width+E,s.push({id:k,kind:"project",x:G,y:W,width:d.width,height:d.height,tone:"sky",label:e.title,meta:"Project",href:`/projects/${e.id}`}),x.push({id:`${b}->${k}`,from:b,to:k,tone:"sky",strength:"medium"}),u[k]={id:k,eyebrow:"Project",title:e.title,summary:e.description,href:`/projects/${e.id}`,ctaLabel:"Open project",tone:"sky",entityKind:"project",chips:[e.status,e.goalTitle],stats:[`${e.progress}% progress`,`${e.activeTaskCount} active task${e.activeTaskCount===1?"":"s"}`]}}),h.linkedHabits.slice(0,i?2:3).forEach((e,d)=>{const m=U(h.goal.id,"habit",e.id),k=tt(e.title,{compact:i}),G=j-(i?44:58),W=z+(i?228:294)+d*(i?92:104);s.push({id:m,kind:"habit",x:G,y:W,width:k.width,height:k.height,tone:"mint",label:e.title,meta:e.polarity,href:"/habits"}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"mint",strength:e.dueToday?"high":"medium"}),u[m]={id:m,eyebrow:"Habit",title:e.title,summary:e.description||"Recurring operating record connected directly to this goal field.",href:"/habits",ctaLabel:"Open habits",tone:"mint",entityKind:"habit",chips:[e.polarity,e.frequency,e.dueToday?"due today":"checked in"],stats:[`${e.streakCount} streak`,`${e.rewardXp}/${e.penaltyXp} xp flow`]}});let O=z+(i?132:156);h.linkedBehaviors.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"behavior",e.id),m=tt(e.title,{compact:i}),k=j-(i?272:352);s.push({id:d,kind:"behavior",x:k,y:O,width:m.width,height:m.height,tone:"orange",label:e.title,meta:e.kind,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"orange",dashed:e.kind!=="committed",strength:e.kind==="committed"?"medium":"low"}),u[d]={id:d,eyebrow:"Behavior",title:e.title,summary:e.replacementMove||e.description||e.urgeStory,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`,ctaLabel:"Open behaviors",tone:"orange",entityKind:"behavior",chips:[e.kind,...e.commonCues.slice(0,2)],stats:[e.shortTermPayoff?"Short-term payoff mapped":"Payoff still to map",e.longTermCost?"Long-term cost mapped":"Cost still to map"]},O+=m.height+(i?18:22)});let X=z+(i?8:10);h.linkedBeliefs.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"belief",e.id),m=tt(e.statement,{compact:i,emphasis:!0}),k=j+(i?278:362);s.push({id:d,kind:"belief",x:k,y:X,width:m.width,height:m.height,tone:"violet",label:e.statement,meta:"belief",href:`/psyche/schemas-beliefs?focus=${e.id}`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"violet",dashed:!0,strength:"low"}),u[d]={id:d,eyebrow:"Belief",title:e.statement,summary:e.flexibleAlternative||e.originNote||"Belief script attached to this part of the map.",href:`/psyche/schemas-beliefs?focus=${e.id}`,ctaLabel:"Open beliefs",tone:"violet",entityKind:"belief",chips:[e.beliefType,`${e.confidence}% grip`],stats:[`${e.linkedBehaviorIds.length} linked behavior${e.linkedBehaviorIds.length===1?"":"s"}`,`${e.linkedReportIds.length} linked report${e.linkedReportIds.length===1?"":"s"}`]},X+=m.height+(i?18:22)});const S=h.linkedReports.slice(0,i?2:3).map(e=>({report:e,size:tt(e.title,{compact:i})})),H=i?20:26;let J=-(S.reduce((e,d)=>e+d.size.width,0)+Math.max(0,S.length-1)*H)/2;S.forEach(({report:e,size:d})=>{const m=U(h.goal.id,"report",e.id),k=j+J+d.width/2,G=z+(i?332:430);J+=d.width+H,s.push({id:m,kind:"report",x:k,y:G,width:d.width,height:d.height,tone:"blue",label:e.title,meta:e.status,href:`/psyche/reports/${e.id}`}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"sky",strength:"medium"}),u[m]={id:m,eyebrow:"Report",title:e.title,summary:e.eventSituation||e.customEventType||"Reflective chain linked into this goal.",href:`/psyche/reports/${e.id}`,ctaLabel:"Open report",tone:"blue",entityKind:"report",chips:[e.status,...e.nextMoves.slice(0,2)],stats:[`${e.emotions.length} emotion${e.emotions.length===1?"":"s"}`,`${e.behaviors.length} move${e.behaviors.length===1?"":"s"}`]}})});const g=((w=s[0])==null?void 0:w.id)??"ghost_goal_center";return{nodes:Et(s,{compact:i}),edges:x,fields:p,inspectors:u,defaultSelectedId:g}}const et={mint:"color-mix(in srgb, var(--success) 64%, transparent)",sky:"color-mix(in srgb, var(--info) 66%, transparent)",violet:"color-mix(in srgb, var(--primary) 72%, transparent)",rose:"color-mix(in srgb, var(--danger) 68%, transparent)",amber:"color-mix(in srgb, var(--warning) 68%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 72%, transparent)",blue:"color-mix(in srgb, var(--info) 72%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 52%, transparent)"},it={mint:"color-mix(in srgb, var(--success) 18%, transparent)",sky:"color-mix(in srgb, var(--info) 18%, transparent)",violet:"color-mix(in srgb, var(--primary) 18%, transparent)",rose:"color-mix(in srgb, var(--danger) 18%, transparent)",amber:"color-mix(in srgb, var(--warning) 18%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 18%, transparent)",blue:"color-mix(in srgb, var(--info) 18%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 12%, transparent)"},A={mint:"color-mix(in srgb, var(--success) 56%, var(--ui-ink-strong) 44%)",sky:"color-mix(in srgb, var(--info) 56%, var(--ui-ink-strong) 44%)",violet:"color-mix(in srgb, var(--primary) 60%, var(--ui-ink-strong) 40%)",rose:"color-mix(in srgb, var(--danger) 58%, var(--ui-ink-strong) 42%)",amber:"color-mix(in srgb, var(--warning) 60%, var(--ui-ink-strong) 40%)",orange:"color-mix(in srgb, var(--tertiary) 60%, var(--ui-ink-strong) 40%)",blue:"color-mix(in srgb, var(--info) 58%, var(--ui-ink-strong) 42%)",slate:"var(--ui-ink-medium)"};function wt(n){switch(n){case"goal":case"value":case"behavior":case"belief":case"report":case"project":case"habit":return n;default:return null}}function Dt(n){if(n.tone)return n.tone;switch(n.kind){case"goal":return"amber";case"value":return"mint";case"belief":return"violet";case"behavior":return"orange";case"project":return"sky";case"habit":return"mint";case"report":return"blue";default:return"slate"}}function Gt(n){if(n.kind==="ghost")return n.meta??null;const i=wt(n.kind);return i?gt(i).label:n.meta??null}function ut(n,i,s){return Math.min(Math.max(n,i),s)}function lt(n,i,s=3){const x=n.trim().split(/\s+/),p=[];let u="";for(let g=0;g<x.length;g+=1){const w=x[g],h=u?`${u} ${w}`:w;if(h.length>i&&u){if(p.push(u),p.length>=s-1){u=[w,...x.slice(g+1)].join(" ");break}u=w}else u=h}u&&p.push(u);const r=p.slice(0,s),v=r.length-1;return v>=0&&r[v].length>i&&(r[v]=`${r[v].slice(0,Math.max(1,i-1)).trimEnd()}…`),r}function Vt(n,i){if(n.length===0&&i.length===0)return{minX:-360,maxX:360,minY:-240,maxY:240};let s=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const r of n){const v=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.width??124)/2,g=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.height??56)/2,w=r.meta&&(r.kind==="goal"||r.kind==="ghost")?48:0;s=Math.min(s,r.x-v),x=Math.max(x,r.x+v),p=Math.min(p,r.y-g-w),u=Math.max(u,r.y+g)}for(const r of i)s=Math.min(s,r.x-r.radiusX),x=Math.max(x,r.x+r.radiusX),p=Math.min(p,r.y-r.radiusY),u=Math.max(u,r.y+r.radiusY);return{minX:s,maxX:x,minY:p,maxY:u}}function vt(n){return{x:n.x,y:n.y}}function Bt(n){if(n.kind==="goal"){const i=n.radius??112;return lt(n.label,Math.max(14,Math.floor(i/7.2)),4)}if(n.kind==="value"||n.kind==="ghost"){const i=n.radius??40;return lt(n.label,Math.max(12,Math.floor(i/3)),3)}return n.kind==="project"?lt(n.label,Math.max(18,Math.floor((n.width??220)/10)),3):lt(n.label,Math.max(16,Math.floor((n.width??180)/10.5)),2)}function Ft(n){switch(n){case"goal":return"amber";case"project":return"sky";case"value":return"mint";case"behavior":return"orange";case"belief":return"violet";case"report":return"blue";default:return"slate"}}function Kt({nodes:n,edges:i,fields:s=[],title:x,hint:p,action:u,legend:r,selectedNodeId:v,onSelectNode:g,minHeightClassName:w="min-h-[34rem] lg:min-h-[44rem]",compact:h=!1,testId:L}){const j=$.useRef(null),z=Xt(),[y,b]=$.useState({width:0,height:0}),[I,P]=$.useState({scale:1,x:0,y:0}),[E,q]=$.useState(null),N=$.useRef(null),O=$.useRef({scale:1,x:0,y:0}),X=$.useRef(new Map),S=$.useRef(null),H=$.useRef(0),D=$.useRef(!1),J=$.useMemo(()=>new Map(n.map(t=>[t.id,t])),[n]),e=$.useMemo(()=>Vt(n,s),[s,n]),d=y.width>0&&y.width<640;$.useEffect(()=>{if(!j.current||typeof ResizeObserver>"u")return;const t=new ResizeObserver(a=>{const l=a[0];b({width:l.contentRect.width,height:l.contentRect.height})});return t.observe(j.current),()=>t.disconnect()},[]);const m=$.useCallback(()=>{if(!y.width||!y.height)return;const t=d?260:h?140:190,a=Math.max(e.maxX-e.minX,1),l=Math.max(e.maxY-e.minY,1),o=ut(Math.min(y.width/(a+t),y.height/(l+t)),d?.16:h?.4:.46,d?.76:h?1.04:1.18),f=(e.minX+e.maxX)/2,Y=(e.minY+e.maxY)/2;P({scale:o,x:y.width/2-f*o,y:y.height/2-Y*o})},[e.maxX,e.maxY,e.minX,e.minY,h,y.height,y.width,d]);$.useEffect(()=>{O.current=I},[I]),$.useEffect(()=>{D.current||m()},[m]);const k=$.useCallback((t,a,l)=>{const o=ut(t,.28,1.9);P(f=>{if(a==null||l==null)return{...f,scale:o};const Y=(a-f.x)/f.scale,V=(l-f.y)/f.scale;return{scale:o,x:a-Y*o,y:l-V*o}})},[]),G=$.useCallback(()=>{const t=[...X.current.values()];if(t.length<2){S.current=null;return}const[a,l]=t,o=Math.hypot(l.x-a.x,l.y-a.y);if(!Number.isFinite(o)||o<=0){S.current=null;return}const f=O.current;S.current={startDistance:o,startScale:f.scale,startViewportX:f.x,startViewportY:f.y,startMidpointX:(a.x+l.x)/2,startMidpointY:(a.y+l.y)/2}},[]),W=t=>{var o;t.preventDefault();const a=(o=j.current)==null?void 0:o.getBoundingClientRect();if(!a)return;D.current=!0;const l=t.deltaY<0?1.1:.9;k(I.scale*l,t.clientX-a.left,t.clientY-a.top)},K=t=>{var f;const a=(f=j.current)==null?void 0:f.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.set(t.pointerId,{x:l,y:o}),X.current.size===1){const Y=O.current;N.current={pointerId:t.pointerId,originX:Y.x,originY:Y.y,startX:l,startY:o}}else N.current=null,G();t.currentTarget.setPointerCapture(t.pointerId)},$t=t=>{var V;const a=(V=j.current)==null?void 0:V.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.has(t.pointerId)&&X.current.set(t.pointerId,{x:l,y:o}),S.current&&X.current.size>=2){const[R,_]=[...X.current.values()],C=Math.hypot(_.x-R.x,_.y-R.y);if(Number.isFinite(C)&&C>0){D.current=!0,H.current=Date.now()+240;const Q=(R.x+_.x)/2,F=(R.y+_.y)/2,T=S.current,Z=ut(T.startScale*C/T.startDistance,.24,1.42),ct=(T.startMidpointX-T.startViewportX)/T.startScale,ht=(T.startMidpointY-T.startViewportY)/T.startScale;P({scale:Z,x:Q-ct*Z,y:F-ht*Z})}return}if(!N.current||N.current.pointerId!==t.pointerId||X.current.size!==1)return;D.current=!0;const f=l-N.current.startX,Y=o-N.current.startY;(Math.abs(f)>3||Math.abs(Y)>3)&&(H.current=Date.now()+240),P(R=>{var _,C;return{...R,x:(((_=N.current)==null?void 0:_.originX)??R.x)+f,y:(((C=N.current)==null?void 0:C.originY)??R.y)+Y}})},xt=t=>{if(X.current.delete(t.pointerId),X.current.size<2&&(S.current=null),X.current.size===1){const[a,l]=[...X.current.entries()][0]??[];if(a!=null&&l){const o=O.current;N.current={pointerId:a,originX:o.x,originY:o.y,startX:l.x,startY:l.y}}}else N.current=null;t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)},nt=E??v??null,rt=$.useCallback(t=>{Date.now()<H.current||(g==null||g(t.id),t.href&&z(t.href))},[z,g]);return c.jsxs("section",{"data-testid":L,className:dt("overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--card-shadow)]","px-3 py-3 sm:px-4 sm:py-4 lg:px-5 lg:py-5"),children:[c.jsxs("div",{className:"mb-3 flex min-w-0 flex-wrap items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Gravity well"}),c.jsx("h2",{className:dt("mt-2 break-words font-display leading-none text-[var(--ui-ink-strong)]",h?"text-[clamp(1.25rem,2vw,1.7rem)]":"text-[clamp(1.45rem,2.8vw,2.3rem)]"),children:x}),p?c.jsx("p",{className:"mt-1.5 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:d?"Select a node, pan the field, and open the full map when you need the wider structure.":p}):null]}),c.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:u})]}),c.jsxs("div",{ref:j,className:dt("group relative overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] touch-none",w),style:{touchAction:"none"},onWheel:W,onPointerDown:K,onPointerMove:$t,onPointerUp:xt,onPointerCancel:xt,children:[c.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_center,color-mix(in_srgb,var(--success)_8%,transparent),transparent_28%),radial-gradient(circle_at_20%_20%,color-mix(in_srgb,var(--primary)_10%,transparent),transparent_24%),var(--ui-surface-section)]"}),c.jsxs("div",{className:"absolute left-3 top-3 z-10 inline-flex max-w-[calc(100%-7rem)] items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-2.5 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] backdrop-blur-xl sm:left-4 sm:top-4 sm:max-w-none sm:px-3",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(Rt,{className:"size-3.5"}),d?"Drag or pinch":"Drag to pan, scroll to zoom"]}),c.jsxs("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5 sm:right-4 sm:top-4 sm:max-w-none sm:gap-2",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom in",onClick:()=>{D.current=!0,k(I.scale*1.12,y.width-96,72)},children:c.jsx(zt,{className:"size-4"})}),c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom out",onClick:()=>{D.current=!0,k(I.scale*.88,y.width-96,72)},children:c.jsx(Ct,{className:"size-4"})}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[4.75rem] sm:px-3","aria-label":"Fit graph",onClick:()=>{D.current=!0,m()},children:[c.jsx(Pt,{className:"size-4"}),d?null:"Fit"]}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[5.5rem] sm:px-3","aria-label":"Reset graph",onClick:()=>{D.current=!1,m()},children:[c.jsx(Nt,{className:"size-4"}),d?null:"Reset"]})]}),r&&r.length>0&&!d?c.jsx("div",{className:"absolute bottom-4 left-4 z-10 flex flex-wrap items-center gap-2 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-xs text-[var(--ui-ink-soft)] backdrop-blur-xl",children:r.map(t=>{const a=t.kind?Ft(t.kind):t.tone??"slate",l=t.kind?gt(t.kind).icon:null;return c.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap rounded-full bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[l?c.jsx(l,{className:"size-3.5",color:A[a],strokeWidth:2.1}):c.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:et[a]}}),t.label]},t.label)})}):null,c.jsxs("svg",{className:"relative z-[1] h-full w-full overflow-hidden",viewBox:`0 0 ${y.width||1200} ${y.height||760}`,role:"img","aria-label":x,style:{overflow:"hidden"},children:[c.jsx("defs",{children:c.jsx("filter",{id:"forge-graph-blur",children:c.jsx("feGaussianBlur",{stdDeviation:"34"})})}),c.jsxs("g",{transform:`translate(${I.x} ${I.y}) scale(${I.scale})`,children:[s.map(t=>c.jsx("ellipse",{cx:t.x,cy:t.y,rx:t.radiusX,ry:t.radiusY,fill:it[t.tone??"rose"],opacity:t.opacity??.42,filter:"url(#forge-graph-blur)"},t.id)),n.filter(t=>t.kind==="goal"||t.kind==="ghost").map(t=>{const a=t.radius??76;return c.jsx("g",{opacity:t.kind==="ghost"?.28:.55,children:[a+74,a+124].map((l,o)=>c.jsx("circle",{cx:t.x,cy:t.y,r:l,fill:"none",stroke:o===0?"var(--ui-border-subtle)":"var(--ui-border-strong)",strokeDasharray:o===0?"0":"10 10"},`${t.id}-ring-${l}`))},`${t.id}-orbital-lanes`)}),i.map(t=>{const a=J.get(t.from),l=J.get(t.to);if(!a||!l)return null;const o=vt(a),f=vt(l),Y=(o.x+f.x)/2,V=(o.y+f.y)/2,R=Math.max(24,Math.abs(o.x-f.x)*.08),_=Y,C=V-R;return c.jsx("path",{d:`M ${o.x} ${o.y} Q ${_} ${C} ${f.x} ${f.y}`,fill:"none",stroke:et[t.tone??"slate"],strokeWidth:t.strength==="high"?3:t.strength==="medium"?2.2:1.6,strokeDasharray:t.dashed?"8 8":void 0,opacity:nt&&t.from!==nt&&t.to!==nt?.18:.62},t.id)}),n.map(t=>{t.id;const a=E===t.id,l=nt===t.id,o=Dt(t),f=Gt(t),Y=Bt(t),V=wt(t.kind),R=V?gt(V).icon:null;if(t.kind==="goal"||t.kind==="value"||t.kind==="ghost"){const M=t.radius??(t.kind==="goal"?76:34),st=f?t.y-M-(t.kind==="goal"?18:10):null,yt=t.kind==="goal"?20:14.5,at=t.kind==="goal"?28:16,It=t.kind==="goal"?t.y-M*.34:t.kind==="value"?t.y-M*.3:t.y-M*.2,Yt=t.kind==="goal"?t.y+M*.2:t.y+10;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(B=>B===t.id?null:B),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("circle",{cx:t.x,cy:t.y,r:M+(l?14:0),fill:l?it[o]:"transparent",stroke:l?et[o]:"transparent",opacity:a?.98:.9}),c.jsx("circle",{cx:t.x,cy:t.y,r:M+(a?2:0),fill:t.kind==="ghost"?"var(--ui-surface-1)":it[o],stroke:t.kind==="ghost"?"var(--ui-border-strong)":et[o],strokeDasharray:t.kind==="ghost"?"8 8":void 0,strokeWidth:l?2.8:1.6}),f?c.jsx("text",{x:t.x,y:st??t.y-12,textAnchor:"middle",fontSize:t.kind==="goal"?"11.5":"10.5",fill:t.kind==="ghost"?"var(--ui-ink-soft)":A[o],style:{letterSpacing:"0.18em",textTransform:"uppercase"},children:f}):null,R?c.jsx(R,{x:t.x-at/2,y:It-at/2,width:at,height:at,color:A[o],strokeWidth:2.1}):null,Y.map((B,bt)=>c.jsx("text",{x:t.x,y:Yt+bt*yt-(Y.length-1)*yt/2,textAnchor:"middle",fontSize:t.kind==="goal"?21:12.8,fontWeight:t.kind==="goal"?600:500,fill:t.kind==="ghost"?"var(--ui-ink-strong)":A[o],children:B},`${t.id}-${B}-${bt}`))]},t.id)}const _=t.width??146,C=t.height??58,Q=t.x-_/2,F=t.y-C/2,T=t.kind==="project"?14:13,Z=Q+14,ct=F+13,ht=F+22,jt=f?F+C*.65:F+C*.56,pt=t.kind==="project"?16:15,Mt=t.kind==="project"?14.2:13.2;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(M=>M===t.id?null:M),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("rect",{x:Q-(l?6:0),y:F-(l?6:0),rx:"28",ry:"28",width:_+(l?12:0),height:C+(l?12:0),fill:l?it[o]:"transparent"}),c.jsx("rect",{x:Q-(a?2:0),y:F-(a?2:0),rx:"22",ry:"22",width:_+(a?4:0),height:C+(a?4:0),fill:it[o],stroke:et[o],strokeWidth:l?2.3:1.3}),R?c.jsx(R,{x:Z,y:ct,width:T,height:T,color:A[o],strokeWidth:2.1}):null,f?c.jsx("text",{x:Z+T+8,y:ht,textAnchor:"start",fontSize:"9.5",fill:A[o],style:{letterSpacing:"0.16em",textTransform:"uppercase",opacity:.82},children:f}):null,Y.map((M,st)=>c.jsx("text",{x:t.x,y:jt+st*pt-(Y.length-1)*pt/2,textAnchor:"middle",fontSize:Mt,fontWeight:600,fill:A[o],children:M},`${t.id}-${M}-${st}`))]},t.id)})]})]})]})]})}export{Kt as P,Wt as b};
1
+ import{r as $,b5 as Xt,j as c,cI as Rt,b4 as zt,cn as Ct,cJ as Pt,cK as Nt}from"./vendor-Dnkkx2co.js";import{Z as dt,B as ot,aS as gt}from"./index-EqQsXoat.js";function U(n,i,s){return`${i}:${n}:${s}`}function ft(n,i,s){return Math.min(Math.max(n,i),s)}function mt(n,i,s){return Math.min(s,Math.max(1,Math.ceil(n.trim().length/i)))}function _t(n,{compact:i}){const s=mt(n,i?13:14,4),p=(i?114:156)+(s-1)*(i?12:18)+Math.min(24,Math.max(0,n.trim().length-18))*(i?.7:1);return ft(p,i?118:164,i?154:210)}function Tt(n,{compact:i}){const s=mt(n,i?11:13,3),p=(i?40:48)+(s-1)*(i?6:8)+Math.min(i?18:26,Math.max(0,n.trim().length-(i?12:16)))*(i?.45:.55);return ft(p,i?42:50,i?56:68)}function tt(n,{compact:i,emphasis:s=!1}){const p=mt(n,i?16:s?22:20,s?3:2);return{width:ft((i?s?184:152:s?224:176)+Math.min(n.length,48)*(i?1.8:2.15),i?s?188:156:s?228:184,i?s?248:208:s?300:244),height:p===1?i?64:70:p===2?i?82:92:i?98:110}}function kt(n){if(n.kind==="goal"||n.kind==="value"||n.kind==="ghost"){const i=n.radius??(n.kind==="goal"?76:34);return{halfWidth:i,halfHeight:i}}return{halfWidth:(n.width??146)/2,halfHeight:(n.height??58)/2}}function Et(n,{compact:i}){const s=n.map(u=>({...u,homeX:u.x,homeY:u.y,locked:u.kind==="goal"||u.kind==="ghost"})),x=i?28:40,p=i?.08:.06;for(let u=0;u<180;u+=1){for(const r of s)r.locked||(r.x+=(r.homeX-r.x)*p,r.y+=(r.homeY-r.y)*p);for(let r=0;r<s.length;r+=1)for(let v=r+1;v<s.length;v+=1){const g=s[r],w=s[v],h=kt(g),L=kt(w),j=w.x-g.x,z=w.y-g.y,y=h.halfWidth+L.halfWidth+x-Math.abs(j),b=h.halfHeight+L.halfHeight+x-Math.abs(z);if(y<=0||b<=0)continue;const I=y<b?"x":"y",P=Math.sign(I==="x"?j||v-r||1:z||v-r||1),E=(I==="x"?y:b)/(g.locked||w.locked?1:2);g.locked||(I==="x"?g.x-=P*E:g.y-=P*E),w.locked||(I==="x"?w.x+=P*E:w.y+=P*E)}}return s.map(({homeX:u,homeY:r,locked:v,...g})=>g)}function St(){return{nodes:[{id:"ghost_goal_north",kind:"ghost",x:-250,y:-20,radius:68,label:"First goal",meta:"Goal",href:"/goals"},{id:"ghost_goal_center",kind:"ghost",x:0,y:34,radius:74,label:"Life goals",meta:"Goal",href:"/goals"},{id:"ghost_goal_south",kind:"ghost",x:250,y:-10,radius:68,label:"Direction",meta:"Goal",href:"/goals"}],edges:[],fields:[],inspectors:{ghost_goal_center:{id:"ghost_goal_center",eyebrow:"Goals",title:"Add the first life goal",summary:"The graph is already laid out. Once a goal exists, values, reports, beliefs, and behaviors will start orbiting it instead of staying fragmented.",href:"/goals",ctaLabel:"Open life goals",tone:"sky",entityKind:"goal",chips:["Goals","Values","Reports"],stats:["0 goals mapped yet"]}},defaultSelectedId:"ghost_goal_center"}}function Wt(n,{compact:i=!1}={}){var w;if(n.length===0)return St();const s=[],x=[],p=[],u={},r=i?560:840,v=-((n.length-1)*r)/2;n.forEach((h,L)=>{const j=v+L*r,z=L%2===0?92:146,y=h.linkedBehaviors.length+h.linkedBeliefs.length+h.linkedReports.length+h.linkedHabits.length,b=`goal:${h.goal.id}`;s.push({id:b,kind:"goal",x:j,y:z,radius:_t(h.goal.title,{compact:i}),tone:"amber",label:h.goal.title,href:`/goals/${h.goal.id}`}),u[b]={id:b,eyebrow:"Goal",title:h.goal.title,summary:h.goal.description,href:`/goals/${h.goal.id}`,ctaLabel:"Open goal",tone:"amber",entityKind:"goal",chips:h.linkedValues.slice(0,4).map(e=>e.title),stats:[`${h.linkedValues.length} linked value${h.linkedValues.length===1?"":"s"}`,`${h.linkedProjects.length} live project${h.linkedProjects.length===1?"":"s"}`,`${h.linkedHabits.length} linked habit${h.linkedHabits.length===1?"":"s"}`,`${y} friction signal${y===1?"":"s"}`]},y>0&&p.push({id:`field:${h.goal.id}`,x:j+18,y:z+20,radiusX:i?144:176,radiusY:i?104:132,tone:"rose",opacity:Math.min(.42,.14+y*.04)});const I=i?208:282;h.linkedValues.slice(0,i?4:5).forEach((e,d)=>{const m=(-95+d*(i?78:64))*(Math.PI/180),k=Tt(e.title,{compact:i}),G=j+Math.cos(m)*I,W=z+Math.sin(m)*I,K=U(h.goal.id,"value",e.id);s.push({id:K,kind:"value",x:G,y:W,radius:k,tone:"mint",label:e.title,meta:`${e.linkedGoalIds.length} goal${e.linkedGoalIds.length===1?"":"s"}`,href:`/psyche/values?focus=${e.id}#values-atlas`}),x.push({id:`${b}->${K}`,from:b,to:K,tone:"mint",strength:"medium"}),u[K]={id:K,eyebrow:"Value",title:e.title,summary:e.valuedDirection||e.whyItMatters||e.description,href:`/psyche/values?focus=${e.id}#values-atlas`,ctaLabel:"Open values",tone:"mint",entityKind:"value",chips:e.committedActions.slice(0,3),stats:[`${e.linkedProjectIds.length} linked project${e.linkedProjectIds.length===1?"":"s"}`,`${e.linkedTaskIds.length} linked task${e.linkedTaskIds.length===1?"":"s"}`]}});const P=h.linkedProjects.slice(0,i?2:3).map(e=>({project:e,size:tt(e.title,{compact:i,emphasis:!0})})),E=i?24:30;let N=-(P.reduce((e,d)=>e+d.size.width,0)+Math.max(0,P.length-1)*E)/2;P.forEach(({project:e,size:d},m)=>{const k=U(h.goal.id,"project",e.id),G=j+N+d.width/2,W=z-(i?330:434)-m*(i?16:20);N+=d.width+E,s.push({id:k,kind:"project",x:G,y:W,width:d.width,height:d.height,tone:"sky",label:e.title,meta:"Project",href:`/projects/${e.id}`}),x.push({id:`${b}->${k}`,from:b,to:k,tone:"sky",strength:"medium"}),u[k]={id:k,eyebrow:"Project",title:e.title,summary:e.description,href:`/projects/${e.id}`,ctaLabel:"Open project",tone:"sky",entityKind:"project",chips:[e.status,e.goalTitle],stats:[`${e.progress}% progress`,`${e.activeTaskCount} active task${e.activeTaskCount===1?"":"s"}`]}}),h.linkedHabits.slice(0,i?2:3).forEach((e,d)=>{const m=U(h.goal.id,"habit",e.id),k=tt(e.title,{compact:i}),G=j-(i?44:58),W=z+(i?228:294)+d*(i?92:104);s.push({id:m,kind:"habit",x:G,y:W,width:k.width,height:k.height,tone:"mint",label:e.title,meta:e.polarity,href:"/habits"}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"mint",strength:e.dueToday?"high":"medium"}),u[m]={id:m,eyebrow:"Habit",title:e.title,summary:e.description||"Recurring operating record connected directly to this goal field.",href:"/habits",ctaLabel:"Open habits",tone:"mint",entityKind:"habit",chips:[e.polarity,e.frequency,e.dueToday?"due today":"checked in"],stats:[`${e.streakCount} streak`,`${e.rewardXp}/${e.penaltyXp} xp flow`]}});let O=z+(i?132:156);h.linkedBehaviors.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"behavior",e.id),m=tt(e.title,{compact:i}),k=j-(i?272:352);s.push({id:d,kind:"behavior",x:k,y:O,width:m.width,height:m.height,tone:"orange",label:e.title,meta:e.kind,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"orange",dashed:e.kind!=="committed",strength:e.kind==="committed"?"medium":"low"}),u[d]={id:d,eyebrow:"Behavior",title:e.title,summary:e.replacementMove||e.description||e.urgeStory,href:`/psyche/behaviors?focus=${e.id}#behavior-columns`,ctaLabel:"Open behaviors",tone:"orange",entityKind:"behavior",chips:[e.kind,...e.commonCues.slice(0,2)],stats:[e.shortTermPayoff?"Short-term payoff mapped":"Payoff still to map",e.longTermCost?"Long-term cost mapped":"Cost still to map"]},O+=m.height+(i?18:22)});let X=z+(i?8:10);h.linkedBeliefs.slice(0,i?2:3).forEach(e=>{const d=U(h.goal.id,"belief",e.id),m=tt(e.statement,{compact:i,emphasis:!0}),k=j+(i?278:362);s.push({id:d,kind:"belief",x:k,y:X,width:m.width,height:m.height,tone:"violet",label:e.statement,meta:"belief",href:`/psyche/schemas-beliefs?focus=${e.id}`}),x.push({id:`${b}->${d}`,from:b,to:d,tone:"violet",dashed:!0,strength:"low"}),u[d]={id:d,eyebrow:"Belief",title:e.statement,summary:e.flexibleAlternative||e.originNote||"Belief script attached to this part of the map.",href:`/psyche/schemas-beliefs?focus=${e.id}`,ctaLabel:"Open beliefs",tone:"violet",entityKind:"belief",chips:[e.beliefType,`${e.confidence}% grip`],stats:[`${e.linkedBehaviorIds.length} linked behavior${e.linkedBehaviorIds.length===1?"":"s"}`,`${e.linkedReportIds.length} linked report${e.linkedReportIds.length===1?"":"s"}`]},X+=m.height+(i?18:22)});const S=h.linkedReports.slice(0,i?2:3).map(e=>({report:e,size:tt(e.title,{compact:i})})),H=i?20:26;let J=-(S.reduce((e,d)=>e+d.size.width,0)+Math.max(0,S.length-1)*H)/2;S.forEach(({report:e,size:d})=>{const m=U(h.goal.id,"report",e.id),k=j+J+d.width/2,G=z+(i?332:430);J+=d.width+H,s.push({id:m,kind:"report",x:k,y:G,width:d.width,height:d.height,tone:"blue",label:e.title,meta:e.status,href:`/psyche/reports/${e.id}`}),x.push({id:`${b}->${m}`,from:b,to:m,tone:"sky",strength:"medium"}),u[m]={id:m,eyebrow:"Report",title:e.title,summary:e.eventSituation||e.customEventType||"Reflective chain linked into this goal.",href:`/psyche/reports/${e.id}`,ctaLabel:"Open report",tone:"blue",entityKind:"report",chips:[e.status,...e.nextMoves.slice(0,2)],stats:[`${e.emotions.length} emotion${e.emotions.length===1?"":"s"}`,`${e.behaviors.length} move${e.behaviors.length===1?"":"s"}`]}})});const g=((w=s[0])==null?void 0:w.id)??"ghost_goal_center";return{nodes:Et(s,{compact:i}),edges:x,fields:p,inspectors:u,defaultSelectedId:g}}const et={mint:"color-mix(in srgb, var(--success) 64%, transparent)",sky:"color-mix(in srgb, var(--info) 66%, transparent)",violet:"color-mix(in srgb, var(--primary) 72%, transparent)",rose:"color-mix(in srgb, var(--danger) 68%, transparent)",amber:"color-mix(in srgb, var(--warning) 68%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 72%, transparent)",blue:"color-mix(in srgb, var(--info) 72%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 52%, transparent)"},it={mint:"color-mix(in srgb, var(--success) 18%, transparent)",sky:"color-mix(in srgb, var(--info) 18%, transparent)",violet:"color-mix(in srgb, var(--primary) 18%, transparent)",rose:"color-mix(in srgb, var(--danger) 18%, transparent)",amber:"color-mix(in srgb, var(--warning) 18%, transparent)",orange:"color-mix(in srgb, var(--tertiary) 18%, transparent)",blue:"color-mix(in srgb, var(--info) 18%, transparent)",slate:"color-mix(in srgb, var(--ui-ink-soft) 12%, transparent)"},A={mint:"color-mix(in srgb, var(--success) 56%, var(--ui-ink-strong) 44%)",sky:"color-mix(in srgb, var(--info) 56%, var(--ui-ink-strong) 44%)",violet:"color-mix(in srgb, var(--primary) 60%, var(--ui-ink-strong) 40%)",rose:"color-mix(in srgb, var(--danger) 58%, var(--ui-ink-strong) 42%)",amber:"color-mix(in srgb, var(--warning) 60%, var(--ui-ink-strong) 40%)",orange:"color-mix(in srgb, var(--tertiary) 60%, var(--ui-ink-strong) 40%)",blue:"color-mix(in srgb, var(--info) 58%, var(--ui-ink-strong) 42%)",slate:"var(--ui-ink-medium)"};function wt(n){switch(n){case"goal":case"value":case"behavior":case"belief":case"report":case"project":case"habit":return n;default:return null}}function Dt(n){if(n.tone)return n.tone;switch(n.kind){case"goal":return"amber";case"value":return"mint";case"belief":return"violet";case"behavior":return"orange";case"project":return"sky";case"habit":return"mint";case"report":return"blue";default:return"slate"}}function Gt(n){if(n.kind==="ghost")return n.meta??null;const i=wt(n.kind);return i?gt(i).label:n.meta??null}function ut(n,i,s){return Math.min(Math.max(n,i),s)}function lt(n,i,s=3){const x=n.trim().split(/\s+/),p=[];let u="";for(let g=0;g<x.length;g+=1){const w=x[g],h=u?`${u} ${w}`:w;if(h.length>i&&u){if(p.push(u),p.length>=s-1){u=[w,...x.slice(g+1)].join(" ");break}u=w}else u=h}u&&p.push(u);const r=p.slice(0,s),v=r.length-1;return v>=0&&r[v].length>i&&(r[v]=`${r[v].slice(0,Math.max(1,i-1)).trimEnd()}…`),r}function Vt(n,i){if(n.length===0&&i.length===0)return{minX:-360,maxX:360,minY:-240,maxY:240};let s=Number.POSITIVE_INFINITY,x=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(const r of n){const v=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.width??124)/2,g=r.kind==="goal"||r.kind==="value"||r.kind==="ghost"?r.radius??32:(r.height??56)/2,w=r.meta&&(r.kind==="goal"||r.kind==="ghost")?48:0;s=Math.min(s,r.x-v),x=Math.max(x,r.x+v),p=Math.min(p,r.y-g-w),u=Math.max(u,r.y+g)}for(const r of i)s=Math.min(s,r.x-r.radiusX),x=Math.max(x,r.x+r.radiusX),p=Math.min(p,r.y-r.radiusY),u=Math.max(u,r.y+r.radiusY);return{minX:s,maxX:x,minY:p,maxY:u}}function vt(n){return{x:n.x,y:n.y}}function Bt(n){if(n.kind==="goal"){const i=n.radius??112;return lt(n.label,Math.max(14,Math.floor(i/7.2)),4)}if(n.kind==="value"||n.kind==="ghost"){const i=n.radius??40;return lt(n.label,Math.max(12,Math.floor(i/3)),3)}return n.kind==="project"?lt(n.label,Math.max(18,Math.floor((n.width??220)/10)),3):lt(n.label,Math.max(16,Math.floor((n.width??180)/10.5)),2)}function Ft(n){switch(n){case"goal":return"amber";case"project":return"sky";case"value":return"mint";case"behavior":return"orange";case"belief":return"violet";case"report":return"blue";default:return"slate"}}function Kt({nodes:n,edges:i,fields:s=[],title:x,hint:p,action:u,legend:r,selectedNodeId:v,onSelectNode:g,minHeightClassName:w="min-h-[34rem] lg:min-h-[44rem]",compact:h=!1,testId:L}){const j=$.useRef(null),z=Xt(),[y,b]=$.useState({width:0,height:0}),[I,P]=$.useState({scale:1,x:0,y:0}),[E,q]=$.useState(null),N=$.useRef(null),O=$.useRef({scale:1,x:0,y:0}),X=$.useRef(new Map),S=$.useRef(null),H=$.useRef(0),D=$.useRef(!1),J=$.useMemo(()=>new Map(n.map(t=>[t.id,t])),[n]),e=$.useMemo(()=>Vt(n,s),[s,n]),d=y.width>0&&y.width<640;$.useEffect(()=>{if(!j.current||typeof ResizeObserver>"u")return;const t=new ResizeObserver(a=>{const l=a[0];b({width:l.contentRect.width,height:l.contentRect.height})});return t.observe(j.current),()=>t.disconnect()},[]);const m=$.useCallback(()=>{if(!y.width||!y.height)return;const t=d?260:h?140:190,a=Math.max(e.maxX-e.minX,1),l=Math.max(e.maxY-e.minY,1),o=ut(Math.min(y.width/(a+t),y.height/(l+t)),d?.16:h?.4:.46,d?.76:h?1.04:1.18),f=(e.minX+e.maxX)/2,Y=(e.minY+e.maxY)/2;P({scale:o,x:y.width/2-f*o,y:y.height/2-Y*o})},[e.maxX,e.maxY,e.minX,e.minY,h,y.height,y.width,d]);$.useEffect(()=>{O.current=I},[I]),$.useEffect(()=>{D.current||m()},[m]);const k=$.useCallback((t,a,l)=>{const o=ut(t,.28,1.9);P(f=>{if(a==null||l==null)return{...f,scale:o};const Y=(a-f.x)/f.scale,V=(l-f.y)/f.scale;return{scale:o,x:a-Y*o,y:l-V*o}})},[]),G=$.useCallback(()=>{const t=[...X.current.values()];if(t.length<2){S.current=null;return}const[a,l]=t,o=Math.hypot(l.x-a.x,l.y-a.y);if(!Number.isFinite(o)||o<=0){S.current=null;return}const f=O.current;S.current={startDistance:o,startScale:f.scale,startViewportX:f.x,startViewportY:f.y,startMidpointX:(a.x+l.x)/2,startMidpointY:(a.y+l.y)/2}},[]),W=t=>{var o;t.preventDefault();const a=(o=j.current)==null?void 0:o.getBoundingClientRect();if(!a)return;D.current=!0;const l=t.deltaY<0?1.1:.9;k(I.scale*l,t.clientX-a.left,t.clientY-a.top)},K=t=>{var f;const a=(f=j.current)==null?void 0:f.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.set(t.pointerId,{x:l,y:o}),X.current.size===1){const Y=O.current;N.current={pointerId:t.pointerId,originX:Y.x,originY:Y.y,startX:l,startY:o}}else N.current=null,G();t.currentTarget.setPointerCapture(t.pointerId)},$t=t=>{var V;const a=(V=j.current)==null?void 0:V.getBoundingClientRect(),l=t.clientX-((a==null?void 0:a.left)??0),o=t.clientY-((a==null?void 0:a.top)??0);if(X.current.has(t.pointerId)&&X.current.set(t.pointerId,{x:l,y:o}),S.current&&X.current.size>=2){const[R,_]=[...X.current.values()],C=Math.hypot(_.x-R.x,_.y-R.y);if(Number.isFinite(C)&&C>0){D.current=!0,H.current=Date.now()+240;const Q=(R.x+_.x)/2,F=(R.y+_.y)/2,T=S.current,Z=ut(T.startScale*C/T.startDistance,.24,1.42),ct=(T.startMidpointX-T.startViewportX)/T.startScale,ht=(T.startMidpointY-T.startViewportY)/T.startScale;P({scale:Z,x:Q-ct*Z,y:F-ht*Z})}return}if(!N.current||N.current.pointerId!==t.pointerId||X.current.size!==1)return;D.current=!0;const f=l-N.current.startX,Y=o-N.current.startY;(Math.abs(f)>3||Math.abs(Y)>3)&&(H.current=Date.now()+240),P(R=>{var _,C;return{...R,x:(((_=N.current)==null?void 0:_.originX)??R.x)+f,y:(((C=N.current)==null?void 0:C.originY)??R.y)+Y}})},xt=t=>{if(X.current.delete(t.pointerId),X.current.size<2&&(S.current=null),X.current.size===1){const[a,l]=[...X.current.entries()][0]??[];if(a!=null&&l){const o=O.current;N.current={pointerId:a,originX:o.x,originY:o.y,startX:l.x,startY:l.y}}}else N.current=null;t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId)},nt=E??v??null,rt=$.useCallback(t=>{Date.now()<H.current||(g==null||g(t.id),t.href&&z(t.href))},[z,g]);return c.jsxs("section",{"data-testid":L,className:dt("overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] shadow-[var(--card-shadow)]","px-3 py-3 sm:px-4 sm:py-4 lg:px-5 lg:py-5"),children:[c.jsxs("div",{className:"mb-3 flex min-w-0 flex-wrap items-start justify-between gap-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Gravity well"}),c.jsx("h2",{className:dt("mt-2 break-words font-display leading-none text-[var(--ui-ink-strong)]",h?"text-[clamp(1.25rem,2vw,1.7rem)]":"text-[clamp(1.45rem,2.8vw,2.3rem)]"),children:x}),p?c.jsx("p",{className:"mt-1.5 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:d?"Select a node, pan the field, and open the full map when you need the wider structure.":p}):null]}),c.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:u})]}),c.jsxs("div",{ref:j,className:dt("group relative overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] touch-none",w),style:{touchAction:"none"},onWheel:W,onPointerDown:K,onPointerMove:$t,onPointerUp:xt,onPointerCancel:xt,children:[c.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_center,color-mix(in_srgb,var(--success)_8%,transparent),transparent_28%),radial-gradient(circle_at_20%_20%,color-mix(in_srgb,var(--primary)_10%,transparent),transparent_24%),var(--ui-surface-section)]"}),c.jsxs("div",{className:"absolute left-3 top-3 z-10 inline-flex max-w-[calc(100%-7rem)] items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-2.5 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)] backdrop-blur-xl sm:left-4 sm:top-4 sm:max-w-none sm:px-3",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(Rt,{className:"size-3.5"}),d?"Drag or pinch":"Drag to pan, scroll to zoom"]}),c.jsxs("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5 sm:right-4 sm:top-4 sm:max-w-none sm:gap-2",onPointerDown:t=>t.stopPropagation(),children:[c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom in",onClick:()=>{D.current=!0,k(I.scale*1.12,y.width-96,72)},children:c.jsx(zt,{className:"size-4"})}),c.jsx(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom out",onClick:()=>{D.current=!0,k(I.scale*.88,y.width-96,72)},children:c.jsx(Ct,{className:"size-4"})}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[4.75rem] sm:px-3","aria-label":"Fit graph",onClick:()=>{D.current=!0,m()},children:[c.jsx(Pt,{className:"size-4"}),d?null:"Fit"]}),c.jsxs(ot,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[5.5rem] sm:px-3","aria-label":"Reset graph",onClick:()=>{D.current=!1,m()},children:[c.jsx(Nt,{className:"size-4"}),d?null:"Reset"]})]}),r&&r.length>0&&!d?c.jsx("div",{className:"absolute bottom-4 left-4 z-10 flex flex-wrap items-center gap-2 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-xs text-[var(--ui-ink-soft)] backdrop-blur-xl",children:r.map(t=>{const a=t.kind?Ft(t.kind):t.tone??"slate",l=t.kind?gt(t.kind).icon:null;return c.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap rounded-full bg-[var(--ui-surface-1)] px-2.5 py-1.5",children:[l?c.jsx(l,{className:"size-3.5",color:A[a],strokeWidth:2.1}):c.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:et[a]}}),t.label]},t.label)})}):null,c.jsxs("svg",{className:"relative z-[1] h-full w-full overflow-hidden",viewBox:`0 0 ${y.width||1200} ${y.height||760}`,role:"img","aria-label":x,style:{overflow:"hidden"},children:[c.jsx("defs",{children:c.jsx("filter",{id:"forge-graph-blur",children:c.jsx("feGaussianBlur",{stdDeviation:"34"})})}),c.jsxs("g",{transform:`translate(${I.x} ${I.y}) scale(${I.scale})`,children:[s.map(t=>c.jsx("ellipse",{cx:t.x,cy:t.y,rx:t.radiusX,ry:t.radiusY,fill:it[t.tone??"rose"],opacity:t.opacity??.42,filter:"url(#forge-graph-blur)"},t.id)),n.filter(t=>t.kind==="goal"||t.kind==="ghost").map(t=>{const a=t.radius??76;return c.jsx("g",{opacity:t.kind==="ghost"?.28:.55,children:[a+74,a+124].map((l,o)=>c.jsx("circle",{cx:t.x,cy:t.y,r:l,fill:"none",stroke:o===0?"var(--ui-border-subtle)":"var(--ui-border-strong)",strokeDasharray:o===0?"0":"10 10"},`${t.id}-ring-${l}`))},`${t.id}-orbital-lanes`)}),i.map(t=>{const a=J.get(t.from),l=J.get(t.to);if(!a||!l)return null;const o=vt(a),f=vt(l),Y=(o.x+f.x)/2,V=(o.y+f.y)/2,R=Math.max(24,Math.abs(o.x-f.x)*.08),_=Y,C=V-R;return c.jsx("path",{d:`M ${o.x} ${o.y} Q ${_} ${C} ${f.x} ${f.y}`,fill:"none",stroke:et[t.tone??"slate"],strokeWidth:t.strength==="high"?3:t.strength==="medium"?2.2:1.6,strokeDasharray:t.dashed?"8 8":void 0,opacity:nt&&t.from!==nt&&t.to!==nt?.18:.62},t.id)}),n.map(t=>{t.id;const a=E===t.id,l=nt===t.id,o=Dt(t),f=Gt(t),Y=Bt(t),V=wt(t.kind),R=V?gt(V).icon:null;if(t.kind==="goal"||t.kind==="value"||t.kind==="ghost"){const M=t.radius??(t.kind==="goal"?76:34),st=f?t.y-M-(t.kind==="goal"?18:10):null,yt=t.kind==="goal"?20:14.5,at=t.kind==="goal"?28:16,It=t.kind==="goal"?t.y-M*.34:t.kind==="value"?t.y-M*.3:t.y-M*.2,Yt=t.kind==="goal"?t.y+M*.2:t.y+10;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(B=>B===t.id?null:B),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("circle",{cx:t.x,cy:t.y,r:M+(l?14:0),fill:l?it[o]:"transparent",stroke:l?et[o]:"transparent",opacity:a?.98:.9}),c.jsx("circle",{cx:t.x,cy:t.y,r:M+(a?2:0),fill:t.kind==="ghost"?"var(--ui-surface-1)":it[o],stroke:t.kind==="ghost"?"var(--ui-border-strong)":et[o],strokeDasharray:t.kind==="ghost"?"8 8":void 0,strokeWidth:l?2.8:1.6}),f?c.jsx("text",{x:t.x,y:st??t.y-12,textAnchor:"middle",fontSize:t.kind==="goal"?"11.5":"10.5",fill:t.kind==="ghost"?"var(--ui-ink-soft)":A[o],style:{letterSpacing:"0.18em",textTransform:"uppercase"},children:f}):null,R?c.jsx(R,{x:t.x-at/2,y:It-at/2,width:at,height:at,color:A[o],strokeWidth:2.1}):null,Y.map((B,bt)=>c.jsx("text",{x:t.x,y:Yt+bt*yt-(Y.length-1)*yt/2,textAnchor:"middle",fontSize:t.kind==="goal"?21:12.8,fontWeight:t.kind==="goal"?600:500,fill:t.kind==="ghost"?"var(--ui-ink-strong)":A[o],children:B},`${t.id}-${B}-${bt}`))]},t.id)}const _=t.width??146,C=t.height??58,Q=t.x-_/2,F=t.y-C/2,T=t.kind==="project"?14:13,Z=Q+14,ct=F+13,ht=F+22,jt=f?F+C*.65:F+C*.56,pt=t.kind==="project"?16:15,Mt=t.kind==="project"?14.2:13.2;return c.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{q(t.id),g==null||g(t.id)},onPointerLeave:()=>q(M=>M===t.id?null:M),onFocus:()=>g==null?void 0:g(t.id),onClick:()=>rt(t),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),rt(t))},className:"cursor-pointer outline-none",children:[c.jsx("rect",{x:Q-(l?6:0),y:F-(l?6:0),rx:"28",ry:"28",width:_+(l?12:0),height:C+(l?12:0),fill:l?it[o]:"transparent"}),c.jsx("rect",{x:Q-(a?2:0),y:F-(a?2:0),rx:"22",ry:"22",width:_+(a?4:0),height:C+(a?4:0),fill:it[o],stroke:et[o],strokeWidth:l?2.3:1.3}),R?c.jsx(R,{x:Z,y:ct,width:T,height:T,color:A[o],strokeWidth:2.1}):null,f?c.jsx("text",{x:Z+T+8,y:ht,textAnchor:"start",fontSize:"9.5",fill:A[o],style:{letterSpacing:"0.16em",textTransform:"uppercase",opacity:.82},children:f}):null,Y.map((M,st)=>c.jsx("text",{x:t.x,y:jt+st*pt-(Y.length-1)*pt/2,textAnchor:"middle",fontSize:Mt,fontWeight:600,fill:A[o],children:M},`${t.id}-${M}-${st}`))]},t.id)})]})]})]})]})}export{Kt as P,Wt as b};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-kIz9EZnX.js";import{i as g}from"./state-VYvD1QVP.js";import{L as h,E as p,ch as w,C as i,c as m,Z as u,cv as y}from"./index-BHIKoiZ6.js";import{P as j}from"./page-hero-oFHaAjtL.js";import{S as o,f as v,m as f,M as b}from"./daily-metrics-dashboard-BMyL0Qr4.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./charts-FcU0F3XV.js";function a(t){return new Intl.NumberFormat().format(Math.round(t))}function c(t){return`${t.toFixed(t>=10?1:2)}%`}function N(t){return t.summary.categoryBreakdown.map(s=>({...s,metrics:t.metrics.filter(n=>n.category===s.category)}))}function P(){return e.jsxs(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(14,20,32,0.96),rgba(9,13,24,0.98))] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"No daily metrics yet"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-white",children:"Psyche metrics will appear after the first local backfill finds conversations."}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-white/58",children:"This surface stays quiet until Forge has stored daily metric rows. It does not run the scanner while rendering the page."})]})}function q(){const t=g({queryKey:["forge-psyche-metrics-view"],queryFn:async()=>(await y()).metrics});if(t.isLoading)return e.jsx(h,{title:"Loading Psyche metrics",description:"Reading stored daily metric rows and summary statistics."});if(t.isError||!t.data)return e.jsx(p,{eyebrow:"Psyche metrics",error:t.error??new Error("Psyche metrics unavailable"),onRetry:()=>void t.refetch()});const s=t.data,n=N(s),l=s.metrics.find(r=>r.metric==="devrageSwearCount")??null,x=s.metrics.find(r=>r.metric==="swearingMessagePercent")??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1380px] gap-5",children:[e.jsx(j,{title:"Psyche Metrics",titleText:"Psyche Metrics",description:"Daily Psyche measurements from stored history, presented with the same operational shape as Vitals.",badge:s.summary.hasData?`${s.summary.metricCount} daily metrics`:"No daily metrics yet"}),e.jsx(w,{}),s.summary.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(o,{title:"Devrage count",description:"Raw daily swear count across scanned user messages.",metric:l}),e.jsx(o,{title:"Swearing rate",description:"Percentage of user messages that contained at least one tracked swear.",metric:x}),e.jsxs(i,{className:"rounded-[28px] border border-amber-200/12 bg-[linear-gradient(180deg,rgba(39,31,17,0.96),rgba(19,21,17,0.95))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/72",children:"Seven-day averages"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swears"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:a(s.context.weeklyAverage.rawSwearCount)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swearing messages"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:c(s.context.weeklyAverage.swearingMessagePercent)})]})]})]}),e.jsxs(i,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Stored coverage"}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[s.summary.trackedDays," days"]}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/62",children:[e.jsxs("div",{children:[a(s.context.conversationsScanned)," conversations"]}),e.jsxs("div",{children:[a(s.context.messagesScanned)," user messages"]}),e.jsxs("div",{children:[s.context.sourceCount," source families"]})]})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(340px,0.9fr)]",children:[e.jsxs(i,{className:"overflow-hidden rounded-[30px] border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(251,191,36,0.14),transparent_36%),linear-gradient(180deg,rgba(20,18,31,0.98),rgba(10,13,26,0.98))] p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Coverage"}),e.jsxs("div",{className:"text-2xl font-semibold text-white",children:[s.summary.trackedDays," tracked days across ",s.summary.metricCount," metrics"]}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/58",children:"Devrage is stored as daily Psyche measurements, so this view reads history from SQLite instead of rescanning conversations during page load."})]}),e.jsxs(m,{className:"bg-white/[0.08] text-white/72",children:["Latest snapshot ",v(s.summary.latestDateKey)]})]}),e.jsx("div",{className:"mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:s.summary.categoryBreakdown.map(r=>{const d=f(r.category);return e.jsxs("div",{className:u("rounded-[22px] border bg-white/[0.03] p-4",d.ring),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(m,{className:d.badge,children:r.category}),e.jsxs("div",{className:"text-xs text-white/44",children:[r.coverageDays," days"]})]}),e.jsx("div",{className:"mt-3 text-2xl font-semibold text-white",children:r.metricCount}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:["active metric",r.metricCount===1?"":"s"]})]},r.category)})})]}),e.jsx(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-6",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Summary statistics"}),e.jsxs("div",{className:"text-lg font-semibold text-white",children:[a(s.context.totalSwears)," total swears across stored history."]}),e.jsxs("div",{className:"grid gap-3 text-sm leading-6 text-white/58",children:[e.jsxs("div",{children:["Daily average: ",a(s.context.dailyAverage.rawSwearCount)," swears and ",c(s.context.dailyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:["Weekly average: ",a(s.context.weeklyAverage.rawSwearCount)," swears and ",c(s.context.weeklyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:[a(s.context.messagesWithSwears)," user messages contained at least one tracked swear."]})]}),e.jsxs("div",{className:"mt-2 rounded-[22px] border border-white/8 bg-white/[0.035] p-4 text-sm text-white/70",children:[s.summary.latestMetricCount," metrics updated on the latest tracked day."]})]})})]}),e.jsx(b,{groups:n})]}):e.jsx(P,{})]})}export{q as PsycheMetricsPage};
1
+ import{j as e}from"./vendor-Dnkkx2co.js";import{i as g}from"./state-vCcAT5Hq.js";import{L as h,E as p,ch as w,C as i,c as m,Z as u,cv as y}from"./index-EqQsXoat.js";import{P as j}from"./page-hero-ffKzgyW3.js";import{S as o,f as v,m as f,M as b}from"./daily-metrics-dashboard-CiJkkkd1.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";import"./charts-DFnEuIMB.js";function a(t){return new Intl.NumberFormat().format(Math.round(t))}function c(t){return`${t.toFixed(t>=10?1:2)}%`}function N(t){return t.summary.categoryBreakdown.map(s=>({...s,metrics:t.metrics.filter(n=>n.category===s.category)}))}function P(){return e.jsxs(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(14,20,32,0.96),rgba(9,13,24,0.98))] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"No daily metrics yet"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-white",children:"Psyche metrics will appear after the first local backfill finds conversations."}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-6 text-white/58",children:"This surface stays quiet until Forge has stored daily metric rows. It does not run the scanner while rendering the page."})]})}function q(){const t=g({queryKey:["forge-psyche-metrics-view"],queryFn:async()=>(await y()).metrics});if(t.isLoading)return e.jsx(h,{title:"Loading Psyche metrics",description:"Reading stored daily metric rows and summary statistics."});if(t.isError||!t.data)return e.jsx(p,{eyebrow:"Psyche metrics",error:t.error??new Error("Psyche metrics unavailable"),onRetry:()=>void t.refetch()});const s=t.data,n=N(s),l=s.metrics.find(r=>r.metric==="devrageSwearCount")??null,x=s.metrics.find(r=>r.metric==="swearingMessagePercent")??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1380px] gap-5",children:[e.jsx(j,{title:"Psyche Metrics",titleText:"Psyche Metrics",description:"Daily Psyche measurements from stored history, presented with the same operational shape as Vitals.",badge:s.summary.hasData?`${s.summary.metricCount} daily metrics`:"No daily metrics yet"}),e.jsx(w,{}),s.summary.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-4 xl:grid-cols-4",children:[e.jsx(o,{title:"Devrage count",description:"Raw daily swear count across scanned user messages.",metric:l}),e.jsx(o,{title:"Swearing rate",description:"Percentage of user messages that contained at least one tracked swear.",metric:x}),e.jsxs(i,{className:"rounded-[28px] border border-amber-200/12 bg-[linear-gradient(180deg,rgba(39,31,17,0.96),rgba(19,21,17,0.95))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-amber-100/72",children:"Seven-day averages"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swears"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:a(s.context.weeklyAverage.rawSwearCount)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-white/[0.045] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Swearing messages"}),e.jsx("span",{className:"text-xl font-semibold text-white",children:c(s.context.weeklyAverage.swearingMessagePercent)})]})]})]}),e.jsxs(i,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Stored coverage"}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-white",children:[s.summary.trackedDays," days"]}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/62",children:[e.jsxs("div",{children:[a(s.context.conversationsScanned)," conversations"]}),e.jsxs("div",{children:[a(s.context.messagesScanned)," user messages"]}),e.jsxs("div",{children:[s.context.sourceCount," source families"]})]})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.1fr)_minmax(340px,0.9fr)]",children:[e.jsxs(i,{className:"overflow-hidden rounded-[30px] border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(251,191,36,0.14),transparent_36%),linear-gradient(180deg,rgba(20,18,31,0.98),rgba(10,13,26,0.98))] p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Coverage"}),e.jsxs("div",{className:"text-2xl font-semibold text-white",children:[s.summary.trackedDays," tracked days across ",s.summary.metricCount," metrics"]}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/58",children:"Devrage is stored as daily Psyche measurements, so this view reads history from SQLite instead of rescanning conversations during page load."})]}),e.jsxs(m,{className:"bg-white/[0.08] text-white/72",children:["Latest snapshot ",v(s.summary.latestDateKey)]})]}),e.jsx("div",{className:"mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:s.summary.categoryBreakdown.map(r=>{const d=f(r.category);return e.jsxs("div",{className:u("rounded-[22px] border bg-white/[0.03] p-4",d.ring),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(m,{className:d.badge,children:r.category}),e.jsxs("div",{className:"text-xs text-white/44",children:[r.coverageDays," days"]})]}),e.jsx("div",{className:"mt-3 text-2xl font-semibold text-white",children:r.metricCount}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:["active metric",r.metricCount===1?"":"s"]})]},r.category)})})]}),e.jsx(i,{className:"rounded-[30px] border-white/8 bg-[linear-gradient(180deg,rgba(13,19,37,0.96),rgba(10,14,30,0.96))] p-6",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Summary statistics"}),e.jsxs("div",{className:"text-lg font-semibold text-white",children:[a(s.context.totalSwears)," total swears across stored history."]}),e.jsxs("div",{className:"grid gap-3 text-sm leading-6 text-white/58",children:[e.jsxs("div",{children:["Daily average: ",a(s.context.dailyAverage.rawSwearCount)," swears and ",c(s.context.dailyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:["Weekly average: ",a(s.context.weeklyAverage.rawSwearCount)," swears and ",c(s.context.weeklyAverage.swearingMessagePercent)," swearing messages."]}),e.jsxs("div",{children:[a(s.context.messagesWithSwears)," user messages contained at least one tracked swear."]})]}),e.jsxs("div",{className:"mt-2 rounded-[22px] border border-white/8 bg-white/[0.035] p-4 text-sm text-white/70",children:[s.summary.latestMetricCount," metrics updated on the latest tracked day."]})]})})]}),e.jsx(b,{groups:n})]}):e.jsx(P,{})]})}export{q as PsycheMetricsPage};
@@ -1 +1 @@
1
- import{j as e,aC as b}from"./vendor-kIz9EZnX.js";import{j as N,i as k,k as S}from"./state-VYvD1QVP.js";import{u as w}from"./forms-CmLAyGqz.js";import{cw as C,L as _,E as M,B as d,ch as P,C as r,a as f,c as j,cx as q}from"./index-BHIKoiZ6.js";import{P as E}from"./page-hero-oFHaAjtL.js";import{m as L}from"./psyche-schemas-RcZYaokx.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function Q(s){return s instanceof Error?s:typeof s=="string"&&s.trim().length>0?new Error(s):new Error("Forge could not complete the requested query collection.")}function R(s){const t=s.find(i=>i.isError);return{isLoading:s.some(i=>i.isPending||i.isLoading),error:t?Q(t.error):null}}async function F(s){await Promise.all(s.map(t=>t.refetch()))}const n={copingResponse:[{value:"fight",label:"Fight"},{value:"flight",label:"Flight"},{value:"freeze",label:"Freeze"},{value:"detach",label:"Detach"},{value:"comply",label:"Comply"},{value:"overcompensate",label:"Overcompensate"},{value:"none",label:"Mixed / unsure"}],childState:[{value:"vulnerable",label:"Vulnerable"},{value:"angry",label:"Angry"},{value:"impulsive",label:"Impulsive"},{value:"lonely",label:"Lonely"},{value:"ashamed",label:"Ashamed"},{value:"none",label:"Mixed / unsure"}],criticStyle:[{value:"demanding",label:"Demanding"},{value:"punitive",label:"Punitive"},{value:"none",label:"Neither / unclear"}],healthyContact:[{value:"healthy_adult",label:"Healthy adult"},{value:"happy_child",label:"Happy child"},{value:"none",label:"Hard to access right now"}]};function D(){var p,x,h,g,v,y;const s=N(),t=k({queryKey:["forge-psyche-mode-guide-sessions"],queryFn:q}),i=w({defaultValues:{summary:"What mode was most present in this moment?",copingResponse:"none",childState:"none",criticStyle:"none",healthyContact:"none"}}),o=S({mutationFn:async a=>{const l=L.parse({summary:a.summary,answers:[{questionKey:"coping_response",value:a.copingResponse},{questionKey:"child_state",value:a.childState},{questionKey:"critic_style",value:a.criticStyle},{questionKey:"healthy_contact",value:a.healthyContact}]});return C(l)},onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-psyche-mode-guide-sessions"]})}}),u=[t],c=R(u),m=((p=o.data)==null?void 0:p.session)??((h=(x=t.data)==null?void 0:x.sessions)==null?void 0:h[0]);return c.isLoading?e.jsx(_,{eyebrow:"Mode guide",title:"Loading guided sessions",description:"Hydrating previous mode-guide runs and the latest stored readings."}):c.error?e.jsx(M,{eyebrow:"Mode guide",error:c.error,onRetry:()=>void F(u)}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(E,{eyebrow:"Mode guide",title:"Guided Mode Identification",description:"A short guided pass can help separate coping responses, child states, critic pressure, and whatever healthy contact is still available.",badge:`${((g=t.data)==null?void 0:g.sessions.length)??0} sessions`,actions:e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Back to mode map"})})}),e.jsx(P,{}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Guided questionnaire"}),e.jsxs("form",{className:"mt-4 grid gap-5",onSubmit:i.handleSubmit(async a=>o.mutateAsync(a)),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Prompt"}),e.jsx("input",{className:"w-full rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none placeholder:text-[var(--ui-ink-muted)]",...i.register("summary")})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-danger-soft)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"When the pressure rose, what coping move dominated?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.copingResponse.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("copingResponse")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[color-mix(in_srgb,var(--primary)_8%,var(--ui-surface-1)_92%)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Which child state felt closest?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.childState.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("childState")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What was the critic like?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.criticStyle.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("criticStyle")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What healthy contact was still reachable?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.healthyContact.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("healthyContact")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]})]}),e.jsx(d,{type:"submit",children:"Run guide"})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest reading"}),m?e.jsxs("div",{className:"mt-4 grid gap-3",children:[m.results.map(a=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsxs(j,{className:"text-[var(--ui-ink-medium)]",children:[Math.round(a.confidence*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:a.family.replaceAll("_"," ")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.reasoning})]},`${a.family}:${a.label}`)),e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Use this in the mode map"})})]}):e.jsx("div",{className:"mt-4",children:e.jsx(f,{eyebrow:"Guided reading",title:"No guided sessions yet",description:"Run the guide once to separate coping response, child state, critic pressure, and reachable healthy contact."})})]}),e.jsxs(r,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Session history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((v=t.data)==null?void 0:v.sessions)??[]).length===0?e.jsx(f,{eyebrow:"Session history",title:"No stored guide history",description:"Completed guide sessions will accumulate here so later mode-map work can build from real prior readings."}):(((y=t.data)==null?void 0:y.sessions)??[]).map(a=>e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.results.map(l=>e.jsx(j,{className:"text-[var(--ui-ink-medium)]",children:l.label},`${a.id}:${l.label}`))})]},a.id))})]})]})]})]})}export{D as PsycheModeGuidePage};
1
+ import{j as e,aC as b}from"./vendor-Dnkkx2co.js";import{j as N,i as k,k as S}from"./state-vCcAT5Hq.js";import{u as w}from"./forms-hB0SqEh-.js";import{cw as C,L as _,E as M,B as d,ch as P,C as r,a as f,c as j,cx as q}from"./index-EqQsXoat.js";import{P as E}from"./page-hero-ffKzgyW3.js";import{m as L}from"./psyche-schemas-Dxj554nU.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function Q(s){return s instanceof Error?s:typeof s=="string"&&s.trim().length>0?new Error(s):new Error("Forge could not complete the requested query collection.")}function R(s){const t=s.find(i=>i.isError);return{isLoading:s.some(i=>i.isPending||i.isLoading),error:t?Q(t.error):null}}async function F(s){await Promise.all(s.map(t=>t.refetch()))}const n={copingResponse:[{value:"fight",label:"Fight"},{value:"flight",label:"Flight"},{value:"freeze",label:"Freeze"},{value:"detach",label:"Detach"},{value:"comply",label:"Comply"},{value:"overcompensate",label:"Overcompensate"},{value:"none",label:"Mixed / unsure"}],childState:[{value:"vulnerable",label:"Vulnerable"},{value:"angry",label:"Angry"},{value:"impulsive",label:"Impulsive"},{value:"lonely",label:"Lonely"},{value:"ashamed",label:"Ashamed"},{value:"none",label:"Mixed / unsure"}],criticStyle:[{value:"demanding",label:"Demanding"},{value:"punitive",label:"Punitive"},{value:"none",label:"Neither / unclear"}],healthyContact:[{value:"healthy_adult",label:"Healthy adult"},{value:"happy_child",label:"Happy child"},{value:"none",label:"Hard to access right now"}]};function D(){var p,x,h,g,v,y;const s=N(),t=k({queryKey:["forge-psyche-mode-guide-sessions"],queryFn:q}),i=w({defaultValues:{summary:"What mode was most present in this moment?",copingResponse:"none",childState:"none",criticStyle:"none",healthyContact:"none"}}),o=S({mutationFn:async a=>{const l=L.parse({summary:a.summary,answers:[{questionKey:"coping_response",value:a.copingResponse},{questionKey:"child_state",value:a.childState},{questionKey:"critic_style",value:a.criticStyle},{questionKey:"healthy_contact",value:a.healthyContact}]});return C(l)},onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-psyche-mode-guide-sessions"]})}}),u=[t],c=R(u),m=((p=o.data)==null?void 0:p.session)??((h=(x=t.data)==null?void 0:x.sessions)==null?void 0:h[0]);return c.isLoading?e.jsx(_,{eyebrow:"Mode guide",title:"Loading guided sessions",description:"Hydrating previous mode-guide runs and the latest stored readings."}):c.error?e.jsx(M,{eyebrow:"Mode guide",error:c.error,onRetry:()=>void F(u)}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(E,{eyebrow:"Mode guide",title:"Guided Mode Identification",description:"A short guided pass can help separate coping responses, child states, critic pressure, and whatever healthy contact is still available.",badge:`${((g=t.data)==null?void 0:g.sessions.length)??0} sessions`,actions:e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Back to mode map"})})}),e.jsx(P,{}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Guided questionnaire"}),e.jsxs("form",{className:"mt-4 grid gap-5",onSubmit:i.handleSubmit(async a=>o.mutateAsync(a)),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Prompt"}),e.jsx("input",{className:"w-full rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none placeholder:text-[var(--ui-ink-muted)]",...i.register("summary")})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-danger-soft)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"When the pressure rose, what coping move dominated?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.copingResponse.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("copingResponse")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[color-mix(in_srgb,var(--primary)_8%,var(--ui-surface-1)_92%)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Which child state felt closest?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:n.childState.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("childState")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What was the critic like?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.criticStyle.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("criticStyle")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]}),e.jsxs(r,{className:"rounded-[24px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"What healthy contact was still reachable?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.healthyContact.map(a=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"radio",value:a.value,...i.register("healthyContact")}),e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:a.label})]},a.value))})]})]}),e.jsx(d,{type:"submit",children:"Run guide"})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(r,{className:"bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest reading"}),m?e.jsxs("div",{className:"mt-4 grid gap-3",children:[m.results.map(a=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsxs(j,{className:"text-[var(--ui-ink-medium)]",children:[Math.round(a.confidence*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:a.family.replaceAll("_"," ")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.reasoning})]},`${a.family}:${a.label}`)),e.jsx(b,{to:"/psyche/modes",children:e.jsx(d,{variant:"secondary",children:"Use this in the mode map"})})]}):e.jsx("div",{className:"mt-4",children:e.jsx(f,{eyebrow:"Guided reading",title:"No guided sessions yet",description:"Run the guide once to separate coping response, child state, critic pressure, and reachable healthy contact."})})]}),e.jsxs(r,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Session history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((v=t.data)==null?void 0:v.sessions)??[]).length===0?e.jsx(f,{eyebrow:"Session history",title:"No stored guide history",description:"Completed guide sessions will accumulate here so later mode-map work can build from real prior readings."}):(((y=t.data)==null?void 0:y.sessions)??[]).map(a=>e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:a.results.map(l=>e.jsx(j,{className:"text-[var(--ui-ink-medium)]",children:l.label},`${a.id}:${l.label}`))})]},a.id))})]})]})]})]})}export{D as PsycheModeGuidePage};
@@ -1 +1 @@
1
- import{j as t,c2 as ae,r as b}from"./vendor-kIz9EZnX.js";import{j as re,i as I,k as se}from"./state-VYvD1QVP.js";import{Z as ie,u as oe,s as ne,cy as le,cq as de,bk as S,bl as M,cn as E,L as ce,E as he,B as C,V as Q,ch as pe,c as ue,b as me,_ as ge,Q as ye,a0 as be,a1 as fe,F as i,I as P,T as m,m as N,co as ve,cm as xe,cp as ke,bA as je,bx as we,by as Ie,bw as Ce}from"./index-BHIKoiZ6.js";import{E as Pe}from"./entity-note-count-link-BrS1-O0o.js";import{A as Se}from"./atlas-panel-B3dPHCmZ.js";import{u as Me,p as Ee}from"./use-psyche-focus-target-qxT5Oy_z.js";import{P as Ne}from"./page-hero-oFHaAjtL.js";import{p as F}from"./query-cache-IQ8W-LNC.js";import{a as K}from"./psyche-schemas-RcZYaokx.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const Fe={coping:"bg-[rgba(251,113,133,0.16)] text-rose-100",child:"bg-[rgba(125,211,252,0.16)] text-sky-100",critic_parent:"bg-[rgba(196,181,253,0.16)] text-violet-100",healthy_adult:"bg-[rgba(110,231,183,0.16)] text-emerald-100",happy_child:"bg-[rgba(251,191,36,0.16)] text-amber-100"};function Le({family:s,label:o,className:h}){return t.jsx("span",{className:ie("inline-flex items-center rounded-full px-3 py-1.5 text-xs",Fe[s],h),children:o})}const g={family:"coping",archetype:"",title:"",persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:null};function Te(s){return{family:s.family,archetype:s.archetype,title:s.title,persona:s.persona,imagery:s.imagery,symbolicForm:s.symbolicForm,facialExpression:s.facialExpression,fear:s.fear,burden:s.burden,protectiveJob:s.protectiveJob,originContext:s.originContext,firstAppearanceAt:s.firstAppearanceAt,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedValueIds:s.linkedValueIds,userId:s.userId??null}}const L={coping:"Coping",child:"Child",critic_parent:"Critic / parent",healthy_adult:"Healthy adult",happy_child:"Happy child"};function $e(){var D,O,q,H;const s=oe(),o=re(),[h,T]=ae(),[U,n]=b.useState(!1),[p,u]=b.useState(null),[y,l]=b.useState(g),[z,f]=b.useState(null),v=I({queryKey:["forge-psyche-modes"],queryFn:je}),x=I({queryKey:["forge-psyche-patterns"],queryFn:we}),k=I({queryKey:["forge-psyche-behaviors"],queryFn:Ie}),j=I({queryKey:["forge-psyche-values"],queryFn:Ce}),d=((D=v.data)==null?void 0:D.modes)??[],R=((O=x.data)==null?void 0:O.patterns)??[],J=((q=k.data)==null?void 0:q.behaviors)??[],G=((H=j.data)==null?void 0:H.values)??[],c=ne(s.selectedUserIds),B=h.get("focus"),$=s.snapshot.dashboard.notesSummaryByEntity;Me(B),b.useEffect(()=>{if(h.get("create")==="1"){n(!0),u(null),l({...g,userId:c});const e=new URLSearchParams(h);e.delete("create"),T(e,{replace:!0})}},[c,h,T]);const A=se({mutationFn:async e=>{const a=K.parse(e);return p?le(p.id,a):de(a)},onSuccess:async()=>{n(!1),u(null),l({...g,userId:c}),f(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-modes"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),V=R.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.preferredResponse||e.targetBehavior,e.user),searchText:S([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),Z=J.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.kind,e.user),searchText:S([e.title,e.kind,e.description],e),kind:"behavior"})),W=G.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.valuedDirection,e.user),searchText:S([e.title,e.valuedDirection,e.description],e),kind:"value"})),X=async e=>{const{pattern:a}=await ve({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return F(o,["forge-psyche-patterns"],"patterns",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},Y=async e=>{const{behavior:a}=await xe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:y.userId});return F(o,["forge-psyche-behaviors"],"behaviors",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.kind,kind:"behavior"}},ee=async e=>{const{value:a}=await ke({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return F(o,["forge-psyche-values"],"values",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},te=[{id:"identity",eyebrow:"Identity",title:"Name the cast member and place it in the right family",description:"Start with the mode itself: who it feels like, what family it belongs to, and the recognizable role it plays.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(be,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:fe(s.snapshot.users.find(r=>r.id===c)??null,"Choose mode owner"),help:"Modes can belong to a human or bot user while still linking across shared patterns, behaviors, and values."}),t.jsx(i,{label:"Mode family",description:"Choose the broader inner family this mode belongs to.",labelHelp:"A mode family is the bigger cluster this state belongs to, like a coping part, a vulnerable child state, or a healthy adult response.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["coping","child","critic_parent","healthy_adult","happy_child"].map(r=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.family===r?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] 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)]"}`,onClick:()=>a({family:r}),children:L[r]},r))})}),t.jsx(i,{label:"Mode name",description:"Give it a memorable name you would instantly recognize later.",labelHelp:"This is the user-facing name of the mode. It should read like a cast member title, not a clinical record.",children:t.jsx(P,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"The Friday Vigil, The Scanner, The Good Son"})}),t.jsx(i,{label:"Archetype",description:"Name the recognizable inner role or pattern this mode most resembles.",labelHelp:"An archetype is the role this mode tends to play, like a protector, a critic, a frightened child, or a calm adult anchor.",children:t.jsx(P,{value:e.archetype,onChange:r=>a({archetype:r.target.value}),placeholder:"Detached protector, vulnerable child, demanding critic"})})]})},{id:"texture",eyebrow:"Texture",title:"Give the mode a recognizable presence",description:"Imagery, facial expression, and persona should make the mode instantly memorable.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Persona",description:"Describe how this mode sounds, moves, and carries itself.",labelHelp:"Persona is the tone, posture, and voice of the mode. Imagine how it enters the room and how it speaks.",children:t.jsx(m,{value:e.persona,onChange:r=>a({persona:r.target.value}),placeholder:"Quiet, hyper-alert, always scanning for threat and trying to stay one step ahead."})}),t.jsx(i,{label:"Imagery",description:"Capture the mental image or scene that helps this mode feel vivid.",labelHelp:"Imagery is the picture that makes the mode easy to remember, like a scene, posture, weather pattern, or atmosphere.",children:t.jsx(m,{value:e.imagery,onChange:r=>a({imagery:r.target.value}),placeholder:"A night watchman under cold fluorescent light, pacing and checking every door twice."})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Symbolic form",description:"Pick the object, creature, or shape that best symbolizes this mode.",labelHelp:"Symbolic form is the metaphor for the mode, like armor, a fox, a storm front, or a glass wall.",children:t.jsx(P,{value:e.symbolicForm,onChange:r=>a({symbolicForm:r.target.value}),placeholder:"A locked visor, a fox, a steel shield"})}),t.jsx(i,{label:"Facial expression",description:"Describe what you would see on the mode's face if it took over.",labelHelp:"This is the visible emotional expression of the mode: tight jaw, blank stare, pleading eyes, or calm grounded attention.",children:t.jsx(P,{value:e.facialExpression,onChange:r=>a({facialExpression:r.target.value}),placeholder:"Tight jaw, narrowed eyes, forced calm"})})]})]})},{id:"burden",eyebrow:"Burden",title:"Map fear, burden, job, and origin",description:"This is what turns a named mode into a readable inner-state profile.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(i,{label:"Fear",description:"Name the threat this mode is trying hard to prevent.",labelHelp:"Fear is the danger the mode believes it must protect you from, such as rejection, shame, collapse, failure, or being trapped.",children:t.jsx(m,{value:e.fear,onChange:r=>a({fear:r.target.value}),placeholder:"If I relax, I will miss the threat and get hurt."})}),t.jsx(i,{label:"Burden",description:"Describe the emotional weight or exhausting role this mode keeps carrying.",labelHelp:"Burden is the heavy job or emotional load the mode feels stuck holding, even when it costs a lot.",children:t.jsx(m,{value:e.burden,onChange:r=>a({burden:r.target.value}),placeholder:"It believes it must never let the guard down, even when that means constant tension."})}),t.jsx(i,{label:"Protective job",description:"Describe the job this mode thinks it is performing for you.",labelHelp:"Protective job is the function the mode is trying to serve, like preventing rejection, keeping control, stopping humiliation, or preserving closeness.",children:t.jsx(m,{value:e.protectiveJob,onChange:r=>a({protectiveJob:r.target.value}),placeholder:"Keeps me prepared so I never get blindsided or look naive."})})]}),t.jsx(i,{label:"Origin context",description:"Describe when this mode first became useful or understandable.",labelHelp:"Origin context is the stretch of life where this mode likely learned its job or became especially necessary.",children:t.jsx(m,{value:e.originContext,onChange:r=>a({originContext:r.target.value}),placeholder:"Started getting stronger during adolescence when mistakes were met with criticism and unpredictability."})})]})},{id:"links",eyebrow:"Links",title:"Attach the mode to the rest of the psyche system",description:"Modes should connect to patterns, behaviors, and values, not sit in isolation.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Linked patterns",description:"Choose the loops this mode tends to activate or maintain.",children:t.jsx(N,{options:V,selectedValues:e.linkedPatternIds,onChange:r=>a({linkedPatternIds:r}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:X})}),t.jsx(i,{label:"Linked behaviors",description:"Choose the moves this mode tends to trigger, justify, or amplify.",children:t.jsx(N,{options:Z,selectedValues:e.linkedBehaviorIds,onChange:r=>a({linkedBehaviorIds:r}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:Y})}),t.jsx(i,{label:"Colliding values",description:"Choose the valued directions this mode most often interrupts.",labelHelp:"These are the values that get obscured, sidelined, or distorted when this mode takes over.",children:t.jsx(N,{options:W,selectedValues:e.linkedValueIds,onChange:r=>a({linkedValueIds:r}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:ee})})]})}];if(v.isLoading||x.isLoading||k.isLoading||j.isLoading)return t.jsx(ce,{eyebrow:"Modes",title:"Loading modes",description:"Getting modes, linked patterns, behaviors, and values ready."});const _=v.error??x.error??k.error??j.error;if(_)return t.jsx(he,{eyebrow:"Modes",error:_,onRetry:()=>void Promise.all([v.refetch(),x.refetch(),k.refetch(),j.refetch()])});const w={coping:d.filter(e=>e.family==="coping"),child:d.filter(e=>e.family==="child"),critic_parent:d.filter(e=>e.family==="critic_parent"),healthy_adult:d.filter(e=>e.family==="healthy_adult"),happy_child:d.filter(e=>e.family==="happy_child")};return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Ne,{entityKind:"mode",title:t.jsx(Q,{kind:"mode",label:"Modes",variant:"heading",size:"lg"}),description:"Modes should look and feel like a cast of inner states with identity, burden, and relational links, not a flat list of records.",badge:`${d.length} modes`,actions:t.jsx(C,{onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:"Add mode"})}),t.jsx(pe,{}),t.jsx(Se,{eyebrow:"Mode families",title:"Modes by family",description:"Use these groups to see which modes show up most often, what role they play, and what they are connected to.",tone:"violet",children:d.length===0?t.jsx("div",{className:"flex justify-start",children:t.jsx(C,{onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:"Add mode"})}):t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:Object.keys(w).map(e=>t.jsxs("div",{className:"grid gap-3 rounded-[26px] bg-[var(--ui-surface-1)] p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(Le,{family:e,label:L[e]}),t.jsx(ue,{children:w[e].length})]}),w[e].length===0?t.jsx("div",{className:"flex",children:t.jsxs(C,{variant:"secondary",onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:["Add ",L[e].toLowerCase()]})}):w[e].map(a=>t.jsxs("div",{"data-psyche-focus-id":a.id,className:`rounded-[22px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${Ee(B===a.id)}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(me,{kind:"mode",compact:!0,gradient:!1}),t.jsx(Q,{kind:"mode",label:a.title,variant:"heading",size:"lg"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Pe,{entityType:"mode_profile",entityId:a.id,count:ge($,"mode_profile",a.id).count}),t.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{u(a),l(Te(a)),n(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:a.archetype}),t.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.persona||a.protectiveJob||"Open the mode to add persona and protective details."})]},a.id))]},e))})}),t.jsx(ye,{open:U,onOpenChange:n,eyebrow:"Mode",title:p?"Refine cast member":"Create mode",description:"Use this guided flow to define the mode, how it shows up, what it is protecting, and where it comes from.",value:y,onChange:l,draftPersistenceKey:p?`psyche.mode.${p.id}`:"psyche.mode.new",steps:te,submitLabel:p?"Save mode":"Create mode",pending:A.isPending,error:z,onSubmit:async()=>{f(null);const e=K.safeParse(y);if(!e.success){f("This mode still needs a family and a name before it can be saved.");return}try{await A.mutateAsync(e.data)}catch(a){f(a instanceof Error?a.message:"Unable to save this mode right now.")}}})]})}export{$e as PsycheModesPage};
1
+ import{j as t,c2 as ae,r as b}from"./vendor-Dnkkx2co.js";import{j as re,i as I,k as se}from"./state-vCcAT5Hq.js";import{Z as ie,u as oe,s as ne,cy as le,cq as de,bk as S,bl as M,cn as E,L as ce,E as he,B as C,V as Q,ch as pe,c as ue,b as me,_ as ge,Q as ye,a0 as be,a1 as fe,F as i,I as P,T as m,m as N,co as ve,cm as xe,cp as ke,bA as je,bx as we,by as Ie,bw as Ce}from"./index-EqQsXoat.js";import{E as Pe}from"./entity-note-count-link-RzBB6ujx.js";import{A as Se}from"./atlas-panel-jgMRyaHn.js";import{u as Me,p as Ee}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as Ne}from"./page-hero-ffKzgyW3.js";import{p as F}from"./query-cache-IQ8W-LNC.js";import{a as K}from"./psyche-schemas-Dxj554nU.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const Fe={coping:"bg-[rgba(251,113,133,0.16)] text-rose-100",child:"bg-[rgba(125,211,252,0.16)] text-sky-100",critic_parent:"bg-[rgba(196,181,253,0.16)] text-violet-100",healthy_adult:"bg-[rgba(110,231,183,0.16)] text-emerald-100",happy_child:"bg-[rgba(251,191,36,0.16)] text-amber-100"};function Le({family:s,label:o,className:h}){return t.jsx("span",{className:ie("inline-flex items-center rounded-full px-3 py-1.5 text-xs",Fe[s],h),children:o})}const g={family:"coping",archetype:"",title:"",persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:null};function Te(s){return{family:s.family,archetype:s.archetype,title:s.title,persona:s.persona,imagery:s.imagery,symbolicForm:s.symbolicForm,facialExpression:s.facialExpression,fear:s.fear,burden:s.burden,protectiveJob:s.protectiveJob,originContext:s.originContext,firstAppearanceAt:s.firstAppearanceAt,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedValueIds:s.linkedValueIds,userId:s.userId??null}}const L={coping:"Coping",child:"Child",critic_parent:"Critic / parent",healthy_adult:"Healthy adult",happy_child:"Happy child"};function $e(){var D,O,q,H;const s=oe(),o=re(),[h,T]=ae(),[U,n]=b.useState(!1),[p,u]=b.useState(null),[y,l]=b.useState(g),[z,f]=b.useState(null),v=I({queryKey:["forge-psyche-modes"],queryFn:je}),x=I({queryKey:["forge-psyche-patterns"],queryFn:we}),k=I({queryKey:["forge-psyche-behaviors"],queryFn:Ie}),j=I({queryKey:["forge-psyche-values"],queryFn:Ce}),d=((D=v.data)==null?void 0:D.modes)??[],R=((O=x.data)==null?void 0:O.patterns)??[],J=((q=k.data)==null?void 0:q.behaviors)??[],G=((H=j.data)==null?void 0:H.values)??[],c=ne(s.selectedUserIds),B=h.get("focus"),$=s.snapshot.dashboard.notesSummaryByEntity;Me(B),b.useEffect(()=>{if(h.get("create")==="1"){n(!0),u(null),l({...g,userId:c});const e=new URLSearchParams(h);e.delete("create"),T(e,{replace:!0})}},[c,h,T]);const A=se({mutationFn:async e=>{const a=K.parse(e);return p?le(p.id,a):de(a)},onSuccess:async()=>{n(!1),u(null),l({...g,userId:c}),f(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-modes"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),V=R.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.preferredResponse||e.targetBehavior,e.user),searchText:S([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),Z=J.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.kind,e.user),searchText:S([e.title,e.kind,e.description],e),kind:"behavior"})),W=G.map(e=>({value:e.id,label:E(e.title,e.user),description:M(e.valuedDirection,e.user),searchText:S([e.title,e.valuedDirection,e.description],e),kind:"value"})),X=async e=>{const{pattern:a}=await ve({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return F(o,["forge-psyche-patterns"],"patterns",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.preferredResponse||a.targetBehavior,kind:"pattern"}},Y=async e=>{const{behavior:a}=await xe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:y.userId});return F(o,["forge-psyche-behaviors"],"behaviors",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.kind,kind:"behavior"}},ee=async e=>{const{value:a}=await ke({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return F(o,["forge-psyche-values"],"values",a),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},te=[{id:"identity",eyebrow:"Identity",title:"Name the cast member and place it in the right family",description:"Start with the mode itself: who it feels like, what family it belongs to, and the recognizable role it plays.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(be,{value:e.userId??null,users:s.snapshot.users,onChange:r=>a({userId:r}),defaultLabel:fe(s.snapshot.users.find(r=>r.id===c)??null,"Choose mode owner"),help:"Modes can belong to a human or bot user while still linking across shared patterns, behaviors, and values."}),t.jsx(i,{label:"Mode family",description:"Choose the broader inner family this mode belongs to.",labelHelp:"A mode family is the bigger cluster this state belongs to, like a coping part, a vulnerable child state, or a healthy adult response.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["coping","child","critic_parent","healthy_adult","happy_child"].map(r=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.family===r?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] 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)]"}`,onClick:()=>a({family:r}),children:L[r]},r))})}),t.jsx(i,{label:"Mode name",description:"Give it a memorable name you would instantly recognize later.",labelHelp:"This is the user-facing name of the mode. It should read like a cast member title, not a clinical record.",children:t.jsx(P,{value:e.title,onChange:r=>a({title:r.target.value}),placeholder:"The Friday Vigil, The Scanner, The Good Son"})}),t.jsx(i,{label:"Archetype",description:"Name the recognizable inner role or pattern this mode most resembles.",labelHelp:"An archetype is the role this mode tends to play, like a protector, a critic, a frightened child, or a calm adult anchor.",children:t.jsx(P,{value:e.archetype,onChange:r=>a({archetype:r.target.value}),placeholder:"Detached protector, vulnerable child, demanding critic"})})]})},{id:"texture",eyebrow:"Texture",title:"Give the mode a recognizable presence",description:"Imagery, facial expression, and persona should make the mode instantly memorable.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Persona",description:"Describe how this mode sounds, moves, and carries itself.",labelHelp:"Persona is the tone, posture, and voice of the mode. Imagine how it enters the room and how it speaks.",children:t.jsx(m,{value:e.persona,onChange:r=>a({persona:r.target.value}),placeholder:"Quiet, hyper-alert, always scanning for threat and trying to stay one step ahead."})}),t.jsx(i,{label:"Imagery",description:"Capture the mental image or scene that helps this mode feel vivid.",labelHelp:"Imagery is the picture that makes the mode easy to remember, like a scene, posture, weather pattern, or atmosphere.",children:t.jsx(m,{value:e.imagery,onChange:r=>a({imagery:r.target.value}),placeholder:"A night watchman under cold fluorescent light, pacing and checking every door twice."})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(i,{label:"Symbolic form",description:"Pick the object, creature, or shape that best symbolizes this mode.",labelHelp:"Symbolic form is the metaphor for the mode, like armor, a fox, a storm front, or a glass wall.",children:t.jsx(P,{value:e.symbolicForm,onChange:r=>a({symbolicForm:r.target.value}),placeholder:"A locked visor, a fox, a steel shield"})}),t.jsx(i,{label:"Facial expression",description:"Describe what you would see on the mode's face if it took over.",labelHelp:"This is the visible emotional expression of the mode: tight jaw, blank stare, pleading eyes, or calm grounded attention.",children:t.jsx(P,{value:e.facialExpression,onChange:r=>a({facialExpression:r.target.value}),placeholder:"Tight jaw, narrowed eyes, forced calm"})})]})]})},{id:"burden",eyebrow:"Burden",title:"Map fear, burden, job, and origin",description:"This is what turns a named mode into a readable inner-state profile.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(i,{label:"Fear",description:"Name the threat this mode is trying hard to prevent.",labelHelp:"Fear is the danger the mode believes it must protect you from, such as rejection, shame, collapse, failure, or being trapped.",children:t.jsx(m,{value:e.fear,onChange:r=>a({fear:r.target.value}),placeholder:"If I relax, I will miss the threat and get hurt."})}),t.jsx(i,{label:"Burden",description:"Describe the emotional weight or exhausting role this mode keeps carrying.",labelHelp:"Burden is the heavy job or emotional load the mode feels stuck holding, even when it costs a lot.",children:t.jsx(m,{value:e.burden,onChange:r=>a({burden:r.target.value}),placeholder:"It believes it must never let the guard down, even when that means constant tension."})}),t.jsx(i,{label:"Protective job",description:"Describe the job this mode thinks it is performing for you.",labelHelp:"Protective job is the function the mode is trying to serve, like preventing rejection, keeping control, stopping humiliation, or preserving closeness.",children:t.jsx(m,{value:e.protectiveJob,onChange:r=>a({protectiveJob:r.target.value}),placeholder:"Keeps me prepared so I never get blindsided or look naive."})})]}),t.jsx(i,{label:"Origin context",description:"Describe when this mode first became useful or understandable.",labelHelp:"Origin context is the stretch of life where this mode likely learned its job or became especially necessary.",children:t.jsx(m,{value:e.originContext,onChange:r=>a({originContext:r.target.value}),placeholder:"Started getting stronger during adolescence when mistakes were met with criticism and unpredictability."})})]})},{id:"links",eyebrow:"Links",title:"Attach the mode to the rest of the psyche system",description:"Modes should connect to patterns, behaviors, and values, not sit in isolation.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:"Linked patterns",description:"Choose the loops this mode tends to activate or maintain.",children:t.jsx(N,{options:V,selectedValues:e.linkedPatternIds,onChange:r=>a({linkedPatternIds:r}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:X})}),t.jsx(i,{label:"Linked behaviors",description:"Choose the moves this mode tends to trigger, justify, or amplify.",children:t.jsx(N,{options:Z,selectedValues:e.linkedBehaviorIds,onChange:r=>a({linkedBehaviorIds:r}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:Y})}),t.jsx(i,{label:"Colliding values",description:"Choose the valued directions this mode most often interrupts.",labelHelp:"These are the values that get obscured, sidelined, or distorted when this mode takes over.",children:t.jsx(N,{options:W,selectedValues:e.linkedValueIds,onChange:r=>a({linkedValueIds:r}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:ee})})]})}];if(v.isLoading||x.isLoading||k.isLoading||j.isLoading)return t.jsx(ce,{eyebrow:"Modes",title:"Loading modes",description:"Getting modes, linked patterns, behaviors, and values ready."});const _=v.error??x.error??k.error??j.error;if(_)return t.jsx(he,{eyebrow:"Modes",error:_,onRetry:()=>void Promise.all([v.refetch(),x.refetch(),k.refetch(),j.refetch()])});const w={coping:d.filter(e=>e.family==="coping"),child:d.filter(e=>e.family==="child"),critic_parent:d.filter(e=>e.family==="critic_parent"),healthy_adult:d.filter(e=>e.family==="healthy_adult"),happy_child:d.filter(e=>e.family==="happy_child")};return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Ne,{entityKind:"mode",title:t.jsx(Q,{kind:"mode",label:"Modes",variant:"heading",size:"lg"}),description:"Modes should look and feel like a cast of inner states with identity, burden, and relational links, not a flat list of records.",badge:`${d.length} modes`,actions:t.jsx(C,{onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:"Add mode"})}),t.jsx(pe,{}),t.jsx(Se,{eyebrow:"Mode families",title:"Modes by family",description:"Use these groups to see which modes show up most often, what role they play, and what they are connected to.",tone:"violet",children:d.length===0?t.jsx("div",{className:"flex justify-start",children:t.jsx(C,{onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:"Add mode"})}):t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:Object.keys(w).map(e=>t.jsxs("div",{className:"grid gap-3 rounded-[26px] bg-[var(--ui-surface-1)] p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(Le,{family:e,label:L[e]}),t.jsx(ue,{children:w[e].length})]}),w[e].length===0?t.jsx("div",{className:"flex",children:t.jsxs(C,{variant:"secondary",onClick:()=>{u(null),l({...g,userId:c}),n(!0)},children:["Add ",L[e].toLowerCase()]})}):w[e].map(a=>t.jsxs("div",{"data-psyche-focus-id":a.id,className:`rounded-[22px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${Ee(B===a.id)}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(me,{kind:"mode",compact:!0,gradient:!1}),t.jsx(Q,{kind:"mode",label:a.title,variant:"heading",size:"lg"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Pe,{entityType:"mode_profile",entityId:a.id,count:ge($,"mode_profile",a.id).count}),t.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{u(a),l(Te(a)),n(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:a.archetype}),t.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.persona||a.protectiveJob||"Open the mode to add persona and protective details."})]},a.id))]},e))})}),t.jsx(ye,{open:U,onOpenChange:n,eyebrow:"Mode",title:p?"Refine cast member":"Create mode",description:"Use this guided flow to define the mode, how it shows up, what it is protecting, and where it comes from.",value:y,onChange:l,draftPersistenceKey:p?`psyche.mode.${p.id}`:"psyche.mode.new",steps:te,submitLabel:p?"Save mode":"Create mode",pending:A.isPending,error:z,onSubmit:async()=>{f(null);const e=K.safeParse(y);if(!e.success){f("This mode still needs a family and a name before it can be saved.");return}try{await A.mutateAsync(e.data)}catch(a){f(a instanceof Error?a.message:"Unable to save this mode right now.")}}})]})}export{$e as PsycheModesPage};
@@ -1 +1 @@
1
- import{b5 as Q,r as g,j as e,aC as y,c2 as U}from"./vendor-kIz9EZnX.js";import{i as G}from"./state-VYvD1QVP.js";import{A as z}from"./ai-surface-workspace-xtB5RFQu.js";import{b as Z,P as J}from"./psyche-graph-IkUQRaDK.js";import{u as H,Q as X,j as Y,F as ee,b as N,C as P,Z as K,S as te,E as se,a8 as re,ch as ae,B as ie,V as ne,c as I,cj as oe,ad as le,ck as de}from"./index-BHIKoiZ6.js";import{P as ce}from"./page-hero-oFHaAjtL.js";import"./board-DqHzdCPQ.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./graph-BTa79qum.js";const D={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function ue({open:t,onOpenChange:o}){const d=Q(),l=H(),[c,b]=g.useState(D),k=[{id:"intent",eyebrow:"Reflect",title:"What do you want to reflect on?",description:"Choose the entrypoint first. Forge will route you into the right guided flow instead of dropping you into a generic form.",render:(i,r)=>e.jsx(Y,{columns:3,value:i.intent,onChange:s=>r({intent:s}),options:[{value:"trigger_report",label:"A situation",description:"Start a Spark-to-Pivot report about something that happened."},{value:"behavior",label:"A behavior",description:"Trace an away move, committed action, or recovery path."},{value:"belief",label:"A belief script",description:"Capture or refine the belief beneath the reaction."},{value:"pattern",label:"A recurring pattern",description:"Map the loop, payoff, cost, and better response."},{value:"value",label:"A blocked value",description:"Clarify which value is being challenged or needs support."},{value:"execution_tension",label:"A goal tension",description:"Reflect on a goal, project, or task that carries friction."}]})},{id:"placement",eyebrow:"Placement",title:"Attach the reflection to the wider system",description:"This keeps the reflection connected to values, behaviors, and live work instead of becoming an isolated note.",render:(i,r)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(ee,{label:"Goal / project / task tension",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{kind:"goal",label:"Goal",compact:!0,gradient:!1}),e.jsx(N,{kind:"project",label:"Project",compact:!0,gradient:!1}),e.jsx(N,{kind:"task",label:"Task",compact:!0,gradient:!1})]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedGoalId,onChange:s=>r({linkedGoalId:s.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),l.snapshot.goals.map(s=>e.jsxs("option",{value:s.id,children:["Goal · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedProjectId,onChange:s=>r({linkedProjectId:s.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),l.snapshot.dashboard.projects.map(s=>e.jsxs("option",{value:s.id,children:["Project · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedTaskId,onChange:s=>r({linkedTaskId:s.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),l.snapshot.tasks.slice(0,40).map(s=>e.jsxs("option",{value:s.id,children:["Task · ",s.title]},s.id))]})]})})})}],h=async()=>{const i=new URLSearchParams({create:"1",intent:c.intent});switch(c.linkedGoalId&&i.set("goalId",c.linkedGoalId),c.linkedProjectId&&i.set("projectId",c.linkedProjectId),c.linkedTaskId&&i.set("taskId",c.linkedTaskId),c.intent){case"behavior":d(`/psyche/behaviors?${i.toString()}`);break;case"belief":d(`/psyche/schemas-beliefs?${i.toString()}`);break;case"pattern":d(`/psyche/patterns?${i.toString()}`);break;case"value":d(`/psyche/values?${i.toString()}`);break;case"execution_tension":case"trigger_report":default:d(`/psyche/reports?${i.toString()}`);break}o(!1),b(D)};return e.jsx(X,{open:t,onOpenChange:o,eyebrow:"Reflect",title:"Start from the right reflective doorway",description:"Choose what you want to reflect on first. Forge will take you into the right guided flow instead of leaving you in a generic form.",value:c,onChange:b,draftPersistenceKey:"psyche.reflect.launcher",steps:k,submitLabel:"Open guided reflection",onSubmit:h})}function _({to:t,children:o,className:d}){return e.jsx(y,{to:t,className:"group block transition-transform duration-[var(--motion-medium)] ease-[var(--ease-standard)] hover:-translate-y-0.5 focus-visible:outline-none",children:e.jsx(P,{className:K("transition-[transform,box-shadow,background,border-color] duration-[var(--motion-medium)] ease-[var(--ease-standard)] group-hover:border-[var(--ui-border-strong)] group-hover:bg-[var(--ui-surface-hover)] group-hover:shadow-[var(--card-shadow-hover)] group-focus-visible:shadow-[var(--card-shadow-hover)]",d),children:o})})}function C(t){return`${t.toFixed(t>=10?0:1)}%`}function f(t){return new Intl.NumberFormat().format(Math.round(t))}const W="inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",me="bg-[linear-gradient(135deg,color-mix(in_srgb,var(--primary)_34%,var(--ui-surface-2)_66%),color-mix(in_srgb,var(--primary)_18%,var(--ui-surface-1)_82%))] text-[var(--ui-ink-strong)]";function M(t,o){return o==="percent"?C(t):f(t)}function pe({metric:t}){const o=t.history.slice(0,7).reverse(),d=Math.max(1,...o.map(l=>l.rawSwearCount));return e.jsxs(P,{className:"min-w-0 border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--ui-warning-soft)_48%,var(--ui-surface-1)_52%)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Devrage metric"}),e.jsxs("div",{className:"mt-2 break-words font-display text-[clamp(1.4rem,2.5vw,2.15rem)] leading-none text-[var(--ui-ink-strong)]",children:[f(t.rawSwearCount)," swears"]})]}),e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:t.latestDateKey??"No history"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Swearing messages"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:C(t.swearingMessagePercent)})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Daily average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.dailyAverage.rawSwearCount,"count")})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Weekly average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.weeklyAverage.rawSwearCount,"count")})]})]}),e.jsx("div",{className:"mt-4 flex h-16 items-end gap-1.5",children:o.length>0?o.map(l=>e.jsx("div",{className:"min-w-0 flex-1 rounded-t-[6px] bg-[var(--warning)]/50",style:{height:`${Math.max(8,l.rawSwearCount/d*64)}px`},title:`${l.dateKey}: ${f(l.rawSwearCount)} swears, ${C(l.swearingMessagePercent)} swearing messages`},l.dateKey)):e.jsx("div",{className:"self-center text-sm text-[var(--ui-ink-faint)]",children:"History will appear after the first local backfill."})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:[f(t.conversationsScanned)," conversations"]}),e.jsxs("span",{children:[f(t.messagesScanned)," messages"]}),e.jsxs("span",{children:[f(t.messagesWithSwears)," flagged"]})]}),e.jsx(y,{to:"/psyche/metrics",className:"mt-4 inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] border border-[color-mix(in_srgb,var(--warning)_24%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-2 text-sm font-medium text-[var(--warning)] transition hover:bg-[color-mix(in_srgb,var(--warning)_20%,transparent)]",children:"Open metrics"})]})}function Se(){var A,T;const t=H(),[o,d]=U(),[l,c]=g.useState(o.get("reflect")==="1"),[b,k]=g.useState(null),h=G({queryKey:["forge-psyche-overview"],queryFn:le}),i=G({queryKey:["forge-psyche-questionnaires-hub"],queryFn:()=>de()}),r=(A=h.data)==null?void 0:A.overview,s=g.useMemo(()=>r?t.snapshot.goals.slice(0,3).map(a=>{const m=r.values.filter(u=>u.linkedGoalIds.includes(a.id)),S=t.snapshot.dashboard.projects.filter(u=>u.goalId===a.id),F=t.snapshot.habits.filter(u=>u.linkedGoalIds.includes(a.id)||u.linkedValueIds.some(w=>m.some(j=>j.id===w))),O=r.reports.filter(u=>u.linkedGoalIds.includes(a.id)),L=r.behaviors.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w))),V=r.beliefs.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w)));return{goal:a,linkedValues:m,linkedProjects:S,linkedHabits:F,linkedReports:O,linkedBehaviors:L,linkedBeliefs:V}}):[],[r,t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.habits]),p=g.useMemo(()=>Z(s,{compact:!0}),[s]);if(g.useEffect(()=>{k(p.defaultSelectedId)},[p.defaultSelectedId]),h.isLoading)return e.jsx(te,{});if(h.isError||!r)return e.jsx(se,{eyebrow:"Psyche",error:h.error,onRetry:()=>void h.refetch()});const n=p.inspectors[b??p.defaultSelectedId]??p.inspectors[p.defaultSelectedId],v=r.patterns[0]??null,R=r.reports[0]??null,x=[...((T=i.data)==null?void 0:T.instruments)??[]].sort((a,m)=>{const S=a.latestRunAt?new Date(a.latestRunAt).getTime():0;return(m.latestRunAt?new Date(m.latestRunAt).getTime():0)-S})[0]??null,E="Values, patterns, behaviors, beliefs, habits, and reports in one live field.",$=r.devrageMetric.hasData||r.devrageMetric.conversationsScanned>0||r.devrageMetric.history.length>0,q=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(re,{metrics:t.snapshot.metrics}),e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"})]}),B=[{id:"hero",title:"Psyche",description:"Top route composition",defaultWidth:12,defaultHeight:1,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ce,{title:"Psyche",titleText:"Psyche",description:E,actions:q})},{id:"sections",title:"Psyche sections",description:"Section switcher",defaultWidth:12,defaultHeight:1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ae,{})},{id:"field",title:"Live field",description:"Graph and inspector stay as movable widgets.",defaultWidth:8,defaultHeight:5,minWidth:6,render:()=>e.jsx(J,{testId:"psyche-hub-graph",compact:!0,title:"Reflective pulse and live entity field",hint:"Select any goal, value, habit, belief, behavior, project, or report.",nodes:p.nodes,edges:p.edges,fields:p.fields,selectedNodeId:b,onSelectNode:k,minHeightClassName:"min-h-[20rem] sm:min-h-[24rem] lg:min-h-[34rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Habits",kind:"habit"},{label:"Behaviors",kind:"behavior"}],action:e.jsxs(e.Fragment,{children:[e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"}),e.jsx(ie,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>c(!0),children:"Reflect"})]})})},{id:"inspector",title:"Inspector",description:"Selected-node inspector widget.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>e.jsxs(P,{className:"h-full min-w-0",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(N,{kind:n.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n.eyebrow})}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(ne,{kind:n.entityKind,label:n.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.25rem,2.2vw,1.8rem)] leading-none text-[var(--ui-ink-strong)]",children:n.title})}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:n.summary}),n.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:n.chips.map(a=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a},a))}):null,n.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:n.stats.map(a=>e.jsx("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)] break-words",children:a},a))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(y,{to:n.href,className:K("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",n.entityKind?oe(n.entityKind,!0):me),children:n.ctaLabel})})]})},...$?[{id:"devrage",title:"Devrage metric",description:"Daily user-message frustration metric.",defaultWidth:4,defaultHeight:3,minWidth:4,render:()=>e.jsx(pe,{metric:r.devrageMetric})}]:[],{id:"actions",title:"Open threads",description:"Action and pulse cards.",defaultWidth:8,defaultHeight:3,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(_,{to:"/psyche/behaviors",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-success-soft)_44%,var(--ui-surface-1)_56%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--success)]",children:"Best next reflective move"}),e.jsx("div",{className:"mt-3 break-words font-display text-[clamp(1.45rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(v==null?void 0:v.preferredResponse)||"Map the active loop, then name the committed move that brings you back."}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:(v==null?void 0:v.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(_,{to:R?`/psyche/reports/${R.id}`:"/psyche/reports",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-accent-soft)_46%,var(--ui-surface-1)_54%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Open threads"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Insights"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openInsights})]}),e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Notes"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openNotes})]})]})]})]})},{id:"questionnaires",title:"Questionnaire pulse",description:"Recent questionnaire state.",defaultWidth:12,defaultHeight:2,render:()=>{var a;return e.jsxs(_,{to:x!=null&&x.latestRunId?`/psyche/questionnaire-runs/${x.latestRunId}`:"/psyche/questionnaires",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--info)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-info-soft)_42%,var(--ui-surface-1)_58%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Questionnaire pulse"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.4rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(x==null?void 0:x.title)??"Questionnaire library ready"}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(((a=i.data)==null?void 0:a.instruments)??[]).length," available"]})]})]})}}];return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(z,{surfaceId:"psyche",baseWidgets:B}),e.jsx(ue,{open:l,onOpenChange:a=>{c(a);const m=new URLSearchParams(o);m.delete("reflect"),d(m,{replace:!0})}})]})}export{Se as PsychePage};
1
+ import{b5 as Q,r as g,j as e,aC as y,c2 as U}from"./vendor-Dnkkx2co.js";import{i as G}from"./state-vCcAT5Hq.js";import{A as z}from"./ai-surface-workspace-CutiG6uS.js";import{b as Z,P as J}from"./psyche-graph-EP5GL612.js";import{u as H,Q as X,j as Y,F as ee,b as N,C as P,Z as K,S as te,E as se,a8 as re,ch as ae,B as ie,V as ne,c as I,cj as oe,ad as le,ck as de}from"./index-EqQsXoat.js";import{P as ce}from"./page-hero-ffKzgyW3.js";import"./board-dIX6etHh.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./graph-DDUZNRsO.js";const D={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function ue({open:t,onOpenChange:o}){const d=Q(),l=H(),[c,b]=g.useState(D),k=[{id:"intent",eyebrow:"Reflect",title:"What do you want to reflect on?",description:"Choose the entrypoint first. Forge will route you into the right guided flow instead of dropping you into a generic form.",render:(i,r)=>e.jsx(Y,{columns:3,value:i.intent,onChange:s=>r({intent:s}),options:[{value:"trigger_report",label:"A situation",description:"Start a Spark-to-Pivot report about something that happened."},{value:"behavior",label:"A behavior",description:"Trace an away move, committed action, or recovery path."},{value:"belief",label:"A belief script",description:"Capture or refine the belief beneath the reaction."},{value:"pattern",label:"A recurring pattern",description:"Map the loop, payoff, cost, and better response."},{value:"value",label:"A blocked value",description:"Clarify which value is being challenged or needs support."},{value:"execution_tension",label:"A goal tension",description:"Reflect on a goal, project, or task that carries friction."}]})},{id:"placement",eyebrow:"Placement",title:"Attach the reflection to the wider system",description:"This keeps the reflection connected to values, behaviors, and live work instead of becoming an isolated note.",render:(i,r)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(ee,{label:"Goal / project / task tension",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{kind:"goal",label:"Goal",compact:!0,gradient:!1}),e.jsx(N,{kind:"project",label:"Project",compact:!0,gradient:!1}),e.jsx(N,{kind:"task",label:"Task",compact:!0,gradient:!1})]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedGoalId,onChange:s=>r({linkedGoalId:s.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),l.snapshot.goals.map(s=>e.jsxs("option",{value:s.id,children:["Goal · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedProjectId,onChange:s=>r({linkedProjectId:s.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),l.snapshot.dashboard.projects.map(s=>e.jsxs("option",{value:s.id,children:["Project · ",s.title]},s.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.linkedTaskId,onChange:s=>r({linkedTaskId:s.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),l.snapshot.tasks.slice(0,40).map(s=>e.jsxs("option",{value:s.id,children:["Task · ",s.title]},s.id))]})]})})})}],h=async()=>{const i=new URLSearchParams({create:"1",intent:c.intent});switch(c.linkedGoalId&&i.set("goalId",c.linkedGoalId),c.linkedProjectId&&i.set("projectId",c.linkedProjectId),c.linkedTaskId&&i.set("taskId",c.linkedTaskId),c.intent){case"behavior":d(`/psyche/behaviors?${i.toString()}`);break;case"belief":d(`/psyche/schemas-beliefs?${i.toString()}`);break;case"pattern":d(`/psyche/patterns?${i.toString()}`);break;case"value":d(`/psyche/values?${i.toString()}`);break;case"execution_tension":case"trigger_report":default:d(`/psyche/reports?${i.toString()}`);break}o(!1),b(D)};return e.jsx(X,{open:t,onOpenChange:o,eyebrow:"Reflect",title:"Start from the right reflective doorway",description:"Choose what you want to reflect on first. Forge will take you into the right guided flow instead of leaving you in a generic form.",value:c,onChange:b,draftPersistenceKey:"psyche.reflect.launcher",steps:k,submitLabel:"Open guided reflection",onSubmit:h})}function _({to:t,children:o,className:d}){return e.jsx(y,{to:t,className:"group block transition-transform duration-[var(--motion-medium)] ease-[var(--ease-standard)] hover:-translate-y-0.5 focus-visible:outline-none",children:e.jsx(P,{className:K("transition-[transform,box-shadow,background,border-color] duration-[var(--motion-medium)] ease-[var(--ease-standard)] group-hover:border-[var(--ui-border-strong)] group-hover:bg-[var(--ui-surface-hover)] group-hover:shadow-[var(--card-shadow-hover)] group-focus-visible:shadow-[var(--card-shadow-hover)]",d),children:o})})}function C(t){return`${t.toFixed(t>=10?0:1)}%`}function f(t){return new Intl.NumberFormat().format(Math.round(t))}const W="inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2 text-sm font-medium whitespace-nowrap text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",me="bg-[linear-gradient(135deg,color-mix(in_srgb,var(--primary)_34%,var(--ui-surface-2)_66%),color-mix(in_srgb,var(--primary)_18%,var(--ui-surface-1)_82%))] text-[var(--ui-ink-strong)]";function M(t,o){return o==="percent"?C(t):f(t)}function pe({metric:t}){const o=t.history.slice(0,7).reverse(),d=Math.max(1,...o.map(l=>l.rawSwearCount));return e.jsxs(P,{className:"min-w-0 border border-[color-mix(in_srgb,var(--warning)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--ui-warning-soft)_48%,var(--ui-surface-1)_52%)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Devrage metric"}),e.jsxs("div",{className:"mt-2 break-words font-display text-[clamp(1.4rem,2.5vw,2.15rem)] leading-none text-[var(--ui-ink-strong)]",children:[f(t.rawSwearCount)," swears"]})]}),e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:t.latestDateKey??"No history"})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Swearing messages"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:C(t.swearingMessagePercent)})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Daily average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.dailyAverage.rawSwearCount,"count")})]}),e.jsxs("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--ui-ink-faint)]",children:"Weekly average"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:M(t.weeklyAverage.rawSwearCount,"count")})]})]}),e.jsx("div",{className:"mt-4 flex h-16 items-end gap-1.5",children:o.length>0?o.map(l=>e.jsx("div",{className:"min-w-0 flex-1 rounded-t-[6px] bg-[var(--warning)]/50",style:{height:`${Math.max(8,l.rawSwearCount/d*64)}px`},title:`${l.dateKey}: ${f(l.rawSwearCount)} swears, ${C(l.swearingMessagePercent)} swearing messages`},l.dateKey)):e.jsx("div",{className:"self-center text-sm text-[var(--ui-ink-faint)]",children:"History will appear after the first local backfill."})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:[f(t.conversationsScanned)," conversations"]}),e.jsxs("span",{children:[f(t.messagesScanned)," messages"]}),e.jsxs("span",{children:[f(t.messagesWithSwears)," flagged"]})]}),e.jsx(y,{to:"/psyche/metrics",className:"mt-4 inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] border border-[color-mix(in_srgb,var(--warning)_24%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-2 text-sm font-medium text-[var(--warning)] transition hover:bg-[color-mix(in_srgb,var(--warning)_20%,transparent)]",children:"Open metrics"})]})}function Se(){var A,T;const t=H(),[o,d]=U(),[l,c]=g.useState(o.get("reflect")==="1"),[b,k]=g.useState(null),h=G({queryKey:["forge-psyche-overview"],queryFn:le}),i=G({queryKey:["forge-psyche-questionnaires-hub"],queryFn:()=>de()}),r=(A=h.data)==null?void 0:A.overview,s=g.useMemo(()=>r?t.snapshot.goals.slice(0,3).map(a=>{const m=r.values.filter(u=>u.linkedGoalIds.includes(a.id)),S=t.snapshot.dashboard.projects.filter(u=>u.goalId===a.id),F=t.snapshot.habits.filter(u=>u.linkedGoalIds.includes(a.id)||u.linkedValueIds.some(w=>m.some(j=>j.id===w))),O=r.reports.filter(u=>u.linkedGoalIds.includes(a.id)),L=r.behaviors.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w))),V=r.beliefs.filter(u=>u.linkedValueIds.some(w=>m.some(j=>j.id===w)));return{goal:a,linkedValues:m,linkedProjects:S,linkedHabits:F,linkedReports:O,linkedBehaviors:L,linkedBeliefs:V}}):[],[r,t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.habits]),p=g.useMemo(()=>Z(s,{compact:!0}),[s]);if(g.useEffect(()=>{k(p.defaultSelectedId)},[p.defaultSelectedId]),h.isLoading)return e.jsx(te,{});if(h.isError||!r)return e.jsx(se,{eyebrow:"Psyche",error:h.error,onRetry:()=>void h.refetch()});const n=p.inspectors[b??p.defaultSelectedId]??p.inspectors[p.defaultSelectedId],v=r.patterns[0]??null,R=r.reports[0]??null,x=[...((T=i.data)==null?void 0:T.instruments)??[]].sort((a,m)=>{const S=a.latestRunAt?new Date(a.latestRunAt).getTime():0;return(m.latestRunAt?new Date(m.latestRunAt).getTime():0)-S})[0]??null,E="Values, patterns, behaviors, beliefs, habits, and reports in one live field.",$=r.devrageMetric.hasData||r.devrageMetric.conversationsScanned>0||r.devrageMetric.history.length>0,q=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(re,{metrics:t.snapshot.metrics}),e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"})]}),B=[{id:"hero",title:"Psyche",description:"Top route composition",defaultWidth:12,defaultHeight:1,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ce,{title:"Psyche",titleText:"Psyche",description:E,actions:q})},{id:"sections",title:"Psyche sections",description:"Section switcher",defaultWidth:12,defaultHeight:1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ae,{})},{id:"field",title:"Live field",description:"Graph and inspector stay as movable widgets.",defaultWidth:8,defaultHeight:5,minWidth:6,render:()=>e.jsx(J,{testId:"psyche-hub-graph",compact:!0,title:"Reflective pulse and live entity field",hint:"Select any goal, value, habit, belief, behavior, project, or report.",nodes:p.nodes,edges:p.edges,fields:p.fields,selectedNodeId:b,onSelectNode:k,minHeightClassName:"min-h-[20rem] sm:min-h-[24rem] lg:min-h-[34rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Habits",kind:"habit"},{label:"Behaviors",kind:"behavior"}],action:e.jsxs(e.Fragment,{children:[e.jsx(y,{to:"/psyche/goal-map",className:W,children:"Open goal map"}),e.jsx(ie,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>c(!0),children:"Reflect"})]})})},{id:"inspector",title:"Inspector",description:"Selected-node inspector widget.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>e.jsxs(P,{className:"h-full min-w-0",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(N,{kind:n.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n.eyebrow})}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:n.entityKind?e.jsx(ne,{kind:n.entityKind,label:n.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"break-words font-display text-[clamp(1.25rem,2.2vw,1.8rem)] leading-none text-[var(--ui-ink-strong)]",children:n.title})}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:n.summary}),n.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:n.chips.map(a=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a},a))}):null,n.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:n.stats.map(a=>e.jsx("div",{className:"min-w-0 rounded-[18px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-medium)] break-words",children:a},a))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(y,{to:n.href,className:K("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[var(--ui-shadow-soft)]",n.entityKind?oe(n.entityKind,!0):me),children:n.ctaLabel})})]})},...$?[{id:"devrage",title:"Devrage metric",description:"Daily user-message frustration metric.",defaultWidth:4,defaultHeight:3,minWidth:4,render:()=>e.jsx(pe,{metric:r.devrageMetric})}]:[],{id:"actions",title:"Open threads",description:"Action and pulse cards.",defaultWidth:8,defaultHeight:3,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(_,{to:"/psyche/behaviors",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-success-soft)_44%,var(--ui-surface-1)_56%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--success)]",children:"Best next reflective move"}),e.jsx("div",{className:"mt-3 break-words font-display text-[clamp(1.45rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(v==null?void 0:v.preferredResponse)||"Map the active loop, then name the committed move that brings you back."}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:(v==null?void 0:v.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(_,{to:R?`/psyche/reports/${R.id}`:"/psyche/reports",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-accent-soft)_46%,var(--ui-surface-1)_54%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Open threads"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Insights"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openInsights})]}),e.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Notes"}),e.jsx("div",{className:"mt-2 break-words font-display text-4xl text-[var(--ui-ink-strong)]",children:r.openNotes})]})]})]})]})},{id:"questionnaires",title:"Questionnaire pulse",description:"Recent questionnaire state.",defaultWidth:12,defaultHeight:2,render:()=>{var a;return e.jsxs(_,{to:x!=null&&x.latestRunId?`/psyche/questionnaire-runs/${x.latestRunId}`:"/psyche/questionnaires",className:"rounded-[28px] border border-[color-mix(in_srgb,var(--info)_22%,var(--ui-border-subtle)_78%)] bg-[color-mix(in_srgb,var(--ui-info-soft)_42%,var(--ui-surface-1)_58%)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--info)]",children:"Questionnaire pulse"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-display text-[clamp(1.4rem,2.2vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:(x==null?void 0:x.title)??"Questionnaire library ready"}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(((a=i.data)==null?void 0:a.instruments)??[]).length," available"]})]})]})}}];return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(z,{surfaceId:"psyche",baseWidgets:B}),e.jsx(ue,{open:l,onOpenChange:a=>{c(a);const m=new URLSearchParams(o);m.delete("reflect"),d(m,{replace:!0})}})]})}export{Se as PsychePage};