forge-openclaw-plugin 0.3.6 → 0.3.8
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-CsDQF9d4.js → action-bar-BFjWjRIM.js} +1 -1
- package/dist/assets/{activity-page-CACf1Sd5.js → activity-page-D-6yBWuZ.js} +1 -1
- package/dist/assets/{ai-surface-workspace-Vn5fqCAT.js → ai-surface-workspace-BEfo9bRO.js} +1 -1
- package/dist/assets/{atlas-panel-GdK1oyxo.js → atlas-panel-BfMyJXxQ.js} +1 -1
- package/dist/assets/{calendar-page-CcVGbvfY.js → calendar-page-D4tQNJ2V.js} +1 -1
- package/dist/assets/{calendar-rules-Dlq0KT93.js → calendar-rules-C-6O_uGU.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-BVFb1_2G.js → calendar-week-toolbar-_NzeKsYx.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-Dgvtdc4i.js → companion-sync-lab-page-D1Oqsf6M.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-ChQVbNJI.js → daily-metrics-dashboard-DtE3pVOl.js} +1 -1
- package/dist/assets/{define-workbench-box-DWAqqjvH.js → define-workbench-box-D-32C8nM.js} +1 -1
- package/dist/assets/{entity-link-multiselect-Do5DTju7.js → entity-link-multiselect-DcCvkesQ.js} +1 -1
- package/dist/assets/{entity-note-count-link-CV3eOv66.js → entity-note-count-link-Cjsk5oT2.js} +1 -1
- package/dist/assets/{entity-notes-surface-CiUgAVl7.js → entity-notes-surface-DQQPLjxd.js} +1 -1
- package/dist/assets/{execution-board-ClaXVQ0H.js → execution-board-agWQbN-y.js} +1 -1
- package/dist/assets/{faceted-token-search-DoSsb7qT.js → faceted-token-search-DldM3-ru.js} +1 -1
- package/dist/assets/{flagship-signal-deck-B2s7TrIN.js → flagship-signal-deck-BlLYW9Kz.js} +1 -1
- package/dist/assets/{floating-action-menu-DGkHCmvI.js → floating-action-menu-D9-psbha.js} +1 -1
- package/dist/assets/{generic-node-view-CgLkbts-.js → generic-node-view-CcepUVhP.js} +1 -1
- package/dist/assets/{goal-detail-page-JRcEYpeA.js → goal-detail-page-DP1n5-Hk.js} +1 -1
- package/dist/assets/{goal-dialog-6R2uYWPQ.js → goal-dialog-Oxx8WqbZ.js} +1 -1
- package/dist/assets/{goals-page-CYestXkp.js → goals-page-CUt1a4Y2.js} +1 -1
- package/dist/assets/{habits-page-B27lnyKu.js → habits-page-5REbWAlo.js} +1 -1
- package/dist/assets/{health-boxes-CeqSGyZ3.js → health-boxes-sHNML3tm.js} +1 -1
- package/dist/assets/{index-DGYIFHgo.js → index-CQ5r7ZUz.js} +2 -2
- package/dist/assets/index-FxgNSuZX.css +1 -0
- package/dist/assets/{inline-note-fields-CJ9ukqFp.js → inline-note-fields-Bql_KfR9.js} +1 -1
- package/dist/assets/{insight-flow-dialog-BgaJRYGX.js → insight-flow-dialog-CN-CMSB7.js} +1 -1
- package/dist/assets/{insights-page-Dc5bilGE.js → insights-page-B1u6ONtQ.js} +1 -1
- package/dist/assets/{kanban-boxes-qIwmQlRq.js → kanban-boxes-DB1kuUlY.js} +1 -1
- package/dist/assets/{kanban-page-BGnVLHeN.js → kanban-page-BBW9_vMu.js} +1 -1
- package/dist/assets/{knowledge-graph-page-B7IsVVO_.js → knowledge-graph-page-CoJaydZb.js} +1 -1
- package/dist/assets/{life-force-page-B5N4DknK.js → life-force-page-DBYbA1GF.js} +1 -1
- package/dist/assets/{life-force-workspace-Da-dmoRX.js → life-force-workspace-BiD9xOEt.js} +1 -1
- package/dist/assets/{metric-tile-BVuj7mc3.js → metric-tile-CuP9DOYm.js} +1 -1
- package/dist/assets/{movement-boxes-BZrdIh8b.js → movement-boxes-DZg_qPPg.js} +1 -1
- package/dist/assets/{movement-page-CY2XLgp_.js → movement-page-CmwsQGR_.js} +1 -1
- package/dist/assets/{note-markdown-BZHBOkEd.js → note-markdown-B82ncnFt.js} +1 -1
- package/dist/assets/{note-tags-input-DucocvNH.js → note-tags-input-C_x5WdK5.js} +1 -1
- package/dist/assets/{notes-boxes-DAQ6KBkJ.js → notes-boxes-BEFlp9yd.js} +1 -1
- package/dist/assets/{notes-page-CSCfdDJl.js → notes-page-B6Vl-GPf.js} +1 -1
- package/dist/assets/{open-in-graph-button-ObO3m8yd.js → open-in-graph-button-C-bJekoH.js} +1 -1
- package/dist/assets/{orbit-map-Bteg-ola.js → orbit-map-DHeTM15g.js} +1 -1
- package/dist/assets/{overview-page-ckfN_sLZ.js → overview-page-BRWje1F9.js} +1 -1
- package/dist/assets/{page-hero-BkrRTu-t.js → page-hero-8bITsx_x.js} +1 -1
- package/dist/assets/{pill-cluster-COzv8VgR.js → pill-cluster-XQjm-wPc.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-BpVAeFmY.js → preference-entity-handoff-button-DwYF_5i3.js} +1 -1
- package/dist/assets/{preferences-page-DseOh9AP.js → preferences-page-C7DBPpNb.js} +1 -1
- package/dist/assets/{project-collections-C7yU5PSi.js → project-collections-mtxanSMf.js} +1 -1
- package/dist/assets/{project-detail-page-Crt46y_7.js → project-detail-page-BT87Goqc.js} +1 -1
- package/dist/assets/{project-dialog-YYxtlqg8.js → project-dialog-DnZe757y.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-DnojKHzy.js → project-management-hierarchy-page-B3R2lNFI.js} +1 -1
- package/dist/assets/{project-management-section-nav-Ctjd348W.js → project-management-section-nav-DyBWxHbe.js} +1 -1
- package/dist/assets/{projects-boxes-D8lLFGBC.js → projects-boxes-CxZj3P29.js} +1 -1
- package/dist/assets/{projects-page-CV_2em8d.js → projects-page-Bec11c0x.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-CYCNk0rz.js → psyche-behaviors-page-DWRpYvl1.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-DwmjBixN.js → psyche-flashcards-page-CX4rcsXZ.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-CdMhyBKh.js → psyche-goal-map-page-Y6b3lCvV.js} +1 -1
- package/dist/assets/{psyche-graph-BcrZcJrq.js → psyche-graph-CQuCWKIp.js} +1 -1
- package/dist/assets/{psyche-metrics-page-D5bX1mNX.js → psyche-metrics-page-DadDJOnm.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-BmX9EOOB.js → psyche-mode-guide-page-B1nz0uCg.js} +1 -1
- package/dist/assets/{psyche-modes-page-CTHFDyLE.js → psyche-modes-page-i3uSuhKA.js} +1 -1
- package/dist/assets/{psyche-page-DRR3Fjv-.js → psyche-page-Y_s-BE2m.js} +1 -1
- package/dist/assets/{psyche-patterns-page-BAS38xYf.js → psyche-patterns-page-DaaOLIlN.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-DpSi-zg3.js → psyche-questionnaire-builder-page-CuF7rXOv.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-BcXIiV4E.js → psyche-questionnaire-detail-page-BfFEMkRY.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-DvccwzWO.js → psyche-questionnaire-run-detail-page-BoQTvd7Q.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-vcyon8IZ.js → psyche-questionnaire-run-page-C0qKiNZN.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-B0DDTner.js → psyche-questionnaires-page-B6hfD448.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BgBA3xIO.js → psyche-report-detail-page-BlFL8moM.js} +1 -1
- package/dist/assets/{psyche-reports-page-Ce1vEEqW.js → psyche-reports-page-DAAcYENp.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-D-IHHohY.js → psyche-schemas-beliefs-page-CsxKSrKM.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-DOKW3m8B.js → psyche-screen-time-page-n4b0e58x.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-j7Sk6Ns1.js → psyche-self-observation-page-BaxEQ2-3.js} +1 -1
- package/dist/assets/{psyche-values-page-NfzdWUyb.js → psyche-values-page-DTv5NMSU.js} +1 -1
- package/dist/assets/{question-flow-dialog-CLHVmFON.js → question-flow-dialog-CskCt5NZ.js} +1 -1
- package/dist/assets/{report-chain-fields-C9MuyBha.js → report-chain-fields-D132-EMh.js} +1 -1
- package/dist/assets/{rewards-page-CVxOBP6m.js → rewards-page-C533lVP-.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-BmbOHH_R.js → scheduling-rules-editor-CDpontGp.js} +1 -1
- package/dist/assets/{schema-badge-BAiS_OAp.js → schema-badge-B3DiMnjB.js} +1 -1
- package/dist/assets/{schemas-B0AXfuOr.js → schemas-CH1_ngUX.js} +1 -1
- package/dist/assets/{select-menu-Bl5MILOj.js → select-menu-BOF-k4Ln.js} +1 -1
- package/dist/assets/{settings-agents-page-BIRP02mt.js → settings-agents-page-B5OQtlZX.js} +1 -1
- package/dist/assets/{settings-bin-page-DxJKeM28.js → settings-bin-page-D_bk3Kcu.js} +1 -1
- package/dist/assets/{settings-calendar-page-aMBtwvO_.js → settings-calendar-page-PuSj9_kM.js} +1 -1
- package/dist/assets/{settings-data-page-nHNergsh.js → settings-data-page-EwFMaeq6.js} +1 -1
- package/dist/assets/{settings-logs-page-CFotPoFy.js → settings-logs-page-BKkse0DX.js} +1 -1
- package/dist/assets/{settings-mobile-page-Bf_1D-bN.js → settings-mobile-page-BrIVmdeB.js} +1 -1
- package/dist/assets/{settings-models-page-BbFNmnik.js → settings-models-page-Mg84D_0K.js} +1 -1
- package/dist/assets/{settings-page-CalbNbcg.js → settings-page-D-kul92f.js} +1 -1
- package/dist/assets/{settings-rewards-page-ByDfCzP5.js → settings-rewards-page-waNyCcX_.js} +1 -1
- package/dist/assets/{settings-section-nav-x_JXfzL9.js → settings-section-nav-BmJWnrYk.js} +1 -1
- package/dist/assets/{settings-users-page-N1jl9hWV.js → settings-users-page-DBgC6y56.js} +1 -1
- package/dist/assets/{settings-wiki-page-Bn2Qr94L.js → settings-wiki-page-CM0te9dI.js} +1 -1
- package/dist/assets/sleep-page-C_krRE59.js +1 -0
- package/dist/assets/{sports-page-DbK4yGrR.js → sports-page-eg5Rfc_E.js} +1 -1
- package/dist/assets/{strategies-page-AUBlFCZ9.js → strategies-page-D4AqvFNW.js} +1 -1
- package/dist/assets/{strategy-detail-page-DCF8mVaL.js → strategy-detail-page-BlYVkXaW.js} +1 -1
- package/dist/assets/{strategy-dialog-50xKlqcz.js → strategy-dialog-FO9Oa0dB.js} +1 -1
- package/dist/assets/{surface-BjT1dIAF.js → surface-MVeeZGKB.js} +1 -1
- package/dist/assets/{task-detail-page-Dsll2LCX.js → task-detail-page-Dy-aRyY6.js} +1 -1
- package/dist/assets/{task-dialog-BfPkbIPE.js → task-dialog-DrA9pba7.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-BTKUS6Jj.js → timebox-planning-dialog-C_gnfxFx.js} +1 -1
- package/dist/assets/{today-boxes-BPi9bDHM.js → today-boxes-BFOws_iC.js} +1 -1
- package/dist/assets/{today-page-BSXSA-Ts.js → today-page-BoPj6a6q.js} +1 -1
- package/dist/assets/{training-load-page-BD0s8-Zm.js → training-load-page-DGU40Zfl.js} +1 -1
- package/dist/assets/{user-badge-ap1PvOxd.js → user-badge-CZWtYeMw.js} +1 -1
- package/dist/assets/{utility-widgets-Cq508sqJ.js → utility-widgets-B3wWGxQc.js} +1 -1
- package/dist/assets/{vitals-page-BnXk8OzN.js → vitals-page-BXRZEP_8.js} +1 -1
- package/dist/assets/{weekly-review-page-CnmSGnEC.js → weekly-review-page-D5cebA5x.js} +1 -1
- package/dist/assets/{weight-loss-page-Bn6lAXNf.js → weight-loss-page-BuUdFh9z.js} +1 -1
- package/dist/assets/{wiki-article-markdown-BDnkdNDC.js → wiki-article-markdown-CvaCjg_t.js} +1 -1
- package/dist/assets/{wiki-editor-page-CHEETB0G.js → wiki-editor-page-Dco79SLY.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-CisvtAzm.js → wiki-ingest-history-page-uvKRkRDF.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-C2faIjzj.js → wiki-ingest-modal-BW6AJPea.js} +1 -1
- package/dist/assets/{wiki-page-CELe_6qL.js → wiki-page-BIL5zMqv.js} +1 -1
- package/dist/assets/{workbench-flow-page-JBVim3L0.js → workbench-flow-page-Dx_nq8R_.js} +1 -1
- package/dist/assets/{workbench-page-q7Z3sQtz.js → workbench-page-BJnt_Zzf.js} +1 -1
- package/dist/assets/{workout-detail-page-9I_3DPYU.js → workout-detail-page-CKgqyB-y.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/server/server/src/app.js +4 -0
- package/dist/server/server/src/health.js +44 -3
- package/dist/server/server/src/openapi.js +31 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/assets/index-UzsVTD1W.css +0 -1
- package/dist/assets/sleep-page-DyU635jb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,j as e,aC as m,d6 as v,bj as b}from"./vendor-BwL6m4SE.js";import{i as w}from"./state-Bpe5dF3T.js";import{F as g}from"./faceted-token-search-
|
|
1
|
+
import{r as u,j as e,aC as m,d6 as v,bj as b}from"./vendor-BwL6m4SE.js";import{i as w}from"./state-Bpe5dF3T.js";import{F as g}from"./faceted-token-search-DldM3-ru.js";import{L as j,e as N,B as p,bs as k,h as S,C as f,k as d,c as _,bL as C}from"./index-CQ5r7ZUz.js";import{P as $}from"./page-hero-8bITsx_x.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function c(l,a){return`${l}: ${a}`}function q(l){const a=new Map;for(const r of l){const t=(s,n,x)=>{a.has(s)||a.set(s,{id:s,label:n,description:x})};for(const s of r.aliases)t(`alias:${s}`,c("Alias",s),"Filter by questionnaire alias.");for(const s of r.symptomDomains)t(`domain:${s}`,c("Domain",s),"Filter by symptom domain.");t(`source:${r.sourceClass}`,c("Source",r.sourceClass.replaceAll("_"," ")),"Filter by source and licence class."),t(`presentation:${r.presentationMode}`,c("Flow",r.presentationMode.replaceAll("_"," ")),"Filter by runner presentation mode."),t(`response:${r.responseStyle}`,c("Response",r.responseStyle.replaceAll("_"," ")),"Filter by response style."),t(`availability:${r.availability}`,c("Availability",r.availability.replaceAll("_"," ")),"Filter by availability."),t(`size:${r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"}`,c("Length",r.itemCount>=50?"long":r.itemCount>=15?"medium":"short"),"Filter by approximate questionnaire length."),t(`self:${r.isSelfReport?"self_report":"other"}`,c("Type",r.isSelfReport?"self report":"other"),"Filter by self-report availability.")}return Array.from(a.values()).sort((r,t)=>r.label.localeCompare(t.label))}function Q(l,a){return l.every(r=>{const[t,s]=r.split(":",2);if(!t||!s)return!0;switch(t){case"alias":return a.aliases.includes(s);case"domain":return a.symptomDomains.includes(s);case"source":return a.sourceClass===s;case"presentation":return a.presentationMode===s;case"response":return a.responseStyle===s;case"availability":return a.availability===s;case"size":return s==="long"?a.itemCount>=50:s==="medium"?a.itemCount>=15&&a.itemCount<50:a.itemCount<15;case"self":return s==="self_report"?a.isSelfReport:!a.isSelfReport;default:return!0}})}function E(){var y;const[l,a]=u.useState(""),[r,t]=u.useState([]),s=w({queryKey:["forge-psyche-questionnaires"],queryFn:()=>C()}),n=((y=s.data)==null?void 0:y.instruments)??[],x=u.useMemo(()=>q(n),[n]),h=u.useMemo(()=>{const i=l.trim().toLowerCase();return n.filter(o=>(i.length===0||`${o.title} ${o.subtitle} ${o.description} ${o.aliases.join(" ")} ${o.symptomDomains.join(" ")} ${o.tags.join(" ")}`.toLowerCase().includes(i))&&Q(r,o))},[n,l,r]);return s.isLoading?e.jsx(j,{eyebrow:"Questionnaires",title:"Loading the questionnaire library",description:"Hydrating the seeded assessment catalog, versions, and latest run history."}):s.isError?e.jsx(N,{eyebrow:"Questionnaires",error:s.error,onRetry:()=>void s.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx($,{eyebrow:"Psyche",title:"Questionnaires",description:"Browse the seeded mental health questionnaire library, narrow it with facet chips, launch guided runs, and build your own versioned instruments.",badge:`${n.length} instruments`,actions:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{children:"Build questionnaire"})})}),e.jsx(k,{}),e.jsx(g,{title:"Questionnaire filters",description:"Search by title or alias, then pin chips for symptom domain, source class, item count, response style, flow mode, self-report status, or availability.",query:l,onQueryChange:a,options:x,selectedOptionIds:r,onSelectedOptionIdsChange:t,resultSummary:`${h.length} of ${n.length} questionnaires visible`}),h.length===0?e.jsx(S,{eyebrow:"Questionnaire library",title:"No questionnaires match the current filters",description:"Clear one or two chips and the seeded catalog will come back into view."}):e.jsx("section",{className:"grid gap-4 xl:grid-cols-2",children:h.map(i=>e.jsxs(f,{className:"min-w-0 overflow-hidden border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words font-label text-[11px] uppercase tracking-[0.18em] text-[var(--tertiary)] [overflow-wrap:anywhere]",children:i.subtitle||"Questionnaire"}),e.jsx("h2",{className:"mt-3 break-words font-display text-[clamp(1.35rem,2vw,1.9rem)] leading-tight text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:i.title}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.description})]}),e.jsxs("div",{className:"min-w-[8.5rem] rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-3 text-left sm:text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Latest"}),e.jsx("div",{className:"mt-2 break-words text-sm text-[var(--ui-ink-medium)]",children:i.latestRunAt?new Date(i.latestRunAt).toLocaleDateString():"Not taken yet"})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(d,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[i.itemCount," items"]}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--success)_68%,var(--ui-ink-strong)_32%)]",children:i.presentationMode.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--info)_68%,var(--ui-ink-strong)_32%)]",children:i.responseStyle.replaceAll("_"," ")}),e.jsx(d,{className:"bg-[color-mix(in_srgb,var(--primary)_12%,var(--ui-surface-1)_88%)] text-[color-mix(in_srgb,var(--primary)_68%,var(--ui-ink-strong)_32%)]",children:i.sourceClass.replaceAll("_"," ")})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:i.symptomDomains.map(o=>e.jsx(d,{className:"max-w-full whitespace-normal break-words bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:o},`${i.id}-${o}`))}),e.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto_auto]",children:[e.jsx("div",{className:"min-w-0 break-words rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:i.completedRunCount>0?`${i.completedRunCount} completed runs saved in history`:"No saved history yet"}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}`,children:e.jsx(p,{variant:"secondary",className:"w-full sm:w-auto",children:"Open detail"})}),e.jsx(m,{to:`/psyche/questionnaires/${i.id}/take`,children:e.jsx(p,{className:"w-full sm:w-auto",children:"Start guided run"})})]})]},i.id))}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{className:"size-5 text-[var(--tertiary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Seeded first wave"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"The current library ships a verified first wave: PHQ-9, GAD-7, WHO-5, PCL-5, AUDIT, SRQ-20, and YSQ-R, each stored in SQLite as a versioned definition with scoring and provenance."})]}),e.jsxs(f,{className:"min-w-0 border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{className:"size-5 text-[var(--secondary)]"}),e.jsx("div",{className:"break-words font-display text-2xl text-[var(--ui-ink-strong)]",children:"Builder ready"})]}),e.jsx("p",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"System questionnaires stay read-only. Custom drafts can branch from any seed, edit structure and scoring JSON safely, and publish new immutable versions without rewriting past runs."}),e.jsx("div",{className:"mt-4",children:e.jsx(m,{to:"/psyche/questionnaires/new",children:e.jsx(p,{variant:"secondary",className:_("w-full sm:w-auto"),children:"Open builder"})})})]})]})]})}export{E as PsycheQuestionnairesPage};
|
package/dist/assets/{psyche-report-detail-page-BgBA3xIO.js → psyche-report-detail-page-BlFL8moM.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as h,j as e,d7 as ie,b5 as ae,c6 as re}from"./vendor-BwL6m4SE.js";import{j as ne,i as p,k as R}from"./state-Bpe5dF3T.js";import{B as b,c as oe,S as de,e as D,T as H,a4 as U,a3 as V,I as C,b as G,bs as le,cr as ce,ac as me,cs as he,b5 as ue,b6 as pe,b7 as xe,bR as ge,ct as ve,cu as fe}from"./index-
|
|
1
|
+
import{r as h,j as e,d7 as ie,b5 as ae,c6 as re}from"./vendor-BwL6m4SE.js";import{j as ne,i as p,k as R}from"./state-Bpe5dF3T.js";import{B as b,c as oe,S as de,e as D,T as H,a4 as U,a3 as V,I as C,b as G,bs as le,cr as ce,ac as me,cs as he,b5 as ue,b6 as pe,b7 as xe,bR as ge,ct as ve,cu as fe}from"./index-CQ5r7ZUz.js";import{A as Y,m as J}from"./motion-DcgUnXhY.js";import{I as ye}from"./insight-flow-dialog-CN-CMSB7.js";import{O as be}from"./open-in-graph-button-C-bJekoH.js";import{E as je}from"./entity-notes-surface-DQQPLjxd.js";import{S as y,B as ke,M as we,T as Te,E as Ne}from"./report-chain-fields-D132-EMh.js";import{P as Ie}from"./page-hero-8bITsx_x.js";import{t as Se}from"./psyche-schemas-DDol0j-g.js";import{b as Le,a as Ce,c as Ee,f as Me,t as Be}from"./schema-visuals-CvC9a3i6.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";import"./question-flow-dialog-CskCt5NZ.js";import"./schemas-CH1_ngUX.js";import"./note-markdown-B82ncnFt.js";import"./note-tags-input-C_x5WdK5.js";import"./entity-link-multiselect-DcCvkesQ.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./user-ownership-DJGl4rAj.js";const X="(max-width: 1023px)";function qe(){const[i,o]=h.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(X).matches);return h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia(X),m=s=>o(s.matches);return o(d.matches),typeof d.addEventListener=="function"?(d.addEventListener("change",m),()=>d.removeEventListener("change",m)):(d.addListener(m),()=>d.removeListener(m))},[]),i}function Ae({stages:i,activeStageId:o,onStageChange:d,stageContent:m,inspector:s}){const a=qe(),[j,g]=h.useState(!1),n=i.find(l=>l.id===o);return h.useEffect(()=>{g(!a)},[a]),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"min-w-0 rounded-[30px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-4",children:[e.jsxs("div",{className:"mb-4 flex 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:"Tracing the chain"}),e.jsx("div",{className:"mt-1 break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),s?e.jsxs(b,{variant:"secondary",size:"sm",onClick:()=>g(l=>!l),children:[j?e.jsx(ie,{className:"size-4"}):e.jsx(ae,{className:"size-4"}),"Inspector"]}):null]}),e.jsx("div",{className:"mb-4 pb-1",children:e.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-3",children:i.map((l,v)=>e.jsxs("button",{type:"button",className:oe("min-w-0 max-w-full rounded-[22px] px-4 py-3 text-left transition",a?"flex-1 basis-[5.5rem]":"basis-[13rem]",l.id===o?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>d(l.id),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[v+1,". ",l.label]}),a?null:e.jsx("div",{className:"mt-1.5 text-sm leading-5",children:l.summary})]},l.id))})}),e.jsxs("div",{className:"min-w-0 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:n==null?void 0:n.label}),e.jsx("span",{className:"min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:n==null?void 0:n.summary})]}),e.jsx(Y,{mode:"wait",children:e.jsx(J.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},exit:{opacity:0,y:-14},transition:{duration:.26,ease:"easeOut"},children:m},o)})]})]}),s?e.jsx(Y,{initial:!1,children:j?e.jsxs(J.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.22,ease:"easeOut"},className:"min-w-0 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-3.5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Linked inspectors"}),e.jsx("div",{className:"mt-3 grid gap-3",children:s})]}):null}):null]})}function Pe(i){return i.join(`
|
|
2
2
|
`)}function E(i,o){return i.includes(o)?i.filter(d=>d!==o):[...i,o]}function Oe(i){return{title:i.title,status:i.status,eventTypeId:i.eventTypeId??"",customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?i.occurredAt.slice(0,16):"",emotions:i.emotions,thoughts:i.thoughts,behaviors:i.behaviors,selfShortTerm:i.consequences.selfShortTerm,selfLongTerm:i.consequences.selfLongTerm,othersShortTerm:i.consequences.othersShortTerm,othersLongTerm:i.consequences.othersLongTerm,modeOverlaysText:Pe(i.modeOverlays),schemaLinks:i.schemaLinks,modeTimeline:i.modeTimeline,nextMoves:i.nextMoves,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds}}function at(){var F,Q,_,K,W,$;const{reportId:i}=re(),o=ne(),[d,m]=h.useState("spark"),[s,a]=h.useState(null),[j,g]=h.useState(!1),n=p({queryKey:["forge-psyche-report",i],queryFn:()=>he(i),enabled:!!i}),l=p({queryKey:["forge-psyche-behaviors"],queryFn:ue}),v=p({queryKey:["forge-psyche-beliefs"],queryFn:pe}),w=p({queryKey:["forge-psyche-modes"],queryFn:xe}),T=p({queryKey:["forge-psyche-schema-catalog"],queryFn:ge}),N=p({queryKey:["forge-psyche-event-types"],queryFn:ve}),I=p({queryKey:["forge-psyche-emotions"],queryFn:fe});h.useEffect(()=>{var t;(t=n.data)!=null&&t.report&&a(Oe(n.data.report))},[n.data]);const M=R({mutationFn:async t=>{var k;const r=(k=n.data)==null?void 0:k.report,u=Se.parse({title:t.title,status:t.status,eventTypeId:t.eventTypeId||null,customEventType:t.customEventType,eventSituation:t.eventSituation,occurredAt:t.occurredAt?new Date(t.occurredAt).toISOString():null,emotions:t.emotions.filter(c=>c.label.trim().length>0),thoughts:t.thoughts.filter(c=>c.text.trim().length>0),behaviors:t.behaviors.filter(c=>c.text.trim().length>0),consequences:{selfShortTerm:t.selfShortTerm,selfLongTerm:t.selfLongTerm,othersShortTerm:t.othersShortTerm,othersLongTerm:t.othersLongTerm},linkedPatternIds:(r==null?void 0:r.linkedPatternIds)??[],linkedValueIds:(r==null?void 0:r.linkedValueIds)??[],linkedGoalIds:(r==null?void 0:r.linkedGoalIds)??[],linkedProjectIds:(r==null?void 0:r.linkedProjectIds)??[],linkedTaskIds:(r==null?void 0:r.linkedTaskIds)??[],linkedBehaviorIds:t.linkedBehaviorIds,linkedBeliefIds:t.linkedBeliefIds,linkedModeIds:t.linkedModeIds,modeOverlays:t.modeOverlaysText.split(`
|
|
3
3
|
`).map(c=>c.trim()).filter(Boolean),schemaLinks:t.schemaLinks.filter(Boolean),modeTimeline:t.modeTimeline.filter(c=>c.stage.trim().length>0&&c.label.trim().length>0),nextMoves:t.nextMoves.filter(Boolean)});return ce(i,u)},onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-report",i]}),o.invalidateQueries({queryKey:["forge-psyche-reports"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]}),o.invalidateQueries({queryKey:["forge-reward-ledger"]})])}}),S=R({mutationFn:me,onSuccess:async()=>{await o.invalidateQueries({queryKey:["forge-psyche-report",i]}),await o.invalidateQueries({queryKey:["forge-insights"]})}}),B=n.error??l.error??v.error??w.error??T.error??N.error??I.error??null;if(n.isLoading||!s)return e.jsx(de,{});if(B)return e.jsx(D,{eyebrow:"Trigger report",error:B,onRetry:()=>void Promise.all([n.refetch(),l.refetch(),v.refetch(),w.refetch(),T.refetch(),N.refetch(),I.refetch()])});if(!n.data)return e.jsx(D,{eyebrow:"Trigger report",error:new Error("Forge returned an empty trigger report payload."),onRetry:()=>void n.refetch()});const q=n.data,x=q.report,A=((F=l.data)==null?void 0:F.behaviors)??[],L=((Q=v.data)==null?void 0:Q.beliefs)??[],f=((_=w.data)==null?void 0:_.modes)??[],P=((K=T.data)==null?void 0:K.schemas)??[],Z=((W=N.data)==null?void 0:W.eventTypes)??[],ee=(($=I.data)==null?void 0:$.emotions)??[],O=[{id:"spark",label:"Spark",summary:"What happened concretely?"},{id:"wave",label:"Wave",summary:"What emotional wave moved through you?"},{id:"script",label:"Script",summary:"What did the mind start saying?"},{id:"lens",label:"Lens",summary:"Which schemas and beliefs got activated?"},{id:"state",label:"State",summary:"Which modes took the wheel?"},{id:"move",label:"Move",summary:"What did you do or want to do?"},{id:"horizon",label:"Horizon",summary:"What were the consequences?"},{id:"pivot",label:"Pivot",summary:"What is the next move now?"}],te={spark:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_13rem]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Title"}),e.jsx(C,{value:s.title,onChange:t=>a({...s,title:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Status"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.status,onChange:t=>a({...s,status:t.target.value}),children:[e.jsx("option",{value:"draft",children:"draft"}),e.jsx("option",{value:"reviewed",children:"reviewed"}),e.jsx("option",{value:"integrated",children:"integrated"})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Event type"}),e.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:s.eventTypeId,onChange:t=>a({...s,eventTypeId:t.target.value}),children:[e.jsx("option",{value:"",children:"Custom or uncategorized"}),Z.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Occurred at"}),e.jsx(C,{type:"datetime-local",value:s.occurredAt,onChange:t=>a({...s,occurredAt:t.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Custom event label"}),e.jsx(C,{value:s.customEventType,onChange:t=>a({...s,customEventType:t.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Situation"}),e.jsx(H,{value:s.eventSituation,onChange:t=>a({...s,eventSituation:t.target.value})})]})]}),wave:e.jsx(Ne,{items:s.emotions,onChange:t=>a({...s,emotions:t}),definitions:ee}),script:e.jsx(Te,{items:s.thoughts,onChange:t=>a({...s,thoughts:t}),beliefs:L,modes:f}),lens:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:"Schema links"}),e.jsx(U,{content:"Use maladaptive schemas for recurring old patterns that were active here. Use adaptive schemas for healthier patterns you want this response to build on.",label:"Explain schema links"})]}),e.jsx(V,{children:"Choose the schemas that were active here or that you want the repair move to strengthen."}),[{title:"Maladaptive schemas",schemas:P.filter(t=>t.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:P.filter(t=>t.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this chain to strengthen."}].map(t=>{const r=Le(t.schemaType);return e.jsxs("div",{className:`rounded-[22px] border p-4 ${r.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx(U,{content:Ee(t.schemaType),label:`Explain ${Ce(t.schemaType)}`})]}),e.jsx(V,{className:"mt-2",children:t.description}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:t.schemas.map(u=>{const k=s.schemaLinks.some(c=>{var z;return((z=Me(c,[u]))==null?void 0:z.id)===u.id});return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${k?`${r.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,schemaLinks:Be(s.schemaLinks,u)}),children:u.title},u.id)})})]},t.schemaType)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked beliefs"}),e.jsx("div",{className:"mt-3 flex max-h-56 flex-wrap gap-2 overflow-y-auto",children:L.map(t=>{const r=s.linkedBeliefIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBeliefIds:E(s.linkedBeliefIds,t.id)}),children:t.statement},t.id)})})]})]}),state:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Mode overlays"}),e.jsx(H,{value:s.modeOverlaysText,onChange:t=>a({...s,modeOverlaysText:t.target.value})})]}),e.jsx(we,{items:s.modeTimeline,onChange:t=>a({...s,modeTimeline:t}),modes:f,stages:O.map(t=>t.label)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked modes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:f.map(t=>{const r=s.linkedModeIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_78%,var(--ui-ink-strong)_22%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedModeIds:E(s.linkedModeIds,t.id)}),children:t.title},t.id)})})]})]}),move:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ke,{items:s.behaviors,onChange:t=>a({...s,behaviors:t}),behaviors:A,modes:f}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Linked behaviors"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:A.map(t=>{const r=s.linkedBehaviorIds.includes(t.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${r?"bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_76%,var(--ui-ink-strong)_24%)]":"bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>a({...s,linkedBehaviorIds:E(s.linkedBehaviorIds,t.id)}),children:t.title},t.id)})})]})]}),horizon:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(y,{title:"Short-term impact on you",description:"What happened to you right away?",addLabel:"Add self effect",items:s.selfShortTerm,onChange:t=>a({...s,selfShortTerm:t}),placeholder:"I shut down and lost the evening."}),e.jsx(y,{title:"Long-term impact on you",description:"What does this cost if it keeps repeating?",addLabel:"Add self cost",items:s.selfLongTerm,onChange:t=>a({...s,selfLongTerm:t}),placeholder:"It keeps training the same abandonment script."}),e.jsx(y,{title:"Short-term impact on others",description:"What happened to other people right away?",addLabel:"Add other effect",items:s.othersShortTerm,onChange:t=>a({...s,othersShortTerm:t}),placeholder:"They felt shut out."}),e.jsx(y,{title:"Long-term impact on others",description:"What pattern does this create over time?",addLabel:"Add other cost",items:s.othersLongTerm,onChange:t=>a({...s,othersLongTerm:t}),placeholder:"Trust gets thinner each time."})]}),pivot:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(y,{title:"What is the next move now?",description:"Finish with concrete repairs, boundaries, or committed actions.",addLabel:"Add next move",items:s.nextMoves,onChange:t=>a({...s,nextMoves:t}),placeholder:"Send one honest repair message tomorrow morning."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(b,{pending:M.isPending,onClick:()=>void M.mutateAsync(s),children:"Save chain"})})]})},se=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked modes"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[f.filter(t=>s.linkedModeIds.includes(t.id)).map(t=>e.jsx(G,{kind:"mode",label:t.title,compact:!0},t.id)),s.linkedModeIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("state"),children:"Link mode"}):null]})]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked beliefs"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[L.filter(t=>s.linkedBeliefIds.includes(t.id)).map(t=>e.jsx("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3",children:e.jsx(G,{kind:"belief",label:t.statement,compact:!0})},t.id)),s.linkedBeliefIds.length===0?e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>m("lens"),children:"Link belief"}):null]})]}),e.jsx(je,{entityType:"trigger_report",entityId:x.id,anchorKey:d,includeAnchorlessWhenAnchored:!0,compact:!0,title:`Stage notes on ${d}`,description:"Use anchored Markdown notes to capture what became clear at this stage of the chain.",invalidateQueryKeys:[["forge-psyche-report",i],["forge-psyche-reports"],["forge-psyche-overview"]]}),e.jsxs("div",{className:"rounded-[22px] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Insights"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[q.insights.map(t=>e.jsxs("div",{className:"rounded-[16px] bg-[var(--ui-surface-1)] px-3 py-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:t.title}),e.jsx("div",{className:"mt-2 text-[var(--ui-ink-soft)]",children:t.summary})]},t.id)),e.jsx(b,{variant:"secondary",pending:S.isPending,onClick:()=>g(!0),children:"Store insight"})]})]})]});return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ie,{eyebrow:"Trigger report",title:x.title,description:"Move through Spark to Pivot in one chain canvas.",badge:x.status,actions:e.jsx(be,{entityType:"trigger_report",entityId:x.id})}),e.jsx(le,{}),e.jsx(Ae,{stages:O,activeStageId:d,onStageChange:m,stageContent:te[d],inspector:se}),e.jsx(ye,{open:j,onOpenChange:g,eyebrow:"Report insight",title:"Store report insight",description:"Capture the insight from this report as a guided recommendation instead of a raw side-panel form.",submitLabel:"Store insight",pending:S.isPending,lockedEntity:{entityType:"trigger_report",entityId:x.id,kind:"report",label:x.title,description:`Anchored to the ${d} stage of this reflective chain.`},initialValue:{originType:"user",originLabel:"Forge Psyche",timeframeLabel:"Current trigger report",rationale:`Captured from the ${d} stage of the Psyche chain canvas.`},onSubmit:async t=>{await S.mutateAsync(t)}})]})}export{at as PsycheReportDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bY as ve,r as S,j as t,aC as fe}from"./vendor-BwL6m4SE.js";import{j as ye,i as d,k as xe}from"./state-Bpe5dF3T.js";import{Q as ke,F as o}from"./question-flow-dialog-CLHVmFON.js";import{E as be}from"./entity-note-count-link-CV3eOv66.js";import{A as we}from"./atlas-panel-GdK1oyxo.js";import{E as L}from"./entity-link-multiselect-Do5DTju7.js";import{S as Ie}from"./schema-badge-BAiS_OAp.js";import{E as Te,T as je,B as Se,S as m,M as Le}from"./report-chain-fields-C9MuyBha.js";import{d as Ne,L as Ce,e as Ee,B as Be,E as J,bs as Pe,h as Me,R as Ae,k as Fe,cv as qe,I as q,T as Re,a4 as Oe,a3 as Qe,bP as De,bN as Ke,b$ as Ue,bQ as $e,b9 as Ge,b3 as He,b5 as _e,b6 as ze,b7 as We,bR as Ve,ct as Ye,cu as Je}from"./index-DGYIFHgo.js";import{P as Xe}from"./page-hero-BkrRTu-t.js";import{U as Ze}from"./user-badge-ap1PvOxd.js";import{U as et}from"./user-select-field-fx129Uh6.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{t as X}from"./psyche-schemas-DDol0j-g.js";import{f as Z,b as tt,a as st,c as rt,t as it}from"./schema-visuals-CvC9a3i6.js";import{g as at,b as C,d as E,e as B,a as nt}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const P={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:null};function ot(l){const n=new Date(l);if(Number.isNaN(n.getTime()))return"";const a=n.getFullYear(),p=String(n.getMonth()+1).padStart(2,"0"),M=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${a}-${p}-${M}T${c}:${i}`}function Ct(){var K,U,$,G,H,_,z,W;const l=Ne(),n=ye(),[a,p]=ve(),[M,c]=S.useState(!1),[i,u]=S.useState(P),[ee,g]=S.useState(null),v=d({queryKey:["forge-psyche-reports"],queryFn:Ge}),f=d({queryKey:["forge-psyche-values"],queryFn:He}),y=d({queryKey:["forge-psyche-behaviors"],queryFn:_e}),x=d({queryKey:["forge-psyche-beliefs"],queryFn:ze}),k=d({queryKey:["forge-psyche-modes"],queryFn:We}),b=d({queryKey:["forge-psyche-schema-catalog"],queryFn:Ve}),w=d({queryKey:["forge-psyche-event-types"],queryFn:Ye}),I=d({queryKey:["forge-psyche-emotions"],queryFn:Je}),A=((K=v.data)==null?void 0:K.reports)??[],te=((U=f.data)==null?void 0:U.values)??[],R=(($=y.data)==null?void 0:$.behaviors)??[],O=((G=x.data)==null?void 0:G.beliefs)??[],T=((H=k.data)==null?void 0:H.modes)??[],F=((_=b.data)==null?void 0:_.schemas)??[],se=((z=w.data)==null?void 0:z.eventTypes)??[],re=((W=I.data)==null?void 0:W.emotions)??[],j=at(l.selectedUserIds),ie=l.snapshot.dashboard.notesSummaryByEntity;S.useEffect(()=>{if(a.get("create")==="1"){c(!0),u({...P,userId:a.get("userId")??j,occurredAt:a.get("occurredAt")?ot(a.get("occurredAt")):"",customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const e=new URLSearchParams(a);e.delete("create"),e.delete("intent"),e.delete("occurredAt"),e.delete("userId"),e.delete("valueId"),e.delete("behaviorId"),e.delete("beliefId"),e.delete("goalId"),e.delete("projectId"),e.delete("taskId"),p(e,{replace:!0})}},[a,p]);const Q=xe({mutationFn:async e=>{const r=X.parse({title:e.title,status:e.status,eventTypeId:e.eventTypeId||null,customEventType:e.customEventType,eventSituation:e.eventSituation,occurredAt:e.occurredAt?new Date(e.occurredAt).toISOString():null,emotions:e.emotions.filter(s=>s.label.trim().length>0),thoughts:e.thoughts.filter(s=>s.text.trim().length>0),behaviors:e.behaviors.filter(s=>s.text.trim().length>0),consequences:{selfShortTerm:e.selfShortTerm,selfLongTerm:e.selfLongTerm,othersShortTerm:e.othersShortTerm,othersLongTerm:e.othersLongTerm},linkedPatternIds:[],linkedValueIds:e.linkedValueIds,linkedGoalIds:e.linkedGoalIds,linkedProjectIds:e.linkedProjectIds,linkedTaskIds:e.linkedTaskIds,linkedBehaviorIds:e.linkedBehaviorIds,linkedBeliefIds:e.linkedBeliefIds,linkedModeIds:e.linkedModeIds,modeOverlays:[],schemaLinks:e.schemaLinks.filter(Boolean),modeTimeline:e.modeTimeline.filter(s=>s.stage.trim().length>0&&s.label.trim().length>0),nextMoves:e.nextMoves.filter(Boolean),userId:e.userId});return qe(r)},onSuccess:async()=>{c(!1),u({...P,userId:j}),g(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-reports"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),ae=te.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.valuedDirection,e.user),searchText:C([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=R.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.kind,e.user),searchText:C([e.title,e.kind,e.description],e),kind:"behavior"})),oe=O.map(e=>({value:e.id,label:B(e.statement,e.user),description:E(e.flexibleAlternative||e.originNote,e.user),searchText:C([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),de=T.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.archetype||e.family,e.user),searchText:C([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{value:r}=await De({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:i.userId});return N(n,["forge-psyche-values"],"values",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.valuedDirection,kind:"value"}},ce=async e=>{const{behavior:r}=await Ke({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:i.userId});return N(n,["forge-psyche-behaviors"],"behaviors",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},he=async e=>{const{belief:r}=await Ue({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:i.userId});return N(n,["forge-psyche-beliefs"],"beliefs",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.statement,description:r.flexibleAlternative||r.originNote,kind:"belief"}},me=async e=>{const{mode:r}=await $e({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:i.userId});return N(n,["forge-psyche-modes"],"modes",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.archetype||r.family,kind:"mode"}},pe=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(et,{value:e.userId,users:l.snapshot.users,onChange:s=>r({userId:s}),defaultLabel:nt(l.snapshot.users.find(s=>s.id===j)??null,"Choose report owner"),help:"Trigger reports can belong to a human or bot user while still linking to shared values, behaviors, beliefs, and modes."}),t.jsx(o,{label:"Report title",children:t.jsx(q,{value:e.title,onChange:s=>r({title:s.target.value}),placeholder:"Friday silence spiral"})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Event type",children:t.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:e.eventTypeId,onChange:s=>r({eventTypeId:s.target.value}),children:[t.jsx("option",{value:"",children:"Custom or uncategorized"}),se.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))]})}),t.jsx(o,{label:"Occurred at",children:t.jsx(q,{type:"datetime-local",value:e.occurredAt,onChange:s=>r({occurredAt:s.target.value})})})]}),t.jsx(o,{label:"Custom event label",children:t.jsx(q,{value:e.customEventType,onChange:s=>r({customEventType:s.target.value}),placeholder:"Unexpected distance after vulnerability"})}),t.jsx(o,{label:"Situation",children:t.jsx(Re,{value:e.eventSituation,onChange:s=>r({eventSituation:s.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Te,{items:e.emotions,onChange:s=>r({emotions:s}),definitions:re}),t.jsx(je,{items:e.thoughts,onChange:s=>r({thoughts:s}),beliefs:O,modes:T}),t.jsx(Se,{items:e.behaviors,onChange:s=>r({behaviors:s}),behaviors:R,modes:T})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(o,{label:"Linked values",children:t.jsx(L,{options:ae,selectedValues:e.linkedValueIds,onChange:s=>r({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:le})}),t.jsx(o,{label:"Linked behaviors",children:t.jsx(L,{options:ne,selectedValues:e.linkedBehaviorIds,onChange:s=>r({linkedBehaviorIds:s}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Linked beliefs",children:t.jsx(L,{options:oe,selectedValues:e.linkedBeliefIds,onChange:s=>r({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:he})}),t.jsx(o,{label:"Linked modes",children:t.jsx(L,{options:de,selectedValues:e.linkedModeIds,onChange:s=>r({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.linkedGoalIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedGoalIds.length," goal tension"]}):null,e.linkedProjectIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedProjectIds.length," project tension"]}):null,e.linkedTaskIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(m,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:e.selfShortTerm,onChange:s=>r({selfShortTerm:s}),placeholder:"I shut down and lost the rest of the evening."}),t.jsx(m,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:e.selfLongTerm,onChange:s=>r({selfLongTerm:s}),placeholder:"It keeps reinforcing the same abandonment story."}),t.jsx(m,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:e.othersShortTerm,onChange:s=>r({othersShortTerm:s}),placeholder:"They felt pushed away and confused."}),t.jsx(m,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:e.othersLongTerm,onChange:s=>r({othersLongTerm:s}),placeholder:"Trust gets thinner every time this loop takes over."})]}),t.jsxs("div",{className:"grid gap-4",children:[t.jsx(o,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:F.filter(s=>s.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:F.filter(s=>s.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(s=>{const V=tt(s.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${V.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:s.title}),t.jsx(Oe,{content:rt(s.schemaType),label:`Explain ${st(s.schemaType)}`})]}),t.jsx(Qe,{className:"mt-2",children:s.description}),t.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.schemas.map(h=>{const ue=e.schemaLinks.some(ge=>{var Y;return((Y=Z(ge,[h]))==null?void 0:Y.id)===h.id});return t.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${ue?`${V.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>r({schemaLinks:it(e.schemaLinks,h)}),children:h.title},h.id)})})]},s.schemaType)})})}),t.jsx(Le,{items:e.modeTimeline,onChange:s=>r({modeTimeline:s}),modes:T,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),t.jsx(m,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:e.nextMoves,onChange:s=>r({nextMoves:s}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(v.isLoading||f.isLoading||y.isLoading||x.isLoading||k.isLoading||b.isLoading||w.isLoading||I.isLoading)return t.jsx(Ce,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const D=v.error??f.error??y.error??x.error??k.error??b.error??w.error??I.error;return D?t.jsx(Ee,{eyebrow:"Trigger reports",error:D,onRetry:()=>void Promise.all([v.refetch(),f.refetch(),y.refetch(),x.refetch(),k.refetch(),b.refetch(),w.refetch(),I.refetch()])}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Xe,{entityKind:"report",title:t.jsx(J,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${A.length} reports`,actions:t.jsx(Be,{onClick:()=>{u({...P,userId:j}),c(!0)},children:"Reflect"})}),t.jsx(Pe,{}),t.jsx(we,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:t.jsx("div",{className:"grid gap-4",children:A.length===0?t.jsx(Me,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):A.map(e=>{var r;return t.jsxs("div",{className:"min-w-0 max-w-full rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-start",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(J,{kind:"report",label:e.title,variant:"heading",size:"xl",lines:2,className:"w-full"}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.customEventType||e.eventSituation})]}),t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2 md:justify-end",children:[e.user?t.jsx(Ze,{user:e.user,compact:!0}):null,t.jsx(be,{entityType:"trigger_report",entityId:e.id,count:Ae(ie,"trigger_report",e.id).count}),t.jsx(Fe,{children:e.status}),t.jsx(fe,{to:`/psyche/reports/${e.id}`,className:"inline-flex min-h-10 max-w-full items-center rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open report"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spark"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.eventSituation})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-success-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Wave"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:((r=e.emotions[0])==null?void 0:r.label)??"No emotion captured yet"})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-info-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Lens"}),t.jsx("div",{className:"mt-3 min-w-0",children:e.schemaLinks[0]?(()=>{const s=Z(e.schemaLinks[0],F);return s?t.jsx(Ie,{label:s.title,schemaType:s.schemaType,compact:!0}):t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.schemaLinks[0]})})():t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"No schema link yet"})})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-warning-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Pivot"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.nextMoves[0]??"No next move yet"})]})]})]},e.id)})})}),t.jsx(ke,{open:M,onOpenChange:c,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:i,onChange:u,draftPersistenceKey:"psyche.report.new",steps:pe,submitLabel:"Create report",pending:Q.isPending,error:ee,onSubmit:async()=>{if(g(null),!X.safeParse({title:i.title,status:i.status,eventTypeId:i.eventTypeId||null,customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?new Date(i.occurredAt).toISOString():null,emotions:i.emotions.filter(r=>r.label.trim().length>0),thoughts:i.thoughts.filter(r=>r.text.trim().length>0),behaviors:i.behaviors.filter(r=>r.text.trim().length>0),consequences:{selfShortTerm:i.selfShortTerm,selfLongTerm:i.selfLongTerm,othersShortTerm:i.othersShortTerm,othersLongTerm:i.othersLongTerm},linkedPatternIds:[],linkedValueIds:i.linkedValueIds,linkedGoalIds:i.linkedGoalIds,linkedProjectIds:i.linkedProjectIds,linkedTaskIds:i.linkedTaskIds,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds,modeOverlays:[],schemaLinks:i.schemaLinks.filter(Boolean),modeTimeline:i.modeTimeline.filter(r=>r.stage.trim().length>0&&r.label.trim().length>0),nextMoves:i.nextMoves.filter(Boolean)}).success){g("This report still needs a title and concrete triggering situation.");return}try{await Q.mutateAsync(i)}catch(r){g(r instanceof Error?r.message:"Unable to create this report right now.")}}})]})}export{Ct as PsycheReportsPage};
|
|
1
|
+
import{bY as ve,r as S,j as t,aC as fe}from"./vendor-BwL6m4SE.js";import{j as ye,i as d,k as xe}from"./state-Bpe5dF3T.js";import{Q as ke,F as o}from"./question-flow-dialog-CskCt5NZ.js";import{E as be}from"./entity-note-count-link-Cjsk5oT2.js";import{A as we}from"./atlas-panel-BfMyJXxQ.js";import{E as L}from"./entity-link-multiselect-DcCvkesQ.js";import{S as Ie}from"./schema-badge-B3DiMnjB.js";import{E as Te,T as je,B as Se,S as m,M as Le}from"./report-chain-fields-D132-EMh.js";import{d as Ne,L as Ce,e as Ee,B as Be,E as J,bs as Pe,h as Me,R as Ae,k as Fe,cv as qe,I as q,T as Re,a4 as Oe,a3 as Qe,bP as De,bN as Ke,b$ as Ue,bQ as $e,b9 as Ge,b3 as He,b5 as _e,b6 as ze,b7 as We,bR as Ve,ct as Ye,cu as Je}from"./index-CQ5r7ZUz.js";import{P as Xe}from"./page-hero-8bITsx_x.js";import{U as Ze}from"./user-badge-CZWtYeMw.js";import{U as et}from"./user-select-field-fx129Uh6.js";import{p as N}from"./query-cache-IQ8W-LNC.js";import{t as X}from"./psyche-schemas-DDol0j-g.js";import{f as Z,b as tt,a as st,c as rt,t as it}from"./schema-visuals-CvC9a3i6.js";import{g as at,b as C,d as E,e as B,a as nt}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const P={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:null};function ot(l){const n=new Date(l);if(Number.isNaN(n.getTime()))return"";const a=n.getFullYear(),p=String(n.getMonth()+1).padStart(2,"0"),M=String(n.getDate()).padStart(2,"0"),c=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${a}-${p}-${M}T${c}:${i}`}function Ct(){var K,U,$,G,H,_,z,W;const l=Ne(),n=ye(),[a,p]=ve(),[M,c]=S.useState(!1),[i,u]=S.useState(P),[ee,g]=S.useState(null),v=d({queryKey:["forge-psyche-reports"],queryFn:Ge}),f=d({queryKey:["forge-psyche-values"],queryFn:He}),y=d({queryKey:["forge-psyche-behaviors"],queryFn:_e}),x=d({queryKey:["forge-psyche-beliefs"],queryFn:ze}),k=d({queryKey:["forge-psyche-modes"],queryFn:We}),b=d({queryKey:["forge-psyche-schema-catalog"],queryFn:Ve}),w=d({queryKey:["forge-psyche-event-types"],queryFn:Ye}),I=d({queryKey:["forge-psyche-emotions"],queryFn:Je}),A=((K=v.data)==null?void 0:K.reports)??[],te=((U=f.data)==null?void 0:U.values)??[],R=(($=y.data)==null?void 0:$.behaviors)??[],O=((G=x.data)==null?void 0:G.beliefs)??[],T=((H=k.data)==null?void 0:H.modes)??[],F=((_=b.data)==null?void 0:_.schemas)??[],se=((z=w.data)==null?void 0:z.eventTypes)??[],re=((W=I.data)==null?void 0:W.emotions)??[],j=at(l.selectedUserIds),ie=l.snapshot.dashboard.notesSummaryByEntity;S.useEffect(()=>{if(a.get("create")==="1"){c(!0),u({...P,userId:a.get("userId")??j,occurredAt:a.get("occurredAt")?ot(a.get("occurredAt")):"",customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const e=new URLSearchParams(a);e.delete("create"),e.delete("intent"),e.delete("occurredAt"),e.delete("userId"),e.delete("valueId"),e.delete("behaviorId"),e.delete("beliefId"),e.delete("goalId"),e.delete("projectId"),e.delete("taskId"),p(e,{replace:!0})}},[a,p]);const Q=xe({mutationFn:async e=>{const r=X.parse({title:e.title,status:e.status,eventTypeId:e.eventTypeId||null,customEventType:e.customEventType,eventSituation:e.eventSituation,occurredAt:e.occurredAt?new Date(e.occurredAt).toISOString():null,emotions:e.emotions.filter(s=>s.label.trim().length>0),thoughts:e.thoughts.filter(s=>s.text.trim().length>0),behaviors:e.behaviors.filter(s=>s.text.trim().length>0),consequences:{selfShortTerm:e.selfShortTerm,selfLongTerm:e.selfLongTerm,othersShortTerm:e.othersShortTerm,othersLongTerm:e.othersLongTerm},linkedPatternIds:[],linkedValueIds:e.linkedValueIds,linkedGoalIds:e.linkedGoalIds,linkedProjectIds:e.linkedProjectIds,linkedTaskIds:e.linkedTaskIds,linkedBehaviorIds:e.linkedBehaviorIds,linkedBeliefIds:e.linkedBeliefIds,linkedModeIds:e.linkedModeIds,modeOverlays:[],schemaLinks:e.schemaLinks.filter(Boolean),modeTimeline:e.modeTimeline.filter(s=>s.stage.trim().length>0&&s.label.trim().length>0),nextMoves:e.nextMoves.filter(Boolean),userId:e.userId});return qe(r)},onSuccess:async()=>{c(!1),u({...P,userId:j}),g(null),await Promise.all([n.invalidateQueries({queryKey:["forge-psyche-reports"]}),n.invalidateQueries({queryKey:["forge-psyche-overview"]}),n.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),ae=te.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.valuedDirection,e.user),searchText:C([e.title,e.valuedDirection,e.description],e),kind:"value"})),ne=R.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.kind,e.user),searchText:C([e.title,e.kind,e.description],e),kind:"behavior"})),oe=O.map(e=>({value:e.id,label:B(e.statement,e.user),description:E(e.flexibleAlternative||e.originNote,e.user),searchText:C([e.statement,e.flexibleAlternative,e.originNote,e.beliefType],e),kind:"belief"})),de=T.map(e=>({value:e.id,label:B(e.title,e.user),description:E(e.archetype||e.family,e.user),searchText:C([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),le=async e=>{const{value:r}=await De({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:i.userId});return N(n,["forge-psyche-values"],"values",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.valuedDirection,kind:"value"}},ce=async e=>{const{behavior:r}=await Ke({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:i.userId});return N(n,["forge-psyche-behaviors"],"behaviors",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.kind,kind:"behavior"}},he=async e=>{const{belief:r}=await Ue({schemaId:null,statement:e,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:i.userId});return N(n,["forge-psyche-beliefs"],"beliefs",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.statement,description:r.flexibleAlternative||r.originNote,kind:"belief"}},me=async e=>{const{mode:r}=await $e({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:i.userId});return N(n,["forge-psyche-modes"],"modes",r),await n.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:r.id,label:r.title,description:r.archetype||r.family,kind:"mode"}},pe=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(et,{value:e.userId,users:l.snapshot.users,onChange:s=>r({userId:s}),defaultLabel:nt(l.snapshot.users.find(s=>s.id===j)??null,"Choose report owner"),help:"Trigger reports can belong to a human or bot user while still linking to shared values, behaviors, beliefs, and modes."}),t.jsx(o,{label:"Report title",children:t.jsx(q,{value:e.title,onChange:s=>r({title:s.target.value}),placeholder:"Friday silence spiral"})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Event type",children:t.jsxs("select",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",value:e.eventTypeId,onChange:s=>r({eventTypeId:s.target.value}),children:[t.jsx("option",{value:"",children:"Custom or uncategorized"}),se.map(s=>t.jsx("option",{value:s.id,children:s.label},s.id))]})}),t.jsx(o,{label:"Occurred at",children:t.jsx(q,{type:"datetime-local",value:e.occurredAt,onChange:s=>r({occurredAt:s.target.value})})})]}),t.jsx(o,{label:"Custom event label",children:t.jsx(q,{value:e.customEventType,onChange:s=>r({customEventType:s.target.value}),placeholder:"Unexpected distance after vulnerability"})}),t.jsx(o,{label:"Situation",children:t.jsx(Re,{value:e.eventSituation,onChange:s=>r({eventSituation:s.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(Te,{items:e.emotions,onChange:s=>r({emotions:s}),definitions:re}),t.jsx(je,{items:e.thoughts,onChange:s=>r({thoughts:s}),beliefs:O,modes:T}),t.jsx(Se,{items:e.behaviors,onChange:s=>r({behaviors:s}),behaviors:R,modes:T})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsx(o,{label:"Linked values",children:t.jsx(L,{options:ae,selectedValues:e.linkedValueIds,onChange:s=>r({linkedValueIds:s}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:le})}),t.jsx(o,{label:"Linked behaviors",children:t.jsx(L,{options:ne,selectedValues:e.linkedBehaviorIds,onChange:s=>r({linkedBehaviorIds:s}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:ce})}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(o,{label:"Linked beliefs",children:t.jsx(L,{options:oe,selectedValues:e.linkedBeliefIds,onChange:s=>r({linkedBeliefIds:s}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:he})}),t.jsx(o,{label:"Linked modes",children:t.jsx(L,{options:de,selectedValues:e.linkedModeIds,onChange:s=>r({linkedModeIds:s}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:me})})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.linkedGoalIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedGoalIds.length," goal tension"]}):null,e.linkedProjectIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedProjectIds.length," project tension"]}):null,e.linkedTaskIds.length>0?t.jsxs("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-soft)]",children:["Linked to ",e.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(e,r)=>t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(m,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:e.selfShortTerm,onChange:s=>r({selfShortTerm:s}),placeholder:"I shut down and lost the rest of the evening."}),t.jsx(m,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:e.selfLongTerm,onChange:s=>r({selfLongTerm:s}),placeholder:"It keeps reinforcing the same abandonment story."}),t.jsx(m,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:e.othersShortTerm,onChange:s=>r({othersShortTerm:s}),placeholder:"They felt pushed away and confused."}),t.jsx(m,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:e.othersLongTerm,onChange:s=>r({othersLongTerm:s}),placeholder:"Trust gets thinner every time this loop takes over."})]}),t.jsxs("div",{className:"grid gap-4",children:[t.jsx(o,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:F.filter(s=>s.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:F.filter(s=>s.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(s=>{const V=tt(s.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${V.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:s.title}),t.jsx(Oe,{content:rt(s.schemaType),label:`Explain ${st(s.schemaType)}`})]}),t.jsx(Qe,{className:"mt-2",children:s.description}),t.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:s.schemas.map(h=>{const ue=e.schemaLinks.some(ge=>{var Y;return((Y=Z(ge,[h]))==null?void 0:Y.id)===h.id});return t.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${ue?`${V.badgeTone} ring-1 ring-[color-mix(in_srgb,var(--primary)_28%,transparent)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>r({schemaLinks:it(e.schemaLinks,h)}),children:h.title},h.id)})})]},s.schemaType)})})}),t.jsx(Le,{items:e.modeTimeline,onChange:s=>r({modeTimeline:s}),modes:T,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),t.jsx(m,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:e.nextMoves,onChange:s=>r({nextMoves:s}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(v.isLoading||f.isLoading||y.isLoading||x.isLoading||k.isLoading||b.isLoading||w.isLoading||I.isLoading)return t.jsx(Ce,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const D=v.error??f.error??y.error??x.error??k.error??b.error??w.error??I.error;return D?t.jsx(Ee,{eyebrow:"Trigger reports",error:D,onRetry:()=>void Promise.all([v.refetch(),f.refetch(),y.refetch(),x.refetch(),k.refetch(),b.refetch(),w.refetch(),I.refetch()])}):t.jsxs("div",{className:"grid gap-5",children:[t.jsx(Xe,{entityKind:"report",title:t.jsx(J,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${A.length} reports`,actions:t.jsx(Be,{onClick:()=>{u({...P,userId:j}),c(!0)},children:"Reflect"})}),t.jsx(Pe,{}),t.jsx(we,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:t.jsx("div",{className:"grid gap-4",children:A.length===0?t.jsx(Me,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):A.map(e=>{var r;return t.jsxs("div",{className:"min-w-0 max-w-full rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5 transition hover:bg-[var(--ui-surface-hover)]",children:[t.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_auto] md:items-start",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(J,{kind:"report",label:e.title,variant:"heading",size:"xl",lines:2,className:"w-full"}),t.jsx("div",{className:"mt-2 min-w-0 break-words text-sm text-[var(--ui-ink-faint)] [overflow-wrap:anywhere]",children:e.customEventType||e.eventSituation})]}),t.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center gap-2 md:justify-end",children:[e.user?t.jsx(Ze,{user:e.user,compact:!0}):null,t.jsx(be,{entityType:"trigger_report",entityId:e.id,count:Ae(ie,"trigger_report",e.id).count}),t.jsx(Fe,{children:e.status}),t.jsx(fe,{to:`/psyche/reports/${e.id}`,className:"inline-flex min-h-10 max-w-full items-center rounded-full bg-[var(--ui-surface-2)] px-3 py-2 text-sm text-[var(--ui-ink-strong)] transition hover:bg-[var(--ui-surface-hover)]",children:"Open report"})]})]}),t.jsxs("div",{className:"mt-5 grid min-w-0 gap-3 xl:grid-cols-4",children:[t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-surface-1)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Spark"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.eventSituation})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-success-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Wave"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:((r=e.emotions[0])==null?void 0:r.label)??"No emotion captured yet"})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-info-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Lens"}),t.jsx("div",{className:"mt-3 min-w-0",children:e.schemaLinks[0]?(()=>{const s=Z(e.schemaLinks[0],F);return s?t.jsx(Ie,{label:s.title,schemaType:s.schemaType,compact:!0}):t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.schemaLinks[0]})})():t.jsx("div",{className:"break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"No schema link yet"})})]}),t.jsxs("div",{className:"min-w-0 rounded-[20px] bg-[var(--ui-warning-soft)] p-4",children:[t.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Pivot"}),t.jsx("div",{className:"mt-3 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:e.nextMoves[0]??"No next move yet"})]})]})]},e.id)})})}),t.jsx(ke,{open:M,onOpenChange:c,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:i,onChange:u,draftPersistenceKey:"psyche.report.new",steps:pe,submitLabel:"Create report",pending:Q.isPending,error:ee,onSubmit:async()=>{if(g(null),!X.safeParse({title:i.title,status:i.status,eventTypeId:i.eventTypeId||null,customEventType:i.customEventType,eventSituation:i.eventSituation,occurredAt:i.occurredAt?new Date(i.occurredAt).toISOString():null,emotions:i.emotions.filter(r=>r.label.trim().length>0),thoughts:i.thoughts.filter(r=>r.text.trim().length>0),behaviors:i.behaviors.filter(r=>r.text.trim().length>0),consequences:{selfShortTerm:i.selfShortTerm,selfLongTerm:i.selfLongTerm,othersShortTerm:i.othersShortTerm,othersLongTerm:i.othersLongTerm},linkedPatternIds:[],linkedValueIds:i.linkedValueIds,linkedGoalIds:i.linkedGoalIds,linkedProjectIds:i.linkedProjectIds,linkedTaskIds:i.linkedTaskIds,linkedBehaviorIds:i.linkedBehaviorIds,linkedBeliefIds:i.linkedBeliefIds,linkedModeIds:i.linkedModeIds,modeOverlays:[],schemaLinks:i.schemaLinks.filter(Boolean),modeTimeline:i.modeTimeline.filter(r=>r.stage.trim().length>0&&r.label.trim().length>0),nextMoves:i.nextMoves.filter(Boolean)}).success){g("This report still needs a title and concrete triggering situation.");return}try{await Q.mutateAsync(i)}catch(r){g(r instanceof Error?r.message:"Unable to create this report right now.")}}})]})}export{Ct as PsycheReportsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bY as be,r as x,j as t}from"./vendor-BwL6m4SE.js";import{j as je,i as w,k as ke}from"./state-Bpe5dF3T.js";import{S as re}from"./schema-badge-BAiS_OAp.js";import{Q as we,F as d}from"./question-flow-dialog-CLHVmFON.js";import{E as Ie}from"./entity-note-count-link-CV3eOv66.js";import{A as se}from"./atlas-panel-GdK1oyxo.js";import{E as F}from"./entity-link-multiselect-Do5DTju7.js";import{d as Te,L as Se,e as Ne,B as $,bs as Ce,R as Le,k as I,b as Be,a4 as ne,cC as Ee,b$ as Fe,a3 as Ae,I as Pe,T as A,bP as Me,bN as qe,bQ as Oe,cv as Qe,bR as Re,b6 as $e,b5 as Ue,b7 as He,b3 as Ke,b9 as De}from"./index-DGYIFHgo.js";import{u as Ve,p as Ge}from"./use-psyche-focus-target-BhNedCZB.js";import{P as _e}from"./page-hero-BkrRTu-t.js";import{U as ze}from"./user-badge-ap1PvOxd.js";import{U as We}from"./user-select-field-fx129Uh6.js";import{p as P}from"./query-cache-IQ8W-LNC.js";import{d as ie}from"./psyche-schemas-DDol0j-g.js";import{c as U,b as K,g as Ye,a as Je,f as Xe}from"./schema-visuals-CvC9a3i6.js";import{g as Ze,b as M,d as q,e as O,a as et}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const S={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:null};function H(a){return{schemaId:a.schemaId,statement:a.statement,beliefType:a.beliefType,originNote:a.originNote,confidence:a.confidence,evidenceFor:a.evidenceFor,evidenceAgainst:a.evidenceAgainst,flexibleAlternative:a.flexibleAlternative,linkedValueIds:a.linkedValueIds,linkedBehaviorIds:a.linkedBehaviorIds,linkedModeIds:a.linkedModeIds,linkedReportIds:a.linkedReportIds,userId:a.userId??null}}function tt({schema:a,beliefs:o,behaviors:f,reports:v}){const g=o.filter(n=>n.schemaId===a.id).length,l=f.filter(n=>n.linkedSchemaIds.includes(a.id)).length,c=v.filter(n=>n.schemaLinks.some(h=>{const r=Xe(h,[a]);return(r==null?void 0:r.id)===a.id})).length;return{beliefCount:g,behaviorCount:l,reportCount:c,total:g+l+c}}function ae({title:a,description:o,titleHelp:f,schemas:v,beliefs:g,behaviors:l,reports:c,onOpenBelief:n}){if(v.length===0)return null;const h=K(v[0].schemaType);return t.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${h.sectionTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"grid min-w-0 gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${h.sectionEyebrow}`,children:[t.jsx("span",{children:a}),f?t.jsx(ne,{content:f,label:`Explain ${a.toLowerCase()}`}):null]}),t.jsx("div",{className:"max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:o})]}),t.jsxs(I,{children:[v.length," schemas"]})]}),t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:v.map(r=>{const j=tt({schema:r,beliefs:g,behaviors:l,reports:c}),p=g.filter(u=>u.schemaId===r.id),y=K(r.schemaType);return t.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${y.cardTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{label:r.title,schemaType:r.schemaType}),t.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:Ye(r.family)}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.description})]}),t.jsxs(I,{children:[j.total," ",y.countLabel]})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.beliefCount," beliefs"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.behaviorCount," behaviors"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.reportCount," reports"]})]}),t.jsxs("div",{className:"mt-4 grid gap-3",children:[p.length>0?t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:`${p.length} ${y.linkSummary}${p.length===1?"":"s"} live here.`}):t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-faint)]",children:y.emptyCopy}),p.slice(0,2).map(u=>t.jsxs("button",{type:"button",className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>n(u),children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.statement}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},r.id)})})]})}function wt(){var Y,J,X,Z,ee,te;const a=Te(),o=je(),[f,v]=be(),[g,l]=x.useState(!1),[c,n]=x.useState(null),[h,r]=x.useState(S),[j,p]=x.useState(null),y=w({queryKey:["forge-psyche-schema-catalog"],queryFn:Re}),u=w({queryKey:["forge-psyche-beliefs"],queryFn:$e}),N=w({queryKey:["forge-psyche-behaviors"],queryFn:Ue}),C=w({queryKey:["forge-psyche-modes"],queryFn:He}),L=w({queryKey:["forge-psyche-values"],queryFn:Ke}),B=w({queryKey:["forge-psyche-reports"],queryFn:De}),b=((Y=y.data)==null?void 0:Y.schemas)??[],T=((J=u.data)==null?void 0:J.beliefs)??[],Q=((X=N.data)==null?void 0:X.behaviors)??[],D=((Z=C.data)==null?void 0:Z.modes)??[],oe=((ee=L.data)==null?void 0:ee.values)??[],R=((te=B.data)==null?void 0:te.reports)??[],k=Ze(a.selectedUserIds),V=f.get("focus"),le=a.snapshot.dashboard.notesSummaryByEntity;Ve(V),x.useEffect(()=>{if(f.get("create")==="1"){l(!0),n(null),r({...S,userId:k});const e=new URLSearchParams(f);e.delete("create"),v(e,{replace:!0})}},[k,f,v]);const G=ke({mutationFn:async e=>{const s=ie.parse(e);return c?Ee(c.id,s):Fe(s)},onSuccess:async()=>{l(!1),n(null),r({...S,userId:k}),p(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),de=oe.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.valuedDirection,e.user),searchText:M([e.title,e.valuedDirection,e.description],e),kind:"value"})),ce=Q.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.kind,e.user),searchText:M([e.title,e.kind,e.description],e),kind:"behavior"})),he=D.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.archetype||e.family,e.user),searchText:M([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ue=R.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.customEventType||e.eventSituation,e.user),searchText:M([e.title,e.customEventType,e.eventSituation],e),kind:"report"})),me=x.useMemo(()=>new Map(b.map(e=>[e.id,e])),[b]),_=x.useMemo(()=>b.filter(e=>e.schemaType==="maladaptive"),[b]),z=x.useMemo(()=>b.filter(e=>e.schemaType==="adaptive"),[b]),pe=async e=>{const{value:s}=await Me({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:h.userId});return P(o,["forge-psyche-values"],"values",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.valuedDirection,kind:"value"}},fe=async e=>{const{behavior:s}=await qe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:h.userId});return P(o,["forge-psyche-behaviors"],"behaviors",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.kind,kind:"behavior"}},ve=async e=>{const{mode:s}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:h.userId});return P(o,["forge-psyche-modes"],"modes",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.archetype||s.family,kind:"mode"}},ge=async e=>{const{report:s}=await Qe({title:e,status:"draft",eventTypeId:null,customEventType:"",eventSituation:e,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:h.userId});return P(o,["forge-psyche-reports"],"reports",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.customEventType||s.eventSituation,kind:"report"}};x.useEffect(()=>{g&&p(null)},[g]);const ye=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(We,{value:e.userId??null,users:a.snapshot.users,onChange:i=>s({userId:i}),defaultLabel:et(a.snapshot.users.find(i=>i.id===k)??null,"Choose belief owner"),help:"Beliefs can belong to a human or bot user even when they connect to shared behaviors, modes, and reports."}),t.jsx(d,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:_,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:z,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(i=>{const m=K(i.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${m.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.title}),t.jsx(ne,{content:U(i.schemaType),label:`Explain ${Je(i.schemaType)}`})]}),t.jsx(Ae,{className:"mt-2",children:i.description}),t.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:i.schemas.map(E=>{const xe=e.schemaId===E.id;return t.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${xe?`${m.badgeTone} ring-1 ring-[var(--ui-ring)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({schemaId:E.id}),children:E.title},E.id)})})]},i.schemaType)})})}),t.jsx(d,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:t.jsx(Pe,{value:e.statement,onChange:i=>s({statement:i.target.value}),placeholder:"If they go quiet, I am already being left."})}),t.jsx(d,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(i=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.beliefType===i?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>s({beliefType:i}),children:i==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},i))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:t.jsx(A,{value:e.originNote,onChange:i=>s({originNote:i.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),t.jsxs(d,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[t.jsx("input",{type:"range",min:0,max:100,value:e.confidence,onChange:i=>s({confidence:Number(i.target.value)})}),t.jsxs("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:[e.confidence,"% grip"]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(d,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:t.jsx(A,{value:e.evidenceFor.join(`
|
|
1
|
+
import{bY as be,r as x,j as t}from"./vendor-BwL6m4SE.js";import{j as je,i as w,k as ke}from"./state-Bpe5dF3T.js";import{S as re}from"./schema-badge-B3DiMnjB.js";import{Q as we,F as d}from"./question-flow-dialog-CskCt5NZ.js";import{E as Ie}from"./entity-note-count-link-Cjsk5oT2.js";import{A as se}from"./atlas-panel-BfMyJXxQ.js";import{E as F}from"./entity-link-multiselect-DcCvkesQ.js";import{d as Te,L as Se,e as Ne,B as $,bs as Ce,R as Le,k as I,b as Be,a4 as ne,cC as Ee,b$ as Fe,a3 as Ae,I as Pe,T as A,bP as Me,bN as qe,bQ as Oe,cv as Qe,bR as Re,b6 as $e,b5 as Ue,b7 as He,b3 as Ke,b9 as De}from"./index-CQ5r7ZUz.js";import{u as Ve,p as Ge}from"./use-psyche-focus-target-BhNedCZB.js";import{P as _e}from"./page-hero-8bITsx_x.js";import{U as ze}from"./user-badge-CZWtYeMw.js";import{U as We}from"./user-select-field-fx129Uh6.js";import{p as P}from"./query-cache-IQ8W-LNC.js";import{d as ie}from"./psyche-schemas-DDol0j-g.js";import{c as U,b as K,g as Ye,a as Je,f as Xe}from"./schema-visuals-CvC9a3i6.js";import{g as Ze,b as M,d as q,e as O,a as et}from"./user-ownership-DJGl4rAj.js";import"./ui-B9TWEtCx.js";import"./motion-DcgUnXhY.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const S={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[],userId:null};function H(a){return{schemaId:a.schemaId,statement:a.statement,beliefType:a.beliefType,originNote:a.originNote,confidence:a.confidence,evidenceFor:a.evidenceFor,evidenceAgainst:a.evidenceAgainst,flexibleAlternative:a.flexibleAlternative,linkedValueIds:a.linkedValueIds,linkedBehaviorIds:a.linkedBehaviorIds,linkedModeIds:a.linkedModeIds,linkedReportIds:a.linkedReportIds,userId:a.userId??null}}function tt({schema:a,beliefs:o,behaviors:f,reports:v}){const g=o.filter(n=>n.schemaId===a.id).length,l=f.filter(n=>n.linkedSchemaIds.includes(a.id)).length,c=v.filter(n=>n.schemaLinks.some(h=>{const r=Xe(h,[a]);return(r==null?void 0:r.id)===a.id})).length;return{beliefCount:g,behaviorCount:l,reportCount:c,total:g+l+c}}function ae({title:a,description:o,titleHelp:f,schemas:v,beliefs:g,behaviors:l,reports:c,onOpenBelief:n}){if(v.length===0)return null;const h=K(v[0].schemaType);return t.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${h.sectionTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"grid min-w-0 gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${h.sectionEyebrow}`,children:[t.jsx("span",{children:a}),f?t.jsx(ne,{content:f,label:`Explain ${a.toLowerCase()}`}):null]}),t.jsx("div",{className:"max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:o})]}),t.jsxs(I,{children:[v.length," schemas"]})]}),t.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:v.map(r=>{const j=tt({schema:r,beliefs:g,behaviors:l,reports:c}),p=g.filter(u=>u.schemaId===r.id),y=K(r.schemaType);return t.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${y.cardTone}`,children:[t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{label:r.title,schemaType:r.schemaType}),t.jsx("div",{className:"mt-3 text-sm text-[var(--ui-ink-faint)]",children:Ye(r.family)}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:r.description})]}),t.jsxs(I,{children:[j.total," ",y.countLabel]})]}),t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.beliefCount," beliefs"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.behaviorCount," behaviors"]}),t.jsxs(I,{className:"bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",children:[j.reportCount," reports"]})]}),t.jsxs("div",{className:"mt-4 grid gap-3",children:[p.length>0?t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:`${p.length} ${y.linkSummary}${p.length===1?"":"s"} live here.`}):t.jsx("div",{className:"rounded-[18px] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-faint)]",children:y.emptyCopy}),p.slice(0,2).map(u=>t.jsxs("button",{type:"button",className:"rounded-[20px] bg-[var(--ui-surface-1)] p-4 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>n(u),children:[t.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:u.statement}),t.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},r.id)})})]})}function wt(){var Y,J,X,Z,ee,te;const a=Te(),o=je(),[f,v]=be(),[g,l]=x.useState(!1),[c,n]=x.useState(null),[h,r]=x.useState(S),[j,p]=x.useState(null),y=w({queryKey:["forge-psyche-schema-catalog"],queryFn:Re}),u=w({queryKey:["forge-psyche-beliefs"],queryFn:$e}),N=w({queryKey:["forge-psyche-behaviors"],queryFn:Ue}),C=w({queryKey:["forge-psyche-modes"],queryFn:He}),L=w({queryKey:["forge-psyche-values"],queryFn:Ke}),B=w({queryKey:["forge-psyche-reports"],queryFn:De}),b=((Y=y.data)==null?void 0:Y.schemas)??[],T=((J=u.data)==null?void 0:J.beliefs)??[],Q=((X=N.data)==null?void 0:X.behaviors)??[],D=((Z=C.data)==null?void 0:Z.modes)??[],oe=((ee=L.data)==null?void 0:ee.values)??[],R=((te=B.data)==null?void 0:te.reports)??[],k=Ze(a.selectedUserIds),V=f.get("focus"),le=a.snapshot.dashboard.notesSummaryByEntity;Ve(V),x.useEffect(()=>{if(f.get("create")==="1"){l(!0),n(null),r({...S,userId:k});const e=new URLSearchParams(f);e.delete("create"),v(e,{replace:!0})}},[k,f,v]);const G=ke({mutationFn:async e=>{const s=ie.parse(e);return c?Ee(c.id,s):Fe(s)},onSuccess:async()=>{l(!1),n(null),r({...S,userId:k}),p(null),await Promise.all([o.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),o.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),de=oe.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.valuedDirection,e.user),searchText:M([e.title,e.valuedDirection,e.description],e),kind:"value"})),ce=Q.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.kind,e.user),searchText:M([e.title,e.kind,e.description],e),kind:"behavior"})),he=D.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.archetype||e.family,e.user),searchText:M([e.title,e.archetype,e.family,e.persona],e),kind:"mode"})),ue=R.map(e=>({value:e.id,label:O(e.title,e.user),description:q(e.customEventType||e.eventSituation,e.user),searchText:M([e.title,e.customEventType,e.eventSituation],e),kind:"report"})),me=x.useMemo(()=>new Map(b.map(e=>[e.id,e])),[b]),_=x.useMemo(()=>b.filter(e=>e.schemaType==="maladaptive"),[b]),z=x.useMemo(()=>b.filter(e=>e.schemaType==="adaptive"),[b]),pe=async e=>{const{value:s}=await Me({title:e,description:"",valuedDirection:e,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[],userId:h.userId});return P(o,["forge-psyche-values"],"values",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.valuedDirection,kind:"value"}},fe=async e=>{const{behavior:s}=await qe({kind:"away",title:e,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[],userId:h.userId});return P(o,["forge-psyche-behaviors"],"behaviors",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.kind,kind:"behavior"}},ve=async e=>{const{mode:s}=await Oe({family:"coping",archetype:"",title:e,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[],userId:h.userId});return P(o,["forge-psyche-modes"],"modes",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.archetype||s.family,kind:"mode"}},ge=async e=>{const{report:s}=await Qe({title:e,status:"draft",eventTypeId:null,customEventType:"",eventSituation:e,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[],userId:h.userId});return P(o,["forge-psyche-reports"],"reports",s),await o.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:s.id,label:s.title,description:s.customEventType||s.eventSituation,kind:"report"}};x.useEffect(()=>{g&&p(null)},[g]);const ye=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(We,{value:e.userId??null,users:a.snapshot.users,onChange:i=>s({userId:i}),defaultLabel:et(a.snapshot.users.find(i=>i.id===k)??null,"Choose belief owner"),help:"Beliefs can belong to a human or bot user even when they connect to shared behaviors, modes, and reports."}),t.jsx(d,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:t.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:_,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:z,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(i=>{const m=K(i.schemaType);return t.jsxs("div",{className:`rounded-[24px] border p-4 ${m.cardTone}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.title}),t.jsx(ne,{content:U(i.schemaType),label:`Explain ${Je(i.schemaType)}`})]}),t.jsx(Ae,{className:"mt-2",children:i.description}),t.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:i.schemas.map(E=>{const xe=e.schemaId===E.id;return t.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${xe?`${m.badgeTone} ring-1 ring-[var(--ui-ring)]`:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"}`,onClick:()=>s({schemaId:E.id}),children:E.title},E.id)})})]},i.schemaType)})})}),t.jsx(d,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:t.jsx(Pe,{value:e.statement,onChange:i=>s({statement:i.target.value}),placeholder:"If they go quiet, I am already being left."})}),t.jsx(d,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(i=>t.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${e.beliefType===i?"border-[var(--ui-border-strong)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)]"}`,onClick:()=>s({beliefType:i}),children:i==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},i))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(e,s)=>t.jsxs(t.Fragment,{children:[t.jsx(d,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:t.jsx(A,{value:e.originNote,onChange:i=>s({originNote:i.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),t.jsxs(d,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[t.jsx("input",{type:"range",min:0,max:100,value:e.confidence,onChange:i=>s({confidence:Number(i.target.value)})}),t.jsxs("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:[e.confidence,"% grip"]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsx(d,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:t.jsx(A,{value:e.evidenceFor.join(`
|
|
2
2
|
`),onChange:i=>s({evidenceFor:i.target.value.split(`
|
|
3
3
|
`).map(m=>m.trim()).filter(Boolean)}),placeholder:`One line per sign
|
|
4
4
|
They stopped replying for days
|
package/dist/assets/{psyche-screen-time-page-DOKW3m8B.js → psyche-screen-time-page-n4b0e58x.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as E,j as e}from"./vendor-BwL6m4SE.js";import{i as N}from"./state-Bpe5dF3T.js";import{S as Q,e as z,k as l,bs as G,C as i,c as x,B as U,cy as V,cz as X,cA as Y,cB as J}from"./index-DGYIFHgo.js";import{P as O}from"./page-hero-BkrRTu-t.js";import{R as w,A,C,X as L,Y as F,T,a as k}from"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const S="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",_="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",j="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",d="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",b="text-[var(--ui-ink-soft)]",m="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Z="border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",K="var(--ui-border-subtle)",h="var(--ui-ink-faint)",ee="color-mix(in_srgb,var(--success)_82%,var(--primary)_18%)",se="color-mix(in_srgb,var(--success)_18%,transparent)",M="color-mix(in_srgb,var(--info)_86%,var(--primary)_14%)",W="color-mix(in_srgb,var(--info)_16%,transparent)",te="var(--ui-ink-strong)",ae="color-mix(in_srgb,var(--ui-ink-strong)_12%,transparent)",D={background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:"8px",color:"var(--ui-ink-strong)"};function re(t){switch(t){case"fresh":return"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]";case"stale":return"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_74%,var(--ui-ink-strong)_26%)]";case"unavailable":return"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_74%,var(--ui-ink-strong)_26%)]";default:return m}}function n(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function R(t){return`${String(t).padStart(2,"0")}:00`}function $(t){return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t]??"Day"}function ie(t,r,c){return!t||!r?c:`${new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} → ${new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`}function H(t,r){const c=typeof t=="number"?t:typeof t=="string"?Number(t):0;return[r==="totalActivitySeconds"||r==="averageActivitySeconds"?n(c):String(Math.round(c)),r==="totalActivitySeconds"?"Activity":r==="averageActivitySeconds"?"Avg activity":r==="pickupCount"||r==="averagePickups"?r==="averagePickups"?"Avg pickups":"Pickups":r==="averageNotifications"?"Avg notifications":"Notifications"]}function pe(){const[t,r]=E.useState("day"),c=N({queryKey:["forge-screen-time-settings"],queryFn:()=>V().then(s=>s.settings)}),v=N({queryKey:["forge-screen-time-day"],queryFn:()=>X().then(s=>s.screenTime)}),p=N({queryKey:["forge-screen-time-month"],queryFn:()=>Y().then(s=>s.screenTime)}),f=N({queryKey:["forge-screen-time-all-time"],queryFn:()=>J().then(s=>s.screenTime)});if(c.isLoading||v.isLoading||p.isLoading||f.isLoading)return e.jsx(Q,{});const q=c.error??v.error??p.error??f.error;if(q||!c.data||!v.data||!p.data||!f.data)return e.jsx(z,{eyebrow:"Psyche",error:q,onRetry:()=>{c.refetch(),v.refetch(),p.refetch(),f.refetch()}});const a=c.data,o=v.data,g=p.data,u=f.data,I=o.topApps.slice(0,3).map(s=>s.displayName||s.bundleIdentifier),B=typeof a.metadata.snapshot_source=="string"?a.metadata.snapshot_source.replaceAll("_"," "):"device activity report";return e.jsxs("div",{className:"space-y-5",children:[e.jsx(O,{title:"Screen Time",titleText:"Screen Time",description:"Apple-compliant device activity, hourly usage, and reflective phone context woven into Psyche.",actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:a.authorizationStatus.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:m,children:a.captureState.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:re(a.captureFreshness),children:a.captureFreshness}),e.jsx(l,{tone:"default",className:m,children:a.syncEnabled?"Sync on":"Sync paused"})]})}),e.jsx(G,{}),e.jsxs(i,{className:S,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:d,children:"Reflective device activity"}),e.jsx("div",{className:x("mt-2 max-w-3xl text-sm",b),children:"Forge treats Screen Time as reflective evidence, not as fake exact foreground traces. Movement overlap is estimated from hourly bins and stays truthful about that."})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["day","month","all_time"].map(s=>e.jsx(U,{variant:"ghost",className:t===s?"h-9 rounded-full border border-[color-mix(in_srgb,var(--success)_35%,var(--ui-border-subtle)_65%)] bg-[var(--ui-success-soft)] px-4 text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 text-[var(--ui-ink-soft)]",onClick:()=>r(s),children:s==="all_time"?"All time":s},s))})]}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-3",children:[e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Today on screen"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:n(o.summary.totalActivitySeconds)}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["Across ",o.summary.activeHourCount," active hours."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Pickups today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:o.summary.pickupCount}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["First pickup"," ",o.summary.firstPickupAt?new Date(o.summary.firstPickupAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"not captured","."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Capture health"}),e.jsx("div",{className:"mt-3 text-lg text-[var(--ui-ink-strong)]",children:a.captureFreshness==="fresh"?a.captureAgeHours!==null?`Updated ${a.captureAgeHours.toFixed(1)}h ago`:"Fresh capture":a.captureFreshness==="stale"?a.captureAgeHours!==null?`Last refresh ${a.captureAgeHours.toFixed(1)}h ago`:"Capture is stale":a.captureFreshness==="unavailable"?"Unavailable":"Waiting for capture"}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:[a.capturedDayCount," days, ",a.capturedHourCount," ","hourly slices, ",a.captureWindowDays," day window."]})]})]}),e.jsx(i,{className:x("mt-3",_),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:B}),e.jsx(l,{tone:"default",className:m,children:"Hourly model"}),e.jsx(l,{tone:"default",className:m,children:ie(a.lastCaptureStartedAt,a.lastCaptureEndedAt,"No captured range yet")}),I.map(s=>e.jsx(l,{tone:"default",className:Z,children:s},s))]})})]}),t==="day"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Hourly rhythm"}),e.jsx("div",{className:x("mt-2 text-sm",b),children:"Activity, pickups, and notification pressure across the day."}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:o.hourlySegments,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"hourIndex",tickFormatter:R,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>R(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:ee,fill:se,strokeWidth:2}),e.jsx(k,{type:"monotone",dataKey:"pickupCount",stroke:M,fill:W,strokeWidth:1.6})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top apps"}),e.jsx("div",{className:"mt-4 space-y-3",children:o.topApps.slice(0,6).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:s.displayName||s.bundleIdentifier}),e.jsx("div",{className:"truncate text-xs text-[var(--ui-ink-faint)]",children:s.categoryLabel||s.bundleIdentifier})]}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:n(s.totalActivitySeconds)})]},s.id))})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:o.topCategories.slice(0,8).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null,t==="month"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Monthly drift"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:g.days,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"dateKey",stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:te,fill:ae,strokeWidth:2})]})})})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Month summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(g.totals.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Pickups"}),e.jsx("span",{children:g.totals.pickupCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Notifications"}),e.jsx("span",{children:g.totals.notificationCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Active days"}),e.jsx("span",{children:g.totals.activeDays})]})]})]})]}):null,t==="all_time"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Weekday pattern"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:u.weekdayPattern,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"weekday",tickFormatter:$,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>$(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"averageActivitySeconds",stroke:M,fill:W,strokeWidth:2})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Lifetime summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Days captured"}),e.jsx("span",{children:u.summary.dayCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(u.summary.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Average per day"}),e.jsx("span",{children:n(u.summary.averageDailyActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total pickups"}),e.jsx("span",{children:u.summary.totalPickups})]})]})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Dominant categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:u.topCategories.slice(0,10).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null]})}export{pe as PsycheScreenTimePage};
|
|
1
|
+
import{r as E,j as e}from"./vendor-BwL6m4SE.js";import{i as N}from"./state-Bpe5dF3T.js";import{S as Q,e as z,k as l,bs as G,C as i,c as x,B as U,cy as V,cz as X,cA as Y,cB as J}from"./index-CQ5r7ZUz.js";import{P as O}from"./page-hero-8bITsx_x.js";import{R as w,A,C,X as L,Y as F,T,a as k}from"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const S="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)] p-5 shadow-[var(--card-shadow)]",_="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",j="min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-5",d="font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="font-label text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",b="text-[var(--ui-ink-soft)]",m="border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",Z="border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",K="var(--ui-border-subtle)",h="var(--ui-ink-faint)",ee="color-mix(in_srgb,var(--success)_82%,var(--primary)_18%)",se="color-mix(in_srgb,var(--success)_18%,transparent)",M="color-mix(in_srgb,var(--info)_86%,var(--primary)_14%)",W="color-mix(in_srgb,var(--info)_16%,transparent)",te="var(--ui-ink-strong)",ae="color-mix(in_srgb,var(--ui-ink-strong)_12%,transparent)",D={background:"var(--ui-surface-modal)",border:"1px solid var(--ui-border-subtle)",borderRadius:"8px",color:"var(--ui-ink-strong)"};function re(t){switch(t){case"fresh":return"border border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]";case"stale":return"border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_74%,var(--ui-ink-strong)_26%)]";case"unavailable":return"border border-[color-mix(in_srgb,var(--danger)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-danger-soft)] text-[color-mix(in_srgb,var(--danger)_74%,var(--ui-ink-strong)_26%)]";default:return m}}function n(t){return t>=3600?`${(t/3600).toFixed(1)}h`:`${Math.round(t/60)}m`}function R(t){return`${String(t).padStart(2,"0")}:00`}function $(t){return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t]??"Day"}function ie(t,r,c){return!t||!r?c:`${new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} → ${new Date(r).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`}function H(t,r){const c=typeof t=="number"?t:typeof t=="string"?Number(t):0;return[r==="totalActivitySeconds"||r==="averageActivitySeconds"?n(c):String(Math.round(c)),r==="totalActivitySeconds"?"Activity":r==="averageActivitySeconds"?"Avg activity":r==="pickupCount"||r==="averagePickups"?r==="averagePickups"?"Avg pickups":"Pickups":r==="averageNotifications"?"Avg notifications":"Notifications"]}function pe(){const[t,r]=E.useState("day"),c=N({queryKey:["forge-screen-time-settings"],queryFn:()=>V().then(s=>s.settings)}),v=N({queryKey:["forge-screen-time-day"],queryFn:()=>X().then(s=>s.screenTime)}),p=N({queryKey:["forge-screen-time-month"],queryFn:()=>Y().then(s=>s.screenTime)}),f=N({queryKey:["forge-screen-time-all-time"],queryFn:()=>J().then(s=>s.screenTime)});if(c.isLoading||v.isLoading||p.isLoading||f.isLoading)return e.jsx(Q,{});const q=c.error??v.error??p.error??f.error;if(q||!c.data||!v.data||!p.data||!f.data)return e.jsx(z,{eyebrow:"Psyche",error:q,onRetry:()=>{c.refetch(),v.refetch(),p.refetch(),f.refetch()}});const a=c.data,o=v.data,g=p.data,u=f.data,I=o.topApps.slice(0,3).map(s=>s.displayName||s.bundleIdentifier),B=typeof a.metadata.snapshot_source=="string"?a.metadata.snapshot_source.replaceAll("_"," "):"device activity report";return e.jsxs("div",{className:"space-y-5",children:[e.jsx(O,{title:"Screen Time",titleText:"Screen Time",description:"Apple-compliant device activity, hourly usage, and reflective phone context woven into Psyche.",actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:a.authorizationStatus.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:m,children:a.captureState.replaceAll("_"," ")}),e.jsx(l,{tone:"default",className:re(a.captureFreshness),children:a.captureFreshness}),e.jsx(l,{tone:"default",className:m,children:a.syncEnabled?"Sync on":"Sync paused"})]})}),e.jsx(G,{}),e.jsxs(i,{className:S,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:d,children:"Reflective device activity"}),e.jsx("div",{className:x("mt-2 max-w-3xl text-sm",b),children:"Forge treats Screen Time as reflective evidence, not as fake exact foreground traces. Movement overlap is estimated from hourly bins and stays truthful about that."})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["day","month","all_time"].map(s=>e.jsx(U,{variant:"ghost",className:t===s?"h-9 rounded-full border border-[color-mix(in_srgb,var(--success)_35%,var(--ui-border-subtle)_65%)] bg-[var(--ui-success-soft)] px-4 text-[color-mix(in_srgb,var(--success)_76%,var(--ui-ink-strong)_24%)]":"h-9 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 text-[var(--ui-ink-soft)]",onClick:()=>r(s),children:s==="all_time"?"All time":s},s))})]}),e.jsxs("div",{className:"mt-5 grid gap-3 md:grid-cols-3",children:[e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Today on screen"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:n(o.summary.totalActivitySeconds)}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["Across ",o.summary.activeHourCount," active hours."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Pickups today"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:o.summary.pickupCount}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:["First pickup"," ",o.summary.firstPickupAt?new Date(o.summary.firstPickupAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"not captured","."]})]}),e.jsxs(i,{className:_,children:[e.jsx("div",{className:P,children:"Capture health"}),e.jsx("div",{className:"mt-3 text-lg text-[var(--ui-ink-strong)]",children:a.captureFreshness==="fresh"?a.captureAgeHours!==null?`Updated ${a.captureAgeHours.toFixed(1)}h ago`:"Fresh capture":a.captureFreshness==="stale"?a.captureAgeHours!==null?`Last refresh ${a.captureAgeHours.toFixed(1)}h ago`:"Capture is stale":a.captureFreshness==="unavailable"?"Unavailable":"Waiting for capture"}),e.jsxs("div",{className:x("mt-2 text-sm",b),children:[a.capturedDayCount," days, ",a.capturedHourCount," ","hourly slices, ",a.captureWindowDays," day window."]})]})]}),e.jsx(i,{className:x("mt-3",_),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(l,{tone:"default",className:m,children:B}),e.jsx(l,{tone:"default",className:m,children:"Hourly model"}),e.jsx(l,{tone:"default",className:m,children:ie(a.lastCaptureStartedAt,a.lastCaptureEndedAt,"No captured range yet")}),I.map(s=>e.jsx(l,{tone:"default",className:Z,children:s},s))]})})]}),t==="day"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Hourly rhythm"}),e.jsx("div",{className:x("mt-2 text-sm",b),children:"Activity, pickups, and notification pressure across the day."}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:o.hourlySegments,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"hourIndex",tickFormatter:R,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>R(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:ee,fill:se,strokeWidth:2}),e.jsx(k,{type:"monotone",dataKey:"pickupCount",stroke:M,fill:W,strokeWidth:1.6})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top apps"}),e.jsx("div",{className:"mt-4 space-y-3",children:o.topApps.slice(0,6).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:s.displayName||s.bundleIdentifier}),e.jsx("div",{className:"truncate text-xs text-[var(--ui-ink-faint)]",children:s.categoryLabel||s.bundleIdentifier})]}),e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:n(s.totalActivitySeconds)})]},s.id))})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Top categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:o.topCategories.slice(0,8).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null,t==="month"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Monthly drift"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:g.days,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"dateKey",stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y))}),e.jsx(k,{type:"monotone",dataKey:"totalActivitySeconds",stroke:te,fill:ae,strokeWidth:2})]})})})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Month summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(g.totals.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Pickups"}),e.jsx("span",{children:g.totals.pickupCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Notifications"}),e.jsx("span",{children:g.totals.notificationCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Active days"}),e.jsx("span",{children:g.totals.activeDays})]})]})]})]}):null,t==="all_time"?e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]",children:[e.jsxs(i,{className:S,children:[e.jsx("div",{className:d,children:"Weekday pattern"}),e.jsx("div",{className:"mt-5 h-72",children:e.jsx(w,{width:"100%",height:"100%",children:e.jsxs(A,{data:u.weekdayPattern,children:[e.jsx(C,{stroke:K,vertical:!1}),e.jsx(L,{dataKey:"weekday",tickFormatter:$,stroke:h,tickLine:!1,axisLine:!1}),e.jsx(F,{stroke:h,tickLine:!1,axisLine:!1,tickFormatter:s=>n(Number(s))}),e.jsx(T,{contentStyle:D,formatter:(s,y)=>H(s,String(y)),labelFormatter:s=>$(Number(s))}),e.jsx(k,{type:"monotone",dataKey:"averageActivitySeconds",stroke:M,fill:W,strokeWidth:2})]})})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Lifetime summary"}),e.jsxs("div",{className:"mt-4 space-y-3 text-sm text-[var(--ui-ink-soft)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Days captured"}),e.jsx("span",{children:u.summary.dayCount})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total activity"}),e.jsx("span",{children:n(u.summary.totalActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Average per day"}),e.jsx("span",{children:n(u.summary.averageDailyActivitySeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Total pickups"}),e.jsx("span",{children:u.summary.totalPickups})]})]})]}),e.jsxs(i,{className:j,children:[e.jsx("div",{className:d,children:"Dominant categories"}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:u.topCategories.slice(0,10).map(s=>e.jsxs(l,{tone:"default",className:m,children:[s.categoryLabel," ·"," ",n(s.totalActivitySeconds)]},s.id))})]})]})]}):null]})}export{pe as PsycheScreenTimePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b6 as It,r as m,j as e,bX as Q,aD as Ct,aG as Re,aT as At,c1 as Be,b3 as Ke}from"./vendor-BwL6m4SE.js";import{j as Ot,i as M,k as W}from"./state-Bpe5dF3T.js";import{E as ie}from"./entity-link-multiselect-Do5DTju7.js";import{n as $,N as qe,p as ze}from"./note-tags-input-DucocvNH.js";import{d as _t,S as Et,e as Mt,B as w,bs as $t,C as Ue,k as f,c as v,I as oe,aA as Ft,T as Lt,cw as Pt,b as He,i as Ve,b2 as Qe,aa as Dt,b1 as Rt,a$ as rt,cx as Bt,b3 as Kt,b4 as qt,b5 as zt,b6 as Ut,b7 as Ht,b9 as Vt}from"./index-DGYIFHgo.js";import{P as Qt}from"./page-hero-BkrRTu-t.js";import{C as Wt}from"./calendar-week-toolbar-BVFb1_2G.js";import{S as le}from"./select-menu-Bl5MILOj.js";import{U as We}from"./user-badge-ap1PvOxd.js";import{U as Yt}from"./user-select-field-fx129Uh6.js";import{s as Ye,b as de,c as Gt,f as Ge,d as Xe}from"./calendar-ui-Cy1XRwzV.js";import{g as Xt,a as Jt}from"./entity-links-DwpxhW2H.js";import{g as Zt,f as ge,a as es,b as N,d as S}from"./user-ownership-DJGl4rAj.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const nt="Self-observation",ts="Forge activity",Z="Entity · ",J="all",ss=[{value:"compact",label:"Compact",description:"One row per entry: time, entity, title."},{value:"informative",label:"Informative",description:"Adds one short preview line and key context."},{value:"extended",label:"Extended",description:"Adds a little more context with a hard text cap."}],rs=[{value:"markdown",label:"Markdown brief",description:"Readable weekly notes for sharing with a therapist."},{value:"csv",label:"CSV table",description:"Structured rows for spreadsheet review."},{value:"json",label:"JSON archive",description:"Full structured payload with filters and metadata."},{value:"ics",label:"Calendar file",description:"Importable weekly timeline in calendar apps."}],Je="box-border min-w-0 max-w-full overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",Y="box-border min-w-0 max-w-full overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",ce="text-[11px] font-medium uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="text-sm font-medium text-[var(--ui-ink-strong)]",Ze="text-[var(--ui-ink-soft)]",ue="text-[var(--ui-ink-faint)]",K="max-w-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",me="max-w-full border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",pe="max-w-full border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_74%,var(--ui-ink-strong)_26%)]",ve="inline-flex max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-xs text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",et="inline-flex max-w-full items-center gap-1 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[11px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",tt="min-w-0 rounded-[8px] border border-dashed border-[var(--ui-border-subtle)] text-left text-sm text-[var(--ui-ink-faint)] transition hover:border-[var(--ui-border-strong)] hover:text-[var(--ui-ink-medium)]",at=new Set(["goal","project","task","strategy","habit","tag","psyche_value","behavior","belief_entry","mode_profile"]),q={noteId:null,contentMarkdown:"",author:"",tags:[],userId:null,observedAtInput:"",linkedPatternIds:[],linkedTriggerReportId:null,linkedEntityValues:[]};function z(n=[]){return $([nt,...n])}function k(n,r){return`${n}:${r}`}function ns(n){const r=n.indexOf(":");if(r<=0||r>=n.length-1)return null;const i=n.slice(0,r);return at.has(i)?{entityType:i,entityId:n.slice(r+1)}:null}function as(n){return n!==null}function is(n){const r=new Set;return n.filter(i=>{const o=`${i.entityType}:${i.entityId}:${i.anchorKey??""}`;return r.has(o)?!1:(r.add(o),!0)})}function it(n){const r=new Date(n);if(Number.isNaN(r.getTime()))return"";const i=r.getFullYear(),o=String(r.getMonth()+1).padStart(2,"0"),x=String(r.getDate()).padStart(2,"0"),h=String(r.getHours()).padStart(2,"0"),_=String(r.getMinutes()).padStart(2,"0");return`${i}-${o}-${x}T${h}:${_}`}function G(n){const r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0");return`${r}-${i}-${o}`}function X(n){return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function U(n,r){const i=n.replace(/\s+/g," ").trim();return i.length<=r?i:`${i.slice(0,Math.max(0,r-3)).trimEnd()}...`}function os(n,r=120){return U(n.contentPlain||n.contentMarkdown,r)}function ot(n){const r=n.note.frontmatter.movement;return!!r&&typeof r=="object"&&!Array.isArray(r)}function T(n){return n.kind==="observation"}function ls(n){return T(n)?n.observation.note.user:n.activity.event.user}function ds(n){if(T(n)){const i=n.observation;return[i.note.contentPlain,i.note.contentMarkdown,i.note.author??"",i.tags.join(" "),i.linkedPatterns.map(o=>o.title).join(" "),i.linkedReports.map(o=>o.title).join(" ")].join(" ").toLowerCase()}const r=n.activity.event;return[r.title,r.description,r.actor??"",r.eventType,r.entityType,n.tags.join(" ")].join(" ").toLowerCase()}function cs(n,r){if(r.length===0)return!0;const i=new Set(n.map(o=>o.toLowerCase()));return r.some(o=>i.has(o.toLowerCase()))}function us(n,r=160){const i=[n.title,n.description].filter(Boolean).join(". ");return U(i,r)}function ms(n,r){const i=n.note.contentPlain||n.note.contentMarkdown;return U(i||"Observation",r)}function ps(n){if(ot(n))return"Movement";const r=n.note.links.find(i=>i.entityType!=="behavior_pattern"&&i.entityType!=="trigger_report");return r?rt(r.entityType):n.linkedPatterns.length>0?"Pattern":n.linkedReports.length>0?"Trigger report":"Observation"}function st(n){const r=n.tags.find(i=>i.startsWith(Z));return r?r.replace(`${Z}`,""):U(n.event.entityType||"Activity",32)}function vs(n){const r=n.filter(i=>i.startsWith(Z)).sort((i,o)=>i.localeCompare(o));return[{value:J,label:"All entities",description:"Show every entity kind across the week."},...r.map(i=>({value:i,label:i.replace(`${Z}`,""),description:`Only entries tagged ${i}.`}))]}function gs(n,r){const i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.download=r,o.click(),URL.revokeObjectURL(i)}function hs(n,r,i){const o=new Date(n),x=new Date(r);return x.setHours(i,Number.isNaN(o.getTime())?0:o.getMinutes(),0,0),x.toISOString()}function xs(n,r){var i;return n?{noteId:n.note.id,contentMarkdown:n.note.contentMarkdown,author:n.note.author??"",tags:$(n.note.tags??[]),userId:n.note.userId??r,observedAtInput:it(n.observedAt),linkedPatternIds:n.linkedPatterns.map(o=>o.id),linkedTriggerReportId:((i=n.linkedReports[0])==null?void 0:i.id)??null,linkedEntityValues:n.note.links.filter(o=>o.entityType!=="behavior_pattern"&&o.entityType!=="trigger_report"&&at.has(o.entityType)).map(o=>k(o.entityType,o.entityId))}:{...q,tags:z(),userId:r}}function bs(n){return n.map(r=>({value:r.id,label:r.title,description:`${r.targetBehavior||r.preferredResponse||"Pattern"}${r.user?` · ${ge(r.user)}`:""}`,searchText:`${r.title} ${r.targetBehavior} ${r.description} ${r.preferredResponse}`.toLowerCase(),kind:"pattern"}))}function fs(n){return n.map(r=>({value:r.id,label:r.title,description:`${r.customEventType||r.eventSituation||"Trigger report"}${r.user?` · ${ge(r.user)}`:""}`,searchText:`${r.title} ${r.customEventType} ${r.eventSituation}`.toLowerCase(),kind:"report"}))}function ys({goals:n,projects:r,tasks:i,strategies:o,habits:x,tags:h,values:_,behaviors:C,beliefs:ee,modes:A}){return[...[...n.map(s=>({value:k("goal",s.id),label:s.title,description:S(s.description,s.user,"Goal"),searchText:N([s.title,s.description??""],s),kind:"goal"})),...r.map(s=>({value:k("project",s.id),label:s.title,description:S(s.description,s.user,"Project"),searchText:N([s.title,s.description??""],s),kind:"project"})),...i.map(s=>({value:k("task",s.id),label:s.title,description:S(s.description,s.user,s.owner??void 0),searchText:N([s.title,s.description??"",s.owner??""],s),kind:"task"})),...o.map(s=>({value:k("strategy",s.id),label:s.title,description:S(s.overview,s.user,"Strategy"),searchText:N([s.title,s.overview??"",s.endStateDescription??""],s),kind:"strategy"})),...x.map(s=>({value:k("habit",s.id),label:s.title,description:S(s.description,s.user,"Habit"),searchText:N([s.title,s.description??""],s),kind:"habit"})),...h.map(s=>({value:k("tag",s.id),label:s.name,description:S(s.description,s.user,s.kind??void 0),searchText:N([s.name,s.kind??"",s.description??""],s)})),..._.map(s=>({value:k("psyche_value",s.id),label:s.title,description:S(s.description,s.user,"Psyche value"),searchText:N([s.title,s.description,s.valuedDirection],s),kind:"value"})),...C.map(s=>({value:k("behavior",s.id),label:s.title,description:S(s.description,s.user,"Behavior"),searchText:N([s.title,s.description,s.kind],s),kind:"behavior"})),...ee.map(s=>({value:k("belief_entry",s.id),label:s.statement,description:S(s.flexibleAlternative||s.originNote,s.user,"Belief"),searchText:N([s.statement,s.flexibleAlternative,s.originNote],s),kind:"belief"})),...A.map(s=>({value:k("mode_profile",s.id),label:s.title,description:S(s.archetype||s.family,s.user,"Mode"),searchText:N([s.title,s.archetype,s.family,s.persona],s),kind:"mode"}))]].sort((s,te)=>s.label.localeCompare(te.label))}function ws(n){return n.note.links.filter(r=>r.entityType!=="behavior_pattern"&&r.entityType!=="trigger_report").slice(0,2).map(r=>e.jsx(f,{className:K,children:rt(r.entityType)},`${n.note.id}-${r.entityType}-${r.entityId}`))}function Bs(){var Oe,_e,Ee,Me,$e,Fe,Le,Pe,De;const n=It(),r=Ot(),i=_t(),o=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],x=Zt(o),[h,_]=m.useState(()=>Ye()),[C,ee]=m.useState([]),[A,he]=m.useState(J),[s,te]=m.useState(""),[F,xe]=m.useState(!1),[D,lt]=m.useState(!0),[R,dt]=m.useState(!0),[y,ct]=m.useState("informative"),[se,ut]=m.useState("markdown"),[mt,E]=m.useState(!1),[u,b]=m.useState({...q,tags:z(),userId:x}),[pt,re]=m.useState(null),be=m.useMemo(()=>de(h,7),[h]),ne=m.useMemo(()=>Gt(h),[h]),fe=m.useMemo(()=>Array.from({length:24},(t,a)=>a),[]),j=M({queryKey:["forge-psyche-self-observation-calendar",h.toISOString(),...o],queryFn:()=>Bt({from:h.toISOString(),to:be.toISOString(),userIds:o})}),ye=M({queryKey:["forge-psyche-values",...o],queryFn:()=>Kt(o)}),we=M({queryKey:["forge-psyche-patterns",...o],queryFn:()=>qt(o)}),ke=M({queryKey:["forge-psyche-behaviors",...o],queryFn:()=>zt(o)}),je=M({queryKey:["forge-psyche-beliefs",...o],queryFn:()=>Ut(o)}),Ne=M({queryKey:["forge-psyche-modes",...o],queryFn:()=>Ht(o)}),Se=M({queryKey:["forge-psyche-reports",...o],queryFn:()=>Vt(o)}),Te=W({mutationFn:()=>Pt({from:h.toISOString(),to:be.toISOString(),userIds:o,tags:$(A===J?C:[...C,A]),includeObservations:D,includeActivity:R,onlyHumanOwned:F,search:s.trim(),format:se}),onSuccess:t=>{gs(t.blob,t.fileName??`forge-self-observation.${se}`)}}),H=W({mutationFn:async t=>{const a=ze(t.observedAtInput)??new Date().toISOString(),d=is([...t.linkedEntityValues.map(l=>ns(l)).filter(as).map(l=>({entityType:l.entityType,entityId:l.entityId,anchorKey:null})),...t.linkedPatternIds.map(l=>({entityType:"behavior_pattern",entityId:l,anchorKey:null})),...t.linkedTriggerReportId?[{entityType:"trigger_report",entityId:t.linkedTriggerReportId,anchorKey:null}]:[]]);return t.noteId?Qe(t.noteId,{contentMarkdown:t.contentMarkdown.trim(),author:t.author.trim()||null,tags:$(t.tags),userId:t.userId,frontmatter:{observedAt:a},links:d}):Dt({contentMarkdown:t.contentMarkdown.trim(),author:t.author.trim()||null,tags:$(t.tags),userId:t.userId,frontmatter:{observedAt:a},links:d})},onSuccess:async()=>{E(!1),b({...q,tags:z(),userId:x}),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),Ve(r),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),vt=W({mutationFn:async({noteId:t,frontmatter:a})=>Qe(t,{frontmatter:a}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})}}),ae=W({mutationFn:t=>Rt(t),onSuccess:async(t,a)=>{u.noteId===a&&(E(!1),b({...q,tags:z(),userId:x})),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),Ve(r),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),V=m.useMemo(()=>{var t;return $([nt,ts,...((t=j.data)==null?void 0:t.calendar.availableTags)??[]])},[(Oe=j.data)==null?void 0:Oe.calendar.availableTags]),gt=m.useMemo(()=>{var t;return bs(((t=we.data)==null?void 0:t.patterns)??[])},[(_e=we.data)==null?void 0:_e.patterns]),ht=m.useMemo(()=>vs(V),[V]),xt=m.useMemo(()=>{var t;return fs(((t=Se.data)==null?void 0:t.reports)??[])},[(Ee=Se.data)==null?void 0:Ee.reports]),bt=m.useMemo(()=>{var t,a,d,l;return ys({goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,tasks:i.snapshot.tasks,strategies:i.snapshot.strategies,habits:i.snapshot.habits,tags:i.snapshot.tags,values:((t=ye.data)==null?void 0:t.values)??[],behaviors:((a=ke.data)==null?void 0:a.behaviors)??[],beliefs:((d=je.data)==null?void 0:d.beliefs)??[],modes:((l=Ne.data)==null?void 0:l.modes)??[]})},[(Me=ke.data)==null?void 0:Me.behaviors,($e=je.data)==null?void 0:$e.beliefs,(Fe=Ne.data)==null?void 0:Fe.modes,i.snapshot.dashboard.projects,i.snapshot.goals,i.snapshot.habits,i.snapshot.strategies,i.snapshot.tags,i.snapshot.tasks,(Le=ye.data)==null?void 0:Le.values]),ft=i.snapshot.users.filter(t=>o.includes(t.id)),yt=o.length===0?"All owners in scope":o.length===1?ge(ft[0]??null):`${o.length} owners selected`,O=m.useMemo(()=>{var d,l;const t=$(A===J?C:[...C,A]);return[...(((d=j.data)==null?void 0:d.calendar.observations)??[]).map(c=>({kind:"observation",id:c.note.id,observedAt:c.observedAt,tags:c.tags,observation:c})),...(((l=j.data)==null?void 0:l.calendar.activity)??[]).map(c=>({kind:"activity",id:c.id,observedAt:c.observedAt,tags:c.tags,activity:c}))].filter(c=>{var I;if(T(c)&&!D||!T(c)&&!R||F&&((I=ls(c))==null?void 0:I.kind)!=="human"||!cs(c.tags,t))return!1;const p=s.trim().toLowerCase();return!(p&&!ds(c).includes(p))}).sort((c,p)=>c.observedAt.localeCompare(p.observedAt))},[A,(Pe=j.data)==null?void 0:Pe.calendar.activity,(De=j.data)==null?void 0:De.calendar.observations,F,s,C,R,D]),wt=m.useMemo(()=>O.filter(T).length,[O]),kt=m.useMemo(()=>O.filter(t=>!T(t)).length,[O]),Ie=m.useMemo(()=>{const t=new Map;for(const a of O){const d=new Date(a.observedAt),l=`${G(d)}:${d.getHours()}`,c=t.get(l)??[];c.push(a),t.set(l,c)}for(const a of t.values())a.sort((d,l)=>d.observedAt.localeCompare(l.observedAt));return t},[O]),Ce=t=>{const a=y==="compact",d=y==="extended",l=ms(t,a?92:d?144:112),c=a?"":os(t.note,d?220:120),p=ps(t),I=d?4:2;return e.jsx("div",{draggable:!a,"data-self-observation-card":t.note.id,onDragStart:g=>{a||(re(t.note.id),g.dataTransfer.setData("text/forge-self-observation-id",t.note.id))},onDragEnd:()=>re(null),className:v("min-w-0 rounded-[8px] border p-3 text-[var(--ui-ink-strong)] transition",ot(t)?"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] hover:bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)]":"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] hover:bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)]",a&&"px-2.5 py-2"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:()=>Nt(t),children:a?e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[e.jsx("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_72%,var(--ui-ink-strong)_28%)]",children:X(t.observedAt)}),e.jsx(f,{className:v("shrink-0",me),children:p}),e.jsx("div",{className:"min-w-0 truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:l})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-2",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_72%,var(--ui-ink-strong)_28%)]",children:X(t.observedAt)}),e.jsx(f,{className:me,children:p}),e.jsx(We,{user:t.note.user,compact:!0})]})}),e.jsx("div",{className:"mt-2 break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:l}),e.jsx("div",{className:v("mt-1 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",d?"line-clamp-3":"line-clamp-1"),children:c}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[t.note.author?e.jsx(f,{className:K,children:t.note.author}):null,t.tags.slice(0,I).map(g=>e.jsx(f,{className:me,children:g},`${t.id}-${g}`)),ws(t),t.linkedPatterns.slice(0,d?2:1).map(g=>e.jsx(He,{kind:"pattern",label:g.title,compact:!0,gradient:!1},g.id)),t.linkedReports.slice(0,1).map(g=>e.jsx(He,{kind:"report",label:g.title,compact:!0,gradient:!1},g.id))]})]})}),a?null:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-danger-soft)] hover:text-[color-mix(in_srgb,var(--danger)_74%,var(--ui-ink-strong)_26%)]","aria-label":`Delete observation ${t.note.id}`,onClick:g=>{g.stopPropagation(),ae.mutateAsync(t.note.id)},children:e.jsx(Be,{className:"size-3.5"})})]})},t.id)},Ae=t=>{const a=y==="compact",d=y==="extended",l=Xt(t.event),c=Jt(t.event),p=U(t.event.title||"Forge activity",a?92:d?144:112),I=a?"":us(t.event,d?220:120),g=d?4:2;return e.jsx("div",{role:a&&l?"button":void 0,tabIndex:a&&l?0:void 0,className:v("min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",a&&"px-2.5 py-2",a&&l&&"cursor-pointer"),onClick:a&&l?()=>n(l):void 0,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:a?e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[e.jsx("div",{className:v("shrink-0 text-[11px] uppercase tracking-[0.16em]",ue),children:X(t.observedAt)}),e.jsx(f,{className:v("shrink-0",pe),children:st(t)}),e.jsx("div",{className:"min-w-0 truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:p})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:v("text-xs uppercase tracking-[0.16em]",ue),children:X(t.observedAt)}),e.jsx(f,{className:pe,children:st(t)}),e.jsx(We,{user:t.event.user,compact:!0})]}),e.jsx("div",{className:"mt-2 break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:p}),t.event.description?e.jsx("div",{className:v("mt-1 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",d?"line-clamp-3":"line-clamp-1"),children:I}):null,e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:t.tags.slice(0,g).map(B=>e.jsx(f,{className:K,children:B},`${t.id}-${B}`))})]})}),!a&&l&&c?e.jsxs(w,{size:"sm",variant:"secondary",onClick:()=>n(l),className:"shrink-0",children:[e.jsx(Ke,{className:"size-4"}),c]}):null]})},t.id)},jt=t=>{b({...q,userId:x,tags:z(),observedAtInput:t?it(t.toISOString()):""})},L=(t,a)=>{const d=new Date(t);d.setHours(a,0,0,0),jt(d),E(!0)},Nt=t=>{b(xs(t,x)),E(!0)},St=async(t,a,d)=>{await vt.mutateAsync({noteId:t.note.id,frontmatter:{...t.note.frontmatter,observedAt:hs(t.observedAt,a,d)}})},Tt=async()=>{const t=await H.mutateAsync(u),a=new URLSearchParams;a.set("create","1"),a.set("sourceObservationNoteId",t.note.id),t.note.userId&&a.set("userId",t.note.userId),n(`/psyche/patterns?${a.toString()}`)};return j.isLoading?e.jsx(Et,{}):j.isError?e.jsx(Mt,{eyebrow:"Self Observation",error:j.error,onRetry:()=>void j.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Qt,{title:"Self Observation",titleText:"Self Observation",description:"Map handwritten reflections and lower-priority Forge activity onto the real week by hour, so the calendar shows both what you noticed and what the system recorded you doing.",badge:`${O.length} visible this week`,actions:e.jsxs(w,{onClick:()=>L(new Date,new Date().getHours()),children:[e.jsx(Q,{className:"size-4"}),"Add observation"]})}),e.jsx($t,{}),e.jsxs(Ue,{className:v("grid gap-4 p-5",Je),children:[e.jsx(Wt,{eyebrow:"Observation week",description:"True self-observation stays primary. Forge activity sits underneath it as supporting context, so you can review the week as lived evidence and export exactly the slice you want to share.",weekStart:h,badges:e.jsxs(e.Fragment,{children:[e.jsx(f,{className:K,children:yt}),e.jsxs(f,{className:"max-w-full border border-[color-mix(in_srgb,var(--success)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[wt," observations"]}),e.jsxs(f,{className:pe,children:[kt," activity"]}),e.jsx(f,{className:K,children:F?"Human-owned only":"All owners"})]}),onPrevious:()=>_(de(h,-7)),onCurrent:()=>_(Ye()),onNext:()=>_(de(h,7))}),e.jsxs("div",{className:"grid min-w-0 max-w-full gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.8fr)]",children:[e.jsxs("div",{className:v("grid min-w-0 w-full max-w-[calc(100vw-4rem)] box-border gap-3 p-4 sm:max-w-full",Y),children:[e.jsxs("div",{children:[e.jsx("div",{className:ce,children:"Filter timeline"}),e.jsx("div",{className:v("mt-1 break-words text-sm [overflow-wrap:anywhere]",Ze),children:"Search the week, focus a specific entity kind, switch density, and narrow the timeline before you review it."})]}),e.jsxs("div",{className:"grid min-w-0 max-w-full gap-3 lg:grid-cols-[minmax(0,1.1fr)_minmax(15rem,0.8fr)_minmax(15rem,0.8fr)]",children:[e.jsx(oe,{value:s,onChange:t=>te(t.target.value),placeholder:"Search notes, authors, activity, or entity labels"}),e.jsx(le,{label:"Entity kind",value:A,options:ht,onChange:he}),e.jsx(le,{label:"Entry view",value:y,options:ss,onChange:ct})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:ce,children:"Extra tags"}),e.jsx("div",{className:v("break-words text-xs [overflow-wrap:anywhere]",ue),children:"Add narrower filters like `focus`, `Forge activity`, or `Source · UI`."}),e.jsx(qe,{value:C,onChange:ee,availableTags:V,placeholder:"Filter by tag"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{variant:D?"primary":"ghost",onClick:()=>lt(t=>!t),children:D?"Hide observations":"Show observations"}),e.jsx(w,{variant:R?"secondary":"ghost",onClick:()=>dt(t=>!t),children:R?"Hide Forge activity":"Show Forge activity"}),e.jsx(w,{variant:F?"secondary":"primary",onClick:()=>xe(!1),children:"All owners"}),e.jsx(w,{variant:F?"primary":"ghost",onClick:()=>xe(!0),children:"Human only"})]})]}),e.jsxs("div",{className:v("grid min-w-0 w-full max-w-[calc(100vw-4rem)] box-border gap-3 p-4 sm:max-w-full",Y),children:[e.jsxs("div",{className:"min-w-0 max-w-full",children:[e.jsx("div",{className:ce,children:"Export week"}),e.jsx("div",{className:v("mt-1 break-words text-sm [overflow-wrap:anywhere]",Ze),children:"Export respects the current search, entity, tag, owner, and observation/activity filters."})]}),e.jsx(le,{label:"Export format",value:se,options:rs,onChange:ut}),e.jsxs(w,{variant:"secondary",pending:Te.isPending,pendingLabel:"Exporting",onClick:()=>void Te.mutateAsync(),children:[e.jsx(Ct,{className:"size-4"}),"Export week"]})]})]})]}),e.jsxs(Ue,{className:v("min-w-0 overflow-hidden p-0",Je),children:[e.jsx("div",{className:"hidden overflow-x-auto lg:block",children:e.jsxs("div",{className:"min-w-[76rem]",children:[e.jsxs("div",{className:"grid grid-cols-[5rem_repeat(7,minmax(10rem,1fr))] border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsx("div",{className:"border-r border-[var(--ui-border-subtle)] px-3 py-4 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hour"}),ne.map(t=>e.jsxs("div",{className:"border-r border-[var(--ui-border-subtle)] px-3 py-4 last:border-r-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:Ge(t)}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:G(t)})]},t.toISOString()))]}),fe.map(t=>e.jsxs("div",{className:"grid grid-cols-[5rem_repeat(7,minmax(10rem,1fr))] border-b border-[var(--ui-border-subtle)] last:border-b-0",children:[e.jsx("div",{className:"border-r border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-4 text-sm text-[var(--ui-ink-soft)]",children:Xe(t)}),ne.map(a=>{const l=`${G(a)}:${t}`,c=Ie.get(l)??[];return e.jsx("div",{"data-self-observation-slot":l,className:v("border-r border-[var(--ui-border-subtle)] px-2 py-2 last:border-r-0",y==="compact"?"min-h-[4.25rem]":y==="extended"?"min-h-[7rem]":"min-h-[5.5rem]"),onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault();const I=p.dataTransfer.getData("text/forge-self-observation-id")||pt;if(!I)return;const g=O.find(B=>T(B)&&B.observation.note.id===I);!g||!T(g)||(St(g.observation,a,t),re(null))},children:e.jsxs("div",{className:"grid gap-2",children:[c.length>0?e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{type:"button",className:et,onClick:()=>L(a,t),children:[e.jsx(Q,{className:"size-3.5"}),"Add"]})}):null,c.map(p=>T(p)?Ce(p.observation):Ae(p.activity)),c.length===0?e.jsx("button",{type:"button",className:v(tt,y==="compact"?"px-3 py-2":"px-3 py-4"),onClick:()=>L(a,t),children:y==="compact"?"Add":"Add observation"}):null]})},l)})]},t))]})}),e.jsx("div",{className:"grid gap-4 p-4 lg:hidden",children:ne.map(t=>{const a=G(t);return e.jsxs("div",{className:v("p-3",Y),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 rounded-[8px] bg-[var(--ui-surface-2)] px-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Ge(t)}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:a})]}),e.jsxs(w,{size:"sm",variant:"secondary",onClick:()=>L(t,new Date().getHours()),children:[e.jsx(Q,{className:"size-4"}),"Add"]})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:fe.map(d=>{const l=`${a}:${d}`,c=Ie.get(l)??[];return e.jsxs("div",{"data-self-observation-slot-mobile":l,className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:Xe(d)}),e.jsxs("button",{type:"button",className:et,onClick:()=>L(t,d),children:[e.jsx(Q,{className:"size-3.5"}),"Add"]})]}),e.jsx("div",{className:"mt-2 grid gap-2",children:c.length===0?e.jsx("button",{type:"button",className:v(tt,y==="compact"?"px-3 py-2":"px-3 py-3"),onClick:()=>L(t,d),children:y==="compact"?"Add":"Add observation"}):c.map(p=>T(p)?Ce(p.observation):Ae(p.activity))})]},l)})})]},a)})})]}),e.jsx(Ft,{open:mt,onOpenChange:E,eyebrow:"Self Observation",title:u.noteId?"Edit observation":"Add observation",description:"Capture the note, set the exact observation time, then attach the pattern, trigger report, and any other Forge records that belong to that moment.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx(Yt,{value:u.userId,users:i.snapshot.users,onChange:t=>b(a=>({...a,userId:t})),defaultLabel:es(i.snapshot.users.find(t=>t.id===x)??null,"Choose observation owner"),help:"Observation notes stay multi-user aware just like the rest of Forge."}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Author"}),e.jsx(oe,{value:u.author,onChange:t=>b(a=>({...a,author:t.target.value})),placeholder:"Albert"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Observed at"}),e.jsx(oe,{type:"datetime-local",value:u.observedAtInput,onChange:t=>b(a=>({...a,observedAtInput:t.target.value}))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Observation note"}),e.jsx(Lt,{value:u.contentMarkdown,onChange:t=>b(a=>({...a,contentMarkdown:t.target.value})),className:"min-h-[14rem]",placeholder:"What happened in this hour, what did you notice, and what mattered?"})]}),e.jsx(qe,{value:u.tags,onChange:t=>b(a=>({...a,tags:t})),availableTags:V,placeholder:"Add note tags for the observation"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:P,children:"Linked patterns"}),e.jsxs("button",{type:"button",className:ve,onClick:()=>void Tt(),disabled:H.isPending||u.contentMarkdown.trim().length===0,children:[e.jsx(Re,{className:"size-3.5"}),"Create pattern from observation"]})]}),e.jsx(ie,{options:gt,selectedValues:u.linkedPatternIds,onChange:t=>b(a=>({...a,linkedPatternIds:t})),placeholder:"Search patterns in scope",emptyMessage:"No patterns in scope yet."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:P,children:"Trigger report"}),e.jsxs("button",{type:"button",className:ve,onClick:()=>{const t=new URLSearchParams;t.set("create","1"),u.observedAtInput&&t.set("occurredAt",ze(u.observedAtInput)??new Date().toISOString()),u.userId&&t.set("userId",u.userId),n(`/psyche/reports?${t.toString()}`),E(!1)},children:[e.jsx(Re,{className:"size-3.5"}),"Create report from time"]})]}),e.jsx(ie,{options:xt,selectedValues:u.linkedTriggerReportId?[u.linkedTriggerReportId]:[],onChange:t=>b(a=>({...a,linkedTriggerReportId:t.at(-1)??null})),placeholder:"Search trigger reports in scope",emptyMessage:"No trigger reports in scope yet."})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:P,children:"Linked records"}),e.jsx(ie,{options:bt,selectedValues:u.linkedEntityValues,onChange:t=>b(a=>({...a,linkedEntityValues:t})),placeholder:"Link goals, projects, tasks, values, beliefs, modes, or other Forge records",emptyMessage:"No linked records in scope yet."})]}),e.jsxs("div",{className:v("px-4 py-4",Y),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 break-words text-sm text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:[e.jsx(At,{className:"size-4 text-[var(--tertiary)]"}),"Cards appear in the hourly week grid at the exact observation time, whether they came from deliberate reflection or rolling movement sync."]}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"Move them later by drag-and-drop, edit the timestamp directly here, or delete them from the card itself when the observation should not stay on the calendar."})]}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.noteId?e.jsxs(w,{variant:"secondary",pending:ae.isPending,pendingLabel:"Deleting",onClick:()=>u.noteId?void ae.mutateAsync(u.noteId):void 0,children:[e.jsx(Be,{className:"size-4"}),"Delete observation"]}):null,u.linkedTriggerReportId?e.jsxs("button",{type:"button",className:v(ve,"py-2 text-sm"),onClick:()=>n(`/psyche/reports/${u.linkedTriggerReportId}`),children:[e.jsx(Ke,{className:"size-4"}),"Open linked report"]}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{variant:"secondary",onClick:()=>E(!1),children:"Cancel"}),e.jsx(w,{pending:H.isPending,pendingLabel:"Saving",disabled:u.contentMarkdown.trim().length===0,onClick:()=>void H.mutateAsync(u),children:"Save observation"})]})]})]})})]})}export{Bs as PsycheSelfObservationPage};
|
|
1
|
+
import{b6 as It,r as m,j as e,bX as Q,aD as Ct,aG as Re,aT as At,c1 as Be,b3 as Ke}from"./vendor-BwL6m4SE.js";import{j as Ot,i as M,k as W}from"./state-Bpe5dF3T.js";import{E as ie}from"./entity-link-multiselect-DcCvkesQ.js";import{n as $,N as qe,p as ze}from"./note-tags-input-C_x5WdK5.js";import{d as _t,S as Et,e as Mt,B as w,bs as $t,C as Ue,k as f,c as v,I as oe,aA as Ft,T as Lt,cw as Pt,b as He,i as Ve,b2 as Qe,aa as Dt,b1 as Rt,a$ as rt,cx as Bt,b3 as Kt,b4 as qt,b5 as zt,b6 as Ut,b7 as Ht,b9 as Vt}from"./index-CQ5r7ZUz.js";import{P as Qt}from"./page-hero-8bITsx_x.js";import{C as Wt}from"./calendar-week-toolbar-_NzeKsYx.js";import{S as le}from"./select-menu-BOF-k4Ln.js";import{U as We}from"./user-badge-CZWtYeMw.js";import{U as Yt}from"./user-select-field-fx129Uh6.js";import{s as Ye,b as de,c as Gt,f as Ge,d as Xe}from"./calendar-ui-Cy1XRwzV.js";import{g as Xt,a as Jt}from"./entity-links-DwpxhW2H.js";import{g as Zt,f as ge,a as es,b as N,d as S}from"./user-ownership-DJGl4rAj.js";import"./use-anchored-overlay-position-BY4kNzPj.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const nt="Self-observation",ts="Forge activity",Z="Entity · ",J="all",ss=[{value:"compact",label:"Compact",description:"One row per entry: time, entity, title."},{value:"informative",label:"Informative",description:"Adds one short preview line and key context."},{value:"extended",label:"Extended",description:"Adds a little more context with a hard text cap."}],rs=[{value:"markdown",label:"Markdown brief",description:"Readable weekly notes for sharing with a therapist."},{value:"csv",label:"CSV table",description:"Structured rows for spreadsheet review."},{value:"json",label:"JSON archive",description:"Full structured payload with filters and metadata."},{value:"ics",label:"Calendar file",description:"Importable weekly timeline in calendar apps."}],Je="box-border min-w-0 max-w-full overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-section)]",Y="box-border min-w-0 max-w-full overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",ce="text-[11px] font-medium uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",P="text-sm font-medium text-[var(--ui-ink-strong)]",Ze="text-[var(--ui-ink-soft)]",ue="text-[var(--ui-ink-faint)]",K="max-w-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-medium)]",me="max-w-full border border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] text-[color-mix(in_srgb,var(--info)_74%,var(--ui-ink-strong)_26%)]",pe="max-w-full border border-[color-mix(in_srgb,var(--warning)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-warning-soft)] text-[color-mix(in_srgb,var(--warning)_74%,var(--ui-ink-strong)_26%)]",ve="inline-flex max-w-full items-center gap-2 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1.5 text-xs text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",et="inline-flex max-w-full items-center gap-1 rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[11px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",tt="min-w-0 rounded-[8px] border border-dashed border-[var(--ui-border-subtle)] text-left text-sm text-[var(--ui-ink-faint)] transition hover:border-[var(--ui-border-strong)] hover:text-[var(--ui-ink-medium)]",at=new Set(["goal","project","task","strategy","habit","tag","psyche_value","behavior","belief_entry","mode_profile"]),q={noteId:null,contentMarkdown:"",author:"",tags:[],userId:null,observedAtInput:"",linkedPatternIds:[],linkedTriggerReportId:null,linkedEntityValues:[]};function z(n=[]){return $([nt,...n])}function k(n,r){return`${n}:${r}`}function ns(n){const r=n.indexOf(":");if(r<=0||r>=n.length-1)return null;const i=n.slice(0,r);return at.has(i)?{entityType:i,entityId:n.slice(r+1)}:null}function as(n){return n!==null}function is(n){const r=new Set;return n.filter(i=>{const o=`${i.entityType}:${i.entityId}:${i.anchorKey??""}`;return r.has(o)?!1:(r.add(o),!0)})}function it(n){const r=new Date(n);if(Number.isNaN(r.getTime()))return"";const i=r.getFullYear(),o=String(r.getMonth()+1).padStart(2,"0"),x=String(r.getDate()).padStart(2,"0"),h=String(r.getHours()).padStart(2,"0"),_=String(r.getMinutes()).padStart(2,"0");return`${i}-${o}-${x}T${h}:${_}`}function G(n){const r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0");return`${r}-${i}-${o}`}function X(n){return new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function U(n,r){const i=n.replace(/\s+/g," ").trim();return i.length<=r?i:`${i.slice(0,Math.max(0,r-3)).trimEnd()}...`}function os(n,r=120){return U(n.contentPlain||n.contentMarkdown,r)}function ot(n){const r=n.note.frontmatter.movement;return!!r&&typeof r=="object"&&!Array.isArray(r)}function T(n){return n.kind==="observation"}function ls(n){return T(n)?n.observation.note.user:n.activity.event.user}function ds(n){if(T(n)){const i=n.observation;return[i.note.contentPlain,i.note.contentMarkdown,i.note.author??"",i.tags.join(" "),i.linkedPatterns.map(o=>o.title).join(" "),i.linkedReports.map(o=>o.title).join(" ")].join(" ").toLowerCase()}const r=n.activity.event;return[r.title,r.description,r.actor??"",r.eventType,r.entityType,n.tags.join(" ")].join(" ").toLowerCase()}function cs(n,r){if(r.length===0)return!0;const i=new Set(n.map(o=>o.toLowerCase()));return r.some(o=>i.has(o.toLowerCase()))}function us(n,r=160){const i=[n.title,n.description].filter(Boolean).join(". ");return U(i,r)}function ms(n,r){const i=n.note.contentPlain||n.note.contentMarkdown;return U(i||"Observation",r)}function ps(n){if(ot(n))return"Movement";const r=n.note.links.find(i=>i.entityType!=="behavior_pattern"&&i.entityType!=="trigger_report");return r?rt(r.entityType):n.linkedPatterns.length>0?"Pattern":n.linkedReports.length>0?"Trigger report":"Observation"}function st(n){const r=n.tags.find(i=>i.startsWith(Z));return r?r.replace(`${Z}`,""):U(n.event.entityType||"Activity",32)}function vs(n){const r=n.filter(i=>i.startsWith(Z)).sort((i,o)=>i.localeCompare(o));return[{value:J,label:"All entities",description:"Show every entity kind across the week."},...r.map(i=>({value:i,label:i.replace(`${Z}`,""),description:`Only entries tagged ${i}.`}))]}function gs(n,r){const i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.download=r,o.click(),URL.revokeObjectURL(i)}function hs(n,r,i){const o=new Date(n),x=new Date(r);return x.setHours(i,Number.isNaN(o.getTime())?0:o.getMinutes(),0,0),x.toISOString()}function xs(n,r){var i;return n?{noteId:n.note.id,contentMarkdown:n.note.contentMarkdown,author:n.note.author??"",tags:$(n.note.tags??[]),userId:n.note.userId??r,observedAtInput:it(n.observedAt),linkedPatternIds:n.linkedPatterns.map(o=>o.id),linkedTriggerReportId:((i=n.linkedReports[0])==null?void 0:i.id)??null,linkedEntityValues:n.note.links.filter(o=>o.entityType!=="behavior_pattern"&&o.entityType!=="trigger_report"&&at.has(o.entityType)).map(o=>k(o.entityType,o.entityId))}:{...q,tags:z(),userId:r}}function bs(n){return n.map(r=>({value:r.id,label:r.title,description:`${r.targetBehavior||r.preferredResponse||"Pattern"}${r.user?` · ${ge(r.user)}`:""}`,searchText:`${r.title} ${r.targetBehavior} ${r.description} ${r.preferredResponse}`.toLowerCase(),kind:"pattern"}))}function fs(n){return n.map(r=>({value:r.id,label:r.title,description:`${r.customEventType||r.eventSituation||"Trigger report"}${r.user?` · ${ge(r.user)}`:""}`,searchText:`${r.title} ${r.customEventType} ${r.eventSituation}`.toLowerCase(),kind:"report"}))}function ys({goals:n,projects:r,tasks:i,strategies:o,habits:x,tags:h,values:_,behaviors:C,beliefs:ee,modes:A}){return[...[...n.map(s=>({value:k("goal",s.id),label:s.title,description:S(s.description,s.user,"Goal"),searchText:N([s.title,s.description??""],s),kind:"goal"})),...r.map(s=>({value:k("project",s.id),label:s.title,description:S(s.description,s.user,"Project"),searchText:N([s.title,s.description??""],s),kind:"project"})),...i.map(s=>({value:k("task",s.id),label:s.title,description:S(s.description,s.user,s.owner??void 0),searchText:N([s.title,s.description??"",s.owner??""],s),kind:"task"})),...o.map(s=>({value:k("strategy",s.id),label:s.title,description:S(s.overview,s.user,"Strategy"),searchText:N([s.title,s.overview??"",s.endStateDescription??""],s),kind:"strategy"})),...x.map(s=>({value:k("habit",s.id),label:s.title,description:S(s.description,s.user,"Habit"),searchText:N([s.title,s.description??""],s),kind:"habit"})),...h.map(s=>({value:k("tag",s.id),label:s.name,description:S(s.description,s.user,s.kind??void 0),searchText:N([s.name,s.kind??"",s.description??""],s)})),..._.map(s=>({value:k("psyche_value",s.id),label:s.title,description:S(s.description,s.user,"Psyche value"),searchText:N([s.title,s.description,s.valuedDirection],s),kind:"value"})),...C.map(s=>({value:k("behavior",s.id),label:s.title,description:S(s.description,s.user,"Behavior"),searchText:N([s.title,s.description,s.kind],s),kind:"behavior"})),...ee.map(s=>({value:k("belief_entry",s.id),label:s.statement,description:S(s.flexibleAlternative||s.originNote,s.user,"Belief"),searchText:N([s.statement,s.flexibleAlternative,s.originNote],s),kind:"belief"})),...A.map(s=>({value:k("mode_profile",s.id),label:s.title,description:S(s.archetype||s.family,s.user,"Mode"),searchText:N([s.title,s.archetype,s.family,s.persona],s),kind:"mode"}))]].sort((s,te)=>s.label.localeCompare(te.label))}function ws(n){return n.note.links.filter(r=>r.entityType!=="behavior_pattern"&&r.entityType!=="trigger_report").slice(0,2).map(r=>e.jsx(f,{className:K,children:rt(r.entityType)},`${n.note.id}-${r.entityType}-${r.entityId}`))}function Bs(){var Oe,_e,Ee,Me,$e,Fe,Le,Pe,De;const n=It(),r=Ot(),i=_t(),o=Array.isArray(i.selectedUserIds)?i.selectedUserIds:[],x=Zt(o),[h,_]=m.useState(()=>Ye()),[C,ee]=m.useState([]),[A,he]=m.useState(J),[s,te]=m.useState(""),[F,xe]=m.useState(!1),[D,lt]=m.useState(!0),[R,dt]=m.useState(!0),[y,ct]=m.useState("informative"),[se,ut]=m.useState("markdown"),[mt,E]=m.useState(!1),[u,b]=m.useState({...q,tags:z(),userId:x}),[pt,re]=m.useState(null),be=m.useMemo(()=>de(h,7),[h]),ne=m.useMemo(()=>Gt(h),[h]),fe=m.useMemo(()=>Array.from({length:24},(t,a)=>a),[]),j=M({queryKey:["forge-psyche-self-observation-calendar",h.toISOString(),...o],queryFn:()=>Bt({from:h.toISOString(),to:be.toISOString(),userIds:o})}),ye=M({queryKey:["forge-psyche-values",...o],queryFn:()=>Kt(o)}),we=M({queryKey:["forge-psyche-patterns",...o],queryFn:()=>qt(o)}),ke=M({queryKey:["forge-psyche-behaviors",...o],queryFn:()=>zt(o)}),je=M({queryKey:["forge-psyche-beliefs",...o],queryFn:()=>Ut(o)}),Ne=M({queryKey:["forge-psyche-modes",...o],queryFn:()=>Ht(o)}),Se=M({queryKey:["forge-psyche-reports",...o],queryFn:()=>Vt(o)}),Te=W({mutationFn:()=>Pt({from:h.toISOString(),to:be.toISOString(),userIds:o,tags:$(A===J?C:[...C,A]),includeObservations:D,includeActivity:R,onlyHumanOwned:F,search:s.trim(),format:se}),onSuccess:t=>{gs(t.blob,t.fileName??`forge-self-observation.${se}`)}}),H=W({mutationFn:async t=>{const a=ze(t.observedAtInput)??new Date().toISOString(),d=is([...t.linkedEntityValues.map(l=>ns(l)).filter(as).map(l=>({entityType:l.entityType,entityId:l.entityId,anchorKey:null})),...t.linkedPatternIds.map(l=>({entityType:"behavior_pattern",entityId:l,anchorKey:null})),...t.linkedTriggerReportId?[{entityType:"trigger_report",entityId:t.linkedTriggerReportId,anchorKey:null}]:[]]);return t.noteId?Qe(t.noteId,{contentMarkdown:t.contentMarkdown.trim(),author:t.author.trim()||null,tags:$(t.tags),userId:t.userId,frontmatter:{observedAt:a},links:d}):Dt({contentMarkdown:t.contentMarkdown.trim(),author:t.author.trim()||null,tags:$(t.tags),userId:t.userId,frontmatter:{observedAt:a},links:d})},onSuccess:async()=>{E(!1),b({...q,tags:z(),userId:x}),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),Ve(r),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),vt=W({mutationFn:async({noteId:t,frontmatter:a})=>Qe(t,{frontmatter:a}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]})}}),ae=W({mutationFn:t=>Rt(t),onSuccess:async(t,a)=>{u.noteId===a&&(E(!1),b({...q,tags:z(),userId:x})),await Promise.all([r.invalidateQueries({queryKey:["forge-psyche-self-observation-calendar"]}),Ve(r),r.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),V=m.useMemo(()=>{var t;return $([nt,ts,...((t=j.data)==null?void 0:t.calendar.availableTags)??[]])},[(Oe=j.data)==null?void 0:Oe.calendar.availableTags]),gt=m.useMemo(()=>{var t;return bs(((t=we.data)==null?void 0:t.patterns)??[])},[(_e=we.data)==null?void 0:_e.patterns]),ht=m.useMemo(()=>vs(V),[V]),xt=m.useMemo(()=>{var t;return fs(((t=Se.data)==null?void 0:t.reports)??[])},[(Ee=Se.data)==null?void 0:Ee.reports]),bt=m.useMemo(()=>{var t,a,d,l;return ys({goals:i.snapshot.goals,projects:i.snapshot.dashboard.projects,tasks:i.snapshot.tasks,strategies:i.snapshot.strategies,habits:i.snapshot.habits,tags:i.snapshot.tags,values:((t=ye.data)==null?void 0:t.values)??[],behaviors:((a=ke.data)==null?void 0:a.behaviors)??[],beliefs:((d=je.data)==null?void 0:d.beliefs)??[],modes:((l=Ne.data)==null?void 0:l.modes)??[]})},[(Me=ke.data)==null?void 0:Me.behaviors,($e=je.data)==null?void 0:$e.beliefs,(Fe=Ne.data)==null?void 0:Fe.modes,i.snapshot.dashboard.projects,i.snapshot.goals,i.snapshot.habits,i.snapshot.strategies,i.snapshot.tags,i.snapshot.tasks,(Le=ye.data)==null?void 0:Le.values]),ft=i.snapshot.users.filter(t=>o.includes(t.id)),yt=o.length===0?"All owners in scope":o.length===1?ge(ft[0]??null):`${o.length} owners selected`,O=m.useMemo(()=>{var d,l;const t=$(A===J?C:[...C,A]);return[...(((d=j.data)==null?void 0:d.calendar.observations)??[]).map(c=>({kind:"observation",id:c.note.id,observedAt:c.observedAt,tags:c.tags,observation:c})),...(((l=j.data)==null?void 0:l.calendar.activity)??[]).map(c=>({kind:"activity",id:c.id,observedAt:c.observedAt,tags:c.tags,activity:c}))].filter(c=>{var I;if(T(c)&&!D||!T(c)&&!R||F&&((I=ls(c))==null?void 0:I.kind)!=="human"||!cs(c.tags,t))return!1;const p=s.trim().toLowerCase();return!(p&&!ds(c).includes(p))}).sort((c,p)=>c.observedAt.localeCompare(p.observedAt))},[A,(Pe=j.data)==null?void 0:Pe.calendar.activity,(De=j.data)==null?void 0:De.calendar.observations,F,s,C,R,D]),wt=m.useMemo(()=>O.filter(T).length,[O]),kt=m.useMemo(()=>O.filter(t=>!T(t)).length,[O]),Ie=m.useMemo(()=>{const t=new Map;for(const a of O){const d=new Date(a.observedAt),l=`${G(d)}:${d.getHours()}`,c=t.get(l)??[];c.push(a),t.set(l,c)}for(const a of t.values())a.sort((d,l)=>d.observedAt.localeCompare(l.observedAt));return t},[O]),Ce=t=>{const a=y==="compact",d=y==="extended",l=ms(t,a?92:d?144:112),c=a?"":os(t.note,d?220:120),p=ps(t),I=d?4:2;return e.jsx("div",{draggable:!a,"data-self-observation-card":t.note.id,onDragStart:g=>{a||(re(t.note.id),g.dataTransfer.setData("text/forge-self-observation-id",t.note.id))},onDragEnd:()=>re(null),className:v("min-w-0 rounded-[8px] border p-3 text-[var(--ui-ink-strong)] transition",ot(t)?"border-[color-mix(in_srgb,var(--info)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-info-soft)] hover:bg-[color-mix(in_srgb,var(--info)_12%,var(--ui-surface-1)_88%)]":"border-[color-mix(in_srgb,var(--success)_30%,var(--ui-border-subtle)_70%)] bg-[var(--ui-success-soft)] hover:bg-[color-mix(in_srgb,var(--success)_12%,var(--ui-surface-1)_88%)]",a&&"px-2.5 py-2"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:()=>Nt(t),children:a?e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[e.jsx("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_72%,var(--ui-ink-strong)_28%)]",children:X(t.observedAt)}),e.jsx(f,{className:v("shrink-0",me),children:p}),e.jsx("div",{className:"min-w-0 truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:l})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-2",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[color-mix(in_srgb,var(--success)_72%,var(--ui-ink-strong)_28%)]",children:X(t.observedAt)}),e.jsx(f,{className:me,children:p}),e.jsx(We,{user:t.note.user,compact:!0})]})}),e.jsx("div",{className:"mt-2 break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:l}),e.jsx("div",{className:v("mt-1 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",d?"line-clamp-3":"line-clamp-1"),children:c}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[t.note.author?e.jsx(f,{className:K,children:t.note.author}):null,t.tags.slice(0,I).map(g=>e.jsx(f,{className:me,children:g},`${t.id}-${g}`)),ws(t),t.linkedPatterns.slice(0,d?2:1).map(g=>e.jsx(He,{kind:"pattern",label:g.title,compact:!0,gradient:!1},g.id)),t.linkedReports.slice(0,1).map(g=>e.jsx(He,{kind:"report",label:g.title,compact:!0,gradient:!1},g.id))]})]})}),a?null:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-danger-soft)] hover:text-[color-mix(in_srgb,var(--danger)_74%,var(--ui-ink-strong)_26%)]","aria-label":`Delete observation ${t.note.id}`,onClick:g=>{g.stopPropagation(),ae.mutateAsync(t.note.id)},children:e.jsx(Be,{className:"size-3.5"})})]})},t.id)},Ae=t=>{const a=y==="compact",d=y==="extended",l=Xt(t.event),c=Jt(t.event),p=U(t.event.title||"Forge activity",a?92:d?144:112),I=a?"":us(t.event,d?220:120),g=d?4:2;return e.jsx("div",{role:a&&l?"button":void 0,tabIndex:a&&l?0:void 0,className:v("min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3 text-[var(--ui-ink-medium)]",a&&"px-2.5 py-2",a&&l&&"cursor-pointer"),onClick:a&&l?()=>n(l):void 0,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:a?e.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[e.jsx("div",{className:v("shrink-0 text-[11px] uppercase tracking-[0.16em]",ue),children:X(t.observedAt)}),e.jsx(f,{className:v("shrink-0",pe),children:st(t)}),e.jsx("div",{className:"min-w-0 truncate text-sm font-medium text-[var(--ui-ink-strong)]",children:p})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:v("text-xs uppercase tracking-[0.16em]",ue),children:X(t.observedAt)}),e.jsx(f,{className:pe,children:st(t)}),e.jsx(We,{user:t.event.user,compact:!0})]}),e.jsx("div",{className:"mt-2 break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:p}),t.event.description?e.jsx("div",{className:v("mt-1 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",d?"line-clamp-3":"line-clamp-1"),children:I}):null,e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:t.tags.slice(0,g).map(B=>e.jsx(f,{className:K,children:B},`${t.id}-${B}`))})]})}),!a&&l&&c?e.jsxs(w,{size:"sm",variant:"secondary",onClick:()=>n(l),className:"shrink-0",children:[e.jsx(Ke,{className:"size-4"}),c]}):null]})},t.id)},jt=t=>{b({...q,userId:x,tags:z(),observedAtInput:t?it(t.toISOString()):""})},L=(t,a)=>{const d=new Date(t);d.setHours(a,0,0,0),jt(d),E(!0)},Nt=t=>{b(xs(t,x)),E(!0)},St=async(t,a,d)=>{await vt.mutateAsync({noteId:t.note.id,frontmatter:{...t.note.frontmatter,observedAt:hs(t.observedAt,a,d)}})},Tt=async()=>{const t=await H.mutateAsync(u),a=new URLSearchParams;a.set("create","1"),a.set("sourceObservationNoteId",t.note.id),t.note.userId&&a.set("userId",t.note.userId),n(`/psyche/patterns?${a.toString()}`)};return j.isLoading?e.jsx(Et,{}):j.isError?e.jsx(Mt,{eyebrow:"Self Observation",error:j.error,onRetry:()=>void j.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Qt,{title:"Self Observation",titleText:"Self Observation",description:"Map handwritten reflections and lower-priority Forge activity onto the real week by hour, so the calendar shows both what you noticed and what the system recorded you doing.",badge:`${O.length} visible this week`,actions:e.jsxs(w,{onClick:()=>L(new Date,new Date().getHours()),children:[e.jsx(Q,{className:"size-4"}),"Add observation"]})}),e.jsx($t,{}),e.jsxs(Ue,{className:v("grid gap-4 p-5",Je),children:[e.jsx(Wt,{eyebrow:"Observation week",description:"True self-observation stays primary. Forge activity sits underneath it as supporting context, so you can review the week as lived evidence and export exactly the slice you want to share.",weekStart:h,badges:e.jsxs(e.Fragment,{children:[e.jsx(f,{className:K,children:yt}),e.jsxs(f,{className:"max-w-full border border-[color-mix(in_srgb,var(--success)_32%,var(--ui-border-subtle)_68%)] bg-[var(--ui-success-soft)] text-[color-mix(in_srgb,var(--success)_74%,var(--ui-ink-strong)_26%)]",children:[wt," observations"]}),e.jsxs(f,{className:pe,children:[kt," activity"]}),e.jsx(f,{className:K,children:F?"Human-owned only":"All owners"})]}),onPrevious:()=>_(de(h,-7)),onCurrent:()=>_(Ye()),onNext:()=>_(de(h,7))}),e.jsxs("div",{className:"grid min-w-0 max-w-full gap-4 xl:grid-cols-[minmax(0,1.4fr)_minmax(18rem,0.8fr)]",children:[e.jsxs("div",{className:v("grid min-w-0 w-full max-w-[calc(100vw-4rem)] box-border gap-3 p-4 sm:max-w-full",Y),children:[e.jsxs("div",{children:[e.jsx("div",{className:ce,children:"Filter timeline"}),e.jsx("div",{className:v("mt-1 break-words text-sm [overflow-wrap:anywhere]",Ze),children:"Search the week, focus a specific entity kind, switch density, and narrow the timeline before you review it."})]}),e.jsxs("div",{className:"grid min-w-0 max-w-full gap-3 lg:grid-cols-[minmax(0,1.1fr)_minmax(15rem,0.8fr)_minmax(15rem,0.8fr)]",children:[e.jsx(oe,{value:s,onChange:t=>te(t.target.value),placeholder:"Search notes, authors, activity, or entity labels"}),e.jsx(le,{label:"Entity kind",value:A,options:ht,onChange:he}),e.jsx(le,{label:"Entry view",value:y,options:ss,onChange:ct})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:ce,children:"Extra tags"}),e.jsx("div",{className:v("break-words text-xs [overflow-wrap:anywhere]",ue),children:"Add narrower filters like `focus`, `Forge activity`, or `Source · UI`."}),e.jsx(qe,{value:C,onChange:ee,availableTags:V,placeholder:"Filter by tag"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{variant:D?"primary":"ghost",onClick:()=>lt(t=>!t),children:D?"Hide observations":"Show observations"}),e.jsx(w,{variant:R?"secondary":"ghost",onClick:()=>dt(t=>!t),children:R?"Hide Forge activity":"Show Forge activity"}),e.jsx(w,{variant:F?"secondary":"primary",onClick:()=>xe(!1),children:"All owners"}),e.jsx(w,{variant:F?"primary":"ghost",onClick:()=>xe(!0),children:"Human only"})]})]}),e.jsxs("div",{className:v("grid min-w-0 w-full max-w-[calc(100vw-4rem)] box-border gap-3 p-4 sm:max-w-full",Y),children:[e.jsxs("div",{className:"min-w-0 max-w-full",children:[e.jsx("div",{className:ce,children:"Export week"}),e.jsx("div",{className:v("mt-1 break-words text-sm [overflow-wrap:anywhere]",Ze),children:"Export respects the current search, entity, tag, owner, and observation/activity filters."})]}),e.jsx(le,{label:"Export format",value:se,options:rs,onChange:ut}),e.jsxs(w,{variant:"secondary",pending:Te.isPending,pendingLabel:"Exporting",onClick:()=>void Te.mutateAsync(),children:[e.jsx(Ct,{className:"size-4"}),"Export week"]})]})]})]}),e.jsxs(Ue,{className:v("min-w-0 overflow-hidden p-0",Je),children:[e.jsx("div",{className:"hidden overflow-x-auto lg:block",children:e.jsxs("div",{className:"min-w-[76rem]",children:[e.jsxs("div",{className:"grid grid-cols-[5rem_repeat(7,minmax(10rem,1fr))] border-b border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsx("div",{className:"border-r border-[var(--ui-border-subtle)] px-3 py-4 text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Hour"}),ne.map(t=>e.jsxs("div",{className:"border-r border-[var(--ui-border-subtle)] px-3 py-4 last:border-r-0",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:Ge(t)}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:G(t)})]},t.toISOString()))]}),fe.map(t=>e.jsxs("div",{className:"grid grid-cols-[5rem_repeat(7,minmax(10rem,1fr))] border-b border-[var(--ui-border-subtle)] last:border-b-0",children:[e.jsx("div",{className:"border-r border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-4 text-sm text-[var(--ui-ink-soft)]",children:Xe(t)}),ne.map(a=>{const l=`${G(a)}:${t}`,c=Ie.get(l)??[];return e.jsx("div",{"data-self-observation-slot":l,className:v("border-r border-[var(--ui-border-subtle)] px-2 py-2 last:border-r-0",y==="compact"?"min-h-[4.25rem]":y==="extended"?"min-h-[7rem]":"min-h-[5.5rem]"),onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault();const I=p.dataTransfer.getData("text/forge-self-observation-id")||pt;if(!I)return;const g=O.find(B=>T(B)&&B.observation.note.id===I);!g||!T(g)||(St(g.observation,a,t),re(null))},children:e.jsxs("div",{className:"grid gap-2",children:[c.length>0?e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{type:"button",className:et,onClick:()=>L(a,t),children:[e.jsx(Q,{className:"size-3.5"}),"Add"]})}):null,c.map(p=>T(p)?Ce(p.observation):Ae(p.activity)),c.length===0?e.jsx("button",{type:"button",className:v(tt,y==="compact"?"px-3 py-2":"px-3 py-4"),onClick:()=>L(a,t),children:y==="compact"?"Add":"Add observation"}):null]})},l)})]},t))]})}),e.jsx("div",{className:"grid gap-4 p-4 lg:hidden",children:ne.map(t=>{const a=G(t);return e.jsxs("div",{className:v("p-3",Y),children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 rounded-[8px] bg-[var(--ui-surface-2)] px-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"break-words text-sm font-medium text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:Ge(t)}),e.jsx("div",{className:"mt-1 text-xs text-[var(--ui-ink-faint)]",children:a})]}),e.jsxs(w,{size:"sm",variant:"secondary",onClick:()=>L(t,new Date().getHours()),children:[e.jsx(Q,{className:"size-4"}),"Add"]})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:fe.map(d=>{const l=`${a}:${d}`,c=Ie.get(l)??[];return e.jsxs("div",{"data-self-observation-slot-mobile":l,className:"min-w-0 rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:Xe(d)}),e.jsxs("button",{type:"button",className:et,onClick:()=>L(t,d),children:[e.jsx(Q,{className:"size-3.5"}),"Add"]})]}),e.jsx("div",{className:"mt-2 grid gap-2",children:c.length===0?e.jsx("button",{type:"button",className:v(tt,y==="compact"?"px-3 py-2":"px-3 py-3"),onClick:()=>L(t,d),children:y==="compact"?"Add":"Add observation"}):c.map(p=>T(p)?Ce(p.observation):Ae(p.activity))})]},l)})})]},a)})})]}),e.jsx(Ft,{open:mt,onOpenChange:E,eyebrow:"Self Observation",title:u.noteId?"Edit observation":"Add observation",description:"Capture the note, set the exact observation time, then attach the pattern, trigger report, and any other Forge records that belong to that moment.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsx(Yt,{value:u.userId,users:i.snapshot.users,onChange:t=>b(a=>({...a,userId:t})),defaultLabel:es(i.snapshot.users.find(t=>t.id===x)??null,"Choose observation owner"),help:"Observation notes stay multi-user aware just like the rest of Forge."}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Author"}),e.jsx(oe,{value:u.author,onChange:t=>b(a=>({...a,author:t.target.value})),placeholder:"Albert"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Observed at"}),e.jsx(oe,{type:"datetime-local",value:u.observedAtInput,onChange:t=>b(a=>({...a,observedAtInput:t.target.value}))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:P,children:"Observation note"}),e.jsx(Lt,{value:u.contentMarkdown,onChange:t=>b(a=>({...a,contentMarkdown:t.target.value})),className:"min-h-[14rem]",placeholder:"What happened in this hour, what did you notice, and what mattered?"})]}),e.jsx(qe,{value:u.tags,onChange:t=>b(a=>({...a,tags:t})),availableTags:V,placeholder:"Add note tags for the observation"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:P,children:"Linked patterns"}),e.jsxs("button",{type:"button",className:ve,onClick:()=>void Tt(),disabled:H.isPending||u.contentMarkdown.trim().length===0,children:[e.jsx(Re,{className:"size-3.5"}),"Create pattern from observation"]})]}),e.jsx(ie,{options:gt,selectedValues:u.linkedPatternIds,onChange:t=>b(a=>({...a,linkedPatternIds:t})),placeholder:"Search patterns in scope",emptyMessage:"No patterns in scope yet."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:P,children:"Trigger report"}),e.jsxs("button",{type:"button",className:ve,onClick:()=>{const t=new URLSearchParams;t.set("create","1"),u.observedAtInput&&t.set("occurredAt",ze(u.observedAtInput)??new Date().toISOString()),u.userId&&t.set("userId",u.userId),n(`/psyche/reports?${t.toString()}`),E(!1)},children:[e.jsx(Re,{className:"size-3.5"}),"Create report from time"]})]}),e.jsx(ie,{options:xt,selectedValues:u.linkedTriggerReportId?[u.linkedTriggerReportId]:[],onChange:t=>b(a=>({...a,linkedTriggerReportId:t.at(-1)??null})),placeholder:"Search trigger reports in scope",emptyMessage:"No trigger reports in scope yet."})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:P,children:"Linked records"}),e.jsx(ie,{options:bt,selectedValues:u.linkedEntityValues,onChange:t=>b(a=>({...a,linkedEntityValues:t})),placeholder:"Link goals, projects, tasks, values, beliefs, modes, or other Forge records",emptyMessage:"No linked records in scope yet."})]}),e.jsxs("div",{className:v("px-4 py-4",Y),children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 break-words text-sm text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:[e.jsx(At,{className:"size-4 text-[var(--tertiary)]"}),"Cards appear in the hourly week grid at the exact observation time, whether they came from deliberate reflection or rolling movement sync."]}),e.jsx("div",{className:"mt-2 break-words text-sm leading-6 text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:"Move them later by drag-and-drop, edit the timestamp directly here, or delete them from the card itself when the observation should not stay on the calendar."})]}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.noteId?e.jsxs(w,{variant:"secondary",pending:ae.isPending,pendingLabel:"Deleting",onClick:()=>u.noteId?void ae.mutateAsync(u.noteId):void 0,children:[e.jsx(Be,{className:"size-4"}),"Delete observation"]}):null,u.linkedTriggerReportId?e.jsxs("button",{type:"button",className:v(ve,"py-2 text-sm"),onClick:()=>n(`/psyche/reports/${u.linkedTriggerReportId}`),children:[e.jsx(Ke,{className:"size-4"}),"Open linked report"]}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(w,{variant:"secondary",onClick:()=>E(!1),children:"Cancel"}),e.jsx(w,{pending:H.isPending,pendingLabel:"Saving",disabled:u.contentMarkdown.trim().length===0,onClick:()=>void H.mutateAsync(u),children:"Save observation"})]})]})]})})]})}export{Bs as PsycheSelfObservationPage};
|