forge-openclaw-plugin 0.2.100 → 0.2.102
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/{activity-page-5oyCFOns.js → activity-page-CgF7K2ww.js} +1 -1
- package/dist/assets/ai-surface-workspace-xtB5RFQu.js +1 -0
- package/dist/assets/atlas-panel-B3dPHCmZ.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-DqHzdCPQ.js} +1 -1
- package/dist/assets/{calendar-page-Bo2iua-a.js → calendar-page-C1Wfd2Fy.js} +1 -1
- package/dist/assets/{calendar-rules-DA1g3QUk.js → calendar-rules-CaZXtlxt.js} +1 -1
- package/dist/assets/calendar-week-toolbar-BZ_-X3Wb.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-FcU0F3XV.js} +8 -8
- package/dist/assets/{companion-sync-lab-page-CosNknOK.js → companion-sync-lab-page-NgeK-O-P.js} +1 -1
- package/dist/assets/daily-metrics-dashboard-BMyL0Qr4.js +1 -0
- package/dist/assets/{entity-note-count-link-BmGDB572.js → entity-note-count-link-BrS1-O0o.js} +1 -1
- package/dist/assets/entity-notes-surface-CBylYDwy.js +1 -0
- package/dist/assets/{execution-board-CDRXQB85.js → execution-board-CpO2ch6v.js} +1 -1
- package/dist/assets/faceted-token-search-D7xPWfOl.js +1 -0
- package/dist/assets/flagship-signal-deck-BEFKOhvx.js +1 -0
- package/dist/assets/{floating-action-menu-CJkI2iFy.js → floating-action-menu-zzC2r0Ob.js} +1 -1
- package/dist/assets/{forms-BFlTgZ3W.js → forms-CmLAyGqz.js} +1 -1
- package/dist/assets/{goal-detail-page-cJvHaLMQ.js → goal-detail-page-JK_Nva8e.js} +1 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-BTa79qum.js} +14 -14
- package/dist/assets/{habits-page-DKb96_mj.js → habits-page-Dx5EhkJi.js} +1 -1
- package/dist/assets/index-BHIKoiZ6.js +19 -0
- package/dist/assets/index-H8R-ABM3.css +1 -0
- package/dist/assets/insight-flow-dialog-BtIQXXsS.js +1 -0
- package/dist/assets/{insights-page-Dc9oFltJ.js → insights-page-CujrosD_.js} +1 -1
- package/dist/assets/{kanban-page-JAxerYh6.js → kanban-page-Q9NuIz5w.js} +1 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +1 -0
- package/dist/assets/{life-force-page-BGDbQuVh.js → life-force-page-BGDkKfbJ.js} +1 -1
- package/dist/assets/{life-force-workspace-B1fYSXRC.js → life-force-workspace-CLVexVnb.js} +1 -1
- package/dist/assets/{maps-ClgJoCjz.js → maps-CF1RagUX.js} +1 -1
- package/dist/assets/metric-tile-4iMd_WnJ.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-CfdU2F35.js} +1 -1
- package/dist/assets/movement-page-ClaoTNuX.js +1 -0
- package/dist/assets/note-markdown-CsGQhQXF.js +3 -0
- package/dist/assets/note-tags-input-DdZi93tj.js +1 -0
- package/dist/assets/notes-page-DYI8s3NN.js +1 -0
- package/dist/assets/{open-in-graph-button-Cg5VrKsC.js → open-in-graph-button-C0TGev7c.js} +1 -1
- package/dist/assets/orbit-map-DVXkfQdd.js +1 -0
- package/dist/assets/overview-page-BwMlFQKX.js +1 -0
- package/dist/assets/page-hero-oFHaAjtL.js +1 -0
- package/dist/assets/pill-cluster-7UZd_lHp.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-D4WAs9pC.js → preference-entity-handoff-button-DOKV9bZc.js} +1 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +1 -0
- package/dist/assets/{project-collections-DvaX20q_.js → project-collections-CZagCmeH.js} +1 -1
- package/dist/assets/{project-detail-page-drPIFZGb.js → project-detail-page-DogvVNEn.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-BUbRXvny.js → project-management-hierarchy-page-Dr7hW9PW.js} +1 -1
- package/dist/assets/{project-management-section-nav-C2Ud8Zdd.js → project-management-section-nav-BLdAgTge.js} +1 -1
- package/dist/assets/{projects-page-BGzEZUtg.js → projects-page-UKrby_5-.js} +1 -1
- package/dist/assets/psyche-behaviors-page-BeVlXvbj.js +5 -0
- package/dist/assets/psyche-flashcards-page-CqAWCO4E.js +1 -0
- package/dist/assets/psyche-goal-map-page-IyNnbk_W.js +1 -0
- package/dist/assets/psyche-graph-IkUQRaDK.js +1 -0
- package/dist/assets/{psyche-metrics-page-zYTJDbyZ.js → psyche-metrics-page-uai0a7Lx.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C7p-ABiF.js +1 -0
- package/dist/assets/psyche-modes-page-CLQ5V3w0.js +1 -0
- package/dist/assets/psyche-page-NQBHkkpU.js +1 -0
- package/dist/assets/psyche-patterns-page-BkRiNpI_.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-Du-7HwPC.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-C5-yf8MF.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-CoSH5O6R.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-ChI7c1wy.js +1 -0
- package/dist/assets/psyche-questionnaires-page-xUcJJzbI.js +1 -0
- package/dist/assets/psyche-report-detail-page-BPrZCFZS.js +3 -0
- package/dist/assets/psyche-reports-page-D2EXJmm6.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-RcZYaokx.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-h0ooZ1lp.js +9 -0
- package/dist/assets/psyche-screen-time-page-_3-4LikV.js +1 -0
- package/dist/assets/psyche-self-observation-page-BdbCsgR5.js +1 -0
- package/dist/assets/psyche-values-page-DuUVki5e.js +5 -0
- package/dist/assets/report-chain-fields-BBMz0sGI.js +1 -0
- package/dist/assets/{rewards-page-C2HQjIAf.js → rewards-page-PZFPa6rR.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-BHOpHOrV.js → scheduling-rules-editor-B9KNKsQz.js} +1 -1
- package/dist/assets/schema-badge-D93RcG36.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-Cdq7foRu.js +1 -0
- package/dist/assets/{settings-agents-page-VuYXTiyc.js → settings-agents-page-DPx2F6wf.js} +3 -3
- package/dist/assets/{settings-bin-page-BNzvYaOk.js → settings-bin-page-COwP3gjo.js} +1 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +5 -0
- package/dist/assets/{settings-data-page-CGSlryuI.js → settings-data-page-CBubzKBw.js} +1 -1
- package/dist/assets/{settings-logs-page-BTK5fine.js → settings-logs-page-uOuXMeBm.js} +1 -1
- package/dist/assets/{settings-mobile-page-CRaObOGo.js → settings-mobile-page-C5rfj8_r.js} +1 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +1 -0
- package/dist/assets/{settings-page-BP81Mb5R.js → settings-page-B4u5TR5g.js} +1 -1
- package/dist/assets/{settings-rewards-page-CDJ1PH2G.js → settings-rewards-page-COiTwkMH.js} +1 -1
- package/dist/assets/{settings-section-nav-CCFm27r2.js → settings-section-nav-Dc4IeVBt.js} +1 -1
- package/dist/assets/{settings-users-page-TdUocFPa.js → settings-users-page-DEGa5DNn.js} +1 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +1 -0
- package/dist/assets/{sleep-page-cI1GMVzk.js → sleep-page-BnSOwkEU.js} +1 -1
- package/dist/assets/{sports-page-06LTqp0V.js → sports-page-l1RqXzA_.js} +1 -1
- package/dist/assets/{state-B-4sS1xO.js → state-VYvD1QVP.js} +1 -1
- package/dist/assets/{strategies-page-DXP9Kx8s.js → strategies-page-DEnPlpAs.js} +1 -1
- package/dist/assets/{strategy-detail-page-D6mx_Mik.js → strategy-detail-page-Ls8bxKeH.js} +1 -1
- package/dist/assets/strategy-dialog-DMyRKrWf.js +1 -0
- package/dist/assets/surface-Bfz_sLX6.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-C0VTeqw0.js} +1 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +1 -0
- package/dist/assets/{timebox-planning-dialog-CaCnoslG.js → timebox-planning-dialog-Ww0NGLLo.js} +1 -1
- package/dist/assets/today-page-CIuFHMi1.js +1 -0
- package/dist/assets/training-load-page-BIwc648i.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-CsEkP2V8.js} +4 -4
- package/dist/assets/use-psyche-focus-target-qxT5Oy_z.js +1 -0
- package/dist/assets/{vendor-DHkYh85p.js → vendor-kIz9EZnX.js} +237 -222
- package/dist/assets/{vitals-page-BQvEjTc6.js → vitals-page-Dz1Jt5H8.js} +1 -1
- package/dist/assets/{weekly-review-page-Tp6Q9CRj.js → weekly-review-page-BFpBe1kI.js} +1 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +5 -0
- package/dist/assets/{wiki-article-markdown-DQYohmW2.js → wiki-article-markdown-gsPTXTg1.js} +1 -1
- package/dist/assets/{wiki-editor-page-Dem_3eZv.js → wiki-editor-page-BpAZHooY.js} +7 -7
- package/dist/assets/{wiki-ingest-history-page-BxoOcCoJ.js → wiki-ingest-history-page-C-ig8O22.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-DhguKk3J.js → wiki-ingest-modal-BK4eQgqs.js} +1 -1
- package/dist/assets/{wiki-page-BLRxVXkl.js → wiki-page-CMTZ60Zt.js} +1 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +5 -0
- package/dist/assets/workbench-page-CtCjYSRe.js +1 -0
- package/dist/assets/workout-detail-page-DD9IGN6l.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +103 -30
- package/dist/server/server/src/health-weight-loss.js +457 -55
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +12 -9
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/server/src/watch-mobile.js +22 -10
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/lib/api.js +14 -4
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/ai-surface-workspace-qgk_B57-.js +0 -1
- package/dist/assets/atlas-panel-rfH2qOez.js +0 -1
- package/dist/assets/calendar-week-toolbar-DU1Q4RYj.js +0 -1
- package/dist/assets/daily-metrics-dashboard-LjuGAB3f.js +0 -1
- package/dist/assets/entity-notes-surface-DgEgicaE.js +0 -1
- package/dist/assets/faceted-token-search-CE1YauRd.js +0 -1
- package/dist/assets/flagship-signal-deck-DDds90Gl.js +0 -1
- package/dist/assets/goals-page-f_39hvUV.js +0 -1
- package/dist/assets/index-BHTUu_4M.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-pzAzyayN.js +0 -1
- package/dist/assets/knowledge-graph-page-UQ3skqEi.js +0 -1
- package/dist/assets/metric-tile-DX6TclqM.js +0 -1
- package/dist/assets/movement-page-6HP6nGJx.js +0 -1
- package/dist/assets/note-markdown-DiW2-5d3.js +0 -3
- package/dist/assets/note-tags-input-DDLXf54U.js +0 -1
- package/dist/assets/notes-page-BuguDjhz.js +0 -1
- package/dist/assets/orbit-map-GD05-0oS.js +0 -1
- package/dist/assets/overview-page-DuOs2OCB.js +0 -1
- package/dist/assets/page-hero-CQWo1Mm_.js +0 -1
- package/dist/assets/pill-cluster-BJogDRDJ.js +0 -1
- package/dist/assets/preferences-page-BaJTMU1I.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dmm_Io9D.js +0 -5
- package/dist/assets/psyche-flashcards-page-BgNKJ6QJ.js +0 -1
- package/dist/assets/psyche-goal-map-page-DXJs98Vr.js +0 -1
- package/dist/assets/psyche-graph-CFgs_Bqc.js +0 -1
- package/dist/assets/psyche-mode-guide-page-XPgRfCOf.js +0 -1
- package/dist/assets/psyche-modes-page-B-GA8oRF.js +0 -1
- package/dist/assets/psyche-page--r6a3e1t.js +0 -1
- package/dist/assets/psyche-patterns-page-BM5-3bMm.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-CJshQ-mg.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-USmR5G5A.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-D7iBCmTi.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-Cpil-kDh.js +0 -1
- package/dist/assets/psyche-questionnaires-page-C-_y3VwS.js +0 -1
- package/dist/assets/psyche-report-detail-page--dkSPRaj.js +0 -3
- package/dist/assets/psyche-reports-page-CUaOXmIN.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BX6xaap3.js +0 -9
- package/dist/assets/psyche-screen-time-page-CAAI4mD7.js +0 -1
- package/dist/assets/psyche-self-observation-page-BZ6FLuwa.js +0 -1
- package/dist/assets/psyche-values-page-yEV6MGt8.js +0 -5
- package/dist/assets/report-chain-fields-fZ8Xd4H6.js +0 -1
- package/dist/assets/schema-badge-DyKbxb51.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-BX-pZNqL.js +0 -1
- package/dist/assets/settings-calendar-page-CjSFB53S.js +0 -5
- package/dist/assets/settings-models-page-DFshpYF8.js +0 -1
- package/dist/assets/settings-wiki-page-B2zX0QQG.js +0 -1
- package/dist/assets/strategy-dialog-BvzomTaF.js +0 -1
- package/dist/assets/task-detail-page-BIWIggdp.js +0 -1
- package/dist/assets/today-page-DO2mRPT2.js +0 -1
- package/dist/assets/training-load-page-CyZ0mlEr.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/weight-loss-page-BBzlhLVV.js +0 -1
- package/dist/assets/workbench-flow-page-DqMkCCTy.js +0 -5
- package/dist/assets/workbench-page-BWd02wPw.js +0 -1
- package/dist/assets/workout-detail-page-BD8u7GyL.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,j as e,aK as Lt,c4 as It,bg as $t,cq as ga,c3 as va,aZ as nt,cr as Nt,F as Ua,bX as Wa,b4 as Ga,cs as fa,ct as Va,c7 as Ya,bc as Xa}from"./vendor-kIz9EZnX.js";import{j as ba,x as Vt,i as te,k as Ce}from"./state-VYvD1QVP.js";import{I as O,B as A,Z as k,c as h,C as N,aY as Yt,aZ as Xt,a_ as wa,a$ as Za,b0 as Ja,S as ya,E as ja,aT as Na,b1 as es,b2 as Zt,b3 as ts,b4 as Sa,b5 as as,u as ss,b6 as is,b7 as rs,b8 as et,h as Jt,d as tt,b9 as ns,aq as ce,ba as ls,bb as os,bc as ds,bd as cs,be as ms,bf as us,bg as xs,O as hs,bh as ps,bi as gs,bj as vs}from"./index-BHIKoiZ6.js";import{F as ka}from"./faceted-token-search-D7xPWfOl.js";import{P as fs}from"./page-hero-oFHaAjtL.js";import{R as qe,P as Qe,O as Ue,C as We,T as ct,D as mt,a as ut}from"./ui-CsEkP2V8.js";import{m as ea}from"./motion-CfdU2F35.js";import{S as ue}from"./surface-Bfz_sLX6.js";import{R as bs,A as ws,C as ys,X as js,Y as Ns,T as Ss,a as ks}from"./charts-FcU0F3XV.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function Ma({open:t,onOpenChange:a,place:s,seed:i,onSave:l}){const[c,u]=x.useState({label:(s==null?void 0:s.label)??(i==null?void 0:i.label)??"",latitude:String((s==null?void 0:s.latitude)??(i==null?void 0:i.latitude)??""),longitude:String((s==null?void 0:s.longitude)??(i==null?void 0:i.longitude)??""),radiusMeters:String((s==null?void 0:s.radiusMeters)??(i==null?void 0:i.radiusMeters)??100),categoryTags:((s==null?void 0:s.categoryTags)??(i==null?void 0:i.categoryTags)??[]).join(", ")});return x.useEffect(()=>{u({label:(s==null?void 0:s.label)??(i==null?void 0:i.label)??"",latitude:String((s==null?void 0:s.latitude)??(i==null?void 0:i.latitude)??""),longitude:String((s==null?void 0:s.longitude)??(i==null?void 0:i.longitude)??""),radiusMeters:String((s==null?void 0:s.radiusMeters)??(i==null?void 0:i.radiusMeters)??100),categoryTags:((s==null?void 0:s.categoryTags)??(i==null?void 0:i.categoryTags)??[]).join(", ")})},[s,i]),e.jsx(qe,{open:t,onOpenChange:a,children:e.jsxs(Qe,{children:[e.jsx(Ue,{className:"fixed inset-0 z-50 bg-[var(--ui-overlay-backdrop)] backdrop-blur-sm"}),e.jsxs(We,{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(ct,{className:"font-display text-[1.3rem] tracking-normal text-[var(--ui-ink-strong)]",children:s?`Edit ${s.label}`:"New known place"}),e.jsx(mt,{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(ut,{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(Lt,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsx(O,{value:c.label,onChange:d=>u(m=>({...m,label:d.target.value})),placeholder:"Home, Main Office, Riverside path..."}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(O,{value:c.latitude,onChange:d=>u(m=>({...m,latitude:d.target.value})),placeholder:"Latitude"}),e.jsx(O,{value:c.longitude,onChange:d=>u(m=>({...m,longitude:d.target.value})),placeholder:"Longitude"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[10rem_minmax(0,1fr)]",children:[e.jsx(O,{value:c.radiusMeters,onChange:d=>u(m=>({...m,radiusMeters:d.target.value})),placeholder:"Radius meters"}),e.jsx(O,{value:c.categoryTags,onChange:d=>u(m=>({...m,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:s==null?void 0:s.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 L(t){return new Date(t).getTime()}function kt(t){return new Date(t).toISOString()}function ta(t,a){const s=L(t.startedAt)-L(a.startedAt);if(s!==0)return s;const i=L(t.endedAt)-L(a.endedAt);return i!==0?i:t.id.localeCompare(a.id)}function Et(t){return t.syncSource==="sleep overlay"}function Ms(t){const a=[...t].filter(i=>L(i.endedAt)>L(i.startedAt)).sort((i,l)=>{const c=L(i.startedAt)-L(l.startedAt);if(c!==0)return c;const u=L(i.endedAt)-L(l.endedAt);return u!==0?u:i.id.localeCompare(l.id)});if(a.length===0)return[];const s=[];for(const i of a){const l=s.at(-1);if(!l){s.push(i);continue}const c=L(l.endedAt);if(L(i.startedAt)<=c+St){const d=Math.max(c,L(i.endedAt));s[s.length-1]={...l,id:`${l.id}__${i.id}`,endedAt:kt(d),asleepSeconds:(l.asleepSeconds??0)+(i.asleepSeconds??0)||null,timeInBedSeconds:(l.timeInBedSeconds??0)+(i.timeInBedSeconds??0)||null,sleepScore:i.sleepScore??l.sleepScore,regularityScore:i.regularityScore??l.regularityScore,efficiency:i.efficiency??l.efficiency,recoveryState:i.recoveryState??l.recoveryState};continue}s.push(i)}return s}function As(t){const a=[];if(typeof t.asleepSeconds=="number"&&t.asleepSeconds>0){const s=t.asleepSeconds/3600;a.push(`${s.toFixed(s>=1?1:2)}h asleep`)}else if(typeof t.timeInBedSeconds=="number"&&t.timeInBedSeconds>0){const s=t.timeInBedSeconds/3600;a.push(`${s.toFixed(s>=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 Cs(t){const a=Math.max(60,Math.round((L(t.endedAt)-L(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:As(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 aa(t,a,s){if(s<=a)return null;const i=kt(a),l=kt(s),c=Math.max(60,Math.round((s-a)/1e3));return{...t,id:`${t.id}::virtual-${a}-${s}`,startedAt:i,endedAt:l,trueStartedAt:i,trueEndedAt:l,visibleStartedAt:i,visibleEndedAt:l,durationSeconds:c,cursor:`${l}::${t.id}::virtual`}}function Ts(t,a){let s=[...t].sort(ta);for(const i of Ms(a)){const l=L(i.startedAt),c=L(i.endedAt),u=Cs(i),d=[];let m=!1;for(const p of s){const f=L(p.startedAt),y=L(p.endedAt);if(y<=l||f>=c){!m&&f>=c&&(d.push(u),m=!0),d.push(p);continue}if(f<l){const T=aa(p,f,Math.min(y,l-St));T&&d.push(T)}if(m||(d.push(u),m=!0),y>c){const T=aa(p,Math.max(f,c+St),y);T&&d.push(T)}}m||d.push(u),s=d.sort(ta)}return s}const sa=24,G=64,Mt=360*60,Aa=5,yt=1,Ps=104,ia=G*8;function pe(t){return t.trim().toLowerCase()}function Ke(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 Ca(t){return new Intl.DateTimeFormat(void 0,{day:"2-digit",month:"2-digit",year:"2-digit"}).format(new Date(t))}function Ds(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",hour12:!1}).format(t)}function De(t){const a=new Date(t);if(Number.isNaN(a.getTime()))return"";const s=a.getFullYear(),i=String(a.getMonth()+1).padStart(2,"0"),l=String(a.getDate()).padStart(2,"0"),c=String(a.getHours()).padStart(2,"0"),u=String(a.getMinutes()).padStart(2,"0");return`${s}-${i}-${l}T${c}:${u}`}function lt(t){if(!t.trim())return null;const a=new Date(t);return Number.isNaN(a.getTime())?null:a.toISOString()}function Le(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function W(t){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t))}function ra(t,a){return`${t.toFixed(3)}, ${a.toFixed(3)}`}function at(t,a){return`${t.toFixed(6)}, ${a.toFixed(6)}`}function na(t){return`${Math.max(1,Math.round(t/60))} min`}function Ls(t){if(t.length===0)return[];const a=Math.min(...t.map(d=>d.latitude)),s=Math.max(...t.map(d=>d.latitude)),i=Math.min(...t.map(d=>d.longitude)),l=Math.max(...t.map(d=>d.longitude)),c=Math.max(s-a,1e-4),u=Math.max(l-i,1e-4);return t.map((d,m)=>({...d,x:12+(d.longitude-i)/u*76,y:12+(1-(d.latitude-a)/c)*76,id:`${d.recordedAt??"point"}-${m}`}))}function ot(t){return t.kind==="trip"&&t.trip!==null}function le(t){return t.kind==="stay"&&t.stay!==null}function At(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 Ie(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 rt(t,a,s,i){const c=(s-t)*Math.PI/180,u=(i-a)*Math.PI/180,d=t*Math.PI/180,m=s*Math.PI/180,p=Math.sin(c/2)**2+Math.cos(d)*Math.cos(m)*Math.sin(u/2)**2;return 2*6371e3*Math.asin(Math.sqrt(p))}function Is(t){return pe([t.label,...t.aliases].join(" "))}function Ne(t,a,s){if(!t.trip)return{label:t.placeLabel??(a==="start"?"Known origin":"Known destination"),detail:W(a==="start"?t.startedAt:t.endedAt)};const i=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=(s==null?void 0:s.includeCoordinates)??!0,u=s!=null&&s.useHistoryAnchorFallback&&a==="start"?"Beginning of history":null;return{label:(l==null?void 0:l.label)??u??(c&&i?ra(i.latitude,i.longitude):a==="start"?"Unknown origin":"Unknown destination"),detail:c&&i&&!l?ra(i.latitude,i.longitude):W(a==="start"?t.startedAt:t.endedAt)}}function $s(t){const a=t.trim().toLowerCase();return a==="travel"||a==="trip"||a==="move"}function Es(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 Fs(t){const a=Ie(t),s=t.title.trim().toLowerCase(),i=s.length===0||s==="stay"||s==="continued stay"||s==="repaired stay"||s==="manual stay";return a&&i?a:t.title.trim()||a||"Stay"}function me(t){if(Et(t))return"Sleep";if(t.kind==="missing")return Es(t);if(t.kind==="stay")return Fs(t);if(t.kind==="trip"&&$s(t.title)){const a=Ne(t,"start").label,s=Ne(t,"end").label;return`${a} → ${s}`}return t.title}function la(t){return t==="left"?24:t==="right"?76:50}function _s(t,a,s){const i=Math.min(t,Mt)/3600,l=s==="sleep overlay",c=l?112:a==="stay"?104:92,u=l?272:a==="stay"?288:232,d=c+i*30;return Math.max(c,Math.min(u,d))}function Ct(t){var a;return{kind:t.kind,label:le(t)?t.stay.label||t.title:ot(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:De(t.startedAt),endedAtInput:De(t.endedAt)}}function jt(t,a){const s=(a==null?void 0:a.startedAt)??new Date(Date.now()-36e5).toISOString(),i=(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:De(s),endedAtInput:De(i)}}function Tt(t,a){var c,u;const s=t.tagsInput.split(",").map(d=>d.trim()).filter(Boolean),i=lt(t.startedAtInput)??(a==null?void 0:a.startedAt)??new Date(Date.now()-3600*1e3).toISOString(),l=lt(t.endedAtInput)??(a==null?void 0:a.endedAt)??new Date().toISOString();return{kind:t.kind,startedAt:i,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:s,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"?((u=a==null?void 0:a.trip)==null?void 0:u.averageSpeedMps)??null:null,metadata:{createdFrom:"movement-life-timeline"}}}function Rs(t,a){var l,c;const s=t.kind==="stay"?((c=(l=t.stay)==null?void 0:l.label)==null?void 0:c.trim())??"":"";if(s)return s;const i=t.title.trim();return i&&i.toLowerCase()!=="stay"?i:a.trim()||"Stay"}function zs(t,a){const s=Ct(t),i=a.trim();return Tt({...s,label:Rs(t,i),placeLabel:i},t)}function Ta(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function dt(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Os(t){var a,s,i;return pe([t.kind,me(t),t.subtitle,t.placeLabel??"",...t.tags,dt(t.startedAt),dt(t.endedAt),Ta(t.startedAt),le(t)?((a=t.stay.place)==null?void 0:a.label)??t.stay.label:ot(t)?[t.trip.label,t.trip.activityType,t.trip.travelMode,(s=t.trip.startPlace)==null?void 0:s.label,(i=t.trip.endPlace)==null?void 0:i.label].filter(Boolean).join(" "):t.kind==="trip"?[t.title,t.subtitle,t.placeLabel??""].filter(Boolean).join(" "):"missing data gap"].join(" "))}function Hs(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 s of["night","morning","afternoon","evening"])a.set(`time:${s}`,{id:`time:${s}`,label:s[0].toUpperCase()+s.slice(1),description:"Filter by the segment start time."});for(const s of t){for(const i of s.tags)a.set(`tag:${i}`,{id:`tag:${i}`,label:i,description:"Movement tag"});s.placeLabel&&a.set(`place:${s.placeLabel}`,{id:`place:${s.placeLabel}`,label:s.placeLabel,description:"Matched place"})}return[...a.values()].sort((s,i)=>s.label.localeCompare(i.label))}function Bs(t,a){return a.every(s=>s==="kind:stay"||s==="kind:trip"?t.kind===s.slice(5):s.startsWith("time:")?Ta(t.startedAt)===s.slice(5):s.startsWith("tag:")?t.tags.includes(s.slice(4)):s.startsWith("place:")?(t.placeLabel??"")===s.slice(6):!0)}function oa(t,a){return t&&{...t,pages:t.pages.map(s=>({...s,segments:s.segments.filter(i=>i.id!==a)}))}}function Ks(t,a){const s=t+(Math.sin((t-.5)*Math.PI)+1)*.5-t,i=t-.5,c=.5+(i*(1-a*.64)+i*i*i*a*2.56);return Math.max(0,Math.min(1,c-(s-t)*a*.08))}function qs(t){return t.getHours()===0?Ca(t.toISOString()):Ds(t)}function Qs(t,a){const s=new Date(t.endedAt).getTime(),i=new Date(t.startedAt).getTime(),l=Math.max(1,s-i),c=Math.max(0,Math.min(1,(a-i)/l));if(t.durationSeconds<=Mt)return c;const u=Math.max(0,1-Math.min(1,Mt/Math.max(1,t.durationSeconds)));return Ks(c,u)}function Us(t,a,s){if(t.items.length===0)return null;const i=t.items[0];if(a<new Date(i.segment.startedAt).getTime())return t.historyHeaderHeight+t.leadHeight-(new Date(i.segment.startedAt).getTime()-a)/36e5*G;for(let u=0;u<t.items.length;u+=1){const d=t.items[u],m=new Date(d.segment.startedAt).getTime(),p=new Date(d.segment.endedAt).getTime();if(a>=m&&a<=p)return d.boxTop+Qs(d.segment,a)*d.displayHeight;const f=t.items[u+1]??null,y=f?new Date(f.segment.startedAt).getTime():s;if(a>p&&a<y)return d.boxBottom+(a-p)/36e5*G}const l=t.items[t.items.length-1],c=new Date(l.segment.endedAt).getTime();return a>=c?l.boxBottom+(a-c)/36e5*G:null}function Ws(t){const a=new Date(t);a.setMinutes(0,0,0);const s=a.getTime();return s<=t?s+36e5:s}function Gs(t,a){const s=[];if(t.items.length===0)return s;const i=t.items[0],l=new Date(i.segment.startedAt).getTime();for(let c=Ws(l-Aa*36e5);c<=a;c+=36e5){const u=Us(t,c,a);if(u===null)continue;const d=new Date(c);s.push({y:u,label:qs(d),strong:d.getHours()===0})}return s}function Vs({segments:t,viewportHeight:a,nowMs:s=Date.now()}){var K;const i=t.length>0?Ps:0,l=t.length>0?G*Aa:0;let c=i+l,u=null;const d=t.map(b=>{const C=_s(b.durationSeconds,b.kind,b.syncSource),E=new Date(b.startedAt).getTime(),H=u===null?0:Math.max(0,(E-u)/36e5)*G;c+=H;const V=c,_=V+C;return c=_,u=new Date(b.endedAt).getTime(),{id:b.id,segment:b,gapBefore:H,displayHeight:C,boxTop:V,boxBottom:_}}),m=s+yt*36e5,p=(()=>{var E;const b=(E=t[t.length-1])==null?void 0:E.endedAt;if(!b)return G*yt;const C=new Date(b).getTime();return Math.max(G*yt,(m-C)/36e5*G)})(),f=(((K=d[d.length-1])==null?void 0:K.boxBottom)??i+l)+p,y=Math.max(f,a>0?a+260:960,i+l+p),T={historyHeaderHeight:i,leadHeight:l,items:d,markers:[],rangeEndMs:m,futureTailHeight:p+Math.max(0,y-f),totalHeight:y};return{...T,markers:Gs(T,m)}}const Ys="bg-[linear-gradient(90deg,color-mix(in_srgb,var(--canvas)_96%,transparent),color-mix(in_srgb,var(--canvas)_42%,transparent),transparent)]",Xs="bg-[linear-gradient(180deg,color-mix(in_srgb,var(--ui-ink-strong)_2%,transparent),color-mix(in_srgb,var(--ui-ink-strong)_8%,transparent),color-mix(in_srgb,var(--ui-ink-strong)_2%,transparent))]",Zs="h-6 w-[3px] rounded-full bg-[var(--info)] shadow-[0_0_14px_color-mix(in_srgb,var(--info)_36%,transparent)]",Js="relative w-[min(18rem,calc(100vw-6rem))] overflow-hidden rounded-[26px] border border-[color-mix(in_srgb,var(--info)_22%,transparent)] bg-[linear-gradient(180deg,var(--ui-accent-soft),var(--ui-info-soft))] shadow-[var(--ui-shadow-soft)]",ei="absolute z-10 h-7 w-8 rounded-[12px] border bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-soft)] backdrop-blur-sm",ti="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",Pt="ring-1 ring-[color-mix(in_srgb,var(--info)_42%,transparent)]",ai="bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Pa="bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",Ae="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",si="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)]",ii="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 ri({layout:t,scrollTop:a,viewportHeight:s}){const i=G*6,l=Math.max(0,a-i),c=Math.min(t.totalHeight,a+Math.max(s,G*8)+i),u=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:k("absolute inset-y-0 left-0 w-18",Ys)}),u.map((d,m)=>e.jsxs("div",{className:"absolute inset-x-0",style:{top:`${d.y}px`},children:[e.jsx("div",{className:k("border-t",d.strong?"border-white/14":"border-white/7")}),e.jsx("div",{className:k("absolute left-3 top-0 -translate-y-1/2 font-label text-[9px] tracking-[0.24em]",d.strong?"text-white/38":"text-white/22"),children:d.label})]},`timeline-grid-${m}`))]})}function ni({fromSide:t,toSide:a,height:s,emphasized:i}){const l=la(t),c=la(a),u=`M ${l} 16 C ${l} ${Math.max(40,s*.26)}, ${c} ${Math.max(70,s*.72)}, ${c} ${s-18}`;return e.jsxs("svg",{viewBox:`0 0 100 ${s}`,className:"absolute inset-x-0 top-0 h-full w-full overflow-visible",preserveAspectRatio:"none",children:[e.jsx("path",{d:u,fill:"none",stroke:i?"color-mix(in srgb, var(--ui-ink-strong) 18%, transparent)":"color-mix(in srgb, var(--ui-ink-strong) 11%, transparent)",strokeWidth:i?"1.05":"0.85",strokeDasharray:i?"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:s-18,r:"1.5",fill:"color-mix(in srgb, var(--ui-ink-strong) 26%, transparent)"})]})}function Dt({position:t}){return e.jsx("div",{className:k("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:Zs})})}function li({segment:t}){const a=(t==null?void 0:t.kind)==="stay"?t.placeLabel||t.title||null:(t==null?void 0:t.kind)==="trip"?Ne(t,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}).label:null,s=a||"Beginning of time";return e.jsx("div",{className:"pointer-events-none flex justify-center px-6 py-4",children:e.jsxs("div",{className:Js,children:[e.jsx(Dt,{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(h,{tone:"signal",className:"bg-white/10 text-white/78",children:"Start"}),e.jsx("div",{className:"font-label text-[10px] uppercase tracking-[0.2em] text-white/28",children:"Beginning of history"})]}),e.jsx("div",{className:"mt-5 font-display text-[1.25rem] tracking-normal text-white",children:s}),e.jsx("div",{className:"mt-2 font-label text-[10px] uppercase tracking-[0.22em] text-white/30",children:a?"Oldest loaded known stay":"Earliest known anchor"})]})]})})}function oi(t,a,s){const i=a+Math.max(96,Math.min(s*.28,220)),l=t.items.find(c=>c.boxBottom>=i)??t.items[t.items.length-1]??null;return l?Ca(l.segment.startedAt):null}function da({side:t,vertical:a,emphasized:s=!1}){return e.jsx("div",{className:k(ei,s?"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 di({layout:t,selected:a,onToggle:s}){var m,p,f,y;const{segment:i}=t,l=Et(i),c=t.displayHeight,u=i.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=i.kind==="trip"?{start:Ne(i,"start",{includeCoordinates:!1,useHistoryAnchorFallback:!0}),end:Ne(i,"end",{includeCoordinates:!1})}:null;return e.jsxs("div",{className:k("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:k("absolute inset-y-0 left-1/2 w-px -translate-x-1/2",Xs)}),e.jsx("div",{className:"relative h-full",children:i.kind==="trip"?e.jsxs(ea.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(da,{side:"center",vertical:"top",emphasized:!0}),e.jsx(da,{side:"center",vertical:"bottom",emphasized:!0})]}):null,e.jsx(ni,{fromSide:"center",toSide:"center",height:c,emphasized:a}),e.jsxs("button",{type:"button",onClick:s,className:k(ti,"left-1/2 -translate-x-1/2",a?Pt:""),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-white/34",children:"Move"}),e.jsx("div",{className:"text-[11px] tracking-[0.18em] text-white/44",children:Ke(i.durationSeconds)})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(h,{className:"bg-white/[0.08] text-white/74",children:Le(((m=i.trip)==null?void 0:m.distanceMeters)??0)}),(((p=i.trip)==null?void 0:p.stops.length)??0)>0?e.jsxs(h,{className:"bg-white/[0.08] text-white/74",children:[(f=i.trip)==null?void 0:f.stops.length," stop",((y=i.trip)==null?void 0:y.stops.length)===1?"":"s"]}):null]}),e.jsxs("div",{className:"mt-2 font-label text-[9px] uppercase tracking-[0.22em] text-white/28",children:[W(i.startedAt)," →"," ",W(i.endedAt)]})]})]}):e.jsx(ea.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:s,className:k("group relative w-full overflow-hidden rounded-[24px] border text-left shadow-[var(--ui-shadow-soft)] transition sm:rounded-[30px]",u,a?Pt:"hover:border-[var(--ui-border-strong)]"),style:{minHeight:`${c}px`},children:[e.jsx(Dt,{position:"top"}),e.jsx(Dt,{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(h,{tone:"signal",className:"bg-white/10 text-white/82",children:l?"Sleep":"Stay"}),e.jsx("div",{className:"text-[11px] tracking-[0.16em] text-white/46 sm:text-xs sm:tracking-[0.18em]",children:Ke(i.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-white sm:text-[1.12rem]",children:me(i)}),i.kind==="stay"&&Ie(i)&&!l?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(h,{className:"max-w-full truncate bg-white/[0.08] text-white/76",children:Ie(i)})}):l?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2 sm:mt-3",children:e.jsx(h,{className:k("max-w-full truncate",Pa),children:i.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-white/34 sm:text-[10px] sm:tracking-[0.22em]",children:[W(i.startedAt)," →"," ",W(i.endedAt)]})})]})]})})})]})}const ci="rounded-[28px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-5 shadow-[var(--ui-shadow-floating)]",st="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",it="text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",ca="text-sm leading-6 text-[var(--ui-ink-medium)]",ye="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%)]",ua="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",mi="bg-[var(--ui-accent-soft)] text-[var(--primary)]",ui="mt-4 rounded-[18px] border border-[color-mix(in_srgb,var(--info)_22%,transparent)] bg-[var(--ui-info-soft)] p-3",xi="text-[11px] uppercase tracking-[0.18em] text-[color-mix(in_srgb,var(--info)_70%,var(--ui-ink-strong)_30%)]",hi="mt-2 text-sm leading-6 text-[var(--ui-ink-medium)]",pi="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 gi({segment:t,onEdit:a,onOpenDetail:s,onDefinePlace:i,onClose:l}){var d;const c=Et(t),u=Ie(t);return e.jsxs(N,{className:ci,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:me(t)}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{className:c?ma:t.sourceKind==="user_defined"?mi:ye,children:c?"Virtual":t.sourceKind==="user_defined"?t.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),t.overrideCount>0?e.jsxs(h,{className:ua,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:s,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(Lt,{className:"size-4"})}):null,e.jsx($t,{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:st,children:[e.jsx("div",{className:it,children:"Started"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-strong)]",children:ge(t.startedAt)})]}),e.jsxs("div",{className:st,children:[e.jsx("div",{className:it,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(h,{tone:"signal",children:Ke(t.durationSeconds)}),ot(t)?e.jsxs(e.Fragment,{children:[e.jsx(h,{className:ye,children:Le(t.trip.distanceMeters)}),t.trip.stops.length>0?e.jsxs(h,{className:ye,children:[t.trip.stops.length," stop",t.trip.stops.length===1?"":"s"]}):null]}):null,c?e.jsx(h,{className:ma,children:t.subtitle}):u?e.jsx(h,{className:ye,children:u}):null]}),le(t)&&!c?e.jsxs("div",{className:ui,children:[e.jsx("div",{className:xi,children:"Location label"}),e.jsx("div",{className:hi,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:i,variant:"ghost",className:pi,children:"Label location"})})]}):null,e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:st,children:[e.jsx("div",{className:it,children:"Timeline summary"}),e.jsx("div",{className:`mt-2 ${ca}`,children:t.kind==="stay"?c?`Sleep overlay from ${W(t.startedAt)} to ${W(t.endedAt)}. Underlying movement boxes are sliced virtually while this overlay is visible.`:`Stay block from ${W(t.startedAt)} to ${W(t.endedAt)}.`:t.kind==="trip"?`Connector from ${Ne(t,"start").label} to ${Ne(t,"end").label}.`:`No reliable movement signal reached Forge from ${W(t.startedAt)} to ${W(t.endedAt)}.`})]}),e.jsxs("div",{className:st,children:[e.jsx("div",{className:it,children:"Projection model"}),e.jsx("div",{className:`mt-2 ${ca}`,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(h,{className:ye,children:["Raw stays ",t.rawStayIds.length]}),e.jsxs(h,{className:ye,children:["Raw trips ",t.rawTripIds.length]}),e.jsxs(h,{className:ye,children:["Raw points ",t.rawPointCount]}),t.hasLegacyCorrections?e.jsx(h,{className:ua,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(va,{className:"size-4 text-[var(--primary)]"}),((d=t.stay.place)==null?void 0:d.label)??"No canonical place linked yet"]}):ot(t)?e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"size-4 text-[var(--primary)]"}),t.trip.activityType||t.trip.travelMode]}):t.kind==="trip"?e.jsxs(e.Fragment,{children:[e.jsx(nt,{className:"size-4 text-[var(--primary)]"}),"Repaired movement connector"]}):e.jsxs(e.Fragment,{children:[e.jsx(Nt,{className:"size-4 text-[var(--ui-ink-soft)]"}),"Missing intervals are synthesized from long signal gaps instead of inventing fake travel."]})})]})}function xa({title:t,points:a,averagePoint:s}){const i=Ls(s?[...a,s]:a),l=s?i.length-1:i.length,c=i.slice(0,l),u=s?i[i.length-1]??null:null,d=c.map((m,p)=>`${p===0?"M":"L"} ${m.x} ${m.y}`).join(" ");return e.jsxs(N,{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((m,p)=>e.jsx("circle",{cx:m.x,cy:m.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)"},m.id)),u?e.jsxs("g",{className:"text-[var(--warning)]",children:[e.jsx("circle",{cx:u.x,cy:u.y,r:3,fill:"currentColor"}),e.jsx("circle",{cx:u.x,cy:u.y,r:6,fill:"none",stroke:"currentColor",strokeWidth:"1",strokeDasharray:"2 2",opacity:.48})]}):null]})})]})}const Ft="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",Da="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)]",Pe="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 vi({open:t,anchor:a,items:s,onClose:i}){if(x.useEffect(()=>{if(!t)return;const m=f=>{f.key==="Escape"&&i()},p=()=>i();return window.addEventListener("keydown",m),window.addEventListener("pointerdown",p),()=>{window.removeEventListener("keydown",m),window.removeEventListener("pointerdown",p)}},[i,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),u=Math.min(368,window.innerWidth-24),d=Math.max(12,Math.min(a.right,window.innerWidth-u-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:`${u}px`,maxHeight:`${c}px`},onPointerDown:m=>m.stopPropagation(),children:[e.jsxs(ue,{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:s.map(m=>{const p=m.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:()=>{m.onSelect(),i()},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:m.label}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:m.description})]})]},m.id)})})]})}),document.body)}function fi({open:t,onOpenChange:a,segment:s,detail:i,loading:l,onEdit:c,onDefinePlace:u}){var f;const d=(i==null?void 0:i.segment)??s,m=(i==null?void 0:i.stayDetail)??null,p=(i==null?void 0:i.tripDetail)??null;return e.jsx(qe,{open:t,onOpenChange:a,children:e.jsxs(Qe,{children:[e.jsx(Ue,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(We,{className:k(Ft,"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(ct,{className:"font-display text-[1.3rem] tracking-[-0.03em] text-[var(--ui-ink-strong)]",children:d?`${me(d)} details`:"Movement details"}),e.jsx(mt,{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:k("rounded-full px-3",Pe),disabled:!d.editable||d.kind==="missing",children:[e.jsx(It,{className:"size-4"}),"Edit"]}):null,e.jsx(ut,{asChild:!0,children:e.jsx("button",{type:"button",className:k(Da,"p-2"),children:e.jsx($t,{className:"size-4 rotate-45"})})})]})]}),l?e.jsx(ue,{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(Te,{label:"Started",value:ge(d.startedAt)}),e.jsx(Te,{label:"Ended",value:ge(d.endedAt)}),e.jsx(Te,{label:"Duration",value:Ke(d.durationSeconds)}),e.jsx(Te,{label:"Raw coverage",value:`${d.rawStayIds.length} stays · ${d.rawTripIds.length} trips · ${d.rawPointCount} points`})]}),m?e.jsxs(e.Fragment,{children:[e.jsxs(ue,{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:m.canonicalPlace?`This stay is linked to ${m.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:u,variant:"ghost",className:k("rounded-full px-4",Pe),children:"Label location"})})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(xa,{title:"Stay positions",points:m.positions,averagePoint:m.averagePosition}),e.jsxs(N,{className:"rounded-[28px] p-5",children:[e.jsx(ha,{title:"Stay metrics",rows:[["Canonical place",((f=m.canonicalPlace)==null?void 0:f.label)??"Not linked yet"],["Average position",m.averagePosition?at(m.averagePosition.latitude,m.averagePosition.longitude):"Unavailable"],["Radius",m.radiusMeters!=null?Le(m.radiusMeters):"Unavailable"],["Samples",String(m.sampleCount)]]}),e.jsxs(ue,{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:m.positions.map((y,T)=>e.jsxs("div",{className:"text-sm text-[var(--ui-ink-medium)]",children:[y.label??`Position ${T+1}`,":"," ",at(y.latitude,y.longitude)]},`${y.recordedAt??"stay"}-${T}`))})]})]})]})]}):null,p?e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsx(xa,{title:"Travel map",points:p.positions}),e.jsx(N,{className:"rounded-[28px] p-5",children:e.jsx(ha,{title:"Trip metrics",rows:[["Start position",p.startPosition?at(p.startPosition.latitude,p.startPosition.longitude):"Unavailable"],["End position",p.endPosition?at(p.endPosition.latitude,p.endPosition.longitude):"Unavailable"],["Distance",Le(p.totalDistanceMeters)],["Moving time",na(p.movingSeconds)],["Idle time",na(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 bi({open:t,segment:a,onOpenChange:s,onEdit:i,onOpenDetail:l,onDefinePlace:c}){return e.jsx(qe,{open:t,onOpenChange:s,children:e.jsxs(Qe,{children:[e.jsx(Ue,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(We,{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(ct,{className:"sr-only",children:a?`${me(a)} actions`:"Movement actions"}),e.jsx(mt,{className:"sr-only",children:"Inspect, edit, or label the selected movement box."}),a?e.jsx(gi,{segment:a,onEdit:i,onOpenDetail:l,onDefinePlace:c,onClose:()=>s(!1)}):null]})]})})}function wi({open:t,onOpenChange:a,segment:s,places:i,loading:l,onSelectPlace:c,onCreatePlace:u}){const d=s?At(s):null,[m,p]=x.useState("");x.useEffect(()=>{if(!t){p("");return}p(Ie(s)??"")},[t,s]);const f=x.useMemo(()=>{if(!d)return[];const b=pe(m);return[...i].filter(C=>b.length===0?!0:Is(C).includes(b)).sort((C,E)=>{const H=pe(C.label),V=pe(E.label),_=b.length>0&&H.startsWith(b),Y=b.length>0&&V.startsWith(b);if(_!==Y)return _?-1:1;const Q=rt(d.latitude,d.longitude,C.latitude,C.longitude),X=rt(d.latitude,d.longitude,E.latitude,E.longitude);return Math.abs(Q-X)>1?Q-X:C.label.localeCompare(E.label)}).slice(0,6)},[i,m,d]),y=pe(m),T=f.some(b=>pe(b.label)===y),K=Ie(s);return e.jsx(qe,{open:t,onOpenChange:a,children:e.jsxs(Qe,{children:[e.jsx(Ue,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(We,{className:k(Ft,"top-[8vh] max-h-[84vh] w-[min(38rem,calc(100vw-1.25rem))] rounded-[30px] p-5"),children:[e.jsx(La,{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(ue,{className:"mt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(h,{tone:"signal",children:"Stay center"}),K?e.jsx(h,{tone:"meta",children:K}):null]}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsx(Te,{label:"Latitude",value:d.latitude.toFixed(6)}),e.jsx(Te,{label:"Longitude",value:d.longitude.toFixed(6)})]})]}):e.jsx(ue,{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(O,{value:m,onChange:b=>p(b.target.value),placeholder:"Type a location name or create a new one"}),e.jsxs(ue,{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..."}):f.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:f.map(b=>{const C=d==null?null:rt(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(h,{tone:"meta",children:[Le(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:Pe,children:"Cancel"}),e.jsx(A,{onClick:()=>{!s||!d||u(s,T?"":m.trim())},disabled:!s||!d,children:y.length>0&&!T?`Create "${m.trim()}"`:"Create new location"})]})]})]})})}function yi({open:t,draft:a,creating:s,saving:i,preflight:l,preflightLoading:c,onDraftChange:u,onFitMissing:d,onSave:m,onOpenChange:p}){return e.jsx(qe,{open:t,onOpenChange:p,children:e.jsxs(Qe,{children:[e.jsx(Ue,{className:"surface-overlay fixed inset-0 z-50 backdrop-blur-xl"}),e.jsxs(We,{className:k(Ft,"top-[8vh] w-[min(34rem,calc(100vw-1.25rem))] rounded-[30px] p-5"),children:[e.jsx(La,{title:s?"Create movement box":"Edit movement box",description:a?s?"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(([f,y])=>e.jsx(A,{type:"button",variant:"ghost",className:k(Pe,a.kind===f?"ring-1 ring-[color-mix(in_srgb,var(--primary)_42%,transparent)]":""),onClick:()=>u({...a,kind:f}),children:y},f))})]}),e.jsx(Be,{label:"Label",value:a.label,onChange:f=>u({...a,label:f})}),a.kind!=="trip"?e.jsx(Be,{label:"Place",value:a.placeLabel,placeholder:"Home, Office, Riverside path...",onChange:f=>u({...a,placeLabel:f})}):null,e.jsx(Be,{label:"Tags",value:a.tagsInput,placeholder:"movement, social, errand",onChange:f=>u({...a,tagsInput:f})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(Be,{label:"Started",type:"datetime-local",value:a.startedAtInput,onChange:f=>u({...a,startedAtInput:f})}),e.jsx(Be,{label:"Ended",type:"datetime-local",value:a.endedAtInput,onChange:f=>u({...a,endedAtInput:f})})]}),e.jsxs(ue,{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:Pe,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(ut,{asChild:!0,children:e.jsx(A,{type:"button",variant:"ghost",className:Pe,children:"Cancel"})}),e.jsxs(A,{onClick:m,disabled:!a||i,children:[e.jsx(Wa,{className:"size-4"}),i?"Saving...":s?"Create box":"Save changes"]})]})]})]})})}function La({title:t,description:a,closeLabel:s}){return e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(ct,{className:"font-display text-[1.3rem] tracking-[-0.03em] text-[var(--ui-ink-strong)]",children:t}),e.jsx(mt,{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a})]}),e.jsx(ut,{asChild:!0,children:e.jsx("button",{type:"button",className:k(Da,"p-2"),"aria-label":s,children:s?e.jsx(Lt,{className:"size-4"}):e.jsx($t,{className:"size-4 rotate-45"})})})]})}function Te({label:t,value:a}){return e.jsxs(ue,{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 ha({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(([s,i])=>e.jsxs("div",{className:"text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"text-[var(--ui-ink-faint)]",children:[s,": "]}),i]},s))})]})}function Be({label:t,value:a,onChange:s,placeholder:i,type:l="text"}){return e.jsxs("label",{className:"grid gap-2 text-sm text-[var(--ui-ink-medium)]",children:[t,e.jsx(O,{type:l,value:a,placeholder:i,onChange:c=>s(c.target.value)})]})}function ji({userIds:t=[]}){var Ut,Wt,Gt;const a=ba(),s=x.useRef(null),i=x.useRef(null),l=x.useRef(null),c=x.useRef(!1),u=x.useRef(!1),d=x.useRef(null),[m,p]=x.useState(null),[f,y]=x.useState(!1),[T,K]=x.useState(!1),[b,C]=x.useState(null),[E,H]=x.useState({}),[V,_]=x.useState(null),[Y,Q]=x.useState(null),[X,Z]=x.useState(null),[Ge,$e]=x.useState(null),[Ee,Fe]=x.useState(!1),[Ve,Se]=x.useState(!1),[ht,ke]=x.useState(null),[pt,_e]=x.useState(null),[ae,q]=x.useState(!1),[se,ie]=x.useState(!1),[B,xe]=x.useState(!1),[w,Ye]=x.useState(""),[ve,Xe]=x.useState([]),[he,Ze]=x.useState(0),[R,Re]=x.useState(0),Me=()=>{const n=s.current;n&&(Ze(n.scrollTop),Re(n.clientHeight))},P=Vt({queryKey:["forge-movement-life-timeline",...t],initialPageParam:null,queryFn:({pageParam:n})=>Zt({before:n??void 0,limit:sa,userIds:t}).then(o=>o.movement),getNextPageParam:n=>n.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),j=Vt({queryKey:["forge-movement-life-timeline-data",...t],initialPageParam:null,queryFn:({pageParam:n})=>Zt({before:n??void 0,includeInvalid:!0,limit:sa,userIds:t}).then(o=>o.movement),getNextPageParam:n=>n.nextCursor??void 0,retry:!1,refetchOnWindowFocus:!1}),fe=x.useMemo(()=>{var n;return((n=P.data)==null?void 0:n.pages.flatMap(o=>o.segments))??[]},[P.data]),oe=x.useMemo(()=>{var n;return((n=j.data)==null?void 0:n.pages.flatMap(o=>o.segments))??[]},[j.data]),de=x.useMemo(()=>{var n;return((n=P.data)==null?void 0:n.pages.reduce((o,g)=>Math.max(o,g.invalidSegmentCount??0),0))??0},[P.data]),S=x.useMemo(()=>[...fe].reverse(),[fe]),J=x.useMemo(()=>[...oe].reverse(),[oe]),ze=x.useMemo(()=>{var o;const n=new Map;for(const g of((o=P.data)==null?void 0:o.pages)??[])for(const F of g.sleepOverlays??[])n.set(F.id,F);return[...n.values()].sort((g,F)=>new Date(g.startedAt).getTime()-new Date(F.startedAt).getTime())},[P.data]),be=x.useMemo(()=>Ts(S,ze),[S,ze]),M=x.useMemo(()=>B?be:S,[S,be,B]),Oe=x.useMemo(()=>be.filter(n=>n.syncSource==="sleep overlay"),[be]),re=((Ut=Oe.at(-1))==null?void 0:Ut.id)??null,r=x.useMemo(()=>M.find(n=>n.id===X)??null,[X,M]),v=x.useMemo(()=>M.find(n=>n.id===m)??null,[M,m]),ee=te({queryKey:["forge-movement-box-detail",(r==null?void 0:r.boxId)??null,...t],queryFn:async()=>r!=null&&r.boxId?(await ts(r.boxId,t)).movement:null,enabled:!!(r!=null&&r.boxId)}),U=x.useMemo(()=>S.find(n=>n.id===Ge)??null,[Ge,S]),ne=te({queryKey:["forge-movement-places",...t],queryFn:async()=>(await Sa(t)).places,retry:!1,refetchOnWindowFocus:!1}),I=x.useMemo(()=>Vs({segments:M,viewportHeight:R}),[M,R]),gt=x.useMemo(()=>new Map(I.items.map(n=>[n.segment.id,n])),[I.items]),$a=x.useMemo(()=>{const n=Math.max(0,he-ia),o=he+Math.max(R,G*8)+ia;return I.items.filter(g=>g.segment.id===m?!0:g.boxBottom>=n&&g.boxTop<=o)},[he,m,I.items,R]),Rt=x.useMemo(()=>oi(I,he,R),[he,I,R]),Ea=()=>{var o;const n=(o=l.current)==null?void 0:o.getBoundingClientRect();if(!n){K(g=>!g);return}C({top:n.bottom+10,right:Math.max(12,window.innerWidth-n.right)}),K(g=>!g)},Fa=x.useMemo(()=>[{id:"add-box",label:"Add box",description:"Create a user-defined stay, move, or missing-data interval.",icon:Ga,onSelect:()=>Q(jt("stay",S.at(-1)??null))},{id:"sleep",label:B?"Hide sleep":"Show sleep",description:"Toggle sleep overlays without rewriting the movement boxes.",icon:ga,onSelect:()=>xe(n=>{const o=!n;return o&&re&&(p(re),y(!0)),o})},{id:"view-data",label:"View data",description:"Open the canonical loaded records and raw-data filters.",icon:Nt,onSelect:()=>q(!0)}],[re,S,B]),zt=(n,o="smooth")=>{const g=s.current,F=gt.get(n);if(!g||!F)return;const He=Math.max(0,F.boxTop-g.clientHeight/2+F.displayHeight/2);if(typeof g.scrollTo=="function"){g.scrollTo({top:He,behavior:o});return}g.scrollTop=He};x.useEffect(()=>{ae&&(!j.hasNextPage||j.isFetchingNextPage||j.fetchNextPage())},[ae,j.fetchNextPage,j.hasNextPage,j.isFetchingNextPage]),x.useEffect(()=>{const n=M.at(-1);!u.current&&n&&(u.current=!0,p(n.id))},[M]),x.useEffect(()=>{if(!c.current&&M.length>0){c.current=!0,requestAnimationFrame(()=>{var o;const n=(o=M[M.length-1])==null?void 0:o.id;n&&zt(n,"auto"),requestAnimationFrame(()=>{Me()})});return}if(d.current&&M.length>d.current.count&&s.current){const n=d.current;d.current=null,requestAnimationFrame(()=>{const o=s.current;if(!o)return;const g=I.totalHeight-n.size;o.scrollTop+=g,Me()})}},[M.length,I.totalHeight,gt]),x.useEffect(()=>{if(!s.current)return;const o=()=>{Me()};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),x.useEffect(()=>{if(!m)return;const n=S.find(o=>o.id===m);n&&H(o=>o[m]?o:{...o,[m]:Ct(n)})},[S,m]),x.useEffect(()=>{var n;m&&(M.some(o=>o.id===m)||(p(((n=M.at(-1))==null?void 0:n.id)??null),y(!1)))},[M,m]),x.useEffect(()=>{if(!B||!re)return;const n=M.findIndex(o=>o.id===re);n<0||(p(re),requestAnimationFrame(()=>{var g;const o=(g=M[n])==null?void 0:g.id;o&&zt(o)}))},[M,re,B,gt]);const vt=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"]})])},Ot=Ce({mutationFn:async n=>{const{segment:o,draft:g,creating:F}=n,He=Tt(g,o);if(F){await Yt(He,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 Xt(o.boxId,{...He,metadata:{updatedFrom:"movement-life-timeline"}},t)},onSuccess:vt}),_a=async(n,o)=>{if(n.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");const g=zs(n,o.label);if(n.sourceKind==="user_defined"){await Xt(n.boxId,{...g,metadata:{updatedFrom:"movement-life-timeline-place-label"}},t);return}await Yt({...g,metadata:{createdFrom:"movement-life-timeline-place-label"}},t)},Ht=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(g=>es(g,{placeExternalUid:o.externalUid,placeLabel:o.label})))},Ra=(n,o)=>{const g=At(n);if(!g)return!0;const F=rt(g.latitude,g.longitude,o.latitude,o.longitude);return F<=100||typeof window>"u"||typeof window.confirm!="function"?!0:window.confirm(`"${o.label}" is ${Le(F)} away from this stay's recorded center. Link it anyway?`)},za=Ce({mutationFn:async n=>{const{segment:o,...g}=n,F=await wa(g,t);return o&&le(o)&&await Ht(o,F.place),F},onSuccess:vt}),Oa=Ce({mutationFn:async n=>{const{segment:o,place:g}=n;if(!Ra(o,g))return{assigned:!1};if(le(o))return await Ht(o,g),{assigned:!0};if(o.kind!=="stay")throw new Error("Only stays can be linked to a saved place.");return await _a(o,g),{assigned:!0}},onSuccess:async n=>{n.assigned&&await vt()}}),ft=Ce({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 ${me(n)} with missing data.`},t)},onSuccess:async(n,o)=>{p(g=>g===o.id?null:g),y(!1),_(g=>g===o.id?null:g),a.setQueryData(["forge-movement-life-timeline",...t],g=>oa(g,o.id)),a.setQueryData(["forge-movement-life-timeline-data",...t],g=>oa(g,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(()=>Hs(J),[J]),we=x.useMemo(()=>{const n=pe(w);return[...J].sort((o,g)=>new Date(g.endedAt).getTime()-new Date(o.endedAt).getTime()).filter(o=>(n.length===0||Os(o).includes(n))&&Bs(o,ve))},[J,w,ve]),Bt=x.useMemo(()=>J.length===0?"No movement records loaded yet.":we.length===J.length&&w.trim().length===0&&ve.length===0?`${J.length} loaded movement records visible`:`${we.length} of ${J.length} loaded records visible`,[J.length,we.length,w,ve.length]),bt=fa({count:we.length,getScrollElement:()=>i.current,estimateSize:()=>136,overscan:8}),D=V?S.find(n=>n.id===V)??null:null,Ba=D?E[D.id]??Ct(D):null,Je=Y!==null,$=Y??Ba,Kt=((Wt=S[0])==null?void 0:Wt.startedAt)??null,qt=((Gt=S[S.length-1])==null?void 0:Gt.endedAt)??null,wt=te({queryKey:["forge-movement-user-box-preflight",(D==null?void 0:D.boxId)??"create",($==null?void 0:$.kind)??null,($==null?void 0:$.startedAtInput)??null,($==null?void 0:$.endedAtInput)??null,Kt,qt,...t],enabled:$!==null&<($.startedAtInput)!==null&<($.endedAtInput)!==null,queryFn:async()=>{if(!$)return null;const n=Tt($,D);return(await as({...n,excludeBoxId:(D==null?void 0:D.sourceKind)==="user_defined"?D.boxId:null,rangeStart:Kt,rangeEnd:qt},t)).preflight}}),Qt=n=>{le(n)&&($e(n.id),Fe(!0))},Ka=(n,o)=>{const g=At(n);g&&(Fe(!1),$e(n.id),ke({...g,label:o.trim()||g.label}),_e(n.id),Se(!0))},qa=()=>{const n=s.current;n&&(Ze(n.scrollTop),Re(n.clientHeight),!(!P.hasNextPage||P.isFetchingNextPage)&&n.scrollTop<=960&&(d.current={count:M.length,size:I.totalHeight},P.fetchNextPage()))};if(P.isPending)return e.jsx(ya,{eyebrow:"Movement",title:"Loading life timeline",description:"Reconstructing the longer road of stays, moves, and places.",columns:1,blocks:6});if(P.isError)return e.jsx(ja,{eyebrow:"Movement",error:P.error,onRetry:()=>void P.refetch()});const Qa=I.totalHeight;return e.jsxs("section",{className:"grid gap-4",children:[e.jsxs(N,{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-white/34",children:"Movement"}),e.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-2",children:[de>0?e.jsxs(h,{className:k("hidden sm:inline-flex",Ae),children:[de," invalid hidden"]}):null,e.jsxs(h,{className:"hidden bg-white/[0.06] text-white/68 sm:inline-flex",children:[M.length," visible"]}),e.jsx("div",{ref:l,children:e.jsxs(A,{type:"button",variant:"ghost",size:"sm","aria-expanded":T,"aria-haspopup":"dialog",className:k("h-9 rounded-full border border-white/10 bg-white/[0.05] px-3 text-white/78 hover:bg-white/[0.1] hover:text-white",T?Pt:""),onClick:Ea,children:[e.jsx(Va,{className:"size-4"}),"Actions"]})})]})]}),e.jsx(vi,{open:T,anchor:b,items:Fa,onClose:()=>K(!1)}),B&&Oe.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:s,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(ri,{layout:I,scrollTop:he,viewportHeight:R}),Rt?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:Rt})}):null,e.jsxs("div",{className:"relative",style:{height:`${Qa}px`},children:[I.historyHeaderHeight>0?e.jsx("div",{className:"absolute inset-x-0 top-0",style:{height:`${I.historyHeaderHeight}px`},children:e.jsx(li,{segment:M[0]??null})}):null,$a.map(n=>{const o=n.segment;return e.jsx(di,{layout:n,selected:m===o.id,onToggle:()=>{p(o.id),y(!0)}},o.id)})]})]})]}),e.jsx(yi,{open:D!==null||Y!==null,segment:D,draft:$,creating:Je,saving:Ot.isPending,preflight:wt.data??null,preflightLoading:wt.isFetching,onDraftChange:n=>{if(Je){Q(n);return}D&&H(o=>({...o,[D.id]:n}))},onFitMissing:()=>{const n=wt.data;if(!(n!=null&&n.nearestMissingStartedAt)||!n.nearestMissingEndedAt)return;const o={...$??jt("stay",D),startedAtInput:De(n.nearestMissingStartedAt),endedAtInput:De(n.nearestMissingEndedAt)};if(Je){Q(o);return}D&&H(g=>({...g,[D.id]:o}))},onSave:()=>{$&&Ot.mutateAsync({segment:D,draft:$,creating:Je},{onSuccess:()=>{_(null),Q(null),se&&(ie(!1),q(!0))}})},onOpenChange:n=>{n||(_(null),Q(null),se&&(ie(!1),q(!0)))}}),e.jsx(bi,{open:f&&v!==null,onOpenChange:n=>{y(n)},segment:v,onEdit:()=>{v!=null&&v.editable&&(_(v.id),y(!1))},onOpenDetail:()=>{v&&(Z(v.id),y(!1))},onDefinePlace:()=>{v&&(Qt(v),y(!1))}}),e.jsx(fi,{open:r!==null,onOpenChange:n=>{n||Z(null)},segment:r,detail:ee.data??null,loading:ee.isFetching,onEdit:()=>{!r||!r.editable||(_(r.id),Z(null))},onDefinePlace:()=>{r&&Qt(r)}}),e.jsx(wi,{open:Ee,onOpenChange:n=>{Fe(n),n||$e(null)},segment:U,places:ne.data??[],loading:ne.isFetching,onSelectPlace:async n=>U?(await Oa.mutateAsync({segment:U,place:n})).assigned:!1,onCreatePlace:(n,o)=>{Ka(n,o)}}),e.jsx(Ma,{open:Ve,onOpenChange:n=>{Se(n),n||(ke(null),_e(null))},place:null,seed:ht,onSave:async n=>{await za.mutateAsync({...n,segment:S.find(o=>o.id===pt)??null})}}),e.jsx(Na,{open:ae,onOpenChange:n=>{q(n),n||se||(Ye(""),Xe([]))},eyebrow:"Movement data",title:"View data",description:"",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ka,{title:"",description:"",query:w,onQueryChange:Ye,options:Ha,selectedOptionIds:ve,onSelectedOptionIdsChange:Xe,resultSummary:Bt,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(N,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Canonical boxes"}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/56",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 items-center gap-2",children:[e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/70",onClick:()=>{ie(!0),q(!1),Q(jt("stay",we.at(-1)??null))},children:"Add box"}),e.jsx(h,{tone:"meta",children:Bt}),de>0?e.jsxs(h,{className:Ae,children:[de," invalid hidden included"]}):null,j.hasNextPage?e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full border border-white/10 bg-white/[0.04] px-3 text-white/70",pending:j.isFetchingNextPage,pendingLabel:"Loading…",onClick:()=>void j.fetchNextPage(),children:"Load older"}):null]})]}),e.jsx("div",{ref:i,className:"h-[36rem] overflow-y-auto rounded-[24px] border border-white/8 bg-white/[0.03]",children:we.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-white/50",children:"No movement record matches the current search. Clear filters or load older timeline history."}):e.jsx("div",{className:"relative w-full",style:{height:`${bt.getTotalSize()}px`},children:bt.getVirtualItems().map(n=>{var g;const o=we[n.index];return e.jsx("div",{ref:bt.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-white/8 bg-white/[0.04] 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),q(!1),_(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-white",children:[o.kind==="stay"?e.jsx(va,{className:"size-3.5 shrink-0 text-[var(--primary)]"}):o.kind==="missing"?e.jsx(Nt,{className:"size-3.5 shrink-0 text-[var(--ui-ink-medium)]"}):e.jsx(nt,{className:"size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-sm font-medium",children:me(o)})]}),e.jsxs("div",{className:"mt-1 text-xs text-white/56",children:[dt(o.startedAt)," →"," ",dt(o.endedAt)]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-1.5",children:[e.jsx(h,{tone:o.kind==="trip"?"signal":"meta",children:o.kind==="trip"?"Move":o.kind==="missing"?"Missing":"Stay"}),e.jsx(h,{className:o.sourceKind==="user_defined"?"bg-[var(--ui-accent-soft)] text-[var(--primary)]":"bg-white/[0.06] text-white/70",children:o.sourceKind==="user_defined"?o.origin==="user_invalidated"?"User invalidated":"User-defined":"Automatic"}),e.jsx(h,{tone:"meta",children:Ke(o.durationSeconds)}),o.origin==="continued_stay"?e.jsx(h,{className:Pa,children:"Continued stay"}):null,o.origin==="repaired_gap"?e.jsx(h,{className:Ae,children:"Repaired"}):null,o.kind==="missing"?e.jsx(h,{className:ai,children:"Missing"}):null,o.isInvalid?e.jsx(h,{className:Ae,children:"Invalid"}):null,o.placeLabel?e.jsx(h,{tone:"default",children:o.placeLabel}):null,o.overrideCount>0?e.jsxs(h,{className:Ae,children:["Overrides ",o.overrideCount]}):null,e.jsxs(h,{className:"bg-white/[0.06] text-white/66",children:["Raw stays ",o.rawStayIds.length]}),e.jsxs(h,{className:"bg-white/[0.06] text-white/66",children:["Raw trips ",o.rawTripIds.length]}),e.jsxs(h,{className:"bg-white/[0.06] text-white/66",children:["Raw points ",o.rawPointCount]}),o.hasLegacyCorrections?e.jsx(h,{className:Ae,children:"Legacy corrections"}):null]})]})}),e.jsx(A,{type:"button",variant:"ghost",size:"sm",className:k("h-8 shrink-0 rounded-full border px-2.5",o.sourceKind==="user_defined"?si:ii),pending:ft.isPending&&((g=ft.variables)==null?void 0:g.id)===o.id,pendingLabel:"",onClick:()=>{window.confirm(o.sourceKind==="user_defined"?`Delete ${me(o)} and remove this user-defined box from every synced surface?`:`Invalidate ${me(o)} into missing data and hide the automatic box everywhere?`)&&ft.mutateAsync(o)},children:e.jsx(Ya,{className:"size-3.5"})})]})},o.id)})})})]})]})})]})}function Ni(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}).format(new Date(t))}function Si(t,a){const s=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${s.format(new Date(t))} - ${s.format(new Date(a))}`}function z(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function je(t){return t>=1e3?`${(t/1e3).toFixed(1)} km`:`${Math.round(t)} m`}function ki(t,a){return t==="distanceMeters"?je(a):t==="caloriesKcal"?`${Math.round(a)} kcal`:z(a)}function Ia(t){return t.trim().toLowerCase()}function xt(t){const a=new Date(t).getHours();return a<6?"night":a<12?"morning":a<18?"afternoon":"evening"}function _t(t){return new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}function Mi(t){const a=new Date(t);return Number.isNaN(a.getTime())?"":new Date(a.getTime()-a.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function pa(t){return{recordedAt:Mi(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 Ai(t){return Ia([_t(t.recordedAt),t.externalUid,t.isStopAnchor?"stop anchor stop":"path trace point",t.accuracyMeters!=null?`${Math.round(t.accuracyMeters)} meters accuracy`:"",xt(t.recordedAt)].join(" "))}function Ci(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(h,{tone:"meta",children:"Stop anchors"})}),a.set("anchor:path",{id:"anchor:path",label:"Path points",description:"Non-anchor trace points",badge:e.jsx(h,{tone:"meta",children:"Path points"})}),a.set("accuracy:precise",{id:"accuracy:precise",label:"Precise",description:"GPS accuracy below 20m",badge:e.jsx(h,{tone:"meta",children:"Precise"})}),a.set("accuracy:loose",{id:"accuracy:loose",label:"Loose accuracy",description:"GPS accuracy at or above 20m",badge:e.jsx(h,{tone:"meta",children:"Loose accuracy"})}),t.forEach(s=>{const i=xt(s.recordedAt);a.has(`time:${i}`)||a.set(`time:${i}`,{id:`time:${i}`,label:i,description:"Recorded during this time band",badge:e.jsx(h,{tone:"meta",className:"capitalize",children:i})})}),[...a.values()]}function Ti(t,a){return a.every(s=>s==="anchor:stop"?t.isStopAnchor:s==="anchor:path"?!t.isStopAnchor:s==="accuracy:precise"?t.accuracyMeters!=null&&t.accuracyMeters<20:s==="accuracy:loose"?t.accuracyMeters==null||t.accuracyMeters>=20:s.startsWith("time:")?xt(t.recordedAt)===s.slice(5):!0)}function Pi(t){if(t.length===0)return[];const a=Math.min(...t.map(d=>d.latitude)),s=Math.max(...t.map(d=>d.latitude)),i=Math.min(...t.map(d=>d.longitude)),l=Math.max(...t.map(d=>d.longitude)),c=Math.max(s-a,1e-4),u=Math.max(l-i,1e-4);return t.map(d=>({x:12+(d.longitude-i)/u*76,y:12+(1-(d.latitude-a)/c)*76}))}function Di({curve:t,startLabel:a,endLabel:s,stopLabels:i}){const l=t.map((c,u)=>`${u===0?"M":"Q"} ${c.x} ${c.y}`).join(" ");return e.jsxs(N,{className:"overflow-hidden rounded-[30px] border border-white/10 bg-[radial-gradient(circle_at_top,rgba(114,204,255,0.18),transparent_44%),linear-gradient(180deg,rgba(6,11,26,0.98),rgba(8,14,28,0.92))] 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-white/42",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-white/64",children:"A softened path that prioritizes rhythm, stops, and landmarks over raw map noise."})]}),e.jsxs(h,{tone:"signal",children:[a," → ",s]})]}),e.jsxs("div",{className:"mt-5 rounded-[26px] border border-white/8 bg-[rgba(255,255,255,0.03)] 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:"rgba(255,255,255,0.86)",strokeWidth:"1.5",strokeDasharray:"2.8 2.8",filter:"url(#movementGlow)"}),t.map((c,u)=>e.jsx("g",{children:e.jsx("circle",{cx:c.x,cy:c.y,r:u===0||u===t.length-1?2.6:1.6,fill:u===0||u===t.length-1?"#ffffff":"rgba(170,229,255,0.96)"})},`${c.x}-${c.y}-${u}`))]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:i.map(c=>e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:c},c))})]})]})}function Li({points:t}){const a=Pi(t),s=a.map((i,l)=>`${l===0?"M":"L"} ${i.x} ${i.y}`).join(" ");return e.jsxs(N,{className:"rounded-[30px] border border-white/10 bg-[linear-gradient(180deg,rgba(8,13,25,0.95),rgba(10,17,30,0.88))] 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-white/42",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-white/62",children:"Recent raw points preserved by the companion before long-term simplification."}),e.jsx("div",{className:"mt-5 rounded-[24px] border border-white/8 bg-[rgba(255,255,255,0.03)] 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:"rgba(255,255,255,0.02)"}),e.jsx("path",{d:s,fill:"none",stroke:"rgba(92,225,230,0.95)",strokeWidth:"1.6"}),a.map((i,l)=>e.jsx("circle",{cx:i.x,cy:i.y,r:l===0||l===a.length-1?2:1.1,fill:l===0||l===a.length-1?"#ffffff":"rgba(92,225,230,0.9)"},`${i.x}-${i.y}-${l}`))]})})]})}function Ii({point:t,draft:a}){return e.jsxs(N,{className:"grid gap-4 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(12,18,32,0.98),rgba(8,13,24,0.98))] 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-white/42",children:"Raw datapoint"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:_t(t.recordedAt)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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(h,{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-white/40",children:"Recorded at"}),e.jsx(O,{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-white/40",children:"Speed (m/s)"}),e.jsx(O,{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-white/40",children:"Latitude"}),e.jsx(O,{value:a.latitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Longitude"}),e.jsx(O,{value:a.longitude,disabled:!0})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/40",children:"Accuracy (m)"}),e.jsx(O,{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-white/40",children:"Altitude (m)"}),e.jsx(O,{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:k("h-10 rounded-full border px-4",a.isStopAnchor?"border-[var(--primary)] bg-[var(--primary)]/16 text-white":"border-white/10 bg-white/[0.04] text-white/64"),disabled:!0,children:[e.jsx(nt,{className:"mr-2 size-4"}),a.isStopAnchor?"Stop anchor":"Path point"]}),e.jsxs("div",{className:"text-sm text-white/50",children:["External id: ",e.jsx("span",{className:"text-white/72",children:t.externalUid})]})]}),e.jsx("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm leading-6 text-white/56",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 Ui(){var ze,be,M,Oe,re;const t=ss(),a=ba(),s=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],[i,l]=x.useState("life"),[c,u]=x.useState(new Date().toISOString().slice(0,10)),[d,m]=x.useState(new Date().toISOString().slice(0,7)),[p,f]=x.useState(null),[y,T]=x.useState(!1),[K,b]=x.useState(!1),[C,E]=x.useState(""),[H,V]=x.useState([]),[_,Y]=x.useState(null),[Q,X]=x.useState(null),[Z,Ge]=x.useState({stayIds:[],tripIds:[]}),[$e,Ee]=x.useState(!1),[Fe,Ve]=x.useState(null),[Se,ht]=x.useState(""),[ke,pt]=x.useState("distanceMeters"),_e=x.useRef(null),ae=te({queryKey:["forge-movement-day",c,...s],queryFn:async()=>(await ms({date:c,userIds:s})).movement}),q=te({queryKey:["forge-movement-month",d,...s],queryFn:async()=>(await us({month:d,userIds:s})).movement}),se=te({queryKey:["forge-movement-all-time",...s],queryFn:async()=>(await xs(s)).movement}),ie=te({queryKey:["forge-life-force",...s],queryFn:async()=>(await hs(s)).lifeForce}),B=te({queryKey:["forge-movement-settings",...s],queryFn:async()=>(await ps(s)).settings}),xe=te({queryKey:["forge-movement-places",...s],queryFn:async()=>(await Sa(s)).places}),w=te({queryKey:["forge-movement-trip",p],queryFn:async()=>p?(await gs(p)).movement:null,enabled:!!p}),Ye=te({queryKey:["forge-movement-selection",c,Z.stayIds.join(","),Z.tripIds.join(","),...s],queryFn:async()=>(await vs({...Z,userIds:s})).movement,enabled:Z.stayIds.length>0||Z.tripIds.length>0}),ve=Ce({mutationFn:async r=>is({trackingEnabled:r},s),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-settings"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]})}}),Xe=Ce({mutationFn:async r=>r.id?rs(r.id,r):wa(r,s),onSuccess:async()=>{await a.invalidateQueries({queryKey:["forge-movement-places"]}),await a.invalidateQueries({queryKey:["forge-movement-day"]}),await a.invalidateQueries({queryKey:["forge-movement-all-time"]})}}),he=x.useMemo(()=>{const r=xe.data??[],v=Se.trim().toLowerCase();return v?r.filter(ee=>[ee.label,...ee.aliases,...ee.categoryTags].join(" ").toLowerCase().includes(v)):r},[Se,xe.data]),Ze=x.useMemo(()=>{var r;return Ci(((r=w.data)==null?void 0:r.trip.points)??[])},[(ze=w.data)==null?void 0:ze.trip.points]),R=x.useMemo(()=>{var ee;const r=((ee=w.data)==null?void 0:ee.trip.points)??[],v=Ia(C);return[...r].sort((U,ne)=>new Date(ne.recordedAt).getTime()-new Date(U.recordedAt).getTime()).filter(U=>(v.length===0||Ai(U).includes(v))&&Ti(U,H))},[C,H,(be=w.data)==null?void 0:be.trip.points]),Re=x.useMemo(()=>{var v;const r=((v=w.data)==null?void 0:v.trip.points.length)??0;return r===0?"No raw datapoints on this trip yet.":R.length===r&&C.trim().length===0&&H.length===0?`${r} datapoints visible`:`${R.length} of ${r} datapoints visible`},[R.length,C,H.length,(M=w.data)==null?void 0:M.trip.points.length]),Me=fa({count:R.length,getScrollElement:()=>_e.current,estimateSize:()=>96,overscan:8}),P=R.find(r=>r.id===_)??((Oe=w.data)==null?void 0:Oe.trip.points.find(r=>r.id===_))??R[0]??((re=w.data)==null?void 0:re.trip.points[0])??null;if(x.useEffect(()=>{if(K){if(!P){Y(null),X(null);return}Y(P.id),X(pa(P))}},[P,K]),x.useEffect(()=>{E(""),V([]),Y(null),X(null),b(!1)},[p]),ae.isLoading||q.isLoading||se.isLoading||B.isLoading||xe.isLoading)return e.jsx(ya,{eyebrow:"Movement",title:"Loading movement workspace",description:"Reconstructing stays, trips, and place intelligence across Forge.",columns:2,blocks:8});if(ae.isError||q.isError||se.isError||B.isError||xe.isError||!ae.data||!q.data||!se.data||!B.data)return e.jsx(ja,{eyebrow:"Movement",error:ae.error??q.error??se.error??B.error??xe.error??new Error("Movement data unavailable"),onRetry:()=>{ae.refetch(),q.refetch(),se.refetch(),B.refetch(),xe.refetch()}});const j=ae.data,fe=q.data,oe=se.data,de=B.data,S=Ye.data??j.selectionAggregate,J=j.trips.reduce((r,v)=>r+et(v).totalAp,0);return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(fs,{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:`${j.summary.tripCount} trips today`,actions:e.jsx("div",{className:"flex flex-wrap gap-2",children:["life","day","month","all_time"].map(r=>e.jsx(A,{variant:"ghost",className:k("h-9 rounded-full border px-4 text-sm",i===r?"border-[var(--primary)] bg-[var(--primary)]/16 text-white":"border-white/10 bg-white/[0.04] text-white/64"),onClick:()=>l(r),children:r==="all_time"?"All time":r==="life"?"Life":r.charAt(0).toUpperCase()+r.slice(1)},r))})}),e.jsxs(N,{className:"grid gap-3 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(12,20,34,0.98),rgba(8,14,25,0.96))] p-4 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Movement AP today"}),e.jsx("div",{className:"mt-2 text-3xl font-semibold text-white",children:Jt(J)}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/40",children:"Typical trip drain"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--primary)]",children:j.trips[0]?tt(et(j.trips[0]).rateApPerHour):"0 AP/h"}),e.jsx("div",{className:"mt-2 text-sm text-white/58",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-white/40",children:"Life Force sync"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-white",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-white/58",children:ie.data?`${tt(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(ns,{children:e.jsxs(N,{className:"overflow-hidden rounded-[30px] border border-white/8 bg-[radial-gradient(circle_at_top_left,rgba(107,214,255,0.16),transparent_42%),linear-gradient(180deg,rgba(10,18,35,0.98),rgba(9,15,28,0.92))]",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-white/42",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-white",children:"Background stays and trips as structured life evidence"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/58",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(h,{tone:"signal",children:de.trackingEnabled?"Tracking on":"Tracking off"}),e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/72",children:de.publishMode.replaceAll("_"," ")}),e.jsx(A,{variant:"ghost",className:"h-9 rounded-full border border-white/10 bg-white/[0.04] px-4",onClick:()=>ve.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(N,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Distance today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:je(j.summary.totalDistanceMeters)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Across trips, stops, and linked place changes."})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Idle time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:z(j.summary.totalIdleSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Time spent settled enough to count as a real stay."})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Estimated phone time"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:z(j.summary.estimatedScreenTimeSeconds)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Estimated from hourly Screen Time bins, not exact foreground traces."})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Known places"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:j.summary.knownPlaceCount}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:"Shared between Forge and the iPhone companion."})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(148,163,184,0.12),rgba(71,85,105,0.12))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Missing data"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:z(j.summary.missingDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.missingCount," grey gap",j.summary.missingCount===1?"":"s"," where Forge had over one hour without enough movement signal."]})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(251,191,36,0.12),rgba(16,185,129,0.08))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Repaired gaps"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:z(j.summary.repairedGapDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.repairedGapCount," inferred span",j.summary.repairedGapCount===1?"":"s"," classified as stay or move instead of leaving blank holes in the day."]})]}),e.jsxs(N,{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(56,189,248,0.12),rgba(99,102,241,0.08))] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/40",children:"Continued stays"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:z(j.summary.continuedStayDurationSeconds)}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[j.summary.continuedStayCount," short stationary span",j.summary.continuedStayCount===1?"":"s"," carried forward so quiet home time stays continuous instead of disappearing."]})]})]})]})}),e.jsx(ls,{children:e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",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-white/56",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-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Span"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:z(S.durationSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:je(S.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Work overlap"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:z(S.trackedWorkSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Notes"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.noteCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Estimated phone time"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:z(S.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.pickupCount})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:S.notificationCount})]})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:S.placeLabels.map(r=>e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:r},r))}),S.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:S.topApps.map(r=>e.jsx(h,{tone:"default",className:"bg-[rgba(114,204,255,0.12)] text-white/80",children:(r.displayName||r.bundleIdentifier)+" · "+z(r.totalActivitySeconds)},r.id))}):null,S.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:S.topCategories.map(r=>e.jsx(h,{tone:"default",className:"bg-white/[0.05] text-white/64",children:r.categoryLabel},r.id))}):null]})})]}),i==="life"?e.jsx(os,{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-white/38",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(ji,{userIds:s})]})}):null,i==="day"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.55fr)_minmax(22rem,1fr)]",children:[e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(7,12,22,0.92))] 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-white/42",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-white/58",children:"A single-row timeline from 00:00 to 24:00, always compressed into one navigable strip."})]}),e.jsx(O,{type:"date",value:c,onChange:r=>u(r.target.value),className:"w-[11rem]"})]}),e.jsx("div",{className:"mt-6 overflow-x-auto pb-2",children:e.jsxs("div",{className:"min-w-[52rem]",children:[e.jsx("div",{className:"mb-3 flex justify-between text-[11px] uppercase tracking-[0.18em] text-white/36",children:["00:00","06:00","12:00","18:00","24:00"].map(r=>e.jsx("span",{children:r},r))}),e.jsx("div",{className:"flex h-28 items-stretch overflow-hidden rounded-[28px] border border-white/10 bg-[rgba(255,255,255,0.03)] p-2",children:j.segments.map(r=>{const v=Math.max(9,r.durationSeconds/86400*100),ee=r.kind==="stay"?Z.stayIds.includes(r.id):r.kind==="trip"?Z.tripIds.includes(r.id):!1;return e.jsxs("button",{type:"button",className:k("relative flex min-w-[5.5rem] flex-col justify-between rounded-[22px] border px-3 py-2 text-left transition",r.kind==="missing"?"border-slate-400/20 bg-[linear-gradient(180deg,rgba(148,163,184,0.18),rgba(51,65,85,0.14))] hover:border-slate-300/30 hover:bg-[rgba(148,163,184,0.14)]":ee?"border-[rgba(171,232,255,0.5)] bg-[rgba(171,232,255,0.16)]":"border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.02))] hover:border-white/14 hover:bg-white/[0.08]"),style:{width:`${v}%`},onClick:()=>{r.kind!=="missing"&&Ge(U=>{const ne=new Set(U.stayIds),I=new Set(U.tripIds);return r.kind==="stay"?ne.has(r.id)?ne.delete(r.id):ne.add(r.id):I.has(r.id)?I.delete(r.id):(I.add(r.id),f(r.id)),{stayIds:[...ne],tripIds:[...I]}})},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(h,{tone:r.kind==="trip"?"signal":r.kind==="missing"?"meta":"default",className:"bg-white/[0.08] text-white/82",children:r.kind==="missing"?"gap":r.kind}),e.jsx("span",{className:"text-[11px] text-white/46",children:z(r.durationSeconds)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"line-clamp-2 text-sm font-semibold text-white",children:r.label}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-white/52",children:r.subtitle})]})]},r.id)})})]})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(h,{tone:"signal",children:Ni(c)}),e.jsxs(h,{tone:"default",className:"bg-white/[0.06] text-white/72",children:[j.summary.tripCount," trips"]}),e.jsxs(h,{tone:"default",className:"bg-white/[0.06] text-white/72",children:[j.summary.stayCount," stays"]}),e.jsxs(h,{tone:"meta",children:[j.summary.missingCount," gaps"]})]})]}),e.jsx("div",{className:"grid gap-4",children:w.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-white/42",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-white/10 bg-white/[0.04] px-4",onClick:()=>T(r=>!r),children:y?"Stylized graph":"Exact path"})})]}),y?e.jsx(Li,{points:w.data.trip.points}):e.jsx(Di,{curve:w.data.stylizedPath.curve,startLabel:w.data.stylizedPath.startLabel,endLabel:w.data.stylizedPath.endLabel,stopLabels:w.data.stylizedPath.stops.map(r=>r.label)}),e.jsxs(N,{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Trip context"}),(()=>{const r=et(w.data.trip);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{tone:"signal",children:je(w.data.trip.distanceMeters)}),e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:w.data.trip.activityType||w.data.trip.travelMode}),e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:z(w.data.trip.durationSeconds)}),e.jsx(h,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:tt(r.rateApPerHour)}),e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:Jt(r.totalAp)})]})})})(),e.jsx("div",{className:"mt-4 text-sm leading-6 text-white/58",children:Si(w.data.trip.startedAt,w.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-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Hourly estimate"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:z(w.data.trip.estimatedScreenTimeSeconds)})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Pickups"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:w.data.trip.pickupCount})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.04] p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Notifications"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:w.data.trip.notificationCount})]})]}),e.jsx("div",{className:"mt-3 text-xs leading-5 text-white/48",children:"Derived from Screen Time hourly bins, not exact foreground traces."}),w.data.trip.topApps.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:w.data.trip.topApps.map(r=>e.jsx(h,{tone:"default",className:"bg-[rgba(114,204,255,0.12)] text-white/80",children:(r.displayName||r.bundleIdentifier)+" · "+z(r.totalActivitySeconds)},r.id))}):null,w.data.trip.topCategories.length>0?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:w.data.trip.topCategories.map(r=>e.jsx(h,{tone:"default",className:"bg-white/[0.05] text-white/64",children:r.categoryLabel},r.id))}):null]})]}):e.jsx(N,{className:"rounded-[30px] border border-dashed border-white/12 bg-white/[0.03] p-6 text-white/58",children:"Select a trip segment to open the stylized trajectory card and exact path toggle."})})]}):null,i==="month"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.85fr)]",children:[e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(9,15,28,0.97),rgba(8,13,24,0.92))] 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-white/42",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-white/58",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(O,{type:"month",value:d,onChange:r=>m(r.target.value),className:"w-[10.5rem]"}),["distanceMeters","movingSeconds","idleSeconds","caloriesKcal"].map(r=>e.jsx(A,{variant:"ghost",className:k("h-9 rounded-full border px-4 text-sm",ke===r?"border-[var(--primary)] bg-[var(--primary)]/14 text-white":"border-white/10 bg-white/[0.04] text-white/62"),onClick:()=>pt(r),children:r==="distanceMeters"?"Distance":r==="movingSeconds"?"Moving":r==="idleSeconds"?"Idle":"Calories"},r))]})]}),e.jsx("div",{className:"mt-6 h-[24rem]",children:e.jsx(bs,{width:"100%",height:"100%",children:e.jsxs(ws,{data:fe.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:"rgba(110,220,255,0.7)"}),e.jsx("stop",{offset:"100%",stopColor:"rgba(110,220,255,0.05)"})]})}),e.jsx(ys,{stroke:"rgba(255,255,255,0.08)",vertical:!1}),e.jsx(js,{dataKey:"dateKey",tick:{fill:"rgba(255,255,255,0.46)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(Ns,{tick:{fill:"rgba(255,255,255,0.46)",fontSize:11},axisLine:!1,tickLine:!1}),e.jsx(Ss,{contentStyle:{background:"rgba(7,12,24,0.94)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:16},formatter:r=>ki(ke,Number(r))}),e.jsx(ks,{type:"monotone",dataKey:ke,stroke:"rgba(126,233,255,0.95)",fill:"url(#movementMonthFill)",strokeWidth:2.4})]})})})]}),e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Month totals"}),e.jsxs("div",{className:"mt-5 grid gap-3",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:je(fe.totals.distanceMeters)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Moving time"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:z(fe.totals.movingSeconds)})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Settled time"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:z(fe.totals.idleSeconds)})]})]})]})]}):null,i==="all_time"?e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(20rem,0.95fr)]",children:[e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(8,13,25,0.97),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(N,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Trips"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:oe.summary.tripCount})]}),e.jsxs(N,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Known places"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:oe.summary.knownPlaceCount})]}),e.jsxs(N,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Distance"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:je(oe.summary.totalDistanceMeters)})]}),e.jsxs(N,{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Countries"}),e.jsx("div",{className:"mt-2 text-3xl text-white",children:oe.summary.visitedCountries})]})]}),e.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2",children:oe.recentTrips.map(r=>e.jsx("button",{type:"button",className:"rounded-[24px] border border-white/8 bg-white/[0.03] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>{l("day"),f(r.id)},children:(()=>{const v=et({startedAt:r.startedAt,endedAt:new Date(new Date(r.startedAt).getTime()+36e5).toISOString(),expectedMet:2});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/36",children:"Recent travel"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:r.label||"Untitled trip"}),e.jsxs("div",{className:"mt-1 text-sm text-white/56",children:[je(r.distanceMeters)," · ",r.activityType||"travel"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(h,{tone:"default",className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:tt(v.rateApPerHour)})})]})})()},r.id))})]}),e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Place categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:oe.categoryBreakdown.map(r=>e.jsxs(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:[r.tag," · ",r.count]},r.tag))})]})]}):null,e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(22rem,0.95fr)]",children:[e.jsx(ds,{children:e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(8,14,28,0.96),rgba(9,15,28,0.92))] 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-white/42",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-white/58",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(O,{value:Se,onChange:r=>ht(r.target.value),placeholder:"Search places",className:"w-[11rem]"}),e.jsx(A,{onClick:()=>{Ve(null),Ee(!0)},children:"Add place"})]})]}),e.jsx("div",{className:"mt-5 grid gap-3",children:he.map(r=>e.jsxs("button",{type:"button",className:"flex items-start justify-between gap-3 rounded-[24px] border border-white/8 bg-white/[0.03] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>{Ve(r),Ee(!0)},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-lg text-white",children:r.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/56",children:[r.latitude.toFixed(4),", ",r.longitude.toFixed(4)," · radius ",Math.round(r.radiusMeters)," m"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:r.categoryTags.map(v=>e.jsx(h,{tone:"default",className:"bg-white/[0.06] text-white/74",children:v},v))})]}),e.jsx(It,{className:"mt-1 size-4 text-white/42"})]},r.id))})]})}),e.jsxs(N,{className:"rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(10,17,31,0.96),rgba(8,13,24,0.92))] p-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/42",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-white/58",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(h,{className:"bg-white/[0.06] text-white/74",children:"Life graph"}),e.jsx(h,{className:"bg-white/[0.06] text-white/74",children:"Day strip"}),e.jsx(h,{className:"bg-white/[0.06] text-white/74",children:"Month chart"}),e.jsx(h,{className:"bg-white/[0.06] text-white/74",children:"Known places"}),e.jsx(h,{className:"bg-white/[0.06] text-white/74",children:"Selection aggregate"})]})]})]}),w.data?e.jsx(Na,{open:K,onOpenChange:r=>{b(r),r||(E(""),V([]),Y(null),X(null))},eyebrow:"Movement data",title:w.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(cs,{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(ka,{title:"Datapoint browser",description:"Search raw points by time band, anchor status, or accuracy before opening the point editor.",query:C,onQueryChange:E,options:Ze,selectedOptionIds:H,onSelectedOptionIdsChange:V,resultSummary:Re,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(N,{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-white/45",children:"Raw datapoints"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Open a point to correct or delete it."})]}),e.jsx(h,{tone:"meta",children:Re})]}),e.jsx("div",{ref:_e,className:"h-[34rem] overflow-y-auto rounded-[24px] border border-white/8 bg-white/[0.03]",children:R.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm leading-6 text-white/50",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:`${Me.getTotalSize()}px`},children:Me.getVirtualItems().map(r=>{const v=R[r.index];return e.jsx("div",{className:"absolute left-0 top-0 w-full px-3 py-2",style:{transform:`translateY(${r.start}px)`},children:e.jsxs("button",{type:"button",className:k("grid w-full gap-3 rounded-[20px] border px-4 py-3 text-left transition",_===v.id?"border-[rgba(171,232,255,0.34)] bg-[rgba(171,232,255,0.12)]":"border-white/8 bg-white/[0.04] hover:bg-white/[0.07]"),onClick:()=>{Y(v.id),X(pa(v))},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-white",children:[e.jsx(Xa,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-base font-medium",children:_t(v.recordedAt)})]}),e.jsxs("div",{className:"mt-2 text-sm text-white/56",children:[v.latitude.toFixed(5),", ",v.longitude.toFixed(5)]})]}),e.jsx(h,{tone:v.isStopAnchor?"signal":"meta",children:v.isStopAnchor?"Stop anchor":"Path point"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{tone:"meta",className:"capitalize",children:xt(v.recordedAt)}),v.accuracyMeters!=null?e.jsxs(h,{tone:"meta",children:[Math.round(v.accuracyMeters)," m accuracy"]}):null,v.speedMps!=null?e.jsxs(h,{tone:"meta",children:[v.speedMps.toFixed(1)," m/s"]}):null]})]})},v.id)})})})]})]}),P&&Q?e.jsx(Ii,{point:P,draft:Q}):e.jsx(N,{className:"rounded-[28px] border border-dashed border-white/12 bg-white/[0.03] p-6 text-white/56",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(Ma,{open:$e,onOpenChange:Ee,place:Fe,onSave:async r=>{await Xe.mutateAsync(r)}})]})}export{Ui as MovementPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as r,r as w}from"./vendor-kIz9EZnX.js";import{Z as x,cL as b,bq as $}from"./index-BHIKoiZ6.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
|
+
`),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
|
+
`)})},`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-kIz9EZnX.js";import{m as c,c as s}from"./index-BHIKoiZ6.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 p(o){const r=o.trim();if(!r)return null;const t=new Date(r);return Number.isNaN(t.getTime())?null:t.toISOString()}function f(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 v(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 h({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{h as N,v as b,f,l as n,p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as p,j as e,aK as Ce,cu as Me,b3 as Qe,b5 as Re,c2 as ze,bg as He,ce as Ye,c7 as Ge,b4 as Je,ca as We}from"./vendor-kIz9EZnX.js";import{j as Xe,i as F,k as ie}from"./state-VYvD1QVP.js";import{b as Fe,c as z,Z as Ze,u as et,g as f,bk as b,bl as k,ao as tt,bm as at,bn as st,bo as W,bp as De,bq as Ie,E as it,B as Q,C as I,h as B,d as nt,br as rt,I as D,bs as lt,T as _e,m as Le,a as ot,bt as dt,bu as ct,bv as ut,i as pt,bw as mt,bx as ht,by as xt,bz as gt,bA as yt,bB as vt,bC as ft,O as bt,bD as kt}from"./index-BHIKoiZ6.js";import{N as ne}from"./note-markdown-CsGQhQXF.js";import{n as Z,N as re,f as jt,p as wt,b as Nt}from"./note-tags-input-DdZi93tj.js";import{P as Tt}from"./page-hero-oFHaAjtL.js";import{F as St}from"./floating-action-menu-zzC2r0Ob.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./board-DqHzdCPQ.js";import"./graph-BTa79qum.js";function At(i){return i.trim().toLowerCase()}function Ct(i,l){return i.includes(l)?i:[...i,l]}function Mt({entityOptions:i,selectedEntityValues:l,onSelectedEntityValuesChange:d,selectedTextTerms:u,onSelectedTextTermsChange:_,placeholder:j="Filter by linked entity or add free text"}){const[S,A]=p.useState(""),[ee,g]=p.useState(!1),[H,y]=p.useState(0),P=At(S),C=p.useMemo(()=>l.map(s=>i.find(c=>c.value===s)).filter(Boolean),[i,l]),L=p.useMemo(()=>{const s=i.filter(c=>!l.includes(c.value));return P?s.filter(c=>`${c.label} ${c.description??""} ${c.searchText??""}`.toLowerCase().includes(P)).slice(0,8):s.slice(0,8)},[i,P,l]),w=S.trim().length>0&&!u.includes(S.trim()),Y=s=>{d(Ct(l,s)),A(""),y(0),g(!1)},K=(s=S)=>{const c=s.trim();!c||u.includes(c)||(_([...u,c]),A(""),y(0),g(!1))},q=s=>{d(l.filter(c=>c!==s))},m=s=>{_(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-white/40",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:!w,className:"rounded-full border border-white/8 bg-white/[0.04] px-2.5 py-1 text-[10px] tracking-[0.14em] text-white/62 transition hover:bg-white/[0.08] hover:text-white disabled:cursor-not-allowed disabled:opacity-40",children:"Free text"})]}),e.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(135deg,rgba(19,28,48,0.88),rgba(10,14,26,0.98))] px-4 py-3 shadow-[0_24px_70px_rgba(3,8,18,0.2)]",children:[C.length>0||u.length>0?e.jsxs("div",{className:"mb-3 flex flex-wrap gap-2",children:[C.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-2 rounded-full border border-white/8 bg-white/[0.06] px-2.5 py-1.5",children:[s.kind?e.jsx(Fe,{kind:s.kind,label:s.label,compact:!0,gradient:!1,className:"max-w-[16rem]"}):e.jsx(z,{className:"bg-white/[0.08] text-white/78",children:s.label}),e.jsx("button",{type:"button",className:"rounded-full text-white/50 transition hover:text-white",onClick:()=>q(s.value),"aria-label":`Remove ${s.label}`,children:e.jsx(Ce,{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-cyan-300/16 bg-cyan-400/10 px-2.5 py-1.5 text-sm text-cyan-50",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Me,{className:"size-3.5"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:s})]}),e.jsx("button",{type:"button",className:"rounded-full text-cyan-100/70 transition hover:text-white",onClick:()=>m(s),"aria-label":`Remove free-text filter ${s}`,children:e.jsx(Ce,{className:"size-3.5"})})]},s))]}):null,u.length>1?e.jsx("div",{className:"mb-3 text-xs text-white/42",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-white/34"}),e.jsx("input",{value:S,onChange:s=>{A(s.target.value),g(!0),y(0)},onFocus:()=>g(!0),onBlur:()=>{window.setTimeout(()=>g(!1),120)},onKeyDown:s=>{if(s.key==="Backspace"&&!S){if(u.length>0){m(u[u.length-1]);return}l.length>0&&q(l[l.length-1]);return}if(s.key==="ArrowDown"){s.preventDefault(),g(!0),y(N=>L.length===0?0:Math.min(L.length-1,N+1));return}if(s.key==="ArrowUp"){s.preventDefault(),y(N=>Math.max(0,N-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-white placeholder:text-white/34 focus:outline-none"})]}),ee?e.jsxs("div",{className:"absolute top-full z-20 mt-2 w-full rounded-[22px] border border-white/8 bg-[rgba(8,13,24,0.96)] p-2 shadow-[0_26px_60px_rgba(4,8,18,0.32)] 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-white/[0.1] text-white":"text-white/70 hover:bg-white/[0.06] hover:text-white"),onMouseEnter:()=>y(c),onMouseDown:N=>N.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(Fe,{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-white/46",children:s.description}):null]})},s.value)),w?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-cyan-100 transition hover:bg-white/[0.06]",onMouseDown:s=>s.preventDefault(),onClick:()=>K(),children:[e.jsx(Me,{className:"size-4"}),e.jsxs("span",{className:"truncate",children:['Add free text "',S.trim(),'"']})]}):null,L.length===0&&!w?e.jsx("div",{className:"px-3 py-2.5 text-sm text-white/42",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 Be(i){return Ft.has(i)}function h(i,l){return`${i}:${l}`}function X(i){const l=i.indexOf(":");if(l<=0||l>=i.length-1)return null;const d=i.slice(0,l);return Be(d)?{entityType:d,entityId:i.slice(l+1)}:null}function Ee(i){return i!==null}function qe(i){const l=i.getAll("linkedTo"),d=i.get("entityType"),u=i.get("entityId");return d&&u&&Be(d)&&l.unshift(h(d,u)),Array.from(new Set(l.map(_=>_.trim()).filter(Boolean)))}function Dt(i){return Array.from(new Set(i.getAll("textTerms").map(l=>l.trim()).filter(Boolean)))}function It(i){return Z(i.getAll("tags"))}function R(i,l=[]){return{contentMarkdown:(i==null?void 0:i.contentMarkdown)??"",author:(i==null?void 0:i.author)??"",linkedValues:(i==null?void 0:i.links.map(d=>h(d.entityType,d.entityId)))??l,tags:Z((i==null?void 0:i.tags)??[]),destroyAtInput:jt((i==null?void 0:i.destroyAt)??null),destroyDelayValue:"",destroyDelayUnit:"days"}}function _t(i){return[...i].sort((l,d)=>l.label.localeCompare(d.label))}function $e(i){return wt(i.destroyAtInput)??Nt(i.destroyDelayValue,i.destroyDelayUnit)}function Ht(){var ve,fe,be,ke,je,we,Ne,Te;const i=Re(),l=Xe(),d=et(),[u,_]=ze(),[j,S]=p.useState(()=>qe(u)),[A,ee]=p.useState(()=>It(u)),[g,H]=p.useState(()=>Dt(u)),[y,P]=p.useState(u.get("author")??""),[C,L]=p.useState(u.get("updatedFrom")??""),[w,Y]=p.useState(u.get("updatedTo")??""),[K,q]=p.useState(!1),[m,s]=p.useState(()=>R(null,qe(u))),[c,N]=p.useState(null),[v,T]=p.useState(null),[$,le]=p.useState(null),oe=F({queryKey:["forge-psyche-values"],queryFn:mt}),de=F({queryKey:["forge-psyche-patterns"],queryFn:ht}),ce=F({queryKey:["forge-psyche-behaviors"],queryFn:xt}),ue=F({queryKey:["forge-psyche-beliefs"],queryFn:gt}),pe=F({queryKey:["forge-psyche-modes"],queryFn:yt}),me=F({queryKey:["forge-psyche-flashcards"],queryFn:vt}),he=F({queryKey:["forge-psyche-reports"],queryFn:ft}),xe=Array.isArray(d.selectedUserIds)?d.selectedUserIds:[],U=F({queryKey:["forge-life-force",...xe],queryFn:async()=>(await bt(xe)).lifeForce});p.useEffect(()=>{const a=new URLSearchParams;for(const n of j)a.append("linkedTo",n);for(const n of A)a.append("tags",n);for(const n of g)a.append("textTerms",n);y.trim()&&a.set("author",y.trim()),C&&a.set("updatedFrom",C),w&&a.set("updatedTo",w),_(a,{replace:!0})},[y,j,A,g,_,C,w]);const G=p.useMemo(()=>{var n,x,J,o,r,Se,Ae;const a=[...d.snapshot.goals.map(t=>({value:h("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:h("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:h("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:h("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:h("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:h("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=oe.data)==null?void 0:n.values)??[]).map(t=>({value:h("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})),...(((x=de.data)==null?void 0:x.patterns)??[]).map(t=>({value:h("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})),...(((J=ce.data)==null?void 0:J.behaviors)??[]).map(t=>({value:h("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})),...(((o=ue.data)==null?void 0:o.beliefs)??[]).map(t=>({value:h("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=pe.data)==null?void 0:r.modes)??[]).map(t=>({value:h("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=me.data)==null?void 0:Se.flashcards)??[]).map(t=>({value:h("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})),...(((Ae=he.data)==null?void 0:Ae.reports)??[]).map(t=>({value:h("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 _t(a)},[(ve=ce.data)==null?void 0:ve.behaviors,(fe=ue.data)==null?void 0:fe.beliefs,(be=me.data)==null?void 0:be.flashcards,(ke=pe.data)==null?void 0:ke.modes,(je=de.data)==null?void 0:je.patterns,(we=he.data)==null?void 0:we.reports,d.snapshot.dashboard.projects,d.snapshot.goals,d.snapshot.habits,d.snapshot.strategies,d.snapshot.tags,d.snapshot.tasks,(Ne=oe.data)==null?void 0:Ne.values]),Pe=p.useMemo(()=>G.map(a=>{const n=X(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)??""}}),[G]),Ke=p.useMemo(()=>j.map(a=>X(a)).filter(Boolean),[j]),O=F({queryKey:["notes-index",j.join("|"),A.join("|"),g.join("|"),y.trim(),C,w],queryFn:()=>kt({linkedTo:Ke,tags:A,textTerms:g,author:y.trim()||void 0,updatedFrom:C||void 0,updatedTo:w||void 0,limit:200})}),te=async()=>{await Promise.all([l.invalidateQueries({queryKey:["notes-index"]}),pt(l)])},ge=ie({mutationFn:async a=>tt({contentMarkdown:a.contentMarkdown.trim(),author:a.author.trim()||null,tags:Z(a.tags),destroyAt:$e(a),links:a.linkedValues.map(n=>X(n)).filter(Ee).map(n=>({entityType:n.entityType,entityId:n.entityId}))}),onSuccess:async()=>{s(R(null,j)),q(!1),await te()}}),ye=ie({mutationFn:async({noteId:a,draft:n})=>at(a,{contentMarkdown:n.contentMarkdown.trim(),author:n.author.trim()||null,tags:Z(n.tags),destroyAt:$e(n),links:n.linkedValues.map(x=>X(x)).filter(Ee).map(x=>({entityType:x.entityType,entityId:x.entityId}))}),onSuccess:async()=>{N(null),T(null),await te()}}),ae=ie({mutationFn:a=>st(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*W().totalAp,M=$?V.find(a=>a.id===$.noteId)??null:null,se=M?De(M):null,E=se?Ie(se.entityType,se.entityId):null,Ve=p.useMemo(()=>M?[{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:()=>{N(M.id),T(R(M))}},{id:"delete-note",label:"Delete note",description:"Soft-delete this note from the main workspace.",icon:Ge,tone:"danger",disabled:ae.isPending,onSelect:()=>{ae.mutateAsync(M.id)}}]:[],[E,M,ae,i]);return O.isError?e.jsx(it,{eyebrow:"Notes",error:O.error,onRetry:()=>void O.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Tt,{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)),q(!0)},children:[e.jsx(Je,{className:"size-4"}),"New note"]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(I,{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:B(W().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(I,{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:B(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(I,{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?`${B(U.data.spentTodayAp)} / ${B(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(I,{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?nt(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(rt,{children:e.jsxs(I,{className:"grid gap-4",children:[e.jsx(Mt,{entityOptions:Pe,selectedEntityValues:j,onSelectedEntityValuesChange:S,selectedTextTerms:g,onSelectedTextTermsChange:H}),e.jsx(re,{value:A,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:y,onChange:a=>P(a.target.value),placeholder:"Filter by author"}),e.jsx(D,{type:"date",value:C,onChange:a=>L(a.target.value)}),e.jsx(D,{type:"date",value:w,onChange:a=>Y(a.target.value)})]})]})}),K?e.jsx(lt,{children:e.jsxs(I,{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"," ",B(W().totalAp),"."]})]}),e.jsx(Q,{variant:"ghost",onClick:()=>{q(!1),s(R(null,j))},children:"Cancel"})]}),e.jsx(_e,{value:m.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:m.author,onChange:a=>s(n=>({...n,author:a.target.value})),placeholder:"Optional author"}),e.jsx(Le,{options:G,selectedValues:m.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:m.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:m.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:m.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:m.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:m.contentMarkdown.trim()?e.jsx(ne,{markdown:m.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:m.contentMarkdown.trim().length===0||m.linkedValues.length===0,onClick:()=>void ge.mutateAsync(m),children:"Save note"})})]})}):null,O.isLoading?e.jsx(I,{className:"text-sm text-[var(--ui-ink-soft)]",children:"Loading notes…"}):V.length===0?e.jsx(ot,{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(dt,{children:e.jsx("div",{className:"grid gap-3",children:V.map(a=>{const n=De(a),x=n?Ie(n.entityType,n.entityId):null,J=c===a.id&&v!==null;return e.jsxs(I,{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:[B(W().totalAp)," ","quick note"]}),a.links.map(o=>e.jsxs(z,{className:"bg-[var(--ui-surface-3)] text-[var(--ui-ink-soft)]",wrap:!0,children:[ct(o.entityType),o.anchorKey?` · ${ut(o.anchorKey)}`:""]},`${a.id}-${o.entityType}-${o.entityId}-${o.anchorKey??""}`)),(a.tags??[]).map(o=>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:o},`${a.id}-tag-${o}`)),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:o=>{o.preventDefault(),o.stopPropagation();const r=o.currentTarget.getBoundingClientRect();le({noteId:a.id,position:{x:r.right-8,y:r.bottom+8}})},"aria-label":`Open actions for note ${a.id}`,children:e.jsx(We,{className:"size-4"})})]}),J?e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsx(_e,{value:v.contentMarkdown,onChange:o=>T(r=>r&&{...r,contentMarkdown:o.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:v.author,onChange:o=>T(r=>r&&{...r,author:o.target.value}),placeholder:"Optional author"}),e.jsx(Le,{options:G,selectedValues:v.linkedValues,onChange:o=>T(r=>r&&{...r,linkedValues:o}),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:v.tags,onChange:o=>T(r=>r&&{...r,tags:o})}),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:v.destroyAtInput,onChange:o=>T(r=>r&&{...r,destroyAtInput:o.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:v.destroyDelayValue,onChange:o=>T(r=>r&&{...r,destroyDelayValue:o.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:v.destroyDelayUnit,onChange:o=>T(r=>r&&{...r,destroyDelayUnit:o.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:v.contentMarkdown.trim()?e.jsx(ne,{markdown:v.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:()=>{N(null),T(null)},children:"Cancel"}),e.jsx(Q,{pending:ye.isPending,pendingLabel:"Saving",disabled:v.contentMarkdown.trim().length===0||v.linkedValues.length===0,onClick:()=>void ye.mutateAsync({noteId:a.id,draft:v}),children:"Save changes"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"mt-4 w-full text-left",onClick:()=>{x&&i(x.includes("#")?x:`${x}#notes`)},disabled:!x,children:e.jsx(ne,{markdown:a.contentMarkdown,className:"line-clamp-none"})}),x?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:!!$,title:"Note actions",subtitle:M?M.contentPlain.slice(0,80)||"Markdown note":void 0,items:Ve,position:($==null?void 0:$.position)??null,onClose:()=>le(null)})]})}export{Ht as NotesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b5 as p,j as s,aU as c}from"./vendor-
|
|
1
|
+
import{b5 as p,j as s,aU as c}from"./vendor-kIz9EZnX.js";import{B as u,cK as m}from"./index-BHIKoiZ6.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as w,j as r,aC as R}from"./vendor-kIz9EZnX.js";import{Z as O}from"./index-BHIKoiZ6.js";import{m as B}from"./motion-CfdU2F35.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 E,j as e,aC as S}from"./vendor-kIz9EZnX.js";import{A as U}from"./ai-surface-workspace-xtB5RFQu.js";import{i as $}from"./state-VYvD1QVP.js";import{P as B,u as Q,bE as z,h as R,d as L,bF as D,c as p,aq as G,Z as J,C as M,b as Y,V as Z,W as ee,_ as te,bG as ie,bH as se,bI as ae,bJ as re,bK as ne,bL as le,bM as oe,be as de,bN as ce}from"./index-BHIKoiZ6.js";import{F as ue}from"./flagship-signal-deck-BEFKOhvx.js";import{L as me}from"./life-force-workspace-CLVexVnb.js";import{E as pe}from"./entity-note-count-link-BrS1-O0o.js";import{P as fe}from"./page-hero-oFHaAjtL.js";import{a as ve,g as xe}from"./activity-copy-Bj4h9OcF.js";import"./board-DqHzdCPQ.js";import"./motion-CfdU2F35.js";import"./ui-CsEkP2V8.js";import"./forms-CmLAyGqz.js";import"./graph-BTa79qum.js";import"./floating-action-menu-zzC2r0Ob.js";import"./charts-FcU0F3XV.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 y=t.indexOf(v);y!==-1&&t.splice(y,1)}const b=t.indexOf("goals");return t.splice(b===-1?0:b,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 be(a){return a>=1e3?`${(a/1e3).toFixed(1)} km`:`${Math.round(a)} m`}function ye(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 Ee(){var X,C;const{t:a}=B(),n=Q(),t=n.snapshot,r=Array.isArray(n.selectedUserIds)?n.selectedUserIds:[],j=r.join("|"),[c,x]=E.useState(!1);E.useEffect(()=>{x(!1);const i=window.setTimeout(()=>{x(!0)},650);return()=>window.clearTimeout(i)},[j]);const g=ge(),b=$({queryKey:["forge-overview-sleep",...r],queryFn:async()=>(await le(r)).sleep,enabled:c,staleTime:6e4})??{},v=$({queryKey:["forge-overview-fitness",...r],queryFn:async()=>(await oe(r)).fitness,enabled:c,staleTime:6e4})??{},y=$({queryKey:["forge-overview-movement-day",g,...r],queryFn:async()=>(await de({date:g,userIds:r})).movement,enabled:c,staleTime:6e4})??{},H=$({queryKey:["forge-overview-vitals",...r],queryFn:async()=>(await ce(r)).vitals,enabled:c,staleTime:6e4})??{},I=z(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=b.data)==null?void 0:X.summary)??null,h=((C=v.data)==null?void 0:C.summary)??null,l=y.data,F=H.data??null,A=ke(F??void 0),O=ye(l),T=k!==null||h!==null||F!==null,W=l!==void 0&&(l.summary.tripCount>0||l.summary.stayCount>0||l.summary.totalMovingSeconds>0||O.length>0),K=t.lifeForce?[{label:"Life Force",value:`${Math.round(t.lifeForce.spentTodayAp)} / ${Math.round(t.lifeForce.dailyBudgetAp)} AP`,detail:`Remaining ${R(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 _(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 q=[{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:J("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(G,{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 ${R(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:T?"Recovery, training, and vitals":"No health data yet"})]}),F?e.jsxs(p,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",children:[F.summary.metricCount," metrics"]}):null]}),b.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…"}):T?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]}),y.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:[O.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"," ",be((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(ue,{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?_(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(S,{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(Y,{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(Z,{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(ee,{value:s.progress})})]}),e.jsx("div",{className:"relative z-20 mt-3",children:e.jsx(pe,{entityType:"goal",entityId:s.id,count:te(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(S,{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(S,{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(S,{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(ie,{compact:i})},{id:"weather",title:"Weather",description:"Optional utility widget.",defaultWidth:3,defaultHeight:2,defaultHidden:!0,render:({compact:i})=>e.jsx(se,{compact:i})},{id:"mini-calendar",title:"Mini calendar",description:"Optional utility widget.",defaultWidth:4,defaultHeight:3,defaultHidden:!0,render:({compact:i})=>e.jsx(ae,{compact:i})},{id:"spotify",title:"Spotify",description:"Optional utility widget.",defaultWidth:4,defaultHeight:2,defaultHidden:!0,render:()=>e.jsx(re,{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(ne,{compact:i,defaultUserId:r[0]??((s=t.users[0])==null?void 0:s.id)??null})}}];return e.jsx(U,{surfaceId:"overview",baseWidgets:q,normalizeLayout:he})}export{Ee as OverviewPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-kIz9EZnX.js";import{aS as h,Z as v,c as y,aq as j}from"./index-BHIKoiZ6.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-kIz9EZnX.js";import{Z as a}from"./index-BHIKoiZ6.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{b5 as p,j as s,b0 as l}from"./vendor-
|
|
1
|
+
import{b5 as p,j as s,b0 as l}from"./vendor-kIz9EZnX.js";import{j as g,k as y}from"./state-VYvD1QVP.js";import{c1 as P,B as C}from"./index-BHIKoiZ6.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(C,{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};
|