forge-openclaw-plugin 0.2.102 → 0.2.104

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 (175) hide show
  1. package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
  2. package/dist/assets/{ai-surface-workspace-xtB5RFQu.js → ai-surface-workspace-CutiG6uS.js} +1 -1
  3. package/dist/assets/{atlas-panel-B3dPHCmZ.js → atlas-panel-jgMRyaHn.js} +1 -1
  4. package/dist/assets/{board-DqHzdCPQ.js → board-dIX6etHh.js} +1 -1
  5. package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
  6. package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
  7. package/dist/assets/{calendar-week-toolbar-BZ_-X3Wb.js → calendar-week-toolbar-nVhgB-0s.js} +1 -1
  8. package/dist/assets/{charts-FcU0F3XV.js → charts-DFnEuIMB.js} +1 -1
  9. package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
  10. package/dist/assets/{daily-metrics-dashboard-BMyL0Qr4.js → daily-metrics-dashboard-CiJkkkd1.js} +1 -1
  11. package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
  12. package/dist/assets/{entity-notes-surface-CBylYDwy.js → entity-notes-surface-Djz50HvD.js} +1 -1
  13. package/dist/assets/execution-board-CtPhI-58.js +1 -0
  14. package/dist/assets/{faceted-token-search-D7xPWfOl.js → faceted-token-search-DEC6ANa9.js} +1 -1
  15. package/dist/assets/{flagship-signal-deck-BEFKOhvx.js → flagship-signal-deck-CtHC3mql.js} +1 -1
  16. package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
  17. package/dist/assets/{forms-CmLAyGqz.js → forms-hB0SqEh-.js} +1 -1
  18. package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
  19. package/dist/assets/goals-page-fsY8NzGB.js +1 -0
  20. package/dist/assets/{graph-BTa79qum.js → graph-DDUZNRsO.js} +1 -1
  21. package/dist/assets/habits-page-COoGz4kj.js +1 -0
  22. package/dist/assets/index-BAXYM89v.css +1 -0
  23. package/dist/assets/index-EqQsXoat.js +19 -0
  24. package/dist/assets/{insight-flow-dialog-BtIQXXsS.js → insight-flow-dialog-DtX_5W7g.js} +1 -1
  25. package/dist/assets/insights-page-cBd74ObU.js +8 -0
  26. package/dist/assets/kanban-page-CYav9THw.js +1 -0
  27. package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
  28. package/dist/assets/{life-force-page-BGDkKfbJ.js → life-force-page-CACGlNhq.js} +1 -1
  29. package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
  30. package/dist/assets/{maps-CF1RagUX.js → maps-C-yOWiDN.js} +1 -1
  31. package/dist/assets/{metric-tile-4iMd_WnJ.js → metric-tile-CMadwnGz.js} +1 -1
  32. package/dist/assets/{motion-CfdU2F35.js → motion-Lt5B1XuE.js} +1 -1
  33. package/dist/assets/movement-page-D5VqFd2q.js +1 -0
  34. package/dist/assets/{note-markdown-CsGQhQXF.js → note-markdown-BzK2Qlgr.js} +1 -1
  35. package/dist/assets/{note-tags-input-DdZi93tj.js → note-tags-input-CZzqJMLc.js} +1 -1
  36. package/dist/assets/notes-page-D3Hsh90C.js +1 -0
  37. package/dist/assets/{open-in-graph-button-C0TGev7c.js → open-in-graph-button-BFPKfyK3.js} +1 -1
  38. package/dist/assets/{orbit-map-DVXkfQdd.js → orbit-map-CnyfSmOG.js} +1 -1
  39. package/dist/assets/{overview-page-BwMlFQKX.js → overview-page-CXdWrOV1.js} +1 -1
  40. package/dist/assets/{page-hero-oFHaAjtL.js → page-hero-ffKzgyW3.js} +1 -1
  41. package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
  42. package/dist/assets/{preference-entity-handoff-button-DOKV9bZc.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
  43. package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
  44. package/dist/assets/project-collections-qSqp90HN.js +1 -0
  45. package/dist/assets/{project-detail-page-DogvVNEn.js → project-detail-page-BifhiLQX.js} +1 -1
  46. package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
  47. package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
  48. package/dist/assets/projects-page-ptcx6H38.js +1 -0
  49. package/dist/assets/{psyche-behaviors-page-BeVlXvbj.js → psyche-behaviors-page-BDwXyDta.js} +1 -1
  50. package/dist/assets/{psyche-flashcards-page-CqAWCO4E.js → psyche-flashcards-page-DL1BP1jX.js} +1 -1
  51. package/dist/assets/{psyche-goal-map-page-IyNnbk_W.js → psyche-goal-map-page-ovcpisx1.js} +1 -1
  52. package/dist/assets/{psyche-graph-IkUQRaDK.js → psyche-graph-EP5GL612.js} +1 -1
  53. package/dist/assets/{psyche-metrics-page-uai0a7Lx.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
  54. package/dist/assets/{psyche-mode-guide-page-C7p-ABiF.js → psyche-mode-guide-page-C0g27Xpt.js} +1 -1
  55. package/dist/assets/{psyche-modes-page-CLQ5V3w0.js → psyche-modes-page-BjKjX5MR.js} +1 -1
  56. package/dist/assets/{psyche-page-NQBHkkpU.js → psyche-page-F4tF2W70.js} +1 -1
  57. package/dist/assets/{psyche-patterns-page-BkRiNpI_.js → psyche-patterns-page-B-14hukK.js} +1 -1
  58. package/dist/assets/{psyche-questionnaire-builder-page-Du-7HwPC.js → psyche-questionnaire-builder-page-BdXmoHvK.js} +1 -1
  59. package/dist/assets/{psyche-questionnaire-detail-page-C5-yf8MF.js → psyche-questionnaire-detail-page-Cu5uwlJu.js} +1 -1
  60. package/dist/assets/{psyche-questionnaire-run-detail-page-CoSH5O6R.js → psyche-questionnaire-run-detail-page-C3R4PClg.js} +1 -1
  61. package/dist/assets/{psyche-questionnaire-run-page-ChI7c1wy.js → psyche-questionnaire-run-page-Div3iDdt.js} +1 -1
  62. package/dist/assets/{psyche-questionnaires-page-xUcJJzbI.js → psyche-questionnaires-page-DpqAPQCp.js} +1 -1
  63. package/dist/assets/{psyche-report-detail-page-BPrZCFZS.js → psyche-report-detail-page-BvWVDKP3.js} +1 -1
  64. package/dist/assets/{psyche-reports-page-D2EXJmm6.js → psyche-reports-page-BrbWUlAq.js} +1 -1
  65. package/dist/assets/{psyche-schemas-RcZYaokx.js → psyche-schemas-Dxj554nU.js} +1 -1
  66. package/dist/assets/{psyche-schemas-beliefs-page-h0ooZ1lp.js → psyche-schemas-beliefs-page-DYKvAtSD.js} +1 -1
  67. package/dist/assets/{psyche-screen-time-page-_3-4LikV.js → psyche-screen-time-page-CAOKCyQw.js} +1 -1
  68. package/dist/assets/{psyche-self-observation-page-BdbCsgR5.js → psyche-self-observation-page-F0MVA0UH.js} +1 -1
  69. package/dist/assets/{psyche-values-page-DuUVki5e.js → psyche-values-page-DyvX-d0o.js} +1 -1
  70. package/dist/assets/{report-chain-fields-BBMz0sGI.js → report-chain-fields-CeC1cJFS.js} +1 -1
  71. package/dist/assets/rewards-page-C2loyODo.js +1 -0
  72. package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
  73. package/dist/assets/{schema-badge-D93RcG36.js → schema-badge-FY7818qB.js} +1 -1
  74. package/dist/assets/{select-menu-Cdq7foRu.js → select-menu-DJsCG6rM.js} +1 -1
  75. package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
  76. package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
  77. package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
  78. package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
  79. package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
  80. package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
  81. package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
  82. package/dist/assets/settings-page-1cArlSPM.js +1 -0
  83. package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
  84. package/dist/assets/{settings-section-nav-Dc4IeVBt.js → settings-section-nav-DP9o4peU.js} +1 -1
  85. package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
  86. package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
  87. package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
  88. package/dist/assets/sports-page-BldIiclr.js +1 -0
  89. package/dist/assets/{state-VYvD1QVP.js → state-vCcAT5Hq.js} +1 -1
  90. package/dist/assets/strategies-page-CaTN99qj.js +1 -0
  91. package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
  92. package/dist/assets/{strategy-dialog-DMyRKrWf.js → strategy-dialog-7X7peRzu.js} +1 -1
  93. package/dist/assets/{surface-Bfz_sLX6.js → surface-CJI17F3n.js} +1 -1
  94. package/dist/assets/{table-C0VTeqw0.js → table-BNqMG3_S.js} +1 -1
  95. package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
  96. package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
  97. package/dist/assets/today-page-BjDijtn8.js +1 -0
  98. package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
  99. package/dist/assets/{ui-CsEkP2V8.js → ui-C1iwpj2-.js} +1 -1
  100. package/dist/assets/{use-psyche-focus-target-qxT5Oy_z.js → use-psyche-focus-target-Ct-acS9G.js} +1 -1
  101. package/dist/assets/{vendor-kIz9EZnX.js → vendor-Dnkkx2co.js} +3 -3
  102. package/dist/assets/{vitals-page-Dz1Jt5H8.js → vitals-page-CE9zdGLF.js} +1 -1
  103. package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
  104. package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
  105. package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
  106. package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
  107. package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
  108. package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
  109. package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
  110. package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
  111. package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
  112. package/dist/assets/{workout-detail-page-DD9IGN6l.js → workout-detail-page-DT-c5cHL.js} +2 -2
  113. package/dist/index.html +9 -9
  114. package/dist/server/server/src/app.js +22 -3
  115. package/dist/server/server/src/health-weight-loss.js +114 -39
  116. package/dist/server/server/src/repositories/model-settings.js +9 -3
  117. package/dist/server/server/src/watch-mobile.js +28 -0
  118. package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
  119. package/dist/server/src/lib/api.js +10 -1
  120. package/openclaw.plugin.json +1 -1
  121. package/package.json +1 -1
  122. package/dist/assets/activity-page-CgF7K2ww.js +0 -1
  123. package/dist/assets/calendar-page-C1Wfd2Fy.js +0 -1
  124. package/dist/assets/calendar-rules-CaZXtlxt.js +0 -1
  125. package/dist/assets/companion-sync-lab-page-NgeK-O-P.js +0 -1
  126. package/dist/assets/entity-note-count-link-BrS1-O0o.js +0 -1
  127. package/dist/assets/execution-board-CpO2ch6v.js +0 -1
  128. package/dist/assets/floating-action-menu-zzC2r0Ob.js +0 -1
  129. package/dist/assets/goal-detail-page-JK_Nva8e.js +0 -1
  130. package/dist/assets/goals-page-yeoJ06Vw.js +0 -1
  131. package/dist/assets/habits-page-Dx5EhkJi.js +0 -1
  132. package/dist/assets/index-BHIKoiZ6.js +0 -19
  133. package/dist/assets/index-H8R-ABM3.css +0 -1
  134. package/dist/assets/insights-page-CujrosD_.js +0 -8
  135. package/dist/assets/kanban-page-Q9NuIz5w.js +0 -1
  136. package/dist/assets/knowledge-graph-page-DaJmlvvM.js +0 -1
  137. package/dist/assets/life-force-workspace-CLVexVnb.js +0 -1
  138. package/dist/assets/movement-page-ClaoTNuX.js +0 -1
  139. package/dist/assets/notes-page-DYI8s3NN.js +0 -1
  140. package/dist/assets/pill-cluster-7UZd_lHp.js +0 -1
  141. package/dist/assets/preferences-page-BrKEkmfD.js +0 -1
  142. package/dist/assets/project-collections-CZagCmeH.js +0 -1
  143. package/dist/assets/project-management-hierarchy-page-Dr7hW9PW.js +0 -1
  144. package/dist/assets/project-management-section-nav-BLdAgTge.js +0 -1
  145. package/dist/assets/projects-page-UKrby_5-.js +0 -1
  146. package/dist/assets/rewards-page-PZFPa6rR.js +0 -1
  147. package/dist/assets/scheduling-rules-editor-B9KNKsQz.js +0 -1
  148. package/dist/assets/settings-agents-page-DPx2F6wf.js +0 -6
  149. package/dist/assets/settings-bin-page-COwP3gjo.js +0 -1
  150. package/dist/assets/settings-calendar-page-C-ghE0YT.js +0 -5
  151. package/dist/assets/settings-data-page-CBubzKBw.js +0 -1
  152. package/dist/assets/settings-logs-page-uOuXMeBm.js +0 -1
  153. package/dist/assets/settings-mobile-page-C5rfj8_r.js +0 -1
  154. package/dist/assets/settings-models-page-DijmUWdU.js +0 -1
  155. package/dist/assets/settings-page-B4u5TR5g.js +0 -1
  156. package/dist/assets/settings-rewards-page-COiTwkMH.js +0 -1
  157. package/dist/assets/settings-users-page-DEGa5DNn.js +0 -1
  158. package/dist/assets/settings-wiki-page-Cvsiz5_e.js +0 -1
  159. package/dist/assets/sleep-page-BnSOwkEU.js +0 -1
  160. package/dist/assets/sports-page-l1RqXzA_.js +0 -1
  161. package/dist/assets/strategies-page-DEnPlpAs.js +0 -1
  162. package/dist/assets/strategy-detail-page-Ls8bxKeH.js +0 -1
  163. package/dist/assets/task-detail-page-CgrYgQLD.js +0 -1
  164. package/dist/assets/timebox-planning-dialog-Ww0NGLLo.js +0 -1
  165. package/dist/assets/today-page-CIuFHMi1.js +0 -1
  166. package/dist/assets/training-load-page-BIwc648i.js +0 -1
  167. package/dist/assets/weekly-review-page-BFpBe1kI.js +0 -1
  168. package/dist/assets/weight-loss-page-BgMoBpBt.js +0 -5
  169. package/dist/assets/wiki-article-markdown-gsPTXTg1.js +0 -4
  170. package/dist/assets/wiki-editor-page-BpAZHooY.js +0 -26
  171. package/dist/assets/wiki-ingest-history-page-C-ig8O22.js +0 -1
  172. package/dist/assets/wiki-ingest-modal-BK4eQgqs.js +0 -1
  173. package/dist/assets/wiki-page-CMTZ60Zt.js +0 -1
  174. package/dist/assets/workbench-flow-page-BIpWUcLJ.js +0 -5
  175. package/dist/assets/workbench-page-CtCjYSRe.js +0 -1
@@ -1 +0,0 @@
1
- import{r as p,j as e,aV as tt,aG as He,c3 as Lt,b5 as Rt,c2 as Kt,c4 as oe,c5 as Me,c6 as Ht,c7 as ze,c8 as Bt,c9 as Ut,bK as at,ca as $e,bc as Wt,cb as it,bg as Qt}from"./vendor-kIz9EZnX.js";import{w as qt,j as Zt,i as rt,k as $}from"./state-VYvD1QVP.js";import{g as bt,b as Be,F as j,I as P,T as Gt,e as be,c as S,d as ee,h as ce,j as we,k as We,m as Yt,n as wt,Q as Qe,o as vt,p as ft,q as Xt,u as Jt,s as Vt,t as ea,v as ta,w as aa,x as ia,y as nt,z as ra,A as na,D as sa,G as la,H as ye,S as oa,E as da,C as Z,J as ca,K as ma,B as G,M as ua,i as ha,N as pa,O as ga}from"./index-BHIKoiZ6.js";import{C as xa}from"./calendar-week-toolbar-BZ_-X3Wb.js";import{T as ya,a as ba}from"./timebox-planning-dialog-Ww0NGLLo.js";import{W as Ue,m as st,a as wa,s as _e,b as Le,c as va,f as Re}from"./calendar-ui-Cy1XRwzV.js";import{P as fa}from"./page-hero-oFHaAjtL.js";import{F as ka}from"./floating-action-menu-zzC2r0Ob.js";import{r as ja,b as Aa,g as lt}from"./calendar-display-preferences-Cid-2RnL.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./scheduling-rules-editor-B9KNKsQz.js";function ot(a,n){const d=new Date(a);return Number.isNaN(d.getTime())?n:d.toISOString()}function de(a){const n=new Date(a);return new Date(n.getTime()-n.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function dt(a,n){var y,b,v,m,N;const d=new Date,w=new Date(d.getTime()+30*6e4),x=new Date(w.getTime()+60*6e4);return{title:(n==null?void 0:n.title)??(a==null?void 0:a.title)??"",description:(n==null?void 0:n.description)??(a==null?void 0:a.description)??"",location:(n==null?void 0:n.location)??(a==null?void 0:a.location)??"",placeAddress:((y=n==null?void 0:n.place)==null?void 0:y.address)??((b=a==null?void 0:a.place)==null?void 0:b.address)??"",placeTimezone:((v=n==null?void 0:n.place)==null?void 0:v.timezone)??((m=a==null?void 0:a.place)==null?void 0:m.timezone)??"",startAtLocal:a?de(a.startAt):n!=null&&n.startAt?de(n.startAt):de(w.toISOString()),endAtLocal:a?de(a.endAt):n!=null&&n.endAt?de(n.endAt):de(x.toISOString()),timezone:(n==null?void 0:n.timezone)??(a==null?void 0:a.timezone)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:(n==null?void 0:n.availability)??(a==null?void 0:a.availability)??"busy",activityPresetKey:ft(a==null?void 0:a.actionProfile),customSustainRateApPerHour:vt(a==null?void 0:a.actionProfile),preferredCalendarId:n&&"preferredCalendarId"in n?n.preferredCalendarId:(a==null?void 0:a.calendarId)??void 0,categoriesText:((N=n==null?void 0:n.categories)==null?void 0:N.join(", "))??(a==null?void 0:a.categories.join(", "))??"",linkQuery:"",links:(n==null?void 0:n.links)??(a==null?void 0:a.links.map(F=>({entityType:F.entityType,entityId:F.entityId,relationshipType:F.relationshipType,label:`${F.entityType.replaceAll("_"," ")} · ${F.entityId}`})))??[]}}function Sa({open:a,onOpenChange:n,writableCalendars:d,linkOptions:w,event:x,seed:y,onSubmit:b,pending:v=!1}){const[m,N]=p.useState(()=>dt(x,y)),[F,c]=p.useState(null);p.useEffect(()=>{a&&(N(dt(x,y)),c(null))},[x,a,y]);const A=p.useMemo(()=>w.map(s=>{const g=bt(s.entityType);return{value:`${s.entityType}:${s.entityId}`,label:s.label,description:s.subtitle,searchText:`${s.label} ${s.subtitle} ${s.entityType}`,kind:g??void 0,menuBadge:g?e.jsx(Be,{kind:g,label:s.label,compact:!0,gradient:!1}):void 0,badge:g?e.jsx(Be,{kind:g,label:s.label,compact:!0}):void 0}}),[w]),u=p.useMemo(()=>[{id:"identity",eyebrow:"Event",title:x?"Refine the Forge event":"Create a Forge calendar event",description:"This event belongs to Forge first. If you choose a writable calendar, Forge will also project it to the connected provider.",render:(s,g)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(j,{label:"Title",children:e.jsx(P,{value:s.title,onChange:o=>g({title:o.target.value}),placeholder:"Weekly research supervision"})}),e.jsx(j,{label:"Description",children:e.jsx(Gt,{value:s.description,onChange:o=>g({description:o.target.value}),placeholder:"Agenda, context, or outcomes you want this event to carry."})}),e.jsx(j,{label:"Location",children:e.jsx(P,{value:s.location,onChange:o=>g({location:o.target.value}),placeholder:"Clinic room 2 or Zoom"})}),e.jsx(j,{label:"Place address",children:e.jsx(P,{value:s.placeAddress,onChange:o=>g({placeAddress:o.target.value}),placeholder:"Bahnhofstrasse 10, Zurich"})}),e.jsx(j,{label:"Place timezone",children:e.jsx(P,{value:s.placeTimezone,onChange:o=>g({placeTimezone:o.target.value}),placeholder:"Europe/Zurich"})})]})},{id:"timing",eyebrow:"Timing",title:"Set the time and visibility",description:"Forge stores the real event window, timezone, and whether it should behave like a busy or free slot for scheduling rules.",render:(s,g)=>e.jsxs("div",{className:"grid gap-4",children:[(()=>{const o=new Date().toISOString(),_=new Date(Date.now()+3600*1e3).toISOString(),M=be({title:s.title,availability:s.availability,activityPresetKey:s.activityPresetKey,customSustainRateApPerHour:s.customSustainRateApPerHour,startAt:ot(s.startAtLocal,o),endAt:ot(s.endAtLocal,_)});return e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:"bg-white/[0.08] text-white/74",children:ee(M.rateApPerHour)}),e.jsx(S,{className:"bg-white/[0.08] text-white/74",children:ce(M.totalAp)})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:"Availability controls whether the event blocks planning. The activity profile controls AP drain, and you can override it with a custom AP per hour."})]})})(),e.jsx(j,{label:"Activity profile",children:e.jsx(we,{value:s.activityPresetKey??(s.availability==="busy"?"meeting":"light_context"),columns:3,onChange:o=>g({activityPresetKey:o}),options:We().filter(o=>o.key!=="task_inherited").map(o=>({value:o.key,label:o.label,description:`${ee(o.defaultRateApPerHour)} · ${o.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:s.customSustainRateApPerHour??"",onChange:o=>g({customSustainRateApPerHour:o.target.value.trim()===""?null:Number(o.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Starts",children:e.jsx(P,{type:"datetime-local",value:s.startAtLocal,onChange:o=>g({startAtLocal:o.target.value})})}),e.jsx(j,{label:"Ends",children:e.jsx(P,{type:"datetime-local",value:s.endAtLocal,onChange:o=>g({endAtLocal:o.target.value})})})]}),e.jsx(j,{label:"Timezone",children:e.jsx(P,{value:s.timezone,onChange:o=>g({timezone:o.target.value}),placeholder:"Europe/Zurich"})}),e.jsx(j,{label:"Availability",children:e.jsx(we,{value:s.availability,onChange:o=>g({availability:o}),options:[{value:"busy",label:"Busy",description:"This event should block timebox recommendations and rule checks."},{value:"free",label:"Free",description:"This event stays visible in the calendar without blocking work."}]})})]})},{id:"links",eyebrow:"Meaning",title:"Connect the event to Forge entities",description:"Attach this event to strategies, goals, projects, tasks, or habits so the calendar carries multi-user operating context instead of staying isolated.",render:(s,g)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(j,{label:"Search Forge entities",description:"Search across human and bot-owned entities; the linked records use the same icon, color, and owner system as the rest of Forge.",children:e.jsx(Yt,{options:A,selectedValues:s.links.map(o=>`${o.entityType}:${o.entityId}`),onChange:o=>{g({links:o.map(_=>{const[M,...L]=_.split(":"),R=L.join(":"),te=w.find(me=>me.entityType===M&&me.entityId===R);return te?{entityType:te.entityType,entityId:te.entityId,relationshipType:"context",label:te.label}:null}).filter(_=>_!==null)})},placeholder:"Search strategies, goals, projects, tasks, habits, human, or bot owners",emptyMessage:"No matching Forge entities found."})})})},{id:"projection",eyebrow:"Projection",title:"Choose where this event should live remotely",description:"You can keep the event local to Forge, or choose a writable connected calendar so Forge also keeps a synced remote copy.",render:(s,g)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[d.length>0?e.jsxs("button",{type:"button",onClick:()=>g({preferredCalendarId:void 0}),className:`rounded-[22px] border px-4 py-4 text-left transition ${s.preferredCalendarId===void 0?"border-[rgba(125,211,252,0.28)] bg-[rgba(125,211,252,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(tt,{className:"size-4"}),"Default synced calendar"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/55",children:"Let Forge use the default writable connected calendar automatically."})]}):null,e.jsxs("button",{type:"button",onClick:()=>g({preferredCalendarId:null}),className:`rounded-[22px] border px-4 py-4 text-left transition ${s.preferredCalendarId===null?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(He,{className:"size-4"}),"Forge only"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/55",children:"Keep the event in Forge without creating a remote provider copy yet."})]}),d.map(o=>e.jsxs("button",{type:"button",onClick:()=>g({preferredCalendarId:o.id}),className:`rounded-[22px] border px-4 py-4 text-left transition ${s.preferredCalendarId===o.id?"border-[rgba(125,211,252,0.28)] bg-[rgba(125,211,252,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(tt,{className:"size-4"}),wt(o)]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/55",children:o.description||`${o.timezone} · writable`})]},o.id))]}),e.jsxs("div",{className:"grid gap-2 rounded-[22px] border border-white/8 bg-white/[0.04] p-4 text-sm text-white/66",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-white",children:[e.jsx(Lt,{className:"size-4 text-[var(--primary)]"}),"Categories and filtering"]}),e.jsx(P,{value:s.categoriesText,onChange:o=>g({categoriesText:o.target.value}),placeholder:"meeting, clinic, research"})]})]})}],[x,w,A,d]);return e.jsx(Qe,{open:a,onOpenChange:n,eyebrow:x?"Edit event":"New event",title:x?"Edit calendar event":"Create calendar event",description:"Forge-owned events can stay local or publish to a connected provider calendar.",value:m,onChange:N,draftPersistenceKey:x?`calendar.event.${x.id}`:"calendar.event.new",steps:u,onSubmit:async()=>{if(!m.title.trim()){c("Add an event title before saving.");return}if(!m.startAtLocal||!m.endAtLocal){c("Set both the start and end time before saving.");return}if(new Date(m.endAtLocal).getTime()<=new Date(m.startAtLocal).getTime()){c("The event end time must be after the start time.");return}c(null),await b({title:m.title.trim(),description:m.description.trim(),location:m.location.trim(),place:{label:m.location.trim(),address:m.placeAddress.trim(),timezone:m.placeTimezone.trim(),latitude:null,longitude:null,source:m.placeAddress.trim()?"manual":"",externalPlaceId:""},startAt:new Date(m.startAtLocal).toISOString(),endAt:new Date(m.endAtLocal).toISOString(),timezone:m.timezone.trim()||"UTC",availability:m.availability,activityPresetKey:m.activityPresetKey,customSustainRateApPerHour:m.customSustainRateApPerHour,categories:m.categoriesText.split(",").map(s=>s.trim()).filter(Boolean),links:m.links.map(s=>({entityType:s.entityType,entityId:s.entityId,relationshipType:s.relationshipType})),...m.preferredCalendarId!==void 0?{preferredCalendarId:m.preferredCalendarId}:{}})},submitLabel:x?"Save event":"Create event",pending:v,pendingLabel:x?"Saving":"Creating",error:F})}function Na({open:a,onOpenChange:n,initialTitle:d,pending:w=!1,onSubmit:x}){const[y,b]=p.useState(d),[v,m]=p.useState(null);return p.useEffect(()=>{a&&(b(d),m(null))},[d,a]),e.jsx(Qe,{open:a,onOpenChange:n,eyebrow:"Calendar",title:"Quick rename",description:"Rename the event without reopening the full event guide.",value:{title:y},onChange:N=>b(N.title),draftPersistenceKey:`calendar.quick-rename.${d}`,steps:[{id:"rename",eyebrow:"Rename",title:"Update the event title",description:"Keep the rename fast and direct. Everything else on the event stays unchanged.",render:(N,F)=>e.jsx(j,{label:"Event title",children:e.jsx(P,{value:N.title,onChange:c=>F({title:c.target.value}),placeholder:"Weekly research supervision"})})}],submitLabel:"Save title",pending:w,pendingLabel:"Saving",error:v,onSubmit:async()=>{const N=y.trim();if(!N){m("Add a title before saving.");return}m(null),await x(N),n(!1)}})}function ct(a){if(a)return{title:a.title,kind:a.kind,color:a.color,timezone:a.timezone,weekDays:a.weekDays,startMinute:a.startMinute,endMinute:a.endMinute,startsOn:a.startsOn,endsOn:a.endsOn,blockingState:a.blockingState,activityPresetKey:ft(a.actionProfile),customSustainRateApPerHour:vt(a.actionProfile)};const n=Ue[0];return{title:n.title,kind:n.kind,color:n.color,timezone:typeof Intl<"u"&&Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",weekDays:[1,2,3,4,5],startMinute:n.startMinute,endMinute:n.endMinute,startsOn:null,endsOn:null,blockingState:n.blockingState,activityPresetKey:n.kind==="main_activity"?"deep_work":n.kind==="secondary_activity"?"admin":n.kind==="holiday"?"holiday_leisure":n.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null}}function mt(a){return a??""}function Ke({draft:a}){const n=Xt({kind:a.kind,startMinute:a.startMinute,endMinute:a.endMinute,activityPresetKey:a.activityPresetKey,customSustainRateApPerHour:a.customSustainRateApPerHour}),d=a.endMinute>a.startMinute?a.endMinute-a.startMinute:1440-a.startMinute+a.endMinute;return e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(S,{className:"bg-white/[0.08] text-white/74",children:ee(n.rateApPerHour)}),e.jsxs(S,{className:"bg-white/[0.08] text-white/74",children:[ce(n.totalAp)," / block"]}),e.jsxs(S,{className:"bg-white/[0.08] text-white/74",children:[Math.round(d/60),"h ",d%60,"m"]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:"This is the default Life Force container drain for each occurrence of the block when no richer task run or timebox already covers that window."})]})}function Ta({open:a,onOpenChange:n,onSubmit:d,pending:w=!1,template:x=null}){const[y,b]=p.useState(()=>ct(x)),[v,m]=p.useState(null),N=x!==null;p.useEffect(()=>{a&&(m(null),b(ct(x)))},[a,x]);const F=p.useMemo(()=>[{id:"preset",eyebrow:"Preset",title:"Start from a recurring block that already matches the rhythm",description:"Use a preset to seed the schedule, then tune the dates and recurrence in the next step.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ke,{draft:c}),e.jsx(j,{label:"Activity profile",children:e.jsx(we,{value:c.activityPresetKey??"maintenance",columns:3,onChange:u=>A({activityPresetKey:u,customSustainRateApPerHour:c.customSustainRateApPerHour}),options:We().filter(u=>u.key!=="task_inherited").map(u=>({value:u.key,label:u.label,description:`${ee(u.defaultRateApPerHour)} · ${u.description}`}))})}),e.jsx(j,{label:"Custom AP per hour",children:e.jsx(P,{type:"number",min:0,step:.5,value:c.customSustainRateApPerHour??"",onChange:u=>A({customSustainRateApPerHour:u.target.value.trim()===""?null:Number(u.target.value)}),placeholder:"Leave empty to use the activity default"})}),e.jsx(j,{label:"Block type",children:e.jsx(we,{value:c.kind,columns:3,onChange:u=>{const s=Ue.find(g=>g.kind===u);if(s){const g=s.kind==="holiday"?[0,1,2,3,4,5,6]:[1,2,3,4,5];A({kind:s.kind,title:s.title,color:s.color,weekDays:g,startMinute:s.startMinute,endMinute:s.endMinute,blockingState:s.blockingState,activityPresetKey:s.kind==="main_activity"?"deep_work":s.kind==="secondary_activity"?"admin":s.kind==="holiday"?"holiday_leisure":s.kind==="rest"?"recovery_break":"maintenance",customSustainRateApPerHour:null});return}A({kind:"custom",title:"Custom block",color:"#7dd3fc",activityPresetKey:"maintenance",customSustainRateApPerHour:null})},options:[...Ue.map(u=>({value:u.kind,label:u.title,description:`${st(u.startMinute)}-${st(u.endMinute)}`})),{value:"custom",label:"Custom",description:"Build a different recurring window."}]})})]})},{id:"shape",eyebrow:"Schedule",title:"Define when this recurring block should exist",description:"Weekdays and times describe the recurring pattern. Optional start and end dates bound when the template is active.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ke,{draft:c}),e.jsx(j,{label:"Block title",children:e.jsx(P,{value:c.title,onChange:u=>A({title:u.target.value}),placeholder:"Main Activity"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.startMinute,onChange:u=>A({startMinute:Number(u.target.value)||0})})}),e.jsx(j,{label:"End minute",children:e.jsx(P,{type:"number",min:0,max:1440,step:15,value:c.endMinute,onChange:u=>A({endMinute:Number(u.target.value)||0})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{label:"Start date",children:e.jsx(P,{type:"date",value:mt(c.startsOn),onChange:u=>A({startsOn:u.target.value.trim()||null})})}),e.jsx(j,{label:"End date",children:e.jsx(P,{type:"date",value:mt(c.endsOn),onChange:u=>A({endsOn:u.target.value.trim()||null})})})]}),e.jsx("div",{className:"text-sm leading-6 text-white/54",children:"Leave the end date empty to keep repeating indefinitely. Holiday blocks work well with all seven weekdays and `0-1440`, and they still carry AP load because leisure and holiday time are real activities."}),e.jsx(j,{label:"Weekdays",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:wa.map((u,s)=>{const g=c.weekDays.includes(s);return e.jsx("button",{type:"button",onClick:()=>A({weekDays:g?c.weekDays.filter(o=>o!==s):[...c.weekDays,s].sort((o,_)=>o-_)}),className:`rounded-full px-3 py-2 text-sm transition ${g?"bg-[var(--primary)]/18 text-[var(--primary)] shadow-[inset_0_0_0_1px_rgba(192,193,255,0.24)]":"bg-white/[0.05] text-white/62 hover:bg-white/[0.08]"}`,children:u},u)})})})]})},{id:"policy",eyebrow:"Policy",title:"Tell Forge whether this block allows or blocks work",description:"Use blocked mode for time that should normally stop optional work. Use allowed mode for protected focus windows.",render:(c,A)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ke,{draft:c}),e.jsx(j,{label:"Work effect",children:e.jsx(we,{value:c.blockingState,onChange:u=>A({blockingState:u}),options:[{value:"blocked",label:"Blocks work",description:"Starting blocked tasks should require an explicit override."},{value:"allowed",label:"Allows work",description:"Use this for protected windows where the right tasks should fit."}]})}),e.jsx(j,{label:"Color",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-white/8 bg-white/6 px-4 py-3",children:[e.jsx("input",{className:"h-10 w-12 rounded-lg border border-white/10 bg-transparent",type:"color",value:c.color,onChange:u=>A({color:u.target.value})}),e.jsx(P,{className:"border-none bg-transparent px-0 py-0",value:c.color,onChange:u=>A({color:u.target.value})})]})})]})}],[]);return e.jsx(Qe,{open:a,onOpenChange:n,eyebrow:"Calendar",title:N?"Edit work block":"Create a work block",description:N?"Adjust the recurring pattern, date bounds, or work policy for this block.":"Build recurring half-day, holiday, or custom blocks so Forge can understand when work should be protected or blocked.",value:y,onChange:b,draftPersistenceKey:x?`calendar.work-block.${x.id}`:"calendar.work-block.new",steps:F,submitLabel:N?"Save changes":"Save work block",pending:w,pendingLabel:N?"Saving changes":"Saving",error:v,onSubmit:async()=>{if(!y.title.trim()){m("Give the block a title so it stays readable in the calendar.");return}if(y.weekDays.length===0){m("Select at least one weekday for the recurring block.");return}if(y.endMinute<=y.startMinute){m("The end minute needs to be later than the start minute.");return}if(y.startsOn&&y.endsOn&&y.endsOn<y.startsOn){m("The end date needs to be on or after the start date.");return}try{m(null),await d({...y,title:y.title.trim()}),n(!1)}catch(c){m(c instanceof Error?c.message:"Forge could not save this work block.")}}})}const Ne=qt(a=>({entry:null,setEntry:n=>a({entry:n}),clear:()=>a({entry:null}),completePaste:()=>a(n=>{var d;return{entry:((d=n.entry)==null?void 0:d.mode)==="cut"?null:n.entry}})}));function Ca(a){const n=new Date(a);n.setUTCHours(9,0,0,0);const d=new Date(n.getTime()+3600*1e3);return{startAt:n.toISOString(),endAt:d.toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",availability:"busy"}}function ut(a){var b;const n=Math.max(60,Math.floor((Date.parse(a.endsAt)-Date.parse(a.startsAt))/1e3)),d=((b=We().find(v=>v.key===a.activityPresetKey))==null?void 0:b.defaultRateApPerHour)??100/24,w=a.customSustainRateApPerHour??d,x=Number((n/3600*w).toFixed(2)),y=new Date().toISOString();return{id:`preview_${a.entityType}_${a.entityId}`,profileKey:`${String(a.entityType)}_${a.entityId}`,title:a.title,entityType:a.entityType,mode:"container",startupAp:0,totalCostAp:x,expectedDurationSeconds:n,sustainRateApPerHour:w,demandWeights:{activation:.1,focus:.35,vigor:.1,composure:.15,flow:.3},doubleCountPolicy:"container_only",sourceMethod:a.customSustainRateApPerHour!==null&&a.customSustainRateApPerHour!==void 0?"manual":a.activityPresetKey?"seeded":"inferred",costBand:w>=10?"standard":"light",recoveryEffect:0,metadata:{activityPresetKey:a.activityPresetKey??null,customSustainRateApPerHour:a.customSustainRateApPerHour??null},createdAt:y,updatedAt:y}}function ht(a){const n=typeof a.location=="string"?a.location:"",d=a.place??{label:n,address:"",timezone:"",latitude:null,longitude:null,source:"",externalPlaceId:""};return{...a,place:{label:d.label||n,address:d.address??"",timezone:d.timezone??"",latitude:d.latitude??null,longitude:d.longitude??null,source:d.source??"",externalPlaceId:d.externalPlaceId??""}}}function pt(a,n){const d=new Date(a.startAt),x=new Date(a.endAt).getTime()-d.getTime(),y=new Date(n);y.setUTCHours(d.getUTCHours(),d.getUTCMinutes(),0,0);const b=new Date(y.getTime()+x);return{startAt:y.toISOString(),endAt:b.toISOString()}}function gt(a){return{type:"calendar_event",eventId:a.id,title:a.title,description:a.description,location:a.location,startAt:a.startAt,endAt:a.endAt,timezone:a.timezone,availability:a.availability,preferredCalendarId:a.calendarId,categories:a.categories,links:a.links.map(n=>({entityType:n.entityType,entityId:n.entityId,relationshipType:n.relationshipType}))}}function Ia(a){switch(a){case"apple":return"Apple";case"google":return"Google";case"caldav":return"CalDAV";case"native":return"Forge";default:return"Derived"}}function Pa(a,n){var d;if(a.calendarId){const w=(d=n.get(a.calendarId))==null?void 0:d.trim();if(w)return w}return a.originType==="native"?"Forge only":Ia(a.originType)}function xt(a){switch(a){case"main_activity":return"Main activity";case"secondary_activity":return"Secondary activity";case"third_activity":return"Third activity";case"rest":return"Rest";case"holiday":return"Holiday";default:return"Custom"}}function yt(a){return a.startsOn&&a.endsOn?`${a.startsOn} to ${a.endsOn}`:a.startsOn?`From ${a.startsOn}`:a.endsOn?`Until ${a.endsOn}`:"Repeats with no end date"}function Qa(){var Ye,Xe,Je,Ve,et;const a=Rt(),[n,d]=Kt(),w=Jt(),x=Array.isArray(w.selectedUserIds)?w.selectedUserIds:[],y=Vt(x),b=Zt(),v=Ne(t=>t.entry),m=Ne(t=>t.setEntry),N=Ne(t=>t.clear),F=Ne(t=>t.completePaste),[c,A]=p.useState(()=>_e()),[u,s]=p.useState(null),[g,o]=p.useState(null),[_,M]=p.useState(!1),[L,R]=p.useState(null),[te,me]=p.useState(!1),[Te,ae]=p.useState(!1),[Y,ue]=p.useState(null),[kt,ie]=p.useState(!1),[Ce,re]=p.useState(null),[ne,Ie]=p.useState(null),he=p.useMemo(()=>ja(),[]),[jt,se]=p.useState(null),[k,pe]=p.useState(null),[Pe,K]=p.useState(null),ve=n.get("timeboxId"),H=p.useMemo(()=>{const t=c.toISOString(),r=Le(c,7).toISOString();return{from:t,to:r}},[c]),X=rt({queryKey:["forge-calendar-overview",H.from,H.to,...x],queryFn:()=>pa({...H,userIds:x})}),B=rt({queryKey:["forge-life-force",...x],queryFn:()=>ga(x)}),z=["forge-calendar-overview",H.from,H.to,...x],fe=t=>{if(t.deletedAt)return!1;const r=new Date(t.startAt).getTime();return r>=new Date(H.from).getTime()&&r<new Date(H.to).getTime()},ge=t=>{b.setQueryData(z,r=>r&&t(r))},E=async()=>{await Promise.all([b.invalidateQueries({queryKey:["forge-calendar-overview"]}),ha(b),b.invalidateQueries({queryKey:["task-context"]}),b.invalidateQueries({queryKey:["project-board"]})])},qe=$({mutationFn:t=>ea({...t,userId:t.userId??y}),onSuccess:E}),Ze=$({mutationFn:({templateId:t,patch:r})=>ta(t,r),onSuccess:E}),De=$({mutationFn:aa,onSuccess:E}),At=$({mutationFn:t=>ia({...t,userId:y}),onSuccess:E}),St=$({mutationFn:({timeboxId:t,startsAt:r,endsAt:l})=>nt(t,{startsAt:r,endsAt:l}),onSuccess:E}),Nt=$({mutationFn:({timeboxId:t,patch:r})=>nt(t,r),onSuccess:E}),Tt=$({mutationFn:ra,onSuccess:async()=>{ue(null),ae(!1),await E()}}),ke=$({mutationFn:t=>na({...t,userId:t.userId??y}),onMutate:async t=>{var h,C,U,W,le,V,D;K({tone:"saving",message:"Saving event changes in the background…"}),await b.cancelQueries({queryKey:z});const r=b.getQueryData(z),l=(r==null?void 0:r.calendar.calendars.find(I=>I.canWrite&&I.selectedForSync))??(r==null?void 0:r.calendar.calendars.find(I=>I.canWrite))??null,T=new Date().toISOString(),O=`calendar_event_optimistic_${Date.now()}`,i={id:O,connectionId:(l==null?void 0:l.connectionId)??null,calendarId:t.preferredCalendarId===void 0?(l==null?void 0:l.id)??null:t.preferredCalendarId,remoteId:null,ownership:"forge",originType:"native",status:"confirmed",title:t.title,description:t.description??"",location:t.location??"",place:{label:((h=t.place)==null?void 0:h.label)??t.location??"",address:((C=t.place)==null?void 0:C.address)??"",timezone:((U=t.place)==null?void 0:U.timezone)??t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",latitude:((W=t.place)==null?void 0:W.latitude)??null,longitude:((le=t.place)==null?void 0:le.longitude)??null,source:((V=t.place)==null?void 0:V.source)??"forge",externalPlaceId:((D=t.place)==null?void 0:D.externalPlaceId)??""},startAt:t.startAt,endAt:t.endAt,timezone:t.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",isAllDay:t.isAllDay??!1,availability:t.availability??"busy",eventType:t.eventType??"general",categories:t.categories??[],sourceMappings:[],links:(t.links??[]).map((I,Q)=>({id:`calendar_event_link_optimistic_${Date.now()}_${Q}`,entityType:I.entityType,entityId:I.entityId,relationshipType:I.relationshipType??"context",createdAt:T,updatedAt:T})),actionProfile:ut({entityType:"calendar_event",entityId:O,title:t.title,startsAt:t.startAt,endsAt:t.endAt,activityPresetKey:t.activityPresetKey??null,customSustainRateApPerHour:t.customSustainRateApPerHour??null}),remoteUpdatedAt:null,deletedAt:null,createdAt:T,updatedAt:T};return r&&fe(i)&&ge(I=>({...I,calendar:{...I.calendar,events:[i,...I.calendar.events]}})),{previous:r,optimisticEventId:i.id}},onError:(t,r,l)=>{l!=null&&l.previous&&b.setQueryData(z,l.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t},r,l)=>{K(null),ge(T=>({...T,calendar:{...T.calendar,events:(fe(t)?[t,...T.calendar.events.filter(O=>O.id!==(l==null?void 0:l.optimisticEventId))]:T.calendar.events.filter(O=>O.id!==(l==null?void 0:l.optimisticEventId))).filter((O,i,h)=>h.findIndex(C=>C.id===O.id)===i)}}))},onSettled:E}),J=$({mutationFn:({eventId:t,patch:r})=>sa(t,r),onMutate:async({eventId:t,patch:r})=>{K({tone:"saving",message:"Saving event changes in the background…"}),await b.cancelQueries({queryKey:z});const l=b.getQueryData(z);return l&&ge(T=>{var C,U,W,le,V;const O=T.calendar.events.find(D=>D.id===t);if(!O)return T;const i=ht(O),h={...i,...r,place:r.place?{...i.place,...r.place}:i.place,calendarId:r.preferredCalendarId===void 0?i.calendarId:r.preferredCalendarId,links:((C=r.links)==null?void 0:C.map((D,I)=>{var Q,Se;return{id:((Q=i.links[I])==null?void 0:Q.id)??`calendar_event_link_optimistic_${Date.now()}_${I}`,entityType:D.entityType,entityId:D.entityId,relationshipType:D.relationshipType??"context",createdAt:((Se=i.links[I])==null?void 0:Se.createdAt)??i.createdAt,updatedAt:new Date().toISOString()}}))??i.links,actionProfile:ut({entityType:"calendar_event",entityId:t,title:r.title??i.title,startsAt:r.startAt??i.startAt,endsAt:r.endAt??i.endAt,activityPresetKey:r.activityPresetKey===void 0?(W=(U=i.actionProfile)==null?void 0:U.metadata)==null?void 0:W.activityPresetKey:r.activityPresetKey,customSustainRateApPerHour:r.customSustainRateApPerHour===void 0?typeof((V=(le=i.actionProfile)==null?void 0:le.metadata)==null?void 0:V.customSustainRateApPerHour)=="number"?i.actionProfile.metadata.customSustainRateApPerHour:null:r.customSustainRateApPerHour}),updatedAt:new Date().toISOString()};return{...T,calendar:{...T.calendar,events:T.calendar.events.map(D=>D.id===t?h:D).filter(fe)}}}),{previous:l}},onError:(t,r,l)=>{l!=null&&l.previous&&b.setQueryData(z,l.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not sync that event change."})},onSuccess:({event:t})=>{K(null),ge(r=>({...r,calendar:{...r.calendar,events:r.calendar.events.map(l=>l.id===t.id?t:l).filter(fe)}}))},onSettled:E}),Oe=$({mutationFn:la,onMutate:async t=>{K({tone:"saving",message:"Removing the event in the background…"}),await b.cancelQueries({queryKey:z});const r=b.getQueryData(z);return r&&ge(l=>({...l,calendar:{...l.calendar,events:l.calendar.events.filter(T=>T.id!==t)}})),{previous:r}},onError:(t,r,l)=>{l!=null&&l.previous&&b.setQueryData(z,l.previous),K({tone:"error",message:t instanceof Error?t.message:"Forge could not delete that event."})},onSuccess:()=>{K(null)},onSettled:E}),je=(Ye=X.data)==null?void 0:Ye.calendar,Ae=p.useMemo(()=>va(c),[c]),f=p.useMemo(()=>je?{...je,events:je.events.map(ht)}:{generatedAt:"",providers:[],connections:[],calendars:[],events:[],workBlockTemplates:[],workBlockInstances:[],timeboxes:[]},[je]),Ct=p.useMemo(()=>new Map(f.calendars.map(t=>[t.id,wt(t)])),[f.calendars]),Fe=p.useMemo(()=>Aa(f.calendars,he.calendarColors),[he.calendarColors,f.calendars]),It=ke.isPending||J.isPending||Oe.isPending,Pt=f.timeboxes.filter(t=>t.status==="planned"),Dt=f.calendars.filter(t=>t.canWrite),xe=(t,r)=>r?`${t} · ${r}`:t,Ee=[...w.snapshot.goals.map(t=>({entityType:"goal",entityId:t.id,label:t.title,subtitle:xe("Goal",ye(t.user))})),...w.snapshot.projects.map(t=>({entityType:"project",entityId:t.id,label:t.title,subtitle:xe("Project",ye(t.user))})),...w.snapshot.tasks.map(t=>({entityType:"task",entityId:t.id,label:t.title,subtitle:xe("Task",ye(t.user))})),...w.snapshot.strategies.map(t=>({entityType:"strategy",entityId:t.id,label:t.title,subtitle:xe("Strategy",ye(t.user))})),...w.snapshot.habits.map(t=>({entityType:"habit",entityId:t.id,label:t.title,subtitle:xe("Habit",ye(t.user))}))],Ot=p.useMemo(()=>new Map(Ee.map(t=>[`${t.entityType}:${t.entityId}`,t.label])),[Ee]),Ft=f.connections.length===0?"No providers connected":`${f.connections.filter(t=>t.status==="connected").length}/${f.connections.length} healthy`,q=(v==null?void 0:v.items.filter(t=>t.type==="calendar_event"))??[];p.useEffect(()=>{if(!ve)return;const t=f.timeboxes.find(l=>l.id===ve);if(!t)return;const r=_e(new Date(t.startsAt));if(r.getTime()!==c.getTime()){A(r);return}((Y==null?void 0:Y.id)!==t.id||!Te)&&(ue(t),ae(!0))},[ve,f.timeboxes,Y==null?void 0:Y.id,Te,c]);const Ge=()=>{if(!ve)return;const t=new URLSearchParams(n);t.delete("timeboxId"),d(t,{replace:!0})},Et=t=>{ae(t),t||(ue(null),Ge())},Mt=t=>{re(null),se(Ca(t)),ie(!0)},zt=async(t,r)=>{const l=pt({startAt:t.startAt,endAt:t.endAt},r);await J.mutateAsync({eventId:t.id,patch:l})},$t=async t=>{if(q.length!==0){for(const r of q){const l=pt(r,t);(v==null?void 0:v.mode)==="cut"?await J.mutateAsync({eventId:r.eventId,patch:l}):await ke.mutateAsync({title:r.title,description:r.description,location:r.location,startAt:l.startAt,endAt:l.endAt,timezone:r.timezone,availability:r.availability,preferredCalendarId:r.preferredCalendarId,categories:r.categories,links:r.links})}F()}},_t=p.useMemo(()=>{if(!k)return[];if(k.kind==="day"){const r=Ae.find(l=>l.toISOString().slice(0,10)===k.dayKey);return r?[{id:"create-event",label:"Create event",description:"Open the event guide with this day already selected.",icon:oe,onSelect:()=>Mt(r)},{id:"create-work-block",label:"Create work block",description:"Open the guided work-block flow while you are looking at this day.",icon:Me,onSelect:()=>{R(null),M(!0)}},{id:"paste",label:(v==null?void 0:v.mode)==="cut"?"Paste moved event":"Paste copied event",description:q.length>0?`${q.length} calendar item${q.length===1?"":"s"} ready to paste here.`:v?"The current clipboard entry does not contain calendar events.":"Copy or cut an event first, then paste it into this day.",icon:Ht,disabled:q.length===0,onSelect:()=>void $t(r)}]:[]}if(k.kind==="work-block"){const r=f.workBlockTemplates.find(l=>l.id===k.templateId);return r?[{id:"edit-work-block",label:"Edit",description:"Adjust the recurring pattern, date bounds, or work policy.",icon:oe,onSelect:()=>{R(r),M(!0)}},{id:"delete-work-block",label:"Delete",description:"Remove this recurring work block from Forge.",icon:ze,tone:"danger",onSelect:()=>{(L==null?void 0:L.id)===r.id&&R(null),De.mutateAsync(r.id)}}]:[]}const t=f.events.find(r=>r.id===k.eventId);return t?[{id:"rename",label:"Quick rename",description:"Change the event title without opening the full event flow.",icon:oe,onSelect:()=>Ie(t)},{id:"copy",label:"Copy",description:"Put this event on the Forge clipboard so you can paste it into another day.",icon:Bt,onSelect:()=>m({id:`clipboard_${t.id}_${Date.now()}`,mode:"copy",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[gt(t)]})},{id:"cut",label:"Cut",description:"Move this event by pasting it into another day.",icon:Ut,onSelect:()=>m({id:`clipboard_cut_${t.id}_${Date.now()}`,mode:"cut",source:"calendar",label:t.title,createdAt:new Date().toISOString(),items:[gt(t)]})},{id:"delete",label:"Delete",description:"Remove the event from Forge and delete any connected remote projection.",icon:ze,tone:"danger",onSelect:()=>{(v==null?void 0:v.mode)==="cut"&&q.some(r=>r.eventId===t.id)&&N(),Oe.mutateAsync(t.id)}}]:[]},[N,q,v,Ae,Oe,De,k,f.events,f.workBlockTemplates,L,m]);return X.isLoading?e.jsx(oa,{}):X.isError||!X.data?e.jsx(da,{eyebrow:"Calendar",error:X.error??new Error("Calendar data is unavailable"),onRetry:()=>void X.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(fa,{entityKind:"project",titleText:"Calendar",title:"Calendar",description:"See the real week first, then open guided flows for work blocks, task rules, timeboxing, and provider setup.",badge:`${f.connections.length} connection${f.connections.length===1?"":"s"}`}),(Xe=B.data)!=null&&Xe.lifeForce?e.jsxs(Z,{className:"grid gap-3 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(15,25,36,0.98),rgba(9,15,26,0.96))] p-4 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Life Force today"}),e.jsxs("div",{className:"mt-2 text-3xl font-semibold text-white",children:[Math.round(B.data.lifeForce.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-white/44",children:["/ ",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Instant headroom"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:[B.data.lifeForce.instantFreeApPerHour.toFixed(1)," AP/h"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Calendar containers now speak the same AP language as live work."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Forecast"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-white",children:[Math.round(B.data.lifeForce.forecastAp)," AP"]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Planned remaining ",ce(B.data.lifeForce.plannedRemainingAp)]})]})]}):null,e.jsxs(Z,{className:"grid gap-4 rounded-[32px] border border-white/8 bg-[linear-gradient(180deg,rgba(17,28,39,0.985),rgba(10,17,29,0.985))]",children:[e.jsx(xa,{description:"The calendar is the priority surface here. Connected provider events, recurring work blocks, and owned task timeboxes all stay visible together.",weekStart:c,status:Pe?e.jsx("div",{className:`inline-flex max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-xs ${Pe.tone==="error"?"border border-rose-400/20 bg-rose-400/10 text-rose-200":"border border-[var(--primary)]/18 bg-[var(--primary)]/12 text-[var(--primary)]"}`,children:Pe.message}):null,badges:e.jsxs(e.Fragment,{children:[(Je=B.data)!=null&&Je.lifeForce?e.jsxs(S,{className:"bg-white/[0.08] text-white/74",children:[Math.round(B.data.lifeForce.spentTodayAp),"/",Math.round(B.data.lifeForce.dailyBudgetAp)," AP"]}):null,It?e.jsxs(S,{className:"bg-white/[0.08] text-white/78",children:[e.jsx(at,{className:"mr-1 size-3.5 animate-spin"}),"Syncing changes"]}):null,v?e.jsxs(S,{className:"bg-white/[0.08] text-white/74",children:[v.mode==="cut"?"Cut":"Copied"," · ",v.label]}):null]}),onPrevious:()=>A(Le(c,-7)),onCurrent:()=>A(_e()),onNext:()=>A(Le(c,7))}),e.jsx("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(min(100%,17rem),1fr))] 2xl:[grid-template-columns:repeat(7,minmax(0,1fr))]",children:Ae.map(t=>{const r=t.toISOString().slice(0,10),l=f.events.filter(i=>i.startAt.slice(0,10)===r&&!i.deletedAt),T=f.workBlockInstances.filter(i=>i.dateKey===r),O=f.timeboxes.filter(i=>i.startsAt.slice(0,10)===r);return e.jsxs("div",{"data-calendar-day":r,onClick:i=>{i.target.closest("[data-calendar-item='true']")||pe({kind:"day",dayKey:r,position:{x:i.clientX,y:i.clientY}})},onDragOver:i=>{i.preventDefault()},onDrop:i=>{i.preventDefault();const h=i.dataTransfer.getData("text/forge-event-id")||g;if(h){const Q=f.events.find(Se=>Se.id===h);Q&&zt(Q,t),o(null);return}const C=i.dataTransfer.getData("text/forge-timebox-id")||u;if(!C)return;const U=f.timeboxes.find(Q=>Q.id===C);if(!U)return;const W=new Date(U.startsAt),V=new Date(U.endsAt).getTime()-W.getTime(),D=new Date(t);D.setUTCHours(W.getUTCHours(),W.getUTCMinutes(),0,0);const I=new Date(D.getTime()+V);St.mutateAsync({timeboxId:C,startsAt:D.toISOString(),endsAt:I.toISOString()}),s(null)},className:"min-w-0 overflow-hidden rounded-[24px] border border-white/6 bg-white/[0.03] p-3 transition hover:border-white/12 hover:bg-white/[0.045]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[18px] bg-[rgba(10,16,30,0.96)] px-3 py-2 text-sm font-medium text-white",children:[e.jsx("span",{className:"min-w-0 truncate",children:Re(t)}),e.jsx("button",{type:"button","aria-label":`Open actions for ${Re(t)}`,className:"rounded-full bg-white/[0.06] p-2 text-white/58 transition hover:bg-white/[0.1] hover:text-white",onClick:i=>{i.stopPropagation(),pe({kind:"day",dayKey:r,position:{x:i.clientX,y:i.clientY}})},children:e.jsx($e,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-3 grid min-w-0 gap-2",children:[T.map(i=>e.jsxs("div",{"data-calendar-item":"true",className:"min-w-0 overflow-hidden rounded-[18px] px-3 py-2 text-sm text-white",style:{backgroundColor:`${i.color}22`,border:`1px solid ${i.color}55`},children:[(()=>{const h=ca(i);return e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"min-w-0 [overflow-wrap:anywhere] font-medium",children:i.title}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-white/[0.08] text-white/78",children:i.blockingState}),e.jsx(S,{size:"sm",className:"shrink-0 bg-white/[0.08] text-white/78",children:xt(i.kind)}),h.rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"shrink-0 bg-[var(--primary)]/14 text-[var(--primary)]",children:ee(h.rateApPerHour)}),e.jsx(S,{size:"sm",className:"shrink-0 bg-white/[0.08] text-white/72",children:ce(h.totalAp)})]}):e.jsx(S,{size:"sm",className:"shrink-0 bg-emerald-400/12 text-emerald-100",children:"Recovery"})]})]}),e.jsx("button",{type:"button","aria-label":`Open actions for ${i.title}`,className:"rounded-full bg-white/[0.05] p-1.5 text-white/56 transition hover:bg-white/[0.1] hover:text-white",onClick:C=>{C.stopPropagation(),pe({kind:"work-block",templateId:i.templateId,position:{x:C.clientX,y:C.clientY}})},children:e.jsx($e,{className:"size-4"})})]})})(),e.jsxs("div",{className:"mt-1 text-white/60",children:[new Date(i.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(i.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.jsx("div",{className:"mt-2 text-xs text-white/48",children:yt(f.workBlockTemplates.find(h=>h.id===i.templateId)??{id:i.templateId,title:i.title,kind:i.kind,color:i.color,startsOn:null,endsOn:null,blockingState:i.blockingState,createdAt:i.createdAt,updatedAt:i.updatedAt})})]},i.id)),l.map(i=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:h=>{o(i.id),h.dataTransfer.setData("text/forge-event-id",i.id)},onClick:h=>{h.stopPropagation(),re(i),se(null),ie(!0)},className:`min-w-0 cursor-move overflow-hidden rounded-[18px] px-3 py-2 text-left text-sm text-white/82 transition ${he.useCalendarColors?"hover:brightness-110":"border border-white/10 bg-white/[0.05] hover:border-white/18 hover:bg-white/[0.08] hover:shadow-[0_12px_32px_rgba(4,9,20,0.22)]"}`,style:he.useCalendarColors?{backgroundColor:`${(i.calendarId?Fe[i.calendarId]:null)??lt(`origin:${i.originType}`)}1f`,border:`1px solid ${(i.calendarId?Fe[i.calendarId]:null)??lt(`origin:${i.originType}`)}55`}:void 0,children:[(be(i),e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 [overflow-wrap:anywhere] font-medium",children:i.title}),e.jsxs("div",{className:"mt-1 text-white/55",children:[new Date(i.startAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(i.endAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.jsx("button",{type:"button","aria-label":`Open quick actions for ${i.title}`,className:"rounded-full bg-white/[0.05] p-1.5 text-white/56 transition hover:bg-white/[0.1] hover:text-white",onClick:h=>{h.stopPropagation(),pe({kind:"event",eventId:i.id,position:{x:h.clientX,y:h.clientY}})},children:e.jsx($e,{className:"size-4"})})})]})),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"max-w-full bg-white/[0.08] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-white/70",children:Pa(i,Ct)}),be(i).rateApPerHour>0?e.jsxs(e.Fragment,{children:[e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(be(i).rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-white/[0.08] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-white/70",children:ce(be(i).totalAp)})]}):null,i.calendarId&&he.useCalendarColors?e.jsx("span",{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:Fe[i.calendarId]}}):null]}),i.place.address||i.place.timezone?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-white/50",children:[i.place.address||i.location,i.place.address&&i.place.timezone?" · ":"",i.place.timezone]}):null,i.links.length>0?e.jsx("div",{className:"mt-2 flex min-w-0 flex-wrap gap-1.5",children:i.links.slice(0,3).map(h=>{const C=bt(h.entityType);return C?e.jsx(Be,{kind:C,label:Ot.get(`${h.entityType}:${h.entityId}`)??h.entityType,compact:!0,gradient:!1},h.id):e.jsx(S,{className:"bg-white/[0.08] text-white/72",children:h.entityType},h.id)})}):null]},i.id)),O.map(i=>e.jsxs("div",{"data-calendar-item":"true",draggable:!0,onDragStart:h=>{s(i.id),h.dataTransfer.setData("text/forge-timebox-id",i.id)},onClick:()=>{ue(i),ae(!0)},className:"min-w-0 cursor-move overflow-hidden rounded-[18px] border border-[rgba(192,193,255,0.18)] bg-[linear-gradient(180deg,rgba(67,72,112,0.34),rgba(43,47,80,0.32))] px-3 py-2 text-left text-sm text-white/82 shadow-[inset_0_0_0_1px_rgba(192,193,255,0.08)] transition hover:border-[rgba(192,193,255,0.32)] hover:bg-[linear-gradient(180deg,rgba(74,79,122,0.4),rgba(48,53,92,0.36))]",children:[(()=>{const h=ma(i);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex min-w-0 items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"line-clamp-2 font-medium leading-5 text-white",children:i.title}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-white/58",children:[e.jsx(Wt,{className:"size-3.5 shrink-0"}),new Date(i.startsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," ","-"," ",new Date(i.endsAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[e.jsx(S,{size:"sm",className:"bg-white/[0.08] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-white/72",children:i.status}),e.jsx(S,{size:"sm",className:"bg-[var(--primary)]/14 px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-[var(--primary)]",children:ee(h.rateApPerHour)}),e.jsx(S,{size:"sm",className:"bg-white/[0.08] px-2 py-0.5 text-[10px] uppercase tracking-[0.14em] text-white/72",children:ce(h.totalAp)})]})]})})(),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),ue(i),ae(!0)},className:"rounded-[999px] bg-white/[0.08] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-white/78 transition hover:bg-white/[0.14]",children:"Edit"}),e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),a(`/tasks/${i.taskId}`)},className:"rounded-[999px] bg-white/[0.08] px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-white/78 transition hover:bg-white/[0.14]",children:"Open task"})]})]},i.id)),T.length===0&&l.length===0&&O.length===0?e.jsx("div",{className:"min-h-[10rem] rounded-[18px] border border-dashed border-white/8 px-3 py-4 text-sm leading-8 text-white/42",children:"Nothing scheduled here yet. Click inside this day to create, block, or paste."}):null]})]},r)})})]}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(oe,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:"Create event"}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:"Add a native Forge event with linked context."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-white/62",children:"Create a real calendar event even with no provider connected, then project it remotely whenever you choose."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),re(null),se(null),ie(!0)},children:[e.jsx(oe,{className:"size-4"}),"Open event guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(Me,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:"Create work block"}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:"Block main activity or protect creative windows."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-white/62",children:"Open the guided flow to create half-day presets, holidays, or custom recurring work blocks."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>{R(null),M(!0)},children:[e.jsx(Me,{className:"size-4"}),"Open work-block guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(He,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:"Plan timebox"}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:"Let Forge recommend valid upcoming slots."})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-white/62",children:"Choose a task, review the suggested windows, and schedule directly into the calendar."}),e.jsx("div",{className:"mt-4",children:e.jsxs(G,{onClick:()=>ae(!0),children:[e.jsx(He,{className:"size-4"}),"Open planning guide"]})})]}),e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-[18px] bg-[var(--primary)]/14 p-3 text-[var(--primary)]",children:e.jsx(it,{className:"size-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:"Manage provider settings"}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:Ft})]})]}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-white/62",children:"Provider connections and setup instructions now live in Settings so the calendar view can stay focused on the week."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar"),children:[e.jsx(Qt,{className:"size-4"}),"Open calendar settings"]}),e.jsxs(G,{variant:"secondary",onClick:()=>a("/settings/calendar?intent=connect"),children:[e.jsx(it,{className:"size-4"}),"Connect provider"]})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",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.18em] text-white/45",children:"This week"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/60",children:"Quick status for the currently visible week."})]}),e.jsxs(G,{variant:"secondary",onClick:()=>void X.refetch(),children:[e.jsx(at,{className:"size-4"}),"Refresh view"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/54",children:"Provider events"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:f.events.length})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/54",children:"Work blocks"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:f.workBlockInstances.length})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/54",children:"Planned timeboxes"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:Pt.length})]})]})]}),e.jsxs(Z,{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,28,38,0.98),rgba(11,17,28,0.98))]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Guided actions"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>me(!0),className:"rounded-[22px] border border-white/8 bg-white/[0.04] px-4 py-4 text-left transition hover:bg-white/[0.06]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:"Adjust task blocking rules"}),e.jsx(S,{className:"bg-white/[0.08] text-white/74",children:"Guided"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Decide which work blocks, calendar conditions, and event keywords should block or allow a task."})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:"Active templates"}),e.jsx(S,{className:"bg-white/[0.08] text-white/74",children:f.workBlockTemplates.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[f.workBlockTemplates.slice(0,4).map(t=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/74",children:[e.jsx("div",{className:"font-medium text-white",children:t.title}),e.jsxs("div",{className:"mt-1 text-white/56",children:[xt(t.kind)," · ",t.weekDays.length," day",t.weekDays.length===1?"":"s"," · ",t.blockingState]}),e.jsx("div",{className:"mt-1 text-white/46",children:yt(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>{R(t),M(!0)},children:[e.jsx(oe,{className:"size-3.5"}),"Edit"]}),e.jsxs(G,{variant:"secondary",size:"sm",onClick:()=>void De.mutateAsync(t.id),children:[e.jsx(ze,{className:"size-3.5"}),"Delete"]})]})]},t.id)),f.workBlockTemplates.length===0?e.jsx("div",{className:"text-sm text-white/52",children:"No recurring templates yet. Open the work-block guide to create the first one."}):null]})]})]})]})]})]}),e.jsx(Ta,{open:_,onOpenChange:t=>{M(t),t||R(null)},pending:qe.isPending||Ze.isPending,template:L,onSubmit:async t=>{if(L){await Ze.mutateAsync({templateId:L.id,patch:t});return}await qe.mutateAsync(t)}}),e.jsx(ya,{open:te,onOpenChange:me,tasks:w.snapshot.tasks,onSave:async({taskId:t,schedulingRules:r,plannedDurationSeconds:l})=>{await ua(t,{schedulingRules:r,plannedDurationSeconds:l}),await w.refresh(),await E(),await b.invalidateQueries({queryKey:["task-context",t]})}}),e.jsx(ba,{open:Te,onOpenChange:Et,tasks:w.snapshot.tasks,editingTimebox:Y,from:H.from,to:H.to,onCreateTimebox:async t=>{await At.mutateAsync(t)},onUpdateTimebox:async(t,r)=>{await Nt.mutateAsync({timeboxId:t,patch:r})},onDeleteTimebox:async t=>{await Tt.mutateAsync(t),Ge()}}),e.jsx(Sa,{open:kt,onOpenChange:t=>{ie(t),t||(re(null),se(null))},writableCalendars:Dt,linkOptions:Ee,event:Ce,seed:jt??void 0,onSubmit:async t=>{if(Ce){const r=Ce.id;ie(!1),re(null),se(null),J.mutateAsync({eventId:r,patch:t}).catch(()=>{});return}else{ie(!1),re(null),se(null),ke.mutateAsync(t).catch(()=>{});return}},pending:ke.isPending||J.isPending}),e.jsx(Na,{open:ne!==null,onOpenChange:t=>{t||Ie(null)},initialTitle:(ne==null?void 0:ne.title)??"",pending:J.isPending,onSubmit:async t=>{if(!ne)return;const r=ne.id;Ie(null),J.mutateAsync({eventId:r,patch:{title:t}}).catch(()=>{})}}),e.jsx(ka,{open:k!==null,title:(k==null?void 0:k.kind)==="event"?((Ve=f.events.find(t=>t.id===k.eventId))==null?void 0:Ve.title)??"Event actions":(k==null?void 0:k.kind)==="work-block"?((et=f.workBlockTemplates.find(t=>t.id===k.templateId))==null?void 0:et.title)??"Work block actions":(k==null?void 0:k.kind)==="day"?Re(Ae.find(t=>t.toISOString().slice(0,10)===k.dayKey)??c):"Calendar actions",subtitle:(k==null?void 0:k.kind)==="day"?"Choose what to create or paste into this day.":(k==null?void 0:k.kind)==="work-block"?"Edit or remove this recurring work block.":v?`Clipboard ready: ${v.label}`:"Quick calendar event actions.",items:_t,position:(k==null?void 0:k.position)??null,onClose:()=>pe(null)})]})}export{Qa as CalendarPage};
@@ -1 +0,0 @@
1
- import{r as g,j as a}from"./vendor-kIz9EZnX.js";import{i as D}from"./state-VYvD1QVP.js";import{Q as K,cV as C,F as y,j as I,I as B,B as R,T as S,cW as W}from"./index-BHIKoiZ6.js";const $=[10,15,30,45,60];function A(){return{mode:"add",minutes:15,note:""}}function U({open:s,onOpenChange:t,entityType:p,entityId:u,targetLabel:r,currentCreditedSeconds:m,pending:w=!1,onSubmit:h}){const[c,b]=g.useState(A),[v,k]=g.useState(null);g.useEffect(()=>{s&&(b(A()),k(null))},[s]);const e=D({queryKey:["forge-xp-metrics"],queryFn:W,enabled:s}),d=g.useMemo(()=>{var x;const o=(x=e.data)==null?void 0:x.metrics.rules.find(f=>f.code==="task_run_progress"),l=Math.max(1,Number((o==null?void 0:o.config.intervalMinutes)??10)),n=Number((o==null?void 0:o.config.fixedXp)??4);return{intervalMinutes:l,fixedXp:n,intervalSeconds:l*60}},[e.data]),i=g.useMemo(()=>{const o=Math.max(0,Math.trunc(c.minutes||0)),l=c.mode==="add"?o:-o,n=Math.max(0,Math.floor(m/60)),x=l>=0?l:-Math.min(Math.abs(l),n),f=Math.max(0,m+x*60),T=Math.floor(Math.max(0,m)/d.intervalSeconds),M=Math.floor(f/d.intervalSeconds)-T;return{requestedDeltaMinutes:l,appliedDeltaMinutes:x,nextCreditedSeconds:f,bucketDelta:M,xpDelta:M*d.fixedXp,maxRemovableMinutes:n}},[d.fixedXp,d.intervalSeconds,m,c.minutes,c.mode]),N=[{id:"adjustment",eyebrow:p==="task"?"Task work":"Project work",title:`Adjust tracked work for ${r}`,description:"Use this for retrospective minute corrections. Forge will add or remove tracked minutes and adjust progress XP automatically when a reward bucket is crossed.",render:(o,l)=>a.jsxs(a.Fragment,{children:[a.jsx(y,{label:"Mode",labelHelp:"Add minutes when work happened off-timer. Remove minutes when the tracked total needs a correction.",children:a.jsx(I,{value:o.mode,onChange:n=>l({mode:n}),options:[{value:"add",label:"Add minutes",description:"Record extra work that already happened."},{value:"remove",label:"Remove minutes",description:"Correct tracked time without deleting the work history."}]})}),a.jsx(y,{label:"Minutes",description:`Currently tracked: ${Math.floor(m/60)} minutes.`,hint:o.mode==="remove"?`You can remove up to ${i.maxRemovableMinutes} whole minutes from the current credited total.`:void 0,children:a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(B,{type:"number",min:1,className:"w-36",value:o.minutes,onChange:n=>l({minutes:Number(n.target.value)||0})}),a.jsx("div",{className:"flex flex-wrap gap-2",children:$.map(n=>a.jsxs(R,{type:"button",variant:o.minutes===n?"primary":"secondary",onClick:()=>l({minutes:n}),children:[n," min"]},n))})]})}),a.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[a.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Preview"}),a.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-3",children:[a.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Applied minutes"}),a.jsxs("div",{className:"mt-2 text-lg text-white",children:[i.appliedDeltaMinutes>0?"+":"",i.appliedDeltaMinutes]})]}),a.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"XP delta"}),a.jsxs("div",{className:"mt-2 text-lg text-white",children:[i.xpDelta>0?"+":"",i.xpDelta]})]}),a.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"New tracked total"}),a.jsxs("div",{className:"mt-2 text-lg text-white",children:[Math.floor(i.nextCreditedSeconds/60)," min"]})]})]}),a.jsxs("div",{className:"mt-3 text-sm leading-6 text-white/58",children:["Reward cadence: ",d.fixedXp," XP every"," ",d.intervalMinutes," credited minutes."," ",i.bucketDelta===0?"This change does not cross a reward bucket.":`This change crosses ${Math.abs(i.bucketDelta)} reward bucket${Math.abs(i.bucketDelta)===1?"":"s"}.`]})]}),a.jsx(y,{label:"Note",description:"Optional context for why this correction is being added. The note stays attached to the adjustment metadata.",children:a.jsx(S,{className:"min-h-28",value:o.note,onChange:n=>l({note:n.target.value}),placeholder:"Captured the review session that happened away from the live timer."})})]})}];return a.jsx(K,{open:s,onOpenChange:t,eyebrow:p==="task"?"Adjust task work":"Adjust project work",title:`Adjust work for ${r}`,description:"Add or remove tracked minutes without creating a live task run.",value:c,onChange:b,draftPersistenceKey:`work-adjustment.${p}.${u}`,steps:N,submitLabel:"Save adjustment",pending:w,pendingLabel:"Saving adjustment...",error:v,onSubmit:async()=>{var x;k(null);const o=Math.max(0,Math.trunc(c.minutes||0)),l=c.mode==="add"?o:-o,n=C.safeParse({entityType:p,entityId:u,deltaMinutes:l,note:c.note});if(!n.success){k(((x=n.error.issues[0])==null?void 0:x.message)??"Enter a valid minute adjustment.");return}try{await h({entityType:p,entityId:u,deltaMinutes:n.data.deltaMinutes,note:n.data.note||void 0}),t(!1)}catch(f){k(f instanceof Error?f.message:"Could not save the work adjustment right now.")}}})}const E={allowWorkBlockKinds:[],blockWorkBlockKinds:[],allowCalendarIds:[],blockCalendarIds:[],allowEventTypes:[],blockEventTypes:[],allowEventKeywords:[],blockEventKeywords:[],allowAvailability:[],blockAvailability:[]};function X(s){return s.map(t=>t.trim().toLowerCase()).filter(Boolean)}function j(s,t){const p=X(s);if(p.length===0)return!1;const u=t.join(" ").toLowerCase();return p.some(r=>u.includes(r))}function F(s){return s.allowWorkBlockKinds.length>0||s.allowCalendarIds.length>0||s.allowEventTypes.length>0||s.allowEventKeywords.length>0||s.allowAvailability.length>0}function P(s,t){return s??t??E}function z(s){const t=s.rules??E,u=(s.at??new Date).getTime(),r=s.overview,m=(r==null?void 0:r.workBlockInstances.filter(e=>{const d=new Date(e.startAt).getTime(),i=new Date(e.endAt).getTime();return d<=u&&u<i}))??[],w=(r==null?void 0:r.events.filter(e=>{if(e.deletedAt)return!1;const d=new Date(e.startAt).getTime(),i=new Date(e.endAt).getTime();return d<=u&&u<i}))??[],h=[],c=m.some(e=>t.blockWorkBlockKinds.includes(e.kind))||w.some(e=>(e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)||t.blockEventTypes.includes(e.eventType)||t.blockAvailability.includes(e.availability)||j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]));c&&(m.some(e=>t.blockWorkBlockKinds.includes(e.kind))&&h.push("The current work block is marked as blocked."),w.some(e=>e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)&&h.push("The active calendar belongs to a blocked calendar source."),w.some(e=>t.blockEventTypes.includes(e.eventType))&&h.push("The active calendar event type is blocked."),w.some(e=>t.blockAvailability.includes(e.availability))&&h.push("The active calendar availability is blocked."),w.some(e=>j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]))&&h.push("The active calendar event matches a blocked keyword."));const b=F(t),v=m.some(e=>t.allowWorkBlockKinds.includes(e.kind))||w.some(e=>(e.calendarId?t.allowCalendarIds.includes(e.calendarId):!1)||t.allowEventTypes.includes(e.eventType)||t.allowAvailability.includes(e.availability)||j(t.allowEventKeywords,[e.title,e.description,e.location,...e.categories]));!c&&b&&!v&&h.push("The current calendar context does not match the allowed rules yet.");const k=[...m.map(e=>`${e.title} (${e.kind.replaceAll("_"," ")})`),...w.map(e=>e.title)];return h.length>0?{blocked:!0,label:"Blocked right now",tone:"blocked",conflicts:h,context:k}:k.length>0?{blocked:!1,label:"Allowed right now",tone:"allowed",conflicts:[],context:k}:{blocked:!1,label:b?"Waiting for an allowed calendar context":"No live calendar conflict right now",tone:b?"waiting":"allowed",conflicts:[],context:[]}}function Y(s,t){return P(s.schedulingRules,t)}export{U as W,z as e,Y as g};
@@ -1 +0,0 @@
1
- import{j as e}from"./vendor-kIz9EZnX.js";import{C as g,c as s}from"./index-BHIKoiZ6.js";import{P as y}from"./page-hero-oFHaAjtL.js";import"./state-VYvD1QVP.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const N=[{id:"health-ready",title:"Health ready",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"approved",syncEligible:!0,lastObservedAt:"2026-04-12T09:00:00.000Z"},{id:"movement-pending-phone",title:"Movement pending on phone",desiredEnabled:!0,appliedEnabled:!1,authorizationStatus:"pending",syncEligible:!1,lastObservedAt:"2026-04-12T09:04:00.000Z"},{id:"screen-time-denied",title:"Screen Time denied",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"denied",syncEligible:!1,lastObservedAt:"2026-04-12T08:54:00.000Z"},{id:"health-off",title:"Health off",desiredEnabled:!1,appliedEnabled:!1,authorizationStatus:"disabled",syncEligible:!1,lastObservedAt:null}],f=[{id:"gap-stay",title:"Quiet short gap",gapSeconds:1080,displacementMeters:42,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-short-jump",title:"Suppressed short jump",gapSeconds:240,displacementMeters:260,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-trip",title:"Repaired move",gapSeconds:1320,displacementMeters:1850,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-long",title:"Long missing gap",gapSeconds:7200,displacementMeters:320,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-boundary",title:"Missing boundary anchor",gapSeconds:960,displacementMeters:null,hasStartBoundary:!1,hasEndBoundary:!0}],k=[{id:"overnight-gap-before-move",title:"Exact overnight stay-gap-move bug",rangeStart:"2026-04-05T21:15:00.000Z",rangeEnd:"2026-04-06T02:40:00.000Z",segments:[{id:"stay-home-evening",kind:"stay",startedAt:"2026-04-05T21:15:00.000Z",endedAt:"2026-04-05T21:30:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"trip-night-move",kind:"trip",startedAt:"2026-04-06T02:34:00.000Z",endedAt:"2026-04-06T02:40:00.000Z",placeLabel:"Night move",placeExternalUid:null,startCoordinate:{latitude:46.5216,longitude:6.6404},endCoordinate:{latitude:46.5226,longitude:6.6424}}]},{id:"repeated-home-stays",title:"Repeated home stays coalesce",rangeStart:"2026-04-05T07:00:00.000Z",rangeEnd:"2026-04-05T08:44:00.000Z",segments:[{id:"stay-home-1",kind:"stay",startedAt:"2026-04-05T07:00:00.000Z",endedAt:"2026-04-05T08:00:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"stay-home-2",kind:"stay",startedAt:"2026-04-05T08:20:00.000Z",endedAt:"2026-04-05T08:40:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.51912,longitude:6.63231},endCoordinate:{latitude:46.51912,longitude:6.63231}},{id:"trip-start-anchor",kind:"trip",startedAt:"2026-04-05T08:44:00.000Z",endedAt:"2026-04-05T08:49:00.000Z",placeLabel:"Walk out",placeExternalUid:null,startCoordinate:{latitude:46.5217,longitude:6.6405},endCoordinate:{latitude:46.5221,longitude:6.6412}}]}],E=[{id:"user-override-home-window",title:"User-defined missing box overrides one automatic home stay",rawMeasurements:[{id:"raw-stay-home",label:"Raw stay · Home",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z"}],automaticBoxes:[{id:"auto-stay-home",kind:"stay",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home"}],userBoxes:[{id:"user-missing-home-window",kind:"missing",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1}],projectedBoxes:[{id:"projected-home-early",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T08:30:00.000Z",title:"Home",overrideCount:0},{id:"projected-home-user-missing",kind:"missing",sourceKind:"user_defined",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1},{id:"projected-home-late",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T09:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home",overrideCount:0}]}],w=3600,T=300,_=100;function x(t,i){return Math.max(0,Math.round((Date.parse(i)-Date.parse(t))/1e3))}function S(t,i){if(!t||!i)return null;const a=6371e3,m=(i.latitude-t.latitude)*Math.PI/180,l=(i.longitude-t.longitude)*Math.PI/180,h=t.latitude*Math.PI/180,c=i.latitude*Math.PI/180,p=Math.sin(m/2)**2+Math.cos(h)*Math.cos(c)*Math.sin(l/2)**2,r=2*Math.atan2(Math.sqrt(p),Math.sqrt(1-p));return a*r}function M(t,i){if(t.placeExternalUid&&i.placeExternalUid&&t.placeExternalUid===i.placeExternalUid)return!0;const a=S(t.endCoordinate,i.startCoordinate);return a!==null&&a<=_}function C(t){return t.gapSeconds>3600?{kind:"missing",origin:"missing",reason:"Gap exceeded one hour, so Forge keeps it as explicit missing data.",suppressedShortJump:!1}:!t.hasStartBoundary||!t.hasEndBoundary||t.displacementMeters===null?{kind:"missing",origin:"missing",reason:"One or both boundary anchors were missing, so the gap stays missing instead of inventing movement.",suppressedShortJump:!1}:t.displacementMeters<=100?{kind:"stay",origin:"repaired_gap",reason:"Boundary displacement stayed within 100 m, so the gap repairs into one stay.",suppressedShortJump:!1}:t.gapSeconds<300?{kind:"stay",origin:"repaired_gap",reason:"The jump crossed 100 m but stayed under five minutes, so Forge suppresses it into stay continuity.",suppressedShortJump:!0}:{kind:"trip",origin:"repaired_gap",reason:"The gap stayed under one hour, crossed 100 m, and lasted at least five minutes, so Forge repairs it into a move.",suppressedShortJump:!1}}function L(t){var b,v,j,A;const i=[...t.segments].sort((d,o)=>d.startedAt.localeCompare(o.startedAt)),a=[];if(i.length===0)return{segments:[],uncoveredIntervals:[]};const m=i[0];x(t.rangeStart,m.startedAt)>0&&a.push({id:`missing_${t.rangeStart}_${m.startedAt}`,kind:"missing",origin:"missing",startedAt:t.rangeStart,endedAt:m.startedAt,title:"Missing data"}),i.forEach((d,o)=>{if(o>0){const n=i[o-1],u=x(n.endedAt,d.startedAt);u>0&&(u>w?a.push({id:`missing_${n.id}_${d.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:d.startedAt,title:"Missing data"}):M(n,d)?a.push({id:`repaired_stay_${n.id}_${d.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:d.startedAt,title:n.placeLabel??d.placeLabel??"Repaired stay"}):S(n.endCoordinate,d.startCoordinate)===null?a.push({id:`missing_${n.id}_${d.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:d.startedAt,title:"Missing data"}):u<T?a.push({id:`repaired_short_jump_${n.id}_${d.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:d.startedAt,title:n.placeLabel??d.placeLabel??"Repaired stay"}):a.push({id:`repaired_trip_${n.id}_${d.id}`,kind:"trip",origin:"repaired_gap",startedAt:n.endedAt,endedAt:d.startedAt,title:"Repaired move"}))}a.push({id:d.id,kind:d.kind,origin:"recorded",startedAt:d.startedAt,endedAt:d.endedAt,title:d.placeLabel??d.kind})});const l=i[i.length-1],h=x(l.endedAt,t.rangeEnd);h>0&&(l.kind==="stay"&&h<=w?a.push({id:`continued_${l.id}_${t.rangeEnd}`,kind:"stay",origin:"continued_stay",startedAt:l.endedAt,endedAt:t.rangeEnd,title:l.placeLabel??"Continued stay"}):a.push({id:`missing_${l.endedAt}_${t.rangeEnd}`,kind:"missing",origin:"missing",startedAt:l.endedAt,endedAt:t.rangeEnd,title:"Missing data"}));const c=[];for(const d of a){const o=c[c.length-1];if(o&&o.kind==="stay"&&d.kind==="stay"&&(o.origin!=="recorded"||d.origin!=="recorded")&&o.endedAt===d.startedAt){c[c.length-1]={...o,id:`${o.id}_${d.id}`,origin:o.origin==="continued_stay"||d.origin==="continued_stay"?"continued_stay":"repaired_gap",endedAt:d.endedAt};continue}c.push(d)}const p=[],r=[...c].sort((d,o)=>d.startedAt.localeCompare(o.startedAt));((b=r[0])==null?void 0:b.startedAt)!==t.rangeStart&&p.push({startedAt:t.rangeStart,endedAt:((v=r[0])==null?void 0:v.startedAt)??t.rangeEnd});for(let d=1;d<r.length;d+=1)r[d-1].endedAt!==r[d].startedAt&&p.push({startedAt:r[d-1].endedAt,endedAt:r[d].startedAt});return((j=r[r.length-1])==null?void 0:j.endedAt)!==t.rangeEnd&&p.push({startedAt:((A=r[r.length-1])==null?void 0:A.endedAt)??t.rangeStart,endedAt:t.rangeEnd}),{segments:r,uncoveredIntervals:p}}function Z(t){return t?new Date(t).toLocaleString():"Waiting for device update"}function F(){return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1180px] gap-5",children:[e.jsx(y,{title:"Companion Sync Lab",description:"Deterministic fixtures for source-state reconciliation and movement gap repair. This route is dev-only and exists to make QA faster than recreating every phone state by hand.",badge:"Dev only"}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[1.05fr_0.95fr]",children:[e.jsxs(g,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Source matrix"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"These rows mirror the pairing source-state contract that the web and phone now share."})]}),e.jsx("div",{className:"grid gap-3",children:N.map(t=>e.jsxs("div",{className:"grid gap-2 rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx(s,{tone:t.desiredEnabled?"signal":"meta",children:t.desiredEnabled?"Enabled":"Off"}),e.jsx(s,{tone:"meta",children:t.desiredEnabled===t.appliedEnabled?"Applied":"Pending on phone"})]}),e.jsxs("div",{className:"grid gap-1 text-xs text-white/56 sm:grid-cols-2",children:[e.jsxs("div",{children:["Authorization: ",t.authorizationStatus]}),e.jsxs("div",{children:["Sync eligible: ",t.syncEligible?"Yes":"No"]}),e.jsxs("div",{children:["Desired: ",t.desiredEnabled?"On":"Off"]}),e.jsxs("div",{children:["Applied: ",t.appliedEnabled?"On":"Off"]}),e.jsxs("div",{className:"sm:col-span-2",children:["Last observed: ",Z(t.lastObservedAt)]})]})]},t.id))})]}),e.jsxs(g,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Gap classifier"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-white/58",children:["Every gap resolves to exactly one of ",e.jsx("code",{children:"stay"}),","," ",e.jsx("code",{children:"trip"}),", or ",e.jsx("code",{children:"missing"}),"."]})]}),e.jsx("div",{className:"grid gap-3",children:f.map(t=>{const i=C(t);return e.jsxs("div",{className:"grid gap-2 rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx(s,{tone:i.kind==="missing"?"meta":i.kind==="trip"?"signal":"default",children:i.kind}),e.jsx(s,{tone:"meta",children:i.origin}),i.suppressedShortJump?e.jsx(s,{className:"bg-amber-400/10 text-amber-100",children:"Suppressed short jump"}):null]}),e.jsxs("div",{className:"grid gap-1 text-xs text-white/56 sm:grid-cols-2",children:[e.jsxs("div",{children:["Gap: ",Math.round(t.gapSeconds/60)," min"]}),e.jsxs("div",{children:["Displacement:"," ",t.displacementMeters===null?"unknown":`${Math.round(t.displacementMeters)} m`]}),e.jsxs("div",{children:["Start boundary: ",t.hasStartBoundary?"present":"missing"]}),e.jsxs("div",{children:["End boundary: ",t.hasEndBoundary?"present":"missing"]})]}),e.jsx("div",{className:"text-sm leading-6 text-white/72",children:i.reason})]},t.id)})})]})]}),e.jsxs(g,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Coverage preview"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"These fixtures normalize a full window and highlight whether any interval would still be left uncovered."})]}),e.jsx("div",{className:"grid gap-3",children:k.map(t=>{const i=L(t);return e.jsxs("div",{className:"grid gap-3 rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsx(s,{className:i.uncoveredIntervals.length===0?"bg-emerald-400/10 text-emerald-100":"bg-rose-400/10 text-rose-100",children:i.uncoveredIntervals.length===0?"Coverage locked":"Coverage broken"}),e.jsxs(s,{tone:"meta",children:[i.segments.length," normalized segment",i.segments.length===1?"":"s"]})]}),e.jsx("div",{className:"grid gap-2",children:i.segments.map(a=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-[16px] border border-white/6 bg-white/[0.02] px-3 py-2 text-xs text-white/68",children:[e.jsx(s,{tone:a.kind==="trip"?"signal":a.kind==="missing"?"meta":"default",children:a.kind}),e.jsx(s,{tone:"meta",children:a.origin}),e.jsxs("span",{children:[new Date(a.startedAt).toLocaleTimeString()," → ",new Date(a.endedAt).toLocaleTimeString()]}),e.jsx("span",{className:"text-white/48",children:a.title})]},a.id))}),i.uncoveredIntervals.length>0?e.jsx("div",{className:"grid gap-2",children:i.uncoveredIntervals.map(a=>e.jsxs("div",{className:"rounded-[14px] border border-rose-400/18 bg-rose-500/10 px-3 py-2 text-xs text-rose-100",children:["Uncovered: ",new Date(a.startedAt).toLocaleTimeString()," →"," ",new Date(a.endedAt).toLocaleTimeString()]},`${a.startedAt}-${a.endedAt}`))}):null]},t.id)})})]}),e.jsxs(g,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Canonical box layers"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Raw phone measurements stay immutable. Forge generates automatic boxes from them, user-defined boxes override them, and the final projected boxes are what both the web and iPhone should render."})]}),e.jsx("div",{className:"grid gap-4",children:E.map(t=>e.jsxs("div",{className:"grid gap-4 rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:t.title}),e.jsxs(s,{tone:"meta",children:["Raw: ",t.rawMeasurements.length]}),e.jsxs(s,{tone:"meta",children:["Automatic: ",t.automaticBoxes.length]}),e.jsxs(s,{tone:"meta",children:["User: ",t.userBoxes.length]}),e.jsxs(s,{tone:"signal",children:["Projected: ",t.projectedBoxes.length]})]}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-4",children:[e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/6 bg-black/10 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Raw measurements"}),t.rawMeasurements.map(i=>e.jsxs("div",{className:"rounded-[14px] border border-white/6 bg-white/[0.03] px-3 py-2 text-xs text-white/68",children:[e.jsx("div",{className:"font-medium text-white",children:i.label}),e.jsxs("div",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]})]},i.id))]}),e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/6 bg-black/10 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Automatic boxes"}),t.automaticBoxes.map(i=>e.jsxs("div",{className:"rounded-[14px] border border-white/6 bg-white/[0.03] px-3 py-2 text-xs text-white/68",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s,{tone:i.kind==="trip"?"signal":i.kind==="missing"?"meta":"default",children:i.kind}),e.jsx(s,{tone:"meta",children:i.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:i.title}),e.jsxs("div",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]})]},i.id))]}),e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/6 bg-black/10 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"User-defined boxes"}),t.userBoxes.map(i=>e.jsxs("div",{className:"rounded-[14px] border border-white/6 bg-white/[0.03] px-3 py-2 text-xs text-white/68",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s,{tone:i.kind==="missing"?"meta":"default",children:i.kind}),e.jsx(s,{className:"bg-pink-400/10 text-pink-100",children:i.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:i.title}),e.jsxs("div",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:"mt-1 text-white/52",children:["Overrides ",i.overrideCount," automatic box",i.overrideCount===1?"":"es"]})]},i.id))]}),e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-white/6 bg-black/10 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Projected visible boxes"}),t.projectedBoxes.map(i=>e.jsxs("div",{className:"rounded-[14px] border border-white/6 bg-white/[0.03] px-3 py-2 text-xs text-white/68",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s,{tone:i.kind==="trip"?"signal":i.kind==="missing"?"meta":"default",children:i.kind}),e.jsx(s,{tone:"meta",children:i.sourceKind})]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:i.title}),e.jsxs("div",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:"mt-1 text-white/52",children:[i.origin,i.overrideCount>0?` · overrides ${i.overrideCount}`:""]})]},i.id))]})]})]},t.id))})]})]})}export{F as CompanionSyncLabPage};
@@ -1 +0,0 @@
1
- import{b5 as l,j as i,aS as x}from"./vendor-kIz9EZnX.js";import{ap as f,cN as h}from"./index-BHIKoiZ6.js";function g({entityType:s,entityId:a,count:r,compact:o=!1,className:p=""}){const n=l(),e=f(s,a);return e?i.jsxs("span",{role:"link",tabIndex:0,className:`inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] text-white/72 transition hover:bg-white/[0.09] hover:text-white ${o?"min-h-5 gap-1 px-2 py-0.5 text-[10px]":"min-h-10 gap-2 px-3 py-2 text-xs"} ${p}`,onClick:t=>{t.stopPropagation(),n(e)},onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),n(e))},children:[i.jsx(x,{className:o?"size-3":"size-3.5"}),h(r)]}):null}export{g as E};
@@ -1 +0,0 @@
1
- import{r as N,bg as Ke,ce as Qe,cb as Xe,cv as be,j as t,c7 as ve,b2 as pt,ca as Ze,cw as Fe,cx as Ye,bM as ht,br as ft,c9 as gt,aO as bt,aP as we,bo as Ue,cy as wt}from"./vendor-kIz9EZnX.js";import{u as jt,a as vt,D as yt,S as Pe,v as Ve,e as Nt,p as kt,f as St,P as _t,g as Te,b as et,C as tt}from"./board-DqHzdCPQ.js";import{P as ye,C as it,B as qe,Z as W,_ as It,aS as at,b as le,c as S,V as nt,U as je}from"./index-BHIKoiZ6.js";import{E as Ct}from"./entity-note-count-link-BrS1-O0o.js";import{F as zt}from"./floating-action-menu-zzC2r0Ob.js";function Dt(e){if(typeof e=="number"&&Number.isInteger(e)&&e>0)return e;if(typeof e=="string"){const a=e.match(/(\d+)/);if(a){const l=Number.parseInt(a[1]??"",10);return Number.isInteger(l)&&l>0?l:null}}return null}function Ge(e){return e.split(/\r?\n/).map(a=>a.trim()).reduce((a,l)=>{const o=l.match(/^[-*+]\s+\[([ xX])\]\s+(.+)$/);if(o)return a.push({label:o[2].trim(),completed:o[1].toLowerCase()==="x"}),a;const c=l.match(/^(?:[-*+]|\d+\.)\s+(.+)$/);return c&&a.push({label:c[1].trim(),completed:null}),a},[]).filter(a=>a.label.length>0)}function $t(e){if(e.acceptanceCriteria.length>0)return{total:e.acceptanceCriteria.length,completed:e.status==="done"?e.acceptanceCriteria.length:0,source:"acceptance_criteria",items:e.acceptanceCriteria};const a=Ge(e.aiInstructions);if(a.length>0){const o=e.status==="done"?a.length:a.filter(c=>c.completed===!0).length;return{total:a.length,completed:o,source:"ai_instructions",items:a.map(c=>c.label)}}const l=Ge(e.description);if(l.length>0){const o=e.status==="done"?l.length:l.filter(c=>c.completed===!0).length;return{total:l.length,completed:o,source:"description",items:l.map(c=>c.label)}}return null}function He(e,a){return e.find(l=>l.refType===a)??null}function st(e,a=null){var x,h,j,D,k,I,$,U,B,M,R;const l=new Set(((x=e.completionReport)==null?void 0:x.linkedGitRefIds)??[]),o=He(e.gitRefs,"branch"),c=He(e.gitRefs,"pull_request"),u=(a==null?void 0:a.gitContext)??null,m=(u==null?void 0:u.pullRequestNumber)??Dt((c==null?void 0:c.refValue)??(c==null?void 0:c.displayTitle)??null);return{actor:(a==null?void 0:a.actor)??null,activeRun:a,stepSummary:$t(e),changedFileCount:((h=e.completionReport)==null?void 0:h.modifiedFiles.length)??0,changedFilesPreview:(((j=e.completionReport)==null?void 0:j.modifiedFiles)??[]).slice(0,2),git:{provider:((D=u==null?void 0:u.provider)==null?void 0:D.trim())||((k=o==null?void 0:o.provider)==null?void 0:k.trim())||((I=c==null?void 0:c.provider)==null?void 0:I.trim())||null,repository:(($=u==null?void 0:u.repository)==null?void 0:$.trim())||((U=o==null?void 0:o.repository)==null?void 0:U.trim())||((B=c==null?void 0:c.repository)==null?void 0:B.trim())||null,branch:((M=u==null?void 0:u.branch)==null?void 0:M.trim())||((R=o==null?void 0:o.refValue)==null?void 0:R.trim())||null,branchUrl:(u==null?void 0:u.branchUrl)??(o==null?void 0:o.url)??null,pullRequestNumber:m,pullRequestUrl:(u==null?void 0:u.pullRequestUrl)??(c==null?void 0:c.url)??null,compareUrl:(u==null?void 0:u.compareUrl)??null,linkedRefCount:l.size}}}const _=["backlog","focus","in_progress","blocked","done"];function Bt({task:e,onOpenTask:a,onEditTask:l,onLinkTask:o,onCreateTaskForIssue:c,onCreateSubtaskForTask:u,onMove:m,onDeleteTask:x,deletePendingTaskId:h,onRequestDelete:j}){const D=e.level==="issue"?{id:"create-task",label:"Create task",description:"Add a focused execution task under this issue.",icon:be,onSelect:()=>c==null?void 0:c(e.id)}:e.level==="task"?{id:"create-subtask",label:"Create subtask",description:"Add a granular child step under this task.",icon:be,onSelect:()=>u==null?void 0:u(e.id)}:null;return[{id:"open-task",label:"Open",description:"Jump to the work-item detail view.",icon:Ke,onSelect:()=>a==null?void 0:a(e.id)},{id:"edit-task",label:"Edit",description:"Open the guided work-item editor.",icon:Qe,onSelect:()=>l==null?void 0:l(e.id)},{id:"link-task",label:"Link",description:"Open the placement step to relink this work item.",icon:Xe,onSelect:()=>o==null?void 0:o(e.id)},...D?[D]:[],{id:"delete-task",label:e.level==="issue"?"Delete issue":e.level==="subtask"?"Delete subtask":"Delete task",description:"Remove this work item directly from the board menu.",icon:ve,tone:"danger",disabled:!x||h===e.id,onSelect:()=>j(e)},..._.filter(k=>k!==e.status).map(k=>({id:`move-task-${k}`,label:`Move to ${k.replaceAll("_"," ")}`,description:"Update the workflow lane for this work item.",onSelect:()=>void m(e.id,k)}))]}function rt(e){return e.startsWith("lane:")||e.includes(":lane:")}function Mt(e){var a,l;return((l=(a=e.data)==null?void 0:a.current)==null?void 0:l.type)==="lane"||rt(String(e.id))}function At(e){var a,l;return((l=(a=e.data)==null?void 0:a.current)==null?void 0:l.type)==="trash"}function Lt(e,a){const l=Math.max(0,Math.min(e.right,a.right)-Math.max(e.left,a.left)),o=Math.max(0,Math.min(e.bottom,a.bottom)-Math.max(e.top,a.top));return l*o}const Et=e=>{const a=kt(e),l=a.find(m=>{const x=e.droppableContainers.find(h=>h.id===m.id);return x?At(x):!1});if(l)return[l];const o=a.find(m=>rt(String(m.id)));if(o)return[o];const u=e.droppableContainers.filter(m=>Mt(m)).map(m=>{const x=e.droppableRects.get(m.id);if(!x)return null;const h=Lt(e.collisionRect,x);return h<=0?null:{id:m.id,data:{droppableContainer:m,value:h}}}).filter(Boolean).sort((m,x)=>{var h,j;return(((h=x==null?void 0:x.data)==null?void 0:h.value)??0)-(((j=m==null?void 0:m.data)==null?void 0:j.value)??0)});return u.length>0?u:a.length>0?a:St(e)};function Rt(e,a){return a&&a.trim().length>0?a:e!=null&&e.actor?`${e.actor} session`:"Active work"}function Ot(e,a){return[(e==null?void 0:e.actor)??null,a].filter(Boolean).join(" · ")}function We(e){e.preventDefault(),e.stopPropagation()}function lt({task:e,goal:a,tags:l,activeRun:o,isSelected:c,isDragging:u=!1,isOverlay:m=!1,style:x,setNodeRef:h,dragAttributes:j,dragListeners:D,isMobile:k=!1,onSelect:I,onStartTask:$,onStopTask:U,onQuickReopen:B,onStepTask:M,onSplitTask:R,onOpenMenu:G,notesSummaryByEntity:C}){var X;const{t:ee,formatDate:ne}=ye(),v=st(e,o??null),z=v.stepSummary,b=_[_.indexOf(e.status)-1]??null,A=_[_.indexOf(e.status)+1]??null,oe=It(C,"task",e.id).count,L=e.level==="issue"?"issue":"task",ce=at(L),te=e.level==="subtask"?"136,146,255":ce.colorToken.rgb.join(", "),P=e.dueDate&&!Number.isNaN(Date.parse(e.dueDate))?ne(e.dueDate):"No due date",J=z&&z.total>0?Math.max(8,Math.round(z.completed/z.total*100)):null,g=v.git.branch,K=v.git.branchUrl,V=v.git.pullRequestNumber?`PR #${v.git.pullRequestNumber}`:null,Q=v.git.pullRequestUrl;return t.jsxs("article",{ref:h,style:{...x,"--board-card-accent":te},className:W("w-full max-w-full min-w-0 overflow-hidden rounded-[18px] p-3 shadow-[inset_0_0_0_1px_rgba(var(--board-card-accent),0.12)] transition cursor-grab active:cursor-grabbing",k&&"touch-none select-none",m&&"rotate-[0.5deg] bg-[linear-gradient(180deg,rgba(var(--board-card-accent),0.22),rgba(var(--board-card-accent),0.08))] shadow-[0_28px_80px_rgba(8,12,24,0.42),inset_0_0_0_1px_rgba(var(--board-card-accent),0.28)]",u&&!m&&"opacity-35 shadow-[inset_0_0_0_1px_rgba(var(--board-card-accent),0.08)]",c?"bg-[linear-gradient(180deg,rgba(var(--board-card-accent),0.18),rgba(var(--board-card-accent),0.06))] shadow-[0_16px_40px_rgba(8,12,24,0.32),inset_0_0_0_1px_rgba(var(--board-card-accent),0.26)]":"bg-[linear-gradient(180deg,rgba(var(--board-card-accent),0.08),rgba(255,255,255,0.03))]"),"data-dragging":u?"true":"false","data-testid":`task-card-${e.id}`,onClick:()=>I(e.id),...j,...D,children:[t.jsx("div",{className:"mb-3 h-px w-full rounded-full",style:{background:`linear-gradient(90deg, rgba(${te}, 0.96), rgba(${te}, 0.18))`}}),t.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx(le,{kind:L,label:e.level,compact:!0,size:"xs",gradient:!1,className:"shrink-0"}),t.jsx(S,{size:"xs",className:"shrink-0 text-[10px] text-[var(--tertiary)]",children:e.priority}),v.actor?t.jsxs(S,{size:"xs",className:"shrink-0 bg-cyan-400/12 text-cyan-100",children:[t.jsx(pt,{className:"mr-1 size-3"}),v.actor]}):null]}),t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[G?t.jsx("button",{type:"button","aria-label":`Open ${e.title} actions`,className:"inline-flex size-8 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white",onClick:f=>{f.preventDefault(),f.stopPropagation(),G(f,e)},children:t.jsx(Ze,{className:"size-3.5"})}):null,k?t.jsxs("div",{className:"flex items-center gap-1",onClick:f=>f.stopPropagation(),children:[t.jsx("button",{type:"button","aria-label":`Move ${e.title} to the previous lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!b,onClick:()=>{b&&(M==null||M(e.id,"previous"))},children:t.jsx(Fe,{className:"size-3.5"})}),t.jsx("button",{type:"button","aria-label":`Move ${e.title} to the next lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!A,onClick:()=>{A&&(M==null||M(e.id,"next"))},children:t.jsx(Ye,{className:"size-3.5"})})]}):null,o?t.jsx("button",{type:"button","aria-label":`Stop work on ${e.title}`,className:"inline-flex size-8 items-center justify-center rounded-full bg-rose-500/16 text-rose-200 transition hover:bg-rose-500/24",onClick:f=>{f.preventDefault(),f.stopPropagation(),U==null||U(o)},children:t.jsx(ht,{className:"size-3.5 fill-current"})}):e.status!=="done"?t.jsx("button",{type:"button","aria-label":`Start work on ${e.title}`,className:"inline-flex size-8 items-center justify-center rounded-full bg-[var(--primary)]/16 text-[var(--primary)] transition hover:bg-[var(--primary)]/24",onClick:f=>{f.preventDefault(),f.stopPropagation(),$==null||$(e.id)},children:t.jsx(ft,{className:"size-4 fill-current"})}):null,(X=e.splitSuggestion)!=null&&X.shouldSplit&&R?t.jsxs("button",{type:"button","aria-label":`Split ${e.title}`,className:"inline-flex items-center gap-1 rounded-full bg-amber-400/12 px-2.5 py-1 text-[10px] font-medium tracking-[0.14em] text-amber-100 transition hover:bg-amber-400/18",onClick:f=>{f.preventDefault(),f.stopPropagation(),R(e.id)},children:[t.jsx(gt,{className:"size-3.5"}),"Split it"]}):null,t.jsxs("span",{className:"shrink-0 text-[11px] text-white/44",children:[e.points," xp"]})]})]}),t.jsx(nt,{kind:L,label:e.title,className:"max-w-full",lines:3,labelClassName:"[overflow-wrap:anywhere]"}),t.jsx("p",{className:"mt-1.5 line-clamp-3 [overflow-wrap:anywhere] text-[12px] leading-5 text-white/62",children:e.description||ee("common.executionBoard.noExecutionNote")}),z?t.jsxs("div",{className:"mt-3 rounded-[16px] border border-white/8 bg-white/[0.045] p-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] text-white/58",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(bt,{className:"size-3.5 text-sky-200"}),z.total," step",z.total===1?"":"s"]}),t.jsxs("span",{className:"tabular-nums text-white/72",children:[z.completed,"/",z.total]})]}),t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-white/8",children:t.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,rgba(56,189,248,0.96),rgba(125,211,252,0.62))]",style:{width:`${J??0}%`}})}),t.jsx("div",{className:"mt-2 grid gap-1.5",children:z.items.slice(0,2).map(f=>t.jsx("div",{className:"truncate text-[11px] text-white/55",children:f},`${e.id}-${f}`))})]}):null,t.jsxs("div",{className:"mt-2.5 flex min-w-0 flex-wrap gap-1.5",children:[g?K?t.jsxs("a",{href:K,target:"_blank",rel:"noreferrer",className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-sky-300/18 bg-sky-400/12 px-2.5 py-1 text-[11px] text-sky-50 transition hover:bg-sky-400/18",onClick:We,children:[t.jsx(we,{className:"size-3.5 shrink-0"}),t.jsx("span",{className:"truncate",children:g})]}):t.jsxs(S,{size:"xs",className:"min-w-0 max-w-full bg-sky-400/12 text-sky-50",children:[t.jsx(we,{className:"mr-1 size-3"}),t.jsx("span",{className:"truncate",children:g})]}):null,V?Q?t.jsxs("a",{href:Q,target:"_blank",rel:"noreferrer",className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border border-fuchsia-300/18 bg-fuchsia-400/12 px-2.5 py-1 text-[11px] text-fuchsia-50 transition hover:bg-fuchsia-400/18",onClick:We,children:[t.jsx(Ue,{className:"size-3.5 shrink-0"}),t.jsx("span",{className:"truncate",children:V})]}):t.jsxs(S,{size:"xs",className:"bg-fuchsia-400/12 text-fuchsia-50",children:[t.jsx(Ue,{className:"mr-1 size-3"}),V]}):null,v.changedFileCount>0?t.jsxs(S,{size:"xs",className:"bg-amber-400/12 text-amber-50",children:[t.jsx(wt,{className:"mr-1 size-3"}),v.changedFileCount," file",v.changedFileCount===1?"":"s"]}):null,v.git.repository?t.jsx(S,{size:"xs",className:"bg-white/8 text-white/70",children:v.git.repository}):null]}),v.changedFilesPreview.length>0?t.jsx("div",{className:"mt-2 flex min-w-0 flex-wrap gap-1.5",children:v.changedFilesPreview.map(f=>t.jsx(S,{size:"xs",wrap:!0,className:"min-w-0 max-w-full bg-white/[0.06] font-mono text-[10px] text-white/65",children:f},f))}):null,t.jsxs("div",{className:"mt-2.5 flex min-w-0 flex-wrap gap-1.5",children:[a?t.jsx(le,{kind:"goal",label:a.title,compact:!0,size:"xs",wrap:!0,className:"min-w-0 max-w-full"}):null,t.jsx(je,{user:e.user,compact:!0,size:"xs"}),t.jsx(Ct,{entityType:"task",entityId:e.id,count:oe,compact:!0}),e.actionPointSummary?t.jsxs(S,{size:"xs",className:"bg-[var(--primary)]/12 text-[var(--primary)]",children:[Math.round(e.actionPointSummary.totalCostAp)," AP"]}):null,e.actionPointSummary?t.jsx(S,{size:"xs",className:"bg-white/8 text-white/72",children:e.actionPointSummary.costBand}):null,e.actionPointSummary?t.jsxs(S,{size:"xs",className:"bg-white/8 text-white/72",children:[Math.round(e.actionPointSummary.expectedDurationSeconds/3600)," h target"]}):null,e.time.totalCreditedSeconds>0?t.jsxs(S,{size:"xs",className:"bg-white/8 text-white/72",children:[Math.floor(e.time.totalCreditedSeconds/60)," min"]}):null,e.time.activeRunCount>0?t.jsxs(S,{size:"xs",className:"bg-emerald-500/12 text-emerald-200",children:[e.time.activeRunCount," live"]}):null,l.slice(0,2).map(f=>t.jsx(S,{size:"xs",className:"bg-white/8",style:{color:f.color},children:f.name},f.id))]}),t.jsxs("div",{className:"mt-2.5 flex min-w-0 items-center justify-between gap-2 text-[11px] text-white/45",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.effort," / ",e.energy]}),t.jsxs("div",{className:"flex min-w-0 shrink-0 items-center gap-2 text-right",children:[e.status==="done"&&B?t.jsx("button",{type:"button",className:"rounded-full bg-white/8 px-3 py-1 text-[10px] tracking-[0.16em] text-white transition hover:bg-white/12",onClick:f=>{f.preventDefault(),f.stopPropagation(),B(e.id)},children:ee("common.executionBoard.reopen")}):null,t.jsx("span",{children:P})]})]})]})}function fe(e){const{task:a,sortableId:l}=e,{attributes:o,listeners:c,setNodeRef:u,transform:m,transition:x,isDragging:h}=et({id:l,data:{type:"task",taskId:a.id,status:a.status}});return t.jsx(lt,{...e,setNodeRef:u,dragAttributes:o,dragListeners:c,isDragging:h,isMobile:e.isMobile,onStartTask:e.onStartTask,onStopTask:e.onStopTask,onStepTask:e.onStepTask,onSplitTask:e.onSplitTask,notesSummaryByEntity:e.notesSummaryByEntity,style:{transform:tt.Transform.toString(m),transition:x}})}function ot({project:e,goal:a,isDragging:l=!1,isOverlay:o=!1,style:c,setNodeRef:u,dragAttributes:m,dragListeners:x,isMobile:h=!1,onStepProject:j,onOpenMenu:D}){const{formatDate:k}=ye(),I=_[_.indexOf(e.workflowStatus)-1]??null,$=_[_.indexOf(e.workflowStatus)+1]??null,B=at("project").colorToken.rgb.join(", "),M=e.workflowStatus.replaceAll("_"," "),R=e.status.replaceAll("_"," "),G=e.updatedAt&&!Number.isNaN(Date.parse(e.updatedAt))?k(e.updatedAt):"No recent update";return t.jsxs("article",{ref:u,style:{...c,"--board-card-accent":B},className:W("w-full max-w-full min-w-0 overflow-hidden rounded-[18px] p-3 shadow-[inset_0_0_0_1px_rgba(var(--board-card-accent),0.12)] transition cursor-grab active:cursor-grabbing",h&&"touch-none select-none",o&&"rotate-[0.5deg] bg-[linear-gradient(180deg,rgba(var(--board-card-accent),0.22),rgba(var(--board-card-accent),0.08))] shadow-[0_28px_80px_rgba(8,12,24,0.42),inset_0_0_0_1px_rgba(var(--board-card-accent),0.28)]",l&&!o&&"opacity-35 shadow-[inset_0_0_0_1px_rgba(var(--board-card-accent),0.08)]",!l&&!o&&"bg-[linear-gradient(180deg,rgba(var(--board-card-accent),0.08),rgba(255,255,255,0.03))]"),"data-testid":`project-card-${e.id}`,...m,...x,children:[t.jsx("div",{className:"mb-3 h-px w-full rounded-full",style:{background:`linear-gradient(90deg, rgba(${B}, 0.96), rgba(${B}, 0.18))`}}),t.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx(le,{kind:"project",label:"project",compact:!0,size:"xs",gradient:!1,className:"shrink-0"}),t.jsx(S,{size:"xs",className:"shrink-0 bg-[var(--primary)]/12 text-[var(--primary)]",children:M}),t.jsx(S,{size:"xs",className:"shrink-0 bg-white/8 text-white/72",children:R})]}),t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[D?t.jsx("button",{type:"button","aria-label":`Open ${e.title} actions`,className:"inline-flex size-8 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white",onClick:C=>{C.preventDefault(),C.stopPropagation(),D(C,e)},children:t.jsx(Ze,{className:"size-3.5"})}):null,h?t.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[t.jsx("button",{type:"button","aria-label":`Move ${e.title} to the previous lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!I,onClick:()=>{I&&(j==null||j(e.id,"previous"))},children:t.jsx(Fe,{className:"size-3.5"})}),t.jsx("button",{type:"button","aria-label":`Move ${e.title} to the next lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!$,onClick:()=>{$&&(j==null||j(e.id,"next"))},children:t.jsx(Ye,{className:"size-3.5"})})]}):null]})]}),t.jsx(nt,{kind:"project",label:e.title,className:"max-w-full",lines:3,labelClassName:"[overflow-wrap:anywhere]"}),t.jsx("p",{className:"mt-1.5 line-clamp-3 [overflow-wrap:anywhere] text-[12px] leading-5 text-white/62",children:e.description||"PRD-backed initiative spanning multiple work items."}),t.jsxs("div",{className:"mt-2.5 flex min-w-0 flex-wrap gap-1.5",children:[a?t.jsx(le,{kind:"goal",label:a.title,compact:!0,size:"xs",wrap:!0,className:"min-w-0 max-w-full"}):null,t.jsx(je,{user:e.user,compact:!0,size:"xs"}),(e.assignees??[]).slice(0,2).map(C=>t.jsx(je,{user:C,compact:!0,size:"xs"},C.id)),t.jsxs(S,{size:"xs",className:"bg-[var(--primary)]/12 text-[var(--primary)]",children:[e.progress,"% progress"]}),t.jsxs(S,{size:"xs",className:"bg-white/8 text-white/72",children:[e.totalTasks," linked tasks"]})]}),t.jsxs("div",{className:"mt-2.5 flex min-w-0 items-center justify-between gap-2 text-[11px] text-white/45",children:[t.jsx("span",{className:"min-w-0 truncate",children:e.goalTitle}),t.jsx("span",{children:G})]})]})}function ge(e){const{project:a,sortableId:l}=e,{attributes:o,listeners:c,setNodeRef:u,transform:m,transition:x,isDragging:h}=et({id:l,data:{type:"project",projectId:a.id,status:a.workflowStatus}});return t.jsx(ot,{...e,setNodeRef:u,dragAttributes:o,dragListeners:c,isDragging:h,style:{transform:tt.Transform.toString(m),transition:x}})}function Je({droppableId:e,status:a,title:l,detail:o,count:c,dragging:u,children:m}){const{setNodeRef:x,isOver:h}=Te({id:e,data:{type:"lane",status:a}});return t.jsx("div",{ref:x,className:W("w-full max-w-full min-w-0 overflow-hidden rounded-[24px] transition",h&&"scale-[1.005]"),"data-lane-id":a,"data-testid":`kanban-lane-${a}`,"data-lane-hover":h?"true":"false",children:t.jsxs(it,{className:W("h-full w-full max-w-full min-w-0 overflow-hidden p-3 transition-[background-color,box-shadow,border-color,transform]",u&&"border border-white/8",h?"border border-[rgba(125,211,252,0.38)] bg-[linear-gradient(180deg,rgba(125,211,252,0.12),rgba(125,211,252,0.05))] shadow-[0_18px_54px_rgba(14,165,233,0.12)]":"border border-transparent"),children:[t.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"type-label text-white/45",children:o}),t.jsx("h3",{className:"mt-1 break-words text-[1.45rem] leading-[1] text-white",children:l})]}),t.jsx("div",{className:"shrink-0 font-display text-[1.45rem] text-[var(--primary)]",children:c})]}),t.jsx("div",{className:W("grid w-full max-w-full min-w-0 min-h-48 content-start gap-2 rounded-[18px] p-2 transition",h?"bg-[rgba(125,211,252,0.08)]":"bg-white/[0.02]"),children:m})]})})}function Ut({title:e,detail:a,children:l}){return t.jsxs("div",{className:"rounded-[20px] border border-cyan-300/20 bg-[linear-gradient(180deg,rgba(34,211,238,0.11),rgba(11,23,34,0.34))] p-2.5 shadow-[inset_0_0_0_1px_rgba(34,211,238,0.08)]",children:[t.jsx("div",{className:"mb-2 flex items-start justify-between gap-3 px-1",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-cyan-100/86",children:[t.jsx(we,{className:"size-3.5"}),t.jsx("span",{className:"truncate",children:e})]}),a?t.jsx("div",{className:"mt-1 text-[11px] text-white/45",children:a}):null]})}),t.jsx("div",{className:"grid gap-2",children:l})]})}function Pt({droppableId:e,title:a,detail:l}){const{setNodeRef:o,isOver:c}=Te({id:e,data:{type:"trash"}});return t.jsx("div",{ref:o,className:W("pointer-events-auto fixed right-4 top-4 z-50 w-[min(18rem,calc(100vw-2rem))] rounded-[28px] border px-5 py-4 shadow-[0_24px_80px_rgba(6,10,20,0.48)] backdrop-blur-2xl transition lg:right-6 lg:top-6",c?"border-rose-300/38 bg-[linear-gradient(180deg,rgba(244,63,94,0.28),rgba(120,24,42,0.46))] text-white scale-[1.02]":"border-white/10 bg-[linear-gradient(180deg,rgba(18,24,38,0.96),rgba(10,14,24,0.94))] text-white/84"),"data-testid":"kanban-trash-dropzone","data-trash-hover":c?"true":"false",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:W("flex size-12 items-center justify-center rounded-full border transition",c?"border-white/28 bg-white/12":"border-white/12 bg-white/6"),children:t.jsx(ve,{className:"size-5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/55",children:"Bin"}),t.jsx("div",{className:"mt-1 text-base font-medium text-white",children:a}),t.jsx("div",{className:"mt-1 text-sm leading-5 text-white/62",children:l})]})]})})}function Jt({tasks:e,projects:a=[],activeRuns:l=[],goals:o,tags:c,selectedTaskId:u,onMove:m,onMoveProject:x,onSelectTask:h,onStartTask:j,onStopTask:D,onQuickReopenTask:k,onDeleteTask:I,onOpenProject:$,onOpenTask:U,onEditProject:B,onEditTask:M,onLinkProject:R,onLinkTask:G,onCreateIssueForProject:C,onCreateTaskForIssue:ee,onCreateSubtaskForTask:ne,onSplitTask:v,notesSummaryByEntity:z}){var $e,Be;const{t:b}=ye(),A=N.useId(),oe=`${A}:trash`,[L,ce]=N.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(max-width: 1023px)").matches),te=jt(vt(_t,{activationConstraint:{distance:6}})),[P,J]=N.useState(null),[g,K]=N.useState(null),[V,Q]=N.useState(null),[X,f]=N.useState(null),[Ne,ct]=N.useState(()=>typeof window>"u"?!1:window.localStorage.getItem("forge.kanban-skip-delete-confirmation")==="true"),[ke,se]=N.useState(!1),[Se,Z]=N.useState({}),[_e,ie]=N.useState({}),re={backlog:{title:b("common.executionBoard.laneBacklogTitle"),detail:b("common.executionBoard.laneBacklogDetail")},focus:{title:b("common.executionBoard.laneFocusTitle"),detail:b("common.executionBoard.laneFocusDetail")},in_progress:{title:b("common.executionBoard.laneProgressTitle"),detail:b("common.executionBoard.laneProgressDetail")},blocked:{title:b("common.executionBoard.laneBlockedTitle"),detail:b("common.executionBoard.laneBlockedDetail")},done:{title:b("common.executionBoard.laneDoneTitle"),detail:b("common.executionBoard.laneDoneDetail")}},F=N.useMemo(()=>e.map(i=>{const n=Se[i.id];return n?{...i,status:n}:i}),[Se,e]),Y=N.useMemo(()=>a.map(i=>{const n=_e[i.id];return n?{...i,workflowStatus:n}:i}),[_e,a]),Ie=N.useMemo(()=>{const i=new Map;for(const n of l){if(n.status!=="active")continue;const s=i.get(n.taskId);(!s||n.isCurrent||n.updatedAt>s.updatedAt)&&i.set(n.taskId,n)}return i},[l]),H=N.useMemo(()=>[...Y.map(i=>({kind:"project",id:i.id,status:i.workflowStatus,project:i,goal:o.find(n=>n.id===i.goalId)})),...F.map(i=>({kind:"task",id:i.id,status:i.status,task:i,goal:o.find(n=>n.id===i.goalId),tags:i.tagIds.map(n=>c.find(s=>s.id===n)).filter(Boolean),activeRun:Ie.get(i.id)??null}))],[Ie,Y,F,o,c]),O=P?H.find(i=>i.id===P)??null:null,dt=N.useMemo(()=>{if(!g)return[];if(g.kind==="project"){const n=Y.find(s=>s.id===g.entityId);return n?[{id:"open-project",label:"Open",description:"Jump to the project detail view.",icon:Ke,onSelect:()=>$==null?void 0:$(n.id)},{id:"edit-project",label:"Edit",description:"Open the guided project editor.",icon:Qe,onSelect:()=>B==null?void 0:B(n.id)},{id:"link-project",label:"Link",description:"Open the anchor step to relink the project to its goal.",icon:Xe,onSelect:()=>R==null?void 0:R(n.id)},{id:"create-issue",label:"Create issue",description:"Break this project into a new vertical slice issue.",icon:be,onSelect:()=>C==null?void 0:C(n.id)},..._.filter(s=>s!==n.workflowStatus).map(s=>({id:`move-project-${s}`,label:`Move to ${s.replaceAll("_"," ")}`,description:"Update the project workflow lane without leaving the board.",onSelect:()=>void(x==null?void 0:x(n.id,s))}))]:[]}const i=F.find(n=>n.id===g.entityId);return i?Bt({task:i,onOpenTask:U,onEditTask:M,onLinkTask:G,onCreateTaskForIssue:ee,onCreateSubtaskForTask:ne,onMove:m,onDeleteTask:I,deletePendingTaskId:X,onRequestDelete:De}):[]},[Y,F,g,C,ne,ee,B,M,R,G,m,x,I,$,U,X,Ne]);function Ce(i){var s;if(i.length===0)return t.jsx("div",{className:"w-full max-w-full rounded-[18px] border border-dashed border-white/8 px-4 py-8 text-center text-sm text-white/35",children:b("common.executionBoard.emptyLane")});if(((s=i[0])==null?void 0:s.status)!=="in_progress")return i.map(d=>d.kind==="task"?t.jsx(fe,{sortableId:`${A}:task:${d.task.id}`,task:d.task,goal:d.goal,tags:d.tags,activeRun:d.activeRun,isSelected:u===d.task.id,isMobile:L,onSelect:h,onStartTask:j,onStopTask:D,onQuickReopen:k,onStepTask:de,onOpenMenu:me,onSplitTask:v,notesSummaryByEntity:z},d.task.id):t.jsx(ge,{sortableId:`${A}:project:${d.project.id}`,project:d.project,goal:d.goal,isMobile:L,onStepProject:ue,onOpenMenu:xe},d.project.id));const n=new Map;for(const d of i){if(d.kind!=="task"||!d.activeRun){const E=n.get("ungrouped");E?E.items.push(d):n.set("ungrouped",{title:"Active work",detail:"Tasks in progress without a tracked branch",items:[d]});continue}const p=st(d.task,d.activeRun),r=[d.activeRun.actor,p.git.repository??"",p.git.branch??""].join("::"),w=n.get(r);if(w){w.items.push(d);continue}n.set(r,{title:Rt(d.activeRun,p.git.branch),detail:Ot(d.activeRun,p.git.repository),items:[d]})}return Array.from(n.entries()).map(([d,p])=>d==="ungrouped"?p.items.map(r=>r.kind==="task"?t.jsx(fe,{sortableId:`${A}:task:${r.task.id}`,task:r.task,goal:r.goal,tags:r.tags,activeRun:r.activeRun,isSelected:u===r.task.id,isMobile:L,onSelect:h,onStartTask:j,onStopTask:D,onQuickReopen:k,onStepTask:de,onOpenMenu:me,onSplitTask:v,notesSummaryByEntity:z},r.task.id):t.jsx(ge,{sortableId:`${A}:project:${r.project.id}`,project:r.project,goal:r.goal,isMobile:L,onStepProject:ue,onOpenMenu:xe},r.project.id)):t.jsx(Ut,{title:p.title,detail:p.detail,children:p.items.map(r=>r.kind==="task"?t.jsx(fe,{sortableId:`${A}:task:${r.task.id}`,task:r.task,goal:r.goal,tags:r.tags,activeRun:r.activeRun,isSelected:u===r.task.id,isMobile:L,onSelect:h,onStartTask:j,onStopTask:D,onQuickReopen:k,onStepTask:de,onOpenMenu:me,onSplitTask:v,notesSummaryByEntity:z},r.task.id):t.jsx(ge,{sortableId:`${A}:project:${r.project.id}`,project:r.project,goal:r.goal,isMobile:L,onStepProject:ue,onOpenMenu:xe},r.project.id))},d))}N.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia("(max-width: 1023px)"),n=s=>{ce(s?s.matches:i.matches)};return n(),typeof i.addEventListener=="function"?(i.addEventListener("change",n),()=>i.removeEventListener("change",n)):(i.addListener(n),()=>i.removeListener(n))},[]),N.useEffect(()=>{if(!P){document.body.style.cursor="";return}return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[P]),N.useEffect(()=>{Z(i=>{const n=new Set(e.map(p=>p.id));let s=!1;const d={};for(const[p,r]of Object.entries(i)){const w=e.find(E=>E.id===p);if(!n.has(p)||!w||w.status===r){s=!0;continue}d[p]=r}return s?d:i})},[e]),N.useEffect(()=>{ie(i=>{const n=new Set(a.map(p=>p.id));let s=!1;const d={};for(const[p,r]of Object.entries(i)){const w=a.find(E=>E.id===p);if(!n.has(p)||!w||w.workflowStatus===r){s=!0;continue}d[p]=r}return s?d:i})},[a]);function ut(i){var d,p;const n=(d=i.active.data.current)==null?void 0:d.taskId,s=(p=i.active.data.current)==null?void 0:p.projectId;typeof n=="string"?J(n):typeof s=="string"&&J(s)}const mt=i=>{ct(i),typeof window<"u"&&window.localStorage.setItem("forge.kanban-skip-delete-confirmation","true")},ze=async(i,n)=>{if(I){f(i.id);try{n&&mt(!0),await I(i.id),Q(null),se(!1),Z(s=>{const d={...s};return delete d[i.id],d})}finally{f(null)}}};function De(i){if(I){if(Ne){ze(i,!1);return}se(!1),Q(i)}}async function xt(i){var Me,Ae,Le,Ee,Re,Oe;const{active:n,over:s}=i;if(J(null),!s||n.id===s.id)return;const d=typeof((Me=n.data.current)==null?void 0:Me.taskId)=="string"?n.data.current.taskId:null,p=typeof((Ae=n.data.current)==null?void 0:Ae.projectId)=="string"?n.data.current.projectId:null,r=(d?H.find(y=>y.kind==="task"&&y.id===d):null)??(p?H.find(y=>y.kind==="project"&&y.id===p):null);if(!r)return;if(((Le=s.data.current)==null?void 0:Le.type)==="trash"){if(r.kind!=="task"||!I)return;De(r.task);return}const w=typeof((Ee=s.data.current)==null?void 0:Ee.status)=="string"?s.data.current.status:null,E=typeof((Re=s.data.current)==null?void 0:Re.taskId)=="string"?s.data.current.taskId:null,q=typeof((Oe=s.data.current)==null?void 0:Oe.projectId)=="string"?s.data.current.projectId:null,pe=(E?H.find(y=>y.kind==="task"&&y.id===E):null)??(q?H.find(y=>y.kind==="project"&&y.id===q):null),T=w??(pe==null?void 0:pe.status)??r.status;if(!(T===r.status||!_.includes(T))){if(r.kind==="task"){Z(y=>({...y,[r.task.id]:T}));try{await m(r.task.id,T)}catch(y){throw Z(he=>{const ae={...he};return delete ae[r.task.id],ae}),y}return}if(x){ie(y=>({...y,[r.project.id]:T}));try{await x(r.project.id,T)}catch(y){throw ie(he=>{const ae={...he};return delete ae[r.project.id],ae}),y}}}}async function de(i,n){const s=F.find(w=>w.id===i);if(!s)return;const d=_.indexOf(s.status),p=n==="previous"?d-1:d+1,r=_[p]??null;if(!(!r||r===s.status)){Z(w=>({...w,[s.id]:r}));try{await m(s.id,r)}catch(w){throw Z(E=>{const q={...E};return delete q[s.id],q}),w}}}async function ue(i,n){const s=Y.find(w=>w.id===i);if(!s||!x)return;const d=_.indexOf(s.workflowStatus),p=n==="previous"?d-1:d+1,r=_[p]??null;if(!(!r||r===s.workflowStatus)){ie(w=>({...w,[s.id]:r}));try{await x(s.id,r)}catch(w){throw ie(E=>{const q={...E};return delete q[s.id],q}),w}}}function me(i,n){const s=i.currentTarget.getBoundingClientRect();K({kind:"task",entityId:n.id,position:{x:s.right-8,y:s.bottom+8}})}function xe(i,n){const s=i.currentTarget.getBoundingClientRect();K({kind:"project",entityId:n.id,position:{x:s.right-8,y:s.bottom+8}})}return t.jsxs(yt,{sensors:te,collisionDetection:Et,onDragStart:ut,onDragCancel:()=>J(null),onDragEnd:i=>void xt(i),children:[(O==null?void 0:O.kind)==="task"&&I?t.jsx(Pt,{droppableId:oe,title:b("common.executionBoard.deleteDropTitle"),detail:b("common.executionBoard.deleteDropDetail")}):null,t.jsx("div",{className:"w-full max-w-full min-w-0 pb-2",children:L?t.jsx("div",{className:"grid w-full max-w-full min-w-0 gap-2",children:_.map(i=>{const n=H.filter(s=>s.status===i);return t.jsx(Pe,{items:n.map(s=>`${A}:${s.kind}:${s.id}`),strategy:Ve,children:t.jsx(Je,{droppableId:`${A}:lane:${i}`,status:i,title:re[i].title,detail:re[i].detail,count:n.length,dragging:P!==null,children:Ce(n)})},i)})}):t.jsx("div",{className:"grid w-full min-w-0 gap-0.5 xl:grid-cols-[repeat(5,minmax(0,1fr))]",children:_.map(i=>{const n=H.filter(s=>s.status===i);return t.jsx(Pe,{items:n.map(s=>`${A}:${s.kind}:${s.id}`),strategy:Ve,children:t.jsx(Je,{droppableId:`${A}:lane:${i}`,status:i,title:re[i].title,detail:re[i].detail,count:n.length,dragging:P!==null,children:Ce(n)})},i)})})}),t.jsx(Nt,{adjustScale:!1,dropAnimation:null,children:O?t.jsx("div",{className:"w-[20rem] max-w-[calc(100vw-2rem)]",children:O.kind==="task"?t.jsx(lt,{task:O.task,goal:O.goal,tags:O.tags,activeRun:O.activeRun,isSelected:u===O.task.id,isDragging:!0,isOverlay:!0,isMobile:L,onSelect:()=>{},onStartTask:j,onSplitTask:v,notesSummaryByEntity:z}):t.jsx(ot,{project:O.project,goal:O.goal,isDragging:!0,isOverlay:!0,isMobile:L})}):null}),t.jsx(zt,{open:g!==null,title:(g==null?void 0:g.kind)==="project"?(($e=Y.find(i=>i.id===g.entityId))==null?void 0:$e.title)??"Project actions":((Be=F.find(i=>i.id===(g==null?void 0:g.entityId)))==null?void 0:Be.title)??"Work item actions",subtitle:(g==null?void 0:g.kind)==="project"?"Edit, relink, move, or break this project into issues.":"Edit, relink, move, or create the next child work item.",items:dt,position:(g==null?void 0:g.position)??null,onClose:()=>K(null)}),V?t.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-[rgba(5,8,18,0.74)] p-4 backdrop-blur-xl",children:t.jsxs(it,{className:"w-full max-w-md border border-white/10 bg-[linear-gradient(180deg,rgba(16,22,36,0.96),rgba(9,13,22,0.98))] shadow-[0_32px_90px_rgba(5,8,18,0.58)]",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"mt-1 flex size-11 shrink-0 items-center justify-center rounded-full bg-rose-500/14 text-rose-100",children:t.jsx(ve,{className:"size-5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-display text-[1.35rem] leading-tight text-white",children:b("common.executionBoard.deleteConfirmTitle")}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-white/64",children:b("common.executionBoard.deleteConfirmDescription",{title:V.title})})]})]}),t.jsxs("label",{className:"mt-5 flex items-center gap-3 rounded-[18px] bg-white/[0.05] px-4 py-3 text-sm text-white/76",children:[t.jsx("input",{type:"checkbox",checked:ke,onChange:i=>se(i.target.checked),className:"size-4 rounded border-white/20 bg-transparent text-[var(--primary)]"}),t.jsx("span",{children:b("common.executionBoard.deleteConfirmCheckbox")})]}),t.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[t.jsx(qe,{variant:"secondary",onClick:()=>{Q(null),se(!1)},children:b("common.executionBoard.deleteConfirmCancel")}),t.jsx(qe,{className:"bg-[linear-gradient(135deg,rgba(251,113,133,0.3),rgba(190,24,93,0.26))] text-white shadow-[0_16px_36px_rgba(190,24,93,0.18)]",pending:X===V.id,pendingLabel:b("common.executionBoard.deletingTask"),onClick:()=>void ze(V,ke),children:b("common.executionBoard.deleteConfirmSubmit")})]})]})}):null]})}export{Jt as E};
@@ -1 +0,0 @@
1
- import{r as h,F as m,j as t,aK as p}from"./vendor-kIz9EZnX.js";import{Z as l}from"./index-BHIKoiZ6.js";function f({open:s,title:c,subtitle:a,items:x,position:i,onClose:n}){return h.useEffect(()=>{if(!s)return;let e=!1;const r=window.setTimeout(()=>{e=!0},0),o=w=>{w.key==="Escape"&&n()},d=()=>{e&&n()};return window.addEventListener("keydown",o),window.addEventListener("pointerdown",d),()=>{window.clearTimeout(r),window.removeEventListener("keydown",o),window.removeEventListener("pointerdown",d)}},[n,s]),!s||!i||typeof document>"u"?null:m.createPortal(t.jsx("div",{className:"fixed inset-0 z-[70]","aria-hidden":"true",children:t.jsxs("div",{className:"fixed z-[71] flex max-h-[min(34rem,calc(100dvh-1.5rem))] w-[min(22rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-[26px] border border-white/10 bg-[rgba(10,15,27,0.97)] p-2 shadow-[0_28px_80px_rgba(4,8,18,0.4)] backdrop-blur-xl",style:{left:Math.min(i.x,window.innerWidth-24-352),top:Math.min(i.y,window.innerHeight-24-544)},onPointerDown:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[20px] bg-white/[0.03] px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-white",children:c}),a?t.jsx("div",{className:"mt-1 text-xs leading-5 text-white/50",children:a}):null]}),t.jsx("button",{type:"button",className:"rounded-full bg-white/[0.04] p-2 text-white/55 transition hover:bg-white/[0.08] hover:text-white",onClick:n,children:t.jsx(p,{className:"size-4"})})]}),t.jsx("div",{className:"mt-2 min-h-0 overflow-y-auto overscroll-contain pr-1",children:t.jsx("div",{className:"grid gap-1",children:x.map(e=>{const r=e.icon;return t.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>{e.disabled||(e.onSelect(),n())},className:l("flex w-full items-start gap-3 rounded-[20px] px-4 py-3 text-left transition",e.disabled?"cursor-not-allowed bg-white/[0.02] text-white/28":e.tone==="danger"?"bg-rose-400/[0.05] text-rose-100 hover:bg-rose-400/[0.12]":"bg-white/[0.03] text-white/76 hover:bg-white/[0.08] hover:text-white"),children:[r?t.jsx("span",{className:l("mt-0.5 rounded-[14px] p-2",e.disabled?"bg-white/[0.03] text-white/28":e.tone==="danger"?"bg-rose-400/[0.12] text-rose-100":"bg-[var(--primary)]/12 text-[var(--primary)]"),children:t.jsx(r,{className:"size-4"})}):null,t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:e.label}),e.description?t.jsx("span",{className:"mt-1 block text-xs leading-5 text-white/48",children:e.description}):null]})]},e.id)})})})]})}),document.body)}export{f as F};
@@ -1 +0,0 @@
1
- import{cc as F,b5 as q,r as o,j as e,aC as p}from"./vendor-kIz9EZnX.js";import{j as A,k as H}from"./state-VYvD1QVP.js";import{P as L,u as z,s as K,i as Q,R as $,a as X,V as T,U as C,B as g,C as v,b as w,c as h,W as _,X as V,Y as W}from"./index-BHIKoiZ6.js";import{O as Y}from"./open-in-graph-button-C0TGev7c.js";import{N as J}from"./note-markdown-CsGQhQXF.js";import{E as Z}from"./entity-notes-surface-CBylYDwy.js";import{P as ee}from"./preference-entity-handoff-button-DOKV9bZc.js";import{b as te,f as se,P as ae}from"./project-collections-CZagCmeH.js";import{P as ie}from"./page-hero-oFHaAjtL.js";import{g as le,a as ne}from"./activity-copy-Bj4h9OcF.js";import{g as oe}from"./entity-links-DwpxhW2H.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";import"./note-tags-input-DdZi93tj.js";function ke(){const{t:s}=L(),i=z(),d=F(),G=q(),u=A(),[O,N]=o.useState(!1),[S,y]=o.useState(!1),[m,B]=o.useState("active"),j=K(i.selectedUserIds),[E,b]=o.useState(null),D=H({mutationFn:()=>$(d.goalId),onSuccess:async()=>{await Promise.all([Q(u),u.invalidateQueries({queryKey:["project-board"]}),u.invalidateQueries({queryKey:["task-context"]})]),G("/goals")}}),a=i.snapshot.dashboard.goals.find(t=>t.id===d.goalId)??null,x=o.useMemo(()=>i.snapshot.dashboard.projects.filter(t=>t.goalId===d.goalId),[d.goalId,i.snapshot.dashboard.projects]),R=o.useMemo(()=>te(x),[x]),n=o.useMemo(()=>se(x,m),[x,m]),k=new Set(x.map(t=>t.id)),I=new Set(i.snapshot.tasks.filter(t=>k.has(t.projectId??"")).map(t=>t.id)),f=i.snapshot.activity.filter(t=>t.entityId===d.goalId||k.has(t.entityId)||I.has(t.entityId)||t.entityType==="task_run"&&typeof t.metadata.taskId=="string"&&I.has(t.metadata.taskId));if(!a)return e.jsx(X,{eyebrow:s("common.goalDetail.eyebrow"),title:s("common.goalDetail.missingTitle"),description:s("common.goalDetail.missingDescription"),action:e.jsx(p,{to:"/goals",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-slate-950 transition hover:opacity-90",children:s("common.goalDetail.backToGoals")})});const l=n.find(t=>t.nextTaskTitle)??n[0]??null,r=i.snapshot.overview.neglectedGoals.find(t=>t.goalId===a.id)??null,c=f[0]??null,M=async t=>{b(t);try{await i.patchProject(t,{status:"active"})}finally{b(null)}},U=async()=>{window.confirm(s("common.goalDetail.deleteGoalConfirm",{title:a.title}))&&await D.mutateAsync()};return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ie,{entityKind:"goal",title:e.jsx(T,{kind:"goal",label:a.title,variant:"heading",size:"lg"}),titleText:a.title,description:a.description?e.jsx(J,{markdown:a.description,className:"[&>p]:text-[13px] [&>p]:leading-6 [&>blockquote]:text-[13px] [&>ul]:text-[13px] [&>ol]:text-[13px]"}):"No strategic description yet.",badge:s(n.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:n.length}),actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ee,{userId:j,domain:"projects",entityType:"goal",entityId:a.id,label:a.title,description:a.description}),e.jsx(Y,{entityType:"goal",entityId:a.id})]})}),a.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(C,{user:a.user})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(g,{onClick:()=>N(!0),children:s("common.goalDetail.edit")}),e.jsx(g,{variant:"secondary",onClick:()=>y(!0),children:s("common.goalDetail.addProject")}),e.jsx(g,{variant:"ghost",className:"text-rose-200 hover:bg-rose-500/10",pending:D.isPending,pendingLabel:s("common.goalDetail.deleting"),onClick:()=>void U(),children:s("common.goalDetail.deleteGoal")})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(v,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:s("common.goalDetail.sectionProjects")}),e.jsx(ae,{value:m,counts:R,onChange:B,className:"justify-end"})]}),n.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:m==="active"?s("common.goalDetail.noProjects"):"No projects match this lifecycle filter yet. Switch filters or restart one to make it active again."}):e.jsx("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:n.map(t=>e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-5 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(w,{kind:"project",compact:!0,gradient:!1}),t.user?e.jsx(C,{user:t.user,compact:!0}):null]}),e.jsx(h,{children:t.status})]}),e.jsx("div",{className:"mt-4",children:e.jsx(p,{to:`/projects/${t.id}`,className:"transition hover:opacity-90",children:e.jsx(T,{kind:"project",label:t.title,variant:"heading",size:"lg"})})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:t.description}),e.jsx("div",{className:"mt-4",children:e.jsx(_,{value:t.progress})}),e.jsx("div",{className:"mt-4 text-[11px] uppercase tracking-[0.16em] text-white/40",children:t.nextTaskTitle?s("common.goalDetail.nextMove",{value:t.nextTaskTitle}):s("common.goalDetail.addNextTask")}),e.jsxs("div",{className:"mt-4 flex flex-wrap justify-between gap-3",children:[e.jsx(p,{to:`/projects/${t.id}`,children:e.jsx(g,{variant:"ghost",children:"Open project"})}),m!=="active"&&t.status!=="active"?e.jsx(g,{variant:"secondary",size:"sm",pending:E===t.id,pendingLabel:"Restarting…",onClick:()=>void M(t.id),children:"Restart"}):null]})]},t.id))})]}),e.jsx("div",{className:"grid min-w-0 gap-5",children:e.jsxs(v,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:s("common.goalDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(w,{kind:"goal",compact:!0,gradient:!1}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s("common.goalDetail.progressTitle",{progress:a.progress,count:a.completedTasks})}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s("common.goalDetail.progressDetail",{xp:a.earnedPoints})}),e.jsx(h,{className:"bg-white/[0.08] text-white/72",children:s(n.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:n.length})})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",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:s("common.goalDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[a.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:s("common.goalDetail.fieldCompletedTasks")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a.completedTasks})]}),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:s("common.goalDetail.fieldXpBanked")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:a.earnedPoints})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",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:s("common.goalDetail.signalNext")}),l?e.jsx(w,{kind:"project",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(l==null?void 0:l.title)??s("common.goalDetail.noProject")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:l!=null&&l.nextTaskTitle?s("common.goalDetail.nextMove",{value:l.nextTaskTitle}):(l==null?void 0:l.description)||s("common.goalDetail.noProjectDetail")})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:s("common.goalDetail.signalRisk")}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(r==null?void 0:r.title)??s("common.goalDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(r==null?void 0:r.summary)||s("common.goalDetail.noRiskDetail")})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:s("common.goalDetail.signalEvidence")}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(c==null?void 0:c.title)??s("common.goalDetail.noEvidence")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(c==null?void 0:c.description)||s("common.goalDetail.noEvidenceDetail")})]})]})]})]})})]}),e.jsx(Z,{entityType:"goal",entityId:a.id,title:"Goal notes",description:"Use notes to capture strategy changes, meaning shifts, and progress context that belongs at the goal level."}),e.jsxs(v,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:s("common.goalDetail.sectionEvidence")}),f.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:s("common.goalDetail.noEvidenceLogged")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:f.slice(0,6).map(t=>e.jsxs(p,{to:oe(t)??`/activity?eventId=${t.id}`,className:"rounded-[18px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsx("div",{className:"font-medium text-white",children:le(t)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:ne(t)})]},t.id))})]}),e.jsx(V,{open:O,editingGoal:a,tags:i.snapshot.tags,users:i.snapshot.users,defaultUserId:a.userId??j,onOpenChange:N,onSubmit:async(t,P)=>{P&&await i.patchGoal(P,t)}}),e.jsx(W,{open:S,goals:i.snapshot.goals,users:i.snapshot.users,editingProject:null,initialGoalId:a.id,defaultUserId:a.userId??j,onOpenChange:y,onSubmit:async t=>{await i.createProject(t)}})]})}export{ke as GoalDetailPage};
@@ -1 +0,0 @@
1
- import{r as g,j as e,aC as b,c4 as P,b8 as C}from"./vendor-kIz9EZnX.js";import{P as S}from"./page-hero-oFHaAjtL.js";import{E as G}from"./entity-note-count-link-BrS1-O0o.js";import{C as N,B as y,b as k,V as p,c as l,X as E,Z as f,u as z,s as L,a as T,_ as B,U as I,W as R}from"./index-BHIKoiZ6.js";import{P as D}from"./pill-cluster-7UZd_lHp.js";import{b as F,f as U,P as M}from"./project-collections-CZagCmeH.js";import"./state-VYvD1QVP.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function O({goals:s,tags:n,users:c,defaultUserId:o=null,pending:d=!1,onCreate:r,onUpdate:j}){const[u,x]=g.useState(!1),[w,m]=g.useState(null),a=s.find(t=>t.id===w)??null;return e.jsxs(e.Fragment,{children:[e.jsxs(N,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Goal arcs"}),e.jsx("h3",{className:"mt-2 font-display text-3xl text-white",children:"Strategic arcs before tickets"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-white/60",children:"This is the long-horizon map. Each arc shows why it matters, how much ground has been covered, and which project should move next."})]}),e.jsx(y,{onClick:()=>{m(null),x(!0)},children:"Create goal"})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-2",children:[s.length===0?e.jsx("div",{className:"rounded-[24px] bg-white/[0.04] p-5 text-sm leading-7 text-white/60 xl:col-span-2",children:"Start with a life goal. Once the destination is clear, you can attach projects and then fill those projects with tasks."}):null,s.map(t=>{const h=`${Math.max(6,Math.min(100,t.progress))}%`;return e.jsxs(b,{to:`/goals/${t.id}`,className:"rounded-[24px] border border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.06),rgba(255,255,255,0.03))] p-4 transition hover:bg-[linear-gradient(180deg,rgba(255,255,255,0.09),rgba(255,255,255,0.04))]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(k,{kind:"goal",compact:!0,gradient:!1}),e.jsx("div",{className:"mt-2",children:e.jsx(p,{kind:"goal",label:t.title,variant:"heading",size:"lg",showKind:!1,lines:2})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:t.description||"No strategic note attached yet."})]}),e.jsx("button",{className:"rounded-full bg-white/6 p-2 text-white/60 transition hover:bg-white/10 hover:text-white",type:"button",onClick:i=>{i.preventDefault(),i.stopPropagation(),m(t.id),x(!0)},children:e.jsx(P,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(l,{className:"bg-white/[0.08] text-white/70",children:t.horizon}),e.jsx(l,{className:t.status==="active"?"text-emerald-300":t.status==="paused"?"text-amber-300":"text-[var(--tertiary)]",children:t.status}),e.jsxs(l,{className:"bg-white/[0.08] text-white/70",children:[t.earnedPoints," / ",t.targetPoints," xp"]}),e.jsxs(l,{className:"bg-white/[0.08] text-white/70",children:[t.totalTasks," tasks"]})]}),e.jsx("div",{className:"mt-4 h-1.5 rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,var(--primary)_0%,var(--secondary)_100%)]",style:{width:h}})}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:t.tags.map(i=>e.jsx(l,{className:"bg-white/[0.06] text-white/58",children:i.name},i.id))}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.16em] text-white/42",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.momentumLabel}),e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",style:{color:t.themeColor},children:["Open arc",e.jsx(C,{className:"size-3.5"})]})]})]},t.id)})]})]}),e.jsx(E,{open:u,pending:d,editingGoal:a,tags:n,users:c,defaultUserId:o,onOpenChange:t=>{x(t),t||m(null)},onSubmit:async(t,h)=>{if(h){await j(h,t);return}await r(t)}})]})}function _({eyebrow:s,title:n,description:c,meta:o,actions:d,className:r}){return e.jsxs("div",{className:f("flex flex-wrap items-start justify-between gap-3",r),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[s?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s}):null,e.jsxs("div",{className:f("min-w-0",s&&"mt-2"),children:[e.jsx("div",{className:"min-w-0 text-lg text-[var(--ui-ink-strong)]",children:n}),c?e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:c}):null]})]}),o||d?e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:[o,d]}):null]})}function ee(){const s=z(),[n,c]=g.useState("active"),[o,d]=g.useState(null),r=s.snapshot.dashboard.goals.length>0,j=F(s.snapshot.dashboard.projects),u=U(s.snapshot.dashboard.projects,n),x=L(s.selectedUserIds),w=new Map(s.snapshot.dashboard.goals.map(a=>[a.id,u.filter(t=>t.goalId===a.id)])),m=async a=>{d(a);try{await s.patchProject(a,{status:"active"})}finally{d(null)}};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(S,{entityKind:"goal",title:e.jsx(p,{kind:"goal",label:"Life Goals",variant:"heading",size:"lg"}),titleText:"Life Goals",description:"Life goals are the destinations you care about over the long run. Each one can hold several projects, and those projects turn direction into real work.",badge:`${s.snapshot.dashboard.goals.length} active goals`,actions:r?e.jsxs("div",{className:"inline-flex min-h-10 items-center rounded-full border border-white/8 bg-white/[0.04] px-4 py-2 text-sm whitespace-nowrap text-white/68",children:[s.snapshot.dashboard.projects.length," live project",s.snapshot.dashboard.projects.length===1?"":"s"," ","attached"]}):null}),e.jsx(O,{goals:s.snapshot.dashboard.goals,tags:s.snapshot.tags,users:s.snapshot.users,defaultUserId:x,onCreate:s.createGoal,onUpdate:s.patchGoal}),r?e.jsx(M,{value:n,counts:j,onChange:c}):null,r?null:e.jsx(T,{eyebrow:"Life goals",title:"No life goals yet",description:"Define the first long-horizon direction above so Forge can attach projects, tasks, momentum, and evidence to something meaningful."}),r?e.jsx("div",{className:"grid gap-4",children:s.snapshot.dashboard.goals.map(a=>{const t=w.get(a.id)??[],h=B(s.snapshot.dashboard.notesSummaryByEntity,"goal",a.id);return e.jsx(b,{to:`/goals/${a.id}`,className:"min-w-0 overflow-hidden rounded-[28px] border border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.03))] p-4 transition hover:bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.04))] sm:p-5",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)] xl:gap-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(D,{children:[a.tags.slice(0,3).map(i=>e.jsx(l,{className:"bg-white/[0.08]",style:{color:i.color},children:i.name},i.id)),e.jsx(l,{className:"bg-white/[0.08] text-white/72",children:a.horizon}),e.jsx(I,{user:a.user,compact:!0})]}),e.jsx("div",{className:"mt-4",children:e.jsx(p,{kind:"goal",label:a.title,variant:"heading",size:"xl",lines:2})}),e.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-7 text-white/58",children:a.description}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Progress"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[a.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Tasks done"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[a.completedTasks,"/",Math.max(a.totalTasks,1)]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"XP banked"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:a.earnedPoints})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(R,{value:a.progress})}),e.jsx("div",{className:"mt-4",children:e.jsx(G,{entityType:"goal",entityId:a.id,count:h.count})})]}),e.jsxs("div",{className:"min-w-0 rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx(_,{title:"Projects carrying this direction",meta:e.jsx("div",{className:"shrink-0 text-sm text-white/48",children:t.length}),className:"gap-2"}),t.length===0?e.jsx("div",{className:"mt-4 text-sm leading-6 text-white/56",children:n==="active"?"No active project is attached yet. Create one so this direction starts producing visible work.":"No projects in this lifecycle view are attached yet. Switch filters or restart one to bring it back into active motion."}):e.jsx("div",{className:"mt-4 grid gap-3",children:t.slice(0,3).map(i=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.05] px-4 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(k,{kind:"project",compact:!0,gradient:!1}),e.jsx(p,{kind:"project",label:i.title,className:"min-w-0",showIcon:!1,lines:2})]}),e.jsx(l,{className:"shrink-0",children:i.status})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:i.description}),e.jsxs("div",{className:"mt-3 text-sm text-white/42",children:["Next move:"," ",i.nextTaskTitle??"Define the first attached task"]}),n!=="active"&&i.status!=="active"?e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(y,{variant:"secondary",size:"sm",pending:o===i.id,pendingLabel:"Restarting…",onClick:v=>{v.preventDefault(),v.stopPropagation(),m(i.id)},children:"Restart"})}):null]},i.id))})]})]})},a.id)})}):e.jsx(N,{children:e.jsx("div",{className:"rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:"Goal cards will appear here once the first long-horizon direction is created."})})]})}export{ee as GoalsPage};
@@ -1 +0,0 @@
1
- import{r as y,j as e,c2 as $e,aG as qe,cd as We,aV as Ge,ce as Ue,c7 as Qe,c5 as ve,bO as ke,cf as Ne,cg as Ye,aK as Ce,ch as Ze,ci as Je,cj as Ve,ck as et}from"./vendor-kIz9EZnX.js";import{R as Ie,P as _e,O as Pe,C as De,T as Le,D as Se,a as Te}from"./ui-CsEkP2V8.js";import{j as tt,i as oe,k as ce}from"./state-VYvD1QVP.js";import{E as at}from"./entity-note-count-link-BrS1-O0o.js";import{N as st}from"./note-markdown-CsGQhQXF.js";import{Q as it,$ as rt,F as g,I as q,T as xe,a0 as nt,a1 as lt,j as ne,b as M,u as dt,a2 as ot,s as ct,a3 as ht,a4 as mt,a5 as xt,a6 as pt,a7 as he,a8 as ut,B as L,V as He,C as A,h as U,d as Ee,a as gt,_ as bt,Z as P,U as yt,c as b,a9 as wt,aa as ft,ab as Ae,ac as jt,ad as vt,O as kt}from"./index-BHIKoiZ6.js";import{u as Nt,p as Ct}from"./use-psyche-focus-target-qxT5Oy_z.js";import{P as It}from"./page-hero-oFHaAjtL.js";import{S as _t}from"./select-menu-Cdq7foRu.js";import{f as Pt}from"./date-keys-Cj1G3TOn.js";import"./motion-CfdU2F35.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";const me={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:""}},Dt=[{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 Lt(t){return{title:t.title,description:t.description,status:t.status,userId:t.userId??null,polarity:t.polarity,frequency:t.frequency,targetCount:t.targetCount,weekDays:t.weekDays,linkedGoalIds:t.linkedGoalIds,linkedProjectIds:t.linkedProjectIds,linkedTaskIds:t.linkedTaskIds,linkedValueIds:t.linkedValueIds,linkedPatternIds:t.linkedPatternIds,linkedBehaviorIds:t.linkedBehaviorIds,linkedBeliefIds:t.linkedBeliefIds,linkedModeIds:t.linkedModeIds,linkedReportIds:t.linkedReportIds,linkedBehaviorId:t.linkedBehaviorId??"",rewardXp:t.rewardXp,penaltyXp:t.penaltyXp,generatedHealthEventTemplate:t.generatedHealthEventTemplate}}function St({open:t,pending:d=!1,editingHabit:o,values:w,patterns:f,behaviors:T,beliefs:c,modes:j,reports:m,goals:v,projects:H,tasks:D,users:B,defaultUserId:k=null,onOpenChange:C,onSubmit:E}){const[R,S]=y.useState(me),[te,K]=y.useState(null),[I,Z]=y.useState({});y.useEffect(()=>{t&&(S(o?Lt(o):{...me,userId:k}),K(null),Z({}))},[k,o,t]);const O=B.find(i=>i.id===k)??null,z=y.useMemo(()=>T.slice().sort((i,r)=>i.title.localeCompare(r.title)),[T]),_=i=>({linkedBehaviorIds:i,linkedBehaviorId:i[0]??""}),N=(i,r)=>i.includes(r)?i.filter(s=>s!==r):[...i,r],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:(i,r)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Title",error:I.title??null,children:e.jsx(q,{value:i.title,onChange:s=>r({title:s.target.value}),placeholder:"Train lower body"})}),e.jsx(g,{label:"Description",children:e.jsx(xe,{value:i.description,onChange:s=>r({description:s.target.value}),placeholder:"Write the habit description in Markdown. Define what counts, edge cases, and examples."})}),e.jsx(nt,{value:i.userId,users:B,onChange:s=>r({userId:s}),label:"Owner user",defaultLabel:lt(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:(i,r)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Polarity",children:e.jsx(ne,{value:i.polarity,onChange:s=>r({polarity:s}),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(g,{label:"Frequency",children:e.jsx(ne,{value:i.frequency,onChange:s=>r({frequency:s}),options:[{value:"daily",label:"Daily",description:"Track against each day."},{value:"weekly",label:"Weekly",description:"Track only on the selected weekdays."}],columns:2})}),i.frequency==="weekly"?e.jsx(g,{label:"Weekdays",error:I.weekDays??null,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:Dt.map(s=>{const n=i.weekDays.includes(s.value);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${n?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>r({weekDays:n?i.weekDays.filter(J=>J!==s.value):[...i.weekDays,s.value].sort()}),children:s.label},s.value)})})}):null,e.jsx(g,{label:"Status",children:e.jsx(ne,{value:i.status,onChange:s=>r({status:s}),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:(i,r)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Generate workout record",children:e.jsx(ne,{value:i.generatedHealthEventTemplate.enabled?"enabled":"disabled",onChange:s=>r({generatedHealthEventTemplate:{...i.generatedHealthEventTemplate,enabled:s==="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})}),i.generatedHealthEventTemplate.enabled?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Workout type",children:e.jsx(q,{value:i.generatedHealthEventTemplate.workoutType,onChange:s=>r({generatedHealthEventTemplate:{...i.generatedHealthEventTemplate,workoutType:s.target.value}}),placeholder:"mobility, walk, strength, recovery"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{label:"Duration (minutes)",children:e.jsx(q,{type:"number",min:1,max:1440,value:i.generatedHealthEventTemplate.durationMinutes,onChange:s=>r({generatedHealthEventTemplate:{...i.generatedHealthEventTemplate,durationMinutes:Number(s.target.value)||45}})})}),e.jsx(g,{label:"Workout XP",children:e.jsx(q,{type:"number",min:0,max:500,value:i.generatedHealthEventTemplate.xpReward,onChange:s=>r({generatedHealthEventTemplate:{...i.generatedHealthEventTemplate,xpReward:Number(s.target.value)||0}})})})]}),e.jsx(g,{label:"Generated session note",children:e.jsx(xe,{value:i.generatedHealthEventTemplate.notesTemplate,onChange:s=>r({generatedHealthEventTemplate:{...i.generatedHealthEventTemplate,notesTemplate:s.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:(i,r)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map(s=>{const n=i.linkedGoalIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedGoalIds:N(i.linkedGoalIds,s.id)}),children:e.jsx(M,{kind:"goal",label:s.title,gradient:n,className:n?"":"opacity-75"})},s.id)})})}),e.jsx(g,{label:"Projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:H.map(s=>{const n=i.linkedProjectIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedProjectIds:N(i.linkedProjectIds,s.id)}),children:e.jsx(M,{kind:"project",label:s.title,gradient:n,className:n?"":"opacity-75"})},s.id)})})}),e.jsx(g,{label:"Tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:D.map(s=>{const n=i.linkedTaskIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedTaskIds:N(i.linkedTaskIds,s.id)}),children:e.jsx(M,{kind:"task",label:s.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.id)})})}),e.jsx(g,{label:"Values",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(s=>{const n=i.linkedValueIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedValueIds:N(i.linkedValueIds,s.id)}),children:e.jsx(M,{kind:"value",label:s.title,gradient:n,className:n?"":"opacity-75"})},s.id)})})}),e.jsx(g,{label:"Patterns",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:f.map(s=>{const n=i.linkedPatternIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedPatternIds:N(i.linkedPatternIds,s.id)}),children:e.jsx(M,{kind:"pattern",label:s.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.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:(i,r)=>e.jsxs(e.Fragment,{children:[e.jsx(g,{label:"Linked behavior",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:z.map(s=>{const n=i.linkedBehaviorIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r(_(N(i.linkedBehaviorIds,s.id))),children:e.jsx(M,{kind:"behavior",label:s.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.id)})})}),e.jsx(g,{label:"Beliefs",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:c.map(s=>{const n=i.linkedBeliefIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedBeliefIds:N(i.linkedBeliefIds,s.id)}),children:e.jsx(M,{kind:"belief",label:s.statement,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.id)})})}),e.jsx(g,{label:"Modes",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:j.map(s=>{const n=i.linkedModeIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedModeIds:N(i.linkedModeIds,s.id)}),children:e.jsx(M,{kind:"mode",label:s.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.id)})})}),e.jsx(g,{label:"Reports",children:e.jsx("div",{className:"flex max-h-44 flex-wrap gap-2 overflow-y-auto",children:m.map(s=>{const n=i.linkedReportIds.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>r({linkedReportIds:N(i.linkedReportIds,s.id)}),children:e.jsx(M,{kind:"report",label:s.title,gradient:n,className:n?"":"opacity-75",wrap:!0})},s.id)})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(g,{label:"Target count",error:I.targetCount??null,children:e.jsx(q,{type:"number",value:i.targetCount,onChange:s=>r({targetCount:Number(s.target.value)||1})})}),e.jsx(g,{label:"Reward XP",error:I.rewardXp??null,children:e.jsx(q,{type:"number",value:i.rewardXp,onChange:s=>r({rewardXp:Number(s.target.value)||1})})}),e.jsx(g,{label:"Penalty XP",error:I.penaltyXp??null,children:e.jsx(q,{type:"number",value:i.penaltyXp,onChange:s=>r({penaltyXp:Number(s.target.value)||1})})})]})]})}];return e.jsx(it,{open:t,onOpenChange:C,eyebrow:"Habit",title:o?"Edit habit":"Create habit",description:"Habits are recurring commitments or recurring slips with explicit XP consequences.",value:R,onChange:S,draftPersistenceKey:o?`habit.${o.id}`:"habit.new",steps:G,pending:d,pendingLabel:o?"Save habit":"Create habit",submitLabel:o?"Save habit":"Create habit",error:te,onSubmit:async()=>{K(null);const i=rt.safeParse(R);if(!i.success){Z(Object.fromEntries(Object.entries(i.error.flatten().fieldErrors).map(([r,s])=>[r,s==null?void 0:s[0]]))),K("Some habit fields still need attention.");return}Z({});try{await E(i.data,o==null?void 0:o.id),S(me),C(!1)}catch(r){K(r instanceof Error?r.message:"Habit update failed.")}}})}const Tt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ht=["S","M","T","W","T","F","S"],Et=[{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 At(t){return t.frequency==="daily"?`${t.targetCount}x daily`:`${t.targetCount}x weekly · ${t.weekDays.map(d=>Tt[d]).join(", ")}`}function W(t){return Pt(t)}function Me(t){const[d,o,w]=t.split("-").map(Number);return new Date(d,o-1,w)}function Be(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function le(t,d){const o=new Date(t);return o.setDate(o.getDate()+d),o}function Fe(t){const d=Be(t),o=(d.getDay()+6)%7;return d.setDate(d.getDate()-o),d}function ee(t){const d=typeof t=="string"?Me(t):t;return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(d)}function de(t,d){return t.polarity==="positive"&&d==="done"||t.polarity==="negative"&&d==="missed"}function pe(t,d){return t.polarity==="positive"?d==="done"?"Done":"Missed":d==="done"?"Performed":"Resisted"}function Ke(t){const d=W(new Date),o=t.checkIns.find(w=>w.dateKey===d)??null;return t.dueToday?{tone:"pending",label:t.frequency==="daily"?"Waiting for today":"Awaiting this week's check-in",cardClass:"border-amber-300/24 shadow-[0_0_0_1px_rgba(251,191,36,0.12)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,rgba(251,191,36,0.18),transparent_44%)]",pillClass:"border border-amber-300/16 bg-amber-300/12 text-amber-100"}:o?de(t,o.status)?{tone:"aligned",label:`${pe(t,o.status)} today`,cardClass:"border-emerald-300/20 shadow-[0_0_0_1px_rgba(52,211,153,0.08)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,rgba(52,211,153,0.16),transparent_44%)]",pillClass:"border border-emerald-300/16 bg-emerald-300/12 text-emerald-100"}:{tone:"unaligned",label:`${pe(t,o.status)} today`,cardClass:"border-rose-300/20 shadow-[0_0_0_1px_rgba(251,113,133,0.08)]",overlayClass:"bg-[radial-gradient(circle_at_top_right,rgba(251,113,133,0.16),transparent_44%)]",pillClass:"border border-rose-300/16 bg-rose-300/12 text-rose-100"}:t.polarity==="positive"?{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,rgba(52,211,153,0.09),transparent_40%)]",pillClass:"border border-white/10 bg-white/[0.06] text-white/62"}:{tone:"neutral",label:"No update due right now",cardClass:"",overlayClass:"bg-[radial-gradient(circle_at_top_right,rgba(251,113,133,0.09),transparent_40%)]",pillClass:"border border-white/10 bg-white/[0.06] text-white/62"}}function Ft(t){return t>=10?{Icon:Ze,className:"border border-amber-300/20 bg-amber-300/10 text-amber-100 shadow-[0_16px_32px_rgba(251,191,36,0.14)]",iconClass:"text-amber-200",valueClass:"text-amber-50",label:"Celebration pace"}:t>=5?{Icon:Je,className:"border border-emerald-300/20 bg-emerald-300/10 text-emerald-100 shadow-[0_16px_32px_rgba(52,211,153,0.12)]",iconClass:"text-emerald-200",valueClass:"text-emerald-50",label:"Locked in"}:t>=1?{Icon:Ve,className:"border border-sky-300/18 bg-sky-300/10 text-sky-100 shadow-[0_16px_32px_rgba(125,211,252,0.1)]",iconClass:"text-sky-200",valueClass:"text-sky-50",label:"Building rhythm"}:{Icon:et,className:"border border-white/10 bg-white/[0.04] text-white/72 shadow-[0_16px_32px_rgba(15,23,42,0.16)]",iconClass:"text-white/55",valueClass:"text-white",label:"Cold start"}}function Mt(t){return t>=80?"bg-emerald-400/12 text-emerald-100":t>=50?"bg-amber-300/12 text-amber-100":"bg-rose-400/12 text-rose-100"}function Bt(t){var T;const d=new Date;if(t.frequency==="daily"){const c=Be(d),j=[];for(let m=-6;m<=0;m+=1){const v=le(c,m),H=W(v),D=t.checkIns.find(C=>C.dateKey===H)??null,B=Ht[v.getDay()],k=m===0;j.push({id:H,label:B,current:k,actionDateKey:H,actionLabel:ee(v),state:D?de(t,D.status)?"aligned":"unaligned":"unknown",title:`${ee(v)} · ${D?pe(t,D.status):"Not informed"}`})}return{caption:"7-day rhythm",rangeLabel:"Past 7 days",showLabels:!0,startLabel:"",endLabel:"",cells:j}}const o=Fe(d),w=new Map;for(const c of t.checkIns){const j=W(Fe(Me(c.dateKey))),m=w.get(j)??[];m.push(c),w.set(j,m)}const f=[];for(let c=-6;c<=0;c+=1){const j=le(o,c*7),m=W(j),v=w.get(m)??[],H=t.weekDays.length>0?[...t.weekDays].sort((E,R)=>R-E)[0]:0,D=W(le(j,H)),B=((T=v[0])==null?void 0:T.dateKey)??D,k=v.filter(E=>de(t,E.status)).length,C=v.length-k;f.push({id:m,label:"",current:c===0,actionDateKey:B,actionLabel:`Week of ${ee(j)}`,state:v.length===0?"unknown":k>=C?"aligned":"unaligned",title:`${ee(j)} week · ${v.length===0?"Not informed":k>=C?"Mostly aligned":"Mostly off track"}`})}return{caption:"7-week rhythm",rangeLabel:"Past 7 weeks",showLabels:!1,startLabel:ee(le(o,-42)),endLabel:"This week",cells:f}}function Kt(t,d){return P("h-8 w-full rounded-[10px] border transition",t==="aligned"&&"border-emerald-300/20 bg-emerald-300/75 shadow-[0_8px_18px_rgba(52,211,153,0.18)]",t==="unaligned"&&"border-rose-300/20 bg-rose-300/75 shadow-[0_8px_18px_rgba(251,113,133,0.18)]",t==="unknown"&&"border-white/8 bg-white/[0.08]",d&&"shadow-[0_0_0_1px_rgba(255,255,255,0.16)]")}function Xt({habit:t,onSelectCell:d}){const o=Bt(t),w=Ke(t);return e.jsxs("div",{className:"w-full rounded-[18px] border border-white/8 bg-black/10 px-3 py-2.5",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-white/34",children:o.caption}),e.jsx("div",{className:"text-[11px] text-white/46",children:o.rangeLabel})]}),e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:o.cells.map(f=>e.jsxs("button",{type:"button",className:"group flex min-w-0 flex-1 items-center gap-1 rounded-[10px] transition hover:bg-white/[0.04]",onClick:()=>d(t,f),title:`Log check-in for ${f.actionLabel}`,"aria-label":`Log check-in for ${f.actionLabel}`,children:[e.jsx("div",{className:P(Kt(f.state,f.current),"h-6 min-w-0 flex-1 rounded-[8px] transition duration-150 group-hover:-translate-y-0.5 group-hover:shadow-[0_10px_22px_rgba(15,23,42,0.22)]")}),o.showLabels?e.jsx("span",{className:"hidden text-[9px] uppercase tracking-[0.14em] text-white/26 transition group-hover:text-white/48 sm:inline",children:f.label}):null]},f.id))}),e.jsx("div",{className:P("shrink-0 rounded-full px-2.5 py-1 text-[10px] font-medium",w.pillClass),children:w.label})]}),o.showLabels?null:e.jsxs("div",{className:"mt-1 text-right text-[10px] uppercase tracking-[0.14em] text-white/26",children:[o.startLabel," - ",o.endLabel]})]})}function Rt(t){return t.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(t,d){return t.polarity==="positive"?d==="aligned"?"done":"missed":d==="aligned"?"missed":"done"}function Y(t,d){return de(t,d)?"aligned":"unaligned"}function aa(){var ge,be,ye,we,fe,je;const t=dt(),d=tt(),[o,w]=$e(),[f,T]=y.useState(null),[c,j]=y.useState(null),[m,v]=y.useState(null),[H,D]=y.useState(""),[B,k]=y.useState(!1),[C,E]=y.useState(null),[R,S]=y.useState(null),te=o.get("focus"),K=o.get("orderBy")??"name",I=ot(t.selectedUserIds),Z=ct(I),O=["forge-habits",K,...I];Nt(te);const z=oe({queryKey:O,queryFn:async()=>(await jt({userIds:I,orderBy:K})).habits}),_=oe({queryKey:["forge-psyche-overview",...I],queryFn:async()=>(await vt(I)).overview}),N=oe({queryKey:["forge-life-force",...I],queryFn:async()=>(await kt(I)).lifeForce});y.useEffect(()=>{o.get("create")==="1"&&(T(null),k(!0),w(a=>{const u=new URLSearchParams(a);return u.delete("create"),u},{replace:!0}))},[o,w]);const G=async()=>{await d.invalidateQueries({queryKey:["forge-habits"]}),await t.refresh()},i=ce({mutationFn:async({input:a,habitId:u})=>u?(await ht(u,a)).habit:(await mt(a)).habit,onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit save failed.")}}),r=ce({mutationFn:async({habitId:a,status:u,dateKey:h,note:$})=>xt(a,{status:u,dateKey:h,note:$}),onSuccess:async()=>{S(null),await G()},onError:a=>{S(a instanceof Error?a.message:"Habit check-in failed.")}}),s=ce({mutationFn:async a=>pt(a),onMutate:async a=>{await d.cancelQueries({queryKey:O});const u=d.getQueryData(O);return d.setQueryData(O,h=>(h==null?void 0:h.filter($=>$.id!==a))??[]),{previousHabits:u}},onSuccess:async()=>{S(null),E(null),await G()},onError:(a,u,h)=>{h!=null&&h.previousHabits&&d.setQueryData(O,h.previousHabits),S(a instanceof Error?a.message:"Habit delete failed.")}}),n=y.useMemo(()=>(z.data??[]).filter(a=>a.status!=="archived"),[z.data]),J=y.useMemo(()=>n.filter(a=>a.dueToday),[n]),Xe=y.useMemo(()=>J.reduce((a,u)=>{var ae;const h=Ae().totalAp,$=((ae=he(u))==null?void 0:ae.totalAp)??0;return a+h+$},0),[J]),Re=y.useMemo(()=>n.reduce((a,u)=>{var h;return a+(((h=he(u))==null?void 0:h.totalAp)??0)},0),[n]),X=y.useMemo(()=>c?c.habit.checkIns.find(a=>a.dateKey===c.cell.actionDateKey)??null:null,[c]);if(y.useEffect(()=>{if(!c){v(null),D("");return}v((X==null?void 0:X.status)??null),D((X==null?void 0:X.note)??"")},[c,X]),z.error)throw z.error;const Oe=a=>{w(u=>{const h=new URLSearchParams(u);return a==="name"?h.delete("orderBy"):h.set("orderBy",a),h},{replace:!0})},V=c?Rt(c.habit):null,ue=m==="done"||m==="missed"||X!==null;return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(It,{entityKind:"habit",title:e.jsx(He,{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(ut,{metrics:t.snapshot.metrics}),e.jsxs(L,{onClick:()=>{T(null),k(!0)},children:[e.jsx(qe,{className:"size-4"}),"New habit"]})]})}),R?e.jsx(A,{className:"border-rose-400/22 bg-rose-400/8 text-rose-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(We,{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-amber-300/16 shadow-[0_0_0_1px_rgba(251,191,36,0.08)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",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-white/58",children:"Habits that still need a check-in today."})]}),e.jsxs(A,{className:"border-[var(--primary)]/16 shadow-[0_0_0_1px_rgba(245,158,11,0.08)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Habit AP due"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:U(Xe)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:"Default Action Point load if every due habit is logged today."})]}),e.jsxs(A,{className:"border-emerald-300/16 shadow-[0_0_0_1px_rgba(52,211,153,0.08)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Best streak"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-emerald-50",children:Math.max(0,...n.map(a=>a.streakCount))}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Average alignment"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[n.length>0?Math.round(n.reduce((a,u)=>a+u.completionRate,0)/n.length):0,"%"]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-white",children:N.data?`${U(N.data.spentTodayAp)} / ${U(N.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-white",children:N.data?Ee(N.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/45",children:"Workout-linked load"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-white",children:U(Re)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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(gt,{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),k(!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-white/8 bg-white/[0.03] p-4 shadow-[0_18px_36px_rgba(15,23,42,0.16)] 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-white",children:"Habit list order"}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:"Choose a stable ordering so the list does not reshuffle while you are logging check-ins."})]}),e.jsx(_t,{label:"Order by",value:K,options:Et,onChange:Oe,className:"w-full sm:w-[19rem]"})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:n.map(a=>{const u=Ke(a),h=Ft(a.streakCount),$=h.Icon,ae=Ae(),se=he(a),ze=bt(t.snapshot.dashboard.notesSummaryByEntity,"habit",a.id).count,ie=a.polarity==="positive"?{label:"Done",status:Q(a,"aligned"),Icon:ke,className:"border-emerald-300/18 bg-emerald-300/14 text-emerald-50 shadow-[0_14px_28px_rgba(52,211,153,0.14)] hover:bg-emerald-300/20"}:{label:"Resisted",status:Q(a,"aligned"),Icon:ve,className:"border-emerald-300/18 bg-emerald-300/14 text-emerald-50 shadow-[0_14px_28px_rgba(52,211,153,0.14)] hover:bg-emerald-300/20"},re=a.polarity==="positive"?{label:"Missed",status:Q(a,"unaligned"),Icon:Ne,className:"border-rose-300/18 bg-rose-300/14 text-rose-50 shadow-[0_14px_28px_rgba(251,113,133,0.14)] hover:bg-rose-300/20"}:{label:"Performed",status:Q(a,"unaligned"),Icon:Ye,className:"border-rose-300/18 bg-rose-300/14 text-rose-50 shadow-[0_14px_28px_rgba(251,113,133,0.14)] hover:bg-rose-300/20"};return e.jsxs(A,{className:P("relative flex h-full flex-col overflow-hidden",u.cardClass,Ct(te===a.id)),"data-psyche-focus-id":a.id,children:[e.jsx("div",{className:P("pointer-events-none absolute inset-0 opacity-100",u.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(He,{kind:"habit",label:a.title,variant:"heading",size:"sm"}),e.jsx(yt,{user:a.user,compact:!0}),e.jsx(b,{className:"bg-white/[0.08] text-white/72",children:a.status}),e.jsxs(b,{className:"bg-white/[0.08] text-white/72",children:[e.jsx(Ge,{className:"mr-1 size-3.5"}),At(a)]}),e.jsx(b,{className:a.polarity==="positive"?"bg-emerald-400/12 text-emerald-200":"bg-rose-400/12 text-rose-200",children:a.polarity==="positive"?"Positive":"Negative"}),a.dueToday?e.jsx(b,{className:"bg-amber-300/12 text-amber-100",children:"Needs check-in"}):null,a.linkedGoalIds.slice(0,1).map(x=>{const l=t.snapshot.goals.find(p=>p.id===x);return l?e.jsxs(b,{className:"bg-amber-400/12 text-amber-100",children:["Goal · ",l.title]},l.id):null}),a.linkedProjectIds.slice(0,1).map(x=>{const l=t.snapshot.dashboard.projects.find(p=>p.id===x);return l?e.jsxs(b,{className:"bg-sky-400/12 text-sky-100",children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(0,1).map(x=>{const l=t.snapshot.tasks.find(p=>p.id===x);return l?e.jsxs(b,{className:"bg-indigo-400/12 text-indigo-100",children:["Task · ",l.title]},l.id):null})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/60",children:a.description?e.jsx(st,{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",h.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",h.iconClass)})]}),e.jsx("div",{className:P("mt-1.5 font-display text-[2.75rem] leading-none",h.valueClass),children:a.streakCount}),e.jsx("div",{className:"mt-1 text-[11px] leading-tight text-white/68",children:h.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-white/8 bg-white/[0.04] px-3 text-white/72 hover:bg-white/[0.08] hover:text-white",disabled:i.isPending,onClick:()=>{T(a),k(!0)},"aria-label":`Edit ${a.title}`,title:"Edit habit",children:e.jsx(Ue,{className:"size-4"})}),e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 min-w-0 rounded-[11px] border border-white/8 bg-white/[0.04] px-3 text-white/72 hover:bg-white/[0.08] hover:text-white",disabled:s.isPending,onClick:()=>E(a),"aria-label":`Delete ${a.title}`,title:"Delete habit",children:e.jsx(Qe,{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(b,{className:P("border-0",Mt(a.completionRate)),children:["Alignment ",a.completionRate,"%"]}),e.jsx(b,{className:"bg-white/[0.08] text-white/72",children:a.polarity==="positive"?`+${a.rewardXp} XP done`:`+${a.rewardXp} XP resisted`}),e.jsx(b,{className:"bg-white/[0.08] text-white/72",children:a.polarity==="positive"?`-${a.penaltyXp} XP missed`:`-${a.penaltyXp} XP performed`}),e.jsxs(b,{className:"bg-[var(--primary)]/12 text-[var(--primary)]",children:[U(ae.totalAp)," check-in"]}),se?e.jsxs(b,{className:"bg-orange-400/12 text-orange-100",children:[U(se.totalAp)," ","workout"]}):null,se?e.jsx(b,{className:"bg-white/[0.08] text-white/72",children:Ee(se.rateApPerHour)}):null,e.jsx(at,{entityType:"habit",entityId:a.id,count:ze,className:"min-h-8 rounded-full border-white/8 bg-white/[0.04] px-3 py-1.5 text-[12px] text-white/68 hover:bg-white/[0.07]"}),a.linkedBehaviorTitles.slice(0,2).map(x=>e.jsxs(b,{className:"bg-orange-400/12 text-orange-100",children:[e.jsx(ve,{className:"mr-1 size-3.5"}),x]},x)),a.linkedProjectIds.slice(1,2).map(x=>{const l=t.snapshot.dashboard.projects.find(p=>p.id===x);return l?e.jsxs(b,{className:"bg-sky-400/12 text-sky-100",children:["Project · ",l.title]},l.id):null}),a.linkedTaskIds.slice(1,2).map(x=>{const l=t.snapshot.tasks.find(p=>p.id===x);return l?e.jsxs(b,{className:"bg-indigo-400/12 text-indigo-100",children:["Task · ",l.title]},l.id):null}),a.linkedValueIds.slice(0,2).map(x=>{var p;const l=(p=_.data)==null?void 0:p.values.find(F=>F.id===x);return l?e.jsxs(b,{className:"bg-emerald-400/12 text-emerald-100",children:["Value · ",l.title]},l.id):null}),a.linkedPatternIds.slice(0,2).map(x=>{var p;const l=(p=_.data)==null?void 0:p.patterns.find(F=>F.id===x);return l?e.jsxs(b,{className:"bg-cyan-400/12 text-cyan-100",children:["Pattern · ",l.title]},l.id):null}),a.linkedBeliefIds.slice(0,2).map(x=>{var p;const l=(p=_.data)==null?void 0:p.beliefs.find(F=>F.id===x);return l?e.jsxs(b,{className:"bg-rose-400/12 text-rose-100",children:["Belief · ",l.statement]},l.id):null}),a.linkedModeIds.slice(0,2).map(x=>{var p;const l=(p=_.data)==null?void 0:p.modes.find(F=>F.id===x);return l?e.jsxs(b,{className:"bg-violet-400/12 text-violet-100",children:["Mode · ",l.title]},l.id):null}),a.linkedReportIds.slice(0,2).map(x=>{var p;const l=(p=_.data)==null?void 0:p.reports.find(F=>F.id===x);return l?e.jsxs(b,{className:"bg-fuchsia-400/12 text-fuchsia-100",children:["Report · ",l.title]},l.id):null})]}),e.jsx("div",{className:"grid gap-4",children:e.jsx(Xt,{habit:a,onSelectCell:(x,l)=>{j({habit:x,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",ie.className),disabled:r.isPending,onClick:()=>void r.mutateAsync({habitId:a.id,status:ie.status,dateKey:W(new Date)}),children:[e.jsx(ie.Icon,{className:"size-4"}),ie.label]}),e.jsxs(L,{variant:"secondary",className:P("h-11 rounded-[16px] border",re.className),disabled:r.isPending,onClick:()=>void r.mutateAsync({habitId:a.id,status:re.status,dateKey:W(new Date)}),children:[e.jsx(re.Icon,{className:"size-4"}),re.label]})]})]})]})]},a.id)})})]}),e.jsx(St,{open:B,pending:i.isPending,editingHabit:f,values:((ge=_.data)==null?void 0:ge.values)??[],patterns:((be=_.data)==null?void 0:be.patterns)??[],behaviors:((ye=_.data)==null?void 0:ye.behaviors)??[],beliefs:((we=_.data)==null?void 0:we.beliefs)??[],modes:((fe=_.data)==null?void 0:fe.modes)??[],reports:((je=_.data)==null?void 0:je.reports)??[],goals:t.snapshot.dashboard.goals,projects:t.snapshot.dashboard.projects,tasks:t.snapshot.tasks,users:t.snapshot.users,defaultUserId:(f==null?void 0:f.userId)??Z,onOpenChange:k,onSubmit:async(a,u)=>{try{await i.mutateAsync({input:a,habitId:u})}catch(h){throw h instanceof wt,h}}}),e.jsx(Ie,{open:C!==null,onOpenChange:a=>{!a&&!s.isPending&&E(null)},children:e.jsxs(_e,{children:[e.jsx(Pe,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),e.jsxs(De,{className:"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 border-white/8 bg-[linear-gradient(180deg,rgba(20,28,42,0.98),rgba(12,17,30,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.45)]",children:[e.jsx("div",{className:"border-b border-white/8 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-white/40",children:"Delete habit"}),e.jsx(Le,{className:"mt-2 text-lg font-semibold text-white",children:(C==null?void 0:C.title)??"Delete this habit?"}),e.jsx(Se,{className:"mt-3 text-sm text-white/56",children:"Remove this habit from Forge. The habit card disappears immediately after delete succeeds."})]}),e.jsx(Te,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-white/8 bg-white/[0.04] px-0 text-white/72 hover:bg-white/[0.08] hover:text-white","aria-label":"Close delete habit modal",title:"Close",disabled:s.isPending,children:e.jsx(Ce,{className:"size-4"})})})]})}),e.jsxs("div",{className:"grid gap-4 p-5",children:[e.jsx("div",{className:"rounded-[20px] border border-rose-400/16 bg-rose-400/8 px-4 py-3 text-sm leading-6 text-rose-100/90",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:s.isPending,children:"Cancel"}),e.jsx(L,{className:"border border-rose-300/18 bg-rose-300/14 text-rose-50 hover:bg-rose-300/20",pending:s.isPending,pendingLabel:"Deleting",onClick:()=>{C&&s.mutateAsync(C.id)},children:"Delete habit"})]})]})]})]})}),e.jsx(Ie,{open:c!==null,onOpenChange:a=>{a||j(null)},children:e.jsxs(_e,{children:[e.jsx(Pe,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),e.jsxs(De,{className:"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 border-white/8 bg-[linear-gradient(180deg,rgba(20,28,42,0.98),rgba(12,17,30,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.45)]",children:[e.jsx(Le,{className:"sr-only",children:"Habit history"}),e.jsx(Se,{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-white/8 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-white/40",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-white",children:c.habit.title}),e.jsx(b,{className:"bg-white/[0.08] text-white/76",children:c.cell.actionLabel})]}),e.jsx("div",{className:"mt-3 text-sm text-white/56",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(Te,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-10 w-10 rounded-[14px] border border-white/8 bg-white/[0.04] px-0 text-white/72 hover:bg-white/[0.08] hover:text-white","aria-label":"Close history modal",title:"Close",children:e.jsx(Ce,{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-emerald-300/24 bg-emerald-300/14 text-white shadow-[0_16px_36px_rgba(52,211,153,0.14)]":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"),onClick:()=>v(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(ke,{className:"size-4"}),V.alignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",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-rose-300/24 bg-rose-300/14 text-white shadow-[0_16px_36px_rgba(251,113,133,0.14)]":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"),onClick:()=>v(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(Ne,{className:"size-4"}),V.unalignedLabel]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:V.unalignedDescription})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:"Optional note"}),e.jsx(xe,{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:()=>j(null),disabled:r.isPending,children:"Cancel"}),e.jsx(L,{disabled:r.isPending||!ue,pending:r.isPending,pendingLabel:"Saving",onClick:async()=>{ue&&(m===null?(await ft(c.habit.id,c.cell.actionDateKey),await G()):await r.mutateAsync({habitId:c.habit.id,status:m,dateKey:c.cell.actionDateKey,note:H.trim()||void 0}),j(null))},children:"Save check-in"})]})]})]}):null]})]})})]})}export{aa as HabitsPage};