forge-openclaw-plugin 0.3.17 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/assets/{action-bar-D3CEYlj4.js → action-bar-BAZevCEA.js} +1 -1
  2. package/dist/assets/{activity-page-Ce1pHIu5.js → activity-page-CnT_hnCU.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-DEliwOjF.js → ai-surface-workspace-GPZzIIut.js} +1 -1
  4. package/dist/assets/artifacts-page-Bqjp0L-L.js +2 -0
  5. package/dist/assets/{atlas-panel-VZOnJa1c.js → atlas-panel-B95nrYpZ.js} +1 -1
  6. package/dist/assets/{board-DprRipIG.js → board-CGgOvBP9.js} +1 -1
  7. package/dist/assets/{calendar-page-Zstsn4uG.js → calendar-page-mlr94wIS.js} +1 -1
  8. package/dist/assets/{calendar-rules-BGIBuEDk.js → calendar-rules-DdxPmBZJ.js} +1 -1
  9. package/dist/assets/{calendar-week-toolbar-DXFkMkbq.js → calendar-week-toolbar-Cu8V6zv1.js} +1 -1
  10. package/dist/assets/{charts-C5S0-BL7.js → charts-Cdtn55ol.js} +1 -1
  11. package/dist/assets/{companion-sync-lab-page-DIPPLFKt.js → companion-sync-lab-page-CJI5jf8W.js} +1 -1
  12. package/dist/assets/{daily-metrics-dashboard-CG-OOCJz.js → daily-metrics-dashboard-CXESx7bU.js} +1 -1
  13. package/dist/assets/{define-workbench-box-BEEdtBkQ.js → define-workbench-box-Dbl9W7oE.js} +1 -1
  14. package/dist/assets/{entity-link-multiselect-BfDAROHB.js → entity-link-multiselect-DZ_jAjs4.js} +1 -1
  15. package/dist/assets/{entity-note-count-link-BGOiaash.js → entity-note-count-link-FOK_qhcC.js} +1 -1
  16. package/dist/assets/{entity-notes-surface-DPsJwqQa.js → entity-notes-surface-Dq9dFKjD.js} +1 -1
  17. package/dist/assets/{execution-board-Dg-2GSKv.js → execution-board-D9hkXKC2.js} +1 -1
  18. package/dist/assets/{faceted-token-search-DV7MSVYb.js → faceted-token-search-BeShxjkc.js} +1 -1
  19. package/dist/assets/{flagship-signal-deck-D3wVL3bC.js → flagship-signal-deck-DZx_HEH9.js} +1 -1
  20. package/dist/assets/{floating-action-menu-BUs382px.js → floating-action-menu-CFrgvQJi.js} +1 -1
  21. package/dist/assets/{forms-ByKjodjN.js → forms-DhEGHkFR.js} +1 -1
  22. package/dist/assets/{generic-node-view-BY5dbPXJ.js → generic-node-view-C1kLClIm.js} +1 -1
  23. package/dist/assets/{goal-detail-page-MYr6j2B4.js → goal-detail-page-BhMrnVQs.js} +1 -1
  24. package/dist/assets/{goal-dialog-nkdME5Uy.js → goal-dialog-BlZHh3dw.js} +1 -1
  25. package/dist/assets/{goals-page-BsFeBzU1.js → goals-page-CesC8IkZ.js} +1 -1
  26. package/dist/assets/{graph-CHVj0Z7n.js → graph-U1J6VkbG.js} +1 -1
  27. package/dist/assets/{habits-page-wO461EVU.js → habits-page-DHxZSThT.js} +1 -1
  28. package/dist/assets/{health-boxes-BphMeSJj.js → health-boxes-BZjIqiiG.js} +1 -1
  29. package/dist/assets/index-CHbe1sy1.css +1 -0
  30. package/dist/assets/{index-gmPaoLN-.js → index-Dj8q65se.js} +2 -2
  31. package/dist/assets/{inline-note-fields-BvQwmMAv.js → inline-note-fields-DpmCMAJf.js} +1 -1
  32. package/dist/assets/{insight-flow-dialog-H_eaOmst.js → insight-flow-dialog-DNIe0sts.js} +1 -1
  33. package/dist/assets/{insights-page-DINYe3cB.js → insights-page-D_N_MWGu.js} +1 -1
  34. package/dist/assets/{kanban-boxes-oACOTDYG.js → kanban-boxes-DTDG5UEJ.js} +1 -1
  35. package/dist/assets/{kanban-page-BGLXH91f.js → kanban-page-DEvIY5IW.js} +1 -1
  36. package/dist/assets/{knowledge-graph-page-VfMvw5jL.js → knowledge-graph-page-CvXSnnG5.js} +1 -1
  37. package/dist/assets/{life-force-page-DQPb6UL-.js → life-force-page-CgvUrqQb.js} +1 -1
  38. package/dist/assets/{life-force-workspace-BJ1aI3JE.js → life-force-workspace-BNeMbRHf.js} +1 -1
  39. package/dist/assets/{maps-CvEHVkBk.js → maps-Dk9tZqTA.js} +1 -1
  40. package/dist/assets/{metric-tile-CbEe19Gd.js → metric-tile-DAhX60rg.js} +1 -1
  41. package/dist/assets/{motion-BibSzp57.js → motion-DeJZhOSA.js} +1 -1
  42. package/dist/assets/{movement-boxes-dtDYhw5c.js → movement-boxes-BOqU18NH.js} +1 -1
  43. package/dist/assets/{movement-page-BhmwCHjs.js → movement-page-DCDeUynh.js} +1 -1
  44. package/dist/assets/{note-markdown-CG8u2d6p.js → note-markdown-Cxj84-0j.js} +1 -1
  45. package/dist/assets/{note-tags-input-D_conqDO.js → note-tags-input-CP0-EPpE.js} +1 -1
  46. package/dist/assets/{notes-boxes-BLKucFqW.js → notes-boxes-C7WPT7mf.js} +1 -1
  47. package/dist/assets/{notes-page-CafVxWjb.js → notes-page-Dll8PIks.js} +1 -1
  48. package/dist/assets/{open-in-graph-button-DFQ4r6SN.js → open-in-graph-button-BHl16hJP.js} +1 -1
  49. package/dist/assets/{orbit-map-DsEl3ori.js → orbit-map-De0qpMpY.js} +1 -1
  50. package/dist/assets/{overview-page-BffcX-pM.js → overview-page-C1RX7dcq.js} +1 -1
  51. package/dist/assets/{page-hero-U603l9rQ.js → page-hero-DYmFM6-q.js} +1 -1
  52. package/dist/assets/pill-cluster-ClkmFVFT.js +1 -0
  53. package/dist/assets/{preference-entity-handoff-button-cPrTpHsV.js → preference-entity-handoff-button-1XXtBsUF.js} +1 -1
  54. package/dist/assets/{preferences-page-DQjFIOmt.js → preferences-page-OwfPIQwe.js} +1 -1
  55. package/dist/assets/{project-collections-B9OGHGqm.js → project-collections-DfmkBk9d.js} +1 -1
  56. package/dist/assets/{project-detail-page-r1Sw2kcO.js → project-detail-page-BC_MNaca.js} +1 -1
  57. package/dist/assets/{project-dialog-B2_PcXAf.js → project-dialog-BuZdXECa.js} +1 -1
  58. package/dist/assets/{project-management-hierarchy-page-qLNG8hsh.js → project-management-hierarchy-page-AhEHe60K.js} +1 -1
  59. package/dist/assets/{project-management-section-nav-DFUlmMEB.js → project-management-section-nav-CnaseOqL.js} +1 -1
  60. package/dist/assets/{projects-boxes-BA7_XaqX.js → projects-boxes-D0zM8PfY.js} +1 -1
  61. package/dist/assets/{projects-page-B6ggXWFw.js → projects-page-ltrWfLrA.js} +1 -1
  62. package/dist/assets/{psyche-behaviors-page-ByWpXlLq.js → psyche-behaviors-page-CPurgDg6.js} +1 -1
  63. package/dist/assets/{psyche-flashcards-page-B9nSc0mk.js → psyche-flashcards-page-DnUSe-bb.js} +1 -1
  64. package/dist/assets/{psyche-goal-map-page-BQU7qI88.js → psyche-goal-map-page-uWocO7kZ.js} +1 -1
  65. package/dist/assets/{psyche-graph-DCeP7r2b.js → psyche-graph-BDszV3UN.js} +1 -1
  66. package/dist/assets/{psyche-metrics-page-DD2lOP-J.js → psyche-metrics-page-CIJLJTPy.js} +1 -1
  67. package/dist/assets/{psyche-mode-guide-page-DbtZgnjr.js → psyche-mode-guide-page-uC8L4WvH.js} +1 -1
  68. package/dist/assets/{psyche-modes-page-3zFJWFQf.js → psyche-modes-page-CtBeRA_3.js} +1 -1
  69. package/dist/assets/{psyche-page-D5vXYkfB.js → psyche-page-Ds3QDsin.js} +1 -1
  70. package/dist/assets/{psyche-patterns-page-BneAAeKS.js → psyche-patterns-page-Cvq5WshW.js} +1 -1
  71. package/dist/assets/{psyche-questionnaire-builder-page-BH1la5C9.js → psyche-questionnaire-builder-page-Cg5Upe6z.js} +1 -1
  72. package/dist/assets/{psyche-questionnaire-detail-page-DYav634P.js → psyche-questionnaire-detail-page-D4jEnNoh.js} +1 -1
  73. package/dist/assets/{psyche-questionnaire-run-detail-page-9VaijhJm.js → psyche-questionnaire-run-detail-page-CWoZEY31.js} +1 -1
  74. package/dist/assets/{psyche-questionnaire-run-page-e1T6k_dS.js → psyche-questionnaire-run-page-Yg_VG2vq.js} +1 -1
  75. package/dist/assets/{psyche-questionnaires-page-Dyv367z9.js → psyche-questionnaires-page-BqeOJRj7.js} +1 -1
  76. package/dist/assets/{psyche-report-detail-page-hqxHIXw2.js → psyche-report-detail-page-BtcMQ7mk.js} +1 -1
  77. package/dist/assets/{psyche-reports-page-DhIfcGbt.js → psyche-reports-page-tagvW0To.js} +1 -1
  78. package/dist/assets/{psyche-schemas-Cg51Ztxz.js → psyche-schemas-CvRSkI_u.js} +1 -1
  79. package/dist/assets/{psyche-schemas-beliefs-page-Dgb5o9vx.js → psyche-schemas-beliefs-page-4NL3415v.js} +1 -1
  80. package/dist/assets/{psyche-screen-time-page-D6MnJGNa.js → psyche-screen-time-page-Bc5AwZHQ.js} +1 -1
  81. package/dist/assets/{psyche-self-observation-page-C1Vyezbv.js → psyche-self-observation-page-CUrUYbQ_.js} +1 -1
  82. package/dist/assets/{psyche-values-page-B_JWVw1Q.js → psyche-values-page-BshT2sXE.js} +1 -1
  83. package/dist/assets/{question-flow-dialog-yMYVk998.js → question-flow-dialog-CPyXCqA-.js} +1 -1
  84. package/dist/assets/{report-chain-fields-D4NM9a6I.js → report-chain-fields-C0UMLpze.js} +1 -1
  85. package/dist/assets/{rewards-page-B5-bcL4R.js → rewards-page-D9BzsNPW.js} +1 -1
  86. package/dist/assets/{scheduling-rules-editor-De72IUax.js → scheduling-rules-editor-DiA6KkQ4.js} +1 -1
  87. package/dist/assets/{schema-badge-jX28kUa6.js → schema-badge-DURw2eYH.js} +1 -1
  88. package/dist/assets/{schemas-BlFy-uPR.js → schemas-D_z2C8l1.js} +1 -1
  89. package/dist/assets/{select-menu-BXv1rsVc.js → select-menu-BUB8__Nx.js} +1 -1
  90. package/dist/assets/{settings-agents-page-DN_np10S.js → settings-agents-page-Kk98Whcf.js} +1 -1
  91. package/dist/assets/{settings-bin-page-BM5BpK_i.js → settings-bin-page-BnJ-mgy2.js} +1 -1
  92. package/dist/assets/{settings-calendar-page-Cg0gSSFs.js → settings-calendar-page-CdhlUnUW.js} +3 -3
  93. package/dist/assets/{settings-data-page-Dwmp2rLy.js → settings-data-page-BvvuZNbb.js} +1 -1
  94. package/dist/assets/{settings-logs-page-DQNM21Re.js → settings-logs-page-CrzkXxtZ.js} +1 -1
  95. package/dist/assets/{settings-mobile-page-DQdiRa-a.js → settings-mobile-page-Dl582NK6.js} +1 -1
  96. package/dist/assets/{settings-models-page-CAEPpuHF.js → settings-models-page-COoBw28S.js} +1 -1
  97. package/dist/assets/{settings-page-Cl2KiCFg.js → settings-page-DqnlOCgo.js} +1 -1
  98. package/dist/assets/{settings-rewards-page-DoIUumhe.js → settings-rewards-page-Cw5QSTjy.js} +1 -1
  99. package/dist/assets/{settings-section-nav-D_N87IG0.js → settings-section-nav-C1NcWveT.js} +1 -1
  100. package/dist/assets/{settings-users-page-CPesR62N.js → settings-users-page-0opvepcM.js} +1 -1
  101. package/dist/assets/{settings-wiki-page-BxMQM5Vi.js → settings-wiki-page-CkpnUkiZ.js} +1 -1
  102. package/dist/assets/{sleep-page-DUYmQKrg.js → sleep-page-DrS1zs3B.js} +1 -1
  103. package/dist/assets/{sports-page-Bzi5TF9T.js → sports-page-EVnB_zjB.js} +1 -1
  104. package/dist/assets/{state-BFyKSULP.js → state-DWw8Jay_.js} +1 -1
  105. package/dist/assets/{strategies-page-C-T2MZx4.js → strategies-page-COhyv_SH.js} +1 -1
  106. package/dist/assets/{strategy-detail-page-3tYuSZu-.js → strategy-detail-page-BaCVkvIu.js} +1 -1
  107. package/dist/assets/{strategy-dialog-BWm4slo4.js → strategy-dialog-DvlPo9WV.js} +1 -1
  108. package/dist/assets/{surface-BJObZeRw.js → surface-Dg5fauKP.js} +1 -1
  109. package/dist/assets/{table-CTLroJKN.js → table-CWVROEBP.js} +1 -1
  110. package/dist/assets/{task-detail-page-ZZOXSpSF.js → task-detail-page-3IeMYIXl.js} +1 -1
  111. package/dist/assets/{task-dialog-2wy0xI7f.js → task-dialog-B7ZT4KE5.js} +1 -1
  112. package/dist/assets/{timebox-planning-dialog-C6h0Hp71.js → timebox-planning-dialog-DoZzpEBp.js} +1 -1
  113. package/dist/assets/{today-boxes-B_TdgSDz.js → today-boxes-BbUNpb16.js} +1 -1
  114. package/dist/assets/today-page-adKXN2g1.js +1 -0
  115. package/dist/assets/{training-load-page-B78e1-o-.js → training-load-page-DTYbu9f0.js} +1 -1
  116. package/dist/assets/{ui-uo_bNP7c.js → ui-CdEDMtXF.js} +1 -1
  117. package/dist/assets/{use-anchored-overlay-position-BSxFX6Hi.js → use-anchored-overlay-position-Cracjgo6.js} +1 -1
  118. package/dist/assets/{use-psyche-focus-target-1GLkhYiv.js → use-psyche-focus-target-DvRgu-94.js} +1 -1
  119. package/dist/assets/{user-badge-C4eZu1e_.js → user-badge-B8hYK6NU.js} +1 -1
  120. package/dist/assets/{user-select-field-CmKwcbZt.js → user-select-field-akGHK-2t.js} +1 -1
  121. package/dist/assets/{utility-widgets-B06wQFrd.js → utility-widgets-D4KsKxLT.js} +2 -2
  122. package/dist/assets/{vendor-B7FKSwHK.js → vendor-y_uz1Wft.js} +1 -1
  123. package/dist/assets/{vitals-page-BC7QFsm2.js → vitals-page-Cjcxh-kO.js} +1 -1
  124. package/dist/assets/{weekly-review-page-BjNsNoWj.js → weekly-review-page-CR57efzH.js} +1 -1
  125. package/dist/assets/{weight-loss-page-BOahGY9r.js → weight-loss-page-Bk7YkB7b.js} +1 -1
  126. package/dist/assets/{wiki-article-markdown-DO47HnZf.js → wiki-article-markdown-um6gpmGQ.js} +1 -1
  127. package/dist/assets/{wiki-editor-page-OWRUHl4O.js → wiki-editor-page-DdP5hvjZ.js} +3 -3
  128. package/dist/assets/{wiki-ingest-history-page-CuHpg2lZ.js → wiki-ingest-history-page-DSTndduq.js} +1 -1
  129. package/dist/assets/{wiki-ingest-modal-EZ3kX-vA.js → wiki-ingest-modal-PNW3CJ-o.js} +1 -1
  130. package/dist/assets/{wiki-page-BPV3HIgu.js → wiki-page-CsJlPyQ6.js} +1 -1
  131. package/dist/assets/{workbench-flow-page-C53KueEz.js → workbench-flow-page-DFtIKgNe.js} +1 -1
  132. package/dist/assets/{workbench-page-DJ7nT2JQ.js → workbench-page-DEpKjMEv.js} +1 -1
  133. package/dist/assets/{workout-detail-page-Dhyu0q7o.js → workout-detail-page-BwfEhxA_.js} +2 -2
  134. package/dist/index.html +8 -8
  135. package/dist/server/apps/api/migrations/073_artifact_entity_links_repair.sql +24 -0
  136. package/openclaw.plugin.json +1 -1
  137. package/package.json +1 -1
  138. package/server/migrations/073_artifact_entity_links_repair.sql +24 -0
  139. package/skills/forge-openclaw/entity_conversation_playbooks.md +9 -6
  140. package/dist/assets/artifacts-page-BgyFVIVM.js +0 -2
  141. package/dist/assets/index-CSd8ylsy.css +0 -1
  142. package/dist/assets/pill-cluster-BYVFNppV.js +0 -1
  143. package/dist/assets/today-page-Dipns9tl.js +0 -1
@@ -1 +1 @@
1
- import{b1 as ht,bq as vt,cE as ft,cF as bt,bk as jt,aG as yt,j as e,aK as Nt,b8 as ce,bZ as kt,r as x,aC as ve,c7 as Ct,bY as It}from"./vendor-B7FKSwHK.js";import{j as St,i as Ke,k as N}from"./state-BFyKSULP.js";import{c as U,j as I,I as v,L as Je,h as et,B as u,C as j,d as wt,e as Pt,bB as Ft,T as E,bC as Ye,bD as Lt,bE as Tt,bF as Mt,bG as Dt,bH as At,bI as Et,bJ as zt,bK as _t,bL as Ot,bM as Gt,bN as $t,bO as Bt,bP as qt,bQ as Qt,bR as Rt,bS as Xe}from"./index-gmPaoLN-.js";import{P as Ut}from"./page-hero-U603l9rQ.js";import{U as tt}from"./user-badge-C4eZu1e_.js";import{b as Z,f as Wt,g as Ht}from"./user-ownership-DJGl4rAj.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{value:"projects",label:"Projects",description:"Goals and projects already living in Forge.",mode:"forge"},{value:"tasks",label:"Tasks",description:"Execution-level work choices inside Forge.",mode:"forge"},{value:"strategies",label:"Strategies",description:"Plan shapes and sequencing choices in Forge.",mode:"forge"},{value:"habits",label:"Habits",description:"Recurring behaviors and routines from Forge.",mode:"forge"},{value:"activities",label:"Activities",description:"Movement, leisure, and social setting concepts.",mode:"concept"},{value:"food",label:"Food",description:"Cuisine, meal mood, and drink preferences.",mode:"concept"},{value:"places",label:"Places",description:"Living environments, venues, and trip shapes.",mode:"concept"},{value:"countries",label:"Countries",description:"Country-level attraction and lifestyle fit.",mode:"concept"},{value:"fashion",label:"Fashion",description:"Silhouette, material, and palette preferences.",mode:"concept"},{value:"people",label:"People",description:"Presence, body-type, and conversation preferences.",mode:"concept"},{value:"media",label:"Media",description:"Film, reading, and music taste.",mode:"concept"},{value:"tools",label:"Tools",description:"Workflow and capture preferences.",mode:"concept"},{value:"custom",label:"Custom",description:"General-purpose concept libraries you control.",mode:"concept"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{signalType:"favorite",label:"Favorite"},{signalType:"must_have",label:"Must-have"},{signalType:"bookmark",label:"Bookmark"},{signalType:"compare_later",label:"Later"},{signalType:"neutral",label:"Neutral"},{signalType:"veto",label:"Veto"}];function le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.dashboard.projects.map(a=>({entityType:"project",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/projects/${a.id}`,searchText:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.strategies.map(a=>({entityType:"strategy",entityId:a.id,domain:"strategies",label:a.title,description:a.overview||a.endStateDescription,user:a.user,href:`/strategies/${a.id}`,searchText:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function de(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.summary.totalItems<2?{title:"Forge does not know enough yet.",description:"Start the game so Forge can ask a few clean comparisons and build a real preference model."}:i.summary.averageConfidence<.28?{title:"Forge has a rough sketch, not a stable read.",description:"There is some signal, but the model still needs more rounds before its preferences are trustworthy."}:{title:"This is what Forge currently thinks.",description:"The summary below is the current best model for this user, this domain, and the active context."}}function ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(a+1)/2*100;return e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:a||"Choose the one that feels more right."}),e.jsx("div",{className:"mt-auto text-sm text-[var(--primary)]",children:"Click this card"})]})}function ds({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:O,onJudge:J,onSignal:G}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] md:inset-x-10 lg:left-1/2 lg:right-auto lg:w-[min(72rem,calc(100vw-3rem))] lg:-translate-x-1/2",children:[e.jsx(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{className:"sr-only",children:"Start comparison rounds from a Forge domain or concept list."}),e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(cs,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:O}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:G}):null]})]})]})})}function cs({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Pick the concept list Forge should draw from. You do not need to assemble the items yourself."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.id))})]}):e.jsx(et,{eyebrow:"Preference game",title:"No pair is ready yet",description:"Forge needs more items in this domain before it can keep asking comparisons."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:Wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function Cs(){var qe,Qe,Re;const i=wt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[O,J]=x.useState(""),[G,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.useState({label:"",description:"",tags:"",manualStatus:"",manualScore:"",confidenceLock:"",bookmarked:!1,compareLater:!1,frozen:!1,featureWeights:{novelty:"0",simplicity:"0",rigor:"0",aesthetics:"0",depth:"0",structure:"0",familiarity:"0",surprise:"0"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ht(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(d=>d.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(d=>d&&r.scores.some(n=>n.itemId===d)?d:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var d,n,l;return[((d=s.item)==null?void 0:d.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),c=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,d,n,l,y,X,Q,Ue,We,He;c&&F({label:((t=c.item)==null?void 0:t.label)??"",description:((s=c.item)==null?void 0:s.description)??"",tags:((d=c.item)==null?void 0:d.tags.join(", "))??"",manualStatus:c.manualStatus??"",manualScore:typeof c.manualScore=="number"?String(c.manualScore):"",confidenceLock:typeof c.confidenceLock=="number"?String(c.confidenceLock):"",bookmarked:c.bookmarked,compareLater:c.compareLater,frozen:c.frozen,featureWeights:{novelty:String(((n=c.item)==null?void 0:n.featureWeights.novelty)??0),simplicity:String(((l=c.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=c.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=c.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=c.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=c.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=c.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=c.item)==null?void 0:He.featureWeights.surprise)??0)}})},[c]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],d=le(S);return d?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(d)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Mt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:zt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>_t(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Ot,onSuccess:b}),Le=N({mutationFn:Bt,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Gt(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:$t,onSuccess:b}),dt=N({mutationFn:qt,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),ct=N({mutationFn:Rt,onSuccess:b}),ot=N({mutationFn:Qt,onSuccess:b}),De=N({mutationFn:async()=>{!(c!=null&&c.item)||!m||!r||(await Lt(c.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Tt(c.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:At,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const d=new URLSearchParams(s);return d.set("contextId",t.id),d.set("tab","contexts"),d})}}),Ee=N({mutationFn:Et,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Dt(t,s),onSuccess:b}),A=t=>{g(s=>{const d=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?d.set(n,l):d.delete(n);return d})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),d=re.filter(l=>l.domain===t),n=(s.length>0?s:d).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await dt.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(d){D(d instanceof Error?d.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const d=P.compare.nextPair;await ct.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:d.left.id,rightItemId:d.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,itemId:t,signalType:s,strength:1})};if(!m)return e.jsx(et,{eyebrow:"Preferences",title:"No Forge user available",description:"Forge needs at least one human or bot user before it can learn preferences."});if(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Pt,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Oe=r.scores.filter(t=>de(t)==="liked"||de(t)==="favorite").slice(0,4),Ge=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=c==null?void 0:c.item)==null?void 0:Qe.sourceEntityType)??null,((Re=c==null?void 0:c.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ut,{title:"Preferences",titleText:"Preferences",description:"Forge keeps an explicit, editable model of what one user prefers in one domain. The first job of this page is to show what Forge currently knows.",badge:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Ft,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="overview"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will ask a small number of pairwise questions. You choose a domain, Forge supplies the candidates, and the model tightens from there."}),e.jsx(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{to:"?tab=map",className:"text-sm text-[var(--primary)]",children:"Open full map"})]}),e.jsxs("div",{className:"relative min-h-[340px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(c==null?void 0:c.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-3 py-1 text-xs transition hover:scale-[1.04]",t.itemId===(c==null?void 0:c.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(t.target.value),placeholder:"Search learned items, explanations, tags, or dominant dimensions"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Item"}),e.jsx("th",{className:"px-3 py-2",children:"Score"}),e.jsx("th",{className:"px-3 py-2",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Evidence"})]})}),e.jsx("tbody",{children:he.map(t=>{var s,d;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(c==null?void 0:c.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((d=t.item)==null?void 0:d.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[de(t)],children:de(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),c!=null&&c.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{value:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).map(t=>e.jsxs("div",{className:"grid grid-cols-[110px_minmax(0,1fr)] items-center gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(d=>({...d,featureWeights:{...d.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[["bookmarked","Bookmarked"],["compareLater","Compare later"],["frozen","Frozen"]].map(([t,s])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:f[t],onChange:d=>F(n=>({...n,[t]:d.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,d=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",d]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var d,n;const s=((n=(d=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:d.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="contexts"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_360px]",children:[e.jsx("div",{className:"grid gap-4",children:r.contexts.map(t=>e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{description:s.target.value}}),className:"min-h-20"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:O,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:G,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!O||!G||O===G,onClick:()=>void Ee.mutateAsync({sourceContextId:O,targetContextId:G}),children:"Merge into target"})]})]})]}):null,T==="concepts"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_380px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"These are the lists Forge can use when you start the game in a concept domain. Seeded lists are editable, and custom lists are fully yours."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Lists",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},d=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,description:n.target.value})),className:"min-h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:d.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(null),children:"Cancel"})]})]}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(ds,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{Cs as PreferencesPage};
1
+ import{b1 as ht,bq as vt,cF as ft,cG as bt,bk as jt,aG as yt,j as e,aK as Nt,b8 as ce,bZ as kt,r as x,aC as ve,c1 as Ct,bY as It}from"./vendor-y_uz1Wft.js";import{j as St,i as Ke,k as N}from"./state-DWw8Jay_.js";import{c as U,j as I,I as v,L as Je,h as et,B as u,C as j,d as wt,e as Pt,bB as Ft,T as E,bC as Ye,bD as Lt,bE as Tt,bF as Mt,bG as Dt,bH as At,bI as Et,bJ as zt,bK as _t,bL as Gt,bM as Ot,bN as $t,bO as Bt,bP as qt,bQ as Qt,bR as Rt,bS as Xe}from"./index-Dj8q65se.js";import{P as Ut}from"./page-hero-DYmFM6-q.js";import{U as tt}from"./user-badge-B8hYK6NU.js";import{b as Z,f as Wt,g as Ht}from"./user-ownership-DJGl4rAj.js";import{R as Kt,P as Yt,O as Xt,C as Zt,T as Vt,D as Jt,a as es}from"./ui-CdEDMtXF.js";import"./motion-DeJZhOSA.js";import"./board-CGgOvBP9.js";import"./forms-DhEGHkFR.js";const st=[{id:"overview",label:"Overview",icon:ht},{id:"map",label:"Map",icon:vt},{id:"table",label:"Table",icon:ft},{id:"history",label:"History",icon:bt},{id:"contexts",label:"Contexts",icon:jt},{id:"concepts",label:"Concepts",icon:yt}],ts=new Set(["projects","tasks","strategies","habits"]),oe=[{value:"projects",label:"Projects",description:"Goals and projects already living in Forge.",mode:"forge"},{value:"tasks",label:"Tasks",description:"Execution-level work choices inside Forge.",mode:"forge"},{value:"strategies",label:"Strategies",description:"Plan shapes and sequencing choices in Forge.",mode:"forge"},{value:"habits",label:"Habits",description:"Recurring behaviors and routines from Forge.",mode:"forge"},{value:"activities",label:"Activities",description:"Movement, leisure, and social setting concepts.",mode:"concept"},{value:"food",label:"Food",description:"Cuisine, meal mood, and drink preferences.",mode:"concept"},{value:"places",label:"Places",description:"Living environments, venues, and trip shapes.",mode:"concept"},{value:"countries",label:"Countries",description:"Country-level attraction and lifestyle fit.",mode:"concept"},{value:"fashion",label:"Fashion",description:"Silhouette, material, and palette preferences.",mode:"concept"},{value:"people",label:"People",description:"Presence, body-type, and conversation preferences.",mode:"concept"},{value:"media",label:"Media",description:"Film, reading, and music taste.",mode:"concept"},{value:"tools",label:"Tools",description:"Workflow and capture preferences.",mode:"concept"},{value:"custom",label:"Custom",description:"General-purpose concept libraries you control.",mode:"concept"}],fe={novelty:"Novelty",simplicity:"Simplicity",rigor:"Rigor",aesthetics:"Aesthetics",depth:"Depth",structure:"Structure",familiarity:"Familiarity",surprise:"Surprise"},ne={novelty:0,simplicity:0,rigor:0,aesthetics:0,depth:0,structure:0,familiarity:0,surprise:0},Ze={liked:"bg-[var(--ui-success-soft)] text-[var(--success)]",disliked:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",uncertain:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",vetoed:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",bookmarked:"bg-[var(--ui-info-soft)] text-[var(--info)]",favorite:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",must_have:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",neutral:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"},ss=[{signalType:"favorite",label:"Favorite"},{signalType:"must_have",label:"Must-have"},{signalType:"bookmark",label:"Bookmark"},{signalType:"compare_later",label:"Later"},{signalType:"neutral",label:"Neutral"},{signalType:"veto",label:"Veto"}];function le(i){return i.trim().toLowerCase()}function R(i){return`${Math.round(i*100)}%`}function as(i){return[...i.goals.map(a=>({entityType:"goal",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/goals/${a.id}`,searchText:Z([a.title,a.description,a.status,a.horizon],a)})),...i.dashboard.projects.map(a=>({entityType:"project",entityId:a.id,domain:"projects",label:a.title,description:a.description,user:a.user,href:`/projects/${a.id}`,searchText:Z([a.title,a.description,a.status,a.goalTitle],a)})),...i.tasks.map(a=>({entityType:"task",entityId:a.id,domain:"tasks",label:a.title,description:a.description,user:a.user,href:`/tasks/${a.id}`,searchText:Z([a.title,a.description,a.status,a.priority,a.owner],a)})),...i.strategies.map(a=>({entityType:"strategy",entityId:a.id,domain:"strategies",label:a.title,description:a.overview||a.endStateDescription,user:a.user,href:`/strategies/${a.id}`,searchText:Z([a.title,a.overview,a.endStateDescription,a.status],a)})),...i.habits.map(a=>({entityType:"habit",entityId:a.id,domain:"habits",label:a.title,description:a.description,user:a.user,href:null,searchText:Z([a.title,a.description,a.status,a.frequency],a)}))]}function is(i,a){return!i||!a?null:i==="goal"?`/goals/${a}`:i==="project"?`/projects/${a}`:i==="task"?`/tasks/${a}`:i==="strategy"?`/strategies/${a}`:null}function de(i){return i.manualStatus??i.status}function rs(i){return i&&st.some(a=>a.id===i)?i:"overview"}function ns(i){return i.summary.totalItems<2?{title:"Forge does not know enough yet.",description:"Start the game so Forge can ask a few clean comparisons and build a real preference model."}:i.summary.averageConfidence<.28?{title:"Forge has a rough sketch, not a stable read.",description:"There is some signal, but the model still needs more rounds before its preferences are trustworthy."}:{title:"This is what Forge currently thinks.",description:"The summary below is the current best model for this user, this domain, and the active context."}}function ls({summary:i}){const a=Math.max(-1,Math.min(1,i.leaning)),o=(a+1)/2*100;return e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:fe[i.dimensionId]}),e.jsxs("span",{children:[i.movement>.08?"Rising":i.movement<-.08?"Falling":"Stable"," ","· ",R(i.confidence)]})]}),e.jsxs("div",{className:"relative h-2 rounded-full bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-strong)]"}),e.jsx("div",{className:U("absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-strong)]",a>=0?"bg-[var(--success)]":"bg-[var(--danger)]"),style:{left:`${o}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.12em] text-[var(--ui-ink-faint)]",children:[e.jsxs("span",{children:[a>=0?"Leans toward":"Leans away from"," ",fe[i.dimensionId].toLowerCase()]}),e.jsxs("span",{children:["Context ",R(i.contextSensitivity)]})]})]})}function Ve({title:i,description:a,sideLabel:o,onClick:g}){return e.jsxs("button",{type:"button",className:"grid min-h-[220px] gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] hover:bg-[var(--ui-surface-hover)]",onClick:g,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:o}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),e.jsx("div",{className:"max-w-[36ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:a||"Choose the one that feels more right."}),e.jsx("div",{className:"mt-auto text-sm text-[var(--primary)]",children:"Click this card"})]})}function ds({state:i,onOpenChange:a,error:o,loading:g,workspaceLoading:k,activeWorkspace:h,conceptSearchQuery:w,onConceptSearchQueryChange:p,filteredCatalogs:S,onSelectDomain:V,onStartCatalogGame:G,onJudge:J,onSignal:O}){return e.jsx(Kt,{open:i.open,onOpenChange:a,children:e.jsxs(Yt,{children:[e.jsx(Xt,{className:"fixed inset-0 z-40 bg-[var(--ui-overlay-backdrop)] backdrop-blur-xl"}),e.jsxs(Zt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 overflow-y-auto rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] md:inset-x-10 lg:left-1/2 lg:right-auto lg:w-[min(72rem,calc(100vw-3rem))] lg:-translate-x-1/2",children:[e.jsx(Vt,{className:"sr-only",children:"Preference game"}),e.jsx(Jt,{className:"sr-only",children:"Start comparison rounds from a Forge domain or concept list."}),e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-4 border-b border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preference game"}),e.jsx("div",{className:"mt-1 font-display text-2xl text-[var(--ui-ink-strong)]",children:i.phase==="domain"?"Choose a domain":i.phase==="catalog"?"Choose a concept list":"Pick the better fit"})]}),e.jsx(es,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close preference game",className:"rounded-full bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx(Nt,{className:"size-4"})})})]}),e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[o?e.jsx("div",{className:"rounded-[18px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm text-[var(--danger)]",children:o}):null,i.phase==="domain"?e.jsx(cs,{onSelectDomain:V}):null,i.phase==="catalog"?e.jsx(os,{domain:i.domain,query:w,onQueryChange:p,catalogs:S,onStartCatalogGame:G}):null,i.phase==="play"?e.jsx(us,{domain:i.domain,loading:g||k,activeWorkspace:h,onJudge:J,onSignal:O}):null]})]})]})})}function cs({onSelectDomain:i}){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:oe.map(a=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>i(a.value),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:a.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:a.mode==="forge"?"Forge":"Concept"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]},a.value))})}function os({domain:i,query:a,onQueryChange:o,catalogs:g,onStartCatalogGame:k}){return e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Pick the concept list Forge should draw from. You do not need to assemble the items yourself."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(v,{value:a,onChange:h=>o(h.target.value),placeholder:"Search concept lists"})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:g.length>0?g.map(h=>e.jsxs("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-5 py-5 text-left transition hover:border-[color-mix(in_srgb,var(--primary)_30%,transparent)] hover:bg-[var(--ui-accent-soft)]",onClick:()=>k(i,h.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[h.items.length," items"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:h.description||"No description yet."})]},h.id)):e.jsx("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] px-5 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No concept list matches that search yet."})})]})}function us({domain:i,loading:a,activeWorkspace:o,onJudge:g,onSignal:k}){var w;const h=(o==null?void 0:o.compare.nextPair)??null;return a?e.jsx(Je,{eyebrow:"Preference game",title:"Preparing the next round",description:"Forge is lining up comparison candidates."}):h?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:((w=oe.find(p=>p.value===i))==null?void 0:w.label)??i}),e.jsx("span",{children:o==null?void 0:o.selectedContext.name}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[(o==null?void 0:o.compare.pendingCount)??0," queued comparisons"]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(Ve,{title:h.left.label,description:h.left.description,sideLabel:"Left",onClick:()=>g("left",1)}),e.jsx(Ve,{title:h.right.label,description:h.right.description,sideLabel:"Right",onClick:()=>g("right",1)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{onClick:()=>g("left",1),children:"Left"}),e.jsx(u,{onClick:()=>g("right",1),children:"Right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("left",1.75),children:"Strong left"}),e.jsx(u,{variant:"secondary",onClick:()=>g("right",1.75),children:"Strong right"}),e.jsx(u,{variant:"secondary",onClick:()=>g("tie",1),children:"Tie"}),e.jsx(u,{variant:"secondary",onClick:()=>g("skip",1),children:"Skip"})]}),e.jsx("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4 lg:grid-cols-2",children:[h.left,h.right].map(p=>e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:p.label}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Quick signals"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(S=>e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>k(p.id,S.signalType),children:S.label},`${p.id}-${S.signalType}`))})]},p.id))})]}):e.jsx(et,{eyebrow:"Preference game",title:"No pair is ready yet",description:"Forge needs more items in this domain before it can keep asking comparisons."})}function ms({users:i,user:a,selectedUserId:o,selectedDomain:g,workspace:k,onPatchSearch:h}){var w;return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Active user"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("select",{value:o,onChange:p=>h({userId:p.target.value,contextId:null,focusItem:null}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",children:i.map(p=>e.jsxs("option",{value:p.id,children:[p.displayName," · ",p.kind]},p.id))}),e.jsx(tt,{user:a}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:Wt(a)})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Domain"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map(p=>e.jsx("button",{type:"button",className:U("rounded-full border px-3 py-2 text-sm transition",p.value===g?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>h({domain:p.value,contextId:null,focusItem:null}),children:p.label},p.value))}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:(w=oe.find(p=>p.value===g))==null?void 0:w.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:k.selectedContext.name}),e.jsx("span",{children:k.selectedContext.shareMode}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.compare.pendingCount," queued comparisons"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[k.libraries.totalCatalogItems," concept items ready"]})]})]})}function xs({selectedTab:i,onSelectTab:a}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(o=>e.jsxs("button",{type:"button",className:U("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm transition",o.id===i?"border-[var(--primary)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>a(o.id),children:[e.jsx(o.icon,{className:"size-4"}),o.label]},o.id))})}function Cs(){var qe,Qe,Re;const i=wt(),a=St(),[o,g]=kt(),[k,h]=x.useState(""),[w,p]=x.useState(""),[S,V]=x.useState(""),[G,J]=x.useState(""),[O,be]=x.useState(""),[z,M]=x.useState({open:!1,phase:"domain",domain:o.get("domain")??"projects"}),[at,D]=x.useState(null),[it,ue]=x.useState(!1),[je,$]=x.useState(null),[f,F]=x.useState({label:"",description:"",tags:"",manualStatus:"",manualScore:"",confidenceLock:"",bookmarked:!1,compareLater:!1,frozen:!1,featureWeights:{novelty:"0",simplicity:"0",rigor:"0",aesthetics:"0",depth:"0",structure:"0",familiarity:"0",surprise:"0"}}),[_,ee]=x.useState({label:"",description:"",tags:""}),[L,W]=x.useState({name:"",description:"",shareMode:"blended",decayDays:"90"}),[H,me]=x.useState({title:"",description:""}),[rt,te]=x.useState({}),[ye,xe]=x.useState(null),[se,pe]=x.useState({title:"",description:""}),[nt,ge]=x.useState(null),[B,ae]=x.useState({label:"",description:"",tags:""}),m=o.get("userId")??Ht(i.selectedUserIds)??((qe=i.snapshot.users[0])==null?void 0:qe.id)??null,C=o.get("domain")??"projects",T=rs(o.get("tab")),K=o.get("contextId"),ie=o.get("focusItem"),lt=x.useMemo(()=>i.snapshot.users.find(t=>t.id===m)??null,[m,i.snapshot.users]),re=x.useMemo(()=>as(i.snapshot),[i.snapshot]),Y=Ke({queryKey:["forge-preferences",m,C,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:C,contextId:K??void 0})).workspace,enabled:!!m}),Ne=Ke({queryKey:["forge-preferences-game",m,z.domain,K],queryFn:async()=>(await Xe({userId:m??void 0,domain:z.domain,contextId:K??void 0})).workspace,enabled:!!m&&z.open}),r=Y.data??null,P=z.domain===C?r:Ne.data??null;x.useEffect(()=>{var s;if(!r)return;const t=ie&&r.scores.some(d=>d.itemId===ie)?ie:((s=r.scores[0])==null?void 0:s.itemId)??null;$(d=>d&&r.scores.some(n=>n.itemId===d)?d:t)},[ie,r]);const he=x.useMemo(()=>{if(!r)return[];const t=le(k);return t?r.scores.filter(s=>{var d,n,l;return[((d=s.item)==null?void 0:d.label)??"",((n=s.item)==null?void 0:n.description)??"",((l=s.item)==null?void 0:l.tags.join(" "))??"",s.status,s.manualStatus??"",s.dominantDimensions.join(" "),s.explanation.join(" ")].join(" ").toLowerCase().includes(t)}):r.scores},[k,r]),c=he.find(t=>t.itemId===je)??(r==null?void 0:r.scores.find(t=>t.itemId===je))??he[0]??(r==null?void 0:r.scores[0])??null;x.useEffect(()=>{var t,s,d,n,l,y,X,Q,Ue,We,He;c&&F({label:((t=c.item)==null?void 0:t.label)??"",description:((s=c.item)==null?void 0:s.description)??"",tags:((d=c.item)==null?void 0:d.tags.join(", "))??"",manualStatus:c.manualStatus??"",manualScore:typeof c.manualScore=="number"?String(c.manualScore):"",confidenceLock:typeof c.confidenceLock=="number"?String(c.confidenceLock):"",bookmarked:c.bookmarked,compareLater:c.compareLater,frozen:c.frozen,featureWeights:{novelty:String(((n=c.item)==null?void 0:n.featureWeights.novelty)??0),simplicity:String(((l=c.item)==null?void 0:l.featureWeights.simplicity)??0),rigor:String(((y=c.item)==null?void 0:y.featureWeights.rigor)??0),aesthetics:String(((X=c.item)==null?void 0:X.featureWeights.aesthetics)??0),depth:String(((Q=c.item)==null?void 0:Q.featureWeights.depth)??0),structure:String(((Ue=c.item)==null?void 0:Ue.featureWeights.structure)??0),familiarity:String(((We=c.item)==null?void 0:We.featureWeights.familiarity)??0),surprise:String(((He=c.item)==null?void 0:He.featureWeights.surprise)??0)}})},[c]);const ke=x.useMemo(()=>{const t=le(w);return re.filter(s=>s.domain===C).filter(s=>t?s.searchText.includes(t):!0).slice(0,12)},[re,w,C]),Ce=x.useMemo(()=>{const t=T==="concepts"?r:P??r,s=(t==null?void 0:t.catalogs)??[],d=le(S);return d?s.filter(n=>[n.title,n.description,n.source,...n.items.flatMap(l=>[l.label,l.description,l.tags.join(" ")])].join(" ").toLowerCase().includes(d)):s},[P,S,T,r]),b=async()=>{await a.invalidateQueries({queryKey:["forge-preferences"]}),await a.invalidateQueries({queryKey:["forge-preferences-game"]})},Ie=N({mutationFn:Ye,onSuccess:b}),Se=N({mutationFn:Mt,onSuccess:async({item:t})=>{await b(),ee({label:"",description:"",tags:""}),$(t.id)}}),we=N({mutationFn:zt,onSuccess:async()=>{await b(),me({title:"",description:""}),g(t=>{const s=new URLSearchParams(t);return s.set("tab","concepts"),s})}}),Pe=N({mutationFn:({catalogId:t,patch:s})=>_t(t,s),onSuccess:async()=>{await b(),xe(null)}}),Fe=N({mutationFn:Gt,onSuccess:b}),Le=N({mutationFn:Bt,onSuccess:async()=>{await b()}}),Te=N({mutationFn:({catalogItemId:t,patch:s})=>Ot(t,s),onSuccess:async()=>{await b(),ge(null)}}),Me=N({mutationFn:$t,onSuccess:b}),dt=N({mutationFn:qt,onSuccess:async()=>{await b(),M(t=>({...t,phase:"play"}))}}),ct=N({mutationFn:Rt,onSuccess:b}),ot=N({mutationFn:Qt,onSuccess:b}),De=N({mutationFn:async()=>{!(c!=null&&c.item)||!m||!r||(await Lt(c.item.id,{label:f.label,description:f.description,tags:f.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:Object.fromEntries(Object.keys(ne).map(t=>[t,Number(f.featureWeights[t]||0)]))}),await Tt(c.item.id,{userId:m,domain:C,contextId:r.selectedContext.id,manualStatus:f.manualStatus||null,manualScore:f.manualScore.trim().length>0?Number(f.manualScore):null,confidenceLock:f.confidenceLock.trim().length>0?Number(f.confidenceLock):null,bookmarked:f.bookmarked,compareLater:f.compareLater,frozen:f.frozen}))},onSuccess:b}),Ae=N({mutationFn:At,onSuccess:async({context:t})=>{await b(),W({name:"",description:"",shareMode:"blended",decayDays:"90"}),g(s=>{const d=new URLSearchParams(s);return d.set("contextId",t.id),d.set("tab","contexts"),d})}}),Ee=N({mutationFn:Et,onSuccess:async()=>{await b(),J(""),be("")}}),q=N({mutationFn:({contextId:t,patch:s})=>Dt(t,s),onSuccess:b}),A=t=>{g(s=>{const d=new URLSearchParams(s);for(const[n,l]of Object.entries(t))l?d.set(n,l):d.delete(n);return d})},ze=(t=C)=>{D(null),M({open:!0,phase:"domain",domain:t})},ut=async t=>{if(!m)return;D(null),ue(!0);const s=re.filter(l=>{var y;return l.domain===t&&((y=l.user)==null?void 0:y.id)===m}),d=re.filter(l=>l.domain===t),n=(s.length>0?s:d).slice(0,12);if(n.length<2){D("Forge needs at least two matching records in this domain before it can start the game."),ue(!1),M(l=>({...l,phase:"domain"}));return}try{A({domain:t,tab:"overview",contextId:null,focusItem:null}),await Promise.all(n.map(l=>Ye({userId:m,domain:t,entityType:l.entityType,entityId:l.entityId,label:l.label,description:l.description,tags:[]}))),await b(),M({open:!0,phase:"play",domain:t})}catch(l){D(l instanceof Error?l.message:"Forge could not start the game."),M(y=>({...y,phase:"domain"}))}finally{ue(!1)}},_e=async(t,s)=>{if(m){D(null),A({domain:t,tab:"overview",contextId:null,focusItem:null});try{await dt.mutateAsync({userId:m,domain:t,contextId:K??void 0,catalogId:s}),M({open:!0,phase:"play",domain:t})}catch(d){D(d instanceof Error?d.message:"Forge could not start the game.")}}},mt=async t=>{if(ts.has(t)){await ut(t);return}D(null),M({open:!0,phase:"catalog",domain:t})},xt=async(t,s=1)=>{if(!m||!(P!=null&&P.compare.nextPair))return;const d=P.compare.nextPair;await ct.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,leftItemId:d.left.id,rightItemId:d.right.id,outcome:t,strength:s})},pt=async(t,s)=>{!m||!P||await ot.mutateAsync({userId:m,domain:z.domain,contextId:P.selectedContext.id,itemId:t,signalType:s,strength:1})};if(!m)return e.jsx(et,{eyebrow:"Preferences",title:"No Forge user available",description:"Forge needs at least one human or bot user before it can learn preferences."});if(Y.isLoading&&!r)return e.jsx(Je,{eyebrow:"Preferences",title:"Loading preference model",description:"Reconstructing current scores, uncertainty, and concept libraries."});if(Y.isError)return e.jsx(Pt,{eyebrow:"Preferences",error:Y.error,onRetry:()=>void Y.refetch()});if(!r)return null;const gt=[...r.dimensions].sort((t,s)=>s.confidence-t.confidence).slice(0,6),Ge=r.scores.filter(t=>de(t)==="liked"||de(t)==="favorite").slice(0,4),Oe=r.scores.filter(t=>t.uncertainty>=.5).slice(0,4),$e=ns(r),Be=is(((Qe=c==null?void 0:c.item)==null?void 0:Qe.sourceEntityType)??null,((Re=c==null?void 0:c.item)==null?void 0:Re.sourceEntityId)??null);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ut,{title:"Preferences",titleText:"Preferences",description:"Forge keeps an explicit, editable model of what one user prefers in one domain. The first job of this page is to show what Forge currently knows.",badge:`${r.summary.totalItems} items · ${R(r.summary.averageConfidence)} confidence`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{className:"min-w-[10rem]",onClick:()=>ze(),children:"Start the game"}),e.jsx(u,{variant:"secondary",onClick:()=>void b(),children:"Refresh model"})]})}),e.jsx(Ft,{}),e.jsx(ms,{users:i.snapshot.users,user:lt,selectedUserId:m,selectedDomain:C,workspace:r,onPatchSearch:A}),e.jsx(xs,{selectedTab:T,onSelectTab:t=>A({tab:t})}),T==="overview"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"What Forge knows"}),e.jsx("div",{className:"font-display text-3xl text-[var(--ui-ink-strong)]",children:$e.title}),e.jsx("div",{className:"max-w-[70ch] text-sm leading-6 text-[var(--ui-ink-soft)]",children:$e.description})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[{label:"Known items",value:r.summary.totalItems,detail:"Items inside this domain"},{label:"Confidence",value:R(r.summary.averageConfidence),detail:"Average certainty"},{label:"Unknowns",value:r.summary.uncertainCount,detail:"Need more rounds"},{label:"Libraries",value:r.libraries.totalCatalogItems,detail:"Seeded concepts ready"}].map(t=>e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:t.value}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.detail})]},t.label))}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:gt.map(t=>e.jsx(ls,{summary:t},t.dimensionId))})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Next move"}),e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:"Start the game"}),e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will ask a small number of pairwise questions. You choose a domain, Forge supplies the candidates, and the model tightens from there."}),e.jsx(u,{className:"w-full",onClick:()=>ze(),children:"Start the game"}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{children:["Current queue: ",r.compare.pendingCount," comparison",r.compare.pendingCount===1?"":"s"]}),e.jsxs("div",{children:["Active context: ",r.selectedContext.name]}),e.jsxs("div",{children:["Library coverage: ",r.libraries.seededCatalogCount," ","seeded lists and ",r.libraries.customCatalogCount," ","custom lists"]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_360px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preference map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Green drifts positive, red drifts negative, and low opacity still means uncertainty."})]}),e.jsx(ve,{to:"?tab=map",className:"text-sm text-[var(--primary)]",children:"Open full map"})]}),e.jsxs("div",{className:"relative min-h-[340px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-2 py-1 text-[11px] shadow-[var(--ui-shadow-soft)] transition hover:scale-[1.04]",t.itemId===(c==null?void 0:c.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*30}%`,top:`${50-t.y*30}%`,opacity:.55+t.confidence*.45},onClick:()=>$(t.itemId),children:t.label},t.itemId))]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Best read so far"}),e.jsx("div",{className:"grid gap-2",children:Ge.length>0?Ge.map(t=>{var s;return e.jsxs("button",{type:"button",className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.explanation[0]||"Forge has positive evidence here."})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"No clear positives yet. A few comparison rounds will change that."})}),e.jsxs("div",{className:"border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Biggest unknowns"}),e.jsx("div",{className:"mt-3 grid gap-2",children:Oe.length>0?Oe.map(t=>{var s;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsxs("div",{className:"mt-1",children:["Uncertainty ",R(t.uncertainty)]})]},t.itemId)}):e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:"The current unknown list is short."})})]})]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Bring in Forge records"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Search goals, projects, tasks, strategies, or habits across human and bot users, then send them straight into this model."})]}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[ke.length," visible"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:w,onChange:t=>p(t.target.value),placeholder:"Search across owners, handles, user kind, title, and description"})]}),e.jsx("div",{className:"grid gap-2",children:ke.map(t=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.label}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.entityType}),t.user?e.jsx(tt,{user:t.user,compact:!0}):null]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.href?e.jsx(ve,{to:t.href,children:e.jsx(u,{variant:"ghost",size:"sm",children:"Open"})}):null,e.jsx(u,{variant:"secondary",size:"sm",pending:Ie.isPending,pendingLabel:"Adding",onClick:()=>void Ie.mutateAsync({userId:m,domain:C,entityType:t.entityType,entityId:t.entityId,label:t.label,description:t.description,tags:[]}),children:"Add to model"})]})]},`${t.entityType}-${t.entityId}`))})]})]}):null,T==="map"?e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Full map"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Click a point to inspect why Forge believes it belongs there."})]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[r.map.length," plotted items"]})]}),e.jsxs("div",{className:"relative min-h-[520px] overflow-hidden rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2 h-px bg-[var(--ui-border-subtle)]"}),e.jsx("div",{className:"absolute inset-y-0 left-1/2 w-px bg-[var(--ui-border-subtle)]"}),r.map.map(t=>e.jsx("button",{type:"button",className:U("absolute -translate-x-1/2 -translate-y-1/2 rounded-full border px-3 py-1 text-xs transition hover:scale-[1.04]",t.itemId===(c==null?void 0:c.itemId)?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":t.score>=0?"border-[color-mix(in_srgb,var(--success)_34%,transparent)] bg-[var(--ui-success-soft)] text-[var(--ui-ink-strong)]":"border-[color-mix(in_srgb,var(--danger)_34%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--ui-ink-strong)]"),style:{left:`${50+t.x*34}%`,top:`${50-t.y*34}%`,opacity:.45+t.confidence*.55},onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:t.label},t.itemId))]})]}):null,T==="table"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_380px]",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:k,onChange:t=>h(t.target.value),placeholder:"Search learned items, explanations, tags, or dominant dimensions"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"Item"}),e.jsx("th",{className:"px-3 py-2",children:"Score"}),e.jsx("th",{className:"px-3 py-2",children:"Confidence"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Evidence"})]})}),e.jsx("tbody",{children:he.map(t=>{var s,d;return e.jsxs("tr",{className:U("cursor-pointer border-t border-[var(--ui-border-subtle)] transition hover:bg-[var(--ui-surface-2)]",t.itemId===(c==null?void 0:c.itemId)?"bg-[var(--ui-surface-2)]":""),onClick:()=>{$(t.itemId),A({focusItem:t.itemId})},children:[e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:((s=t.item)==null?void 0:s.label)??t.itemId}),e.jsx("div",{className:"text-xs text-[var(--ui-ink-muted)]",children:(((d=t.item)==null?void 0:d.tags)??[]).join(" · ")})]}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.latentScore.toFixed(2)}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:R(t.confidence)}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(I,{className:Ze[de(t)],children:de(t)})}),e.jsx("td",{className:"px-3 py-3 text-[var(--ui-ink-medium)]",children:t.evidenceCount})]},t.itemId)})})]})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Item editor"}),c!=null&&c.item?e.jsxs(e.Fragment,{children:[e.jsx(v,{value:f.label,onChange:t=>F(s=>({...s,label:t.target.value})),placeholder:"Item label"}),e.jsx(E,{value:f.description,onChange:t=>F(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"Item description"}),e.jsx(v,{value:f.tags,onChange:t=>F(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{value:f.manualStatus,onChange:t=>F(s=>({...s,manualStatus:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Inferred status"}),Object.keys(Ze).map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(v,{value:f.manualScore,onChange:t=>F(s=>({...s,manualScore:t.target.value})),placeholder:"Manual score"}),e.jsx(v,{value:f.confidenceLock,onChange:t=>F(s=>({...s,confidenceLock:t.target.value})),placeholder:"Confidence lock 0-1"})]}),e.jsx("div",{className:"grid gap-2",children:Object.keys(ne).map(t=>e.jsxs("div",{className:"grid grid-cols-[110px_minmax(0,1fr)] items-center gap-3",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:fe[t]}),e.jsx(v,{value:f.featureWeights[t],onChange:s=>F(d=>({...d,featureWeights:{...d.featureWeights,[t]:s.target.value}}))})]},t))}),e.jsx("div",{className:"grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[["bookmarked","Bookmarked"],["compareLater","Compare later"],["frozen","Frozen"]].map(([t,s])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:f[t],onChange:d=>F(n=>({...n,[t]:d.target.checked}))}),e.jsx("span",{children:s})]},t))}),e.jsx(u,{pending:De.isPending,pendingLabel:"Saving item",onClick:()=>void De.mutateAsync(),children:"Save item model"}),Be?e.jsx(ve,{className:"text-sm text-[var(--primary)]",to:Be,children:"Open linked entity"}):null]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Select a row to inspect or edit it."}),e.jsxs("div",{className:"mt-3 border-t border-[var(--ui-border-subtle)] pt-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Add custom item"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsx(v,{value:_.label,onChange:t=>ee(s=>({...s,label:t.target.value})),placeholder:"Custom item label"}),e.jsx(E,{value:_.description,onChange:t=>ee(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What is this preference item?"}),e.jsx(v,{value:_.tags,onChange:t=>ee(s=>({...s,tags:t.target.value})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!_.label.trim(),pending:Se.isPending,pendingLabel:"Creating item",onClick:()=>void Se.mutateAsync({userId:m,domain:C,label:_.label,description:_.description,tags:_.tags.split(",").map(t=>t.trim()).filter(Boolean),featureWeights:ne,queueForCompare:!0}),children:"Create custom item"})]})]})]})]}):null,T==="history"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-3",children:[e.jsxs(j,{className:"grid gap-3 xl:col-span-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Recent pairwise judgments"}),e.jsx("div",{className:"grid gap-2",children:r.history.judgments.slice(0,12).map(t=>{var n,l,y,X;const s=((l=(n=r.scores.find(Q=>Q.itemId===t.leftItemId))==null?void 0:n.item)==null?void 0:l.label)??t.leftItemId,d=((X=(y=r.scores.find(Q=>Q.itemId===t.rightItemId))==null?void 0:y.item)==null?void 0:X.label)??t.rightItemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:[s," vs ",d]}),e.jsxs("div",{className:"mt-1",children:["Outcome ",t.outcome," · strength"," ",t.strength," ·"," ",new Date(t.createdAt).toLocaleString()]})]},t.id)})})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Signals and snapshots"}),e.jsx("div",{className:"grid gap-2",children:r.history.signals.slice(0,8).map(t=>{var d,n;const s=((n=(d=r.scores.find(l=>l.itemId===t.itemId))==null?void 0:d.item)==null?void 0:n.label)??t.itemId;return e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:[s," · ",t.signalType," ·"," ",new Date(t.createdAt).toLocaleString()]},t.id)})}),e.jsx("div",{className:"grid gap-2",children:r.history.snapshots.slice(0,5).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-soft)]",children:["Snapshot ",new Date(t.createdAt).toLocaleString()]},t.id))}),e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Stale items: ",r.history.staleItemIds.length," · Flipped items: ",r.history.flippedItemIds.length]})]})]}):null,T==="contexts"?e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_360px]",children:[e.jsx("div",{className:"grid gap-4",children:r.contexts.map(t=>e.jsxs(j,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.name}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.isDefault?e.jsx(I,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:"Default"}):null,e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.shareMode}),t.active?null:e.jsx(I,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:"Inactive"})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-4",children:[e.jsx(v,{value:t.name,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{name:s.target.value}}),placeholder:"Context name"}),e.jsxs("select",{value:t.shareMode,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{shareMode:s.target.value}}),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:String(t.decayDays),onChange:s=>void q.mutateAsync({contextId:t.id,patch:{decayDays:Number(s.target.value||90)}}),placeholder:"Decay days"}),e.jsx(u,{variant:"secondary",onClick:()=>A({contextId:t.id,tab:"overview"}),children:"Open context"})]}),e.jsx(E,{value:t.description,onChange:s=>void q.mutateAsync({contextId:t.id,patch:{description:s.target.value}}),className:"min-h-20"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{active:!t.active}}),children:t.active?"Deactivate":"Activate"}),t.isDefault?null:e.jsx(u,{variant:"secondary",onClick:()=>void q.mutateAsync({contextId:t.id,patch:{isDefault:!0}}),children:"Make default"})]})]},t.id))}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create context"}),e.jsx(v,{value:L.name,onChange:t=>W(s=>({...s,name:t.target.value})),placeholder:"Context name"}),e.jsx(E,{value:L.description,onChange:t=>W(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What changes in this context?"}),e.jsxs("select",{value:L.shareMode,onChange:t=>W(s=>({...s,shareMode:t.target.value})),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"blended",children:"blended"}),e.jsx("option",{value:"shared",children:"shared"}),e.jsx("option",{value:"isolated",children:"isolated"})]}),e.jsx(v,{value:L.decayDays,onChange:t=>W(s=>({...s,decayDays:t.target.value})),placeholder:"Decay days"}),e.jsx(u,{disabled:!L.name.trim(),pending:Ae.isPending,pendingLabel:"Creating context",onClick:()=>void Ae.mutateAsync({userId:m,domain:C,name:L.name,description:L.description,shareMode:L.shareMode,decayDays:Number(L.decayDays||90),active:!0,isDefault:!1}),children:"Create context"})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Merge contexts"}),e.jsxs("select",{value:G,onChange:t=>J(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Source context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:O,onChange:t=>be(t.target.value),className:"min-h-10 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none",children:[e.jsx("option",{value:"",children:"Target context"}),r.contexts.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx(u,{pending:Ee.isPending,pendingLabel:"Merging",disabled:!G||!O||G===O,onClick:()=>void Ee.mutateAsync({sourceContextId:G,targetContextId:O}),children:"Merge into target"})]})]})]}):null,T==="concepts"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_380px]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Concept libraries"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"These are the lists Forge can use when you start the game in a concept domain. Seeded lists are editable, and custom lists are fully yours."})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-4",children:[["Lists",r.libraries.totalCatalogs],["Concepts",r.libraries.totalCatalogItems],["Seeded",r.libraries.seededCatalogCount],["Custom",r.libraries.customCatalogCount]].map(([t,s])=>e.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 font-display text-3xl text-[var(--ui-ink-strong)]",children:s})]},t))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx(v,{value:S,onChange:t=>V(t.target.value),placeholder:"Search lists, concepts, tags, and seeded domains"})]})]}),e.jsxs(j,{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Create concept list"}),e.jsx(v,{value:H.title,onChange:t=>me(s=>({...s,title:t.target.value})),placeholder:"List title"}),e.jsx(E,{value:H.description,onChange:t=>me(s=>({...s,description:t.target.value})),className:"min-h-24",placeholder:"What should this list help compare?"}),e.jsx(u,{disabled:!H.title.trim(),pending:we.isPending,pendingLabel:"Creating list",onClick:()=>void we.mutateAsync({userId:m,domain:C,title:H.title,description:H.description}),children:"Create list"})]})]}),e.jsx("div",{className:"grid gap-4",children:Ce.map(t=>{const s=rt[t.id]??{label:"",description:"",tags:""},d=t.items.filter(n=>S.trim()?[n.label,n.description,n.tags.join(" ")].join(" ").toLowerCase().includes(le(S)):!0);return e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0",children:ye===t.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:se.title,onChange:n=>pe(l=>({...l,title:n.target.value}))}),e.jsx(E,{value:se.description,onChange:n=>pe(l=>({...l,description:n.target.value})),className:"min-h-24"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-display text-2xl text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:t.source}),e.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[t.items.length," items"]})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:t.description||"No description yet."})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>void _e(C,t.id),children:"Start from this list"}),ye===t.id?e.jsxs(e.Fragment,{children:[e.jsx(u,{size:"sm",pending:Pe.isPending,pendingLabel:"Saving",onClick:()=>void Pe.mutateAsync({catalogId:t.id,patch:{title:se.title,description:se.description}}),children:"Save"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>xe(null),children:"Cancel"})]}):e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{xe(t.id),pe({title:t.title,description:t.description})},children:"Edit list"}),e.jsx(u,{variant:"ghost",size:"sm",pending:Fe.isPending,pendingLabel:"Deleting",onClick:()=>void Fe.mutateAsync(t.id),children:"Delete list"})]})]}),e.jsx("div",{className:"grid gap-2",children:d.map(n=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-3",children:nt===n.id?e.jsxs("div",{className:"grid gap-3",children:[e.jsx(v,{value:B.label,onChange:l=>ae(y=>({...y,label:l.target.value}))}),e.jsx(E,{value:B.description,onChange:l=>ae(y=>({...y,description:l.target.value})),className:"min-h-20"}),e.jsx(v,{value:B.tags,onChange:l=>ae(y=>({...y,tags:l.target.value})),placeholder:"comma, separated, tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{size:"sm",pending:Te.isPending,pendingLabel:"Saving",onClick:()=>void Te.mutateAsync({catalogItemId:n.id,patch:{label:B.label,description:B.description,tags:B.tags.split(",").map(l=>l.trim()).filter(Boolean)}}),children:"Save concept"}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>ge(null),children:"Cancel"})]})]}):e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:n.label}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:n.description||"No description yet."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:n.tags.map(l=>e.jsx(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:l},`${n.id}-${l}`))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>{ge(n.id),ae({label:n.label,description:n.description,tags:n.tags.join(", ")})},children:"Edit"}),e.jsxs(u,{variant:"ghost",size:"sm",pending:Me.isPending,pendingLabel:"Deleting",onClick:()=>void Me.mutateAsync(n.id),children:[e.jsx(Ct,{className:"mr-1 size-4"}),"Delete"]})]})]})},n.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(It,{className:"size-4"}),"Add concept to ",t.title]}),e.jsx(v,{value:s.label,onChange:n=>te(l=>({...l,[t.id]:{...s,label:n.target.value}})),placeholder:"Concept label"}),e.jsx(E,{value:s.description,onChange:n=>te(l=>({...l,[t.id]:{...s,description:n.target.value}})),className:"min-h-20",placeholder:"Short description"}),e.jsx(v,{value:s.tags,onChange:n=>te(l=>({...l,[t.id]:{...s,tags:n.target.value}})),placeholder:"comma, separated, tags"}),e.jsx(u,{disabled:!s.label.trim(),pending:Le.isPending,pendingLabel:"Adding",onClick:()=>void Le.mutateAsync({catalogId:t.id,label:s.label,description:s.description,tags:s.tags.split(",").map(n=>n.trim()).filter(Boolean),featureWeights:ne}).then(()=>te(n=>({...n,[t.id]:{label:"",description:"",tags:""}}))),children:"Add concept"})]})]},t.id)})})]}):null]}),e.jsx(ds,{state:z,onOpenChange:t=>{t||D(null),M(s=>({...s,open:t}))},error:at,loading:it,workspaceLoading:Ne.isLoading,activeWorkspace:P,conceptSearchQuery:S,onConceptSearchQueryChange:V,filteredCatalogs:Ce,onSelectDomain:t=>void mt(t),onStartCatalogGame:(t,s)=>void _e(t,s),onJudge:(t,s)=>void xt(t,s),onSignal:(t,s)=>void pt(t,s)})]})}export{Cs as PreferencesPage};
@@ -1 +1 @@
1
- import{j as a}from"./vendor-B7FKSwHK.js";import{c as n}from"./index-gmPaoLN-.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(e){return{active:e.filter(t=>t.status==="active").length,paused:e.filter(t=>t.status==="paused").length,completed:e.filter(t=>t.status==="completed").length,all:e.length}}function f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
1
+ import{j as a}from"./vendor-y_uz1Wft.js";import{c as n}from"./index-Dj8q65se.js";const u={active:"Active",paused:"Suspended",completed:"Finished",all:"All"};function d({value:e,counts:t,onChange:s,className:o}){return a.jsx("div",{className:n("flex flex-wrap gap-2",o),children:Object.keys(u).map(r=>{const i=r===e;return a.jsxs("button",{type:"button",onClick:()=>s(r),className:n("inline-flex min-h-10 items-center gap-2 rounded-full border px-4 py-2 text-sm transition",i?"border-[var(--ui-border-strong)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),children:[a.jsx("span",{children:u[r]}),a.jsx("span",{className:n("rounded-full px-2 py-0.5 text-[11px]",i?"bg-[var(--ui-surface-active)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t[r]})]},r)})})}function v(e){return{active:e.filter(t=>t.status==="active").length,paused:e.filter(t=>t.status==="paused").length,completed:e.filter(t=>t.status==="completed").length,all:e.length}}function f(e,t){return t==="all"?e:e.filter(s=>s.status===t)}export{d as P,v as b,f};
@@ -1 +1 @@
1
- import{b_ as ee,b7 as te,r as k,j as e,aC as j}from"./vendor-B7FKSwHK.js";import{j as se,i as F,k as w}from"./state-BFyKSULP.js";import{S as ae}from"./scheduling-rules-editor-De72IUax.js";import{u as ie,d as re,e as oe,S as ne,a2 as ce,b as v,E as le,C as u,B as m,j as h,i as y,bp as de,bq as pe,ao as me,an as xe,ap as je,br as ue,Y as he}from"./index-gmPaoLN-.js";import{O as ge}from"./open-in-graph-button-DFQ4r6SN.js";import{ProjectDialog as we}from"./project-dialog-B2_PcXAf.js";import{P as ve}from"./project-management-section-nav-DFUlmMEB.js";import{TaskDialog as ye}from"./task-dialog-2wy0xI7f.js";import{e as fe,W as be}from"./calendar-rules-BGIBuEDk.js";import{E as ke}from"./execution-board-Dg-2GSKv.js";import{N as U}from"./note-markdown-CG8u2d6p.js";import{E as Ne}from"./entity-notes-surface-DPsJwqQa.js";import{P as Ie}from"./preference-entity-handoff-button-cPrTpHsV.js";import{P as De}from"./page-hero-U603l9rQ.js";import{U as H}from"./user-badge-C4eZu1e_.js";import{g as Se,a as Pe}from"./activity-copy-Bj4h9OcF.js";import{g as qe}from"./entity-links-DwpxhW2H.js";import{g as Qe}from"./user-ownership-DJGl4rAj.js";import"./motion-BibSzp57.js";import"./ui-uo_bNP7c.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";import"./question-flow-dialog-yMYVk998.js";import"./inline-note-fields-BvQwmMAv.js";import"./user-select-field-CmKwcbZt.js";import"./schemas-BlFy-uPR.js";import"./goal-dialog-nkdME5Uy.js";import"./entity-note-count-link-BGOiaash.js";import"./floating-action-menu-BUs382px.js";import"./note-tags-input-D_conqDO.js";import"./entity-link-multiselect-BfDAROHB.js";import"./use-anchored-overlay-position-BSxFX6Hi.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function dt(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[_,E]=k.useState(!1),[G,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=Qe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,B=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],O=new Set(B.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||O.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&O.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>ue(o.projectId),enabled:!!o.projectId&&!n}),Y=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>he({...I,userIds:N}),enabled:!!o.projectId&&!n}),J=w({mutationFn:t=>xe(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:je,onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>de(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>pe(o.projectId),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),V=w({mutationFn:t=>me(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:B,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(oe,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(ne,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=fe({rules:s.project.schedulingRules,overview:(M=Y.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ve,{}),e.jsx(De,{entityKind:"project",title:e.jsx(le,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(U,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ce,{metrics:i.snapshot.metrics}),e.jsx(Ie,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ge,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(H,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(H,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(U,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{kind:"project",compact:!0,gradient:!1}),e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(ke,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await J.mutateAsync(t)},onDeleteTask:async t=>{await V.mutateAsync(t)}}),n?null:e.jsx(Ne,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:qe(t)??`/activity?eventId=${t.id}`,className:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Se(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:Pe(t)})]},t.id))})]}),e.jsx(we,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(ye,{open:_,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(be,{open:G,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{dt as ProjectDetailPage};
1
+ import{b_ as ee,b7 as te,r as k,j as e,aC as j}from"./vendor-y_uz1Wft.js";import{j as se,i as F,k as w}from"./state-DWw8Jay_.js";import{S as ae}from"./scheduling-rules-editor-DiA6KkQ4.js";import{u as ie,d as re,e as oe,S as ne,a2 as ce,b as v,E as le,C as u,B as m,j as h,i as y,bp as de,bq as pe,ao as me,an as xe,ap as je,br as ue,Y as he}from"./index-Dj8q65se.js";import{O as ge}from"./open-in-graph-button-BHl16hJP.js";import{ProjectDialog as we}from"./project-dialog-BuZdXECa.js";import{P as ve}from"./project-management-section-nav-CnaseOqL.js";import{TaskDialog as ye}from"./task-dialog-B7ZT4KE5.js";import{e as fe,W as be}from"./calendar-rules-DdxPmBZJ.js";import{E as ke}from"./execution-board-D9hkXKC2.js";import{N as U}from"./note-markdown-Cxj84-0j.js";import{E as Ne}from"./entity-notes-surface-Dq9dFKjD.js";import{P as Ie}from"./preference-entity-handoff-button-1XXtBsUF.js";import{P as De}from"./page-hero-DYmFM6-q.js";import{U as H}from"./user-badge-B8hYK6NU.js";import{g as Se,a as Pe}from"./activity-copy-Bj4h9OcF.js";import{g as qe}from"./entity-links-DwpxhW2H.js";import{g as Qe}from"./user-ownership-DJGl4rAj.js";import"./motion-DeJZhOSA.js";import"./ui-CdEDMtXF.js";import"./board-CGgOvBP9.js";import"./forms-DhEGHkFR.js";import"./question-flow-dialog-CPyXCqA-.js";import"./inline-note-fields-DpmCMAJf.js";import"./user-select-field-akGHK-2t.js";import"./schemas-D_z2C8l1.js";import"./goal-dialog-BlZHh3dw.js";import"./entity-note-count-link-FOK_qhcC.js";import"./floating-action-menu-CFrgvQJi.js";import"./note-tags-input-CP0-EPpE.js";import"./entity-link-multiselect-DZ_jAjs4.js";import"./use-anchored-overlay-position-Cracjgo6.js";function Te(a){return!!(a&&a.startsWith("campaign:"))}function dt(){var M;const{t:a}=ie(),i=re(),N=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],o=ee(),K=te(),r=se(),[W,C]=k.useState(!1),[_,E]=k.useState(!1),[G,R]=k.useState(!1),[I]=k.useState(()=>{const t=new Date,l=new Date(t);l.setHours(0,0,0,0);const $=new Date(t);return $.setHours(23,59,59,999),{from:l.toISOString(),to:$.toISOString()}}),D=Qe(N),c=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null,A=c?i.snapshot.goals.find(t=>t.id===c.goalId)??null:null,B=c?i.snapshot.tasks.filter(t=>t.projectId===c.id||!t.projectId&&t.goalId===c.goalId):[],O=new Set(B.map(t=>t.id)),z=c?i.snapshot.activity.filter(t=>t.entityId===c.goalId||t.entityId===c.id||O.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&O.has(t.metadata.taskId)):[],n=Te(o.projectId),f=F({queryKey:["project-board",o.projectId],queryFn:()=>ue(o.projectId),enabled:!!o.projectId&&!n}),Y=F({queryKey:["project-calendar-overview",o.projectId,I.from,I.to,...N],queryFn:()=>he({...I,userIds:N}),enabled:!!o.projectId&&!n}),J=w({mutationFn:t=>xe(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})])}}),L=w({mutationFn:je,onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),g=w({mutationFn:t=>de(o.projectId,{status:t}),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["forge-xp-metrics"]}),r.invalidateQueries({queryKey:["forge-reward-ledger"]}),r.invalidateQueries({queryKey:["forge-operator-context"]})])}}),S=w({mutationFn:()=>pe(o.projectId),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]})]),K("/projects")}}),V=w({mutationFn:t=>me(t),onSuccess:async()=>{await Promise.all([y(r),r.invalidateQueries({queryKey:["project-board",o.projectId]}),r.invalidateQueries({queryKey:["task-context"]})])}}),s=f.data??(c&&A?{project:c,goal:A,tasks:B,activity:z}:void 0),b=i.snapshot.dashboard.projects.find(t=>t.id===o.projectId)??null;if(f.isError&&!n)return e.jsx(oe,{eyebrow:a("common.projectDetail.errorEyebrow"),error:f.error,onRetry:()=>void f.refetch()});if(!s)return e.jsx(ne,{});const d=s.tasks.find(t=>t.status==="focus"||t.status==="in_progress")??s.tasks[0]??null,p=s.tasks.find(t=>t.status==="blocked")??s.tasks.find(t=>t.status==="backlog")??null;s.activity[0];const X="notesSummaryByEntity"in s?s.notesSummaryByEntity:i.snapshot.dashboard.notesSummaryByEntity,P=g.isPending||S.isPending,x=fe({rules:s.project.schedulingRules,overview:(M=Y.data)==null?void 0:M.calendar}),q=i.snapshot.strategies.filter(t=>t.targetGoalIds.includes(s.goal.id)),Q=i.snapshot.strategies.filter(t=>t.targetProjectIds.includes(s.project.id)),T=async t=>{await g.mutateAsync(t)},Z=async()=>{window.confirm(a("common.projectDetail.deleteProjectConfirm",{title:s.project.title}))&&await S.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ve,{}),e.jsx(De,{entityKind:"project",title:e.jsx(le,{kind:"project",label:s.project.title,variant:"heading",size:"lg"}),titleText:s.project.title,description:s.project.description?e.jsx(U,{markdown:s.project.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No project description yet.",badge:e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ce,{metrics:i.snapshot.metrics}),e.jsx(Ie,{userId:D,domain:"projects",entityType:"project",entityId:s.project.id,label:s.project.title,description:s.project.description}),e.jsx(ge,{entityType:"project",entityId:s.project.id})]})}),s.project.user?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-white/62",children:[e.jsx("span",{className:"text-white/42",children:"Owned by"}),e.jsx(H,{user:s.project.user}),s.project.assignees&&s.project.assignees.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/35",children:"Assigned with"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.project.assignees.map(t=>e.jsx(H,{user:t,compact:!0},t.id))})]}):null]}):null,s.project.productRequirementsDocument?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Product requirements document"}),e.jsx("div",{className:"mt-3",children:e.jsx(U,{markdown:s.project.productRequirementsDocument,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"})})]}):null,q.length>0||Q.length>0?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Strategy stack"}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Goal-level strategies"}),q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No goal-level strategies linked yet."}):q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:"Project-level strategies"}),Q.length===0?e.jsx("div",{className:"text-sm text-white/48",children:"No lower-level strategies linked yet."}):Q.map(t=>e.jsxs(j,{to:`/strategies/${t.id}`,className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 transition hover:bg-white/[0.07]",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx("div",{className:"mt-1 text-xs text-white/48",children:t.overview||t.endStateDescription})]},t.id))]})]})]}):null,n?e.jsxs(u,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(m,{onClick:()=>E(!0),children:a("common.projectDetail.addTask")}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>R(!0),children:"Adjust work"}),n?null:e.jsx(m,{variant:"secondary",onClick:()=>C(!0),children:a("common.projectDetail.editProject")}),!n&&s.project.status==="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="paused",pendingLabel:a("common.projectDetail.suspending"),onClick:()=>void T("paused"),children:a("common.projectDetail.suspendProject")}):null,!n&&s.project.status!=="completed"?e.jsx(m,{pending:P&&g.variables==="completed",pendingLabel:a("common.projectDetail.finishing"),onClick:()=>void T("completed"),children:a("common.projectDetail.finishProject")}):null,!n&&s.project.status!=="active"?e.jsx(m,{variant:"secondary",pending:P&&g.variables==="active",pendingLabel:a("common.projectDetail.restarting"),onClick:()=>void T("active"),children:a("common.projectDetail.restartProject")}):null,n?null:e.jsx(m,{variant:"ghost",pending:S.isPending,pendingLabel:a("common.projectDetail.deleting"),onClick:()=>void Z(),children:a("common.projectDetail.deleteProject")}),e.jsx(j,{to:`/goals/${s.goal.id}`,children:e.jsx(m,{variant:"ghost",children:a("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(u,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:a("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:a("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{kind:"project",compact:!0,gradient:!1}),e.jsx(v,{kind:"goal",label:s.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(j,{to:d?`/tasks/${d.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalNext")}),d?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??a("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(d==null?void 0:d.description)||a("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(j,{to:p?`/tasks/${p.id}`:`/projects/${s.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:a("common.projectDetail.signalRisk")}),p?e.jsx(v,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(p==null?void 0:p.title)??a("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(p==null?void 0:p.description)||a("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:a("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:a(`common.enums.projectStatus.${s.project.status}`)}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s.project.momentumLabel}),e.jsxs(h,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(s.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[s.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:a("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a(`common.enums.projectStatus.${s.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:s.tasks.filter(t=>t.status==="focus"||t.status==="in_progress").length})]})]})]})]}),n?null:e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(ae,{title:"Project scheduling defaults",subtitle:"Define the calendar contexts where work from this project is allowed or blocked. Tasks can inherit these defaults or override them.",initialRules:s.project.schedulingRules,saveLabel:"Save project scheduling",onSave:async({schedulingRules:t})=>{await i.patchProject(s.project.id,{schedulingRules:t}),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["project-calendar-overview",o.projectId]})}}),e.jsxs(u,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Calendar status"}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{className:x.tone==="blocked"?"bg-rose-500/14 text-rose-100":x.tone==="waiting"?"bg-amber-500/14 text-amber-100":"bg-emerald-500/14 text-emerald-100",children:x.label}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:"Project defaults"})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:"These rules act as the default calendar gate for every task in the project unless a task sets its own override."}),x.context.length>0?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current context"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x.context.map(t=>e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:t},t))})]}):null,x.conflicts.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:x.conflicts.map(t=>e.jsx("div",{className:"rounded-[16px] bg-rose-500/10 px-3 py-2 text-sm text-rose-100",children:t},t))}):null,e.jsx("div",{className:"mt-4",children:e.jsx(j,{to:"/calendar",children:e.jsx(m,{variant:"secondary",children:"Open calendar workspace"})})})]})]}),e.jsx(ke,{tasks:s.tasks,activeRuns:i.snapshot.activeTaskRuns,goals:i.snapshot.goals,tags:i.snapshot.tags,notesSummaryByEntity:X,selectedTaskId:null,onMove:async(t,l)=>{await i.patchTaskStatus(t,l),await r.invalidateQueries({queryKey:["project-board",o.projectId]})},onSelectTask:t=>K(`/tasks/${t}`),onStopTask:async t=>{await i.stopTaskRun(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}),await r.invalidateQueries({queryKey:["task-context",t.taskId]})},onQuickReopenTask:async t=>{await J.mutateAsync(t)},onDeleteTask:async t=>{await V.mutateAsync(t)}}),n?null:e.jsx(Ne,{entityType:"project",entityId:s.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",o.projectId]]}),e.jsxs(u,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3 lg:grid-cols-2",children:s.activity.slice(0,6).map(t=>e.jsxs(j,{to:qe(t)??`/activity?eventId=${t.id}`,className:"min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Se(t)}),e.jsx(h,{children:t.source})]}),e.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:Pe(t)})]},t.id))})]}),e.jsx(we,{open:W,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:b,defaultUserId:(b==null?void 0:b.userId)??D,onOpenChange:C,onSubmit:async(t,l)=>{l&&(await i.patchProject(l,t),await r.invalidateQueries({queryKey:["project-board",o.projectId]}))}}),e.jsx(ye,{open:_,goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,workItems:i.snapshot.workItems,tags:i.snapshot.tags,users:i.snapshot.users,editingTask:null,initialProjectId:n?null:s.project.id,defaultUserId:s.project.userId??D,onRefreshEntities:i.refresh,onOpenChange:E,onSubmit:async(t,l)=>{l?await i.patchTask(l,t):await i.createTask(t),await r.invalidateQueries({queryKey:["project-board",o.projectId]})}}),n?null:e.jsx(be,{open:G,onOpenChange:R,entityType:"project",entityId:s.project.id,targetLabel:s.project.title,currentCreditedSeconds:s.project.time.totalCreditedSeconds,pending:L.isPending,onSubmit:async t=>{await L.mutateAsync(t)}})]})}export{dt as ProjectDetailPage};
@@ -1 +1 @@
1
- import{r as u,j as t}from"./vendor-B7FKSwHK.js";import{Q as T,F as i,a as y}from"./question-flow-dialog-yMYVk998.js";import{I as R}from"./inline-note-fields-BvQwmMAv.js";import{u as _,E as q,I as w,T as k}from"./index-gmPaoLN-.js";import{U as L}from"./user-select-field-CmKwcbZt.js";import{U as A}from"./user-badge-C4eZu1e_.js";import{p as B}from"./schemas-BlFy-uPR.js";import{a as K}from"./user-ownership-DJGl4rAj.js";import"./ui-uo_bNP7c.js";import"./motion-BibSzp57.js";import"./state-BFyKSULP.js";import"./board-DprRipIG.js";import"./forms-ByKjodjN.js";const C={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]};function M(a){return{goalId:a.goalId,title:a.title,description:a.description,status:a.status,workflowStatus:a.workflowStatus,userId:a.userId??null,assigneeUserIds:a.assigneeUserIds??[],targetPoints:a.targetPoints,themeColor:a.themeColor,productRequirementsDocument:a.productRequirementsDocument,notes:[]}}function ee({open:a,goals:l,users:I,editingProject:n,initialGoalId:m,initialStepId:S,defaultUserId:p=null,onOpenChange:v,onSubmit:N}){const{t:s}=_(),h=I??[],[b,j]=u.useState(C),[E,c]=u.useState(null),[d,g]=u.useState({}),f=l.find(r=>r.id===b.goalId)??null,F=h.find(r=>r.id===((f==null?void 0:f.userId)??p))??null,D=r=>{g(Object.fromEntries(Object.entries(r).map(([o,e])=>[o,e==null?void 0:e[0]])))};u.useEffect(()=>{var r;a&&(c(null),g({}),j(n?M(n):{...C,goalId:m??"",userId:((r=l.find(o=>o.id===m))==null?void 0:r.userId)??p}))},[p,n,l,m,a]);const U=[{id:"anchor",eyebrow:"Anchor",title:"Attach the project to the right goal",description:"Projects should serve one clear life-goal arc, so start by picking the direction this initiative belongs to.",render:(r,o)=>t.jsx(i,{label:s("common.dialogs.project.goal"),error:d.goalId??null,children:t.jsx("div",{className:"grid min-w-0 max-w-full gap-3",children:l.map(e=>{const x=e.id===r.goalId;return t.jsxs("button",{type:"button",className:`min-w-0 max-w-full overflow-hidden rounded-[22px] border px-4 py-4 text-left transition ${x?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>o({goalId:e.id}),children:[t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-between gap-2",children:[t.jsx(q,{kind:"goal",label:e.title,className:"min-w-0 max-w-full"}),t.jsx("span",{className:"min-w-0 max-w-full",children:t.jsx(A,{user:e.user,compact:!0})})]}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-faint)]",children:e.description||"No strategic note attached yet."})]},e.id)})})})},{id:"shape",eyebrow:"Shape",title:"Name the initiative and the work it will make possible",description:"Keep the project concrete. The title should sound like something you can actually move forward this season.",render:(r,o)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:s("common.dialogs.project.title"),error:d.title??null,children:t.jsx(w,{value:r.title,onChange:e=>o({title:e.target.value}),placeholder:"Launch the new creative practice system"})}),t.jsx(i,{label:s("common.dialogs.project.descriptionLabel"),children:t.jsx(k,{value:r.description,onChange:e=>o({description:e.target.value}),placeholder:"Write the project description in Markdown. Use as much detail as the workstream needs."})}),t.jsx(i,{label:"Product requirements document",children:t.jsx(k,{value:r.productRequirementsDocument,onChange:e=>o({productRequirementsDocument:e.target.value}),placeholder:"Capture the PRD in Markdown so the project view can present it clearly."})}),t.jsx(L,{value:r.userId,users:h,onChange:e=>o({userId:e}),label:"Owner user",defaultLabel:K(F),help:"Projects can intentionally cross user boundaries, but the linked goal owner is suggested by default."}),t.jsx(i,{label:"Assignees",children:t.jsx("select",{multiple:!0,value:r.assigneeUserIds,onChange:e=>o({assigneeUserIds:Array.from(e.target.selectedOptions,x=>x.value)}),className:"min-h-28 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_35%,var(--ui-border-strong)_65%)]",children:h.map(e=>t.jsxs("option",{value:e.id,children:[e.displayName," · ",e.kind]},e.id))})})]})},{id:"signal",eyebrow:"Signal",title:"Set the project's posture and progress target",description:"This keeps the board, reward system, and detail views aligned without forcing you through a giant settings form.",render:(r,o)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:s("common.dialogs.project.status"),children:t.jsx(y,{value:r.status,onChange:e=>o({status:e}),options:[{value:"active",label:s("common.enums.projectStatus.active"),description:"Push this initiative now."},{value:"paused",label:s("common.enums.projectStatus.paused"),description:"Keep it available without active pressure."},{value:"completed",label:s("common.enums.projectStatus.completed"),description:"This initiative has landed."}]})}),t.jsx(i,{label:"Board workflow status",children:t.jsx(y,{value:r.workflowStatus,onChange:e=>o({workflowStatus:e}),options:[{value:"backlog",label:"Backlog"},{value:"focus",label:"Focus"},{value:"in_progress",label:"In progress"},{value:"blocked",label:"Blocked"},{value:"done",label:"Done"}]})}),t.jsx(i,{label:s("common.dialogs.project.targetXp"),error:d.targetPoints??null,children:t.jsx(w,{type:"number",value:r.targetPoints,onChange:e=>o({targetPoints:Number(e.target.value)||0})})}),t.jsx(i,{label:s("common.dialogs.project.themeColor"),error:d.themeColor??null,children:t.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[t.jsx("input",{className:"h-10 w-12 rounded-lg border border-[var(--ui-border-subtle)] bg-transparent",type:"color",value:r.themeColor,onChange:e=>o({themeColor:e.target.value})}),t.jsx(w,{className:"border-none bg-transparent px-0 py-0",value:r.themeColor,onChange:e=>o({themeColor:e.target.value})})]})})]})},{id:"notes",eyebrow:"Evidence",title:"Keep the creation context attached to the project from day one",description:"Use linked Markdown notes when the initiative needs setup context, assumptions, or a handoff summary right away.",render:(r,o)=>t.jsx(i,{label:"Creation notes",children:t.jsx(R,{notes:r.notes,onChange:e=>o({notes:e}),entityLabel:"project"})})}];return t.jsx(T,{open:a,onOpenChange:v,eyebrow:s("common.dialogs.project.eyebrow"),title:s(n?"common.dialogs.project.editTitle":"common.dialogs.project.createTitle"),description:s("common.dialogs.project.description"),value:b,onChange:j,draftPersistenceKey:n?`project.${n.id}`:"project.new",steps:U,initialStepId:S,submitLabel:s(n?"common.dialogs.project.save":"common.dialogs.project.create"),error:E,onSubmit:async()=>{c(null);const r=B.safeParse(b);if(!r.success){D(r.error.flatten().fieldErrors),c("A couple of answers still need attention before this project can be saved.");return}g({});try{await N(r.data,n==null?void 0:n.id),v(!1)}catch(o){c(o instanceof Error?o.message:s("common.dialogs.project.submitError"))}}})}export{ee as ProjectDialog,C as defaultProjectValues};
1
+ import{r as u,j as t}from"./vendor-y_uz1Wft.js";import{Q as T,F as i,a as y}from"./question-flow-dialog-CPyXCqA-.js";import{I as R}from"./inline-note-fields-DpmCMAJf.js";import{u as _,E as q,I as w,T as k}from"./index-Dj8q65se.js";import{U as L}from"./user-select-field-akGHK-2t.js";import{U as A}from"./user-badge-B8hYK6NU.js";import{p as B}from"./schemas-D_z2C8l1.js";import{a as K}from"./user-ownership-DJGl4rAj.js";import"./ui-CdEDMtXF.js";import"./motion-DeJZhOSA.js";import"./state-DWw8Jay_.js";import"./board-CGgOvBP9.js";import"./forms-DhEGHkFR.js";const C={goalId:"",title:"",description:"",status:"active",workflowStatus:"backlog",userId:null,assigneeUserIds:[],targetPoints:240,themeColor:"#c0c1ff",productRequirementsDocument:"",notes:[]};function M(a){return{goalId:a.goalId,title:a.title,description:a.description,status:a.status,workflowStatus:a.workflowStatus,userId:a.userId??null,assigneeUserIds:a.assigneeUserIds??[],targetPoints:a.targetPoints,themeColor:a.themeColor,productRequirementsDocument:a.productRequirementsDocument,notes:[]}}function ee({open:a,goals:l,users:I,editingProject:n,initialGoalId:m,initialStepId:S,defaultUserId:p=null,onOpenChange:v,onSubmit:N}){const{t:s}=_(),h=I??[],[b,j]=u.useState(C),[E,c]=u.useState(null),[d,g]=u.useState({}),f=l.find(r=>r.id===b.goalId)??null,F=h.find(r=>r.id===((f==null?void 0:f.userId)??p))??null,D=r=>{g(Object.fromEntries(Object.entries(r).map(([o,e])=>[o,e==null?void 0:e[0]])))};u.useEffect(()=>{var r;a&&(c(null),g({}),j(n?M(n):{...C,goalId:m??"",userId:((r=l.find(o=>o.id===m))==null?void 0:r.userId)??p}))},[p,n,l,m,a]);const U=[{id:"anchor",eyebrow:"Anchor",title:"Attach the project to the right goal",description:"Projects should serve one clear life-goal arc, so start by picking the direction this initiative belongs to.",render:(r,o)=>t.jsx(i,{label:s("common.dialogs.project.goal"),error:d.goalId??null,children:t.jsx("div",{className:"grid min-w-0 max-w-full gap-3",children:l.map(e=>{const x=e.id===r.goalId;return t.jsxs("button",{type:"button",className:`min-w-0 max-w-full overflow-hidden rounded-[22px] border px-4 py-4 text-left transition ${x?"border-[color-mix(in_srgb,var(--primary)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>o({goalId:e.id}),children:[t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-between gap-2",children:[t.jsx(q,{kind:"goal",label:e.title,className:"min-w-0 max-w-full"}),t.jsx("span",{className:"min-w-0 max-w-full",children:t.jsx(A,{user:e.user,compact:!0})})]}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm leading-6 text-[var(--ui-ink-faint)]",children:e.description||"No strategic note attached yet."})]},e.id)})})})},{id:"shape",eyebrow:"Shape",title:"Name the initiative and the work it will make possible",description:"Keep the project concrete. The title should sound like something you can actually move forward this season.",render:(r,o)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:s("common.dialogs.project.title"),error:d.title??null,children:t.jsx(w,{value:r.title,onChange:e=>o({title:e.target.value}),placeholder:"Launch the new creative practice system"})}),t.jsx(i,{label:s("common.dialogs.project.descriptionLabel"),children:t.jsx(k,{value:r.description,onChange:e=>o({description:e.target.value}),placeholder:"Write the project description in Markdown. Use as much detail as the workstream needs."})}),t.jsx(i,{label:"Product requirements document",children:t.jsx(k,{value:r.productRequirementsDocument,onChange:e=>o({productRequirementsDocument:e.target.value}),placeholder:"Capture the PRD in Markdown so the project view can present it clearly."})}),t.jsx(L,{value:r.userId,users:h,onChange:e=>o({userId:e}),label:"Owner user",defaultLabel:K(F),help:"Projects can intentionally cross user boundaries, but the linked goal owner is suggested by default."}),t.jsx(i,{label:"Assignees",children:t.jsx("select",{multiple:!0,value:r.assigneeUserIds,onChange:e=>o({assigneeUserIds:Array.from(e.target.selectedOptions,x=>x.value)}),className:"min-h-28 rounded-[var(--radius-control)] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[color-mix(in_srgb,var(--primary)_35%,var(--ui-border-strong)_65%)]",children:h.map(e=>t.jsxs("option",{value:e.id,children:[e.displayName," · ",e.kind]},e.id))})})]})},{id:"signal",eyebrow:"Signal",title:"Set the project's posture and progress target",description:"This keeps the board, reward system, and detail views aligned without forcing you through a giant settings form.",render:(r,o)=>t.jsxs(t.Fragment,{children:[t.jsx(i,{label:s("common.dialogs.project.status"),children:t.jsx(y,{value:r.status,onChange:e=>o({status:e}),options:[{value:"active",label:s("common.enums.projectStatus.active"),description:"Push this initiative now."},{value:"paused",label:s("common.enums.projectStatus.paused"),description:"Keep it available without active pressure."},{value:"completed",label:s("common.enums.projectStatus.completed"),description:"This initiative has landed."}]})}),t.jsx(i,{label:"Board workflow status",children:t.jsx(y,{value:r.workflowStatus,onChange:e=>o({workflowStatus:e}),options:[{value:"backlog",label:"Backlog"},{value:"focus",label:"Focus"},{value:"in_progress",label:"In progress"},{value:"blocked",label:"Blocked"},{value:"done",label:"Done"}]})}),t.jsx(i,{label:s("common.dialogs.project.targetXp"),error:d.targetPoints??null,children:t.jsx(w,{type:"number",value:r.targetPoints,onChange:e=>o({targetPoints:Number(e.target.value)||0})})}),t.jsx(i,{label:s("common.dialogs.project.themeColor"),error:d.themeColor??null,children:t.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[t.jsx("input",{className:"h-10 w-12 rounded-lg border border-[var(--ui-border-subtle)] bg-transparent",type:"color",value:r.themeColor,onChange:e=>o({themeColor:e.target.value})}),t.jsx(w,{className:"border-none bg-transparent px-0 py-0",value:r.themeColor,onChange:e=>o({themeColor:e.target.value})})]})})]})},{id:"notes",eyebrow:"Evidence",title:"Keep the creation context attached to the project from day one",description:"Use linked Markdown notes when the initiative needs setup context, assumptions, or a handoff summary right away.",render:(r,o)=>t.jsx(i,{label:"Creation notes",children:t.jsx(R,{notes:r.notes,onChange:e=>o({notes:e}),entityLabel:"project"})})}];return t.jsx(T,{open:a,onOpenChange:v,eyebrow:s("common.dialogs.project.eyebrow"),title:s(n?"common.dialogs.project.editTitle":"common.dialogs.project.createTitle"),description:s("common.dialogs.project.description"),value:b,onChange:j,draftPersistenceKey:n?`project.${n.id}`:"project.new",steps:U,initialStepId:S,submitLabel:s(n?"common.dialogs.project.save":"common.dialogs.project.create"),error:E,onSubmit:async()=>{c(null);const r=B.safeParse(b);if(!r.success){D(r.error.flatten().fieldErrors),c("A couple of answers still need attention before this project can be saved.");return}g({});try{await N(r.data,n==null?void 0:n.id),v(!1)}catch(o){c(o instanceof Error?o.message:s("common.dialogs.project.submitError"))}}})}export{ee as ProjectDialog,C as defaultProjectValues};