forge-openclaw-plugin 0.3.2 → 0.3.4
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.
- package/dist/assets/action-bar-CMGr_Uv_.js +1 -0
- package/dist/assets/activity-page-DwGKkJtr.js +1 -0
- package/dist/assets/ai-surface-workspace-UtnoNmjq.js +1 -0
- package/dist/assets/{atlas-panel-G3wGxjYf.js → atlas-panel-f1kc-LkD.js} +1 -1
- package/dist/assets/{board-dIX6etHh.js → board-CLOHbg6t.js} +1 -1
- package/dist/assets/calendar-page-C4YqeVrC.js +1 -0
- package/dist/assets/calendar-rules-BQppCPiN.js +1 -0
- package/dist/assets/{calendar-week-toolbar-CWSK5hJl.js → calendar-week-toolbar-DdPuHUwd.js} +1 -1
- package/dist/assets/{charts-DFnEuIMB.js → charts-DwTguE_x.js} +1 -1
- package/dist/assets/companion-sync-lab-page-N3cR33GS.js +1 -0
- package/dist/assets/daily-metrics-dashboard-CXnAtN2T.js +1 -0
- package/dist/assets/define-workbench-box-DkffygDU.js +1 -0
- package/dist/assets/entity-link-multiselect-wuyJ8BbW.js +1 -0
- package/dist/assets/{entity-note-count-link-ef3ZOpKM.js → entity-note-count-link-CEtKyMAl.js} +1 -1
- package/dist/assets/entity-notes-surface-iKNiierJ.js +1 -0
- package/dist/assets/execution-board-DesFZ1f5.js +1 -0
- package/dist/assets/{faceted-token-search-CZmtyJTT.js → faceted-token-search-D4Okr-Kr.js} +1 -1
- package/dist/assets/{flagship-signal-deck-DxRfmfpN.js → flagship-signal-deck-CW91n6u9.js} +1 -1
- package/dist/assets/{floating-action-menu-cKjNsPYD.js → floating-action-menu-GCeuOdYZ.js} +1 -1
- package/dist/assets/{forms-hB0SqEh-.js → forms-C5d5hTf2.js} +1 -1
- package/dist/assets/generic-node-view-COhU_Wm3.js +10 -0
- package/dist/assets/goal-detail-page-Bd8JU3IK.js +1 -0
- package/dist/assets/goal-dialog-CLz5fYhO.js +1 -0
- package/dist/assets/goals-page-CZHNVyY-.js +1 -0
- package/dist/assets/{graph-DDUZNRsO.js → graph-Cd5WF3lw.js} +1 -1
- package/dist/assets/habits-page-CXiBB7_N.js +1 -0
- package/dist/assets/health-boxes-BUcsxDLh.js +1 -0
- package/dist/assets/index-BejvcRGb.js +2 -0
- package/dist/assets/{index-Bcem7l5u.css → index-CEgIwgk9.css} +1 -1
- package/dist/assets/inline-note-fields-CcRDO3pd.js +1 -0
- package/dist/assets/insight-flow-dialog-DUBk2MR8.js +1 -0
- package/dist/assets/{insights-page-DHG-o9P_.js → insights-page-8fLhCYsM.js} +3 -3
- package/dist/assets/kanban-boxes-CH7plRk1.js +1 -0
- package/dist/assets/kanban-page-Bq-aYwUL.js +1 -0
- package/dist/assets/knowledge-graph-page-DYFfWh4Y.js +1 -0
- package/dist/assets/life-force-page-D80rgBBR.js +1 -0
- package/dist/assets/{life-force-workspace-sszLD-Yn.js → life-force-workspace-CcmZRRfU.js} +1 -1
- package/dist/assets/{maps-C-yOWiDN.js → maps-D0Mm6WPG.js} +1 -1
- package/dist/assets/{metric-tile-B-tDTcBt.js → metric-tile-DysHMgM3.js} +1 -1
- package/dist/assets/{motion-Lt5B1XuE.js → motion-DwjmC9aq.js} +1 -1
- package/dist/assets/movement-boxes-BH3botKt.js +1 -0
- package/dist/assets/movement-page-D5KLMKS9.js +1 -0
- package/dist/assets/{note-markdown-CCyyE85h.js → note-markdown-Byd_vNkS.js} +1 -1
- package/dist/assets/note-tags-input-DYAFDq8Q.js +1 -0
- package/dist/assets/notes-boxes-CPiPps1e.js +1 -0
- package/dist/assets/notes-page-DehVrOOb.js +1 -0
- package/dist/assets/{open-in-graph-button-CMjJZX7G.js → open-in-graph-button-L21MKsb5.js} +1 -1
- package/dist/assets/{orbit-map-v2Pv9RU_.js → orbit-map-ChJOQ8CN.js} +1 -1
- package/dist/assets/overview-page-D_ewyeWF.js +1 -0
- package/dist/assets/page-hero-DlHEJ0Yt.js +1 -0
- package/dist/assets/pill-cluster-DhOR4m7X.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-CKDxCnbl.js → preference-entity-handoff-button-ugHU2us9.js} +1 -1
- package/dist/assets/preferences-page-BTTXeSDR.js +1 -0
- package/dist/assets/{project-collections-NBwk6yV-.js → project-collections-USb6PUe0.js} +1 -1
- package/dist/assets/project-detail-page-1tD6tUsB.js +1 -0
- package/dist/assets/project-dialog-BaHhJqP6.js +1 -0
- package/dist/assets/project-management-hierarchy-page-D4HV8QXs.js +1 -0
- package/dist/assets/project-management-section-nav-9OV6_ifH.js +1 -0
- package/dist/assets/projects-boxes-AyudWls3.js +1 -0
- package/dist/assets/projects-page-DizVVzbt.js +1 -0
- package/dist/assets/psyche-behaviors-page-CX5MJjWj.js +5 -0
- package/dist/assets/psyche-flashcards-page-DzCGy-FV.js +1 -0
- package/dist/assets/psyche-goal-map-page-BcKR792E.js +1 -0
- package/dist/assets/psyche-graph-BNllZR67.js +1 -0
- package/dist/assets/psyche-metrics-page-CpEKlZLO.js +1 -0
- package/dist/assets/psyche-mode-guide-page-DXKSE2o7.js +1 -0
- package/dist/assets/psyche-modes-page-Bh6eeNm1.js +1 -0
- package/dist/assets/psyche-page-B44RJrrC.js +1 -0
- package/dist/assets/psyche-patterns-page-Bm7T5FMJ.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-BNtMNjY8.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-BnMXErRK.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-CWKxbdwZ.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-DwH7Sk52.js +1 -0
- package/dist/assets/psyche-questionnaires-page-B1t_a8QU.js +1 -0
- package/dist/assets/{psyche-report-detail-page-Ci14mNUK.js → psyche-report-detail-page-x2AtC99e.js} +3 -3
- package/dist/assets/psyche-reports-page-KiwCgWPa.js +1 -0
- package/dist/assets/{psyche-schemas-Dxj554nU.js → psyche-schemas-Dtskzvv1.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-CIEoAJAp.js +9 -0
- package/dist/assets/psyche-screen-time-page-DO6UycL9.js +1 -0
- package/dist/assets/psyche-self-observation-page-CPcpUSdm.js +1 -0
- package/dist/assets/psyche-values-page-BAgNeo4L.js +5 -0
- package/dist/assets/question-flow-dialog-BByFV8Yw.js +2 -0
- package/dist/assets/{report-chain-fields-CbkT7WOO.js → report-chain-fields-BpRWMp7h.js} +1 -1
- package/dist/assets/rewards-page-kIiX8SHn.js +1 -0
- package/dist/assets/{scheduling-rules-editor-BUGnZJ0g.js → scheduling-rules-editor-oQXGcL5l.js} +1 -1
- package/dist/assets/{schema-badge-CLAA4p-b.js → schema-badge-BoNjw3h4.js} +1 -1
- package/dist/assets/schemas-IBbtdPzn.js +1 -0
- package/dist/assets/{select-menu-Cqs5t3ng.js → select-menu-U-YryCwP.js} +1 -1
- package/dist/assets/{settings-agents-page-pmkVrOO8.js → settings-agents-page-CbHeMq3e.js} +4 -4
- package/dist/assets/settings-bin-page-LxS2YPsA.js +1 -0
- package/dist/assets/{settings-calendar-page-BBjAMOCf.js → settings-calendar-page-CZc-I-HK.js} +3 -3
- package/dist/assets/settings-data-page-m-aBRMR9.js +1 -0
- package/dist/assets/settings-logs-page-BUEGWlQu.js +1 -0
- package/dist/assets/settings-mobile-page-C_5CHjHl.js +1 -0
- package/dist/assets/settings-models-page-B4HQu8kL.js +1 -0
- package/dist/assets/settings-page-CY8N-fNV.js +1 -0
- package/dist/assets/settings-rewards-page-C0XQoWjb.js +1 -0
- package/dist/assets/{settings-section-nav-Co0AaDG-.js → settings-section-nav-CkqqtM0F.js} +1 -1
- package/dist/assets/settings-users-page-COCBOq7d.js +1 -0
- package/dist/assets/settings-wiki-page-Dy1d7-z-.js +1 -0
- package/dist/assets/sleep-page-1kKicdFq.js +1 -0
- package/dist/assets/sports-page-DJErRii_.js +1 -0
- package/dist/assets/{state-vCcAT5Hq.js → state-BtwEvpO6.js} +1 -1
- package/dist/assets/strategies-page-CWNFb9vv.js +1 -0
- package/dist/assets/strategy-detail-page-D9rFVXRS.js +1 -0
- package/dist/assets/strategy-dialog-BIVHfUR6.js +1 -0
- package/dist/assets/{surface-CyWI7e1R.js → surface-B3oXO1No.js} +1 -1
- package/dist/assets/{table-BNqMG3_S.js → table-BuONJH1s.js} +1 -1
- package/dist/assets/task-detail-page-r8ipOpAF.js +1 -0
- package/dist/assets/task-dialog-C3kkWtcT.js +6 -0
- package/dist/assets/timebox-planning-dialog-BadS5tEr.js +1 -0
- package/dist/assets/today-boxes-CiccN0Gw.js +1 -0
- package/dist/assets/today-page-DvQredbl.js +1 -0
- package/dist/assets/training-load-page-CkX-nSoe.js +1 -0
- package/dist/assets/{ui-C1iwpj2-.js → ui-B9O-eUim.js} +1 -1
- package/dist/assets/use-anchored-overlay-position-BrQ4cqKn.js +1 -0
- package/dist/assets/{use-psyche-focus-target-Ct-acS9G.js → use-psyche-focus-target-Cuxni3SK.js} +1 -1
- package/dist/assets/user-badge-BKzwGZDd.js +1 -0
- package/dist/assets/user-ownership-DJGl4rAj.js +1 -0
- package/dist/assets/user-select-field-BNqv8-wd.js +1 -0
- package/dist/assets/utility-widgets-DvxKA6dI.js +3 -0
- package/dist/assets/{vendor-Dnkkx2co.js → vendor-Cpmju3nw.js} +1 -1
- package/dist/assets/vitals-page-CRIsr_C7.js +1 -0
- package/dist/assets/weekly-review-page-CNqxLRCd.js +1 -0
- package/dist/assets/weight-loss-page-SSsCp1Yw.js +5 -0
- package/dist/assets/{wiki-article-markdown-Bi02AsVt.js → wiki-article-markdown-C9VKineE.js} +2 -2
- package/dist/assets/{wiki-editor-page-OZf9l4Tg.js → wiki-editor-page-DxGsKvF7.js} +5 -5
- package/dist/assets/wiki-ingest-history-page-CFmP7K1F.js +1 -0
- package/dist/assets/wiki-ingest-modal-BLw2PSWP.js +1 -0
- package/dist/assets/wiki-page-BiQ-jAuz.js +1 -0
- package/dist/assets/workbench-flow-page-D960hXu_.js +5 -0
- package/dist/assets/workbench-page-BWlY-FiL.js +1 -0
- package/dist/assets/workout-detail-page-G32yJoE9.js +2 -0
- package/dist/index.html +8 -10
- package/dist/server/server/src/app.js +10 -0
- package/dist/server/server/src/health-weight-loss.js +11 -3
- package/dist/server/server/src/services/dashboard.js +4 -4
- package/dist/server/server/src/services/gamification.js +71 -32
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/activity-page-DRRbpVK-.js +0 -1
- package/dist/assets/ai-surface-workspace-DJPt-OaW.js +0 -1
- package/dist/assets/calendar-page-y8G1ige8.js +0 -1
- package/dist/assets/calendar-rules-CRhXqGQu.js +0 -1
- package/dist/assets/companion-sync-lab-page-kEgOF3c6.js +0 -1
- package/dist/assets/daily-metrics-dashboard-BJjUIZVA.js +0 -1
- package/dist/assets/entity-notes-surface-CaCjjUaq.js +0 -1
- package/dist/assets/execution-board-RRWm2srb.js +0 -1
- package/dist/assets/goal-detail-page-BgQlK7yT.js +0 -1
- package/dist/assets/goals-page-Cz2i3pVy.js +0 -1
- package/dist/assets/habits-page-BmEmWCGv.js +0 -1
- package/dist/assets/index-QJkjKYzZ.js +0 -19
- package/dist/assets/insight-flow-dialog-CdYMHwMP.js +0 -1
- package/dist/assets/kanban-page-C6S_fJRc.js +0 -1
- package/dist/assets/knowledge-graph-page-juA9QCy0.js +0 -1
- package/dist/assets/life-force-page-ChTIA4mV.js +0 -1
- package/dist/assets/movement-page-Dx3T3HrG.js +0 -1
- package/dist/assets/note-tags-input-BS14YXHn.js +0 -1
- package/dist/assets/notes-page-D3yGl8TN.js +0 -1
- package/dist/assets/overview-page-DSOpBpHf.js +0 -1
- package/dist/assets/page-hero-CONuJu5J.js +0 -1
- package/dist/assets/pill-cluster-W2fY48OM.js +0 -1
- package/dist/assets/preferences-page-Br3zrLlH.js +0 -1
- package/dist/assets/project-detail-page-BIU9_TRN.js +0 -1
- package/dist/assets/project-management-hierarchy-page-C2H620xD.js +0 -1
- package/dist/assets/project-management-section-nav-DRPVS1Eh.js +0 -1
- package/dist/assets/projects-page-w7a_L2-z.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dt4CMC-q.js +0 -5
- package/dist/assets/psyche-flashcards-page-rXz06dqO.js +0 -1
- package/dist/assets/psyche-goal-map-page-BCcD6Jkl.js +0 -1
- package/dist/assets/psyche-graph-CXlAj4ED.js +0 -1
- package/dist/assets/psyche-metrics-page-B1otiir6.js +0 -1
- package/dist/assets/psyche-mode-guide-page-C6AdVIAv.js +0 -1
- package/dist/assets/psyche-modes-page-DoUqz2mR.js +0 -1
- package/dist/assets/psyche-page-BJNLQn8W.js +0 -1
- package/dist/assets/psyche-patterns-page-CzpMSAPu.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-DjzatGVZ.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-B0Qfowfg.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-B2dNj4jJ.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-DyD9Ui-g.js +0 -1
- package/dist/assets/psyche-questionnaires-page-BxfKcoi3.js +0 -1
- package/dist/assets/psyche-reports-page-ALhNueiV.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-C0P2Vw6-.js +0 -9
- package/dist/assets/psyche-screen-time-page-BYnaT3cb.js +0 -1
- package/dist/assets/psyche-self-observation-page-eM9vpwIB.js +0 -1
- package/dist/assets/psyche-values-page-BqrGIDok.js +0 -5
- package/dist/assets/rewards-page-DpAJ8IxE.js +0 -1
- package/dist/assets/settings-bin-page-BwtLrweW.js +0 -1
- package/dist/assets/settings-data-page-Bqy5SukM.js +0 -1
- package/dist/assets/settings-logs-page-8khtrf4T.js +0 -1
- package/dist/assets/settings-mobile-page-BcyRjEU_.js +0 -1
- package/dist/assets/settings-models-page-DlSnO9WX.js +0 -1
- package/dist/assets/settings-page-CyBQ2qcB.js +0 -1
- package/dist/assets/settings-rewards-page-BBX2WtVM.js +0 -1
- package/dist/assets/settings-users-page-JSnfFFPu.js +0 -1
- package/dist/assets/settings-wiki-page--nT23Fdy.js +0 -1
- package/dist/assets/sleep-page-CGMi3MtV.js +0 -1
- package/dist/assets/sports-page-Kv5bBoLr.js +0 -1
- package/dist/assets/strategies-page-Br7RdUJO.js +0 -1
- package/dist/assets/strategy-detail-page-CBWXjUhC.js +0 -1
- package/dist/assets/strategy-dialog-BTwkaSxI.js +0 -1
- package/dist/assets/task-detail-page-Qis9354n.js +0 -1
- package/dist/assets/timebox-planning-dialog-DB8snOBD.js +0 -1
- package/dist/assets/today-page-D9A5PU0S.js +0 -1
- package/dist/assets/training-load-page-Bpd4DQAh.js +0 -1
- package/dist/assets/vitals-page-CVYC-4RG.js +0 -1
- package/dist/assets/weekly-review-page-BP7N3fNB.js +0 -1
- package/dist/assets/weight-loss-page-_fX3N1UK.js +0 -5
- package/dist/assets/wiki-ingest-history-page-CzeNSL7N.js +0 -1
- package/dist/assets/wiki-ingest-modal-Ig_xnyc6.js +0 -1
- package/dist/assets/wiki-page-B4xuNgY4.js +0 -1
- package/dist/assets/workbench-flow-page-BhRJCALC.js +0 -5
- package/dist/assets/workbench-page-DxVs2AOY.js +0 -1
- package/dist/assets/workout-detail-page-D4wfkE98.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,j as e,aK as $t,b_ as It,b3 as Ft,ck as ga,bZ as fa,aZ as ot,cl as wt,F as Ua,cm as Wa,bX as Ga,cn as ba,co as Va,c1 as Ya,bu as Xa}from"./vendor-Cpmju3nw.js";import{j as ya,x as Yt,i as ae,k as Pe}from"./state-BtwEvpO6.js";import{I as B,B as A,c as w,k as v,C as k,aF as Xt,aG as Zt,aH as ja,aI as Za,aJ as Ja,S as Na,e as ka,aA as wa,aK as Jt,aL as er,aM as tr,aN as Sa,aO as ar,d as rr,aP as at,n as ea,m as rt,a4 as ce,aQ as sr,aR as ir,aS as nr,aT as lr,aU as or,O as dr,aV as cr,aW as ur,aX as mr}from"./index-BejvcRGb.js";import{F as Ma}from"./faceted-token-search-D4Okr-Kr.js";import{P as xr}from"./page-hero-DlHEJ0Yt.js";import{R as Qe,P as Ue,O as We,C as Ge,T as mt,D as xt,a as vt}from"./ui-B9O-eUim.js";import{m as ta}from"./motion-DwjmC9aq.js";import{S as me}from"./surface-B3oXO1No.js";import{M as vr,a as pr,b as hr,c as gr,d as fr}from"./movement-boxes-BH3botKt.js";import{R as br,A as yr,C as jr,X as Nr,Y as kr,T as wr,a as Sr}from"./charts-DwTguE_x.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";import"./generic-node-view-COhU_Wm3.js";import"./graph-Cd5WF3lw.js";import"./define-workbench-box-DkffygDU.js";function Aa({open:t,onOpenChange:a,place:r,seed:s,onSave:l}){const[c,m]=x.useState({label:(r==null?void 0:r.label)??(s==null?void 0:s.label)??"",latitude:String((r==null?void 0:r.latitude)??(s==null?void 0:s.latitude)??""),longitude:String((r==null?void 0:r.longitude)??(s==null?void 0:s.longitude)??""),radiusMeters:String((r==null?void 0:r.radiusMeters)??(s==null?void 0:s.radiusMeters)??100),categoryTags:((r==null?void 0:r.categoryTags)??(s==null?void 0:s.categoryTags)??[]).join(", ")});return x.useEffect(()=>{m({label:(r==null?void 0:r.label)??(s==null?void 0:s.label)??"",latitude:String((r==null?void 0:r.latitude)??(s==null?void 0:s.latitude)??""),longitude:String((r==null?void 0:r.longitude)??(s==null?void 0:s.longitude)??""),radiusMeters:String((r==null?void 0:r.radiusMeters)??(s==null?void 0:s.radiusMeters)??100),categoryTags:((r==null?void 0:r.categoryTags)??(s==null?void 0:s.categoryTags)??[]).join(", ")})},[r,s]),e.jsx(Qe,{open:t,onOpenChange:a,children:e.jsxs(Ue,{children:[e.jsx(We,{className:"fixed inset-0 z-50 bg-[var(--ui-overlay-backdrop)] backdrop-blur-sm"}),e.jsxs(Ge,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(32rem,calc(100vw-1.25rem))] -translate-x-1/2 rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-5 shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(mt,{className:"font-display text-[1.3rem] tracking-normal text-[var(--ui-ink-strong)]",children:r?`Edit ${r.label}`:"New known place"}),e.jsx(xt,{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Define life landmarks once so the companion and web views can reason about stays and trips consistently."})]}),e.jsx(vt,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:e.jsx($t,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsx(B,{value:c.label,onChange:d=>m(u=>({...u,label:d.target.value})),placeholder:"Home, Main Office, Riverside path..."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(B,{value:c.latitude,onChange:d=>m(u=>({...u,latitude:d.target.value})),placeholder:"Latitude"}),e.jsx(B,{value:c.longitude,onChange:d=>m(u=>({...u,longitude:d.target.value})),placeholder:"Longitude"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[10rem_minmax(0,1fr)]",children:[e.jsx(B,{value:c.radiusMeters,onChange:d=>m(u=>({...u,radiusMeters:d.target.value})),placeholder:"Radius meters"}),e.jsx(B,{value:c.categoryTags,onChange:d=>m(u=>({...u,categoryTags:d.target.value})),placeholder:"home, gym, holiday, parents-house"})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(A,{variant:"ghost",onClick:()=>a(!1),className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:"Cancel"}),e.jsx(A,{onClick:()=>void l({id:r==null?void 0:r.id,label:c.label,latitude:Number(c.latitude),longitude:Number(c.longitude),radiusMeters:Number(c.radiusMeters),categoryTags:c.categoryTags.split(",").map(d=>d.trim()).filter(Boolean)}).then(()=>a(!1)),children:"Save place"})]})]})]})})}const St=1e3;function I(t){return new Date(t).getTime()}function Mt(t){return new Date(t).toISOString()}function aa(t,a){const r=I(t.startedAt)-I(a.startedAt);if(r!==0)return r;const s=I(t.endedAt)-I(a.endedAt);return s!==0?s:t.id.localeCompare(a.id)}function Et(t){return t.syncSource==="sleep overlay"}function Mr(t){const a=[...t].filter(s=>I(s.endedAt)>I(s.startedAt)).sort((s,l)=>{const c=I(s.startedAt)-I(l.startedAt);if(c!==0)return c;const m=I(s.endedAt)-I(l.endedAt);return m!==0?m:s.id.localeCompare(l.id)});if(a.length===0)return[];const r=[];for(const s of a){const l=r.at(-1);if(!l){r.push(s);continue}const c=I(l.endedAt);if(I(s.startedAt)<=c+St){const d=Math.max(c,I(s.endedAt));r[r.length-1]={...l,id:`${l.id}__${s.id}`,endedAt:Mt(d),asleepSeconds:(l.asleepSeconds??0)+(s.asleepSeconds??0)||null,timeInBedSeconds:(l.timeInBedSeconds??0)+(s.timeInBedSeconds??0)||null,sleepScore:s.sleepScore??l.sleepScore,regularityScore:s.regularityScore??l.regularityScore,efficiency:s.efficiency??l.efficiency,recoveryState:s.recoveryState??l.recoveryState};continue}r.push(s)}return r}function Ar(t){const a=[];if(typeof t.asleepSeconds=="number"&&t.asleepSeconds>0){const r=t.asleepSeconds/3600;a.push(`${r.toFixed(r>=1?1:2)}h asleep`)}else if(typeof t.timeInBedSeconds=="number"&&t.timeInBedSeconds>0){const r=t.timeInBedSeconds/3600;a.push(`${r.toFixed(r>=1?1:2)}h in bed`)}return typeof t.sleepScore=="number"&&a.push(`score ${t.sleepScore}`),typeof t.regularityScore=="number"&&a.push(`regularity ${t.regularityScore}`),t.recoveryState&&a.push(t.recoveryState),a.join(" · ")||"Sleep session"}function Cr(t){const a=Math.max(60,Math.round((I(t.endedAt)-I(t.startedAt))/1e3));return{id:`sleep-overlay-${t.id}`,boxId:`sleep-overlay-${t.id}`,kind:"stay",sourceKind:"automatic",origin:"recorded",editable:!1,isInvalid:!1,startedAt:t.startedAt,endedAt:t.endedAt,trueStartedAt:t.startedAt,trueEndedAt:t.endedAt,visibleStartedAt:t.startedAt,visibleEndedAt:t.endedAt,durationSeconds:a,laneSide:"left",connectorFromLane:"left",connectorToLane:"left",title:"Sleep",subtitle:Ar(t),placeLabel:null,tags:["sleep"],syncSource:"sleep overlay",cursor:`${t.endedAt}::sleep-overlay-${t.id}`,overrideCount:0,overriddenAutomaticBoxIds:[],overriddenUserBoxIds:[],isFullyHidden:!1,rawStayIds:[],rawTripIds:[],rawPointCount:0,hasLegacyCorrections:!1,stay:null,trip:null}}function ra(t,a,r){if(r<=a)return null;const s=Mt(a),l=Mt(r),c=Math.max(60,Math.round((r-a)/1e3));return{...t,id:`${t.id}::virtual-${a}-${r}`,startedAt:s,endedAt:l,trueStartedAt:s,trueEndedAt:l,visibleStartedAt:s,visibleEndedAt:l,durationSeconds:c,cursor:`${l}::${t.id}::virtual`}}function Tr(t,a){let r=[...t].sort(aa);for(const s of Mr(a)){const l=I(s.startedAt),c=I(s.endedAt),m=Cr(s),d=[];let u=!1;for(const p of r){const g=I(p.startedAt),j=I(p.endedAt);if(j<=l||g>=c){!u&&g>=c&&(d.push(m),u=!0),d.push(p);continue}if(g<l){const P=ra(p,g,Math.min(j,l-St));P&&d.push(P)}if(u||(d.push(m),u=!0),j>c){const P=ra(p,Math.max(g,c+St),j);P&&d.push(P)}}u||d.push(m),r=d.sort(aa)}return r}const sa=24,X=64,At=360*60,Ca=5,Nt=1,Pr=104,ia=X*8;function he(t){return t.trim().toLowerCase()}function qe(t){return t>=86400?`${Math.round(t/3600)}h`:t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.max(1,Math.round(t/60))}m`}function ge(t){return new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Ta(t){return new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit",year:"2-digit"}).format(new Date(t))}function Dr(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",hour12:!1}).format(t)}function $e(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const r=a.getFullYear(),s=String(a.getMonth()+1).padStart(2,"0"),l=String(a.getDate()).padStart(2,"0"),c=String(a.getHours()).padStart(2,"0"),m=String(a.getMinutes()).padStart(2,"0");return`${r}-${s}-${l}T${c}:${m}`}function dt(t){if(!t.trim())return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function Ie(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function Y(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function na(t,a){return`${t.toFixed(3)}, ${a.toFixed(3)}`}function st(t,a){return`${t.toFixed(6)}, ${a.toFixed(6)}`}function la(t){return`${Math.max(1,Math.round(t/60))} min`}function Lr(t){if(t.length===0)return[];const a=Math.min(...t.map(d=>d.latitude)),r=Math.max(...t.map(d=>d.latitude)),s=Math.min(...t.map(d=>d.longitude)),l=Math.max(...t.map(d=>d.longitude)),c=Math.max(r-a,1e-4),m=Math.max(l-s,1e-4);return t.map((d,u)=>({...d,x:12+(d.longitude-s)/m*76,y:12+(1-(d.latitude-a)/c)*76,id:`${d.recordedAt??"point"}-${u}`}))}function ct(t){return t.kind==="trip"&&t.trip!==null}function le(t){return t.kind==="stay"&&t.stay!==null}function Ct(t){return!le(t)||t.stay.place?null:{label:t.stay.label||t.title,latitude:t.stay.centerLatitude,longitude:t.stay.centerLongitude,radiusMeters:t.stay.radiusMeters,categoryTags:t.tags}}function Fe(t){var a;return t?t.kind==="stay"&&le(t)?((a=t.stay.place)==null?void 0:a.label)??t.placeLabel??t.stay.label??null:t.placeLabel??null:null}function lt(t,a,r,s){const c=(r-t)*Math.PI/180,m=(s-a)*Math.PI/180,d=t*Math.PI/180,u=r*Math.PI/180,p=Math.sin(c/2)**2+Math.cos(d)*Math.cos(u)*Math.sin(m/2)**2;return 2*6371e3*Math.asin(Math.sqrt(p))}function $r(t){return he([t.label,...t.aliases].join(" "))}function we(t,a,r){if(!t.trip)return{label:t.placeLabel??(a==="start"?"Known origin":"Known destination"),detail:Y(a==="start"?t.startedAt:t.endedAt)};const s=a==="start"?t.trip.points[0]??null:t.trip.points[t.trip.points.length-1]??null,l=a==="start"?t.trip.startPlace:t.trip.endPlace,c=(r==null?void 0:r.includeCoordinates)??!0,m=r!=null&&r.useHistoryAnchorFallback&&a==="start"?"Beginning of history":null;return{label:(l==null?void 0:l.label)??m??(c&&s?na(s.latitude,s.longitude):a==="start"?"Unknown origin":"Unknown destination"),detail:c&&s&&!l?na(s.latitude,s.longitude):Y(a==="start"?t.startedAt:t.endedAt)}}function Ir(t){const a=t.trim().toLowerCase();return a==="travel"||a==="trip"||a==="move"}function Fr(t){const a=t.title.trim().toLowerCase();return a.length===0||a==="stay"||a==="continued stay"||a==="repaired stay"?t.sourceKind==="user_defined"?t.origin==="user_invalidated"?"User invalidated movement":"User-defined missing data":"Missing data":t.title}function Er(t){const a=Fe(t),r=t.title.trim().toLowerCase(),s=r.length===0||r==="stay"||r==="continued stay"||r==="repaired stay"||r==="manual stay";return a&&s?a:t.title.trim()||a||"Stay"}function ue(t){if(Et(t))return"Sleep";if(t.kind==="missing")return Fr(t);if(t.kind==="stay")return Er(t);if(t.kind==="trip"&&Ir(t.title)){const a=we(t,"start").label,r=we(t,"end").label;return`${a} → ${r}`}return t.title}function oa(t){return t==="left"?24:t==="right"?76:50}function _r(t,a,r){const s=Math.min(t,At)/3600,l=r==="sleep overlay",c=l?112:a==="stay"?104:92,m=l?272:a==="stay"?288:232,d=c+s*30;return Math.max(c,Math.min(m,d))}function Tt(t){var a;return{kind:t.kind,label:le(t)?t.stay.label||t.title:ct(t)&&t.trip.label||t.title,placeLabel:le(t)?((a=t.stay.place)==null?void 0:a.label)??t.placeLabel??"":"",tagsInput:t.tags.join(", "),startedAtInput:$e(t.startedAt),endedAtInput:$e(t.endedAt)}}function kt(t,a){const r=(a==null?void 0:a.startedAt)??new Date(Date.now()-36e5).toISOString(),s=(a==null?void 0:a.endedAt)??new Date().toISOString();return{kind:t,label:t==="missing"?"User-defined missing data":t==="stay"?(a==null?void 0:a.placeLabel)||"Manual stay":"Manual move",placeLabel:(a==null?void 0:a.placeLabel)??"",tagsInput:t==="missing"?"user-defined, missing-data":t==="stay"?"user-defined, stay":"user-defined, move",startedAtInput:$e(r),endedAtInput:$e(s)}}function Pt(t,a){var c,m;const r=t.tagsInput.split(",").map(d=>d.trim()).filter(Boolean),s=dt(t.startedAtInput)??(a==null?void 0:a.startedAt)??new Date(Date.now()-3600*1e3).toISOString(),l=dt(t.endedAtInput)??(a==null?void 0:a.endedAt)??new Date().toISOString();return{kind:t.kind,startedAt:s,endedAt:l,title:t.label.trim(),subtitle:t.kind==="missing"?"User-defined missing-data override.":"User-defined movement box.",placeLabel:t.placeLabel.trim()||null,tags:r,distanceMeters:t.kind==="trip"?Math.max(((c=a==null?void 0:a.trip)==null?void 0:c.distanceMeters)??150,150):null,averageSpeedMps:t.kind==="trip"?((m=a==null?void 0:a.trip)==null?void 0:m.averageSpeedMps)??null:null,metadata:{createdFrom:"movement-life-timeline"}}}function Rr(t,a){var l,c;const r=t.kind==="stay"?((c=(l=t.stay)==null?void 0:l.label)==null?void 0:c.trim())??"":"";if(r)return r;const s=t.title.trim();return s&&s.toLowerCase()!=="stay"?s:a.trim()||"Stay"}function zr(t,a){const r=Tt(t),s=a.trim();return Pt({...r,label:Rr(t,s),placeLabel:s},t)}function Pa(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function ut(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Or(t){var a,r,s;return he([t.kind,ue(t),t.subtitle,t.placeLabel??"",...t.tags,ut(t.startedAt),ut(t.endedAt),Pa(t.startedAt),le(t)?((a=t.stay.place)==null?void 0:a.label)??t.stay.label:ct(t)?[t.trip.label,t.trip.activityType,t.trip.travelMode,(r=t.trip.startPlace)==null?void 0:r.label,(s=t.trip.endPlace)==null?void 0:s.label].filter(Boolean).join(" "):t.kind==="trip"?[t.title,t.subtitle,t.placeLabel??""].filter(Boolean).join(" "):"missing data gap"].join(" "))}function Hr(t){const a=new Map;a.set("kind:stay",{id:"kind:stay",label:"Stay",description:"Stationary spans and place anchors."}),a.set("kind:trip",{id:"kind:trip",label:"Move",description:"Trips and movement connectors."});for(const r of["night","morning","afternoon","evening"])a.set(`time:${r}`,{id:`time:${r}`,label:r[0].toUpperCase()+r.slice(1),description:"Filter by the segment start time."});for(const r of t){for(const s of r.tags)a.set(`tag:${s}`,{id:`tag:${s}`,label:s,description:"Movement tag"});r.placeLabel&&a.set(`place:${r.placeLabel}`,{id:`place:${r.placeLabel}`,label:r.placeLabel,description:"Matched place"})}return[...a.values()].sort((r,s)=>r.label.localeCompare(s.label))}function Br(t,a){return a.every(r=>r==="kind:stay"||r==="kind:trip"?t.kind===r.slice(5):r.startsWith("time:")?Pa(t.startedAt)===r.slice(5):r.startsWith("tag:")?t.tags.includes(r.slice(4)):r.startsWith("place:")?(t.placeLabel??"")===r.slice(6):!0)}function da(t,a){return t&&{...t,pages:t.pages.map(r=>({...r,segments:r.segments.filter(s=>s.id!==a)}))}}function Kr(t,a){const r=t+(Math.sin((t-.5)*Math.PI)+1)*.5-t,s=t-.5,c=.5+(s*(1-a*.64)+s*s*s*a*2.56);return Math.max(0,Math.min(1,c-(r-t)*a*.08))}function qr(t){return t.getHours()===0?Ta(t.toISOString()):Dr(t)}function Qr(t,a){const r=new Date(t.endedAt).getTime(),s=new Date(t.startedAt).getTime(),l=Math.max(1,r-s),c=Math.max(0,Math.min(1,(a-s)/l));if(t.durationSeconds<=At)return c;const m=Math.max(0,1-Math.min(1,At/Math.max(1,t.durationSeconds)));return Kr(c,m)}function Ur(t,a,r){if(t.items.length===0)return null;const s=t.items[0];if(a<new Date(s.segment.startedAt).getTime())return t.historyHeaderHeight+t.leadHeight-(new Date(s.segment.startedAt).getTime()-a)/36e5*X;for(let m=0;m<t.items.length;m+=1){const d=t.items[m],u=new Date(d.segment.startedAt).getTime(),p=new Date(d.segment.endedAt).getTime();if(a>=u&&a<=p)return d.boxTop+Qr(d.segment,a)*d.displayHeight;const g=t.items[m+1]??null,j=g?new Date(g.segment.startedAt).getTime():r;if(a>p&&a<j)return d.boxBottom+(a-p)/36e5*X}const l=t.items[t.items.length-1],c=new Date(l.segment.endedAt).getTime();return a>=c?l.boxBottom+(a-c)/36e5*X:null}function Wr(t){const a=new Date(t);a.setMinutes(0,0,0);const r=a.getTime();return r<=t?r+36e5:r}function Gr(t,a){const r=[];if(t.items.length===0)return r;const s=t.items[0],l=new Date(s.segment.startedAt).getTime();for(let c=Wr(l-Ca*36e5);c<=a;c+=36e5){const m=Ur(t,c,a);if(m===null)continue;const d=new Date(c);r.push({y:m,label:qr(d),strong:d.getHours()===0})}return r}function Vr({segments:t,viewportHeight:a,nowMs:r=Date.now()}){var U;const s=t.length>0?Pr:0,l=t.length>0?X*Ca:0;let c=s+l,m=null;const d=t.map(b=>{const C=_r(b.durationSeconds,b.kind,b.syncSource),E=new Date(b.startedAt).getTime(),K=m===null?0:Math.max(0,(E-m)/36e5)*X;c+=K;const Z=c,z=Z+C;return c=z,m=new Date(b.endedAt).getTime(),{id:b.id,segment:b,gapBefore:K,displayHeight:C,boxTop:Z,boxBottom:z}}),u=r+Nt*36e5,p=(()=>{var E;const b=(E=t[t.length-1])==null?void 0:E.endedAt;if(!b)return X*Nt;const C=new Date(b).getTime();return Math.max(X*Nt,(u-C)/36e5*X)})(),g=(((U=d[d.length-1])==null?void 0:U.boxBottom)??s+l)+p,j=Math.max(g,a>0?a+260:960,s+l+p),P={historyHeaderHeight:s,leadHeight:l,items:d,markers:[],rangeEndMs:u,futureTailHeight:p+Math.max(0,j-g),totalHeight:j};return{...P,markers:Gr(P,u)}}const Yr="bg-[image:var(--ui-surface-section)]",Xr="bg-[image:var(--ui-surface-section)]",Zr="h-6 w-[3px] rounded-full bg-[var(--info)] shadow-[var(--ui-shadow-soft)]",Jr="relative w-[min(18rem,calc(100vw-6rem))] overflow-hidden rounded-[26px] border border-[color-mix(in_srgb,var(--info)_22%,transparent)] bg-[image:var(--ui-surface-section)] shadow-[var(--ui-shadow-soft)]",es="absolute z-10 h-7 w-8 rounded-[12px] border bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-soft)] backdrop-blur-sm",ts="group absolute top-1/2 max-w-[min(8rem,calc(100vw-8rem))] -translate-y-1/2 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] px-2.5 py-2 text-left shadow-[var(--ui-shadow-soft)] backdrop-blur-sm transition hover:border-[var(--ui-border-strong)] sm:max-w-[9rem] sm:px-3",Dt="ring-1 ring-[color-mix(in_srgb,var(--info)_42%,transparent)]",as="bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Da="bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",Te="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",rs="border-[color-mix(in_srgb,var(--danger)_26%,transparent)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_78%,var(--ui-ink-strong)_22%)] hover:bg-[color-mix(in_srgb,var(--danger)_18%,transparent)]",ss="border-[color-mix(in_srgb,var(--warning)_26%,transparent)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] hover:bg-[color-mix(in_srgb,var(--warning)_18%,transparent)]";function is({layout:t,scrollTop:a,viewportHeight:r}){const s=X*6,l=Math.max(0,a-s),c=Math.min(t.totalHeight,a+Math.max(r,X*8)+s),m=t.markers.filter(d=>d.y>=l&&d.y<=c);return e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 overflow-hidden rounded-[30px]",style:{height:`${t.totalHeight}px`},children:[e.jsx("div",{className:w("absolute inset-y-0 left-0 w-18",Yr)}),m.map((d,u)=>e.jsxs("div",{className:"absolute inset-x-0",style:{top:`${d.y}px`},children:[e.jsx("div",{className:w("border-t",(d.strong,"border-[var(--ui-border-subtle)]"))}),e.jsx("div",{className:w("absolute left-3 top-0 -translate-y-1/2 font-label text-[9px] tracking-[0.24em]",(d.strong,"text-[var(--ui-ink-muted)]")),children:d.label})]},`timeline-grid-${u}`))]})}function ns({fromSide:t,toSide:a,height:r,emphasized:s}){const l=oa(t),c=oa(a),m=`M ${l} 16 C ${l} ${Math.max(40,r*.26)}, ${c} ${Math.max(70,r*.72)}, ${c} ${r-18}`;return e.jsxs("svg",{viewBox:`0 0 100 ${r}`,className:"absolute inset-x-0 top-0 h-full w-full overflow-visible",preserveAspectRatio:"none",children:[e.jsx("path",{d:m,fill:"none",stroke:s?"color-mix(in srgb, var(--ui-ink-strong) 18%, transparent)":"color-mix(in srgb, var(--ui-ink-strong) 11%, transparent)",strokeWidth:s?"1.05":"0.85",strokeDasharray:s?"3 10":"2.5 12",strokeLinecap:"round"}),e.jsx("circle",{cx:l,cy:"16",r:"1.5",fill:"color-mix(in srgb, var(--ui-ink-strong) 26%, transparent)"}),e.jsx("circle",{cx:c,cy:r-18,r:"1.5",fill:"color-mix(in srgb, var(--ui-ink-strong) 26%, transparent)"})]})}function Lt({position:t}){return e.jsx("div",{className:w("absolute left-1/2 z-20 flex -translate-x-1/2 items-center justify-center",t==="top"?"-top-3":"-bottom-3"),children:e.jsx("div",{className:Zr})})}function ls({segment:t}){const a=(t==null?void 0:t.kind)==="stay"?t.placeLabel||t.title||null:(t==null?void 0:t.kind)==="trip"?we(t,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}).label:null,r=a||"Beginning of time";return e.jsx("div",{className:"pointer-events-none flex justify-center px-6 py-4",children:e.jsxs("div",{className:Jr,children:[e.jsx(Lt,{position:"bottom"}),e.jsxs("div",{className:"relative z-10 px-5 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(v,{tone:"signal",className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:"Start"}),e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Beginning of history"})]}),e.jsx("div",{className:"mt-5 font-display text-[1.25rem] tracking-normal text-[var(--ui-ink-strong)]",children:r}),e.jsx("div",{className:"mt-2 font-label text-[10px] uppercase tracking-[0.22em] text-[var(--ui-ink-muted)]",children:a?"Oldest loaded known stay":"Earliest known anchor"})]})]})})}function os(t,a,r){const s=a+Math.max(96,Math.min(r*.28,220)),l=t.items.find(c=>c.boxBottom>=s)??t.items[t.items.length-1]??null;return l?Ta(l.segment.startedAt):null}function ca({side:t,vertical:a,emphasized:r=!1}){return e.jsx("div",{className:w(es,r?"border-[color-mix(in_srgb,var(--info)_34%,transparent)]":"border-[var(--ui-border-subtle)]",t==="left"?"left-[8%]":t==="right"?"right-[8%]":"left-1/2 -translate-x-1/2",a==="top"?"top-0":"bottom-0")})}function ds({layout:t,selected:a,onToggle:r}){var u,p,g,j;const{segment:s}=t,l=Et(s),c=t.displayHeight,m=s.kind==="stay"?l?"bg-[var(--ui-info-soft)] border-[color-mix(in_srgb,var(--info)_28%,transparent)]":"bg-[var(--ui-accent-soft)] border-[color-mix(in_srgb,var(--primary)_24%,transparent)]":"",d=s.kind==="trip"?{start:we(s,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}),end:we(s,"end",{includeCoordinates:!1})}:null;return e.jsxs("div",{className:w("absolute left-0 w-full px-3 sm:px-6",a?"z-40":"z-10"),"data-testid":"movement-timeline-row","data-selected":a?"true":"false",style:{top:`${t.boxTop}px`,height:`${c}px`},children:[e.jsx("div",{className:w("absolute inset-y-0 left-1/2 w-px -translate-x-1/2",Xr)}),e.jsx("div",{className:"relative h-full",children:s.kind==="trip"?e.jsxs(ta.div,{layout:!0,animate:{x:0},transition:{type:"spring",stiffness:240,damping:30},className:"absolute inset-x-0 top-0 z-10 h-full",children:[d&&a?e.jsxs(e.Fragment,{children:[e.jsx(ca,{side:"center",vertical:"top",emphasized:!0}),e.jsx(ca,{side:"center",vertical:"bottom",emphasized:!0})]}):null,e.jsx(ns,{fromSide:"center",toSide:"center",height:c,emphasized:a}),e.jsxs("button",{type:"button",onClick:r,className:w(ts,"left-1/2 -translate-x-1/2",a?Dt:""),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Move"}),e.jsx("div",{className:"text-[11px] tracking-[0.18em] text-[var(--ui-ink-strong)]/44",children:qe(s.durationSeconds)})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:Ie(((u=s.trip)==null?void 0:u.distanceMeters)??0)}),(((p=s.trip)==null?void 0:p.stops.length)??0)>0?e.jsxs(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[(g=s.trip)==null?void 0:g.stops.length," stop",((j=s.trip)==null?void 0:j.stops.length)===1?"":"s"]}):null]}),e.jsxs("div",{className:"mt-2 font-label text-[9px] uppercase tracking-[0.22em] text-[var(--ui-ink-muted)]",children:[Y(s.startedAt)," →"," ",Y(s.endedAt)]})]})]}):e.jsx(ta.div,{layout:!0,animate:{x:0},transition:{type:"spring",stiffness:260,damping:28},className:"absolute left-1/2 top-0 z-10 w-[min(18.5rem,calc(100vw-3.25rem))] -translate-x-1/2 sm:w-[min(21rem,calc(100vw-5rem))]",children:e.jsxs("button",{type:"button",onClick:r,className:w("group relative w-full overflow-hidden rounded-[24px] border text-left shadow-[var(--ui-shadow-soft)] transition sm:rounded-[30px]",m,a?Dt:"hover:border-[var(--ui-border-strong)]"),style:{minHeight:`${c}px`},children:[e.jsx(Lt,{position:"top"}),e.jsx(Lt,{position:"bottom"}),e.jsxs("div",{className:"relative z-10 flex h-full flex-col justify-between p-3.5 sm:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(v,{tone:"signal",className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-medium)]",children:l?"Sleep":"Stay"}),e.jsx("div",{className:"text-[11px] tracking-[0.16em] text-[var(--ui-ink-muted)] sm:text-xs sm:tracking-[0.18em]",children:qe(s.durationSeconds)})]}),e.jsxs("div",{className:"mt-3 min-w-0 sm:mt-5",children:[e.jsx("div",{className:"truncate font-display text-[1rem] tracking-normal text-[var(--ui-ink-strong)] sm:text-[1.12rem]",children:ue(s)}),s.kind==="stay"&&Fe(s)&&!l?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(v,{className:"max-w-full truncate bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:Fe(s)})}):l?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(v,{className:w("max-w-full truncate",Da),children:s.subtitle})}):null]}),e.jsx("div",{className:"mt-auto pt-4 sm:pt-8",children:e.jsxs("div",{className:"font-label text-[9px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)] sm:text-[10px] sm:tracking-[0.22em]",children:[Y(s.startedAt)," →"," ",Y(s.endedAt)]})})]})]})})})]})}const cs="rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-5 shadow-[var(--ui-shadow-floating)]",it="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",nt="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",ua="text-sm leading-6 text-[var(--ui-ink-medium)]",Ne="bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",ma="bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",xa="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",us="bg-[var(--ui-accent-soft)] text-[var(--primary)]",ms="mt-4 rounded-[18px] border border-[color-mix(in_srgb,var(--info)_22%,transparent)] bg-[var(--ui-info-soft)] p-3",xs="text-[11px] uppercase tracking-[0.18em] text-[color-mix(in_srgb,var(--info)_70%,var(--ui-ink-strong)_30%)]",vs="mt-2 text-sm leading-6 text-[var(--ui-ink-medium)]",ps="rounded-full border border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] px-4 text-[color-mix(in_srgb,var(--info)_72%,var(--ui-ink-strong)_28%)] hover:bg-[color-mix(in_srgb,var(--info)_18%,transparent)]";function hs({segment:t,onEdit:a,onOpenDetail:r,onDefinePlace:s,onClose:l}){var d;const c=Et(t),m=Fe(t);return e.jsxs(k,{className:cs,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:c?"Sleep overlay":t.kind==="stay"?"Stay detail":t.kind==="trip"?"Move detail":"Missing data"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:ue(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(v,{className:c?ma:t.sourceKind==="user_defined"?us:Ne,children:c?"Virtual":t.sourceKind==="user_defined"?t.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),t.overrideCount>0?e.jsxs(v,{className:xa,children:["Overrides ",t.overrideCount," automatic box",t.overrideCount===1?"":"es"]}):null]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{onClick:r,variant:"ghost",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",disabled:c,children:"Details"}),e.jsx(A,{onClick:a,variant:"ghost",className:"size-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Edit movement segment",disabled:c||t.kind==="missing"||!t.editable,children:e.jsx(It,{className:"size-4"})}),l?e.jsx("button",{type:"button",onClick:l,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close movement segment actions",children:e.jsx($t,{className:"size-4"})}):null,e.jsx(Ft,{className:"size-4 text-[var(--ui-ink-faint)]"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:it,children:[e.jsx("div",{className:nt,children:"Started"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:ge(t.startedAt)})]}),e.jsxs("div",{className:it,children:[e.jsx("div",{className:nt,children:"Ended"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:ge(t.endedAt)})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(v,{tone:"signal",children:qe(t.durationSeconds)}),ct(t)?e.jsxs(e.Fragment,{children:[e.jsx(v,{className:Ne,children:Ie(t.trip.distanceMeters)}),t.trip.stops.length>0?e.jsxs(v,{className:Ne,children:[t.trip.stops.length," stop",t.trip.stops.length===1?"":"s"]}):null]}):null,c?e.jsx(v,{className:ma,children:t.subtitle}):m?e.jsx(v,{className:Ne,children:m}):null]}),le(t)&&!c?e.jsxs("div",{className:ms,children:[e.jsx("div",{className:xs,children:"Location label"}),e.jsx("div",{className:vs,children:t.stay.place?`This stay is currently linked to ${t.stay.place.label}. Search saved places or relabel it from this stay center.`:"Search saved places for this stay, or create a new one from the stay center so later matching stays inherit it automatically."}),e.jsx("div",{className:"mt-3",children:e.jsx(A,{onClick:s,variant:"ghost",className:ps,children:"Label location"})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:it,children:[e.jsx("div",{className:nt,children:"Timeline summary"}),e.jsx("div",{className:`mt-2 ${ua}`,children:t.kind==="stay"?c?`Sleep overlay from ${Y(t.startedAt)} to ${Y(t.endedAt)}. Underlying movement boxes are sliced virtually while this overlay is visible.`:`Stay block from ${Y(t.startedAt)} to ${Y(t.endedAt)}.`:t.kind==="trip"?`Connector from ${we(t,"start").label} to ${we(t,"end").label}.`:`No reliable movement signal reached Forge from ${Y(t.startedAt)} to ${Y(t.endedAt)}.`})]}),e.jsxs("div",{className:it,children:[e.jsx("div",{className:nt,children:"Projection model"}),e.jsx("div",{className:`mt-2 ${ua}`,children:c?"This sleep layer is visual only. Forge does not persist these split boxes; it temporarily slices the visible movement boxes around each sleep interval.":"Raw phone measurements stay immutable. Forge derives automatic boxes from that raw movement evidence, then overlays user-defined boxes on top without mutating the imported raw data."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(v,{className:Ne,children:["Raw stays ",t.rawStayIds.length]}),e.jsxs(v,{className:Ne,children:["Raw trips ",t.rawTripIds.length]}),e.jsxs(v,{className:Ne,children:["Raw points ",t.rawPointCount]}),t.hasLegacyCorrections?e.jsx(v,{className:xa,children:"Legacy corrections present"}):null]})]})]}),e.jsx("div",{className:"mt-5 flex flex-wrap items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:c?e.jsxs(e.Fragment,{children:[e.jsx(ga,{className:"size-4 text-[var(--info)]"}),"Sleep overlay"]}):le(t)?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"size-4 text-[var(--primary)]"}),((d=t.stay.place)==null?void 0:d.label)??"No canonical place linked yet"]}):ct(t)?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"size-4 text-[var(--primary)]"}),t.trip.activityType||t.trip.travelMode]}):t.kind==="trip"?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"size-4 text-[var(--primary)]"}),"Repaired movement connector"]}):e.jsxs(e.Fragment,{children:[e.jsx(wt,{className:"size-4 text-[var(--ui-ink-soft)]"}),"Missing intervals are synthesized from long signal gaps instead of inventing fake travel."]})})]})}function va({title:t,points:a,averagePoint:r}){const s=Lr(r?[...a,r]:a),l=r?s.length-1:s.length,c=s.slice(0,l),m=r?s[s.length-1]??null:null,d=c.map((u,p)=>`${p===0?"M":"L"} ${u.x} ${u.y}`).join(" ");return e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Relative coordinates normalized into one view so we can inspect the actual captured stay or trip geometry in one glance."}),e.jsx("div",{className:"mt-5 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-52 w-full",children:[e.jsx("rect",{x:"0",y:"0",width:"100",height:"100",rx:"18",fill:"var(--ui-surface-1)"}),c.length>1?e.jsx("path",{d,fill:"none",stroke:"var(--primary)",strokeWidth:"1.6"}):null,c.map((u,p)=>e.jsx("circle",{cx:u.x,cy:u.y,r:p===0||p===c.length-1?2.2:1.4,fill:p===0||p===c.length-1?"var(--ui-ink-strong)":"var(--primary)"},u.id)),m?e.jsxs("g",{className:"text-[var(--warning)]",children:[e.jsx("circle",{cx:m.x,cy:m.y,r:3,fill:"currentColor"}),e.jsx("circle",{cx:m.x,cy:m.y,r:6,fill:"none",stroke:"currentColor",strokeWidth:"1",strokeDasharray:"2 2",opacity:.48})]}):null]})})]})}const _t="fixed left-1/2 z-50 -translate-x-1/2 overflow-y-auto border border-[var(--ui-border-subtle)] bg-[var(--card-gradient)] text-[var(--ui-ink)] shadow-[var(--card-shadow)] backdrop-blur-xl outline-none",La="rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",Le="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]";function gs({open:t,anchor:a,items:r,onClose:s}){if(x.useEffect(()=>{if(!t)return;const u=g=>{g.key==="Escape"&&s()},p=()=>s();return window.addEventListener("keydown",u),window.addEventListener("pointerdown",p),()=>{window.removeEventListener("keydown",u),window.removeEventListener("pointerdown",p)}},[s,t]),!t||!a||typeof document>"u")return null;const l=Math.max(12,Math.min(a.top,window.innerHeight-360)),c=Math.max(220,window.innerHeight-l-96),m=Math.min(368,window.innerWidth-24),d=Math.max(12,Math.min(a.right,window.innerWidth-m-12));return Ua.createPortal(e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[70]",children:e.jsxs("div",{className:"pointer-events-auto fixed z-[71] overflow-y-auto overscroll-contain rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--card-gradient)] p-2 shadow-[var(--card-shadow)] backdrop-blur-xl",style:{top:`${l}px`,right:`${d}px`,width:`${m}px`,maxHeight:`${c}px`},onPointerDown:u=>u.stopPropagation(),children:[e.jsxs(me,{className:"rounded-[22px] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:"Movement actions"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:"Add boxes, inspect raw data, and adjust timeline overlays."})]}),e.jsx("div",{className:"mt-2 grid gap-1",children:r.map(u=>{const p=u.icon;return e.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 rounded-[20px] bg-[var(--ui-surface-1)] px-4 py-3 text-left text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>{u.onSelect(),s()},children:[e.jsx("span",{className:"rounded-[14px] bg-[var(--ui-accent-soft)] p-2 text-[var(--primary)]",children:e.jsx(p,{className:"size-4"})}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:u.label}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:u.description})]})]},u.id)})})]})}),document.body)}function fs({open:t,onOpenChange:a,segment:r,detail:s,loading:l,onEdit:c,onDefinePlace:m}){var g;const d=(s==null?void 0:s.segment)??r,u=(s==null?void 0:s.stayDetail)??null,p=(s==null?void 0:s.tripDetail)??null;return e.jsx(Qe,{open:t,onOpenChange:a,children:e.jsxs(Ue,{children:[e.jsx(We,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(Ge,{className:w(_t,"top-[6vh] max-h-[88vh] w-[min(60rem,calc(100vw-1.25rem))] rounded-[30px] p-5"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(mt,{className:"font-display text-[1.3rem] tracking-[-0.03em] text-[var(--ui-ink-strong)]",children:d?`${ue(d)} details`:"Movement details"}),e.jsx(xt,{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Inspect the canonical box, the raw movement evidence behind it, and the exact coordinates Forge used to assemble this stay or trip."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsxs(A,{onClick:c,variant:"ghost",className:w("rounded-full px-3",Le),disabled:!d.editable||d.kind==="missing",children:[e.jsx(It,{className:"size-4"}),"Edit"]}):null,e.jsx(vt,{asChild:!0,children:e.jsx("button",{type:"button",className:w(La,"p-2"),children:e.jsx(Ft,{className:"size-4 rotate-45"})})})]})]}),l?e.jsx(me,{className:"mt-6 text-sm text-[var(--ui-ink-soft)]",children:"Loading the canonical box detail and raw movement evidence..."}):d?e.jsxs("div",{className:"mt-6 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(De,{label:"Started",value:ge(d.startedAt)}),e.jsx(De,{label:"Ended",value:ge(d.endedAt)}),e.jsx(De,{label:"Duration",value:qe(d.durationSeconds)}),e.jsx(De,{label:"Raw coverage",value:`${d.rawStayIds.length} stays · ${d.rawTripIds.length} trips · ${d.rawPointCount} points`})]}),u?e.jsxs(e.Fragment,{children:[e.jsxs(me,{className:"border-[var(--primary)]/20 bg-[var(--ui-accent-soft)]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--primary)]",children:"Location label"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-strong)]",children:u.canonicalPlace?`This stay is linked to ${u.canonicalPlace.label}. Search a different saved place or relabel it from the stay center.`:"This stay has no saved place yet. Search known locations first, or create a new place directly from the stay center."}),e.jsx("div",{className:"mt-3",children:e.jsx(A,{onClick:m,variant:"ghost",className:w("rounded-full px-4",Le),children:"Label location"})})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(va,{title:"Stay positions",points:u.positions,averagePoint:u.averagePosition}),e.jsxs(k,{className:"rounded-[28px] p-5",children:[e.jsx(pa,{title:"Stay metrics",rows:[["Canonical place",((g=u.canonicalPlace)==null?void 0:g.label)??"Not linked yet"],["Average position",u.averagePosition?st(u.averagePosition.latitude,u.averagePosition.longitude):"Unavailable"],["Radius",u.radiusMeters!=null?Ie(u.radiusMeters):"Unavailable"],["Samples",String(u.sampleCount)]]}),e.jsxs(me,{muted:!0,className:"mt-4 rounded-[18px] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Exact positions"}),e.jsx("div",{className:"mt-3 grid gap-2",children:u.positions.map((j,P)=>e.jsxs("div",{className:"text-sm text-[var(--ui-ink-medium)]",children:[j.label??`Position ${P+1}`,":"," ",st(j.latitude,j.longitude)]},`${j.recordedAt??"stay"}-${P}`))})]})]})]})]}):null,p?e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(va,{title:"Travel map",points:p.positions}),e.jsx(k,{className:"rounded-[28px] p-5",children:e.jsx(pa,{title:"Trip metrics",rows:[["Start position",p.startPosition?st(p.startPosition.latitude,p.startPosition.longitude):"Unavailable"],["End position",p.endPosition?st(p.endPosition.latitude,p.endPosition.longitude):"Unavailable"],["Distance",Ie(p.totalDistanceMeters)],["Moving time",la(p.movingSeconds)],["Idle time",la(p.idleSeconds)],["Average speed",p.averageSpeedMps!=null?`${p.averageSpeedMps.toFixed(2)} m/s`:"Unavailable"],["Max speed",p.maxSpeedMps!=null?`${p.maxSpeedMps.toFixed(2)} m/s`:"Unavailable"],["Stops",String(p.stopCount)]]})})]}):null]}):null]})]})})}function bs({open:t,segment:a,onOpenChange:r,onEdit:s,onOpenDetail:l,onDefinePlace:c}){return e.jsx(Qe,{open:t,onOpenChange:r,children:e.jsxs(Ue,{children:[e.jsx(We,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(Ge,{className:"fixed left-1/2 top-[6vh] z-50 max-h-[88vh] w-[min(36rem,calc(100vw-1.25rem))] -translate-x-1/2 overflow-y-auto rounded-[30px] outline-none",children:[e.jsx(mt,{className:"sr-only",children:a?`${ue(a)} actions`:"Movement actions"}),e.jsx(xt,{className:"sr-only",children:"Inspect, edit, or label the selected movement box."}),a?e.jsx(hs,{segment:a,onEdit:s,onOpenDetail:l,onDefinePlace:c,onClose:()=>r(!1)}):null]})]})})}function ys({open:t,onOpenChange:a,segment:r,places:s,loading:l,onSelectPlace:c,onCreatePlace:m}){const d=r?Ct(r):null,[u,p]=x.useState("");x.useEffect(()=>{if(!t){p("");return}p(Fe(r)??"")},[t,r]);const g=x.useMemo(()=>{if(!d)return[];const b=he(u);return[...s].filter(C=>b.length===0?!0:$r(C).includes(b)).sort((C,E)=>{const K=he(C.label),Z=he(E.label),z=b.length>0&&K.startsWith(b),J=b.length>0&&Z.startsWith(b);if(z!==J)return z?-1:1;const G=lt(d.latitude,d.longitude,C.latitude,C.longitude),ee=lt(d.latitude,d.longitude,E.latitude,E.longitude);return Math.abs(G-ee)>1?G-ee:C.label.localeCompare(E.label)}).slice(0,6)},[s,u,d]),j=he(u),P=g.some(b=>he(b.label)===j),U=Fe(r);return e.jsx(Qe,{open:t,onOpenChange:a,children:e.jsxs(Ue,{children:[e.jsx(We,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(Ge,{className:w(_t,"top-[8vh] max-h-[84vh] w-[min(38rem,calc(100vw-1.25rem))] rounded-[30px] p-5"),children:[e.jsx($a,{title:"Label stay location",description:"Search saved locations by name first. If this stay is new, create a location from the stay center with latitude and longitude already filled in.",closeLabel:"Close location label dialog"}),d?e.jsxs(me,{className:"mt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{tone:"signal",children:"Stay center"}),U?e.jsx(v,{tone:"meta",children:U}):null]}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsx(De,{label:"Latitude",value:d.latitude.toFixed(6)}),e.jsx(De,{label:"Longitude",value:d.longitude.toFixed(6)})]})]}):e.jsx(me,{className:"mt-5 border-[var(--warning)]/20 text-sm text-[var(--ui-ink-soft)]",children:"Forge can only label stays that already have a recorded stay center."}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsx(B,{value:u,onChange:b=>p(b.target.value),placeholder:"Type a location name or create a new one"}),e.jsxs(me,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:"Known places"}),l?e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"Loading saved places..."}):g.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:g.map(b=>{const C=d==null?null:lt(d.latitude,d.longitude,b.latitude,b.longitude);return e.jsxs("button",{type:"button",onClick:()=>void c(b).then(E=>{E&&a(!1)}),className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:border-[var(--primary)]/40 hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-strong)]",children:b.label}),C!=null?e.jsxs(v,{tone:"meta",children:[Ie(C)," away"]}):null]}),b.aliases.length>0||b.categoryTags.length>0?e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:[...b.aliases,...b.categoryTags].join(" · ")}):null]},b.id)})}):e.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:"No saved place matches this stay yet."})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-2",children:[e.jsx(A,{variant:"ghost",onClick:()=>a(!1),className:Le,children:"Cancel"}),e.jsx(A,{onClick:()=>{!r||!d||m(r,P?"":u.trim())},disabled:!r||!d,children:j.length>0&&!P?`Create "${u.trim()}"`:"Create new location"})]})]})]})})}function js({open:t,draft:a,creating:r,saving:s,preflight:l,preflightLoading:c,onDraftChange:m,onFitMissing:d,onSave:u,onOpenChange:p}){return e.jsx(Qe,{open:t,onOpenChange:p,children:e.jsxs(Ue,{children:[e.jsx(We,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(Ge,{className:w(_t,"top-[8vh] w-[min(34rem,calc(100vw-1.25rem))] rounded-[30px] p-5"),children:[e.jsx($a,{title:r?"Create movement box":"Edit movement box",description:a?r?"Create a canonical user-defined stay, move, or missing-data box without mutating raw phone measurements.":`Adjust this user-defined ${a.kind} box. Automatic boxes stay immutable and can only be invalidated.`:"No segment selected."}),a?e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2 text-sm text-[var(--ui-ink-medium)]",children:["Kind",e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[["stay","Stay"],["trip","Move"],["missing","Missing"]].map(([g,j])=>e.jsx(A,{type:"button",variant:"ghost",className:w(Le,a.kind===g?"ring-1 ring-[color-mix(in_srgb,var(--primary)_42%,transparent)]":""),onClick:()=>m({...a,kind:g}),children:j},g))})]}),e.jsx(Ke,{label:"Label",value:a.label,onChange:g=>m({...a,label:g})}),a.kind!=="trip"?e.jsx(Ke,{label:"Place",value:a.placeLabel,placeholder:"Home, Office, Riverside path...",onChange:g=>m({...a,placeLabel:g})}):null,e.jsx(Ke,{label:"Tags",value:a.tagsInput,placeholder:"movement, social, errand",onChange:g=>m({...a,tagsInput:g})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(Ke,{label:"Started",type:"datetime-local",value:a.startedAtInput,onChange:g=>m({...a,startedAtInput:g})}),e.jsx(Ke,{label:"Ended",type:"datetime-local",value:a.endedAtInput,onChange:g=>m({...a,endedAtInput:g})})]}),e.jsxs(me,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Overlap guidance"}),e.jsx(A,{type:"button",variant:"ghost",className:Le,onClick:d,disabled:!(l!=null&&l.nearestMissingStartedAt)||!(l!=null&&l.nearestMissingEndedAt),children:"Fit Missing Time"})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:c?"Checking visible overlaps and missing windows...":l!=null&&l.overlapsAnything?`This box overlaps ${l.affectedAutomaticBoxIds.length} automatic and ${l.affectedUserBoxIds.length} manual boxes. Saving will fully override ${l.fullyOverriddenUserBoxIds.length} manual boxes and trim ${l.trimmedUserBoxIds.length}.`:"No overlap in the currently visible timeline window."}),e.jsxs("div",{className:"mt-3 grid gap-1 text-xs text-[var(--ui-ink-faint)]",children:[e.jsxs("div",{children:["Visible range:"," ",l!=null&&l.visibleRangeStart&&(l!=null&&l.visibleRangeEnd)?`${ge(l.visibleRangeStart)} -> ${ge(l.visibleRangeEnd)}`:"Unavailable"]}),e.jsxs("div",{children:["Suggested missing slot:"," ",l!=null&&l.nearestMissingStartedAt&&(l!=null&&l.nearestMissingEndedAt)?`${ge(l.nearestMissingStartedAt)} -> ${ge(l.nearestMissingEndedAt)}`:"No missing interval in view"]})]})]})]}):null,e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx(vt,{asChild:!0,children:e.jsx(A,{type:"button",variant:"ghost",className:Le,children:"Cancel"})}),e.jsxs(A,{onClick:u,disabled:!a||s,children:[e.jsx(Wa,{className:"size-4"}),s?"Saving...":r?"Create box":"Save changes"]})]})]})]})})}function $a({title:t,description:a,closeLabel:r}){return e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(mt,{className:"font-display text-[1.3rem] tracking-[-0.03em] text-[var(--ui-ink-strong)]",children:t}),e.jsx(xt,{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a})]}),e.jsx(vt,{asChild:!0,children:e.jsx("button",{type:"button",className:w(La,"p-2"),"aria-label":r,children:r?e.jsx($t,{className:"size-4"}):e.jsx(Ft,{className:"size-4 rotate-45"})})})]})}function De({label:t,value:a}){return e.jsxs(me,{className:"rounded-[18px] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:a})]})}function pa({title:t,rows:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:t}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.map(([r,s])=>e.jsxs("div",{className:"text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"text-[var(--ui-ink-faint)]",children:[r,": "]}),s]},r))})]})}function Ke({label:t,value:a,onChange:r,placeholder:s,type:l="text"}){return e.jsxs("label",{className:"grid gap-2 text-sm text-[var(--ui-ink-medium)]",children:[t,e.jsx(B,{type:l,value:a,placeholder:s,onChange:c=>r(c.target.value)})]})}function Ns({userIds:t=[]}){var Wt,Gt,Vt;const a=ya(),r=x.useRef(null),s=x.useRef(null),l=x.useRef(null),c=x.useRef(!1),m=x.useRef(!1),d=x.useRef(null),[u,p]=x.useState(null),[g,j]=x.useState(!1),[P,U]=x.useState(!1),[b,C]=x.useState(null),[E,K]=x.useState({}),[Z,z]=x.useState(null),[J,G]=x.useState(null),[ee,te]=x.useState(null),[Ve,Ee]=x.useState(null),[_e,Re]=x.useState(!1),[Ye,Se]=x.useState(!1),[ht,Me]=x.useState(null),[gt,ze]=x.useState(null),[re,W]=x.useState(!1),[se,ie]=x.useState(!1),[q,xe]=x.useState(!1),[y,Xe]=x.useState(""),[fe,Ze]=x.useState([]),[ve,Je]=x.useState(0),[O,Oe]=x.useState(0),Ae=()=>{const n=r.current;n&&(Je(n.scrollTop),Oe(n.clientHeight))},D=Yt({queryKey:["forge-movement-life-timeline",...t],initialPageParam:null,queryFn:({pageParam:n})=>Jt({before:n??void 0,limit:sa,userIds:t}).then(o=>o.movement),getNextPageParam:n=>n.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),N=Yt({queryKey:["forge-movement-life-timeline-data",...t],initialPageParam:null,queryFn:({pageParam:n})=>Jt({before:n??void 0,includeInvalid:!0,limit:sa,userIds:t}).then(o=>o.movement),getNextPageParam:n=>n.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),be=x.useMemo(()=>{var n;return((n=D.data)==null?void 0:n.pages.flatMap(o=>o.segments))??[]},[D.data]),oe=x.useMemo(()=>{var n;return((n=N.data)==null?void 0:n.pages.flatMap(o=>o.segments))??[]},[N.data]),de=x.useMemo(()=>{var n;return((n=D.data)==null?void 0:n.pages.reduce((o,h)=>Math.max(o,h.invalidSegmentCount??0),0))??0},[D.data]),_=x.useMemo(()=>[...be].reverse(),[be]),T=x.useMemo(()=>[...oe].reverse(),[oe]),et=x.useMemo(()=>{var o;const n=new Map;for(const h of((o=D.data)==null?void 0:o.pages)??[])for(const R of h.sleepOverlays??[])n.set(R.id,R);return[...n.values()].sort((h,R)=>new Date(h.startedAt).getTime()-new Date(R.startedAt).getTime())},[D.data]),ye=x.useMemo(()=>Tr(_,et),[_,et]),S=x.useMemo(()=>q?ye:_,[_,ye,q]),He=x.useMemo(()=>ye.filter(n=>n.syncSource==="sleep overlay"),[ye]),ne=((Wt=He.at(-1))==null?void 0:Wt.id)??null,L=x.useMemo(()=>S.find(n=>n.id===ee)??null,[ee,S]),i=x.useMemo(()=>S.find(n=>n.id===u)??null,[S,u]),f=ae({queryKey:["forge-movement-box-detail",(L==null?void 0:L.boxId)??null,...t],queryFn:async()=>L!=null&&L.boxId?(await tr(L.boxId,t)).movement:null,enabled:!!(L!=null&&L.boxId)}),Q=x.useMemo(()=>_.find(n=>n.id===Ve)??null,[Ve,_]),V=ae({queryKey:["forge-movement-places",...t],queryFn:async()=>(await Sa(t)).places,retry:!1,refetchOnWindowFocus:!1}),M=x.useMemo(()=>Vr({segments:S,viewportHeight:O}),[S,O]),pe=x.useMemo(()=>new Map(M.items.map(n=>[n.segment.id,n])),[M.items]),Ce=x.useMemo(()=>{const n=Math.max(0,ve-ia),o=ve+Math.max(O,X*8)+ia;return M.items.filter(h=>h.segment.id===u?!0:h.boxBottom>=n&&h.boxTop<=o)},[ve,u,M.items,O]),zt=x.useMemo(()=>os(M,ve,O),[ve,M,O]),Fa=()=>{var o;const n=(o=l.current)==null?void 0:o.getBoundingClientRect();if(!n){U(h=>!h);return}C({top:n.bottom+10,right:Math.max(12,window.innerWidth-n.right)}),U(h=>!h)},Ea=x.useMemo(()=>[{id:"add-box",label:"Add box",description:"Create a user-defined stay, move, or missing-data interval.",icon:Ga,onSelect:()=>G(kt("stay",_.at(-1)??null))},{id:"sleep",label:q?"Hide sleep":"Show sleep",description:"Toggle sleep overlays without rewriting the movement boxes.",icon:ga,onSelect:()=>xe(n=>{const o=!n;return o&&ne&&(p(ne),j(!0)),o})},{id:"view-data",label:"View data",description:"Open the canonical loaded records and raw-data filters.",icon:wt,onSelect:()=>W(!0)}],[ne,_,q]),Ot=(n,o="smooth")=>{const h=r.current,R=pe.get(n);if(!h||!R)return;const Be=Math.max(0,R.boxTop-h.clientHeight/2+R.displayHeight/2);if(typeof h.scrollTo=="function"){h.scrollTo({top:Be,behavior:o});return}h.scrollTop=Be};x.useEffect(()=>{re&&(!N.hasNextPage||N.isFetchingNextPage||N.fetchNextPage())},[re,N.fetchNextPage,N.hasNextPage,N.isFetchingNextPage]),x.useEffect(()=>{const n=S.at(-1);!m.current&&n&&(m.current=!0,p(n.id))},[S]),x.useEffect(()=>{if(!c.current&&S.length>0){c.current=!0,requestAnimationFrame(()=>{var o;const n=(o=S[S.length-1])==null?void 0:o.id;n&&Ot(n,"auto"),requestAnimationFrame(()=>{Ae()})});return}if(d.current&&S.length>d.current.count&&r.current){const n=d.current;d.current=null,requestAnimationFrame(()=>{const o=r.current;if(!o)return;const h=M.totalHeight-n.size;o.scrollTop+=h,Ae()})}},[S.length,M.totalHeight,pe]),x.useEffect(()=>{if(!r.current)return;const o=()=>{Ae()};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),x.useEffect(()=>{if(!u)return;const n=_.find(o=>o.id===u);n&&K(o=>o[u]?o:{...o,[u]:Tt(n)})},[_,u]),x.useEffect(()=>{var n;u&&(S.some(o=>o.id===u)||(p(((n=S.at(-1))==null?void 0:n.id)??null),j(!1)))},[S,u]),x.useEffect(()=>{if(!q||!ne)return;const n=S.findIndex(o=>o.id===ne);n<0||(p(ne),requestAnimationFrame(()=>{var h;const o=(h=S[n])==null?void 0:h.id;o&&Ot(o)}))},[S,ne,q,pe]);const ft=async()=>{await Promise.all([a.invalidateQueries({queryKey:["forge-movement-life-timeline"]}),a.invalidateQueries({queryKey:["forge-movement-life-timeline-data"]}),a.invalidateQueries({queryKey:["forge-movement-box-detail"]}),a.invalidateQueries({queryKey:["forge-movement-day"]}),a.invalidateQueries({queryKey:["forge-movement-month"]}),a.invalidateQueries({queryKey:["forge-movement-all-time"]}),a.invalidateQueries({queryKey:["forge-movement-places"]}),a.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})])},Ht=Pe({mutationFn:async n=>{const{segment:o,draft:h,creating:R}=n,Be=Pt(h,o);if(R){await Xt(Be,t);return}if(!o)throw new Error("No movement box selected.");if(o.sourceKind!=="user_defined")throw new Error("Automatic movement boxes are immutable. Invalidate them into missing data or create a user-defined override instead.");await Zt(o.boxId,{...Be,metadata:{updatedFrom:"movement-life-timeline"}},t)},onSuccess:ft}),_a=async(n,o)=>{if(n.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");const h=zr(n,o.label);if(n.sourceKind==="user_defined"){await Zt(n.boxId,{...h,metadata:{updatedFrom:"movement-life-timeline-place-label"}},t);return}await Xt({...h,metadata:{createdFrom:"movement-life-timeline-place-label"}},t)},Bt=async(n,o)=>{if(n.rawStayIds.length===0)throw new Error("This stay has no raw stay ids to relabel.");await Promise.all(n.rawStayIds.map(h=>er(h,{placeExternalUid:o.externalUid,placeLabel:o.label})))},Ra=(n,o)=>{const h=Ct(n);if(!h)return!0;const R=lt(h.latitude,h.longitude,o.latitude,o.longitude);return R<=100||typeof window>"u"||typeof window.confirm!="function"?!0:window.confirm(`"${o.label}" is ${Ie(R)} away from this stay's recorded center. Link it anyway?`)},za=Pe({mutationFn:async n=>{const{segment:o,...h}=n,R=await ja(h,t);return o&&le(o)&&await Bt(o,R.place),R},onSuccess:ft}),Oa=Pe({mutationFn:async n=>{const{segment:o,place:h}=n;if(!Ra(o,h))return{assigned:!1};if(le(o))return await Bt(o,h),{assigned:!0};if(o.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");return await _a(o,h),{assigned:!0}},onSuccess:async n=>{n.assigned&&await ft()}}),bt=Pe({mutationFn:async n=>{if(n.sourceKind==="user_defined"){await Za(n.boxId,t);return}await Ja(n.boxId,{title:"User invalidated automatic movement",subtitle:`Overrides ${ue(n)} with missing data.`},t)},onSuccess:async(n,o)=>{p(h=>h===o.id?null:h),j(!1),z(h=>h===o.id?null:h),a.setQueryData(["forge-movement-life-timeline",...t],h=>da(h,o.id)),a.setQueryData(["forge-movement-life-timeline-data",...t],h=>da(h,o.id)),await Promise.all([a.invalidateQueries({queryKey:["forge-movement-life-timeline"]}),a.invalidateQueries({queryKey:["forge-movement-life-timeline-data"]}),a.invalidateQueries({queryKey:["forge-movement-day"]}),a.invalidateQueries({queryKey:["forge-movement-month"]}),a.invalidateQueries({queryKey:["forge-movement-all-time"]}),a.invalidateQueries({queryKey:["forge-movement-selection"]}),a.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})])}}),Ha=x.useMemo(()=>Hr(T),[T]),je=x.useMemo(()=>{const n=he(y);return[...T].sort((o,h)=>new Date(h.endedAt).getTime()-new Date(o.endedAt).getTime()).filter(o=>(n.length===0||Or(o).includes(n))&&Br(o,fe))},[T,y,fe]),Kt=x.useMemo(()=>T.length===0?"No movement records loaded yet.":je.length===T.length&&y.trim().length===0&&fe.length===0?`${T.length} loaded movement records visible`:`${je.length} of ${T.length} loaded records visible`,[T.length,je.length,y,fe.length]),yt=ba({count:je.length,getScrollElement:()=>s.current,estimateSize:()=>136,overscan:8}),$=Z?_.find(n=>n.id===Z)??null:null,Ba=$?E[$.id]??Tt($):null,tt=J!==null,F=J??Ba,qt=((Gt=_[0])==null?void 0:Gt.startedAt)??null,Qt=((Vt=_[_.length-1])==null?void 0:Vt.endedAt)??null,jt=ae({queryKey:["forge-movement-user-box-preflight",($==null?void 0:$.boxId)??"create",(F==null?void 0:F.kind)??null,(F==null?void 0:F.startedAtInput)??null,(F==null?void 0:F.endedAtInput)??null,qt,Qt,...t],enabled:F!==null&&dt(F.startedAtInput)!==null&&dt(F.endedAtInput)!==null,queryFn:async()=>{if(!F)return null;const n=Pt(F,$);return(await ar({...n,excludeBoxId:($==null?void 0:$.sourceKind)==="user_defined"?$.boxId:null,rangeStart:qt,rangeEnd:Qt},t)).preflight}}),Ut=n=>{le(n)&&(Ee(n.id),Re(!0))},Ka=(n,o)=>{const h=Ct(n);h&&(Re(!1),Ee(n.id),Me({...h,label:o.trim()||h.label}),ze(n.id),Se(!0))},qa=()=>{const n=r.current;n&&(Je(n.scrollTop),Oe(n.clientHeight),!(!D.hasNextPage||D.isFetchingNextPage)&&n.scrollTop<=960&&(d.current={count:S.length,size:M.totalHeight},D.fetchNextPage()))};if(D.isPending)return e.jsx(Na,{eyebrow:"Movement",title:"Loading life timeline",description:"Reconstructing the longer road of stays, moves, and places.",columns:1,blocks:6});if(D.isError)return e.jsx(ka,{eyebrow:"Movement",error:D.error,onRetry:()=>void D.refetch()});const Qa=M.totalHeight;return e.jsxs("section",{className:"grid gap-4",children:[e.jsxs(k,{className:"overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-3 sm:rounded-[34px] sm:p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3 px-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.22em] text-[var(--ui-ink-muted)]",children:"Movement"}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-2",children:[de>0?e.jsxs(v,{className:w("hidden sm:inline-flex",Te),children:[de," invalid hidden"]}):null,e.jsxs(v,{className:"hidden bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] sm:inline-flex",children:[S.length," visible"]}),e.jsx("div",{ref:l,children:e.jsxs(A,{type:"button",variant:"ghost",size:"sm","aria-expanded":P,"aria-haspopup":"dialog",className:w("h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",P?Dt:""),onClick:Fa,children:[e.jsx(Va,{className:"size-4"}),"Actions"]})})]})]}),e.jsx(gs,{open:P,anchor:b,items:Ea,onClose:()=>U(!1)}),q&&He.length===0?e.jsx("p",{className:"mb-3 px-1 text-sm text-[color-mix(in_srgb,var(--warning)_72%,var(--ui-ink-strong)_28%)]",children:"No sleep session overlaps the currently loaded timeline range yet. Scroll further back to load older history."}):null,e.jsxs("div",{ref:r,onScroll:qa,className:"relative h-[82vh] overflow-auto rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)]",children:[e.jsx(is,{layout:M,scrollTop:ve,viewportHeight:O}),zt?e.jsx("div",{className:"pointer-events-none sticky top-3 z-50 flex h-0 justify-center",children:e.jsx("div",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-soft)] backdrop-blur-xl",children:zt})}):null,e.jsxs("div",{className:"relative",style:{height:`${Qa}px`},children:[M.historyHeaderHeight>0?e.jsx("div",{className:"absolute inset-x-0 top-0",style:{height:`${M.historyHeaderHeight}px`},children:e.jsx(ls,{segment:S[0]??null})}):null,Ce.map(n=>{const o=n.segment;return e.jsx(ds,{layout:n,selected:u===o.id,onToggle:()=>{p(o.id),j(!0)}},o.id)})]})]})]}),e.jsx(js,{open:$!==null||J!==null,segment:$,draft:F,creating:tt,saving:Ht.isPending,preflight:jt.data??null,preflightLoading:jt.isFetching,onDraftChange:n=>{if(tt){G(n);return}$&&K(o=>({...o,[$.id]:n}))},onFitMissing:()=>{const n=jt.data;if(!(n!=null&&n.nearestMissingStartedAt)||!n.nearestMissingEndedAt)return;const o={...F??kt("stay",$),startedAtInput:$e(n.nearestMissingStartedAt),endedAtInput:$e(n.nearestMissingEndedAt)};if(tt){G(o);return}$&&K(h=>({...h,[$.id]:o}))},onSave:()=>{F&&Ht.mutateAsync({segment:$,draft:F,creating:tt},{onSuccess:()=>{z(null),G(null),se&&(ie(!1),W(!0))}})},onOpenChange:n=>{n||(z(null),G(null),se&&(ie(!1),W(!0)))}}),e.jsx(bs,{open:g&&i!==null,onOpenChange:n=>{j(n)},segment:i,onEdit:()=>{i!=null&&i.editable&&(z(i.id),j(!1))},onOpenDetail:()=>{i&&(te(i.id),j(!1))},onDefinePlace:()=>{i&&(Ut(i),j(!1))}}),e.jsx(fs,{open:L!==null,onOpenChange:n=>{n||te(null)},segment:L,detail:f.data??null,loading:f.isFetching,onEdit:()=>{!L||!L.editable||(z(L.id),te(null))},onDefinePlace:()=>{L&&Ut(L)}}),e.jsx(ys,{open:_e,onOpenChange:n=>{Re(n),n||Ee(null)},segment:Q,places:V.data??[],loading:V.isFetching,onSelectPlace:async n=>Q?(await Oa.mutateAsync({segment:Q,place:n})).assigned:!1,onCreatePlace:(n,o)=>{Ka(n,o)}}),e.jsx(Aa,{open:Ye,onOpenChange:n=>{Se(n),n||(Me(null),ze(null))},place:null,seed:ht,onSave:async n=>{await za.mutateAsync({...n,segment:_.find(o=>o.id===gt)??null})}}),e.jsx(wa,{open:re,onOpenChange:n=>{W(n),n||se||(Xe(""),Ze([]))},eyebrow:"Movement data",title:"View data",description:"",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ma,{title:"",description:"",query:y,onQueryChange:Xe,options:Ha,selectedOptionIds:fe,onSelectedOptionIdsChange:Ze,resultSummary:Kt,placeholder:"Search movement labels, places, times, tags, or add time and kind filters",emptyStateMessage:"Keep typing or pick filters to narrow the movement history."}),e.jsxs(k,{className:"grid min-w-0 gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Canonical boxes"}),e.jsx("div",{className:"max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-muted)]",children:"This list shows the canonical movement boxes projected by Forge. Automatic boxes are derived from immutable raw phone measurements. User-defined boxes override the projection without mutating raw movement data."})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-[var(--ui-ink-medium)]",onClick:()=>{ie(!0),W(!1),G(kt("stay",je.at(-1)??null))},children:"Add box"}),e.jsx(v,{tone:"meta",children:Kt}),de>0?e.jsxs(v,{className:Te,children:[de," invalid hidden included"]}):null,N.hasNextPage?e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 text-[var(--ui-ink-medium)]",pending:N.isFetchingNextPage,pendingLabel:"Loading…",onClick:()=>void N.fetchNextPage(),children:"Load older"}):null]})]}),e.jsx("div",{ref:s,className:"h-[36rem] overflow-y-auto rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:je.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-[var(--ui-ink-muted)]",children:"No movement record matches the current search. Clear filters or load older timeline history."}):e.jsx("div",{className:"relative w-full",style:{height:`${yt.getTotalSize()}px`},children:yt.getVirtualItems().map(n=>{var h;const o=je[n.index];return e.jsx("div",{ref:yt.measureElement,"data-index":n.index,className:"absolute left-0 top-0 w-full px-3 py-2",style:{transform:`translateY(${n.start}px)`},children:e.jsxs("div",{className:"flex items-start gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2.5",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left transition hover:opacity-100",onClick:()=>{o.editable&&(ie(!0),W(!1),z(o.id))},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[o.kind==="stay"?e.jsx(fa,{className:"size-3.5 shrink-0 text-[var(--primary)]"}):o.kind==="missing"?e.jsx(wt,{className:"size-3.5 shrink-0 text-[var(--ui-ink-medium)]"}):e.jsx(ot,{className:"size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-sm font-medium",children:ue(o)})]}),e.jsxs("div",{className:"mt-1 text-xs text-[var(--ui-ink-muted)]",children:[ut(o.startedAt)," →"," ",ut(o.endedAt)]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1.5",children:[e.jsx(v,{tone:o.kind==="trip"?"signal":"meta",children:o.kind==="trip"?"Move":o.kind==="missing"?"Missing":"Stay"}),e.jsx(v,{className:o.sourceKind==="user_defined"?"bg-[var(--ui-accent-soft)] text-[var(--primary)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:o.sourceKind==="user_defined"?o.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),e.jsx(v,{tone:"meta",children:qe(o.durationSeconds)}),o.origin==="continued_stay"?e.jsx(v,{className:Da,children:"Continued stay"}):null,o.origin==="repaired_gap"?e.jsx(v,{className:Te,children:"Repaired"}):null,o.kind==="missing"?e.jsx(v,{className:as,children:"Missing"}):null,o.isInvalid?e.jsx(v,{className:Te,children:"Invalid"}):null,o.placeLabel?e.jsx(v,{tone:"default",children:o.placeLabel}):null,o.overrideCount>0?e.jsxs(v,{className:Te,children:["Overrides ",o.overrideCount]}):null,e.jsxs(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Raw stays ",o.rawStayIds.length]}),e.jsxs(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Raw trips ",o.rawTripIds.length]}),e.jsxs(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:["Raw points ",o.rawPointCount]}),o.hasLegacyCorrections?e.jsx(v,{className:Te,children:"Legacy corrections"}):null]})]})}),e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:w("h-8 shrink-0 rounded-full border px-2.5",o.sourceKind==="user_defined"?rs:ss),pending:bt.isPending&&((h=bt.variables)==null?void 0:h.id)===o.id,pendingLabel:"",onClick:()=>{window.confirm(o.sourceKind==="user_defined"?`Delete ${ue(o)} and remove this user-defined box from every synced surface?`:`Invalidate ${ue(o)} into missing data and hide the automatic box everywhere?`)&&bt.mutateAsync(o)},children:e.jsx(Ya,{className:"size-3.5"})})]})},`${o.kind}:${o.id}:${o.startedAt}:${o.endedAt}:${n.index}`)})})})]})]})})]})}function ks(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}).format(new Date(t))}function ws(t,a){const r=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${r.format(new Date(t))} - ${r.format(new Date(a))}`}function H(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function ke(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function Ss(t,a){return t==="distanceMeters"?ke(a):t==="caloriesKcal"?`${Math.round(a)} kcal`:H(a)}function Ia(t){return t.trim().toLowerCase()}function pt(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function Rt(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Ms(t){const a=new Date(t);return Number.isNaN(a.getTime())?"":new Date(a.getTime()-a.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function ha(t){return{recordedAt:Ms(t.recordedAt),latitude:String(t.latitude),longitude:String(t.longitude),accuracyMeters:t.accuracyMeters!=null?String(t.accuracyMeters):"",altitudeMeters:t.altitudeMeters!=null?String(t.altitudeMeters):"",speedMps:t.speedMps!=null?String(t.speedMps):"",isStopAnchor:t.isStopAnchor}}function As(t){return Ia([Rt(t.recordedAt),t.externalUid,t.isStopAnchor?"stop anchor stop":"path trace point",t.accuracyMeters!=null?`${Math.round(t.accuracyMeters)} meters accuracy`:"",pt(t.recordedAt)].join(" "))}function Cs(t){const a=new Map;return a.set("anchor:stop",{id:"anchor:stop",label:"Stop anchors",description:"Only the canonical pause anchors",badge:e.jsx(v,{tone:"meta",children:"Stop anchors"})}),a.set("anchor:path",{id:"anchor:path",label:"Path points",description:"Non-anchor trace points",badge:e.jsx(v,{tone:"meta",children:"Path points"})}),a.set("accuracy:precise",{id:"accuracy:precise",label:"Precise",description:"GPS accuracy below 20m",badge:e.jsx(v,{tone:"meta",children:"Precise"})}),a.set("accuracy:loose",{id:"accuracy:loose",label:"Loose accuracy",description:"GPS accuracy at or above 20m",badge:e.jsx(v,{tone:"meta",children:"Loose accuracy"})}),t.forEach(r=>{const s=pt(r.recordedAt);a.has(`time:${s}`)||a.set(`time:${s}`,{id:`time:${s}`,label:s,description:"Recorded during this time band",badge:e.jsx(v,{tone:"meta",className:"capitalize",children:s})})}),[...a.values()]}function Ts(t,a){return a.every(r=>r==="anchor:stop"?t.isStopAnchor:r==="anchor:path"?!t.isStopAnchor:r==="accuracy:precise"?t.accuracyMeters!=null&&t.accuracyMeters<20:r==="accuracy:loose"?t.accuracyMeters==null||t.accuracyMeters>=20:r.startsWith("time:")?pt(t.recordedAt)===r.slice(5):!0)}function Ps(t){if(t.length===0)return[];const a=Math.min(...t.map(d=>d.latitude)),r=Math.max(...t.map(d=>d.latitude)),s=Math.min(...t.map(d=>d.longitude)),l=Math.max(...t.map(d=>d.longitude)),c=Math.max(r-a,1e-4),m=Math.max(l-s,1e-4);return t.map(d=>({x:12+(d.longitude-s)/m*76,y:12+(1-(d.latitude-a)/c)*76}))}function Ds({curve:t,startLabel:a,endLabel:r,stopLabels:s}){const l=t.map((c,m)=>`${m===0?"M":"Q"} ${c.x} ${c.y}`).join(" ");return e.jsxs(k,{className:"overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Stylized trajectory"}),e.jsx(ce,{content:"This graph is a softened trip trace. It emphasizes rhythm, stops, and endpoints instead of raw GPS jitter."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:"A softened path that prioritizes rhythm, stops, and landmarks over raw map noise."})]}),e.jsxs(v,{tone:"signal",children:[a," → ",r]})]}),e.jsxs("div",{className:"mt-5 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("svg",{viewBox:"0 0 100 60",className:"h-48 w-full",children:[e.jsx("defs",{children:e.jsxs("filter",{id:"movementGlow",children:[e.jsx("feGaussianBlur",{stdDeviation:"1.8",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),e.jsx("path",{d:l,fill:"none",stroke:"var(--ui-ink-medium)",strokeWidth:"1.5",strokeDasharray:"2.8 2.8",filter:"url(#movementGlow)"}),t.map((c,m)=>e.jsx("g",{children:e.jsx("circle",{cx:c.x,cy:c.y,r:m===0||m===t.length-1?2.6:1.6,fill:m===0||m===t.length-1?"var(--ui-ink-strong)":"var(--info)"})},`${c.x}-${c.y}-${m}`))]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.map(c=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:c},c))})]})]})}function Ls({points:t}){const a=Ps(t),r=a.map((s,l)=>`${l===0?"M":"L"} ${s.x} ${s.y}`).join(" ");return e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Exact path"}),e.jsx(ce,{content:"This keeps the recent raw location points. Use it when you want the literal recorded trace instead of the cleaned movement graph."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:"Recent raw points preserved by the companion before long-term simplification."}),e.jsx("div",{className:"mt-5 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:e.jsxs("svg",{viewBox:"0 0 100 100",className:"h-52 w-full",children:[e.jsx("rect",{x:"0",y:"0",width:"100",height:"100",rx:"18",fill:"var(--ui-surface-2)"}),e.jsx("path",{d:r,fill:"none",stroke:"var(--info)",strokeWidth:"1.6"}),a.map((s,l)=>e.jsx("circle",{cx:s.x,cy:s.y,r:l===0||l===a.length-1?2:1.1,fill:l===0||l===a.length-1?"var(--ui-ink-strong)":"var(--info)"},`${s.x}-${s.y}-${l}`))]})})]})}function $s({point:t,draft:a}){return e.jsxs(k,{className:"grid gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Raw datapoint"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:Rt(t.recordedAt)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Raw phone measurements are immutable in product UI. To change the visible movement story, create or edit user-defined boxes in the Life Timeline instead."})]}),e.jsx(v,{tone:t.isStopAnchor?"signal":"meta",children:t.isStopAnchor?"Stop anchor":"Path point"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Recorded at"}),e.jsx(B,{type:"datetime-local",value:a.recordedAt,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Speed (m/s)"}),e.jsx(B,{value:a.speedMps,disabled:!0,placeholder:"Optional"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Latitude"}),e.jsx(B,{value:a.latitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Longitude"}),e.jsx(B,{value:a.longitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Accuracy (m)"}),e.jsx(B,{value:a.accuracyMeters,disabled:!0,placeholder:"Optional"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:"Altitude (m)"}),e.jsx(B,{value:a.altitudeMeters,disabled:!0,placeholder:"Optional"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(A,{variant:"ghost",className:w("h-10 rounded-full border px-4",a.isStopAnchor?"border-[var(--primary)] bg-[var(--primary)]/16 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),disabled:!0,children:[e.jsx(ot,{className:"mr-2 size-4"}),a.isStopAnchor?"Stop anchor":"Path point"]}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-muted)]",children:["External id: ",e.jsx("span",{className:"text-[var(--ui-ink-medium)]",children:t.externalUid})]})]}),e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"This browser is read-only now. Raw points stay immutable so the web app and iPhone can both project the same repaired canonical boxes from the backend."})]})}function Vs(){var ye,S,He,ne,L;const t=rr(),a=ya(),r=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[s,l]=x.useState("life"),[c,m]=x.useState(new Date().toISOString().slice(0,10)),[d,u]=x.useState(new Date().toISOString().slice(0,7)),[p,g]=x.useState(null),[j,P]=x.useState(!1),[U,b]=x.useState(!1),[C,E]=x.useState(""),[K,Z]=x.useState([]),[z,J]=x.useState(null),[G,ee]=x.useState(null),[te,Ve]=x.useState({stayIds:[],tripIds:[]}),[Ee,_e]=x.useState(!1),[Re,Ye]=x.useState(null),[Se,ht]=x.useState(""),[Me,gt]=x.useState("distanceMeters"),ze=x.useRef(null),re=ae({queryKey:["forge-movement-day",c,...r],queryFn:async()=>(await nr({date:c,userIds:r})).movement}),W=ae({queryKey:["forge-movement-month",d,...r],queryFn:async()=>(await lr({month:d,userIds:r})).movement}),se=ae({queryKey:["forge-movement-all-time",...r],queryFn:async()=>(await or(r)).movement}),ie=ae({queryKey:["forge-life-force",...r],queryFn:async()=>(await dr(r)).lifeForce}),q=ae({queryKey:["forge-movement-settings",...r],queryFn:async()=>(await cr(r)).settings}),xe=ae({queryKey:["forge-movement-places",...r],queryFn:async()=>(await Sa(r)).places}),y=ae({queryKey:["forge-movement-trip",p],queryFn:async()=>p?(await ur(p)).movement:null,enabled:!!p}),Xe=ae({queryKey:["forge-movement-selection",c,te.stayIds.join(","),te.tripIds.join(","),...r],queryFn:async()=>(await mr({...te,userIds:r})).movement,enabled:te.stayIds.length>0||te.tripIds.length>0}),fe=Pe({mutationFn:async i=>sr({trackingEnabled:i},r),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-settings"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]})}}),Ze=Pe({mutationFn:async i=>i.id?ir(i.id,i):ja(i,r),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-places"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]}),await a.invalidateQueries({queryKey:["forge-movement-all-time"]})}}),ve=x.useMemo(()=>{const i=xe.data??[],f=Se.trim().toLowerCase();return f?i.filter(Q=>[Q.label,...Q.aliases,...Q.categoryTags].join(" ").toLowerCase().includes(f)):i},[Se,xe.data]),Je=x.useMemo(()=>{var i;return Cs(((i=y.data)==null?void 0:i.trip.points)??[])},[(ye=y.data)==null?void 0:ye.trip.points]),O=x.useMemo(()=>{var Q;const i=((Q=y.data)==null?void 0:Q.trip.points)??[],f=Ia(C);return[...i].sort((V,M)=>new Date(M.recordedAt).getTime()-new Date(V.recordedAt).getTime()).filter(V=>(f.length===0||As(V).includes(f))&&Ts(V,K))},[C,K,(S=y.data)==null?void 0:S.trip.points]),Oe=x.useMemo(()=>{var f;const i=((f=y.data)==null?void 0:f.trip.points.length)??0;return i===0?"No raw datapoints on this trip yet.":O.length===i&&C.trim().length===0&&K.length===0?`${i} datapoints visible`:`${O.length} of ${i} datapoints visible`},[O.length,C,K.length,(He=y.data)==null?void 0:He.trip.points.length]),Ae=ba({count:O.length,getScrollElement:()=>ze.current,estimateSize:()=>96,overscan:8}),D=O.find(i=>i.id===z)??((ne=y.data)==null?void 0:ne.trip.points.find(i=>i.id===z))??O[0]??((L=y.data)==null?void 0:L.trip.points[0])??null;if(x.useEffect(()=>{if(U){if(!D){J(null),ee(null);return}J(D.id),ee(ha(D))}},[D,U]),x.useEffect(()=>{E(""),Z([]),J(null),ee(null),b(!1)},[p]),re.isLoading||W.isLoading||se.isLoading||q.isLoading||xe.isLoading)return e.jsx(Na,{eyebrow:"Movement",title:"Loading movement workspace",description:"Reconstructing stays, trips, and place intelligence across Forge.",columns:2,blocks:8});if(re.isError||W.isError||se.isError||q.isError||xe.isError||!re.data||!W.data||!se.data||!q.data)return e.jsx(ka,{eyebrow:"Movement",error:re.error??W.error??se.error??q.error??xe.error??new Error("Movement data unavailable"),onRetry:()=>{re.refetch(),W.refetch(),se.refetch(),q.refetch(),xe.refetch()}});const N=re.data,be=W.data,oe=se.data,de=q.data,_=N.segments.filter((i,f,Q)=>{const V=`${i.kind}:${i.id}:${i.startedAt}:${i.endedAt}`;return Q.findIndex(M=>`${M.kind}:${M.id}:${M.startedAt}:${M.endedAt}`===V)===f}),T=Xe.data??N.selectionAggregate,et=N.trips.reduce((i,f)=>i+at(f).totalAp,0);return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(xr,{entityKind:"project",title:"Movement",description:"Turn passive place and travel signals into a real Forge domain: day rhythm, travel arcs, known landmarks, linked work, and reflective evidence.",badge:`${N.summary.tripCount} trips today`,actions:e.jsx("div",{className:"flex flex-wrap gap-2",children:["life","day","month","all_time"].map(i=>e.jsx(A,{variant:"ghost",className:w("h-9 rounded-full border px-4 text-sm",s===i?"border-[var(--primary)] bg-[var(--primary)]/16 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),onClick:()=>l(i),children:i==="all_time"?"All time":i==="life"?"Life":i.charAt(0).toUpperCase()+i.slice(1)},i))})}),e.jsxs(k,{className:"grid gap-3 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-4 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Movement AP today"}),e.jsx("div",{className:"mt-2 text-3xl font-semibold text-[var(--ui-ink-strong)]",children:ea(et)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Trips and transitions now contribute to the same Action Point ledger as work, habits, and notes."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Typical trip drain"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:N.trips[0]?rt(at(N.trips[0]).rateApPerHour):"0 AP/h"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Movement uses a MET-like drain under the hood, translated into Forge Action Points."})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:ie.data?`${Math.round(ie.data.spentTodayAp??0)}/${Math.round(ie.data.dailyBudgetAp??0)} AP`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:ie.data?`${rt(ie.data.instantFreeApPerHour)} free right now`:"Movement can now be read against today’s live capacity."})]})]}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.65fr)_minmax(20rem,0.95fr)]",children:[e.jsx(vr,{children:e.jsxs(k,{className:"overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Movement operating mode"}),e.jsx(ce,{content:"This is the passive capture state of the movement system: whether tracking is running, how much is published into Forge, and how aggressive retention is."})]}),e.jsx("div",{className:"mt-2 text-[clamp(1.05rem,1.8vw,1.35rem)] text-[var(--ui-ink-strong)]",children:"Background stays and trips as structured life evidence"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-[var(--ui-ink-muted)]",children:"The companion samples quietly while stationary, switches to denser trip capture when you move, and keeps only simplified long-term traces."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{tone:"signal",children:de.trackingEnabled?"Tracking on":"Tracking off"}),e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:de.publishMode.replaceAll("_"," ")}),e.jsx(A,{variant:"ghost",className:"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4",onClick:()=>fe.mutate(!de.trackingEnabled),children:de.trackingEnabled?"Pause passive capture":"Enable passive capture"})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Distance today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:ke(N.summary.totalDistanceMeters)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Across trips, stops, and linked place changes."})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Idle time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:H(N.summary.totalIdleSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Time spent settled enough to count as a real stay."})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Estimated phone time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:H(N.summary.estimatedScreenTimeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Estimated from hourly Screen Time bins, not exact foreground traces."})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Known places"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:N.summary.knownPlaceCount}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Shared between Forge and the iPhone companion."})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Missing data"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:H(N.summary.missingDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:[N.summary.missingCount," grey gap",N.summary.missingCount===1?"":"s"," where Forge had over one hour without enough movement signal."]})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Repaired gaps"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:H(N.summary.repairedGapDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:[N.summary.repairedGapCount," inferred span",N.summary.repairedGapCount===1?"":"s"," classified as stay or move instead of leaving blank holes in the day."]})]}),e.jsxs(k,{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Continued stays"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:H(N.summary.continuedStayDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:[N.summary.continuedStayCount," short stationary span",N.summary.continuedStayCount===1?"":"s"," carried forward so quiet home time stays continuous instead of disappearing."]})]})]})]})}),e.jsx(pr,{children:e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Selection aggregate"}),e.jsx(ce,{content:"When you select stays or trips, Forge totals their span, distance, work overlap, notes, and places here."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Select any combination of stays and trips to sum movement, time, and work evidence."}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Span"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:H(T.durationSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:ke(T.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Work overlap"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:H(T.trackedWorkSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Notes"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:T.noteCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Estimated phone time"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:H(T.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:T.pickupCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:T.notificationCount})]})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:T.placeLabels.map(i=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i},i))}),T.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:T.topApps.map(i=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-info-soft)] text-[var(--ui-ink-medium)]",children:(i.displayName||i.bundleIdentifier)+" · "+H(i.totalActivitySeconds)},i.id))}):null,T.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:T.topCategories.map(i=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.categoryLabel},i.id))}):null]})})]}),s==="life"?e.jsx(hr,{children:e.jsxs("section",{className:"grid gap-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-3 px-1",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Life graph"}),e.jsx(ce,{content:"This graph shows the movement road of your life: stays are blocks, moves connect them, and the hour/day lines live in the background. Click a segment for details, then use edit when you want to correct it."})]})}),e.jsx(Ns,{userIds:r})]})}):null,s==="day"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.55fr)_minmax(22rem,1fr)]",children:[e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Day strip"}),e.jsx(ce,{content:"A compressed 24-hour strip. Each segment keeps its true order and duration, but the whole day stays navigable on one line."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"A single-row timeline from 00:00 to 24:00, always compressed into one navigable strip."})]}),e.jsx(B,{type:"date",value:c,onChange:i=>m(i.target.value),className:"w-[11rem]"})]}),e.jsx("div",{className:"mt-6 overflow-x-auto pb-2",children:e.jsxs("div",{className:"w-full min-w-full sm:min-w-[52rem]",children:[e.jsx("div",{className:"mb-3 flex justify-between text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:["00:00","06:00","12:00","18:00","24:00"].map(i=>e.jsx("span",{children:i},i))}),e.jsx("div",{className:"flex h-28 items-stretch overflow-hidden rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2",children:_.map((i,f)=>{const Q=Math.max(9,i.durationSeconds/86400*100),V=i.kind==="stay"?te.stayIds.includes(i.id):i.kind==="trip"?te.tripIds.includes(i.id):!1;return e.jsxs("button",{type:"button",className:w("relative flex min-w-0 flex-col justify-between rounded-[22px] border px-3 py-2 text-left transition sm:min-w-[5.5rem]",i.kind==="missing"?"border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-3)]":V?"border-[color-mix(in_srgb,var(--info)_34%,transparent)] bg-[var(--ui-info-soft)]":"border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-3)]"),style:{width:`${Q}%`},onClick:()=>{i.kind!=="missing"&&Ve(M=>{const pe=new Set(M.stayIds),Ce=new Set(M.tripIds);return i.kind==="stay"?pe.has(i.id)?pe.delete(i.id):pe.add(i.id):Ce.has(i.id)?Ce.delete(i.id):(Ce.add(i.id),g(i.id)),{stayIds:[...pe],tripIds:[...Ce]}})},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(v,{tone:i.kind==="trip"?"signal":i.kind==="missing"?"meta":"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.kind==="missing"?"gap":i.kind}),e.jsx("span",{className:"text-[11px] text-[var(--ui-ink-muted)]",children:H(i.durationSeconds)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"line-clamp-2 text-sm font-semibold text-[var(--ui-ink-strong)]",children:i.label}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-muted)]",children:i.subtitle})]})]},`${i.kind}:${i.id}:${i.startedAt}:${i.endedAt}:${f}`)})})]})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(v,{tone:"signal",children:ks(c)}),e.jsxs(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N.summary.tripCount," trips"]}),e.jsxs(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[N.summary.stayCount," stays"]}),e.jsxs(v,{tone:"meta",children:[N.summary.missingCount," gaps"]})]})]}),e.jsx("div",{className:"grid gap-4",children:y.data?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Selected trip"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(A,{variant:"ghost",className:"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4",onClick:()=>P(i=>!i),children:j?"Stylized graph":"Exact path"})})]}),j?e.jsx(Ls,{points:y.data.trip.points}):e.jsx(Ds,{curve:y.data.stylizedPath.curve,startLabel:y.data.stylizedPath.startLabel,endLabel:y.data.stylizedPath.endLabel,stopLabels:y.data.stylizedPath.stops.map(i=>i.label)}),e.jsxs(k,{className:"rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Trip context"}),(()=>{const i=at(y.data.trip);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(v,{tone:"signal",children:ke(y.data.trip.distanceMeters)}),e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:y.data.trip.activityType||y.data.trip.travelMode}),e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:H(y.data.trip.durationSeconds)}),e.jsx(v,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:rt(i.rateApPerHour)}),e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:ea(i.totalAp)})]})})})(),e.jsx("div",{className:"mt-4 text-sm leading-6 text-[var(--ui-ink-muted)]",children:ws(y.data.trip.startedAt,y.data.trip.endedAt)}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Hourly estimate"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:H(y.data.trip.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:y.data.trip.pickupCount})]}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:y.data.trip.notificationCount})]})]}),e.jsx("div",{className:"mt-3 text-xs leading-5 text-[var(--ui-ink-muted)]",children:"Derived from Screen Time hourly bins, not exact foreground traces."}),y.data.trip.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:y.data.trip.topApps.map(i=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-info-soft)] text-[var(--ui-ink-medium)]",children:(i.displayName||i.bundleIdentifier)+" · "+H(i.totalActivitySeconds)},i.id))}):null,y.data.trip.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:y.data.trip.topCategories.map(i=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:i.categoryLabel},i.id))}):null]})]}):e.jsx(k,{className:"rounded-[30px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-6 text-[var(--ui-ink-muted)]",children:"Select a trip segment to open the stylized trajectory card and exact path toggle."})})]}):null,s==="month"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.85fr)]",children:[e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Month view"}),e.jsx(ce,{content:"This chart stays quantitative. Switch the metric to compare daily distance, moving time, idle time, or calories across the month."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"Switch the Y-axis between motion, idle time, and energy without losing the same monthly frame."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{type:"month",value:d,onChange:i=>u(i.target.value),className:"w-[10.5rem]"}),["distanceMeters","movingSeconds","idleSeconds","caloriesKcal"].map(i=>e.jsx(A,{variant:"ghost",className:w("h-9 rounded-full border px-4 text-sm",Me===i?"border-[var(--primary)] bg-[var(--primary)]/14 text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),onClick:()=>gt(i),children:i==="distanceMeters"?"Distance":i==="movingSeconds"?"Moving":i==="idleSeconds"?"Idle":"Calories"},i))]})]}),e.jsx("div",{className:"mt-6 h-[24rem]",children:e.jsx(br,{width:"100%",height:"100%",children:e.jsxs(yr,{data:be.days,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"movementMonthFill",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--info)",stopOpacity:.7}),e.jsx("stop",{offset:"100%",stopColor:"var(--info)",stopOpacity:.08})]})}),e.jsx(jr,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(Nr,{dataKey:"dateKey",tick:{fill:"var(--ui-ink-muted)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(kr,{tick:{fill:"var(--ui-ink-muted)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(wr,{contentStyle:{background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:16},itemStyle:{color:"var(--ui-ink-strong)"},labelStyle:{color:"var(--ui-ink-medium)"},formatter:i=>Ss(Me,Number(i))}),e.jsx(Sr,{type:"monotone",dataKey:Me,stroke:"var(--info)",fill:"url(#movementMonthFill)",strokeWidth:2.4})]})})})]}),e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Month totals"}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Distance"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:ke(be.totals.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Moving time"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:H(be.totals.movingSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Settled time"}),e.jsx("div",{className:"mt-2 text-2xl text-[var(--ui-ink-strong)]",children:H(be.totals.idleSeconds)})]})]})]})]}):null,s==="all_time"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(20rem,0.95fr)]",children:[e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(k,{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Trips"}),e.jsx("div",{className:"mt-2 text-3xl text-[var(--ui-ink-strong)]",children:oe.summary.tripCount})]}),e.jsxs(k,{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Known places"}),e.jsx("div",{className:"mt-2 text-3xl text-[var(--ui-ink-strong)]",children:oe.summary.knownPlaceCount})]}),e.jsxs(k,{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Distance"}),e.jsx("div",{className:"mt-2 text-3xl text-[var(--ui-ink-strong)]",children:ke(oe.summary.totalDistanceMeters)})]}),e.jsxs(k,{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Countries"}),e.jsx("div",{className:"mt-2 text-3xl text-[var(--ui-ink-strong)]",children:oe.summary.visitedCountries})]})]}),e.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:oe.recentTrips.map(i=>e.jsx("button",{type:"button",className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-3)]",onClick:()=>{l("day"),g(i.id)},children:(()=>{const f=at({startedAt:i.startedAt,endedAt:new Date(new Date(i.startedAt).getTime()+36e5).toISOString(),expectedMet:2});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Recent travel"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:i.label||"Untitled trip"}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-muted)]",children:[ke(i.distanceMeters)," · ",i.activityType||"travel"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(v,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:rt(f.rateApPerHour)})})]})})()},i.id))})]}),e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Place categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:oe.categoryBreakdown.map(i=>e.jsxs(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[i.tag," · ",i.count]},i.tag))})]})]}):null,e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(22rem,0.95fr)]",children:[e.jsx(gr,{children:e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Known places"}),e.jsx(ce,{content:"Known places turn raw stationary spans into named contexts like home, work, gym, nature, or any custom place tag you want Forge to remember."})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:"These landmarks anchor stays, travel XP, and contextual reasoning in both Forge and the companion. Seeded tags like home, workplace, gym, holiday, grocery, or nature matter for downstream calculations, but place tags stay open-ended."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{value:Se,onChange:i=>ht(i.target.value),placeholder:"Search places",className:"w-[11rem]"}),e.jsx(A,{onClick:()=>{Ye(null),_e(!0)},children:"Add place"})]})]}),e.jsx("div",{className:"mt-5 grid gap-3",children:ve.map(i=>e.jsxs("button",{type:"button",className:"flex items-start justify-between gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-left transition hover:bg-[var(--ui-surface-3)]",onClick:()=>{Ye(i),_e(!0)},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg text-[var(--ui-ink-strong)]",children:i.label}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-muted)]",children:[i.latitude.toFixed(4),", ",i.longitude.toFixed(4)," · radius ",Math.round(i.radiusMeters)," m"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.categoryTags.map(f=>e.jsx(v,{tone:"default",className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:f},f))})]}),e.jsx(It,{className:"mt-1 size-4 text-[var(--ui-ink-muted)]"})]},i.id))})]})}),e.jsxs(k,{className:"rounded-[30px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-[var(--ui-ink-muted)]",children:"Movement help"}),e.jsx(ce,{content:"Most movement surfaces on this page have help buttons. Use them to understand the graph, the day strip, the month chart, and the place system without keeping a large prose block on screen."})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-muted)]",children:"Use the small help icons across this page for graph explanations, timeline semantics, and metric meanings."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Life graph"}),e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Day strip"}),e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Month chart"}),e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Known places"}),e.jsx(v,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:"Selection aggregate"})]})]})]}),y.data?e.jsx(wa,{open:U,onOpenChange:i=>{b(i),i||(E(""),Z([]),J(null),ee(null))},eyebrow:"Movement data",title:y.data.trip.label||"Trip datapoints",description:"Inspect the raw datapoints behind this trip. Raw measurements are read-only here; visible movement corrections now happen through canonical user-defined boxes.",children:e.jsx(fr,{children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,24rem)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ma,{title:"Datapoint browser",description:"Search raw points by time band, anchor status, or accuracy before opening the point editor.",query:C,onQueryChange:E,options:Je,selectedOptionIds:K,onSelectedOptionIdsChange:Z,resultSummary:Oe,placeholder:"Search timestamps, accuracy, point ids, or filter chips",emptyStateMessage:"Keep typing or pick a time/quality chip to narrow the trip datapoints."}),e.jsxs(k,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-muted)]",children:"Raw datapoints"}),e.jsx("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:"Open a point to correct or delete it."})]}),e.jsx(v,{tone:"meta",children:Oe})]}),e.jsx("div",{ref:ze,className:"h-[34rem] overflow-y-auto rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",children:O.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-[var(--ui-ink-muted)]",children:"No datapoint matches the current search. Clear some filters or search by time, anchor type, or accuracy."}):e.jsx("div",{className:"relative w-full",style:{height:`${Ae.getTotalSize()}px`},children:Ae.getVirtualItems().map(i=>{const f=O[i.index];return e.jsx("div",{className:"absolute left-0 top-0 w-full px-3 py-2",style:{transform:`translateY(${i.start}px)`},children:e.jsxs("button",{type:"button",className:w("grid w-full gap-3 rounded-[20px] border px-4 py-3 text-left transition",z===f.id?"border-[color-mix(in_srgb,var(--info)_34%,transparent)] bg-[var(--ui-info-soft)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] hover:bg-[var(--ui-surface-3)]"),onClick:()=>{J(f.id),ee(ha(f))},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(Xa,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:Rt(f.recordedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-[var(--ui-ink-muted)]",children:[f.latitude.toFixed(5),", ",f.longitude.toFixed(5)]})]}),e.jsx(v,{tone:f.isStopAnchor?"signal":"meta",children:f.isStopAnchor?"Stop anchor":"Path point"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{tone:"meta",className:"capitalize",children:pt(f.recordedAt)}),f.accuracyMeters!=null?e.jsxs(v,{tone:"meta",children:[Math.round(f.accuracyMeters)," m accuracy"]}):null,f.speedMps!=null?e.jsxs(v,{tone:"meta",children:[f.speedMps.toFixed(1)," m/s"]}):null]})]})},f.id)})})})]})]}),D&&G?e.jsx($s,{point:D,draft:G}):e.jsx(k,{className:"rounded-[28px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-6 text-[var(--ui-ink-muted)]",children:"Pick a datapoint to inspect its raw measurement details. To correct what the user sees, use canonical user-defined movement boxes in the Life Timeline."})]})})}):null,e.jsx(Aa,{open:Ee,onOpenChange:_e,place:Re,onSave:async i=>{await Ze.mutateAsync(i)}})]})}export{Vs as MovementPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as r,r as w}from"./vendor-
|
|
1
|
+
import{j as r,r as w}from"./vendor-Cpmju3nw.js";import{c as x,c8 as b,a_ as $}from"./index-BejvcRGb.js";function m(d,s){const i=[],e=/(!?\[\[([^\]]+)\]\]|\[([^\]]+)\]\(([^)]+)\)|`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*)/g;let l=0,n=null,a=0;for(;(n=e.exec(d))!==null;){if(n.index>l&&(i.push(r.jsx(w.Fragment,{children:d.slice(l,n.index)},`${s}-text-${a}`)),a+=1),n[1]&&n[2]){const o=n[2].trim(),t=n[1].startsWith("!"),c=o.indexOf("|"),h=c>=0?o.slice(0,c).trim():o,p=c>=0?o.slice(c+1).trim():h;if(h.toLowerCase().startsWith("forge:")){const[,u,g]=h.split(":"),f=u&&g?$(u,g):null,v=f?b(f):null;i.push(v?r.jsxs("a",{href:v,className:"inline-flex max-w-full items-center gap-1 rounded-full border border-[var(--warning)]/20 bg-[var(--ui-warning-soft)] px-2 py-0.5 text-[0.9em] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)] transition hover:bg-[var(--ui-surface-3)]",children:[r.jsx("span",{className:"shrink-0 text-[0.72em] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Forge"}),r.jsx("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:p})]},`${s}-forge-${a}`):r.jsx("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-[var(--ui-surface-2)] px-2 py-0.5 text-[0.9em] text-[var(--ui-ink-soft)]",children:r.jsx("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:p})},`${s}-forge-${a}`))}else{const u=b(`/wiki/page/${encodeURIComponent(h)}`);i.push(r.jsxs("a",{href:u,className:x("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[0.9em] transition",t?"border border-[var(--info)]/20 bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)] hover:bg-[var(--ui-surface-3)]":"bg-[var(--ui-surface-2)] text-[var(--secondary)] hover:bg-[var(--ui-surface-3)]"),children:[t?r.jsx("span",{className:"shrink-0 text-[0.72em] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Embed"}):null,r.jsx("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:p})]},`${s}-wiki-${a}`))}}else if(n[3]&&n[4]){const o=n[4].trim(),t=/^https?:\/\//i.test(o);i.push(r.jsx("a",{href:o,className:"break-words text-[var(--secondary)] underline decoration-current/35 underline-offset-4 transition hover:text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",target:t?"_blank":void 0,rel:t?"noreferrer":void 0,children:n[3]},`${s}-link-${a}`))}else n[5]?i.push(r.jsx("code",{className:"rounded bg-[var(--ui-surface-2)] px-1.5 py-0.5 text-[0.92em] text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:n[5]},`${s}-code-${a}`)):n[6]?i.push(r.jsx("strong",{className:"font-semibold text-[var(--ui-ink-strong)]",children:n[6]},`${s}-strong-${a}`)):n[7]&&i.push(r.jsx("em",{className:"italic text-[var(--ui-ink-medium)]",children:n[7]},`${s}-em-${a}`));l=e.lastIndex,a+=1}return l<d.length&&i.push(r.jsx(w.Fragment,{children:d.slice(l)},`${s}-tail-${a}`)),i}function j(d){const s=d.replace(/\r/g,"").split(`
|
|
2
2
|
`),i=[];let e=0;for(;e<s.length;){const l=s[e]??"",n=l.trim();if(!n){e+=1;continue}if(n.startsWith("```")){const t=[];for(e+=1;e<s.length&&!(s[e]??"").trim().startsWith("```");)t.push(s[e]??""),e+=1;e+=1,i.push(r.jsx("pre",{className:"max-w-full overflow-x-auto rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-xs leading-6 text-[var(--ui-ink-strong)]",children:r.jsx("code",{className:"block min-w-0 whitespace-pre",children:t.join(`
|
|
3
3
|
`)})},`code-${e}`));continue}const a=l.match(/^(#{1,6})\s+(.*)$/);if(a){const t=a[1].length,c=t===1?"text-xl":t===2?"text-lg":t===3?"text-base":"text-sm";i.push(r.jsx("div",{className:x("font-semibold text-[var(--ui-ink-strong)]",c),children:m(a[2],`heading-${e}`)},`heading-${e}`)),e+=1;continue}if(/^>\s?/.test(l)){const t=[];for(;e<s.length&&/^>\s?/.test(s[e]??"");)t.push((s[e]??"").replace(/^>\s?/,"")),e+=1;i.push(r.jsx("blockquote",{className:"border-l-2 border-[var(--secondary)]/50 pl-4 text-sm leading-7 text-[var(--ui-ink-soft)]",children:m(t.join(" "),`quote-${e}`)},`quote-${e}`));continue}if(/^[-*+]\s+/.test(l)||/^\d+\.\s+/.test(l)){const t=/^\d+\.\s+/.test(l),c=[];for(;e<s.length&&(/^[-*+]\s+/.test(s[e]??"")||/^\d+\.\s+/.test(s[e]??""));)c.push((s[e]??"").replace(/^[-*+]\s+/,"").replace(/^\d+\.\s+/,"")),e+=1;const h=t?"ol":"ul";i.push(r.jsx(h,{className:x("space-y-1 pl-5 text-sm leading-7 text-[var(--ui-ink-soft)]",t?"list-decimal":"list-disc"),children:c.map((p,u)=>r.jsx("li",{children:m(p,`list-${e}-${u}`)},`item-${e}-${u}`))},`list-${e}`));continue}const o=[];for(;e<s.length;){const t=s[e]??"";if(!t.trim()||t.trim().startsWith("```")||/^#{1,6}\s+/.test(t)||/^>\s?/.test(t)||/^[-*+]\s+/.test(t)||/^\d+\.\s+/.test(t))break;o.push(t.trim()),e+=1}i.push(r.jsx("p",{className:"text-sm leading-7 text-[var(--ui-ink-soft)]",children:m(o.join(" "),`paragraph-${e}`)},`paragraph-${e}`))}return i}function y({markdown:d,className:s}){return r.jsx("div",{className:x("grid gap-3",s),children:j(d)})}export{y as N};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as i}from"./vendor-Cpmju3nw.js";import{k as s}from"./index-BejvcRGb.js";import{E as c}from"./entity-link-multiselect-wuyJ8BbW.js";const m=[{value:"Working memory",label:"Working memory",description:"What you are actively working on right now."},{value:"Short-term memory",label:"Short-term memory",description:"What just happened and still needs near-term recall."},{value:"Episodic memory",label:"Episodic memory",description:"Long-term recall for what happened or what you did."},{value:"Semantic memory",label:"Semantic memory",description:"Long-term knowledge about what something is."},{value:"Procedural memory",label:"Procedural memory",description:"Long-term know-how and repeatable how-to knowledge."}];function l(o){const r=new Set;return o.map(t=>t.trim()).filter(Boolean).filter(t=>{const a=t.toLowerCase();return r.has(a)?!1:(r.add(a),!0)})}function f(o){const r=o.trim();if(!r)return null;const t=new Date(r);return Number.isNaN(t.getTime())?null:t.toISOString()}function v(o){if(!o)return"";const r=new Date(o);if(Number.isNaN(r.getTime()))return"";const t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),e=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),n=String(r.getMinutes()).padStart(2,"0");return`${t}-${a}-${e}T${u}:${n}`}function h(o,r){const t=Number(o);if(!Number.isFinite(t)||t<=0)return null;const a=r==="hours"?3600*1e3:1440*60*1e3;return new Date(Date.now()+t*a).toISOString()}function d(o){const r=new Set(m.map(e=>e.value.toLowerCase())),t=m.map(e=>({value:e.value,label:e.label,description:e.description,searchText:`${e.label} ${e.description}`,badge:i.jsx(s,{className:"border border-[color-mix(in_srgb,var(--info)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",children:e.label}),menuBadge:i.jsx(s,{className:"border border-[color-mix(in_srgb,var(--info)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",children:e.label})})),a=l(o).filter(e=>!r.has(e.toLowerCase())).map(e=>({value:e,label:e,description:"Custom note tag",searchText:e,badge:i.jsx(s,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:e}),menuBadge:i.jsx(s,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:e})}));return[...t,...a]}function x({value:o,onChange:r,availableTags:t=[],placeholder:a="Add a memory tag or create a custom tag"}){const e=d([...t,...o]);return i.jsx(c,{options:e,selectedValues:l(o),onChange:u=>r(l(u)),placeholder:a,emptyMessage:"No note tags yet.",createLabel:"Add custom tag",onCreate:async u=>{const n=u.trim();return{value:n,label:n,description:"Custom note tag",searchText:n,badge:i.jsx(s,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:n}),menuBadge:i.jsx(s,{className:"border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:n})}}})}export{x as N,h as b,v as f,l as n,f as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as i}from"./vendor-Cpmju3nw.js";import{c as a,a as t,b as c,d as m,e as p,f as l,g as u,j as f,m as d}from"./generic-node-view-COhU_Wm3.js";import{d as n}from"./define-workbench-box-DkffygDU.js";function s({children:e}){return i.jsx(i.Fragment,{children:e})}const o=m({itemKind:"note",itemLabel:"Note",defaultEntityTypes:["note"],defaultLimit:20}),r=p(),x=n(s,{id:"surface:notes-index:filters",surfaceId:"notes-index",routePath:"/notes",title:"Note filters",icon:"filter",description:"Entity, tag, text, author, and date filters for notes.",category:"Notes",tags:["notes","filters","search"],inputs:o,params:r,output:[t({label:"Filter summary",description:"Summary of the current note filters and search scope."})],tools:[u("Search Forge entities by query and entity types.")],NodeView:a({title:"Note filters",description:"Entity, tag, text, author, and date filters for notes.",inputs:o,params:r,output:[t({label:"Filter summary",description:"Summary of the current note filters and search scope."})],tools:[u("Search Forge entities by query and entity types.")]}),execute:e=>l(e,{query:"",entityTypes:["note"],limit:20})}),N=n(s,{id:"surface:notes-index:composer",surfaceId:"notes-index",routePath:"/notes",title:"Note composer",icon:"write",description:"Markdown note composer with links, tags, and capture actions.",category:"Notes",tags:["notes","composer","capture"],inputs:o,params:r,output:[t({label:"Draft summary",description:"Summary of the current note drafting surface."})],tools:[d("Create an evidence note from markdown content.")],NodeView:a({title:"Note composer",description:"Markdown note composer with links, tags, and capture actions.",inputs:o,params:r,output:[t({label:"Draft summary",description:"Summary of the current note drafting surface."})],tools:[d("Create an evidence note from markdown content.")]}),execute:e=>f(e,{draftable:!0},"This node can draft or create a note.")}),g=n(s,{id:"surface:notes-index:library",surfaceId:"notes-index",routePath:"/notes",title:"Notes library",icon:"library",description:"Filtered library of Forge notes and linked evidence.",category:"Notes",tags:["notes","library","history"],inputs:[],params:[],output:c({itemKind:"note",itemLabel:"Note"}),tools:[],NodeView:a({title:"Notes library",description:"Filtered library of Forge notes and linked evidence.",inputs:[],params:[],output:c({itemKind:"note",itemLabel:"Note"}),tools:[]}),execute:e=>l(e,{query:"",entityTypes:["note"],limit:20})});export{x as N,N as a,g as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as m,j as e,aK as Ae,cp as Ce,b7 as Qe,b6 as Re,bY as ze,b3 as He,c8 as Ye,c1 as Xe,bX as Ge,c4 as Je}from"./vendor-Cpmju3nw.js";import{j as We,i as F,k as ie}from"./state-BtwEvpO6.js";import{E as Fe}from"./entity-link-multiselect-wuyJ8BbW.js";import{b as De,k as z,c as Ze,d as et,g as f,aY as J,aZ as _e,a_ as Ie,e as tt,B as Q,C as _,n as P,m as at,I as D,T as Le,h as st,a$ as it,b0 as nt,b1 as rt,aa as ot,b2 as lt,i as dt,b3 as ct,b4 as ut,b5 as mt,b6 as pt,b7 as xt,b8 as ht,b9 as gt,O as vt,ba as yt}from"./index-BejvcRGb.js";import{N as ne}from"./note-markdown-Byd_vNkS.js";import{N as re,n as Z,f as ft,p as bt,b as kt}from"./note-tags-input-DYAFDq8Q.js";import{P as jt}from"./page-hero-DlHEJ0Yt.js";import{N as Nt,a as wt,b as Tt}from"./notes-boxes-CPiPps1e.js";import{F as St}from"./floating-action-menu-GCeuOdYZ.js";import{b,d as k}from"./user-ownership-DJGl4rAj.js";import"./use-anchored-overlay-position-BrQ4cqKn.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";import"./generic-node-view-COhU_Wm3.js";import"./graph-Cd5WF3lw.js";import"./define-workbench-box-DkffygDU.js";function Mt(i){return i.trim().toLowerCase()}function At(i,o){return i.includes(o)?i:[...i,o]}function Ct({entityOptions:i,selectedEntityValues:o,onSelectedEntityValuesChange:d,selectedTextTerms:u,onSelectedTextTermsChange:I,placeholder:j="Filter by linked entity or add free text"}){const[S,M]=m.useState(""),[ee,g]=m.useState(!1),[H,v]=m.useState(0),B=Mt(S),A=m.useMemo(()=>o.map(s=>i.find(c=>c.value===s)).filter(Boolean),[i,o]),L=m.useMemo(()=>{const s=i.filter(c=>!o.includes(c.value));return B?s.filter(c=>`${c.label} ${c.description??""} ${c.searchText??""}`.toLowerCase().includes(B)).slice(0,8):s.slice(0,8)},[i,B,o]),N=S.trim().length>0&&!u.includes(S.trim()),Y=s=>{d(At(o,s)),M(""),v(0),g(!1)},K=(s=S)=>{const c=s.trim();!c||u.includes(c)||(I([...u,c]),M(""),v(0),g(!1))},$=s=>{d(o.filter(c=>c!==s))},p=s=>{I(u.filter(c=>c!==s))};return e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-muted)]",children:[e.jsx("span",{children:"Search hints: entity chips match linked records, free-text chips match note body or author."}),e.jsx("button",{type:"button",onClick:()=>K(),disabled:!N,className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] tracking-[0.14em] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] disabled:cursor-not-allowed disabled:opacity-40",children:"Free text"})]}),e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] px-4 py-3 shadow-[var(--ui-shadow-floating)]",children:[A.length>0||u.length>0?e.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[A.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1.5",children:[s.kind?e.jsx(De,{kind:s.kind,label:s.label,compact:!0,gradient:!1,className:"max-w-[16rem]"}):e.jsx(z,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:s.label}),e.jsx("button",{type:"button",className:"rounded-full text-[var(--ui-ink-muted)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>$(s.value),"aria-label":`Remove ${s.label}`,children:e.jsx(Ae,{className:"size-3.5"})})]},s.value)),u.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-[color-mix(in_srgb,var(--info)_24%,transparent)] bg-[var(--ui-info-soft)] px-2.5 py-1.5 text-sm text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ce,{className:"size-3.5"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:s})]}),e.jsx("button",{type:"button",className:"rounded-full text-[color-mix(in_srgb,var(--info)_70%,var(--ui-ink-strong)_30%)] transition hover:text-[var(--ui-ink-strong)]",onClick:()=>p(s),"aria-label":`Remove free-text filter ${s}`,children:e.jsx(Ae,{className:"size-3.5"})})]},s))]}):null,u.length>1?e.jsx("div",{className:"mb-3 text-xs text-[var(--ui-ink-muted)]",children:"Free-text chips are combined with OR."}):null,e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qe,{className:"size-4 text-[var(--ui-ink-muted)]"}),e.jsx("input",{value:S,onChange:s=>{M(s.target.value),g(!0),v(0)},onFocus:()=>g(!0),onBlur:()=>{window.setTimeout(()=>g(!1),120)},onKeyDown:s=>{if(s.key==="Backspace"&&!S){if(u.length>0){p(u[u.length-1]);return}o.length>0&&$(o[o.length-1]);return}if(s.key==="ArrowDown"){s.preventDefault(),g(!0),v(w=>L.length===0?0:Math.min(L.length-1,w+1));return}if(s.key==="ArrowUp"){s.preventDefault(),v(w=>Math.max(0,w-1));return}if(s.key==="Escape"){g(!1);return}if(s.key!=="Enter")return;s.preventDefault();const c=L[H];if(c){Y(c.value);return}K()},placeholder:j,className:"min-w-0 flex-1 bg-transparent text-sm text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-muted)] focus:outline-none"})]}),ee?e.jsxs("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-2 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[L.map((s,c)=>e.jsx("button",{type:"button",className:Ze("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",c===H?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>v(c),onMouseDown:w=>w.preventDefault(),onClick:()=>Y(s.value),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.kind?e.jsx(De,{kind:s.kind,label:s.label,compact:!0,gradient:!1}):s.label}),s.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-muted)]",children:s.description}):null]})},s.value)),N?e.jsxs("button",{type:"button",className:"mt-1 flex w-full items-center gap-2 rounded-[18px] px-3 py-2.5 text-left text-sm text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)] transition hover:bg-[var(--ui-surface-2)]",onMouseDown:s=>s.preventDefault(),onClick:()=>K(),children:[e.jsx(Ce,{className:"size-4"}),e.jsxs("span",{className:"truncate",children:['Add free text "',S.trim(),'"']})]}):null,L.length===0&&!N?e.jsx("div",{className:"px-3 py-2.5 text-sm text-[var(--ui-ink-muted)]",children:"Keep typing to find a linked entity, or press Enter to add a free-text badge."}):null]}):null]})]})]})}const Ft=new Set(["goal","project","task","strategy","habit","tag","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","flashcard","trigger_report"]);function Pe(i){return Ft.has(i)}function x(i,o){return`${i}:${o}`}function W(i){const o=i.indexOf(":");if(o<=0||o>=i.length-1)return null;const d=i.slice(0,o);return Pe(d)?{entityType:d,entityId:i.slice(o+1)}:null}function Ee(i){return i!==null}function $e(i){const o=i.getAll("linkedTo"),d=i.get("entityType"),u=i.get("entityId");return d&&u&&Pe(d)&&o.unshift(x(d,u)),Array.from(new Set(o.map(I=>I.trim()).filter(Boolean)))}function Dt(i){return Array.from(new Set(i.getAll("textTerms").map(o=>o.trim()).filter(Boolean)))}function _t(i){return Z(i.getAll("tags"))}function R(i,o=[]){return{contentMarkdown:(i==null?void 0:i.contentMarkdown)??"",author:(i==null?void 0:i.author)??"",linkedValues:(i==null?void 0:i.links.map(d=>x(d.entityType,d.entityId)))??o,tags:Z((i==null?void 0:i.tags)??[]),destroyAtInput:ft((i==null?void 0:i.destroyAt)??null),destroyDelayValue:"",destroyDelayUnit:"days"}}function It(i){return[...i].sort((o,d)=>o.label.localeCompare(d.label))}function qe(i){return bt(i.destroyAtInput)??kt(i.destroyDelayValue,i.destroyDelayUnit)}function Zt(){var ye,fe,be,ke,je,Ne,we,Te;const i=Re(),o=We(),d=et(),[u,I]=ze(),[j,S]=m.useState(()=>$e(u)),[M,ee]=m.useState(()=>_t(u)),[g,H]=m.useState(()=>Dt(u)),[v,B]=m.useState(u.get("author")??""),[A,L]=m.useState(u.get("updatedFrom")??""),[N,Y]=m.useState(u.get("updatedTo")??""),[K,$]=m.useState(!1),[p,s]=m.useState(()=>R(null,$e(u))),[c,w]=m.useState(null),[y,T]=m.useState(null),[q,oe]=m.useState(null),le=F({queryKey:["forge-psyche-values"],queryFn:ct}),de=F({queryKey:["forge-psyche-patterns"],queryFn:ut}),ce=F({queryKey:["forge-psyche-behaviors"],queryFn:mt}),ue=F({queryKey:["forge-psyche-beliefs"],queryFn:pt}),me=F({queryKey:["forge-psyche-modes"],queryFn:xt}),pe=F({queryKey:["forge-psyche-flashcards"],queryFn:ht}),xe=F({queryKey:["forge-psyche-reports"],queryFn:gt}),he=Array.isArray(d.selectedUserIds)?d.selectedUserIds:[],U=F({queryKey:["forge-life-force",...he],queryFn:async()=>(await vt(he)).lifeForce});m.useEffect(()=>{const a=new URLSearchParams;for(const n of j)a.append("linkedTo",n);for(const n of M)a.append("tags",n);for(const n of g)a.append("textTerms",n);v.trim()&&a.set("author",v.trim()),A&&a.set("updatedFrom",A),N&&a.set("updatedTo",N),I(a,{replace:!0})},[v,j,M,g,I,A,N]);const X=m.useMemo(()=>{var n,h,G,l,r,Se,Me;const a=[...d.snapshot.goals.map(t=>({value:x("goal",t.id),label:t.title,description:k(t.description,t.user,"Goal"),searchText:b([t.title,t.description],t),kind:f("goal")??void 0})),...d.snapshot.dashboard.projects.map(t=>({value:x("project",t.id),label:t.title,description:k(`${t.description}${t.description?" · ":""}${t.goalTitle}`,t.user,t.goalTitle),searchText:b([t.title,t.description,t.goalTitle],t),kind:f("project")??void 0})),...d.snapshot.tasks.map(t=>({value:x("task",t.id),label:t.title,description:k(`${t.description}${t.description?" · ":""}${t.owner}`,t.user,t.owner),searchText:b([t.title,t.description,t.owner],t),kind:f("task")??void 0})),...d.snapshot.strategies.map(t=>({value:x("strategy",t.id),label:t.title,description:k(t.overview,t.user,"Strategy"),searchText:b([t.title,t.overview,t.endStateDescription],t),kind:f("strategy")??void 0})),...d.snapshot.habits.map(t=>({value:x("habit",t.id),label:t.title,description:k(t.description,t.user,"Habit"),searchText:b([t.title,t.description],t),kind:f("habit")??void 0})),...d.snapshot.tags.map(t=>({value:x("tag",t.id),label:t.name,description:k(t.description,t.user,t.kind),searchText:b([t.name,t.kind,t.description],t),kind:f("tag")??void 0})),...(((n=le.data)==null?void 0:n.values)??[]).map(t=>({value:x("psyche_value",t.id),label:t.title,description:k(t.description,t.user,"Psyche value"),searchText:b([t.title,t.description,t.valuedDirection],t),kind:f("psyche_value")??void 0})),...(((h=de.data)==null?void 0:h.patterns)??[]).map(t=>({value:x("behavior_pattern",t.id),label:t.title,description:k(t.description,t.user,"Behavior pattern"),searchText:b([t.title,t.description,t.targetBehavior],t),kind:f("behavior_pattern")??void 0})),...(((G=ce.data)==null?void 0:G.behaviors)??[]).map(t=>({value:x("behavior",t.id),label:t.title,description:k(t.description,t.user,"Behavior"),searchText:b([t.title,t.description,t.kind],t),kind:f("behavior")??void 0})),...(((l=ue.data)==null?void 0:l.beliefs)??[]).map(t=>({value:x("belief_entry",t.id),label:t.statement,description:k(t.flexibleAlternative||t.originNote,t.user,"Belief"),searchText:b([t.statement,t.flexibleAlternative,t.originNote],t),kind:f("belief_entry")??void 0})),...(((r=me.data)==null?void 0:r.modes)??[]).map(t=>({value:x("mode_profile",t.id),label:t.title,description:k(t.archetype||t.family,t.user,"Mode"),searchText:b([t.title,t.archetype,t.family,t.persona],t),kind:f("mode_profile")??void 0})),...(((Se=pe.data)==null?void 0:Se.flashcards)??[]).map(t=>({value:x("flashcard",t.id),label:t.title||t.message,description:k(t.triggerSentence||t.triggerSituation,t.user,"Flashcard"),searchText:b([t.title,t.message,t.triggerSentence,t.triggerSituation,...t.tags],t),kind:f("flashcard")??void 0})),...(((Me=xe.data)==null?void 0:Me.reports)??[]).map(t=>({value:x("trigger_report",t.id),label:t.title,description:k(t.eventSituation,t.user,"Trigger report"),searchText:b([t.title,t.eventSituation,t.customEventType??""],t),kind:f("trigger_report")??void 0}))];return It(a)},[(ye=ce.data)==null?void 0:ye.behaviors,(fe=ue.data)==null?void 0:fe.beliefs,(be=pe.data)==null?void 0:be.flashcards,(ke=me.data)==null?void 0:ke.modes,(je=de.data)==null?void 0:je.patterns,(Ne=xe.data)==null?void 0:Ne.reports,d.snapshot.dashboard.projects,d.snapshot.goals,d.snapshot.habits,d.snapshot.strategies,d.snapshot.tags,d.snapshot.tasks,(we=le.data)==null?void 0:we.values]),Be=m.useMemo(()=>X.map(a=>{const n=W(a.value);return{value:a.value,label:a.label,description:a.description,searchText:a.searchText,kind:a.kind,entityType:(n==null?void 0:n.entityType)??"goal",entityId:(n==null?void 0:n.entityId)??""}}),[X]),Ke=m.useMemo(()=>j.map(a=>W(a)).filter(Boolean),[j]),O=F({queryKey:["notes-index",j.join("|"),M.join("|"),g.join("|"),v.trim(),A,N],queryFn:()=>yt({linkedTo:Ke,tags:M,textTerms:g,author:v.trim()||void 0,updatedFrom:A||void 0,updatedTo:N||void 0,limit:200})}),te=async()=>{await Promise.all([o.invalidateQueries({queryKey:["notes-index"]}),dt(o)])},ge=ie({mutationFn:async a=>ot({contentMarkdown:a.contentMarkdown.trim(),author:a.author.trim()||null,tags:Z(a.tags),destroyAt:qe(a),links:a.linkedValues.map(n=>W(n)).filter(Ee).map(n=>({entityType:n.entityType,entityId:n.entityId}))}),onSuccess:async()=>{s(R(null,j)),$(!1),await te()}}),ve=ie({mutationFn:async({noteId:a,draft:n})=>lt(a,{contentMarkdown:n.contentMarkdown.trim(),author:n.author.trim()||null,tags:Z(n.tags),destroyAt:qe(n),links:n.linkedValues.map(h=>W(h)).filter(Ee).map(h=>({entityType:h.entityType,entityId:h.entityId}))}),onSuccess:async()=>{w(null),T(null),await te()}}),ae=ie({mutationFn:a=>rt(a),onSuccess:te}),V=((Te=O.data)==null?void 0:Te.notes)??[],Ue=new Date().toISOString().slice(0,10),Oe=V.filter(a=>a.createdAt.slice(0,10)===Ue).length*J().totalAp,C=q?V.find(a=>a.id===q.noteId)??null:null,se=C?_e(C):null,E=se?Ie(se.entityType,se.entityId):null,Ve=m.useMemo(()=>C?[{id:"open-linked",label:"Open linked record",description:E?"Jump back into the main entity this note is attached to.":"This note has no navigable linked record yet.",icon:He,disabled:!E,onSelect:()=>{E&&i(E.includes("#")?E:`${E}#notes`)}},{id:"edit-note",label:"Edit note",description:"Update the Markdown body, note tags, expiry, or connected entity links.",icon:Ye,onSelect:()=>{w(C.id),T(R(C))}},{id:"delete-note",label:"Delete note",description:"Soft-delete this note from the main workspace.",icon:Xe,tone:"danger",disabled:ae.isPending,onSelect:()=>{ae.mutateAsync(C.id)}}]:[],[E,C,ae,i]);return O.isError?e.jsx(tt,{eyebrow:"Notes",error:O.error,onRetry:()=>void O.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(jt,{title:"Notes",titleText:"Notes",description:"Notes are first-class Markdown entities in Forge. Search them by linked records, note tags, date, or free text, then create durable or ephemeral notes that stay connected to the rest of the graph.",badge:`${V.length} visible`,actions:e.jsxs(Q,{onClick:()=>{s(R(null,j)),$(!0)},children:[e.jsx(Ge,{className:"size-4"}),"New note"]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(_,{className:"border-[var(--primary)]/16 shadow-[var(--card-shadow)]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Quick note default"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:P(J().totalAp)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Standalone notes count as a tiny Action Point impulse unless a richer active work context already covers them."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Notes created today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:P(Oe)}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Visible notes created today in this workspace at the default quick note cost."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Life Force sync"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U.data?`${P(U.data.spentTodayAp)} / ${P(U.data.dailyBudgetAp)}`:"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Notes participate in the same Action Point ledger as tasks, habits, movement, and calendar work."})]}),e.jsxs(_,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Instant headroom"}),e.jsx("div",{className:"mt-3 text-2xl font-display text-[var(--ui-ink-strong)]",children:U.data?at(U.data.instantFreeApPerHour):"Loading..."}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-soft)]",children:"Useful when deciding whether to just capture a quick note or stay inside a heavier work stream."})]})]}),e.jsx(Nt,{children:e.jsxs(_,{className:"grid gap-4",children:[e.jsx(Ct,{entityOptions:Be,selectedEntityValues:j,onSelectedEntityValuesChange:S,selectedTextTerms:g,onSelectedTextTermsChange:H}),e.jsx(re,{value:M,onChange:ee,placeholder:"Filter by memory tag or custom note tag"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(12rem,0.38fr)_minmax(12rem,0.38fr)]",children:[e.jsx(D,{value:v,onChange:a=>B(a.target.value),placeholder:"Filter by author"}),e.jsx(D,{type:"date",value:A,onChange:a=>L(a.target.value)}),e.jsx(D,{type:"date",value:N,onChange:a=>Y(a.target.value)})]})]})}),K?e.jsx(wt,{children:e.jsxs(_,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"New note"}),e.jsxs("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Notes are independent Markdown entities. Link them to one or more real records, add memory-system or custom tags, and optionally make them ephemeral with an automatic destroy time. Standalone notes default to"," ",P(J().totalAp),"."]})]}),e.jsx(Q,{variant:"ghost",onClick:()=>{$(!1),s(R(null,j))},children:"Cancel"})]}),e.jsx(Le,{value:p.contentMarkdown,onChange:a=>s(n=>({...n,contentMarkdown:a.target.value})),className:"min-h-[16rem]",placeholder:"Write the note in Markdown. This can be as short as a handoff line or as long as a wiki page."}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[e.jsx(D,{value:p.author,onChange:a=>s(n=>({...n,author:a.target.value})),placeholder:"Optional author"}),e.jsx(Fe,{options:X,selectedValues:p.linkedValues,onChange:a=>s(n=>({...n,linkedValues:a})),placeholder:"Link this note to strategies, goals, projects, tasks, habits, or human/bot-owned records",emptyMessage:"No matching entities found yet."})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(re,{value:p.tags,onChange:a=>s(n=>({...n,tags:a}))}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Ephemeral auto-destroy"}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(D,{type:"datetime-local",value:p.destroyAtInput,onChange:a=>s(n=>({...n,destroyAtInput:a.target.value}))}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(D,{type:"number",min:"1",value:p.destroyDelayValue,onChange:a=>s(n=>({...n,destroyDelayValue:a.target.value})),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)]",value:p.destroyDelayUnit,onChange:a=>s(n=>({...n,destroyDelayUnit:a.target.value})),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:p.contentMarkdown.trim()?e.jsx(ne,{markdown:p.contentMarkdown}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"Markdown preview appears here."})})]}),e.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:e.jsx(Q,{pending:ge.isPending,pendingLabel:"Saving",disabled:p.contentMarkdown.trim().length===0||p.linkedValues.length===0,onClick:()=>void ge.mutateAsync(p),children:"Save note"})})]})}):null,O.isLoading?e.jsx(_,{className:"text-sm text-[var(--ui-ink-soft)]",children:"Loading notes…"}):V.length===0?e.jsx(st,{eyebrow:"Notes",title:"No matching notes yet",description:"Try broader linked-entity filters, remove a date bound, or add the first durable note from the button above."}):e.jsx(Tt,{children:e.jsx("div",{className:"grid gap-3",children:V.map(a=>{const n=_e(a),h=n?Ie(n.entityType,n.entityId):null,G=c===a.id&&y!==null;return e.jsxs(_,{className:"min-w-0 overflow-hidden p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[(a.author??"Unknown author").toString()," •"," ",new Date(a.updatedAt).toLocaleString()]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(z,{className:"bg-[var(--primary)]/12 text-[var(--primary)]",wrap:!0,children:[P(J().totalAp)," ","quick note"]}),a.links.map(l=>e.jsxs(z,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",wrap:!0,children:[it(l.entityType),l.anchorKey?` · ${nt(l.anchorKey)}`:""]},`${a.id}-${l.entityType}-${l.entityId}-${l.anchorKey??""}`)),(a.tags??[]).map(l=>e.jsx(z,{className:"border-[var(--info)]/20 bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:l},`${a.id}-tag-${l}`)),a.destroyAt?e.jsxs(z,{className:"border-[var(--warning)]/20 bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:["Ephemeral · deletes"," ",new Date(a.destroyAt).toLocaleString()]}):null]})]}),e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",onClick:l=>{l.preventDefault(),l.stopPropagation();const r=l.currentTarget.getBoundingClientRect();oe({noteId:a.id,position:{x:r.right-8,y:r.bottom+8}})},"aria-label":`Open actions for note ${a.id}`,children:e.jsx(Je,{className:"size-4"})})]}),G?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(Le,{value:y.contentMarkdown,onChange:l=>T(r=>r&&{...r,contentMarkdown:l.target.value}),className:"min-h-[14rem]"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]",children:[e.jsx(D,{value:y.author,onChange:l=>T(r=>r&&{...r,author:l.target.value}),placeholder:"Optional author"}),e.jsx(Fe,{options:X,selectedValues:y.linkedValues,onChange:l=>T(r=>r&&{...r,linkedValues:l}),placeholder:"Update the linked entities",emptyMessage:"No matching entities found yet."})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(re,{value:y.tags,onChange:l=>T(r=>r&&{...r,tags:l})}),e.jsxs("div",{className:"grid gap-3 rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Ephemeral auto-destroy"}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-[var(--ui-ink-soft)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(D,{type:"datetime-local",value:y.destroyAtInput,onChange:l=>T(r=>r&&{...r,destroyAtInput:l.target.value})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(D,{type:"number",min:"1",value:y.destroyDelayValue,onChange:l=>T(r=>r&&{...r,destroyDelayValue:l.target.value}),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-sm text-[var(--ui-ink-strong)]",value:y.destroyDelayUnit,onChange:l=>T(r=>r&&{...r,destroyDelayUnit:l.target.value}),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:y.contentMarkdown.trim()?e.jsx(ne,{markdown:y.contentMarkdown}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"No content yet."})})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(Q,{variant:"ghost",onClick:()=>{w(null),T(null)},children:"Cancel"}),e.jsx(Q,{pending:ve.isPending,pendingLabel:"Saving",disabled:y.contentMarkdown.trim().length===0||y.linkedValues.length===0,onClick:()=>void ve.mutateAsync({noteId:a.id,draft:y}),children:"Save changes"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"mt-4 w-full text-left",onClick:()=>{h&&i(h.includes("#")?h:`${h}#notes`)},disabled:!h,children:e.jsx(ne,{markdown:a.contentMarkdown,className:"line-clamp-none"})}),h?e.jsx("div",{className:"mt-4 inline-flex text-xs uppercase tracking-[0.16em] text-[var(--secondary)]",children:"Open linked record"}):null]})]},a.id)})})}),e.jsx(St,{open:!!q,title:"Note actions",subtitle:C?C.contentPlain.slice(0,80)||"Markdown note":void 0,items:Ve,position:(q==null?void 0:q.position)??null,onClose:()=>oe(null)})]})}export{Zt as NotesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b6 as p,j as s,aU as c}from"./vendor-Cpmju3nw.js";import{B as u,c7 as m}from"./index-BejvcRGb.js";function d({entityType:a,entityId:e,view:n,label:o="Open in graph",variant:r="secondary",size:t}){const i=p();return s.jsxs(u,{variant:r,size:t,onClick:()=>i(m(a,e,{view:n})),children:[s.jsx(c,{className:"size-4"}),o]})}export{d as O};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as w,j as r,aC as R}from"./vendor-
|
|
1
|
+
import{r as w,j as r,aC as R}from"./vendor-Cpmju3nw.js";import{c as O}from"./index-BejvcRGb.js";import{m as B}from"./motion-DwjmC9aq.js";const z={mint:"border-[color-mix(in_srgb,var(--success)_28%,var(--ui-border-subtle)_72%)] bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--success)_62%,var(--ui-ink-strong)_38%)]",sky:"border-[color-mix(in_srgb,var(--info)_28%,var(--ui-border-subtle)_72%)] bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--info)_62%,var(--ui-ink-strong)_38%)]",violet:"border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--primary)_62%,var(--ui-ink-strong)_38%)]",rose:"border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[color-mix(in_srgb,var(--danger)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--danger)_62%,var(--ui-ink-strong)_38%)]"};function M(d,a,n){return Math.min(Math.max(d,a),n)}function X(d){const a=d.detail.trim().length;return a>84?130:a>44?118:106}function Y(d,a,n){const v=a/2,p=n/2,b=M(Math.min(a/620,n/430),.64,1.06),s=d.map(i=>{const e=i.angle*Math.PI/180,o=i.radius*b,l=Math.min(184,Math.max(154,a-48)),c=X(i),x=v+Math.cos(e)*o,h=p+Math.sin(e)*o;return{...i,x,y:h,width:l,height:c,homeX:x,homeY:h}}),u=a<720?16:22,y=20,m=a-20,_=18,t=n-18;for(let i=0;i<220;i+=1){for(const e of s)e.x+=(e.homeX-e.x)*.065,e.y+=(e.homeY-e.y)*.065;for(let e=0;e<s.length;e+=1)for(let o=e+1;o<s.length;o+=1){const l=s[e],c=s[o],x=c.x-l.x,h=c.y-l.y,k=l.width/2+c.width/2+u-Math.abs(x),N=l.height/2+c.height/2+u-Math.abs(h);if(k<=0||N<=0)continue;const j=k<N?"x":"y",f=Math.sign(j==="x"?x||o-e||1:h||o-e||1),g=(j==="x"?k:N)/2;j==="x"?(l.x-=f*g,c.x+=f*g):(l.y-=f*g,c.y+=f*g)}for(const e of s)e.x=M(e.x,y+e.width/2,m-e.width/2),e.y=M(e.y,_+e.height/2,t-e.height/2)}return s}function A({title:d,description:a,centerLabel:n,centerValue:v,nodes:p,action:b}){const s=w.useRef(null),[u,y]=w.useState({width:0,height:0});w.useEffect(()=>{if(!s.current||typeof ResizeObserver>"u")return;const t=new ResizeObserver(i=>{const e=i[0];y({width:e.contentRect.width,height:e.contentRect.height})});return t.observe(s.current),()=>t.disconnect()},[]);const m=p.length>0?p:[{id:"values",label:"Values",title:"Add value",detail:"Name what matters",href:"/psyche/values?create=1",angle:-86,radius:112,tone:"mint"},{id:"patterns",label:"Patterns",title:"Add pattern",detail:"Map a loop",href:"/psyche/patterns?create=1",angle:-14,radius:122,tone:"rose"},{id:"beliefs",label:"Beliefs",title:"Add belief",detail:"Capture a script",href:"/psyche/schemas-beliefs?create=1",angle:72,radius:118,tone:"violet"},{id:"reports",label:"Reports",title:"Reflect",detail:"Open the chain",href:"/psyche/reports?create=1",angle:160,radius:124,tone:"sky"}],_=w.useMemo(()=>Y(m,Math.max(u.width,320),Math.max(u.height,320)),[m,u.height,u.width]);return r.jsxs("section",{className:"overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[radial-gradient(circle_at_top,color-mix(in_srgb,var(--success)_12%,transparent),transparent_42%),var(--ui-surface-section)] px-4 py-4 shadow-[var(--card-shadow)] lg:px-5",children:[r.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--success)]",children:"Reflective map"}),r.jsx("h2",{className:"mt-2 break-words font-display text-[clamp(1.35rem,2.3vw,2rem)] leading-none text-[var(--ui-ink-strong)]",children:d}),r.jsx("p",{className:"mt-2 max-w-2xl break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:a})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("div",{className:"inline-flex min-w-0 items-center gap-3 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-2",children:[r.jsx("span",{className:"text-xs uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n}),r.jsx("span",{className:"min-w-0 break-words text-sm font-medium text-[var(--ui-ink-strong)]",children:v})]}),b?r.jsx("div",{className:"shrink-0",children:b}):null]})]}),r.jsx("div",{className:"grid gap-3 md:hidden",children:m.map(t=>r.jsxs(R,{to:t.href,className:O("block min-w-0 rounded-[20px] border px-4 py-3 shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-surface-hover)]",z[t.tone??"mint"]),children:[r.jsx("div",{className:"break-words text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:t.label}),r.jsx("div",{className:"mt-1.5 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:t.title}),r.jsx("div",{className:"mt-1.5 break-words text-sm leading-5 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:t.detail})]},t.id))}),r.jsxs("div",{ref:s,className:"relative hidden min-h-[20rem] overflow-hidden rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] md:block lg:min-h-[22rem]",children:[r.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_center,color-mix(in_srgb,var(--success)_8%,transparent),transparent_32%),var(--ui-surface-section)]"}),[112,168,224].map(t=>r.jsx("div",{className:"absolute left-1/2 top-1/2 rounded-full border border-[var(--ui-border-subtle)]",style:{width:`${t*2}px`,height:`${t*2}px`,transform:"translate(-50%, -50%)"}},t)),r.jsx("div",{className:"absolute inset-1/2 size-32 -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] shadow-[var(--card-shadow)]",children:r.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-center",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n}),r.jsx("div",{className:"mt-2 font-display text-2xl text-[var(--ui-ink-strong)]",children:v})]})}),_.map((t,i)=>r.jsx(B.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},transition:{duration:.35,delay:i*.05,ease:"easeOut"},className:"absolute w-[min(11.5rem,calc(100vw-4rem))] max-w-[11.5rem] -translate-x-1/2 -translate-y-1/2",style:{left:`${t.x}px`,top:`${t.y}px`},whileHover:{y:-6,scale:1.03},children:r.jsxs(R,{to:t.href,className:O("block min-w-0 rounded-[22px] border px-3.5 py-3 shadow-[var(--ui-shadow-soft)] backdrop-blur-sm transition hover:-translate-y-0.5 hover:bg-[var(--ui-surface-hover)]",z[t.tone??"mint"]),children:[r.jsx("div",{className:"break-words text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:t.label}),r.jsx("div",{className:"mt-1.5 break-words font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:t.title}),r.jsx("div",{className:"mt-1.5 break-words text-sm leading-5 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:t.detail})]})},t.id))]})]})}export{A as O};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as R,j as e,aC as F}from"./vendor-Cpmju3nw.js";import{A as q}from"./ai-surface-workspace-UtnoNmjq.js";import{i as $}from"./state-BtwEvpO6.js";import{T as Q,W as B,M as z,S as G,Q as Y}from"./utility-widgets-DvxKA6dI.js";import{F as J}from"./flagship-signal-deck-CW91n6u9.js";import{u as Z,d as ee,bb as te,n as E,m as L,bc as D,k as p,a4 as ie,c as se,C as M,b as ae,E as re,P as ne,R as le,bd as oe,be as de,aS as ce,bf as ue}from"./index-BejvcRGb.js";import{L as me}from"./life-force-workspace-CcmZRRfU.js";import{E as pe}from"./entity-note-count-link-CEtKyMAl.js";import{P as fe}from"./page-hero-DlHEJ0Yt.js";import{a as ve,g as xe}from"./activity-copy-Bj4h9OcF.js";import"./board-CLOHbg6t.js";import"./generic-node-view-COhU_Wm3.js";import"./graph-Cd5WF3lw.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./forms-C5d5hTf2.js";import"./floating-action-menu-GCeuOdYZ.js";import"./charts-DwTguE_x.js";const f={"Life Force":"Life Force compares today's spent Action Points with the modeled daily budget. It is Forge's local capacity planning layer, not a medical score.",Momentum:"Momentum summarizes recent execution, XP, streak context, and movement across Forge records. Use it as an attention signal.",Instant:"Instant AP/hour estimates current headroom from the Life Force drain model. Higher values mean Forge thinks the next block can absorb more effort.",Level:"Level comes from the XP ledger. It represents accumulated meaningful Forge activity for the selected user scope.","Weekly XP":"Weekly XP is recent reward-ledger movement. It helps separate a genuinely active week from old accumulated progress."};function he(a){const n=["gamification","summary","pipeline","body-signals","signals"],t=[...a.order];let r=!1;for(const v of n)t.includes(v)||(t.push(v),r=!0);const j=t.indexOf("summary"),c=t.indexOf("pipeline"),x=t.indexOf("body-signals"),g=t.indexOf("signals");if(j===-1||c===-1||x===-1||g===-1)return r?{...a,order:t}:a;if(j<c&&c<x&&x<g&&!r)return a;for(const v of n){const b=t.indexOf(v);b!==-1&&t.splice(b,1)}const y=t.indexOf("goals");return t.splice(y===-1?0:y,0,...n),{...a,order:t}}function ge(a=new Date){const n=a.getFullYear(),t=String(a.getMonth()+1).padStart(2,"0"),r=String(a.getDate()).padStart(2,"0");return`${n}-${t}-${r}`}function P(a){if(a>=3600){const n=a/3600;return n>=10||Number.isInteger(n)?`${Math.round(n)}h`:`${n.toFixed(1)}h`}return`${Math.max(1,Math.round(a/60))}m`}function ye(a){return a>=1e3?`${(a/1e3).toFixed(1)} km`:`${Math.round(a)} m`}function be(a){if(!a)return[];const n=new Map;for(const t of a.segments){if(t.kind!=="stay"||t.durationSeconds<=0)continue;const r=t.label.trim()||"Unlabeled stay";n.set(r,(n.get(r)??0)+t.durationSeconds)}return[...n.entries()].map(([t,r])=>({label:t,seconds:r})).sort((t,r)=>r.seconds-t.seconds).slice(0,3)}function ke(a){return a?["restingHeartRate","heartRateVariabilitySDNN","vo2Max","oxygenSaturation"].map(t=>a.metrics.find(r=>r.metric===t)).filter(t=>!!t).slice(0,3):[]}function we(a){if(a.latestValue==null)return"No reading";const n=a.unit==="steps"||a.unit==="flights"||a.unit==="kcal"||a.unit==="min"?0:1;return`${a.latestValue.toLocaleString(void 0,{maximumFractionDigits:n,minimumFractionDigits:n===0||a.latestValue>=100?0:1})} ${a.unit}`}function De(){var X,C;const{t:a}=Z(),n=ee(),t=n.snapshot,r=Array.isArray(n.selectedUserIds)?n.selectedUserIds:[],j=r.join("|"),[c,x]=R.useState(!1);R.useEffect(()=>{x(!1);const i=window.setTimeout(()=>{x(!0)},650);return()=>window.clearTimeout(i)},[j]);const g=ge(),y=$({queryKey:["forge-overview-sleep",...r],queryFn:async()=>(await oe(r)).sleep,enabled:c,staleTime:6e4})??{},v=$({queryKey:["forge-overview-fitness",...r],queryFn:async()=>(await de(r)).fitness,enabled:c,staleTime:6e4})??{},b=$({queryKey:["forge-overview-movement-day",g,...r],queryFn:async()=>(await ce({date:g,userIds:r})).movement,enabled:c,staleTime:6e4})??{},H=$({queryKey:["forge-overview-vitals",...r],queryFn:async()=>(await ue(r)).vitals,enabled:c,staleTime:6e4})??{},I=te(r,{skip:!c}),u=t.dashboard.milestoneRewards.find(i=>!i.completed)??t.dashboard.milestoneRewards[0]??null,o=t.overview.topTasks[0]??null,d=t.overview.dueHabits[0]??null,m=t.overview.recentEvidence[0]??null,V=new Map(t.projects.map(i=>[i.id,i])),N=t.metrics.momentumScore>=80?"Strong":t.metrics.momentumScore>=60?"Steady":"Needs attention",k=((X=y.data)==null?void 0:X.summary)??null,h=((C=v.data)==null?void 0:C.summary)??null,l=b.data,S=H.data??null,A=ke(S??void 0),T=be(l),O=k!==null||h!==null||S!==null,W=l!==void 0&&(l.summary.tripCount>0||l.summary.stayCount>0||l.summary.totalMovingSeconds>0||T.length>0),K=t.lifeForce?[{label:"Life Force",value:`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP`,detail:`Remaining ${E(t.lifeForce.remainingAp)}`,help:f["Life Force"]},{label:"Momentum",value:`${t.metrics.momentumScore}`,detail:`${N} · ${t.metrics.streakDays} day streak`,help:f.Momentum},{label:"Instant",value:L(t.lifeForce.instantFreeApPerHour),detail:t.lifeForce.overloadApPerHour>0?`${L(t.lifeForce.overloadApPerHour)} overload`:"Headroom right now",help:f.Instant},{label:"Level",value:`L${t.metrics.level}`,detail:`${t.metrics.currentLevelXp} XP in level`,help:f.Level},{label:"Weekly XP",value:`${t.metrics.weeklyXp}`,detail:`${t.metrics.totalXp} total XP`,help:f["Weekly XP"]}]:[{label:"Level",value:`L${t.metrics.level}`,detail:`${t.metrics.currentLevelXp} XP in level`,help:f.Level},{label:"Weekly XP",value:`${t.metrics.weeklyXp}`,detail:`${t.metrics.totalXp} total XP`,help:f["Weekly XP"]},{label:"Momentum",value:`${t.metrics.momentumScore}`,detail:`${N} · ${t.metrics.streakDays} day streak`,help:f.Momentum}];function U(i){return i.entityType==="goal"?`/goals/${i.entityId}`:i.entityType==="project"?`/projects/${i.entityId}`:i.entityType==="task"?`/tasks/${i.entityId}`:i.entityType==="habit"?"/habits":i.entityType==="task_run"&&typeof i.metadata.taskId=="string"?`/tasks/${i.metadata.taskId}`:`/activity?eventId=${i.id}`}const _=[{id:"hero",title:"Overview",description:"The route header stays movable like any other surface block.",defaultWidth:12,defaultHeight:2,removable:!1,minHeight:2,maxHeight:3,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:()=>e.jsx(fe,{title:"Overview",titleText:"Overview",description:`${N}. Life Force, momentum, XP, goals, active projects, and top tasks all start here.`,badge:`Momentum ${t.metrics.momentumScore}`})},{id:"gamification",title:"Forge Smith",description:"Selected-user level, XP, streak, trophy, and unlock state.",defaultWidth:12,defaultHeight:4,removable:!1,minHeight:3,surfaceChrome:"none",defaultTitleVisible:!1,defaultDescriptionVisible:!1,render:({compact:i})=>{var s;return I.data?e.jsx(D,{metrics:I.data.metrics,compact:i}):e.jsx(D,{metrics:{scope:{mode:"operator_fallback",userIds:t.userScope.selectedUserIds,users:t.userScope.selectedUsers,label:((s=t.userScope.selectedUsers[0])==null?void 0:s.displayName)??"Forge"},profile:t.metrics,achievements:[],milestoneRewards:[],momentumPulse:{status:t.metrics.momentumScore>=80?"surging":t.metrics.momentumScore>=60?"steady":"recovering",headline:`${t.metrics.streakDays}-day streak`,detail:`${t.metrics.currentLevelXp}/${t.metrics.nextLevelXp} XP in level ${t.metrics.level}.`,celebrationLabel:"Forge Smith",nextMilestoneId:null,nextMilestoneLabel:"Next unlock"},catalogPreview:[],unlockedItemCount:0,totalItemCount:144,nextUnlock:null,newestUnlock:null,nextTargets:[],equipment:{selectedMascotSkin:null,selectedHudTreatment:null,selectedStreakEffect:null,selectedTrophyShelf:null,selectedCelebrationVariant:null,updatedAt:null},mascot:{mood:"wise",spriteKey:"mascot-state-014",streakSpriteKey:"mascot-state-017",headline:"Small heat still counts.",line:"Return to the anvil today.",pressureLevel:0,missedDays:0,lastActiveDateKey:null},celebrations:[],recentLedger:[],rules:[],dailyAmbientXp:0,dailyAmbientCap:12},compact:i})}},{id:"summary",title:"Momentum summary",description:"Smaller titles and denser metrics free space for the widgets themselves.",defaultWidth:12,defaultHeight:3,minWidth:6,render:({compact:i})=>e.jsxs("div",{className:"rounded-[24px] bg-[var(--ui-surface-1)] 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.16em] text-[var(--ui-ink-faint)]",children:"Momentum summary"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:"Core live metrics"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Life Force, momentum, XP, and instant headroom stay grouped here."})]}),e.jsx(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:N})]}),e.jsx("div",{className:se("mt-4 grid gap-3",i?"grid-cols-2":"sm:grid-cols-2 xl:grid-cols-5"),children:K.map(s=>e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{children:s.label}),e.jsx(ie,{label:`Explain ${s.label}`,title:s.label,content:s.help,panelClassName:"normal-case tracking-normal"})]}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--ui-ink-strong)]",children:s.value}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-[var(--ui-ink-faint)]",children:s.detail})]},s.label))})]})},{id:"life-force",title:"Life Force",description:"Dynamic Action Points, the editable capacity curve, current drains, and stat growth all live here.",defaultWidth:12,defaultHeight:7,minWidth:6,render:()=>t.lifeForce?e.jsx(me,{selectedUserIds:r,fallbackLifeForce:t.lifeForce,onRefresh:n.refresh,showEditor:!1}):e.jsx(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Life Force is not configured for this user yet. Once a profile exists, the full capacity curve, drains, and recommendations will appear here."})},{id:"body-signals",title:"Life, health, movement",description:"Health imports and movement context make the overview feel like a real daily operating page.",defaultWidth:12,defaultHeight:4,minWidth:6,render:()=>e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-3",children:[e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Life Force"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:t.lifeForce?`${Math.round(t.lifeForce.remainingAp)} AP remaining`:"No Life Force profile yet"})]}),t.lifeForce?e.jsx(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:L(t.lifeForce.instantFreeApPerHour)}):null]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:t.lifeForce?`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP spent today. Remaining ${E(t.lifeForce.remainingAp)} with ${L(t.lifeForce.currentDrainApPerHour)} current drain.`:"Once Life Force is configured, this block will show today's budget, remaining headroom, and live drain."})]}),e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Body signals"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:O?"Recovery, training, and vitals":"No health data yet"})]}),S?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[S.summary.metricCount," metrics"]}):null]}),y.isLoading||v.isLoading||H.isLoading?e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Loading recent sleep, workout, and body-signal metrics…"}):O?e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-[var(--ui-ink-soft)]",children:[k?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Average sleep"}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:P(k.averageSleepSeconds)})]}):null,k?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Sleep score"}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:Math.round(k.averageSleepScore)})]}):null,h?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("span",{children:"Exercise"}),e.jsxs("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:[Math.round(h.exerciseMinutes)," min"]})]}):null,h?e.jsx("div",{className:"text-xs leading-5 text-[var(--ui-ink-faint)]",children:h.topWorkoutType?`${h.topWorkoutType} is the top workout type right now.`:"Workout imports are available when Apple Health or habit-generated sessions exist."}):null,A.length>0?e.jsx("div",{className:"mt-1 grid gap-2",children:A.map(i=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"font-medium text-[var(--ui-ink-strong)]",children:we(i)})]},i.metric))}):null]}):e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Sleep, workout, and vitals summaries appear here as soon as Forge has recent HealthKit records."})]}),e.jsxs(M,{className:"rounded-[24px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Movement"}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-[var(--ui-ink-strong)]",children:W?"Today's place balance":"No movement timeline yet"})]}),W?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[P((l==null?void 0:l.summary.totalMovingSeconds)??0)," ","moving"]}):null]}),b.isLoading?e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Loading today's stays, trips, and place balance…"}):W?e.jsxs("div",{className:"mt-3 grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[T.map(i=>e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[P(i.seconds)," at ",i.label]},i.label)),((l==null?void 0:l.summary.totalMovingSeconds)??0)>0?e.jsxs(p,{className:"bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[P((l==null?void 0:l.summary.totalMovingSeconds)??0)," ","moving"]}):null]}),e.jsxs("div",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:[(l==null?void 0:l.summary.tripCount)??0," trip",((l==null?void 0:l.summary.tripCount)??0)===1?"":"s"," and"," ",ye((l==null?void 0:l.summary.totalDistanceMeters)??0)," ","tracked today."]})]}):e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Movement summaries appear here once the companion has synced stays, trips, or known places."})]})]})},{id:"signals",title:"Action signals",description:"Direct links to the next things worth opening.",defaultWidth:7,defaultHeight:4,minWidth:4,render:()=>e.jsx(J,{eyebrow:"Actions",title:"Open what matters now",description:"These cards stay compact by default so the page can fit more live context at once.",items:[{id:"top-task",label:o?"Top task":d?"Due habit":"Recovery lane",title:(o==null?void 0:o.title)??(d==null?void 0:d.title)??"Get a real task moving",detail:(o==null?void 0:o.description)||(d==null?void 0:d.description)||"There is no single top task yet, so use this surface to choose one clean next move.",badge:o?`${o.points} xp`:d?`${d.rewardXp} xp`:`${t.metrics.weeklyXp} weekly xp`,href:o?`/tasks/${o.id}`:d?"/habits":"/today",actionLabel:o?"Open task":d?"Open habits":"Open today"},{id:"reward",label:"Next reward",title:(u==null?void 0:u.title)??"Keep the streak alive",detail:(u==null?void 0:u.progressLabel)??`Level ${t.metrics.level} is active. ${t.metrics.weeklyXp} weekly XP is already logged.`,badge:(u==null?void 0:u.rewardLabel)??`${t.metrics.comboMultiplier.toFixed(2)}x combo`,href:"/rewards",actionLabel:"Open rewards"},{id:"recent-activity",label:"Recent activity",title:m?xe(m):"No recent evidence",detail:m?ve(m):"The next work closeout or note will appear here.",badge:(m==null?void 0:m.source)??"activity",href:m?U(m):"/activity",actionLabel:"Open"}]})},{id:"goals",title:"Goals",description:"Long-range direction stays visible without taking over the whole page.",defaultWidth:8,defaultHeight:5,minWidth:4,render:({compact:i})=>e.jsx("div",{className:"grid gap-3",children:t.overview.activeGoals.slice(0,i?2:4).map(s=>{var w;return e.jsxs("div",{className:"group relative rounded-[20px] bg-[var(--ui-surface-1)] p-4 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsx(F,{to:`/goals/${s.id}`,className:"absolute inset-0 rounded-[20px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--primary)]","aria-label":`Open goal ${s.title}`}),e.jsxs("div",{className:"pointer-events-none relative z-10",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsx(ae,{kind:"goal",label:((w=s.tags[0])==null?void 0:w.name)??s.horizon,compact:!0,gradient:!1}),e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[s.progress,"%"]})]}),e.jsx("div",{className:"mt-3",children:e.jsx(re,{kind:"goal",label:s.title,variant:"heading",size:i?"md":"lg",lines:2,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),i?null:e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description}),e.jsx("div",{className:"mt-3",children:e.jsx(ne,{value:s.progress})})]}),e.jsx("div",{className:"relative z-20 mt-3",children:e.jsx(pe,{entityType:"goal",entityId:s.id,count:le(t.dashboard.notesSummaryByEntity,"goal",s.id).count})})]},s.id)})})},{id:"pipeline",title:"Projects, habits, tasks",description:"Execution blocks can shrink while keeping the useful subtitles visible.",defaultWidth:12,defaultHeight:5,minWidth:6,render:({compact:i})=>e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-3",children:[e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Projects"}),t.overview.projects.slice(0,i?3:4).map(s=>{var w;return e.jsxs(F,{to:`/projects/${s.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:((w=V.get(s.id))==null?void 0:w.status)??"active"})]}),e.jsxs(p,{wrap:!0,className:"max-w-[7rem] shrink-0",children:[s.earnedPoints," xp"]})]}),i?null:e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:s.description})]},s.id)})]}),e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Due habits"}),t.overview.dueHabits.slice(0,i?3:4).map(s=>e.jsx(F,{to:"/habits","aria-label":`Open habit ${s.title}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),i?null:e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:s.description})]}),e.jsxs(p,{wrap:!0,className:"max-w-[7rem] shrink-0 bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[s.rewardXp," xp"]})]})},s.id))]}),e.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Top tasks"}),t.overview.topTasks.slice(0,i?3:4).map(s=>e.jsx(F,{to:`/tasks/${s.id}`,className:"block min-w-0 max-w-full rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-hover)]",children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-[var(--ui-ink-strong)]",children:s.title}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:s.status.replaceAll("_"," ")})]}),e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[s.points," xp"]})]})},s.id))]})]})},{id:"time",title:"Clock",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(Q,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(B,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(z,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(G,{surfaceId:"overview"})},{id:"quick-capture",title:"Quick capture",description:"Save a standalone note or wiki draft from any dashboard.",defaultWidth:5,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>{var s;return e.jsx(Y,{compact:i,defaultUserId:r[0]??((s=t.users[0])==null?void 0:s.id)??null})}}];return e.jsx(q,{surfaceId:"overview",baseWidgets:_,normalizeLayout:he})}export{De as OverviewPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-Cpmju3nw.js";import{a as h,c as v,k as y,a4 as j}from"./index-BejvcRGb.js";function u(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g," ")}function N({eyebrow:r,titleText:t,entityKind:n,copyMode:i}){if(!r||i==="title_only"||typeof r!="string")return null;const l=u(r),s=t?u(t):null,o=n?u(h(n).label):null;return!l||s&&(l===s||s.includes(l)||l.includes(s))||o&&l===o?null:r}function E({eyebrow:r,entityKind:t,title:n,titleText:i,description:l,helpTitle:s,helpContent:o,helpLabel:b,badge:m,actions:p,copyMode:w="title_only"}){const a=t?h(t):null,d=a==null?void 0:a.icon,c=N({eyebrow:r,titleText:i,entityKind:t,copyMode:w}),x=i??(typeof n=="string"?n:"this page"),g=o??(typeof l=="string"?l:null),f=!!(a||c||m);return e.jsxs("header",{className:"relative min-w-0 w-full max-w-full overflow-visible border-b border-[var(--ui-border-subtle)] px-5 py-5 sm:px-6 lg:grid lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end lg:px-7 lg:py-6",style:{background:"var(--hero-gradient)",paddingTop:"var(--forge-shell-hero-padding-top)",paddingBottom:"var(--forge-shell-hero-padding-bottom)"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(circle at top right, color-mix(in srgb, var(--forge-body-ambient-primary) 94%, transparent), transparent 34%)"}}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[var(--ui-border-strong)]"}),e.jsxs("div",{className:"relative min-w-0 w-full max-w-full",children:[f?e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-[11px] font-medium uppercase tracking-[0.2em] text-[var(--ui-ink-faint)]",children:[a&&d?e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--ui-ink-soft)]","aria-label":a.label,title:a.label,children:[e.jsx(d,{className:v("size-3.5",a.iconClassName)}),e.jsx("span",{children:a.label})]}):null,c?e.jsx("span",{className:"text-[var(--secondary)]/80",children:c}):null,m?e.jsx(y,{tone:"signal",className:"h-8 overflow-visible rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-[11px] font-medium tracking-[0.14em] text-[var(--ui-ink-medium)] uppercase",children:m}):null]}):null,e.jsxs("div",{className:v("flex min-w-0 max-w-4xl items-start gap-2",f?"mt-3":""),children:[e.jsx("div",{className:"min-w-0 text-[clamp(1.85rem,3.5vw,4rem)] font-medium leading-[0.92] text-[var(--ui-ink-strong)]",style:{transform:"translateY(var(--forge-shell-hero-title-translate-y)) scale(var(--forge-shell-hero-title-scale))",transformOrigin:"top left",willChange:"transform"},children:n}),g?e.jsx(j,{className:"mt-2 shrink-0",label:b??`Explain what the ${x} page shows and how to interpret it`,title:s??`${x} explained`,content:g}):null]}),e.jsx("div",{className:"mt-2 min-w-0 max-w-3xl text-[14px] leading-6 text-[var(--ui-ink-soft)] sm:text-[15px]",style:{opacity:"var(--forge-shell-hero-description-opacity)",transform:"translateY(var(--forge-shell-hero-description-translate-y))",willChange:"opacity, transform"},children:l})]}),p?e.jsx("div",{className:"relative mt-4 flex min-w-0 w-full max-w-full flex-wrap items-center gap-2 lg:mt-0 lg:max-w-[26rem] lg:justify-end",children:p}):null]})}export{E as P};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./vendor-Cpmju3nw.js";import{c as a}from"./index-BejvcRGb.js";function i({children:r,className:s}){return t.jsx("div",{className:a("flex flex-wrap gap-2",s),children:r})}export{i as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b6 as p,j as s,b0 as l}from"./vendor-Cpmju3nw.js";import{j as g,k as y}from"./state-BtwEvpO6.js";import{bt as P,B as b}from"./index-BejvcRGb.js";function v({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c,size:f="sm"}){const u=p(),d=g(),t=y({mutationFn:async()=>{if(!e)throw new Error("Select a single owner before sending entities to Preferences.");return P({userId:e,domain:n,entityType:o,entityId:r,label:i,description:a,tags:c})},onSuccess:async({item:m})=>{await d.invalidateQueries({queryKey:["forge-preferences"]}),u(`/preferences?userId=${encodeURIComponent(e??"")}&domain=${encodeURIComponent(n)}&focusItem=${encodeURIComponent(m.id)}`)}});return s.jsxs(b,{variant:"secondary",size:f,disabled:!e,pending:t.isPending,pendingLabel:"Sending to Preferences",onClick:()=>void t.mutateAsync(),title:e?"Add this entity to the Preferences compare queue.":"Select a single user scope before sending entities to Preferences.",children:[s.jsx(l,{className:"size-4"}),"Send to Preferences"]})}export{v as P};
|