forge-openclaw-plugin 0.2.101 → 0.2.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/activity-page-Dv6X5ZCV.js +1 -0
- package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
- package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
- package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
- package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
- package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
- package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
- package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
- package/dist/assets/goals-page-fsY8NzGB.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
- package/dist/assets/habits-page-COoGz4kj.js +1 -0
- package/dist/assets/index-BAXYM89v.css +1 -0
- package/dist/assets/index-EqQsXoat.js +19 -0
- package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
- package/dist/assets/insights-page-cBd74ObU.js +8 -0
- package/dist/assets/kanban-page-CYav9THw.js +1 -0
- package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
- package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/metric-tile-CMadwnGz.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
- package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
- package/dist/assets/overview-page-CXdWrOV1.js +1 -0
- package/dist/assets/page-hero-ffKzgyW3.js +1 -0
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
- package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
- package/dist/assets/project-collections-qSqp90HN.js +1 -0
- package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
- package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
- package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
- package/dist/assets/projects-page-ptcx6H38.js +1 -0
- package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
- package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
- package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
- package/dist/assets/psyche-graph-EP5GL612.js +1 -0
- package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
- package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
- package/dist/assets/psyche-page-F4tF2W70.js +1 -0
- package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
- package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
- package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
- package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
- package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
- package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
- package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
- package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/schema-badge-FY7818qB.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-DJsCG6rM.js +1 -0
- package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
- package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
- package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
- package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
- package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
- package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
- package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
- package/dist/assets/settings-page-1cArlSPM.js +1 -0
- package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
- package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
- package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
- package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
- package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
- package/dist/assets/sports-page-BldIiclr.js +1 -0
- package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
- package/dist/assets/strategies-page-CaTN99qj.js +1 -0
- package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
- package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
- package/dist/assets/surface-CJI17F3n.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
- package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
- package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
- package/dist/assets/today-page-BjDijtn8.js +1 -0
- package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
- package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
- package/dist/assets/vendor-Dnkkx2co.js +1067 -0
- package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
- package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
- package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
- package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
- package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
- package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
- package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
- package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
- package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
- package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
- package/dist/assets/workout-detail-page-DT-c5cHL.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +125 -33
- package/dist/server/server/src/health-weight-loss.js +554 -77
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +21 -12
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +24 -5
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/activity-page-CpjuNSHw.js +0 -1
- package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
- package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
- package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
- package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
- package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
- package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
- package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
- package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
- package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
- package/dist/assets/execution-board-D07gOocB.js +0 -1
- package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
- package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
- package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
- package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
- package/dist/assets/goals-page-BTk7mg_T.js +0 -1
- package/dist/assets/habits-page-BJxagdzx.js +0 -1
- package/dist/assets/index-CF4J4R9L.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
- package/dist/assets/insights-page-D6rOa7uk.js +0 -8
- package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
- package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
- package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
- package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
- package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
- package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
- package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
- package/dist/assets/notes-page-CKXnF_KU.js +0 -1
- package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
- package/dist/assets/overview-page-1miYqaVS.js +0 -1
- package/dist/assets/page-hero-DRy5b2MU.js +0 -1
- package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
- package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
- package/dist/assets/project-collections-xPz2mlRr.js +0 -1
- package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
- package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
- package/dist/assets/projects-page-C5ViRuf4.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
- package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
- package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
- package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
- package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
- package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
- package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
- package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
- package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
- package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
- package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
- package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
- package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
- package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
- package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
- package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
- package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
- package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-fYyreSdQ.js +0 -1
- package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
- package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
- package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
- package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
- package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
- package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
- package/dist/assets/settings-models-page-D26270R2.js +0 -1
- package/dist/assets/settings-page-DYDTFlnv.js +0 -1
- package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
- package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
- package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
- package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
- package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
- package/dist/assets/strategies-page-C4qvXnql.js +0 -1
- package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
- package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
- package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
- package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
- package/dist/assets/today-page-BKlu6gx5.js +0 -1
- package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/vendor-DHkYh85p.js +0 -1052
- package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
- package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
- package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
- package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
- package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
- package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
- package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
- package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
- package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
- package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,db as V,dc as Y,cr as me,dd as Z,aQ as J,de as xe,aD as ge,cg as he}from"./vendor-DHkYh85p.js";import{j as pe,i as X,k}from"./state-B-4sS1xO.js";import{dA as be,dB as fe,dC as ve,dD as je,dE as ke,dF as ye,j as we,F as Ne,I as ee,c as u,S as Fe,E as ae,B as x,C as y,Z as T,Q as te,f as Se,dx as Re,dG as De}from"./index-CF4J4R9L.js";import{S as Ce}from"./settings-section-nav-DSOuht_F.js";import{P as Be}from"./page-hero-DRy5b2MU.js";import{M as g}from"./metric-tile-DKpo-8xw.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function E(t){if(!Number.isFinite(t)||t<=0)return"0 B";const l=["B","KB","MB","GB","TB"];let n=t,m=0;for(;n>=1024&&m<l.length-1;)n/=1024,m+=1;return`${n.toFixed(n>=100?0:n>=10?1:2)} ${l[m]}`}function Me(t,l){const n=URL.createObjectURL(t),m=document.createElement("a");m.href=n,m.download=l,m.click(),URL.revokeObjectURL(n)}function Ae(t){return t?t===1?"Every hour":t===24?"Every day":t===168?"Every week":`Every ${t} hours`:"Off"}function se(t){switch(t){case"manual":return"Manual";case"automatic":return"Automatic";case"pre_restore":return"Safety backup before restore";case"pre_switch_root":return"Safety backup before folder change";default:return t}}function w(t,l="Unknown time"){if(!t)return l;const n=new Date(t);return Number.isNaN(n.getTime())?l:Se(t)}function Ee({tone:t,message:l}){return e.jsx("div",{className:T("rounded-[20px] border px-4 py-3 text-sm leading-6",t==="success"?"border-emerald-400/20 bg-emerald-500/[0.08] text-emerald-100/88":t==="warning"?"border-amber-400/20 bg-amber-500/[0.08] text-amber-100/88":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)]"),children:l})}function z({label:t,value:l,icon:n}){return e.jsxs("div",{className:"rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:[e.jsx(n,{className:"size-4"}),t]}),e.jsx("div",{className:"mt-3 break-all text-sm leading-6 text-[var(--ui-ink-soft)]",children:l})]})}function Ie(){var G,W;const t=pe(),[l,n]=o.useState(""),[m,$]=o.useState(""),[L,q]=o.useState(""),[O,U]=o.useState(!0),[f,re]=o.useState([]),[P,v]=o.useState(null),[ie,N]=o.useState(!1),[c,F]=o.useState({mode:"migrate_current",targetDataRoot:"",createSafetyBackup:!0}),[ne,j]=o.useState(null),[i,_]=o.useState(null),[K,H]=o.useState({createSafetyBackup:!0}),[oe,R]=o.useState(null),p=X({queryKey:["forge-operator-session"],queryFn:Re}),le=p.isSuccess,S=X({queryKey:["forge-data-management"],queryFn:De,enabled:le}),D=async()=>{await Promise.all([t.invalidateQueries({queryKey:["forge-operator-session"]}),t.invalidateQueries({queryKey:["forge-data-management"]})])},I=k({mutationFn:()=>be({backupDirectory:l,backupFrequencyHours:m==="off"?null:Number(m||"24"),backupRetentionDays:L==="forever"?null:Number(L||"30"),autoRepairEnabled:O}),onSuccess:async()=>{v({tone:"success",message:"Backup settings saved."}),await D()}}),C=k({mutationFn:()=>fe("Manual backup from Settings → Data"),onSuccess:async()=>{v({tone:"success",message:"Backup created."}),await D()}}),B=k({mutationFn:ve,onSuccess:({candidates:a})=>{re(a),v({tone:a.some(d=>d.newerThanCurrent)?"warning":"neutral",message:a.length>0?`Found ${a.length} Forge ${a.length===1?"copy":"copies"} on disk.`:"No other Forge data copies were found in the scanned folders."})}}),M=k({mutationFn:a=>je({targetDataRoot:a.targetDataRoot,mode:a.mode,createSafetyBackup:a.createSafetyBackup}),onSuccess:async()=>{v({tone:"success",message:"Forge is now using the selected data folder."}),N(!1),await D()}}),A=k({mutationFn:({backupId:a,createSafetyBackup:d})=>ke(a,d),onSuccess:async()=>{v({tone:"success",message:"Backup restored. Forge is now running from that restored state."}),_(null),await D()}}),Q=k({mutationFn:async a=>{const d=await ye(a);return Me(d.blob,d.fileName??`forge-export.${a}`),a},onSuccess:a=>{v({tone:"neutral",message:`Started download for ${a}.`})}}),s=(G=S.data)==null?void 0:G.data;o.useEffect(()=>{s&&(n(a=>a||s.settings.backupDirectory),$(a=>a||(s.settings.backupFrequencyHours?String(s.settings.backupFrequencyHours):"off")),U(s.settings.autoRepairEnabled),q(a=>a||(s.settings.backupRetentionDays?String(s.settings.backupRetentionDays):"forever")),F(a=>({...a,targetDataRoot:a.targetDataRoot||s.current.dataRoot})))},[s]);const de=o.useMemo(()=>f.find(a=>a.newerThanCurrent),[f]),h=o.useMemo(()=>f.find(a=>a.dataRoot===c.targetDataRoot.trim()),[c.targetDataRoot,f]),ce=[{id:"mode",eyebrow:"Step 1",title:"What do you want Forge to do?",description:"Choose whether Forge should move the current data into a new folder or switch to a folder that already contains the right Forge data.",render:(a,d)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(we,{value:a.mode,onChange:b=>d({mode:b}),options:[{value:"migrate_current",label:"Move the current data",description:"Copy the live database and local secrets key into a new folder, then switch Forge to it."},{value:"adopt_existing",label:"Use an existing data folder",description:"Keep the target folder as it is and point Forge at that existing database directly."}]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:a.createSafetyBackup,onChange:b=>d({createSafetyBackup:b.target.checked})}),e.jsx("span",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create one safety backup first."})]})]})},{id:"folder",eyebrow:"Step 2",title:c.mode==="migrate_current"?"Choose the new data folder":"Choose the data folder to use",description:c.mode==="migrate_current"?"Pick an empty folder for the moved Forge data.":"Pick the folder that already contains the Forge data you trust.",render:(a,d)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Ne,{label:"Data folder",description:"Forge will place or read the database and backups from here.",children:e.jsx(ee,{value:a.targetDataRoot,onChange:b=>d({targetDataRoot:b.target.value}),placeholder:"/absolute/path/to/forge-data"})}),h?e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Found on this machine"}),e.jsx("div",{className:"mt-2 break-all",children:h.databasePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:h.sourceHint}),e.jsxs(u,{className:"bg-white/[0.08] text-white/78",children:[h.counts.notes," notes"]}),e.jsxs(u,{className:"bg-white/[0.08] text-white/78",children:[h.counts.tasks," tasks"]}),h.newerThanCurrent?e.jsx(u,{className:"bg-amber-500/16 text-amber-100",children:"Newer than the current copy"}):null]})]}):e.jsx("div",{className:"rounded-[22px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:c.mode==="migrate_current"?"Forge will copy the current data into this folder and then switch over.":"If this folder already holds a Forge database, Forge will start using it after you confirm."})]})}],ue=[{id:"review",eyebrow:"Step 1",title:"Review the backup you want to restore",description:"Restoring replaces the current database with the selected backup.",render:(a,d)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:i?w(i.createdAt):"Selected backup"}),e.jsx("div",{className:"mt-2",children:(i==null?void 0:i.note)||"Forge backup archive"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:i?se(i.mode):"Backup"}),e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:i?E(i.sizeBytes):"0 B"}),i!=null&&i.includesWiki?e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:"Includes wiki"}):null]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:a.createSafetyBackup,onChange:b=>d({createSafetyBackup:b.target.checked})}),e.jsx("span",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Create one safety backup of the current state first."})]})]})},{id:"confirm",eyebrow:"Step 2",title:"Confirm the restore",description:"Use this only when you are confident this backup is the state you want back.",render:()=>e.jsx("div",{className:"rounded-[22px] border border-amber-400/20 bg-amber-500/[0.08] p-4 text-sm leading-6 text-amber-100/88",children:"Forge will replace the live database with this backup, then reopen the restored copy."})}];if(p.isLoading||S.isLoading)return e.jsx(Fe,{eyebrow:"Data",title:"Loading data controls",description:"Checking the live data folder, backup plan, and recovery tools.",columns:3,blocks:6});if(p.isError)return e.jsx(ae,{eyebrow:"Data",error:p.error,onRetry:()=>void p.refetch()});if(S.isError||!s)return e.jsx(ae,{eyebrow:"Data",error:S.error??new Error("Forge returned an empty data payload."),onRetry:()=>void S.refetch()});const r=s.current;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mx-auto grid w-full max-w-[1480px] gap-5",children:[e.jsx(Be,{eyebrow:"Data, backups, recovery",title:"Data",description:"See where Forge is saving the live data, keep it protected with backups, look for a newer copy on disk if something goes wrong, and download the database or its structure when you need it.",badge:`${r.integrityOk?"Healthy":"Needs attention"} · ${E(r.databaseSizeBytes)}`,actions:e.jsxs(e.Fragment,{children:[e.jsxs(x,{variant:"secondary",pending:B.isPending,pendingLabel:"Scanning",onClick:()=>void B.mutateAsync(),children:[e.jsx(V,{className:"size-4"}),"Look for other Forge copies"]}),e.jsxs(x,{pending:C.isPending,pendingLabel:"Creating backup",onClick:()=>void C.mutateAsync(),children:[e.jsx(Y,{className:"size-4"}),"Create backup now"]})]})}),e.jsx(Ce,{}),(W=p.data)!=null&&W.session?e.jsxs("div",{className:"rounded-[20px] border border-emerald-400/20 bg-emerald-500/[0.08] px-4 py-3 text-sm text-emerald-100/88",children:["You are managing Forge data as"," ",e.jsx("span",{className:"font-medium text-white",children:p.data.session.actorLabel}),"."]}):null,P?e.jsx(Ee,{tone:P.tone,message:P.message}):null,e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(y,{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Live data folder"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-[var(--ui-ink-strong)]",children:r.dataRoot}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This is the folder Forge is reading and writing right now."})]}),e.jsx(u,{className:T(r.integrityOk?"bg-emerald-500/14 text-emerald-100":"bg-amber-500/14 text-amber-100"),children:r.integrityMessage})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:[e.jsx(z,{label:"Database file",value:r.databasePath,icon:me}),e.jsx(z,{label:"Folder layout",value:r.layout,icon:Z}),e.jsx(z,{label:"Last database change",value:r.databaseLastModifiedAt?w(r.databaseLastModifiedAt):"Unknown",icon:J})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3 xl:grid-cols-6",children:[e.jsx(g,{label:"Notes",value:r.counts.notes}),e.jsx(g,{label:"Goals",value:r.counts.goals}),e.jsx(g,{label:"Projects",value:r.counts.projects}),e.jsx(g,{label:"Tasks",value:r.counts.tasks}),e.jsx(g,{label:"Runs",value:r.counts.taskRuns}),e.jsx(g,{label:"Tags",value:r.counts.tags})]})]}),e.jsxs(y,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex size-11 items-center justify-center rounded-2xl border border-emerald-400/20 bg-emerald-500/[0.12]",children:e.jsx(xe,{className:"size-5 text-emerald-200"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:"Protection plan"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Choose where backups go, how often Forge creates them, and whether scans should call out newer copies found elsewhere on disk."})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsx(g,{label:"Automatic backup",value:Ae(s.settings.backupFrequencyHours),detail:s.settings.lastAutoBackupAt?`Last run ${w(s.settings.lastAutoBackupAt)}`:"No automatic backup recorded yet"}),e.jsx(g,{label:"Manual backup",value:s.settings.lastManualBackupAt?w(s.settings.lastManualBackupAt):"None yet",detail:`${s.backups.length} backup${s.backups.length===1?"":"s"} saved`}),e.jsx(g,{label:"Retention",value:s.settings.backupRetentionDays?`${s.settings.backupRetentionDays} days`:"Keep forever",detail:"Automatic backups only"})]}),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:"Backup folder"}),e.jsx(ee,{value:l,onChange:a=>n(a.target.value)})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Automatic backup"}),e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",value:m||"24",onChange:a=>$(a.target.value),children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"1",children:"Every hour"}),e.jsx("option",{value:"6",children:"Every 6 hours"}),e.jsx("option",{value:"24",children:"Every day"}),e.jsx("option",{value:"168",children:"Every week"})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Keep automatic backups"}),e.jsxs("select",{className:"h-11 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 text-sm text-[var(--ui-ink-strong)] outline-none transition focus:border-[var(--primary)]",value:L||"30",onChange:a=>q(a.target.value),children:[e.jsx("option",{value:"7",children:"7 days"}),e.jsx("option",{value:"14",children:"14 days"}),e.jsx("option",{value:"30",children:"30 days"}),e.jsx("option",{value:"90",children:"90 days"}),e.jsx("option",{value:"365",children:"1 year"}),e.jsx("option",{value:"forever",children:"Keep forever"})]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsx("input",{type:"checkbox",className:"mt-1",checked:O,onChange:a=>U(a.target.checked)}),e.jsx("span",{className:"text-sm leading-6 text-[var(--ui-ink-soft)]",children:"When I scan, point out Forge copies that look newer than the one I am using now."})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(x,{pending:I.isPending,pendingLabel:"Saving",onClick:()=>void I.mutateAsync(),children:"Save backup settings"}),e.jsx(x,{variant:"secondary",pending:C.isPending,pendingLabel:"Creating backup",onClick:()=>void C.mutateAsync(),children:"Create backup now"})]})]})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(y,{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Change data folder"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Move today’s Forge data into a new folder, or switch to another folder that already contains the right Forge database."})]}),e.jsxs("div",{className:"rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:[e.jsx("div",{className:"font-medium text-[var(--ui-ink-strong)]",children:"Current folder"}),e.jsx("div",{className:"mt-2 break-all",children:r.dataRoot}),h?e.jsxs("div",{className:"mt-3 text-sm text-[var(--ui-ink-soft)]",children:["Selected scanned copy: ",h.dataRoot]}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(x,{onClick:()=>{F(a=>({...a,mode:"migrate_current",targetDataRoot:a.targetDataRoot||r.dataRoot})),j(null),N(!0)},children:[e.jsx(Z,{className:"size-4"}),"Move current data"]}),e.jsxs(x,{variant:"secondary",onClick:()=>{F(a=>({...a,mode:"adopt_existing",targetDataRoot:a.targetDataRoot||r.dataRoot})),j(null),N(!0)},children:[e.jsx(J,{className:"size-4"}),"Use existing data folder"]})]})]}),e.jsxs(y,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Downloads"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Download the live database itself, or export a structure and table snapshot in other formats."})]}),e.jsx(ge,{className:"size-5 text-[var(--ui-ink-faint)]"})]}),e.jsx("div",{className:"grid gap-3",children:s.exportOptions.map(a=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:a.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.description})]}),e.jsx(x,{variant:"secondary",pending:Q.isPending,pendingLabel:"Preparing",onClick:()=>void Q.mutateAsync(a.format),children:"Download"})]},a.format))})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(y,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Backup history"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Go back to an older saved state if you need to undo a bad change."})]}),e.jsx(Y,{className:"size-5 text-[var(--ui-ink-faint)]"})]}),e.jsx("div",{className:"grid gap-3",children:s.backups.length===0?e.jsx("div",{className:"rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No backups yet. Create one now so you have a safe restore point."}):s.backups.map(a=>e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:w(a.createdAt)}),e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:se(a.mode)})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:a.note||"Forge backup archive"})]}),e.jsx(x,{variant:"secondary",onClick:()=>{H({createSafetyBackup:!0}),R(null),_(a)},children:"Restore"})]}),e.jsxs("div",{className:"mt-3 grid gap-2 text-xs text-[var(--ui-ink-faint)] md:grid-cols-2",children:[e.jsx("div",{className:"break-all",children:a.archivePath}),e.jsx("div",{children:E(a.sizeBytes)})]})]},a.id))})]}),e.jsxs(y,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Find other Forge copies"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Search common folders on this machine for other Forge databases. Use this when Forge opened the wrong copy or when you think a newer copy exists somewhere else."})]}),e.jsxs(x,{variant:"secondary",pending:B.isPending,pendingLabel:"Scanning",onClick:()=>void B.mutateAsync(),children:[e.jsx(V,{className:"size-4"}),"Scan now"]})]}),e.jsx("div",{className:"grid gap-3",children:f.length===0?e.jsx("div",{className:"rounded-[20px] border border-dashed border-[var(--ui-border-subtle)] px-4 py-6 text-sm text-[var(--ui-ink-soft)]",children:"No scan results yet. Run a scan to compare the live data folder with other Forge copies on disk."}):f.map(a=>e.jsxs("div",{className:T("rounded-[22px] border p-4",a.sameAsCurrent?"border-emerald-400/18 bg-emerald-500/[0.08]":a.newerThanCurrent?"border-amber-400/20 bg-amber-500/[0.08]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]"),children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm font-semibold text-[var(--ui-ink-strong)]",children:a.dataRoot}),e.jsx(u,{className:"bg-white/[0.08] text-white/78",children:a.sourceHint}),a.newerThanCurrent?e.jsx(u,{className:"bg-amber-500/16 text-amber-100",children:"Newer than current"}):null,a.sameAsCurrent?e.jsx(u,{className:"bg-emerald-500/16 text-emerald-100",children:"Current copy"}):null]}),e.jsx("div",{className:"mt-2 break-all text-sm text-[var(--ui-ink-soft)]",children:a.databasePath})]}),a.sameAsCurrent?null:e.jsx(x,{variant:"secondary",onClick:()=>{F({mode:"adopt_existing",targetDataRoot:a.dataRoot,createSafetyBackup:!0}),j(null),N(!0)},children:"Use this folder"})]}),e.jsxs("div",{className:"mt-4 grid gap-2 text-xs text-[var(--ui-ink-faint)] md:grid-cols-5",children:[e.jsx("div",{children:a.integrityMessage}),e.jsx("div",{children:w(a.databaseLastModifiedAt??new Date().toISOString())}),e.jsx("div",{children:E(a.databaseSizeBytes)}),e.jsxs("div",{children:[a.counts.notes," notes"]}),e.jsxs("div",{children:[a.counts.tasks," tasks"]})]})]},a.id))}),de?e.jsxs("div",{className:"flex items-start gap-3 rounded-[20px] border border-amber-400/20 bg-amber-500/[0.08] px-4 py-3 text-sm text-amber-100/88",children:[e.jsx(he,{className:"mt-0.5 size-4 shrink-0"}),e.jsx("div",{children:"Forge found a copy on disk that looks newer than the one you are using now. Review it carefully before switching."})]}):null]})]})]}),e.jsx(te,{open:ie,onOpenChange:a=>{N(a),a||j(null)},eyebrow:"Data folder",title:c.mode==="migrate_current"?"Move Forge data":"Use an existing Forge data folder",description:"This guided flow keeps the folder change explicit and gives you a safety backup option first.",value:c,onChange:F,draftPersistenceKey:`settings.data.root.${c.mode}`,steps:ce,pending:M.isPending,pendingLabel:c.mode==="migrate_current"?"Moving data":"Switching folder",submitLabel:c.mode==="migrate_current"?"Move and switch":"Use this folder",error:ne??(M.error instanceof Error?M.error.message:null),onSubmit:async()=>{if(!c.targetDataRoot.trim()){j("Choose a data folder first.");return}j(null),await M.mutateAsync(c)}}),e.jsx(te,{open:i!==null,onOpenChange:a=>{a||(_(null),R(null))},eyebrow:"Restore backup",title:"Restore Forge backup",description:"This flow replaces the live data with an older saved state.",value:K,onChange:H,draftPersistenceKey:i?`settings.data.restore.${i.id}`:"settings.data.restore",steps:ue,pending:A.isPending,pendingLabel:"Restoring",submitLabel:"Restore this backup",error:oe??(A.error instanceof Error?A.error.message:null),onSubmit:async()=>{if(!i){R("Choose a backup first.");return}R(null),await A.mutateAsync({backupId:i.id,createSafetyBackup:K.createSafetyBackup})}})]})}export{Ie as SettingsDataPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c2 as _,r as c,j as n,cs as q,aK as U,b3 as H,o as V}from"./vendor-DHkYh85p.js";import{x as Q}from"./state-B-4sS1xO.js";import{c as A,S as G,E as J,C as D,B as P,I as W,Z as B,en as Z,eo as X,b as Y,ep as ee}from"./index-CF4J4R9L.js";import{P as te}from"./page-hero-DRy5b2MU.js";import{S as se}from"./settings-section-nav-DSOuht_F.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const ne=["error","warning","info","debug"],re=["server","ui","system","agent","openclaw"],ie=60;function E(t){return t.trim().toLowerCase()}function $(t){return Array.from(new Set(t.map(r=>(r==null?void 0:r.trim())??"").filter(Boolean)))}function S(t,r){const s=$(t.getAll(r));if(s.length>0)return s;const a=t.get(r);return a!=null&&a.trim()?[a.trim()]:[]}function ae(t){return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format(new Date(t))}function K(t){return t==="error"?"border-rose-400/20 bg-rose-500/[0.08] text-rose-100":t==="warning"?"border-amber-400/20 bg-amber-500/[0.08] text-amber-100":t==="info"?"border-sky-400/20 bg-sky-500/[0.08] text-sky-100":"border-white/10 bg-white/[0.04] text-white/68"}function R(t){return t==="error"?"Errors":t==="warning"?"Warnings":t==="info"?"Info":"Debug"}function F(t){return t==="openclaw"?"OpenClaw":t.charAt(0).toUpperCase()+t.slice(1)}function oe(t){return[t.scope?`scope: ${t.scope}`:null,t.eventKey?`event: ${t.eventKey}`:null,t.route?`route: ${t.route}`:null,t.functionName?`function: ${t.functionName}`:null,t.jobId?`job: ${t.jobId}`:null,t.entityType&&t.entityId?`entity: ${t.entityType}:${t.entityId}`:null,t.requestId?`request: ${t.requestId}`:null].filter(r=>!!r)}function le(t){return E([t.message,t.scope,t.eventKey,t.route,t.functionName,t.requestId,t.entityType,t.entityId,t.jobId,JSON.stringify(t.details)].filter(Boolean).join(" "))}function j(t,r){return n.jsx(A,{size:"sm",className:B("bg-white/[0.08] text-white/74",r),children:t})}function z(t,r){return X(t)?n.jsx(Y,{kind:t,label:r,compact:!0,gradient:!1}):j(r,"bg-[rgba(192,193,255,0.12)] text-white/84")}function k({label:t,placeholder:r,options:s,selectedIds:a,onChange:h,emptyMessage:u="No matches yet."}){const[y,d]=c.useState(!1),[f,b]=c.useState(""),[T,w]=c.useState(0),I=c.useRef(null),L=c.useRef(null),M=Z(I,y,{offset:8,preferredMaxHeight:320,minHeight:160}),C=c.useMemo(()=>a.map(i=>s.find(o=>o.id===i)??null).filter(i=>i!==null),[s,a]),p=E(f),x=c.useMemo(()=>{const i=s.filter(o=>!a.includes(o.id));return p?i.filter(o=>E(`${o.label} ${o.description??""} ${o.searchText??""}`).includes(p)).slice(0,10):i.slice(0,10)},[p,s,a]),v=i=>{a.includes(i)||(h([...a,i]),b(""),w(0),d(!1))},O=i=>{h(a.filter(o=>o!==i))};return c.useEffect(()=>{if(!y)return;const i=e=>{var m,g;const l=e.target;(m=I.current)!=null&&m.contains(l)||(g=L.current)!=null&&g.contains(l)||d(!1)},o=e=>{e.key==="Escape"&&d(!1)};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",o)}},[y]),n.jsxs("label",{className:"grid gap-2",children:[n.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-white/45",children:t}),n.jsxs("div",{ref:I,className:"relative rounded-[20px] border border-white/8 bg-white/[0.04] px-3 py-2.5",children:[C.length>0?n.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:C.map(i=>n.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/8 bg-white/[0.05] px-1.5 py-1",children:[i.badge,n.jsx("button",{type:"button",className:"rounded-full p-0.5 text-white/46 transition hover:text-white",onClick:()=>O(i.id),"aria-label":`Remove ${i.label}`,children:n.jsx(U,{className:"size-3"})})]},i.id))}):null,n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(H,{className:"size-3.5 text-white/34"}),n.jsx("input",{value:f,onChange:i=>{b(i.target.value),w(0),d(!0)},onFocus:()=>d(!0),onKeyDown:i=>{if(i.key==="Backspace"&&!f&&a.length>0){O(a[a.length-1]);return}if(i.key==="ArrowDown"){i.preventDefault(),d(!0),w(o=>x.length===0?0:Math.min(x.length-1,o+1));return}if(i.key==="ArrowUp"){i.preventDefault(),w(o=>Math.max(0,o-1));return}if(i.key==="Escape"){d(!1);return}i.key==="Enter"&&x[T]&&(i.preventDefault(),v(x[T].id))},placeholder:r,className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]}),y&&M&&typeof document<"u"?V.createPortal(n.jsx("div",{ref:L,role:"listbox","aria-multiselectable":"true",className:"z-[80] overflow-y-auto overscroll-contain rounded-[20px] border border-white/8 bg-[rgba(8,13,24,0.96)] p-2 shadow-[0_26px_60px_rgba(4,8,18,0.32)] backdrop-blur-xl [webkit-overflow-scrolling:touch]",style:M,children:x.length>0?x.map((i,o)=>n.jsx("button",{type:"button",role:"option","aria-selected":!1,className:B("flex w-full items-start justify-between gap-3 rounded-[16px] px-3 py-2 text-left transition",o===T?"bg-white/[0.1] text-white":"text-white/70 hover:bg-white/[0.06] hover:text-white"),onMouseEnter:()=>w(o),onMouseDown:e=>e.preventDefault(),onClick:()=>v(i.id),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate text-sm font-medium",children:i.menuBadge??i.badge}),i.description?n.jsx("div",{className:"mt-1 text-xs leading-5 text-white/46",children:i.description}):null]})},i.id)):n.jsx("div",{className:"px-3 py-2 text-sm text-white/42",children:u})}),document.body):null]})]})}function ce(t,r){const s=`${r.entityType}:${r.entityId}`;t.has(s)||t.set(s,{id:s,label:r.label,description:r.description,searchText:r.searchText,badge:r.badge,menuBadge:r.menuBadge})}function de(t){const r=new Map;for(const s of t){if(!s.entityType||!s.entityId)continue;const a=`${s.entityType}:${s.entityId}`;if(r.has(a))continue;const h=s.entityType==="wiki_ingest_job"?`Ingest ${s.entityId}`:`${s.entityType} ${s.entityId}`;ce(r,{entityType:s.entityType,entityId:s.entityId,label:h,description:"Seen in diagnostics logs",searchText:E(`${h} ${s.scope} ${s.message} ${s.eventKey}`),badge:z(s.entityType,h),menuBadge:z(s.entityType,h)})}return Array.from(r.values()).sort((s,a)=>s.label.localeCompare(a.label))}const ue=c.memo(function({entry:r}){const[s,a]=c.useState(!1),h=c.useMemo(()=>s&&Object.keys(r.details).length>0?JSON.stringify(r.details,null,2):"",[s,r.details]);return n.jsxs(D,{className:"grid gap-4",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"grid gap-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:B("rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.16em]",K(r.level)),children:r.level}),n.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-white/60",children:r.source}),n.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-white/60",children:r.scope}),r.eventKey?n.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.04] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-white/46",children:r.eventKey}):null]}),n.jsx("div",{className:"text-base font-medium text-white",children:r.message}),n.jsx("div",{className:"flex flex-wrap gap-3 text-xs text-white/45",children:oe(r).map(u=>n.jsx("span",{children:u},u))})]}),n.jsxs("div",{className:"shrink-0 text-right text-xs text-white/40",children:[n.jsx("div",{children:ae(r.createdAt)}),n.jsx("div",{className:"mt-1 font-mono text-[11px]",children:r.id})]})]}),Object.keys(r.details).length>0?n.jsxs("details",{className:"rounded-[18px] border border-white/8 bg-[rgba(7,11,21,0.72)] px-4 py-3",onToggle:u=>a(u.currentTarget.open),children:[n.jsx("summary",{className:"cursor-pointer text-sm text-white/70",children:"View structured details"}),s?n.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-6 text-white/58",children:h}):null]}):null]})});function ve(){const[t,r]=_(),s=c.useMemo(()=>{var g,N;const e=((g=t.get("entityType"))==null?void 0:g.trim())||"",l=((N=t.get("entityId"))==null?void 0:N.trim())||"",m=S(t,"entity");return m.length===0&&e&&l&&m.push(`${e}:${l}`),{search:t.get("search")||"",levels:S(t,"level"),sources:S(t,"source"),scopes:S(t,"scope"),routes:S(t,"route"),jobs:S(t,"jobId"),entities:$(m)}},[t]),a=Q({queryKey:["forge-diagnostic-logs","settings-filters"],initialPageParam:null,queryFn:({pageParam:e})=>ee({limit:ie,beforeCreatedAt:e==null?void 0:e.beforeCreatedAt,beforeId:e==null?void 0:e.beforeId}),getNextPageParam:e=>e.nextCursor,retry:!1,refetchOnWindowFocus:!1}),h=(e,l)=>{const m=new URLSearchParams(t);l.trim()?m.set(e,l.trim()):m.delete(e),r(m,{replace:!0})},u=(e,l,m=[])=>{const g=new URLSearchParams(t);g.delete(e);for(const N of m)g.delete(N);for(const N of $(l))g.append(e,N);r(g,{replace:!0})},y=()=>{const e=new URLSearchParams(t);["search","level","source","scope","route","jobId","entity","entityType","entityId"].forEach(l=>e.delete(l)),r(e,{replace:!0})},d=c.useMemo(()=>{var e;return((e=a.data)==null?void 0:e.pages.flatMap(l=>l.logs))??[]},[a.data]),f=E(s.search),b=c.useRef(null),T=c.useMemo(()=>ne.map(e=>({id:e,label:R(e),searchText:`${e} ${R(e)}`,badge:n.jsx(A,{size:"sm",className:K(e),children:R(e)})})),[]),w=c.useMemo(()=>re.map(e=>({id:e,label:F(e),searchText:`${e} ${F(e)}`,badge:j(F(e))})),[]),I=c.useMemo(()=>$(d.map(e=>e.scope)).map(e=>({id:e,label:e,searchText:e,badge:j(e)})),[d]),L=c.useMemo(()=>$(d.map(e=>e.route)).map(e=>({id:e,label:e,description:"Filter logs to one or more exact routes.",searchText:e,badge:j(e,"max-w-[16rem]"),menuBadge:j(e)})),[d]),M=c.useMemo(()=>$(d.map(e=>e.jobId)).map(e=>({id:e,label:e,description:"Background job or ingest run id.",searchText:e,badge:j(e,"max-w-[14rem]"),menuBadge:j(e)})),[d]),C=c.useMemo(()=>de(d),[d]),p=c.useMemo(()=>d.filter(e=>{if(f&&!le(e).includes(f)||s.levels.length>0&&!s.levels.includes(e.level)||s.sources.length>0&&!s.sources.includes(e.source)||s.scopes.length>0&&!s.scopes.includes(e.scope)||s.routes.length>0&&!s.routes.includes(e.route??"")||s.jobs.length>0&&!s.jobs.includes(e.jobId??""))return!1;if(s.entities.length>0){const l=e.entityType&&e.entityId?`${e.entityType}:${e.entityId}`:"";if(!l||!s.entities.includes(l))return!1}return!0}),[s,f,d]),x=[s.search,s.levels.join("|"),s.sources.join("|"),s.scopes.join("|"),s.routes.join("|"),s.jobs.join("|"),s.entities.join("|")].join("::");c.useEffect(()=>{var e;(e=b.current)==null||e.scrollTo({top:0})},[x]);const v=q({count:p.length,getScrollElement:()=>b.current,estimateSize:()=>260,overscan:8}),O=v.getVirtualItems(),i=()=>{const e=b.current;if(!e||!a.hasNextPage||a.isFetchingNextPage)return;e.scrollHeight-e.scrollTop-e.clientHeight<=800&&a.fetchNextPage()},o=s.levels.length+s.sources.length+s.scopes.length+s.routes.length+s.jobs.length+s.entities.length+(s.search.trim()?1:0);return a.isPending?n.jsx(G,{eyebrow:"Settings",title:"Loading diagnostics",description:"Collecting the latest frontend, backend, and runtime traces.",columns:1,blocks:6}):a.isError?n.jsx(J,{eyebrow:"Settings",error:a.error,onRetry:()=>void a.refetch()}):n.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[n.jsx(te,{title:"Logs",description:"Inspect shared diagnostics from the UI, backend routes, background jobs, and LLM flows.",badge:`${p.length} matching${p.length!==d.length?` · ${d.length} loaded`:""}${a.hasNextPage?" · more available":""}`}),n.jsx(se,{}),n.jsxs(D,{className:"grid gap-4",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Filters"}),n.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:"Use token filters with OR-style badge selections for levels, sources, routes, jobs, scopes, and linked entities. Search still matches the message body and structured details."})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o>0?n.jsxs(P,{variant:"ghost",size:"sm",onClick:y,children:["Clear ",o]}):null,n.jsx(P,{variant:"secondary",size:"sm",onClick:()=>void a.refetch(),pending:a.isRefetching&&!a.isFetchingNextPage,pendingLabel:"Refreshing",children:"Refresh"})]})]}),n.jsxs("label",{className:"grid gap-2",children:[n.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-white/45",children:"Search message or details"}),n.jsx(W,{value:s.search,onChange:e=>h("search",e.target.value),placeholder:"LLM compilation failed, wiki_ingest, request_failed…",className:"h-11 rounded-[20px]"})]}),n.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[n.jsx(k,{label:"Levels",placeholder:"Add one or more levels",options:T,selectedIds:s.levels,onChange:e=>u("level",e),emptyMessage:"No additional log levels."}),n.jsx(k,{label:"Sources",placeholder:"Add one or more sources",options:w,selectedIds:s.sources,onChange:e=>u("source",e),emptyMessage:"No additional log sources."}),n.jsx(k,{label:"Scopes",placeholder:"Search scopes",options:I,selectedIds:s.scopes,onChange:e=>u("scope",e),emptyMessage:"No scopes match the current logs."}),n.jsx(k,{label:"Routes",placeholder:"Search exact routes",options:L,selectedIds:s.routes,onChange:e=>u("route",e),emptyMessage:"No routes match the current logs."}),n.jsx(k,{label:"Jobs",placeholder:"Search job ids",options:M,selectedIds:s.jobs,onChange:e=>u("jobId",e),emptyMessage:"No job ids match the current logs."}),n.jsx(k,{label:"Entities",placeholder:"Search Forge entities or logged ids",options:C,selectedIds:s.entities,onChange:e=>u("entity",e,["entityType","entityId"]),emptyMessage:"No logged entities match yet."})]})]}),n.jsx("div",{className:"grid gap-3",children:p.length===0?n.jsx(D,{className:"text-sm text-white/58",children:"No diagnostic entries match the current filters yet."}):n.jsx(D,{className:"p-0",children:n.jsxs("div",{ref:b,onScroll:i,className:"h-[72vh] overflow-y-auto px-3 py-3",children:[n.jsx("div",{className:"relative",style:{height:`${v.getTotalSize()}px`},children:O.map(e=>{const l=p[e.index];return l?n.jsx("div",{"data-index":e.index,ref:v.measureElement,className:"absolute left-0 top-0 w-full pb-3",style:{transform:`translateY(${e.start}px)`},children:n.jsx(ue,{entry:l})},l.id):null})}),n.jsx("div",{className:"border-t border-white/6 px-1 py-3 text-center text-xs text-white/46",children:a.isFetchingNextPage?"Loading older logs…":a.hasNextPage?"Scroll to load older logs.":`Showing all ${d.length} loaded logs.`})]})})})]})}export{ve as SettingsLogsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as m,di as J,j as e,dj as V,dk as X,cw as q,cx as M,dh as Y,dl as O,dm as Z,bl as H,bF as U,dn as ee,dp as D,aC as C,cb as R,dq as se}from"./vendor-DHkYh85p.js";import{j as te,i as ie,k as f}from"./state-B-4sS1xO.js";import{u as ae,s as ne,ed as re,ee as le,ef as de,eg as oe,S as ce,E as xe,C as A,B as o,c as a,dy as he}from"./index-CF4J4R9L.js";import{S as me}from"./settings-section-nav-DSOuht_F.js";import{P as pe}from"./page-hero-DRy5b2MU.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function ge(t){return t.replaceAll("."," ")}function ue(t){const l=typeof t.sleepNights=="number"?t.sleepNights:typeof t.sleepSessions=="number"?t.sleepSessions:0,p=typeof t.sleepSegments=="number"?t.sleepSegments:0,N=typeof t.sleepRawRecords=="number"?t.sleepRawRecords:0,u=typeof t.sleepSessions=="number"?t.sleepSessions:0,v=typeof t.workouts=="number"?t.workouts:0,c=t.vitals&&typeof t.vitals=="object"&&!Array.isArray(t.vitals)&&typeof t.vitals.metricEntries=="number"?t.vitals.metricEntries:0;return`${l||u} nights · ${p} segments · ${N} raw records · ${v} workouts · ${c} vitals`}function G(t){return t?"signal":"meta"}function ve(t){return t.replaceAll("_"," ")}function we(t){return t?new Date(t).toLocaleString():"Waiting for device update"}function je(t,l){return t?l?"signal":"default":"meta"}function fe(t){return t.transportMode==="iroh"?"Iroh":"Manual HTTP"}function Ne(t){return t.transportMode==="iroh"?"signal":"meta"}function Le(){const t=ae(),l=te(),p=Array.isArray(t.selectedUserIds)?t.selectedUserIds:[],N=ne(p),[u,v]=m.useState(null),[c,b]=m.useState(!1),[y,w]=m.useState(!1),[z,k]=m.useState(!1),[n,$]=m.useState(null),x=ie({queryKey:["forge-companion-overview",...p],queryFn:async()=>(await he(p)).overview}),d=f({mutationFn:async(s="iroh")=>re({userId:N??null,transportMode:s}),onSuccess:async s=>{$({qrPayload:s.qrPayload}),b(!0),await l.invalidateQueries({queryKey:["forge-companion-overview"]})}}),S=f({mutationFn:async s=>le(s),onSuccess:async()=>{await l.invalidateQueries({queryKey:["forge-companion-overview"]})}}),E=f({mutationFn:async()=>de({userIds:p,includeRevoked:!1}),onSuccess:async()=>{await l.invalidateQueries({queryKey:["forge-companion-overview"]})}}),j=f({mutationFn:async s=>oe(s.pairingSessionId,s.source,s.desiredEnabled),onSuccess:async()=>{await l.invalidateQueries({queryKey:["forge-companion-overview"]})}});if(m.useEffect(()=>{if(!n){v(null);return}J.toDataURL(JSON.stringify(n.qrPayload),{width:320,margin:1}).then(v)},[n]),m.useEffect(()=>{w(!1),k(!1)},[n]),x.isLoading)return e.jsx(ce,{eyebrow:"Companion",title:"Loading mobile companion",description:"Checking pairing state and recent sync status.",columns:2,blocks:5});if(x.isError||!x.data)return e.jsx(xe,{eyebrow:"Companion",error:x.error??new Error("Companion overview unavailable"),onRetry:()=>void x.refetch()});const i=x.data,g=i.pairings.filter(s=>s.status!=="revoked"),L=i.pairings.length-g.length,P=n?JSON.stringify(n.qrPayload,null,2):"",K=async()=>{if(n&&c){b(!1);return}if(n&&!c){b(!0);return}await d.mutateAsync("iroh")},_=async()=>{await d.mutateAsync("manual-http")},B=async()=>{if(P){if(!navigator.clipboard){w(!0);return}try{await navigator.clipboard.writeText(P),k(!0),window.setTimeout(()=>k(!1),1800)}catch{w(!0)}}};return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5 pb-24 lg:pb-0",children:[e.jsx(pe,{title:"Mobile companion",description:"Pair the native iPhone companion, sync Apple Health, and keep the bridge open for watch and location signals.",badge:i.healthState.replaceAll("_"," ")}),e.jsx(me,{}),e.jsxs("section",{className:"grid gap-4",children:[null,e.jsxs(A,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Pair iPhone"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Pair your iPhone privately"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:"Forge uses its own Iroh/QUIC companion route by default. Scan once from the iPhone app; manual HTTP stays as the advanced LAN or Tailscale path."})]}),e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:justify-end",children:[e.jsxs(o,{variant:"secondary",className:"w-full sm:w-auto",onClick:()=>void _(),pending:d.isPending&&d.variables==="manual-http",pendingLabel:"Generating",children:[e.jsx(V,{className:"size-4"}),"Advanced HTTP"]}),e.jsxs(o,{className:"w-full sm:w-auto",onClick:()=>void K(),pending:d.isPending&&d.variables!=="manual-http",pendingLabel:"Generating",children:[e.jsx(X,{className:"size-4"}),n?c?"Hide QR":"Show QR":"Generate Forge QR",n?c?e.jsx(q,{className:"size-4"}):e.jsx(M,{className:"size-4"}):null]})]})]}),c?e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.03] p-4 sm:p-5",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(260px,360px)_1fr]",children:[u?e.jsxs("div",{className:"grid justify-items-center gap-4 rounded-[24px] bg-white px-6 py-6 text-slate-950",children:[e.jsx("img",{src:u,alt:"Forge Companion pairing QR code",className:"w-full max-w-[320px]"}),e.jsx("div",{className:"max-w-[320px] text-center text-sm text-slate-600",children:"Scan this code from Forge Companion on iPhone."})]}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-white/10 bg-white/[0.03] px-5 py-8 text-center text-sm text-white/55",children:"Generating the QR code now."}),e.jsxs("div",{className:"grid content-start gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n?e.jsxs(a,{tone:Ne(n.qrPayload),children:[e.jsx(Y,{className:"size-3"}),fe(n.qrPayload)]}):null,e.jsxs(a,{tone:"meta",children:[e.jsx(O,{className:"size-3"}),"One-time token"]})]}),e.jsxs("div",{className:"grid gap-3 text-sm leading-6 text-white/66",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Z,{className:"mt-1 size-4 shrink-0 text-white/45"}),e.jsx("span",{children:"Open Forge Companion and choose Scan Forge QR."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(O,{className:"mt-1 size-4 shrink-0 text-white/45"}),e.jsx("span",{children:"The iPhone receives the desktop node, relay hint, and pairing token for the Forge Iroh route."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(H,{className:"mt-1 size-4 shrink-0 text-white/45"}),e.jsx("span",{children:"After verification, the app moves straight into native permissions and first sync."})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/62",children:n?e.jsxs("span",{children:["Expires"," ",new Date(n.qrPayload.expiresAt).toLocaleString(),"."]}):"Generate the one-time QR and scan it from the iPhone app."}),n?e.jsxs(o,{variant:"secondary",pending:d.isPending,pendingLabel:"Generating",onClick:()=>void d.mutateAsync("iroh"),children:[e.jsx(U,{className:"size-4"}),"Regenerate QR"]}):null]})]})]}),n?e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/62",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("div",{className:"text-white/78",children:"Fallback pairing payload"}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/45",children:"Use this only when the iPhone camera cannot scan the QR. The payload contains the same Forge Iroh connection recipe."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(o,{variant:"secondary",onClick:()=>void B(),children:[z?e.jsx(H,{className:"size-4"}):e.jsx(ee,{className:"size-4"}),z?"Copied":"Copy payload"]}),e.jsxs(o,{variant:"secondary",onClick:()=>w(s=>!s),children:[y?"Hide payload":"Show payload",y?e.jsx(q,{className:"size-4"}):e.jsx(M,{className:"size-4"})]})]})]}),y?e.jsx("pre",{className:"max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-[16px] bg-slate-950/60 p-3 font-mono text-[11px] leading-5 text-white/70",children:P}):null]}):null]}):e.jsx("div",{className:"rounded-[24px] border border-dashed border-white/10 bg-white/[0.03] px-5 py-6 text-sm leading-6 text-white/55",children:"Generate a one-time Forge QR when the iPhone is in your hand. The code expires automatically and can be regenerated anytime."})]}),e.jsxs(A,{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Companion state"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Pairings"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:g.length}),L>0?e.jsxs("div",{className:"mt-2 text-xs text-white/42",children:[L," revoked hidden"]}):null]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Sleep sessions"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.sleepSessions})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Raw sleep records"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.sleepRawRecords})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Workouts"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.workouts})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Vitals days"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.vitalsDaySummaries??0})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Vital entries"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.vitalsMetricEntries??0})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Reflected sleep"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.reflectiveSleepSessions})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Linked workouts"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.linkedWorkouts})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Habit-generated"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.habitGeneratedWorkouts})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Reconciled"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:i.counts.reconciledWorkouts})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(a,{children:i.healthState.replaceAll("_"," ")}),i.lastSyncAt?e.jsxs(a,{tone:"meta",children:["Last sync ",new Date(i.lastSyncAt).toLocaleString()]}):null,e.jsxs(a,{tone:G(i.permissions.healthKitAuthorized),children:["HealthKit ",i.permissions.healthKitAuthorized?"ready":"needed"]}),e.jsxs(a,{tone:G(i.permissions.backgroundRefreshEnabled),children:["Background refresh"," ",i.permissions.backgroundRefreshEnabled?"ready":"not yet"]}),e.jsxs(a,{tone:"meta",children:["Location ",i.permissions.locationReady?"ready":"later"]}),e.jsxs(a,{tone:"meta",children:["Motion ",i.permissions.motionReady?"ready":"later"]})]}),e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Pairing path"}),e.jsxs("div",{className:"grid gap-2 text-sm text-white/62",children:[e.jsx("div",{children:"1. Generate the Forge QR from this page."}),e.jsx("div",{children:"2. Scan it in Forge Companion to pass the desktop node and pairing token."}),e.jsx("div",{children:"3. Approve Health access on iPhone, then run the first sync."}),e.jsx("div",{children:"4. Use Advanced HTTP only for a local, Tailscale, or direct TCP route."})]})]}),e.jsxs("div",{className:"grid gap-3",children:[g.length>0?e.jsx("div",{className:"flex justify-end",children:e.jsxs(o,{variant:"secondary",pending:E.isPending,pendingLabel:"Revoking all",onClick:()=>void E.mutateAsync(),children:[e.jsx(D,{className:"size-4"}),"Revoke all"]})}):null,g.map(s=>e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base text-white",children:s.deviceName??s.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/56",children:[s.platform??"ios"," · ",s.status]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(a,{tone:s.status==="healthy"?"signal":"meta",children:s.status.replaceAll("_"," ")}),s.lastSyncAt?e.jsxs(a,{tone:"meta",children:["Synced ",new Date(s.lastSyncAt).toLocaleString()]}):null]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.capabilities.map(h=>e.jsx(a,{tone:"meta",size:"sm",wrap:!0,children:ge(h)},h))}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-sm text-white/55",children:[e.jsxs("div",{className:"grid gap-1",children:[e.jsx("div",{children:s.apiBaseUrl}),e.jsxs("div",{children:["Expires ",new Date(s.expiresAt).toLocaleString()]}),s.lastSyncError?e.jsx("div",{className:"text-rose-200/80",children:s.lastSyncError}):null]}),e.jsxs(o,{variant:"secondary",pending:S.isPending&&S.variables===s.id,pendingLabel:"Revoking",disabled:s.status==="revoked",onClick:()=>void S.mutateAsync(s.id),children:[e.jsx(D,{className:"size-4"}),s.status==="revoked"?"Revoked":"Revoke"]})]}),e.jsxs("div",{className:"grid gap-3 rounded-[16px] border border-white/8 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Device sync sources"}),[["health","Health"],["movement","Movement"],["screenTime","Screen Time"]].map(([h,Q])=>{var F,I;const r=s.sourceStates[h],W=r.desiredEnabled!==r.appliedEnabled,T=j.isPending&&((F=j.variables)==null?void 0:F.pairingSessionId)===s.id&&((I=j.variables)==null?void 0:I.source)===h;return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[14px] border border-white/6 bg-white/[0.03] px-3 py-3",children:[e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"text-sm text-white",children:Q}),e.jsx(a,{tone:je(r.desiredEnabled,r.syncEligible),size:"sm",children:r.desiredEnabled?"Enabled":"Off"}),W?e.jsx(a,{tone:"meta",size:"sm",children:"Pending on phone"}):e.jsx(a,{tone:"meta",size:"sm",children:"Applied"})]}),e.jsxs("div",{className:"text-xs text-white/55",children:["Authorization ",ve(r.authorizationStatus)," · ","Last seen ",we(r.lastObservedAt)]})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":r.desiredEnabled,"aria-label":`${Q} sync source`,disabled:T,onClick:()=>void j.mutateAsync({pairingSessionId:s.id,source:h,desiredEnabled:!r.desiredEnabled}),className:`relative inline-flex h-7 w-12 items-center rounded-full border transition ${r.desiredEnabled?"border-[rgba(171,232,255,0.4)] bg-[rgba(111,133,232,0.36)]":"border-white/10 bg-white/[0.06]"} ${T?"opacity-60":""}`,children:e.jsx("span",{className:`inline-block size-5 rounded-full bg-white shadow transition ${r.desiredEnabled?"translate-x-6":"translate-x-1"}`})})]},h)})]})]},s.id)),g.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-6 text-sm text-white/55",children:"No companion paired yet. Generate a QR code, then open the iOS companion and scan it."}):null]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(o,{variant:"secondary",onClick:()=>void x.refetch(),children:[e.jsx(U,{className:"size-4"}),"Refresh status"]}),e.jsxs(C,{to:"/sleep",className:"inline-flex min-h-11 items-center gap-2 rounded-[16px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/72 transition hover:bg-white/[0.06] hover:text-white",children:[e.jsx(R,{className:"size-4"}),"Open sleep view"]}),e.jsxs(C,{to:"/sports",className:"inline-flex min-h-11 items-center gap-2 rounded-[16px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/72 transition hover:bg-white/[0.06] hover:text-white",children:[e.jsx(R,{className:"size-4"}),"Open sports view"]}),e.jsxs(C,{to:"/vitals",className:"inline-flex min-h-11 items-center gap-2 rounded-[16px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/72 transition hover:bg-white/[0.06] hover:text-white",children:[e.jsx(R,{className:"size-4"}),"Open vitals view"]})]})]})]}),e.jsxs(A,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Sync history"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Recent HealthKit import runs"})]}),e.jsxs(a,{tone:"meta",children:[i.importRuns.length," recent runs"]})]}),e.jsxs("div",{className:"grid gap-3",children:[i.importRuns.map(s=>e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{className:"size-4 text-white/55"}),e.jsxs("div",{className:"text-base text-white",children:[s.sourceDevice||"iPhone"," import"]}),e.jsx(a,{tone:s.status==="completed"?"signal":"meta",children:s.status})]}),e.jsxs("div",{className:"text-sm text-white/60",children:[new Date(s.importedAt).toLocaleString()," ·"," ",ue(s.payloadSummary)]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-white/60",children:[e.jsxs(a,{tone:"meta",children:["Imported ",s.importedCount]}),e.jsxs(a,{tone:"meta",children:["Created ",s.createdCount]}),e.jsxs(a,{tone:"meta",children:["Updated ",s.updatedCount]}),e.jsxs(a,{tone:"meta",children:["Merged ",s.mergedCount]})]}),s.errorMessage?e.jsx("div",{className:"text-sm text-rose-200/80",children:s.errorMessage}):null]}),s.pairingSessionId?e.jsxs("div",{className:"text-sm text-white/45 lg:text-right",children:["Pairing ",s.pairingSessionId]}):null]},s.id)),i.importRuns.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-6 text-sm text-white/55",children:"No sync runs yet. Pair the iPhone companion and run the first HealthKit import."}):null]})]})]})}export{Le as SettingsMobilePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,b2 as $,dr as _,aG as D,bn as G,df as H,c7 as Z}from"./vendor-DHkYh85p.js";import{j as J,i as Q,k as x}from"./state-B-4sS1xO.js";import{S as V}from"./settings-section-nav-DSOuht_F.js";import{P as X}from"./page-hero-DRy5b2MU.js";import{dj as Y,eh as ee,ei as te,ej as ae,ek as se,el as ie,L as ne,E as oe,C as j,B as l,c as p,b$ as de,em as re}from"./index-CF4J4R9L.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";function f(s="openai-api"){return{label:s==="openai-codex"?"OpenAI Codex":s==="openai-compatible"?"Local compatible endpoint":s==="mock"?"Workbench mock runtime":"OpenAI API",provider:s,baseUrl:s==="openai-codex"?"https://chatgpt.com/backend-api":s==="openai-compatible"?"http://127.0.0.1:11434/v1":s==="mock"?"mock://workbench":"https://api.openai.com/v1",model:s==="mock"?"mock-echo":"gpt-5.4-mini",apiKey:""}}function le(s){return{id:s.id,label:s.label,provider:s.provider,baseUrl:s.baseUrl,model:s.model,apiKey:""}}function je(){var z,B,q;const s=J(),[a,c]=o.useState(()=>f()),[y,N]=o.useState(""),[C,k]=o.useState("gpt-5.4-mini"),[A,S]=o.useState(""),[O,I]=o.useState("gpt-5.4-mini"),[v,u]=o.useState(""),[d,b]=o.useState(null),[M,m]=o.useState(null),r=Q({queryKey:["forge-settings"],queryFn:de}),R=Q({queryKey:["forge-openai-codex-oauth",d],queryFn:async()=>{if(!d)throw new Error("Missing OAuth session id");return await re(d)},enabled:!!d,refetchInterval:t=>{var W;const n=(W=t.state.data)==null?void 0:W.session.status;return n&&["authorized","error","consumed","expired"].includes(n)?!1:1500}}),w=async()=>{await s.invalidateQueries({queryKey:["forge-settings"]}),await s.invalidateQueries({queryKey:["forge-openai-codex-oauth",d]})},L=x({mutationFn:()=>Y({modelSettings:{forgeAgent:{basicChat:{connectionId:y||null,model:C},wiki:{connectionId:A||null,model:O}}}}),onSuccess:w}),F=x({mutationFn:()=>ee({id:a.id,label:a.label,provider:a.provider,authMode:a.provider==="openai-codex"?"oauth":"api_key",baseUrl:a.baseUrl,model:a.model,apiKey:a.provider==="openai-codex"?void 0:a.apiKey||void 0,oauthSessionId:a.provider==="openai-codex"?d??void 0:void 0}),onSuccess:async()=>{m("Connection saved."),a.provider==="openai-codex"&&(b(null),u("")),c(f(a.provider)),await w()}}),P=x({mutationFn:te,onSuccess:w}),K=x({mutationFn:async()=>ae({connectionId:a.id,provider:a.provider,baseUrl:a.baseUrl,model:a.model,apiKey:a.provider==="openai-codex"?void 0:a.apiKey||void 0}),onSuccess:({result:t})=>{m(`Connection test succeeded: ${t.outputPreview}`)},onError:t=>{m(t instanceof Error?t.message:"Connection test failed.")}}),E=x({mutationFn:se,onSuccess:({session:t})=>{b(t.id),m("OpenAI Codex OAuth started."),t.authUrl&&window.open(t.authUrl,"_blank","noopener,noreferrer")}}),U=x({mutationFn:async()=>{if(!d)throw new Error("No OAuth session started yet.");return await ie(d,v)},onSuccess:({session:t})=>{m(t.status==="authorized"?"OpenAI Codex OAuth authorized.":"Manual OAuth code submitted.")}});o.useEffect(()=>{var n;const t=(n=r.data)==null?void 0:n.settings;t&&(N(t.modelSettings.forgeAgent.basicChat.connectionId??""),k(t.modelSettings.forgeAgent.basicChat.model),S(t.modelSettings.forgeAgent.wiki.connectionId??""),I(t.modelSettings.forgeAgent.wiki.model))},[r.data]);const h=((z=r.data)==null?void 0:z.settings.modelSettings.connections)??[],i=((B=R.data)==null?void 0:B.session)??null,T=o.useMemo(()=>!a.label.trim()||!a.model.trim()?!1:a.provider==="openai-codex"?!!(a.id||(i==null?void 0:i.status)==="authorized"):a.provider==="mock"?!0:a.apiKey.trim().length>0||!!a.id,[a,i==null?void 0:i.status]);if(r.isLoading)return e.jsx(ne,{eyebrow:"Models",title:"Loading model settings",description:"Fetching Forge agent defaults and configured AI connections."});if(r.isError||!((q=r.data)!=null&&q.settings))return e.jsx(oe,{eyebrow:"Models",error:r.error??new Error("Forge returned an empty model settings payload."),onRetry:()=>void r.refetch()});const g=r.data.settings;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(X,{eyebrow:"AI runtime",title:"Model Settings",description:"Manage Forge Agent defaults, OpenAI OAuth/API connections, and local OpenAI-compatible endpoints as first-class chat agents.",badge:`${h.length} model connection${h.length===1?"":"s"}`}),e.jsx(V,{}),e.jsxs(j,{className:"grid gap-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Forge Agent defaults"}),e.jsx("div",{className:"text-xs leading-5 text-white/52",children:"Forge Agent stays the default system agent. Choose which model connection powers basic chat and the managed wiki workflow."})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("span",{className:"text-sm text-white/72",children:"Basic chat connection"}),e.jsxs("select",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:y,onChange:t=>N(t.target.value),children:[e.jsx("option",{value:"",children:"No external connection"}),h.map(t=>e.jsxs("option",{value:t.id,children:[t.label," (",t.agentLabel,")"]},t.id))]}),e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:C,onChange:t=>k(t.target.value),placeholder:"Model"})]}),e.jsxs("label",{className:"grid gap-2 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("span",{className:"text-sm text-white/72",children:"KarpaWiki model connection"}),e.jsxs("select",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:A,onChange:t=>S(t.target.value),children:[e.jsx("option",{value:"",children:"No external connection"}),h.map(t=>e.jsxs("option",{value:t.id,children:[t.label," (",t.agentLabel,")"]},t.id))]}),e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:O,onChange:t=>I(t.target.value),placeholder:"Model"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(l,{pending:L.isPending,pendingLabel:"Saving defaults",onClick:()=>void L.mutateAsync(),children:"Save Forge Agent defaults"}),e.jsxs(p,{className:"bg-white/[0.06] text-white/78",children:["Forge Agent",g.modelSettings.forgeAgent.basicChat.connectionLabel?` basic chat: ${g.modelSettings.forgeAgent.basicChat.connectionLabel}`:" basic chat stays local"]}),e.jsx(p,{className:"bg-white/[0.06] text-white/78",children:g.modelSettings.forgeAgent.wiki.connectionLabel?`KarpaWiki: ${g.modelSettings.forgeAgent.wiki.connectionLabel}`:"KarpaWiki: no external model selected"})]})]}),e.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Connection editor"}),e.jsx("div",{className:"text-xs leading-5 text-white/52",children:"Every saved connection becomes a first-class agent layered on top of Forge Agent."})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Provider"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:[["openai-api","OpenAI API"],["openai-codex","OpenAI Codex OAuth"],["openai-compatible","OpenAI-compatible"]].map(([t,n])=>e.jsx("button",{type:"button",className:`rounded-[18px] px-4 py-3 text-left text-sm transition ${a.provider===t?"bg-[var(--primary)]/[0.18] text-white":"bg-white/[0.04] text-white/62 hover:bg-white/[0.08]"}`,onClick:()=>{c(f(t)),b(null),u("")},children:n},t))})]}),e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:a.label,onChange:t=>c(n=>({...n,label:t.target.value})),placeholder:"Connection label"}),e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:a.model,onChange:t=>c(n=>({...n,model:t.target.value})),placeholder:"Model"}),a.provider==="mock"?e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white",children:"The Workbench mock runtime is only meant for local development and test workflows."}),e.jsxs("div",{className:"text-xs leading-5 text-white/52",children:["Use mock models like ",e.jsx("code",{children:"mock-echo"}),", ",e.jsx("code",{children:"mock-json"}),",",e.jsx("code",{children:"mock-tool-search"}),", ",e.jsx("code",{children:"mock-tool-note"}),", or",e.jsx("code",{children:"mock-chat-memory"})," to exercise deterministic flow behavior without a real external model."]})]}):a.provider!=="openai-codex"?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:a.baseUrl,onChange:t=>c(n=>({...n,baseUrl:t.target.value})),placeholder:"Base URL"}),e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:a.apiKey,onChange:t=>c(n=>({...n,apiKey:t.target.value})),placeholder:a.id?"Leave blank to keep the stored key":"API key",type:"password"})]}):e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"text-sm text-white",children:["OpenAI Codex uses the documented PKCE flow with the local callback at ",g.modelSettings.oauth.openAiCodex.callbackUrl,"."]}),e.jsx("div",{className:"text-xs leading-5 text-white/52",children:"Start OAuth, finish the browser sign-in, then save the resulting connection as a chat agent backed by the ChatGPT Codex runtime."}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(l,{variant:"secondary",pending:E.isPending,pendingLabel:"Starting OAuth",onClick:()=>void E.mutateAsync(),children:[e.jsx(D,{className:"size-4"}),"Start OAuth"]}),i!=null&&i.authUrl?e.jsxs(l,{variant:"secondary",onClick:()=>window.open(i.authUrl??"","_blank","noopener,noreferrer"),children:["Open sign-in",e.jsx(G,{className:"size-4"})]}):null]}),i?e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-black/20 p-3 text-sm text-white/72",children:[e.jsxs("div",{children:["Status: ",i.status]}),i.accountLabel?e.jsxs("div",{children:["Account: ",i.accountLabel]}):null,i.error?e.jsx("div",{className:"text-rose-200",children:i.error}):null]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("input",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:v,onChange:t=>u(t.target.value),placeholder:"Paste the authorization code or full redirect URL"}),e.jsx(l,{variant:"secondary",disabled:!v.trim()||!d,pending:U.isPending,pendingLabel:"Submitting",onClick:()=>void U.mutateAsync(),children:"Submit manual code"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(l,{pending:F.isPending,pendingLabel:"Saving connection",disabled:!T,onClick:()=>void F.mutateAsync(),children:"Save connection"}),e.jsxs(l,{variant:"secondary",pending:K.isPending,pendingLabel:"Testing",disabled:a.provider==="openai-codex"?!a.id:a.provider==="mock"?!1:!a.id&&!a.apiKey.trim(),onClick:()=>void K.mutateAsync(),children:[e.jsx(H,{className:"size-4"}),"Test connection"]})]}),M?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/72",children:M}):null]})]}),e.jsxs(j,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Connected agents"}),e.jsx("div",{className:"text-xs leading-5 text-white/52",children:"Each connection registers its own chat-facing agent identity."})]})]}),e.jsxs("div",{className:"grid gap-3",children:[h.length===0?e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-5 text-sm leading-6 text-white/58",children:"No external model connection yet. Add one with OAuth or API credentials and Forge will expose it as a first-class agent."}):null,h.map(t=>e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-white",children:t.label}),e.jsxs("div",{className:"mt-1 text-xs text-white/46",children:[t.agentLabel," · ",t.provider," ·"," ",t.model]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{variant:"secondary",onClick:()=>{c(le(t)),b(null),u("")},children:"Edit"}),e.jsx(l,{variant:"secondary",pending:P.isPending,pendingLabel:"Deleting",onClick:()=>void P.mutateAsync(t.id),children:e.jsx(Z,{className:"size-4"})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(p,{className:"bg-white/[0.06] text-white/78",children:t.authMode==="oauth"?"OAuth":"API key"}),e.jsx(p,{className:"bg-white/[0.06] text-white/78",children:t.status}),e.jsx(p,{className:"bg-white/[0.06] text-white/78",children:t.baseUrl}),t.accountLabel?e.jsx(p,{className:"bg-white/[0.06] text-white/78",children:t.accountLabel}):null]})]},t.id))]})]})]})]})}export{je as SettingsModelsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as j,j as e,aD as pe,d9 as xe,aC as ue,aG as ge,bl as he,da as be,aQ as fe}from"./vendor-DHkYh85p.js";import{j as ye,i as _,k as $}from"./state-B-4sS1xO.js";import{u as ve}from"./forms-BFlTgZ3W.js";import{Q as we,de as Y,F as L,I as F,j as je,df as Ne,T as ke,dg as D,B as N,dh as ee,P as Se,aF as Ce,di as Fe,dj as I,dk as Te,dl as Pe,dm as De,dn as Ae,dp as X,S as Ee,E as Z,C as T,dq as _e,dr as $e,ds as Ie,dt as Le,du as Me,dv as Qe,dw as Re,dx as qe,b$ as ze,dy as Je,dz as Ke}from"./index-CF4J4R9L.js";import{S as Oe}from"./settings-section-nav-DSOuht_F.js";import{P as Ge}from"./page-hero-DRy5b2MU.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./graph-D6JLqDbD.js";function R({theme:s,title:l,description:n}){return e.jsx("div",{className:"overflow-hidden rounded-[24px] border border-white/10",style:{background:`linear-gradient(180deg, ${s.panelHigh}, ${s.panelLow})`,color:s.ink},children:e.jsxs("div",{className:"px-4 py-4",style:{background:`radial-gradient(circle at top left, ${s.primary}33, transparent 42%), radial-gradient(circle at top right, ${s.secondary}2a, transparent 36%), linear-gradient(180deg, ${s.panel}, ${s.canvas})`},children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.2em] opacity-60",children:"Preview"}),e.jsx("div",{className:"mt-2 font-display text-xl",children:l}),e.jsx("div",{className:"mt-2 text-sm leading-6 opacity-72",children:n}),e.jsx("div",{className:"mt-5 flex gap-2",children:[s.primary,s.secondary,s.tertiary,s.panelHigh].map(i=>e.jsx("div",{className:"h-9 flex-1 rounded-[14px] border border-black/10",style:{background:i}},i))})]})})}function w({label:s,value:l,onChange:n,description:i}){return e.jsx(L,{label:s,description:i,children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-[5.5rem_minmax(0,1fr)]",children:[e.jsx("input",{type:"color",value:l,onChange:d=>n(d.target.value),className:"h-12 w-full cursor-pointer rounded-[18px] border border-white/10 bg-transparent p-1"}),e.jsx(F,{value:l,onChange:d=>n(d.target.value),placeholder:"#7cc7ff"})]})})}function He({open:s,onOpenChange:l,value:n,onSave:i}){const[d,p]=j.useState(n),[u,m]=j.useState(""),[y,f]=j.useState(null),k=j.useRef(null),c=a=>{const r=Y.parse(JSON.parse(a));p(r),m(JSON.stringify(r,null,2)),f(null)},g=a=>{const r=ee(a);p({...r,label:d.label.trim().length>0?d.label:`${r.label} Custom`})},S=async a=>{var o;const r=(o=a.target.files)==null?void 0:o[0];if(r)try{c(await r.text())}catch(C){f(C instanceof Error?C.message:"Forge could not parse that JSON theme.")}finally{a.target.value=""}},A=[{id:"identity",eyebrow:"Custom theme",title:"Name the mood and choose a starting point",description:"Start from a Forge preset, then tune the accents and surfaces in the next steps.",render:(a,r)=>e.jsxs("div",{className:"grid gap-5",children:[e.jsx(L,{label:"Theme label",description:"This label appears in Settings when the custom theme is active.",children:e.jsx(F,{value:a.label,onChange:o=>r({label:o.target.value}),placeholder:"Midnight Circuit"})}),e.jsx(L,{label:"Starter preset",children:e.jsx(je,{value:"",onChange:o=>g(o),options:Object.entries(Ne).map(([o,C])=>({value:o,label:C.label,description:C.description})),columns:2})}),e.jsx(R,{theme:a,title:a.label,description:"Live preview of the current custom theme draft."})]})},{id:"accents",eyebrow:"Custom theme",title:"Set the accent colors",description:"These colors drive buttons, highlights, charts, and the ambient shell lighting.",render:(a,r)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(w,{label:"Primary",description:"Main emphasis color for actions and active state.",value:a.primary,onChange:o=>r({primary:o})}),e.jsx(w,{label:"Secondary",description:"Support accent for positive or secondary emphasis.",value:a.secondary,onChange:o=>r({secondary:o})}),e.jsx(w,{label:"Tertiary",description:"Warm contrast color for warnings, highlights, and supporting metrics.",value:a.tertiary,onChange:o=>r({tertiary:o})})]})},{id:"surfaces",eyebrow:"Custom theme",title:"Tune the shell surfaces",description:"Forge currently assumes a dark shell, so these should remain fairly deep colors for legibility.",render:(a,r)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(w,{label:"Canvas",description:"Primary app background.",value:a.canvas,onChange:o=>r({canvas:o})}),e.jsx(w,{label:"Panel",description:"Default card and rail background.",value:a.panel,onChange:o=>r({panel:o})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(w,{label:"Panel high",description:"Raised highlights and stronger sections.",value:a.panelHigh,onChange:o=>r({panelHigh:o})}),e.jsx(w,{label:"Panel low",description:"Lower contrast and deeper card areas.",value:a.panelLow,onChange:o=>r({panelLow:o})})]}),e.jsx(w,{label:"Ink",description:"Main text and readable foreground color.",value:a.ink,onChange:o=>r({ink:o})}),e.jsx(R,{theme:a,title:a.label,description:"Live preview after the current surface edits."})]})},{id:"import",eyebrow:"Custom theme",title:"Import or paste JSON directly",description:"You can skip the picker workflow entirely by uploading a JSON file or pasting a valid theme object.",render:a=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(L,{label:"Direct JSON",description:"Paste a full custom theme object, then click Apply JSON.",children:e.jsx(ke,{value:u,onChange:r=>m(r.target.value),className:"min-h-52 font-mono text-[13px] leading-6",placeholder:JSON.stringify(D,null,2)})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(N,{type:"button",variant:"secondary",onClick:()=>{try{c(u)}catch(r){f(r instanceof Error?r.message:"Forge could not parse that JSON theme.")}},children:"Apply JSON"}),e.jsx(N,{type:"button",variant:"ghost",onClick:()=>{var r;return(r=k.current)==null?void 0:r.click()},children:"Upload JSON file"}),e.jsx("input",{ref:k,type:"file",accept:"application/json,.json",className:"hidden",onChange:S})]}),e.jsx(R,{theme:a,title:a.label,description:"Preview of the theme that will be saved if you submit now."})]})}];return e.jsx(we,{open:s,onOpenChange:a=>{a&&(p(n),m(""),f(null)),l(a)},eyebrow:"Settings",title:"Forge custom theme",description:"Build a dark Forge palette visually, or import one directly as JSON.",value:d,onChange:a=>{p(a),f(null)},draftPersistenceKey:"settings.theme-customizer",steps:A,error:y,onSubmit:async()=>{try{const a=Y.parse(d);i(a),l(!1)}catch(a){f(a instanceof Error?a.message:"Forge could not save that custom theme.")}},submitLabel:"Save custom theme",contentClassName:"lg:w-[min(62rem,calc(100vw-1.5rem))]"})}function Ue({theme:s}){return e.jsx("div",{className:"mt-3 grid grid-cols-4 gap-2",children:[s.primary,s.secondary,s.tertiary,s.panelHigh].map(l=>e.jsx("div",{className:"h-6 rounded-[10px] border border-black/10",style:{background:l}},l))})}function Be({selected:s,theme:l}){return e.jsxs("div",{className:"relative min-h-[138px] overflow-hidden rounded-[18px] border border-white/10 bg-[radial-gradient(circle_at_24%_10%,rgba(255,199,104,0.22),transparent_30%),radial-gradient(circle_at_88%_12%,rgba(84,191,255,0.16),transparent_32%),linear-gradient(145deg,rgba(255,255,255,0.08),rgba(255,255,255,0.025))]",children:[e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/42 to-transparent"}),e.jsx("img",{src:Me(l),alt:`${l} neutral Forge Smith mascot preview`,className:"absolute bottom-1 left-1/2 h-[124px] w-[124px] -translate-x-1/2 object-contain drop-shadow-[0_18px_30px_rgba(0,0,0,0.34)]"}),e.jsxs("div",{className:"absolute left-3 top-3 flex items-center gap-2 rounded-full border border-white/10 bg-black/28 px-2.5 py-1 text-[9px] font-semibold uppercase tracking-[0.14em] text-white/78 backdrop-blur-md",children:[e.jsx(ge,{className:"size-3 text-amber-200"}),"Live rewards"]}),e.jsx("div",{className:"absolute bottom-3 left-3 flex items-center gap-1.5",children:Qe.map(n=>e.jsx("span",{className:"grid size-11 place-items-center overflow-hidden rounded-[12px] border border-white/12 bg-black/26 p-1 shadow-[0_12px_22px_rgba(0,0,0,0.22)] backdrop-blur-md",children:e.jsx("img",{src:Re(l,n),alt:`${l} reward thumbnail`,className:"size-full object-contain"})},n))}),e.jsx("span",{className:`absolute right-3 top-3 grid size-7 place-items-center rounded-full border ${s?"border-emerald-200/55 bg-emerald-300/18 text-emerald-100":"border-white/15 bg-black/20 text-white/40"}`,children:s?e.jsx(he,{className:"size-4"}):null})]})}function V({healthy:s}){return e.jsx(T,{className:"p-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Mobile companion"}),e.jsx("div",{className:"mt-1 text-base font-medium text-white",children:s?"iPhone bridge is syncing":"Connect the iPhone bridge"}),e.jsx("div",{className:"mt-1 max-w-3xl text-sm leading-6 text-white/58",children:s?"Review HealthKit, movement, and background sync permissions.":"Pair or refresh the native companion before relying on HealthKit, movement, or watch signals."})]}),e.jsx(ue,{to:"/settings/mobile",className:"inline-flex min-h-10 items-center rounded-[14px] bg-white/[0.08] px-3 py-2 text-sm text-white transition hover:bg-white/[0.12]",children:"Open mobile settings"})]})})}function M(s){return new Date(s).toLocaleString()}function te({integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i}){return i?[i.integrity.headline,i.integrity.topIssues.length>0?i.integrity.topIssues[0].summary:"No active Doctor warnings are holding back integrity.",`Storage mode: ${l}. Latest Doctor run: ${M(i.integrity.lastCheckedAt)}.`]:s>=100?["All currently reported settings and storage checks passed.",`Latest audit: ${M(n)}.`]:[`Forge is holding back ${Math.max(0,100-s)}% because the latest settings and storage audit reported a consistency warning.`,"The current audit only exposes the aggregate score, so per-check details are not available yet.",`Storage mode: ${l}. Latest audit: ${M(n)}.`]}function se({integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i}){const d=(i==null?void 0:i.integrity.score)??s,p=te({integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i});return e.jsxs("details",{className:"group relative inline-flex",children:[e.jsxs("summary",{className:"inline-flex cursor-pointer list-none items-center gap-1 rounded-full border border-white/10 bg-white/[0.05] px-2.5 py-1 text-[11px] font-medium normal-case tracking-normal text-white/72 transition marker:hidden hover:border-white/18 hover:bg-white/[0.08] hover:text-white/88 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[rgba(192,193,255,0.35)] [&::-webkit-details-marker]:hidden",onKeyDown:u=>{var m;u.key==="Escape"&&((m=u.currentTarget.parentElement)==null||m.removeAttribute("open"))},children:[e.jsx(xe,{className:"size-3.5","aria-hidden":"true"}),d,"% integrity"]}),e.jsxs("span",{role:"tooltip",className:"absolute right-0 top-[calc(100%+0.55rem)] z-50 hidden w-[min(19rem,calc(100vw-2rem))] rounded-[16px] border border-white/10 bg-[rgba(10,15,27,0.98)] px-3 py-2.5 text-left text-xs leading-5 tracking-normal text-white/70 normal-case shadow-[0_18px_48px_rgba(3,8,18,0.46)] group-open:block",children:[e.jsx("span",{className:"block font-medium text-white/88",children:d>=100?"Integrity is complete":`Why this is ${d}%`}),p.map(u=>e.jsx("span",{className:"mt-1 block",children:u},u))]})]})}function We({integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i,doctorLoading:d,onRefreshDoctor:p,onApplyFix:u,applyingFixId:m}){const y=(i==null?void 0:i.integrity.score)??s,f=(i==null?void 0:i.integrity.lastCheckedAt)??n,k=(i==null?void 0:i.issues.filter(g=>g.severity!=="info").slice(0,4))??[],[c]=te({integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i});return e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Security posture"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/58",children:"Local-first means Forge stores its runtime data on this machine. Integrity is the latest internal consistency score from settings and data checks."}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-white/50",children:c})]}),e.jsx(se,{integrityScore:s,storageMode:l,lastAuditAt:n,doctor:i})]}),e.jsxs("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] bg-white/[0.04] px-3 py-3",children:[e.jsx("div",{className:"text-xs text-white/54",children:"Storage mode"}),e.jsx("div",{className:"mt-1 text-base font-medium text-white",children:l})]}),e.jsxs("div",{className:"rounded-[14px] bg-white/[0.04] px-3 py-3",children:[e.jsx("div",{className:"text-xs text-white/54",children:"Last Doctor run"}),e.jsx("div",{className:"mt-1 text-base font-medium text-white",children:M(f)})]})]}),e.jsxs("div",{className:"mt-3 rounded-[14px] border border-white/8 bg-white/[0.035] p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx(be,{className:"size-4 text-cyan-200"}),"Forge Doctor"]}),e.jsxs(N,{type:"button",variant:"secondary",pending:d,onClick:p,children:[e.jsx(fe,{className:"size-4"}),"Run"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:i?`${y}% integrity. ${i.integrity.headline}`:"Run Doctor to check settings, storage, entities, rewards, and runtime consistency."}),k.length>0?e.jsx("div",{className:"mt-3 grid gap-2",children:k.map(g=>{var S;return e.jsx(Ye,{issue:g,applying:m===((S=g.fix)==null?void 0:S.id),onApplyFix:u},g.id)})}):i?e.jsx("div",{className:"mt-3 rounded-[12px] border border-emerald-200/12 bg-emerald-300/8 px-3 py-2 text-sm text-emerald-100",children:"No active consistency warnings."}):null]})]})}function Ye({issue:s,applying:l,onApplyFix:n}){var i;return e.jsx("div",{className:"rounded-[12px] border border-white/8 bg-black/12 px-3 py-2",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs uppercase tracking-[0.14em] text-white/42",children:[s.group," / ",s.severity]}),e.jsx("div",{className:"mt-1 text-sm text-white/78",children:s.summary})]}),((i=s.fix)==null?void 0:i.kind)==="safe_auto_fix"?e.jsx(N,{type:"button",variant:"secondary",pending:l,onClick:()=>n(s.fix.id),children:"Apply fix"}):null]})})}function lt(){var G,H,U,B,W;const{t:s}=Se(),l=Ce(),n=ye(),[i,d]=j.useState(!1),p=_({queryKey:["forge-operator-session"],queryFn:qe}),u=p.isSuccess,m=_({queryKey:["forge-settings"],queryFn:ze,enabled:u}),y=Fe(void 0,{skip:!u}),f=_({queryKey:["forge-companion-overview"],queryFn:async()=>(await Je()).overview,enabled:u,staleTime:3e4}),k=_({queryKey:["forge-gamification-assets"],queryFn:Ke,enabled:u,staleTime:3e4}),c=ve({defaultValues:{profile:{operatorName:"",operatorEmail:"",operatorTitle:""},notifications:{goalDriftAlerts:!0,dailyQuestReminders:!0,achievementCelebrations:!0},execution:{maxActiveTasks:2,timeAccountingMode:"split"},themePreference:"obsidian",gamificationTheme:"dramatic-smithie",customTheme:D,localePreference:"en"}}),g=async()=>{await Promise.all([n.invalidateQueries({queryKey:["forge-operator-session"]}),n.invalidateQueries({queryKey:["forge-settings"]})])},S=$({mutationFn:t=>I(t),onSuccess:g}),A=$({mutationFn:t=>I(t),onSuccess:async t=>{n.setQueryData(["forge-settings"],t),await g()}}),a=$({mutationFn:t=>I(t),onSuccess:async t=>{n.setQueryData(["forge-settings"],t),await g()}}),r=$({mutationFn:async t=>(await Te(t),I({gamificationTheme:t})),onSuccess:async t=>{n.setQueryData(["forge-settings"],t),await Promise.all([n.invalidateQueries({queryKey:["forge-settings"]}),n.invalidateQueries({queryKey:["forge-gamification-assets"]})])}}),[o,C]=Pe(),[ae,ie]=De(),[re,q]=j.useState(),ne=async()=>{await o().unwrap(),l(Ie([])),l(Le.util.resetApiState()),n.removeQueries({predicate:t=>{const[b]=t.queryKey;return typeof b=="string"&&b.startsWith("forge-")}}),await Promise.all([g(),p.refetch()])};j.useEffect(()=>{var t;(t=m.data)!=null&&t.settings&&c.reset(Ae.parse(m.data.settings))},[m.data,c]);const x=(G=m.data)==null?void 0:G.settings,le=(H=y.data)==null?void 0:H.doctor,P=c.watch("themePreference"),z=c.watch("gamificationTheme"),J=((U=k.data)==null?void 0:U.assets.styles)??[],Q=J.find(t=>t.id===z),v=c.watch("customTheme")??D,K=((B=f.data)==null?void 0:B.healthState)==="healthy_sync",oe=async t=>{if(window.confirm("Apply this Forge Doctor fix? Forge will only run the selected safe repair.")){q(t);try{await ae({fixIds:[t]}).unwrap(),await Promise.all([m.refetch(),y.refetch()])}finally{q(void 0)}}},O=async(t,b=v)=>{c.setValue("themePreference",t,{shouldDirty:!0}),c.setValue("customTheme",b??D,{shouldDirty:!0}),await A.mutateAsync({themePreference:t,customTheme:b??D})},ce=async t=>{c.setValue("gamificationTheme",t,{shouldDirty:!0}),await a.mutateAsync({gamificationTheme:t})};return j.useEffect(()=>{if(x)return X(P,v),()=>{X(x.themePreference,x.customTheme??null)}},[v,P,x,x==null?void 0:x.customTheme,x==null?void 0:x.themePreference]),p.isLoading||m.isLoading?e.jsx(Ee,{eyebrow:"Settings",title:"Loading settings",description:"Establishing the operator session and fetching current configuration.",columns:2,blocks:6}):p.isError?e.jsx(Z,{eyebrow:"Settings",error:p.error,onRetry:()=>void p.refetch()}):m.isError||!x?e.jsx(Z,{eyebrow:"Settings",error:m.error??new Error("Forge returned an empty settings payload."),onRetry:()=>void m.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(Ge,{title:"Settings",description:"Tune execution policy, timer behaviour, and personal preferences.",badge:e.jsx(se,{integrityScore:x.security.integrityScore,storageMode:x.security.storageMode,lastAuditAt:x.security.lastAuditAt})}),null,e.jsx(Oe,{}),(W=p.data)!=null&&W.session?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-[18px] border border-emerald-400/20 bg-emerald-500/[0.08] px-4 py-3 text-sm text-emerald-100/88",children:[e.jsxs("div",{children:["Operator session active as"," ",e.jsx("span",{className:"font-medium text-white",children:p.data.session.actorLabel}),"."]}),e.jsx(N,{variant:"secondary",size:"sm",pending:C.isLoading,pendingLabel:"Resetting session",onClick:()=>void ne(),children:"Reset operator session"})]}):null,e.jsxs("div",{className:"grid gap-4",children:[K?null:e.jsx(V,{healthy:!1}),e.jsxs("form",{className:"grid gap-4",onSubmit:c.handleSubmit(async t=>{await S.mutateAsync(t)}),children:[e.jsxs(T,{className:"p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Operator profile"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Name"}),e.jsx(F,{...c.register("profile.operatorName")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Email"}),e.jsx(F,{...c.register("profile.operatorEmail")})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Title"}),e.jsx(F,{...c.register("profile.operatorTitle")})]}),e.jsx("div",{className:"mt-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Execution policy"}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,0.7fr)_minmax(0,1.3fr)]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Maximum active tasks"}),e.jsx(F,{type:"number",min:1,max:8,...c.register("execution.maxActiveTasks",{valueAsNumber:!0})})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Time accounting mode"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:[{value:"split",label:"Split",description:"Multitasking divides credited time across active tasks."},{value:"parallel",label:"Parallel",description:"Every active task receives full credited wall time."},{value:"primary_only",label:"Primary only",description:"Only the highlighted task earns credited time during overlap."}].map(t=>e.jsxs("label",{className:"grid gap-2 rounded-[16px] bg-white/[0.04] px-3 py-3",children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"radio",value:t.value,...c.register("execution.timeAccountingMode")}),e.jsx("span",{className:"text-white/82",children:t.label})]}),e.jsx("span",{className:"text-xs leading-5 text-white/56",children:t.description})]},t.value))})]})]}),e.jsx("div",{className:"mt-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Notification rules"}),e.jsxs("label",{className:"flex items-center justify-between rounded-[16px] bg-white/[0.04] px-3 py-2.5",children:[e.jsx("span",{className:"text-white/72",children:"Goal drift alerts"}),e.jsx("input",{type:"checkbox",...c.register("notifications.goalDriftAlerts")})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-[16px] bg-white/[0.04] px-3 py-2.5",children:[e.jsx("span",{className:"text-white/72",children:"Daily quest reminders"}),e.jsx("input",{type:"checkbox",...c.register("notifications.dailyQuestReminders")})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-[16px] bg-white/[0.04] px-3 py-2.5",children:[e.jsx("span",{className:"text-white/72",children:"Achievement celebrations"}),e.jsx("input",{type:"checkbox",...c.register("notifications.achievementCelebrations")})]})]}),e.jsxs(T,{className:"p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Theme calibration"}),e.jsx("p",{className:"text-sm text-white/58",children:"Switch between Forge dark and light presets, follow the system palette, or save your own shell theme."}),e.jsx("div",{className:"grid gap-2 xl:grid-cols-3",children:_e.map(t=>{const b=ee(t.value,v),h=P===t.value;return e.jsxs("button",{type:"button",onClick:()=>void O(t.value,(t.value==="custom",v)),className:`rounded-[18px] border px-3 py-3 text-left transition ${h?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] shadow-[0_18px_36px_rgba(5,12,24,0.24)]":"border-white/8 bg-white/[0.04] hover:bg-white/[0.07]"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:t.value==="custom"?v.label:t.label}),e.jsx("div",{className:"mt-1 line-clamp-2 text-xs leading-5 text-white/58",children:t.description})]}),e.jsx("div",{className:`mt-1 size-4 rounded-full border ${h?"border-[rgba(192,193,255,0.65)] bg-[var(--primary)]":"border-white/25"}`})]}),e.jsx(Ue,{theme:b})]},t.value)})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-3 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Custom theme editor"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/58",children:"Save a custom Forge palette through a guided modal, or paste and upload JSON directly."})]}),e.jsx(N,{type:"button",variant:P==="custom"?"secondary":"ghost",onClick:()=>d(!0),pending:A.isPending,children:P==="custom"?"Edit custom theme":"Create custom theme"})]})]}),e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Gamification style"}),e.jsx("p",{className:"text-sm text-white/58",children:"Choose the reward art style and download its optional trophy, unlock, and mascot sprites."})]}),Q!=null&&Q.installed?e.jsx("span",{className:"inline-flex rounded-full border border-emerald-200/18 bg-emerald-300/10 px-3 py-1 text-xs font-medium text-emerald-100",children:"Selected style downloaded"}):e.jsx("span",{className:"inline-flex rounded-full border border-amber-200/18 bg-amber-300/10 px-3 py-1 text-xs font-medium text-amber-100",children:"Selected style not downloaded"})]}),e.jsx("div",{className:"mt-3 grid gap-2 xl:grid-cols-3",children:$e.map(t=>{const b=z===t.value,h=J.find(me=>me.id===t.value),E=(h==null?void 0:h.installed)??!1,de=r.isPending&&r.variables===t.value;return e.jsxs("div",{className:`grid gap-2 rounded-[18px] border p-2.5 text-left transition ${b?"border-amber-200/28 bg-amber-300/[0.09] shadow-[0_18px_42px_rgba(0,0,0,0.26)]":"border-white/8 bg-white/[0.035] hover:border-white/16 hover:bg-white/[0.065]"}`,children:[e.jsx("button",{type:"button",onClick:()=>void ce(t.value),className:"grid gap-2 text-left","aria-label":`Select ${t.label}`,"aria-pressed":b,children:e.jsx(Be,{selected:b,theme:t.value})}),e.jsxs("span",{className:"grid gap-1 px-1 pb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-white",children:t.label}),e.jsx("span",{className:"line-clamp-2 text-xs leading-5 text-white/58",children:t.description}),e.jsx("span",{className:"mt-1 text-[11px] uppercase tracking-[0.14em] text-white/42",children:E?`Downloaded ${(h==null?void 0:h.spriteCount)??0}/${(h==null?void 0:h.expectedSpriteCount)??0}`:"Not downloaded"}),e.jsxs(N,{type:"button",variant:E?"secondary":"primary",pending:de,disabled:E||r.isPending,onClick:()=>r.mutate(t.value),children:[e.jsx(pe,{className:"size-4"}),E?"Downloaded":"Download"]})]})]},t.value)})}),a.isPending?e.jsx("div",{className:"text-sm text-white/48",children:"Saving reward style…"}):null,r.isError?e.jsx("div",{className:"mt-3 rounded-[14px] border border-red-300/20 bg-red-500/10 px-3 py-2 text-sm text-red-100",children:r.error instanceof Error?r.error.message:"Could not download the selected reward art."}):null]}),e.jsxs(T,{className:"p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:s("common.settings.localeLabel")}),e.jsx("p",{className:"text-sm text-white/58",children:s("common.settings.localeDescription")}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:[{value:"en",label:s("common.settings.localeEnglish")},{value:"fr",label:s("common.settings.localeFrench")}].map(t=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[16px] bg-white/[0.04] px-3 py-3",children:[e.jsx("input",{type:"radio",value:t.value,...c.register("localePreference")}),e.jsx("span",{className:"text-white/72",children:t.label})]},t.value))}),e.jsx(N,{type:"submit",pending:S.isPending,pendingLabel:"Saving settings",children:"Save settings"})]})]}),K?e.jsx(V,{healthy:!0}):null,e.jsx(We,{integrityScore:x.security.integrityScore,storageMode:x.security.storageMode,lastAuditAt:x.security.lastAuditAt,doctor:le,doctorLoading:y.isFetching||ie.isLoading,onRefreshDoctor:()=>void y.refetch(),onApplyFix:t=>void oe(t),applyingFixId:re})]}),e.jsx(He,{open:i,onOpenChange:d,value:v,onSave:t=>void O("custom",t)})]})}export{lt as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,r as w}from"./vendor-DHkYh85p.js";import{j as $,i as v,k as K}from"./state-B-4sS1xO.js";import{u as D}from"./forms-BFlTgZ3W.js";import{S as H}from"./settings-section-nav-DSOuht_F.js";import{c as u,Z as S,W as B,f as z,u as U,eq as Y,er as ee,S as se,E as te,C as ae,I as P,T as E,B as V,dx as re,cZ as ie,es as le,et as ne,ad as de}from"./index-CF4J4R9L.js";import{m as G}from"./motion-BeD44FeG.js";import{P as ce}from"./page-hero-DRy5b2MU.js";import{M as W}from"./metric-tile-DKpo-8xw.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./graph-D6JLqDbD.js";function oe(a){switch(a){case"platinum":return"text-cyan-200";case"gold":return"text-amber-200";case"silver":return"text-slate-200";default:return"text-orange-200"}}function me(a){switch(a){case"surging":return"from-[rgba(192,193,255,0.3)] via-[rgba(78,222,163,0.22)] to-[rgba(255,185,95,0.22)]";case"steady":return"from-[rgba(192,193,255,0.24)] via-[rgba(192,193,255,0.14)] to-[rgba(78,222,163,0.18)]";default:return"from-[rgba(255,185,95,0.2)] via-[rgba(255,185,95,0.12)] to-[rgba(192,193,255,0.16)]"}}function xe({profile:a,achievements:o,milestoneRewards:n,momentumPulse:m,recentLedger:R=[],className:j,tone:k="core"}){const y=o.filter(r=>r.unlocked),h=(y.length>0?y:o).slice(0,3),X=n.slice(0,3),L=R.slice(0,3),I=Math.min(100,Math.round(a.currentLevelXp/a.nextLevelXp*100));return e.jsxs("section",{className:S("min-w-0 overflow-hidden rounded-[30px] border border-white/6 bg-[linear-gradient(180deg,rgba(18,24,40,0.96),rgba(11,16,28,0.94))] shadow-[0_24px_70px_rgba(4,8,18,0.3)]",k==="psyche"&&"bg-[linear-gradient(180deg,rgba(18,27,35,0.96),rgba(12,20,26,0.94))]",j),children:[e.jsx("div",{className:S("bg-gradient-to-r px-5 py-5",me(m.status)),children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.2em] text-white/55",children:"Weekly progress"}),e.jsx("h2",{className:"mt-3 font-display text-3xl leading-none text-white lg:text-4xl",children:m.headline}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-white/68",children:m.detail})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsxs(u,{wrap:!0,className:"bg-black/20 text-white/84",children:["Level ",a.level]}),e.jsxs(u,{wrap:!0,className:"bg-black/20 text-white/84",children:[a.streakDays," day streak"]}),e.jsxs(u,{wrap:!0,className:"bg-black/20 text-white/84",children:[a.weeklyXp," weekly XP"]})]})]})}),e.jsxs("div",{className:"grid gap-5 px-5 py-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(G.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.24,ease:"easeOut"},className:"overflow-hidden rounded-[24px] bg-white/[0.04] p-4",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:"font-medium text-white",children:"Next reward"}),e.jsx("div",{className:"mt-2 text-sm text-white/60",children:m.nextMilestoneLabel})]}),e.jsx(u,{wrap:!0,className:"max-w-[12rem] shrink-0 self-start text-[var(--tertiary)]",children:m.celebrationLabel})]}),e.jsx("div",{className:"mt-5",children:e.jsx(B,{value:I})}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.16em] text-white/38",children:[e.jsxs("span",{children:[a.currentLevelXp,"/",a.nextLevelXp," XP"]}),e.jsxs("span",{children:[a.comboMultiplier.toFixed(2),"x combo"]})]})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:h.map((r,d)=>e.jsxs(G.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.24,delay:.04*d,ease:"easeOut"},className:"overflow-hidden rounded-[22px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 font-medium text-white",children:r.title}),e.jsx(u,{wrap:!0,className:S("max-w-[8rem] shrink-0 self-start",oe(r.tier)),children:r.tier})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:r.summary}),e.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.16em] text-white/40",children:r.progressLabel})]},r.id))})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"overflow-hidden rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Rewards in progress"}),e.jsx("div",{className:"mt-4 grid gap-3",children:X.map(r=>{const d=Math.min(100,Math.round(r.current/r.target*100));return e.jsxs("div",{className:"overflow-hidden rounded-[18px] bg-[rgba(8,13,28,0.68)] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 font-medium text-white",children:r.title}),e.jsx(u,{wrap:!0,className:S("max-w-[10.5rem] shrink-0 self-start",r.completed?"text-emerald-300":"text-white/68"),children:r.rewardLabel})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:r.summary}),e.jsx("div",{className:"mt-4",children:e.jsx(B,{value:d})}),e.jsx("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:r.progressLabel})]},r.id)})})]}),L.length>0?e.jsxs("div",{className:"overflow-hidden rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Recent XP changes"}),e.jsx("div",{className:"mt-4 grid gap-3",children:L.map(r=>e.jsxs("div",{className:"overflow-hidden rounded-[18px] bg-[rgba(8,13,28,0.68)] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1 font-medium text-white",children:r.reasonTitle}),e.jsxs(u,{wrap:!0,className:S("max-w-[8rem] shrink-0 self-start",r.deltaXp>=0?"text-emerald-300":"text-amber-300"),children:[r.deltaXp>0?"+":"",r.deltaXp," XP"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:r.reasonSummary}),e.jsx("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:z(r.createdAt)})]},r.id))})]}):null]})]})]})}function pe(a){return JSON.stringify(a,null,2)}function Z(a){const o=a.trim();if(!o)return{};const n=JSON.parse(o);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Expected a JSON object.");return n}function ke(){var F,_,A;const a=U(),o=$(),[n,m]=w.useState(""),[R,j]=w.useState(null),[k,y]=w.useState(null),h=v({queryKey:["forge-operator-session"],queryFn:re}),X=h.isSuccess,L=v({queryKey:["forge-xp-metrics"],queryFn:ie}),I=v({queryKey:["forge-reward-rules"],queryFn:le,enabled:X}),r=v({queryKey:["forge-reward-ledger"],queryFn:()=>ne(30),enabled:X}),d=v({queryKey:["forge-psyche-overview"],queryFn:async()=>(await de()).overview}),g=D({defaultValues:{title:"",description:"",active:!0,configJson:"{}"}}),l=D({defaultValues:{entityType:"task",entityId:"",deltaXp:15,reasonTitle:"Operator bonus",reasonSummary:"Manual boost for a meaningful action captured with good provenance.",metadataJson:"{}"}}),q=async()=>{await Promise.all([o.invalidateQueries({queryKey:["forge-xp-metrics"]}),o.invalidateQueries({queryKey:["forge-reward-rules"]}),o.invalidateQueries({queryKey:["forge-reward-ledger"]})])},O=K({mutationFn:s=>Y(s.ruleId,{title:s.title,description:s.description,active:s.active,config:s.config}),onSuccess:q}),b=K({mutationFn:ee,onSuccess:q}),x=((F=I.data)==null?void 0:F.rules)??[],M=w.useMemo(()=>{var s,i,f,N,T,C,Q;return{system:[{id:"operator_manual_reward",label:"Operator reward ledger"}],goal:a.snapshot.goals.map(t=>({id:t.id,label:t.title})),project:a.snapshot.dashboard.projects.map(t=>({id:t.id,label:t.title})),task:a.snapshot.tasks.map(t=>({id:t.id,label:t.title})),habit:a.snapshot.habits.map(t=>({id:t.id,label:t.title})),tag:a.snapshot.tags.map(t=>({id:t.id,label:t.name})),note:[],insight:[],psyche_value:(((s=d.data)==null?void 0:s.values)??[]).map(t=>({id:t.id,label:t.title})),behavior_pattern:(((i=d.data)==null?void 0:i.patterns)??[]).map(t=>({id:t.id,label:t.title})),behavior:(((f=d.data)==null?void 0:f.behaviors)??[]).map(t=>({id:t.id,label:t.title})),belief_entry:(((N=d.data)==null?void 0:N.beliefs)??[]).map(t=>({id:t.id,label:t.statement})),mode_profile:(((T=d.data)==null?void 0:T.modes)??[]).map(t=>({id:t.id,label:t.title})),flashcard:(((C=d.data)==null?void 0:C.flashcards)??[]).map(t=>({id:t.id,label:t.title||t.message})),trigger_report:(((Q=d.data)==null?void 0:Q.reports)??[]).map(t=>({id:t.id,label:t.title}))}},[d.data,a.snapshot.dashboard.projects,a.snapshot.goals,a.snapshot.habits,a.snapshot.tags,a.snapshot.tasks]);w.useEffect(()=>{var N;const s=l.getValues("entityType"),i=l.getValues("entityId"),f=M[s]??[];i&&f.some(T=>T.id===i)||l.setValue("entityId",((N=f[0])==null?void 0:N.id)??"")},[l,M]),w.useEffect(()=>{x.length&&(!n||!x.some(s=>s.id===n))&&m(x[0].id)},[x,n]);const p=x.find(s=>s.id===n)??x[0]??null;w.useEffect(()=>{p&&(g.reset({title:p.title,description:p.description,active:p.active,configJson:pe(p.config)}),j(null))},[p,g]);const c=(_=L.data)==null?void 0:_.metrics,J=(((A=r.data)==null?void 0:A.ledger)??[]).filter(s=>s.metadata.manual===!0).slice(0,8);return h.isLoading?e.jsx(se,{eyebrow:"Settings · Rewards",title:"Loading reward controls",description:"Establishing the operator session and fetching reward configuration.",columns:2,blocks:6}):h.isError?e.jsx(te,{eyebrow:"Settings · Rewards",error:h.error,onRetry:()=>void h.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(ce,{title:"Rewards",description:"XP command deck, reward rule editor, manual bonus grants, and ledger history."}),e.jsx(H,{}),e.jsx("div",{className:"grid gap-5",children:e.jsxs(ae,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Reward operations"}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[c?e.jsx(xe,{profile:c.profile,achievements:c.achievements,milestoneRewards:c.milestoneRewards,momentumPulse:c.momentumPulse,recentLedger:c.recentLedger}):null,c?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(W,{label:"Total XP",value:c.profile.totalXp,tone:"core"}),e.jsx(W,{label:"Daily ambient",value:`${c.dailyAmbientXp} / ${c.dailyAmbientCap}`,tone:"core"})]}):null,e.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:"Reward rule editor"}),x.length>0?e.jsxs("form",{className:"mt-4 grid gap-4",onSubmit:g.handleSubmit(async s=>{try{j(null);const i=Z(s.configJson);if(!p)return;await O.mutateAsync({ruleId:p.id,title:s.title,description:s.description,active:s.active,config:i})}catch(i){j(i instanceof Error?i.message:"Invalid reward rule config.")}}),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Rule"}),e.jsx("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:n,onChange:s=>m(s.target.value),children:x.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Title"}),e.jsx(P,{...g.register("title")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Description"}),e.jsx(E,{className:"min-h-24",...g.register("description")})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-[18px] bg-[rgba(8,13,28,0.68)] px-4 py-3",children:[e.jsx("span",{className:"text-white/72",children:"Rule is active"}),e.jsx("input",{type:"checkbox",...g.register("active")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Config JSON"}),e.jsx(E,{className:"min-h-28 font-mono text-xs",...g.register("configJson")})]}),R?e.jsx("div",{className:"text-sm text-amber-300",children:R}):null,e.jsx(V,{type:"submit",pending:O.isPending,pendingLabel:"Saving rule",children:"Save reward rule"})]}):e.jsx("div",{className:"mt-4 text-sm text-white/58",children:"Loading reward rules…"})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:"Manual bonus XP"}),e.jsxs("form",{className:"mt-4 grid gap-4",onSubmit:l.handleSubmit(async s=>{try{y(null);const i=Z(s.metadataJson);await b.mutateAsync({entityType:s.entityType,entityId:s.entityId,deltaXp:s.deltaXp,reasonTitle:s.reasonTitle,reasonSummary:s.reasonSummary,metadata:i}),l.reset({...s,entityId:"",reasonTitle:"Operator bonus",reasonSummary:"Manual boost for a meaningful action captured with good provenance.",metadataJson:"{}"})}catch(i){y(i instanceof Error?i.message:"Invalid metadata payload.")}}),children:[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-white/58",children:"Entity type"}),e.jsx("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",...l.register("entityType"),children:Object.keys(M).map(s=>e.jsx("option",{value:s,children:s.replaceAll("_"," ")},s))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Entity id"}),e.jsx("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",...l.register("entityId"),children:(M[l.watch("entityType")]??[]).map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]})]}),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-white/58",children:"Delta XP"}),e.jsx(P,{type:"number",...l.register("deltaXp",{valueAsNumber:!0})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Reason title"}),e.jsx(P,{...l.register("reasonTitle")})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Reason summary"}),e.jsx(E,{className:"min-h-24",...l.register("reasonSummary")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Metadata JSON"}),e.jsx(E,{className:"min-h-24 font-mono text-xs",...l.register("metadataJson")})]}),k?e.jsx("div",{className:"text-sm text-amber-300",children:k}):null,e.jsx(V,{type:"submit",pending:b.isPending,pendingLabel:"Issuing bonus",children:"Issue bonus XP"})]}),b.data?e.jsxs("div",{className:"mt-4 rounded-[18px] bg-[rgba(192,193,255,0.12)] p-4 text-sm text-white",children:["Granted ",b.data.reward.deltaXp>0?"+":"",b.data.reward.deltaXp," XP for ",e.jsx("strong",{children:b.data.reward.reasonTitle}),"."]}):null]})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:"Manual bonus history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:J.length===0?e.jsx("div",{className:"rounded-[18px] bg-[rgba(8,13,28,0.68)] p-4 text-sm text-white/58",children:"No manual bonus grants yet."}):J.map(s=>e.jsxs("div",{className:"rounded-[18px] bg-[rgba(8,13,28,0.68)] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:s.reasonTitle}),e.jsxs(u,{className:s.deltaXp>=0?"text-emerald-300":"text-amber-300",children:[s.deltaXp>0?"+":"",s.deltaXp," XP"]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:s.reasonSummary||"No summary supplied."}),e.jsxs("div",{className:"mt-2 text-xs uppercase tracking-[0.16em] text-white/38",children:[s.entityType," · ",s.entityId," · ",new Date(s.createdAt).toLocaleString()]})]},s.id))})]})]})]})})]})}export{ke as SettingsRewardsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as p,j as e,aC as ee}from"./vendor-DHkYh85p.js";import{i as te,k as $}from"./state-B-4sS1xO.js";import{S as se}from"./settings-section-nav-DSOuht_F.js";import{P as ie}from"./page-hero-DRy5b2MU.js";import{i as ae,C as ne,B as re,M as le}from"./graph-D6JLqDbD.js";import{C as S,aq as ce,c as f,U as C,Q as K,F as M,j as T,I as R,T as oe,W as de,u as he,eu as xe,ev as ue,ew as pe,B as X,ex as ge}from"./index-CF4J4R9L.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";const Q=[{id:"visibility",label:"Discovery and visibility",description:"What the source user can discover, inspect, and pull into read flows on the target side.",rights:[{key:"discoverable",label:"Discoverable",description:"The target appears as a reachable collaborator in the source user's graph and pickers."},{key:"canListUsers",label:"List users",description:"The source user can include the target in directory, comparison, and routing surfaces."},{key:"canReadProfile",label:"Read profile",description:"The source user can inspect the target's identity card, handle, type, and description."},{key:"canReadEntities",label:"Read entities",description:"The source user can read the target's goals, projects, tasks, notes, strategies, and related records."},{key:"canSearchEntities",label:"Search entities",description:"The source user can find the target's work through Forge search and entity pickers."}]},{id:"coordination",label:"Messaging, context, and handoff",description:"What the source user can message, connect, and coordinate on the target side before changing execution.",rights:[{key:"canLinkEntities",label:"Share context",description:"The source user can attach the target's records into shared notes, strategies, calendar context, and cross-owner plans."},{key:"canCoordinate",label:"Message and coordinate",description:"The source user can communicate with the target through Forge, hand off work, and coordinate execution."},{key:"canViewMetrics",label:"View metrics",description:"The source user can inspect the target's XP, alignment, and progress metrics."},{key:"canViewActivity",label:"View activity",description:"The source user can inspect the target's activity stream, evidence, and execution trail."}]},{id:"execution",label:"Plan and execution control",description:"What the source user can actually change on the target side once collaboration is trusted.",rights:[{key:"canManageStrategies",label:"Manage strategies",description:"The source user can draft and update strategies that belong to the target."},{key:"canCreateOnBehalf",label:"Create on behalf",description:"The source user can intentionally create new target-owned entities."},{key:"canAffectEntities",label:"Affect entities",description:"The source user can mutate work that belongs to the target."}]}],me=[{id:"full_collab",label:"Full collaboration",description:"Use when two humans or agents can see, coordinate, plan, and change each other's work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!0,canManageStrategies:!0,canCreateOnBehalf:!0,canViewMetrics:!0,canViewActivity:!0}},{id:"coordination_only",label:"Coordinate only",description:"Use when the source user may see and coordinate with the target but should not directly mutate target-owned work.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!0,canCoordinate:!0,canAffectEntities:!1,canManageStrategies:!0,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"observe_only",label:"Observe only",description:"Use when the source user should keep visibility into the target without planning or execution control.",rights:{discoverable:!0,canListUsers:!0,canReadProfile:!0,canReadEntities:!0,canSearchEntities:!0,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!0,canViewActivity:!0}},{id:"hidden",label:"Hidden edge",description:"Use when this direction should stop discovering, reading, or acting on the target.",rights:{discoverable:!1,canListUsers:!1,canReadProfile:!1,canReadEntities:!1,canSearchEntities:!1,canLinkEntities:!1,canCoordinate:!1,canAffectEntities:!1,canManageStrategies:!1,canCreateOnBehalf:!1,canViewMetrics:!1,canViewActivity:!1}}],I=Q.reduce((t,r)=>t+r.rights.length,0);function F(t){return Object.values(t.config.rights).filter(Boolean).length}function q(t){const r=[];return t.config.rights.canReadEntities&&r.push("See"),t.config.rights.canCoordinate&&r.push("Message"),t.config.rights.canManageStrategies&&r.push("Plan"),t.config.rights.canAffectEntities&&r.push("Affect"),r.join(" · ")||"Hidden"}function be(t){return!t.config.rights.discoverable&&!t.config.rights.canReadEntities?"Hidden":t.config.rights.canAffectEntities&&t.config.rights.canManageStrategies?"Trusted":t.config.rights.canCoordinate||t.config.rights.canLinkEntities?"Coordinated":"Observed"}function Z(t){return[{id:"see",label:"See",enabled:t.config.rights.discoverable&&t.config.rights.canReadEntities&&t.config.rights.canSearchEntities},{id:"message",label:"Message",enabled:t.config.rights.canCoordinate},{id:"share",label:"Share context",enabled:t.config.rights.canLinkEntities},{id:"plan",label:"Plan",enabled:t.config.rights.canManageStrategies},{id:"affect",label:"Affect",enabled:t.config.rights.canAffectEntities||t.config.rights.canCreateOnBehalf}]}function fe(t,r){return Object.entries(r.rights).every(([i,x])=>t.config.rights[i]===x)}function we(t,r){const i=t.filter(a=>a.kind==="human"),x=t.filter(a=>a.kind==="bot"),u={x:560,y:360},g={width:226,height:132},d=i[0]??null,v=[...i.slice(d?1:0).map(a=>({user:a,radius:245,offset:-90})),...x.map(a=>({user:a,radius:390,offset:-90}))],b=v.length,N=[...d?[{user:d,position:{x:u.x-g.width/2,y:u.y-g.height/2}}]:[],...v.map((a,o)=>{const h=(a.offset+360/Math.max(b,1)*o)*Math.PI/180;return{user:a.user,position:{x:u.x+Math.cos(h)*a.radius-g.width/2,y:u.y+Math.sin(h)*a.radius-g.height/2}}})],U=new Set(r.selectedGrant?[r.selectedGrant.subjectUserId,r.selectedGrant.targetUserId]:r.selectedUserId?[r.selectedUserId]:[]);return N.map(({user:a,position:o})=>{const h=U.has(a.id),s=a.id===r.selectedUserId;return{id:a.id,position:o,draggable:!1,selectable:!1,data:{label:e.jsxs("div",{className:`min-w-[206px] rounded-[22px] border px-4 py-4 shadow-[0_24px_60px_rgba(0,0,0,0.28)] transition ${s?"border-[rgba(244,185,122,0.45)] bg-[rgba(27,16,10,0.92)]":h?"border-white/18 bg-[rgba(14,20,34,0.94)]":"border-white/10 bg-[rgba(9,15,28,0.92)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(C,{user:a}),e.jsx(f,{className:"bg-white/[0.08] text-white/65",children:a.kind})]}),e.jsxs("div",{className:"mt-3 text-xs text-white/52",children:["@",a.handle]}),e.jsx("div",{className:"mt-2 line-clamp-2 text-xs leading-5 text-white/46",children:a.description||"No user description yet."})]})},style:{background:"transparent",border:"none",padding:0}}})}function je(t,r,i){return t.filter(x=>x.subjectUserId!==x.targetUserId).map(x=>{const u=r===x.id,g=i!==null&&(x.subjectUserId===i||x.targetUserId===i),d=F(x),w=u?"#f4b97a":!x.config.rights.discoverable&&!x.config.rights.canReadEntities?"rgba(248,113,113,0.55)":g?"rgba(192,193,255,0.78)":"rgba(255,255,255,0.32)";return{id:x.id,source:x.subjectUserId,target:x.targetUserId,label:`${q(x)} · ${d}/${I}`,markerEnd:{type:le.ArrowClosed,color:w},labelStyle:{fill:u?"#f4b97a":"rgba(255,255,255,0.68)",fontSize:11,fontWeight:600},labelBgStyle:{fill:u?"rgba(34,23,16,0.96)":"rgba(8,13,24,0.94)",stroke:u?"rgba(244,185,122,0.36)":"rgba(255,255,255,0.14)",strokeWidth:1},labelBgPadding:[7,5],labelBgBorderRadius:8,style:{stroke:w,strokeWidth:u?2.5:g?1.8:1.25},animated:u}})}function ve({users:t,grants:r,selectedGrantId:i=null,selectedUserId:x=null,onOpenGrant:u,onOpenUser:g}){const d=r.find(o=>o.id===i)??null,w=p.useMemo(()=>we(t,{selectedUserId:x,selectedGrant:d}),[d,x,t]),v=p.useMemo(()=>je(r,i,x),[r,i,x]),b=p.useMemo(()=>r.filter(o=>o.subjectUserId!==o.targetUserId),[r]),N=b.filter(o=>F(o)===I).length,U=b.filter(o=>o.config.rights.canCoordinate).length,a=b.filter(o=>o.config.rights.canAffectEntities||o.config.rights.canCreateOnBehalf).length;return e.jsxs(S,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"grid gap-4 border-b border-white/8 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Directed relationship graph"}),e.jsx(ce,{content:"Keep Forge, OpenClaw, Hermes, and the browser on the same runtime and storage root when these arrows should describe one shared human and bot system.",label:"Explain the shared runtime rule"})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:"Click a user card to open that user's settings. Click any arrow to open the exact directional relationship flow for that lane."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[b.length," edges"]}),e.jsxs(f,{className:"bg-emerald-500/12 text-emerald-200",children:[N," fully open"]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Full collaboration"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:N}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions still running with the default fully open posture."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination lanes"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:U}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to coordinate directly through Forge."})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:a}),e.jsx("div",{className:"text-xs leading-5 text-white/48",children:"Directions allowed to create or mutate target-owned work."})]})]})]}),e.jsx("div",{className:"h-[min(72vh,54rem)] min-h-[34rem] bg-[radial-gradient(circle_at_top,rgba(244,185,122,0.08),transparent_34%),linear-gradient(180deg,rgba(6,10,20,0.97),rgba(8,14,26,0.94))]",children:e.jsxs(ae,{className:"user-relationship-flow",nodes:w,edges:v,fitView:!0,fitViewOptions:{padding:.18,maxZoom:.95},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:(o,h)=>{g(h.id)},onEdgeClick:(o,h)=>{u(h.id)},attributionPosition:"bottom-left",children:[e.jsx(ne,{showInteractive:!1}),e.jsx(re,{gap:28,size:1,color:"rgba(255,255,255,0.06)"})]})})]})}const Ne={kind:"human",handle:"",displayName:"",description:"",accentColor:"#c0c1ff"};function W(t){return t?{kind:t.kind,handle:t.handle,displayName:t.displayName,description:t.description,accentColor:t.accentColor}:Ne}function ye({open:t,onOpenChange:r,user:i,grants:x,ownership:u,xp:g,pending:d=!1,onSubmit:w,onOpenRelationship:v}){const[b,N]=p.useState(()=>W(i)),[U,a]=p.useState(null);p.useEffect(()=>{t&&(N(W(i)),a(null))},[t,i]);const o=p.useMemo(()=>x.filter(c=>c.subjectUserId!==c.targetUserId),[x]),h=p.useMemo(()=>i?o.filter(c=>c.subjectUserId===i.id):[],[o,i]),s=p.useMemo(()=>i?o.filter(c=>c.targetUserId===i.id):[],[o,i]),y=[{id:"identity",eyebrow:i?"Edit user":"Create user",title:i?"Update the user identity":"Add a human or bot user",description:"Set the owner type and the public identity Forge will use across ownership, routing, and collaboration surfaces.",render:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Kind",description:"Humans represent real people. Bots represent agents or automations with their own ownership lane.",children:e.jsx(T,{columns:2,value:c.kind,onChange:k=>m({kind:k}),options:[{value:"human",label:"Human",description:"Use for a real person in the Forge runtime."},{value:"bot",label:"Bot",description:"Use for an agent, assistant, or automation actor."}]})}),e.jsx(M,{label:"Handle",description:"This becomes the stable short id shown as @handle.",hint:"Use lowercase and a durable label, for example forge-operator or planner-bot.",children:e.jsx(R,{value:c.handle,onChange:k=>m({handle:k.target.value}),placeholder:"forge-operator"})}),e.jsx(M,{label:"Display name",description:"This is the human-readable label used across the UI.",children:e.jsx(R,{value:c.displayName,onChange:k=>m({displayName:k.target.value}),placeholder:"Forge Operator"})})]})},{id:"profile",eyebrow:"Profile",title:"Describe the user lane",description:"Capture what this user represents in the shared Forge runtime and pick the accent color that helps the lane stay recognizable.",render:(c,m)=>e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Description",description:"Explain what this user is responsible for and what side of the system it represents.",children:e.jsx(oe,{value:c.description,onChange:k=>m({description:k.target.value}),className:"min-h-36",placeholder:"Primary human operator for strategy, execution, and review."})}),e.jsx(M,{label:"Accent color",description:"Forge uses this accent to help the user stand out in ownership and collaboration surfaces.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{value:c.accentColor,onChange:k=>m({accentColor:k.target.value}),placeholder:"#c0c1ff"}),e.jsx("div",{className:"size-10 shrink-0 rounded-full border border-white/10",style:{backgroundColor:c.accentColor||"#c0c1ff"}})]})}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Owned records"}),e.jsx("div",{className:"mt-2 text-white",children:(u==null?void 0:u.totalOwnedEntities)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Total XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.totalXp)??0})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Weekly XP"}),e.jsx("div",{className:"mt-2 text-white",children:(g==null?void 0:g.weeklyXp)??0})]})]})]})},{id:"relationships",eyebrow:"Relationships",title:"Open directional relationship settings",description:"Each arrow is a separate contract. Open the exact lane you want to adjust and Forge will take you into the relationship flow.",render:()=>i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx(C,{user:i}),e.jsxs("div",{className:"mt-3 text-sm leading-6 text-white/56",children:["@",i.handle," · ",i.description||"No description yet."]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Outbound lanes"}),h.length>0?h.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:q(c)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(c),"/",I," rights"]})]})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No outbound relationship lanes yet."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Inbound lanes"}),s.length>0?s.map(c=>e.jsxs("button",{type:"button",className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-4 text-left transition hover:bg-white/[0.05]",onClick:()=>v(c.id),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:c.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:c.targetUser})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z(c).map(m=>e.jsx(f,{className:m.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:m.label},`${c.id}-${m.id}`))})]},c.id)):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-white/52",children:"No inbound relationship lanes yet."})]})]})]}):e.jsx("div",{className:"rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm leading-6 text-white/52",children:"Create the user first, then Forge will generate the directional relationship lanes you can tune from here."})}];return e.jsx(K,{open:t,onOpenChange:r,eyebrow:i?"User settings":"Create user",title:i?"User settings":"Create user",description:"Edit the user identity, clarify what this lane represents, and jump into relationship settings without crowding the page.",value:b,onChange:N,draftPersistenceKey:i?`users.settings.${i.id}`:"users.settings.new",steps:y,submitLabel:i?"Save user":"Create user",pending:d,pendingLabel:i?"Saving user":"Creating user",error:U,contentClassName:"lg:w-[min(58rem,calc(100vw-1.5rem))]",onSubmit:async()=>{const c=b.handle.trim(),m=b.displayName.trim();if(c.length===0){a("Add a handle before saving this user.");return}if(m.length===0){a("Add a display name before saving this user.");return}await w({userId:i==null?void 0:i.id,input:{kind:b.kind,handle:c,displayName:m,description:b.description.trim(),accentColor:b.accentColor.trim()||"#c0c1ff"}}),r(!1)}})}function z(t,r){return{accessLevel:(t==null?void 0:t.accessLevel)??"manage",applyScope:"this_arrow",rights:{discoverable:(t==null?void 0:t.config.rights.discoverable)??!0,canListUsers:(t==null?void 0:t.config.rights.canListUsers)??!0,canReadProfile:(t==null?void 0:t.config.rights.canReadProfile)??!0,canReadEntities:(t==null?void 0:t.config.rights.canReadEntities)??!0,canSearchEntities:(t==null?void 0:t.config.rights.canSearchEntities)??!0,canLinkEntities:(t==null?void 0:t.config.rights.canLinkEntities)??!0,canCoordinate:(t==null?void 0:t.config.rights.canCoordinate)??!0,canAffectEntities:(t==null?void 0:t.config.rights.canAffectEntities)??!0,canManageStrategies:(t==null?void 0:t.config.rights.canManageStrategies)??!0,canCreateOnBehalf:(t==null?void 0:t.config.rights.canCreateOnBehalf)??!0,canViewMetrics:(t==null?void 0:t.config.rights.canViewMetrics)??!0,canViewActivity:(t==null?void 0:t.config.rights.canViewActivity)??!0}}}function ke({open:t,onOpenChange:r,grant:i,grants:x,pending:u=!1,onSubmit:g}){const d=p.useMemo(()=>i?x.find(a=>a.subjectUserId===i.targetUserId&&a.targetUserId===i.subjectUserId)??null:null,[i,x]),[w,v]=p.useState(()=>z(i,!!d));p.useEffect(()=>{t&&v(z(i,!!d))},[i,t,d]);const b=p.useMemo(()=>Object.values(w.rights).filter(Boolean).length,[w.rights]),N=Math.round(b/I*100),U=[{id:"posture",eyebrow:"Relationship posture",title:"Set the trust mode for this arrow",description:"Each arrow is directional. Decide whether you want to tune only this lane or mirror the same contract onto both directions.",render:(a,o)=>e.jsxs(e.Fragment,{children:[i?e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(C,{user:i.subjectUser}),e.jsx("span",{className:"text-white/45",children:"→"}),e.jsx(C,{user:i.targetUser})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(f,{className:"bg-white/[0.08] text-white/74",children:be(i)}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:[F(i),"/",I," rights"]})]})]}):null,e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Access level"}),e.jsx(T,{columns:2,value:a.accessLevel,onChange:h=>o({accessLevel:h}),options:[{value:"view",label:"View",description:"Use when this lane should stay mostly observational."},{value:"manage",label:"Manage",description:"Use when the source side can actively collaborate or act."}]})]}),d?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Apply scope"}),e.jsx(T,{columns:2,value:a.applyScope,onChange:h=>o({applyScope:h}),options:[{value:"this_arrow",label:"This arrow",description:"Only change the exact direction you opened."},{value:"both_arrows",label:"Both arrows",description:"Mirror the same contract onto the reverse direction too."}]})]}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Quick preset"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:me.map(h=>e.jsxs("button",{type:"button",className:`rounded-[22px] border p-4 text-left transition ${i&&fe(i,h)?"border-[rgba(244,185,122,0.35)] bg-[rgba(244,185,122,0.08)]":"border-white/8 bg-white/[0.03] hover:bg-white/[0.05]"}`,onClick:()=>o({rights:{...a.rights,...h.rights}}),children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/56",children:h.description})]},h.id))})]})]})},{id:"rights",eyebrow:"Rights",title:"Tune the individual permissions",description:"Use the preset as the starting point, then sharpen the exact boundaries only where this relationship needs them.",render:(a,o)=>e.jsx(e.Fragment,{children:Q.map(h=>e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:h.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/54",children:h.description})]}),e.jsx("div",{className:"grid gap-2",children:h.rights.map(s=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white",children:s.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/50",children:s.description})]}),e.jsx("input",{type:"checkbox",checked:a.rights[s.key],onChange:y=>o({rights:{...a.rights,[s.key]:y.target.checked}})})]},s.key))})]},h.id))})},{id:"review",eyebrow:"Review",title:"Review the final relationship contract",description:"Check the enabled capabilities, confirm whether both directions should match, and then save the relationship.",render:a=>{var o,h;return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Capability coverage"}),e.jsx("div",{className:"mt-4",children:e.jsx(de,{value:N})}),e.jsxs("div",{className:"mt-3 text-sm text-white/62",children:[b,"/",I," rights enabled"]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:Z({...i??{id:"draft",subjectUserId:"",targetUserId:"",accessLevel:a.accessLevel,config:{self:!1,mutable:!0,linkedEntities:!0,rights:a.rights},createdAt:"",updatedAt:"",subjectUser:null,targetUser:null},accessLevel:a.accessLevel,config:{...(i==null?void 0:i.config)??{self:!1,mutable:!0,linkedEntities:!0},rights:a.rights}}).map(s=>e.jsx(f,{className:s.enabled?"bg-white/[0.08] text-white/74":"bg-white/[0.04] text-white/38",children:s.label},s.id))})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Save scope"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/58",children:a.applyScope==="both_arrows"&&d?"Forge will apply the same access level and rights to both directions of this pair.":"Forge will only update the exact arrow you opened."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:["access ",a.accessLevel]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/74",children:["scope"," ",a.applyScope==="both_arrows"&&d?"both arrows":"this arrow"]})]}),d?e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3 text-sm text-white/54",children:["Reverse arrow available:"," ",((o=d.subjectUser)==null?void 0:o.displayName)??d.subjectUserId," ","→"," ",((h=d.targetUser)==null?void 0:h.displayName)??d.targetUserId]}):null]})]})})}}];return e.jsx(K,{open:t,onOpenChange:r,eyebrow:"Relationship settings",title:"Relationship settings",description:"Edit the exact directional contract between two users without keeping the full rights editor pinned on the page.",value:w,onChange:v,draftPersistenceKey:i?`users.relationship.${i.id}`:"users.relationship.new",steps:U,submitLabel:"Save relationship",pending:u,pendingLabel:"Saving relationship",contentClassName:"lg:w-[min(62rem,calc(100vw-1.5rem))]",onSubmit:async()=>{i&&(await g({grantId:i.id,patch:{accessLevel:w.accessLevel,rights:w.rights},reverseGrantId:(d==null?void 0:d.id)??null,applyToReverse:w.applyScope==="both_arrows"&&d!==null}),r(!1))}})}function Le(){var P;const t=he(),[r,i]=p.useState(null),[x,u]=p.useState(null),[g,d]=p.useState(!1),[w,v]=p.useState(!1),[b,N]=p.useState(""),U=te({queryKey:["forge-user-directory"],queryFn:ge}),a=async()=>{await Promise.all([t.refresh(),U.refetch()])},o=$({mutationFn:async({input:n,userId:l})=>l?(await xe(l,n)).user:(await ue(n)).user,onSuccess:async()=>{i(null),d(!1),await a()}}),h=$({mutationFn:async({grantId:n,patch:l})=>(await pe(n,l)).grant,onSuccess:a}),s=(P=U.data)==null?void 0:P.directory,y=(s==null?void 0:s.grants.find(n=>n.id===x))??null,c=p.useMemo(()=>new Map(((s==null?void 0:s.ownership)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.ownership]),m=p.useMemo(()=>new Map(((s==null?void 0:s.xp)??[]).map(n=>[n.userId,n])),[s==null?void 0:s.xp]),k=p.useMemo(()=>{const n=new Map;for(const l of(s==null?void 0:s.grants)??[]){if(!l.targetUser||l.subjectUserId===l.targetUserId)continue;const j=n.get(l.subjectUserId)??[];j.push(l.targetUser),n.set(l.subjectUserId,j)}return n},[s==null?void 0:s.grants]),O=p.useMemo(()=>{const n=((s==null?void 0:s.grants)??[]).filter(l=>l.subjectUserId!==l.targetUserId);return{totalEdges:n.length,fullyOpenEdges:n.filter(l=>Object.values(l.config.rights).every(Boolean)).length,coordinationEdges:n.filter(l=>l.config.rights.canCoordinate).length,executionEdges:n.filter(l=>l.config.rights.canAffectEntities||l.config.rights.canCreateOnBehalf).length}},[s==null?void 0:s.grants]),A=b.trim().toLowerCase(),B=p.useMemo(()=>{const l=((s==null?void 0:s.users)??t.snapshot.users).filter(j=>A?[j.displayName,j.handle,j.kind,j.description].join(" ").toLowerCase().includes(A):!0);return{humans:l.filter(j=>j.kind==="human"),bots:l.filter(j=>j.kind==="bot")}},[s==null?void 0:s.users,A,t.snapshot.users]),J=(y==null?void 0:y.subjectUserId)??(r==null?void 0:r.id)??null,Y=(y==null?void 0:y.id)??null;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ie,{title:"Users",description:"Forge users can be human or bot. Ownership, search, and routing are prepared so work can move across both sides of the system.",badge:`${t.snapshot.users.length} users`}),e.jsx(se,{}),e.jsx(ye,{open:g,onOpenChange:d,user:r,grants:(s==null?void 0:s.grants)??[],ownership:r?c.get(r.id)??null:null,xp:r?m.get(r.id)??null:null,pending:o.isPending,onSubmit:async n=>{await o.mutateAsync(n)},onOpenRelationship:n=>{d(!1),u(n),v(!0)}}),e.jsx(ke,{open:w,onOpenChange:v,grant:y,grants:(s==null?void 0:s.grants)??[],pending:h.isPending,onSubmit:async n=>{await h.mutateAsync({grantId:n.grantId,patch:n.patch}),n.applyToReverse&&n.reverseGrantId&&await h.mutateAsync({grantId:n.reverseGrantId,patch:n.patch})}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Multi-user posture"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:(s==null?void 0:s.posture.summary)??"Forge is preparing modular user access while keeping the current posture permissive."})]}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:(s==null?void 0:s.posture.accessModel)??"permissive"})]}),e.jsx("div",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:e.jsx(R,{value:b,onChange:n=>N(n.target.value),placeholder:"Search human, bot, @handle, or description"})})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(S,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Multi-agent onboarding"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:"Forge now treats the users graph as the collaboration control plane. Create each human or bot here, keep the runtime shared, then narrow only the specific arrows that should stop seeing, coordinating, planning, or affecting another user."})]}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:"default open"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Directional edges"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.totalEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Fully open"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.fullyOpenEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Coordination"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.coordinationEdges})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Execution control"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:O.executionEdges})]})]}),e.jsxs("div",{className:"grid gap-2 text-sm leading-6 text-white/56",children:[e.jsx("div",{children:"1. Create the human and bot users that should exist in the shared Forge system."}),e.jsx("div",{children:"2. Point OpenClaw, Hermes, and the browser at the same Forge runtime and storage root."}),e.jsx("div",{children:"3. Use the graph below to decide what each direction can see, message, plan, or change."}),e.jsx("div",{children:"4. Keep strategy drafting open while the plan is negotiated, then lock the strategy once it becomes the contract."})]})]}),e.jsx(ve,{users:(s==null?void 0:s.users)??t.snapshot.users,grants:(s==null?void 0:s.grants)??[],selectedGrantId:Y,selectedUserId:J,onOpenUser:n=>{const l=((s==null?void 0:s.users)??t.snapshot.users).find(j=>j.id===n)??null;u(null),i(l),d(!0)},onOpenGrant:n=>{i(null),u(n),v(!0)}}),e.jsxs(S,{className:"grid gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Agent onboarding"}),e.jsx("div",{className:"text-sm leading-6 text-white/60",children:"OpenClaw, Hermes, and the Forge UI all read this same multi-user graph. Keep the defaults open while you are still wiring collaboration, then narrow specific arrows when one user or agent should stop seeing, messaging, planning, or changing another user's work."}),e.jsx("div",{className:"text-sm leading-6 text-white/52",children:"Forge now treats every owner as either human or bot, keeps search cross-user by default, and allows cross-owner links plus explicit coordination lanes between projects, tasks, notes, and strategies."}),e.jsx("div",{children:e.jsx(ee,{to:"/settings/agents",className:"inline-flex min-h-10 items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-3 py-2 text-[13px] font-medium text-white transition hover:bg-white/12",children:"Open agent onboarding"})})]})]}),e.jsx(S,{children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"User directory"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:"Open any user to edit its identity and jump into the exact directional relationship lanes from the user settings flow."})]}),e.jsx(X,{onClick:()=>{u(null),i(null),d(!0)},children:"Create user"})]})}),e.jsx("div",{className:"grid gap-5",children:[{title:"Human users",users:B.humans},{title:"Bot users",users:B.bots}].map(n=>e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:n.title}),e.jsx(f,{className:"bg-white/[0.08] text-white/72",children:n.users.length})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:n.users.map(l=>{var j,D,G,_,H,V;return e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(C,{user:l}),e.jsxs("div",{className:"mt-3 text-sm text-white/58",children:["@",l.handle]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:l.description||"No description yet."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(f,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[((j=m.get(l.id))==null?void 0:j.totalXp)??0," XP"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((D=m.get(l.id))==null?void 0:D.weeklyXp)??0," weekly"]}),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((G=m.get(l.id))==null?void 0:G.rewardEventCount)??0," ","rewards"]}),Object.entries(((_=c.get(l.id))==null?void 0:_.entityCounts)??{}).sort((E,L)=>L[1]-E[1]).slice(0,4).map(([E,L])=>e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[L," ",E]},`${l.id}-${E}`)),e.jsxs(f,{className:"bg-white/[0.08] text-white/70",children:[((H=c.get(l.id))==null?void 0:H.totalOwnedEntities)??0," ","owned"]})]}),e.jsxs("div",{className:"mt-3 text-xs leading-5 text-white/50",children:["Can currently read:"," ",(k.get(l.id)??[]).map(E=>`${E.displayName} (${E.kind})`).join(", ")||"no other users"]}),(V=m.get(l.id))!=null&&V.lastRewardAt?e.jsxs("div",{className:"mt-2 text-xs leading-5 text-white/45",children:["Last XP movement:"," ",new Date(m.get(l.id).lastRewardAt).toLocaleString()]}):null]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(X,{variant:"secondary",onClick:()=>{u(null),i(l),d(!0)},children:"Open settings"})})]})},l.id)})})]},n.title))})]})]})}export{Le as SettingsUsersPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r,j as e,aC as W,bg as H,c7 as T,cD as Y,cE as Z}from"./vendor-DHkYh85p.js";import{j as X,i as Q,k as x}from"./state-B-4sS1xO.js";import{S as J}from"./settings-section-nav-DSOuht_F.js";import{P as ee}from"./page-hero-DRy5b2MU.js";import{bV as ie,bW as se,bX as te,bY as ae,bZ as ne,L as re,E as q,B as p,C as w,c as j,aq as de,I as l,b_ as le,b$ as ce}from"./index-CF4J4R9L.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const R=[{value:"gpt-5.4",label:"GPT-5.4",description:"Highest quality drafting for long, connected wiki pages."},{value:"gpt-5.4-mini",label:"GPT-5.4 mini",description:"Balanced speed and quality for regular ingest jobs."},{value:"gpt-5.4-nano",label:"GPT-5.4 nano",description:"Fastest and cheapest option for smaller imports."}];R[1].value;const oe="medium",me="medium";function he(s){const t=s==null?void 0:s.reasoningEffort;return t==="none"||t==="low"||t==="medium"||t==="high"||t==="xhigh"?t:oe}function xe(s){const t=s==null?void 0:s.verbosity;return t==="low"||t==="medium"||t==="high"?t:me}function z(s){var m;return{model:((m=R.find(g=>g.value===s.model))==null?void 0:m.label)??s.model,reasoning:he(s.metadata),verbosity:xe(s.metadata),hasKey:!!s.secretId}}function ke(){var F,O;const s=X(),[t,m]=r.useState(""),[g,y]=r.useState(""),[N,f]=r.useState("personal"),[u,U]=r.useState("Fast wiki search"),[b,B]=r.useState("text-embedding-3-small"),[k,_]=r.useState("https://api.openai.com/v1"),[S,C]=r.useState(""),[L,D]=r.useState("1200"),[P,G]=r.useState("200"),c=Q({queryKey:["forge-wiki-settings"],queryFn:le}),V=Q({queryKey:["forge-settings"],queryFn:ce}),h=async()=>{await Promise.all([s.invalidateQueries({queryKey:["forge-wiki-settings"]}),s.invalidateQueries({queryKey:["forge-wiki-pages"]}),s.invalidateQueries({queryKey:["forge-wiki-page"]}),s.invalidateQueries({queryKey:["forge-wiki-search"]})])},K=x({mutationFn:()=>ie({label:t.trim(),description:g.trim(),visibility:N}),onSuccess:async()=>{m(""),y(""),f("personal"),await h()}}),A=x({mutationFn:()=>se({label:u.trim(),model:b.trim(),baseUrl:k.trim(),apiKey:S.trim()||void 0,chunkSize:Number(L),chunkOverlap:Number(P)}),onSuccess:async()=>{C(""),await h()}}),I=x({mutationFn:({kind:i,profileId:o})=>te(i,o),onSuccess:h}),E=x({mutationFn:()=>ae(),onSuccess:h}),M=x({mutationFn:()=>ne(),onSuccess:h});if(c.isLoading)return e.jsx(re,{eyebrow:"KarpaWiki settings",title:"Loading KarpaWiki controls",description:"Fetching spaces and profile configuration for KarpaWiki."});if(c.isError)return e.jsx(q,{eyebrow:"KarpaWiki settings",error:c.error,onRetry:()=>void c.refetch()});const n=(F=c.data)==null?void 0:F.settings;if(!n)return e.jsx(q,{eyebrow:"KarpaWiki settings",error:new Error("Forge returned an empty KarpaWiki settings payload."),onRetry:()=>void c.refetch()});const d=n.llmProfiles.find(i=>i.enabled)??n.llmProfiles[0]??null,v=d?z(d):null,$="Canonical knowledge lives in SQLite notes, with Forge maintaining metadata, links, search, and optional embedding indexes in the database. Text search and entity-linked search work without embeddings, while semantic search stays additive and profile-driven. Ingest jobs can create pages and media assets now, with room for richer OCR, transcription, and multimodal compilation later.",a=(O=V.data)==null?void 0:O.settings.modelSettings.forgeAgent.wiki;return e.jsxs("div",{className:"mx-auto grid w-full max-w-[1440px] gap-5",children:[e.jsx(ee,{eyebrow:"SQLite memory",title:"KarpaWiki Settings",titleText:"KarpaWiki Settings",description:"Configure SQLite-backed spaces, parse models, and embedding profiles for the KarpaWiki memory system.",badge:`${n.spaces.length} spaces · ${n.embeddingProfiles.length} embedding profiles`,actions:e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"secondary",pending:E.isPending,pendingLabel:"Syncing",onClick:()=>void E.mutateAsync(),children:"Refresh indexes"}),e.jsx(p,{pending:M.isPending,pendingLabel:"Reindexing",onClick:()=>void M.mutateAsync(),disabled:n.embeddingProfiles.length===0,children:"Reindex embeddings"})]})}),e.jsx(J,{}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{className:"grid gap-4",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Auto-ingest model"}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"KarpaWiki ingest now reads its credentials and model slot from the dedicated Models settings page instead of owning the OpenAI setup flow here."})]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.8fr)_minmax(24rem,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-5 rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(22,32,49,0.9),rgba(12,18,31,0.9))] p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Current profile"}),e.jsx("div",{className:"mt-2 text-xl font-semibold text-white",children:(a==null?void 0:a.connectionLabel)??(d==null?void 0:d.label)??"No external KarpaWiki model selected"}),e.jsx("div",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/58",children:a!=null&&a.connectionLabel?"Forge now resolves wiki ingest through the selected Models connection and syncs the managed wiki profile automatically.":"Pick a Models connection when you want Forge wiki ingest to run through the OpenAI API or a local compatible endpoint."})]}),e.jsx(W,{to:"/settings/models",className:"inline-flex min-h-11 items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:"Open model settings"})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Model"}),e.jsx("div",{className:"mt-2 text-white",children:(a==null?void 0:a.model)??(v==null?void 0:v.model)??"Not set"})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Provider"}),e.jsx("div",{className:"mt-2 text-white",children:(a==null?void 0:a.connectionLabel)??"Not set"})]}),e.jsxs("div",{className:"rounded-[20px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Endpoint"}),e.jsx("div",{className:"mt-2 flex items-center gap-2 text-white",children:(a==null?void 0:a.baseUrl)??(d==null?void 0:d.baseUrl)??"Not set"})]})]})]}),e.jsxs("div",{className:"grid gap-3 rounded-[28px] border border-white/8 bg-white/[0.03] p-6",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Supported controls"}),e.jsxs("div",{className:"text-sm leading-6 text-white/58",children:["OpenAI API and local compatible endpoints are configured under Settings ","->"," Models. OpenAI Codex OAuth lives there as a chat agent path, while Wiki keeps the SQLite memory controls here and consumes the selected ingest model slot."]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["GPT-5.4","GPT-5.4 mini","GPT-5.4 nano"].map(i=>e.jsx(j,{className:"bg-white/[0.06] text-white/78",children:i},i))}),e.jsxs(W,{to:"/settings/models",className:"inline-flex min-h-11 items-center rounded-[16px] bg-white/[0.08] px-4 py-3 text-sm text-white transition hover:bg-white/[0.12]",children:["Open model settings",e.jsx(H,{className:"ml-2 size-4"})]})]})]}),e.jsxs("div",{className:"grid gap-3",children:[n.llmProfiles.length===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-5 text-sm leading-6 text-white/58",children:"No LLM profile yet. Set up OpenAI once, test it, and Forge will use it for wiki auto-ingest."}):null,n.llmProfiles.map(i=>{const o=z(i);return e.jsxs("div",{className:"grid gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsxs("div",{className:"mt-1 text-xs text-white/46",children:[o.model," · thinking ",o.reasoning," · verbosity ",o.verbosity]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",className:"rounded-full p-2 text-white/48 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>void I.mutateAsync({kind:"llm",profileId:i.id}),children:e.jsx(T,{className:"size-4"})})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-white/58",children:[e.jsx(j,{className:"bg-white/[0.06] text-white/76",children:i.baseUrl}),e.jsx(j,{className:"bg-white/[0.06] text-white/76",children:o.hasKey?"key saved":"key missing"})]})]},i.id)})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm text-white",children:"Spaces"}),e.jsx(de,{content:$,label:"Explain the wiki operating model"})]}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"Personal and shared wiki spaces map to explicit SQLite namespaces."})]})]}),e.jsx("div",{className:"grid gap-3",children:n.spaces.map(i=>e.jsxs("div",{className:"grid gap-1 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-white/42",children:i.visibility})]}),e.jsx("div",{className:"text-xs text-white/46",children:i.slug}),e.jsx("div",{className:"text-sm text-white/60",children:i.description||"No description yet."})]},i.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsx(l,{value:t,onChange:i=>m(i.target.value),placeholder:"New space label"}),e.jsx(l,{value:g,onChange:i=>y(i.target.value),placeholder:"Description"}),e.jsxs("select",{className:"rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-3 text-sm text-white",value:N,onChange:i=>f(i.target.value),children:[e.jsx("option",{value:"personal",children:"Personal"}),e.jsx("option",{value:"shared",children:"Shared"})]}),e.jsx(p,{pending:K.isPending,pendingLabel:"Creating",disabled:!t.trim(),onClick:()=>void K.mutateAsync(),children:"Create space"})]})]}),e.jsxs(w,{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Z,{className:"size-4 text-[var(--secondary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white",children:"Embedding profiles"}),e.jsx("div",{className:"text-xs leading-5 text-white/50",children:"Semantic search stays opt-in. The recommended starter is fast and cheap, with heading-aware chunking for agent memory retrieval."})]})]}),e.jsx("div",{className:"grid gap-3",children:n.embeddingProfiles.map(i=>e.jsxs("div",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-white",children:i.label}),e.jsx("button",{type:"button",className:"rounded-full p-2 text-white/48 transition hover:bg-white/[0.08] hover:text-white",onClick:()=>void I.mutateAsync({kind:"embedding",profileId:i.id}),children:e.jsx(T,{className:"size-4"})})]}),e.jsxs("div",{className:"text-xs text-white/46",children:[i.model," · ",i.baseUrl]}),e.jsxs("div",{className:"text-sm text-white/60",children:["chunkSize ",i.chunkSize," · overlap"," ",i.chunkOverlap]})]},i.id))}),e.jsxs("div",{className:"grid gap-3 rounded-[20px] bg-white/[0.03] p-4",children:[e.jsx(l,{value:u,onChange:i=>U(i.target.value),placeholder:"Profile label"}),e.jsx(l,{value:b,onChange:i=>B(i.target.value),placeholder:"Model"}),e.jsx(l,{value:k,onChange:i=>_(i.target.value),placeholder:"Base URL"}),e.jsx(l,{value:S,onChange:i=>C(i.target.value),placeholder:"API key (optional)",type:"password"}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(l,{value:L,onChange:i=>D(i.target.value),placeholder:"Chunk size",type:"number"}),e.jsx(l,{value:P,onChange:i=>G(i.target.value),placeholder:"Chunk overlap",type:"number"})]}),e.jsx(p,{pending:A.isPending,pendingLabel:"Saving",disabled:!u.trim()||!b.trim(),onClick:()=>void A.mutateAsync(),children:"Save embedding profile"})]})]})]})]})]})}export{ke as SettingsWikiPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as g,j as e,aV as te,cq as se,bX as ae}from"./vendor-DHkYh85p.js";import{j as re,i as A,k as ie}from"./state-B-4sS1xO.js";import{u as ne,eC as de,S as le,E as ce,ck as oe,eD as xe,eE as me,C as S,c as p,eF as he,Z as v,B as C,I as Q,T as pe,m as ue,bL as ge,eG as we,bw as be,bx as ve,by as fe,bz as je,bC as ye}from"./index-CF4J4R9L.js";import{P as Ne}from"./page-hero-DRy5b2MU.js";import{p as Se,b as ke}from"./health-link-options-Cpx8w7uM.js";import"./board-BkDRaMp6.js";import"./ui-C13Nbgas.js";import"./motion-BeD44FeG.js";import"./forms-BFlTgZ3W.js";import"./graph-D6JLqDbD.js";const Ae=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],W={awake:{label:"Awake",strong:"rgba(251, 191, 36, 0.95)",soft:"rgba(251, 191, 36, 0.16)",text:"text-amber-200"},core:{label:"Core",strong:"rgba(165, 180, 252, 0.96)",soft:"rgba(165, 180, 252, 0.18)",text:"text-indigo-100"},deep:{label:"Deep",strong:"rgba(45, 212, 191, 0.96)",soft:"rgba(45, 212, 191, 0.18)",text:"text-teal-100"},rem:{label:"REM",strong:"rgba(96, 165, 250, 0.96)",soft:"rgba(96, 165, 250, 0.18)",text:"text-sky-100"},in_bed:{label:"In bed",strong:"rgba(255, 255, 255, 0.4)",soft:"rgba(255, 255, 255, 0.1)",text:"text-white/72"},asleep_unspecified:{label:"Asleep",strong:"rgba(196, 181, 253, 0.96)",soft:"rgba(196, 181, 253, 0.16)",text:"text-violet-100"}};function I(t){return W[t]??W.asleep_unspecified}function u(t){if(t<=0)return"0m";const s=Math.floor(t/3600),a=Math.round(t%3600/60);return s===0?`${a}m`:a===0?`${s}h`:`${s}h ${a}m`}function Te(t){const s=Math.round(t/60);return s===0?"on baseline":`${s>0?"+":"-"}${Math.abs(s)}m`}function R(t){return`${Math.round(t*100)}%`}function T(t,s){return t?new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",timeZone:s}).format(new Date(t)):"n/a"}function O(t,s){return new Intl.DateTimeFormat(void 0,{weekday:"long",day:"numeric",month:"long",timeZone:s}).format(new Date(t))}function q(t,s,a){return`${T(t,a)} - ${T(s,a)}`}function Re(t){const[s,a]=t.split("-").map(Number);return new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(s,(a??1)-1,1))}function U(t){const s=new Date(t),a=(t.getDay()+6)%7;return s.setDate(t.getDate()-a),s}function Me(t){const s=U(t);return s.setDate(s.getDate()+6),s}function _e(t){const s=t.getFullYear(),a=`${t.getMonth()+1}`.padStart(2,"0"),r=`${t.getDate()}`.padStart(2,"0");return`${s}-${a}-${r}`}function B(t){return{qualitySummary:typeof t.annotations.qualitySummary=="string"?t.annotations.qualitySummary:"",notes:typeof t.annotations.notes=="string"?t.annotations.notes:"",tagsText:Array.isArray(t.annotations.tags)?t.annotations.tags.join(", "):"",linkValues:Array.isArray(t.links)?t.links.map(s=>`${s.entityType}:${s.entityId}`):[]}}function De(t,s){if(!t)return[];const[a,r]=t.split("-").map(Number),n=new Date(a,(r??1)-1,1),x=new Date(a,r??1,0),d=U(n),h=Me(x),l=new Map(s.map(c=>[c.dateKey,c])),i=[];for(const c=new Date(d);c<=h;c.setDate(c.getDate()+1)){const j=_e(c);i.push({dateKey:j,dayNumber:c.getDate(),outsideMonth:c.getMonth()!==n.getMonth(),sleep:l.get(j)??null})}return i}function Ie(t){return t>0?"text-emerald-200":t<0?"text-rose-200":"text-white/70"}function G(t){return t==="recharged"||t==="recovered"?"bg-emerald-400/16 text-emerald-100":t==="steady"||t==="stable"?"bg-sky-400/16 text-sky-100":t==="fragile"||t==="strained"?"bg-amber-400/16 text-amber-100":t==="depleted"?"bg-rose-400/16 text-rose-100":"bg-white/10 text-white/76"}function Be(t){return t==="provider_raw"?"bg-emerald-400/16 text-emerald-100":t==="historical_raw"?"bg-amber-400/16 text-amber-100":"bg-white/10 text-white/70"}function qe(t){return t==="provider_raw"?"Provider raw data":t==="historical_raw"?"Historical raw data":"Raw data unavailable"}function Ce(t){return t.qualityKind==="provider_native"?"bg-emerald-400/16 text-emerald-100":"bg-amber-400/16 text-amber-100"}function $e(t,s){const a=t.stage;if(typeof a=="string"&&a.trim().length>0)return a;const r=t.sourceType;if(typeof r=="string"&&r.trim().length>0)return r;const n=t.stageBreakdown;if(Array.isArray(n)&&n.length>0){const x=n[0];if(x&&typeof x=="object"&&typeof x.stage=="string")return(x.stage||"asleep_unspecified").trim()}return s.includes("awake")?"awake":"asleep_unspecified"}function Ee(t){const s=t,a=(s==null?void 0:s.segments)??(s==null?void 0:s.rawSegments)??[],r=(s==null?void 0:s.auditLogs)??(s==null?void 0:s.rawLogs)??[],n=s!=null&&s.sourceRecords&&s.sourceRecords.length>0?s.sourceRecords:r.filter(d=>typeof d.startedAt=="string"&&typeof d.endedAt=="string").map(d=>({id:d.id,importRunId:d.importRunId,pairingSessionId:d.pairingSessionId,sleepSessionId:d.sleepSessionId,userId:d.userId,provider:d.source,providerRecordType:d.logType,providerRecordUid:d.externalUid??d.id,sourceDevice:"",sourceTimezone:d.sourceTimezone,localDateKey:d.localDateKey,startedAt:d.startedAt,endedAt:d.endedAt,rawStage:$e(d.payload,d.logType),rawValue:null,qualityKind:"historical_import",payload:d.payload,metadata:d.metadata,ingestedAt:d.createdAt})),x=(s==null?void 0:s.rawDataStatus)??(n.length>0?"historical_raw":"raw_unavailable");return{sourceRecords:n,segments:a,auditLogs:r,rawDataStatus:x}}function J({stages:t}){const s=t.reduce((a,r)=>a+r.seconds,0);return t.length===0||s===0?e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No stage composition was stored for this night yet."}):e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"flex h-3 overflow-hidden rounded-full bg-white/[0.08]",children:t.map(a=>{const r=I(a.stage);return e.jsx("div",{className:"h-full",style:{width:`${Math.max(4,a.seconds/s*100)}%`,background:r.strong},title:`${r.label} · ${u(a.seconds)}`},a.stage)})}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:t.map(a=>{const r=I(a.stage),n="percentage"in a&&typeof a.percentage=="number"?a.percentage:s>0?a.seconds/s:0;return e.jsxs("div",{className:"rounded-[16px] border border-white/8 px-3 py-3",style:{background:r.soft},children:[e.jsx("div",{className:v("text-sm font-medium",r.text),children:r.label}),e.jsx("div",{className:"mt-1 text-lg text-white",children:u(a.seconds)}),e.jsx("div",{className:"text-xs text-white/54",children:R(n)})]},a.stage)})})]})}function H({blocks:t,selectedBlockId:s,onSelect:a}){return e.jsxs("div",{className:"relative h-12 overflow-hidden rounded-[18px] border border-white/8 bg-black/20",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[linear-gradient(90deg,rgba(255,255,255,0.06)_1px,transparent_1px)] bg-[length:25%_100%]"}),t.map(r=>{const n=I(r.stage),x=s===r.id;return e.jsx("button",{type:"button",onClick:()=>a(r.id),className:v("absolute inset-y-[5px] rounded-[12px] border transition",x?"border-white/60 shadow-[0_0_0_1px_rgba(255,255,255,0.18)]":"border-white/10"),style:{left:`${r.offsetRatio*100}%`,width:`${Math.max(r.widthRatio*100,1.8)}%`,background:n.strong},title:`${r.label} · ${u(r.durationSeconds)} · ${r.startedAt} - ${r.endedAt}`,children:r.widthRatio>.13?e.jsx("span",{className:"truncate px-2 text-[10px] font-medium text-slate-950/85",children:r.label}):null},r.id)})]})}function Ke({timeline:t,timeZone:s}){var l,i;const a=t.blocks.filter(c=>c.lane==="in_bed"),r=t.blocks.filter(c=>c.lane==="sleep"),n=((l=r[0])==null?void 0:l.id)??((i=a[0])==null?void 0:i.id)??null,[x,d]=g.useState(n);g.useEffect(()=>{d(n)},[n,t.startedAt,t.endedAt,t.totalSeconds]);const h=t.blocks.find(c=>c.id===x)??null;return t.hasRawSegments?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-3",children:[a.length>0?e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed window"}),e.jsx(H,{blocks:a,selectedBlockId:x,onSelect:d})]}):null,e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:t.hasSleepStageData?"Sleep phases":"Recorded sleep coverage"}),e.jsx(H,{blocks:r.length>0?r:a,selectedBlockId:x,onSelect:d})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-white/48",children:[e.jsx("span",{children:T(t.startedAt,s)}),e.jsx("span",{children:u(t.totalSeconds)}),e.jsx("span",{children:T(t.endedAt,s)})]}),h?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:v("text-sm font-medium",I(h.stage).text),children:h.label}),e.jsxs("div",{className:"mt-1 text-sm text-white/58",children:[T(h.startedAt,s)," -"," ",T(h.endedAt,s)]})]}),e.jsx(p,{tone:"meta",children:u(h.durationSeconds)})]})}):null]}):e.jsx("div",{className:"rounded-[18px] border border-dashed border-white/10 bg-black/10 px-4 py-5 text-sm text-white/56",children:"Phase timing is unavailable for this night. Forge still keeps the canonical overnight summary, but the companion did not store segment-level timing."})}function Fe({latestNight:t}){return t?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(135deg,rgba(7,17,40,0.96),rgba(16,24,54,0.94))] p-0",children:e.jsxs("div",{className:"relative overflow-hidden px-6 py-6 sm:px-7 sm:py-7",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top_right,rgba(96,165,250,0.22),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(45,212,191,0.14),transparent_34%)]"}),e.jsxs("div",{className:"relative grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(p,{className:v("border-white/0",G(t.recoveryState)),children:t.qualitativeState}),e.jsx(p,{tone:"meta",children:t.sourceTimezone}),t.hasReflection?e.jsx(p,{tone:"meta",children:"Has reflection"}):null,t.hasRawSegments?e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}):null]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.2em] text-white/42",children:"Last night"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-end gap-x-4 gap-y-2",children:[e.jsx("div",{className:"text-[clamp(2.5rem,6vw,5rem)] font-medium leading-none text-white",children:u(t.asleepSeconds)}),e.jsxs("div",{className:"pb-2 text-sm text-white/58",children:["asleep across ",q(t.startedAt,t.endedAt,t.sourceTimezone)]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/64",children:O(t.endedAt,t.sourceTimezone)}),t.qualitySummary?e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/72",children:t.qualitySummary}):e.jsx("div",{className:"mt-4 max-w-2xl text-sm leading-6 text-white/56",children:"Canonical overnight summary computed from synced sleep segments, with raw evidence still available underneath."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Score"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.score??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Regularity"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:t.regularity??"n/a"})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-black/20 px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(t.efficiency)})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Baseline"}),e.jsx("div",{className:"mt-2 text-lg text-white",children:"Compared with recent nights"})]}),e.jsx(se,{className:"size-5 text-[var(--primary)]"})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"7-night average"}),e.jsx("span",{className:"text-sm text-white",children:u(t.weeklyAverageSleepSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Versus baseline"}),e.jsx("span",{className:v("text-sm",Ie(t.deltaFromWeeklyAverageSeconds)),children:Te(t.deltaFromWeeklyAverageSeconds)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Bedtime drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.bedtimeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Wake drift"}),e.jsxs("span",{className:"text-sm text-white",children:[t.wakeDriftMinutes??0,"m"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Restorative share"}),e.jsx("span",{className:"text-sm text-white",children:R(t.restorativeShare)})]})]})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/20 px-5 py-5",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]})]})]})}):e.jsxs(S,{className:"overflow-hidden p-6",children:[e.jsx("div",{className:"text-sm uppercase tracking-[0.18em] text-white/42",children:"Sleep"}),e.jsx("div",{className:"mt-4 text-2xl text-white",children:"No overnight sleep yet"}),e.jsx("div",{className:"mt-3 max-w-2xl text-sm leading-6 text-white/58",children:"The sleep page will switch to a night-first summary once the companion syncs a canonical overnight session."})]})}function F({title:t,value:s,description:a}){return e.jsxs(S,{className:"h-full border-white/8 bg-white/[0.03]",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:t}),e.jsx("div",{className:"mt-3 text-3xl text-white",children:s}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/56",children:a})]})}function ze({days:t,selectedSleepId:s,onSelect:a}){const r=g.useMemo(()=>Array.from(new Set(t.map(l=>l.dateKey.slice(0,7)))).sort((l,i)=>l.localeCompare(i)),[t]),[n,x]=g.useState(r[r.length-1]??"");g.useEffect(()=>{if(r.length===0){x("");return}r.includes(n)||x(r[r.length-1]??"")},[n,r]);const d=r.indexOf(n),h=g.useMemo(()=>De(n,t),[t,n]);return n?e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(12,20,40,0.96))] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Sleep calendar"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:Re(n)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d<=0,onClick:()=>x(r[Math.max(0,d-1)]??n),children:"Previous"}),e.jsx(C,{type:"button",variant:"secondary",className:"h-9 rounded-full",disabled:d===-1||d>=r.length-1,onClick:()=>x(r[Math.min(r.length-1,d+1)]??n),children:"Next"})]})]}),e.jsx("div",{className:"grid grid-cols-7 gap-2 text-center text-[11px] uppercase tracking-[0.16em] text-white/38",children:Ae.map(l=>e.jsx("div",{children:l},l))}),e.jsx("div",{className:"grid grid-cols-7 gap-2",children:h.map(l=>{const i=l.sleep,c=(i==null?void 0:i.sleepId)===s,j=i&&typeof i.score=="number"?i.score>=80?"rgba(45,212,191,0.22)":i.score>=65?"rgba(96,165,250,0.22)":"rgba(251,191,36,0.18)":"rgba(255,255,255,0.04)";return e.jsxs("button",{type:"button",disabled:!i,"aria-pressed":c,"aria-label":`Select sleep for ${l.dateKey}`,onClick:()=>{i&&(x(i.dateKey.slice(0,7)),a(i.sleepId,i.dateKey.slice(0,7)))},className:v("min-h-[90px] rounded-[18px] border px-2 py-2 text-left transition",i?"border-white/10 hover:border-white/22 hover:bg-white/[0.05]":"border-white/6 bg-white/[0.02]",c&&"border-[var(--primary)] bg-[var(--primary)]/12",l.outsideMonth&&!i&&"opacity-35"),style:i?{background:`linear-gradient(180deg, ${j}, rgba(255,255,255,0.03))`}:void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:v("text-sm",l.outsideMonth?"text-white/40":"text-white/82"),children:l.dayNumber}),i!=null&&i.hasReflection?e.jsx("span",{className:"size-2 rounded-full bg-emerald-300"}):null]}),i?e.jsxs("div",{className:"mt-4 grid gap-1",children:[e.jsxs("div",{className:"text-lg text-white",children:[i.sleepHours.toFixed(1),"h"]}),e.jsxs("div",{className:"text-xs text-white/52",children:[i.score??"n/a"," score"]}),e.jsx("div",{className:"text-xs text-white/40",children:i.hasRawSegments?"phases available":"summary only"})]}):null]},l.dateKey)})})]})}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-5 py-8 text-sm leading-6 text-white/56",children:"No canonical nights are available for the calendar yet."})}function z({active:t,children:s,onClick:a}){return e.jsx("button",{type:"button",onClick:a,className:v("rounded-full border px-4 py-2 text-sm transition",t?"border-[var(--primary)] bg-[var(--primary)]/12 text-white":"border-white/8 bg-white/[0.03] text-white/60 hover:text-white"),children:s})}function Le({session:t,draft:s,rawDetail:a,rawDetailLoading:r,pending:n,tab:x,linkOptions:d,onTabChange:h,onDraftChange:l,onSave:i}){const[c,j]=g.useState(null),y=g.useMemo(()=>Ee(a),[a]),$=typeof t.derived.efficiency=="number"?t.derived.efficiency:t.timeInBedSeconds>0?t.asleepSeconds/t.timeInBedSeconds:0,E=typeof t.derived.restorativeShare=="number"?t.derived.restorativeShare:0,M=typeof t.derived.recoveryState=="string"?t.derived.recoveryState:null;return e.jsx(S,{className:"overflow-hidden border-white/8 bg-[linear-gradient(180deg,rgba(10,17,33,0.98),rgba(13,20,38,0.96))] p-0",children:e.jsxs("div",{className:"grid gap-5 px-5 py-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",G(M)),children:M?M.replaceAll("_"," "):"Canonical night"}),e.jsxs(p,{tone:"meta",children:[t.rawSegmentCount," raw segments"]}),e.jsx(p,{tone:"meta",children:t.sourceTimezone})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Selected night"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:O(t.endedAt,t.sourceTimezone)}),e.jsx("div",{className:"mt-2 text-sm text-white/56",children:q(t.startedAt,t.endedAt,t.sourceTimezone)})]}),e.jsxs("div",{className:"grid gap-2 text-right",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Summary"}),e.jsx("div",{className:"text-3xl text-white",children:u(t.asleepSeconds)}),e.jsx("div",{className:"text-sm text-white/54",children:"asleep"})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"In bed"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.timeInBedSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Awake"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:u(t.awakeSeconds)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Efficiency"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R($)})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.18em] text-white/40",children:"Restorative"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:R(E)})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(z,{active:x==="summary",onClick:()=>h("summary"),children:"Summary"}),e.jsx(z,{active:x==="reflection",onClick:()=>h("reflection"),children:"Reflection"}),e.jsx(z,{active:x==="raw",onClick:()=>h("raw"),children:"Show raw data"})]}),x==="summary"?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Phase timeline"}),e.jsx("div",{className:"mt-4",children:r?e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-6 text-sm text-white/56",children:"Loading phase timing from raw sleep segments…"}):e.jsx(Ke,{timeline:(a==null?void 0:a.phaseTimeline)??{startedAt:t.startedAt,endedAt:t.endedAt,totalSeconds:Math.max(0,Math.round((new Date(t.endedAt).getTime()-new Date(t.startedAt).getTime())/1e3)),hasRawSegments:!1,hasSleepStageData:!1,blocks:[]},timeZone:t.sourceTimezone})})]}),e.jsxs("div",{className:"rounded-[22px] border border-white/8 bg-black/18 px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Stage composition"}),e.jsx("div",{className:"mt-4",children:e.jsx(J,{stages:t.stageBreakdown})})]})]}):null,x==="reflection"?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Quality summary"}),e.jsx(Q,{value:s.qualitySummary,onChange:o=>l({qualitySummary:o.target.value}),placeholder:"Recovered after a late evening, but sleep onset drifted."})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Night notes"}),e.jsx(pe,{className:"min-h-[200px]",value:s.notes,onChange:o=>l({notes:o.target.value}),placeholder:"What shaped this night, and what should we remember about it?"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Tags"}),e.jsx(Q,{value:s.tagsText,onChange:o=>l({tagsText:o.target.value}),placeholder:"travel, stress, good-routine, late-caffeine"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Linked context"}),e.jsx(ue,{options:d,selectedValues:s.linkValues,onChange:o=>l({linkValues:o}),placeholder:"Search goals, tasks, habits, beliefs, reports, or patterns…"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(C,{type:"button",pending:n,pendingLabel:"Saving",onClick:i,children:[e.jsx(ae,{className:"size-4"}),"Save reflection"]})})]}):null,x==="raw"?e.jsxs("div",{className:"grid gap-5",children:[e.jsx("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-4 text-sm leading-6 text-white/56",children:"Forge shows the canonical overnight session by default. This view reveals the evidence stack underneath it: raw provider or historical imported records first, then Forge-normalized sleep segments."}),r?e.jsx("div",{className:"text-sm text-white/56",children:"Loading raw sleep evidence…"}):null,r?null:e.jsxs("div",{className:"grid gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",Be(y.rawDataStatus)),children:qe(y.rawDataStatus)}),y.rawDataStatus==="historical_raw"?e.jsx(p,{tone:"meta",children:"Partial evidence"}):null]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Raw data"}),y.sourceRecords.length?y.sourceRecords.map(o=>e.jsxs("div",{className:"rounded-[16px] border border-white/8 bg-black/18 px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{className:v("border-white/0",Ce(o)),children:o.qualityKind==="provider_native"?"Provider raw":"Historical raw"}),e.jsx(p,{tone:"meta",className:"capitalize",children:o.rawStage.replaceAll("_"," ")}),e.jsx("span",{className:"text-sm text-white/64",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-white/42",children:o.providerRecordType.replaceAll("_"," ")}),e.jsx(C,{type:"button",variant:"secondary",className:"h-8 rounded-full px-3",onClick:()=>j(_=>_===o.id?null:o.id),children:c===o.id?"Hide JSON":"See JSON"})]})]}),e.jsx("div",{className:"mt-3 text-sm text-white/50",children:u(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))}),c===o.id?e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[14px] border border-white/8 bg-slate-950/70 p-3 text-xs leading-6 text-white/72",children:JSON.stringify({payload:o.payload,metadata:o.metadata},null,2)}):null]},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No raw data was stored for this night."})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Sleep segments"}),y.segments.length?y.segments.map(o=>e.jsx("div",{className:"rounded-[16px] border border-white/8 bg-black/18 px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(p,{tone:"meta",className:"capitalize",children:o.stage.replaceAll("_"," ")}),e.jsx(p,{tone:"meta",children:o.qualityKind==="provider_native"?"provider-backed":"historical"}),e.jsx("span",{className:"text-sm text-white/64",children:q(o.startedAt,o.endedAt,o.sourceTimezone)})]}),e.jsx("span",{className:"text-sm text-white/50",children:u(Math.max(0,Math.round((new Date(o.endedAt).getTime()-new Date(o.startedAt).getTime())/1e3)))})]})},o.id)):e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-black/10 px-4 py-4 text-sm text-white/52",children:"No normalized sleep segments were stored for this night."})]})]})]}):null]})})}function Xe(){var V;const t=ne(),s=re(),[a,r]=g.useState({}),[n,x]=g.useState(null),[d,h]=g.useState("summary"),l=Array.isArray(t==null?void 0:t.selectedUserIds)?t.selectedUserIds:[],i=t==null?void 0:t.snapshot,c=A({queryKey:["forge-sleep",...l],queryFn:async()=>(await ge(l)).sleep}),j=A({queryKey:["forge-sleep-raw",n],enabled:!!n,queryFn:async()=>we(n)}),y=A({queryKey:["forge-sleep-values",...l],queryFn:async()=>(await be(l)).values}),$=A({queryKey:["forge-sleep-patterns",...l],queryFn:async()=>(await ve(l)).patterns}),E=A({queryKey:["forge-sleep-behaviors",...l],queryFn:async()=>(await fe(l)).behaviors}),M=A({queryKey:["forge-sleep-beliefs",...l],queryFn:async()=>(await je(l)).beliefs}),o=A({queryKey:["forge-sleep-reports",...l],queryFn:async()=>(await ye(l)).reports});g.useEffect(()=>{c.data&&r(Object.fromEntries(c.data.sessions.map(m=>[m.id,B(m)])))},[c.data]),g.useEffect(()=>{var N,f,k;if(!((N=c.data)!=null&&N.sessions.length)){x(null);return}c.data.sessions.some(K=>K.id===n)||x(((f=c.data.latestNight)==null?void 0:f.sleepId)??((k=c.data.sessions[0])==null?void 0:k.id)??null)},[n,c.data]),g.useEffect(()=>{h("summary")},[n]);const _=ie({mutationFn:async m=>de(m.sleepId,{qualitySummary:m.qualitySummary,notes:m.notes,tags:m.tagsText.split(",").map(N=>N.trim()).filter(Boolean),links:Se(m.linkValues)}),onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-sleep"]}),await s.invalidateQueries({queryKey:["forge-sleep-raw"]})}});if(c.isLoading)return e.jsx(le,{eyebrow:"Sleep",title:"Loading sleep surface",description:"Reading canonical nights, calendar summaries, and sleep phase detail.",columns:2,blocks:6});if(c.isError||!c.data)return e.jsx(ce,{eyebrow:"Sleep",error:c.error??new Error("Sleep data unavailable"),onRetry:()=>void c.refetch()});const w=c.data,D=w.sessions,L=new Map(D.map(m=>[m.id,m])),b=(n?L.get(n):null)??(w.latestNight?L.get(w.latestNight.sleepId):null)??D[0]??null,P=b?a[b.id]??B(b):null,Y=ke({goals:(i==null?void 0:i.dashboard.goals)??[],projects:(i==null?void 0:i.dashboard.projects)??[],tasks:(i==null?void 0:i.dashboard.tasks)??[],habits:(i==null?void 0:i.dashboard.habits)??[],values:y.data??[],patterns:$.data??[],behaviors:E.data??[],beliefs:M.data??[],reports:o.data??[]});function X(m,N){r(f=>{const k=D.find(ee=>ee.id===m),K=f[m]??(k?B(k):{qualitySummary:"",notes:"",tagsText:"",linkValues:[]});return{...f,[m]:{...K,...N}}})}async function Z(m){const N=D.find(k=>k.id===m);if(!N)return;const f=a[m]??B(N);await _.mutateAsync({sleepId:m,qualitySummary:f.qualitySummary,notes:f.notes,tagsText:f.tagsText,linkValues:f.linkValues})}return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ne,{eyebrow:"Health",title:"Sleep",description:"Canonical overnight sessions first, with last-night recovery, a clickable night calendar, and raw segment evidence only when you ask for it.",badge:`${D.length} nights`}),e.jsx(oe,{}),e.jsx(xe,{children:e.jsx(Fe,{latestNight:w.latestNight})}),e.jsx(me,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,0.95fr)_minmax(0,1.05fr)]",children:[e.jsx(F,{title:"Weekly average",value:u(w.summary.averageSleepSeconds),description:"Average overnight sleep duration across the recent week, used as the baseline for the latest-night comparison."}),e.jsx(F,{title:"Regularity",value:`${w.summary.averageRegularityScore}`,description:`Average bedtime drift ${w.summary.averageBedtimeConsistencyMinutes}m and wake drift ${w.summary.averageWakeConsistencyMinutes}m.`}),e.jsx(F,{title:"Restorative share",value:R(w.summary.averageRestorativeShare),description:`Deep + REM share across recent nights, with ${w.summary.reflectiveNightCount} nights already carrying context.`}),e.jsxs(S,{className:"border-white/8 bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Recent stage mix"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:"Average nightly phases"})]}),e.jsx(te,{className:"size-5 text-[var(--primary)]"})]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:w.stageAverages.length>0?w.stageAverages.slice(0,5).map(m=>e.jsxs(p,{tone:"meta",children:[I(m.stage).label," ",u(m.averageSeconds)]},m.stage)):e.jsx("div",{className:"text-sm text-white/52",children:"Stage averages will appear once nights include phase data."})})]})]})}),e.jsx(he,{children:e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,25rem)_minmax(0,1fr)]",children:[e.jsx(ze,{days:w.calendarDays,selectedSleepId:(b==null?void 0:b.id)??null,onSelect:m=>x(m)}),b&&P?e.jsx(Le,{session:b,draft:P,rawDetail:j.data??null,rawDetailLoading:j.isLoading,pending:_.isPending&&((V=_.variables)==null?void 0:V.sleepId)===b.id,tab:d,linkOptions:Y,onTabChange:h,onDraftChange:m=>X(b.id,m),onSave:()=>void Z(b.id)}):e.jsx(S,{className:"border-white/8 bg-white/[0.03] px-6 py-8 text-sm leading-6 text-white/58",children:"Pick a night from the calendar to inspect its phase timing, stage summary, and reflection context."})]})})]})}export{Xe as SleepPage};
|