forge-openclaw-plugin 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{action-bar-5Ii4UzHa.js → action-bar-CMGr_Uv_.js} +1 -1
- package/dist/assets/{activity-page-CWjTKFY3.js → activity-page-DwGKkJtr.js} +1 -1
- package/dist/assets/{ai-surface-workspace-Dd2FSRom.js → ai-surface-workspace-UtnoNmjq.js} +1 -1
- package/dist/assets/{atlas-panel-Dinteouh.js → atlas-panel-f1kc-LkD.js} +1 -1
- package/dist/assets/{calendar-page-BWkXhzDf.js → calendar-page-C4YqeVrC.js} +1 -1
- package/dist/assets/{calendar-rules-CjyuTu2I.js → calendar-rules-BQppCPiN.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-D-nd9tkk.js → calendar-week-toolbar-DdPuHUwd.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-G0t1TqqZ.js → companion-sync-lab-page-N3cR33GS.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-DpIAdzFX.js → daily-metrics-dashboard-CXnAtN2T.js} +1 -1
- package/dist/assets/{define-workbench-box-BIOZopF2.js → define-workbench-box-DkffygDU.js} +1 -1
- package/dist/assets/{entity-link-multiselect-DZZjpL_d.js → entity-link-multiselect-wuyJ8BbW.js} +1 -1
- package/dist/assets/{entity-note-count-link-CmRRdXAr.js → entity-note-count-link-CEtKyMAl.js} +1 -1
- package/dist/assets/{entity-notes-surface-8MPDscsu.js → entity-notes-surface-iKNiierJ.js} +1 -1
- package/dist/assets/{execution-board-Bi8gi8J6.js → execution-board-DesFZ1f5.js} +1 -1
- package/dist/assets/{faceted-token-search-BGs4TqxT.js → faceted-token-search-D4Okr-Kr.js} +1 -1
- package/dist/assets/{flagship-signal-deck-jLxHEHvb.js → flagship-signal-deck-CW91n6u9.js} +1 -1
- package/dist/assets/{floating-action-menu-Itpm7T2_.js → floating-action-menu-GCeuOdYZ.js} +1 -1
- package/dist/assets/{generic-node-view-KePoUF3Z.js → generic-node-view-COhU_Wm3.js} +1 -1
- package/dist/assets/{goal-detail-page-a1lEswpJ.js → goal-detail-page-Bd8JU3IK.js} +1 -1
- package/dist/assets/{goal-dialog-CYgRzl4y.js → goal-dialog-CLz5fYhO.js} +1 -1
- package/dist/assets/{goals-page-JY_EJq9U.js → goals-page-CZHNVyY-.js} +1 -1
- package/dist/assets/{habits-page-BRI8AoaQ.js → habits-page-CXiBB7_N.js} +1 -1
- package/dist/assets/{health-boxes-DZJOFTOI.js → health-boxes-BUcsxDLh.js} +1 -1
- package/dist/assets/{index-wEZUnRh0.js → index-BejvcRGb.js} +2 -2
- package/dist/assets/{index-Bcem7l5u.css → index-CEgIwgk9.css} +1 -1
- package/dist/assets/{inline-note-fields-CUVRzQkI.js → inline-note-fields-CcRDO3pd.js} +1 -1
- package/dist/assets/{insight-flow-dialog-By73oG1H.js → insight-flow-dialog-DUBk2MR8.js} +1 -1
- package/dist/assets/{insights-page-DLyN-9yz.js → insights-page-8fLhCYsM.js} +1 -1
- package/dist/assets/{kanban-boxes-M71CejV4.js → kanban-boxes-CH7plRk1.js} +1 -1
- package/dist/assets/{kanban-page-InKHhJQD.js → kanban-page-Bq-aYwUL.js} +1 -1
- package/dist/assets/{knowledge-graph-page-C-GEQGRY.js → knowledge-graph-page-DYFfWh4Y.js} +1 -1
- package/dist/assets/{life-force-page-Dq88NzNp.js → life-force-page-D80rgBBR.js} +1 -1
- package/dist/assets/{life-force-workspace-Bl_0slZi.js → life-force-workspace-CcmZRRfU.js} +1 -1
- package/dist/assets/{metric-tile-yQJgjYrN.js → metric-tile-DysHMgM3.js} +1 -1
- package/dist/assets/{movement-boxes-C-rc3N8Z.js → movement-boxes-BH3botKt.js} +1 -1
- package/dist/assets/{movement-page-DK-d1uYa.js → movement-page-D5KLMKS9.js} +1 -1
- package/dist/assets/{note-markdown-7czv-KMH.js → note-markdown-Byd_vNkS.js} +1 -1
- package/dist/assets/{note-tags-input-CkgkqiT3.js → note-tags-input-DYAFDq8Q.js} +1 -1
- package/dist/assets/{notes-boxes-BQuR1MiB.js → notes-boxes-CPiPps1e.js} +1 -1
- package/dist/assets/{notes-page-ec9g1mPh.js → notes-page-DehVrOOb.js} +1 -1
- package/dist/assets/{open-in-graph-button-B_4fdm4l.js → open-in-graph-button-L21MKsb5.js} +1 -1
- package/dist/assets/{orbit-map-DPQNBqS-.js → orbit-map-ChJOQ8CN.js} +1 -1
- package/dist/assets/{overview-page-CZjMab2o.js → overview-page-D_ewyeWF.js} +1 -1
- package/dist/assets/{page-hero-BRcqE3a4.js → page-hero-DlHEJ0Yt.js} +1 -1
- package/dist/assets/{pill-cluster-dy6jG_dV.js → pill-cluster-DhOR4m7X.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-DOV-_2Vm.js → preference-entity-handoff-button-ugHU2us9.js} +1 -1
- package/dist/assets/{preferences-page-Co8w5hzp.js → preferences-page-BTTXeSDR.js} +1 -1
- package/dist/assets/{project-collections-DNgKleDl.js → project-collections-USb6PUe0.js} +1 -1
- package/dist/assets/{project-detail-page-C-Ib1x8w.js → project-detail-page-1tD6tUsB.js} +1 -1
- package/dist/assets/{project-dialog-D_hgOdB9.js → project-dialog-BaHhJqP6.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-asf61KSz.js → project-management-hierarchy-page-D4HV8QXs.js} +1 -1
- package/dist/assets/{project-management-section-nav-DAZA1oXG.js → project-management-section-nav-9OV6_ifH.js} +1 -1
- package/dist/assets/{projects-boxes-CHLr1Bs-.js → projects-boxes-AyudWls3.js} +1 -1
- package/dist/assets/{projects-page-BsM8yCqQ.js → projects-page-DizVVzbt.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-COSZeP4J.js → psyche-behaviors-page-CX5MJjWj.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CJmgGL9x.js → psyche-flashcards-page-DzCGy-FV.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-avrWNSs9.js → psyche-goal-map-page-BcKR792E.js} +1 -1
- package/dist/assets/{psyche-graph-BmwbnNBY.js → psyche-graph-BNllZR67.js} +1 -1
- package/dist/assets/{psyche-metrics-page-CY0J_aMx.js → psyche-metrics-page-CpEKlZLO.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-COcswIHZ.js → psyche-mode-guide-page-DXKSE2o7.js} +1 -1
- package/dist/assets/{psyche-modes-page-BXF_GZoP.js → psyche-modes-page-Bh6eeNm1.js} +1 -1
- package/dist/assets/{psyche-page-VsMBNG1F.js → psyche-page-B44RJrrC.js} +1 -1
- package/dist/assets/{psyche-patterns-page-DVoIro0Q.js → psyche-patterns-page-Bm7T5FMJ.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-CahcrbQj.js → psyche-questionnaire-builder-page-BNtMNjY8.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-CYSgADAD.js → psyche-questionnaire-detail-page-BnMXErRK.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-D5q5URTu.js → psyche-questionnaire-run-detail-page-CWKxbdwZ.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-DUoA-VSs.js → psyche-questionnaire-run-page-DwH7Sk52.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-dbQlqbKh.js → psyche-questionnaires-page-B1t_a8QU.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-D_Mmlf2D.js → psyche-report-detail-page-x2AtC99e.js} +1 -1
- package/dist/assets/{psyche-reports-page-CO3J4Js3.js → psyche-reports-page-KiwCgWPa.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-BUNGL4zW.js → psyche-schemas-beliefs-page-CIEoAJAp.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-Bm18uHDg.js → psyche-screen-time-page-DO6UycL9.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-VdPMBuK4.js → psyche-self-observation-page-CPcpUSdm.js} +1 -1
- package/dist/assets/{psyche-values-page-DivSQodJ.js → psyche-values-page-BAgNeo4L.js} +1 -1
- package/dist/assets/{question-flow-dialog-Dsnsc8be.js → question-flow-dialog-BByFV8Yw.js} +1 -1
- package/dist/assets/{report-chain-fields-Bf-WCSJQ.js → report-chain-fields-BpRWMp7h.js} +1 -1
- package/dist/assets/{rewards-page-CI53Cp0i.js → rewards-page-kIiX8SHn.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-Bg3QU_qt.js → scheduling-rules-editor-oQXGcL5l.js} +1 -1
- package/dist/assets/{schema-badge-CRThEDqP.js → schema-badge-BoNjw3h4.js} +1 -1
- package/dist/assets/{schemas-B8-kIOFQ.js → schemas-IBbtdPzn.js} +1 -1
- package/dist/assets/{select-menu-rT3Qd5t5.js → select-menu-U-YryCwP.js} +1 -1
- package/dist/assets/{settings-agents-page-VDUv2WuO.js → settings-agents-page-CbHeMq3e.js} +1 -1
- package/dist/assets/{settings-bin-page-DfuGJVqc.js → settings-bin-page-LxS2YPsA.js} +1 -1
- package/dist/assets/{settings-calendar-page-ex7eHB1y.js → settings-calendar-page-CZc-I-HK.js} +1 -1
- package/dist/assets/{settings-data-page-BPWyPVGo.js → settings-data-page-m-aBRMR9.js} +1 -1
- package/dist/assets/{settings-logs-page-CwTT4n63.js → settings-logs-page-BUEGWlQu.js} +1 -1
- package/dist/assets/{settings-mobile-page-B6sVk872.js → settings-mobile-page-C_5CHjHl.js} +1 -1
- package/dist/assets/{settings-models-page-Dq5XViZd.js → settings-models-page-B4HQu8kL.js} +1 -1
- package/dist/assets/{settings-page-BRxdAxbS.js → settings-page-CY8N-fNV.js} +1 -1
- package/dist/assets/{settings-rewards-page-DRvxTwv3.js → settings-rewards-page-C0XQoWjb.js} +1 -1
- package/dist/assets/{settings-section-nav-D_vKvOWd.js → settings-section-nav-CkqqtM0F.js} +1 -1
- package/dist/assets/{settings-users-page-B6oSpOaV.js → settings-users-page-COCBOq7d.js} +1 -1
- package/dist/assets/{settings-wiki-page-Bkv-SS3J.js → settings-wiki-page-Dy1d7-z-.js} +1 -1
- package/dist/assets/{sleep-page-DELXxo6j.js → sleep-page-1kKicdFq.js} +1 -1
- package/dist/assets/{sports-page-ByWQL0Gf.js → sports-page-DJErRii_.js} +1 -1
- package/dist/assets/{strategies-page-PuUHsaSJ.js → strategies-page-CWNFb9vv.js} +1 -1
- package/dist/assets/{strategy-detail-page-CSyVdv29.js → strategy-detail-page-D9rFVXRS.js} +1 -1
- package/dist/assets/{strategy-dialog-Fgpc0z1M.js → strategy-dialog-BIVHfUR6.js} +1 -1
- package/dist/assets/{surface-DzVqQDmf.js → surface-B3oXO1No.js} +1 -1
- package/dist/assets/{task-detail-page-BoLvJ_4F.js → task-detail-page-r8ipOpAF.js} +1 -1
- package/dist/assets/{task-dialog-B2cGkhLk.js → task-dialog-C3kkWtcT.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-BjiC2jh0.js → timebox-planning-dialog-BadS5tEr.js} +1 -1
- package/dist/assets/{today-boxes-B4f4sBXg.js → today-boxes-CiccN0Gw.js} +1 -1
- package/dist/assets/{today-page-Cusp2JI8.js → today-page-DvQredbl.js} +1 -1
- package/dist/assets/{training-load-page-CsZbK6rY.js → training-load-page-CkX-nSoe.js} +1 -1
- package/dist/assets/{user-badge-CQygGKVs.js → user-badge-BKzwGZDd.js} +1 -1
- package/dist/assets/{utility-widgets-DRESNarT.js → utility-widgets-DvxKA6dI.js} +1 -1
- package/dist/assets/{vitals-page-BlTZ4f78.js → vitals-page-CRIsr_C7.js} +1 -1
- package/dist/assets/{weekly-review-page-3Pk3NeGE.js → weekly-review-page-CNqxLRCd.js} +1 -1
- package/dist/assets/{weight-loss-page-CRCtv1fX.js → weight-loss-page-SSsCp1Yw.js} +3 -3
- package/dist/assets/{wiki-article-markdown-D0PWvioX.js → wiki-article-markdown-C9VKineE.js} +1 -1
- package/dist/assets/{wiki-editor-page-OZMYUgFo.js → wiki-editor-page-DxGsKvF7.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-DXZHzAqU.js → wiki-ingest-history-page-CFmP7K1F.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-Ro0V4UMB.js → wiki-ingest-modal-BLw2PSWP.js} +1 -1
- package/dist/assets/{wiki-page-B1g3Rfxy.js → wiki-page-BiQ-jAuz.js} +1 -1
- package/dist/assets/{workbench-flow-page-qh5nItU6.js → workbench-flow-page-D960hXu_.js} +1 -1
- package/dist/assets/{workbench-page-CFWfAYMV.js → workbench-page-BWlY-FiL.js} +1 -1
- package/dist/assets/{workout-detail-page-Cw6t6Xj9.js → workout-detail-page-G32yJoE9.js} +1 -1
- package/dist/index.html +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,j as a}from"./vendor-Cpmju3nw.js";import{i as D}from"./state-BtwEvpO6.js";import{Q as K,F as y,a as C}from"./question-flow-dialog-
|
|
1
|
+
import{r as v,j as a}from"./vendor-Cpmju3nw.js";import{i as D}from"./state-BtwEvpO6.js";import{Q as K,F as y,a as C}from"./question-flow-dialog-BByFV8Yw.js";import{I,B,T as R,cm as S}from"./index-BejvcRGb.js";import{w as $}from"./schemas-IBbtdPzn.js";const W=[10,15,30,45,60];function A(){return{mode:"add",minutes:15,note:""}}function Y({open:s,onOpenChange:t,entityType:p,entityId:u,targetLabel:l,currentCreditedSeconds:m,pending:k=!1,onSubmit:h}){const[c,b]=v.useState(A),[g,f]=v.useState(null);v.useEffect(()=>{s&&(b(A()),f(null))},[s]);const e=D({queryKey:["forge-xp-metrics"],queryFn:S,enabled:s}),d=v.useMemo(()=>{var x;const o=(x=e.data)==null?void 0:x.metrics.rules.find(w=>w.code==="task_run_progress"),i=Math.max(1,Number((o==null?void 0:o.config.intervalMinutes)??10)),n=Number((o==null?void 0:o.config.fixedXp)??4);return{intervalMinutes:i,fixedXp:n,intervalSeconds:i*60}},[e.data]),r=v.useMemo(()=>{const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=Math.max(0,Math.floor(m/60)),x=i>=0?i:-Math.min(Math.abs(i),n),w=Math.max(0,m+x*60),T=Math.floor(Math.max(0,m)/d.intervalSeconds),M=Math.floor(w/d.intervalSeconds)-T;return{requestedDeltaMinutes:i,appliedDeltaMinutes:x,nextCreditedSeconds:w,bucketDelta:M,xpDelta:M*d.fixedXp,maxRemovableMinutes:n}},[d.fixedXp,d.intervalSeconds,m,c.minutes,c.mode]),N=[{id:"adjustment",eyebrow:p==="task"?"Task work":"Project work",title:`Adjust tracked work for ${l}`,description:"Use this for retrospective minute corrections. Forge will add or remove tracked minutes and adjust progress XP automatically when a reward bucket is crossed.",render:(o,i)=>a.jsxs(a.Fragment,{children:[a.jsx(y,{label:"Mode",labelHelp:"Add minutes when work happened off-timer. Remove minutes when the tracked total needs a correction.",children:a.jsx(C,{value:o.mode,onChange:n=>i({mode:n}),options:[{value:"add",label:"Add minutes",description:"Record extra work that already happened."},{value:"remove",label:"Remove minutes",description:"Correct tracked time without deleting the work history."}]})}),a.jsx(y,{label:"Minutes",description:`Currently tracked: ${Math.floor(m/60)} minutes.`,hint:o.mode==="remove"?`You can remove up to ${r.maxRemovableMinutes} whole minutes from the current credited total.`:void 0,children:a.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[a.jsx(I,{type:"number",min:1,className:"w-36",value:o.minutes,onChange:n=>i({minutes:Number(n.target.value)||0})}),a.jsx("div",{className:"flex flex-wrap gap-2",children:W.map(n=>a.jsxs(B,{type:"button",variant:o.minutes===n?"primary":"secondary",onClick:()=>i({minutes:n}),children:[n," min"]},n))})]})}),a.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[a.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Preview"}),a.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-3",children:[a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Applied minutes"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.appliedDeltaMinutes>0?"+":"",r.appliedDeltaMinutes]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"XP delta"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[r.xpDelta>0?"+":"",r.xpDelta]})]}),a.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"New tracked total"}),a.jsxs("div",{className:"mt-2 text-lg text-[var(--ui-ink-strong)]",children:[Math.floor(r.nextCreditedSeconds/60)," min"]})]})]}),a.jsxs("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:["Reward cadence: ",d.fixedXp," XP every"," ",d.intervalMinutes," credited minutes."," ",r.bucketDelta===0?"This change does not cross a reward bucket.":`This change crosses ${Math.abs(r.bucketDelta)} reward bucket${Math.abs(r.bucketDelta)===1?"":"s"}.`]})]}),a.jsx(y,{label:"Note",description:"Optional context for why this correction is being added. The note stays attached to the adjustment metadata.",children:a.jsx(R,{className:"min-h-28",value:o.note,onChange:n=>i({note:n.target.value}),placeholder:"Captured the review session that happened away from the live timer."})})]})}];return a.jsx(K,{open:s,onOpenChange:t,eyebrow:p==="task"?"Adjust task work":"Adjust project work",title:`Adjust work for ${l}`,description:"Add or remove tracked minutes without creating a live task run.",value:c,onChange:b,draftPersistenceKey:`work-adjustment.${p}.${u}`,steps:N,submitLabel:"Save adjustment",pending:k,pendingLabel:"Saving adjustment...",error:g,onSubmit:async()=>{var x;f(null);const o=Math.max(0,Math.trunc(c.minutes||0)),i=c.mode==="add"?o:-o,n=$.safeParse({entityType:p,entityId:u,deltaMinutes:i,note:c.note});if(!n.success){f(((x=n.error.issues[0])==null?void 0:x.message)??"Enter a valid minute adjustment.");return}try{await h({entityType:p,entityId:u,deltaMinutes:n.data.deltaMinutes,note:n.data.note||void 0}),t(!1)}catch(w){f(w instanceof Error?w.message:"Could not save the work adjustment right now.")}}})}const E={allowWorkBlockKinds:[],blockWorkBlockKinds:[],allowCalendarIds:[],blockCalendarIds:[],allowEventTypes:[],blockEventTypes:[],allowEventKeywords:[],blockEventKeywords:[],allowAvailability:[],blockAvailability:[]};function X(s){return s.map(t=>t.trim().toLowerCase()).filter(Boolean)}function j(s,t){const p=X(s);if(p.length===0)return!1;const u=t.join(" ").toLowerCase();return p.some(l=>u.includes(l))}function F(s){return s.allowWorkBlockKinds.length>0||s.allowCalendarIds.length>0||s.allowEventTypes.length>0||s.allowEventKeywords.length>0||s.allowAvailability.length>0}function P(s,t){return s??t??E}function G(s){const t=s.rules??E,u=(s.at??new Date).getTime(),l=s.overview,m=(l==null?void 0:l.workBlockInstances.filter(e=>{const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],k=(l==null?void 0:l.events.filter(e=>{if(e.deletedAt)return!1;const d=new Date(e.startAt).getTime(),r=new Date(e.endAt).getTime();return d<=u&&u<r}))??[],h=[],c=m.some(e=>t.blockWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)||t.blockEventTypes.includes(e.eventType)||t.blockAvailability.includes(e.availability)||j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]));c&&(m.some(e=>t.blockWorkBlockKinds.includes(e.kind))&&h.push("The current work block is marked as blocked."),k.some(e=>e.calendarId?t.blockCalendarIds.includes(e.calendarId):!1)&&h.push("The active calendar belongs to a blocked calendar source."),k.some(e=>t.blockEventTypes.includes(e.eventType))&&h.push("The active calendar event type is blocked."),k.some(e=>t.blockAvailability.includes(e.availability))&&h.push("The active calendar availability is blocked."),k.some(e=>j(t.blockEventKeywords,[e.title,e.description,e.location,...e.categories]))&&h.push("The active calendar event matches a blocked keyword."));const b=F(t),g=m.some(e=>t.allowWorkBlockKinds.includes(e.kind))||k.some(e=>(e.calendarId?t.allowCalendarIds.includes(e.calendarId):!1)||t.allowEventTypes.includes(e.eventType)||t.allowAvailability.includes(e.availability)||j(t.allowEventKeywords,[e.title,e.description,e.location,...e.categories]));!c&&b&&!g&&h.push("The current calendar context does not match the allowed rules yet.");const f=[...m.map(e=>`${e.title} (${e.kind.replaceAll("_"," ")})`),...k.map(e=>e.title)];return h.length>0?{blocked:!0,label:"Blocked right now",tone:"blocked",conflicts:h,context:f}:f.length>0?{blocked:!1,label:"Allowed right now",tone:"allowed",conflicts:[],context:f}:{blocked:!1,label:b?"Waiting for an allowed calendar context":"No live calendar conflict right now",tone:b?"waiting":"allowed",conflicts:[],context:[]}}function H(s,t){return P(s.schedulingRules,t)}export{Y as W,G as e,H as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,aV as m}from"./vendor-Cpmju3nw.js";import{k as x,B as a}from"./index-
|
|
1
|
+
import{j as e,aV as m}from"./vendor-Cpmju3nw.js";import{k as x,B as a}from"./index-BejvcRGb.js";import{f as d}from"./calendar-ui-Cy1XRwzV.js";function j({eyebrow:s="Week view",description:i,weekStart:n,status:r,badges:t,onPrevious:l,onCurrent:o,onNext:c}){return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s}),e.jsx("p",{className:"mt-2 max-w-3xl break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i}),r?e.jsx("div",{className:"mt-3",children:r}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsxs(x,{className:"border border-[color-mix(in_srgb,var(--primary)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",children:[e.jsx(m,{className:"mr-1 size-3.5"}),"Week of ",d(n)]}),t,e.jsx(a,{variant:"secondary",onClick:l,children:"Previous"}),e.jsx(a,{variant:"secondary",onClick:o,children:"This week"}),e.jsx(a,{variant:"secondary",onClick:c,children:"Next"})]})]})}export{j as C};
|
package/dist/assets/{companion-sync-lab-page-G0t1TqqZ.js → companion-sync-lab-page-N3cR33GS.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-Cpmju3nw.js";import{C as h,k as d}from"./index-wEZUnRh0.js";import{P as $}from"./page-hero-BRcqE3a4.js";import"./state-BtwEvpO6.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";const B=[{id:"health-ready",title:"Health ready",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"approved",syncEligible:!0,lastObservedAt:"2026-04-12T09:00:00.000Z"},{id:"movement-pending-phone",title:"Movement pending on phone",desiredEnabled:!0,appliedEnabled:!1,authorizationStatus:"pending",syncEligible:!1,lastObservedAt:"2026-04-12T09:04:00.000Z"},{id:"screen-time-denied",title:"Screen Time denied",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"denied",syncEligible:!1,lastObservedAt:"2026-04-12T08:54:00.000Z"},{id:"health-off",title:"Health off",desiredEnabled:!1,appliedEnabled:!1,authorizationStatus:"disabled",syncEligible:!1,lastObservedAt:null}],Z=[{id:"gap-stay",title:"Quiet short gap",gapSeconds:1080,displacementMeters:42,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-short-jump",title:"Suppressed short jump",gapSeconds:240,displacementMeters:260,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-trip",title:"Repaired move",gapSeconds:1320,displacementMeters:1850,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-long",title:"Long missing gap",gapSeconds:7200,displacementMeters:320,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-boundary",title:"Missing boundary anchor",gapSeconds:960,displacementMeters:null,hasStartBoundary:!1,hasEndBoundary:!0}],D=[{id:"overnight-gap-before-move",title:"Exact overnight stay-gap-move bug",rangeStart:"2026-04-05T21:15:00.000Z",rangeEnd:"2026-04-06T02:40:00.000Z",segments:[{id:"stay-home-evening",kind:"stay",startedAt:"2026-04-05T21:15:00.000Z",endedAt:"2026-04-05T21:30:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"trip-night-move",kind:"trip",startedAt:"2026-04-06T02:34:00.000Z",endedAt:"2026-04-06T02:40:00.000Z",placeLabel:"Night move",placeExternalUid:null,startCoordinate:{latitude:46.5216,longitude:6.6404},endCoordinate:{latitude:46.5226,longitude:6.6424}}]},{id:"repeated-home-stays",title:"Repeated home stays coalesce",rangeStart:"2026-04-05T07:00:00.000Z",rangeEnd:"2026-04-05T08:44:00.000Z",segments:[{id:"stay-home-1",kind:"stay",startedAt:"2026-04-05T07:00:00.000Z",endedAt:"2026-04-05T08:00:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"stay-home-2",kind:"stay",startedAt:"2026-04-05T08:20:00.000Z",endedAt:"2026-04-05T08:40:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.51912,longitude:6.63231},endCoordinate:{latitude:46.51912,longitude:6.63231}},{id:"trip-start-anchor",kind:"trip",startedAt:"2026-04-05T08:44:00.000Z",endedAt:"2026-04-05T08:49:00.000Z",placeLabel:"Walk out",placeExternalUid:null,startCoordinate:{latitude:46.5217,longitude:6.6405},endCoordinate:{latitude:46.5221,longitude:6.6412}}]}],U=[{id:"user-override-home-window",title:"User-defined missing box overrides one automatic home stay",rawMeasurements:[{id:"raw-stay-home",label:"Raw stay · Home",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z"}],automaticBoxes:[{id:"auto-stay-home",kind:"stay",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home"}],userBoxes:[{id:"user-missing-home-window",kind:"missing",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1}],projectedBoxes:[{id:"projected-home-early",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T08:30:00.000Z",title:"Home",overrideCount:0},{id:"projected-home-user-missing",kind:"missing",sourceKind:"user_defined",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1},{id:"projected-home-late",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T09:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home",overrideCount:0}]}],T=3600,O=300,R=100;function N(t,s){return Math.max(0,Math.round((Date.parse(s)-Date.parse(t))/1e3))}function L(t,s){if(!t||!s)return null;const i=6371e3,g=(s.latitude-t.latitude)*Math.PI/180,l=(s.longitude-t.longitude)*Math.PI/180,u=t.latitude*Math.PI/180,c=s.latitude*Math.PI/180,m=Math.sin(g/2)**2+Math.cos(u)*Math.cos(c)*Math.sin(l/2)**2,r=2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m));return i*r}function I(t,s){if(t.placeExternalUid&&s.placeExternalUid&&t.placeExternalUid===s.placeExternalUid)return!0;const i=L(t.endCoordinate,s.startCoordinate);return i!==null&&i<=R}function H(t){return t.gapSeconds>3600?{kind:"missing",origin:"missing",reason:"Gap exceeded one hour, so Forge keeps it as explicit missing data.",suppressedShortJump:!1}:!t.hasStartBoundary||!t.hasEndBoundary||t.displacementMeters===null?{kind:"missing",origin:"missing",reason:"One or both boundary anchors were missing, so the gap stays missing instead of inventing movement.",suppressedShortJump:!1}:t.displacementMeters<=100?{kind:"stay",origin:"repaired_gap",reason:"Boundary displacement stayed within 100 m, so the gap repairs into one stay.",suppressedShortJump:!1}:t.gapSeconds<300?{kind:"stay",origin:"repaired_gap",reason:"The jump crossed 100 m but stayed under five minutes, so Forge suppresses it into stay continuity.",suppressedShortJump:!0}:{kind:"trip",origin:"repaired_gap",reason:"The gap stayed under one hour, crossed 100 m, and lasted at least five minutes, so Forge repairs it into a move.",suppressedShortJump:!1}}function P(t){var E,w,_,C;const s=[...t.segments].sort((a,o)=>a.startedAt.localeCompare(o.startedAt)),i=[];if(s.length===0)return{segments:[],uncoveredIntervals:[]};const g=s[0];N(t.rangeStart,g.startedAt)>0&&i.push({id:`missing_${t.rangeStart}_${g.startedAt}`,kind:"missing",origin:"missing",startedAt:t.rangeStart,endedAt:g.startedAt,title:"Missing data"}),s.forEach((a,o)=>{if(o>0){const n=s[o-1],y=N(n.endedAt,a.startedAt);y>0&&(y>T?i.push({id:`missing_${n.id}_${a.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:a.startedAt,title:"Missing data"}):I(n,a)?i.push({id:`repaired_stay_${n.id}_${a.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:n.placeLabel??a.placeLabel??"Repaired stay"}):L(n.endCoordinate,a.startCoordinate)===null?i.push({id:`missing_${n.id}_${a.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:a.startedAt,title:"Missing data"}):y<O?i.push({id:`repaired_short_jump_${n.id}_${a.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:n.placeLabel??a.placeLabel??"Repaired stay"}):i.push({id:`repaired_trip_${n.id}_${a.id}`,kind:"trip",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:"Repaired move"}))}i.push({id:a.id,kind:a.kind,origin:"recorded",startedAt:a.startedAt,endedAt:a.endedAt,title:a.placeLabel??a.kind})});const l=s[s.length-1],u=N(l.endedAt,t.rangeEnd);u>0&&(l.kind==="stay"&&u<=T?i.push({id:`continued_${l.id}_${t.rangeEnd}`,kind:"stay",origin:"continued_stay",startedAt:l.endedAt,endedAt:t.rangeEnd,title:l.placeLabel??"Continued stay"}):i.push({id:`missing_${l.endedAt}_${t.rangeEnd}`,kind:"missing",origin:"missing",startedAt:l.endedAt,endedAt:t.rangeEnd,title:"Missing data"}));const c=[];for(const a of i){const o=c[c.length-1];if(o&&o.kind==="stay"&&a.kind==="stay"&&(o.origin!=="recorded"||a.origin!=="recorded")&&o.endedAt===a.startedAt){c[c.length-1]={...o,id:`${o.id}_${a.id}`,origin:o.origin==="continued_stay"||a.origin==="continued_stay"?"continued_stay":"repaired_gap",endedAt:a.endedAt};continue}c.push(a)}const m=[],r=[...c].sort((a,o)=>a.startedAt.localeCompare(o.startedAt));((E=r[0])==null?void 0:E.startedAt)!==t.rangeStart&&m.push({startedAt:t.rangeStart,endedAt:((w=r[0])==null?void 0:w.startedAt)??t.rangeEnd});for(let a=1;a<r.length;a+=1)r[a-1].endedAt!==r[a].startedAt&&m.push({startedAt:r[a-1].endedAt,endedAt:r[a].startedAt});return((_=r[r.length-1])==null?void 0:_.endedAt)!==t.rangeEnd&&m.push({startedAt:((C=r[r.length-1])==null?void 0:C.endedAt)??t.rangeStart,endedAt:t.rangeEnd}),{segments:r,uncoveredIntervals:m}}function F(t){return t?new Date(t).toLocaleString():"Waiting for device update"}const v="grid min-w-0 gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",x="grid min-w-0 gap-2 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",b="grid min-w-0 gap-2 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",j="rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",A="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",S="text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",f="text-sm font-medium text-[var(--ui-ink-strong)]",p="text-[var(--ui-ink-soft)]",k="text-[var(--ui-ink-faint)]",z="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",G="bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",M="bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",J="bg-[var(--ui-accent-soft)] text-[var(--primary)]";function se(){return e.jsxs("div",{className:"mx-auto grid min-w-0 w-full max-w-[1180px] gap-5",children:[e.jsx($,{title:"Companion Sync Lab",description:"Deterministic fixtures for source-state reconciliation and movement gap repair. This route is dev-only and exists to make QA faster than recreating every phone state by hand.",badge:"Dev only"}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[1.05fr_0.95fr]",children:[e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Source matrix"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"These rows mirror the pairing source-state contract that the web and phone now share."})]}),e.jsx("div",{className:"grid gap-3",children:B.map(t=>e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{tone:t.desiredEnabled?"signal":"meta",children:t.desiredEnabled?"Enabled":"Off"}),e.jsx(d,{tone:"meta",children:t.desiredEnabled===t.appliedEnabled?"Applied":"Pending on phone"})]}),e.jsxs("div",{className:`grid gap-1 text-xs ${p} sm:grid-cols-2`,children:[e.jsxs("div",{children:["Authorization: ",t.authorizationStatus]}),e.jsxs("div",{children:["Sync eligible: ",t.syncEligible?"Yes":"No"]}),e.jsxs("div",{children:["Desired: ",t.desiredEnabled?"On":"Off"]}),e.jsxs("div",{children:["Applied: ",t.appliedEnabled?"On":"Off"]}),e.jsxs("div",{className:"sm:col-span-2",children:["Last observed: ",F(t.lastObservedAt)]})]})]},t.id))})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Gap classifier"}),e.jsxs("div",{className:`mt-2 text-sm leading-6 ${p}`,children:["Every gap resolves to exactly one of ",e.jsx("code",{children:"stay"}),","," ",e.jsx("code",{children:"trip"}),", or ",e.jsx("code",{children:"missing"}),"."]})]}),e.jsx("div",{className:"grid gap-3",children:Z.map(t=>{const s=H(t);return e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{tone:s.kind==="missing"?"meta":s.kind==="trip"?"signal":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.origin}),s.suppressedShortJump?e.jsx(d,{className:z,children:"Suppressed short jump"}):null]}),e.jsxs("div",{className:`grid gap-1 text-xs ${p} sm:grid-cols-2`,children:[e.jsxs("div",{children:["Gap: ",Math.round(t.gapSeconds/60)," min"]}),e.jsxs("div",{children:["Displacement:"," ",t.displacementMeters===null?"unknown":`${Math.round(t.displacementMeters)} m`]}),e.jsxs("div",{children:["Start boundary:"," ",t.hasStartBoundary?"present":"missing"]}),e.jsxs("div",{children:["End boundary:"," ",t.hasEndBoundary?"present":"missing"]})]}),e.jsx("div",{className:`text-sm leading-6 ${p}`,children:s.reason})]},t.id)})})]})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Coverage preview"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"These fixtures normalize a full window and highlight whether any interval would still be left uncovered."})]}),e.jsx("div",{className:"grid gap-3",children:D.map(t=>{const s=P(t);return e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{className:s.uncoveredIntervals.length===0?G:M,children:s.uncoveredIntervals.length===0?"Coverage locked":"Coverage broken"}),e.jsxs(d,{tone:"meta",children:[s.segments.length," normalized segment",s.segments.length===1?"":"s"]})]}),e.jsx("div",{className:"grid gap-2",children:s.segments.map(i=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx(d,{tone:i.kind==="trip"?"signal":i.kind==="missing"?"meta":"default",children:i.kind}),e.jsx(d,{tone:"meta",children:i.origin}),e.jsxs("span",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]}),e.jsx("span",{className:k,children:i.title})]},i.id))}),s.uncoveredIntervals.length>0?e.jsx("div",{className:"grid gap-2",children:s.uncoveredIntervals.map(i=>e.jsxs("div",{className:`rounded-[14px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-3 py-2 text-xs ${M}`,children:["Uncovered:"," ",new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]},`${i.startedAt}-${i.endedAt}`))}):null]},t.id)})})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Canonical box layers"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"Raw phone measurements stay immutable. Forge generates automatic boxes from them, user-defined boxes override them, and the final projected boxes are what both the web and iPhone should render."})]}),e.jsx("div",{className:"grid gap-4",children:U.map(t=>e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsxs(d,{tone:"meta",children:["Raw: ",t.rawMeasurements.length]}),e.jsxs(d,{tone:"meta",children:["Automatic: ",t.automaticBoxes.length]}),e.jsxs(d,{tone:"meta",children:["User: ",t.userBoxes.length]}),e.jsxs(d,{tone:"signal",children:["Projected: ",t.projectedBoxes.length]})]}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-4",children:[e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Raw measurements"}),t.rawMeasurements.map(s=>e.jsxs("div",{className:j,children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.label}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Automatic boxes"}),t.automaticBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="trip"?"signal":s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"User-defined boxes"}),t.userBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{className:J,children:s.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:`mt-1 ${k}`,children:["Overrides ",s.overrideCount," automatic box",s.overrideCount===1?"":"es"]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Projected visible boxes"}),t.projectedBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="trip"?"signal":s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.sourceKind})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:`mt-1 ${k}`,children:[s.origin,s.overrideCount>0?` · overrides ${s.overrideCount}`:""]})]},s.id))]})]})]},t.id))})]})]})}export{se as CompanionSyncLabPage};
|
|
1
|
+
import{j as e}from"./vendor-Cpmju3nw.js";import{C as h,k as d}from"./index-BejvcRGb.js";import{P as $}from"./page-hero-DlHEJ0Yt.js";import"./state-BtwEvpO6.js";import"./motion-DwjmC9aq.js";import"./ui-B9O-eUim.js";import"./board-CLOHbg6t.js";import"./forms-C5d5hTf2.js";const B=[{id:"health-ready",title:"Health ready",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"approved",syncEligible:!0,lastObservedAt:"2026-04-12T09:00:00.000Z"},{id:"movement-pending-phone",title:"Movement pending on phone",desiredEnabled:!0,appliedEnabled:!1,authorizationStatus:"pending",syncEligible:!1,lastObservedAt:"2026-04-12T09:04:00.000Z"},{id:"screen-time-denied",title:"Screen Time denied",desiredEnabled:!0,appliedEnabled:!0,authorizationStatus:"denied",syncEligible:!1,lastObservedAt:"2026-04-12T08:54:00.000Z"},{id:"health-off",title:"Health off",desiredEnabled:!1,appliedEnabled:!1,authorizationStatus:"disabled",syncEligible:!1,lastObservedAt:null}],Z=[{id:"gap-stay",title:"Quiet short gap",gapSeconds:1080,displacementMeters:42,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-short-jump",title:"Suppressed short jump",gapSeconds:240,displacementMeters:260,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-trip",title:"Repaired move",gapSeconds:1320,displacementMeters:1850,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-long",title:"Long missing gap",gapSeconds:7200,displacementMeters:320,hasStartBoundary:!0,hasEndBoundary:!0},{id:"gap-missing-boundary",title:"Missing boundary anchor",gapSeconds:960,displacementMeters:null,hasStartBoundary:!1,hasEndBoundary:!0}],D=[{id:"overnight-gap-before-move",title:"Exact overnight stay-gap-move bug",rangeStart:"2026-04-05T21:15:00.000Z",rangeEnd:"2026-04-06T02:40:00.000Z",segments:[{id:"stay-home-evening",kind:"stay",startedAt:"2026-04-05T21:15:00.000Z",endedAt:"2026-04-05T21:30:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"trip-night-move",kind:"trip",startedAt:"2026-04-06T02:34:00.000Z",endedAt:"2026-04-06T02:40:00.000Z",placeLabel:"Night move",placeExternalUid:null,startCoordinate:{latitude:46.5216,longitude:6.6404},endCoordinate:{latitude:46.5226,longitude:6.6424}}]},{id:"repeated-home-stays",title:"Repeated home stays coalesce",rangeStart:"2026-04-05T07:00:00.000Z",rangeEnd:"2026-04-05T08:44:00.000Z",segments:[{id:"stay-home-1",kind:"stay",startedAt:"2026-04-05T07:00:00.000Z",endedAt:"2026-04-05T08:00:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.5191,longitude:6.6323},endCoordinate:{latitude:46.5191,longitude:6.6323}},{id:"stay-home-2",kind:"stay",startedAt:"2026-04-05T08:20:00.000Z",endedAt:"2026-04-05T08:40:00.000Z",placeLabel:"Home",placeExternalUid:"place_home",startCoordinate:{latitude:46.51912,longitude:6.63231},endCoordinate:{latitude:46.51912,longitude:6.63231}},{id:"trip-start-anchor",kind:"trip",startedAt:"2026-04-05T08:44:00.000Z",endedAt:"2026-04-05T08:49:00.000Z",placeLabel:"Walk out",placeExternalUid:null,startCoordinate:{latitude:46.5217,longitude:6.6405},endCoordinate:{latitude:46.5221,longitude:6.6412}}]}],U=[{id:"user-override-home-window",title:"User-defined missing box overrides one automatic home stay",rawMeasurements:[{id:"raw-stay-home",label:"Raw stay · Home",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z"}],automaticBoxes:[{id:"auto-stay-home",kind:"stay",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home"}],userBoxes:[{id:"user-missing-home-window",kind:"missing",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1}],projectedBoxes:[{id:"projected-home-early",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T08:00:00.000Z",endedAt:"2026-04-05T08:30:00.000Z",title:"Home",overrideCount:0},{id:"projected-home-user-missing",kind:"missing",sourceKind:"user_defined",origin:"user_invalidated",startedAt:"2026-04-05T08:30:00.000Z",endedAt:"2026-04-05T09:00:00.000Z",title:"User invalidated automatic movement",overrideCount:1},{id:"projected-home-late",kind:"stay",sourceKind:"automatic",origin:"recorded",startedAt:"2026-04-05T09:00:00.000Z",endedAt:"2026-04-05T10:00:00.000Z",title:"Home",overrideCount:0}]}],T=3600,O=300,R=100;function N(t,s){return Math.max(0,Math.round((Date.parse(s)-Date.parse(t))/1e3))}function L(t,s){if(!t||!s)return null;const i=6371e3,g=(s.latitude-t.latitude)*Math.PI/180,l=(s.longitude-t.longitude)*Math.PI/180,u=t.latitude*Math.PI/180,c=s.latitude*Math.PI/180,m=Math.sin(g/2)**2+Math.cos(u)*Math.cos(c)*Math.sin(l/2)**2,r=2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m));return i*r}function I(t,s){if(t.placeExternalUid&&s.placeExternalUid&&t.placeExternalUid===s.placeExternalUid)return!0;const i=L(t.endCoordinate,s.startCoordinate);return i!==null&&i<=R}function H(t){return t.gapSeconds>3600?{kind:"missing",origin:"missing",reason:"Gap exceeded one hour, so Forge keeps it as explicit missing data.",suppressedShortJump:!1}:!t.hasStartBoundary||!t.hasEndBoundary||t.displacementMeters===null?{kind:"missing",origin:"missing",reason:"One or both boundary anchors were missing, so the gap stays missing instead of inventing movement.",suppressedShortJump:!1}:t.displacementMeters<=100?{kind:"stay",origin:"repaired_gap",reason:"Boundary displacement stayed within 100 m, so the gap repairs into one stay.",suppressedShortJump:!1}:t.gapSeconds<300?{kind:"stay",origin:"repaired_gap",reason:"The jump crossed 100 m but stayed under five minutes, so Forge suppresses it into stay continuity.",suppressedShortJump:!0}:{kind:"trip",origin:"repaired_gap",reason:"The gap stayed under one hour, crossed 100 m, and lasted at least five minutes, so Forge repairs it into a move.",suppressedShortJump:!1}}function P(t){var E,w,_,C;const s=[...t.segments].sort((a,o)=>a.startedAt.localeCompare(o.startedAt)),i=[];if(s.length===0)return{segments:[],uncoveredIntervals:[]};const g=s[0];N(t.rangeStart,g.startedAt)>0&&i.push({id:`missing_${t.rangeStart}_${g.startedAt}`,kind:"missing",origin:"missing",startedAt:t.rangeStart,endedAt:g.startedAt,title:"Missing data"}),s.forEach((a,o)=>{if(o>0){const n=s[o-1],y=N(n.endedAt,a.startedAt);y>0&&(y>T?i.push({id:`missing_${n.id}_${a.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:a.startedAt,title:"Missing data"}):I(n,a)?i.push({id:`repaired_stay_${n.id}_${a.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:n.placeLabel??a.placeLabel??"Repaired stay"}):L(n.endCoordinate,a.startCoordinate)===null?i.push({id:`missing_${n.id}_${a.id}`,kind:"missing",origin:"missing",startedAt:n.endedAt,endedAt:a.startedAt,title:"Missing data"}):y<O?i.push({id:`repaired_short_jump_${n.id}_${a.id}`,kind:"stay",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:n.placeLabel??a.placeLabel??"Repaired stay"}):i.push({id:`repaired_trip_${n.id}_${a.id}`,kind:"trip",origin:"repaired_gap",startedAt:n.endedAt,endedAt:a.startedAt,title:"Repaired move"}))}i.push({id:a.id,kind:a.kind,origin:"recorded",startedAt:a.startedAt,endedAt:a.endedAt,title:a.placeLabel??a.kind})});const l=s[s.length-1],u=N(l.endedAt,t.rangeEnd);u>0&&(l.kind==="stay"&&u<=T?i.push({id:`continued_${l.id}_${t.rangeEnd}`,kind:"stay",origin:"continued_stay",startedAt:l.endedAt,endedAt:t.rangeEnd,title:l.placeLabel??"Continued stay"}):i.push({id:`missing_${l.endedAt}_${t.rangeEnd}`,kind:"missing",origin:"missing",startedAt:l.endedAt,endedAt:t.rangeEnd,title:"Missing data"}));const c=[];for(const a of i){const o=c[c.length-1];if(o&&o.kind==="stay"&&a.kind==="stay"&&(o.origin!=="recorded"||a.origin!=="recorded")&&o.endedAt===a.startedAt){c[c.length-1]={...o,id:`${o.id}_${a.id}`,origin:o.origin==="continued_stay"||a.origin==="continued_stay"?"continued_stay":"repaired_gap",endedAt:a.endedAt};continue}c.push(a)}const m=[],r=[...c].sort((a,o)=>a.startedAt.localeCompare(o.startedAt));((E=r[0])==null?void 0:E.startedAt)!==t.rangeStart&&m.push({startedAt:t.rangeStart,endedAt:((w=r[0])==null?void 0:w.startedAt)??t.rangeEnd});for(let a=1;a<r.length;a+=1)r[a-1].endedAt!==r[a].startedAt&&m.push({startedAt:r[a-1].endedAt,endedAt:r[a].startedAt});return((_=r[r.length-1])==null?void 0:_.endedAt)!==t.rangeEnd&&m.push({startedAt:((C=r[r.length-1])==null?void 0:C.endedAt)??t.rangeStart,endedAt:t.rangeEnd}),{segments:r,uncoveredIntervals:m}}function F(t){return t?new Date(t).toLocaleString():"Waiting for device update"}const v="grid min-w-0 gap-4 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",x="grid min-w-0 gap-2 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4",b="grid min-w-0 gap-2 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-3",j="rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",A="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",S="text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",f="text-sm font-medium text-[var(--ui-ink-strong)]",p="text-[var(--ui-ink-soft)]",k="text-[var(--ui-ink-faint)]",z="bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]",G="bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]",M="bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]",J="bg-[var(--ui-accent-soft)] text-[var(--primary)]";function se(){return e.jsxs("div",{className:"mx-auto grid min-w-0 w-full max-w-[1180px] gap-5",children:[e.jsx($,{title:"Companion Sync Lab",description:"Deterministic fixtures for source-state reconciliation and movement gap repair. This route is dev-only and exists to make QA faster than recreating every phone state by hand.",badge:"Dev only"}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[1.05fr_0.95fr]",children:[e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Source matrix"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"These rows mirror the pairing source-state contract that the web and phone now share."})]}),e.jsx("div",{className:"grid gap-3",children:B.map(t=>e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{tone:t.desiredEnabled?"signal":"meta",children:t.desiredEnabled?"Enabled":"Off"}),e.jsx(d,{tone:"meta",children:t.desiredEnabled===t.appliedEnabled?"Applied":"Pending on phone"})]}),e.jsxs("div",{className:`grid gap-1 text-xs ${p} sm:grid-cols-2`,children:[e.jsxs("div",{children:["Authorization: ",t.authorizationStatus]}),e.jsxs("div",{children:["Sync eligible: ",t.syncEligible?"Yes":"No"]}),e.jsxs("div",{children:["Desired: ",t.desiredEnabled?"On":"Off"]}),e.jsxs("div",{children:["Applied: ",t.appliedEnabled?"On":"Off"]}),e.jsxs("div",{className:"sm:col-span-2",children:["Last observed: ",F(t.lastObservedAt)]})]})]},t.id))})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Gap classifier"}),e.jsxs("div",{className:`mt-2 text-sm leading-6 ${p}`,children:["Every gap resolves to exactly one of ",e.jsx("code",{children:"stay"}),","," ",e.jsx("code",{children:"trip"}),", or ",e.jsx("code",{children:"missing"}),"."]})]}),e.jsx("div",{className:"grid gap-3",children:Z.map(t=>{const s=H(t);return e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{tone:s.kind==="missing"?"meta":s.kind==="trip"?"signal":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.origin}),s.suppressedShortJump?e.jsx(d,{className:z,children:"Suppressed short jump"}):null]}),e.jsxs("div",{className:`grid gap-1 text-xs ${p} sm:grid-cols-2`,children:[e.jsxs("div",{children:["Gap: ",Math.round(t.gapSeconds/60)," min"]}),e.jsxs("div",{children:["Displacement:"," ",t.displacementMeters===null?"unknown":`${Math.round(t.displacementMeters)} m`]}),e.jsxs("div",{children:["Start boundary:"," ",t.hasStartBoundary?"present":"missing"]}),e.jsxs("div",{children:["End boundary:"," ",t.hasEndBoundary?"present":"missing"]})]}),e.jsx("div",{className:`text-sm leading-6 ${p}`,children:s.reason})]},t.id)})})]})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Coverage preview"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"These fixtures normalize a full window and highlight whether any interval would still be left uncovered."})]}),e.jsx("div",{className:"grid gap-3",children:D.map(t=>{const s=P(t);return e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsx(d,{className:s.uncoveredIntervals.length===0?G:M,children:s.uncoveredIntervals.length===0?"Coverage locked":"Coverage broken"}),e.jsxs(d,{tone:"meta",children:[s.segments.length," normalized segment",s.segments.length===1?"":"s"]})]}),e.jsx("div",{className:"grid gap-2",children:s.segments.map(i=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx(d,{tone:i.kind==="trip"?"signal":i.kind==="missing"?"meta":"default",children:i.kind}),e.jsx(d,{tone:"meta",children:i.origin}),e.jsxs("span",{children:[new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]}),e.jsx("span",{className:k,children:i.title})]},i.id))}),s.uncoveredIntervals.length>0?e.jsx("div",{className:"grid gap-2",children:s.uncoveredIntervals.map(i=>e.jsxs("div",{className:`rounded-[14px] border border-[color-mix(in_srgb,var(--danger)_28%,var(--ui-border-subtle)_72%)] bg-[var(--ui-danger-soft)] px-3 py-2 text-xs ${M}`,children:["Uncovered:"," ",new Date(i.startedAt).toLocaleTimeString()," →"," ",new Date(i.endedAt).toLocaleTimeString()]},`${i.startedAt}-${i.endedAt}`))}):null]},t.id)})})]}),e.jsxs(h,{className:v,children:[e.jsxs("div",{children:[e.jsx("div",{className:A,children:"Canonical box layers"}),e.jsx("div",{className:`mt-2 text-sm leading-6 ${p}`,children:"Raw phone measurements stay immutable. Forge generates automatic boxes from them, user-defined boxes override them, and the final projected boxes are what both the web and iPhone should render."})]}),e.jsx("div",{className:"grid gap-4",children:U.map(t=>e.jsxs("div",{className:x,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:f,children:t.title}),e.jsxs(d,{tone:"meta",children:["Raw: ",t.rawMeasurements.length]}),e.jsxs(d,{tone:"meta",children:["Automatic: ",t.automaticBoxes.length]}),e.jsxs(d,{tone:"meta",children:["User: ",t.userBoxes.length]}),e.jsxs(d,{tone:"signal",children:["Projected: ",t.projectedBoxes.length]})]}),e.jsxs("div",{className:"grid gap-3 xl:grid-cols-4",children:[e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Raw measurements"}),t.rawMeasurements.map(s=>e.jsxs("div",{className:j,children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:s.label}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Automatic boxes"}),t.automaticBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="trip"?"signal":s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"User-defined boxes"}),t.userBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{className:J,children:s.origin})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:`mt-1 ${k}`,children:["Overrides ",s.overrideCount," automatic box",s.overrideCount===1?"":"es"]})]},s.id))]}),e.jsxs("div",{className:b,children:[e.jsx("div",{className:S,children:"Projected visible boxes"}),t.projectedBoxes.map(s=>e.jsxs("div",{className:j,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{tone:s.kind==="trip"?"signal":s.kind==="missing"?"meta":"default",children:s.kind}),e.jsx(d,{tone:"meta",children:s.sourceKind})]}),e.jsx("div",{className:"mt-2 font-medium text-[var(--ui-ink-strong)]",children:s.title}),e.jsxs("div",{children:[new Date(s.startedAt).toLocaleTimeString()," →"," ",new Date(s.endedAt).toLocaleTimeString()]}),e.jsxs("div",{className:`mt-1 ${k}`,children:[s.origin,s.overrideCount>0?` · overrides ${s.overrideCount}`:""]})]},s.id))]})]})]},t.id))})]})]})}export{se as CompanionSyncLabPage};
|
package/dist/assets/{daily-metrics-dashboard-DpIAdzFX.js → daily-metrics-dashboard-CXnAtN2T.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as w,j as e,bB as A,d0 as re,d1 as te,aI as ie,d2 as ne,d3 as le,d4 as oe,aG as de,aX as ue,cU as ce,aK as xe}from"./vendor-Cpmju3nw.js";import{R as ge,P as ve,O as me,C as fe,T as pe,D as he,a as be}from"./ui-B9O-eUim.js";import{C as N,k as c,a4 as D,c as h}from"./index-wEZUnRh0.js";import{R as _,d as O,C as B,X as I,Y as $,T as z,B as G,a as W,c as T,b as je}from"./charts-DwTguE_x.js";function C(a){return a?new Date(`${a}T12:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"No date yet"}function E(a,s){return s==="cumulative"?a.total??a.latest??a.maximum??a.average:a.latest??a.average??a.maximum??a.minimum}function x(a,s){if(s==null)return"No reading";const r=a.unit==="steps"||a.unit==="flights"||a.unit==="kcal"||a.unit==="min"||a.unit==="swears"||a.unit==="conversations"||a.unit==="messages"?0:(a.unit==="%",1);return`${s.toLocaleString(void 0,{maximumFractionDigits:r,minimumFractionDigits:r===0||s>=100?0:1})} ${a.unit}`}function K(a){return a.deltaValue==null?"No baseline yet":`${a.deltaValue>0?"+":""}${x(a,a.deltaValue)}`}function S(a){const s="Baseline is the average of the previous up to seven stored daily readings for this metric, excluding the latest day. Delta is latest reading minus that previous-window average.";return a.category!=="conversationTone"?s:a.metric==="devrageSwearCount"?`${s} For devrage swears, days with scanned conversations and zero swears count as 0, but days with no stored scanner rows are not invented into the average.`:a.metric==="devrageAverageMaxCumulativeRage"||a.metric==="devrageMaxCumulativeRage"?`${s} For cumulative rage, each swear-bearing user message adds its swear count and each clean user message cools the running score by 1, floored at 0. The baseline is the previous tracked-days average of that daily peak metric.`:a.metric==="swearingMessagePercent"?`${s} For swearing rate, the daily value is swear-bearing user messages divided by scanned user messages for that day.`:s}function we(a){return Math.round(a*10)/10}const j={fill:"var(--ui-ink-faint)",fontSize:11},H={stroke:"var(--ui-border-subtle)"},X="var(--ui-border-subtle)",Y={stroke:"var(--ui-border-strong)",strokeWidth:1};function U(a,s){return E(a,s)}function L(a){const s=a.days.map(r=>U(r,a.aggregation)).filter(r=>r!=null);return s.length===0?{minimum:null,average:null,maximum:null,count:0}:{minimum:Math.min(...s),average:s.reduce((r,t)=>r+t,0)/s.length,maximum:Math.max(...s),count:s.length}}function V(a){return new Date(`${a}T12:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ke({active:a,payload:s,label:r,metric:t}){var i;if(!a||!(s!=null&&s.length)||typeof r!="string")return null;const n=((i=s.find(l=>typeof l.value=="number"))==null?void 0:i.value)??null;return e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:V(r)}),e.jsx("div",{className:"mt-1 text-sm font-semibold text-[var(--ui-ink-strong)]",children:x(t,n)})]})}function q({metric:a,height:s=180,detailed:r=!1}){const t=w.useMemo(()=>L(a),[a]),n=w.useMemo(()=>a.days.map(d=>({dateKey:d.dateKey,value:U(d,a.aggregation),sampleCount:d.sampleCount})),[a]),i=n.map(d=>d.value).filter(d=>d!=null),l=i.length>0?Math.min(...i):0,v=i.length>0?Math.max(...i):1,p=Math.max((v-l)*.12,a.unit==="%"?2:1),u=f(a.category),m=`metric-gradient-${a.metric.replace(/[^a-z0-9]/gi,"-")}`;return i.length===0?e.jsx("div",{className:"flex items-center justify-center rounded-[22px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-center text-sm text-[var(--ui-ink-faint)]",style:{height:s},children:"Waiting for chart data"}):e.jsx("div",{className:h("overflow-hidden rounded-[22px] border bg-[var(--ui-surface-1)] p-3",u.ring),style:{height:s},children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(O,{data:n,margin:{top:r?18:8,right:r?18:4,bottom:r?12:0,left:r?8:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--primary)",stopOpacity:.55}),e.jsx("stop",{offset:"56%",stopColor:"var(--warning)",stopOpacity:.22}),e.jsx("stop",{offset:"100%",stopColor:"var(--warning)",stopOpacity:.02})]})}),e.jsx(B,{stroke:X,vertical:r}),e.jsx(I,{dataKey:"dateKey",tickFormatter:V,minTickGap:r?22:34,tick:j,axisLine:H,tickLine:!1}),e.jsx($,{width:r?62:36,domain:[Math.max(0,l-p),v+p],tickFormatter:d=>x(a,Number(d)).replace(` ${a.unit}`,""),tick:j,axisLine:!1,tickLine:!1}),t.average!=null?e.jsx(je,{y:we(t.average),stroke:"var(--ui-ink-faint)",strokeDasharray:"5 5",ifOverflow:"extendDomain"}):null,e.jsx(z,{cursor:Y,content:e.jsx(ke,{metric:a})}),a.aggregation==="cumulative"?e.jsx(G,{dataKey:"value",radius:[8,8,2,2],fill:`url(#${m})`,maxBarSize:r?34:20}):e.jsx(W,{type:"monotone",dataKey:"value",stroke:"var(--primary)",strokeWidth:r?3:2,fill:`url(#${m})`,dot:r?{r:3,fill:"var(--warning)"}:!1,activeDot:{r:5,fill:"var(--warning)"}})]})})})}function ye({metric:a,open:s,onOpenChange:r}){const t=L(a),n=f(a.category);return e.jsx(ge,{open:s,onOpenChange:r,children:e.jsxs(ve,{children:[e.jsx(me,{className:"fixed inset-0 z-50 bg-[var(--overlay)] backdrop-blur-xl"}),e.jsxs(fe,{className:"fixed inset-3 z-[51] grid min-h-0 overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] sm:inset-5",children:[e.jsxs(pe,{className:"sr-only",children:[a.label," chart"]}),e.jsx(he,{className:"sr-only",children:"Full-screen time-series chart for the selected daily metric."}),e.jsxs("div",{className:"grid min-h-0 grid-rows-[auto_minmax(0,1fr)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4 sm:px-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[a.category," time series"]}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)] sm:text-3xl",children:a.label}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx(c,{className:n.badge,children:a.aggregation}),e.jsxs(c,{tone:"meta",children:[a.coverageDays," tracked days"]}),e.jsxs(c,{tone:"meta",children:["latest ",C(a.latestDateKey)]})]})]}),e.jsx(be,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-11 items-center justify-center 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)]","aria-label":"Close metric chart",children:e.jsx(xe,{className:"size-5"})})})]}),e.jsxs("div",{className:"grid min-h-0 gap-4 overflow-y-auto p-4 sm:p-6 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsx(q,{metric:a,height:560,detailed:!0}),e.jsx("div",{className:"grid content-start gap-3",children:[["Latest",a.latestValue],["Period min",t.minimum],["Period average",t.average],["Period max",t.maximum],["Baseline",a.baselineValue],["Delta",a.deltaValue]].map(([i,l])=>e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{children:i}),i==="Baseline"?e.jsx(D,{label:`Explain ${a.label} baseline`,title:"Baseline calculation",content:S(a)}):null]})}),e.jsx("div",{className:"mt-1 break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:x(a,typeof l=="number"?l:null)})]},String(i)))})]})]})]})]})})}function Ne(a){return a.deltaValue==null||a.deltaValue===0?"steady":a.deltaValue>0?"up":"down"}function f(a){switch(a){case"recovery":return{ring:"border-[var(--danger)]/20",badge:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",glow:"from-[var(--ui-danger-soft)] via-[var(--ui-surface-2)] to-transparent"};case"cardio":return{ring:"border-[var(--info)]/24",badge:"bg-[var(--ui-info-soft)] text-[var(--info)]",glow:"from-[var(--ui-info-soft)] via-[var(--ui-surface-2)] to-transparent"};case"breathing":return{ring:"border-[var(--success)]/22",badge:"bg-[var(--ui-success-soft)] text-[var(--success)]",glow:"from-[var(--ui-success-soft)] via-[var(--ui-surface-2)] to-transparent"};case"composition":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};case"temperature":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};case"conversationTone":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};default:return{ring:"border-[var(--ui-border-subtle)]",badge:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",glow:"from-[var(--ui-accent-soft)] via-[var(--ui-surface-2)] to-transparent"}}}function J(a){switch(a){case"restingHeartRate":case"walkingHeartRateAverage":case"heartRateRecoveryOneMinute":return ue;case"heartRateVariabilitySDNN":case"vo2Max":return de;case"oxygenSaturation":case"respiratoryRate":return oe;case"bodyMass":case"bodyFatPercentage":case"leanBodyMass":return le;case"stepCount":case"flightsClimbed":case"appleExerciseTime":return ne;case"basalEnergyBurned":return ie;case"swearingMessagePercent":return te;case"devrageSwearCount":case"devrageAverageMaxCumulativeRage":case"devrageMaxCumulativeRage":return re;default:return A}}function k(a,s){if(!a)return null;const r=a.aggregation,t=a.days.find(n=>n.dateKey===s);return t?E(t,r):null}function Q(a,s){return a?x(a,s):"No signal"}function De({active:a,payload:s,label:r,swearMetric:t,percentMetric:n,averageRageMetric:i,maxRageMetric:l}){if(!a||!(s!=null&&s.length)||typeof r!="string")return null;const v=new Map(s.filter(u=>typeof u.dataKey=="string").map(u=>[String(u.dataKey),u.value??null])),p=[["Max rage peak",l,v.get("maxPeak")??null],["Average rage peak",i,v.get("averagePeak")??null],["Swears",t,v.get("swears")??null],["Swearing rate",n,v.get("rate")??null]];return e.jsxs("div",{className:"min-w-56 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] p-3 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:V(r)}),e.jsx("div",{className:"mt-2 grid gap-2",children:p.map(([u,m,d])=>e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"min-w-0 text-[var(--ui-ink-soft)]",children:u}),e.jsx("span",{className:"min-w-0 break-words text-right font-semibold text-[var(--ui-ink-strong)]",children:Q(m,d)})]},u))})]})}function y({label:a,metric:s,fallback:r="No signal"}){const t=f("conversationTone");return e.jsxs("div",{className:"min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:s?x(s,s.latestValue):r}),s?e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap gap-2 text-xs",children:[e.jsx(c,{className:t.badge,children:K(s)}),e.jsxs(c,{tone:"meta",children:[s.coverageDays," days"]})]}):null]})}function Ke({swearMetric:a,percentMetric:s,averageRageMetric:r,maxRageMetric:t,compact:n=!1}){var F;const i=w.useId().replace(/:/g,""),l=`devrage-rage-${i}`,v=`devrage-swears-${i}`,p=`devrage-panel-${i}`,u=w.useMemo(()=>Array.from(new Set([a,s,r,t].flatMap(g=>(g==null?void 0:g.days.map(se=>se.dateKey))??[]))).sort().slice(n?-14:-28).map(g=>({dateKey:g,swears:k(a,g),rate:k(s,g),averagePeak:k(r,g),maxPeak:k(t,g)})),[r,n,t,s,a]),m=u.flatMap(o=>[o.swears,o.averagePeak,o.maxPeak]).filter(o=>o!=null),d=u.map(o=>o.rate).filter(o=>o!=null),Z=m.length>0||d.length>0,M=Math.max(1,...m),R=Math.max(10,...d),ee=(t==null?void 0:t.latestDateKey)??(r==null?void 0:r.latestDateKey)??(a==null?void 0:a.latestDateKey)??(s==null?void 0:s.latestDateKey)??null,b=t??r??a??s,P=(b==null?void 0:b.deltaValue)??null,ae=P==null?"Baseline forming":P>0?"Rage pressure rising":P<0?"Rage pressure cooling":"Rage pressure steady";return Z?e.jsxs(N,{className:"relative overflow-hidden rounded-[30px] border border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] bg-[linear-gradient(135deg,color-mix(in_srgb,var(--ui-warning-soft)_30%,var(--ui-surface-section)_70%),var(--ui-surface-section)_48%,color-mix(in_srgb,var(--ui-info-soft)_18%,var(--ui-surface-section)_82%))] p-0 shadow-[var(--card-shadow)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-55 [background-image:linear-gradient(rgba(255,255,255,0.055)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.04)_1px,transparent_1px)] [background-size:32px_32px]"}),e.jsxs("div",{className:"relative grid gap-5 p-5 sm:p-6 lg:grid-cols-[minmax(0,1.45fr)_minmax(280px,0.75fr)]",children:[e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Conversation tone figure"}),e.jsx("div",{className:"mt-1 break-words text-3xl font-semibold leading-tight text-[var(--ui-ink-strong)] sm:text-4xl",children:"Cumulative rage profile"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Swear volume, swearing-message rate, average thread peak, and maximum thread peak on one daily surface."})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(c,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:ae}),b?e.jsx(D,{label:"Explain devrage baseline",title:"Baseline calculation",content:S(b)}):null,e.jsxs(c,{tone:"meta",children:["Latest ",C(ee)]})]})]}),e.jsx("div",{className:"overflow-hidden rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",style:{height:n?280:340},children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(O,{data:u,margin:{top:18,right:12,bottom:0,left:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:p,x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--warning)",stopOpacity:.36}),e.jsx("stop",{offset:"52%",stopColor:"var(--primary)",stopOpacity:.12}),e.jsx("stop",{offset:"100%",stopColor:"var(--info)",stopOpacity:.18})]}),e.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--warning)",stopOpacity:.62}),e.jsx("stop",{offset:"58%",stopColor:"var(--danger)",stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:"var(--danger)",stopOpacity:.02})]}),e.jsxs("linearGradient",{id:v,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--ui-ink-strong)",stopOpacity:.34}),e.jsx("stop",{offset:"100%",stopColor:"var(--ui-ink-faint)",stopOpacity:.06})]})]}),e.jsx(B,{stroke:X,strokeDasharray:"4 10",vertical:!1}),e.jsx(I,{dataKey:"dateKey",tickFormatter:V,minTickGap:n?36:24,tick:j,axisLine:H,tickLine:!1}),e.jsx($,{yAxisId:"rage",width:42,domain:[0,Math.ceil(M*1.18)],tickFormatter:o=>Number(o).toFixed(0),tick:j,axisLine:!1,tickLine:!1}),e.jsx($,{yAxisId:"rate",orientation:"right",width:42,domain:[0,Math.min(100,Math.ceil(R*1.22))],tickFormatter:o=>`${Number(o).toFixed(0)}%`,tick:j,axisLine:!1,tickLine:!1}),e.jsx(z,{cursor:Y,content:e.jsx(De,{swearMetric:a,percentMetric:s,averageRageMetric:r,maxRageMetric:t})}),e.jsx(G,{yAxisId:"rage",dataKey:"swears",radius:[10,10,3,3],fill:`url(#${v})`,maxBarSize:n?16:22}),e.jsx(W,{yAxisId:"rage",type:"monotone",dataKey:"averagePeak",stroke:"var(--warning)",strokeWidth:2,fill:`url(#${l})`,dot:!1,activeDot:{r:5,fill:"var(--warning)"}}),e.jsx(T,{yAxisId:"rage",type:"monotone",dataKey:"maxPeak",stroke:"var(--danger)",strokeWidth:3,dot:{r:3,fill:"var(--danger)"},activeDot:{r:6,fill:"var(--danger)"}}),e.jsx(T,{yAxisId:"rate",type:"monotone",dataKey:"rate",stroke:"var(--info)",strokeWidth:2,strokeDasharray:"6 6",dot:!1,activeDot:{r:5,fill:"var(--info)"}})]})})}),e.jsx("div",{className:"flex min-w-0 flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[["Swears","bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"],["Average peak","bg-[var(--ui-warning-soft)] text-[var(--warning)]"],["Max peak","bg-[var(--ui-danger-soft)] text-[var(--danger)]"],["Swearing rate","bg-[var(--ui-info-soft)] text-[var(--info)]"]].map(([o,g])=>e.jsx(c,{className:g,children:o},o))})]}),e.jsxs("div",{className:"grid min-w-0 content-start gap-3",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest peak"}),e.jsx("div",{className:"mt-2 break-words text-5xl font-semibold leading-none text-[var(--ui-ink-strong)]",children:Q(t??r,((F=t??r)==null?void 0:F.latestValue)??null)}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Peak score is the highest cumulative swear streak pressure reached inside any scanned thread for the day."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2",children:[e.jsx(y,{label:"Average thread peak",metric:r}),e.jsx(y,{label:"Swearing rate",metric:s}),e.jsx(y,{label:"Swears",metric:a}),e.jsx(y,{label:"Max thread peak",metric:t})]})]})]})]}):e.jsxs(N,{className:"rounded-[30px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Cumulative rage profile"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:"Waiting for devrage history"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will draw the rage profile after the local scanner stores daily conversation-tone rows."})]})}function Le({title:a,description:s,metric:r,emptyDescription:t}){const n=r?J(r.metric):A,i=f(r?r.category:"default"),l=r?Ne(r):"steady";return e.jsxs(N,{className:h("relative overflow-hidden rounded-[28px] border bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",i.ring),children:[e.jsx("div",{className:h("pointer-events-none absolute inset-0 bg-gradient-to-br opacity-90",i.glow)}),e.jsxs("div",{className:"relative grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s})]}),e.jsx("div",{className:"shrink-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",children:e.jsx(n,{className:"size-5"})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:r?x(r,r.latestValue):"No signal yet"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-[var(--ui-ink-soft)]",children:[r?e.jsx(c,{className:i.badge,children:r.label}):null,r?e.jsx(c,{className:h("border-none",l==="up"?"bg-[var(--ui-success-soft)] text-[var(--success)]":l==="down"?"bg-[var(--ui-danger-soft)] text-[var(--danger)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),children:K(r)}):null,r?e.jsx(D,{label:`Explain ${r.label} delta`,title:"Delta calculation",content:S(r)}):null,r?e.jsxs(c,{tone:"meta",children:[r.coverageDays," days tracked"]}):null]}),e.jsx("div",{className:"break-words text-xs text-[var(--ui-ink-faint)]",children:r?`Latest reading on ${C(r.latestDateKey)}`:t??"Forge will populate this card as soon as daily readings are available."})]})]})]})}function Ce({metric:a}){const[s,r]=w.useState(!1),t=J(a.metric),n=f(a.category),i=a.days.at(-1),l=L(a);return e.jsxs(N,{className:h("overflow-hidden rounded-[28px] border bg-[var(--ui-surface-section)] p-5",n.ring),children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-4",children:[e.jsx("div",{className:"shrink-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",children:e.jsx(t,{className:"size-5"})}),e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.category}),e.jsx("div",{className:"break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:a.label}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[a.coverageDays," tracked day",a.coverageDays===1?"":"s"]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[e.jsx(c,{className:n.badge,children:a.aggregation}),e.jsxs("button",{type:"button",className:"inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-xs font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>r(!0),children:[e.jsx(ce,{className:"size-3.5"}),"Full screen"]})]})]}),e.jsxs("div",{className:"mt-5 grid gap-4 md:grid-cols-[minmax(0,0.95fr)_minmax(220px,1.05fr)]",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Latest"}),e.jsx("div",{className:"mt-1 break-words text-3xl font-semibold text-[var(--ui-ink-strong)]",children:x(a,a.latestValue)}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:a.latestDateKey?`Latest reading on ${C(a.latestDateKey)}`:"Waiting for the first successful reading"})]}),e.jsxs("div",{className:"grid gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0",children:"Baseline"}),e.jsx(D,{label:`Explain ${a.label} baseline`,title:"Baseline calculation",content:S(a)})]}),e.jsx("span",{className:"min-w-0 break-words text-right font-medium text-[var(--ui-ink-strong)]",children:x(a,a.baselineValue)})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0",children:"Delta"}),e.jsx("span",{className:h("min-w-0 break-words text-right font-medium",a.deltaValue==null?"text-[var(--ui-ink-soft)]":a.deltaValue>0?"text-[var(--success)]":a.deltaValue<0?"text-[var(--danger)]":"text-[var(--ui-ink-strong)]"),children:K(a)})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0",children:"Latest samples"}),e.jsx("span",{className:"min-w-0 break-words text-right font-medium text-[var(--ui-ink-strong)]",children:(i==null?void 0:i.sampleCount)??0})]})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx(q,{metric:a}),e.jsxs("div",{className:"grid gap-2 text-xs text-[var(--ui-ink-faint)] sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period min"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.minimum)})]}),e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period avg"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.average)})]}),e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period max"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.maximum)})]})]})]})]}),e.jsx(ye,{metric:a,open:s,onOpenChange:r})]})}function Fe({groups:a}){return e.jsx("section",{className:"grid gap-5",children:a.map(s=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s.category}),e.jsxs("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[s.metrics.length," signals in this lane"]})]}),e.jsxs(c,{className:f(s.category).badge,children:[s.coverageDays," days of coverage"]})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:s.metrics.map(r=>e.jsx(Ce,{metric:r},r.metric))})]},s.category))})}export{Ke as D,Fe as M,Le as S,C as f,f as m};
|
|
1
|
+
import{r as w,j as e,bB as A,d0 as re,d1 as te,aI as ie,d2 as ne,d3 as le,d4 as oe,aG as de,aX as ue,cU as ce,aK as xe}from"./vendor-Cpmju3nw.js";import{R as ge,P as ve,O as me,C as fe,T as pe,D as he,a as be}from"./ui-B9O-eUim.js";import{C as N,k as c,a4 as D,c as h}from"./index-BejvcRGb.js";import{R as _,d as O,C as B,X as I,Y as $,T as z,B as G,a as W,c as T,b as je}from"./charts-DwTguE_x.js";function C(a){return a?new Date(`${a}T12:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"No date yet"}function E(a,s){return s==="cumulative"?a.total??a.latest??a.maximum??a.average:a.latest??a.average??a.maximum??a.minimum}function x(a,s){if(s==null)return"No reading";const r=a.unit==="steps"||a.unit==="flights"||a.unit==="kcal"||a.unit==="min"||a.unit==="swears"||a.unit==="conversations"||a.unit==="messages"?0:(a.unit==="%",1);return`${s.toLocaleString(void 0,{maximumFractionDigits:r,minimumFractionDigits:r===0||s>=100?0:1})} ${a.unit}`}function K(a){return a.deltaValue==null?"No baseline yet":`${a.deltaValue>0?"+":""}${x(a,a.deltaValue)}`}function S(a){const s="Baseline is the average of the previous up to seven stored daily readings for this metric, excluding the latest day. Delta is latest reading minus that previous-window average.";return a.category!=="conversationTone"?s:a.metric==="devrageSwearCount"?`${s} For devrage swears, days with scanned conversations and zero swears count as 0, but days with no stored scanner rows are not invented into the average.`:a.metric==="devrageAverageMaxCumulativeRage"||a.metric==="devrageMaxCumulativeRage"?`${s} For cumulative rage, each swear-bearing user message adds its swear count and each clean user message cools the running score by 1, floored at 0. The baseline is the previous tracked-days average of that daily peak metric.`:a.metric==="swearingMessagePercent"?`${s} For swearing rate, the daily value is swear-bearing user messages divided by scanned user messages for that day.`:s}function we(a){return Math.round(a*10)/10}const j={fill:"var(--ui-ink-faint)",fontSize:11},H={stroke:"var(--ui-border-subtle)"},X="var(--ui-border-subtle)",Y={stroke:"var(--ui-border-strong)",strokeWidth:1};function U(a,s){return E(a,s)}function L(a){const s=a.days.map(r=>U(r,a.aggregation)).filter(r=>r!=null);return s.length===0?{minimum:null,average:null,maximum:null,count:0}:{minimum:Math.min(...s),average:s.reduce((r,t)=>r+t,0)/s.length,maximum:Math.max(...s),count:s.length}}function V(a){return new Date(`${a}T12:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ke({active:a,payload:s,label:r,metric:t}){var i;if(!a||!(s!=null&&s.length)||typeof r!="string")return null;const n=((i=s.find(l=>typeof l.value=="number"))==null?void 0:i.value)??null;return e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-[var(--ui-ink-medium)] shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:V(r)}),e.jsx("div",{className:"mt-1 text-sm font-semibold text-[var(--ui-ink-strong)]",children:x(t,n)})]})}function q({metric:a,height:s=180,detailed:r=!1}){const t=w.useMemo(()=>L(a),[a]),n=w.useMemo(()=>a.days.map(d=>({dateKey:d.dateKey,value:U(d,a.aggregation),sampleCount:d.sampleCount})),[a]),i=n.map(d=>d.value).filter(d=>d!=null),l=i.length>0?Math.min(...i):0,v=i.length>0?Math.max(...i):1,p=Math.max((v-l)*.12,a.unit==="%"?2:1),u=f(a.category),m=`metric-gradient-${a.metric.replace(/[^a-z0-9]/gi,"-")}`;return i.length===0?e.jsx("div",{className:"flex items-center justify-center rounded-[22px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-center text-sm text-[var(--ui-ink-faint)]",style:{height:s},children:"Waiting for chart data"}):e.jsx("div",{className:h("overflow-hidden rounded-[22px] border bg-[var(--ui-surface-1)] p-3",u.ring),style:{height:s},children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(O,{data:n,margin:{top:r?18:8,right:r?18:4,bottom:r?12:0,left:r?8:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:m,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--primary)",stopOpacity:.55}),e.jsx("stop",{offset:"56%",stopColor:"var(--warning)",stopOpacity:.22}),e.jsx("stop",{offset:"100%",stopColor:"var(--warning)",stopOpacity:.02})]})}),e.jsx(B,{stroke:X,vertical:r}),e.jsx(I,{dataKey:"dateKey",tickFormatter:V,minTickGap:r?22:34,tick:j,axisLine:H,tickLine:!1}),e.jsx($,{width:r?62:36,domain:[Math.max(0,l-p),v+p],tickFormatter:d=>x(a,Number(d)).replace(` ${a.unit}`,""),tick:j,axisLine:!1,tickLine:!1}),t.average!=null?e.jsx(je,{y:we(t.average),stroke:"var(--ui-ink-faint)",strokeDasharray:"5 5",ifOverflow:"extendDomain"}):null,e.jsx(z,{cursor:Y,content:e.jsx(ke,{metric:a})}),a.aggregation==="cumulative"?e.jsx(G,{dataKey:"value",radius:[8,8,2,2],fill:`url(#${m})`,maxBarSize:r?34:20}):e.jsx(W,{type:"monotone",dataKey:"value",stroke:"var(--primary)",strokeWidth:r?3:2,fill:`url(#${m})`,dot:r?{r:3,fill:"var(--warning)"}:!1,activeDot:{r:5,fill:"var(--warning)"}})]})})})}function ye({metric:a,open:s,onOpenChange:r}){const t=L(a),n=f(a.category);return e.jsx(ge,{open:s,onOpenChange:r,children:e.jsxs(ve,{children:[e.jsx(me,{className:"fixed inset-0 z-50 bg-[var(--overlay)] backdrop-blur-xl"}),e.jsxs(fe,{className:"fixed inset-3 z-[51] grid min-h-0 overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] sm:inset-5",children:[e.jsxs(pe,{className:"sr-only",children:[a.label," chart"]}),e.jsx(he,{className:"sr-only",children:"Full-screen time-series chart for the selected daily metric."}),e.jsxs("div",{className:"grid min-h-0 grid-rows-[auto_minmax(0,1fr)]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4 sm:px-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[a.category," time series"]}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)] sm:text-3xl",children:a.label}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsx(c,{className:n.badge,children:a.aggregation}),e.jsxs(c,{tone:"meta",children:[a.coverageDays," tracked days"]}),e.jsxs(c,{tone:"meta",children:["latest ",C(a.latestDateKey)]})]})]}),e.jsx(be,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex size-11 items-center justify-center 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)]","aria-label":"Close metric chart",children:e.jsx(xe,{className:"size-5"})})})]}),e.jsxs("div",{className:"grid min-h-0 gap-4 overflow-y-auto p-4 sm:p-6 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsx(q,{metric:a,height:560,detailed:!0}),e.jsx("div",{className:"grid content-start gap-3",children:[["Latest",a.latestValue],["Period min",t.minimum],["Period average",t.average],["Period max",t.maximum],["Baseline",a.baselineValue],["Delta",a.deltaValue]].map(([i,l])=>e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{children:i}),i==="Baseline"?e.jsx(D,{label:`Explain ${a.label} baseline`,title:"Baseline calculation",content:S(a)}):null]})}),e.jsx("div",{className:"mt-1 break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:x(a,typeof l=="number"?l:null)})]},String(i)))})]})]})]})]})})}function Ne(a){return a.deltaValue==null||a.deltaValue===0?"steady":a.deltaValue>0?"up":"down"}function f(a){switch(a){case"recovery":return{ring:"border-[var(--danger)]/20",badge:"bg-[var(--ui-danger-soft)] text-[var(--danger)]",glow:"from-[var(--ui-danger-soft)] via-[var(--ui-surface-2)] to-transparent"};case"cardio":return{ring:"border-[var(--info)]/24",badge:"bg-[var(--ui-info-soft)] text-[var(--info)]",glow:"from-[var(--ui-info-soft)] via-[var(--ui-surface-2)] to-transparent"};case"breathing":return{ring:"border-[var(--success)]/22",badge:"bg-[var(--ui-success-soft)] text-[var(--success)]",glow:"from-[var(--ui-success-soft)] via-[var(--ui-surface-2)] to-transparent"};case"composition":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};case"temperature":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};case"conversationTone":return{ring:"border-[var(--warning)]/22",badge:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",glow:"from-[var(--ui-warning-soft)] via-[var(--ui-surface-2)] to-transparent"};default:return{ring:"border-[var(--ui-border-subtle)]",badge:"bg-[var(--ui-accent-soft)] text-[var(--primary)]",glow:"from-[var(--ui-accent-soft)] via-[var(--ui-surface-2)] to-transparent"}}}function J(a){switch(a){case"restingHeartRate":case"walkingHeartRateAverage":case"heartRateRecoveryOneMinute":return ue;case"heartRateVariabilitySDNN":case"vo2Max":return de;case"oxygenSaturation":case"respiratoryRate":return oe;case"bodyMass":case"bodyFatPercentage":case"leanBodyMass":return le;case"stepCount":case"flightsClimbed":case"appleExerciseTime":return ne;case"basalEnergyBurned":return ie;case"swearingMessagePercent":return te;case"devrageSwearCount":case"devrageAverageMaxCumulativeRage":case"devrageMaxCumulativeRage":return re;default:return A}}function k(a,s){if(!a)return null;const r=a.aggregation,t=a.days.find(n=>n.dateKey===s);return t?E(t,r):null}function Q(a,s){return a?x(a,s):"No signal"}function De({active:a,payload:s,label:r,swearMetric:t,percentMetric:n,averageRageMetric:i,maxRageMetric:l}){if(!a||!(s!=null&&s.length)||typeof r!="string")return null;const v=new Map(s.filter(u=>typeof u.dataKey=="string").map(u=>[String(u.dataKey),u.value??null])),p=[["Max rage peak",l,v.get("maxPeak")??null],["Average rage peak",i,v.get("averagePeak")??null],["Swears",t,v.get("swears")??null],["Swearing rate",n,v.get("rate")??null]];return e.jsxs("div",{className:"min-w-56 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] p-3 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:V(r)}),e.jsx("div",{className:"mt-2 grid gap-2",children:p.map(([u,m,d])=>e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"min-w-0 text-[var(--ui-ink-soft)]",children:u}),e.jsx("span",{className:"min-w-0 break-words text-right font-semibold text-[var(--ui-ink-strong)]",children:Q(m,d)})]},u))})]})}function y({label:a,metric:s,fallback:r="No signal"}){const t=f("conversationTone");return e.jsxs("div",{className:"min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:s?x(s,s.latestValue):r}),s?e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap gap-2 text-xs",children:[e.jsx(c,{className:t.badge,children:K(s)}),e.jsxs(c,{tone:"meta",children:[s.coverageDays," days"]})]}):null]})}function Ke({swearMetric:a,percentMetric:s,averageRageMetric:r,maxRageMetric:t,compact:n=!1}){var F;const i=w.useId().replace(/:/g,""),l=`devrage-rage-${i}`,v=`devrage-swears-${i}`,p=`devrage-panel-${i}`,u=w.useMemo(()=>Array.from(new Set([a,s,r,t].flatMap(g=>(g==null?void 0:g.days.map(se=>se.dateKey))??[]))).sort().slice(n?-14:-28).map(g=>({dateKey:g,swears:k(a,g),rate:k(s,g),averagePeak:k(r,g),maxPeak:k(t,g)})),[r,n,t,s,a]),m=u.flatMap(o=>[o.swears,o.averagePeak,o.maxPeak]).filter(o=>o!=null),d=u.map(o=>o.rate).filter(o=>o!=null),Z=m.length>0||d.length>0,M=Math.max(1,...m),R=Math.max(10,...d),ee=(t==null?void 0:t.latestDateKey)??(r==null?void 0:r.latestDateKey)??(a==null?void 0:a.latestDateKey)??(s==null?void 0:s.latestDateKey)??null,b=t??r??a??s,P=(b==null?void 0:b.deltaValue)??null,ae=P==null?"Baseline forming":P>0?"Rage pressure rising":P<0?"Rage pressure cooling":"Rage pressure steady";return Z?e.jsxs(N,{className:"relative overflow-hidden rounded-[30px] border border-[color-mix(in_srgb,var(--warning)_22%,var(--ui-border-subtle)_78%)] bg-[linear-gradient(135deg,color-mix(in_srgb,var(--ui-warning-soft)_30%,var(--ui-surface-section)_70%),var(--ui-surface-section)_48%,color-mix(in_srgb,var(--ui-info-soft)_18%,var(--ui-surface-section)_82%))] p-0 shadow-[var(--card-shadow)]",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-55 [background-image:linear-gradient(rgba(255,255,255,0.055)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.04)_1px,transparent_1px)] [background-size:32px_32px]"}),e.jsxs("div",{className:"relative grid gap-5 p-5 sm:p-6 lg:grid-cols-[minmax(0,1.45fr)_minmax(280px,0.75fr)]",children:[e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:"Conversation tone figure"}),e.jsx("div",{className:"mt-1 break-words text-3xl font-semibold leading-tight text-[var(--ui-ink-strong)] sm:text-4xl",children:"Cumulative rage profile"}),e.jsx("div",{className:"mt-2 max-w-2xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Swear volume, swearing-message rate, average thread peak, and maximum thread peak on one daily surface."})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsx(c,{className:"bg-[var(--ui-warning-soft)] text-[var(--warning)]",children:ae}),b?e.jsx(D,{label:"Explain devrage baseline",title:"Baseline calculation",content:S(b)}):null,e.jsxs(c,{tone:"meta",children:["Latest ",C(ee)]})]})]}),e.jsx("div",{className:"overflow-hidden rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",style:{height:n?280:340},children:e.jsx(_,{width:"100%",height:"100%",children:e.jsxs(O,{data:u,margin:{top:18,right:12,bottom:0,left:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:p,x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--warning)",stopOpacity:.36}),e.jsx("stop",{offset:"52%",stopColor:"var(--primary)",stopOpacity:.12}),e.jsx("stop",{offset:"100%",stopColor:"var(--info)",stopOpacity:.18})]}),e.jsxs("linearGradient",{id:l,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--warning)",stopOpacity:.62}),e.jsx("stop",{offset:"58%",stopColor:"var(--danger)",stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:"var(--danger)",stopOpacity:.02})]}),e.jsxs("linearGradient",{id:v,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--ui-ink-strong)",stopOpacity:.34}),e.jsx("stop",{offset:"100%",stopColor:"var(--ui-ink-faint)",stopOpacity:.06})]})]}),e.jsx(B,{stroke:X,strokeDasharray:"4 10",vertical:!1}),e.jsx(I,{dataKey:"dateKey",tickFormatter:V,minTickGap:n?36:24,tick:j,axisLine:H,tickLine:!1}),e.jsx($,{yAxisId:"rage",width:42,domain:[0,Math.ceil(M*1.18)],tickFormatter:o=>Number(o).toFixed(0),tick:j,axisLine:!1,tickLine:!1}),e.jsx($,{yAxisId:"rate",orientation:"right",width:42,domain:[0,Math.min(100,Math.ceil(R*1.22))],tickFormatter:o=>`${Number(o).toFixed(0)}%`,tick:j,axisLine:!1,tickLine:!1}),e.jsx(z,{cursor:Y,content:e.jsx(De,{swearMetric:a,percentMetric:s,averageRageMetric:r,maxRageMetric:t})}),e.jsx(G,{yAxisId:"rage",dataKey:"swears",radius:[10,10,3,3],fill:`url(#${v})`,maxBarSize:n?16:22}),e.jsx(W,{yAxisId:"rage",type:"monotone",dataKey:"averagePeak",stroke:"var(--warning)",strokeWidth:2,fill:`url(#${l})`,dot:!1,activeDot:{r:5,fill:"var(--warning)"}}),e.jsx(T,{yAxisId:"rage",type:"monotone",dataKey:"maxPeak",stroke:"var(--danger)",strokeWidth:3,dot:{r:3,fill:"var(--danger)"},activeDot:{r:6,fill:"var(--danger)"}}),e.jsx(T,{yAxisId:"rate",type:"monotone",dataKey:"rate",stroke:"var(--info)",strokeWidth:2,strokeDasharray:"6 6",dot:!1,activeDot:{r:5,fill:"var(--info)"}})]})})}),e.jsx("div",{className:"flex min-w-0 flex-wrap gap-2 text-xs text-[var(--ui-ink-soft)]",children:[["Swears","bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"],["Average peak","bg-[var(--ui-warning-soft)] text-[var(--warning)]"],["Max peak","bg-[var(--ui-danger-soft)] text-[var(--danger)]"],["Swearing rate","bg-[var(--ui-info-soft)] text-[var(--info)]"]].map(([o,g])=>e.jsx(c,{className:g,children:o},o))})]}),e.jsxs("div",{className:"grid min-w-0 content-start gap-3",children:[e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest peak"}),e.jsx("div",{className:"mt-2 break-words text-5xl font-semibold leading-none text-[var(--ui-ink-strong)]",children:Q(t??r,((F=t??r)==null?void 0:F.latestValue)??null)}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Peak score is the highest cumulative swear streak pressure reached inside any scanned thread for the day."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2",children:[e.jsx(y,{label:"Average thread peak",metric:r}),e.jsx(y,{label:"Swearing rate",metric:s}),e.jsx(y,{label:"Swears",metric:a}),e.jsx(y,{label:"Max thread peak",metric:t})]})]})]})]}):e.jsxs(N,{className:"rounded-[30px] border border-dashed border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Cumulative rage profile"}),e.jsx("div",{className:"mt-2 text-2xl font-semibold text-[var(--ui-ink-strong)]",children:"Waiting for devrage history"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Forge will draw the rage profile after the local scanner stores daily conversation-tone rows."})]})}function Le({title:a,description:s,metric:r,emptyDescription:t}){const n=r?J(r.metric):A,i=f(r?r.category:"default"),l=r?Ne(r):"steady";return e.jsxs(N,{className:h("relative overflow-hidden rounded-[28px] border bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",i.ring),children:[e.jsx("div",{className:h("pointer-events-none absolute inset-0 bg-gradient-to-br opacity-90",i.glow)}),e.jsxs("div",{className:"relative grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a}),e.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)]",children:s})]}),e.jsx("div",{className:"shrink-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",children:e.jsx(n,{className:"size-5"})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:r?x(r,r.latestValue):"No signal yet"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-[var(--ui-ink-soft)]",children:[r?e.jsx(c,{className:i.badge,children:r.label}):null,r?e.jsx(c,{className:h("border-none",l==="up"?"bg-[var(--ui-success-soft)] text-[var(--success)]":l==="down"?"bg-[var(--ui-danger-soft)] text-[var(--danger)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),children:K(r)}):null,r?e.jsx(D,{label:`Explain ${r.label} delta`,title:"Delta calculation",content:S(r)}):null,r?e.jsxs(c,{tone:"meta",children:[r.coverageDays," days tracked"]}):null]}),e.jsx("div",{className:"break-words text-xs text-[var(--ui-ink-faint)]",children:r?`Latest reading on ${C(r.latestDateKey)}`:t??"Forge will populate this card as soon as daily readings are available."})]})]})]})}function Ce({metric:a}){const[s,r]=w.useState(!1),t=J(a.metric),n=f(a.category),i=a.days.at(-1),l=L(a);return e.jsxs(N,{className:h("overflow-hidden rounded-[28px] border bg-[var(--ui-surface-section)] p-5",n.ring),children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-4",children:[e.jsx("div",{className:"shrink-0 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",children:e.jsx(t,{className:"size-5"})}),e.jsxs("div",{className:"grid min-w-0 gap-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.category}),e.jsx("div",{className:"break-words text-xl font-semibold text-[var(--ui-ink-strong)]",children:a.label}),e.jsxs("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:[a.coverageDays," tracked day",a.coverageDays===1?"":"s"]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[e.jsx(c,{className:n.badge,children:a.aggregation}),e.jsxs("button",{type:"button",className:"inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-xs font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>r(!0),children:[e.jsx(ce,{className:"size-3.5"}),"Full screen"]})]})]}),e.jsxs("div",{className:"mt-5 grid gap-4 md:grid-cols-[minmax(0,0.95fr)_minmax(220px,1.05fr)]",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Latest"}),e.jsx("div",{className:"mt-1 break-words text-3xl font-semibold text-[var(--ui-ink-strong)]",children:x(a,a.latestValue)}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:a.latestDateKey?`Latest reading on ${C(a.latestDateKey)}`:"Waiting for the first successful reading"})]}),e.jsxs("div",{className:"grid gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0",children:"Baseline"}),e.jsx(D,{label:`Explain ${a.label} baseline`,title:"Baseline calculation",content:S(a)})]}),e.jsx("span",{className:"min-w-0 break-words text-right font-medium text-[var(--ui-ink-strong)]",children:x(a,a.baselineValue)})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0",children:"Delta"}),e.jsx("span",{className:h("min-w-0 break-words text-right font-medium",a.deltaValue==null?"text-[var(--ui-ink-soft)]":a.deltaValue>0?"text-[var(--success)]":a.deltaValue<0?"text-[var(--danger)]":"text-[var(--ui-ink-strong)]"),children:K(a)})]}),e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[e.jsx("span",{className:"min-w-0",children:"Latest samples"}),e.jsx("span",{className:"min-w-0 break-words text-right font-medium text-[var(--ui-ink-strong)]",children:(i==null?void 0:i.sampleCount)??0})]})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx(q,{metric:a}),e.jsxs("div",{className:"grid gap-2 text-xs text-[var(--ui-ink-faint)] sm:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period min"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.minimum)})]}),e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period avg"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.average)})]}),e.jsxs("div",{className:"min-w-0 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{children:"Period max"}),e.jsx("div",{className:"mt-1 break-words font-medium text-[var(--ui-ink-medium)]",children:x(a,l.maximum)})]})]})]})]}),e.jsx(ye,{metric:a,open:s,onOpenChange:r})]})}function Fe({groups:a}){return e.jsx("section",{className:"grid gap-5",children:a.map(s=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:s.category}),e.jsxs("div",{className:"mt-1 break-words text-2xl font-semibold text-[var(--ui-ink-strong)]",children:[s.metrics.length," signals in this lane"]})]}),e.jsxs(c,{className:f(s.category).badge,children:[s.coverageDays," days of coverage"]})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:s.metrics.map(r=>e.jsx(Ce,{metric:r},r.metric))})]},s.category))})}export{Ke as D,Fe as M,Le as S,C as f,f as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as t}from"./generic-node-view-
|
|
1
|
+
import{i as t}from"./generic-node-view-COhU_Wm3.js";function p(n,e){const o=r=>n(r);return o.displayName=e.title.replace(/\s+/g,""),t(o,e)}export{p as d};
|
package/dist/assets/{entity-link-multiselect-DZZjpL_d.js → entity-link-multiselect-wuyJ8BbW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as r,aK as X,b7 as T,F as G,bX as J}from"./vendor-Cpmju3nw.js";import{b as A,c as i}from"./index-
|
|
1
|
+
import{r as n,j as r,aK as X,b7 as T,F as G,bX as J}from"./vendor-Cpmju3nw.js";import{b as A,c as i}from"./index-BejvcRGb.js";import{u as W}from"./use-anchored-overlay-position-BrQ4cqKn.js";function E(c){return c.trim().toLowerCase()}function H(c,b){return c.includes(b)?c:[...c,b]}function te({options:c,selectedValues:b,onChange:w,placeholder:K="Search or create…",emptyMessage:U="No matching entries yet.",createLabel:q="Create",onCreate:h,className:F,variant:I="default"}){const[v,y]=n.useState(""),[g,o]=n.useState(!1),[D,f]=n.useState(0),[M,S]=n.useState(!1),[_,p]=n.useState(null),[O,Q]=n.useState([]),j=n.useRef(null),C=n.useRef(null),L=c??[],l=b??[],s=I==="action-bar",P=W(j,g,{offset:6,preferredMaxHeight:320,minHeight:160}),m=n.useMemo(()=>{const e=new Map;return[...O,...L].forEach(t=>{e.set(t.value,t)}),Array.from(e.values())},[O,L]),z=n.useMemo(()=>l.map(e=>m.find(t=>t.value===e)??{value:e,label:e}),[m,l]),d=E(v),x=n.useMemo(()=>{const e=m.filter(t=>!l.includes(t.value));return d?e.filter(t=>`${t.label} ${t.description??""} ${t.searchText??""}`.toLowerCase().includes(d)).slice(0,8):e.slice(0,8)},[m,d,l]),R=m.some(e=>E(e.label)===d);n.useEffect(()=>{if(!g)return;const e=a=>{var $,B;const u=a.target;($=j.current)!=null&&$.contains(u)||(B=C.current)!=null&&B.contains(u)||o(!1)},t=a=>{a.key==="Escape"&&o(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[g]);const k=e=>{w(H(l,e)),y(""),p(null),f(0),o(!1)},V=e=>{w(l.filter(t=>t!==e))},N=async()=>{const e=v.trim();if(!(!h||!e)){S(!0);try{const t=await h(e);Q(a=>a.some(u=>u.value===t.value)?a:[t,...a]),w(H(l,t.value)),y(""),p(null),f(0),o(!1)}catch(t){p(t instanceof Error?t.message:"Unable to create that link right now.")}finally{S(!1)}}};return r.jsxs("div",{className:i("relative grid gap-2",F),ref:j,children:[r.jsxs("div",{className:i("rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",s?"rounded-[20px] border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3.5 py-3 shadow-[inset_0_1px_0_var(--ui-border-subtle)]":"px-3 py-3"),children:[z.length>0?r.jsx("div",{className:i("flex flex-wrap gap-2",s?"mb-2.5":"mb-2"),children:z.map(e=>r.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[e.kind?r.jsx(A,{kind:e.kind,label:e.label,compact:!0,wrap:!0,gradient:!1,className:"max-w-full"}):e.badge?e.badge:r.jsx("span",{className:i("inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm","border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]"),children:r.jsx("span",{className:"max-w-full break-words whitespace-normal [overflow-wrap:anywhere]",children:e.label})}),r.jsx("button",{type:"button",className:i("rounded-full transition","text-[var(--ui-ink-faint)] hover:text-[var(--ui-ink-strong)]"),"aria-label":`Remove ${e.label}`,onClick:()=>V(e.value),children:r.jsx(X,{className:"size-3.5"})})]},e.value))}):null,r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(T,{className:i("size-4","text-[var(--ui-ink-faint)]")}),r.jsx("input",{type:"text",value:v,onChange:e=>{y(e.target.value),p(null),o(!0),f(0)},onFocus:()=>o(!0),onKeyDown:e=>{if(e.key==="Backspace"&&!v&&l.length>0){V(l[l.length-1]);return}if(e.key==="ArrowDown"){e.preventDefault(),o(!0),f(u=>x.length===0?0:Math.min(x.length-1,u+1));return}if(e.key==="ArrowUp"){e.preventDefault(),f(u=>Math.max(0,u-1));return}if(e.key==="Escape"){o(!1);return}if(e.key!=="Enter")return;e.preventDefault();const t=x[D];if(t){k(t.value);return}const a=m.find(u=>E(u.label)===d);if(a&&!l.includes(a.value)){k(a.value);return}N()},placeholder:K,className:i("min-w-0 flex-1 bg-transparent text-sm focus:outline-none","text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)]")})]})]}),g&&P&&typeof document<"u"?G.createPortal(r.jsxs("div",{ref:C,role:"listbox","aria-multiselectable":"true",className:i("z-[80] overflow-y-auto overscroll-contain rounded-[22px] p-2 [webkit-overflow-scrolling:touch]",s?"border border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--ui-surface-1)_94%,transparent)] shadow-[var(--ui-shadow-floating)]":"border border-[var(--ui-border-subtle)] bg-[color-mix(in_srgb,var(--ui-surface-1)_96%,transparent)] shadow-[var(--ui-shadow-floating)]","backdrop-blur-xl"),style:P,children:[x.map((e,t)=>r.jsx("button",{type:"button",role:"option","aria-selected":!1,className:i("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",t===D?"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onMouseEnter:()=>f(t),onMouseDown:a=>a.preventDefault(),onPointerDown:a=>{a.preventDefault(),k(e.value)},onClick:()=>k(e.value),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-sm font-medium",children:e.kind?r.jsx(A,{kind:e.kind,label:e.label,compact:!0,gradient:!1}):e.menuBadge?e.menuBadge:e.badge?e.badge:e.label}),e.description?r.jsx("div",{className:i("mt-1 text-xs leading-5","text-[var(--ui-ink-soft)]"),children:e.description}):null]})},e.value)),!R&&d&&h?r.jsxs("button",{type:"button",disabled:M,className:i("mt-1 flex w-full items-center gap-2 rounded-[18px] px-3 py-2.5 text-left text-sm transition disabled:opacity-50","text-[var(--secondary)] hover:bg-[var(--ui-surface-hover)]"),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.preventDefault(),N()},onClick:()=>void N(),children:[r.jsx(J,{className:"size-4"}),r.jsx("span",{className:"truncate",children:M?"Creating…":`${q} "${v.trim()}"`})]}):null,x.length===0&&(!d||R||!h)?r.jsx("div",{className:i("px-3 py-2.5 text-sm","text-[var(--ui-ink-soft)]"),children:U}):null]}),document.body):null,_?r.jsx("div",{className:"text-sm text-[color-mix(in_srgb,var(--danger)_74%,var(--ui-ink-strong)_26%)]",children:_}):null]})}export{te as E};
|
package/dist/assets/{entity-note-count-link-CmRRdXAr.js → entity-note-count-link-CEtKyMAl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b6 as l,j as o,aS as p}from"./vendor-Cpmju3nw.js";import{ca as x,ab as f}from"./index-
|
|
1
|
+
import{b6 as l,j as o,aS as p}from"./vendor-Cpmju3nw.js";import{ca as x,ab as f}from"./index-BejvcRGb.js";function g({entityType:n,entityId:i,count:s,compact:r=!1,className:u=""}){const a=l(),t=f(n,i);return t?o.jsxs("span",{role:"link",tabIndex:0,className:`inline-flex items-center rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] ${r?"min-h-5 gap-1 px-2 py-0.5 text-[10px]":"min-h-10 gap-2 px-3 py-2 text-xs"} ${u}`,onClick:e=>{e.stopPropagation(),a(t)},onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),a(t))},children:[o.jsx(p,{className:r?"size-3":"size-3.5"}),x(s)]}):null}export{g as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e,bX as qe,b7 as Je,cM as Ke,c8 as We,c1 as Pe}from"./vendor-Cpmju3nw.js";import{j as Ye,i as y,k as W}from"./state-BtwEvpO6.js";import{d as Ze,b0 as Y,c9 as es,aa as ss,b2 as ts,b1 as as,C as rs,a4 as is,k as b,ca as ns,B as v,I as j,T as Me,a$ as N,i as ls,ba as os,b3 as ds,b4 as cs,b5 as us,b6 as ms,b7 as ps,b8 as xs,b9 as ys}from"./index-wEZUnRh0.js";import{N as Z}from"./note-markdown-7czv-KMH.js";import{n as ee,N as ze,f as vs,p as gs,b as hs}from"./note-tags-input-CkgkqiT3.js";import{e as u}from"./user-ownership-DJGl4rAj.js";function fs(o,d,c){return o.links.filter(p=>!(p.entityType===d&&p.entityId===c))}function bs(o,d){return o.entityType===d.entityType&&o.entityId===d.entityId&&(o.anchorKey??null)===(d.anchorKey??null)}function se(o){const d=new Set;return o.filter(c=>{const p=`${c.entityType}:${c.entityId}:${c.anchorKey??""}`;return d.has(p)?!1:(d.add(p),!0)})}function Fe(o,d,c){return gs(o)??hs(d,c)}function Ss({entityType:o,entityId:d,anchorKey:c,includeAnchorlessWhenAnchored:p=!1,title:Qe="Notes",description:Ve="Markdown notes linked to this entity stay searchable, editable, and visible alongside the work.",invalidateQueryKeys:Be=[],compact:te=!1}){var Ce,Se,De,Te,Le,Ie,Ee,$e,Ae;const m=Ze(),L=Ye(),[I,Oe]=l.useState(""),[ae,E]=l.useState(!1),[h,$]=l.useState(""),[re,A]=l.useState(!1),[Ue,q]=l.useState({entityType:"goal",entityId:""}),[ie,K]=l.useState([]),[ne,P]=l.useState([]),[le,M]=l.useState(""),[oe,z]=l.useState(""),[de,F]=l.useState("days"),[He,Q]=l.useState(null),[f,V]=l.useState(""),[ce,k]=l.useState(!1),[B,O]=l.useState([]),[Re,U]=l.useState({entityType:"goal",entityId:""}),[ue,w]=l.useState([]),[me,_]=l.useState(""),[pe,C]=l.useState(""),[xe,S]=l.useState("days"),H=Y(c),ye=es(o,c),g=y({queryKey:["notes",o,d],queryFn:()=>os({linkedEntityType:o,linkedEntityId:d,limit:100})}),ve=y({queryKey:["forge-psyche-values"],queryFn:ds}),ge=y({queryKey:["forge-psyche-patterns"],queryFn:cs}),he=y({queryKey:["forge-psyche-behaviors"],queryFn:us}),fe=y({queryKey:["forge-psyche-beliefs"],queryFn:ms}),be=y({queryKey:["forge-psyche-modes"],queryFn:ps}),je=y({queryKey:["forge-psyche-flashcards"],queryFn:xs}),Ne=y({queryKey:["forge-psyche-reports"],queryFn:ys}),R=l.useMemo(()=>{var s,n,r,a,x,i,D,T;return{goal:m.snapshot.goals.map(t=>({id:t.id,label:u(t.title,t.user)})),project:m.snapshot.dashboard.projects.map(t=>({id:t.id,label:u(t.title,t.user)})),task:m.snapshot.tasks.map(t=>({id:t.id,label:u(t.title,t.user)})),strategy:m.snapshot.strategies.map(t=>({id:t.id,label:u(t.title,t.user)})),habit:m.snapshot.habits.map(t=>({id:t.id,label:u(t.title,t.user)})),tag:m.snapshot.tags.map(t=>({id:t.id,label:u(t.name,t.user)})),note:(((s=g.data)==null?void 0:s.notes)??[]).map(t=>({id:t.id,label:t.contentPlain||t.contentMarkdown})),insight:[],psyche_value:(((n=ve.data)==null?void 0:n.values)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),behavior_pattern:(((r=ge.data)==null?void 0:r.patterns)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),behavior:(((a=he.data)==null?void 0:a.behaviors)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),belief_entry:(((x=fe.data)==null?void 0:x.beliefs)??[]).map(t=>({id:t.id,label:u(t.statement,t.user)})),mode_profile:(((i=be.data)==null?void 0:i.modes)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),flashcard:(((D=je.data)==null?void 0:D.flashcards)??[]).map(t=>({id:t.id,label:u(t.title||t.message,t.user)})),mode_guide_session:[],event_type:[],emotion_definition:[],trigger_report:(((T=Ne.data)==null?void 0:T.reports)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),calendar_event:[],work_block_template:[],task_timebox:[],preference_catalog:[],preference_catalog_item:[],preference_context:[],preference_item:[],questionnaire_instrument:[],sleep_session:[],workout_session:[]}},[(Ce=he.data)==null?void 0:Ce.behaviors,(Se=fe.data)==null?void 0:Se.beliefs,(De=je.data)==null?void 0:De.flashcards,(Te=be.data)==null?void 0:Te.modes,(Le=g.data)==null?void 0:Le.notes,(Ie=ge.data)==null?void 0:Ie.patterns,(Ee=Ne.data)==null?void 0:Ee.reports,m.snapshot.dashboard.projects,m.snapshot.goals,m.snapshot.habits,m.snapshot.strategies,m.snapshot.tags,m.snapshot.tasks,($e=ve.data)==null?void 0:$e.values]),X=async()=>{await Promise.all([L.invalidateQueries({queryKey:["notes",o,d]}),ls(L),...Be.map(s=>L.invalidateQueries({queryKey:s}))])},ke=W({mutationFn:async s=>ss({contentMarkdown:s,tags:ee(ne),destroyAt:Fe(le,oe,de),links:se([{entityType:o,entityId:d,anchorKey:c??null},...ie])}),onSuccess:async()=>{$(""),A(!1),K([]),q({entityType:"goal",entityId:""}),P([]),M(""),z(""),F("days"),await X()}}),we=W({mutationFn:async({noteId:s,contentMarkdown:n,links:r,tags:a,destroyAt:x})=>ts(s,{contentMarkdown:n,links:r,tags:a,destroyAt:x}),onSuccess:async()=>{Q(null),V(""),k(!1),O([]),U({entityType:"goal",entityId:""}),w([]),_(""),C(""),S("days"),await X()}}),Xe=W({mutationFn:async s=>as(s),onSuccess:X}),G=l.useMemo(()=>{var n;return(((n=g.data)==null?void 0:n.notes)??[]).filter(r=>c===void 0?!0:r.links.some(a=>a.entityType===o&&a.entityId===d&&((a.anchorKey??null)===c||p&&(a.anchorKey??null)===null))).filter(r=>{const a=I.trim().toLowerCase();return a?`${r.contentPlain} ${r.author??""} ${(r.tags??[]).join(" ")}`.toLowerCase().includes(a):!0})},[c,d,o,p,(Ae=g.data)==null?void 0:Ae.notes,I]),Ge=(s,n,r)=>{const a=s.entityId.trim();return a?(n(se([...r,{entityType:s.entityType,entityId:a,anchorKey:null}])),!0):!1},J=s=>{var r,a;const n=(r=R[s.entityType])==null?void 0:r.find(x=>x.id===s.entityId);return(a=n==null?void 0:n.label)!=null&&a.trim()?n.label.trim():`Deleted ${N(s.entityType)}`},_e=(s,n,r,a,x)=>e.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked entities"}),e.jsxs(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[s.length," linked"]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:s.map(i=>{const D=s.length>1;return e.jsxs("div",{className:"inline-flex max-w-full items-center gap-2 rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:[N(i.entityType)," · ",J(i)]}),i.anchorKey?e.jsx("span",{className:"shrink-0 rounded-full bg-[var(--ui-surface-3)] px-2 py-0.5 text-[11px] text-[var(--ui-ink-soft)]",children:Y(i.anchorKey)}):null,e.jsx("button",{type:"button",disabled:!D,className:"shrink-0 text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)] disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>n(s.filter(T=>!bs(T,i))),"aria-label":`Remove ${N(i.entityType)} link to ${J(i)}`,children:e.jsx(Pe,{className:"size-3.5"})})]},`${x}-${i.entityType}-${i.entityId}-${i.anchorKey??""}`)})}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto]",children:[e.jsx("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:r.entityType,onChange:i=>a({...r,entityType:i.target.value,entityId:""}),children:["goal","project","task","strategy","habit","tag","note","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"].map(i=>e.jsx("option",{value:i,children:N(i)},i))}),e.jsxs("select",{className:"min-w-0 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:r.entityId,onChange:i=>a({...r,entityId:i.target.value}),children:[e.jsx("option",{value:"",children:(R[r.entityType]??[]).length>0?"Choose linked item":"No linked items available"}),(R[r.entityType]??[]).map(i=>e.jsx("option",{value:i.id,children:i.label},i.id))]}),e.jsx(v,{variant:"secondary",disabled:!r.entityId,onClick:()=>{Ge(r,n,s)&&a({...r,entityId:""})},children:"Add link"})]})]});return e.jsx(rs,{id:"notes",className:te?"min-w-0 overflow-hidden p-0":"min-w-0 overflow-hidden",children:e.jsxs("div",{className:te?"p-4":void 0,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:Qe}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:Ve}),H?e.jsxs("div",{className:"mt-3 inline-flex max-w-full items-center gap-2 rounded-full bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:["Pinned to ",H]}),ye?e.jsx(is,{content:ye,label:`Explain ${H}`}):null]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:ns(G.length)}),ae?null:e.jsxs(v,{type:"button",size:"sm",onClick:()=>E(!0),children:[e.jsx(qe,{className:"size-4"}),"Add note"]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3",children:[e.jsx(Je,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(j,{value:I,onChange:s=>Oe(s.target.value),placeholder:"Search notes by content, author, or note tag",className:"border-0 bg-transparent px-0 py-0"})]}),ae?e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(qe,{className:"size-4 text-[var(--secondary)]"}),"Add note"]}),e.jsxs(v,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>A(s=>!s),children:[e.jsx(Ke,{className:"size-4"}),re?"Back to editor":"Preview"]})]}),e.jsx("div",{className:"mt-3",children:re?e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:h.trim()?e.jsx(Z,{markdown:h}):e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-faint)]",children:"Markdown preview appears here once you have note content."})})]}):e.jsx(Me,{value:h,onChange:s=>$(s.target.value),placeholder:"Write in Markdown. Summaries, blockers, what changed, and why all work well here.",className:"min-h-[12rem]"})}),e.jsx("div",{className:"mt-3",children:_e(se([{entityType:o,entityId:d,anchorKey:c??null},...ie]),s=>K(s.filter(n=>!(n.entityType===o&&n.entityId===d&&(n.anchorKey??null)===(c??null)))),Ue,q,"composer-note-links")}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(ze,{value:ne,onChange:P}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"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-faint)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(j,{type:"datetime-local",value:le,onChange:s=>M(s.target.value)}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(j,{type:"number",min:"1",value:oe,onChange:s=>z(s.target.value),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:de,onChange:s=>F(s.target.value),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(v,{type:"button",variant:"secondary",onClick:()=>{E(!1),A(!1),$(""),K([]),q({entityType:"goal",entityId:""}),P([]),M(""),z(""),F("days")},children:"Cancel"}),e.jsx(v,{pending:ke.isPending,pendingLabel:"Saving",disabled:h.trim().length===0,onClick:async()=>{await ke.mutateAsync(h.trim()),E(!1)},children:"Save note"})]})]}):null,e.jsxs("div",{className:"mt-4 grid gap-3",children:[g.isLoading?e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"Loading notes…"}):null,!g.isLoading&&G.length===0?e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"No notes are linked here yet."}):null,G.map(s=>{const n=He===s.id,r=fs(s,o,d);return e.jsxs("article",{className:"min-w-0 rounded-[24px] border border-[var(--ui-border-subtle)] 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",{className:"min-w-0",children:[e.jsxs("div",{className:"break-words text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:[(s.author??"Unknown author").toString()," •"," ",new Date(s.updatedAt).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[r.map(a=>e.jsxs(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",wrap:!0,children:[N(a.entityType)," ·"," ",J(a),a.anchorKey?` · ${Y(a.anchorKey)}`:""]},`${s.id}-${a.entityType}-${a.entityId}-${a.anchorKey??""}`)),(s.tags??[]).map(a=>e.jsx(b,{className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:a},`${s.id}-tag-${a}`)),s.destroyAt?e.jsxs(b,{className:"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(s.destroyAt).toLocaleString()]}):null]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>{Q(s.id),V(s.contentMarkdown),k(!1),O(s.links),U({entityType:"goal",entityId:""}),w(ee(s.tags??[])),_(vs(s.destroyAt??null)),C(""),S("days")},children:e.jsx(We,{className:"size-4"})}),e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] transition hover:bg-[color-mix(in_srgb,var(--danger)_18%,var(--ui-surface-hover)_82%)]",onClick:()=>{Xe.mutateAsync(s.id)},children:e.jsx(Pe,{className:"size-4"})})]})]}),n?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(v,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>k(a=>!a),children:[e.jsx(Ke,{className:"size-4"}),ce?"Back to editor":"Preview"]})}),e.jsx("div",{className:"mt-3",children:ce?e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:f.trim()?e.jsx(Z,{markdown:f}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"No content yet."})})]}):e.jsx(Me,{value:f,onChange:a=>V(a.target.value),className:"min-h-[12rem]"})}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(ze,{value:ue,onChange:w}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"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-faint)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(j,{type:"datetime-local",value:me,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(j,{type:"number",min:"1",value:pe,onChange:a=>C(a.target.value),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:xe,onChange:a=>S(a.target.value),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsx("div",{className:"mt-3",children:_e(B,O,Re,U,`edit-note-links-${s.id}`)}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(v,{variant:"secondary",onClick:()=>{Q(null),k(!1),w([]),_(""),C(""),S("days")},children:"Cancel"}),e.jsx(v,{pending:we.isPending,pendingLabel:"Saving",disabled:f.trim().length===0||B.length===0,onClick:async()=>{await we.mutateAsync({noteId:s.id,contentMarkdown:f.trim(),links:B,tags:ee(ue),destroyAt:Fe(me,pe,xe)})},children:"Save changes"})]})]}):e.jsx("div",{className:"mt-4",children:e.jsx(Z,{markdown:s.contentMarkdown})})]},s.id)})]})]})})}export{Ss as E};
|
|
1
|
+
import{r as l,j as e,bX as qe,b7 as Je,cM as Ke,c8 as We,c1 as Pe}from"./vendor-Cpmju3nw.js";import{j as Ye,i as y,k as W}from"./state-BtwEvpO6.js";import{d as Ze,b0 as Y,c9 as es,aa as ss,b2 as ts,b1 as as,C as rs,a4 as is,k as b,ca as ns,B as v,I as j,T as Me,a$ as N,i as ls,ba as os,b3 as ds,b4 as cs,b5 as us,b6 as ms,b7 as ps,b8 as xs,b9 as ys}from"./index-BejvcRGb.js";import{N as Z}from"./note-markdown-Byd_vNkS.js";import{n as ee,N as ze,f as vs,p as gs,b as hs}from"./note-tags-input-DYAFDq8Q.js";import{e as u}from"./user-ownership-DJGl4rAj.js";function fs(o,d,c){return o.links.filter(p=>!(p.entityType===d&&p.entityId===c))}function bs(o,d){return o.entityType===d.entityType&&o.entityId===d.entityId&&(o.anchorKey??null)===(d.anchorKey??null)}function se(o){const d=new Set;return o.filter(c=>{const p=`${c.entityType}:${c.entityId}:${c.anchorKey??""}`;return d.has(p)?!1:(d.add(p),!0)})}function Fe(o,d,c){return gs(o)??hs(d,c)}function Ss({entityType:o,entityId:d,anchorKey:c,includeAnchorlessWhenAnchored:p=!1,title:Qe="Notes",description:Ve="Markdown notes linked to this entity stay searchable, editable, and visible alongside the work.",invalidateQueryKeys:Be=[],compact:te=!1}){var Ce,Se,De,Te,Le,Ie,Ee,$e,Ae;const m=Ze(),L=Ye(),[I,Oe]=l.useState(""),[ae,E]=l.useState(!1),[h,$]=l.useState(""),[re,A]=l.useState(!1),[Ue,q]=l.useState({entityType:"goal",entityId:""}),[ie,K]=l.useState([]),[ne,P]=l.useState([]),[le,M]=l.useState(""),[oe,z]=l.useState(""),[de,F]=l.useState("days"),[He,Q]=l.useState(null),[f,V]=l.useState(""),[ce,k]=l.useState(!1),[B,O]=l.useState([]),[Re,U]=l.useState({entityType:"goal",entityId:""}),[ue,w]=l.useState([]),[me,_]=l.useState(""),[pe,C]=l.useState(""),[xe,S]=l.useState("days"),H=Y(c),ye=es(o,c),g=y({queryKey:["notes",o,d],queryFn:()=>os({linkedEntityType:o,linkedEntityId:d,limit:100})}),ve=y({queryKey:["forge-psyche-values"],queryFn:ds}),ge=y({queryKey:["forge-psyche-patterns"],queryFn:cs}),he=y({queryKey:["forge-psyche-behaviors"],queryFn:us}),fe=y({queryKey:["forge-psyche-beliefs"],queryFn:ms}),be=y({queryKey:["forge-psyche-modes"],queryFn:ps}),je=y({queryKey:["forge-psyche-flashcards"],queryFn:xs}),Ne=y({queryKey:["forge-psyche-reports"],queryFn:ys}),R=l.useMemo(()=>{var s,n,r,a,x,i,D,T;return{goal:m.snapshot.goals.map(t=>({id:t.id,label:u(t.title,t.user)})),project:m.snapshot.dashboard.projects.map(t=>({id:t.id,label:u(t.title,t.user)})),task:m.snapshot.tasks.map(t=>({id:t.id,label:u(t.title,t.user)})),strategy:m.snapshot.strategies.map(t=>({id:t.id,label:u(t.title,t.user)})),habit:m.snapshot.habits.map(t=>({id:t.id,label:u(t.title,t.user)})),tag:m.snapshot.tags.map(t=>({id:t.id,label:u(t.name,t.user)})),note:(((s=g.data)==null?void 0:s.notes)??[]).map(t=>({id:t.id,label:t.contentPlain||t.contentMarkdown})),insight:[],psyche_value:(((n=ve.data)==null?void 0:n.values)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),behavior_pattern:(((r=ge.data)==null?void 0:r.patterns)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),behavior:(((a=he.data)==null?void 0:a.behaviors)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),belief_entry:(((x=fe.data)==null?void 0:x.beliefs)??[]).map(t=>({id:t.id,label:u(t.statement,t.user)})),mode_profile:(((i=be.data)==null?void 0:i.modes)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),flashcard:(((D=je.data)==null?void 0:D.flashcards)??[]).map(t=>({id:t.id,label:u(t.title||t.message,t.user)})),mode_guide_session:[],event_type:[],emotion_definition:[],trigger_report:(((T=Ne.data)==null?void 0:T.reports)??[]).map(t=>({id:t.id,label:u(t.title,t.user)})),calendar_event:[],work_block_template:[],task_timebox:[],preference_catalog:[],preference_catalog_item:[],preference_context:[],preference_item:[],questionnaire_instrument:[],sleep_session:[],workout_session:[]}},[(Ce=he.data)==null?void 0:Ce.behaviors,(Se=fe.data)==null?void 0:Se.beliefs,(De=je.data)==null?void 0:De.flashcards,(Te=be.data)==null?void 0:Te.modes,(Le=g.data)==null?void 0:Le.notes,(Ie=ge.data)==null?void 0:Ie.patterns,(Ee=Ne.data)==null?void 0:Ee.reports,m.snapshot.dashboard.projects,m.snapshot.goals,m.snapshot.habits,m.snapshot.strategies,m.snapshot.tags,m.snapshot.tasks,($e=ve.data)==null?void 0:$e.values]),X=async()=>{await Promise.all([L.invalidateQueries({queryKey:["notes",o,d]}),ls(L),...Be.map(s=>L.invalidateQueries({queryKey:s}))])},ke=W({mutationFn:async s=>ss({contentMarkdown:s,tags:ee(ne),destroyAt:Fe(le,oe,de),links:se([{entityType:o,entityId:d,anchorKey:c??null},...ie])}),onSuccess:async()=>{$(""),A(!1),K([]),q({entityType:"goal",entityId:""}),P([]),M(""),z(""),F("days"),await X()}}),we=W({mutationFn:async({noteId:s,contentMarkdown:n,links:r,tags:a,destroyAt:x})=>ts(s,{contentMarkdown:n,links:r,tags:a,destroyAt:x}),onSuccess:async()=>{Q(null),V(""),k(!1),O([]),U({entityType:"goal",entityId:""}),w([]),_(""),C(""),S("days"),await X()}}),Xe=W({mutationFn:async s=>as(s),onSuccess:X}),G=l.useMemo(()=>{var n;return(((n=g.data)==null?void 0:n.notes)??[]).filter(r=>c===void 0?!0:r.links.some(a=>a.entityType===o&&a.entityId===d&&((a.anchorKey??null)===c||p&&(a.anchorKey??null)===null))).filter(r=>{const a=I.trim().toLowerCase();return a?`${r.contentPlain} ${r.author??""} ${(r.tags??[]).join(" ")}`.toLowerCase().includes(a):!0})},[c,d,o,p,(Ae=g.data)==null?void 0:Ae.notes,I]),Ge=(s,n,r)=>{const a=s.entityId.trim();return a?(n(se([...r,{entityType:s.entityType,entityId:a,anchorKey:null}])),!0):!1},J=s=>{var r,a;const n=(r=R[s.entityType])==null?void 0:r.find(x=>x.id===s.entityId);return(a=n==null?void 0:n.label)!=null&&a.trim()?n.label.trim():`Deleted ${N(s.entityType)}`},_e=(s,n,r,a,x)=>e.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked entities"}),e.jsxs(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[s.length," linked"]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:s.map(i=>{const D=s.length>1;return e.jsxs("div",{className:"inline-flex max-w-full items-center gap-2 rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsxs("span",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:[N(i.entityType)," · ",J(i)]}),i.anchorKey?e.jsx("span",{className:"shrink-0 rounded-full bg-[var(--ui-surface-3)] px-2 py-0.5 text-[11px] text-[var(--ui-ink-soft)]",children:Y(i.anchorKey)}):null,e.jsx("button",{type:"button",disabled:!D,className:"shrink-0 text-[var(--ui-ink-faint)] transition hover:text-[var(--ui-ink-strong)] disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>n(s.filter(T=>!bs(T,i))),"aria-label":`Remove ${N(i.entityType)} link to ${J(i)}`,children:e.jsx(Pe,{className:"size-3.5"})})]},`${x}-${i.entityType}-${i.entityId}-${i.anchorKey??""}`)})}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto]",children:[e.jsx("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:r.entityType,onChange:i=>a({...r,entityType:i.target.value,entityId:""}),children:["goal","project","task","strategy","habit","tag","note","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","flashcard","event_type","emotion_definition","trigger_report"].map(i=>e.jsx("option",{value:i,children:N(i)},i))}),e.jsxs("select",{className:"min-w-0 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:r.entityId,onChange:i=>a({...r,entityId:i.target.value}),children:[e.jsx("option",{value:"",children:(R[r.entityType]??[]).length>0?"Choose linked item":"No linked items available"}),(R[r.entityType]??[]).map(i=>e.jsx("option",{value:i.id,children:i.label},i.id))]}),e.jsx(v,{variant:"secondary",disabled:!r.entityId,onClick:()=>{Ge(r,n,s)&&a({...r,entityId:""})},children:"Add link"})]})]});return e.jsx(rs,{id:"notes",className:te?"min-w-0 overflow-hidden p-0":"min-w-0 overflow-hidden",children:e.jsxs("div",{className:te?"p-4":void 0,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:Qe}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:Ve}),H?e.jsxs("div",{className:"mt-3 inline-flex max-w-full items-center gap-2 rounded-full bg-[var(--ui-surface-1)] px-3 py-2 text-xs text-[var(--ui-ink-soft)]",children:[e.jsxs("span",{children:["Pinned to ",H]}),ye?e.jsx(is,{content:ye,label:`Explain ${H}`}):null]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:ns(G.length)}),ae?null:e.jsxs(v,{type:"button",size:"sm",onClick:()=>E(!0),children:[e.jsx(qe,{className:"size-4"}),"Add note"]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3",children:[e.jsx(Je,{className:"size-4 text-[var(--ui-ink-faint)]"}),e.jsx(j,{value:I,onChange:s=>Oe(s.target.value),placeholder:"Search notes by content, author, or note tag",className:"border-0 bg-transparent px-0 py-0"})]}),ae?e.jsxs("div",{className:"mt-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx(qe,{className:"size-4 text-[var(--secondary)]"}),"Add note"]}),e.jsxs(v,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>A(s=>!s),children:[e.jsx(Ke,{className:"size-4"}),re?"Back to editor":"Preview"]})]}),e.jsx("div",{className:"mt-3",children:re?e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:h.trim()?e.jsx(Z,{markdown:h}):e.jsx("div",{className:"text-sm leading-6 text-[var(--ui-ink-faint)]",children:"Markdown preview appears here once you have note content."})})]}):e.jsx(Me,{value:h,onChange:s=>$(s.target.value),placeholder:"Write in Markdown. Summaries, blockers, what changed, and why all work well here.",className:"min-h-[12rem]"})}),e.jsx("div",{className:"mt-3",children:_e(se([{entityType:o,entityId:d,anchorKey:c??null},...ie]),s=>K(s.filter(n=>!(n.entityType===o&&n.entityId===d&&(n.anchorKey??null)===(c??null)))),Ue,q,"composer-note-links")}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(ze,{value:ne,onChange:P}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"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-faint)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(j,{type:"datetime-local",value:le,onChange:s=>M(s.target.value)}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(j,{type:"number",min:"1",value:oe,onChange:s=>z(s.target.value),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:de,onChange:s=>F(s.target.value),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(v,{type:"button",variant:"secondary",onClick:()=>{E(!1),A(!1),$(""),K([]),q({entityType:"goal",entityId:""}),P([]),M(""),z(""),F("days")},children:"Cancel"}),e.jsx(v,{pending:ke.isPending,pendingLabel:"Saving",disabled:h.trim().length===0,onClick:async()=>{await ke.mutateAsync(h.trim()),E(!1)},children:"Save note"})]})]}):null,e.jsxs("div",{className:"mt-4 grid gap-3",children:[g.isLoading?e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"Loading notes…"}):null,!g.isLoading&&G.length===0?e.jsx("div",{className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"No notes are linked here yet."}):null,G.map(s=>{const n=He===s.id,r=fs(s,o,d);return e.jsxs("article",{className:"min-w-0 rounded-[24px] border border-[var(--ui-border-subtle)] 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",{className:"min-w-0",children:[e.jsxs("div",{className:"break-words text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:[(s.author??"Unknown author").toString()," •"," ",new Date(s.updatedAt).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[r.map(a=>e.jsxs(b,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",wrap:!0,children:[N(a.entityType)," ·"," ",J(a),a.anchorKey?` · ${Y(a.anchorKey)}`:""]},`${s.id}-${a.entityType}-${a.entityId}-${a.anchorKey??""}`)),(s.tags??[]).map(a=>e.jsx(b,{className:"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_78%,var(--ui-ink-strong)_22%)]",wrap:!0,children:a},`${s.id}-tag-${a}`)),s.destroyAt?e.jsxs(b,{className:"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(s.destroyAt).toLocaleString()]}):null]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>{Q(s.id),V(s.contentMarkdown),k(!1),O(s.links),U({entityType:"goal",entityId:""}),w(ee(s.tags??[])),_(vs(s.destroyAt??null)),C(""),S("days")},children:e.jsx(We,{className:"size-4"})}),e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)] transition hover:bg-[color-mix(in_srgb,var(--danger)_18%,var(--ui-surface-hover)_82%)]",onClick:()=>{Xe.mutateAsync(s.id)},children:e.jsx(Pe,{className:"size-4"})})]})]}),n?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(v,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>k(a=>!a),children:[e.jsx(Ke,{className:"size-4"}),ce?"Back to editor":"Preview"]})}),e.jsx("div",{className:"mt-3",children:ce?e.jsxs("div",{className:"rounded-[20px] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Preview"}),e.jsx("div",{className:"mt-3",children:f.trim()?e.jsx(Z,{markdown:f}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"No content yet."})})]}):e.jsx(Me,{value:f,onChange:a=>V(a.target.value),className:"min-h-[12rem]"})}),e.jsxs("div",{className:"mt-3 grid gap-3 lg:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsx(ze,{value:ue,onChange:w}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"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-faint)]",children:"Set an exact destroy time or a relative delay. Leaving both blank keeps the note durable."})]}),e.jsx(j,{type:"datetime-local",value:me,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr)_10rem]",children:[e.jsx(j,{type:"number",min:"1",value:pe,onChange:a=>C(a.target.value),placeholder:"Destroy after"}),e.jsxs("select",{className:"rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--ui-border-strong)]",value:xe,onChange:a=>S(a.target.value),children:[e.jsx("option",{value:"hours",children:"Hours"}),e.jsx("option",{value:"days",children:"Days"})]})]})]})]}),e.jsx("div",{className:"mt-3",children:_e(B,O,Re,U,`edit-note-links-${s.id}`)}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(v,{variant:"secondary",onClick:()=>{Q(null),k(!1),w([]),_(""),C(""),S("days")},children:"Cancel"}),e.jsx(v,{pending:we.isPending,pendingLabel:"Saving",disabled:f.trim().length===0||B.length===0,onClick:async()=>{await we.mutateAsync({noteId:s.id,contentMarkdown:f.trim(),links:B,tags:ee(ue),destroyAt:Fe(me,pe,xe)})},children:"Save changes"})]})]}):e.jsx("div",{className:"mt-4",children:e.jsx(Z,{markdown:s.contentMarkdown})})]},s.id)})]})]})})}export{Ss as E};
|