forge-openclaw-plugin 0.2.118 → 0.3.1

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 (119) hide show
  1. package/dist/assets/{activity-page-DPPiiyLO.js → activity-page-DRRbpVK-.js} +1 -1
  2. package/dist/assets/{ai-surface-workspace-B_fV9C4s.js → ai-surface-workspace-DJPt-OaW.js} +1 -1
  3. package/dist/assets/{atlas-panel-BPTJyMcI.js → atlas-panel-G3wGxjYf.js} +1 -1
  4. package/dist/assets/{calendar-page-D4DcRQv7.js → calendar-page-y8G1ige8.js} +1 -1
  5. package/dist/assets/{calendar-rules-Cl_xMrBn.js → calendar-rules-CRhXqGQu.js} +1 -1
  6. package/dist/assets/{calendar-week-toolbar-BARSOEO9.js → calendar-week-toolbar-CWSK5hJl.js} +1 -1
  7. package/dist/assets/{companion-sync-lab-page-COFYDI3w.js → companion-sync-lab-page-kEgOF3c6.js} +1 -1
  8. package/dist/assets/daily-metrics-dashboard-BJjUIZVA.js +1 -0
  9. package/dist/assets/{entity-note-count-link-BX93WYgh.js → entity-note-count-link-ef3ZOpKM.js} +1 -1
  10. package/dist/assets/{entity-notes-surface-CBlKc-x-.js → entity-notes-surface-CaCjjUaq.js} +1 -1
  11. package/dist/assets/{execution-board-Dh41UeKR.js → execution-board-RRWm2srb.js} +1 -1
  12. package/dist/assets/{faceted-token-search-BgxYH_gW.js → faceted-token-search-CZmtyJTT.js} +1 -1
  13. package/dist/assets/{flagship-signal-deck-bolzzK8q.js → flagship-signal-deck-DxRfmfpN.js} +1 -1
  14. package/dist/assets/{floating-action-menu-C5H-Wr2B.js → floating-action-menu-cKjNsPYD.js} +1 -1
  15. package/dist/assets/{goal-detail-page-CQeFnGDJ.js → goal-detail-page-BgQlK7yT.js} +1 -1
  16. package/dist/assets/{goals-page-BTg9crEK.js → goals-page-Cz2i3pVy.js} +1 -1
  17. package/dist/assets/{habits-page-C4vqk346.js → habits-page-BmEmWCGv.js} +1 -1
  18. package/dist/assets/index-Bcem7l5u.css +1 -0
  19. package/dist/assets/{index-By3tQxiE.js → index-QJkjKYzZ.js} +2 -2
  20. package/dist/assets/{insight-flow-dialog-JPYCsTKI.js → insight-flow-dialog-CdYMHwMP.js} +1 -1
  21. package/dist/assets/{insights-page-CFhVMlVL.js → insights-page-DHG-o9P_.js} +1 -1
  22. package/dist/assets/{kanban-page-DC3IDsnh.js → kanban-page-C6S_fJRc.js} +1 -1
  23. package/dist/assets/{knowledge-graph-page-DucyRYTZ.js → knowledge-graph-page-juA9QCy0.js} +1 -1
  24. package/dist/assets/{life-force-page-UrXfxaSO.js → life-force-page-ChTIA4mV.js} +1 -1
  25. package/dist/assets/{life-force-workspace-BhPNH7ad.js → life-force-workspace-sszLD-Yn.js} +1 -1
  26. package/dist/assets/{metric-tile-DtRPjN4V.js → metric-tile-B-tDTcBt.js} +1 -1
  27. package/dist/assets/{movement-page-DCIdTQEN.js → movement-page-Dx3T3HrG.js} +1 -1
  28. package/dist/assets/{note-markdown-CepDxj3v.js → note-markdown-CCyyE85h.js} +1 -1
  29. package/dist/assets/{note-tags-input-BXYaDkOr.js → note-tags-input-BS14YXHn.js} +1 -1
  30. package/dist/assets/{notes-page-Bl1LlCLo.js → notes-page-D3yGl8TN.js} +1 -1
  31. package/dist/assets/{open-in-graph-button-C263zl5l.js → open-in-graph-button-CMjJZX7G.js} +1 -1
  32. package/dist/assets/{orbit-map-Cb_AJyIj.js → orbit-map-v2Pv9RU_.js} +1 -1
  33. package/dist/assets/{overview-page-C2yLity7.js → overview-page-DSOpBpHf.js} +1 -1
  34. package/dist/assets/{page-hero-5RTqAI88.js → page-hero-CONuJu5J.js} +1 -1
  35. package/dist/assets/{pill-cluster-CBrrtZBm.js → pill-cluster-W2fY48OM.js} +1 -1
  36. package/dist/assets/{preference-entity-handoff-button-BQzg2J4k.js → preference-entity-handoff-button-CKDxCnbl.js} +1 -1
  37. package/dist/assets/{preferences-page-DekYF-Yz.js → preferences-page-Br3zrLlH.js} +1 -1
  38. package/dist/assets/{project-collections-BVXB8PPF.js → project-collections-NBwk6yV-.js} +1 -1
  39. package/dist/assets/{project-detail-page-CQlrLEn9.js → project-detail-page-BIU9_TRN.js} +1 -1
  40. package/dist/assets/{project-management-hierarchy-page--mzM_zRE.js → project-management-hierarchy-page-C2H620xD.js} +1 -1
  41. package/dist/assets/{project-management-section-nav-DQl0qRWy.js → project-management-section-nav-DRPVS1Eh.js} +1 -1
  42. package/dist/assets/{projects-page-Dr_0NdVP.js → projects-page-w7a_L2-z.js} +1 -1
  43. package/dist/assets/{psyche-behaviors-page-DOUaCWON.js → psyche-behaviors-page-Dt4CMC-q.js} +1 -1
  44. package/dist/assets/{psyche-flashcards-page-BA84fO_X.js → psyche-flashcards-page-rXz06dqO.js} +1 -1
  45. package/dist/assets/{psyche-goal-map-page-DpXAg1Vf.js → psyche-goal-map-page-BCcD6Jkl.js} +1 -1
  46. package/dist/assets/{psyche-graph-BxcbAbXt.js → psyche-graph-CXlAj4ED.js} +1 -1
  47. package/dist/assets/psyche-metrics-page-B1otiir6.js +1 -0
  48. package/dist/assets/{psyche-mode-guide-page-CBlIS5N_.js → psyche-mode-guide-page-C6AdVIAv.js} +1 -1
  49. package/dist/assets/{psyche-modes-page-DE6KDK_1.js → psyche-modes-page-DoUqz2mR.js} +1 -1
  50. package/dist/assets/psyche-page-BJNLQn8W.js +1 -0
  51. package/dist/assets/{psyche-patterns-page-DbCNRuww.js → psyche-patterns-page-CzpMSAPu.js} +1 -1
  52. package/dist/assets/{psyche-questionnaire-builder-page-DnraDj1H.js → psyche-questionnaire-builder-page-DjzatGVZ.js} +1 -1
  53. package/dist/assets/{psyche-questionnaire-detail-page-DQ6zNQkk.js → psyche-questionnaire-detail-page-B0Qfowfg.js} +1 -1
  54. package/dist/assets/{psyche-questionnaire-run-detail-page-BGrOIX0B.js → psyche-questionnaire-run-detail-page-B2dNj4jJ.js} +1 -1
  55. package/dist/assets/{psyche-questionnaire-run-page-Bg3BhBHb.js → psyche-questionnaire-run-page-DyD9Ui-g.js} +1 -1
  56. package/dist/assets/{psyche-questionnaires-page-BEreTNjG.js → psyche-questionnaires-page-BxfKcoi3.js} +1 -1
  57. package/dist/assets/{psyche-report-detail-page-Br9KlJBG.js → psyche-report-detail-page-Ci14mNUK.js} +1 -1
  58. package/dist/assets/{psyche-reports-page-Bk6QpAEF.js → psyche-reports-page-ALhNueiV.js} +1 -1
  59. package/dist/assets/{psyche-schemas-beliefs-page-Db8d2ga7.js → psyche-schemas-beliefs-page-C0P2Vw6-.js} +1 -1
  60. package/dist/assets/{psyche-screen-time-page-NazHUAkT.js → psyche-screen-time-page-BYnaT3cb.js} +1 -1
  61. package/dist/assets/{psyche-self-observation-page-H6FToucM.js → psyche-self-observation-page-eM9vpwIB.js} +1 -1
  62. package/dist/assets/{psyche-values-page-DqM382-6.js → psyche-values-page-BqrGIDok.js} +1 -1
  63. package/dist/assets/{report-chain-fields-nW4zndrM.js → report-chain-fields-CbkT7WOO.js} +1 -1
  64. package/dist/assets/{rewards-page-C-tZVnIK.js → rewards-page-DpAJ8IxE.js} +1 -1
  65. package/dist/assets/{scheduling-rules-editor-DGF-044c.js → scheduling-rules-editor-BUGnZJ0g.js} +1 -1
  66. package/dist/assets/{schema-badge-57AJ3FY-.js → schema-badge-CLAA4p-b.js} +1 -1
  67. package/dist/assets/{select-menu-mfaklv7r.js → select-menu-Cqs5t3ng.js} +1 -1
  68. package/dist/assets/{settings-agents-page-CPJeeYg0.js → settings-agents-page-pmkVrOO8.js} +1 -1
  69. package/dist/assets/{settings-bin-page-D3eX5aNf.js → settings-bin-page-BwtLrweW.js} +1 -1
  70. package/dist/assets/{settings-calendar-page-Bgx8NIsP.js → settings-calendar-page-BBjAMOCf.js} +1 -1
  71. package/dist/assets/{settings-data-page-BuMSUjpp.js → settings-data-page-Bqy5SukM.js} +1 -1
  72. package/dist/assets/{settings-logs-page-CHb2GNUM.js → settings-logs-page-8khtrf4T.js} +1 -1
  73. package/dist/assets/{settings-mobile-page-ClUvXhJg.js → settings-mobile-page-BcyRjEU_.js} +1 -1
  74. package/dist/assets/{settings-models-page-njK6D7zc.js → settings-models-page-DlSnO9WX.js} +1 -1
  75. package/dist/assets/{settings-page-Dm--cx6B.js → settings-page-CyBQ2qcB.js} +1 -1
  76. package/dist/assets/{settings-rewards-page-3aShLM3A.js → settings-rewards-page-BBX2WtVM.js} +1 -1
  77. package/dist/assets/{settings-section-nav-BWox23Qv.js → settings-section-nav-Co0AaDG-.js} +1 -1
  78. package/dist/assets/{settings-users-page-D-hEPpgQ.js → settings-users-page-JSnfFFPu.js} +1 -1
  79. package/dist/assets/{settings-wiki-page-CC-rOtDm.js → settings-wiki-page--nT23Fdy.js} +1 -1
  80. package/dist/assets/{sleep-page-Cm_Ei2w1.js → sleep-page-CGMi3MtV.js} +1 -1
  81. package/dist/assets/{sports-page-CqSI-j-H.js → sports-page-Kv5bBoLr.js} +1 -1
  82. package/dist/assets/{strategies-page-BuJ4zLLv.js → strategies-page-Br7RdUJO.js} +1 -1
  83. package/dist/assets/{strategy-detail-page-CLmy0jbW.js → strategy-detail-page-CBWXjUhC.js} +1 -1
  84. package/dist/assets/{strategy-dialog-DnJix1ys.js → strategy-dialog-BTwkaSxI.js} +1 -1
  85. package/dist/assets/{surface-DRNu5Fpz.js → surface-CyWI7e1R.js} +1 -1
  86. package/dist/assets/{task-detail-page-DTnNjW33.js → task-detail-page-Qis9354n.js} +1 -1
  87. package/dist/assets/{timebox-planning-dialog-DckIr1K4.js → timebox-planning-dialog-DB8snOBD.js} +1 -1
  88. package/dist/assets/{today-page-Cgk4HBPK.js → today-page-D9A5PU0S.js} +1 -1
  89. package/dist/assets/{training-load-page-C-7iINaB.js → training-load-page-Bpd4DQAh.js} +1 -1
  90. package/dist/assets/vitals-page-CVYC-4RG.js +1 -0
  91. package/dist/assets/{weekly-review-page-DFmuzzig.js → weekly-review-page-BP7N3fNB.js} +1 -1
  92. package/dist/assets/{weight-loss-page-CWtgeuti.js → weight-loss-page-_fX3N1UK.js} +1 -1
  93. package/dist/assets/{wiki-article-markdown-BkQg8Hne.js → wiki-article-markdown-Bi02AsVt.js} +1 -1
  94. package/dist/assets/{wiki-editor-page-BYKcdX5I.js → wiki-editor-page-OZf9l4Tg.js} +1 -1
  95. package/dist/assets/{wiki-ingest-history-page-D_p4myw1.js → wiki-ingest-history-page-CzeNSL7N.js} +1 -1
  96. package/dist/assets/{wiki-ingest-modal-C-CidueO.js → wiki-ingest-modal-Ig_xnyc6.js} +1 -1
  97. package/dist/assets/wiki-page-B4xuNgY4.js +1 -0
  98. package/dist/assets/{workbench-flow-page-Q3r2IJty.js → workbench-flow-page-BhRJCALC.js} +1 -1
  99. package/dist/assets/{workbench-page-BFfWMGm6.js → workbench-page-DxVs2AOY.js} +1 -1
  100. package/dist/assets/{workout-detail-page-DeDyz1Kk.js → workout-detail-page-D4wfkE98.js} +1 -1
  101. package/dist/index.html +2 -2
  102. package/dist/server/server/migrations/069_psyche_devrage_cumulative_rage.sql +5 -0
  103. package/dist/server/server/src/app.js +3 -2
  104. package/dist/server/server/src/openapi.js +48 -8
  105. package/dist/server/server/src/psyche-types.js +18 -4
  106. package/dist/server/server/src/services/devrage-scanner.js +115 -10
  107. package/dist/server/server/src/services/devrage.js +61 -11
  108. package/openclaw.plugin.json +1 -1
  109. package/package.json +1 -1
  110. package/server/migrations/069_psyche_devrage_cumulative_rage.sql +5 -0
  111. package/skills/forge-openclaw/SKILL.md +7 -0
  112. package/skills/forge-openclaw/entity_conversation_playbooks.md +23 -0
  113. package/skills/forge-openclaw/psyche_entity_playbooks.md +32 -0
  114. package/dist/assets/daily-metrics-dashboard-BNGQlJkQ.js +0 -1
  115. package/dist/assets/index-BAXYM89v.css +0 -1
  116. package/dist/assets/psyche-metrics-page-D8JQEoOl.js +0 -1
  117. package/dist/assets/psyche-page-Dkh7R2Dc.js +0 -1
  118. package/dist/assets/vitals-page-CqE4bYMf.js +0 -1
  119. package/dist/assets/wiki-page-DYpg9ZEO.js +0 -1
@@ -1 +1 @@
1
- import{r as m,j as e,c9 as Ae,bA as we,bC as Pe,aH as ue,bL as De,cR as Me,c7 as He,bK as Te,bX as Ce,aC as Oe}from"./vendor-Dnkkx2co.js";import{j as me,i as xe,k as $}from"./state-vCcAT5Hq.js";import{i as q,cP as Le,cQ as J,C as j,c as U,B as ee,Z as K,O as pe}from"./index-By3tQxiE.js";import{F as Se}from"./floating-action-menu-C5H-Wr2B.js";import{A as Fe,C as Ee,X as Ie,L as ce,Y as Xe,T as ze,b as Re,a as Ye,c as Be}from"./charts-DFnEuIMB.js";const Y=20,le=288,M={top:16,right:18,bottom:28,left:42},te=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function We(t,a){return te.map((s,o)=>({weekday:o,baselineDailyAp:t.baselineDailyAp,points:t.currentCurve.map(i=>({...i,locked:o===a?i.locked:!1}))}))}function se(t){return`${Number(t.toFixed(1))} AP`}function O(t){return`${Number(t.toFixed(1))} AP/h`}function re(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(a)}function _e(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric"}).format(a)}function C(t,a,s){return Math.min(s,Math.max(a,t))}function Ke(t){if(t.length<2)return 0;let a=0;for(let s=0;s<t.length-1;s+=1){const o=t[s],i=t[s+1];a+=(o.rateApPerHour+i.rateApPerHour)/2*((i.minuteOfDay-o.minuteOfDay)/60)}return a}function de(t,a){if(t.length===0)return 0;if(a<=t[0].minuteOfDay)return t[0].rateApPerHour;for(let s=0;s<t.length-1;s+=1){const o=t[s],i=t[s+1];if(a<=i.minuteOfDay){const y=Math.max(1,i.minuteOfDay-o.minuteOfDay),g=(a-o.minuteOfDay)/y;return o.rateApPerHour+(i.rateApPerHour-o.rateApPerHour)*g}}return t[t.length-1].rateApPerHour}function $e(t,a){const s=Ke(t);if(s<=0||a<=0)return t.map(i=>({...i,rateApPerHour:0}));const o=a/s;return t.map(i=>({...i,rateApPerHour:Number((i.rateApPerHour*o).toFixed(4))}))}function qe(t,a,s){var x;if(a<=0||a>=t.length-1)return((x=t[a])==null?void 0:x.rateApPerHour)??0;const o=t[a-1],i=t[a],y=t[a+1];let g=0;for(let v=0;v<t.length-1;v+=1){if(v===a-1||v===a)continue;const n=t[v],H=t[v+1];g+=(n.rateApPerHour+H.rateApPerHour)/2*((H.minuteOfDay-n.minuteOfDay)/60)}const L=Math.max(Y/60,(i.minuteOfDay-o.minuteOfDay)/60),P=Math.max(Y/60,(y.minuteOfDay-i.minuteOfDay)/60);return Math.max(0,(2*(s-g)-o.rateApPerHour*L-y.rateApPerHour*P)/(L+P))}function Qe(t){switch(t){case"danger":return"bg-rose-400/12 text-rose-100";case"warning":return"bg-amber-400/12 text-amber-100";case"success":return"bg-emerald-400/12 text-emerald-100";case"info":default:return"bg-sky-400/12 text-sky-100"}}function Ge(t){switch(t){case"primary":return"Primary";case"secondary":return"Secondary";case"recovery":return"Recovery";case"background":default:return"Ambient"}}function fe(t){return t.spentTodayAp>t.dailyBudgetAp?"Over budget":t.spentTodayAp<t.targetBandMinAp?"Below target band":"Inside target band"}function Ve(t){return t.overloadApPerHour>0||t.instantFreeApPerHour<=0?"Recovery":t.instantCapacityApPerHour>=t.currentDrainApPerHour+4?"Deep work":"Low-friction admin"}function Ze({lifeForce:t}){return e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Daily AP"}),e.jsxs("div",{className:"mt-2 font-display text-4xl text-[var(--primary)]",children:[Math.round(t.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-[var(--ui-ink-faint)]",children:["/ ",Math.round(t.dailyBudgetAp)]})]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Target band ",Math.round(t.targetBandMinAp),"-",Math.round(t.targetBandMaxAp)," AP"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:fe(t)})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:t.instantFreeApPerHour.toFixed(1)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:[O(t.instantCapacityApPerHour)," capacity minus"," ",O(t.currentDrainApPerHour)," load"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overloaded`:"No overload right now"})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Fatigue buffer"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:t.fatigueBufferApPerHour.toFixed(1)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Short-term strain rises with overlap and falls with recovery."})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Forecast"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:Math.round(t.forecastAp)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Planned remaining ",se(t.plannedRemainingAp)]}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:["Remaining ",se(t.remainingAp)]})]})]})}function Je({lifeForce:t}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-6",children:t.stats.map(a=>e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.label}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:["L",a.level]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(a.xp)," XP"]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:a.key==="life_force"?`+${Math.round((a.costModifier-1)*100)}% daily resilience`:`${Math.round((1-a.costModifier)*100)}% cost relief`})]},a.key))})}function Ue({lifeForce:t,weekday:a,points:s,baselineDailyAp:o,isDirty:i,isSaving:y,onChange:g,onReset:L,onSave:P,onWeekdayChange:x}){var ne,oe;const v=m.useRef(null),[n,H]=m.useState(null),[I,ae]=m.useState(720),[p,Q]=m.useState(null),S=m.useMemo(()=>new Date().getDay(),[]),F=m.useMemo(()=>{const r=new Date;return r.getHours()*60+r.getMinutes()},[]),B=m.useMemo(()=>[...s].sort((r,c)=>r.minuteOfDay-c.minuteOfDay),[s]),l=m.useMemo(()=>B.map(r=>({...r,locked:a===S?r.minuteOfDay<=F:!1})),[F,B,S,a]),b=m.useMemo(()=>{const r=Math.max(t.instantCapacityApPerHour,...l.map(c=>c.rateApPerHour),8);return Math.max(12,Math.ceil(r*1.25))},[t.instantCapacityApPerHour,l]),G=m.useMemo(()=>l.map(r=>({...r,label:re(r.minuteOfDay)})),[l]),k=m.useMemo(()=>[0,240,480,720,960,1200,1440],[]),V=m.useMemo(()=>Array.from(new Set([0,Math.max(2,Math.round(b/3)),Math.max(4,Math.round(2*b/3)),b])).sort((r,c)=>r-c),[b]),W=Math.max(I,1),E=Math.max(160,W-M.left-M.right),X=le-M.top-M.bottom;m.useEffect(()=>{const r=()=>{var u;const c=((u=v.current)==null?void 0:u.clientWidth)??0;ae(c>0?c:720)};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),m.useEffect(()=>{if(n===null||!v.current)return;const r=v.current,c=d=>{if(d.pointerId!==n.pointerId)return;d.preventDefault();const h=r.getBoundingClientRect(),A=Number.isFinite(d.clientX)?d.clientX:h.left+n.pointerX,f=Number.isFinite(d.clientY)?d.clientY:h.top+n.pointerY,D=C(A-h.left,0,h.width),z=C(f-h.top,0,h.height),_=C(A-h.left-M.left,0,E),ge=C(f-h.top-M.top,0,X);g(l.map((N,w)=>{if(w!==n.index)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};if(N.locked||w===0||w===l.length-1)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};const ye=l[w-1].minuteOfDay+Y,je=l[w+1].minuteOfDay-Y,ke=Math.round(C(_/E*1440,ye,je)),R=l.map(ie=>({minuteOfDay:ie.minuteOfDay,rateApPerHour:ie.rateApPerHour,locked:ie.locked}));R[w]={...R[w],minuteOfDay:ke};const be=qe(R,w,o),Ne=C((X-ge)/X*b,0,Math.max(0,be));return R[w]={...R[w],rateApPerHour:Number(Ne.toFixed(3))},R[w]})),H(N=>N===null||N.pointerId!==d.pointerId?N:{...N,pointerX:D,pointerY:z})},u=d=>{(!d||d.pointerId===n.pointerId)&&H(null)};return window.addEventListener("pointermove",c,{passive:!1}),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[o,n,g,X,E,l,b]);const he=m.useMemo(()=>{if(!p)return[];const r=l[p.index]??null;return[{id:"remove-point",label:"Remove point",description:r===null?"No turn point is selected.":`Delete the turn point at ${re(r.minuteOfDay)}.`,icon:He,tone:"danger",disabled:r===null||p.index===0||p.index===l.length-1,onSelect:()=>{g(l.filter((c,u)=>u!==p.index))}},{id:"flatten-point",label:"Flatten point",description:r===null?"No turn point is selected.":"Place the handle back on the interpolated segment between its neighbors.",icon:Te,disabled:r===null||p.index===0||p.index===l.length-1,onSelect:()=>{const c=l[p.index-1],u=l[p.index+1],d=de([c,u],r.minuteOfDay);g(l.map((h,A)=>A===p.index?{...h,rateApPerHour:Number(d.toFixed(3))}:h))}}]},[p,g,l]),Z=m.useMemo(()=>l.map(r=>({...r,x:M.left+r.minuteOfDay/1440*E,y:M.top+(1-r.rateApPerHour/Math.max(1,b))*X})),[X,E,l,b]),T=n===null?null:{pointerX:n.pointerX,pointerY:n.pointerY,constrainedX:((ne=Z[n.index])==null?void 0:ne.x)??n.pointerX,constrainedY:((oe=Z[n.index])==null?void 0:oe.y)??n.pointerY};return e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force view"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Instant Life Force editor"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"One click adds a turn point. Drag future handles. Right click a handle to remove or flatten it. The ghost handle follows your finger or cursor while the real turn point stays constrained on the curve and normalized to the baseline daily AP budget."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-full bg-[var(--ui-surface-2)] p-1",children:te.map((r,c)=>e.jsx("button",{type:"button",className:K("rounded-full px-3 py-1.5 text-[11px] font-medium transition",a===c?"bg-[var(--primary)] text-slate-950":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>x(c),children:r},r))}),e.jsx(ee,{variant:"secondary",onClick:L,children:"Reset"}),e.jsxs(ee,{onClick:P,pending:y,disabled:!i,children:[e.jsx(Ce,{className:"mr-2 size-4"}),"Save curve"]})]})]}),e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{ref:v,className:K("relative h-72 w-full overflow-hidden rounded-[20px] bg-[var(--ui-surface-1)]",n!==null?"select-none touch-none":""),style:{touchAction:n===null?"pan-y":"none"},role:"img","aria-label":"Life Force capacity curve editor",onClick:r=>{if(n!==null||!v.current||r.target!==r.currentTarget)return;const c=v.current.getBoundingClientRect(),u=C(r.clientX-c.left-M.left,0,E),d=Math.round(u/E*1440),h=l.findIndex(_=>_.minuteOfDay>d);if(h<=0)return;const A=l[h-1],f=l[h];if(d-A.minuteOfDay<Y||f.minuteOfDay-d<Y)return;const D=de(l,d),z=[...l];z.splice(h,0,{minuteOfDay:d,rateApPerHour:Number(D.toFixed(3)),locked:a===S&&d<=F}),g(z)},children:[e.jsxs(Fe,{width:W,height:le,data:G,margin:M,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"life-force-chart-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--ui-accent-soft)"}),e.jsx("stop",{offset:"100%",stopColor:"var(--ui-surface-1)"})]})}),e.jsx(Ee,{vertical:!1,stroke:"var(--ui-border-subtle)",strokeDasharray:"3 4"}),e.jsx(Ie,{dataKey:"minuteOfDay",type:"number",domain:[0,1440],ticks:k,tickFormatter:_e,tick:{fill:"var(--ui-ink-faint)",fontSize:10},tickLine:!1,axisLine:{stroke:"var(--ui-border-subtle)"},children:e.jsx(ce,{value:"Time",position:"insideBottom",offset:-10,fill:"var(--ui-ink-faint)",fontSize:10})}),e.jsx(Xe,{type:"number",domain:[0,b],ticks:V,tick:{fill:"var(--ui-ink-faint)",fontSize:10},tickLine:!1,axisLine:{stroke:"var(--ui-border-subtle)"},width:34,children:e.jsx(ce,{value:"AP/h",angle:-90,position:"insideLeft",fill:"var(--ui-ink-faint)",fontSize:10,style:{textAnchor:"middle"}})}),e.jsx(ze,{cursor:{stroke:"var(--ui-border-strong)",strokeDasharray:"3 4"},content:({active:r,payload:c})=>{var d;const u=r?(d=c==null?void 0:c[0])==null?void 0:d.payload:null;return u?e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.label}),e.jsx("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:O(u.rateApPerHour)})]}):null}}),a===S?e.jsx(Re,{x:F,stroke:"var(--ui-border-strong)",strokeDasharray:"3 4"}):null,e.jsx(Ye,{type:"linear",dataKey:"rateApPerHour",stroke:"none",fill:"url(#life-force-chart-fill)",isAnimationActive:!1}),e.jsx(Be,{type:"linear",dataKey:"rateApPerHour",stroke:"var(--primary)",strokeWidth:1.5,dot:!1,activeDot:!1,isAnimationActive:!1})]}),T?e.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-[15] h-full w-full","aria-hidden":"true",children:[e.jsx("line",{x1:T.constrainedX,y1:T.constrainedY,x2:T.pointerX,y2:T.pointerY,stroke:"var(--primary)",strokeDasharray:"4 5",strokeWidth:"1.5"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"11",fill:"var(--ui-accent-soft)",stroke:"var(--primary)",strokeWidth:"1.5","data-testid":"life-force-ghost-handle"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"3.5",fill:"var(--ui-ink-soft)"})]}):null,Z.map((r,c)=>{const u=c===0||c===Z.length-1,d=(n==null?void 0:n.index)===c,h=u?14:16,A=u?22:28;return e.jsx("button",{type:"button","aria-label":`Turn point at ${re(r.minuteOfDay)}`,className:K("absolute z-20 flex items-center justify-center rounded-full transition-transform duration-75",r.locked||u?"cursor-not-allowed":"cursor-grab active:cursor-grabbing",d?"scale-110":""),style:{left:r.x-A/2,top:r.y-A/2,width:A,height:A,touchAction:"none"},onPointerDown:f=>{if(f.preventDefault(),f.stopPropagation(),r.locked||u||!v.current)return;"setPointerCapture"in f.currentTarget&&f.currentTarget.setPointerCapture(f.pointerId);const D=v.current.getBoundingClientRect(),z=Number.isFinite(f.clientX)?f.clientX:D.left+r.x,_=Number.isFinite(f.clientY)?f.clientY:D.top+r.y;H({index:c,pointerId:f.pointerId,pointerX:C(z-D.left,0,D.width),pointerY:C(_-D.top,0,D.height)})},onContextMenu:f=>{f.preventDefault(),f.stopPropagation(),Q({index:c,position:{x:f.clientX+6,y:f.clientY+6}})},children:e.jsx("span",{className:K("pointer-events-none inline-flex rounded-full border border-[var(--ui-border-strong)] shadow-[var(--ui-shadow-soft)]",r.locked||u?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]"),style:{width:h,height:h,opacity:d?.96:1}})},`${r.minuteOfDay}-${c}`)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] text-[var(--ui-ink-faint)]",children:[e.jsxs("div",{children:["Editing ",te[a]," curve"]}),e.jsxs("div",{children:[Math.round(o)," AP/day baseline"]})]})]})]}),e.jsx(Se,{open:p!==null,title:"Turn point actions",subtitle:"Delete the turn point or flatten it back onto the surrounding segment.",items:he,position:(p==null?void 0:p.position)??null,onClose:()=>Q(null)})]})}function et(){return e.jsx(j,{className:"overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force studio"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Edit weekday curves in the dedicated view"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"The full weekday editor, turn-point menu, and curve calibration now live in their own page so Overview can stay fast and readable."})]}),e.jsxs(Oe,{to:"/life-force",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-on-accent)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",children:[e.jsx(ue,{className:"size-4"}),"Open Life Force studio"]})]})})}function tt({drains:t,plannedDrains:a,warnings:s,recommendations:o}){return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Current drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"What is consuming Life Force now"})]}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[t.length," active"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:t.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No current drainers are active. This is a good moment to choose your next intentional action."}):t.map(i=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:O(i.apPerHour)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Ge(i.role)})]})]})},i.id))})]}),e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Planned drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"What the rest of today is already asking from you"})]}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[a.length," planned"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No future AP load has been forecast yet. The day is still open."}):a.slice(0,6).map(i=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:se(i.instantAp)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:O(i.apPerHour)})]})]})},i.id))})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Warnings"}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.map(i=>e.jsxs("div",{className:K("rounded-[18px] px-4 py-4",Qe(i.tone)),children:[e.jsx("div",{className:"text-sm font-semibold",children:i.title}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-current/80",children:i.detail})]},i.id))})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Recommendations"}),e.jsx("div",{className:"mt-4 grid gap-2",children:o.map((i,y)=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i},`${i}-${y}`))})]})]})]})}function ve({lifeForce:t,onTired:a,onOkayAgain:s,tiredPending:o,okayPending:i,feedback:y}){return e.jsxs(j,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force now"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[t.instantFreeApPerHour.toFixed(1)," AP/h free"]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:[Math.round(t.spentTodayAp)," /"," ",Math.round(t.dailyBudgetAp)," AP used today"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:fe(t)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(ee,{variant:"secondary",onClick:a,pending:o,children:[e.jsx(we,{className:"mr-2 size-4"}),"I'm getting tired"]}),e.jsxs(ee,{variant:"secondary",onClick:s,pending:i,children:[e.jsx(Pe,{className:"mr-2 size-4"}),"I'm okay again"]})]})]}),y?e.jsx("div",{className:"mt-4 rounded-[18px] border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] px-4 py-3 text-sm text-[var(--ui-ink-medium)]",children:y}):null,e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(ue,{className:"size-4 text-[var(--primary)]"}),"Instant capacity"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:O(t.instantCapacityApPerHour)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(De,{className:"size-4 text-[var(--primary)]"}),"Current load"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:O(t.currentDrainApPerHour)}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overload`:"Inside instant limit"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(Me,{className:"size-4 text-[var(--primary)]"}),"Next move"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:t.recommendations[0]??"Favor the next clean, manageable action."}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Ve(t)})]})]})]})}function ot({selectedUserIds:t,fallbackLifeForce:a,onRefresh:s,showEditor:o=!0}){var b,G;const i=me(),y=new Date().getDay(),[g,L]=m.useState(y),P=xe({queryKey:["forge-life-force",...t],queryFn:()=>pe(t),initialData:a===void 0?void 0:{lifeForce:a,templates:te.map((k,V)=>({weekday:V,baselineDailyAp:a.baselineDailyAp,points:a.currentCurve.map(W=>({...W,locked:V===y?W.locked:!1}))}))}}),x=((b=P.data)==null?void 0:b.lifeForce)??a,n=(((G=P.data)==null?void 0:G.templates)??We(x,y)).find(k=>k.weekday===g)??{weekday:g,baselineDailyAp:x.baselineDailyAp,points:x.currentCurve},[H,I]=m.useState(n.points),[ae,p]=m.useState(!1),[Q,S]=m.useState(null);m.useEffect(()=>{I(n.points),p(!1)},[n.points,n.weekday]);const F=$({mutationFn:k=>Le(n.weekday,{points:$e(k,n.baselineDailyAp)},t),onSuccess:async k=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),I(k.points),p(!1)}}),B=$({mutationFn:()=>J({signalType:"tired"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),S("Tiredness signal applied. Today’s Life Force now reflects the extra strain.")}}),l=$({mutationFn:()=>J({signalType:"okay_again"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),S("Recovery signal applied. Instant strain has been eased for the rest of today.")}});return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ze,{lifeForce:x}),e.jsx(Je,{lifeForce:x}),e.jsx(ve,{lifeForce:x,onTired:()=>{B.mutateAsync()},onOkayAgain:()=>{l.mutateAsync()},tiredPending:B.isPending,okayPending:l.isPending,feedback:Q}),o?e.jsx(Ue,{lifeForce:x,weekday:g,points:H,baselineDailyAp:n.baselineDailyAp,isDirty:ae,isSaving:F.isPending,onWeekdayChange:L,onChange:k=>{I(k),p(!0)},onReset:()=>{I(n.points),p(!1)},onSave:()=>{F.mutateAsync(H)}}):e.jsx(et,{}),e.jsx(tt,{drains:x.activeDrains,plannedDrains:x.plannedDrains,warnings:x.warnings,recommendations:x.recommendations}),x.topTaskIdsNeedingSplit.length>0?e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink-strong)]",children:[e.jsx(Ae,{className:"size-4 text-[var(--primary)]"}),"Tasks asking to be split"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.topTaskIdsNeedingSplit.map(k=>e.jsx(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:k},k))})]}):null]})}function ct({selectedUserIds:t,fallbackLifeForce:a,onRefresh:s}){var n;const o=Array.isArray(t)?t:[],i=me(),g=((n=xe({queryKey:["forge-life-force",...o],queryFn:()=>pe(o),initialData:a===void 0?void 0:{lifeForce:a,templates:[]}}).data)==null?void 0:n.lifeForce)??a;if(!g)return e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Not calibrated yet"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Today can still load without a Life Force snapshot, but the AP and instant headroom model is not available for this state yet."})]});const[L,P]=m.useState(null),x=$({mutationFn:()=>J({signalType:"tired"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),P("Tiredness signal applied. Today’s headroom has been reduced.")}}),v=$({mutationFn:()=>J({signalType:"okay_again"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),P("Recovery signal applied. Today’s headroom has been eased.")}});return e.jsx(ve,{lifeForce:g,onTired:()=>{x.mutateAsync()},onOkayAgain:()=>{v.mutateAsync()},tiredPending:x.isPending,okayPending:v.isPending,feedback:L})}export{ot as L,ct as a};
1
+ import{r as m,j as e,c9 as Ae,bA as we,bC as Pe,aH as ue,bL as De,cR as Me,c7 as He,bK as Te,bX as Ce,aC as Oe}from"./vendor-Dnkkx2co.js";import{j as me,i as xe,k as $}from"./state-vCcAT5Hq.js";import{i as q,cP as Le,cQ as J,C as j,c as U,B as ee,Z as K,O as pe}from"./index-QJkjKYzZ.js";import{F as Se}from"./floating-action-menu-cKjNsPYD.js";import{A as Fe,C as Ee,X as Ie,L as ce,Y as Xe,T as ze,b as Re,a as Ye,c as Be}from"./charts-DFnEuIMB.js";const Y=20,le=288,M={top:16,right:18,bottom:28,left:42},te=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function We(t,a){return te.map((s,o)=>({weekday:o,baselineDailyAp:t.baselineDailyAp,points:t.currentCurve.map(i=>({...i,locked:o===a?i.locked:!1}))}))}function se(t){return`${Number(t.toFixed(1))} AP`}function O(t){return`${Number(t.toFixed(1))} AP/h`}function re(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(a)}function _e(t){const a=new Date(2026,0,1,0,t,0,0);return new Intl.DateTimeFormat(void 0,{hour:"numeric"}).format(a)}function C(t,a,s){return Math.min(s,Math.max(a,t))}function Ke(t){if(t.length<2)return 0;let a=0;for(let s=0;s<t.length-1;s+=1){const o=t[s],i=t[s+1];a+=(o.rateApPerHour+i.rateApPerHour)/2*((i.minuteOfDay-o.minuteOfDay)/60)}return a}function de(t,a){if(t.length===0)return 0;if(a<=t[0].minuteOfDay)return t[0].rateApPerHour;for(let s=0;s<t.length-1;s+=1){const o=t[s],i=t[s+1];if(a<=i.minuteOfDay){const y=Math.max(1,i.minuteOfDay-o.minuteOfDay),g=(a-o.minuteOfDay)/y;return o.rateApPerHour+(i.rateApPerHour-o.rateApPerHour)*g}}return t[t.length-1].rateApPerHour}function $e(t,a){const s=Ke(t);if(s<=0||a<=0)return t.map(i=>({...i,rateApPerHour:0}));const o=a/s;return t.map(i=>({...i,rateApPerHour:Number((i.rateApPerHour*o).toFixed(4))}))}function qe(t,a,s){var x;if(a<=0||a>=t.length-1)return((x=t[a])==null?void 0:x.rateApPerHour)??0;const o=t[a-1],i=t[a],y=t[a+1];let g=0;for(let v=0;v<t.length-1;v+=1){if(v===a-1||v===a)continue;const n=t[v],H=t[v+1];g+=(n.rateApPerHour+H.rateApPerHour)/2*((H.minuteOfDay-n.minuteOfDay)/60)}const L=Math.max(Y/60,(i.minuteOfDay-o.minuteOfDay)/60),P=Math.max(Y/60,(y.minuteOfDay-i.minuteOfDay)/60);return Math.max(0,(2*(s-g)-o.rateApPerHour*L-y.rateApPerHour*P)/(L+P))}function Qe(t){switch(t){case"danger":return"bg-rose-400/12 text-rose-100";case"warning":return"bg-amber-400/12 text-amber-100";case"success":return"bg-emerald-400/12 text-emerald-100";case"info":default:return"bg-sky-400/12 text-sky-100"}}function Ge(t){switch(t){case"primary":return"Primary";case"secondary":return"Secondary";case"recovery":return"Recovery";case"background":default:return"Ambient"}}function fe(t){return t.spentTodayAp>t.dailyBudgetAp?"Over budget":t.spentTodayAp<t.targetBandMinAp?"Below target band":"Inside target band"}function Ve(t){return t.overloadApPerHour>0||t.instantFreeApPerHour<=0?"Recovery":t.instantCapacityApPerHour>=t.currentDrainApPerHour+4?"Deep work":"Low-friction admin"}function Ze({lifeForce:t}){return e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Daily AP"}),e.jsxs("div",{className:"mt-2 font-display text-4xl text-[var(--primary)]",children:[Math.round(t.spentTodayAp),e.jsxs("span",{className:"ml-2 text-lg text-[var(--ui-ink-faint)]",children:["/ ",Math.round(t.dailyBudgetAp)]})]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Target band ",Math.round(t.targetBandMinAp),"-",Math.round(t.targetBandMaxAp)," AP"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:fe(t)})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:t.instantFreeApPerHour.toFixed(1)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:[O(t.instantCapacityApPerHour)," capacity minus"," ",O(t.currentDrainApPerHour)," load"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overloaded`:"No overload right now"})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Fatigue buffer"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:t.fatigueBufferApPerHour.toFixed(1)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Short-term strain rises with overlap and falls with recovery."})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Forecast"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-[var(--ui-ink-strong)]",children:Math.round(t.forecastAp)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:["Planned remaining ",se(t.plannedRemainingAp)]}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:["Remaining ",se(t.remainingAp)]})]})]})}function Je({lifeForce:t}){return e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-6",children:t.stats.map(a=>e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.label}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:["L",a.level]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[Math.round(a.xp)," XP"]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:a.key==="life_force"?`+${Math.round((a.costModifier-1)*100)}% daily resilience`:`${Math.round((1-a.costModifier)*100)}% cost relief`})]},a.key))})}function Ue({lifeForce:t,weekday:a,points:s,baselineDailyAp:o,isDirty:i,isSaving:y,onChange:g,onReset:L,onSave:P,onWeekdayChange:x}){var ne,oe;const v=m.useRef(null),[n,H]=m.useState(null),[I,ae]=m.useState(720),[p,Q]=m.useState(null),S=m.useMemo(()=>new Date().getDay(),[]),F=m.useMemo(()=>{const r=new Date;return r.getHours()*60+r.getMinutes()},[]),B=m.useMemo(()=>[...s].sort((r,c)=>r.minuteOfDay-c.minuteOfDay),[s]),l=m.useMemo(()=>B.map(r=>({...r,locked:a===S?r.minuteOfDay<=F:!1})),[F,B,S,a]),b=m.useMemo(()=>{const r=Math.max(t.instantCapacityApPerHour,...l.map(c=>c.rateApPerHour),8);return Math.max(12,Math.ceil(r*1.25))},[t.instantCapacityApPerHour,l]),G=m.useMemo(()=>l.map(r=>({...r,label:re(r.minuteOfDay)})),[l]),k=m.useMemo(()=>[0,240,480,720,960,1200,1440],[]),V=m.useMemo(()=>Array.from(new Set([0,Math.max(2,Math.round(b/3)),Math.max(4,Math.round(2*b/3)),b])).sort((r,c)=>r-c),[b]),W=Math.max(I,1),E=Math.max(160,W-M.left-M.right),X=le-M.top-M.bottom;m.useEffect(()=>{const r=()=>{var u;const c=((u=v.current)==null?void 0:u.clientWidth)??0;ae(c>0?c:720)};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),m.useEffect(()=>{if(n===null||!v.current)return;const r=v.current,c=d=>{if(d.pointerId!==n.pointerId)return;d.preventDefault();const h=r.getBoundingClientRect(),A=Number.isFinite(d.clientX)?d.clientX:h.left+n.pointerX,f=Number.isFinite(d.clientY)?d.clientY:h.top+n.pointerY,D=C(A-h.left,0,h.width),z=C(f-h.top,0,h.height),_=C(A-h.left-M.left,0,E),ge=C(f-h.top-M.top,0,X);g(l.map((N,w)=>{if(w!==n.index)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};if(N.locked||w===0||w===l.length-1)return{minuteOfDay:N.minuteOfDay,rateApPerHour:N.rateApPerHour,locked:N.locked};const ye=l[w-1].minuteOfDay+Y,je=l[w+1].minuteOfDay-Y,ke=Math.round(C(_/E*1440,ye,je)),R=l.map(ie=>({minuteOfDay:ie.minuteOfDay,rateApPerHour:ie.rateApPerHour,locked:ie.locked}));R[w]={...R[w],minuteOfDay:ke};const be=qe(R,w,o),Ne=C((X-ge)/X*b,0,Math.max(0,be));return R[w]={...R[w],rateApPerHour:Number(Ne.toFixed(3))},R[w]})),H(N=>N===null||N.pointerId!==d.pointerId?N:{...N,pointerX:D,pointerY:z})},u=d=>{(!d||d.pointerId===n.pointerId)&&H(null)};return window.addEventListener("pointermove",c,{passive:!1}),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[o,n,g,X,E,l,b]);const he=m.useMemo(()=>{if(!p)return[];const r=l[p.index]??null;return[{id:"remove-point",label:"Remove point",description:r===null?"No turn point is selected.":`Delete the turn point at ${re(r.minuteOfDay)}.`,icon:He,tone:"danger",disabled:r===null||p.index===0||p.index===l.length-1,onSelect:()=>{g(l.filter((c,u)=>u!==p.index))}},{id:"flatten-point",label:"Flatten point",description:r===null?"No turn point is selected.":"Place the handle back on the interpolated segment between its neighbors.",icon:Te,disabled:r===null||p.index===0||p.index===l.length-1,onSelect:()=>{const c=l[p.index-1],u=l[p.index+1],d=de([c,u],r.minuteOfDay);g(l.map((h,A)=>A===p.index?{...h,rateApPerHour:Number(d.toFixed(3))}:h))}}]},[p,g,l]),Z=m.useMemo(()=>l.map(r=>({...r,x:M.left+r.minuteOfDay/1440*E,y:M.top+(1-r.rateApPerHour/Math.max(1,b))*X})),[X,E,l,b]),T=n===null?null:{pointerX:n.pointerX,pointerY:n.pointerY,constrainedX:((ne=Z[n.index])==null?void 0:ne.x)??n.pointerX,constrainedY:((oe=Z[n.index])==null?void 0:oe.y)??n.pointerY};return e.jsxs(e.Fragment,{children:[e.jsxs(j,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force view"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Instant Life Force editor"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"One click adds a turn point. Drag future handles. Right click a handle to remove or flatten it. The ghost handle follows your finger or cursor while the real turn point stays constrained on the curve and normalized to the baseline daily AP budget."})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 rounded-full bg-[var(--ui-surface-2)] p-1",children:te.map((r,c)=>e.jsx("button",{type:"button",className:K("rounded-full px-3 py-1.5 text-[11px] font-medium transition",a===c?"bg-[var(--primary)] text-slate-950":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>x(c),children:r},r))}),e.jsx(ee,{variant:"secondary",onClick:L,children:"Reset"}),e.jsxs(ee,{onClick:P,pending:y,disabled:!i,children:[e.jsx(Ce,{className:"mr-2 size-4"}),"Save curve"]})]})]}),e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsxs("div",{ref:v,className:K("relative h-72 w-full overflow-hidden rounded-[20px] bg-[var(--ui-surface-1)]",n!==null?"select-none touch-none":""),style:{touchAction:n===null?"pan-y":"none"},role:"img","aria-label":"Life Force capacity curve editor",onClick:r=>{if(n!==null||!v.current||r.target!==r.currentTarget)return;const c=v.current.getBoundingClientRect(),u=C(r.clientX-c.left-M.left,0,E),d=Math.round(u/E*1440),h=l.findIndex(_=>_.minuteOfDay>d);if(h<=0)return;const A=l[h-1],f=l[h];if(d-A.minuteOfDay<Y||f.minuteOfDay-d<Y)return;const D=de(l,d),z=[...l];z.splice(h,0,{minuteOfDay:d,rateApPerHour:Number(D.toFixed(3)),locked:a===S&&d<=F}),g(z)},children:[e.jsxs(Fe,{width:W,height:le,data:G,margin:M,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"life-force-chart-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--ui-accent-soft)"}),e.jsx("stop",{offset:"100%",stopColor:"var(--ui-surface-1)"})]})}),e.jsx(Ee,{vertical:!1,stroke:"var(--ui-border-subtle)",strokeDasharray:"3 4"}),e.jsx(Ie,{dataKey:"minuteOfDay",type:"number",domain:[0,1440],ticks:k,tickFormatter:_e,tick:{fill:"var(--ui-ink-faint)",fontSize:10},tickLine:!1,axisLine:{stroke:"var(--ui-border-subtle)"},children:e.jsx(ce,{value:"Time",position:"insideBottom",offset:-10,fill:"var(--ui-ink-faint)",fontSize:10})}),e.jsx(Xe,{type:"number",domain:[0,b],ticks:V,tick:{fill:"var(--ui-ink-faint)",fontSize:10},tickLine:!1,axisLine:{stroke:"var(--ui-border-subtle)"},width:34,children:e.jsx(ce,{value:"AP/h",angle:-90,position:"insideLeft",fill:"var(--ui-ink-faint)",fontSize:10,style:{textAnchor:"middle"}})}),e.jsx(ze,{cursor:{stroke:"var(--ui-border-strong)",strokeDasharray:"3 4"},content:({active:r,payload:c})=>{var d;const u=r?(d=c==null?void 0:c[0])==null?void 0:d.payload:null;return u?e.jsxs("div",{className:"rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.label}),e.jsx("div",{className:"mt-1 text-[var(--ui-ink-soft)]",children:O(u.rateApPerHour)})]}):null}}),a===S?e.jsx(Re,{x:F,stroke:"var(--ui-border-strong)",strokeDasharray:"3 4"}):null,e.jsx(Ye,{type:"linear",dataKey:"rateApPerHour",stroke:"none",fill:"url(#life-force-chart-fill)",isAnimationActive:!1}),e.jsx(Be,{type:"linear",dataKey:"rateApPerHour",stroke:"var(--primary)",strokeWidth:1.5,dot:!1,activeDot:!1,isAnimationActive:!1})]}),T?e.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-[15] h-full w-full","aria-hidden":"true",children:[e.jsx("line",{x1:T.constrainedX,y1:T.constrainedY,x2:T.pointerX,y2:T.pointerY,stroke:"var(--primary)",strokeDasharray:"4 5",strokeWidth:"1.5"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"11",fill:"var(--ui-accent-soft)",stroke:"var(--primary)",strokeWidth:"1.5","data-testid":"life-force-ghost-handle"}),e.jsx("circle",{cx:T.pointerX,cy:T.pointerY,r:"3.5",fill:"var(--ui-ink-soft)"})]}):null,Z.map((r,c)=>{const u=c===0||c===Z.length-1,d=(n==null?void 0:n.index)===c,h=u?14:16,A=u?22:28;return e.jsx("button",{type:"button","aria-label":`Turn point at ${re(r.minuteOfDay)}`,className:K("absolute z-20 flex items-center justify-center rounded-full transition-transform duration-75",r.locked||u?"cursor-not-allowed":"cursor-grab active:cursor-grabbing",d?"scale-110":""),style:{left:r.x-A/2,top:r.y-A/2,width:A,height:A,touchAction:"none"},onPointerDown:f=>{if(f.preventDefault(),f.stopPropagation(),r.locked||u||!v.current)return;"setPointerCapture"in f.currentTarget&&f.currentTarget.setPointerCapture(f.pointerId);const D=v.current.getBoundingClientRect(),z=Number.isFinite(f.clientX)?f.clientX:D.left+r.x,_=Number.isFinite(f.clientY)?f.clientY:D.top+r.y;H({index:c,pointerId:f.pointerId,pointerX:C(z-D.left,0,D.width),pointerY:C(_-D.top,0,D.height)})},onContextMenu:f=>{f.preventDefault(),f.stopPropagation(),Q({index:c,position:{x:f.clientX+6,y:f.clientY+6}})},children:e.jsx("span",{className:K("pointer-events-none inline-flex rounded-full border border-[var(--ui-border-strong)] shadow-[var(--ui-shadow-soft)]",r.locked||u?"bg-[var(--ui-surface-2)]":"bg-[var(--ui-surface-1)]"),style:{width:h,height:h,opacity:d?.96:1}})},`${r.minuteOfDay}-${c}`)})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 px-1 text-[11px] text-[var(--ui-ink-faint)]",children:[e.jsxs("div",{children:["Editing ",te[a]," curve"]}),e.jsxs("div",{children:[Math.round(o)," AP/day baseline"]})]})]})]}),e.jsx(Se,{open:p!==null,title:"Turn point actions",subtitle:"Delete the turn point or flatten it back onto the surrounding segment.",items:he,position:(p==null?void 0:p.position)??null,onClose:()=>Q(null)})]})}function et(){return e.jsx(j,{className:"overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force studio"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"Edit weekday curves in the dedicated view"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"The full weekday editor, turn-point menu, and curve calibration now live in their own page so Overview can stay fast and readable."})]}),e.jsxs(Oe,{to:"/life-force",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] border border-[var(--primary)]/14 bg-[var(--ui-accent-soft)] px-3 py-2 text-[13px] font-medium text-[var(--ui-ink-on-accent)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-accent-soft-hover)]",children:[e.jsx(ue,{className:"size-4"}),"Open Life Force studio"]})]})})}function tt({drains:t,plannedDrains:a,warnings:s,recommendations:o}){return e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Current drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"What is consuming Life Force now"})]}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[t.length," active"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:t.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No current drainers are active. This is a good moment to choose your next intentional action."}):t.map(i=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:O(i.apPerHour)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Ge(i.role)})]})]})},i.id))})]}),e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Planned drains"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:"What the rest of today is already asking from you"})]}),e.jsxs(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[a.length," planned"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.length===0?e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4 text-sm text-[var(--ui-ink-soft)]",children:"No future AP load has been forecast yet. The day is still open."}):a.slice(0,6).map(i=>e.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-2)] px-4 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--ui-ink-strong)]",children:i.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:i.why})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[e.jsx("div",{className:"text-base font-semibold text-[var(--primary)]",children:se(i.instantAp)}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:O(i.apPerHour)})]})]})},i.id))})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Warnings"}),e.jsx("div",{className:"mt-4 grid gap-3",children:s.map(i=>e.jsxs("div",{className:K("rounded-[18px] px-4 py-4",Qe(i.tone)),children:[e.jsx("div",{className:"text-sm font-semibold",children:i.title}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-current/80",children:i.detail})]},i.id))})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Recommendations"}),e.jsx("div",{className:"mt-4 grid gap-2",children:o.map((i,y)=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i},`${i}-${y}`))})]})]})]})}function ve({lifeForce:t,onTired:a,onOkayAgain:s,tiredPending:o,okayPending:i,feedback:y}){return e.jsxs(j,{className:"overflow-hidden p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force now"}),e.jsxs("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[t.instantFreeApPerHour.toFixed(1)," AP/h free"]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:[Math.round(t.spentTodayAp)," /"," ",Math.round(t.dailyBudgetAp)," AP used today"]}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:fe(t)})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(ee,{variant:"secondary",onClick:a,pending:o,children:[e.jsx(we,{className:"mr-2 size-4"}),"I'm getting tired"]}),e.jsxs(ee,{variant:"secondary",onClick:s,pending:i,children:[e.jsx(Pe,{className:"mr-2 size-4"}),"I'm okay again"]})]})]}),y?e.jsx("div",{className:"mt-4 rounded-[18px] border border-[color-mix(in_srgb,var(--primary)_24%,transparent)] bg-[var(--ui-accent-soft)] px-4 py-3 text-sm text-[var(--ui-ink-medium)]",children:y}):null,e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(ue,{className:"size-4 text-[var(--primary)]"}),"Instant capacity"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:O(t.instantCapacityApPerHour)})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(De,{className:"size-4 text-[var(--primary)]"}),"Current load"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:O(t.currentDrainApPerHour)}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:t.overloadApPerHour>0?`${O(t.overloadApPerHour)} overload`:"Inside instant limit"})]}),e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",children:[e.jsx(Me,{className:"size-4 text-[var(--primary)]"}),"Next move"]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:t.recommendations[0]??"Favor the next clean, manageable action."}),e.jsx("div",{className:"mt-2 text-xs uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:Ve(t)})]})]})]})}function ot({selectedUserIds:t,fallbackLifeForce:a,onRefresh:s,showEditor:o=!0}){var b,G;const i=me(),y=new Date().getDay(),[g,L]=m.useState(y),P=xe({queryKey:["forge-life-force",...t],queryFn:()=>pe(t),initialData:a===void 0?void 0:{lifeForce:a,templates:te.map((k,V)=>({weekday:V,baselineDailyAp:a.baselineDailyAp,points:a.currentCurve.map(W=>({...W,locked:V===y?W.locked:!1}))}))}}),x=((b=P.data)==null?void 0:b.lifeForce)??a,n=(((G=P.data)==null?void 0:G.templates)??We(x,y)).find(k=>k.weekday===g)??{weekday:g,baselineDailyAp:x.baselineDailyAp,points:x.currentCurve},[H,I]=m.useState(n.points),[ae,p]=m.useState(!1),[Q,S]=m.useState(null);m.useEffect(()=>{I(n.points),p(!1)},[n.points,n.weekday]);const F=$({mutationFn:k=>Le(n.weekday,{points:$e(k,n.baselineDailyAp)},t),onSuccess:async k=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),I(k.points),p(!1)}}),B=$({mutationFn:()=>J({signalType:"tired"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),S("Tiredness signal applied. Today’s Life Force now reflects the extra strain.")}}),l=$({mutationFn:()=>J({signalType:"okay_again"},t),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),S("Recovery signal applied. Instant strain has been eased for the rest of today.")}});return e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ze,{lifeForce:x}),e.jsx(Je,{lifeForce:x}),e.jsx(ve,{lifeForce:x,onTired:()=>{B.mutateAsync()},onOkayAgain:()=>{l.mutateAsync()},tiredPending:B.isPending,okayPending:l.isPending,feedback:Q}),o?e.jsx(Ue,{lifeForce:x,weekday:g,points:H,baselineDailyAp:n.baselineDailyAp,isDirty:ae,isSaving:F.isPending,onWeekdayChange:L,onChange:k=>{I(k),p(!0)},onReset:()=>{I(n.points),p(!1)},onSave:()=>{F.mutateAsync(H)}}):e.jsx(et,{}),e.jsx(tt,{drains:x.activeDrains,plannedDrains:x.plannedDrains,warnings:x.warnings,recommendations:x.recommendations}),x.topTaskIdsNeedingSplit.length>0?e.jsxs(j,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-[var(--ui-ink-strong)]",children:[e.jsx(Ae,{className:"size-4 text-[var(--primary)]"}),"Tasks asking to be split"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.topTaskIdsNeedingSplit.map(k=>e.jsx(U,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:k},k))})]}):null]})}function ct({selectedUserIds:t,fallbackLifeForce:a,onRefresh:s}){var n;const o=Array.isArray(t)?t:[],i=me(),g=((n=xe({queryKey:["forge-life-force",...o],queryFn:()=>pe(o),initialData:a===void 0?void 0:{lifeForce:a,templates:[]}}).data)==null?void 0:n.lifeForce)??a;if(!g)return e.jsxs(j,{className:"p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Not calibrated yet"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Today can still load without a Life Force snapshot, but the AP and instant headroom model is not available for this state yet."})]});const[L,P]=m.useState(null),x=$({mutationFn:()=>J({signalType:"tired"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),P("Tiredness signal applied. Today’s headroom has been reduced.")}}),v=$({mutationFn:()=>J({signalType:"okay_again"},o),onSuccess:async()=>{await i.invalidateQueries({queryKey:["forge-life-force"]}),await q(i),s&&await s(),P("Recovery signal applied. Today’s headroom has been eased.")}});return e.jsx(ve,{lifeForce:g,onTired:()=>{x.mutateAsync()},onOkayAgain:()=>{v.mutateAsync()},tiredPending:x.isPending,okayPending:v.isPending,feedback:L})}export{ot as L,ct as a};
@@ -1 +1 @@
1
- import{j as r}from"./vendor-Dnkkx2co.js";import{C as l,aq as c,Z as o}from"./index-By3tQxiE.js";function p({label:a,value:i,tone:e="default",detail:s,help:n,className:t}){return r.jsxs(l,{className:o("rounded-[22px] p-4",e==="core"&&"bg-[linear-gradient(180deg,color-mix(in_srgb,var(--primary)_12%,var(--surface-panel)),color-mix(in_srgb,var(--surface-low)_92%,var(--primary)_8%))]",e==="psyche"&&"bg-[linear-gradient(180deg,color-mix(in_srgb,var(--secondary)_12%,var(--surface-panel)),color-mix(in_srgb,var(--surface-low)_92%,var(--secondary)_8%))]",t),children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:a}),n?r.jsx(c,{label:`Explain ${a}`,title:a,content:n,panelClassName:"normal-case tracking-normal"}):null]}),r.jsx("div",{className:"mt-3 font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),s?r.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:s}):null]})}export{p as M};
1
+ import{j as r}from"./vendor-Dnkkx2co.js";import{C as l,aq as c,Z as o}from"./index-QJkjKYzZ.js";function p({label:a,value:i,tone:e="default",detail:s,help:n,className:t}){return r.jsxs(l,{className:o("rounded-[22px] p-4",e==="core"&&"bg-[linear-gradient(180deg,color-mix(in_srgb,var(--primary)_12%,var(--surface-panel)),color-mix(in_srgb,var(--surface-low)_92%,var(--primary)_8%))]",e==="psyche"&&"bg-[linear-gradient(180deg,color-mix(in_srgb,var(--secondary)_12%,var(--surface-panel)),color-mix(in_srgb,var(--surface-low)_92%,var(--secondary)_8%))]",t),children:[r.jsxs("div",{className:"flex items-center gap-1.5 font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[r.jsx("span",{children:a}),n?r.jsx(c,{label:`Explain ${a}`,title:a,content:n,panelClassName:"normal-case tracking-normal"}):null]}),r.jsx("div",{className:"mt-3 font-display text-3xl text-[var(--ui-ink-strong)]",children:i}),s?r.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:s}):null]})}export{p as M};