forge-openclaw-plugin 0.2.101 → 0.2.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
  3. package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
  4. package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
  8. package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
  15. package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/metric-tile-CMadwnGz.js +1 -0
  32. package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
  35. package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
  39. package/dist/assets/overview-page-CXdWrOV1.js +1 -0
  40. package/dist/assets/page-hero-ffKzgyW3.js +1 -0
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
  50. package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
  51. package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
  52. package/dist/assets/psyche-graph-EP5GL612.js +1 -0
  53. package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
  55. package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
  56. package/dist/assets/psyche-page-F4tF2W70.js +1 -0
  57. package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
  58. package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
  59. package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
  60. package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
  61. package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
  62. package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
  63. package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
  64. package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
  65. package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
  67. package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
  68. package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
  69. package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
  70. package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/schema-badge-FY7818qB.js +1 -0
  74. package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
  75. package/dist/assets/select-menu-DJsCG6rM.js +1 -0
  76. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  77. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  78. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  79. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  80. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  81. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  82. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  83. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  84. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  85. package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
  86. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  87. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  88. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  89. package/dist/assets/sports-page-BldIiclr.js +1 -0
  90. package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
  91. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  92. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  93. package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
  94. package/dist/assets/surface-CJI17F3n.js +1 -0
  95. package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
  96. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  97. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  98. package/dist/assets/today-page-BjDijtn8.js +1 -0
  99. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  100. package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
  101. package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
  102. package/dist/assets/vendor-Dnkkx2co.js +1067 -0
  103. package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
  104. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  105. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  106. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  107. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  108. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  109. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  110. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  111. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  112. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  113. package/dist/assets/workout-detail-page-DT-c5cHL.js +2 -0
  114. package/dist/index.html +9 -9
  115. package/dist/openclaw/local-runtime.js +41 -14
  116. package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  117. package/dist/server/server/src/app.js +125 -33
  118. package/dist/server/server/src/health-weight-loss.js +554 -77
  119. package/dist/server/server/src/health.js +12 -4
  120. package/dist/server/server/src/movement.js +84 -1
  121. package/dist/server/server/src/openapi.js +123 -18
  122. package/dist/server/server/src/repositories/model-settings.js +21 -12
  123. package/dist/server/server/src/repositories/settings.js +19 -5
  124. package/dist/server/src/components/ui/info-tooltip.js +6 -6
  125. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  126. package/dist/server/src/lib/api.js +24 -5
  127. package/dist/server/src/lib/theme-system.js +8 -0
  128. package/openclaw.plugin.json +1 -1
  129. package/package.json +3 -3
  130. package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
  131. package/skills/forge-openclaw/SKILL.md +13 -0
  132. package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
  133. package/dist/assets/activity-page-CpjuNSHw.js +0 -1
  134. package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
  135. package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
  136. package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
  137. package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
  138. package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
  139. package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
  140. package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
  141. package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
  142. package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
  143. package/dist/assets/execution-board-D07gOocB.js +0 -1
  144. package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
  145. package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
  146. package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
  147. package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
  148. package/dist/assets/goals-page-BTk7mg_T.js +0 -1
  149. package/dist/assets/habits-page-BJxagdzx.js +0 -1
  150. package/dist/assets/index-CF4J4R9L.js +0 -19
  151. package/dist/assets/index-CZbuZQjw.css +0 -1
  152. package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
  153. package/dist/assets/insights-page-D6rOa7uk.js +0 -8
  154. package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
  155. package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
  156. package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
  157. package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
  158. package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
  159. package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
  160. package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
  161. package/dist/assets/notes-page-CKXnF_KU.js +0 -1
  162. package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
  163. package/dist/assets/overview-page-1miYqaVS.js +0 -1
  164. package/dist/assets/page-hero-DRy5b2MU.js +0 -1
  165. package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
  166. package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
  167. package/dist/assets/project-collections-xPz2mlRr.js +0 -1
  168. package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
  169. package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
  170. package/dist/assets/projects-page-C5ViRuf4.js +0 -1
  171. package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
  172. package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
  173. package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
  174. package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
  175. package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
  176. package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
  177. package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
  178. package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
  179. package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
  180. package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
  181. package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
  182. package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
  183. package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
  184. package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
  185. package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
  186. package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
  187. package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
  188. package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
  189. package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
  190. package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
  191. package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
  192. package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
  193. package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
  194. package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
  195. package/dist/assets/select-menu-fYyreSdQ.js +0 -1
  196. package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
  197. package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
  198. package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
  199. package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
  200. package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
  201. package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
  202. package/dist/assets/settings-models-page-D26270R2.js +0 -1
  203. package/dist/assets/settings-page-DYDTFlnv.js +0 -1
  204. package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
  205. package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
  206. package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
  207. package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
  208. package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
  209. package/dist/assets/strategies-page-C4qvXnql.js +0 -1
  210. package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
  211. package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
  212. package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
  213. package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
  214. package/dist/assets/today-page-BKlu6gx5.js +0 -1
  215. package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
  216. package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
  217. package/dist/assets/vendor-DHkYh85p.js +0 -1052
  218. package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
  219. package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
  220. package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
  221. package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
  222. package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
  223. package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
  224. package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
  225. package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
  226. package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
  227. package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
@@ -0,0 +1 @@
1
+ import{r as p,j as e,c2 as Ye,aG as Ze,cd as Je,aV as Ve,ce as es,c7 as ss,c5 as Ce,bO as Ie,cf as Pe,cg as as,aK as De,ch as ts,ci as rs,cj as is,ck as ns}from"./vendor-Dnkkx2co.js";import{R as Le,P as Se,O as Te,C as He,T as Ee,D as Ae,a as Be}from"./ui-C1iwpj2-.js";import{j as ls,i as me,k as ge}from"./state-vCcAT5Hq.js";import{E as os}from"./entity-note-count-link-RzBB6ujx.js";import{N as ds}from"./note-markdown-BzK2Qlgr.js";import{Q as cs,$ as us,F as b,I as q,T as ve,a0 as ms,a1 as gs,j as oe,b as F,u as xs,a2 as hs,s as bs,a3 as vs,a4 as ps,a5 as fs,a6 as ks,a7 as xe,a8 as ys,B as L,V as Fe,C as A,h as U,d as Me,a as js,_ as ws,Z as P,U as _s,c as v,a9 as Ns,aa as Cs,ab as Ke,ac as Is,ad as Ps,O as Ds}from"./index-EqQsXoat.js";import{u as Ls,p as Ss}from"./use-psyche-focus-target-Ct-acS9G.js";import{P as Ts}from"./page-hero-ffKzgyW3.js";import{S as Hs}from"./select-menu-DJsCG6rM.js";import{f as Es}from"./date-keys-Cj1G3TOn.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";const he={title:"",description:"",status:"active",userId:null,polarity:"positive",frequency:"daily",targetCount:1,weekDays:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedValueIds:[],linkedPatternIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedReportIds:[],linkedBehaviorId:"",rewardXp:12,penaltyXp:8,generatedHealthEventTemplate:{enabled:!1,workoutType:"workout",title:"",durationMinutes:45,xpReward:0,tags:[],links:[],notesTemplate:""}},As=[{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"},{value:0,label:"Sun"}];function Bs(s){return{title:s.title,description:s.description,status:s.status,userId:s.userId??null,polarity:s.polarity,frequency:s.frequency,targetCount:s.targetCount,weekDays:s.weekDays,linkedGoalIds:s.linkedGoalIds,linkedProjectIds:s.linkedProjectIds,linkedTaskIds:s.linkedTaskIds,linkedValueIds:s.linkedValueIds,linkedPatternIds:s.linkedPatternIds,linkedBehaviorIds:s.linkedBehaviorIds,linkedBeliefIds:s.linkedBeliefIds,linkedModeIds:s.linkedModeIds,linkedReportIds:s.linkedReportIds,linkedBehaviorId:s.linkedBehaviorId??"",rewardXp:s.rewardXp,penaltyXp:s.penaltyXp,generatedHealthEventTemplate:s.generatedHealthEventTemplate}}function Fs({open:s,pending:o=!1,editingHabit:d,values:f,patterns:k,behaviors:T,beliefs:c,modes:y,reports:m,goals:j,projects:H,tasks:D,users:M,defaultUserId:w=null,onOpenChange:N,onSubmit:E}){const[R,S]=p.useState(he),[te,K]=p.useState(null),[C,Z]=p.useState({});p.useEffect(()=>{s&&(S(d?Bs(d):{...he,userId:w}),K(null),Z({}))},[w,d,s]);const O=M.find(r=>r.id===w)??null,z=p.useMemo(()=>T.slice().sort((r,i)=>r.title.localeCompare(i.title)),[T]),I=r=>({linkedBehaviorIds:r,linkedBehaviorId:r[0]??""}),_=(r,i)=>r.includes(i)?r.filter(t=>t!==i):[...r,i],G=[{id:"intent",eyebrow:"Habit",title:"Name the recurring move",description:"Use habits for recurring commitments and recurring slips. Keep the title concrete so the daily check-in never needs interpretation.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Title",error:C.title??null,children:e.jsx(q,{value:r.title,onChange:t=>i({title:t.target.value}),placeholder:"Train lower body"})}),e.jsx(b,{label:"Description",children:e.jsx(ve,{value:r.description,onChange:t=>i({description:t.target.value}),placeholder:"Write the habit description in Markdown. Define what counts, edge cases, and examples."})}),e.jsx(ms,{value:r.userId,users:M,onChange:t=>i({userId:t}),label:"Owner user",defaultLabel:gs(O),help:"Habits can be owned by humans or bots. When one scoped user is active, Forge uses that as the default."})]})},{id:"shape",eyebrow:"Shape",title:"Set direction and cadence",description:"Forge uses polarity to decide whether doing the habit is good or bad, and cadence to know when it should show up.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Polarity",children:e.jsx(oe,{value:r.polarity,onChange:t=>i({polarity:t}),options:[{value:"positive",label:"Positive",description:"Doing it is aligned and should award XP."},{value:"negative",label:"Negative",description:"Doing it is a slip and should cost XP."}],columns:2})}),e.jsx(b,{label:"Frequency",children:e.jsx(oe,{value:r.frequency,onChange:t=>i({frequency:t}),options:[{value:"daily",label:"Daily",description:"Track against each day."},{value:"weekly",label:"Weekly",description:"Track only on the selected weekdays."}],columns:2})}),r.frequency==="weekly"?e.jsx(b,{label:"Weekdays",error:C.weekDays??null,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:As.map(t=>{const n=r.weekDays.includes(t.value);return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${n?"border-[color-mix(in_srgb,var(--primary)_30%,var(--ui-border-subtle)_70%)] 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:()=>i({weekDays:n?r.weekDays.filter(J=>J!==t.value):[...r.weekDays,t.value].sort()}),children:t.label},t.value)})})}):null,e.jsx(b,{label:"Status",children:e.jsx(oe,{value:r.status,onChange:t=>i({status:t}),options:[{value:"active",label:"Active",description:"Show it in the daily operating flow."},{value:"paused",label:"Paused",description:"Keep it visible but not currently due."},{value:"archived",label:"Archived",description:"Keep the record but retire it from active work."}]})})]})},{id:"generation",eyebrow:"Generation",title:"Decide whether this habit should create a workout record",description:"Use this when a completed habit should generate a structured sports or recovery session in Forge, then reconcile with HealthKit later if the same session gets imported.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Generate workout record",children:e.jsx(oe,{value:r.generatedHealthEventTemplate.enabled?"enabled":"disabled",onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,enabled:t==="enabled"}}),options:[{value:"disabled",label:"Disabled",description:"This habit only affects the habit ledger."},{value:"enabled",label:"Enabled",description:"A completed check-in creates a workout or recovery session."}],columns:2})}),r.generatedHealthEventTemplate.enabled?e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Workout type",children:e.jsx(q,{value:r.generatedHealthEventTemplate.workoutType,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,workoutType:t.target.value}}),placeholder:"mobility, walk, strength, recovery"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(b,{label:"Duration (minutes)",children:e.jsx(q,{type:"number",min:1,max:1440,value:r.generatedHealthEventTemplate.durationMinutes,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,durationMinutes:Number(t.target.value)||45}})})}),e.jsx(b,{label:"Workout XP",children:e.jsx(q,{type:"number",min:0,max:500,value:r.generatedHealthEventTemplate.xpReward,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,xpReward:Number(t.target.value)||0}})})})]}),e.jsx(b,{label:"Generated session note",children:e.jsx(ve,{value:r.generatedHealthEventTemplate.notesTemplate,onChange:t=>i({generatedHealthEventTemplate:{...r.generatedHealthEventTemplate,notesTemplate:t.target.value}}),placeholder:"Morning routine session generated from habit completion."})})]}):null]})},{id:"links",eyebrow:"Links",title:"Connect the habit to real Forge work",description:"Link habits to the goals, projects, and tasks they support so they stay anchored in the same operating graph as everything else.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(t=>{const n=r.linkedGoalIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedGoalIds:_(r.linkedGoalIds,t.id)}),children:e.jsx(F,{kind:"goal",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(t=>{const n=r.linkedProjectIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedProjectIds:_(r.linkedProjectIds,t.id)}),children:e.jsx(F,{kind:"project",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:D.map(t=>{const n=r.linkedTaskIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedTaskIds:_(r.linkedTaskIds,t.id)}),children:e.jsx(F,{kind:"task",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Values",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(t=>{const n=r.linkedValueIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedValueIds:_(r.linkedValueIds,t.id)}),children:e.jsx(F,{kind:"value",label:t.title,gradient:n,className:n?"":"opacity-75"})},t.id)})})}),e.jsx(b,{label:"Patterns",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:k.map(t=>{const n=r.linkedPatternIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedPatternIds:_(r.linkedPatternIds,t.id)}),children:e.jsx(F,{kind:"pattern",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})})]})},{id:"reward",eyebrow:"Reward",title:"Link the behavior and XP logic",description:"Habits can point back to a Psyche behavior. Reward XP is granted for aligned outcomes; penalty XP is applied for misaligned ones.",render:(r,i)=>e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Linked behavior",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:z.map(t=>{const n=r.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i(I(_(r.linkedBehaviorIds,t.id))),children:e.jsx(F,{kind:"behavior",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Beliefs",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:c.map(t=>{const n=r.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedBeliefIds:_(r.linkedBeliefIds,t.id)}),children:e.jsx(F,{kind:"belief",label:t.statement,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Modes",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:y.map(t=>{const n=r.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedModeIds:_(r.linkedModeIds,t.id)}),children:e.jsx(F,{kind:"mode",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsx(b,{label:"Reports",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:m.map(t=>{const n=r.linkedReportIds.includes(t.id);return e.jsx("button",{type:"button",onClick:()=>i({linkedReportIds:_(r.linkedReportIds,t.id)}),children:e.jsx(F,{kind:"report",label:t.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},t.id)})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(b,{label:"Target count",error:C.targetCount??null,children:e.jsx(q,{type:"number",value:r.targetCount,onChange:t=>i({targetCount:Number(t.target.value)||1})})}),e.jsx(b,{label:"Reward XP",error:C.rewardXp??null,children:e.jsx(q,{type:"number",value:r.rewardXp,onChange:t=>i({rewardXp:Number(t.target.value)||1})})}),e.jsx(b,{label:"Penalty XP",error:C.penaltyXp??null,children:e.jsx(q,{type:"number",value:r.penaltyXp,onChange:t=>i({penaltyXp:Number(t.target.value)||1})})})]})]})}];return e.jsx(cs,{open:s,onOpenChange:N,eyebrow:"Habit",title:d?"Edit habit":"Create habit",description:"Habits are recurring commitments or recurring slips with explicit XP consequences.",value:R,onChange:S,draftPersistenceKey:d?`habit.${d.id}`:"habit.new",steps:G,pending:o,pendingLabel:d?"Save habit":"Create habit",submitLabel:d?"Save habit":"Create habit",error:te,onSubmit:async()=>{K(null);const r=us.safeParse(R);if(!r.success){Z(Object.fromEntries(Object.entries(r.error.flatten().fieldErrors).map(([i,t])=>[i,t==null?void 0:t[0]]))),K("Some habit fields still need attention.");return}Z({});try{await E(r.data,d==null?void 0:d.id),S(he),N(!1)}catch(i){K(i instanceof Error?i.message:"Habit update failed.")}}})}const Ms=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ks=["S","M","T","W","T","F","S"],Xs=[{value:"name",label:"Name A-Z",description:"Keep the list stable alphabetically."},{value:"needs_attention",label:"Needs attention",description:"Bubble up habits still waiting on today."},{value:"streak",label:"Longest streak",description:"Put the strongest current streaks first."},{value:"created_at",label:"Newest created",description:"Show the most recently created habits first."},{value:"updated_at",label:"Recently updated",description:"Sort by the most recently changed habits."}];function Rs(s){return s.frequency==="daily"?`${s.targetCount}x daily`:`${s.targetCount}x weekly · ${s.weekDays.map(o=>Ms[o]).join(", ")}`}function W(s){return Es(s)}function ze(s){const[o,d,f]=s.split("-").map(Number);return new Date(o,d-1,f)}function $e(s){return new Date(s.getFullYear(),s.getMonth(),s.getDate())}function de(s,o){const d=new Date(s);return d.setDate(d.getDate()+o),d}function Xe(s){const o=$e(s),d=(o.getDay()+6)%7;return o.setDate(o.getDate()-d),o}function ee(s){const o=typeof s=="string"?ze(s):s;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(o)}function ue(s,o){return s.polarity==="positive"&&o==="done"||s.polarity==="negative"&&o==="missed"}function pe(s,o){return s.polarity==="positive"?o==="done"?"Done":"Missed":o==="done"?"Performed":"Resisted"}function qe(s){const o=W(new Date),d=s.checkIns.find(f=>f.dateKey===o)??null;return s.dueToday?{tone:"pending",label:s.frequency==="daily"?"Waiting for today":"Awaiting this week's check-in",cardClass:"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--warning)_18%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]"}:d?ue(s,d.status)?{tone:"aligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--success)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]"}:{tone:"unaligned",label:`${pe(s,d.status)} today`,cardClass:"border-[color-mix(in_srgb,var(--danger)_24%,var(--ui-border-subtle)_76%)] shadow-[var(--ui-shadow-soft)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_16%,transparent),transparent_44%)]",pillClass:"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}:s.polarity==="positive"?{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--success)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}:{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,color-mix(in_srgb,var(--danger)_9%,transparent),transparent_40%)]",pillClass:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"}}function Os(s){return s>=10?{Icon:ts,className:"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Celebration pace"}:s>=5?{Icon:rs,className:"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Locked in"}:s>=1?{Icon:is,className:"border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Building rhythm"}:{Icon:ns,className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] shadow-[var(--ui-shadow-soft)]",iconClass:"text-[var(--ui-ink-soft)]",valueClass:"text-[var(--ui-ink-strong)]",label:"Cold start"}}function zs(s){return s>=80?"border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":s>=50?"border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]"}const se="border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Re="border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",Oe="border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",ce="border-[color-mix(in_srgb,var(--warning)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",be="border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]",ae="border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[color-mix(in_srgb,var(--primary)_72%,var(--ui-ink-strong)_28%)]";function $s(s){var T;const o=new Date;if(s.frequency==="daily"){const c=$e(o),y=[];for(let m=-6;m<=0;m+=1){const j=de(c,m),H=W(j),D=s.checkIns.find(N=>N.dateKey===H)??null,M=Ks[j.getDay()],w=m===0;y.push({id:H,label:M,current:w,actionDateKey:H,actionLabel:ee(j),state:D?ue(s,D.status)?"aligned":"unaligned":"unknown",title:`${ee(j)} · ${D?pe(s,D.status):"Not informed"}`})}return{caption:"7-day rhythm",rangeLabel:"Past 7 days",showLabels:!0,startLabel:"",endLabel:"",cells:y}}const d=Xe(o),f=new Map;for(const c of s.checkIns){const y=W(Xe(ze(c.dateKey))),m=f.get(y)??[];m.push(c),f.set(y,m)}const k=[];for(let c=-6;c<=0;c+=1){const y=de(d,c*7),m=W(y),j=f.get(m)??[],H=s.weekDays.length>0?[...s.weekDays].sort((E,R)=>R-E)[0]:0,D=W(de(y,H)),M=((T=j[0])==null?void 0:T.dateKey)??D,w=j.filter(E=>ue(s,E.status)).length,N=j.length-w;k.push({id:m,label:"",current:c===0,actionDateKey:M,actionLabel:`Week of ${ee(y)}`,state:j.length===0?"unknown":w>=N?"aligned":"unaligned",title:`${ee(y)} week · ${j.length===0?"Not informed":w>=N?"Mostly aligned":"Mostly off track"}`})}return{caption:"7-week rhythm",rangeLabel:"Past 7 weeks",showLabels:!1,startLabel:ee(de(d,-42)),endLabel:"This week",cells:k}}function qs(s,o){return P("h-8 w-full rounded-[10px] border transition",s==="aligned"&&"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--success)_58%,var(--ui-surface-1)_42%)] shadow-[var(--ui-shadow-soft)]",s==="unaligned"&&"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[color-mix(in_srgb,var(--danger)_54%,var(--ui-surface-1)_46%)] shadow-[var(--ui-shadow-soft)]",s==="unknown"&&"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",o&&"ring-1 ring-[color-mix(in_srgb,var(--primary)_34%,transparent)]")}function Ws({habit:s,onSelectCell:o}){const d=$s(s),f=qe(s);return e.jsxs("div",{className:"w-full rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2.5 shadow-[var(--ui-shadow-soft)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:d.caption}),e.jsx("div",{className:"text-[11px] text-[var(--ui-ink-soft)]",children:d.rangeLabel})]}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:d.cells.map(k=>e.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-1 rounded-[10px] transition hover:bg-[var(--ui-surface-hover)]",onClick:()=>o(s,k),title:`Log check-in for ${k.actionLabel}`,"aria-label":`Log check-in for ${k.actionLabel}`,children:[e.jsx("div",{className:P(qs(k.state,k.current),"h-6 min-w-0 flex-1 rounded-[8px] transition duration-150 group-hover:-translate-y-0.5 group-hover:shadow-[var(--ui-shadow-soft)]")}),d.showLabels?e.jsx("span",{className:"hidden text-[9px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)] transition group-hover:text-[var(--ui-ink-medium)] sm:inline",children:k.label}):null]},k.id))}),e.jsx("div",{className:P("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium",f.pillClass),children:f.label})]}),d.showLabels?null:e.jsxs("div",{className:"mt-1 text-right text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-muted)]",children:[d.startLabel," - ",d.endLabel]})]})}function Gs(s){return s.polarity==="positive"?{alignedLabel:"Done",alignedDescription:"Log that the intended habit happened.",unalignedLabel:"Missed",unalignedDescription:"Log that the habit did not happen."}:{alignedLabel:"Resisted",alignedDescription:"Log that the unwanted behavior was resisted.",unalignedLabel:"Performed",unalignedDescription:"Log that the unwanted behavior happened."}}function Q(s,o){return s.polarity==="positive"?o==="aligned"?"done":"missed":o==="aligned"?"missed":"done"}function Y(s,o){return ue(s,o)?"aligned":"unaligned"}function oa(){var ke,ye,je,we,_e,Ne;const s=xs(),o=ls(),[d,f]=Ye(),[k,T]=p.useState(null),[c,y]=p.useState(null),[m,j]=p.useState(null),[H,D]=p.useState(""),[M,w]=p.useState(!1),[N,E]=p.useState(null),[R,S]=p.useState(null),te=d.get("focus"),K=d.get("orderBy")??"name",C=hs(s.selectedUserIds),Z=bs(C),O=["forge-habits",K,...C];Ls(te);const z=me({queryKey:O,queryFn:async()=>(await Is({userIds:C,orderBy:K})).habits}),I=me({queryKey:["forge-psyche-overview",...C],queryFn:async()=>(await Ps(C)).overview}),_=me({queryKey:["forge-life-force",...C],queryFn:async()=>(await Ds(C)).lifeForce});p.useEffect(()=>{d.get("create")==="1"&&(T(null),w(!0),f(a=>{const h=new URLSearchParams(a);return h.delete("create"),h},{replace:!0}))},[d,f]);const G=async()=>{await o.invalidateQueries({queryKey:["forge-habits"]}),await s.refresh()},r=ge({mutationFn:async({input:a,habitId:h})=>h?(await vs(h,a)).habit:(await ps(a)).habit,onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit save failed.")}}),i=ge({mutationFn:async({habitId:a,status:h,dateKey:u,note:$})=>fs(a,{status:h,dateKey:u,note:$}),onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit check-in failed.")}}),t=ge({mutationFn:async a=>ks(a),onMutate:async a=>{await o.cancelQueries({queryKey:O});const h=o.getQueryData(O);return o.setQueryData(O,u=>(u==null?void 0:u.filter($=>$.id!==a))??[]),{previousHabits:h}},onSuccess:async()=>{S(null),E(null),await G()},onError:(a,h,u)=>{u!=null&&u.previousHabits&&o.setQueryData(O,u.previousHabits),S(a instanceof Error?a.message:"Habit delete failed.")}}),n=p.useMemo(()=>(z.data??[]).filter(a=>a.status!=="archived"),[z.data]),J=p.useMemo(()=>n.filter(a=>a.dueToday),[n]),We=p.useMemo(()=>J.reduce((a,h)=>{var re;const u=Ke().totalAp,$=((re=xe(h))==null?void 0:re.totalAp)??0;return a+u+$},0),[J]),Ge=p.useMemo(()=>n.reduce((a,h)=>{var u;return a+(((u=xe(h))==null?void 0:u.totalAp)??0)},0),[n]),X=p.useMemo(()=>c?c.habit.checkIns.find(a=>a.dateKey===c.cell.actionDateKey)??null:null,[c]);if(p.useEffect(()=>{if(!c){j(null),D("");return}j((X==null?void 0:X.status)??null),D((X==null?void 0:X.note)??"")},[c,X]),z.error)throw z.error;const Ue=a=>{f(h=>{const u=new URLSearchParams(h);return a==="name"?u.delete("orderBy"):u.set("orderBy",a),u},{replace:!0})},V=c?Gs(c.habit):null,fe=m==="done"||m==="missed"||X!==null;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ts,{entityKind:"habit",title:e.jsx(Fe,{kind:"habit",label:"Habits",variant:"heading",size:"lg"}),titleText:"Habits",description:"Habits track recurring commitments and recurring slips with explicit daily consequences, linked behaviors, and real XP movement.",badge:`${n.length} habits`,actions:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(ys,{metrics:s.snapshot.metrics}),e.jsxs(L,{onClick:()=>{T(null),w(!0)},children:[e.jsx(Ze,{className:"size-4"}),"New habit"]})]})}),R?e.jsx(A,{className:"border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Je,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("div",{children:R})]})}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Due today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:J.length}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habits that still need a check-in today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--primary)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Habit AP due"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:U(We)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Default Action Point load if every due habit is logged today."})]}),e.jsxs(A,{className:"border-[color-mix(in_srgb,var(--success)_22%,var(--ui-border-subtle)_78%)] shadow-[var(--ui-shadow-soft)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Best streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",children:Math.max(0,...n.map(a=>a.streakCount))}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Longest current aligned streak across active habits."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Average alignment"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[n.length>0?Math.round(n.reduce((a,h)=>a+h.completionRate,0)/n.length):0,"%"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Share of recent habit check-ins that matched the intended direction."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?`${U(_.data.spentTodayAp)} / ${U(_.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit check-ins debit the same Action Point ledger as work, notes, movement, and workouts."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:_.data?Me(_.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Use this to tell whether now is a good moment for heavier habits or just a light check-in."})]}),e.jsxs(A,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Workout-linked load"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U(Ge)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Habit-generated workout templates stay visible as Action Point cost instead of hiding behind the XP reward."})]})]}),z.isLoading?e.jsx(A,{children:"Loading habits..."}):n.length===0?e.jsx(js,{eyebrow:"Habits",title:"No recurring habits yet",description:"Create the recurring commitments or recurring slips you want Forge to track explicitly. Positive habits pay out when completed. Negative habits invert that logic.",action:e.jsx(L,{onClick:()=>{T(null),w(!0)},children:"Create habit"})}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 shadow-[var(--ui-shadow-soft)] sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"max-w-xl",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Habit list order"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Choose a stable ordering so the list does not reshuffle while you are logging check-ins."})]}),e.jsx(Hs,{label:"Order by",value:K,options:Xs,onChange:Ue,className:"w-full sm:w-[19rem]"})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:n.map(a=>{const h=qe(a),u=Os(a.streakCount),$=u.Icon,re=Ke(),ie=xe(a),Qe=ws(s.snapshot.dashboard.notesSummaryByEntity,"habit",a.id).count,ne=a.polarity==="positive"?{label:"Done",status:Q(a,"aligned"),Icon:Ie,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"}:{label:"Resisted",status:Q(a,"aligned"),Icon:Ce,className:"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--success)_24%,var(--ui-surface-hover)_76%)]"},le=a.polarity==="positive"?{label:"Missed",status:Q(a,"unaligned"),Icon:Pe,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"}:{label:"Performed",status:Q(a,"unaligned"),Icon:as,className:"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]"};return e.jsxs(A,{className:P("relative flex h-full flex-col overflow-hidden",h.cardClass,Ss(te===a.id)),"data-psyche-focus-id":a.id,children:[e.jsx("div",{className:P("pointer-events-none absolute inset-0 opacity-100",h.overlayClass)}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:"habit",label:a.title,variant:"heading",size:"sm"}),e.jsx(_s,{user:a.user,compact:!0}),e.jsx(v,{className:se,children:a.status}),e.jsxs(v,{className:se,children:[e.jsx(Ve,{className:"mr-1 size-3.5"}),Rs(a)]}),e.jsx(v,{className:a.polarity==="positive"?Re:Oe,children:a.polarity==="positive"?"Positive":"Negative"}),a.dueToday?e.jsx(v,{className:ce,children:"Needs check-in"}):null,a.linkedGoalIds.slice(0,1).map(g=>{const l=s.snapshot.goals.find(x=>x.id===g);return l?e.jsxs(v,{className:ce,children:["Goal · ",l.title]},l.id):null}),a.linkedProjectIds.slice(0,1).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(0,1).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:a.description?e.jsx(ds,{markdown:a.description,className:"[&>p]:text-sm [&>p]:leading-6 [&>blockquote]:text-sm [&>ul]:text-sm [&>ol]:text-sm"}):"No extra notes yet."})]}),e.jsxs("div",{className:"ml-auto inline-flex shrink-0 flex-col items-end gap-2 self-start text-right",children:[e.jsxs("div",{className:P("inline-flex flex-col self-end rounded-[20px] px-3 py-2.5 text-right",u.className),children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5 text-[10px] uppercase tracking-[0.16em]",children:[e.jsx("span",{children:"Streak"}),e.jsx($,{className:P("size-3.5 shrink-0",u.iconClass)})]}),e.jsx("div",{className:P("mt-1.5 font-display text-[2.75rem] leading-none",u.valueClass),children:a.streakCount}),e.jsx("div",{className:"mt-1 text-[11px] leading-tight text-[var(--ui-ink-soft)]",children:u.label})]}),e.jsxs("div",{className:"ml-auto grid grid-cols-2 gap-1.5",children:[e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:r.isPending,onClick:()=>{T(a),w(!0)},"aria-label":`Edit ${a.title}`,title:"Edit habit",children:e.jsx(es,{className:"size-4"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:t.isPending,onClick:()=>E(a),"aria-label":`Delete ${a.title}`,title:"Delete habit",children:e.jsx(ss,{className:"size-4"})})]})]})]}),e.jsxs("div",{className:"mt-auto grid gap-4 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(v,{className:P("",zs(a.completionRate)),children:["Alignment ",a.completionRate,"%"]}),e.jsx(v,{className:se,children:a.polarity==="positive"?`+${a.rewardXp} XP done`:`+${a.rewardXp} XP resisted`}),e.jsx(v,{className:se,children:a.polarity==="positive"?`-${a.penaltyXp} XP missed`:`-${a.penaltyXp} XP performed`}),e.jsxs(v,{className:ae,children:[U(re.totalAp)," check-in"]}),ie?e.jsxs(v,{className:ce,children:[U(ie.totalAp)," ","workout"]}):null,ie?e.jsx(v,{className:se,children:Me(ie.rateApPerHour)}):null,e.jsx(os,{entityType:"habit",entityId:a.id,count:Qe,className:"min-h-8 rounded-full border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"}),a.linkedBehaviorTitles.slice(0,2).map(g=>e.jsxs(v,{className:ce,children:[e.jsx(Ce,{className:"mr-1 size-3.5"}),g]},g)),a.linkedProjectIds.slice(1,2).map(g=>{const l=s.snapshot.dashboard.projects.find(x=>x.id===g);return l?e.jsxs(v,{className:be,children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(1,2).map(g=>{const l=s.snapshot.tasks.find(x=>x.id===g);return l?e.jsxs(v,{className:ae,children:["Task · ",l.title]},l.id):null}),a.linkedValueIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.values.find(B=>B.id===g);return l?e.jsxs(v,{className:Re,children:["Value · ",l.title]},l.id):null}),a.linkedPatternIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.patterns.find(B=>B.id===g);return l?e.jsxs(v,{className:be,children:["Pattern · ",l.title]},l.id):null}),a.linkedBeliefIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.beliefs.find(B=>B.id===g);return l?e.jsxs(v,{className:Oe,children:["Belief · ",l.statement]},l.id):null}),a.linkedModeIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.modes.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Mode · ",l.title]},l.id):null}),a.linkedReportIds.slice(0,2).map(g=>{var x;const l=(x=I.data)==null?void 0:x.reports.find(B=>B.id===g);return l?e.jsxs(v,{className:ae,children:["Report · ",l.title]},l.id):null})]}),e.jsx("div",{className:"grid gap-4",children:e.jsx(Ws,{habit:a,onSelectCell:(g,l)=>{y({habit:g,cell:l}),S(null)}})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",ne.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:ne.status,dateKey:W(new Date)}),children:[e.jsx(ne.Icon,{className:"size-4"}),ne.label]}),e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",le.className),disabled:i.isPending,onClick:()=>void i.mutateAsync({habitId:a.id,status:le.status,dateKey:W(new Date)}),children:[e.jsx(le.Icon,{className:"size-4"}),le.label]})]})]})]})]},a.id)})})]}),e.jsx(Fs,{open:M,pending:r.isPending,editingHabit:k,values:((ke=I.data)==null?void 0:ke.values)??[],patterns:((ye=I.data)==null?void 0:ye.patterns)??[],behaviors:((je=I.data)==null?void 0:je.behaviors)??[],beliefs:((we=I.data)==null?void 0:we.beliefs)??[],modes:((_e=I.data)==null?void 0:_e.modes)??[],reports:((Ne=I.data)==null?void 0:Ne.reports)??[],goals:s.snapshot.dashboard.goals,projects:s.snapshot.dashboard.projects,tasks:s.snapshot.tasks,users:s.snapshot.users,defaultUserId:(k==null?void 0:k.userId)??Z,onOpenChange:w,onSubmit:async(a,h)=>{try{await r.mutateAsync({input:a,habitId:h})}catch(u){throw u instanceof Ns,u}}}),e.jsx(Le,{open:N!==null,onOpenChange:a=>{!a&&!t.isPending&&E(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(30rem,calc(100vw-2rem))] max-w-[30rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex 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-[var(--ui-ink-faint)]",children:"Delete habit"}),e.jsx(Ee,{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:(N==null?void 0:N.title)??"Delete this habit?"}),e.jsx(Ae,{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"Remove this habit from Forge. The habit card disappears immediately after delete succeeds."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close delete habit modal",title:"Close",disabled:t.isPending,children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm leading-6 text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",children:"This removes the habit and its check-in history from the habits page."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>E(null),disabled:t.isPending,children:"Cancel"}),e.jsx(L,{className:"border border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] hover:bg-[color-mix(in_srgb,var(--danger)_22%,var(--ui-surface-hover)_78%)]",pending:t.isPending,pendingLabel:"Deleting",onClick:()=>{N&&t.mutateAsync(N.id)},children:"Delete habit"})]})]})]})]})}),e.jsx(Le,{open:c!==null,onOpenChange:a=>{a||y(null)},children:e.jsxs(Se,{children:[e.jsx(Te,{className:"surface-overlay fixed inset-0 z-40 backdrop-blur-xl"}),e.jsxs(He,{className:"surface-modal-panel fixed inset-x-4 top-1/2 z-50 mx-auto w-[min(42rem,calc(100vw-2rem))] max-w-[42rem] -translate-y-1/2 overflow-hidden rounded-[30px] border",children:[e.jsx(Ee,{className:"sr-only",children:"Habit history"}),e.jsx(Ae,{className:"sr-only",children:"Log or revise a habit check-in for a selected history point."}),c&&V?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-b border-[var(--ui-border-subtle)] px-5 py-4",children:e.jsxs("div",{className:"flex 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-[var(--ui-ink-faint)]",children:"Habit history"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-lg font-semibold text-[var(--ui-ink-strong)]",children:c.habit.title}),e.jsx(v,{children:c.cell.actionLabel})]}),e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:c.habit.frequency==="daily"?"Log or revise the check-in for this specific day.":"Log or revise the representative check-in for this week."})]}),e.jsx(Be,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-0 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close history modal",title:"Close",children:e.jsx(De,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="aligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="aligned"?"border-[color-mix(in_srgb,var(--success)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="aligned"?null:Q(c.habit,"aligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Ie,{className:"size-4"}),V.alignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.alignedDescription})]}),e.jsxs("button",{type:"button","aria-pressed":m!==null&&Y(c.habit,m)==="unaligned",className:P("rounded-[22px] border px-4 py-4 text-left transition",m!==null&&Y(c.habit,m)==="unaligned"?"border-[color-mix(in_srgb,var(--danger)_34%,var(--ui-border-subtle)_66%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] shadow-[var(--ui-shadow-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>j(a=>a!==null&&Y(c.habit,a)==="unaligned"?null:Q(c.habit,"unaligned")),children:[e.jsxs("div",{className:"flex items-center gap-2 text-base font-medium",children:[e.jsx(Pe,{className:"size-4"}),V.unalignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:V.unalignedDescription})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Optional note"}),e.jsx(ve,{value:H,onChange:a=>D(a.target.value),placeholder:"Add context for what happened on this day or week.",className:"min-h-24"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(L,{variant:"secondary",onClick:()=>y(null),disabled:i.isPending,children:"Cancel"}),e.jsx(L,{disabled:i.isPending||!fe,pending:i.isPending,pendingLabel:"Saving",onClick:async()=>{fe&&(m===null?(await Cs(c.habit.id,c.cell.actionDateKey),await G()):await i.mutateAsync({habitId:c.habit.id,status:m,dateKey:c.cell.actionDateKey,note:H.trim()||void 0}),y(null))},children:"Save check-in"})]})]})]}):null]})]})})]})}export{oa as HabitsPage};