forge-openclaw-plugin 0.3.15 → 0.3.17

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 (415) hide show
  1. package/README.md +6 -6
  2. package/dist/assets/{action-bar-B9MYlps2.js → action-bar-D3CEYlj4.js} +1 -1
  3. package/dist/assets/{activity-page-DbzbChcE.js → activity-page-Ce1pHIu5.js} +1 -1
  4. package/dist/assets/{ai-surface-workspace-CF0257Hs.js → ai-surface-workspace-DEliwOjF.js} +1 -1
  5. package/dist/assets/artifacts-page-BgyFVIVM.js +2 -0
  6. package/dist/assets/{atlas-panel-CO3RYAKn.js → atlas-panel-VZOnJa1c.js} +1 -1
  7. package/dist/assets/{board-CuxQRKPJ.js → board-DprRipIG.js} +1 -1
  8. package/dist/assets/{calendar-page-BuuHKEHC.js → calendar-page-Zstsn4uG.js} +1 -1
  9. package/dist/assets/{calendar-rules-DKftgNx5.js → calendar-rules-BGIBuEDk.js} +1 -1
  10. package/dist/assets/{calendar-week-toolbar-ChIpkT-G.js → calendar-week-toolbar-DXFkMkbq.js} +1 -1
  11. package/dist/assets/{charts-BzT4pUPg.js → charts-C5S0-BL7.js} +1 -1
  12. package/dist/assets/{companion-sync-lab-page-BZRX4Btw.js → companion-sync-lab-page-DIPPLFKt.js} +1 -1
  13. package/dist/assets/{daily-metrics-dashboard-CXDsaAQd.js → daily-metrics-dashboard-CG-OOCJz.js} +1 -1
  14. package/dist/assets/{define-workbench-box-CpG0Zb1L.js → define-workbench-box-BEEdtBkQ.js} +1 -1
  15. package/dist/assets/{entity-link-multiselect-Dl4rZqdg.js → entity-link-multiselect-BfDAROHB.js} +1 -1
  16. package/dist/assets/{entity-note-count-link-Bs1aKYyD.js → entity-note-count-link-BGOiaash.js} +1 -1
  17. package/dist/assets/{entity-notes-surface-B56XSw7M.js → entity-notes-surface-DPsJwqQa.js} +1 -1
  18. package/dist/assets/execution-board-Dg-2GSKv.js +1 -0
  19. package/dist/assets/{faceted-token-search-Dg2rjknH.js → faceted-token-search-DV7MSVYb.js} +1 -1
  20. package/dist/assets/{flagship-signal-deck-C6KVPhmM.js → flagship-signal-deck-D3wVL3bC.js} +1 -1
  21. package/dist/assets/{floating-action-menu-DAFAEBcA.js → floating-action-menu-BUs382px.js} +1 -1
  22. package/dist/assets/{forms-D1qJ3oOP.js → forms-ByKjodjN.js} +1 -1
  23. package/dist/assets/{generic-node-view-C6DK5hJ6.js → generic-node-view-BY5dbPXJ.js} +1 -1
  24. package/dist/assets/{goal-detail-page-CC4VXud6.js → goal-detail-page-MYr6j2B4.js} +1 -1
  25. package/dist/assets/{goal-dialog-15hD8EBp.js → goal-dialog-nkdME5Uy.js} +1 -1
  26. package/dist/assets/goals-page-BsFeBzU1.js +1 -0
  27. package/dist/assets/{graph-BF4IsheG.js → graph-CHVj0Z7n.js} +1 -1
  28. package/dist/assets/habits-page-wO461EVU.js +1 -0
  29. package/dist/assets/{health-boxes-DqgvIYoL.js → health-boxes-BphMeSJj.js} +1 -1
  30. package/dist/assets/index-CSd8ylsy.css +1 -0
  31. package/dist/assets/index-gmPaoLN-.js +2 -0
  32. package/dist/assets/{inline-note-fields-COgzxr_7.js → inline-note-fields-BvQwmMAv.js} +1 -1
  33. package/dist/assets/{insight-flow-dialog-Dmb6NSGp.js → insight-flow-dialog-H_eaOmst.js} +1 -1
  34. package/dist/assets/{insights-page-OnqR4cYI.js → insights-page-DINYe3cB.js} +3 -3
  35. package/dist/assets/{kanban-boxes-BWUzntCV.js → kanban-boxes-oACOTDYG.js} +1 -1
  36. package/dist/assets/{kanban-page-BI16Gzp_.js → kanban-page-BGLXH91f.js} +1 -1
  37. package/dist/assets/knowledge-graph-page-VfMvw5jL.js +1 -0
  38. package/dist/assets/{life-force-page-CDEXEQai.js → life-force-page-DQPb6UL-.js} +1 -1
  39. package/dist/assets/{life-force-workspace-C7UOnJEf.js → life-force-workspace-BJ1aI3JE.js} +1 -1
  40. package/dist/assets/{maps-BTVHALP8.js → maps-CvEHVkBk.js} +1 -1
  41. package/dist/assets/{metric-tile-boeHB1R1.js → metric-tile-CbEe19Gd.js} +1 -1
  42. package/dist/assets/{motion-DcgUnXhY.js → motion-BibSzp57.js} +1 -1
  43. package/dist/assets/{movement-boxes-BUSqaTL2.js → movement-boxes-dtDYhw5c.js} +1 -1
  44. package/dist/assets/{movement-page-DcbO0497.js → movement-page-BhmwCHjs.js} +1 -1
  45. package/dist/assets/{note-markdown-DXXI3W3V.js → note-markdown-CG8u2d6p.js} +1 -1
  46. package/dist/assets/{note-tags-input-CYh3TVW2.js → note-tags-input-D_conqDO.js} +1 -1
  47. package/dist/assets/{notes-boxes-CMJXX2K0.js → notes-boxes-BLKucFqW.js} +1 -1
  48. package/dist/assets/notes-page-CafVxWjb.js +1 -0
  49. package/dist/assets/{open-in-graph-button-4UYrp1XP.js → open-in-graph-button-DFQ4r6SN.js} +1 -1
  50. package/dist/assets/{orbit-map-BwK7sDaC.js → orbit-map-DsEl3ori.js} +1 -1
  51. package/dist/assets/overview-page-BffcX-pM.js +1 -0
  52. package/dist/assets/page-hero-U603l9rQ.js +1 -0
  53. package/dist/assets/pill-cluster-BYVFNppV.js +1 -0
  54. package/dist/assets/{preference-entity-handoff-button-C2ATjvws.js → preference-entity-handoff-button-cPrTpHsV.js} +1 -1
  55. package/dist/assets/{preferences-page-BAexXHye.js → preferences-page-DQjFIOmt.js} +1 -1
  56. package/dist/assets/{project-collections-B9nr-Ts-.js → project-collections-B9OGHGqm.js} +1 -1
  57. package/dist/assets/project-detail-page-r1Sw2kcO.js +1 -0
  58. package/dist/assets/{project-dialog-CBA-D65n.js → project-dialog-B2_PcXAf.js} +1 -1
  59. package/dist/assets/project-management-hierarchy-page-qLNG8hsh.js +1 -0
  60. package/dist/assets/{project-management-section-nav-DJ3QKCtr.js → project-management-section-nav-DFUlmMEB.js} +1 -1
  61. package/dist/assets/{projects-boxes-iBu_PRqe.js → projects-boxes-BA7_XaqX.js} +1 -1
  62. package/dist/assets/projects-page-B6ggXWFw.js +1 -0
  63. package/dist/assets/psyche-behaviors-page-ByWpXlLq.js +5 -0
  64. package/dist/assets/{psyche-flashcards-page-DQaw_vUQ.js → psyche-flashcards-page-B9nSc0mk.js} +1 -1
  65. package/dist/assets/{psyche-goal-map-page-C-ZTVOEP.js → psyche-goal-map-page-BQU7qI88.js} +1 -1
  66. package/dist/assets/{psyche-graph-DYzeClxn.js → psyche-graph-DCeP7r2b.js} +1 -1
  67. package/dist/assets/{psyche-metrics-page-C9hKn10A.js → psyche-metrics-page-DD2lOP-J.js} +1 -1
  68. package/dist/assets/psyche-mode-guide-page-DbtZgnjr.js +1 -0
  69. package/dist/assets/psyche-modes-page-3zFJWFQf.js +1 -0
  70. package/dist/assets/psyche-page-D5vXYkfB.js +1 -0
  71. package/dist/assets/psyche-patterns-page-BneAAeKS.js +5 -0
  72. package/dist/assets/{psyche-questionnaire-builder-page-gRwdGXde.js → psyche-questionnaire-builder-page-BH1la5C9.js} +1 -1
  73. package/dist/assets/{psyche-questionnaire-detail-page-CIP9b2UI.js → psyche-questionnaire-detail-page-DYav634P.js} +1 -1
  74. package/dist/assets/psyche-questionnaire-run-detail-page-9VaijhJm.js +1 -0
  75. package/dist/assets/{psyche-questionnaire-run-page-CXiJyd5i.js → psyche-questionnaire-run-page-e1T6k_dS.js} +1 -1
  76. package/dist/assets/{psyche-questionnaires-page-CFPKwA3O.js → psyche-questionnaires-page-Dyv367z9.js} +1 -1
  77. package/dist/assets/{psyche-report-detail-page-dU30a2WE.js → psyche-report-detail-page-hqxHIXw2.js} +3 -3
  78. package/dist/assets/psyche-reports-page-DhIfcGbt.js +1 -0
  79. package/dist/assets/{psyche-schemas-DDol0j-g.js → psyche-schemas-Cg51Ztxz.js} +1 -1
  80. package/dist/assets/psyche-schemas-beliefs-page-Dgb5o9vx.js +9 -0
  81. package/dist/assets/{psyche-screen-time-page-lIe6GQxJ.js → psyche-screen-time-page-D6MnJGNa.js} +1 -1
  82. package/dist/assets/{psyche-self-observation-page-BTE3KfIl.js → psyche-self-observation-page-C1Vyezbv.js} +1 -1
  83. package/dist/assets/{psyche-values-page-DclBZ9xw.js → psyche-values-page-B_JWVw1Q.js} +2 -2
  84. package/dist/assets/{question-flow-dialog-Ded2E85L.js → question-flow-dialog-yMYVk998.js} +2 -2
  85. package/dist/assets/{report-chain-fields-DY640iqL.js → report-chain-fields-D4NM9a6I.js} +1 -1
  86. package/dist/assets/rewards-page-B5-bcL4R.js +1 -0
  87. package/dist/assets/{scheduling-rules-editor-jakFfxqF.js → scheduling-rules-editor-De72IUax.js} +1 -1
  88. package/dist/assets/{schema-badge-30B5syHA.js → schema-badge-jX28kUa6.js} +1 -1
  89. package/dist/assets/{schemas-Db29G8NU.js → schemas-BlFy-uPR.js} +1 -1
  90. package/dist/assets/{select-menu-BF2zI3RW.js → select-menu-BXv1rsVc.js} +1 -1
  91. package/dist/assets/{settings-agents-page-Bh-Bv6FQ.js → settings-agents-page-DN_np10S.js} +1 -1
  92. package/dist/assets/settings-bin-page-BM5BpK_i.js +1 -0
  93. package/dist/assets/{settings-calendar-page-BA4_Qqiu.js → settings-calendar-page-Cg0gSSFs.js} +3 -3
  94. package/dist/assets/{settings-data-page-K4kpmQJY.js → settings-data-page-Dwmp2rLy.js} +1 -1
  95. package/dist/assets/{settings-logs-page-DkuNPAZo.js → settings-logs-page-DQNM21Re.js} +1 -1
  96. package/dist/assets/{settings-mobile-page-4pCNwD91.js → settings-mobile-page-DQdiRa-a.js} +1 -1
  97. package/dist/assets/settings-models-page-CAEPpuHF.js +1 -0
  98. package/dist/assets/{settings-page-B_Be0vOY.js → settings-page-Cl2KiCFg.js} +1 -1
  99. package/dist/assets/{settings-rewards-page-C6nFTWJu.js → settings-rewards-page-DoIUumhe.js} +1 -1
  100. package/dist/assets/{settings-section-nav-Lo-VKCfZ.js → settings-section-nav-D_N87IG0.js} +1 -1
  101. package/dist/assets/{settings-users-page-CVzNp4-m.js → settings-users-page-CPesR62N.js} +1 -1
  102. package/dist/assets/{settings-wiki-page-DXM--7BB.js → settings-wiki-page-BxMQM5Vi.js} +1 -1
  103. package/dist/assets/{sleep-page-DvPdZMKx.js → sleep-page-DUYmQKrg.js} +1 -1
  104. package/dist/assets/{sports-page-DjuZlOur.js → sports-page-Bzi5TF9T.js} +1 -1
  105. package/dist/assets/{state-Bpe5dF3T.js → state-BFyKSULP.js} +1 -1
  106. package/dist/assets/{strategies-page-PE1IlatS.js → strategies-page-C-T2MZx4.js} +1 -1
  107. package/dist/assets/{strategy-detail-page-C4KiEGCI.js → strategy-detail-page-3tYuSZu-.js} +1 -1
  108. package/dist/assets/{strategy-dialog-Cwf7Y3P5.js → strategy-dialog-BWm4slo4.js} +1 -1
  109. package/dist/assets/{surface-ubuOfukq.js → surface-BJObZeRw.js} +1 -1
  110. package/dist/assets/{table-U7otr5go.js → table-CTLroJKN.js} +1 -1
  111. package/dist/assets/task-detail-page-ZZOXSpSF.js +1 -0
  112. package/dist/assets/{task-dialog-CI_Fy_FW.js → task-dialog-2wy0xI7f.js} +5 -5
  113. package/dist/assets/timebox-planning-dialog-C6h0Hp71.js +1 -0
  114. package/dist/assets/{today-boxes-CYuxSkZf.js → today-boxes-B_TdgSDz.js} +1 -1
  115. package/dist/assets/today-page-Dipns9tl.js +1 -0
  116. package/dist/assets/training-load-page-B78e1-o-.js +1 -0
  117. package/dist/assets/{ui-B9TWEtCx.js → ui-uo_bNP7c.js} +1 -1
  118. package/dist/assets/{use-anchored-overlay-position-BY4kNzPj.js → use-anchored-overlay-position-BSxFX6Hi.js} +1 -1
  119. package/dist/assets/{use-psyche-focus-target-BhNedCZB.js → use-psyche-focus-target-1GLkhYiv.js} +1 -1
  120. package/dist/assets/{user-badge-ByhC6bMU.js → user-badge-C4eZu1e_.js} +1 -1
  121. package/dist/assets/{user-select-field-fx129Uh6.js → user-select-field-CmKwcbZt.js} +1 -1
  122. package/dist/assets/{utility-widgets-ilORjDmg.js → utility-widgets-B06wQFrd.js} +2 -2
  123. package/dist/assets/{vendor-BwL6m4SE.js → vendor-B7FKSwHK.js} +222 -212
  124. package/dist/assets/{vitals-page-mdEqIm_9.js → vitals-page-BC7QFsm2.js} +1 -1
  125. package/dist/assets/{weekly-review-page-C8W-yg5r.js → weekly-review-page-BjNsNoWj.js} +1 -1
  126. package/dist/assets/{weight-loss-page-BApTknCn.js → weight-loss-page-BOahGY9r.js} +1 -1
  127. package/dist/assets/{wiki-article-markdown-DBccllQg.js → wiki-article-markdown-DO47HnZf.js} +2 -2
  128. package/dist/assets/{wiki-editor-page-BfRfH1O3.js → wiki-editor-page-OWRUHl4O.js} +5 -5
  129. package/dist/assets/{wiki-ingest-history-page-C-6H3MU6.js → wiki-ingest-history-page-CuHpg2lZ.js} +1 -1
  130. package/dist/assets/{wiki-ingest-modal-DnlhByD_.js → wiki-ingest-modal-EZ3kX-vA.js} +1 -1
  131. package/dist/assets/wiki-page-BPV3HIgu.js +1 -0
  132. package/dist/assets/{workbench-flow-page-_-NKIx5R.js → workbench-flow-page-C53KueEz.js} +3 -3
  133. package/dist/assets/{workbench-page-NIAzggwX.js → workbench-page-DJ7nT2JQ.js} +1 -1
  134. package/dist/assets/workout-detail-page-Dhyu0q7o.js +2 -0
  135. package/dist/index.html +8 -8
  136. package/dist/openclaw/api-client.js +28 -2
  137. package/dist/openclaw/local-runtime.js +31 -14
  138. package/dist/openclaw/parity.d.ts +1 -1
  139. package/dist/openclaw/parity.js +10 -0
  140. package/dist/openclaw/routes.js +78 -0
  141. package/dist/openclaw/tools.js +42 -0
  142. package/dist/server/apps/api/migrations/072_artifact_store.sql +106 -0
  143. package/dist/server/{server → apps/api}/src/app.js +365 -4
  144. package/dist/server/{server → apps/api}/src/connectors/box-registry.js +3 -3
  145. package/dist/server/{server → apps/api}/src/db.js +23 -4
  146. package/dist/server/{server → apps/api}/src/health-weight-loss.js +1 -1
  147. package/dist/server/{server → apps/api}/src/openapi.js +570 -1
  148. package/dist/server/{server → apps/api}/src/questionnaire-seeds.js +1 -1
  149. package/dist/server/{server → apps/api}/src/repositories/ai-connectors.js +1 -1
  150. package/dist/server/apps/api/src/repositories/entity-links.js +66 -0
  151. package/dist/server/{server → apps/api}/src/repositories/habits.js +1 -1
  152. package/dist/server/apps/api/src/services/artifacts.js +1059 -0
  153. package/dist/server/{server → apps/api}/src/services/companion-iroh.js +4 -1
  154. package/dist/server/{server → apps/api}/src/services/doctor.js +3 -3
  155. package/dist/server/{server → apps/api}/src/services/entity-crud.js +22 -0
  156. package/dist/server/{server → apps/api}/src/services/gamification-assets.js +1 -1
  157. package/dist/server/{server → apps/api}/src/services/gamification.js +1 -1
  158. package/dist/server/{server → apps/api}/src/services/knowledge-graph.js +48 -3
  159. package/dist/server/{server → apps/api}/src/services/psyche-observation-calendar.js +1 -0
  160. package/dist/server/{server → apps/api}/src/types.js +4 -2
  161. package/dist/server/{server → apps/api}/src/watch-mobile.js +1 -1
  162. package/dist/server/{src → apps/web/src}/lib/api.js +69 -0
  163. package/dist/server/{src → apps/web/src}/lib/entity-visuals.js +10 -1
  164. package/dist/server/{src → apps/web/src}/lib/knowledge-graph-types.js +9 -0
  165. package/openclaw.plugin.json +2 -1
  166. package/package.json +3 -3
  167. package/server/index.js +3 -3
  168. package/server/migrations/072_artifact_store.sql +106 -0
  169. package/skills/forge-openclaw/SKILL.md +60 -7
  170. package/skills/forge-openclaw/entity_conversation_playbooks.md +212 -14
  171. package/skills/forge-openclaw/psyche_entity_playbooks.md +20 -0
  172. package/dist/assets/execution-board-D66C_ikW.js +0 -1
  173. package/dist/assets/goals-page-CQ2lJMzI.js +0 -1
  174. package/dist/assets/habits-page-a7KVPaQp.js +0 -1
  175. package/dist/assets/index-ClJbJhca.css +0 -1
  176. package/dist/assets/index-FpGANF9S.js +0 -2
  177. package/dist/assets/knowledge-graph-page-DxEBaEke.js +0 -1
  178. package/dist/assets/notes-page-DvHMcQey.js +0 -1
  179. package/dist/assets/overview-page-Z5vaUTm3.js +0 -1
  180. package/dist/assets/page-hero-DvrM83_C.js +0 -1
  181. package/dist/assets/pill-cluster-DYI3Ibj8.js +0 -1
  182. package/dist/assets/project-detail-page-B9PqyPu9.js +0 -1
  183. package/dist/assets/project-management-hierarchy-page-DXK14jn0.js +0 -1
  184. package/dist/assets/projects-page-CdAk-ByT.js +0 -1
  185. package/dist/assets/psyche-behaviors-page-CbhhTfU2.js +0 -5
  186. package/dist/assets/psyche-mode-guide-page-CR8e984W.js +0 -1
  187. package/dist/assets/psyche-modes-page-lQdpAcY3.js +0 -1
  188. package/dist/assets/psyche-page-CTdIDkw9.js +0 -1
  189. package/dist/assets/psyche-patterns-page-Drgm-f7I.js +0 -5
  190. package/dist/assets/psyche-questionnaire-run-detail-page-SYndwtF3.js +0 -1
  191. package/dist/assets/psyche-reports-page-Cn0EBndy.js +0 -1
  192. package/dist/assets/psyche-schemas-beliefs-page-Bab4xSWv.js +0 -9
  193. package/dist/assets/rewards-page-FxUXB76B.js +0 -1
  194. package/dist/assets/settings-bin-page-DT8JJero.js +0 -1
  195. package/dist/assets/settings-models-page-CZHG3t7W.js +0 -1
  196. package/dist/assets/task-detail-page-B3SMFZQ3.js +0 -1
  197. package/dist/assets/timebox-planning-dialog-BtFuVoA1.js +0 -1
  198. package/dist/assets/today-page-CHGpLEZ3.js +0 -1
  199. package/dist/assets/training-load-page-GZJF-Yy5.js +0 -1
  200. package/dist/assets/wiki-page-DPZ55e3x.js +0 -1
  201. package/dist/assets/workout-detail-page-3fxr6HL4.js +0 -2
  202. /package/dist/server/{server → apps/api}/migrations/001_core.sql +0 -0
  203. /package/dist/server/{server → apps/api}/migrations/002_psyche.sql +0 -0
  204. /package/dist/server/{server → apps/api}/migrations/003_habits.sql +0 -0
  205. /package/dist/server/{server → apps/api}/migrations/004_habit_links.sql +0 -0
  206. /package/dist/server/{server → apps/api}/migrations/005_habit_psyche_links.sql +0 -0
  207. /package/dist/server/{server → apps/api}/migrations/006_work_adjustments.sql +0 -0
  208. /package/dist/server/{server → apps/api}/migrations/007_weekly_review_closures.sql +0 -0
  209. /package/dist/server/{server → apps/api}/migrations/008_calendar_execution.sql +0 -0
  210. /package/dist/server/{server → apps/api}/migrations/009_true_calendar_events.sql +0 -0
  211. /package/dist/server/{server → apps/api}/migrations/010_calendar_selection_state.sql +0 -0
  212. /package/dist/server/{server → apps/api}/migrations/011_calendar_timezone_backfill.sql +0 -0
  213. /package/dist/server/{server → apps/api}/migrations/012_work_block_ranges.sql +0 -0
  214. /package/dist/server/{server → apps/api}/migrations/013_microsoft_local_auth_settings.sql +0 -0
  215. /package/dist/server/{server → apps/api}/migrations/014_note_tags_and_ephemeral.sql +0 -0
  216. /package/dist/server/{server → apps/api}/migrations/015_multi_user_and_strategies.sql +0 -0
  217. /package/dist/server/{server → apps/api}/migrations/016_health_companion.sql +0 -0
  218. /package/dist/server/{server → apps/api}/migrations/016_strategy_contracts_and_user_graph.sql +0 -0
  219. /package/dist/server/{server → apps/api}/migrations/017_preferences.sql +0 -0
  220. /package/dist/server/{server → apps/api}/migrations/018_preference_catalogs.sql +0 -0
  221. /package/dist/server/{server → apps/api}/migrations/019_wiki_memory.sql +0 -0
  222. /package/dist/server/{server → apps/api}/migrations/020_wiki_page_hierarchy.sql +0 -0
  223. /package/dist/server/{server → apps/api}/migrations/021_hide_evidence_from_wiki_index.sql +0 -0
  224. /package/dist/server/{server → apps/api}/migrations/022_wiki_ingest_background.sql +0 -0
  225. /package/dist/server/{server → apps/api}/migrations/023_diagnostic_logs.sql +0 -0
  226. /package/dist/server/{server → apps/api}/migrations/024_questionnaires.sql +0 -0
  227. /package/dist/server/{server → apps/api}/migrations/025_ai_model_connections.sql +0 -0
  228. /package/dist/server/{server → apps/api}/migrations/026_custom_theme_settings.sql +0 -0
  229. /package/dist/server/{server → apps/api}/migrations/027_ai_processors.sql +0 -0
  230. /package/dist/server/{server → apps/api}/migrations/028_movement_domain.sql +0 -0
  231. /package/dist/server/{server → apps/api}/migrations/029_watch_micro_capture.sql +0 -0
  232. /package/dist/server/{server → apps/api}/migrations/030_surface_layouts.sql +0 -0
  233. /package/dist/server/{server → apps/api}/migrations/031_ai_processor_runtime_upgrades.sql +0 -0
  234. /package/dist/server/{server → apps/api}/migrations/032_ai_connectors.sql +0 -0
  235. /package/dist/server/{server → apps/api}/migrations/033_movement_trip_point_sync.sql +0 -0
  236. /package/dist/server/{server → apps/api}/migrations/034_movement_segment_sync.sql +0 -0
  237. /package/dist/server/{server → apps/api}/migrations/035_google_local_auth_settings.sql +0 -0
  238. /package/dist/server/{server → apps/api}/migrations/036_google_local_auth_client_secret.sql +0 -0
  239. /package/dist/server/{server → apps/api}/migrations/037_workbench_public_inputs_and_run_inputs.sql +0 -0
  240. /package/dist/server/{server → apps/api}/migrations/038_data_management_settings.sql +0 -0
  241. /package/dist/server/{server → apps/api}/migrations/039_life_force_and_action_points.sql +0 -0
  242. /package/dist/server/{server → apps/api}/migrations/040_screen_time_domain.sql +0 -0
  243. /package/dist/server/{server → apps/api}/migrations/041_companion_source_states.sql +0 -0
  244. /package/dist/server/{server → apps/api}/migrations/042_movement_boxes.sql +0 -0
  245. /package/dist/server/{server → apps/api}/migrations/043_movement_box_overlap_overrides.sql +0 -0
  246. /package/dist/server/{server → apps/api}/migrations/044_macos_local_calendar_provider.sql +0 -0
  247. /package/dist/server/{server → apps/api}/migrations/045_sleep_nights_and_raw_segments.sql +0 -0
  248. /package/dist/server/{server → apps/api}/migrations/046_work_item_hierarchy.sql +0 -0
  249. /package/dist/server/{server → apps/api}/migrations/047_sleep_source_records.sql +0 -0
  250. /package/dist/server/{server → apps/api}/migrations/048_task_run_git_context.sql +0 -0
  251. /package/dist/server/{server → apps/api}/migrations/049_agent_runtime_sessions.sql +0 -0
  252. /package/dist/server/{server → apps/api}/migrations/050_agent_token_bootstrap_policy.sql +0 -0
  253. /package/dist/server/{server → apps/api}/migrations/051_agent_token_scope_policy.sql +0 -0
  254. /package/dist/server/{server → apps/api}/migrations/052_agent_identity_tightening.sql +0 -0
  255. /package/dist/server/{server → apps/api}/migrations/053_agent_runtime_session_canonical_labels.sql +0 -0
  256. /package/dist/server/{server → apps/api}/migrations/054_sqlite_backed_wiki_memory.sql +0 -0
  257. /package/dist/server/{server → apps/api}/migrations/055_gamification_progression.sql +0 -0
  258. /package/dist/server/{server → apps/api}/migrations/056_gamification_equipment.sql +0 -0
  259. /package/dist/server/{server → apps/api}/migrations/057_gamification_catalog_cleanup.sql +0 -0
  260. /package/dist/server/{server → apps/api}/migrations/058_gamification_theme_preference.sql +0 -0
  261. /package/dist/server/{server → apps/api}/migrations/059_data_backup_retention.sql +0 -0
  262. /package/dist/server/{server → apps/api}/migrations/060_psyche_devrage_metrics.sql +0 -0
  263. /package/dist/server/{server → apps/api}/migrations/061_health_workout_raw_evidence.sql +0 -0
  264. /package/dist/server/{server → apps/api}/migrations/062_health_mobile_sync_sessions.sql +0 -0
  265. /package/dist/server/{server → apps/api}/migrations/063_psyche_flashcards.sql +0 -0
  266. /package/dist/server/{server → apps/api}/migrations/064_health_workout_time_series_identity.sql +0 -0
  267. /package/dist/server/{server → apps/api}/migrations/065_weight_loss_nutrition_insights.sql +0 -0
  268. /package/dist/server/{server → apps/api}/migrations/066_watch_action_receipts.sql +0 -0
  269. /package/dist/server/{server → apps/api}/migrations/067_weight_loss_daily_active_overrides.sql +0 -0
  270. /package/dist/server/{server → apps/api}/migrations/068_remove_generated_movement_wiki_logs.sql +0 -0
  271. /package/dist/server/{server → apps/api}/migrations/069_psyche_devrage_cumulative_rage.sql +0 -0
  272. /package/dist/server/{server → apps/api}/migrations/070_health_mobile_sync_completion_index.sql +0 -0
  273. /package/dist/server/{server → apps/api}/migrations/071_agent_runtime_claude_identity.sql +0 -0
  274. /package/dist/server/{server → apps/api}/src/data-management-types.js +0 -0
  275. /package/dist/server/{server → apps/api}/src/debug.js +0 -0
  276. /package/dist/server/{server → apps/api}/src/demo-data.js +0 -0
  277. /package/dist/server/{server → apps/api}/src/discovery-advertiser.js +0 -0
  278. /package/dist/server/{server → apps/api}/src/e2e-server.js +0 -0
  279. /package/dist/server/{server → apps/api}/src/errors.js +0 -0
  280. /package/dist/server/{server → apps/api}/src/health-workout-adapters.js +0 -0
  281. /package/dist/server/{server → apps/api}/src/health-workout-analytics.js +0 -0
  282. /package/dist/server/{server → apps/api}/src/health.js +0 -0
  283. /package/dist/server/{server → apps/api}/src/index.js +0 -0
  284. /package/dist/server/{server → apps/api}/src/managers/base.js +0 -0
  285. /package/dist/server/{server → apps/api}/src/managers/contracts.js +0 -0
  286. /package/dist/server/{server → apps/api}/src/managers/platform/api-gateway-manager.js +0 -0
  287. /package/dist/server/{server → apps/api}/src/managers/platform/audit-manager.js +0 -0
  288. /package/dist/server/{server → apps/api}/src/managers/platform/authentication-manager.js +0 -0
  289. /package/dist/server/{server → apps/api}/src/managers/platform/authorization-manager.js +0 -0
  290. /package/dist/server/{server → apps/api}/src/managers/platform/background-job-manager.js +0 -0
  291. /package/dist/server/{server → apps/api}/src/managers/platform/configuration-manager.js +0 -0
  292. /package/dist/server/{server → apps/api}/src/managers/platform/database-manager.js +0 -0
  293. /package/dist/server/{server → apps/api}/src/managers/platform/event-bus-manager.js +0 -0
  294. /package/dist/server/{server → apps/api}/src/managers/platform/external-service-manager.js +0 -0
  295. /package/dist/server/{server → apps/api}/src/managers/platform/health-manager.js +0 -0
  296. /package/dist/server/{server → apps/api}/src/managers/platform/llm-manager.js +0 -0
  297. /package/dist/server/{server → apps/api}/src/managers/platform/migration-manager.js +0 -0
  298. /package/dist/server/{server → apps/api}/src/managers/platform/mock-workbench-provider.js +0 -0
  299. /package/dist/server/{server → apps/api}/src/managers/platform/openai-responses-provider.js +0 -0
  300. /package/dist/server/{server → apps/api}/src/managers/platform/search-index-manager.js +0 -0
  301. /package/dist/server/{server → apps/api}/src/managers/platform/secrets-manager.js +0 -0
  302. /package/dist/server/{server → apps/api}/src/managers/platform/session-manager.js +0 -0
  303. /package/dist/server/{server → apps/api}/src/managers/platform/storage-manager.js +0 -0
  304. /package/dist/server/{server → apps/api}/src/managers/platform/token-manager.js +0 -0
  305. /package/dist/server/{server → apps/api}/src/managers/platform/transaction-manager.js +0 -0
  306. /package/dist/server/{server → apps/api}/src/managers/platform/trusted-network.js +0 -0
  307. /package/dist/server/{server → apps/api}/src/managers/runtime.js +0 -0
  308. /package/dist/server/{server → apps/api}/src/managers/type-guards.js +0 -0
  309. /package/dist/server/{server → apps/api}/src/movement.js +0 -0
  310. /package/dist/server/{server → apps/api}/src/preferences-seeds.js +0 -0
  311. /package/dist/server/{server → apps/api}/src/preferences-types.js +0 -0
  312. /package/dist/server/{server → apps/api}/src/psyche-types.js +0 -0
  313. /package/dist/server/{server → apps/api}/src/questionnaire-flow.js +0 -0
  314. /package/dist/server/{server → apps/api}/src/questionnaire-types.js +0 -0
  315. /package/dist/server/{server → apps/api}/src/repositories/activity-events.js +0 -0
  316. /package/dist/server/{server → apps/api}/src/repositories/agent-runtime-sessions.js +0 -0
  317. /package/dist/server/{server → apps/api}/src/repositories/ai-processors.js +0 -0
  318. /package/dist/server/{server → apps/api}/src/repositories/calendar.js +0 -0
  319. /package/dist/server/{server → apps/api}/src/repositories/collaboration.js +0 -0
  320. /package/dist/server/{server → apps/api}/src/repositories/deleted-entities.js +0 -0
  321. /package/dist/server/{server → apps/api}/src/repositories/diagnostic-logs.js +0 -0
  322. /package/dist/server/{server → apps/api}/src/repositories/domains.js +0 -0
  323. /package/dist/server/{server → apps/api}/src/repositories/entity-ownership.js +0 -0
  324. /package/dist/server/{server → apps/api}/src/repositories/event-log.js +0 -0
  325. /package/dist/server/{server → apps/api}/src/repositories/gamification.js +0 -0
  326. /package/dist/server/{server → apps/api}/src/repositories/goals.js +0 -0
  327. /package/dist/server/{server → apps/api}/src/repositories/model-settings.js +0 -0
  328. /package/dist/server/{server → apps/api}/src/repositories/notes.js +0 -0
  329. /package/dist/server/{server → apps/api}/src/repositories/preferences.js +0 -0
  330. /package/dist/server/{server → apps/api}/src/repositories/projects.js +0 -0
  331. /package/dist/server/{server → apps/api}/src/repositories/psyche.js +0 -0
  332. /package/dist/server/{server → apps/api}/src/repositories/questionnaires.js +0 -0
  333. /package/dist/server/{server → apps/api}/src/repositories/rewards.js +0 -0
  334. /package/dist/server/{server → apps/api}/src/repositories/settings.js +0 -0
  335. /package/dist/server/{server → apps/api}/src/repositories/strategies.js +0 -0
  336. /package/dist/server/{server → apps/api}/src/repositories/surface-layouts.js +0 -0
  337. /package/dist/server/{server → apps/api}/src/repositories/tags.js +0 -0
  338. /package/dist/server/{server → apps/api}/src/repositories/task-runs.js +0 -0
  339. /package/dist/server/{server → apps/api}/src/repositories/tasks.js +0 -0
  340. /package/dist/server/{server → apps/api}/src/repositories/users.js +0 -0
  341. /package/dist/server/{server → apps/api}/src/repositories/weekly-reviews.js +0 -0
  342. /package/dist/server/{server → apps/api}/src/repositories/wiki-memory.js +0 -0
  343. /package/dist/server/{server → apps/api}/src/repositories/work-adjustments.js +0 -0
  344. /package/dist/server/{server → apps/api}/src/runtime-data-root.js +0 -0
  345. /package/dist/server/{server → apps/api}/src/screen-time.js +0 -0
  346. /package/dist/server/{server → apps/api}/src/seed-demo.js +0 -0
  347. /package/dist/server/{server → apps/api}/src/services/calendar-runtime.js +0 -0
  348. /package/dist/server/{server → apps/api}/src/services/context.js +0 -0
  349. /package/dist/server/{server → apps/api}/src/services/dashboard.js +0 -0
  350. /package/dist/server/{server → apps/api}/src/services/data-management.js +0 -0
  351. /package/dist/server/{server → apps/api}/src/services/devrage-scanner.js +0 -0
  352. /package/dist/server/{server → apps/api}/src/services/devrage.js +0 -0
  353. /package/dist/server/{server → apps/api}/src/services/git-helper.js +0 -0
  354. /package/dist/server/{server → apps/api}/src/services/google-calendar-oauth-config.js +0 -0
  355. /package/dist/server/{server → apps/api}/src/services/insights.js +0 -0
  356. /package/dist/server/{server → apps/api}/src/services/legacy-wiki-markdown-import.js +0 -0
  357. /package/dist/server/{server → apps/api}/src/services/life-force-model.js +0 -0
  358. /package/dist/server/{server → apps/api}/src/services/life-force.js +0 -0
  359. /package/dist/server/{server → apps/api}/src/services/macos-calendar-helper.js +0 -0
  360. /package/dist/server/{server → apps/api}/src/services/openai-codex-oauth.js +0 -0
  361. /package/dist/server/{server → apps/api}/src/services/projects.js +0 -0
  362. /package/dist/server/{server → apps/api}/src/services/psyche.js +0 -0
  363. /package/dist/server/{server → apps/api}/src/services/relations.js +0 -0
  364. /package/dist/server/{server → apps/api}/src/services/reviews.js +0 -0
  365. /package/dist/server/{server → apps/api}/src/services/run-recovery.js +0 -0
  366. /package/dist/server/{server → apps/api}/src/services/tagging.js +0 -0
  367. /package/dist/server/{server → apps/api}/src/services/task-run-watchdog.js +0 -0
  368. /package/dist/server/{server → apps/api}/src/services/work-time.js +0 -0
  369. /package/dist/server/{server → apps/api}/src/web.js +0 -0
  370. /package/dist/server/{src → apps/web/src}/components/customization/utility-widgets.js +0 -0
  371. /package/dist/server/{src → apps/web/src}/components/ui/info-tooltip.js +0 -0
  372. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/calendar/calendar-boxes.js +0 -0
  373. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/goals/goals-boxes.js +0 -0
  374. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/habits/habits-boxes.js +0 -0
  375. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/health/health-boxes.js +0 -0
  376. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/insights/insights-boxes.js +0 -0
  377. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/kanban/kanban-boxes.js +0 -0
  378. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/movement/movement-boxes.js +0 -0
  379. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/notes/notes-boxes.js +0 -0
  380. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/overview/overview-boxes.js +0 -0
  381. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/preferences/preferences-boxes.js +0 -0
  382. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/projects/projects-boxes.js +0 -0
  383. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/psyche/psyche-boxes.js +0 -0
  384. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/questionnaires/questionnaires-boxes.js +0 -0
  385. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/review/review-boxes.js +0 -0
  386. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/shared/define-workbench-box.js +0 -0
  387. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/shared/generic-node-view.js +0 -0
  388. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/strategies/strategies-boxes.js +0 -0
  389. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/tasks/tasks-boxes.js +0 -0
  390. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/today/today-boxes.js +0 -0
  391. /package/dist/server/{src → apps/web/src}/components/workbench-boxes/wiki/wiki-boxes.js +0 -0
  392. /package/dist/server/{src → apps/web/src}/lib/api-error.js +0 -0
  393. /package/dist/server/{src → apps/web/src}/lib/calendar-name-deduper.js +0 -0
  394. /package/dist/server/{src → apps/web/src}/lib/data-management-types.js +0 -0
  395. /package/dist/server/{src → apps/web/src}/lib/date-keys.js +0 -0
  396. /package/dist/server/{src → apps/web/src}/lib/diagnostics.js +0 -0
  397. /package/dist/server/{src → apps/web/src}/lib/gamification-catalog.js +0 -0
  398. /package/dist/server/{src → apps/web/src}/lib/knowledge-graph.js +0 -0
  399. /package/dist/server/{src → apps/web/src}/lib/psyche-schemas.js +0 -0
  400. /package/dist/server/{src → apps/web/src}/lib/psyche-types.js +0 -0
  401. /package/dist/server/{src → apps/web/src}/lib/questionnaire-types.js +0 -0
  402. /package/dist/server/{src → apps/web/src}/lib/runtime-paths.js +0 -0
  403. /package/dist/server/{src → apps/web/src}/lib/schemas.js +0 -0
  404. /package/dist/server/{src → apps/web/src}/lib/snapshot-normalizer.js +0 -0
  405. /package/dist/server/{src → apps/web/src}/lib/theme-system.js +0 -0
  406. /package/dist/server/{src → apps/web/src}/lib/types.js +0 -0
  407. /package/dist/server/{src → apps/web/src}/lib/utils.js +0 -0
  408. /package/dist/server/{src → apps/web/src}/lib/weight-loss-energy-model.js +0 -0
  409. /package/dist/server/{src → apps/web/src}/lib/weight-loss-types.js +0 -0
  410. /package/dist/server/{src → apps/web/src}/lib/workbench/boxes.js +0 -0
  411. /package/dist/server/{src → apps/web/src}/lib/workbench/contracts.js +0 -0
  412. /package/dist/server/{src → apps/web/src}/lib/workbench/nodes.js +0 -0
  413. /package/dist/server/{src → apps/web/src}/lib/workbench/registry.js +0 -0
  414. /package/dist/server/{src → apps/web/src}/lib/workbench/runtime.js +0 -0
  415. /package/dist/server/{src → apps/web/src}/lib/workbench/tool-catalog.js +0 -0
@@ -1 +0,0 @@
1
- import{j as t,bY as re,r as b}from"./vendor-BwL6m4SE.js";import{j as ae,i as I,k as se}from"./state-Bpe5dF3T.js";import{Q as ie,F as i}from"./question-flow-dialog-Ded2E85L.js";import{E as oe}from"./entity-note-count-link-Bs1aKYyD.js";import{A as ne}from"./atlas-panel-CO3RYAKn.js";import{E as S}from"./entity-link-multiselect-Dl4rZqdg.js";import{c as le,d as de,L as ce,e as he,B as C,E as q,bs as pe,k as ue,b as me,R as ge,bY as ye,bQ as be,I as P,T as m,bO as fe,bN as ve,bP as xe,b7 as ke,b4 as je,b5 as we,b3 as Ie}from"./index-FpGANF9S.js";import{u as Ce,p as Pe}from"./use-psyche-focus-target-BhNedCZB.js";import{P as Se}from"./page-hero-DvrM83_C.js";import{U as Me}from"./user-select-field-fx129Uh6.js";import{p as M}from"./query-cache-IQ8W-LNC.js";import{a as K}from"./psyche-schemas-DDol0j-g.js";import{g as Ee,b as E,d as N,e as F,a as Ne}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";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:le("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 Xe(){var D,O,H,Q;const s=de(),o=ae(),[h,T]=re(),[U,n]=b.useState(!1),[p,u]=b.useState(null),[y,l]=b.useState(g),[R,f]=b.useState(null),v=I({queryKey:["forge-psyche-modes"],queryFn:ke}),x=I({queryKey:["forge-psyche-patterns"],queryFn:je}),k=I({queryKey:["forge-psyche-behaviors"],queryFn:we}),j=I({queryKey:["forge-psyche-values"],queryFn:Ie}),d=((D=v.data)==null?void 0:D.modes)??[],z=((O=x.data)==null?void 0:O.patterns)??[],J=((H=k.data)==null?void 0:H.behaviors)??[],G=((Q=j.data)==null?void 0:Q.values)??[],c=Ee(s.selectedUserIds),B=h.get("focus"),$=s.snapshot.dashboard.notesSummaryByEntity;Ce(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 r=K.parse(e);return p?ye(p.id,r):be(r)},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=z.map(e=>({value:e.id,label:F(e.title,e.user),description:N(e.preferredResponse||e.targetBehavior,e.user),searchText:E([e.title,e.preferredResponse,e.targetBehavior,e.description],e),kind:"pattern"})),Y=J.map(e=>({value:e.id,label:F(e.title,e.user),description:N(e.kind,e.user),searchText:E([e.title,e.kind,e.description],e),kind:"behavior"})),W=G.map(e=>({value:e.id,label:F(e.title,e.user),description:N(e.valuedDirection,e.user),searchText:E([e.title,e.valuedDirection,e.description],e),kind:"value"})),X=async e=>{const{pattern:r}=await fe({title:e,description:"",targetBehavior:e,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:y.userId});return M(o,["forge-psyche-patterns"],"patterns",r),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.preferredResponse||r.targetBehavior,kind:"pattern"}},Z=async e=>{const{behavior:r}=await ve({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:y.userId});return M(o,["forge-psyche-behaviors"],"behaviors",r),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},ee=async e=>{const{value:r}=await xe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:y.userId});return M(o,["forge-psyche-values"],"values",r),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.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,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Me,{value:e.userId??null,users:s.snapshot.users,onChange:a=>r({userId:a}),defaultLabel:Ne(s.snapshot.users.find(a=>a.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(a=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.family===a?"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:()=>r({family:a}),children:L[a]},a))})}),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:a=>r({title:a.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:a=>r({archetype:a.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,r)=>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:a=>r({persona:a.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:a=>r({imagery:a.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:a=>r({symbolicForm:a.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:a=>r({facialExpression:a.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,r)=>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:a=>r({fear:a.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:a=>r({burden:a.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:a=>r({protectiveJob:a.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:a=>r({originContext:a.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,r)=>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(S,{options:V,selectedValues:e.linkedPatternIds,onChange:a=>r({linkedPatternIds:a}),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(S,{options:Y,selectedValues:e.linkedBehaviorIds,onChange:a=>r({linkedBehaviorIds:a}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:Z})}),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(S,{options:W,selectedValues:e.linkedValueIds,onChange:a=>r({linkedValueIds:a}),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(Se,{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(ne,{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(r=>t.jsxs("div",{"data-psyche-focus-id":r.id,className:`rounded-[22px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${Pe(B===r.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:r.title,variant:"heading",size:"lg"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(oe,{entityType:"mode_profile",entityId:r.id,count:ge($,"mode_profile",r.id).count}),t.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{u(r),l(Te(r)),n(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:r.archetype}),t.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.persona||r.protectiveJob||"Open the mode to add persona and protective details."})]},r.id))]},e))})}),t.jsx(ie,{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:R,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(r){f(r instanceof Error?r.message:"Unable to save this mode right now.")}}})]})}export{Xe as PsycheModesPage};
@@ -1 +0,0 @@
1
- import{b6 as V,r as f,j as e,aC as k,bY as Q}from"./vendor-BwL6m4SE.js";import{i as F}from"./state-Bpe5dF3T.js";import{A as U}from"./ai-surface-workspace-CF0257Hs.js";import{b as z,P as Y}from"./psyche-graph-DYzeClxn.js";import{d as W,b as N,C,c as H,S as J,e as X,V as Z,bs as ee,B as te,E as se,k as I,bK as ae,a2 as re,bL as ie}from"./index-FpGANF9S.js";import{Q as ne,a as oe,F as le}from"./question-flow-dialog-Ded2E85L.js";import{P as de}from"./page-hero-DvrM83_C.js";import"./board-CuxQRKPJ.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./forms-D1qJ3oOP.js";const G={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function ce({open:t,onOpenChange:c}){const u=V(),o=W(),[l,b]=f.useState(G),y=[{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,a)=>e.jsx(oe,{columns:3,value:i.intent,onChange:s=>a({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,a)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(le,{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=>a({linkedGoalId:s.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),o.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=>a({linkedProjectId:s.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),o.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=>a({linkedTaskId:s.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),o.snapshot.tasks.slice(0,40).map(s=>e.jsxs("option",{value:s.id,children:["Task · ",s.title]},s.id))]})]})})})}],x=async()=>{const i=new URLSearchParams({create:"1",intent:l.intent});switch(l.linkedGoalId&&i.set("goalId",l.linkedGoalId),l.linkedProjectId&&i.set("projectId",l.linkedProjectId),l.linkedTaskId&&i.set("taskId",l.linkedTaskId),l.intent){case"behavior":u(`/psyche/behaviors?${i.toString()}`);break;case"belief":u(`/psyche/schemas-beliefs?${i.toString()}`);break;case"pattern":u(`/psyche/patterns?${i.toString()}`);break;case"value":u(`/psyche/values?${i.toString()}`);break;case"execution_tension":case"trigger_report":default:u(`/psyche/reports?${i.toString()}`);break}c(!1),b(G)};return e.jsx(ne,{open:t,onOpenChange:c,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:l,onChange:b,draftPersistenceKey:"psyche.reflect.launcher",steps:y,submitLabel:"Open guided reflection",onSubmit:x})}function _({to:t,children:c,className:u}){return e.jsx(k,{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(C,{className:H("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)]",u),children:c})})}function D(t){return`${t.toFixed(t>=10?0:1)}%`}function h(t){return new Intl.NumberFormat().format(Math.round(t))}const M="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)]",ue="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 me({metric:t}){const c=t.history.slice(0,7).reverse(),u=Math.max(1,...c.map(o=>o.rawSwearCount));return e.jsxs(C,{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:[h(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:D(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:"Rage peak"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:h(t.maxCumulativeRage)})]}),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:"Avg thread peak"}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:h(t.averageMaxCumulativeRage)})]})]}),e.jsx("div",{className:"mt-4 flex h-16 items-end gap-1.5",children:c.length>0?c.map(o=>e.jsx("div",{className:"min-w-0 flex-1 rounded-t-[6px] bg-[var(--warning)]/50",style:{height:`${Math.max(8,o.rawSwearCount/u*64)}px`},title:`${o.dateKey}: ${h(o.rawSwearCount)} swears, ${D(o.swearingMessagePercent)} swearing messages, ${h(o.maxCumulativeRage)} max cumulative rage`},o.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:[h(t.conversationsScanned)," conversations"]}),e.jsxs("span",{children:[h(t.messagesScanned)," messages"]}),e.jsxs("span",{children:[h(t.messagesWithSwears)," flagged"]}),e.jsxs("span",{children:[h(t.maxSwearingStreak)," max streak"]})]}),e.jsx(k,{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 Ne(){var R,T;const t=W(),[c,u]=Q(),[o,l]=f.useState(c.get("reflect")==="1"),[b,y]=f.useState(null),x=F({queryKey:["forge-psyche-overview"],queryFn:re}),i=F({queryKey:["forge-psyche-questionnaires-hub"],queryFn:()=>ie()}),a=(R=x.data)==null?void 0:R.overview,s=f.useMemo(()=>a?t.snapshot.goals.slice(0,3).map(r=>{const m=a.values.filter(d=>d.linkedGoalIds.includes(r.id)),S=t.snapshot.dashboard.projects.filter(d=>d.goalId===r.id),A=t.snapshot.habits.filter(d=>d.linkedGoalIds.includes(r.id)||d.linkedValueIds.some(w=>m.some(j=>j.id===w))),B=a.reports.filter(d=>d.linkedGoalIds.includes(r.id)),L=a.behaviors.filter(d=>d.linkedValueIds.some(w=>m.some(j=>j.id===w))),O=a.beliefs.filter(d=>d.linkedValueIds.some(w=>m.some(j=>j.id===w)));return{goal:r,linkedValues:m,linkedProjects:S,linkedHabits:A,linkedReports:B,linkedBehaviors:L,linkedBeliefs:O}}):[],[a,t.snapshot.dashboard.projects,t.snapshot.goals,t.snapshot.habits]),p=f.useMemo(()=>z(s,{compact:!0}),[s]);if(f.useEffect(()=>{y(p.defaultSelectedId)},[p.defaultSelectedId]),x.isLoading)return e.jsx(J,{});if(x.isError||!a)return e.jsx(X,{eyebrow:"Psyche",error:x.error,onRetry:()=>void x.refetch()});const n=p.inspectors[b??p.defaultSelectedId]??p.inspectors[p.defaultSelectedId],g=a.patterns[0]??null,P=a.reports[0]??null,v=[...((T=i.data)==null?void 0:T.instruments)??[]].sort((r,m)=>{const S=r.latestRunAt?new Date(r.latestRunAt).getTime():0;return(m.latestRunAt?new Date(m.latestRunAt).getTime():0)-S})[0]??null,K="Values, patterns, behaviors, beliefs, habits, and reports in one live field.",$=a.devrageMetric.hasData||a.devrageMetric.conversationsScanned>0||a.devrageMetric.history.length>0,E=e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(Z,{metrics:t.snapshot.metrics}),e.jsx(k,{to:"/psyche/goal-map",className:M,children:"Open goal map"})]}),q=[{id:"hero",title:"Psyche",description:"Top route composition",defaultWidth:12,defaultHeight:1,removable:!1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(de,{title:"Psyche",titleText:"Psyche",description:K,actions:E})},{id:"sections",title:"Psyche sections",description:"Section switcher",defaultWidth:12,defaultHeight:1,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(ee,{})},{id:"field",title:"Live field",description:"Graph and inspector stay as movable widgets.",defaultWidth:8,defaultHeight:5,minWidth:6,render:()=>e.jsx(Y,{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:y,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(k,{to:"/psyche/goal-map",className:M,children:"Open goal map"}),e.jsx(te,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>l(!0),children:"Reflect"})]})})},{id:"inspector",title:"Inspector",description:"Selected-node inspector widget.",defaultWidth:4,defaultHeight:5,minWidth:4,render:()=>e.jsxs(C,{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(se,{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(r=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:r},r))}):null,n.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:n.stats.map(r=>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:r},r))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(k,{to:n.href,className:H("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?ae(n.entityKind,!0):ue),children:n.ctaLabel})})]})},...$?[{id:"devrage",title:"Devrage metric",description:"Daily user-message frustration metric.",defaultWidth:4,defaultHeight:3,minWidth:4,render:()=>e.jsx(me,{metric:a.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:(g==null?void 0:g.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:(g==null?void 0:g.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(_,{to:P?`/psyche/reports/${P.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:a.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:a.openNotes})]})]})]})]})},{id:"questionnaires",title:"Questionnaire pulse",description:"Recent questionnaire state.",defaultWidth:12,defaultHeight:2,render:()=>{var r;return e.jsxs(_,{to:v!=null&&v.latestRunId?`/psyche/questionnaire-runs/${v.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:(v==null?void 0:v.title)??"Questionnaire library ready"}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(((r=i.data)==null?void 0:r.instruments)??[]).length," available"]})]})]})}}];return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(U,{surfaceId:"psyche",baseWidgets:q}),e.jsx(ce,{open:o,onOpenChange:r=>{l(r);const m=new URLSearchParams(c);m.delete("reflect"),u(m,{replace:!0})}})]})}export{Ne as PsychePage};
@@ -1,5 +0,0 @@
1
- import{bY as ke,r as y,j as t}from"./vendor-BwL6m4SE.js";import{j as je,i as f,k as Ie}from"./state-Bpe5dF3T.js";import{Q as Ne,F as l}from"./question-flow-dialog-Ded2E85L.js";import{E as Se}from"./entity-note-count-link-Bs1aKYyD.js";import{A as ie}from"./atlas-panel-CO3RYAKn.js";import{E as F}from"./entity-link-multiselect-Dl4rZqdg.js";import{O as Ce}from"./orbit-map-BwK7sDaC.js";import{d as Pe,L as Te,e as Le,B as q,E as ne,bs as Be,b as _,R as Ee,k as Fe,i as qe,bZ as _e,bO as Me,b_ as oe,b2 as Oe,I as Ae,T as w,bP as Qe,bQ as Ke,b$ as $e,b4 as Re,b3 as De,bR as Ue,b7 as Ve,b6 as We,b5 as ze}from"./index-FpGANF9S.js";import{S as A}from"./schema-badge-30B5syHA.js";import{u as Ge,p as He}from"./use-psyche-focus-target-BhNedCZB.js";import{P as Je}from"./page-hero-DvrM83_C.js";import{U as Ye}from"./user-badge-ByhC6bMU.js";import{U as Ze}from"./user-select-field-fx129Uh6.js";import{p as Q}from"./query-cache-IQ8W-LNC.js";import{c as le}from"./psyche-schemas-DDol0j-g.js";import{g as Xe,f as de}from"./schema-visuals-CvC9a3i6.js";import{g as et,b as K,d as $,e as R,a as tt}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const k={title:"",description:"",targetBehavior:"",cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[],userId:null};function at(i){return{title:i.title,description:i.description,targetBehavior:i.targetBehavior,cueContexts:i.cueContexts,shortTermPayoff:i.shortTermPayoff,longTermCost:i.longTermCost,preferredResponse:i.preferredResponse,linkedValueIds:i.linkedValueIds,linkedSchemaLabels:i.linkedSchemaLabels,linkedModeIds:i.linkedModeIds,linkedBeliefIds:i.linkedBeliefIds,userId:i.userId??null}}function st(i){const n=new Set;return i.filter(d=>{const j=`${d.entityType}:${d.entityId}:${d.anchorKey??""}`;return n.has(j)?!1:(n.add(j),!0)})}function rt(i){const n=i.replace(/\s+/g," ").trim();return n.length<=180?n:`${n.slice(0,177).trimEnd()}...`}function Ct(){var Y,Z,X,ee,te,ae;const i=Pe(),n=je(),[d,j]=ke(),[ce,p]=y.useState(!1),[u,v]=y.useState(null),[c,b]=y.useState(null),[I,h]=y.useState(k),[ue,N]=y.useState(null),S=f({queryKey:["forge-psyche-patterns"],queryFn:Re}),C=f({queryKey:["forge-psyche-values"],queryFn:De}),P=f({queryKey:["forge-psyche-schema-catalog"],queryFn:Ue}),T=f({queryKey:["forge-psyche-modes"],queryFn:Ve}),L=f({queryKey:["forge-psyche-beliefs"],queryFn:We}),B=f({queryKey:["forge-psyche-behaviors"],queryFn:ze}),m=((Y=S.data)==null?void 0:Y.patterns)??[],D=((Z=C.data)==null?void 0:Z.values)??[],M=((X=P.data)==null?void 0:X.schemas)??[],U=((ee=T.data)==null?void 0:ee.modes)??[],V=((te=L.data)==null?void 0:te.beliefs)??[],W=((ae=B.data)==null?void 0:ae.behaviors)??[],g=et(i.selectedUserIds),z=d.get("focus"),pe=i.snapshot.dashboard.notesSummaryByEntity,x=f({enabled:c!==null,queryKey:["forge-note",c],queryFn:()=>oe(c)});Ge(z),y.useEffect(()=>{if(d.get("create")==="1"){p(!0),v(null),h({...k,userId:d.get("userId")??g}),b(d.get("sourceObservationNoteId"));const e=new URLSearchParams(d);e.delete("create"),e.delete("sourceObservationNoteId"),e.delete("userId"),j(e,{replace:!0})}},[g,d,j]);const G=Ie({mutationFn:async e=>{var o,E;const a=le.parse(e);if(u)return _e(u.id,a);const s=await Me(a);if(c){const O=((E=(o=x.data)==null?void 0:o.note)==null?void 0:E.id)===c?x.data.note:(await oe(c)).note;await Oe(c,{links:st([...O.links,{entityType:"behavior_pattern",entityId:s.pattern.id,anchorKey:null}])})}return s},onSuccess:async()=>{p(!1),v(null),b(null),h({...k,userId:g}),N(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-patterns"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),qe(n),n.invalidateQueries({queryKey:["notes-index"]})])}}),he=D.map(e=>({value:e.id,label:R(e.title,e.user),description:$(e.valuedDirection,e.user),searchText:K([e.title,e.valuedDirection,e.description],e),kind:"value"})),me=M.map(e=>({value:e.title,label:e.title,description:`${e.description} ${Xe(e.family)}`,searchText:`${e.slug} ${e.family} ${e.schemaType}`,badge:t.jsx(A,{label:e.title,schemaType:e.schemaType,compact:!0}),menuBadge:t.jsx(A,{label:e.title,schemaType:e.schemaType,compact:!0})})),ge=U.map(e=>({value:e.id,label:R(e.title,e.user),description:$(e.archetype||e.family,e.user),searchText:K([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ye=V.map(e=>({value:e.id,label:R(e.statement,e.user),description:$(e.flexibleAlternative||e.originNote,e.user),searchText:K([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),fe=async e=>{const{mode:a}=await Ke({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:I.userId});return Q(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"}},ve=async e=>{const{value:a}=await Qe({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:I.userId});return Q(n,["forge-psyche-values"],"values",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.title,description:a.valuedDirection,kind:"value"}},be=async e=>{const{belief:a}=await $e({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:I.userId});return Q(n,["forge-psyche-beliefs"],"beliefs",a),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:a.id,label:a.statement,description:a.flexibleAlternative||a.originNote,kind:"belief"}},H=y.useMemo(()=>m.filter(e=>!W.some(a=>a.kind==="away"&&a.linkedPatternIds.includes(e.id))),[m,W]),xe=m.slice(0,5).map((e,a)=>({id:e.id,label:`${e.linkedValueIds.length} values`,title:e.title,detail:e.preferredResponse,href:`/psyche/patterns?focus=${e.id}#pattern-lanes`,angle:-92+a*70,radius:150+a%2*14,tone:["rose","sky","violet","mint"][a%4]})),we=[{id:"loop",eyebrow:"Loop",title:"Name the pattern and the behavior it keeps producing",description:"This should feel like a recognizable loop, not a diagnostic label.",render:(e,a)=>{var s;return t.jsxs(t.Fragment,{children:[c?t.jsxs("div",{className:"rounded-[22px] border border-[color-mix(in_srgb,var(--tertiary)_24%,var(--ui-border-subtle)_76%)] bg-[color-mix(in_srgb,var(--tertiary)_10%,var(--ui-surface-1)_90%)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--tertiary)]",children:"Source observation"}),t.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:x.isLoading?"Loading the saved observation note...":(s=x.data)!=null&&s.note?rt(x.data.note.contentPlain||x.data.note.contentMarkdown):"Forge will link this pattern back to the saved observation when you submit it."})]}):null,t.jsx(Ze,{value:e.userId??null,users:i.snapshot.users,onChange:o=>a({userId:o}),defaultLabel:tt(i.snapshot.users.find(o=>o.id===g)??null,"Choose pattern owner"),help:"Patterns can belong to a human or bot user even when linked values, modes, or beliefs cross owners."}),t.jsx(l,{label:"Pattern name",description:"Give the loop a name you will recognize quickly later.",children:t.jsx(Ae,{value:e.title,onChange:o=>a({title:o.target.value}),placeholder:"Anxious reassurance loop"})}),t.jsx(l,{label:"What happens in the loop",description:"Describe the actual sequence of behavior, not the diagnosis.",children:t.jsx(w,{value:e.targetBehavior,onChange:o=>a({targetBehavior:o.target.value}),placeholder:"What do you actually do when the trigger hits?"})}),t.jsx(l,{label:"Description",description:"Write the loop in plain language so it stays usable in the future.",children:t.jsx(w,{value:e.description,onChange:o=>a({description:o.target.value}),placeholder:"Describe the loop in plain human language so it stays recognizable later."})})]})}},{id:"dynamics",eyebrow:"Dynamics",title:"Capture cues, payoff, cost, and the desired response",description:"The goal is to make the action map obvious at a glance.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(l,{label:"Common cues",description:"Add one cue per line so the trigger pattern stays easy to scan.",children:t.jsx(w,{value:e.cueContexts.join(`
2
- `),onChange:s=>a({cueContexts:s.target.value.split(`
3
- `).map(o=>o.trim()).filter(Boolean)}),placeholder:`One line per cue
4
- Silence after vulnerability
5
- Late-night social comparison`})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(l,{label:"Short-term payoff",description:"What relief, certainty, control, or distance do you get right away?",children:t.jsx(w,{value:e.shortTermPayoff,onChange:s=>a({shortTermPayoff:s.target.value}),placeholder:"What relief do you get right away?"})}),t.jsx(l,{label:"Long-term cost",description:"What does the loop cost you later in closeness, energy, values, or progress?",children:t.jsx(w,{value:e.longTermCost,onChange:s=>a({longTermCost:s.target.value}),placeholder:"What does this cost over time?"})})]}),t.jsx(l,{label:"Preferred response",description:"Name the return-path response you want to practice instead.",children:t.jsx(w,{value:e.preferredResponse,onChange:s=>a({preferredResponse:s.target.value}),placeholder:"What do you want to practice instead?"})})]})},{id:"links",eyebrow:"Links",title:"Attach the loop to values, schemas, modes, and beliefs",description:"This is what turns a private note into a navigable graphical system.",render:(e,a)=>t.jsxs(t.Fragment,{children:[t.jsx(l,{label:"Linked values",description:"Choose the values this loop pulls against or tries to protect badly.",children:t.jsx(F,{options:he,selectedValues:e.linkedValueIds,onChange:s=>a({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:ve})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(l,{label:"Schema labels",description:"Attach the schema themes that define the pressure in this loop.",children:t.jsx(F,{options:me,selectedValues:e.linkedSchemaLabels,onChange:s=>a({linkedSchemaLabels:s}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),t.jsx(l,{label:"Linked modes",description:"Search for an existing mode or press Enter to create and link one immediately.",children:t.jsx(F,{options:ge,selectedValues:e.linkedModeIds,onChange:s=>a({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:fe})})]}),t.jsx(l,{label:"Linked beliefs",description:"Search for a belief, or type a new one and press Enter to create it inline.",children:t.jsx(F,{options:ye,selectedValues:e.linkedBeliefIds,onChange:s=>a({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:be})})]})}];if(S.isLoading||C.isLoading||P.isLoading||T.isLoading||L.isLoading||B.isLoading)return t.jsx(Te,{eyebrow:"Patterns",title:"Loading patterns",description:"Getting patterns, values, schemas, beliefs, modes, and linked behaviors ready."});const J=S.error??C.error??P.error??T.error??L.error??B.error;return J?t.jsx(Le,{eyebrow:"Psyche patterns",error:J,onRetry:()=>void Promise.all([S.refetch(),C.refetch(),P.refetch(),T.refetch(),L.refetch(),B.refetch()])}):t.jsxs("div",{className:"grid min-w-0 gap-5",children:[t.jsx(Je,{entityKind:"pattern",title:t.jsx(ne,{kind:"pattern",label:"Patterns",variant:"heading",size:"lg"}),description:"See each pattern as a loop: what starts it, what payoff it gives, what it costs, and what you want to do instead.",badge:`${m.length} patterns`,actions:t.jsx(q,{onClick:()=>{v(null),b(null),h({...k,userId:g}),p(!0)},children:"Add pattern"})}),t.jsx(Be,{}),t.jsx(Ce,{title:"See the loops that keep pulling against your values",description:"This map shows which patterns are hot, what they are connected to, and which response wants to replace them.",centerLabel:"Pattern field",centerValue:`${m.length} tracked`,nodes:xe,action:t.jsx(q,{onClick:()=>{v(null),b(null),h({...k,userId:g}),p(!0)},children:"Add pattern"})}),H.length>0?t.jsx(ie,{eyebrow:"Seed behavior drafts",title:"Some patterns still do not have an explicit away-move draft",description:"These are the best candidates to push into the Behaviors page next.",tone:"rose",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:H.slice(0,8).map(e=>t.jsx(_,{kind:"pattern",label:e.title,compact:!0},e.id))})}):null,t.jsx(ie,{eyebrow:"Pattern action map",title:"Read each loop from cue to return path",description:"Each lane turns a raw pattern into a visible behavior map: cues, short-term relief, long-term cost, and the move you actually want.",tone:"sky",className:"scroll-mt-24",children:t.jsx("div",{id:"pattern-lanes",className:"grid min-w-0 gap-4",children:m.length===0?t.jsx("div",{className:"flex justify-start",children:t.jsx(q,{onClick:()=>{v(null),h({...k,userId:g}),p(!0)},children:"Add pattern"})}):m.map(e=>{const a=D.filter(r=>e.linkedValueIds.includes(r.id)),s=U.filter(r=>e.linkedModeIds.includes(r.id)),o=V.filter(r=>e.linkedBeliefIds.includes(r.id)),E=z===e.id,O=Ee(pe,"behavior_pattern",e.id).count;return t.jsxs("div",{"data-psyche-focus-id":e.id,className:`min-w-0 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition ${He(E)}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(ne,{kind:"pattern",label:e.title,variant:"heading",size:"xl",lines:2,labelClassName:"[overflow-wrap:anywhere]"}),t.jsx("div",{className:"mt-2 max-w-3xl break-words text-sm leading-7 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.description})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.user?t.jsx(Ye,{user:e.user,compact:!0}):null,t.jsx(Se,{entityType:"behavior_pattern",entityId:e.id,count:O}),t.jsx(q,{variant:"secondary",onClick:()=>{v(e),b(null),h(at(e)),p(!0)},children:"Edit"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[var(--ui-surface-2)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Cue"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.cueContexts[0]??"No cue captured yet."})]}),t.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[color-mix(in_srgb,var(--danger)_10%,var(--ui-surface-1)_90%)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Loop"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.targetBehavior})]}),t.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[color-mix(in_srgb,var(--warning)_10%,var(--ui-surface-1)_90%)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Short-term relief / long-term cost"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.shortTermPayoff||"No payoff note yet."}),t.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.longTermCost||"No long-term cost note yet."})]}),t.jsxs("div",{className:"min-w-0 rounded-[22px] bg-[color-mix(in_srgb,var(--success)_10%,var(--ui-surface-1)_90%)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Return path"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.preferredResponse})]})]}),t.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap gap-2",children:[a.map(r=>t.jsx(_,{kind:"value",label:r.title,compact:!0,wrap:!0},r.id)),s.map(r=>t.jsx(_,{kind:"mode",label:r.title,compact:!0,wrap:!0},r.id)),e.linkedModeLabels.map(r=>t.jsx(Fe,{className:"whitespace-normal break-words text-[color-mix(in_srgb,var(--primary)_66%,var(--ui-ink-strong)_34%)] [overflow-wrap:anywhere]",children:r},`legacy-${r}`)),e.linkedSchemaLabels.map(r=>{var se,re;return t.jsx(A,{label:((se=de(r,M))==null?void 0:se.title)??r,schemaType:((re=de(r,M))==null?void 0:re.schemaType)??"maladaptive",compact:!0},r)}),o.map(r=>t.jsx(_,{kind:"belief",label:r.statement,compact:!0,wrap:!0},r.id))]})]},e.id)})})}),t.jsx(Ne,{open:ce,onOpenChange:e=>{p(e),!e&&!u&&b(null)},eyebrow:"Behavior pattern",title:u?"Refine pattern lane":"Create pattern",description:c&&!u?"This pattern is being created from a saved observation. Submitting the dialog will link the new pattern back to that observation note.":"Pattern capture should feel like mapping a loop, not filling an admin form.",value:I,onChange:h,draftPersistenceKey:u?`psyche.pattern.${u.id}`:`psyche.pattern.new.${c??"blank"}`,steps:we,submitLabel:u?"Save pattern":"Create pattern",pending:G.isPending,error:ue,onSubmit:async()=>{N(null);const e=le.safeParse(I);if(!e.success){N("This pattern still needs a title, a loop description, and a preferred response.");return}try{await G.mutateAsync(e.data)}catch(a){N(a instanceof Error?a.message:"Unable to save this pattern right now.")}}})]})}export{Ct as PsychePatternsPage};
@@ -1 +0,0 @@
1
- import{c6 as g,j as e,aC as o}from"./vendor-BwL6m4SE.js";import{i as h}from"./state-Bpe5dF3T.js";import{P as v}from"./page-hero-DvrM83_C.js";import{L as b,e as w,B as d,C as l,h as f,k as y,c as j,cn as k}from"./index-FpGANF9S.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const c="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",u="min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",m="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",N="border border-[color-mix(in_srgb,var(--success)_36%,var(--ui-border-subtle)_64%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_70%,var(--ui-ink-strong)_30%)]",C="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]";function R(){const{runId:t=""}=g(),a=h({queryKey:["forge-psyche-questionnaire-run",t],queryFn:()=>k(t),enabled:t.length>0});if(a.isLoading)return e.jsx(b,{eyebrow:"Questionnaire result",title:"Loading scored run",description:"Hydrating the recorded answers, stored scores, and longitudinal context."});if(a.isError||!a.data)return e.jsx(w,{eyebrow:"Questionnaire result",error:a.error,onRetry:()=>void a.refetch()});const s=a.data,x=new Map(s.answers.map(r=>[r.itemId,r]));return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(v,{eyebrow:"Questionnaire result",title:s.instrument.title,description:"Stored raw answers, computed scores, and score history all remain attached to the exact version used for this run.",badge:s.run.completedAt?"Completed":"Draft",actions:e.jsxs(e.Fragment,{children:[e.jsx(o,{to:`/psyche/questionnaires/${s.instrument.id}`,children:e.jsx(d,{variant:"secondary",children:"Back to questionnaire"})}),e.jsx(o,{to:`/psyche/questionnaires/${s.instrument.id}/take`,children:e.jsx(d,{children:"Take again"})})]})}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.9fr)_minmax(18rem,1.1fr)]",children:[e.jsxs(l,{className:u,children:[e.jsx("div",{className:c,children:"Stored scores"}),s.scores.length===0?e.jsx("div",{className:"mt-4",children:e.jsx(f,{eyebrow:"Scores",title:"No scores stored yet",description:"This run has not been completed, so there are no persisted score rows yet."})}):e.jsx("div",{className:"mt-4 grid gap-3",children:s.scores.map(r=>e.jsx("div",{className:m,children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.label}),r.bandLabel?e.jsx("div",{className:"mt-2 break-words text-xs uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)] [overflow-wrap:anywhere]",children:r.bandLabel}):null]}),e.jsx("div",{className:"min-w-0 break-words text-right text-lg font-semibold text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.valueText??r.valueNumeric??"—"})]})},r.scoreKey))})]}),e.jsxs(l,{className:u,children:[e.jsx("div",{className:c,children:"Answer ledger"}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.version.definition.items.map(r=>{const i=x.get(r.id);return e.jsxs("div",{className:m,children:[e.jsx("div",{className:"break-words text-sm font-medium leading-6 text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:r.prompt}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:r.options.map(n=>{const p=(i==null?void 0:i.optionKey)===n.key;return e.jsx(y,{className:j("max-w-full break-words [overflow-wrap:anywhere]",p?N:C),children:n.label},`${r.id}-${n.key}`)})})]},r.id)})})]})]})]})}export{R as PsycheQuestionnaireRunDetailPage};
@@ -1 +0,0 @@
1
- import{bY as ve,r as S,j as t,aC as fe}from"./vendor-BwL6m4SE.js";import{j as ye,i as d,k as xe}from"./state-Bpe5dF3T.js";import{Q as ke,F as o}from"./question-flow-dialog-Ded2E85L.js";import{E as be}from"./entity-note-count-link-Bs1aKYyD.js";import{A as we}from"./atlas-panel-CO3RYAKn.js";import{E as L}from"./entity-link-multiselect-Dl4rZqdg.js";import{S as Ie}from"./schema-badge-30B5syHA.js";import{E as Te,T as je,B as Se,S as m,M as Le}from"./report-chain-fields-DY640iqL.js";import{d as Ne,L as Ce,e as Ee,B as Be,E as J,bs as Pe,h as Me,R as Ae,k as Fe,cv as qe,I as q,T as Re,a4 as Oe,a3 as Qe,bP as De,bN as Ke,b$ as Ue,bQ as $e,b9 as Ge,b3 as He,b5 as _e,b6 as ze,b7 as We,bR as Ve,ct as Ye,cu as Je}from"./index-FpGANF9S.js";import{P as Xe}from"./page-hero-DvrM83_C.js";import{U as Ze}from"./user-badge-ByhC6bMU.js";import{U as et}from"./user-select-field-fx129Uh6.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{t as X}from"./psyche-schemas-DDol0j-g.js";import{f as Z,b as tt,a as st,c as rt,t as it}from"./schema-visuals-CvC9a3i6.js";import{g as at,b as C,d as E,e as B,a as nt}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const P={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:null};function ot(l){const n=new Date(l);if(Number.isNaN(n.getTime()))return"";const a=n.getFullYear(),p=String(n.getMonth()+1).padStart(2,"0"),M=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${a}-${p}-${M}T${c}:${i}`}function Ct(){var K,U,$,G,H,_,z,W;const l=Ne(),n=ye(),[a,p]=ve(),[M,c]=S.useState(!1),[i,u]=S.useState(P),[ee,g]=S.useState(null),v=d({queryKey:["forge-psyche-reports"],queryFn:Ge}),f=d({queryKey:["forge-psyche-values"],queryFn:He}),y=d({queryKey:["forge-psyche-behaviors"],queryFn:_e}),x=d({queryKey:["forge-psyche-beliefs"],queryFn:ze}),k=d({queryKey:["forge-psyche-modes"],queryFn:We}),b=d({queryKey:["forge-psyche-schema-catalog"],queryFn:Ve}),w=d({queryKey:["forge-psyche-event-types"],queryFn:Ye}),I=d({queryKey:["forge-psyche-emotions"],queryFn:Je}),A=((K=v.data)==null?void 0:K.reports)??[],te=((U=f.data)==null?void 0:U.values)??[],R=(($=y.data)==null?void 0:$.behaviors)??[],O=((G=x.data)==null?void 0:G.beliefs)??[],T=((H=k.data)==null?void 0:H.modes)??[],F=((_=b.data)==null?void 0:_.schemas)??[],se=((z=w.data)==null?void 0:z.eventTypes)??[],re=((W=I.data)==null?void 0:W.emotions)??[],j=at(l.selectedUserIds),ie=l.snapshot.dashboard.notesSummaryByEntity;S.useEffect(()=>{if(a.get("create")==="1"){c(!0),u({...P,userId:a.get("userId")??j,occurredAt:a.get("occurredAt")?ot(a.get("occurredAt")):"",customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const e=new URLSearchParams(a);e.delete("create"),e.delete("intent"),e.delete("occurredAt"),e.delete("userId"),e.delete("valueId"),e.delete("behaviorId"),e.delete("beliefId"),e.delete("goalId"),e.delete("projectId"),e.delete("taskId"),p(e,{replace:!0})}},[a,p]);const Q=xe({mutationFn:async e=>{const r=X.parse({title:e.title,status:e.status,eventTypeId:e.eventTypeId||null,customEventType:e.customEventType,eventSituation:e.eventSituation,occurredAt:e.occurredAt?new Date(e.occurredAt).toISOString():null,emotions:e.emotions.filter(s=>s.label.trim().length>0),thoughts:e.thoughts.filter(s=>s.text.trim().length>0),behaviors:e.behaviors.filter(s=>s.text.trim().length>0),consequences:{selfShortTerm:e.selfShortTerm,selfLongTerm:e.selfLongTerm,othersShortTerm:e.othersShortTerm,othersLongTerm:e.othersLongTerm},linkedPatternIds:[],linkedValueIds:e.linkedValueIds,linkedGoalIds:e.linkedGoalIds,linkedProjectIds:e.linkedProjectIds,linkedTaskIds:e.linkedTaskIds,linkedBehaviorIds:e.linkedBehaviorIds,linkedBeliefIds:e.linkedBeliefIds,linkedModeIds:e.linkedModeIds,modeOverlays:[],schemaLinks:e.schemaLinks.filter(Boolean),modeTimeline:e.modeTimeline.filter(s=>s.stage.trim().length>0&&s.label.trim().length>0),nextMoves:e.nextMoves.filter(Boolean),userId:e.userId});return qe(r)},onSuccess:async()=>{c(!1),u({...P,userId:j}),g(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-reports"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),ae=te.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.valuedDirection,e.user),searchText:C([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=R.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.kind,e.user),searchText:C([e.title,e.kind,e.description],e),kind:"behavior"})),oe=O.map(e=>({value:e.id,label:B(e.statement,e.user),description:E(e.flexibleAlternative||e.originNote,e.user),searchText:C([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),de=T.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.archetype||e.family,e.user),searchText:C([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{value:r}=await De({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:i.userId});return N(n,["forge-psyche-values"],"values",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.valuedDirection,kind:"value"}},ce=async e=>{const{behavior:r}=await Ke({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:i.userId});return N(n,["forge-psyche-behaviors"],"behaviors",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},he=async e=>{const{belief:r}=await Ue({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:i.userId});return N(n,["forge-psyche-beliefs"],"beliefs",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.statement,description:r.flexibleAlternative||r.originNote,kind:"belief"}},me=async e=>{const{mode:r}=await $e({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:i.userId});return N(n,["forge-psyche-modes"],"modes",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.archetype||r.family,kind:"mode"}},pe=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(et,{value:e.userId,users:l.snapshot.users,onChange:s=>r({userId:s}),defaultLabel:nt(l.snapshot.users.find(s=>s.id===j)??null,"Choose report owner"),help:"Trigger reports can belong to a human or bot user while still linking to shared values, behaviors, beliefs, and modes."}),t.jsx(o,{label:"Report title",children:t.jsx(q,{value:e.title,onChange:s=>r({title:s.target.value}),placeholder:"Friday silence spiral"})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Event type",children:t.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:e.eventTypeId,onChange:s=>r({eventTypeId:s.target.value}),children:[t.jsx("option",{value:"",children:"Custom or uncategorized"}),se.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))]})}),t.jsx(o,{label:"Occurred at",children:t.jsx(q,{type:"datetime-local",value:e.occurredAt,onChange:s=>r({occurredAt:s.target.value})})})]}),t.jsx(o,{label:"Custom event label",children:t.jsx(q,{value:e.customEventType,onChange:s=>r({customEventType:s.target.value}),placeholder:"Unexpected distance after vulnerability"})}),t.jsx(o,{label:"Situation",children:t.jsx(Re,{value:e.eventSituation,onChange:s=>r({eventSituation:s.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Te,{items:e.emotions,onChange:s=>r({emotions:s}),definitions:re}),t.jsx(je,{items:e.thoughts,onChange:s=>r({thoughts:s}),beliefs:O,modes:T}),t.jsx(Se,{items:e.behaviors,onChange:s=>r({behaviors:s}),behaviors:R,modes:T})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(o,{label:"Linked values",children:t.jsx(L,{options:ae,selectedValues:e.linkedValueIds,onChange:s=>r({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:le})}),t.jsx(o,{label:"Linked behaviors",children:t.jsx(L,{options:ne,selectedValues:e.linkedBehaviorIds,onChange:s=>r({linkedBehaviorIds:s}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Linked beliefs",children:t.jsx(L,{options:oe,selectedValues:e.linkedBeliefIds,onChange:s=>r({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:he})}),t.jsx(o,{label:"Linked modes",children:t.jsx(L,{options:de,selectedValues:e.linkedModeIds,onChange:s=>r({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.linkedGoalIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedGoalIds.length," goal tension"]}):null,e.linkedProjectIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedProjectIds.length," project tension"]}):null,e.linkedTaskIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(m,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:e.selfShortTerm,onChange:s=>r({selfShortTerm:s}),placeholder:"I shut down and lost the rest of the evening."}),t.jsx(m,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:e.selfLongTerm,onChange:s=>r({selfLongTerm:s}),placeholder:"It keeps reinforcing the same abandonment story."}),t.jsx(m,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:e.othersShortTerm,onChange:s=>r({othersShortTerm:s}),placeholder:"They felt pushed away and confused."}),t.jsx(m,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:e.othersLongTerm,onChange:s=>r({othersLongTerm:s}),placeholder:"Trust gets thinner every time this loop takes over."})]}),t.jsxs("div",{className:"grid gap-4",children:[t.jsx(o,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:F.filter(s=>s.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:F.filter(s=>s.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(s=>{const V=tt(s.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${V.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:s.title}),t.jsx(Oe,{content:rt(s.schemaType),label:`Explain ${st(s.schemaType)}`})]}),t.jsx(Qe,{className:"mt-2",children:s.description}),t.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.schemas.map(h=>{const ue=e.schemaLinks.some(ge=>{var Y;return((Y=Z(ge,[h]))==null?void 0:Y.id)===h.id});return t.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${ue?`${V.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>r({schemaLinks:it(e.schemaLinks,h)}),children:h.title},h.id)})})]},s.schemaType)})})}),t.jsx(Le,{items:e.modeTimeline,onChange:s=>r({modeTimeline:s}),modes:T,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),t.jsx(m,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:e.nextMoves,onChange:s=>r({nextMoves:s}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(v.isLoading||f.isLoading||y.isLoading||x.isLoading||k.isLoading||b.isLoading||w.isLoading||I.isLoading)return t.jsx(Ce,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const D=v.error??f.error??y.error??x.error??k.error??b.error??w.error??I.error;return D?t.jsx(Ee,{eyebrow:"Trigger reports",error:D,onRetry:()=>void Promise.all([v.refetch(),f.refetch(),y.refetch(),x.refetch(),k.refetch(),b.refetch(),w.refetch(),I.refetch()])}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Xe,{entityKind:"report",title:t.jsx(J,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${A.length} reports`,actions:t.jsx(Be,{onClick:()=>{u({...P,userId:j}),c(!0)},children:"Reflect"})}),t.jsx(Pe,{}),t.jsx(we,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:t.jsx("div",{className:"grid gap-4",children:A.length===0?t.jsx(Me,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):A.map(e=>{var r;return t.jsxs("div",{className:"min-w-0 max-w-full rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-start",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(J,{kind:"report",label:e.title,variant:"heading",size:"xl",lines:2,className:"w-full"}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.customEventType||e.eventSituation})]}),t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2 md:justify-end",children:[e.user?t.jsx(Ze,{user:e.user,compact:!0}):null,t.jsx(be,{entityType:"trigger_report",entityId:e.id,count:Ae(ie,"trigger_report",e.id).count}),t.jsx(Fe,{children:e.status}),t.jsx(fe,{to:`/psyche/reports/${e.id}`,className:"inline-flex min-h-10 max-w-full items-center rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open report"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spark"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.eventSituation})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-success-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Wave"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:((r=e.emotions[0])==null?void 0:r.label)??"No emotion captured yet"})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-info-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Lens"}),t.jsx("div",{className:"mt-3 min-w-0",children:e.schemaLinks[0]?(()=>{const s=Z(e.schemaLinks[0],F);return s?t.jsx(Ie,{label:s.title,schemaType:s.schemaType,compact:!0}):t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.schemaLinks[0]})})():t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"No schema link yet"})})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-warning-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Pivot"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.nextMoves[0]??"No next move yet"})]})]})]},e.id)})})}),t.jsx(ke,{open:M,onOpenChange:c,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:i,onChange:u,draftPersistenceKey:"psyche.report.new",steps:pe,submitLabel:"Create report",pending:Q.isPending,error:ee,onSubmit:async()=>{if(g(null),!X.safeParse({title:i.title,status:i.status,eventTypeId:i.eventTypeId||null,customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?new Date(i.occurredAt).toISOString():null,emotions:i.emotions.filter(r=>r.label.trim().length>0),thoughts:i.thoughts.filter(r=>r.text.trim().length>0),behaviors:i.behaviors.filter(r=>r.text.trim().length>0),consequences:{selfShortTerm:i.selfShortTerm,selfLongTerm:i.selfLongTerm,othersShortTerm:i.othersShortTerm,othersLongTerm:i.othersLongTerm},linkedPatternIds:[],linkedValueIds:i.linkedValueIds,linkedGoalIds:i.linkedGoalIds,linkedProjectIds:i.linkedProjectIds,linkedTaskIds:i.linkedTaskIds,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds,modeOverlays:[],schemaLinks:i.schemaLinks.filter(Boolean),modeTimeline:i.modeTimeline.filter(r=>r.stage.trim().length>0&&r.label.trim().length>0),nextMoves:i.nextMoves.filter(Boolean)}).success){g("This report still needs a title and concrete triggering situation.");return}try{await Q.mutateAsync(i)}catch(r){g(r instanceof Error?r.message:"Unable to create this report right now.")}}})]})}export{Ct as PsycheReportsPage};
@@ -1,9 +0,0 @@
1
- import{bY as be,r as x,j as t}from"./vendor-BwL6m4SE.js";import{j as je,i as w,k as ke}from"./state-Bpe5dF3T.js";import{S as re}from"./schema-badge-30B5syHA.js";import{Q as we,F as d}from"./question-flow-dialog-Ded2E85L.js";import{E as Ie}from"./entity-note-count-link-Bs1aKYyD.js";import{A as se}from"./atlas-panel-CO3RYAKn.js";import{E as F}from"./entity-link-multiselect-Dl4rZqdg.js";import{d as Te,L as Se,e as Ne,B as $,bs as Ce,R as Le,k as I,b as Be,a4 as ne,cC as Ee,b$ as Fe,a3 as Ae,I as Pe,T as A,bP as Me,bN as qe,bQ as Oe,cv as Qe,bR as Re,b6 as $e,b5 as Ue,b7 as He,b3 as Ke,b9 as De}from"./index-FpGANF9S.js";import{u as Ve,p as Ge}from"./use-psyche-focus-target-BhNedCZB.js";import{P as _e}from"./page-hero-DvrM83_C.js";import{U as ze}from"./user-badge-ByhC6bMU.js";import{U as We}from"./user-select-field-fx129Uh6.js";import{p as P}from"./query-cache-IQ8W-LNC.js";import{d as ie}from"./psyche-schemas-DDol0j-g.js";import{c as U,b as K,g as Ye,a as Je,f as Xe}from"./schema-visuals-CvC9a3i6.js";import{g as Ze,b as M,d as q,e as O,a as et}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const S={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:null};function H(a){return{schemaId:a.schemaId,statement:a.statement,beliefType:a.beliefType,originNote:a.originNote,confidence:a.confidence,evidenceFor:a.evidenceFor,evidenceAgainst:a.evidenceAgainst,flexibleAlternative:a.flexibleAlternative,linkedValueIds:a.linkedValueIds,linkedBehaviorIds:a.linkedBehaviorIds,linkedModeIds:a.linkedModeIds,linkedReportIds:a.linkedReportIds,userId:a.userId??null}}function tt({schema:a,beliefs:o,behaviors:f,reports:v}){const g=o.filter(n=>n.schemaId===a.id).length,l=f.filter(n=>n.linkedSchemaIds.includes(a.id)).length,c=v.filter(n=>n.schemaLinks.some(h=>{const r=Xe(h,[a]);return(r==null?void 0:r.id)===a.id})).length;return{beliefCount:g,behaviorCount:l,reportCount:c,total:g+l+c}}function ae({title:a,description:o,titleHelp:f,schemas:v,beliefs:g,behaviors:l,reports:c,onOpenBelief:n}){if(v.length===0)return null;const h=K(v[0].schemaType);return t.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${h.sectionTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"grid min-w-0 gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${h.sectionEyebrow}`,children:[t.jsx("span",{children:a}),f?t.jsx(ne,{content:f,label:`Explain ${a.toLowerCase()}`}):null]}),t.jsx("div",{className:"max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:o})]}),t.jsxs(I,{children:[v.length," schemas"]})]}),t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:v.map(r=>{const j=tt({schema:r,beliefs:g,behaviors:l,reports:c}),p=g.filter(u=>u.schemaId===r.id),y=K(r.schemaType);return t.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${y.cardTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{label:r.title,schemaType:r.schemaType}),t.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:Ye(r.family)}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.description})]}),t.jsxs(I,{children:[j.total," ",y.countLabel]})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.beliefCount," beliefs"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.behaviorCount," behaviors"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.reportCount," reports"]})]}),t.jsxs("div",{className:"mt-4 grid gap-3",children:[p.length>0?t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:`${p.length} ${y.linkSummary}${p.length===1?"":"s"} live here.`}):t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-faint)]",children:y.emptyCopy}),p.slice(0,2).map(u=>t.jsxs("button",{type:"button",className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>n(u),children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.statement}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},r.id)})})]})}function wt(){var Y,J,X,Z,ee,te;const a=Te(),o=je(),[f,v]=be(),[g,l]=x.useState(!1),[c,n]=x.useState(null),[h,r]=x.useState(S),[j,p]=x.useState(null),y=w({queryKey:["forge-psyche-schema-catalog"],queryFn:Re}),u=w({queryKey:["forge-psyche-beliefs"],queryFn:$e}),N=w({queryKey:["forge-psyche-behaviors"],queryFn:Ue}),C=w({queryKey:["forge-psyche-modes"],queryFn:He}),L=w({queryKey:["forge-psyche-values"],queryFn:Ke}),B=w({queryKey:["forge-psyche-reports"],queryFn:De}),b=((Y=y.data)==null?void 0:Y.schemas)??[],T=((J=u.data)==null?void 0:J.beliefs)??[],Q=((X=N.data)==null?void 0:X.behaviors)??[],D=((Z=C.data)==null?void 0:Z.modes)??[],oe=((ee=L.data)==null?void 0:ee.values)??[],R=((te=B.data)==null?void 0:te.reports)??[],k=Ze(a.selectedUserIds),V=f.get("focus"),le=a.snapshot.dashboard.notesSummaryByEntity;Ve(V),x.useEffect(()=>{if(f.get("create")==="1"){l(!0),n(null),r({...S,userId:k});const e=new URLSearchParams(f);e.delete("create"),v(e,{replace:!0})}},[k,f,v]);const G=ke({mutationFn:async e=>{const s=ie.parse(e);return c?Ee(c.id,s):Fe(s)},onSuccess:async()=>{l(!1),n(null),r({...S,userId:k}),p(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),de=oe.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.valuedDirection,e.user),searchText:M([e.title,e.valuedDirection,e.description],e),kind:"value"})),ce=Q.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.kind,e.user),searchText:M([e.title,e.kind,e.description],e),kind:"behavior"})),he=D.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.archetype||e.family,e.user),searchText:M([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ue=R.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.customEventType||e.eventSituation,e.user),searchText:M([e.title,e.customEventType,e.eventSituation],e),kind:"report"})),me=x.useMemo(()=>new Map(b.map(e=>[e.id,e])),[b]),_=x.useMemo(()=>b.filter(e=>e.schemaType==="maladaptive"),[b]),z=x.useMemo(()=>b.filter(e=>e.schemaType==="adaptive"),[b]),pe=async e=>{const{value:s}=await Me({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:h.userId});return P(o,["forge-psyche-values"],"values",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.valuedDirection,kind:"value"}},fe=async e=>{const{behavior:s}=await qe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:h.userId});return P(o,["forge-psyche-behaviors"],"behaviors",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.kind,kind:"behavior"}},ve=async e=>{const{mode:s}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:h.userId});return P(o,["forge-psyche-modes"],"modes",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.archetype||s.family,kind:"mode"}},ge=async e=>{const{report:s}=await Qe({title:e,status:"draft",eventTypeId:null,customEventType:"",eventSituation:e,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:h.userId});return P(o,["forge-psyche-reports"],"reports",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.customEventType||s.eventSituation,kind:"report"}};x.useEffect(()=>{g&&p(null)},[g]);const ye=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(We,{value:e.userId??null,users:a.snapshot.users,onChange:i=>s({userId:i}),defaultLabel:et(a.snapshot.users.find(i=>i.id===k)??null,"Choose belief owner"),help:"Beliefs can belong to a human or bot user even when they connect to shared behaviors, modes, and reports."}),t.jsx(d,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:_,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:z,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(i=>{const m=K(i.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${m.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.title}),t.jsx(ne,{content:U(i.schemaType),label:`Explain ${Je(i.schemaType)}`})]}),t.jsx(Ae,{className:"mt-2",children:i.description}),t.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:i.schemas.map(E=>{const xe=e.schemaId===E.id;return t.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${xe?`${m.badgeTone} ring-1 ring-[var(--ui-ring)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({schemaId:E.id}),children:E.title},E.id)})})]},i.schemaType)})})}),t.jsx(d,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:t.jsx(Pe,{value:e.statement,onChange:i=>s({statement:i.target.value}),placeholder:"If they go quiet, I am already being left."})}),t.jsx(d,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(i=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.beliefType===i?"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:()=>s({beliefType:i}),children:i==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},i))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:t.jsx(A,{value:e.originNote,onChange:i=>s({originNote:i.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),t.jsxs(d,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[t.jsx("input",{type:"range",min:0,max:100,value:e.confidence,onChange:i=>s({confidence:Number(i.target.value)})}),t.jsxs("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:[e.confidence,"% grip"]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(d,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:t.jsx(A,{value:e.evidenceFor.join(`
2
- `),onChange:i=>s({evidenceFor:i.target.value.split(`
3
- `).map(m=>m.trim()).filter(Boolean)}),placeholder:`One line per sign
4
- They stopped replying for days
5
- I was ignored when I asked directly`})}),t.jsx(d,{label:"Evidence against",description:"Add one counterexample, nuance, or disconfirming sign per line.",children:t.jsx(A,{value:e.evidenceAgainst.join(`
6
- `),onChange:i=>s({evidenceAgainst:i.target.value.split(`
7
- `).map(m=>m.trim()).filter(Boolean)}),placeholder:`One line per counterpoint
8
- They later explained they were overwhelmed
9
- Other people stay close without constant contact`})})]})]})},{id:"repair",eyebrow:"Repair",title:"Define the flexible alternative and attach the wider system",description:"The flexible alternative is the repair move; the links keep it attached to behaviors, values, modes, and reports.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Flexible alternative",description:"Write the steadier line you want available when the old script activates.",labelHelp:"A flexible alternative is not fake positivity. It is a truer, more workable belief that leaves room for uncertainty.",children:t.jsx(A,{value:e.flexibleAlternative,onChange:i=>s({flexibleAlternative:i.target.value}),placeholder:"Silence can mean many things. I can check the facts before deciding I am being left."})}),t.jsx(d,{label:"Linked values",description:"Choose the valued directions this belief interferes with most.",children:t.jsx(F,{options:de,selectedValues:e.linkedValueIds,onChange:i=>s({linkedValueIds:i}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:pe})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[t.jsx(d,{label:"Linked behaviors",description:"Choose the moves this belief tends to trigger or justify.",children:t.jsx(F,{options:ce,selectedValues:e.linkedBehaviorIds,onChange:i=>s({linkedBehaviorIds:i}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:fe})}),t.jsx(d,{label:"Linked modes",description:"Choose the inner states that most often carry this script.",children:t.jsx(F,{options:he,selectedValues:e.linkedModeIds,onChange:i=>s({linkedModeIds:i}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:ve})}),t.jsx(d,{label:"Linked reports",description:"Choose the reflective chains where this script has already shown up.",children:t.jsx(F,{options:ue,selectedValues:e.linkedReportIds,onChange:i=>s({linkedReportIds:i}),placeholder:"Search or create a report…",emptyMessage:"No reports match yet.",createLabel:"Create report",onCreate:ge})})]})]})}];if(y.isLoading||u.isLoading||N.isLoading||C.isLoading||L.isLoading||B.isLoading)return t.jsx(Se,{eyebrow:"Schemas & beliefs",title:"Loading schemas and beliefs",description:"Getting schemas, beliefs, behaviors, modes, values, and linked reports ready."});const W=y.error??u.error??N.error??C.error??L.error??B.error;return W?t.jsx(Ne,{eyebrow:"Schemas & beliefs",error:W,onRetry:()=>void Promise.all([y.refetch(),u.refetch(),N.refetch(),C.refetch(),L.refetch(),B.refetch()])}):t.jsxs("div",{className:"grid min-w-0 gap-5",children:[t.jsx(_e,{title:"Schemas & Beliefs",description:"Review your schemas and beliefs together. See which beliefs are tied to each schema, then open any belief to edit it in context.",badge:`${T.length} beliefs`,actions:t.jsx($,{onClick:()=>{n(null),r({...S,userId:k}),l(!0)},children:"Add belief"})}),t.jsx(Ce,{}),t.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[t.jsx(se,{eyebrow:"Schemas",title:"Schemas",description:"Use these groups to notice recurring old patterns and to reinforce healthier patterns you want to rely on more often.",titleHelp:"Schemas are broad recurring patterns that shape how situations feel and how you respond. Use them to organize beliefs, behaviors, and reports around patterns that repeat.",tone:"violet",children:b.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Schema data is unavailable right now."}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(ae,{title:"Maladaptive schemas",titleHelp:U("maladaptive"),description:"These schemas describe recurring old patterns that can change how you read situations and react.",schemas:_,beliefs:T,behaviors:Q,reports:R,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}}),t.jsx(ae,{title:"Adaptive schemas",titleHelp:U("adaptive"),description:"These schemas describe healthier patterns you want to trust, practice, and strengthen over time.",schemas:z,beliefs:T,behaviors:Q,reports:R,onOpenBelief:e=>{n(e),r(H(e)),l(!0)}})]})}),t.jsx(se,{eyebrow:"Beliefs",title:"Beliefs",description:"Use this list to review and edit the stories you tell yourself. Open any belief to update the wording, evidence, or a more flexible alternative.",titleHelp:"Beliefs are the specific scripts or rules that show up in your mind, such as what you expect from yourself, from other people, or from a situation.",tone:"sky",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx($,{onClick:()=>{n(null),r({...S,userId:k}),l(!0)},children:"Add belief"}),T.length===0?t.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Your beliefs will appear here after you add the first one."}):T.map(e=>{const s=e.schemaId?me.get(e.schemaId)??null:null,i=V===e.id;return t.jsxs("div",{"data-psyche-focus-id":e.id,className:`rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)] ${Ge(i)}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:e.statement}),t.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.user?t.jsx(ze,{user:e.user,compact:!0}):null,t.jsx(Ie,{entityType:"belief_entry",entityId:e.id,count:Le(le,"belief_entry",e.id).count}),t.jsxs(I,{children:[e.confidence,"% grip"]}),t.jsx($,{variant:"secondary",size:"sm",onClick:()=>{n(e),r(H(e)),l(!0)},children:"Edit"})]})]}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:e.flexibleAlternative||"No flexible alternative recorded yet."}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[s?t.jsx(re,{label:s.title,schemaType:s.schemaType,compact:!0,showType:!0}):null,D.filter(m=>e.linkedModeIds.includes(m.id)).slice(0,2).map(m=>t.jsx(Be,{kind:"mode",label:m.title,compact:!0},m.id))]})]},e.id)})]})})]}),t.jsx(we,{open:g,onOpenChange:l,eyebrow:"Belief",title:c?"Refine belief":"Create belief",description:"Use this guided flow to capture the belief, what seems to support it, and a more flexible alternative.",value:h,onChange:r,draftPersistenceKey:c?`psyche.belief.${c.id}`:"psyche.belief.new",steps:ye,submitLabel:c?"Save belief":"Create belief",pending:G.isPending,error:j,onSubmit:async()=>{p(null);const e=ie.safeParse(h);if(!e.success){p("This belief still needs a statement before it can be saved.");return}try{await G.mutateAsync(e.data)}catch(s){p(s instanceof Error?s.message:"Unable to save this belief right now.")}}})]})}export{wt as PsycheSchemasBeliefsPage};
@@ -1 +0,0 @@
1
- import{r as S,j as t,aF as le,ds as ce,aI as J,aG as Z,dt as ee,b7 as de,bG as ue}from"./vendor-BwL6m4SE.js";import{j as me,i as he,k as pe}from"./state-Bpe5dF3T.js";import{d as ke,dX as ge,aq as fe,bb as ye,e as Ce,V as be,B as j,dY as A,k as N,C as D,c as P,P as re,cO as ve,dZ as xe,d_ as we}from"./index-FpGANF9S.js";import{P as Se}from"./page-hero-DvrM83_C.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const U=[{id:"xp_levels",label:"XP and level",trophyCount:8,unlockCount:4},{id:"streaks",label:"Streak and comeback",trophyCount:14,unlockCount:10},{id:"tasks",label:"Tasks and focus runs",trophyCount:14,unlockCount:4},{id:"projects",label:"Projects, goals, and strategy",trophyCount:14,unlockCount:4},{id:"wiki",label:"Wiki, notes, and knowledge graph",trophyCount:16,unlockCount:6},{id:"psyche",label:"Psyche",trophyCount:18,unlockCount:10},{id:"habits",label:"Habits, Life Force, and health",trophyCount:8,unlockCount:8},{id:"agents",label:"Agents and collaboration",trophyCount:4,unlockCount:2}],je=[1,2,3,5,7,14,21,30,45,60,90,180,365,730],Ae=[1,2,3,5,7,10,14,21,30,60];function e(r,l){return{metric:r,threshold:l}}function n(...r){return{allOf:r}}function $(r){return r.toLowerCase().replace(/['’]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Te(r,l){const u=(r+1)/l;return u>.82?"platinum":u>.55?"gold":u>.25?"silver":"bronze"}function _e(r){return r==="platinum"?"legendary":r==="gold"?"hard":r==="silver"?"standard":"intro"}function Ne(r){return r==="platinum"?"legendary":r==="gold"?"epic":r==="silver"?"rare":"common"}function Pe(r){return`item-${r.kind}-${$(r.category)}-${$(r.title)}`}function a(r,l,u,d,i,m){return{category:r,kind:"trophy",title:l,summary:i,requirement:u,requirementText:d,reward:`${l} trophy on the Forge shelf`}}function o(r,l,u,d,i,m,p){return{category:r,kind:"unlock",title:l,summary:m,requirement:d,requirementText:i,reward:`${l} cosmetic`,unlockType:u,rewardPayload:p}}const Re=[a("xp_levels","The First Heat",e("nonManualXp",5e3),"Earn 5,000 non-manual XP.","The first real furnace of work is hot enough to be noticed."),a("xp_levels","Bellows Graduate",e("nonManualXp",1e4),"Earn 10,000 non-manual XP.","Your reward ledger is no longer a spark; it is a system."),a("xp_levels","Iron Apprentice",e("nonManualXp",2e4),"Earn 20,000 non-manual XP.","You have repeated the work enough that the anvil knows your hand."),a("xp_levels","Steel Temper",e("nonManualXp",5e4),"Earn 50,000 non-manual XP.","Pressure has started to make the metal cleaner instead of louder."),a("xp_levels","Crown of Coals",e("nonManualXp",1e5),"Earn 100,000 non-manual XP.","A visible crown for an invisible mountain of completed work."),a("xp_levels","Obsidian Master",e("nonManualXp",25e4),"Earn 250,000 non-manual XP.","The Forge Smith stops testing your seriousness and starts respecting it."),a("xp_levels","Star-Forge Adept",e("nonManualXp",5e5),"Earn 500,000 non-manual XP.","Your XP trail burns like a constellation across the operating system."),a("xp_levels","Mythic Smith",e("nonManualXp",1e6),"Earn 1,000,000 non-manual XP.","A ridiculous trophy for a ridiculous amount of lived execution.")],Fe=[o("xp_levels","Obsidian Smith","mascot_skin",e("nonManualXp",8e3),"Earn 8,000 non-manual XP.","A dramatic black-iron Forge Smith skin.",{mascotSkin:"obsidian-smith"}),o("xp_levels","Molten Progress Bar","hud_treatment",e("nonManualXp",25e3),"Earn 25,000 non-manual XP.","A bright molten XP fill for the level ring.",{hudTreatment:"molten-progress"}),o("xp_levels","Apex Level Frame","icon_frame",e("nonManualXp",1e5),"Earn 100,000 non-manual XP.","A high-tier frame for level and trophy icons.",{iconFrame:"apex-level"}),o("xp_levels","Masterwork Glow","celebration_variant",e("nonManualXp",25e4),"Earn 250,000 non-manual XP.","A stronger forge-bell reveal for major unlocks.",{celebrationVariant:"masterwork-glow"})],Ee=[a("streaks","Spark Kept",e("longestStreakDays",1),"Play one qualifying day.","The first day is small, but the forge heard it."),a("streaks","Three-Day Furnace",e("longestStreakDays",3),"Reach a 3-day streak.","Three returns make the first shape of discipline."),a("streaks","Week-Fire",e("longestStreakDays",7),"Reach a 7-day streak.","Seven days changes the temperature of your life."),a("streaks","Twin-Week Bellows",e("longestStreakDays",14),"Reach a 14-day streak.","Two weeks of showing up makes the room expect you."),a("streaks","Cinder Discipline",e("longestStreakDays",21),"Reach a 21-day streak.","The fire is not accidental anymore."),a("streaks","Monthly Forge",e("longestStreakDays",30),"Reach a 30-day streak.","A full month of returns becomes a personal weather system."),a("streaks","Sixty-Day Flame",e("longestStreakDays",60),"Reach a 60-day streak.","The Smith grows stronger because you stopped disappearing."),a("streaks","Quarter-Anvil",e("longestStreakDays",90),"Reach a 90-day streak.","Ninety days is not motivation. It is architecture."),a("streaks","Half-Year Inferno",e("longestStreakDays",180),"Reach a 180-day streak.","The forge is now a season of your life."),a("streaks","Year of Steel",e("longestStreakDays",365),"Reach a 365-day streak.","A year of returns. The anvil has become a witness."),a("streaks","Comeback Hammer",e("comebackAfter7Count",1),"Return after 7+ missed days and complete a qualifying action.","You came back after the room went cold."),a("streaks","Repair Artist",e("comebackAfter7Count",3),"Complete 3 major comebacks.","Breaking the chain did not become breaking the story."),a("streaks","Rust Refuser",n(e("comebackAfter7Count",5),e("longestStreakDays",30)),"Complete 5 major comebacks and reach a 30-day streak.","You repeatedly turned absence into a new strike."),a("streaks","Relentless Return",n(e("comebackAfter7Count",8),e("longestStreakDays",90)),"Complete 8 major comebacks and reach a 90-day streak.","This trophy is for the part of you that keeps coming back.")],Ie=[o("streaks","Bronze Ember Flame","streak_effect",e("longestStreakDays",3),"Reach a 3-day streak.","A small ember around the streak HUD.",{streakEffect:"bronze-ember"}),o("streaks","Blue Forge-Fire","streak_effect",e("longestStreakDays",7),"Reach a 7-day streak.","A cool blue streak flame.",{streakEffect:"blue-forge-fire"}),o("streaks","Violet Arc Flame","streak_effect",e("longestStreakDays",21),"Reach a 21-day streak.","A sharper violet flame effect.",{streakEffect:"violet-arc"}),o("streaks","Molten Crown Fire","streak_effect",e("longestStreakDays",60),"Reach a 60-day streak.","A crown-like fire treatment for streaks.",{streakEffect:"molten-crown"}),o("streaks","Stern Pressure Pose","mascot_pose",e("comebackAfter7Count",1),"Complete a major comeback.","Unlocks the Smith's stern pressure pose.",{mascotPose:"stern-pressure"}),o("streaks","Comeback Pose","mascot_pose",e("comebackAfter7Count",2),"Complete 2 major comebacks.","Unlocks the Smith's comeback repair pose.",{mascotPose:"comeback"}),o("streaks","Awakening Forge Pose","mascot_pose",e("longestStreakDays",30),"Reach a 30-day streak.","Unlocks the forge awakening mascot pose.",{mascotPose:"awakening-forge"}),o("streaks","Yearfire Aura","streak_effect",e("longestStreakDays",365),"Reach a 365-day streak.","A huge aura for year-scale presence.",{streakEffect:"yearfire-aura"}),o("streaks","Old Foundry Shelf","trophy_shelf",e("longestStreakDays",90),"Reach a 90-day streak.","A warmer trophy shelf skin.",{trophyShelf:"old-foundry"}),o("streaks","Relentless Bell","celebration_variant",e("longestStreakDays",180),"Reach a 180-day streak.","A heavier celebration sound-and-spark treatment.",{celebrationVariant:"relentless-bell"})],Me=[a("tasks","First Strike",e("taskCompletionCount",25),"Complete 25 tasks.","A real task trail begins."),a("tasks","Clean Swing",n(e("taskCompletionCount",50),e("focusRunCount",10)),"Complete 50 tasks and 10 task runs.","Tasks and time-tracked execution start to converge."),a("tasks","Five Rivets",n(e("taskCompletionCount",75),e("taskCloseoutReportCount",5)),"Complete 75 tasks and 5 completion reports.","You are leaving proof behind, not just checkmarks."),a("tasks","Task Blade",n(e("taskCompletionCount",120),e("focusRunCount",25)),"Complete 120 tasks and 25 task runs.","A sharp blade forged out of repeated finishes."),a("tasks","Anvil Marathon",n(e("taskCompletionCount",300),e("focusRunCount",75)),"Complete 300 tasks and 75 task runs.","The long road achievement for serious execution."),a("tasks","Deep-Work Maul",e("creditedFocusMinutes",3e3),"Log 3,000 credited focus minutes.","The heavy hammer of deliberate time."),a("tasks","Planned Heat",e("plannedFocusRunCount",25),"Complete 25 planned task runs.","You planned the heat before striking the metal."),a("tasks","Closeout Scribe",e("taskCloseoutReportCount",25),"Write 25 task completion reports.","The Forge remembers what changed because you wrote it down."),a("tasks","Hundred-Hammer Road",e("taskCompletionCount",500),"Complete 500 tasks.","A road paved with finished work."),a("tasks","Timebox Knight",n(e("plannedFocusRunCount",75),e("creditedFocusMinutes",7500)),"Complete 75 planned runs and 7,500 focus minutes.","A trophy for time that obeyed the mission."),a("tasks","Backlog Breaker",e("taskCompletionCount",750),"Complete 750 tasks.","The backlog learned to fear your return."),a("tasks","Execution Monarch",n(e("taskCompletionCount",1e3),e("focusRunCount",200)),"Complete 1,000 tasks and 200 task runs.","A crown for turning vague intention into finished artifacts."),a("tasks","Forge Ledger Exact",e("taskCloseoutReportCount",100),"Write 100 task completion reports.","The most boring discipline becomes the most useful history."),a("tasks","The Hammer Does Not Blink",n(e("taskCompletionCount",1500),e("creditedFocusMinutes",15e3)),"Complete 1,500 tasks and 15,000 focus minutes.","For absurd consistency under real load.")],Ke=[o("tasks","Hammer Cursor","icon_frame",e("taskCompletionCount",75),"Complete 75 tasks.","A hammer-shaped action accent.",{iconFrame:"hammer-cursor"}),o("tasks","Focus Rail Glow","hud_treatment",e("focusRunCount",25),"Complete 25 task runs.","A task-run glow for compact HUDs.",{hudTreatment:"focus-rail-glow"}),o("tasks","Completion Burst","celebration_variant",e("taskCloseoutReportCount",25),"Write 25 completion reports.","A sharper task-completion burst.",{celebrationVariant:"completion-burst"}),o("tasks","Ember Knight","mascot_skin",e("taskCompletionCount",500),"Complete 500 tasks.","A molten-armored Forge Smith skin for execution mastery.",{mascotSkin:"ember-knight"})],$e=[a("projects","Aligned Spark",e("goalLinkedTaskCompletionCount",25),"Complete 25 goal-linked tasks.","Work starts pointing at something bigger."),a("projects","Goal Rivet",n(e("goalLinkedTaskCompletionCount",50),e("distinctGoalsWithCompletions",3)),"Complete 50 goal-linked tasks across 3 goals.","Several goals now have real rivets, not just titles."),a("projects","Strategist's Seal",n(e("goalLinkedTaskCompletionCount",50),e("distinctGoalsWithCompletions",5)),"Complete 50 goal-linked tasks across 5 goals.","A seal for strategy that survived contact with execution."),a("projects","Project Spine",n(e("projectLinkedTaskCompletionCount",100),e("activeProjectCount",5)),"Complete 100 project-linked tasks while maintaining 5 active projects.","The work has a spine across multiple initiatives."),a("projects","Strategy Weld",e("strategyCount",10),"Create 10 strategies.","You forged planning layers instead of improvising every day."),a("projects","Purpose Hammer",e("goalLinkedTaskCompletionCount",150),"Complete 150 goal-linked tasks.","The hammer keeps landing where your stated life points."),a("projects","Arc Builder",n(e("projectLinkedTaskCompletionCount",250),e("distinctGoalsWithCompletions",8)),"Complete 250 project-linked tasks across 8 goals.","Multiple arcs moved because you kept building."),a("projects","North-Star Foundry",n(e("goalLinkedTaskCompletionCount",300),e("strategyCount",20)),"Complete 300 goal-linked tasks and create 20 strategies.","The north star is no longer decorative."),a("projects","Project Finisher",e("projectCompletionCount",5),"Complete 5 projects.","Finished projects leave heavier evidence than active dreams."),a("projects","Life-Work Crown",n(e("projectCompletionCount",10),e("goalLinkedTaskCompletionCount",500)),"Complete 10 projects and 500 goal-linked tasks.","A crown for long arcs that actually closed."),a("projects","Portfolio Anvil",e("activeProjectCount",12),"Maintain 12 active projects.","A large operating portfolio, held without flattening."),a("projects","Tracer Bullet Guild",n(e("projectCompletionCount",15),e("strategyCount",35)),"Complete 15 projects and create 35 strategies.","Strategy and delivery joined hands repeatedly."),a("projects","Mountain Moved",e("goalLinkedTaskCompletionCount",1e3),"Complete 1,000 goal-linked tasks.","The trophy for moving a mountain one task at a time."),a("projects","The Work Had A Spine",n(e("projectCompletionCount",25),e("distinctGoalsWithCompletions",12)),"Complete 25 projects across 12 goals.","Your life map became execution history.")],Le=[o("projects","Goal Compass Frame","icon_frame",e("goalLinkedTaskCompletionCount",50),"Complete 50 goal-linked tasks.","A compass frame for aligned-work trophies.",{iconFrame:"goal-compass"}),o("projects","War-Room Iron Shelf","trophy_shelf",e("projectLinkedTaskCompletionCount",150),"Complete 150 project-linked tasks.","A darker tactical trophy shelf.",{trophyShelf:"war-room-iron"}),o("projects","North-Star HUD","hud_treatment",e("strategyCount",20),"Create 20 strategies.","A strategy-forward HUD treatment.",{hudTreatment:"north-star"}),o("projects","Foundry Compass Burst","celebration_variant",e("projectCompletionCount",10),"Complete 10 projects.","A compass-shaped major reveal.",{celebrationVariant:"foundry-compass"})],Ge=[a("wiki","First Inscription",e("wikiPageCount",50),"Create 50 wiki pages.","Knowledge has started to become an archive."),a("wiki","Memory Rivet",e("noteCount",100),"Create 100 notes.","The system remembers because you gave it material."),a("wiki","Archive Ember",n(e("wikiPageCount",150),e("wikiLinkCount",50)),"Create 150 wiki pages and 50 wiki links.","The archive starts connecting to itself."),a("wiki","Knowledge Anvil",n(e("wikiPageCount",250),e("wikiLinkCount",150)),"Create 250 wiki pages and 150 wiki links.","A serious anvil of memory and links."),a("wiki","Living Index",n(e("wikiPageWithSummaryCount",100),e("linkedWikiPageCount",100)),"Maintain 100 wiki pages with summaries and linked entities.","Pages now carry shape, summary, and relationships."),a("wiki","Black Library",n(e("wikiPageCount",500),e("wikiLinkCount",300)),"Create 500 wiki pages and 300 wiki links.","The great hard knowledge trophy."),a("wiki","Obsidian Index",n(e("wikiPageWithSummaryCount",250),e("wikiLinkCount",500)),"Maintain 250 summarized pages and 500 links.","The archive is no longer just big; it is navigable."),a("wiki","Graph Lantern",e("knowledgeGraphNodeCount",500),"Reach 500 Knowledge Graph nodes.","The graph has enough stars to navigate by."),a("wiki","Entity Weaver",e("linkedWikiPageCount",200),"Link 200 wiki pages to other pages or entities.","Your memory connects to the operating system."),a("wiki","Codex Temper",n(e("wikiPageCount",750),e("wikiLinkCount",750)),"Create 750 wiki pages and 750 wiki links.","A codex tempered by breadth and connection."),a("wiki","Note Furnace",e("noteCount",500),"Create 500 notes.","Raw notes became a real furnace of evidence."),a("wiki","Archive Cartographer",n(e("wikiPageWithSummaryCount",400),e("linkedWikiPageCount",300)),"Maintain 400 summarized pages and 300 linked pages.","You mapped the archive enough that it can map you back."),a("wiki","The Shelf Breathes",e("knowledgeGraphNodeCount",1e3),"Reach 1,000 Knowledge Graph nodes.","The knowledge system feels alive at a glance."),a("wiki","Librarian of Coals",n(e("noteCount",1e3),e("wikiLinkCount",1e3)),"Create 1,000 notes and 1,000 wiki links.","A trophy for the long, quiet archive discipline."),a("wiki","Living Codex",n(e("wikiPageCount",1500),e("wikiPageWithSummaryCount",750),e("wikiLinkCount",1500)),"Create 1,500 pages, 750 summarized pages, and 1,500 links.","The living memory crown."),a("wiki","Memory Starfield",e("knowledgeGraphNodeCount",2e3),"Reach 2,000 Knowledge Graph nodes.","The graph becomes a sky.")],Oe=[o("wiki","Quiet Library Shelf","trophy_shelf",e("wikiPageCount",150),"Create 150 wiki pages.","A quiet library shelf skin.",{trophyShelf:"quiet-library"}),o("wiki","Rune Page Frame","icon_frame",e("wikiLinkCount",150),"Create 150 wiki links.","A runic frame for knowledge trophies.",{iconFrame:"rune-page"}),o("wiki","Scholar Glass HUD","hud_treatment",e("wikiPageWithSummaryCount",100),"Maintain 100 summarized wiki pages.","A glassy scholar HUD treatment.",{hudTreatment:"scholar-glass"}),o("wiki","Archive Sparks","celebration_variant",e("linkedWikiPageCount",200),"Link 200 wiki pages to other pages or entities.","A page-flare reveal variant.",{celebrationVariant:"archive-sparks"}),o("wiki","Astral Archive Shelf","trophy_shelf",e("knowledgeGraphNodeCount",1e3),"Reach 1,000 Knowledge Graph nodes.","A cosmic trophy shelf for memory work.",{trophyShelf:"astral-archive"}),o("wiki","Reading Smith Pose","mascot_pose",e("wikiPageWithSummaryCount",250),"Maintain 250 summarized wiki pages.","Unlocks the Forge Smith reading pose.",{mascotPose:"reading"})],De=[a("psyche","Named Spark",e("psycheValueCount",5),"Create 5 Psyche values.","You named the values the forge should obey."),a("psyche","Pattern Tongs",e("behaviorPatternCount",5),"Create 5 behavior patterns.","The recurring loops are now held with tongs."),a("psyche","Belief Crucible",e("beliefEntryCount",5),"Create 5 belief entries.","Beliefs entered the fire where they can be worked."),a("psyche","Mode Lantern",e("modeProfileCount",3),"Create 3 mode profiles.","The inner cast has names and lantern light."),a("psyche","Trigger Witness",e("triggerReportCount",3),"Create 3 trigger reports.","You turned moments of activation into evidence."),a("psyche","Mode Cartographer",n(e("modeProfileCount",8),e("linkedModeProfileCount",8)),"Create 8 mode profiles, each linked to a value, behavior, or pattern.","A map of modes, not a pile of labels."),a("psyche","Trigger Alchemist",n(e("triggerReportRichCount",30),e("triggerReportCompletedCount",20)),"Complete 30 rich trigger reports and mark 20 reports beyond draft.","Activation was turned into material for change."),a("psyche","Pattern Breaker",n(e("behaviorPatternCount",20),e("behaviorPatternWithReplacementCount",10)),"Create 20 patterns and link 10 to replacement responses.","The old loops now have counter-moves."),a("psyche","Belief Temperer",n(e("beliefEntryCount",25),e("beliefFlexibleAlternativeCount",25)),"Create 25 beliefs with flexible alternatives.","Rigid beliefs were heated until they could bend."),a("psyche","Value Blade",n(e("psycheValueCount",10),e("goalLinkedTaskCompletionCount",100)),"Create 10 values and complete 100 goal-linked tasks.","Values and work started cutting in the same direction."),a("psyche","Shadow Temper",n(e("modeProfileCount",12),e("triggerReportRichCount",50)),"Create 12 modes and 50 rich trigger reports.","Shadow material became usable steel."),a("psyche","Inner Forge",n(e("psycheValueCount",12),e("behaviorPatternCount",25),e("beliefFlexibleAlternativeCount",30)),"Create 12 values, 25 patterns, and 30 flexible beliefs.","A full inner forge takes shape."),a("psyche","Schema Bell",e("questionnaireRunCount",40),"Complete 40 questionnaire runs.","Structured self-observation rang the bell repeatedly."),a("psyche","Mode Guide",e("modeGuideSessionCount",5),"Complete 5 mode guide sessions.","Guided mode work became an actual practice."),a("psyche","Repair Script",e("behaviorCount",10),"Create 10 Psyche behaviors.","Behaviors now carry repair plans, not just names."),a("psyche","Flexible Self",e("beliefFlexibleAlternativeCount",50),"Create 50 beliefs with flexible alternatives.","A trophy for not letting old beliefs remain iron cages."),a("psyche","Trigger Cartography",e("triggerReportRichCount",100),"Create 100 rich trigger reports.","The map of activation became detailed enough to steer by."),a("psyche","The Inner Council",n(e("modeProfileCount",20),e("behaviorCount",20),e("beliefFlexibleAlternativeCount",75)),"Create 20 modes, 20 behaviors, and 75 flexible beliefs.","The inner system became a council instead of noise.")],He=[o("psyche","Scholar Smith","mascot_skin",e("psycheValueCount",7),"Create 7 Psyche values.","A wise, bookish Forge Smith skin.",{mascotSkin:"scholar-smith"}),o("psyche","Wise Smith Pose","mascot_pose",e("modeProfileCount",3),"Create 3 mode profiles.","Unlocks the wise mentor pose.",{mascotPose:"wise"}),o("psyche","Reflection Frame","icon_frame",e("beliefEntryCount",10),"Create 10 belief entries.","A reflective frame for Psyche trophies.",{iconFrame:"reflection"}),o("psyche","Mode Lens HUD","hud_treatment",e("modeProfileCount",8),"Create 8 mode profiles.","A HUD tuned to Psyche work.",{hudTreatment:"mode-lens"}),o("psyche","Shadow Smith","mascot_skin",e("triggerReportRichCount",25),"Create 25 rich trigger reports.","A darker Smith skin for shadow work.",{mascotSkin:"shadow-smith"}),o("psyche","Arcane Metallurgist","mascot_skin",e("beliefFlexibleAlternativeCount",25),"Create 25 beliefs with flexible alternatives.","A rune-lit Smith skin for deep reflection.",{mascotSkin:"arcane-metallurgist"}),o("psyche","Inner-Fire Halo","streak_effect",e("psycheValueCount",10),"Create 10 Psyche values.","A halo-like flame for reflective momentum.",{streakEffect:"inner-fire-halo"}),o("psyche","Mode Lantern Reveal","celebration_variant",e("modeProfileCount",12),"Create 12 mode profiles.","A lantern reveal for Psyche unlocks.",{celebrationVariant:"mode-lantern"}),o("psyche","Therapist's Shelf","trophy_shelf",e("triggerReportRichCount",50),"Create 50 rich trigger reports.","A quiet shelf for inner-work trophies.",{trophyShelf:"therapist-shelf"}),o("psyche","Prismatic Crucible","celebration_variant",e("beliefFlexibleAlternativeCount",50),"Create 50 flexible belief alternatives.","A prismatic reveal for belief work.",{celebrationVariant:"prismatic-crucible"})],ze=[a("habits","Ritual Spark",e("habitAlignedCount",25),"Record 25 aligned habit check-ins.","Your recurring commitments have started to leave marks."),a("habits","Routine Rivet",e("habitAlignedCount",75),"Record 75 aligned habit check-ins.","The habit rail is no longer decorative."),a("habits","Habit Heat",n(e("habitAlignedCount",150),e("habitStreakMax",14)),"Record 150 aligned check-ins and a 14-day habit streak.","One behavior got hot enough to shape you."),a("habits","Ritual Iron",e("habitAlignedCount",365),"Record 365 aligned habit check-ins.","The hard habit trophy."),a("habits","Recovery Shield",e("recoveryEventCount",50),"Earn 50 recovery rewards.","Recovery was treated as part of the work."),a("habits","Life-Force Alloy",e("lifeForceSnapshotCount",100),"Record 100 Life Force day snapshots.","Energy accounting became a usable alloy."),a("habits","Sleep Temper",e("healthSleepSessionCount",120),"Import 120 sleep sessions.","Sleep became evidence, not a guess."),a("habits","Vitality Forge",n(e("workoutSessionCount",100),e("healthSleepSessionCount",200)),"Import 100 workouts and 200 sleep sessions.","Body data and execution entered the same forge.")],Be=[o("habits","Recovery Blue Flame","streak_effect",e("recoveryEventCount",20),"Earn 20 recovery rewards.","A cooler recovery flame.",{streakEffect:"recovery-blue"}),o("habits","Ritual Check Glow","hud_treatment",e("habitAlignedCount",75),"Record 75 aligned habit check-ins.","A habit-check glow for the HUD.",{hudTreatment:"ritual-check"}),o("habits","Storm Forger","mascot_skin",e("workoutSessionCount",50),"Import 50 workouts.","A storm-lit Smith skin for movement arcs.",{mascotSkin:"storm-forger"}),o("habits","Clockwork Smith","mascot_skin",e("habitAlignedCount",150),"Record 150 aligned habit check-ins.","A clockwork skin for ritual precision.",{mascotSkin:"clockwork-smith"}),o("habits","Vital Flame","streak_effect",e("healthSleepSessionCount",90),"Import 90 sleep sessions.","A vital-sign flame around streak indicators.",{streakEffect:"vital-flame"}),o("habits","Life-Force Frame","icon_frame",e("lifeForceSnapshotCount",100),"Record 100 Life Force snapshots.","An AP-inspired frame for body trophies.",{iconFrame:"life-force"}),o("habits","Steady-State Aura","streak_effect",e("habitStreakMax",60),"Reach a 60-day habit streak.","An aura for long stable rituals.",{streakEffect:"steady-state"}),o("habits","Celestial Smith","mascot_skin",n(e("workoutSessionCount",100),e("healthSleepSessionCount",200)),"Import 100 workouts and 200 sleep sessions.","A celestial skin for body stewardship.",{mascotSkin:"celestial-smith"})],We=[a("agents","Companion Spark",e("agentActionCount",5),"Record 5 agent actions.","The first sign of a working human-agent council."),a("agents","Bot Bellows",e("agentCompletedActionCount",20),"Complete 20 agent actions.","Agents are not just present; they are moving work."),a("agents","Council Spark",e("collaborationRewardCount",50),"Earn 50 collaboration rewards.","The collaboration trophy for meaningful assisted work."),a("agents","Guild Forge",n(e("agentCompletedActionCount",100),e("collaborationRewardCount",100)),"Complete 100 agent actions and earn 100 collaboration rewards.","The Forge has become a small guild.")],Ue=[o("agents","Guild Badge Frame","icon_frame",e("agentCompletedActionCount",20),"Complete 20 agent actions.","A guild frame for agent trophies.",{iconFrame:"guild-badge"}),o("agents","Council Sparks Reveal","celebration_variant",e("collaborationRewardCount",50),"Earn 50 collaboration rewards.","A council-sparks reveal for collaboration.",{celebrationVariant:"council-sparks"})],Ye=[...Re,...Fe,...Ee,...Ie,...Me,...Ke,...$e,...Le,...Ge,...Oe,...De,...He,...ze,...Be,...We,...Ue];function Xe(){let r=0,l=0,u=0;const d=new Map;return Ye.map(i=>{const m=U.find(L=>L.id===i.category);if(!m)throw new Error(`Unknown gamification category ${i.category}`);const p=d.get(i.category)??{trophy:0,unlock:0},x=p[i.kind];p[i.kind]+=1,d.set(i.category,p);const R=i.kind==="trophy"?m.trophyCount:m.unlockCount,v=Te(x,R),F=`${i.kind}-${$(i.category)}-${$(i.title)}`,w=i.kind==="trophy"?l++:u++;return{id:F,kind:i.kind,category:i.category,tier:v,difficulty:_e(v),hidden:i.hidden??!1,title:i.title,summary:i.summary,requirement:i.requirement,requirementText:i.requirementText,reward:i.reward,unlockType:i.kind==="unlock"?i.unlockType??"icon_frame":null,rewardPayload:i.kind==="unlock"?i.rewardPayload??{}:{trophyId:F},assetKey:Pe(i),sheetKey:`${i.kind==="trophy"?"trophies":"unlocks"}-r${Math.floor(w/10)+1}-c${w%10+1}`,rarity:Ne(v),sortOrder:r++}})}const y=Xe();function qe(){if(y.length!==144)throw new Error(`GAMIFICATION_CATALOG must contain exactly 144 items; found ${y.length}.`);const r=y.filter(d=>d.kind==="trophy").length,l=y.filter(d=>d.kind==="unlock").length;if(r!==96||l!==48)throw new Error(`GAMIFICATION_CATALOG must contain 96 trophies and 48 unlocks; found ${r}/${l}.`);for(const d of U){const i=y.filter(p=>p.category===d.id&&p.kind==="trophy").length,m=y.filter(p=>p.category===d.id&&p.kind==="unlock").length;if(i!==d.trophyCount||m!==d.unlockCount)throw new Error(`${d.id} expected ${d.trophyCount}/${d.unlockCount}, found ${i}/${m}.`)}if(new Set(y.map(d=>d.assetKey)).size!==y.length)throw new Error("Every trophy and unlock must have a unique asset key.")}qe();const te=U.map(r=>({id:r.id,label:r.label})),Ve=Array.from({length:30},(r,l)=>`mascot-state-${String(l+1).padStart(3,"0")}`),Qe=je.map((r,l)=>[r,`mascot-state-${String(17+l).padStart(3,"0")}`]),Je=Ae.map((r,l)=>[r,`mascot-state-${String(10-l).padStart(3,"0")}`]),z=Ve;if(z.length!==30)throw new Error(`GAMIFICATION_MASCOT_KEYS must contain exactly 30 mascot/state keys; found ${z.length}.`);function Ze(r){switch(r.category){case"xp_levels":return"#f59e0b";case"streaks":return"#fb923c";case"tasks":return"#f97316";case"projects":return"#38bdf8";case"wiki":return"#a78bfa";case"psyche":return"#8b5cf6";case"habits":return"#4ade80";case"agents":return"#22d3ee";default:return"#f59e0b"}}function et(r){return["cinematic stylized blacksmith game icon",r.category.replace(/_/g," "),r.kind,r.title,"obsidian iron, ember gold, cool violet and cyan steel highlights, no text"].join(", ")}const tt=Object.fromEntries(y.map(r=>[r.assetKey,{key:r.assetKey,role:"item",itemKind:r.kind,alt:`${r.title} ${r.kind} icon.`,dominantColor:Ze(r),tierFrame:r.tier,sourcePath:`gamification/source/themes/dark-fantasy/items/${r.assetKey}.png`,spritePath:`gamification/sprites/themes/dark-fantasy/items/${r.assetKey}-{size}.webp`,sheetKey:r.sheetKey,prompt:et(r)}])),at=Object.fromEntries(z.map(r=>{const l=Number(r.replace("mascot-state-","")),u=l<=10,d=l>=17;return[r,{key:r,role:d||u?"streak":"mascot",alt:u?"The Forge Smith in a safe cold-forge absence state.":"The Forge Smith mascot in a dramatic blacksmith game-art pose.",dominantColor:u?"#64748b":d?"#fb923c":"#38bdf8",tierFrame:"none",sourcePath:`gamification/source/themes/dark-fantasy/mascots/${r}.png`,spritePath:`gamification/sprites/themes/dark-fantasy/mascots/${r}-{size}.webp`,sheetKey:null,prompt:"dramatic Forge Smith blacksmith mascot, premium game art, no text, no watermark"}]}));({...tt,...at});function T(r){r.currentTarget.hidden=!0}const rt=["all","bronze","silver","gold","platinum"],st=[{id:"trophies",label:"Trophies"},{id:"unlocks",label:"Unlocks"},{id:"armory",label:"Mascot Armory"},{id:"streak",label:"Streak Forge"}],B={mascot_skin:{field:"selectedMascotSkin",payloadKey:"mascotSkin",label:"Mascot skin"},hud_treatment:{field:"selectedHudTreatment",payloadKey:"hudTreatment",label:"HUD treatment"},streak_effect:{field:"selectedStreakEffect",payloadKey:"streakEffect",label:"Streak flame"},trophy_shelf:{field:"selectedTrophyShelf",payloadKey:"trophyShelf",label:"Trophy shelf"},celebration_variant:{field:"selectedCelebrationVariant",payloadKey:"celebrationVariant",label:"Celebration"}};function se(r){switch(r){case"platinum":return"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--primary)]";case"gold":return"border-[color-mix(in_srgb,var(--warning)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]";case"silver":return"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]";default:return"border-[color-mix(in_srgb,var(--warning)_26%,var(--ui-border-subtle)_74%)] bg-[var(--ui-warning-soft)] text-[var(--warning)]"}}const ae="min-w-0 overflow-hidden rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",H="min-w-0 overflow-hidden rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",C="text-[var(--ui-ink-strong)]",b="text-[var(--ui-ink-soft)]",_="text-[var(--ui-ink-faint)]",W="bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]";function ot(r){const l=r.unlockType?B[r.unlockType]:null,u=l?r.rewardPayload[l.payloadKey]:null;return typeof u=="string"?u:null}function nt({item:r,gamificationTheme:l,onSelect:u}){return t.jsxs("button",{type:"button",onClick:()=>u(r),className:P("group relative min-h-[19rem] overflow-hidden rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left shadow-[var(--ui-shadow-soft)] transition hover:-translate-y-0.5 hover:border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] hover:bg-[var(--ui-surface-hover)]",!r.unlocked&&"opacity-78"),children:[t.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[t.jsx(N,{className:P("border",se(r.tier)),children:r.tier}),t.jsx(N,{className:W,children:r.unlocked?"earned":"locked"})]}),t.jsx("div",{className:"mt-3 grid place-items-center",children:t.jsx("img",{src:A(r.assetKey,512,l),alt:"",onError:T,className:P("size-36 object-contain drop-shadow-[var(--ui-shadow-soft)] transition group-hover:scale-[1.03]",!r.unlocked&&"grayscale")})}),t.jsxs("div",{className:"mt-3 min-w-0",children:[t.jsx("div",{className:`font-display text-lg ${C}`,children:r.title}),t.jsx("p",{className:`mt-2 line-clamp-2 text-sm leading-6 ${b}`,children:r.unlocked?r.summary:r.requirementText})]}),t.jsxs("div",{className:"mt-4",children:[t.jsx(re,{value:r.progressPercent}),t.jsxs("div",{className:`mt-2 flex justify-between gap-3 text-[11px] uppercase tracking-[0.16em] ${_}`,children:[t.jsxs("span",{children:[r.progressCurrent,"/",r.progressTarget]}),t.jsxs("span",{children:[r.progressPercent,"%"]})]})]})]})}function kt(){var X,q,V,Q;const r=ke(),l=ge(),u=me(),d=fe(),i=Array.isArray(r.selectedUserIds)?r.selectedUserIds:[],[m,p]=S.useState("trophies"),[x,R]=S.useState("all"),[v,F]=S.useState("all"),[w,L]=S.useState("all"),[G,oe]=S.useState(""),[k,E]=S.useState(null),I=he({queryKey:["forge-gamification-catalog",...i],queryFn:()=>we(i)}),M=ye(i),Y=pe({mutationFn:s=>xe(s,i),onSuccess:async()=>{await Promise.all([u.invalidateQueries({queryKey:["forge-gamification-catalog"]}),u.invalidateQueries({queryKey:["forge-xp-metrics"]})]),d(ve.util.invalidateTags(["Gamification"]))}}),g=(X=I.data)==null?void 0:X.catalog,O=(g==null?void 0:g.items)??[],ne=S.useMemo(()=>{const s=G.trim().toLowerCase();return O.filter(c=>m==="trophies"&&c.kind!=="trophy"||m==="unlocks"&&c.kind!=="unlock"||(m==="armory"||m==="streak")&&c.kind!=="unlock"||m==="armory"&&!c.unlockType||m==="streak"&&c.unlockType!=="streak_effect"||x!=="all"&&c.category!==x||v!=="all"&&c.tier!==v||w==="unlocked"&&!c.unlocked||w==="locked"&&c.unlocked?!1:s?`${c.title} ${c.summary} ${c.requirementText} ${c.reward}`.toLowerCase().includes(s):!0)},[x,O,G,w,m,v]),h=(g==null?void 0:g.equipment)??((q=M.data)==null?void 0:q.metrics.equipment)??null,ie=O.filter(s=>s.kind==="unlock"&&s.unlockType&&B[s.unlockType]);return I.isError?t.jsx(Ce,{eyebrow:"Rewards",error:I.error,onRetry:()=>void I.refetch()}):t.jsxs("div",{className:"mx-auto grid w-full max-w-[1320px] gap-5",children:[t.jsx(Se,{title:"Trophy Hall",description:"Achievements are earned from real Forge behavior: tasks, runs, goals, wiki links, Psyche work, habits, Life Force, health, and collaboration.",badge:g?`${g.unlockedCount}/${g.totalCount} earned`:"Loading",actions:(V=M.data)!=null&&V.metrics?t.jsx(be,{metrics:M.data.metrics.profile}):null}),t.jsxs("section",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,0.42fr)]",children:[t.jsxs("div",{className:ae,children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(s=>t.jsxs(j,{type:"button",variant:m===s.id?"primary":"secondary",size:"sm",onClick:()=>p(s.id),children:[s.id==="trophies"?t.jsx(le,{className:"size-4"}):null,s.id==="armory"?t.jsx(ce,{className:"size-4"}):null,s.id==="streak"?t.jsx(J,{className:"size-4"}):null,s.id==="unlocks"?t.jsx(Z,{className:"size-4"}):null,s.label]},s.id))}),t.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap items-center gap-2",children:[["all","unlocked","locked"].map(s=>t.jsxs(j,{type:"button",variant:w===s?"primary":"secondary",size:"sm",onClick:()=>L(s),children:[s==="locked"?t.jsx(ee,{className:"size-4"}):null,s]},s)),t.jsxs("label",{className:`ml-auto flex min-h-10 min-w-0 max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm ${b} sm:min-w-[16rem]`,children:[t.jsx(de,{className:`size-4 shrink-0 ${_}`}),t.jsx("input",{value:G,onChange:s=>oe(s.target.value),placeholder:"Search rewards",className:"min-w-0 flex-1 bg-transparent text-[var(--ui-ink-strong)] outline-none placeholder:text-[var(--ui-ink-faint)]"})]})]}),t.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap gap-2",children:[t.jsx(j,{type:"button",variant:x==="all"?"primary":"secondary",size:"sm",onClick:()=>R("all"),children:"all categories"}),te.map(s=>t.jsx(j,{type:"button",variant:x===s.id?"primary":"secondary",size:"sm",onClick:()=>R(s.id),children:s.label},s.id))]}),t.jsx("div",{className:"mt-4 flex min-w-0 flex-wrap gap-2",children:rt.map(s=>t.jsx(j,{type:"button",variant:v===s?"primary":"secondary",size:"sm",onClick:()=>F(s),children:s},s))})]}),t.jsxs("div",{className:ae,children:[t.jsxs("div",{className:`flex items-center gap-2 text-sm font-semibold ${C}`,children:[t.jsx(Z,{className:"size-4 text-[var(--tertiary)]"}),"Near completion"]}),((g==null?void 0:g.nextTargets)??[]).map(s=>t.jsxs("button",{type:"button",onClick:()=>E(s),className:"grid min-w-0 grid-cols-[2.75rem_minmax(0,1fr)_3rem] items-center gap-3 rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-left transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsx("img",{src:A(s.assetKey,256,l),alt:"",onError:T,className:"size-11 object-contain"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:`block truncate text-sm ${C}`,children:s.title}),t.jsx("span",{className:`block truncate text-[11px] ${_}`,children:s.requirementText})]}),t.jsxs("span",{className:`text-right text-xs ${b}`,children:[s.progressPercent,"%"]})]},s.id))]})]}),m==="armory"?t.jsxs("section",{className:"grid gap-3 lg:grid-cols-[minmax(18rem,0.42fr)_minmax(0,1fr)]",children:[t.jsxs("div",{className:"relative min-h-[24rem] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 shadow-[var(--ui-shadow-soft)]",children:[t.jsx("img",{src:A(((Q=M.data)==null?void 0:Q.metrics.mascot.spriteKey)??"mascot-state-014",512,l),alt:"Forge Smith mascot",onError:T,className:"absolute inset-x-0 bottom-0 mx-auto h-[23rem] object-contain"}),t.jsxs("div",{className:"relative z-10",children:[t.jsx(N,{className:"bg-[var(--ui-accent-soft)] text-[var(--tertiary)]",children:"Equipped"}),t.jsxs("div",{className:`mt-3 grid gap-1 text-sm ${b}`,children:[t.jsxs("span",{children:["Skin: ",(h==null?void 0:h.selectedMascotSkin)??"default"]}),t.jsxs("span",{children:["HUD: ",(h==null?void 0:h.selectedHudTreatment)??"default"]}),t.jsxs("span",{children:["Flame: ",(h==null?void 0:h.selectedStreakEffect)??"default"]}),t.jsxs("span",{children:["Shelf: ",(h==null?void 0:h.selectedTrophyShelf)??"default"]})]})]})]}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3",children:ie.map(s=>{const c=s.unlockType?B[s.unlockType]:null,f=ot(s),K=!!(c&&f&&(h==null?void 0:h[c.field])===f);return t.jsxs(D,{className:P("p-4",!s.unlocked&&"opacity-70"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx(N,{className:W,children:(c==null?void 0:c.label)??"Cosmetic"}),K?t.jsx(ue,{className:"size-4 text-[var(--success)]"}):null]}),t.jsx("img",{src:A(s.assetKey,256,l),alt:"",onError:T,className:P("mx-auto mt-3 size-28 object-contain",!s.unlocked&&"grayscale")}),t.jsx("div",{className:`mt-3 font-display text-lg ${C}`,children:s.title}),t.jsx("p",{className:`mt-2 line-clamp-2 text-sm leading-6 ${b}`,children:s.unlocked?s.summary:s.requirementText}),t.jsx(j,{type:"button",variant:K?"secondary":"primary",size:"sm",disabled:!s.unlocked||!c||!f||Y.isPending,className:"mt-4 w-full",onClick:()=>{!c||!f||Y.mutate({[c.field]:K?null:f})},children:K?"Unequip":s.unlocked?"Equip":"Locked"})]},s.id)})})]}):m==="streak"?t.jsxs("section",{className:"grid gap-4",children:[t.jsxs(D,{className:"p-4",children:[t.jsxs("div",{className:`flex items-center gap-2 font-display text-xl ${C}`,children:[t.jsx(J,{className:"size-5 text-[var(--tertiary)]"}),"Streak power states"]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 md:grid-cols-4 xl:grid-cols-5",children:Qe.map(([s,c])=>t.jsxs("div",{className:H,children:[t.jsx("img",{src:A(c,256,l),alt:"",onError:T,className:"mx-auto size-28 object-contain"}),t.jsxs("div",{className:`mt-2 text-center text-sm ${b}`,children:[s," day power"]})]},c))})]}),t.jsxs(D,{className:"p-4",children:[t.jsxs("div",{className:`flex items-center gap-2 font-display text-xl ${C}`,children:[t.jsx(ee,{className:`size-5 ${_}`}),"Absence pressure states"]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 md:grid-cols-4 xl:grid-cols-5",children:Je.map(([s,c])=>t.jsxs("div",{className:H,children:[t.jsx("img",{src:A(c,256,l),alt:"",onError:T,className:"mx-auto size-28 object-contain"}),t.jsxs("div",{className:`mt-2 text-center text-sm ${b}`,children:[s," days away"]})]},c))})]})]}):t.jsx("section",{className:"grid gap-5",children:te.map(s=>{const c=ne.filter(f=>f.category===s.id);return c.length===0?null:t.jsxs("section",{className:"grid gap-3",children:[t.jsx("div",{className:"flex items-end justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("div",{className:`font-display text-xl ${C}`,children:s.label}),t.jsxs("div",{className:`text-sm ${_}`,children:[c.length," visible rewards"]})]})}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:c.map(f=>t.jsx(nt,{item:f,gamificationTheme:l,onSelect:E},f.id))})]},s.id)})}),k?t.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center bg-[var(--ui-overlay)] p-4 backdrop-blur-sm",onClick:()=>E(null),children:t.jsxs("div",{className:"max-h-[calc(100vh-2rem)] w-full max-w-[34rem] overflow-y-auto rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--card-gradient)] p-5 shadow-[var(--card-shadow)]",onClick:s=>s.stopPropagation(),children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start",children:[t.jsx("img",{src:A(k.assetKey,512,l),alt:"",onError:T,className:"size-32 shrink-0 object-contain"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(N,{className:P("border",se(k.tier)),children:k.tier}),t.jsx(N,{className:W,children:k.kind})]}),t.jsx("div",{className:`mt-3 font-display text-2xl ${C}`,children:k.title}),t.jsx("p",{className:`mt-2 text-sm leading-6 ${b}`,children:k.summary})]})]}),t.jsxs("div",{className:`mt-5 ${H}`,children:[t.jsx("div",{className:`text-sm font-semibold ${C}`,children:"Requirement"}),t.jsx("p",{className:`mt-2 text-sm leading-6 ${b}`,children:k.requirementText}),t.jsxs("div",{className:"mt-4",children:[t.jsx(re,{value:k.progressPercent}),t.jsxs("div",{className:`mt-2 flex justify-between gap-3 text-[11px] uppercase tracking-[0.16em] ${_}`,children:[t.jsxs("span",{children:[k.progressCurrent,"/",k.progressTarget]}),t.jsx("span",{children:k.unlocked?"earned":"locked"})]})]})]}),t.jsx("div",{className:"mt-4 flex justify-end",children:t.jsx(j,{type:"button",variant:"secondary",onClick:()=>E(null),children:"Close"})})]})}):null]})}export{kt as RewardsPage};
@@ -1 +0,0 @@
1
- import{r as u,j as e,b7 as q,c$ as E,c1 as R}from"./vendor-BwL6m4SE.js";import{j as Q,i as B,k as h}from"./state-Bpe5dF3T.js";import{S as K}from"./settings-section-nav-Lo-VKCfZ.js";import{S as H,e as P,C as x,I as W,c as G,B as y,b as V,dg as A,dh as $,cU as Y,di as O}from"./index-FpGANF9S.js";import{P as U}from"./page-hero-DvrM83_C.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const a={goal:"Goals",project:"Projects",task:"Tasks",strategy:"Strategies",habit:"Habits",tag:"Tags",note:"Notes",insight:"Insights",psyche_value:"Values",behavior_pattern:"Patterns",behavior:"Behaviors",belief_entry:"Beliefs",mode_profile:"Modes",mode_guide_session:"Mode guides",flashcard:"Flashcards",event_type:"Event types",emotion_definition:"Emotions",trigger_report:"Reports",calendar_event:"Calendar events",work_block_template:"Work blocks",task_timebox:"Timeboxes",preference_catalog:"Preference catalogs",preference_catalog_item:"Preference catalog items",preference_context:"Preference contexts",preference_item:"Preference items",questionnaire_instrument:"Questionnaires",sleep_session:"Sleep sessions",workout_session:"Workout sessions"},J={goal:"goal",project:"project",task:"task",strategy:"strategy",habit:"habit",tag:null,note:null,insight:"report",psyche_value:"value",behavior_pattern:"pattern",behavior:"behavior",belief_entry:"belief",mode_profile:"mode",mode_guide_session:"mode",flashcard:"flashcard",event_type:null,emotion_definition:null,trigger_report:"report",calendar_event:null,work_block_template:null,task_timebox:null,preference_catalog:null,preference_catalog_item:null,preference_context:null,preference_item:null,questionnaire_instrument:null,sleep_session:null,workout_session:null},v="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",X="text-[var(--ui-ink-strong)]",j="text-[var(--ui-ink-soft)]",m="text-[var(--ui-ink-faint)]",Z="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",ee="border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",te="grid min-w-0 gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 lg:grid-cols-[minmax(0,1fr)_auto]";function se(f){return new Date(f).toLocaleString()}function me(){var C,T;const f=Q(),[b,D]=u.useState(""),[l,L]=u.useState([]),c=B({queryKey:["forge-operator-session"],queryFn:Y}),M=c.isSuccess,o=B({queryKey:["forge-settings-bin"],queryFn:O,enabled:M}),p=async()=>{await f.invalidateQueries({predicate:t=>Array.isArray(t.queryKey)&&typeof t.queryKey[0]=="string"&&t.queryKey[0].startsWith("forge-")})},_=h({mutationFn:t=>A({operations:[{entityType:t.entityType,id:t.entityId}]}),onSuccess:p}),w=h({mutationFn:t=>$({operations:[{entityType:t.entityType,id:t.entityId,mode:"hard"}]}),onSuccess:p}),k=h({mutationFn:t=>A({operations:t.map(s=>({entityType:s.entityType,id:s.entityId}))}),onSuccess:p}),N=h({mutationFn:t=>$({operations:t.map(s=>({entityType:s.entityType,id:s.entityId,mode:"hard"}))}),onSuccess:p}),d=((C=o.data)==null?void 0:C.bin.records)??[],g=b.trim().toLowerCase(),r=u.useMemo(()=>d.filter(t=>l.length===0||l.includes(t.entityType)?g?[t.title,t.subtitle??"",t.entityType,t.entityId,t.deletedByActor??"",t.deletedSource??"",t.deleteReason??""].join(" ").toLowerCase().includes(g):!0:!1),[g,d,l]),S=u.useMemo(()=>{const t=new Map;for(const s of r){const i=t.get(s.entityType)??[];i.push(s),t.set(s.entityType,i)}return[...t.entries()].sort((s,i)=>a[s[0]].localeCompare(a[i[0]]))},[r]),I=u.useMemo(()=>[...new Set(d.map(t=>t.entityType))].sort((t,s)=>a[t].localeCompare(a[s])),[d]);function z(t){L(s=>s.includes(t)?s.filter(i=>i!==t):[...s,t])}async function F(){r.length===0||!window.confirm(`Permanently delete ${r.length} item${r.length===1?"":"s"} from the bin? This cannot be undone.`)||await N.mutateAsync(r)}return c.isLoading||o.isLoading?e.jsx(H,{eyebrow:"Settings",title:"Loading bin",description:"Loading deleted items and restore controls.",columns:2,blocks:6}):c.isError?e.jsx(P,{eyebrow:"Settings",error:c.error,onRetry:()=>void c.refetch()}):o.isError?e.jsx(P,{eyebrow:"Settings",error:o.error,onRetry:()=>void o.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(U,{title:"Bin",description:"Restore soft-deleted items or permanently remove them when you really mean it.",badge:`${((T=o.data)==null?void 0:T.bin.totalCount)??0} deleted items`}),e.jsx(K,{}),e.jsxs(x,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-start",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:v,children:"Find deleted items"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:`pointer-events-none absolute left-4 top-1/2 size-4 -translate-y-1/2 ${m}`}),e.jsx(W,{value:b,onChange:t=>D(t.target.value),placeholder:"Search title, id, reason, or source",className:"pl-11"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(t=>{const s=l.includes(t);return e.jsx("button",{type:"button",onClick:()=>z(t),className:G("rounded-full border px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",s?ee:Z),children:a[t]},t)})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 lg:max-w-[22rem] lg:justify-end",children:[e.jsxs(y,{variant:"secondary",size:"sm",disabled:r.length===0,pending:k.isPending,pendingLabel:"Restoring",onClick:()=>void k.mutateAsync(r),children:[e.jsx(E,{className:"size-4"}),e.jsx("span",{children:"Restore visible"})]}),e.jsxs(y,{variant:"secondary",size:"sm",disabled:r.length===0,pending:N.isPending,pendingLabel:"Deleting",onClick:()=>void F(),children:[e.jsx(R,{className:"size-4"}),e.jsx("span",{children:"Delete visible forever"})]})]})]}),e.jsxs("div",{className:`flex flex-wrap gap-3 text-sm ${m}`,children:[e.jsxs("span",{children:[r.length," visible"]}),l.length>0?e.jsxs("span",{children:[l.length," type filters active"]}):null,g?e.jsxs("span",{children:["Search: “",b.trim(),"”"]}):null]})]}),d.length===0?e.jsxs(x,{children:[e.jsx("div",{className:v,children:"Deleted items"}),e.jsx("div",{className:`mt-4 ${j}`,children:"Nothing is in the bin right now."})]}):S.length===0?e.jsxs(x,{children:[e.jsx("div",{className:v,children:"Deleted items"}),e.jsx("div",{className:`mt-4 ${j}`,children:"No deleted items match the current search or filters."})]}):e.jsx("div",{className:"grid gap-5",children:S.map(([t,s])=>{const i=J[t];return e.jsxs(x,{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[i?e.jsx(V,{kind:i,label:a[t],compact:!0}):null,i?null:e.jsx("div",{className:`rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1 text-[11px] uppercase tracking-[0.16em] ${m}`,children:a[t]}),e.jsxs("div",{className:`text-sm ${m}`,children:[s.length," deleted"]})]})}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.map(n=>e.jsxs("div",{className:te,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`break-words text-lg font-medium [overflow-wrap:anywhere] ${X}`,children:n.title}),n.subtitle?e.jsx("div",{className:`mt-1 break-words text-sm [overflow-wrap:anywhere] ${j}`,children:n.subtitle}):null,e.jsxs("div",{className:`mt-3 flex flex-wrap gap-3 break-words text-xs [overflow-wrap:anywhere] ${m}`,children:[e.jsxs("span",{children:["Deleted ",se(n.deletedAt)]}),n.deletedByActor?e.jsxs("span",{children:["By ",n.deletedByActor]}):null,n.deletedSource?e.jsxs("span",{children:["Source ",n.deletedSource]}):null,n.deleteReason?e.jsxs("span",{children:["Reason: ",n.deleteReason]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-start justify-end gap-2",children:[e.jsxs(y,{variant:"secondary",size:"sm",pending:_.isPending,pendingLabel:"Restoring",onClick:()=>void _.mutateAsync(n),children:[e.jsx(E,{className:"size-4"}),e.jsx("span",{children:"Restore"})]}),e.jsxs(y,{variant:"secondary",size:"sm",pending:w.isPending,pendingLabel:"Deleting",onClick:()=>void w.mutateAsync(n),children:[e.jsx(R,{className:"size-4"}),e.jsx("span",{children:"Delete forever"})]})]})]},`${n.entityType}:${n.entityId}`))})]},t)})})]})}export{me as SettingsBinPage};
@@ -1 +0,0 @@
1
- import{r as n,j as e,b2 as le,dq as fe,c1 as ce,dr as ke,aG as ye,cN as Ne,de as Ce}from"./vendor-BwL6m4SE.js";import{j as we,i as I,k as h}from"./state-Bpe5dF3T.js";import{S as Ae}from"./settings-section-nav-Lo-VKCfZ.js";import{P as Se}from"./page-hero-DvrM83_C.js";import{L as Oe,e as Ie,C as w,B as o,k as l,cP as Me,dF as Pe,dG as Le,dH as Ee,dI as Ke,dJ as Fe,dK as Ue,dL as _e,cV as ze,bn as $e,dM as Be}from"./index-FpGANF9S.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const ue="grid min-w-0 gap-2 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",M="grid min-w-0 gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",P="rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-5 text-sm leading-6 text-[var(--ui-ink-soft)]",d="min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none placeholder:text-[var(--ui-ink-faint)] transition focus:border-[var(--primary)]/35 focus:bg-[var(--ui-surface-3)]",j="text-sm text-[var(--ui-ink-strong)]",L="text-[var(--ui-ink-soft)]",m="text-[var(--ui-ink-faint)]",We="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",g="bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",qe="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",Qe="rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-4 py-5 text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]";function E(i="openai-api"){return{label:i==="openai-codex"?"OpenAI Codex":i==="openai-compatible"?"Local compatible endpoint":i==="mock"?"Workbench mock runtime":"OpenAI API",provider:i,baseUrl:i==="openai-codex"?"https://chatgpt.com/backend-api":i==="openai-compatible"?"http://127.0.0.1:11434/v1":i==="mock"?"mock://workbench":"https://api.openai.com/v1",model:i==="mock"?"mock-echo":"gpt-5.4-mini",apiKey:""}}function Te(i){return{id:i.id,label:i.label,provider:i.provider,baseUrl:i.baseUrl,model:i.model,apiKey:""}}function ea(){var ie,te,ne,re,de;const i=we(),[s,x]=n.useState(()=>E()),[K,F]=n.useState(""),[U,_]=n.useState("gpt-5.4-mini"),[z,$]=n.useState(""),[B,W]=n.useState("gpt-5.4-mini"),[A,me]=n.useState("Fast wiki search"),[S,ge]=n.useState("text-embedding-3-small"),[q,he]=n.useState("https://api.openai.com/v1"),[Q,T]=n.useState(""),[R,xe]=n.useState("1200"),[D,pe]=n.useState("200"),[O,y]=n.useState(""),[c,N]=n.useState(null),[G,v]=n.useState(null),u=I({queryKey:["forge-settings"],queryFn:ze}),C=I({queryKey:["forge-wiki-settings"],queryFn:$e}),ve=I({queryKey:["forge-openai-codex-oauth",c],queryFn:async()=>{if(!c)throw new Error("Missing OAuth session id");return await Be(c)},enabled:!!c,refetchInterval:a=>{var oe;const r=(oe=a.state.data)==null?void 0:oe.session.status;return r&&["authorized","error","consumed","expired"].includes(r)?!1:1500}}),f=async()=>{await i.invalidateQueries({queryKey:["forge-settings"]}),await i.invalidateQueries({queryKey:["forge-wiki-settings"]}),await i.invalidateQueries({queryKey:["forge-wiki-search"]}),await i.invalidateQueries({queryKey:["forge-openai-codex-oauth",c]})},H=h({mutationFn:()=>Me({modelSettings:{forgeAgent:{basicChat:{connectionId:K||null,model:U},wiki:{connectionId:z||null,model:B}}}}),onSuccess:f}),Z=h({mutationFn:()=>Fe({id:s.id,label:s.label,provider:s.provider,authMode:s.provider==="openai-codex"?"oauth":"api_key",baseUrl:s.baseUrl,model:s.model,apiKey:s.provider==="openai-codex"?void 0:s.apiKey||void 0,oauthSessionId:s.provider==="openai-codex"?c??void 0:void 0}),onSuccess:async()=>{v("Connection saved."),s.provider==="openai-codex"&&(N(null),y("")),x(E(s.provider)),await f()},onError:a=>{v(a instanceof Error?a.message:"Connection save failed.")}}),J=h({mutationFn:_e,onSuccess:f}),V=h({mutationFn:()=>Le({label:A.trim(),model:S.trim(),baseUrl:q.trim(),apiKey:Q.trim()||void 0,chunkSize:Number(R),chunkOverlap:Number(D)}),onSuccess:async()=>{T(""),await f()}}),X=h({mutationFn:a=>Pe("embedding",a),onSuccess:f}),Y=h({mutationFn:async()=>Ue({connectionId:s.id,provider:s.provider,baseUrl:s.baseUrl,model:s.model,apiKey:s.provider==="openai-codex"?void 0:s.apiKey||void 0}),onSuccess:({result:a})=>{v(`Connection test succeeded: ${a.outputPreview}`)},onError:a=>{v(a instanceof Error?a.message:"Connection test failed.")}}),ee=h({mutationFn:Ee,onSuccess:({session:a})=>{N(a.id),v("OpenAI Codex OAuth started."),a.authUrl&&window.open(a.authUrl,"_blank","noopener,noreferrer")}}),ae=h({mutationFn:async()=>{if(!c)throw new Error("No OAuth session started yet.");return await Ke(c,O)},onSuccess:({session:a})=>{v(a.status==="authorized"?"OpenAI Codex OAuth authorized.":"Manual OAuth code submitted.")}});n.useEffect(()=>{var r;const a=(r=u.data)==null?void 0:r.settings;a&&(F(a.modelSettings.forgeAgent.basicChat.connectionId??""),_(a.modelSettings.forgeAgent.basicChat.model),$(a.modelSettings.forgeAgent.wiki.provider==="openai-codex"?a.modelSettings.forgeAgent.wiki.connectionId??"":""),W(a.modelSettings.forgeAgent.wiki.model))},[u.data]);const p=((ie=u.data)==null?void 0:ie.settings.modelSettings.connections)??[],se=p.filter(a=>a.provider==="openai-codex"&&a.authMode==="oauth"),be=se.filter(a=>a.hasStoredCredential),t=((te=ve.data)==null?void 0:te.session)??null,b=s.id?p.find(a=>a.id===s.id):null,je=n.useMemo(()=>!s.label.trim()||!s.model.trim()?!1:s.provider==="openai-codex"?!!((t==null?void 0:t.status)==="authorized"||s.id&&(b!=null&&b.hasStoredCredential)):s.provider==="mock"?!0:s.apiKey.trim().length>0||!!s.id,[s,b==null?void 0:b.hasStoredCredential,t==null?void 0:t.status]);if(u.isLoading)return e.jsx(Oe,{eyebrow:"Models",title:"Loading model settings",description:"Fetching Forge agent defaults and configured AI connections."});if(u.isError||!((ne=u.data)!=null&&ne.settings))return e.jsx(Ie,{eyebrow:"Models",error:u.error??new Error("Forge returned an empty model settings payload."),onRetry:()=>void u.refetch()});const k=u.data.settings;return e.jsxs("div",{className:"mx-auto grid min-w-0 w-full max-w-[1440px] gap-5",children:[e.jsx(Se,{eyebrow:"AI runtime",title:"Model Settings",description:"Manage Forge Agent defaults, OpenAI OAuth/API connections, and local OpenAI-compatible endpoints as first-class chat agents.",badge:`${p.length} model connection${p.length===1?"":"s"}`}),e.jsx(Ae,{}),e.jsxs(w,{className:"grid gap-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:j,children:"Forge Agent defaults"}),e.jsx("div",{className:`text-xs leading-5 ${m}`,children:"Forge Agent stays the default system agent. Choose which model connection powers basic chat and the managed wiki workflow."})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("label",{className:ue,children:[e.jsx("span",{className:`text-sm ${L}`,children:"Basic chat connection"}),e.jsxs("select",{className:d,value:K,onChange:a=>F(a.target.value),children:[e.jsx("option",{value:"",children:"No external connection"}),p.map(a=>e.jsxs("option",{value:a.id,children:[a.label," (",a.agentLabel,")"]},a.id))]}),e.jsx("input",{className:d,value:U,onChange:a=>_(a.target.value),placeholder:"Model"})]}),e.jsxs("label",{className:ue,children:[e.jsx("span",{className:`text-sm ${L}`,children:"KarpaWiki Codex OAuth connection"}),e.jsxs("select",{className:d,value:z,onChange:a=>$(a.target.value),children:[e.jsx("option",{value:"",children:"No Codex OAuth connection"}),se.map(a=>e.jsxs("option",{value:a.id,disabled:!a.hasStoredCredential,children:[a.label," (",a.accountLabel??a.agentLabel,")",a.hasStoredCredential?"":" · needs OAuth"]},a.id))]}),e.jsx("input",{className:d,value:B,onChange:a=>W(a.target.value),placeholder:"Model"}),e.jsx("span",{className:`text-xs leading-5 ${m}`,children:"KarpaWiki smart ingest uses ChatGPT/Codex OAuth only. It does not use metered OpenAI Platform API keys."})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(o,{pending:H.isPending,pendingLabel:"Saving defaults",onClick:()=>void H.mutateAsync(),children:"Save Forge Agent defaults"}),e.jsxs(l,{className:g,children:["Forge Agent",k.modelSettings.forgeAgent.basicChat.connectionLabel?` basic chat: ${k.modelSettings.forgeAgent.basicChat.connectionLabel}`:" basic chat stays local"]}),e.jsx(l,{className:g,children:k.modelSettings.forgeAgent.wiki.connectionLabel?`KarpaWiki OAuth: ${k.modelSettings.forgeAgent.wiki.connectionLabel}`:"KarpaWiki: no Codex OAuth model selected"}),be.length===0?e.jsx(l,{className:qe,children:"Add OpenAI Codex OAuth before smart ingest"}):null]})]}),e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fe,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:j,children:"KarpaWiki embeddings"}),e.jsx("div",{className:`text-xs leading-5 ${m}`,children:"Semantic search profiles live with model settings. They remain optional; KarpaWiki text search and entity-linked search still work without embeddings."})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-3",children:[C.isLoading?e.jsx("div",{className:P,children:"Loading embedding profiles."}):null,C.isError?e.jsx("div",{className:Qe,children:"Could not load KarpaWiki embedding profiles."}):null,((re=C.data)==null?void 0:re.settings.embeddingProfiles.length)===0?e.jsx("div",{className:P,children:"No embedding profile yet. Add one only if you want semantic wiki search in addition to exact search and links."}):null,(de=C.data)==null?void 0:de.settings.embeddingProfiles.map(a=>e.jsxs("div",{className:"grid min-w-0 gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-[var(--ui-ink-strong)]",children:a.label}),e.jsxs("div",{className:`mt-1 break-words text-xs [overflow-wrap:anywhere] ${m}`,children:[a.model," · ",a.baseUrl]})]}),e.jsx(o,{variant:"secondary",pending:X.isPending,pendingLabel:"Deleting",onClick:()=>void X.mutateAsync(a.id),children:e.jsx(ce,{className:"size-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(l,{className:g,children:["chunk ",a.chunkSize]}),e.jsxs(l,{className:g,children:["overlap ",a.chunkOverlap]}),e.jsx(l,{className:g,children:a.enabled?"enabled":"disabled"})]})]},a.id))]}),e.jsxs("div",{className:M,children:[e.jsx("input",{className:d,value:A,onChange:a=>me(a.target.value),placeholder:"Profile label"}),e.jsx("input",{className:d,value:S,onChange:a=>ge(a.target.value),placeholder:"Embedding model"}),e.jsx("input",{className:d,value:q,onChange:a=>he(a.target.value),placeholder:"Embedding base URL"}),e.jsx("input",{className:d,value:Q,onChange:a=>T(a.target.value),placeholder:"Embedding API key (optional)",type:"password"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("input",{className:d,value:R,onChange:a=>xe(a.target.value),placeholder:"Chunk size",type:"number"}),e.jsx("input",{className:d,value:D,onChange:a=>pe(a.target.value),placeholder:"Chunk overlap",type:"number"})]}),e.jsx(o,{pending:V.isPending,pendingLabel:"Saving",disabled:!A.trim()||!S.trim(),onClick:()=>void V.mutateAsync(),children:"Save embedding profile"})]})]})]}),e.jsxs("div",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ke,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:j,children:"Connection editor"}),e.jsx("div",{className:`text-xs leading-5 ${m}`,children:"Every saved connection becomes a first-class agent layered on top of Forge Agent."})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:We,children:"Provider"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:[["openai-api","OpenAI API"],["openai-codex","OpenAI Codex OAuth"],["openai-compatible","OpenAI-compatible"]].map(([a,r])=>e.jsx("button",{type:"button",className:`rounded-[18px] px-4 py-3 text-left text-sm transition ${s.provider===a?"border border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>{x(E(a)),N(null),y("")},children:r},a))})]}),e.jsx("input",{className:d,value:s.label,onChange:a=>x(r=>({...r,label:a.target.value})),placeholder:"Connection label"}),e.jsx("input",{className:d,value:s.model,onChange:a=>x(r=>({...r,model:a.target.value})),placeholder:"Model"}),s.provider==="mock"?e.jsxs("div",{className:M,children:[e.jsx("div",{className:j,children:"The Workbench mock runtime is only meant for local development and test workflows."}),e.jsxs("div",{className:`text-xs leading-5 ${m}`,children:["Use mock models like ",e.jsx("code",{children:"mock-echo"}),","," ",e.jsx("code",{children:"mock-json"}),",",e.jsx("code",{children:"mock-tool-search"}),","," ",e.jsx("code",{children:"mock-tool-note"}),", or",e.jsx("code",{children:"mock-chat-memory"})," to exercise deterministic flow behavior without a real external model."]})]}):s.provider!=="openai-codex"?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:d,value:s.baseUrl,onChange:a=>x(r=>({...r,baseUrl:a.target.value})),placeholder:"Base URL"}),e.jsx("input",{className:d,value:s.apiKey,onChange:a=>x(r=>({...r,apiKey:a.target.value})),placeholder:s.id?"Leave blank to keep the stored key":"API key",type:"password"})]}):e.jsxs("div",{className:M,children:[e.jsxs("div",{className:j,children:["OpenAI Codex uses the documented PKCE flow with the local callback at"," ",e.jsx("span",{className:"break-words [overflow-wrap:anywhere]",children:k.modelSettings.oauth.openAiCodex.callbackUrl})]}),e.jsx("div",{className:`text-xs leading-5 ${m}`,children:"Start OAuth, finish the browser sign-in, then save the resulting connection as a chat agent backed by the ChatGPT Codex runtime."}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(o,{variant:"secondary",pending:ee.isPending,pendingLabel:"Starting OAuth",onClick:()=>void ee.mutateAsync(),children:[e.jsx(ye,{className:"size-4"}),"Start OAuth"]}),t!=null&&t.authUrl?e.jsxs(o,{variant:"secondary",onClick:()=>window.open(t.authUrl??"","_blank","noopener,noreferrer"),children:["Open sign-in",e.jsx(Ne,{className:"size-4"})]}):null]}),t?e.jsxs("div",{className:"grid min-w-0 gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] p-3 text-sm text-[var(--ui-code-text)]",children:[e.jsxs("div",{children:["Status: ",t.status]}),t.accountLabel?e.jsxs("div",{children:["Account: ",t.accountLabel]}):null,t.error?e.jsx("div",{className:"text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:t.error}):null]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("input",{className:d,value:O,onChange:a=>y(a.target.value),placeholder:"Paste the authorization code or full redirect URL"}),e.jsx(o,{variant:"secondary",disabled:!O.trim()||!c,pending:ae.isPending,pendingLabel:"Submitting",onClick:()=>void ae.mutateAsync(),children:"Submit manual code"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(o,{pending:Z.isPending,pendingLabel:"Saving connection",disabled:!je,onClick:()=>void Z.mutateAsync(),children:"Save connection"}),e.jsxs(o,{variant:"secondary",pending:Y.isPending,pendingLabel:"Testing",disabled:s.provider==="openai-codex"?!s.id:s.provider==="mock"?!1:!s.id&&!s.apiKey.trim(),onClick:()=>void Y.mutateAsync(),children:[e.jsx(Ce,{className:"size-4"}),"Test connection"]})]}),G?e.jsx("div",{className:`rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm ${L}`,children:G}):null]})]}),e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:j,children:"Connected agents"}),e.jsx("div",{className:`text-xs leading-5 ${m}`,children:"Each connection registers its own chat-facing agent identity."})]})]}),e.jsxs("div",{className:"grid gap-3",children:[p.length===0?e.jsx("div",{className:P,children:"No external model connection yet. Add one with OAuth or API credentials and Forge will expose it as a first-class agent."}):null,p.map(a=>e.jsxs("div",{className:"grid min-w-0 gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:a.label}),e.jsxs("div",{className:`mt-1 break-words text-xs [overflow-wrap:anywhere] ${m}`,children:[a.agentLabel," · ",a.provider," ·"," ",a.model]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{variant:"secondary",onClick:()=>{x(Te(a)),N(null),y("")},children:"Edit"}),e.jsx(o,{variant:"secondary",pending:J.isPending,pendingLabel:"Deleting",onClick:()=>void J.mutateAsync(a.id),children:e.jsx(ce,{className:"size-4"})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{className:g,children:a.authMode==="oauth"?"OAuth":"API key"}),e.jsx(l,{className:g,children:a.status}),e.jsx(l,{className:g,wrap:!0,children:a.baseUrl}),a.accountLabel?e.jsx(l,{className:g,wrap:!0,children:a.accountLabel}):null]})]},a.id))]})]})]})]})}export{ea as SettingsModelsPage};