forge-openclaw-plugin 0.2.7 → 0.2.10
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/README.md +73 -1
- package/dist/assets/{board-CzgvdLO8.js → board-C_m78kvK.js} +2 -2
- package/dist/assets/{board-CzgvdLO8.js.map → board-C_m78kvK.js.map} +1 -1
- package/dist/assets/index-BWtLtXwb.js +36 -0
- package/dist/assets/index-BWtLtXwb.js.map +1 -0
- package/dist/assets/index-Dp5GXY_z.css +1 -0
- package/dist/assets/{motion-STUd1O46.js → motion-CpZvZumD.js} +2 -2
- package/dist/assets/{motion-STUd1O46.js.map → motion-CpZvZumD.js.map} +1 -1
- package/dist/assets/{table-CtNlETLc.js → table-DtyXTw03.js} +2 -2
- package/dist/assets/{table-CtNlETLc.js.map → table-DtyXTw03.js.map} +1 -1
- package/dist/assets/{ui-ThzkR_oW.js → ui-BXbpiKyS.js} +2 -2
- package/dist/assets/{ui-ThzkR_oW.js.map → ui-BXbpiKyS.js.map} +1 -1
- package/dist/assets/{vendor-DyHAI6nk.js → vendor-QBH6qVEe.js} +84 -74
- package/dist/assets/vendor-QBH6qVEe.js.map +1 -0
- package/dist/assets/{viz-BJuBCz_G.js → viz-w-IMeueL.js} +2 -2
- package/dist/assets/{viz-BJuBCz_G.js.map → viz-w-IMeueL.js.map} +1 -1
- package/dist/index.html +8 -8
- package/dist/openclaw/api-client.d.ts +1 -0
- package/dist/openclaw/local-runtime.js +2 -1
- package/dist/openclaw/plugin-entry-shared.js +12 -0
- package/dist/server/app.js +104 -67
- package/dist/server/demo-data.js +49 -0
- package/dist/server/openapi.js +84 -43
- package/dist/server/psyche-types.js +1 -30
- package/dist/server/repositories/deleted-entities.js +60 -26
- package/dist/server/repositories/goals.js +2 -5
- package/dist/server/repositories/notes.js +359 -0
- package/dist/server/repositories/projects.js +2 -5
- package/dist/server/repositories/psyche.js +11 -14
- package/dist/server/repositories/task-runs.js +2 -0
- package/dist/server/repositories/tasks.js +21 -10
- package/dist/server/seed-demo.js +11 -0
- package/dist/server/services/dashboard.js +4 -1
- package/dist/server/services/entity-crud.js +27 -30
- package/dist/server/services/insights.js +5 -5
- package/dist/server/services/projects.js +3 -1
- package/dist/server/services/psyche.js +4 -4
- package/dist/server/types.js +70 -11
- package/openclaw.plugin.json +12 -1
- package/package.json +1 -1
- package/server/migrations/001_core.sql +78 -0
- package/server/migrations/002_psyche.sql +164 -13
- package/skills/forge-openclaw/SKILL.md +17 -5
- package/dist/assets/index-8d_oM8fL.js +0 -27
- package/dist/assets/index-8d_oM8fL.js.map +0 -1
- package/dist/assets/index-D4A_bq8m.css +0 -1
- package/dist/assets/vendor-DyHAI6nk.js.map +0 -1
- package/dist/server/repositories/comments.js +0 -176
- package/server/migrations/003_timer_execution.sql +0 -18
- package/server/migrations/004_psyche_linked_entities.sql +0 -5
- package/server/migrations/005_adaptive_schemas.sql +0 -157
- package/server/migrations/006_psyche_auth_setting.sql +0 -4
- package/server/migrations/007_deleted_entities.sql +0 -16
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var lr=Object.defineProperty;var dr=(t,s,a)=>s in t?lr(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var Et=(t,s,a)=>dr(t,typeof s!="symbol"?s+"":s,a);import{J as cr,g as mr,j as e,r as y,K as hr,S as ur,Q as pr,L as xr,M as gr,N as br,O as fr,T as vr,U as ys,V as Ve,W as ft,X as on,Y as ws,Z as Ft,$ as sa,a0 as aa,a1 as ln,a2 as ia,a3 as vt,a4 as yr,a5 as wr,a6 as Pt,a7 as jr,a8 as na,a9 as Ee,aa as Se,ab as ce,ac as ee,ad as qt,ae as Rs,af as dn,a as kr,ag as hs,ah as Nr,ai as nt,aj as Tr,ak as Sr,al as ra,am as cn,an as Pe,ao as te,ap as de,aq as Cr,ar as Ir,as as oa,at as la,au as Pr,av as Lr,aw as Mr,ax as Er,ay as Ar,az as Dr,aA as xe,aB as Rr,aC as _r,aD as gt,aE as Ze,aF as St,aG as xi,aH as us,aI as ps,aJ as js,aK as Or,aL as mn,aM as hn,aN as $r,aO as Fr,aP as qr,aQ as Br,aR as zr,aS as Kr,aT as Xr,aU as Gr,aV as Qr,aW as Wr,aX as Hr,aY as un,aZ as xs,a_ as Ur,a$ as Yr,b0 as Jr,b1 as Vr,b2 as Zr,b3 as Zs,b4 as eo,b5 as to,b6 as so,b7 as ao,b8 as io,b9 as ye,ba as _s,bb as no,bc as ro,H as oo,bd as lo,be as co}from"./vendor-QBH6qVEe.js";import{m as De,A as bt,u as mo}from"./motion-CpZvZumD.js";import{R as Bt,P as zt,O as Kt,C as Xt,T as ks,D as Ns,a as gs}from"./ui-BXbpiKyS.js";import{c as ho,u as uo,f as gi,g as po}from"./table-DtyXTw03.js";import{R as pn,A as xo,X as xn,Y as gn,a as bi,B as go,b as bo}from"./viz-w-IMeueL.js";import{u as fo,a as vo,D as yo,S as fi,v as vi,b as wo,p as jo,c as ko,P as No,d as To,e as So,C as Co}from"./board-C_m78kvK.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function a(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function r(i){if(i.ep)return;i.ep=!0;const n=a(i);fetch(i.href,n)}})();function Q(...t){return cr(mr(t))}function da(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(t))}function ca({className:t,tone:s="primary"}){return e.jsx("span",{"aria-hidden":"true",className:Q("inline-block size-4 rounded-full border border-white/14 border-t-transparent bg-[conic-gradient(from_180deg_at_50%_50%,rgba(255,255,255,0.02),rgba(255,255,255,0.34),rgba(255,255,255,0.02))] align-middle motion-safe:animate-spin",s==="primary"&&"shadow-[0_0_0_1px_rgba(192,193,255,0.22)]",s==="subtle"&&"opacity-80 shadow-[0_0_0_1px_rgba(255,255,255,0.08)]",s==="psyche"&&"shadow-[0_0_0_1px_rgba(110,231,183,0.2)]",t)})}function Io(){return{common:{actions:{cancel:"Cancel",close:"Close",create:"Create",edit:"Edit",inspect:"Inspect",open:"Open",refresh:"Refresh",retry:"Retry",save:"Save",reset:"Reset filters",view:"View"},labels:{loading:"Loading",backgroundActivity:"Background activity",syncInProgress:"Sync in progress",connectionState:"Connection state",errorCode:"Error code: {code}",noDate:"No date",noProject:"No project linked",noGoal:"No life goal linked",noExecutionNote:"No execution note attached yet.",noRunNote:"No run note recorded.",released:"Released",stable:"Stable",timedOut:"Timed out",waiting:"Waiting",today:"Today"},enums:{taskStatus:{backlog:"Backlog",focus:"Focus",in_progress:"In progress",blocked:"Blocked",done:"Done"},priority:{critical:"Critical",high:"High",medium:"Medium",low:"Low"},effort:{marathon:"Marathon",deep:"Deep",light:"Light"},energy:{high:"High",steady:"Steady",low:"Low"},projectStatus:{active:"Active",paused:"Paused",completed:"Completed"},goalHorizon:{quarter:"Quarter",year:"Year",lifetime:"Lifetime"}},shell:{appName:"The Kinetic Forge",appMark:"FORGE",more:"More",command:"Command",moreRoutesEyebrow:"More routes",moreRoutesTitle:"Move through Forge",moreRoutesDescription:"Use this sheet for secondary destinations so the bottom bar stays clean and easy to use.",loadingEyebrow:"Forge shell",loadingTitle:"Loading Forge",loadingDescription:"Checking your operator session and loading your latest snapshot.",sessionEyebrow:"Forge operator session",stateEyebrow:"Forge state",settled:"Up to date",savingOne:"Saving {count} change",savingOther:"Saving {count} changes",refreshingOne:"Refreshing {count} view",refreshingOther:"Refreshing {count} views",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",rail:{taskBackToKanban:"Back to Kanban",taskOpenToday:"Open Today",projectAll:"All projects",projectGoals:"Goal architecture",goalAll:"All goals",goalProjects:"Active projects",psycheHub:"Psyche hub",psycheReports:"Reports",overview:"Overview",today:"Today"},momentum:{title:"Momentum",streak:"Streak",xp:"XP",momentum:"Momentum",streakBadgeOne:"{count} day streak",streakBadgeOther:"{count} day streak",weeklyXp:"{count} weekly XP",liveMomentum:"{count}% momentum",psycheMode:"Psyche active"}},routeLabels:{overview:"Overview",goals:"Goals",projects:"Projects",kanban:"Kanban",today:"Today",notes:"Notes",psyche:"Psyche",activity:"Activity",insights:"Insights",review:"Review",settings:"Settings"},routeDetails:{overview:"See priorities, momentum, and recent evidence in one place.",goals:"Keep long-term direction connected to day-to-day work.",projects:"Track the initiatives currently moving your goals forward.",kanban:"Move active work across the board without losing context.",today:"Focus today on the clearest next move.",notes:"Search Markdown work notes and reopen the linked work fast.",psyche:"Reflect on values, patterns, and reports with structure.",activity:"Review the visible audit trail of what changed and when.",insights:"Store and review coaching, analysis, and recommendations.",review:"Review the week and set the next push.",settings:"Manage collaboration, safety, and operator preferences."},navigation:{openRoute:"Open {label}",create:"Create",createTitle:"Create in Forge",createDescription:"Choose what you want to add next.",closeCreateMenu:"Close create menu",newGoal:"New life goal",newGoalDescription:"Define a long-term direction.",newProject:"New project",newProjectDescription:"Add a concrete initiative under a life goal.",newTask:"New task",newTaskDescription:"Capture the next actionable step in a project."},commandPalette:{searchPlaceholder:"Jump to a route, goal, project, or focus task",noResults:"No command matches this search yet.",categoryRoute:"Route",categoryGoal:"Goal",categoryProject:"Project",categoryTask:"Task",routeOverview:"Open the overview.",routeToday:"Open today.",routeKanban:"Open the board.",routeNotes:"Search notes.",routePsyche:"Open Psyche.",routeGoals:"Open your life goals.",routeProjects:"Open your projects.",routeReview:"Open weekly review.",routeSettings:"Open settings.",openLifeGoal:"Open life goal",openFocusTask:"Open focus task"},pageState:{loadingTitle:"Getting things ready",loadingDescription:"Loading the latest Forge data for this view."},settings:{localeLabel:"Language",localeDescription:"Choose the language used throughout Forge.",localeEnglish:"English",localeFrench:"French",localeSaved:"Language saved"},overview:{heroEyebrow:"Strategic overview",heroEmptyTitle:"Ready to get started",heroDescription:"See your goals, active projects, current tasks, and recent evidence in one place.",emptyTitle:"No overview yet",emptyDescription:"Create a life goal, project, or task to give Forge something real to organize.",emptyAction:"Open life goals",commandEyebrow:"Command surface",commandTitle:"Now, next, risks, and recent proof",commandDescription:"See what needs attention now, what comes next, where drift is appearing, and what progress is already visible.",sectionGoals:"Active life goals",sectionProjects:"Active projects",sectionFocus:"Today's focus",sectionEvidence:"Recent evidence",sectionMomentum:"Momentum core",sectionAttention:"Needs attention",noGoals:"No life goals are active yet. Start by defining the direction you want Forge to support.",noProjects:"No active projects yet. Add a project to turn a goal into practical work.",noFocus:"No focus tasks yet. Promote a task when you know what deserves attention next.",noEvidence:"No evidence has been recorded yet. Completed work and logged activity will appear here.",noProjectYet:"No project yet",noAttention:"No major drift signal right now. Forge will raise neglected goals here when they start slipping.",metricsLevel:"Level",metricsWeeklyXp:"Weekly XP",metricsFocusTasks:"Focus tasks",metricsOverdue:"Overdue"},todayPage:{heroEyebrow:"Today",heroEmptyTitle:"No daily direction yet",heroDescription:"Start a task, earn XP, and keep today's work clear.",emptyTitle:"No daily runway yet",emptyDescription:"Add goals, tasks, or reward targets so Forge can shape a useful day plan.",emptyAction:"Open life goals",commandEyebrow:"Today command",commandTitle:"Directive, daily quests, recovery, and finish line",commandDescription:"See the next useful move clearly and keep the day grounded in real work.",questsTitle:"Daily quests",questsEmpty:"No daily quests yet. They will appear once Forge has enough live work and reward context.",rewardsTitle:"Milestone rewards",rewardsEmpty:"No milestone rewards are active yet. Long-term rewards will appear here as progress structure grows.",signalDirective:"Directive",signalQuest:"Quest chain",signalComeback:"Recovery",signalFinish:"Finish line",noDirective:"Choose one clear task to anchor the day.",noQuest:"No active daily quest chain",noQuestDetail:"Daily quests should reinforce real work, not distract from it.",noComeback:"Recovery window is clear",noFinish:"Keep the day clean",noDirectiveDetail:"Promote a real task and Today will become sharper immediately.",noFinishDetail:"A good finish today should make tomorrow lighter, not noisier."},kanban:{heroEyebrow:"Task board",heroTitle:"Task board",heroDescription:"Use the board to move active work, review blocked items, and open task details when you need more context.",emptyTitle:"No board yet",emptyDescription:"Create your first task inside a project to start using the board.",emptyAction:"Open life goals",healthEyebrow:"Board status",healthTitle:"Visible work, focus, blockers, and completed work",healthDescription:"See what is active, what needs attention, and what has already been completed.",visibleWork:"Visible work",focusWork:"Current focus",blockedWork:"Blocked work",completedWork:"Completed work",visibleDetail:"{hidden} tasks are outside the current filters.",focusDetailReady:"These are the tasks most ready to be picked up next.",focusDetailEmpty:"Move one backlog task into focus to make the board more useful.",blockedDetail:"These tasks need a decision, an unblock, or a reset before they can move again.",blockedDetailEmpty:"No blocked tasks right now.",doneDetail:"Completed work stays here until you review it or reopen it.",doneDetailEmpty:"Nothing has been completed on this board yet.",boardFilters:"Board filters",filterGoal:"Goal",filterOwner:"Owner",allGoals:"All goals",allOwners:"All owners",noTasksMatch:"No tasks match these filters",noTasksMatchDescription:"These filters hide every task. Reset them to see the full board again.",taskContext:"Task details",evidence:"Recent activity",runHistory:"Run history",noTaskEvidence:"No activity has been recorded for this task yet.",noRunHistory:"No runs have been recorded for this task yet.",taskPlacement:"Task placement",projectLabel:"Project: {value}",goalLabel:"Life goal: {value}",ownerLabel:"Owner: {value}",dueLabel:"Due: {value}",openTask:"Open task",openProject:"Open project",openGoal:"Open life goal",noProjectLinked:"No project linked",noGoalLinked:"No life goal linked"},dailyRunway:{runwayEyebrow:"Today",runwayTitle:"Tasks for today",prioritiesOne:"{count} task",prioritiesOther:"{count} tasks",unassigned:"Unassigned",runwayItem:"Task {index}",noNote:"No note yet.",inspect:"Open task",actionBacklog:"Start",actionFocus:"Start",actionProgress:"Done",actionBlocked:"Start",timelineEyebrow:"By status",timelineTitle:"Tasks by status",emptyBucket:"Nothing here right now."},executionBoard:{laneBacklogTitle:"Backlog",laneBacklogDetail:"Not started yet",laneFocusTitle:"Focus",laneFocusDetail:"Ready to work on",laneProgressTitle:"In progress",laneProgressDetail:"Currently moving",laneBlockedTitle:"Blocked",laneBlockedDetail:"Needs attention",laneDoneTitle:"Done",laneDoneDetail:"Completed",noExecutionNote:"No note yet.",reopen:"Reopen",emptyLane:"No tasks in this lane."},weeklyReview:{heroEyebrow:"Weekly review",heroDescription:"Review the week, note what moved, and decide what needs attention next.",summaryEyebrow:"Weekly summary",summaryTitle:"This week, wins, recovery, and next steps",summaryDescription:"Use this review to understand what happened this week and choose the most useful next move.",sectionMomentum:"Momentum summary",sectionGoals:"Goal check-in",sectionWins:"Wins",completionBonus:"Completion bonus",finalize:"Finish review",noWin:"No win recorded yet",noWinDetail:"If this week was quiet, use the review to capture one useful takeaway anyway.",noRecovery:"No recovery suggestion yet",noRecoveryDetail:"If the week felt steady, keep a light recovery option available for next week."},dialogs:{closeDialog:"Close dialog",task:{eyebrow:"Task",createTitle:"Create task",editTitle:"Edit task",description:"Use tasks for the next concrete step inside a project. Pick the project first so Forge can keep the larger context aligned.",project:"Project",selectProject:"Select a project",goal:"Life goal",title:"Title",descriptionLabel:"Description",owner:"Owner",xp:"XP",priority:"Priority",status:"Status",effort:"Effort",energy:"Energy",dueDate:"Due date",tags:"Tags",save:"Save task",create:"Create task"},project:{eyebrow:"Project",createTitle:"Create project",editTitle:"Edit project",description:"Use projects to turn a life goal into a concrete stream of work with tasks, evidence, and momentum.",goal:"Life goal",selectGoal:"Select a life goal",title:"Title",descriptionLabel:"Description",status:"Status",targetXp:"Target XP",themeColor:"Theme color",save:"Save project",create:"Create project",submitError:"Project update failed."},goal:{eyebrow:"Life goal",createTitle:"Create life goal",editTitle:"Edit life goal",description:"Use life goals to define what matters over the coming months or years before you break the path into projects.",title:"Title",descriptionLabel:"Description",horizon:"Horizon",status:"Status",targetXp:"Target XP",themeColor:"Theme color",tags:"Life domains and context",save:"Save life goal",create:"Create life goal",submitError:"Goal update failed."}},taskDetail:{eyebrow:"Task",errorEyebrow:"Task",emptyPayload:"Forge returned an empty task payload.",heroFallback:"Use this task page to update the work, move it forward, and keep its context clear.",commandEyebrow:"Task overview",commandTitle:"What this task is, what to do next, and where it fits",commandDescription:"Use this page to update the task itself and understand its surrounding context clearly.",signalState:"State",signalNext:"Next move",signalEvidence:"Recent activity",signalAnchor:"Connected project",noStateChange:"No state change needed",terminalStateDetail:"This task is already in a completed state unless you decide to reopen it.",noEvidence:"No recent activity yet",noEvidenceDetail:"Completed work, corrections, and logged sessions will appear here as the task moves.",noAnchor:"No connected project yet",linkAnchorDetail:"Connect this task to a project or life goal so Forge can show why it matters.",edit:"Edit task",openProject:"Open project",openGoal:"Open life goal",markNotCompleted:"Mark not completed",sectionStatus:"Task status",fieldProject:"Project",fieldGoal:"Life goal",fieldDueDate:"Due date",pendingMove:"Moving",actionBacklog:"Move to backlog",actionFocus:"Move to focus",actionProgress:"Start now",actionBlocked:"Mark blocked",actionDone:"Mark completed",sectionEvidence:"Recent activity",noVisibleEvidence:"No activity has been recorded for this task yet.",removeLog:"Remove log",openRelatedItem:"Open related item",sectionRuns:"Work sessions",noRuns:"No work sessions have been recorded for this task yet.",sectionMetadata:"More task details",metaOwner:"Owner: {value}",metaEffort:"Effort: {value}",metaEnergy:"Energy: {value}",metaCreated:"Created: {value}",metaUpdated:"Last updated: {value}",metaCompleted:"Completed at: {value}",metaNotCompleted:"Not completed"},projectDetail:{errorEyebrow:"Project",heroEyebrow:"Project",commandEyebrow:"Project status",commandTitle:"Momentum, next task, risk, and evidence",commandDescription:"Use this page to see what is moving, what needs attention next, and what evidence already supports the project.",signalMomentum:"Momentum",signalNext:"Next task",signalRisk:"Risk",signalEvidence:"Evidence",trackedTasksOne:"{count} tracked task",trackedTasksOther:"{count} tracked tasks",noNextTask:"No next task selected yet",noNextTaskDetail:"Pick or create a task so the project has a clear next move.",needsFocus:"Needs focus",noRisk:"No immediate risk signal",noRiskDetail:"Blocked or neglected work will appear here when the project starts drifting.",noEvidence:"No recent evidence yet",noEvidenceDetail:"Completed work and logged activity will appear here as the project moves.",compatibility:"Compatibility mode",compatibilityDescription:"This project comes from an older snapshot format. You can review it here, but editing the project itself needs the updated backend.",addTask:"Add task",editProject:"Edit project",openGoal:"Open life goal",sectionHealth:"Project health",fieldStatus:"Status",fieldProgress:"Progress",fieldMomentum:"Momentum",sectionEvidence:"Recent evidence"},goalDetail:{eyebrow:"Life goal",missingTitle:"This life goal is not available",missingDescription:"Forge cannot find this life goal in the current snapshot. Return to the goals view and choose an active one.",backToGoals:"Back to goals",heroBadgeOne:"{count} project",heroBadgeOther:"{count} projects",commandEyebrow:"Goal status",commandTitle:"Progress, next push, risk, and evidence",commandDescription:"Use this page to see what is advancing the goal, what should move next, and where support is needed.",signalProgress:"Progress",signalNext:"Next push",signalRisk:"Risk",signalEvidence:"Evidence",progressTitle:"{progress}% with {count} completed tasks",progressDetail:"{xp} XP is already banked on this goal.",noProject:"No active project yet",noProjectDetail:"Add a project so this goal has a concrete execution path.",needsProject:"Needs project",nextMove:"Next move: {value}",noRisk:"No drift signal right now",noRiskDetail:"If this goal starts slipping, Forge will surface that pressure here.",noEvidence:"No recent evidence yet",noEvidenceDetail:"Completed tasks, project motion, and agent actions will appear here as proof of progress.",edit:"Edit life goal",addProject:"Add project",sectionProjects:"Projects advancing this goal",noProjects:"This goal does not have an active project yet. Add one to turn the goal into practical motion.",addNextTask:"Add the next task",sectionHealth:"Goal health",fieldProgress:"Progress",fieldCompletedTasks:"Completed tasks",fieldXpBanked:"XP banked",sectionEvidence:"Recent evidence",noEvidenceLogged:"No evidence has been logged for this goal yet. Task completions, project updates, and agent actions will appear here."}}}}const Po=Io(),Lo={common:{actions:{cancel:"Annuler",close:"Fermer",create:"Créer",edit:"Modifier",inspect:"Inspecter",open:"Ouvrir",refresh:"Actualiser",retry:"Réessayer",save:"Enregistrer",reset:"Réinitialiser les filtres",view:"Voir"},labels:{loading:"Chargement",backgroundActivity:"Activité en arrière-plan",syncInProgress:"Synchronisation en cours",connectionState:"État de la connexion",errorCode:"Code d'erreur : {code}",noDate:"Aucune date",noProject:"Aucun projet lié",noGoal:"Aucun objectif de vie lié",noExecutionNote:"Aucune note d'exécution pour le moment.",noRunNote:"Aucune note d'exécution enregistrée.",released:"Libérée",stable:"Stable",timedOut:"Expirée",waiting:"En attente",today:"Aujourd'hui"},enums:{taskStatus:{backlog:"Backlog",focus:"Priorité",in_progress:"En cours",blocked:"Bloqué",done:"Terminé"},priority:{critical:"Critique",high:"Élevée",medium:"Moyenne",low:"Basse"},effort:{marathon:"Marathon",deep:"Approfondi",light:"Léger"},energy:{high:"Haute",steady:"Stable",low:"Basse"},projectStatus:{active:"Actif",paused:"En pause",completed:"Terminé"},goalHorizon:{quarter:"Trimestre",year:"Année",lifetime:"Vie entière"}},shell:{appName:"The Kinetic Forge",appMark:"FORGE",more:"Plus",command:"Commande",moreRoutesEyebrow:"Autres vues",moreRoutesTitle:"Parcourir Forge",moreRoutesDescription:"Utilisez ce panneau pour accéder aux vues secondaires sans surcharger la barre inférieure.",loadingEyebrow:"Forge",loadingTitle:"Chargement de Forge",loadingDescription:"Vérification de votre session opérateur et chargement du dernier instantané.",sessionEyebrow:"Session opérateur Forge",stateEyebrow:"État de Forge",settled:"À jour",savingOne:"Enregistrement de {count} modification",savingOther:"Enregistrement de {count} modifications",refreshingOne:"Actualisation de {count} vue",refreshingOther:"Actualisation de {count} vues",collapseSidebar:"Réduire la barre latérale",expandSidebar:"Déployer la barre latérale",rail:{taskBackToKanban:"Retour au Kanban",taskOpenToday:"Ouvrir Aujourd'hui",projectAll:"Tous les projets",projectGoals:"Architecture des objectifs",goalAll:"Tous les objectifs",goalProjects:"Projets actifs",psycheHub:"Hub Psyche",psycheReports:"Rapports",overview:"Vue d'ensemble",today:"Aujourd'hui"},momentum:{title:"Momentum",streak:"Série",xp:"XP",momentum:"Momentum",streakBadgeOne:"{count} jour de série",streakBadgeOther:"{count} jours de série",weeklyXp:"{count} XP cette semaine",liveMomentum:"{count}% de momentum",psycheMode:"Psyche active"}},routeLabels:{overview:"Vue d'ensemble",goals:"Objectifs",projects:"Projets",kanban:"Kanban",today:"Aujourd'hui",notes:"Notes",psyche:"Psyche",activity:"Activité",insights:"Insights",review:"Revue",settings:"Réglages"},routeDetails:{overview:"Voyez les priorités, le momentum et les preuves récentes au même endroit.",goals:"Reliez la direction long terme au travail du quotidien.",projects:"Suivez les initiatives qui font avancer vos objectifs.",kanban:"Faites progresser le travail actif sans perdre le contexte.",today:"Concentrez aujourd'hui sur le prochain mouvement le plus net.",notes:"Recherchez les notes Markdown et rouvrez vite le travail lié.",psyche:"Réfléchissez avec structure sur vos valeurs, vos schémas et vos rapports.",activity:"Relisez la trace visible de ce qui a changé et quand.",insights:"Stockez et relisez coaching, analyses et recommandations.",review:"Relisez la semaine et préparez la prochaine poussée.",settings:"Gérez la collaboration, la sécurité et vos préférences."},navigation:{openRoute:"Ouvrir {label}",create:"Créer",createTitle:"Créer dans Forge",createDescription:"Choisissez ce que vous voulez ajouter ensuite.",closeCreateMenu:"Fermer le menu de création",newGoal:"Nouvel objectif de vie",newGoalDescription:"Définir une direction à long terme.",newProject:"Nouveau projet",newProjectDescription:"Ajouter une initiative concrète sous un objectif de vie.",newTask:"Nouvelle tâche",newTaskDescription:"Capturer la prochaine étape actionnable dans un projet."},commandPalette:{searchPlaceholder:"Aller à une vue, un objectif, un projet ou une tâche prioritaire",noResults:"Aucune commande ne correspond à cette recherche.",categoryRoute:"Vue",categoryGoal:"Objectif",categoryProject:"Projet",categoryTask:"Tâche",routeOverview:"Ouvrir la vue d'ensemble.",routeToday:"Ouvrir aujourd'hui.",routeKanban:"Ouvrir le tableau.",routeNotes:"Rechercher les notes.",routePsyche:"Ouvrir Psyche.",routeGoals:"Ouvrir vos objectifs de vie.",routeProjects:"Ouvrir vos projets.",routeReview:"Ouvrir la revue hebdomadaire.",routeSettings:"Ouvrir les réglages.",openLifeGoal:"Ouvrir l'objectif de vie",openFocusTask:"Ouvrir la tâche prioritaire"},pageState:{loadingTitle:"Préparation en cours",loadingDescription:"Chargement des dernières données Forge pour cette vue."},settings:{localeLabel:"Langue",localeDescription:"Choisissez la langue utilisée dans Forge.",localeEnglish:"Anglais",localeFrench:"Français",localeSaved:"Langue enregistrée"},overview:{heroEyebrow:"Vue stratégique",heroEmptyTitle:"Prêt à démarrer",heroDescription:"Voyez vos objectifs, projets actifs, tâches en cours et preuves récentes au même endroit.",emptyTitle:"Pas encore de vue d'ensemble",emptyDescription:"Créez un objectif de vie, un projet ou une tâche pour donner à Forge une base réelle.",emptyAction:"Ouvrir les objectifs de vie",commandEyebrow:"Vue de commande",commandTitle:"Maintenant, ensuite, risques et preuves récentes",commandDescription:"Cette vue doit montrer ce qui mérite votre attention maintenant, ce qui vient ensuite, où la dérive apparaît et les progrès déjà visibles.",sectionGoals:"Objectifs de vie actifs",sectionProjects:"Projets actifs",sectionFocus:"Priorité du jour",sectionEvidence:"Preuves récentes",sectionMomentum:"Noyau de momentum",sectionAttention:"À surveiller",noGoals:"Aucun objectif de vie actif pour le moment. Commencez par définir la direction que Forge doit soutenir.",noProjects:"Aucun projet actif. Ajoutez un projet pour transformer un objectif en travail concret.",noFocus:"Aucune tâche prioritaire pour le moment. Faites passer une tâche en priorité quand vous savez quoi faire ensuite.",noEvidence:"Aucune preuve enregistrée pour le moment. Le travail accompli et l'activité journalisée apparaîtront ici.",noProjectYet:"Pas encore de projet",noAttention:"Aucun signal majeur de dérive pour le moment. Forge affichera ici les objectifs négligés.",metricsLevel:"Niveau",metricsWeeklyXp:"XP hebdo",metricsFocusTasks:"Tâches prioritaires",metricsOverdue:"En retard"},todayPage:{heroEyebrow:"Aujourd'hui",heroEmptyTitle:"Pas encore de direction du jour",heroDescription:"Commencez une tâche, gagnez de l'XP et gardez la journée claire.",emptyTitle:"Pas encore de piste du jour",emptyDescription:"Ajoutez des objectifs, des tâches ou des cibles de récompense pour que Forge puisse construire une journée utile.",emptyAction:"Ouvrir les objectifs de vie",commandEyebrow:"Commande du jour",commandTitle:"Directive, quêtes du jour, reprise et ligne d'arrivée",commandDescription:"Aujourd'hui doit rendre le prochain mouvement utile évident et garder la journée ancrée dans un vrai travail.",questsTitle:"Quêtes du jour",questsEmpty:"Pas encore de quêtes du jour. Elles apparaîtront quand Forge aura assez de travail réel et de contexte de récompense.",rewardsTitle:"Récompenses jalons",rewardsEmpty:"Aucune récompense jalon active pour le moment. Elles apparaîtront à mesure que la structure de progression se précise.",signalDirective:"Directive",signalQuest:"Chaîne de quêtes",signalComeback:"Reprise",signalFinish:"Ligne d'arrivée",noDirective:"Choisissez une tâche claire pour ancrer la journée.",noQuest:"Aucune chaîne de quêtes active",noQuestDetail:"Les quêtes du jour doivent renforcer le vrai travail, pas le détourner.",noComeback:"La fenêtre de reprise est claire",noFinish:"Gardez la journée nette",noDirectiveDetail:"Faites passer une vraie tâche en priorité et la vue Aujourd'hui deviendra plus nette.",noFinishDetail:"Une bonne fin de journée doit alléger demain, pas l'encombrer."},kanban:{heroEyebrow:"Tableau des tâches",heroTitle:"Tableau des tâches",heroDescription:"Utilisez le tableau pour faire avancer le travail actif, revoir les blocages et ouvrir les détails quand nécessaire.",emptyTitle:"Pas encore de tableau",emptyDescription:"Créez votre première tâche dans un projet pour commencer à utiliser le tableau.",emptyAction:"Ouvrir les objectifs de vie",healthEyebrow:"État du tableau",healthTitle:"Travail visible, priorité, blocages et travail terminé",healthDescription:"Le tableau doit montrer ce qui est actif, ce qui demande de l'attention et ce qui est déjà terminé.",visibleWork:"Travail visible",focusWork:"Priorité actuelle",blockedWork:"Travail bloqué",completedWork:"Travail terminé",visibleDetail:"{hidden} tâches sont hors des filtres actuels.",focusDetailReady:"Ce sont les tâches les plus prêtes à être reprises maintenant.",focusDetailEmpty:"Faites passer une tâche du backlog en priorité pour rendre le tableau plus utile.",blockedDetail:"Ces tâches ont besoin d'une décision, d'un déblocage ou d'une remise à plat avant d'avancer.",blockedDetailEmpty:"Aucune tâche bloquée pour le moment.",doneDetail:"Le travail terminé reste ici jusqu'à sa revue ou sa réouverture.",doneDetailEmpty:"Rien n'a encore été terminé sur ce tableau.",boardFilters:"Filtres du tableau",filterGoal:"Objectif",filterOwner:"Responsable",allGoals:"Tous les objectifs",allOwners:"Tous les responsables",noTasksMatch:"Aucune tâche ne correspond à ces filtres",noTasksMatchDescription:"Ces filtres masquent toutes les tâches. Réinitialisez-les pour revoir l'ensemble du tableau.",taskContext:"Détails de la tâche",evidence:"Activité récente",runHistory:"Historique d'exécution",noTaskEvidence:"Aucune activité n'a encore été enregistrée pour cette tâche.",noRunHistory:"Aucune exécution n'a encore été enregistrée pour cette tâche.",taskPlacement:"Placement de la tâche",projectLabel:"Projet : {value}",goalLabel:"Objectif de vie : {value}",ownerLabel:"Responsable : {value}",dueLabel:"Échéance : {value}",openTask:"Ouvrir la tâche",openProject:"Ouvrir le projet",openGoal:"Ouvrir l'objectif de vie",noProjectLinked:"Aucun projet lié",noGoalLinked:"Aucun objectif de vie lié"},dailyRunway:{runwayEyebrow:"Aujourd'hui",runwayTitle:"Tâches du jour",prioritiesOne:"{count} tâche",prioritiesOther:"{count} tâches",unassigned:"Non attribué",runwayItem:"Tâche {index}",noNote:"Aucune note pour le moment.",inspect:"Ouvrir la tâche",actionBacklog:"Commencer",actionFocus:"Commencer",actionProgress:"Terminer",actionBlocked:"Commencer",timelineEyebrow:"Par statut",timelineTitle:"Tâches par statut",emptyBucket:"Rien ici pour le moment."},executionBoard:{laneBacklogTitle:"Backlog",laneBacklogDetail:"Pas encore commencé",laneFocusTitle:"Priorité",laneFocusDetail:"Prêt à être traité",laneProgressTitle:"En cours",laneProgressDetail:"En mouvement",laneBlockedTitle:"Bloqué",laneBlockedDetail:"Demande de l'attention",laneDoneTitle:"Terminé",laneDoneDetail:"Achevé",noExecutionNote:"Aucune note pour le moment.",reopen:"Rouvrir",emptyLane:"Aucune tâche dans cette colonne."},weeklyReview:{heroEyebrow:"Revue hebdomadaire",heroDescription:"Relisez la semaine, notez ce qui a avancé et décidez de ce qui demande de l'attention ensuite.",summaryEyebrow:"Résumé hebdomadaire",summaryTitle:"Cette semaine, les progrès, la récupération et la suite",summaryDescription:"Utilisez cette revue pour comprendre la semaine et choisir le prochain mouvement utile.",sectionMomentum:"Résumé du momentum",sectionGoals:"Point sur les objectifs",sectionWins:"Progrès",completionBonus:"Bonus de complétion",finalize:"Terminer la revue",noWin:"Aucun progrès enregistré",noWinDetail:"Même si la semaine a été calme, notez au moins un apprentissage utile.",noRecovery:"Aucune suggestion de récupération",noRecoveryDetail:"Si la semaine a été stable, gardez malgré tout une option légère de récupération."},dialogs:{closeDialog:"Fermer la fenêtre",task:{eyebrow:"Tâche",createTitle:"Créer une tâche",editTitle:"Modifier la tâche",description:"Utilisez les tâches pour représenter la prochaine étape concrète dans un projet. Choisissez d'abord le projet pour garder le bon contexte.",project:"Projet",selectProject:"Sélectionner un projet",goal:"Objectif de vie",title:"Titre",descriptionLabel:"Description",owner:"Responsable",xp:"XP",priority:"Priorité",status:"Statut",effort:"Effort",energy:"Énergie",dueDate:"Date d'échéance",tags:"Tags",save:"Enregistrer la tâche",create:"Créer la tâche"},project:{eyebrow:"Projet",createTitle:"Créer un projet",editTitle:"Modifier le projet",description:"Utilisez les projets pour transformer un objectif de vie en flux de travail concret avec tâches, preuves et momentum.",goal:"Objectif de vie",selectGoal:"Sélectionner un objectif de vie",title:"Titre",descriptionLabel:"Description",status:"Statut",targetXp:"XP cible",themeColor:"Couleur du thème",save:"Enregistrer le projet",create:"Créer le projet",submitError:"La mise à jour du projet a échoué."},goal:{eyebrow:"Objectif de vie",createTitle:"Créer un objectif de vie",editTitle:"Modifier l'objectif de vie",description:"Utilisez les objectifs de vie pour définir ce qui compte sur les mois ou les années à venir avant de le décliner en projets.",title:"Titre",descriptionLabel:"Description",horizon:"Horizon",status:"Statut",targetXp:"XP cible",themeColor:"Couleur du thème",tags:"Domaines de vie et contexte",save:"Enregistrer l'objectif de vie",create:"Créer l'objectif de vie",submitError:"La mise à jour de l'objectif a échoué."}},taskDetail:{eyebrow:"Tâche",errorEyebrow:"Tâche",emptyPayload:"Forge a renvoyé une charge utile de tâche vide.",heroFallback:"Utilisez cette page pour mettre à jour la tâche, la faire avancer et garder son contexte clair.",commandEyebrow:"Commande de tâche",commandTitle:"Statut, prochaine action, preuves et contexte",commandDescription:"Cette page doit aider à modifier directement la tâche et à comprendre clairement son contexte.",signalState:"Statut",signalNext:"Prochaine action",signalEvidence:"Activité récente",signalAnchor:"Projet lié",noStateChange:"Aucun changement d'état nécessaire",terminalStateDetail:"Cette tâche est déjà dans un état terminé, sauf si vous décidez de la rouvrir.",noEvidence:"Aucune activité récente pour le moment",noEvidenceDetail:"Le travail terminé, les corrections et les sessions apparaîtront ici à mesure que la tâche avance.",noAnchor:"Aucun projet lié",linkAnchorDetail:"Reliez cette tâche à un projet ou à un objectif de vie pour que Forge puisse montrer pourquoi elle compte.",edit:"Modifier la tâche",openProject:"Ouvrir le projet",openGoal:"Ouvrir l'objectif de vie",markNotCompleted:"Marquer comme non terminée",sectionStatus:"Statut de la tâche",fieldProject:"Projet",fieldGoal:"Objectif de vie",fieldDueDate:"Date d'échéance",pendingMove:"Déplacement",actionBacklog:"Passer au backlog",actionFocus:"Passer en priorité",actionProgress:"Commencer maintenant",actionBlocked:"Marquer bloquée",actionDone:"Marquer terminée",sectionEvidence:"Activité récente",noVisibleEvidence:"Aucune activité n'a encore été enregistrée pour cette tâche.",removeLog:"Supprimer l'entrée",openRelatedItem:"Ouvrir l'élément lié",sectionRuns:"Sessions de travail",noRuns:"Aucune session de travail n'a encore été enregistrée pour cette tâche.",sectionMetadata:"Autres détails de la tâche",metaOwner:"Responsable : {value}",metaEffort:"Effort : {value}",metaEnergy:"Énergie : {value}",metaCreated:"Créée : {value}",metaUpdated:"Dernière mise à jour : {value}",metaCompleted:"Terminée le : {value}",metaNotCompleted:"Non terminée"},projectDetail:{errorEyebrow:"Projet",heroEyebrow:"Projet",commandEyebrow:"État du projet",commandTitle:"Momentum, prochaine tâche, risque et preuves",commandDescription:"Utilisez cette page pour voir ce qui avance, ce qui demande votre attention ensuite, et quelles preuves soutiennent déjà le projet.",signalMomentum:"Momentum",signalNext:"Prochaine tâche",signalRisk:"Risque",signalEvidence:"Preuves",trackedTasksOne:"{count} tâche suivie",trackedTasksOther:"{count} tâches suivies",noNextTask:"Aucune prochaine tâche choisie",noNextTaskDetail:"Choisissez ou créez une tâche pour donner au projet un prochain mouvement clair.",needsFocus:"Besoin de priorité",noRisk:"Aucun risque immédiat",noRiskDetail:"Le travail bloqué ou négligé apparaîtra ici si le projet commence à dériver.",noEvidence:"Aucune preuve récente",noEvidenceDetail:"Le travail terminé et l'activité enregistrée apparaîtront ici à mesure que le projet avance.",compatibility:"Mode de compatibilité",compatibilityDescription:"Ce projet provient d'un ancien format d'instantané. Vous pouvez le consulter ici, mais sa modification demande le backend mis à jour.",addTask:"Ajouter une tâche",editProject:"Modifier le projet",openGoal:"Ouvrir l'objectif de vie",sectionHealth:"Santé du projet",fieldStatus:"Statut",fieldProgress:"Progression",fieldMomentum:"Momentum",sectionEvidence:"Preuves récentes"},goalDetail:{eyebrow:"Objectif de vie",missingTitle:"Cet objectif de vie n'est pas disponible",missingDescription:"Forge ne trouve pas cet objectif de vie dans l'instantané actuel. Revenez à la vue des objectifs et choisissez-en un actif.",backToGoals:"Retour aux objectifs",heroBadgeOne:"{count} projet",heroBadgeOther:"{count} projets",commandEyebrow:"État de l'objectif",commandTitle:"Progression, prochain élan, risque et preuves",commandDescription:"Utilisez cette page pour voir ce qui fait avancer l'objectif, ce qui doit bouger ensuite, et où du soutien est nécessaire.",signalProgress:"Progression",signalNext:"Prochain élan",signalRisk:"Risque",signalEvidence:"Preuves",progressTitle:"{progress}% avec {count} tâches terminées",progressDetail:"{xp} XP sont déjà cumulés sur cet objectif.",noProject:"Aucun projet actif pour le moment",noProjectDetail:"Ajoutez un projet pour donner à cet objectif un chemin d'exécution concret.",needsProject:"Projet nécessaire",nextMove:"Prochaine action : {value}",noRisk:"Aucun signal de dérive pour le moment",noRiskDetail:"Si cet objectif commence à glisser, Forge affichera cette pression ici.",noEvidence:"Aucune preuve récente",noEvidenceDetail:"Les tâches terminées, le mouvement des projets et les actions d'agents apparaîtront ici comme preuve de progression.",edit:"Modifier l'objectif de vie",addProject:"Ajouter un projet",sectionProjects:"Projets qui font avancer cet objectif",noProjects:"Cet objectif n'a pas encore de projet actif. Ajoutez-en un pour le transformer en mouvement concret.",addNextTask:"Ajouter la prochaine tâche",sectionHealth:"Santé de l'objectif",fieldProgress:"Progression",fieldCompletedTasks:"Tâches terminées",fieldXpBanked:"XP cumulés",sectionEvidence:"Preuves récentes",noEvidenceLogged:"Aucune preuve n'a encore été enregistrée pour cet objectif. Les tâches terminées, les mises à jour de projet et les actions d'agents apparaîtront ici."}}},yi={en:Po,fr:Lo};function wi(t,s){const a=s.split(".");let r=t;for(const i of a){if(!r||typeof r=="string")return;r=r[i]}return typeof r=="string"?r:void 0}function Mo(t,s){return s?t.replace(/\{(\w+)\}/g,(a,r)=>{const i=s[r];return i==null?"":String(i)}):t}function bs(t,s,a){const r=wi(yi[t],s),i=wi(yi.en,s);return Mo(r??i??s,a)}const Eo={locale:"en",t:(t,s)=>bs("en",t,s),formatDate:t=>t?new Intl.DateTimeFormat("en",{month:"short",day:"numeric"}).format(new Date(`${t}T00:00:00.000Z`)):bs("en","common.labels.noDate"),formatDateTime:t=>new Intl.DateTimeFormat("en",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(t)),formatNumber:t=>new Intl.NumberFormat("en").format(t)},bn=y.createContext(null);function Ao({children:t,locale:s}){const a=y.useMemo(()=>({locale:s,t:(r,i)=>bs(s,r,i),formatDate:r=>r?new Intl.DateTimeFormat(s,{month:"short",day:"numeric"}).format(new Date(`${r}T00:00:00.000Z`)):bs(s,"common.labels.noDate"),formatDateTime:r=>new Intl.DateTimeFormat(s,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(r)),formatNumber:r=>new Intl.NumberFormat(s).format(r)}),[s]);return e.jsx(bn.Provider,{value:a,children:t})}function Te(){return y.useContext(bn)??Eo}function ji({active:t,label:s,className:a}){const{t:r}=Te();return e.jsxs(De.div,{initial:!1,animate:{opacity:t?1:.55,y:0,scale:t?1:.98},transition:{duration:.24,ease:"easeOut"},className:Q("surface-pulse ambient-glow inline-flex min-h-11 shrink-0 items-center gap-2.5 rounded-full border border-white/8 px-4 py-2 text-left shadow-[0_18px_40px_rgba(3,8,18,0.22)] backdrop-blur-xl",a),"aria-live":"polite",children:[e.jsx(ca,{tone:"subtle",className:t?"opacity-100":"opacity-45"}),e.jsxs("div",{className:"inline-flex min-w-0 items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"type-label text-white/56",children:r("common.labels.backgroundActivity")}),e.jsx("span",{className:"text-white/30",children:"•"}),e.jsx("span",{className:"truncate text-sm text-white/80",children:s})]})]})}function B({className:t,tone:s="default",size:a="md",wrap:r=!1,...i}){return e.jsx("span",{className:Q("inline-flex max-w-full items-center rounded-full border border-white/8 bg-white/6 font-medium text-white/78",r?"whitespace-normal break-words [overflow-wrap:anywhere]":"overflow-hidden text-ellipsis whitespace-nowrap",a==="sm"?"min-h-7 px-2.5 py-1 text-[12px]":"min-h-8 px-3 py-1.5 text-[12px]",s==="meta"&&"bg-white/[0.04] text-white/58",s==="signal"&&"bg-[rgba(192,193,255,0.12)] text-white/86",t),...i})}const Do={goal:{kind:"goal",label:"Goal",icon:ys,iconClassName:"text-amber-100",nameClassName:"text-amber-100",badgeClassName:"border-amber-300/24 bg-[linear-gradient(135deg,rgba(251,191,36,0.24),rgba(251,191,36,0.08))] text-amber-50",subtleBadgeClassName:"border-amber-300/18 bg-[rgba(251,191,36,0.08)] text-amber-100",buttonClassName:"border-amber-300/20 bg-[rgba(251,191,36,0.12)] text-amber-50 hover:bg-[rgba(251,191,36,0.18)]"},project:{kind:"project",label:"Project",icon:vr,iconClassName:"text-sky-100",nameClassName:"text-sky-100",badgeClassName:"border-sky-300/24 bg-[linear-gradient(135deg,rgba(56,189,248,0.22),rgba(56,189,248,0.08))] text-sky-50",subtleBadgeClassName:"border-sky-300/18 bg-[rgba(56,189,248,0.08)] text-sky-100",buttonClassName:"border-sky-300/20 bg-[rgba(56,189,248,0.12)] text-sky-50 hover:bg-[rgba(56,189,248,0.18)]"},task:{kind:"task",label:"Task",icon:fr,iconClassName:"text-indigo-100",nameClassName:"text-indigo-100",badgeClassName:"border-indigo-300/24 bg-[linear-gradient(135deg,rgba(129,140,248,0.22),rgba(129,140,248,0.08))] text-indigo-50",subtleBadgeClassName:"border-indigo-300/18 bg-[rgba(129,140,248,0.08)] text-indigo-100",buttonClassName:"border-indigo-300/20 bg-[rgba(129,140,248,0.12)] text-indigo-50 hover:bg-[rgba(129,140,248,0.18)]"},value:{kind:"value",label:"Value",icon:br,iconClassName:"text-emerald-100",nameClassName:"text-emerald-100",badgeClassName:"border-emerald-300/24 bg-[linear-gradient(135deg,rgba(52,211,153,0.24),rgba(52,211,153,0.08))] text-emerald-50",subtleBadgeClassName:"border-emerald-300/18 bg-[rgba(52,211,153,0.08)] text-emerald-100",buttonClassName:"border-emerald-300/20 bg-[rgba(52,211,153,0.12)] text-emerald-50 hover:bg-[rgba(52,211,153,0.18)]"},pattern:{kind:"pattern",label:"Pattern",icon:gr,iconClassName:"text-rose-100",nameClassName:"text-rose-100",badgeClassName:"border-rose-300/24 bg-[linear-gradient(135deg,rgba(251,113,133,0.24),rgba(251,113,133,0.08))] text-rose-50",subtleBadgeClassName:"border-rose-300/18 bg-[rgba(251,113,133,0.08)] text-rose-100",buttonClassName:"border-rose-300/20 bg-[rgba(251,113,133,0.12)] text-rose-50 hover:bg-[rgba(251,113,133,0.18)]"},behavior:{kind:"behavior",label:"Behavior",icon:xr,iconClassName:"text-orange-100",nameClassName:"text-orange-100",badgeClassName:"border-orange-300/24 bg-[linear-gradient(135deg,rgba(251,146,60,0.24),rgba(251,146,60,0.08))] text-orange-50",subtleBadgeClassName:"border-orange-300/18 bg-[rgba(251,146,60,0.08)] text-orange-100",buttonClassName:"border-orange-300/20 bg-[rgba(251,146,60,0.12)] text-orange-50 hover:bg-[rgba(251,146,60,0.18)]"},belief:{kind:"belief",label:"Belief",icon:pr,iconClassName:"text-violet-100",nameClassName:"text-violet-100",badgeClassName:"border-violet-300/24 bg-[linear-gradient(135deg,rgba(167,139,250,0.24),rgba(167,139,250,0.08))] text-violet-50",subtleBadgeClassName:"border-violet-300/18 bg-[rgba(167,139,250,0.08)] text-violet-100",buttonClassName:"border-violet-300/20 bg-[rgba(167,139,250,0.12)] text-violet-50 hover:bg-[rgba(167,139,250,0.18)]"},mode:{kind:"mode",label:"Mode",icon:ur,iconClassName:"text-fuchsia-100",nameClassName:"text-fuchsia-100",badgeClassName:"border-fuchsia-300/24 bg-[linear-gradient(135deg,rgba(217,70,239,0.24),rgba(217,70,239,0.08))] text-fuchsia-50",subtleBadgeClassName:"border-fuchsia-300/18 bg-[rgba(217,70,239,0.08)] text-fuchsia-100",buttonClassName:"border-fuchsia-300/20 bg-[rgba(217,70,239,0.12)] text-fuchsia-50 hover:bg-[rgba(217,70,239,0.18)]"},report:{kind:"report",label:"Report",icon:hr,iconClassName:"text-blue-100",nameClassName:"text-blue-100",badgeClassName:"border-blue-300/24 bg-[linear-gradient(135deg,rgba(96,165,250,0.24),rgba(96,165,250,0.08))] text-blue-50",subtleBadgeClassName:"border-blue-300/18 bg-[rgba(96,165,250,0.08)] text-blue-100",buttonClassName:"border-blue-300/20 bg-[rgba(96,165,250,0.12)] text-blue-50 hover:bg-[rgba(96,165,250,0.18)]"}};function ot(t){return Do[t]}function _t(t,s){const a=ot(t);return s?`border ${a.buttonClassName}`:"border border-white/8 bg-white/[0.05] text-white/62 hover:bg-white/[0.08] hover:text-white"}function re({kind:t,label:s,compact:a=!1,showIcon:r=!0,iconOnly:i=!1,gradient:n=!0,wrap:o=!1,className:h,...l}){const x=ot(t),g=x.icon;return e.jsxs(B,{size:a?"sm":"md",wrap:o,className:Q("max-w-full min-w-0 gap-1.5 border font-medium",n?x.badgeClassName:x.subtleBadgeClassName,a&&!i&&"px-2.5",i&&"px-2.5",h),...l,children:[r?e.jsx(g,{className:Q("size-3.5 shrink-0",x.iconClassName)}):null,i?null:e.jsx("span",{className:Q("min-w-0 max-w-full",o?"whitespace-normal break-words [overflow-wrap:anywhere]":"truncate"),children:s??x.label})]})}const Ro={sm:"text-base",md:"text-lg",lg:"text-2xl",xl:"text-3xl"},Os={1:"truncate whitespace-nowrap",2:"overflow-hidden whitespace-normal [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:2]",3:"overflow-hidden whitespace-normal [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:3]"};function ue({kind:t,label:s,variant:a="inline",size:r="md",showKind:i=!1,showIcon:n=!0,showBadge:o=!1,badgeLabel:h,badgeCompact:l=!0,badgeGradient:x=!1,lines:g=1,labelClassName:f,className:d,...u}){const b=ot(t),c=b.icon;return a==="pill"?e.jsxs("span",{className:Q("inline-flex max-w-full items-center gap-2 rounded-full border px-4 py-2 font-medium shadow-[0_10px_28px_rgba(3,8,18,0.18)]",b.badgeClassName,d),...u,children:[n?e.jsx(c,{className:Q("size-4 shrink-0",b.iconClassName)}):null,e.jsx("span",{className:Q("min-w-0 max-w-full",Os[g],f),children:s})]}):a==="heading"?e.jsxs("span",{className:Q("inline-flex max-w-full min-w-0 items-center gap-3",d),...u,children:[o?e.jsx(re,{kind:t,label:h??b.label,compact:l,gradient:x,className:"shrink-0"}):null,i&&!o?e.jsx(re,{kind:t,label:h??b.label,compact:!0,gradient:!1,className:"shrink-0"}):null,e.jsx("span",{className:Q("min-w-0 max-w-full font-display leading-tight",Ro[r],Os[g],b.nameClassName,f),children:s})]}):e.jsxs("span",{className:Q("inline-flex max-w-full min-w-0 items-center gap-2",d),...u,children:[n?e.jsx(c,{className:Q("size-4 shrink-0",b.iconClassName)}):null,o?e.jsx(re,{kind:t,label:h??b.label,compact:l,gradient:x,className:"shrink-0"}):null,i?e.jsx("span",{className:Q("text-sm font-medium",b.nameClassName),children:b.label}):null,e.jsx("span",{className:Q("min-w-0 max-w-full",Os[g],b.nameClassName,f),children:s})]})}function ae({className:t,size:s,...a}){return e.jsx("input",{...a,className:Q("interactive-tap w-full rounded-[22px] border border-white/8 bg-white/6 px-4 py-3 text-[15px] text-white outline-none ring-0 placeholder:text-white/35 focus:border-[rgba(192,193,255,0.35)]",t)})}function _o({open:t,onOpenChange:s,snapshot:a}){const r=Ve(),{t:i}=Te(),[n,o]=y.useState("");y.useEffect(()=>{t||o("")},[t]);const h=y.useMemo(()=>[...[{id:"route-overview",title:i("common.routeLabels.overview"),detail:i("common.commandPalette.routeOverview"),href:"/overview",category:i("common.commandPalette.categoryRoute")},{id:"route-today",title:i("common.routeLabels.today"),detail:i("common.commandPalette.routeToday"),href:"/today",category:i("common.commandPalette.categoryRoute")},{id:"route-kanban",title:i("common.routeLabels.kanban"),detail:i("common.commandPalette.routeKanban"),href:"/kanban",category:i("common.commandPalette.categoryRoute")},{id:"route-psyche",title:i("common.routeLabels.psyche"),detail:i("common.commandPalette.routePsyche"),href:"/psyche",category:i("common.commandPalette.categoryRoute")},{id:"route-notes",title:i("common.routeLabels.notes"),detail:i("common.commandPalette.routeNotes"),href:"/notes",category:i("common.commandPalette.categoryRoute")},{id:"route-goals",title:i("common.routeLabels.goals"),detail:i("common.commandPalette.routeGoals"),href:"/goals",category:i("common.commandPalette.categoryRoute")},{id:"route-projects",title:i("common.routeLabels.projects"),detail:i("common.commandPalette.routeProjects"),href:"/projects",category:i("common.commandPalette.categoryRoute")},{id:"route-review",title:i("common.routeLabels.review"),detail:i("common.commandPalette.routeReview"),href:"/review/weekly",category:i("common.commandPalette.categoryRoute")},{id:"route-settings",title:i("common.routeLabels.settings"),detail:i("common.commandPalette.routeSettings"),href:"/settings",category:i("common.commandPalette.categoryRoute")}],...a.dashboard.goals.slice(0,6).map(g=>({id:`goal-${g.id}`,title:g.title,detail:i("common.commandPalette.openLifeGoal"),href:`/goals/${g.id}`,category:i("common.commandPalette.categoryGoal"),kind:"goal"})),...a.dashboard.projects.slice(0,6).map(g=>({id:`project-${g.id}`,title:g.title,detail:g.goalTitle,href:`/projects/${g.id}`,category:i("common.commandPalette.categoryProject"),kind:"project"})),...a.overview.topTasks.slice(0,8).map(g=>({id:`task-${g.id}`,title:g.title,detail:i("common.commandPalette.openFocusTask"),href:`/tasks/${g.id}`,category:i("common.commandPalette.categoryTask"),kind:"task"}))],[a,i]),l=y.useMemo(()=>{const x=n.trim().toLowerCase();return x?h.filter(g=>`${g.title} ${g.detail} ${g.category}`.toLowerCase().includes(x)).slice(0,12):h.slice(0,12)},[h,n]);return e.jsx(Bt,{open:t,onOpenChange:s,children:e.jsxs(zt,{children:[e.jsx(Kt,{className:"fixed inset-0 z-40 bg-[rgba(5,10,18,0.68)] backdrop-blur-xl"}),e.jsxs(Xt,{className:"fixed inset-x-4 top-[12vh] z-50 mx-auto max-w-2xl overflow-hidden rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(20,28,42,0.98),rgba(12,17,30,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.45)]",children:[e.jsxs("div",{className:"border-b border-white/8 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] bg-white/[0.04] px-4 py-3",children:[e.jsx(ft,{className:"size-4 text-white/42"}),e.jsx(ae,{autoFocus:!0,value:n,onChange:x=>o(x.target.value),placeholder:i("common.commandPalette.searchPlaceholder"),className:"border-0 bg-transparent px-0 py-0 focus:border-0"})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-white/50",children:[{label:i("common.routeLabels.overview"),icon:on},{label:i("common.routeLabels.today"),icon:ws},{label:i("common.routeLabels.kanban"),icon:Ft},{label:i("common.routeLabels.notes"),icon:sa},{label:i("common.routeLabels.psyche"),icon:aa},{label:i("common.routeLabels.goals"),icon:ys},{label:i("common.routeLabels.projects"),icon:ln},{label:i("common.routeLabels.settings"),icon:ia}].map(x=>e.jsxs("span",{className:"inline-flex min-h-10 items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-xs text-white/58",children:[e.jsx(x.icon,{className:"size-3.5"}),x.label]},x.label))})]}),e.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-3",children:e.jsxs("div",{className:"grid gap-2",children:[l.map(x=>e.jsx("button",{type:"button",className:"interactive-tap rounded-[22px] bg-white/[0.04] px-4 py-3 text-left transition hover:bg-white/[0.07]",onClick:()=>{s(!1),r(x.href)},children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white/46",children:x.category}),e.jsx("div",{className:"mt-1 type-title-md text-white",children:x.kind?e.jsx(ue,{kind:x.kind,label:x.title}):x.title}),e.jsx("div",{className:"mt-1 text-sm text-white/58",children:x.detail})]}),e.jsx(vt,{className:"size-4 text-white/35"})]})},x.id)),l.length===0?e.jsx("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-5 text-sm text-white/56",children:i("common.commandPalette.noResults")}):null]})})]})]})})}function ki({routeKey:t,tone:s="core",children:a}){const r=s==="psyche"?10:18,i=s==="psyche"?.26:.2;return e.jsx(bt,{mode:"wait",initial:!1,children:e.jsx(De.div,{className:"w-full max-w-full min-w-0",initial:{opacity:0,y:r},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:i,ease:"easeOut"},children:a},t)})}const Oo=yr("inline-flex min-w-0 max-w-full items-center justify-center gap-2 overflow-hidden whitespace-nowrap rounded-[var(--radius-control)] font-medium leading-none transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[rgba(192,193,255,0.45)] disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{primary:"bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] text-white shadow-[0_12px_30px_rgba(192,193,255,0.08)]",secondary:"bg-white/8 text-white hover:bg-white/12",ghost:"bg-transparent text-[var(--primary)] hover:bg-white/6"},size:{sm:"min-h-[2.125rem] px-2.5 py-[0.4375rem] text-[13px]",md:"interactive-tap min-h-10 px-3 py-2 text-[13px]",lg:"min-h-11 px-4 py-2.5 text-sm"}},defaultVariants:{variant:"primary",size:"md"}});function X({className:t,variant:s,size:a,pending:r=!1,pendingLabel:i,children:n,disabled:o,...h}){return e.jsxs("button",{className:Q(Oo({variant:s,size:a}),t),disabled:o||r,"aria-busy":r,...h,children:[r?e.jsx(ca,{className:"size-3.5",tone:"subtle"}):null,e.jsx("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2 overflow-hidden truncate whitespace-nowrap",children:r&&i?i:n})]})}function ma({open:t,onOpenChange:s,eyebrow:a,title:r,description:i,children:n}){const{t:o}=Te();return e.jsx(Bt,{open:t,onOpenChange:s,children:e.jsxs(zt,{children:[e.jsx(Kt,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),e.jsxs(Xt,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-xl flex-col overflow-hidden rounded-[32px] border border-white/8 bg-[linear-gradient(180deg,rgba(20,28,42,0.98),rgba(12,17,30,0.98))] shadow-[0_32px_90px_rgba(3,8,18,0.45)]",children:[e.jsx("div",{className:"border-b border-white/8 px-5 py-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"type-label text-white/46",children:a}),e.jsx(ks,{className:"mt-2 type-display-section text-white",children:r}),i?e.jsx(Ns,{className:"mt-3 type-body text-white/64",children:i}):null]}),e.jsx(X,{variant:"secondary",onClick:()=>s(!1),children:o("common.actions.close")})]})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",children:n})]})]})})}function lt({children:t,className:s}){return e.jsx("div",{className:Q("text-sm leading-6 text-white/50",s),children:t})}function Ne({content:t,label:s="Explain this field",className:a}){const[r,i]=y.useState(!1),n=y.useRef(null),o=y.useId();return y.useEffect(()=>{if(!r)return;const h=l=>{var x;(x=n.current)!=null&&x.contains(l.target)||i(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[r]),e.jsxs("span",{ref:n,className:Q("relative inline-flex items-center",a),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[e.jsx("button",{type:"button","aria-label":s,"aria-describedby":r?o:void 0,"aria-expanded":r,className:"inline-flex size-5 items-center justify-center rounded-full text-white/42 transition hover:bg-white/[0.06] hover:text-white/78 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[rgba(192,193,255,0.35)]",onFocus:()=>i(!0),onBlur:()=>i(!1),onClick:()=>i(h=>!h),children:e.jsx(wr,{className:"size-3.5"})}),e.jsx("span",{id:o,role:"tooltip",className:Q("pointer-events-none absolute right-0 top-[calc(100%+0.55rem)] z-40 w-[min(16rem,calc(100vw-2.5rem))] max-w-[calc(100vw-2.5rem)] rounded-[18px] border border-white/8 bg-[rgba(12,17,30,0.96)] px-3 py-2.5 text-sm leading-6 text-white/74 shadow-[0_18px_48px_rgba(3,8,18,0.42)] transition",r?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:t})]})}const Ni="(max-width: 1023px)";function $o(){const[t,s]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(Ni).matches);return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(Ni),r=i=>{s(i.matches)};return s(a.matches),typeof a.addEventListener=="function"?(a.addEventListener("change",r),()=>a.removeEventListener("change",r)):(a.addListener(r),()=>a.removeListener(r))},[]),t}function q({label:t,description:s,labelHelp:a,hint:r,error:i,children:n}){return e.jsxs("label",{className:"grid gap-2",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-white",children:[e.jsx("span",{children:t}),a?e.jsx(Ne,{content:a,label:`Explain ${t}`}):null]}),s?e.jsx("span",{className:"text-sm leading-6 text-white/54",children:s}):null,n,r?e.jsx(lt,{children:r}):null,i?e.jsx("span",{className:"text-sm text-rose-300",children:i}):null]})}function Re({options:t,value:s,onChange:a,columns:r=2}){return e.jsx("div",{className:Q("grid gap-3",r===3?"md:grid-cols-3":"md:grid-cols-2"),children:t.map(i=>{const n=i.value===s;return e.jsxs("button",{type:"button",className:Q("rounded-[22px] border px-4 py-4 text-left transition",n?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white shadow-[0_18px_36px_rgba(5,12,24,0.24)]":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"),onClick:()=>a(i.value),children:[e.jsx("div",{className:"font-medium",children:i.label}),i.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:i.description}):null]},i.value)})})}function qe({open:t,onOpenChange:s,eyebrow:a,title:r,description:i,value:n,onChange:o,steps:h,onSubmit:l,submitLabel:x,pending:g=!1,pendingLabel:f,error:d}){const{t:u}=Te(),b=$o(),[c,j]=y.useState(0),k=h[c];y.useEffect(()=>{t||j(0)},[t]);const $=N=>{o({...n,...N})},M=h.length,I=M===0?0:(c+1)/M*100;return e.jsx(Bt,{open:t,onOpenChange:s,children:e.jsxs(zt,{children:[e.jsx(Kt,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl"}),e.jsxs(Xt,{"data-testid":"question-flow-dialog",className:Q("fixed z-50 flex flex-col overflow-y-auto border border-white/8 bg-[linear-gradient(180deg,rgba(21,28,44,0.985),rgba(12,17,30,0.985))] shadow-[0_30px_90px_rgba(3,8,18,0.45)]",b?"inset-x-3 bottom-3 top-4 rounded-[30px]":"left-1/2 top-1/2 h-[min(52rem,calc(100vh-1rem))] w-[min(56rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 rounded-[34px]"),children:[e.jsx(ks,{className:"sr-only",children:r}),e.jsx(Ns,{className:"sr-only",children:i}),e.jsx("div",{className:"sticky top-0 z-10 border-b border-white/8 bg-[rgba(12,17,30,0.9)] px-4 py-2.5 backdrop-blur-xl md:px-6",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.18em] text-white/42",children:[e.jsx("span",{className:"truncate",children:a}),e.jsxs("span",{className:"whitespace-nowrap",children:["Step ",c+1," of ",M]})]}),e.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-white/[0.06]",children:e.jsx(De.div,{className:"h-full rounded-full bg-[linear-gradient(90deg,rgba(192,193,255,0.9),rgba(125,211,252,0.82))]",animate:{width:`${I}%`},transition:{duration:.35,ease:"easeOut"}})})]}),e.jsx(gs,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":u("common.dialogs.closeDialog"),className:"rounded-full bg-white/6 p-2 text-white/65 transition hover:bg-white/10 hover:text-white",children:e.jsx(Pt,{className:"size-4"})})})]})}),e.jsx("div",{"data-testid":"question-flow-canvas",className:"flex-1 px-4 py-4 md:px-6 md:py-5",children:e.jsx(bt,{mode:"wait",children:e.jsxs(De.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},exit:{opacity:0,y:-18},transition:{duration:.28,ease:"easeOut"},className:"flex min-h-full flex-col gap-5",children:[e.jsxs("div",{className:"flex min-h-full flex-col justify-start",children:[k.eyebrow?e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[var(--secondary)]",children:k.eyebrow}):null,e.jsx("h3",{className:"mt-1.5 font-display text-[clamp(1.45rem,2.15vw,2rem)] leading-tight text-white",children:k.title}),k.description?e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-white/58",children:k.description}):null,e.jsx("div",{className:"mt-5 grid flex-1 content-start gap-5",children:k.render(n,$)})]}),d?e.jsx("div",{className:"rounded-[20px] border border-rose-400/20 bg-rose-400/10 px-4 py-3 text-sm text-rose-200",children:d}):null]},k.id)})}),e.jsx("div",{className:"sticky bottom-0 border-t border-white/8 bg-[rgba(12,17,30,0.92)] px-4 py-2.5 backdrop-blur-xl md:px-6",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 sm:justify-between",children:[e.jsx("div",{className:"hidden min-w-0 shrink text-[12px] text-white/45 sm:block",children:e.jsxs("span",{className:"truncate whitespace-nowrap",children:["Step ",c+1,"/",M]})}),e.jsxs("div",{className:"flex shrink-0 flex-nowrap items-center gap-1.5 overflow-x-auto sm:gap-2",children:[c>0?e.jsxs(X,{type:"button",variant:"secondary",className:"min-w-max px-3 text-[12px]",onClick:()=>j(N=>Math.max(0,N-1)),children:[e.jsx(jr,{className:"size-4"}),"Back"]}):e.jsx(gs,{asChild:!0,children:e.jsx(X,{type:"button",variant:"secondary",className:"min-w-max px-3 text-[12px]",children:u("common.actions.cancel")})}),c<M-1?e.jsxs(X,{type:"button",className:"min-w-max px-3 text-[12px]",onClick:()=>j(N=>Math.min(M-1,N+1)),children:["Continue",e.jsx(vt,{className:"size-4"})]}):e.jsxs(X,{type:"button",className:"min-w-max px-3 text-[12px]",pending:g,pendingLabel:f,onClick:()=>void l(),children:[e.jsx(na,{className:"size-4"}),x]})]})]})})]})]})})}function le({className:t,...s}){return e.jsx("textarea",{...s,className:Q("min-h-28 w-full rounded-[22px] border border-white/8 bg-white/6 px-4 py-3 text-[15px] text-white outline-none placeholder:text-white/35 focus:border-[rgba(192,193,255,0.35)]",t)})}const Fo=Ee(["en","fr"]),fn=Se({title:ee().trim().min(1,"Title is required"),description:ee().trim(),horizon:Ee(["quarter","year","lifetime"]),status:Ee(["active","paused","completed"]),targetPoints:qt.number().int().min(25).max(1e4),themeColor:ee().trim().regex(/^#[0-9a-fA-F]{6}$/,"Theme color must be a valid hex value"),tagIds:ce(ee())}),vn=Se({goalId:ee().trim().min(1,"Life goal is required"),title:ee().trim().min(1,"Title is required"),description:ee().trim(),status:Ee(["active","paused","completed"]),targetPoints:qt.number().int().min(25).max(1e4),themeColor:ee().trim().regex(/^#[0-9a-fA-F]{6}$/,"Theme color must be a valid hex value")}),qo=Se({profile:Se({operatorName:ee().trim().min(1,"Name is required"),operatorEmail:ee().trim().min(1,"Email is required"),operatorTitle:ee().trim().min(1,"Title is required")}),notifications:Se({goalDriftAlerts:Rs(),dailyQuestReminders:Rs(),achievementCelebrations:Rs()}),execution:Se({maxActiveTasks:qt.number().int().min(1).max(8),timeAccountingMode:Ee(["split","parallel","primary_only"])}),themePreference:Ee(["obsidian","solar","system"]),localePreference:Fo}),Bo=Se({label:ee().trim().min(1,"Label is required"),agentLabel:ee().trim().min(1,"Agent name is required"),agentType:ee().trim().min(1,"Agent type is required"),description:ee().trim(),trustLevel:Ee(["standard","trusted","autonomous"]),autonomyMode:Ee(["approval_required","scoped_write","autonomous"]),approvalMode:Ee(["approval_by_default","high_impact_only","none"]),scopes:ce(ee().trim().min(1)).min(1)}),zo=Se({originType:Ee(["system","user","agent"]),originAgentId:ee().trim(),originLabel:ee().trim(),entityType:ee().trim(),entityId:ee().trim(),timeframeLabel:ee().trim(),title:ee().trim().min(1,"Title is required"),summary:ee().trim().min(1,"Summary is required"),recommendation:ee().trim().min(1,"Recommendation is required"),rationale:ee().trim(),confidence:qt.number().min(0).max(1),ctaLabel:ee().trim().min(1,"CTA label is required")}),yn=Se({title:ee().trim().min(1,"Title is required"),description:ee().trim(),owner:ee().trim().min(1,"Owner is required"),goalId:ee().trim(),projectId:ee().trim().min(1,"Project is required"),priority:Ee(["low","medium","high","critical"]),status:Ee(["backlog","focus","in_progress","blocked","done"]),effort:Ee(["light","deep","marathon"]),energy:Ee(["low","steady","high"]),dueDate:ee().trim(),points:qt.number().int().min(5).max(500),tagIds:ce(ee())});Se({name:ee().trim().min(1,"Name is required"),kind:Ee(["value","category","execution"]),color:ee().trim().regex(/^#[0-9a-fA-F]{6}$/,"Color must be a valid hex value"),description:ee().trim()});const $s={title:"",description:"",horizon:"year",status:"active",targetPoints:400,themeColor:"#c8a46b",tagIds:[]};function Ko(t){return{title:t.title,description:t.description,horizon:t.horizon,status:t.status,targetPoints:t.targetPoints,themeColor:t.themeColor,tagIds:t.tagIds}}function ha({open:t,pending:s=!1,editingGoal:a,tags:r,onOpenChange:i,onSubmit:n}){const{t:o}=Te(),[h,l]=y.useState($s),[x,g]=y.useState(null),[f,d]=y.useState({}),u=c=>{d(Object.fromEntries(Object.entries(c).map(([j,k])=>[j,k==null?void 0:k[0]])))};y.useEffect(()=>{t&&(g(null),d({}),l(a?Ko(a):$s))},[a,t]);const b=[{id:"intent",eyebrow:"Direction",title:"Name the arc and why it matters",description:"Start with the long-horizon direction itself. We can refine cadence, tags, and visual tone after the intent is clear.",render:(c,j)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:o("common.dialogs.goal.title"),error:f.title??null,children:e.jsx(ae,{value:c.title,onChange:k=>j({title:k.target.value}),placeholder:"Build a durable body and calm energy"})}),e.jsx(q,{label:o("common.dialogs.goal.descriptionLabel"),children:e.jsx(le,{value:c.description,onChange:k=>j({description:k.target.value}),placeholder:"Describe the direction in plain language so projects can attach to it later."})})]})},{id:"cadence",eyebrow:"Cadence",title:"Choose the horizon and current posture",description:"Keep this simple: how long does this arc run, and is it currently active, paused, or already complete?",render:(c,j)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:o("common.dialogs.goal.horizon"),children:e.jsx(Re,{value:c.horizon,onChange:k=>j({horizon:k}),options:[{value:"quarter",label:o("common.enums.goalHorizon.quarter"),description:"Tight strategic push for the coming months."},{value:"year",label:o("common.enums.goalHorizon.year"),description:"A full-cycle objective for this year."},{value:"lifetime",label:o("common.enums.goalHorizon.lifetime"),description:"A long-running life arc that projects can keep serving."}],columns:3})}),e.jsx(q,{label:o("common.dialogs.goal.status"),children:e.jsx(Re,{value:c.status,onChange:k=>j({status:k}),options:[{value:"active",label:o("common.enums.projectStatus.active"),description:"This is live right now."},{value:"paused",label:o("common.enums.projectStatus.paused"),description:"Keep it visible, but do not push it right now."},{value:"completed",label:o("common.enums.projectStatus.completed"),description:"You have already fulfilled this arc."}]})})]})},{id:"signal",eyebrow:"Signal",title:"Set the target and visual signature",description:"Give Forge enough signal to show progress and make this arc recognizable throughout the app.",render:(c,j)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:o("common.dialogs.goal.targetXp"),error:f.targetPoints??null,children:e.jsx(ae,{type:"number",value:c.targetPoints,onChange:k=>j({targetPoints:Number(k.target.value)||0})})}),e.jsx(q,{label:o("common.dialogs.goal.themeColor"),error:f.themeColor??null,children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-white/8 bg-white/6 px-4 py-3",children:[e.jsx("input",{className:"h-10 w-12 rounded-lg border border-white/10 bg-transparent",type:"color",value:c.themeColor,onChange:k=>j({themeColor:k.target.value})}),e.jsx(ae,{className:"border-none bg-transparent px-0 py-0",value:c.themeColor,onChange:k=>j({themeColor:k.target.value})})]})}),e.jsx(q,{label:o("common.dialogs.goal.tags"),children:e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(k=>{const $=c.tagIds.includes(k.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${$?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>j({tagIds:$?c.tagIds.filter(M=>M!==k.id):[...c.tagIds,k.id]}),children:k.name},k.id)})})})]})}];return e.jsx(qe,{open:t,onOpenChange:i,eyebrow:o("common.dialogs.goal.eyebrow"),title:o(a?"common.dialogs.goal.editTitle":"common.dialogs.goal.createTitle"),description:o("common.dialogs.goal.description"),value:h,onChange:l,steps:b,pending:s,pendingLabel:o(a?"common.dialogs.goal.save":"common.dialogs.goal.create"),submitLabel:o(a?"common.dialogs.goal.save":"common.dialogs.goal.create"),error:x,onSubmit:async()=>{g(null);const c=fn.safeParse(h);if(!c.success){u(c.error.flatten().fieldErrors),g("Some answers still need attention before this goal arc can be saved.");return}d({});try{await n(c.data,a==null?void 0:a.id),l($s),i(!1)}catch(j){g(j instanceof Error?j.message:o("common.dialogs.goal.submitError"))}}})}const Ti={goalId:"",title:"",description:"",status:"active",targetPoints:240,themeColor:"#c0c1ff"};function Xo(t){return{goalId:t.goalId,title:t.title,description:t.description,status:t.status,targetPoints:t.targetPoints,themeColor:t.themeColor}}function ua({open:t,goals:s,editingProject:a,initialGoalId:r,onOpenChange:i,onSubmit:n}){const{t:o}=Te(),[h,l]=y.useState(Ti),[x,g]=y.useState(null),[f,d]=y.useState({}),u=c=>{d(Object.fromEntries(Object.entries(c).map(([j,k])=>[j,k==null?void 0:k[0]])))};y.useEffect(()=>{t&&(g(null),d({}),l(a?Xo(a):{...Ti,goalId:r??""}))},[a,r,t]);const b=[{id:"anchor",eyebrow:"Anchor",title:"Attach the project to the right goal",description:"Projects should serve one clear life-goal arc, so start by picking the direction this initiative belongs to.",render:(c,j)=>e.jsx(q,{label:o("common.dialogs.project.goal"),error:f.goalId??null,children:e.jsx("div",{className:"grid gap-3",children:s.map(k=>{const $=k.id===c.goalId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${$?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>j({goalId:k.id}),children:[e.jsx(ue,{kind:"goal",label:k.title,className:"max-w-full"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:k.description||"No strategic note attached yet."})]},k.id)})})})},{id:"shape",eyebrow:"Shape",title:"Name the initiative and the work it will make possible",description:"Keep the project concrete. The title should sound like something you can actually move forward this season.",render:(c,j)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:o("common.dialogs.project.title"),error:f.title??null,children:e.jsx(ae,{value:c.title,onChange:k=>j({title:k.target.value}),placeholder:"Launch the new creative practice system"})}),e.jsx(q,{label:o("common.dialogs.project.descriptionLabel"),children:e.jsx(le,{value:c.description,onChange:k=>j({description:k.target.value}),placeholder:"Describe the outcome and the kind of work this project will contain."})})]})},{id:"signal",eyebrow:"Signal",title:"Set the project's posture and progress target",description:"This keeps the board, reward system, and detail views aligned without forcing you through a giant settings form.",render:(c,j)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:o("common.dialogs.project.status"),children:e.jsx(Re,{value:c.status,onChange:k=>j({status:k}),options:[{value:"active",label:o("common.enums.projectStatus.active"),description:"Push this initiative now."},{value:"paused",label:o("common.enums.projectStatus.paused"),description:"Keep it available without active pressure."},{value:"completed",label:o("common.enums.projectStatus.completed"),description:"This initiative has landed."}]})}),e.jsx(q,{label:o("common.dialogs.project.targetXp"),error:f.targetPoints??null,children:e.jsx(ae,{type:"number",value:c.targetPoints,onChange:k=>j({targetPoints:Number(k.target.value)||0})})}),e.jsx(q,{label:o("common.dialogs.project.themeColor"),error:f.themeColor??null,children:e.jsxs("div",{className:"flex items-center gap-3 rounded-[22px] border border-white/8 bg-white/6 px-4 py-3",children:[e.jsx("input",{className:"h-10 w-12 rounded-lg border border-white/10 bg-transparent",type:"color",value:c.themeColor,onChange:k=>j({themeColor:k.target.value})}),e.jsx(ae,{className:"border-none bg-transparent px-0 py-0",value:c.themeColor,onChange:k=>j({themeColor:k.target.value})})]})})]})}];return e.jsx(qe,{open:t,onOpenChange:i,eyebrow:o("common.dialogs.project.eyebrow"),title:o(a?"common.dialogs.project.editTitle":"common.dialogs.project.createTitle"),description:o("common.dialogs.project.description"),value:h,onChange:l,steps:b,submitLabel:o(a?"common.dialogs.project.save":"common.dialogs.project.create"),error:x,onSubmit:async()=>{g(null);const c=vn.safeParse(h);if(!c.success){u(c.error.flatten().fieldErrors),g("A couple of answers still need attention before this project can be saved.");return}d({});try{await n(c.data,a==null?void 0:a.id),i(!1)}catch(j){g(j instanceof Error?j.message:o("common.dialogs.project.submitError"))}}})}const Si={title:"",description:"",owner:"Albert",goalId:"",projectId:"",priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,tagIds:[]};function Go(t){return{title:t.title,description:t.description,owner:t.owner,goalId:t.goalId??"",projectId:t.projectId??"",priority:t.priority,status:t.status,effort:t.effort,energy:t.energy,dueDate:t.dueDate??"",points:t.points,tagIds:t.tagIds}}function Ts({open:t,goals:s,projects:a,tags:r,editingTask:i,initialProjectId:n,onOpenChange:o,onSubmit:h}){const{t:l}=Te(),x=s??[],g=a??[],f=r??[],[d,u]=y.useState(Si),[b,c]=y.useState(null),[j,k]=y.useState({}),$=N=>{k(Object.fromEntries(Object.entries(N).map(([m,w])=>[m,w==null?void 0:w[0]])))};y.useEffect(()=>{var N;t&&(c(null),k({}),u(i?Go(i):{...Si,projectId:n??"",goalId:((N=g.find(m=>m.id===n))==null?void 0:N.goalId)??""}))},[i,n,t,g]);const M=y.useMemo(()=>g.find(N=>N.id===d.projectId)??null,[d.projectId,g]);y.useEffect(()=>{M&&d.goalId!==M.goalId&&u(N=>({...N,goalId:M.goalId}))},[d.goalId,M]);const I=[{id:"anchor",eyebrow:"Placement",title:"Choose where this task belongs",description:"Link the task to the right project so the board, life goal, and rewards stay connected.",render:(N,m)=>{var w;return e.jsxs(e.Fragment,{children:[e.jsx(q,{label:l("common.dialogs.task.project"),labelHelp:"Projects are the main home for tasks. Pick the stream of work this task belongs to.",error:j.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:g.map(L=>{const S=L.id===N.projectId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${S?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>m({projectId:L.id,goalId:L.goalId}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(ue,{kind:"project",label:L.title,className:"min-w-0",showIcon:!1}),e.jsx(re,{kind:"goal",label:L.goalTitle,compact:!0,gradient:!1})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:L.description})]},L.id)})})}),e.jsx(q,{label:l("common.dialogs.task.goal"),labelHelp:"The life goal is shown automatically from the project so you can still see the bigger reason this task matters.",children:e.jsx(ae,{readOnly:!0,value:M?((w=x.find(L=>L.id===M.goalId))==null?void 0:w.title)??"":"",placeholder:"The linked life goal will appear here."})})]})}},{id:"shape",eyebrow:"Shape",title:"Define the next concrete move",description:"Keep the task small enough to be actionable and strong enough to clearly move the project forward.",render:(N,m)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:l("common.dialogs.task.title"),error:j.title??null,children:e.jsx(ae,{value:N.title,onChange:w=>m({title:w.target.value}),placeholder:"Draft the first mode atlas sketch"})}),e.jsx(q,{label:l("common.dialogs.task.descriptionLabel"),children:e.jsx(le,{value:N.description,onChange:w=>m({description:w.target.value}),placeholder:"Describe the outcome or boundary conditions for this move."})}),e.jsx(q,{label:l("common.dialogs.task.owner"),labelHelp:"The owner is the person or role expected to carry this task.",error:j.owner??null,children:e.jsx(ae,{value:N.owner,onChange:w=>m({owner:w.target.value}),placeholder:"Albert"})})]})},{id:"execution",eyebrow:"Execution",title:"Set priority, status, effort, and energy",description:"This is the minimum the execution engine needs in order to place the task well and show the right next move.",render:(N,m)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:l("common.dialogs.task.priority"),labelHelp:"Priority controls how strongly Forge should surface this task in the board and daily views.",children:e.jsx(Re,{value:N.priority,onChange:w=>m({priority:w}),options:[{value:"low",label:l("common.enums.priority.low")},{value:"medium",label:l("common.enums.priority.medium")},{value:"high",label:l("common.enums.priority.high")},{value:"critical",label:l("common.enums.priority.critical")}]})}),e.jsx(q,{label:l("common.dialogs.task.status"),labelHelp:"Status tells Forge whether the task is waiting, ready for focus, active, blocked, or done.",children:e.jsx(Re,{value:N.status,onChange:w=>m({status:w}),options:[{value:"backlog",label:l("common.enums.taskStatus.backlog")},{value:"focus",label:l("common.enums.taskStatus.focus")},{value:"in_progress",label:l("common.enums.taskStatus.in_progress")},{value:"blocked",label:l("common.enums.taskStatus.blocked")}]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:l("common.dialogs.task.effort"),labelHelp:"Effort describes how much concentration and time this task usually needs.",children:e.jsx(Re,{value:N.effort,onChange:w=>m({effort:w}),options:[{value:"light",label:l("common.enums.effort.light")},{value:"deep",label:l("common.enums.effort.deep")},{value:"marathon",label:l("common.enums.effort.marathon")}]})}),e.jsx(q,{label:l("common.dialogs.task.energy"),labelHelp:"Energy helps you match this task to a low-energy, steady, or high-energy moment.",children:e.jsx(Re,{value:N.energy,onChange:w=>m({energy:w}),options:[{value:"low",label:l("common.enums.energy.low")},{value:"steady",label:l("common.enums.energy.steady")},{value:"high",label:l("common.enums.energy.high")}]})})]})]})},{id:"signal",eyebrow:"Reward and timing",title:"Set the reward and timing details",description:"This keeps the daily surfaces honest without forcing you through a bloated last-mile form.",render:(N,m)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:l("common.dialogs.task.xp"),labelHelp:"XP is the reward weight for finishing this task. Higher XP should mean more meaningful work.",error:j.points??null,children:e.jsx(ae,{type:"number",value:N.points,onChange:w=>m({points:Number(w.target.value)||0}),placeholder:"60"})}),e.jsx(q,{label:l("common.dialogs.task.dueDate"),labelHelp:"Only add a due date when timing really matters for this task.",children:e.jsx(ae,{type:"date",value:N.dueDate,onChange:w=>m({dueDate:w.target.value})})})]}),e.jsx(q,{label:l("common.dialogs.task.tags"),children:e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(w=>{const L=N.tagIds.includes(w.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${L?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>m({tagIds:L?N.tagIds.filter(S=>S!==w.id):[...N.tagIds,w.id]}),children:w.name},w.id)})})})]})}];return e.jsx(qe,{open:t,onOpenChange:o,eyebrow:l("common.dialogs.task.eyebrow"),title:l(i?"common.dialogs.task.editTitle":"common.dialogs.task.createTitle"),description:l("common.dialogs.task.description"),value:d,onChange:u,steps:I,submitLabel:l(i?"common.dialogs.task.save":"common.dialogs.task.create"),error:b,onSubmit:async()=>{c(null);const N=yn.safeParse(d);if(!N.success){$(N.error.flatten().fieldErrors),c("A few task details still need attention before this move can be saved.");return}k({});try{await h(N.data,i==null?void 0:i.id),o(!1)}catch(m){c(m instanceof Error?m.message:"Unable to save this task right now.")}}})}const Ci="(max-width: 1023px)";function Qo(){const[t,s]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(Ci).matches);return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(Ci),r=i=>{s(i.matches)};return s(a.matches),typeof a.addEventListener=="function"?(a.addEventListener("change",r),()=>a.removeEventListener("change",r)):(a.addListener(r),()=>a.removeListener(r))},[]),t}function Ii({kind:t,title:s,description:a,onClick:r}){return e.jsxs("button",{type:"button",className:"w-full min-w-0 rounded-[22px] border border-white/8 bg-white/[0.04] px-4 py-4 text-left transition hover:bg-white/[0.08]",onClick:r,children:[e.jsx(re,{kind:t,label:s,compact:!0,gradient:!1,className:"max-w-full"}),e.jsx("div",{className:"mt-1 text-sm text-white/55",children:a})]})}function Wo({goals:t,projects:s,tags:a,onCreateGoal:r,onCreateProject:i,onCreateTask:n,className:o}){const{t:h}=Te(),l=Ve(),x=t??[],g=s??[],f=a??[],[d,u]=y.useState(!1),[b,c]=y.useState(!1),[j,k]=y.useState(!1),[$,M]=y.useState(!1),[I,N]=y.useState(null),m=Qo(),w=y.useRef(null),L=y.useRef(null);y.useEffect(()=>{if(!d||m)return;const O=()=>{var R;const C=(R=w.current)==null?void 0:R.getBoundingClientRect();C&&N({top:Math.max(24,C.top-18),right:Math.max(24,window.innerWidth-C.right)})};O();const A=C=>{var R,J;(R=w.current)!=null&&R.contains(C.target)||(J=L.current)!=null&&J.contains(C.target)||u(!1)},v=C=>{C.key==="Escape"&&u(!1)};return document.addEventListener("pointerdown",A),document.addEventListener("keydown",v),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),()=>{document.removeEventListener("pointerdown",A),document.removeEventListener("keydown",v),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0)}},[m,d]);const S=[{id:"goal",kind:"goal",group:"Execution",title:h("common.navigation.newGoal"),description:h("common.navigation.newGoalDescription"),onSelect:()=>{u(!1),c(!0)}},{id:"project",kind:"project",group:"Execution",title:h("common.navigation.newProject"),description:h("common.navigation.newProjectDescription"),onSelect:()=>{u(!1),k(!0)}},{id:"task",kind:"task",group:"Execution",title:h("common.navigation.newTask"),description:h("common.navigation.newTaskDescription"),onSelect:()=>{u(!1),M(!0)}},{id:"value",kind:"value",group:"Psyche",title:"Value",description:"Place one value into the goal, project, and task constellation.",onSelect:()=>{u(!1),l("/psyche/values?create=1")}},{id:"pattern",kind:"pattern",group:"Psyche",title:"Pattern",description:"Map a loop, its payoff, its cost, and the response you want.",onSelect:()=>{u(!1),l("/psyche/patterns?create=1")}},{id:"behavior",kind:"behavior",group:"Psyche",title:"Behavior",description:"Describe the move first, then classify it and link it.",onSelect:()=>{u(!1),l("/psyche/behaviors?create=1")}},{id:"report",kind:"report",group:"Psyche",title:"Report",description:"Start a Spark-to-Pivot reflective chain.",onSelect:()=>{u(!1),l("/psyche/reports?create=1")}}];return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:w,className:o,style:m?{right:"max(1rem, calc(var(--forge-safe-area-right) + 1rem))",bottom:"var(--forge-mobile-create-bottom)"}:void 0,children:e.jsxs(X,{type:"button","data-testid":"create-floating-trigger","aria-expanded":d,"aria-haspopup":"dialog",onClick:()=>u(O=>m?!0:!O),className:`min-w-max max-w-[calc(100vw-2rem)] shrink-0 rounded-full px-3.5 py-2 text-[12px] shadow-[0_20px_60px_rgba(4,8,18,0.34)] ${d?"bg-[linear-gradient(135deg,rgba(192,193,255,0.52),rgba(125,211,252,0.24))] text-white":""}`,children:[e.jsx(dn,{className:`size-4 transition ${d?"text-white":"text-white/72"}`}),h("common.navigation.create")]})}),d&&!m&&typeof document<"u"&&I?kr.createPortal(e.jsxs("div",{ref:L,"data-testid":"create-desktop-menu",className:"fixed z-50 w-[min(26rem,calc(100vw-2rem))] max-h-[min(34rem,calc(100vh-4rem))] overflow-y-auto rounded-[30px] border border-white/8 bg-[linear-gradient(180deg,rgba(18,24,40,0.985),rgba(10,15,27,0.985))] p-4 shadow-[0_28px_90px_rgba(3,8,18,0.46)]",style:{top:`${I.top}px`,right:`${I.right}px`,transform:"translateY(-100%)"},children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Create"}),e.jsx("div",{className:"mt-2 text-lg font-medium text-white",children:"Start the next move"}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/56",children:"Pick one thing to create. The flow keeps the first step light and visible."}),["Execution","Psyche"].map(O=>e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/38",children:O}),e.jsx("div",{className:"mt-2 grid gap-2",children:S.filter(A=>A.group===O).map(A=>e.jsx(Ii,{kind:A.kind,title:A.title,description:A.description,onClick:A.onSelect},A.id))})]},O))]}),document.body):null,e.jsx(Bt,{open:d&&m,onOpenChange:u,children:e.jsxs(zt,{children:[e.jsx(Kt,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.72)] backdrop-blur-xl lg:hidden"}),e.jsxs(Xt,{"data-testid":"create-mobile-sheet",className:"fixed inset-x-4 bottom-28 z-50 flex max-h-[min(30rem,calc(100vh-8rem))] flex-col overflow-hidden rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(24,31,50,0.98),rgba(15,21,36,0.98))] p-0 shadow-[0_30px_90px_rgba(3,8,18,0.45)] lg:hidden",style:{left:"max(1rem, calc(var(--forge-safe-area-left) + 1rem))",right:"max(1rem, calc(var(--forge-safe-area-right) + 1rem))",bottom:"calc(var(--forge-mobile-nav-clearance) - 0.5rem)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-white/8 px-5 py-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:h("common.navigation.create")}),e.jsx(ks,{className:"mt-2 font-display text-2xl text-white",children:h("common.navigation.createTitle")}),e.jsx(Ns,{className:"mt-2 text-sm leading-6 text-white/60",children:h("common.navigation.createDescription")})]}),e.jsx(gs,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":h("common.navigation.closeCreateMenu"),className:"rounded-full bg-white/6 p-2 text-white/65 transition hover:bg-white/10 hover:text-white",children:e.jsx(Pt,{className:"size-4"})})})]}),e.jsx("div",{className:"overflow-y-auto p-4 overscroll-contain",children:["Execution","Psyche"].map(O=>e.jsxs("div",{className:"mt-1 grid gap-2 first:mt-0",children:[e.jsx("div",{className:"px-1 text-[11px] uppercase tracking-[0.18em] text-white/38",children:O}),S.filter(A=>A.group===O).map(A=>e.jsx(Ii,{kind:A.kind,title:A.title,description:A.description,onClick:A.onSelect},A.id))]},O))})]})]})}),e.jsx(ha,{open:b,editingGoal:null,tags:f,onOpenChange:c,onSubmit:async O=>{await r(O)}}),e.jsx(ua,{open:j,goals:x,editingProject:null,onOpenChange:k,onSubmit:async O=>{await i(O)}}),e.jsx(Ts,{open:$,goals:x,projects:g,tags:f,editingTask:null,onOpenChange:M,onSubmit:async O=>{await n(O)}})]})}function Ho(t){return t===null?"20":String(Math.max(1,Math.round(t/60)))}function Uo({tasks:t,projects:s,activeRunCount:a,maxActiveTasks:r,timeAccountingMode:i,pending:n,errorMessage:o,initialTaskId:h,defaultProjectId:l,onCancel:x,onStartExisting:g,onCreateAndStart:f}){const[d,u]=y.useState("existing"),[b,c]=y.useState(""),[j,k]=y.useState(h??null),[$,M]=y.useState(""),[I,N]=y.useState(""),[m,w]=y.useState(l??""),[L,S]=y.useState("planned"),[O,A]=y.useState("20");y.useEffect(()=>{u(h?"existing":"new"),c(""),k(h??null),M(""),N(""),w(l??""),S("planned"),A("20")},[l,h]);const v=y.useMemo(()=>t.filter(K=>K.status!=="done").sort((K,D)=>K.time.hasCurrentRun!==D.time.hasCurrentRun?Number(D.time.hasCurrentRun)-Number(K.time.hasCurrentRun):K.status!==D.status?K.status.localeCompare(D.status):K.title.localeCompare(D.title)),[t]),C=y.useMemo(()=>{const K=b.trim().toLowerCase();return K?v.filter(D=>{const F=s.find(W=>W.id===D.projectId);return[D.title,D.description,(F==null?void 0:F.title)??""].some(W=>W.toLowerCase().includes(K))}):v},[s,v,b]),R=y.useMemo(()=>s.find(K=>K.id===m)??null,[m,s]),J=L==="planned"?Math.max(60,(Number.parseInt(O,10)||20)*60):null,G=d==="existing"?!!j:!!($.trim()&&m),se=i==="split"?"Split time":i==="parallel"?"Parallel time":"Primary only";return e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Start work"}),e.jsx("h3",{className:"mt-2 font-display text-[clamp(1.2rem,1.8vw,1.65rem)] text-white",children:"Pick a task and start the timer"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:"Use an existing task or create a new one quickly. Forge will move the task into in progress as soon as work starts."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[a,"/",r," live"]}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:se})]})]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:[{value:"existing",label:"Existing task",detail:"Search and start something that already exists."},{value:"new",label:"New quick task",detail:"Create a task with a title, short description, and project."}].map(K=>{const D=d===K.value;return e.jsxs("button",{type:"button",className:Q("rounded-[18px] border px-4 py-4 text-left transition",D?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/65 hover:bg-white/[0.07]"),onClick:()=>u(K.value),children:[e.jsx("div",{className:"font-medium",children:K.label}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-inherit/80",children:K.detail})]},K.value)})}),d==="existing"?e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Search tasks"}),e.jsxs("div",{className:"relative",children:[e.jsx(ft,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-white/32"}),e.jsx(ae,{value:b,onChange:K=>c(K.target.value),placeholder:"Search task title or project",className:"pl-10"})]})]}),e.jsx("div",{className:"grid max-h-[19rem] gap-2 overflow-y-auto rounded-[20px] bg-white/[0.03] p-2",children:C.length===0?e.jsx("div",{className:"rounded-[16px] border border-dashed border-white/8 px-4 py-8 text-center text-sm text-white/42",children:"No tasks match. Switch to New quick task to create one now."}):C.slice(0,16).map(K=>{const D=j===K.id,F=s.find(W=>W.id===K.projectId);return e.jsx("button",{type:"button",className:Q("rounded-[16px] border px-4 py-3 text-left transition",D?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"),onClick:()=>k(K.id),children:e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(ue,{kind:"task",label:K.title,className:"max-w-full"}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[F?e.jsx(re,{kind:"project",label:F.title,compact:!0,gradient:!1}):null,e.jsx(B,{className:"bg-white/[0.08] text-white/70",children:K.status.replaceAll("_"," ")}),K.time.activeRunCount>0?e.jsxs(B,{className:"bg-emerald-500/12 text-emerald-200",children:[K.time.activeRunCount," live"]}):null]})]}),e.jsxs("span",{className:"text-[12px] text-white/45",children:[K.points," xp"]})]})},K.id)})})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Task title"}),e.jsx(ae,{value:$,onChange:K=>M(K.target.value),placeholder:"Write the next concrete task"})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Short description"}),e.jsx(le,{value:I,onChange:K=>N(K.target.value),placeholder:"Keep it short and concrete."})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Project"}),e.jsxs("select",{value:m,onChange:K=>w(K.target.value),className:"min-h-10 rounded-[var(--radius-control)] border border-white/10 bg-white/[0.04] px-3 py-2 text-sm text-white outline-none transition focus:border-[rgba(192,193,255,0.3)]",children:[e.jsx("option",{value:"",children:"Select project"}),s.map(K=>e.jsx("option",{value:K.id,children:K.title},K.id))]})]}),R?e.jsxs("div",{className:"rounded-[16px] bg-white/[0.04] px-4 py-3 text-sm text-white/62",children:["This task will be created inside ",e.jsx("span",{className:"font-medium text-white",children:R.title})," and started immediately."]}):null]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("span",{className:"type-label text-white/45",children:"Timer"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_8rem]",children:[[{value:"planned",label:"20 min planned",detail:"Pomodoro-style by default."},{value:"unlimited",label:"Unlimited",detail:"Keep tracking until you stop."}].map(K=>{const D=L===K.value;return e.jsxs("button",{type:"button",className:Q("rounded-[18px] border px-4 py-3 text-left transition",D?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/65 hover:bg-white/[0.07]"),onClick:()=>S(K.value),children:[e.jsx("div",{className:"font-medium",children:K.label}),e.jsx("div",{className:"mt-1.5 text-sm leading-6 text-inherit/80",children:K.detail})]},K.value)}),e.jsxs("label",{className:Q("grid gap-2",L!=="planned"&&"opacity-50"),children:[e.jsx("span",{className:"type-label text-white/45",children:"Minutes"}),e.jsx(ae,{type:"number",min:1,max:240,disabled:L!=="planned",value:O,onChange:K=>A(K.target.value)})]})]})]}),o?e.jsx("div",{className:"rounded-[18px] bg-rose-500/10 px-4 py-3 text-sm leading-6 text-rose-200",children:o}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-white/6 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 text-[12px] text-white/45",children:[e.jsx("div",{className:"rounded-full bg-white/[0.05] px-3 py-2",children:"Starts in progress"}),e.jsx("div",{className:"rounded-full bg-white/[0.05] px-3 py-2",children:L==="planned"?`${Ho(J)} min target`:"Unlimited timer"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{variant:"secondary",size:"lg",onClick:x,children:"Cancel"}),e.jsxs(X,{size:"lg",pending:n,pendingLabel:"Starting",disabled:!G,onClick:async()=>{if(G){if(d==="existing"&&j){await g(j,{timerMode:L,plannedDurationSeconds:J});return}await f({title:$.trim(),description:I.trim(),projectId:m,timerMode:L,plannedDurationSeconds:J})}},children:[d==="existing"?e.jsx(hs,{className:"size-4"}):e.jsx(Nr,{className:"size-4"}),"Start work",e.jsx(nt,{className:"size-4"})]})]})]})]})}function Pi({open:t,onOpenChange:s,presentation:a="responsive",...r}){const i=e.jsx(Uo,{...r,onCancel:()=>s(!1)});return e.jsxs(e.Fragment,{children:[t&&a!=="mobile_sheet"?e.jsx("div",{className:"hidden lg:block",children:e.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-[linear-gradient(180deg,rgba(17,24,39,0.98),rgba(11,16,28,0.97))] p-4 shadow-[0_24px_60px_rgba(3,8,18,0.28)]",children:[e.jsx("div",{className:"mb-3 flex justify-end",children:e.jsxs(X,{variant:"ghost",size:"sm",className:"px-3",onClick:()=>s(!1),children:[e.jsx(Pt,{className:"size-4"}),"Close"]})}),i]})}):null,a!=="desktop_inline"?e.jsx("div",{className:a==="responsive"?"lg:hidden":"",children:e.jsx(ma,{open:t,onOpenChange:s,eyebrow:"Start work",title:"Start work",description:"Pick an existing task or create a new one quickly, then start the timer immediately.",children:i})}):null]})}const pa=y.createContext({expanded:!1,setExpanded:()=>{}});function Li({children:t}){const[s,a]=y.useState(!1),r=y.useRef(0);return y.useEffect(()=>{if(!s)return;r.current=performance.now();let i=window.scrollY;const n=()=>{if(performance.now()-r.current<280){i=window.scrollY;return}window.scrollY-i>16&&a(!1),i=window.scrollY};return window.addEventListener("scroll",n,{passive:!0}),()=>window.removeEventListener("scroll",n)},[s]),e.jsx(pa.Provider,{value:{expanded:s,setExpanded:a},children:t})}function Nt(t){const s=Math.max(0,Math.floor(t)),a=Math.floor(s/3600),r=Math.floor(s%3600/60),i=s%60;return a>0?`${a}:${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function Yo(t,s,a,r,i){const n=Math.max(1,t.length),o=Date.parse(a),h=Number.isFinite(o)?Math.max(0,Math.floor((i-o)/1e3)):0;return t.map(l=>{const x=s.find(c=>c.id===l.taskId),g=l.status==="active"?l.elapsedWallSeconds+h:l.elapsedWallSeconds,f=l.status!=="active"?0:r==="parallel"?h:r==="split"?h/n:l.isCurrent?h:0,d=l.creditedSeconds+f,u=l.timerMode==="planned"&&l.plannedDurationSeconds!==null?Math.max(0,l.plannedDurationSeconds-g):null,b=l.timerMode==="planned"&&l.plannedDurationSeconds!==null?Math.max(0,g-l.plannedDurationSeconds):0;return{run:l,title:(x==null?void 0:x.title)??l.taskTitle,wallSeconds:g,creditedSeconds:d,remainingSeconds:u,overtimeSeconds:b}}).sort((l,x)=>Number(x.run.isCurrent)-Number(l.run.isCurrent))}function wn(t,s,a,r){const[i,n]=y.useState(()=>Date.now());return y.useEffect(()=>{if(t.length===0)return;const o=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(o)},[t.length]),y.useMemo(()=>Yo(t,s,a,r,i),[a,i,t,s,r])}function Mi({runs:t,tasks:s,generatedAt:a,timeAccountingMode:r,pending:i,onOpenStartWork:n,onPause:o,onFocus:h}){const{expanded:l,setExpanded:x}=y.useContext(pa),g=wn(t,s,a,r),f=g.find(u=>u.run.isCurrent)??g[0]??null,d=f?g.filter(u=>u.run.id!==f.run.id):[];return f?e.jsxs("div",{className:Q("flex min-h-[2.125rem] min-w-0 items-center rounded-full border border-white/8 bg-white/[0.04] transition-colors",l&&"border-[var(--primary)]/25 bg-[var(--primary)]/[0.06]"),children:[e.jsxs("button",{type:"button","aria-expanded":l,"aria-label":l?"Collapse work details":"Expand work details",className:"flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded-l-full py-1 pl-2.5 pr-2 transition-colors hover:bg-white/[0.04]",onClick:()=>x(u=>!u),children:[e.jsx(hs,{className:"size-3.5 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-[12px] font-medium text-white",children:f.title}),e.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-white/44",children:Nt(f.creditedSeconds)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:[d.length>0?e.jsx("button",{type:"button",title:"Switch to next task",disabled:i,className:"inline-flex size-6 items-center justify-center rounded-full bg-[var(--primary)]/15 text-[10px] font-bold tabular-nums text-[var(--primary)] transition hover:bg-[var(--primary)]/25 disabled:pointer-events-none disabled:opacity-70",onClick:()=>void h(d[0].run.id),children:g.length}):null,e.jsx("button",{type:"button",title:"Stop",disabled:i,className:"inline-flex size-6 items-center justify-center rounded-full text-white/50 transition hover:bg-white/[0.1] hover:text-white disabled:pointer-events-none disabled:opacity-70",onClick:()=>void o(f.run.id),children:e.jsx(Tr,{className:"size-2.5 fill-current"})}),e.jsx("button",{type:"button",title:"Start new work",disabled:i,className:"inline-flex size-6 items-center justify-center rounded-full text-white/50 transition hover:bg-white/[0.1] hover:text-white disabled:pointer-events-none disabled:opacity-70",onClick:()=>n(),children:e.jsx(nt,{className:"size-2.5 fill-current"})})]})]}):e.jsxs("div",{className:"flex min-h-[2.125rem] min-w-0 items-center gap-1.5 rounded-full border border-white/8 bg-white/[0.04] py-1 pl-2.5 pr-1",children:[e.jsx(hs,{className:"size-3.5 shrink-0 text-white/48"}),e.jsx("span",{className:"truncate text-[12px] text-white/48",children:"No active work"}),e.jsx("button",{type:"button",className:"ml-auto inline-flex h-[1.5rem] shrink-0 items-center rounded-full bg-white/10 px-2 text-[11px] font-medium text-white transition hover:bg-white/15",onClick:n,children:"Start work"})]})}function Ei({runs:t,tasks:s,generatedAt:a,timeAccountingMode:r,pending:i,onOpenStartWork:n,onFocus:o,onPause:h,onComplete:l}){const{expanded:x}=y.useContext(pa),g=wn(t,s,a,r),f=g.find(b=>b.run.isCurrent)??g[0]??null,d=f?g.filter(b=>b.run.id!==f.run.id):[],u=r==="split"&&g.length>1?`Split across ${g.length} active tasks`:r==="parallel"&&g.length>1?`Parallel time across ${g.length} active tasks`:r==="primary_only"&&g.length>1?"Only the current task is earning credited time":null;return f?e.jsx(bt,{initial:!1,children:x?e.jsx(De.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.25,ease:"easeOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"mt-2 rounded-2xl border border-white/8 bg-[linear-gradient(180deg,rgba(192,193,255,0.10),rgba(192,193,255,0.03))] p-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(B,{tone:"signal",className:"text-white/82",children:"Current task"}),e.jsx(B,{tone:"meta",children:f.run.timerMode==="planned"?"Planned timer":"Unlimited timer"}),u?e.jsx(B,{tone:"meta",children:u}):null]}),e.jsx("div",{className:"mt-3 text-xl font-medium text-white md:text-2xl",children:f.title}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-4 text-sm text-white/62",children:[e.jsxs("span",{children:[Nt(f.creditedSeconds)," credited"]}),e.jsxs("span",{children:[Nt(f.wallSeconds)," wall time"]}),f.run.timerMode==="planned"?f.overtimeSeconds>0?e.jsxs("span",{className:"text-amber-200",children:["+",Nt(f.overtimeSeconds)," overtime"]}):e.jsxs("span",{children:[Nt(f.remainingSeconds??0)," remaining"]}):e.jsx("span",{children:"Unlimited session"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(X,{variant:"secondary",pending:i,pendingLabel:"Opening",onClick:n,children:[e.jsx(hs,{className:"size-4"}),"Start work"]}),e.jsxs(X,{variant:"secondary",pending:i,pendingLabel:"Pausing",onClick:()=>void h(f.run.id),children:[e.jsx(Sr,{className:"size-4"}),"Pause"]}),e.jsxs(X,{pending:i,pendingLabel:"Completing",onClick:()=>void l(f.run.id),children:[e.jsx(ra,{className:"size-4"}),"Complete"]})]})]}),d.length>0?e.jsx("div",{className:"mt-4 grid gap-2 lg:grid-cols-2",children:d.map(b=>e.jsxs("button",{type:"button",className:Q("flex items-center justify-between gap-3 rounded-2xl bg-white/[0.04] px-4 py-3 text-left transition hover:bg-white/[0.08]",i&&"pointer-events-none opacity-70"),onClick:()=>void o(b.run.id),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium text-white/88",children:b.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-3 text-[12px] text-white/48",children:[e.jsxs("span",{children:[Nt(b.creditedSeconds)," credited"]}),e.jsx("span",{children:b.run.timerMode==="planned"?"planned":"unlimited"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-white/42",children:[e.jsx(ws,{className:"size-3.5"}),"Switch"]})]},b.run.id))}):null]})},"timer-rail-detail"):null}):null}function Y({className:t,...s}){return e.jsx("div",{className:Q("w-full max-w-full min-w-0 rounded-[var(--radius-card)] bg-[var(--card-gradient)] p-5 shadow-[var(--card-shadow)] backdrop-blur-sm",t),...s})}class jn extends Error{constructor(a){super(a.message);Et(this,"status");Et(this,"code");Et(this,"details");Et(this,"requestPath");this.name="ForgeApiError",this.status=a.status,this.code=a.code,this.details=a.details??[],this.requestPath=a.requestPath}}function Jo(t){return t instanceof jn?{title:`Request failed (${t.status})`,description:t.details.length>0?`${t.message} ${t.details.map(s=>`${s.path}: ${s.message}`).join(" · ")}`:t.message,code:t.code}:t instanceof Error?{title:"Something went wrong",description:t.message,code:"unknown_error"}:{title:"Something went wrong",description:"Unexpected API failure.",code:"unknown_error"}}function Qe({eyebrow:t,title:s,description:a}){const{t:r}=Te();return e.jsxs(Y,{className:"surface-pulse ambient-glow mx-auto grid max-w-2xl gap-4 text-center",children:[e.jsx("div",{className:"type-label text-white/40",children:t??r("common.labels.loading")}),e.jsx("div",{className:"type-display-section text-white",children:s??r("common.pageState.loadingTitle")}),e.jsx("p",{className:"type-body mx-auto max-w-xl text-white/60",children:a??r("common.pageState.loadingDescription")}),e.jsxs("div",{className:"mx-auto flex min-h-11 items-center gap-3 rounded-full bg-white/[0.05] px-4 py-3 text-white/60",children:[e.jsx(ca,{tone:"subtle",className:"size-3.5"}),e.jsx("span",{className:"type-meta",children:r("common.labels.syncInProgress")})]})]})}function je({error:t,onRetry:s,eyebrow:a}){const{t:r}=Te(),{title:i,description:n,code:o}=Jo(t);return e.jsxs(Y,{className:"mx-auto grid max-w-2xl gap-4",children:[e.jsx("div",{className:"type-label text-rose-200/72",children:a??r("common.labels.connectionState")}),e.jsx("div",{className:"type-display-section text-white",children:i}),e.jsx("p",{className:"type-body text-white/62",children:n}),e.jsx("div",{className:"type-meta text-white/40",children:r("common.labels.errorCode",{code:o})}),s?e.jsx("div",{className:"flex flex-wrap gap-3",children:e.jsxs(X,{type:"button",variant:"secondary",onClick:s,children:[e.jsx(cn,{className:"mr-2 size-4"}),r("common.actions.retry")]})}):null]})}function Xe({eyebrow:t,title:s,description:a,action:r}){const{t:i}=Te();return e.jsxs(Y,{className:"mx-auto grid max-w-2xl gap-4 text-center",children:[e.jsx("div",{className:"type-label text-white/38",children:t??i("common.labels.loading")}),e.jsx("div",{className:"type-display-section text-white",children:s}),e.jsx("p",{className:"type-body mx-auto max-w-xl text-white/60",children:a}),r?e.jsx("div",{className:"flex justify-center",children:r}):null]})}function kn(t){const s=t.startsWith("/")?t:`/${t}`;return s.endsWith("/")?s:`${s}/`}function Vo(t){const s=kn(t);return s==="/"?"/":s.endsWith("/")?s.slice(0,-1):s}function Zo(){return new URL(kn("/forge/"),window.location.origin)}function Nn(t){if(t.startsWith("/api/"))return t;const s=t.startsWith("/")?t.slice(1):t;return new URL(s,Zo()).pathname}function el(){const t=Pe();y.useEffect(()=>{const s=new EventSource(Nn("/api/v1/events/stream")),a=()=>{Promise.all([t.invalidateQueries({queryKey:["forge-snapshot"]}),t.invalidateQueries({queryKey:["task-context"]})])};return s.addEventListener("snapshot",a),s.addEventListener("activity",a),s.onerror=()=>{s.close()},()=>{s.removeEventListener("snapshot",a),s.removeEventListener("activity",a),s.close()}},[t])}function st(t){return{id:(t==null?void 0:t.id)??"",title:(t==null?void 0:t.title)??"",description:(t==null?void 0:t.description)??"",status:(t==null?void 0:t.status)??"backlog",priority:(t==null?void 0:t.priority)??"medium",owner:(t==null?void 0:t.owner)??"Albert",goalId:(t==null?void 0:t.goalId)??null,projectId:(t==null?void 0:t.projectId)??null,dueDate:(t==null?void 0:t.dueDate)??null,effort:(t==null?void 0:t.effort)??"deep",energy:(t==null?void 0:t.energy)??"steady",points:(t==null?void 0:t.points)??0,sortOrder:(t==null?void 0:t.sortOrder)??0,completedAt:(t==null?void 0:t.completedAt)??null,createdAt:(t==null?void 0:t.createdAt)??new Date(0).toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date(0).toISOString(),tagIds:(t==null?void 0:t.tagIds)??[],time:(t==null?void 0:t.time)??{totalTrackedSeconds:0,totalCreditedSeconds:0,activeRunCount:0,hasCurrentRun:!1,currentRunId:null}}}function Fs(t){return{id:(t==null?void 0:t.id)??"",goalId:(t==null?void 0:t.goalId)??"",title:(t==null?void 0:t.title)??"",description:(t==null?void 0:t.description)??(t==null?void 0:t.summary)??"",status:(t==null?void 0:t.status)==="paused"||(t==null?void 0:t.status)==="completed"?t.status:"active",targetPoints:(t==null?void 0:t.targetPoints)??(t==null?void 0:t.totalPoints)??0,themeColor:(t==null?void 0:t.themeColor)??"#c0c1ff",createdAt:(t==null?void 0:t.createdAt)??new Date(0).toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date(0).toISOString(),goalTitle:(t==null?void 0:t.goalTitle)??"",activeTaskCount:(t==null?void 0:t.activeTaskCount)??0,completedTaskCount:(t==null?void 0:t.completedTaskCount)??0,totalTasks:(t==null?void 0:t.totalTasks)??0,earnedPoints:(t==null?void 0:t.earnedPoints)??(t==null?void 0:t.totalPoints)??0,progress:(t==null?void 0:t.progress)??0,nextTaskId:(t==null?void 0:t.nextTaskId)??null,nextTaskTitle:(t==null?void 0:t.nextTaskTitle)??null,momentumLabel:(t==null?void 0:t.momentumLabel)??"No momentum yet",time:(t==null?void 0:t.time)??{totalTrackedSeconds:0,totalCreditedSeconds:0,activeRunCount:0,hasCurrentRun:!1,currentRunId:null}}}function tl(t){var n,o,h,l,x,g,f,d,u,b,c,j,k,$,M,I,N,m,w,L,S,O,A,v,C,R,J,G,se,K,D,F,W,T,H,U,Z,ie,ge,z,E,p,P,_,ve,oe,Me,Oe,ze,mt,tt,ht,Ie,ne,we,fe,be,Ge,he,We,pe,Sa,Ca,Ia,Pa,La,Ma,Ea,Aa,Da,Ra,_a,Oa,$a,Fa,qa,Ba,za,Ka,Xa,Ga,Qa,Wa,Ha,Ua,Ya,Ja,Va,Za,ei,ti,si,ai,ii,ni,ri,oi,li,di,ci,mi,hi,ui,pi;const s=t,a=(s.projects??s.campaigns??[]).map(Fs),r=(((n=s.dashboard)==null?void 0:n.projects)??((o=s.dashboard)==null?void 0:o.campaigns)??a).map(Fs),i=(((h=s.overview)==null?void 0:h.projects)??((l=s.overview)==null?void 0:l.campaigns)??r).map(Fs);return{...t,meta:{apiVersion:"v1",transport:"rest+sse",generatedAt:((x=t.meta)==null?void 0:x.generatedAt)??new Date().toISOString(),backend:((g=t.meta)==null?void 0:g.backend)??"forge-node-runtime",mode:((f=t.meta)==null?void 0:f.mode)??"transitional-node"},metrics:{totalXp:((d=t.metrics)==null?void 0:d.totalXp)??0,level:((u=t.metrics)==null?void 0:u.level)??1,currentLevelXp:((b=t.metrics)==null?void 0:b.currentLevelXp)??0,nextLevelXp:((c=t.metrics)==null?void 0:c.nextLevelXp)??120,weeklyXp:((j=t.metrics)==null?void 0:j.weeklyXp)??0,streakDays:((k=t.metrics)==null?void 0:k.streakDays)??0,comboMultiplier:(($=t.metrics)==null?void 0:$.comboMultiplier)??1,momentumScore:((M=t.metrics)==null?void 0:M.momentumScore)??0,topGoalId:((I=t.metrics)==null?void 0:I.topGoalId)??null,topGoalTitle:((N=t.metrics)==null?void 0:N.topGoalTitle)??null},dashboard:{stats:{totalPoints:((w=(m=t.dashboard)==null?void 0:m.stats)==null?void 0:w.totalPoints)??0,completedThisWeek:((S=(L=t.dashboard)==null?void 0:L.stats)==null?void 0:S.completedThisWeek)??0,activeGoals:((A=(O=t.dashboard)==null?void 0:O.stats)==null?void 0:A.activeGoals)??0,alignmentScore:((C=(v=t.dashboard)==null?void 0:v.stats)==null?void 0:C.alignmentScore)??0,focusTasks:((J=(R=t.dashboard)==null?void 0:R.stats)==null?void 0:J.focusTasks)??0,overdueTasks:((se=(G=t.dashboard)==null?void 0:G.stats)==null?void 0:se.overdueTasks)??0,dueThisWeek:((D=(K=t.dashboard)==null?void 0:K.stats)==null?void 0:D.dueThisWeek)??0},goals:((F=t.dashboard)==null?void 0:F.goals)??[],projects:r,tasks:(((W=t.dashboard)==null?void 0:W.tasks)??[]).map(st),tags:((T=t.dashboard)==null?void 0:T.tags)??[],suggestedTags:((H=t.dashboard)==null?void 0:H.suggestedTags)??[],owners:((U=t.dashboard)==null?void 0:U.owners)??[],executionBuckets:(((Z=t.dashboard)==null?void 0:Z.executionBuckets)??[]).map(Mt=>({...Mt,tasks:(Mt.tasks??[]).map(st)})),gamification:((ie=t.dashboard)==null?void 0:ie.gamification)??{totalXp:((ge=t.metrics)==null?void 0:ge.totalXp)??0,level:((z=t.metrics)==null?void 0:z.level)??1,currentLevelXp:((E=t.metrics)==null?void 0:E.currentLevelXp)??0,nextLevelXp:((p=t.metrics)==null?void 0:p.nextLevelXp)??120,weeklyXp:((P=t.metrics)==null?void 0:P.weeklyXp)??0,streakDays:((_=t.metrics)==null?void 0:_.streakDays)??0,comboMultiplier:((ve=t.metrics)==null?void 0:ve.comboMultiplier)??1,momentumScore:((oe=t.metrics)==null?void 0:oe.momentumScore)??0,topGoalId:((Me=t.metrics)==null?void 0:Me.topGoalId)??null,topGoalTitle:((Oe=t.metrics)==null?void 0:Oe.topGoalTitle)??null},achievements:((ze=t.dashboard)==null?void 0:ze.achievements)??[],milestoneRewards:((mt=t.dashboard)==null?void 0:mt.milestoneRewards)??[],recentActivity:((tt=t.dashboard)==null?void 0:tt.recentActivity)??[],notesSummaryByEntity:((ht=t.dashboard)==null?void 0:ht.notesSummaryByEntity)??{}},overview:{generatedAt:((Ie=t.overview)==null?void 0:Ie.generatedAt)??new Date().toISOString(),strategicHeader:{streakDays:((we=(ne=t.overview)==null?void 0:ne.strategicHeader)==null?void 0:we.streakDays)??((fe=t.metrics)==null?void 0:fe.streakDays)??0,level:((Ge=(be=t.overview)==null?void 0:be.strategicHeader)==null?void 0:Ge.level)??((he=t.metrics)==null?void 0:he.level)??1,totalXp:((pe=(We=t.overview)==null?void 0:We.strategicHeader)==null?void 0:pe.totalXp)??((Sa=t.metrics)==null?void 0:Sa.totalXp)??0,currentLevelXp:((Ia=(Ca=t.overview)==null?void 0:Ca.strategicHeader)==null?void 0:Ia.currentLevelXp)??((Pa=t.metrics)==null?void 0:Pa.currentLevelXp)??0,nextLevelXp:((Ma=(La=t.overview)==null?void 0:La.strategicHeader)==null?void 0:Ma.nextLevelXp)??((Ea=t.metrics)==null?void 0:Ea.nextLevelXp)??120,momentumScore:((Da=(Aa=t.overview)==null?void 0:Aa.strategicHeader)==null?void 0:Da.momentumScore)??((Ra=t.metrics)==null?void 0:Ra.momentumScore)??0,focusTasks:((Oa=(_a=t.overview)==null?void 0:_a.strategicHeader)==null?void 0:Oa.focusTasks)??0,overdueTasks:((Fa=($a=t.overview)==null?void 0:$a.strategicHeader)==null?void 0:Fa.overdueTasks)??0},projects:i,activeGoals:((qa=t.overview)==null?void 0:qa.activeGoals)??[],topTasks:(((Ba=t.overview)==null?void 0:Ba.topTasks)??[]).map(st),recentEvidence:((za=t.overview)==null?void 0:za.recentEvidence)??[],achievements:((Ka=t.overview)==null?void 0:Ka.achievements)??[],domainBalance:((Xa=t.overview)==null?void 0:Xa.domainBalance)??[],neglectedGoals:((Ga=t.overview)==null?void 0:Ga.neglectedGoals)??[]},today:{generatedAt:((Qa=t.today)==null?void 0:Qa.generatedAt)??new Date().toISOString(),directive:{task:(Ha=(Wa=t.today)==null?void 0:Wa.directive)!=null&&Ha.task?st(t.today.directive.task):null,goalTitle:((Ya=(Ua=t.today)==null?void 0:Ua.directive)==null?void 0:Ya.goalTitle)??null,rewardXp:((Va=(Ja=t.today)==null?void 0:Ja.directive)==null?void 0:Va.rewardXp)??0,sessionLabel:((ei=(Za=t.today)==null?void 0:Za.directive)==null?void 0:ei.sessionLabel)??"No active session"},timeline:(((ti=t.today)==null?void 0:ti.timeline)??[]).map(Mt=>({...Mt,tasks:(Mt.tasks??[]).map(st)})),dailyQuests:((si=t.today)==null?void 0:si.dailyQuests)??[],milestoneRewards:((ai=t.today)==null?void 0:ai.milestoneRewards)??[],momentum:{streakDays:((ni=(ii=t.today)==null?void 0:ii.momentum)==null?void 0:ni.streakDays)??0,momentumScore:((oi=(ri=t.today)==null?void 0:ri.momentum)==null?void 0:oi.momentumScore)??0,recoveryHint:((di=(li=t.today)==null?void 0:li.momentum)==null?void 0:di.recoveryHint)??""}},risk:{generatedAt:((ci=t.risk)==null?void 0:ci.generatedAt)??new Date().toISOString(),overdueTasks:(((mi=t.risk)==null?void 0:mi.overdueTasks)??[]).map(st),blockedTasks:(((hi=t.risk)==null?void 0:hi.blockedTasks)??[]).map(st),neglectedGoals:((ui=t.risk)==null?void 0:ui.neglectedGoals)??[],summary:((pi=t.risk)==null?void 0:pi.summary)??""},goals:t.goals??[],projects:a,tags:t.tags??[],tasks:(t.tasks??[]).map(st),activity:t.activity??[],activeTaskRuns:t.activeTaskRuns??[]}}async function sl(t){const s=await t.text();if(!s)return null;try{return JSON.parse(s)}catch{return s}}async function V(t,s){const a=new Headers(s==null?void 0:s.headers);a.set("x-forge-source","ui"),(s==null?void 0:s.body)!==void 0&&!a.has("content-type")&&a.set("content-type","application/json");const r=await fetch(Nn(t),{credentials:"same-origin",headers:a,...s}),i=await sl(r);if(!r.ok){const n=typeof i=="object"&&i!==null?i:null,o=Array.isArray(n==null?void 0:n.details)?n.details:[];throw new jn({status:r.status,code:typeof(n==null?void 0:n.code)=="string"?n.code:typeof(n==null?void 0:n.error)=="string"?n.error:"request_failed",message:typeof(n==null?void 0:n.error)=="string"?n.error:typeof(n==null?void 0:n.message)=="string"?n.message:typeof i=="string"?i:`Request failed: ${r.status}`,requestPath:t,details:o})}return i}function Gt(){return V("/api/v1/auth/operator-session")}function al(){return V("/api/v1/auth/operator-session",{method:"DELETE"})}function il(){return V("/api/v1/context").then(tl)}function nl(){return V("/api/v1/insights")}function Tn(){return V("/api/v1/psyche/overview")}function yt(){return V("/api/v1/psyche/values")}function Lt(t){return V("/api/v1/psyche/values",{method:"POST",body:JSON.stringify(t)})}function rl(t,s){return V(`/api/v1/psyche/values/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Ss(){return V("/api/v1/psyche/patterns")}function xa(t){return V("/api/v1/psyche/patterns",{method:"POST",body:JSON.stringify(t)})}function ol(t,s){return V(`/api/v1/psyche/patterns/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function wt(){return V("/api/v1/psyche/behaviors")}function Cs(t){return V("/api/v1/psyche/behaviors",{method:"POST",body:JSON.stringify(t)})}function ll(t,s){return V(`/api/v1/psyche/behaviors/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Qt(){return V("/api/v1/psyche/schema-catalog")}function Wt(){return V("/api/v1/psyche/beliefs")}function ga(t){return V("/api/v1/psyche/beliefs",{method:"POST",body:JSON.stringify(t)})}function dl(t,s){return V(`/api/v1/psyche/beliefs/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function jt(){return V("/api/v1/psyche/modes")}function Ht(t){return V("/api/v1/psyche/modes",{method:"POST",body:JSON.stringify(t)})}function cl(t,s){return V(`/api/v1/psyche/modes/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function ml(){return V("/api/v1/psyche/mode-guides")}function hl(t){return V("/api/v1/psyche/mode-guides",{method:"POST",body:JSON.stringify(t)})}function Sn(){return V("/api/v1/psyche/event-types")}function Cn(){return V("/api/v1/psyche/emotions")}function ba(){return V("/api/v1/psyche/reports")}function In(t){return V("/api/v1/psyche/reports",{method:"POST",body:JSON.stringify(t)})}function ul(t){return V(`/api/v1/psyche/reports/${t}`)}function pl(t,s){return V(`/api/v1/psyche/reports/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Pn(t={}){const s=new URLSearchParams;t.linkedEntityType&&s.set("linkedEntityType",t.linkedEntityType),t.linkedEntityId&&s.set("linkedEntityId",t.linkedEntityId),t.anchorKey!==void 0&&t.anchorKey!==null&&s.set("anchorKey",t.anchorKey),t.author&&s.set("author",t.author),t.query&&s.set("query",t.query),t.limit&&s.set("limit",String(t.limit));const a=s.size>0?`?${s.toString()}`:"";return V(`/api/v1/notes${a}`)}function Ln(t){return V("/api/v1/notes",{method:"POST",body:JSON.stringify(t)})}function xl(t,s){return V(`/api/v1/notes/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function gl(t,s="soft"){const a=s==="soft"?"":`?mode=${s}`;return V(`/api/v1/notes/${t}${a}`,{method:"DELETE"})}function Mn(t){return V("/api/v1/insights",{method:"POST",body:JSON.stringify({...t,originAgentId:t.originAgentId||null,originLabel:t.originLabel||null,entityType:t.entityType||null,entityId:t.entityId||null,timeframeLabel:t.timeframeLabel||null,visibility:"visible",status:"open",evidence:[]})})}function bl(t){return V(`/api/v1/insights/${t}`,{method:"DELETE"})}function Ai(t,s,a=""){return V(`/api/v1/insights/${t}/feedback`,{method:"POST",body:JSON.stringify({feedbackType:s,note:a})})}function fl(){return V("/api/v1/reviews/weekly")}function vl(t){return V(`/api/v1/projects/${t}/board`)}function yl(){return V("/api/v1/operator/context")}function fa(){return V("/api/v1/settings")}function wl(){return V("/api/v1/settings/bin")}function jl(){return V("/api/v1/agents/onboarding")}function kl(){return V("/api/v1/approval-requests")}function Nl(t,s=""){return V(`/api/v1/approval-requests/${t}/approve`,{method:"POST",body:JSON.stringify({note:s})})}function Tl(t,s=""){return V(`/api/v1/approval-requests/${t}/reject`,{method:"POST",body:JSON.stringify({note:s})})}function Sl(){return V("/api/v1/rewards/rules")}function Cl(t,s){return V(`/api/v1/rewards/rules/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Il(t){return V("/api/v1/rewards/bonus",{method:"POST",body:JSON.stringify(t)})}function Pl(t=50){return V(`/api/v1/rewards/ledger?limit=${t}`)}function Ll(){return V("/api/v1/metrics/xp")}function Ml(t){return V("/api/v1/settings",{method:"PATCH",body:JSON.stringify(t)})}function Di(t){return V("/api/v1/entities/delete",{method:"POST",body:JSON.stringify(t)})}function Ri(t){return V("/api/v1/entities/restore",{method:"POST",body:JSON.stringify(t)})}function El(t){return V("/api/v1/settings/tokens",{method:"POST",body:JSON.stringify(t)})}function Al(t){return V(`/api/v1/settings/tokens/${t}/rotate`,{method:"POST"})}function Dl(t){return V(`/api/v1/settings/tokens/${t}/revoke`,{method:"POST"})}function Rl(t={}){const s=new URLSearchParams;return s.set("limit",String(t.limit??100)),t.entityType&&s.set("entityType",t.entityType),t.entityId&&s.set("entityId",t.entityId),t.includeCorrected&&s.set("includeCorrected","true"),V(`/api/v1/activity?${s.toString()}`)}function En(t){return V("/api/v1/goals",{method:"POST",body:JSON.stringify(t)})}function An(t){return V("/api/v1/projects",{method:"POST",body:JSON.stringify(t)})}function _l(t,s){return V(`/api/v1/projects/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Ol(t,s){return V(`/api/v1/goals/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function ea(t){const s={...t,goalId:t.goalId||null,projectId:t.projectId||null,dueDate:t.dueDate||null};return V("/api/v1/tasks",{method:"POST",body:JSON.stringify(s)})}function Is(t,s){return V(`/api/v1/tasks/${t}`,{method:"PATCH",body:JSON.stringify({...s,goalId:s.goalId===""?null:s.goalId,projectId:s.projectId===""?null:s.projectId,dueDate:s.dueDate===""?null:s.dueDate})})}function va(t){return V(`/api/v1/tasks/${t}/uncomplete`,{method:"POST",body:JSON.stringify({})})}function $l(t){return V(`/api/v1/tasks/${t}/context`)}function Fl(t){return V("/api/v1/operator/log-work",{method:"POST",body:JSON.stringify(t)})}function Dn(t,s="Removed from the visible archive."){return V(`/api/v1/activity/${t}/remove`,{method:"POST",body:JSON.stringify({reason:s})})}function ql(t){return V("/api/v1/session-events",{method:"POST",body:JSON.stringify(t)})}function _i(t,s){return V(`/api/v1/tasks/${t}/runs`,{method:"POST",body:JSON.stringify(s)})}function Bl(t,s){return V(`/api/v1/task-runs/${t}/heartbeat`,{method:"POST",body:JSON.stringify(s)})}function zl(t,s={}){return V(`/api/v1/task-runs/${t}/focus`,{method:"POST",body:JSON.stringify(s)})}function Rn(t,s){return V(`/api/v1/task-runs/${t}/complete`,{method:"POST",body:JSON.stringify(s)})}function _n(t,s){return V(`/api/v1/task-runs/${t}/release`,{method:"POST",body:JSON.stringify(s)})}const On=y.createContext(null),$e=[{to:"/overview",labelKey:"common.routeLabels.overview",detailKey:"common.routeDetails.overview",icon:on},{to:"/goals",labelKey:"common.routeLabels.goals",detailKey:"common.routeDetails.goals",icon:ys},{to:"/projects",labelKey:"common.routeLabels.projects",detailKey:"common.routeDetails.projects",icon:ln},{to:"/kanban",labelKey:"common.routeLabels.kanban",detailKey:"common.routeDetails.kanban",icon:Ft},{to:"/today",labelKey:"common.routeLabels.today",detailKey:"common.routeDetails.today",icon:ws},{to:"/notes",labelKey:"common.routeLabels.notes",detailKey:"common.routeDetails.notes",icon:sa},{to:"/psyche",labelKey:"common.routeLabels.psyche",detailKey:"common.routeDetails.psyche",icon:aa},{to:"/activity",labelKey:"common.routeLabels.activity",detailKey:"common.routeDetails.activity",icon:la},{to:"/insights",labelKey:"common.routeLabels.insights",detailKey:"common.routeDetails.insights",icon:Pr},{to:"/review/weekly",labelKey:"common.routeLabels.review",detailKey:"common.routeDetails.review",icon:Lr},{to:"/settings",labelKey:"common.routeLabels.settings",detailKey:"common.routeDetails.settings",icon:ia}],Kl=[$e[0],$e[4],$e[3],$e[6]],Xl=[$e[1],$e[2],$e[5],$e[7],$e[8],$e[9],$e[10]];function $n(t){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:t>=1e3?1:0}).format(t)}function Gl({to:t,labelKey:s,icon:a,compact:r=!1}){const{t:i}=Te(),n=i(s);return e.jsxs(gt,{to:t,title:r?n:void 0,"aria-label":n,className:({isActive:o})=>`interactive-tap flex items-center rounded-[18px] text-sm transition ${o?"bg-white/[0.08] text-white shadow-[inset_0_0_0_1px_rgba(192,193,255,0.2)]":"text-white/60 hover:bg-white/[0.04] hover:text-white"} ${r?"justify-center px-3 py-3.5":"gap-3 px-4 py-3"}`,children:[e.jsx(a,{className:"size-4 shrink-0"}),r?null:e.jsx("span",{children:n})]})}function Ql(){const[t,s]=y.useState(!1),{t:a}=Te();return e.jsxs(e.Fragment,{children:[e.jsx("nav",{"data-testid":"mobile-bottom-nav",className:"fixed inset-x-0 bottom-0 z-40 border-t border-white/6 bg-[rgba(9,14,28,0.94)] backdrop-blur-xl lg:hidden",style:{paddingLeft:"max(0.75rem, calc(var(--forge-safe-area-left) + 0.75rem))",paddingRight:"max(0.75rem, calc(var(--forge-safe-area-right) + 0.75rem))",paddingTop:"0.75rem",paddingBottom:"calc(var(--forge-safe-area-bottom) + 0.75rem)"},children:e.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[Kl.map(r=>e.jsxs(gt,{to:r.to,className:({isActive:i})=>`flex min-h-11 flex-col items-center justify-center gap-1 rounded-2xl px-2 py-2 text-[12px] ${i?"bg-white/[0.08] text-[var(--primary)]":"text-white/55"}`,children:[e.jsx(r.icon,{className:"size-4"}),e.jsx("span",{children:a(r.labelKey)})]},r.to)),e.jsxs("button",{type:"button",className:"flex min-h-11 flex-col items-center justify-center gap-1 rounded-2xl px-2 py-2 text-[12px] text-white/55",onClick:()=>s(!0),children:[e.jsx(ia,{className:"size-4"}),e.jsx("span",{children:a("common.shell.more")})]})]})}),e.jsx(ma,{open:t,onOpenChange:s,eyebrow:a("common.shell.moreRoutesEyebrow"),title:a("common.shell.moreRoutesTitle"),description:a("common.shell.moreRoutesDescription"),children:e.jsx("div",{className:"grid gap-3",children:Xl.map(r=>e.jsxs(gt,{to:r.to,onClick:()=>s(!1),className:({isActive:i})=>`interactive-tap flex items-center justify-between rounded-[24px] px-4 py-4 ${i?"bg-white/[0.08] text-white":"bg-white/[0.04] text-white/70"}`,children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(r.icon,{className:"size-4 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-base font-medium",children:a(r.labelKey)}),e.jsx("span",{className:"mt-1 block text-sm text-white/54",children:a(r.detailKey)})]})]}),e.jsx(la,{className:"size-4 text-white/35"})]},r.to))})})]})}function Wl({onClick:t}){const{t:s}=Te();return e.jsxs(X,{variant:"secondary",size:"sm",className:"min-w-[8.25rem] px-3.5",onClick:t,children:[e.jsx(ft,{className:"size-4"}),s("common.shell.command"),e.jsx(B,{size:"sm",tone:"meta",className:"ml-1 hidden bg-white/[0.06] text-white/52 xl:inline-flex",children:"⌘K"})]})}function Hl({children:t,settings:s,timerPending:a,startWorkOpen:r,startWorkPending:i,startWorkError:n,startWorkDefaults:o,onOpenStartWork:h,onCloseStartWork:l,onStartExistingTask:x,onCreateAndStartTask:g,onFocusRun:f,onPauseRun:d,onCompleteRun:u}){const b=oa(),c=Le(),{t:j}=Te(),k=$e.find(G=>b.pathname.startsWith(G.to))??$e[0],[$,M]=y.useState(!1),[I,N]=y.useState(!1),[m,w]=y.useState(!1),L=b.pathname.startsWith("/psyche"),S=Mr(),O=Er(),A=mo(),v=S+O,C=[{id:"streak",label:j("common.shell.momentum.streak"),compactValue:String(c.snapshot.metrics.streakDays),expandedValue:j(c.snapshot.metrics.streakDays===1?"common.shell.momentum.streakBadgeOne":"common.shell.momentum.streakBadgeOther",{count:c.snapshot.metrics.streakDays}),icon:Ar},{id:"xp",label:j("common.shell.momentum.xp"),compactValue:String(c.snapshot.metrics.totalXp),expandedValue:`${c.snapshot.metrics.totalXp} XP`,icon:Ft},{id:"momentum",label:j("common.shell.momentum.momentum"),compactValue:`${c.snapshot.metrics.momentumScore}%`,expandedValue:j("common.shell.momentum.liveMomentum",{count:c.snapshot.metrics.momentumScore}),icon:Dr}],R=O>0?j(O===1?"common.shell.savingOne":"common.shell.savingOther",{count:O}):S>0?j(S===1?"common.shell.refreshingOne":"common.shell.refreshingOther",{count:S}):j("common.shell.settled"),J=y.useMemo(()=>b.pathname.startsWith("/tasks/")?[{to:"/kanban",label:j("common.shell.rail.taskBackToKanban")},{to:"/today",label:j("common.shell.rail.taskOpenToday")}]:b.pathname.startsWith("/projects/")?[{to:"/projects",label:j("common.shell.rail.projectAll")},{to:"/goals",label:j("common.shell.rail.projectGoals")}]:b.pathname.startsWith("/goals/")?[{to:"/goals",label:j("common.shell.rail.goalAll")},{to:"/projects",label:j("common.shell.rail.goalProjects")}]:b.pathname.startsWith("/psyche")?[{to:"/psyche",label:j("common.shell.rail.psycheHub")},{to:"/psyche/reports",label:j("common.shell.rail.psycheReports")}]:[{to:"/overview",label:j("common.shell.rail.overview")},{to:"/today",label:j("common.shell.rail.today")}],[b.pathname,j]);return y.useEffect(()=>{const G=se=>{(se.metaKey||se.ctrlKey)&&se.key.toLowerCase()==="k"&&(se.preventDefault(),M(K=>!K))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[]),y.useEffect(()=>{try{window.localStorage.getItem("forge.desktop-nav-collapsed")==="true"&&w(!0)}catch{return}},[]),y.useEffect(()=>{try{window.localStorage.setItem("forge.desktop-nav-collapsed",String(m))}catch{return}},[m]),y.useEffect(()=>{const G=window.innerWidth>=1024?52:32,se=()=>{N(window.scrollY>G)};return se(),window.addEventListener("scroll",se,{passive:!0}),window.addEventListener("resize",se),()=>{window.removeEventListener("scroll",se),window.removeEventListener("resize",se)}},[]),e.jsxs("div",{className:`min-h-screen ${c.snapshot.meta.mode==="transitional-node"?"theme-forge-obsidian":""}`,children:[e.jsx(_o,{open:$,onOpenChange:M,snapshot:c.snapshot}),e.jsxs("div",{className:"hidden lg:grid lg:min-h-screen",style:{gridTemplateColumns:m?"5.75rem minmax(0,1fr)":"17.75rem minmax(0,1fr)"},children:[e.jsxs("aside",{className:Q("flex min-h-screen flex-col border-r border-white/5 bg-[rgba(8,13,28,0.78)] py-6 backdrop-blur-xl transition-[padding,width]",m?"px-3":"px-5"),children:[e.jsxs("div",{className:Q("flex items-start",m?"flex-col items-center gap-3":"justify-between gap-3"),children:[e.jsxs(xe,{to:"/overview",className:Q("block min-w-0",m&&"text-center"),children:[e.jsx("div",{className:Q("font-display text-[var(--primary)]",m?"text-2xl":"text-3xl"),children:j("common.shell.appMark")}),m?null:e.jsxs("div",{className:"type-meta mt-2 text-white/40",children:["Level ",c.snapshot.metrics.level]})]}),e.jsx(X,{type:"button",variant:"secondary",size:"sm",className:"mt-0.5 px-2.5",onClick:()=>w(G=>!G),"aria-label":j(m?"common.shell.expandSidebar":"common.shell.collapseSidebar"),title:j(m?"common.shell.expandSidebar":"common.shell.collapseSidebar"),children:m?e.jsx(Rr,{className:"size-4"}):e.jsx(_r,{className:"size-4"})})]}),e.jsx("div",{className:Q("grid gap-2",m?"mt-6":"mt-8"),children:$e.map(G=>e.jsx(Gl,{to:G.to,labelKey:G.labelKey,icon:G.icon,compact:m},G.to))}),e.jsx("div",{className:Q(m?"mt-4":"mt-6"),children:e.jsxs("div",{className:Q("rounded-[24px] bg-white/[0.04]",m?"px-2 py-2.5":"p-4"),children:[m?null:e.jsx("div",{className:"type-label text-white/40",children:j("common.shell.momentum.title")}),e.jsx("div",{className:Q("grid",m?"gap-1.5":"mt-3 gap-3"),children:C.map(G=>{const se=G.icon;return m?e.jsxs("div",{title:`${G.label}: ${G.compactValue}`,className:"flex min-w-0 flex-col items-center gap-1 rounded-[16px] bg-white/[0.04] px-1 py-2.5 text-center",children:[e.jsx(se,{className:"size-3.5 shrink-0 text-white/42"}),e.jsx("div",{className:"max-w-full text-[12px] font-semibold leading-none text-white",children:G.compactValue})]},G.id):e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-white/42",children:G.label}),e.jsx("div",{className:"mt-1 text-lg font-semibold leading-tight text-white",children:G.expandedValue})]},G.id)})})]})})]}),e.jsxs("div",{className:"min-h-screen",children:[e.jsx(Li,{children:e.jsxs(De.header,{className:"sticky top-0 z-30 border-b border-white/5 bg-[rgba(10,16,30,0.82)] px-6 backdrop-blur-xl",animate:A?void 0:{paddingTop:I?6:10,paddingBottom:I?6:9},transition:{duration:.35,ease:"easeOut"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-5",children:[e.jsx(De.div,{className:"shrink-0 font-display text-white",animate:A?void 0:{fontSize:I?"1rem":"1.12rem",lineHeight:1},transition:{duration:.35,ease:"easeOut"},children:j(k.labelKey)}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Mi,{runs:c.snapshot.activeTaskRuns,tasks:c.snapshot.tasks,generatedAt:c.snapshot.meta.generatedAt,timeAccountingMode:s.execution.timeAccountingMode,pending:a,onOpenStartWork:()=>h(),onPause:d,onFocus:f})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:[e.jsx(ji,{active:v>0,label:R}),e.jsx(Wl,{onClick:()=>M(!0)}),e.jsxs(X,{variant:"secondary",size:"sm",className:"min-w-[7.25rem] px-3.5",onClick:()=>void c.refresh(),children:[e.jsx(cn,{className:"size-4"}),j("common.actions.refresh")]})]})]}),e.jsx(Ei,{runs:c.snapshot.activeTaskRuns,tasks:c.snapshot.tasks,generatedAt:c.snapshot.meta.generatedAt,timeAccountingMode:s.execution.timeAccountingMode,pending:a,onOpenStartWork:()=>h(),onFocus:f,onPause:d,onComplete:u}),e.jsx(bt,{initial:!1,children:I?null:e.jsxs(De.div,{className:"mt-3 flex items-center justify-between gap-4 border-t border-white/6 pt-3",initial:A?void 0:{opacity:0,height:0,marginTop:0,paddingTop:0},animate:A?void 0:{opacity:1,height:"auto",marginTop:12,paddingTop:12},exit:A?void 0:{opacity:0,height:0,marginTop:0,paddingTop:0},transition:{duration:.28,ease:"easeOut"},children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:J.map(G=>e.jsx(xe,{to:G.to,className:"interactive-tap inline-flex min-h-10 min-w-max items-center justify-center rounded-full bg-white/[0.04] px-4 py-2 text-[13px] leading-none whitespace-nowrap text-white/62 transition hover:bg-white/[0.07] hover:text-white",children:G.label},G.to))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{tone:"meta",children:j(c.snapshot.metrics.streakDays===1?"common.shell.momentum.streakBadgeOne":"common.shell.momentum.streakBadgeOther",{count:c.snapshot.metrics.streakDays})}),e.jsx(B,{tone:"meta",children:j("common.shell.momentum.weeklyXp",{count:c.snapshot.metrics.weeklyXp})}),e.jsx(B,{tone:L?"signal":"meta",children:L?j("common.shell.momentum.psycheMode"):j("common.shell.momentum.liveMomentum",{count:c.snapshot.metrics.momentumScore})})]})]},"desktop-shell-secondary-row")})]})}),e.jsx("div",{className:"px-6 pt-3",children:e.jsx(Pi,{open:r,onOpenChange:G=>{G||l()},presentation:"desktop_inline",tasks:c.snapshot.tasks,projects:c.snapshot.dashboard.projects,activeRunCount:c.snapshot.activeTaskRuns.length,maxActiveTasks:s.execution.maxActiveTasks,timeAccountingMode:s.execution.timeAccountingMode,pending:i,errorMessage:n,initialTaskId:o.taskId??null,defaultProjectId:o.projectId??null,onStartExisting:x,onCreateAndStart:g})}),e.jsx("main",{className:"px-6 py-3",children:e.jsx(ki,{routeKey:b.pathname,tone:L?"psyche":"core",children:t})})]})]}),e.jsxs("div",{className:"min-h-[100dvh] overflow-x-clip lg:hidden",children:[e.jsx(Li,{children:e.jsxs(De.header,{className:"sticky top-0 z-30 border-b border-white/6 bg-[rgba(8,13,28,0.92)] px-4 backdrop-blur-xl",animate:A?void 0:{paddingTop:I?6:9,paddingBottom:I?6:8},transition:{duration:.35,ease:"easeOut"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:Q("shrink-0 font-display text-white transition",I?"text-[0.95rem]":"text-base"),children:j(k.labelKey)}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Mi,{runs:c.snapshot.activeTaskRuns,tasks:c.snapshot.tasks,generatedAt:c.snapshot.meta.generatedAt,timeAccountingMode:s.execution.timeAccountingMode,pending:a,onOpenStartWork:()=>h(),onPause:d,onFocus:f})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx(X,{variant:"secondary",size:"sm",className:"min-h-[2.125rem] px-2.5",onClick:()=>M(!0),children:e.jsx(ft,{className:"size-4"})}),e.jsxs("div",{className:"inline-flex min-h-[2.125rem] items-center gap-1.5 rounded-full border border-white/8 bg-white/[0.05] px-2.5 text-[12px] font-medium text-[var(--primary)]",children:[e.jsx(Ft,{className:"size-3.5 shrink-0"}),e.jsxs("span",{children:[$n(c.snapshot.metrics.totalXp)," XP"]})]})]})]}),e.jsx(Ei,{runs:c.snapshot.activeTaskRuns,tasks:c.snapshot.tasks,generatedAt:c.snapshot.meta.generatedAt,timeAccountingMode:s.execution.timeAccountingMode,pending:a,onOpenStartWork:()=>h(),onFocus:f,onPause:d,onComplete:u}),I?null:e.jsxs(e.Fragment,{children:[e.jsx(bt,{initial:!1,children:e.jsx(De.div,{initial:A?void 0:{opacity:0,height:0},animate:A?void 0:{opacity:1,height:"auto"},exit:A?void 0:{opacity:0,height:0},transition:{duration:.28,ease:"easeOut"},className:"overflow-hidden",children:e.jsx("div",{className:"mt-2 text-[13px] leading-5 text-white/52",children:j(k.detailKey)})},"mobile-shell-copy")}),e.jsx("div",{className:"mt-2",children:e.jsx(ji,{active:v>0,label:R})})]})]})}),e.jsx(Pi,{open:r,onOpenChange:G=>{G||l()},presentation:"mobile_sheet",tasks:c.snapshot.tasks,projects:c.snapshot.dashboard.projects,activeRunCount:c.snapshot.activeTaskRuns.length,maxActiveTasks:s.execution.maxActiveTasks,timeAccountingMode:s.execution.timeAccountingMode,pending:i,errorMessage:n,initialTaskId:o.taskId??null,defaultProjectId:o.projectId??null,onStartExisting:x,onCreateAndStart:g}),e.jsx("main",{className:"overflow-x-clip px-4 py-2.5 lg:pb-24",style:{paddingBottom:"calc(var(--forge-mobile-nav-clearance) + 2.5rem)",paddingLeft:"max(1rem, calc(var(--forge-safe-area-left) + 1rem))",paddingRight:"max(1rem, calc(var(--forge-safe-area-right) + 1rem))"},children:e.jsx(ki,{routeKey:b.pathname,tone:L?"psyche":"core",children:t})}),e.jsx(Ql,{})]}),e.jsx(Wo,{className:"fixed z-40 lg:bottom-6 lg:right-6",goals:c.snapshot.dashboard.goals,projects:c.snapshot.dashboard.projects,tags:c.snapshot.tags,onCreateGoal:c.createGoal,onCreateProject:c.createProject,onCreateTask:c.createTask})]})}function Ul(){var A;el();const t=y.useRef(`forge_session_${Math.random().toString(36).slice(2,10)}`),s=y.useRef(null),a=y.useRef(null),r=Pe(),[i,n]=y.useState(!1),[o,h]=y.useState({}),[l,x]=y.useState(null),[g,f]=y.useState(null),d=te({queryKey:["forge-shell-operator-session"],queryFn:Gt}),u=te({queryKey:["forge-snapshot"],queryFn:il,enabled:d.isSuccess}),b=te({queryKey:["forge-settings"],queryFn:fa,enabled:d.isSuccess});y.useEffect(()=>{var R;const v=(R=u.data)==null?void 0:R.metrics.totalXp;if(typeof v!="number")return;if(a.current===null){a.current=v;return}const C=v-a.current;a.current=v,C!==0&&(f({deltaXp:C,totalXp:v}),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{f(null),s.current=null},2600))},[(A=u.data)==null?void 0:A.metrics.totalXp]),y.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]),y.useEffect(()=>{if(!d.isSuccess)return;let v=!1,C=!1,R=!1;const J=()=>{v=!0},G=(D,F)=>ql({sessionId:t.current,eventType:D,metrics:F}).catch(()=>{});G("session_started",{visible:document.visibilityState==="visible",interacted:!1});const se=window.setTimeout(()=>{document.visibilityState==="visible"&&v&&!C&&(C=!0,G("dwell_120_seconds",{visible:!0,interacted:!0}))},12e4),K=()=>{const D=Math.max(1,document.documentElement.scrollHeight-window.innerHeight),F=Math.round(window.scrollY/D*100);F>=75&&v&&!R&&(R=!0,G("scroll_depth_75",{visible:document.visibilityState==="visible",interacted:!0,scrollDepth:F}))};return window.addEventListener("pointerdown",J),window.addEventListener("keydown",J),window.addEventListener("scroll",K,{passive:!0}),()=>{window.clearTimeout(se),window.removeEventListener("pointerdown",J),window.removeEventListener("keydown",J),window.removeEventListener("scroll",K)}},[d.isSuccess]);const c=de({mutationFn:v=>ea(v),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),j=de({mutationFn:v=>En(v),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),k=de({mutationFn:v=>An(v),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),$=de({mutationFn:({goalId:v,patch:C})=>Ol(v,C),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),M=de({mutationFn:({projectId:v,patch:C})=>_l(v,C),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),I=de({mutationFn:({taskId:v,status:C})=>Is(v,{status:C}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),N=de({mutationFn:({taskId:v,input:C})=>_i(v,C),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),m=de({mutationFn:v=>zl(v),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),w=de({mutationFn:({runId:v,actor:C,note:R})=>_n(v,{actor:C,note:R??""}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),L=de({mutationFn:({runId:v,actor:C,note:R})=>Rn(v,{actor:C,note:R??""}),onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}}),S=de({mutationFn:async v=>{var G,se;const C=(G=u.data)==null?void 0:G.dashboard.projects.find(K=>K.id===v.projectId);if(!C)throw new Error("Select a project before starting work.");const R=((se=b.data)==null?void 0:se.settings.profile.operatorName)??"Albert",J=await ea({title:v.title,description:v.description,owner:R,goalId:C.goalId,projectId:C.id,priority:"medium",status:"in_progress",effort:"deep",energy:"steady",dueDate:"",points:60,tagIds:[]});return await _i(J.task.id,{actor:R,timerMode:v.timerMode,plannedDurationSeconds:v.plannedDurationSeconds,isCurrent:!0,leaseTtlSeconds:1800,note:""}),J.task},onSuccess:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})}});if(y.useEffect(()=>{const v=u.data;if(!v||v.activeTaskRuns.length===0)return;const C=window.setInterval(()=>{if(document.visibilityState==="visible"){for(const R of v.activeTaskRuns)Bl(R.id,{actor:R.actor,leaseTtlSeconds:R.leaseTtlSeconds,note:R.note}).catch(()=>{});r.invalidateQueries({queryKey:["forge-snapshot"]})}},3e4);return()=>window.clearInterval(C)},[r,u.data]),d.isLoading||u.isLoading||b.isLoading)return e.jsx("div",{className:"grid min-h-screen place-items-center p-6",children:e.jsx(Qe,{eyebrow:"Forge shell",title:"Loading Forge",description:"Checking your operator session and loading your latest snapshot."})});if(d.isError)return e.jsx("div",{className:"grid min-h-screen place-items-center p-6",children:e.jsx(je,{eyebrow:"Forge operator session",error:d.error,onRetry:()=>void r.invalidateQueries({queryKey:["forge-shell-operator-session"]})})});if(b.isError)return e.jsx("div",{className:"grid min-h-screen place-items-center p-6",children:e.jsx(je,{eyebrow:"Forge settings",error:b.error,onRetry:()=>void r.invalidateQueries({queryKey:["forge-settings"]})})});if(u.isError||!u.data||!b.data)return e.jsx("div",{className:"grid min-h-screen place-items-center p-6",children:e.jsx(je,{eyebrow:"Forge state",error:u.error,onRetry:()=>void r.invalidateQueries({queryKey:["forge-snapshot"]})})});const O={snapshot:u.data,refresh:async()=>{await r.invalidateQueries({queryKey:["forge-snapshot"]})},createTask:async v=>{await c.mutateAsync(v)},startTaskNow:async(v,C={})=>{const R=b.data.settings.profile.operatorName;await N.mutateAsync({taskId:v,input:{actor:R,timerMode:C.timerMode??"planned",plannedDurationSeconds:C.plannedDurationSeconds===void 0?1200:C.plannedDurationSeconds,isCurrent:!0,leaseTtlSeconds:1800,note:""}})},createGoal:async v=>{await j.mutateAsync(v)},createProject:async v=>{await k.mutateAsync(v)},patchGoal:async(v,C)=>{await $.mutateAsync({goalId:v,patch:C})},patchProject:async(v,C)=>{await M.mutateAsync({projectId:v,patch:C})},patchTaskStatus:async(v,C)=>{await I.mutateAsync({taskId:v,status:C})},openStartWork:(v={})=>{h(v),x(null),n(!0)}};return e.jsx(Ao,{locale:b.data.settings.localePreference,children:e.jsx(On.Provider,{value:O,children:e.jsxs(e.Fragment,{children:[e.jsx(Hl,{settings:b.data.settings,timerPending:m.isPending||w.isPending||L.isPending,startWorkOpen:i,startWorkPending:N.isPending||S.isPending,startWorkError:l,startWorkDefaults:o,onOpenStartWork:v=>{h(v??{}),x(null),n(!0)},onCloseStartWork:()=>{n(!1),x(null)},onStartExistingTask:async(v,C)=>{try{const R=b.data.settings.profile.operatorName;await N.mutateAsync({taskId:v,input:{actor:R,timerMode:C.timerMode,plannedDurationSeconds:C.plannedDurationSeconds,isCurrent:!0,leaseTtlSeconds:1800,note:""}}),n(!1),x(null)}catch(R){x(R instanceof Error?R.message:"Could not start work.")}},onCreateAndStartTask:async v=>{try{await S.mutateAsync(v),n(!1),x(null)}catch(C){x(C instanceof Error?C.message:"Could not create and start the task.")}},onFocusRun:async v=>{await m.mutateAsync(v)},onPauseRun:async v=>{const C=u.data.activeTaskRuns.find(R=>R.id===v);await w.mutateAsync({runId:v,actor:C==null?void 0:C.actor,note:C==null?void 0:C.note})},onCompleteRun:async v=>{const C=u.data.activeTaskRuns.find(R=>R.id===v);await L.mutateAsync({runId:v,actor:C==null?void 0:C.actor,note:C==null?void 0:C.note})},children:e.jsx(Cr,{context:O})}),g?e.jsx("div",{className:"pointer-events-none fixed inset-x-0 bottom-24 z-50 flex justify-center px-4 lg:bottom-6",children:e.jsxs("div",{className:Q("inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-[0_18px_48px_rgba(3,8,18,0.38)] backdrop-blur-xl",g.deltaXp>0?"border-emerald-400/30 bg-emerald-500/14 text-emerald-100":"border-rose-400/30 bg-rose-500/14 text-rose-100"),children:[e.jsx(Ft,{className:"size-4 shrink-0"}),e.jsxs("span",{children:[g.deltaXp>0?`XP +${g.deltaXp}`:`XP ${g.deltaXp}`," · ",$n(g.totalXp)," total"]})]})}):null]})})})}function Le(){return y.useContext(On)??Ir()}function qs(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g," ")}function Yl({eyebrow:t,titleText:s,entityKind:a,copyMode:r}){if(!t||r==="title_only"||typeof t!="string")return null;const i=qs(t),n=s?qs(s):null,o=a?qs(ot(a).label):null;return!i||n&&(i===n||n.includes(i)||i.includes(n))||o&&i===o?null:t}function ke({eyebrow:t,entityKind:s,title:a,titleText:r,description:i,badge:n,actions:o,copyMode:h="title_only"}){const l=s?ot(s):null,x=l==null?void 0:l.icon,g=Yl({eyebrow:t,titleText:r,entityKind:s,copyMode:h}),f=!!(l||g||n);return e.jsxs("section",{className:"grid w-full max-w-full min-w-0 gap-1.5 rounded-[24px] bg-[var(--hero-gradient)] px-4 py-2.5 shadow-[var(--card-shadow)] lg:grid-cols-[minmax(0,1fr)_auto] lg:px-5 lg:py-3",children:[e.jsxs("div",{className:"min-w-0",children:[f?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&x?e.jsx("div",{className:Q("inline-flex size-8 shrink-0 items-center justify-center rounded-full border bg-white/[0.04] shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]",l.subtleBadgeClassName),"aria-label":l.label,title:l.label,children:e.jsx(x,{className:Q("size-4",l.iconClassName)})}):null,g?e.jsx("div",{className:"type-label text-[var(--secondary)]",children:g}):null,n?e.jsx(B,{tone:"signal",className:"bg-white/[0.08] text-white/78",children:n}):null]}):null,e.jsx("div",{className:Q("max-w-4xl text-[clamp(1.2rem,1.85vw,1.7rem)] leading-[1] text-white",f?"mt-1.5":""),children:a}),e.jsx("p",{className:"mt-1 hidden max-w-3xl text-[13px] leading-5 text-white/54 sm:block",children:i})]}),o?e.jsx("div",{className:"flex min-w-0 flex-wrap items-start gap-2 lg:justify-end",children:o}):null]})}function dt(t){return t.entityType==="goal"?`/goals/${t.entityId}`:t.entityType==="project"?`/projects/${t.entityId}`:t.entityType==="task"?`/tasks/${t.entityId}`:t.entityType==="task_run"&&typeof t.metadata.taskId=="string"?`/tasks/${t.metadata.taskId}`:null}function fs(t){return t.entityType==="goal"?"Open goal":t.entityType==="project"?"Open project":t.entityType==="task"||t.entityType==="task_run"?"Open task":null}const Rt=ho(),Oi=[Rt.accessor("title",{header:"Event",cell:t=>{const s=dt(t.row.original);return s?e.jsx(xe,{to:s,className:"font-medium text-white transition hover:text-[var(--primary)]",children:t.getValue()}):e.jsx("div",{className:"font-medium text-white",children:t.getValue()})}}),Rt.accessor("source",{header:"Source",cell:t=>e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/50",children:t.getValue()})}),Rt.accessor("createdAt",{header:"When",cell:t=>e.jsx("div",{className:"text-sm text-white/55",children:da(t.getValue())})}),Rt.display({id:"actions",header:"Open",cell:t=>{const s=dt(t.row.original);return s?e.jsx(xe,{to:s,className:"inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)] transition hover:text-white",children:"Open"}):e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/32",children:"Archive only"})}})];function Jl({rows:t,onRemove:s}){const a=s?[...Oi,Rt.display({id:"remove",header:"Correct",cell:i=>e.jsx(X,{variant:"ghost",className:"h-auto px-0 py-0 text-[11px] uppercase tracking-[0.16em] text-white/55",onClick:()=>{s(i.row.original.id)},children:"Remove log"})})]:Oi,r=uo({columns:a,data:t,getCoreRowModel:po()});return e.jsx(Y,{className:"overflow-hidden p-0",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:r.getHeaderGroups().map(i=>e.jsx("tr",{className:"bg-white/[0.03]",children:i.headers.map(n=>e.jsx("th",{className:"px-5 py-4 text-left font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:n.isPlaceholder?null:gi(n.column.columnDef.header,n.getContext())},n.id))},i.id))}),e.jsx("tbody",{children:r.getRowModel().rows.map(i=>e.jsx("tr",{className:"bg-white/[0.015] transition hover:bg-white/[0.035]",children:i.getVisibleCells().map(n=>e.jsx("td",{className:"px-5 py-4 align-top",children:gi(n.column.columnDef.cell,n.getContext())},n.id))},i.id))})]})})}function Vl(){var x;const[t]=Ze(),s=Pe(),a=t.get("entityId")??void 0,r=t.get("entityType")??void 0,i=t.get("eventId"),n=te({queryKey:["activity-archive",r,a],queryFn:()=>Rl({limit:100,entityType:r,entityId:a})}),o=de({mutationFn:g=>Dn(g),onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:["activity-archive"]}),s.invalidateQueries({queryKey:["forge-snapshot"]}),s.invalidateQueries({queryKey:["task-context"]}),s.invalidateQueries({queryKey:["project-board"]})])}}),h=((x=n.data)==null?void 0:x.activity)??[];if(n.isLoading)return e.jsx(Qe,{eyebrow:"Evidence archive",title:"Loading activity",description:"Pulling the visible audit trail, grouped evidence, and correction history."});if(n.isError)return e.jsx(je,{eyebrow:"Evidence archive",error:n.error,onRetry:()=>void n.refetch()});if(h.length===0)return e.jsx(Xe,{eyebrow:"Evidence archive",title:a?"No evidence matched this filter":"No activity recorded yet",description:a?"Forge could not find visible events for this specific entity yet. Try a broader archive view or create some work first.":"As you complete work, log runs, or make corrections, the audit trail will appear here."});const l=h.reduce((g,f)=>{const d=f.createdAt.slice(0,10);return g[d]=[...g[d]??[],f],g},{});return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{title:"Activity",description:a?"This filtered archive shows the evidence connected to the item you opened, so you can confirm what changed and when.":"Activity is your visible audit trail. Use it to inspect progress, confirm corrections, and trace work back to the goal, project, or task it came from.",badge:`${h.length} recent events`}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsx(Jl,{rows:h,onRemove:async g=>{await o.mutateAsync(g)}}),e.jsx("div",{className:"grid gap-4",children:Object.entries(l).slice(0,6).map(([g,f])=>e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:g}),e.jsx("div",{className:"mt-4 grid gap-3",children:f.slice(0,3).map(d=>e.jsxs("div",{className:`rounded-[18px] p-4 ${i===d.id?"bg-[rgba(192,193,255,0.12)] shadow-[inset_0_0_0_1px_rgba(192,193,255,0.2)]":"bg-white/[0.04]"}`,children:[e.jsx("div",{className:"font-medium text-white",children:d.title}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:d.description}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:da(d.createdAt)}),dt(d)&&fs(d)?e.jsx(xe,{to:dt(d),className:"mt-3 inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:fs(d)}):null]},d.id))})]},g))})]})]})}const Zl={spark:"Spark stage",story:"Story stage",state:"State stage",lens:"Lens stage",pivot:"Pivot stage"};function ed(t,s){return`${t}:${s}`}function Be(t,s,a){return(t==null?void 0:t[ed(s,a)])??{count:0,latestNoteId:null,latestCreatedAt:null}}function Fn(t){return`${t} Note${t===1?"":"s"}`}function Tt(t){return t.replaceAll("_"," ")}function Ot(t){if(!t)return null;const s=t.trim().toLowerCase(),a=Zl[s];return a||s.split(/[_\-\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function td(t,s){const a=Ot(s);return a?t==="trigger_report"?`This note is pinned to the ${a.toLowerCase()} of the report, so it stays attached to that part of the reflective chain.`:`This note is pinned to the "${a}" section of the ${Tt(t)} instead of only the whole entity.`:null}function ya(t,s){switch(t){case"goal":return`/goals/${s}`;case"project":return`/projects/${s}`;case"task":return`/tasks/${s}`;case"psyche_value":return`/psyche/values?focus=${s}#values-atlas`;case"behavior_pattern":return`/psyche/patterns?focus=${s}#pattern-lanes`;case"behavior":return`/psyche/behaviors?focus=${s}#behavior-columns`;case"belief_entry":return`/psyche/schemas-beliefs?focus=${s}`;case"mode_profile":return`/psyche/modes?focus=${s}`;case"trigger_report":return`/psyche/reports/${s}`;default:return null}}function qn(t,s){switch(t){case"goal":case"project":case"task":case"trigger_report":{const a=ya(t,s);return a?`${a}#notes`:null}default:return`/notes?entityType=${encodeURIComponent(t)}&entityId=${encodeURIComponent(s)}`}}function sd(t){return t.links.find(s=>ya(s.entityType,s.entityId)!==null)??t.links[0]??null}function Zt(t,s){const a=[],r=/(\[([^\]]+)\]\(([^)]+)\)|`([^`]+)`|\*\*([^*]+)\*\*|\*([^*]+)\*)/g;let i=0,n=null,o=0;for(;(n=r.exec(t))!==null;){if(n.index>i&&(a.push(e.jsx(y.Fragment,{children:t.slice(i,n.index)},`${s}-text-${o}`)),o+=1),n[2]&&n[3]){const h=n[3].trim(),l=/^https?:\/\//i.test(h);a.push(e.jsx("a",{href:h,className:"text-[var(--secondary)] underline decoration-[rgba(125,211,252,0.4)] underline-offset-4 transition hover:text-white",target:l?"_blank":void 0,rel:l?"noreferrer":void 0,children:n[2]},`${s}-link-${o}`))}else n[4]?a.push(e.jsx("code",{className:"rounded bg-white/[0.08] px-1.5 py-0.5 text-[0.92em] text-white/90",children:n[4]},`${s}-code-${o}`)):n[5]?a.push(e.jsx("strong",{className:"font-semibold text-white",children:n[5]},`${s}-strong-${o}`)):n[6]&&a.push(e.jsx("em",{className:"italic text-white/88",children:n[6]},`${s}-em-${o}`));i=r.lastIndex,o+=1}return i<t.length&&a.push(e.jsx(y.Fragment,{children:t.slice(i)},`${s}-tail-${o}`)),a}function ad(t){const s=t.replace(/\r/g,"").split(`
|
|
2
|
+
`),a=[];let r=0;for(;r<s.length;){const i=s[r]??"",n=i.trim();if(!n){r+=1;continue}if(n.startsWith("```")){const l=[];for(r+=1;r<s.length&&!(s[r]??"").trim().startsWith("```");)l.push(s[r]??""),r+=1;r+=1,a.push(e.jsx("pre",{className:"overflow-x-auto rounded-[18px] bg-[rgba(6,10,18,0.88)] px-4 py-3 text-xs leading-6 text-white/86",children:e.jsx("code",{children:l.join(`
|
|
3
|
+
`)})},`code-${r}`));continue}const o=i.match(/^(#{1,6})\s+(.*)$/);if(o){const l=o[1].length,x=l===1?"text-xl":l===2?"text-lg":l===3?"text-base":"text-sm";a.push(e.jsx("div",{className:Q("font-semibold text-white",x),children:Zt(o[2],`heading-${r}`)},`heading-${r}`)),r+=1;continue}if(/^>\s?/.test(i)){const l=[];for(;r<s.length&&/^>\s?/.test(s[r]??"");)l.push((s[r]??"").replace(/^>\s?/,"")),r+=1;a.push(e.jsx("blockquote",{className:"border-l-2 border-[var(--secondary)]/50 pl-4 text-sm leading-7 text-white/72",children:Zt(l.join(" "),`quote-${r}`)},`quote-${r}`));continue}if(/^[-*+]\s+/.test(i)||/^\d+\.\s+/.test(i)){const l=/^\d+\.\s+/.test(i),x=[];for(;r<s.length&&(/^[-*+]\s+/.test(s[r]??"")||/^\d+\.\s+/.test(s[r]??""));)x.push((s[r]??"").replace(/^[-*+]\s+/,"").replace(/^\d+\.\s+/,"")),r+=1;const g=l?"ol":"ul";a.push(e.jsx(g,{className:Q("space-y-1 pl-5 text-sm leading-7 text-white/74",l?"list-decimal":"list-disc"),children:x.map((f,d)=>e.jsx("li",{children:Zt(f,`list-${r}-${d}`)},`item-${r}-${d}`))},`list-${r}`));continue}const h=[];for(;r<s.length;){const l=s[r]??"";if(!l.trim()||l.trim().startsWith("```")||/^#{1,6}\s+/.test(l)||/^>\s?/.test(l)||/^[-*+]\s+/.test(l)||/^\d+\.\s+/.test(l))break;h.push(l.trim()),r+=1}a.push(e.jsx("p",{className:"text-sm leading-7 text-white/72",children:Zt(h.join(" "),`paragraph-${r}`)},`paragraph-${r}`))}return a}function ms({markdown:t,className:s}){return e.jsx("div",{className:Q("grid gap-3",s),children:ad(t)})}function id(t,s,a){return t.links.filter(r=>!(r.entityType===s&&r.entityId===a))}function nd(t,s){return t.entityType===s.entityType&&t.entityId===s.entityId&&(t.anchorKey??null)===(s.anchorKey??null)}function Bs(t){const s=new Set;return t.filter(a=>{const r=`${a.entityType}:${a.entityId}:${a.anchorKey??""}`;return s.has(r)?!1:(s.add(r),!0)})}function Ps({entityType:t,entityId:s,anchorKey:a,includeAnchorlessWhenAnchored:r=!1,title:i="Notes",description:n="Markdown notes linked to this entity stay searchable, editable, and visible alongside the work.",invalidateQueryKeys:o=[],compact:h=!1}){var oe,Me,Oe,ze,mt,tt,ht,Ie;const l=Le(),x=Pe(),[g,f]=y.useState(""),[d,u]=y.useState(!1),[b,c]=y.useState(""),[j,k]=y.useState(!1),[$,M]=y.useState({entityType:"goal",entityId:""}),[I,N]=y.useState([]),[m,w]=y.useState(null),[L,S]=y.useState(""),[O,A]=y.useState(!1),[v,C]=y.useState([]),[R,J]=y.useState({entityType:"goal",entityId:""}),G=Ot(a),se=td(t,a),K=te({queryKey:["notes",t,s],queryFn:()=>Pn({linkedEntityType:t,linkedEntityId:s,limit:100})}),D=te({queryKey:["forge-psyche-values"],queryFn:yt}),F=te({queryKey:["forge-psyche-patterns"],queryFn:Ss}),W=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),T=te({queryKey:["forge-psyche-beliefs"],queryFn:Wt}),H=te({queryKey:["forge-psyche-modes"],queryFn:jt}),U=te({queryKey:["forge-psyche-reports"],queryFn:ba}),Z=y.useMemo(()=>{var ne,we,fe,be,Ge,he,We;return{goal:l.snapshot.goals.map(pe=>({id:pe.id,label:pe.title})),project:l.snapshot.dashboard.projects.map(pe=>({id:pe.id,label:pe.title})),task:l.snapshot.tasks.map(pe=>({id:pe.id,label:pe.title})),tag:l.snapshot.tags.map(pe=>({id:pe.id,label:pe.name})),note:(((ne=K.data)==null?void 0:ne.notes)??[]).map(pe=>({id:pe.id,label:pe.contentPlain||pe.contentMarkdown})),insight:[],psyche_value:(((we=D.data)==null?void 0:we.values)??[]).map(pe=>({id:pe.id,label:pe.title})),behavior_pattern:(((fe=F.data)==null?void 0:fe.patterns)??[]).map(pe=>({id:pe.id,label:pe.title})),behavior:(((be=W.data)==null?void 0:be.behaviors)??[]).map(pe=>({id:pe.id,label:pe.title})),belief_entry:(((Ge=T.data)==null?void 0:Ge.beliefs)??[]).map(pe=>({id:pe.id,label:pe.statement})),mode_profile:(((he=H.data)==null?void 0:he.modes)??[]).map(pe=>({id:pe.id,label:pe.title})),mode_guide_session:[],event_type:[],emotion_definition:[],trigger_report:(((We=U.data)==null?void 0:We.reports)??[]).map(pe=>({id:pe.id,label:pe.title}))}},[(oe=W.data)==null?void 0:oe.behaviors,(Me=T.data)==null?void 0:Me.beliefs,(Oe=H.data)==null?void 0:Oe.modes,(ze=K.data)==null?void 0:ze.notes,(mt=F.data)==null?void 0:mt.patterns,(tt=U.data)==null?void 0:tt.reports,l.snapshot.dashboard.projects,l.snapshot.goals,l.snapshot.tags,l.snapshot.tasks,(ht=D.data)==null?void 0:ht.values]),ie=async()=>{await Promise.all([x.invalidateQueries({queryKey:["notes",t,s]}),x.invalidateQueries({queryKey:["forge-snapshot"]}),...o.map(ne=>x.invalidateQueries({queryKey:ne}))])},ge=de({mutationFn:async ne=>Ln({contentMarkdown:ne,links:Bs([{entityType:t,entityId:s,anchorKey:a??null},...I])}),onSuccess:async()=>{c(""),k(!1),N([]),M({entityType:"goal",entityId:""}),await ie()}}),z=de({mutationFn:async({noteId:ne,contentMarkdown:we,links:fe})=>xl(ne,{contentMarkdown:we,links:fe}),onSuccess:async()=>{w(null),S(""),A(!1),C([]),J({entityType:"goal",entityId:""}),await ie()}}),E=de({mutationFn:async ne=>gl(ne),onSuccess:ie}),p=y.useMemo(()=>{var we;return(((we=K.data)==null?void 0:we.notes)??[]).filter(fe=>a===void 0?!0:fe.links.some(be=>be.entityType===t&&be.entityId===s&&((be.anchorKey??null)===a||r&&(be.anchorKey??null)===null))).filter(fe=>{const be=g.trim().toLowerCase();return be?`${fe.contentPlain} ${fe.author??""}`.toLowerCase().includes(be):!0})},[a,s,t,r,(Ie=K.data)==null?void 0:Ie.notes,g]),P=(ne,we,fe)=>{const be=ne.entityId.trim();return be?(we(Bs([...fe,{entityType:ne.entityType,entityId:be,anchorKey:null}])),!0):!1},_=ne=>{var fe,be;const we=(fe=Z[ne.entityType])==null?void 0:fe.find(Ge=>Ge.id===ne.entityId);return(be=we==null?void 0:we.label)!=null&&be.trim()?we.label.trim():`Deleted ${Tt(ne.entityType)}`},ve=(ne,we,fe,be,Ge)=>e.jsxs("div",{className:"rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Linked entities"}),e.jsxs(B,{className:"bg-white/[0.08] text-white/68",children:[ne.length," linked"]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:ne.map(he=>{const We=ne.length>1;return e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.08] px-3 py-2 text-sm text-white/72",children:[e.jsxs("span",{children:[Tt(he.entityType)," · ",_(he)]}),he.anchorKey?e.jsx("span",{className:"rounded-full bg-white/[0.08] px-2 py-0.5 text-[11px] text-white/54",children:Ot(he.anchorKey)}):null,e.jsx("button",{type:"button",disabled:!We,className:"text-white/44 transition hover:text-white disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>we(ne.filter(pe=>!nd(pe,he))),"aria-label":`Remove ${Tt(he.entityType)} link to ${_(he)}`,children:e.jsx(ps,{className:"size-3.5"})})]},`${Ge}-${he.entityType}-${he.entityId}-${he.anchorKey??""}`)})}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-[minmax(0,11rem)_minmax(0,1fr)_auto]",children:[e.jsx("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:fe.entityType,onChange:he=>be({...fe,entityType:he.target.value,entityId:""}),children:["goal","project","task","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","event_type","emotion_definition","trigger_report"].map(he=>e.jsx("option",{value:he,children:Tt(he)},he))}),e.jsxs("select",{className:"min-w-0 rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:fe.entityId,onChange:he=>be({...fe,entityId:he.target.value}),children:[e.jsx("option",{value:"",children:(Z[fe.entityType]??[]).length>0?"Choose linked item":"No linked items available"}),(Z[fe.entityType]??[]).map(he=>e.jsx("option",{value:he.id,children:he.label},he.id))]}),e.jsx(X,{variant:"secondary",disabled:!fe.entityId,onClick:()=>{P(fe,we,ne)&&be({...fe,entityId:""})},children:"Add link"})]})]});return e.jsx(Y,{id:"notes",className:h?"min-w-0 overflow-hidden p-0":"min-w-0 overflow-hidden",children:e.jsxs("div",{className:h?"p-4":void 0,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:i}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:n}),G?e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 rounded-full bg-white/[0.05] px-3 py-2 text-xs text-white/64",children:[e.jsxs("span",{children:["Pinned to ",G]}),se?e.jsx(Ne,{content:se,label:`Explain ${G}`}):null]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:Fn(p.length)}),d?null:e.jsxs(X,{type:"button",size:"sm",onClick:()=>u(!0),children:[e.jsx(St,{className:"size-4"}),"Add note"]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-[22px] border border-white/8 bg-white/[0.04] px-3 py-3",children:[e.jsx(ft,{className:"size-4 text-white/34"}),e.jsx(ae,{value:g,onChange:ne=>f(ne.target.value),placeholder:"Search notes by content or author",className:"border-0 bg-transparent px-0 py-0"})]}),d?e.jsxs("div",{className:"mt-4 rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/70",children:[e.jsx(St,{className:"size-4 text-[var(--secondary)]"}),"Add note"]}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>k(ne=>!ne),children:[e.jsx(xi,{className:"size-4"}),j?"Back to editor":"Preview"]})]}),e.jsx("div",{className:"mt-3",children:j?e.jsxs("div",{className:"rounded-[20px] bg-[rgba(9,14,25,0.78)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Preview"}),e.jsx("div",{className:"mt-3",children:b.trim()?e.jsx(ms,{markdown:b}):e.jsx("div",{className:"text-sm leading-6 text-white/42",children:"Markdown preview appears here once you have note content."})})]}):e.jsx(le,{value:b,onChange:ne=>c(ne.target.value),placeholder:"Write in Markdown. Summaries, blockers, what changed, and why all work well here.",className:"min-h-[12rem]"})}),e.jsx("div",{className:"mt-3",children:ve(Bs([{entityType:t,entityId:s,anchorKey:a??null},...I]),ne=>N(ne.filter(we=>!(we.entityType===t&&we.entityId===s&&(we.anchorKey??null)===(a??null)))),$,M,"composer-note-links")}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(X,{type:"button",variant:"secondary",onClick:()=>{u(!1),k(!1),c(""),N([]),M({entityType:"goal",entityId:""})},children:"Cancel"}),e.jsx(X,{pending:ge.isPending,pendingLabel:"Saving",disabled:b.trim().length===0,onClick:async()=>{await ge.mutateAsync(b.trim()),u(!1)},children:"Save note"})]})]}):null,e.jsxs("div",{className:"mt-4 grid gap-3",children:[K.isLoading?e.jsx("div",{className:"rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/56",children:"Loading notes…"}):null,!K.isLoading&&p.length===0?e.jsx("div",{className:"rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/56",children:"No notes are linked here yet."}):null,p.map(ne=>{const we=m===ne.id,fe=id(ne,t,s);return e.jsxs("article",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] 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:"text-xs uppercase tracking-[0.16em] text-white/38",children:[(ne.author??"Unknown author").toString()," • ",new Date(ne.updatedAt).toLocaleString()]}),fe.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:fe.map(be=>e.jsxs(B,{className:"bg-white/[0.08] text-white/68",wrap:!0,children:[Tt(be.entityType)," · ",_(be),be.anchorKey?` · ${Ot(be.anchorKey)}`:""]},`${ne.id}-${be.entityType}-${be.entityId}-${be.anchorKey??""}`))}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-white/[0.06] text-white/60 transition hover:bg-white/[0.1] hover:text-white",onClick:()=>{w(ne.id),S(ne.contentMarkdown),A(!1),C(ne.links),J({entityType:"goal",entityId:""})},children:e.jsx(us,{className:"size-4"})}),e.jsx("button",{type:"button",className:"inline-flex size-9 items-center justify-center rounded-full bg-rose-500/10 text-rose-200 transition hover:bg-rose-500/16",onClick:()=>{E.mutateAsync(ne.id)},children:e.jsx(ps,{className:"size-4"})})]})]}),we?e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"gap-2",onClick:()=>A(be=>!be),children:[e.jsx(xi,{className:"size-4"}),O?"Back to editor":"Preview"]})}),e.jsx("div",{className:"mt-3",children:O?e.jsxs("div",{className:"rounded-[20px] bg-[rgba(9,14,25,0.78)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Preview"}),e.jsx("div",{className:"mt-3",children:L.trim()?e.jsx(ms,{markdown:L}):e.jsx("div",{className:"text-sm text-white/42",children:"No content yet."})})]}):e.jsx(le,{value:L,onChange:be=>S(be.target.value),className:"min-h-[12rem]"})}),e.jsx("div",{className:"mt-3",children:ve(v,C,R,J,`edit-note-links-${ne.id}`)}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx(X,{variant:"secondary",onClick:()=>{w(null),A(!1)},children:"Cancel"}),e.jsx(X,{pending:z.isPending,pendingLabel:"Saving",disabled:L.trim().length===0||v.length===0,onClick:async()=>{await z.mutateAsync({noteId:ne.id,contentMarkdown:L.trim(),links:v})},children:"Save changes"})]})]}):e.jsx("div",{className:"mt-4",children:e.jsx(ms,{markdown:ne.contentMarkdown})})]},ne.id)})]})]})})}function ct({value:t,className:s,tone:a="primary"}){const r=`${Math.max(4,Math.min(100,t))}%`,i=a==="secondary"?"from-[var(--secondary)] to-[rgba(78,222,163,0.45)]":a==="tertiary"?"from-[var(--tertiary)] to-[rgba(255,185,95,0.45)]":"from-[var(--primary)] to-[rgba(192,193,255,0.45)]";return e.jsx("div",{className:Q("h-1.5 rounded-full bg-white/[0.08]",s),children:e.jsx("div",{className:Q("h-full rounded-full bg-gradient-to-r",i),style:{width:r}})})}function Bn(t){const s=`${t.title} ${t.description} ${t.source??""}`.toLowerCase();return s.includes("playwright")||s.includes("operator console")||s.includes("retroactive work logging")}function Ls(t){return Bn(t)?"Work log added":t.title}function Ms(t){return Bn(t)?"This entry was added later so the work history stays complete and accurate.":t.description}function rd(){const{t}=Te(),s=Le(),a=js(),[r,i]=y.useState(!1),[n,o]=y.useState(!1),h=s.snapshot.dashboard.goals.find(c=>c.id===a.goalId)??null,l=y.useMemo(()=>s.snapshot.dashboard.projects.filter(c=>c.goalId===a.goalId),[a.goalId,s.snapshot.dashboard.projects]),x=new Set(l.map(c=>c.id)),g=new Set(s.snapshot.tasks.filter(c=>x.has(c.projectId??"")).map(c=>c.id)),f=s.snapshot.activity.filter(c=>c.entityId===a.goalId||x.has(c.entityId)||g.has(c.entityId)||c.entityType==="task_run"&&typeof c.metadata.taskId=="string"&&g.has(c.metadata.taskId));if(!h)return e.jsx(Xe,{eyebrow:t("common.goalDetail.eyebrow"),title:t("common.goalDetail.missingTitle"),description:t("common.goalDetail.missingDescription"),action:e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-slate-950 transition hover:opacity-90",children:t("common.goalDetail.backToGoals")})});const d=l.find(c=>c.nextTaskTitle)??l[0]??null,u=s.snapshot.overview.neglectedGoals.find(c=>c.goalId===h.id)??null,b=f[0]??null;return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ke,{entityKind:"goal",title:e.jsx(ue,{kind:"goal",label:h.title,variant:"heading",size:"lg"}),titleText:h.title,description:h.description,badge:t(l.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:l.length})}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(X,{onClick:()=>i(!0),children:t("common.goalDetail.edit")}),e.jsx(X,{variant:"secondary",onClick:()=>o(!0),children:t("common.goalDetail.addProject")})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.goalDetail.sectionProjects")}),l.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.goalDetail.noProjects")}):e.jsx("div",{className:"mt-4 grid gap-4 lg:grid-cols-2",children:l.map(c=>e.jsxs(xe,{to:`/projects/${c.id}`,className:"rounded-[22px] bg-white/[0.04] p-5 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(re,{kind:"project",compact:!0,gradient:!1}),e.jsx(B,{children:c.status})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ue,{kind:"project",label:c.title,variant:"heading",size:"lg"})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:c.description}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:c.progress})}),e.jsx("div",{className:"mt-4 text-[11px] uppercase tracking-[0.16em] text-white/40",children:c.nextTaskTitle?t("common.goalDetail.nextMove",{value:c.nextTaskTitle}):t("common.goalDetail.addNextTask")})]},c.id))})]}),e.jsx("div",{className:"grid min-w-0 gap-5",children:e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.goalDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(re,{kind:"goal",compact:!0,gradient:!1}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t("common.goalDetail.progressTitle",{progress:h.progress,count:h.completedTasks})}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t("common.goalDetail.progressDetail",{xp:h.earnedPoints})}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t(l.length===1?"common.goalDetail.heroBadgeOne":"common.goalDetail.heroBadgeOther",{count:l.length})})]}),e.jsxs("div",{className:"mt-4 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:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.goalDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[h.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.goalDetail.fieldCompletedTasks")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:h.completedTasks})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.goalDetail.fieldXpBanked")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:h.earnedPoints})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",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/42",children:t("common.goalDetail.signalNext")}),d?e.jsx(re,{kind:"project",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(d==null?void 0:d.title)??t("common.goalDetail.noProject")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:d!=null&&d.nextTaskTitle?t("common.goalDetail.nextMove",{value:d.nextTaskTitle}):(d==null?void 0:d.description)||t("common.goalDetail.noProjectDetail")})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:t("common.goalDetail.signalRisk")}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(u==null?void 0:u.title)??t("common.goalDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(u==null?void 0:u.summary)||t("common.goalDetail.noRiskDetail")})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:t("common.goalDetail.signalEvidence")}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(b==null?void 0:b.title)??t("common.goalDetail.noEvidence")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(b==null?void 0:b.description)||t("common.goalDetail.noEvidenceDetail")})]})]})]})]})})]}),e.jsx(Ps,{entityType:"goal",entityId:h.id,title:"Goal notes",description:"Use notes to capture strategy changes, meaning shifts, and progress context that belongs at the goal level."}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.goalDetail.sectionEvidence")}),f.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.goalDetail.noEvidenceLogged")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:f.slice(0,6).map(c=>e.jsxs(xe,{to:dt(c)??`/activity?eventId=${c.id}`,className:"rounded-[18px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsx("div",{className:"font-medium text-white",children:Ls(c)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:Ms(c)})]},c.id))})]}),e.jsx(ha,{open:r,editingGoal:h,tags:s.snapshot.tags,onOpenChange:i,onSubmit:async(c,j)=>{j&&await s.patchGoal(j,c)}}),e.jsx(ua,{open:n,goals:s.snapshot.goals,editingProject:null,initialGoalId:h.id,onOpenChange:o,onSubmit:async c=>{await s.createProject(c)}})]})}function Fe({entityType:t,entityId:s,count:a,className:r=""}){const i=qn(t,s);return i?e.jsxs(xe,{to:i,className:`inline-flex min-h-10 items-center gap-2 rounded-full border border-white/10 bg-white/[0.05] px-3 py-2 text-xs text-white/72 transition hover:bg-white/[0.09] hover:text-white ${r}`,onClick:n=>n.stopPropagation(),children:[e.jsx(sa,{className:"size-3.5"}),Fn(a)]}):null}function od({goals:t,tags:s,pending:a=!1,onCreate:r,onUpdate:i}){const[n,o]=y.useState(!1),[h,l]=y.useState(null),x=t.find(g=>g.id===h)??null;return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Goal arcs"}),e.jsx("h3",{className:"mt-2 font-display text-3xl text-white",children:"Strategic arcs before tickets"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-white/60",children:"This is the long-horizon map. Each arc shows why it matters, how much ground has been covered, and which project should move next."})]}),e.jsx(X,{onClick:()=>{l(null),o(!0)},children:"Create goal"})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-2",children:[t.length===0?e.jsx("div",{className:"rounded-[24px] bg-white/[0.04] p-5 text-sm leading-7 text-white/60 xl:col-span-2",children:"Start with a life goal. Once the destination is clear, you can attach projects and then fill those projects with tasks."}):null,t.map(g=>{const f=`${Math.max(6,Math.min(100,g.progress))}%`;return e.jsxs(xe,{to:`/goals/${g.id}`,className:"rounded-[24px] border border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.06),rgba(255,255,255,0.03))] p-4 transition hover:bg-[linear-gradient(180deg,rgba(255,255,255,0.09),rgba(255,255,255,0.04))]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(re,{kind:"goal",compact:!0,gradient:!1}),e.jsx("div",{className:"mt-2",children:e.jsx(ue,{kind:"goal",label:g.title,variant:"heading",size:"lg",showKind:!1})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/58",children:g.description||"No strategic note attached yet."})]}),e.jsx("button",{className:"rounded-full bg-white/6 p-2 text-white/60 transition hover:bg-white/10 hover:text-white",type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),l(g.id),o(!0)},children:e.jsx(Or,{className:"size-4"})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(B,{className:"bg-white/[0.08] text-white/70",children:g.horizon}),e.jsx(B,{className:g.status==="active"?"text-emerald-300":g.status==="paused"?"text-amber-300":"text-[var(--tertiary)]",children:g.status}),e.jsxs(B,{className:"bg-white/[0.08] text-white/70",children:[g.earnedPoints," / ",g.targetPoints," xp"]}),e.jsxs(B,{className:"bg-white/[0.08] text-white/70",children:[g.totalTasks," tasks"]})]}),e.jsx("div",{className:"mt-4 h-1.5 rounded-full bg-white/[0.08]",children:e.jsx("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,var(--primary)_0%,var(--secondary)_100%)]",style:{width:f}})}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:g.tags.map(d=>e.jsx(B,{className:"bg-white/[0.06] text-white/58",children:d.name},d.id))}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 text-[11px] uppercase tracking-[0.16em] text-white/42",children:[e.jsx("span",{children:g.momentumLabel}),e.jsxs("span",{className:"inline-flex items-center gap-2",style:{color:g.themeColor},children:["Open arc",e.jsx(vt,{className:"size-3.5"})]})]})]},g.id)})]})]}),e.jsx(ha,{open:n,pending:a,editingGoal:x,tags:s,onOpenChange:g=>{o(g),g||l(null)},onSubmit:async(g,f)=>{if(f){await i(f,g);return}await r(g)}})]})}function ld(){const t=Le(),s=t.snapshot.dashboard.goals.length>0,a=new Map(t.snapshot.dashboard.goals.map(r=>[r.id,t.snapshot.dashboard.projects.filter(i=>i.goalId===r.id)]));return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"goal",title:e.jsx(ue,{kind:"goal",label:"Life Goals",variant:"heading",size:"lg"}),titleText:"Life Goals",description:"Life goals are the destinations you care about over the long run. Each one can hold several projects, and those projects turn direction into real work.",badge:`${t.snapshot.dashboard.goals.length} active goals`,actions:s?e.jsxs("div",{className:"inline-flex min-h-10 items-center rounded-full border border-white/8 bg-white/[0.04] px-4 py-2 text-sm whitespace-nowrap text-white/68",children:[t.snapshot.dashboard.projects.length," live project",t.snapshot.dashboard.projects.length===1?"":"s"," attached"]}):null}),e.jsx(od,{goals:t.snapshot.dashboard.goals,tags:t.snapshot.tags,onCreate:t.createGoal,onUpdate:t.patchGoal}),s?null:e.jsx(Xe,{eyebrow:"Life goals",title:"No life goals yet",description:"Define the first long-horizon direction above so Forge can attach projects, tasks, momentum, and evidence to something meaningful."}),s?e.jsx("div",{className:"grid gap-4",children:t.snapshot.dashboard.goals.map(r=>{const i=a.get(r.id)??[],n=Be(t.snapshot.dashboard.notesSummaryByEntity,"goal",r.id);return e.jsx(xe,{to:`/goals/${r.id}`,className:"rounded-[28px] border border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.03))] p-4 transition hover:bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.04))] sm:p-5",children:e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)] xl:gap-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.tags.slice(0,3).map(o=>e.jsx(B,{className:"bg-white/[0.08]",style:{color:o.color},children:o.name},o.id)),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:r.horizon})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ue,{kind:"goal",label:r.title,variant:"heading",size:"xl"})}),e.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-7 text-white/58",children:r.description}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Progress"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[r.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Tasks done"}),e.jsxs("div",{className:"mt-2 text-xl text-white",children:[r.completedTasks,"/",Math.max(r.totalTasks,1)]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"XP banked"}),e.jsx("div",{className:"mt-2 text-xl text-white",children:r.earnedPoints})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:r.progress})}),e.jsx("div",{className:"mt-4",children:e.jsx(Fe,{entityType:"goal",entityId:r.id,count:n.count})})]}),e.jsxs("div",{className:"rounded-[24px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:"Projects carrying this direction"}),e.jsx("div",{className:"text-sm text-white/48",children:i.length})]}),i.length===0?e.jsx("div",{className:"mt-4 text-sm leading-6 text-white/56",children:"No live project is attached yet. Create one so this direction starts producing visible work."}):e.jsx("div",{className:"mt-4 grid gap-3",children:i.slice(0,3).map(o=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.05] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(re,{kind:"project",compact:!0,gradient:!1}),e.jsx(ue,{kind:"project",label:o.title,className:"min-w-0",showIcon:!1})]}),e.jsx(B,{children:o.status})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:o.description}),e.jsxs("div",{className:"mt-3 text-sm text-white/42",children:["Next move: ",o.nextTaskTitle??"Define the first attached task"]})]},o.id))})]})]})},r.id)})}):e.jsx(Y,{children:e.jsx("div",{className:"rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:"Goal cards will appear here once the first long-horizon direction is created."})})]})}const dd={title:"",description:"",owner:"Albert",goalId:"",projectId:"",priority:"medium",status:"focus",effort:"deep",energy:"steady",dueDate:"",points:60,tagIds:[]},cd={goalId:"",title:"",description:"",status:"active",targetPoints:240,themeColor:"#c0c1ff"},md={title:"",description:"",horizon:"year",status:"active",targetPoints:400,themeColor:"#c8a46b",tagIds:[]},hd=["goal","project","task","tag","note","insight","psyche_value","behavior_pattern","behavior","belief_entry","mode_profile","mode_guide_session","event_type","emotion_definition","trigger_report"];function ud(t){return t!==null&&hd.includes(t)}function wa(t,s,a=96){const r=t.trim()||s.trim();return r.length<=a?r:`${r.slice(0,a-1).trimEnd()}…`}function pd(t){return[t.summary.trim(),t.rationale.trim()?`Why it matters: ${t.rationale.trim()}`:""].filter(Boolean).join(`
|
|
4
|
+
|
|
5
|
+
`)}function ja(t){return!ud(t.entityType)||!t.entityId?null:{entityType:t.entityType,entityId:t.entityId,anchorKey:null}}function zn(t,s,a){var r,i;return t.entityType==="goal"&&t.entityId?t.entityId:t.entityType==="project"&&t.entityId?((r=s.find(n=>n.id===t.entityId))==null?void 0:r.goalId)??"":t.entityType==="task"&&t.entityId?((i=a.find(n=>n.id===t.entityId))==null?void 0:i.goalId)??"":""}function xd(t,s){var a;return t.entityType==="project"&&t.entityId?t.entityId:t.entityType==="task"&&t.entityId?((a=s.find(r=>r.id===t.entityId))==null?void 0:a.projectId)??"":""}function Kn(t,s,a){const r=[];return a.length>0&&r.push("task"),s.length>0&&r.push("project"),r.push("goal"),ja(t)&&r.push("note"),r}function gd(t,s,a){const r=Kn(t,s,a);return r.includes("task")&&(t.entityType==="task"||t.entityType==="project")?"task":r.includes("project")&&t.entityType==="goal"?"project":r[0]??"goal"}function bd(t,s,a){var h,l,x;const r=zn(t,s,a),n=xd(t,a)||(r?((h=s.find(g=>g.goalId===r))==null?void 0:h.id)??"":"")||((l=s[0])==null?void 0:l.id)||"",o=n?((x=s.find(g=>g.id===n))==null?void 0:x.goalId)??r:r;return{...dd,title:wa(t.recommendation,t.title),description:pd(t),goalId:o,projectId:n}}function fd(t,s,a,r){var o;const n=zn(t,a,r)||((o=s[0])==null?void 0:o.id)||"";return{...cd,goalId:n,title:wa(t.title,t.recommendation),description:`${t.summary.trim()}
|
|
6
|
+
|
|
7
|
+
Recommendation: ${t.recommendation.trim()}`.trim()}}function vd(t){return{...md,title:wa(t.title,t.recommendation),description:`${t.summary.trim()}
|
|
8
|
+
|
|
9
|
+
Recommendation: ${t.recommendation.trim()}`.trim()}}function yd(t){return[`## ${t.title.trim()}`,"",t.summary.trim(),"","### Recommendation","",t.recommendation.trim(),t.rationale.trim()?"":null,t.rationale.trim()?"### Why this matters":null,t.rationale.trim()||null].filter(s=>!!s).join(`
|
|
10
|
+
`)}function $i(t,s,a,r){return{kind:gd(t,s,a),task:bd(t,a,r),project:fd(t,s,a,r),goal:vd(t),noteMarkdown:yd(t)}}function wd(t){switch(t){case"task":return{label:"Task",description:"Turn the recommendation into one concrete next move."};case"project":return{label:"Project",description:"Start a larger initiative when the insight needs a stream of work."};case"goal":return{label:"Goal",description:"Capture a new long-term direction when this changes strategy."};case"note":return{label:"Linked note",description:"Attach the recommendation as durable evidence without creating new work."}}}function jd({open:t,onOpenChange:s,insight:a,goals:r,projects:i,tasks:n,tags:o,pending:h=!1,onSubmit:l}){const x=y.useMemo(()=>Kn(a,r,i),[r,a,i]),g=y.useMemo(()=>ja(a),[a]),[f,d]=y.useState(()=>$i(a,r,i,n)),[u,b]=y.useState(null),[c,j]=y.useState({});y.useEffect(()=>{t&&(d($i(a,r,i,n)),b(null),j({}))},[r,a,t,i,n]);const k=f.task.projectId?i.find(N=>N.id===f.task.projectId)??null:null;y.useEffect(()=>{k&&f.task.goalId!==k.goalId&&d(N=>({...N,task:{...N.task,goalId:k.goalId}}))},[f.task.goalId,k]);const $=f.project.goalId?r.find(N=>N.id===f.project.goalId)??null:null,M=y.useMemo(()=>{var N,m,w;if(!g)return null;switch(g.entityType){case"goal":return((N=r.find(L=>L.id===g.entityId))==null?void 0:N.title)??"Linked goal";case"project":return((m=i.find(L=>L.id===g.entityId))==null?void 0:m.title)??"Linked project";case"task":return((w=n.find(L=>L.id===g.entityId))==null?void 0:w.title)??"Linked task";default:return`${g.entityType.replaceAll("_"," ")}`}},[r,i,g,n]),I=[{id:"kind",eyebrow:"Apply",title:"Choose what this insight should become",description:"Accept means you agree with the recommendation. Apply means you turn it into a real record right now.",render:(N,m)=>e.jsx(q,{label:"Apply as",description:"Pick the kind of record Forge should create from this recommendation.",hint:"Task is the best default when the insight points to a concrete next move.",children:e.jsx(Re,{value:N.kind,onChange:w=>m({kind:w}),options:x.map(w=>({value:w,...wd(w)})),columns:x.length>=3?3:2})})},{id:"details",eyebrow:"Details",title:"Review the record Forge will create",description:"The fields are prefilled from the insight, but you can tighten them before saving.",render:(N,m)=>N.kind==="task"?e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Task title",error:c.title??null,children:e.jsx(ae,{value:N.task.title,onChange:w=>m({task:{...N.task,title:w.target.value}}),placeholder:"Turn the recommendation into a task"})}),e.jsx(q,{label:"Description",children:e.jsx(le,{value:N.task.description,onChange:w=>m({task:{...N.task,description:w.target.value}}),placeholder:"Add the operational context for this task."})}),e.jsx(q,{label:"Project",error:c.projectId??null,children:e.jsx("div",{className:"grid gap-3",children:i.map(w=>{const L=w.id===N.task.projectId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${L?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>m({task:{...N.task,projectId:w.id,goalId:w.goalId}}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"font-medium",children:w.title}),e.jsx(re,{kind:"goal",label:w.goalTitle,compact:!0,gradient:!1})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:w.description||"No project note attached yet."})]},w.id)})})}),e.jsx(q,{label:"Owner",error:c.owner??null,children:e.jsx(ae,{value:N.task.owner,onChange:w=>m({task:{...N.task,owner:w.target.value}}),placeholder:"Albert"})}),e.jsx(q,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(w=>{const L=N.task.tagIds.includes(w.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${L?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>m({task:{...N.task,tagIds:L?N.task.tagIds.filter(S=>S!==w.id):[...N.task.tagIds,w.id]}}),children:w.name},w.id)})})})]}):N.kind==="project"?e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Project title",error:c.title??null,children:e.jsx(ae,{value:N.project.title,onChange:w=>m({project:{...N.project,title:w.target.value}}),placeholder:"Turn the insight into a project"})}),e.jsx(q,{label:"Description",children:e.jsx(le,{value:N.project.description,onChange:w=>m({project:{...N.project,description:w.target.value}}),placeholder:"Describe the initiative this insight points to."})}),e.jsx(q,{label:"Goal",error:c.goalId??null,children:e.jsx("div",{className:"grid gap-3",children:r.map(w=>{const L=w.id===N.project.goalId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${L?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>m({project:{...N.project,goalId:w.id}}),children:[e.jsx("div",{className:"font-medium",children:w.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:w.description||"No strategic note attached yet."})]},w.id)})})}),$?e.jsxs(lt,{children:["This project will sit under the “",$.title,"” goal."]}):null]}):N.kind==="goal"?e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Goal title",error:c.title??null,children:e.jsx(ae,{value:N.goal.title,onChange:w=>m({goal:{...N.goal,title:w.target.value}}),placeholder:"Turn the insight into a life goal"})}),e.jsx(q,{label:"Description",children:e.jsx(le,{value:N.goal.description,onChange:w=>m({goal:{...N.goal,description:w.target.value}}),placeholder:"Describe the strategic direction this insight suggests."})}),e.jsx(q,{label:"Tags",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(w=>{const L=N.goal.tagIds.includes(w.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${L?"bg-white/16 text-white":"bg-white/6 text-white/58 hover:bg-white/10 hover:text-white"}`,onClick:()=>m({goal:{...N.goal,tagIds:L?N.goal.tagIds.filter(S=>S!==w.id):[...N.goal.tagIds,w.id]}}),children:w.name},w.id)})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked note",description:"This stores the insight as durable Markdown evidence on the linked entity instead of creating a new work item.",hint:M?`This note will attach to ${M}.`:void 0,children:e.jsx(le,{value:N.noteMarkdown,onChange:w=>m({noteMarkdown:w.target.value}),placeholder:"Write the applied note content in Markdown",className:"min-h-64"})}),M?e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm text-white/70",children:["Linked target: ",e.jsx("span",{className:"font-medium text-white",children:M})]}):null]})}];return e.jsx(qe,{open:t,onOpenChange:s,eyebrow:"Apply insight",title:"Turn this insight into a real record",description:"Apply should create something concrete inside Forge, not just change the status label.",value:f,onChange:d,steps:I,submitLabel:"Apply insight",pending:h,error:u,onSubmit:async()=>{b(null),j({});try{if(f.kind==="task"){const N=yn.safeParse(f.task);if(!N.success){j(Object.fromEntries(Object.entries(N.error.flatten().fieldErrors).map(([m,w])=>[m,w==null?void 0:w[0]]))),b("This applied task still needs a valid title, project, and owner.");return}await l({kind:"task",input:N.data}),s(!1);return}if(f.kind==="project"){const N=vn.safeParse(f.project);if(!N.success){j(Object.fromEntries(Object.entries(N.error.flatten().fieldErrors).map(([m,w])=>[m,w==null?void 0:w[0]]))),b("This applied project still needs a valid title and goal.");return}await l({kind:"project",input:N.data}),s(!1);return}if(f.kind==="goal"){const N=fn.safeParse(f.goal);if(!N.success){j(Object.fromEntries(Object.entries(N.error.flatten().fieldErrors).map(([m,w])=>[m,w==null?void 0:w[0]]))),b("This applied goal still needs a valid title and target.");return}await l({kind:"goal",input:N.data}),s(!1);return}if(!f.noteMarkdown.trim()){b("The linked note needs Markdown content before it can be saved.");return}if(!g){b("This insight is not attached to a specific entity yet, so Forge cannot place a linked note for it.");return}await l({kind:"note",input:{contentMarkdown:f.noteMarkdown.trim()}}),s(!1)}catch(N){b(N instanceof Error?N.message:"Unable to apply this insight right now.")}}})}function Fi(t,s){return{originType:(t==null?void 0:t.originType)??"user",originAgentId:(t==null?void 0:t.originAgentId)??"",originLabel:(t==null?void 0:t.originLabel)??"",entityType:(s==null?void 0:s.entityType)??(t==null?void 0:t.entityType)??"",entityId:(s==null?void 0:s.entityId)??(t==null?void 0:t.entityId)??"",timeframeLabel:(t==null?void 0:t.timeframeLabel)??"This week",title:(t==null?void 0:t.title)??"",summary:(t==null?void 0:t.summary)??"",recommendation:(t==null?void 0:t.recommendation)??"",rationale:(t==null?void 0:t.rationale)??"",confidence:(t==null?void 0:t.confidence)??.72,ctaLabel:(t==null?void 0:t.ctaLabel)??"Review insight",targetKind:(s==null?void 0:s.entityType)??(t==null?void 0:t.entityType)??"general"}}function Xn({open:t,onOpenChange:s,title:a="Store insight",description:r="Capture a clear observation, its recommendation, and where it belongs without dropping into a raw admin form.",eyebrow:i="Insight",pending:n=!1,submitLabel:o="Store insight",initialValue:h,lockedEntity:l,entityCandidates:x=[],onSubmit:g}){const[f,d]=y.useState(()=>Fi(h,l)),[u,b]=y.useState(null);y.useEffect(()=>{t&&(d(Fi(h,l)),b(null))},[h,l,t]);const c=y.useMemo(()=>{const $=new Set(["general"]);return x.forEach(M=>$.add(M.entityType)),l&&$.add(l.entityType),Array.from($)},[x,l]),j=x.filter($=>$.entityType===f.targetKind),k=[{id:"focus",eyebrow:"Focus",title:"Name the insight and place it in the right context",description:"Start with the main observation, then decide whether this belongs to a specific entity or should stay general.",render:($,M)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Insight title",description:"Write the main idea as a clear headline.",labelHelp:"The title should sound like the recommendation or realization you want to remember, not like an internal database field.",children:e.jsx(ae,{value:$.title,onChange:I=>M({title:I.target.value}),placeholder:"Weekly review needs a tighter end ritual"})}),e.jsx(q,{label:"Timeframe",description:"Keep the horizon short and readable.",children:e.jsx(ae,{value:$.timeframeLabel,onChange:I=>M({timeframeLabel:I.target.value}),placeholder:"This week"})}),e.jsx(q,{label:"Where should this insight live?",description:"Use a specific entity when the insight is about one goal, project, task, or report. Keep it general when it applies to the wider system.",children:l?e.jsxs("div",{className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx(re,{kind:l.kind,label:l.label}),l.description?e.jsx(lt,{className:"mt-2",children:l.description}):null]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{value:$.targetKind,onChange:I=>M({targetKind:I,entityType:I==="general"?"":I,entityId:""}),options:c.map(I=>({value:I,label:I==="general"?"General insight":I==="trigger_report"?"Report":I.charAt(0).toUpperCase()+I.slice(1),description:I==="general"?"Store it in the broader insight feed.":`Attach it to a specific ${I==="trigger_report"?"report":I}.`})),columns:c.length>=3?3:2}),$.targetKind!=="general"?j.length>0?e.jsx("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:j.map(I=>{const N=$.entityType===I.entityType&&$.entityId===I.entityId;return e.jsxs("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${N?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.07]"}`,onClick:()=>M({entityType:I.entityType,entityId:I.entityId}),children:[e.jsx(re,{kind:I.kind,label:I.label,compact:!0}),I.description?e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/54",children:I.description}):null]},`${I.entityType}:${I.entityId}`)})}):e.jsxs(lt,{className:"mt-4",children:["No ",$.targetKind==="trigger_report"?"reports":`${$.targetKind}s`," are ready to attach here yet."]}):null]})})]})},{id:"observation",eyebrow:"Observation",title:"Capture what you are seeing clearly",description:"Keep the summary plain and useful. Add the why only if it helps the next action make sense.",render:($,M)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Summary",description:"Describe the pattern, problem, or opportunity in plain language.",labelHelp:"Write what is actually happening, not a slogan and not a long essay.",children:e.jsx(le,{value:$.summary,onChange:I=>M({summary:I.target.value}),placeholder:"The weekly review loses energy because the close-out is vague, so finished work never turns into clear next moves."})}),e.jsx(q,{label:"Why this matters",description:"Optional context that helps explain the recommendation.",children:e.jsx(le,{value:$.rationale,onChange:I=>M({rationale:I.target.value}),placeholder:"When the close-out is loose, important wins disappear from memory and the next week starts without momentum."})})]})},{id:"move",eyebrow:"Next move",title:"Turn the insight into a recommendation",description:"Finish with the recommendation you want the user or agent to actually act on.",render:($,M)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Recommendation",description:"Write the concrete move this insight points toward.",labelHelp:"A recommendation should be actionable. If the user read only this line, they should know what to do next.",children:e.jsx(le,{value:$.recommendation,onChange:I=>M({recommendation:I.target.value}),placeholder:"Add a fixed five-minute close-out block that turns finished tasks into one sentence of evidence and one next move."})}),e.jsx(q,{label:"Confidence",description:"Choose how strongly this recommendation holds up right now.",children:e.jsx(Re,{value:String($.confidence),onChange:I=>M({confidence:Number(I)}),options:[{value:"0.55",label:"Low",description:"Useful hunch, still early."},{value:"0.72",label:"Medium",description:"Solid pattern, worth acting on."},{value:"0.88",label:"High",description:"Clear enough to trust strongly."}],columns:3})})]})}];return e.jsx(qe,{open:t,onOpenChange:s,eyebrow:i,title:a,description:r,value:f,onChange:d,steps:k,submitLabel:o,pending:n,error:u,onSubmit:async()=>{b(null);const $=zo.safeParse({originType:f.originType,originAgentId:f.originAgentId,originLabel:f.originLabel,entityType:f.targetKind==="general"?"":f.entityType,entityId:f.targetKind==="general"?"":f.entityId,timeframeLabel:f.timeframeLabel,title:f.title,summary:f.summary,recommendation:f.recommendation,rationale:f.rationale,confidence:f.confidence,ctaLabel:f.ctaLabel});if(!$.success){b("This insight still needs a title, a summary, and a recommendation before it can be stored.");return}try{await g($.data),s(!1)}catch(M){b(M instanceof Error?M.message:"Unable to store this insight right now.")}}})}function kd(){var $,M,I,N;const t=Pe(),s=Ve(),{snapshot:a}=Le(),[r,i]=y.useState(!1),[n,o]=y.useState(null),h=te({queryKey:["forge-insights"],queryFn:nl}),l=de({mutationFn:Mn,onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),x=de({mutationFn:({insightId:m,feedbackType:w})=>Ai(m,w),onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),g=de({mutationFn:({insightId:m})=>bl(m),onMutate:async({insightId:m})=>{await t.cancelQueries({queryKey:["forge-insights"]});const w=t.getQueryData(["forge-insights"]);if(w){const L=w.insights.feed.find(S=>S.id===m);t.setQueryData(["forge-insights"],{insights:{...w.insights,feed:w.insights.feed.filter(S=>S.id!==m),openCount:(L==null?void 0:L.status)==="open"?Math.max(0,w.insights.openCount-1):w.insights.openCount}})}return{previous:w}},onError:(m,w,L)=>{L!=null&&L.previous&&t.setQueryData(["forge-insights"],L.previous)},onSettled:async()=>{await t.invalidateQueries({queryKey:["forge-insights"]})}}),f=de({mutationFn:async({insight:m,submission:w})=>{let L=null,S="Applied the insight.";if(w.kind==="task"){const O=await ea(w.input);L=`/tasks/${O.task.id}`,S=`Created task: ${O.task.title}`}else if(w.kind==="project"){const O=await An(w.input);L=`/projects/${O.project.id}`,S=`Created project: ${O.project.title}`}else if(w.kind==="goal"){const O=await En(w.input);L=`/goals/${O.goal.id}`,S=`Created goal: ${O.goal.title}`}else{const O=ja(m);if(!O)throw new Error("This insight is not linked to a concrete entity yet, so Forge cannot attach a linked note to it.");await Ln({contentMarkdown:w.input.contentMarkdown,links:[O]}),L=qn(O.entityType,O.entityId),S="Created a linked note from the insight."}return await Ai(m.id,"applied",S),{href:L}},onSuccess:async({href:m})=>{await Promise.all([t.invalidateQueries({queryKey:["forge-insights"]}),t.invalidateQueries({queryKey:["forge-snapshot"]}),t.invalidateQueries({queryKey:["forge-xp-metrics"]}),t.invalidateQueries({queryKey:["forge-reward-ledger"]}),t.invalidateQueries({queryKey:["notes-index"]})]),o(null),m&&s(m)}}),d=($=h.data)==null?void 0:$.insights,u=y.useMemo(()=>[...a.goals.slice(0,8).map(m=>({entityType:"goal",entityId:m.id,kind:"goal",label:m.title,description:m.description})),...a.projects.slice(0,8).map(m=>({entityType:"project",entityId:m.id,kind:"project",label:m.title,description:m.goalTitle})),...a.tasks.slice(0,10).map(m=>({entityType:"task",entityId:m.id,kind:"task",label:m.title,description:m.status.replaceAll("_"," ")}))],[a.goals,a.projects,a.tasks]),b=x.isPending?((M=x.variables)==null?void 0:M.insightId)??null:null,c=g.isPending?((I=g.variables)==null?void 0:I.insightId)??null:null,j=f.isPending?((N=f.variables)==null?void 0:N.insight.id)??null:null,k=a.metrics.topGoalId?a.goals.find(m=>m.id===a.metrics.topGoalId)??null:null;return h.isLoading?e.jsx(Qe,{eyebrow:"Insights",title:"Loading the insight feed",description:"Pulling coaching, momentum analysis, and stored recommendations."}):h.isError||!d?e.jsx(je,{eyebrow:"Insights",error:h.error,onRetry:()=>void t.invalidateQueries({queryKey:["forge-insights"]})}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{title:"Insights",description:"Save useful advice from you or your agent, review what seems worth acting on, and turn the good ones into real work when the timing is right.",badge:`${d.openCount} open`,actions:e.jsx(X,{onClick:()=>i(!0),children:"Store insight"})}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Momentum analysis"}),e.jsx("div",{className:"mt-4 grid grid-cols-5 gap-2 sm:grid-cols-10",children:d.momentumHeatmap.map(m=>e.jsxs("div",{className:"rounded-[16px] bg-white/[0.04] p-3",children:[e.jsx("div",{className:"h-12 rounded-[12px]",style:{background:m.intensity>=4?"rgba(192,193,255,0.95)":m.intensity===3?"rgba(192,193,255,0.7)":m.intensity===2?"rgba(192,193,255,0.45)":m.intensity===1?"rgba(192,193,255,0.2)":"rgba(255,255,255,0.05)"}}),e.jsx("div",{className:"mt-2 text-[10px] uppercase tracking-[0.16em] text-white/40",children:m.label})]},m.id))})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Execution trends"}),e.jsx(Ne,{content:"The lavender series tracks completed XP by time window. The green series tracks execution pressure from focused and completed work. Read them together to see whether visible output and active work are moving in sync.",label:"Explain execution trends"})]}),e.jsx("div",{className:"mt-4 h-72 min-w-0",children:e.jsx(pn,{width:"100%",height:"100%",minWidth:280,minHeight:288,children:e.jsxs(xo,{data:d.executionTrends,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"insight-xp",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#c0c1ff",stopOpacity:"0.8"}),e.jsx("stop",{offset:"100%",stopColor:"#c0c1ff",stopOpacity:"0.08"})]})}),e.jsx(xn,{dataKey:"label",tick:{fill:"rgba(255,255,255,0.42)",fontSize:11}}),e.jsx(gn,{hide:!0}),e.jsx(bi,{dataKey:"xp",stroke:"#c0c1ff",fill:"url(#insight-xp)",strokeWidth:2}),e.jsx(bi,{dataKey:"focusScore",stroke:"#4edea3",fill:"rgba(78,222,163,0.06)",strokeWidth:2})]})})}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#c0c1ff]"}),e.jsx("span",{children:"Completed XP"}),e.jsx(Ne,{content:"Completed XP is the reward Forge logged for finished work in each time window. It helps you see whether things are actually getting finished, not just started.",label:"Explain completed XP"})]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.04] px-3 py-2 text-sm text-white/64",children:[e.jsx("span",{className:"size-2.5 rounded-full bg-[#4edea3]"}),e.jsx("span",{children:"Focus score"}),e.jsx(Ne,{content:"Focus score is Forge's rough read of how much active execution pressure was present in each window, based on focused and completed work.",label:"Explain focus score"})]})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/54",children:"Use this chart to spot whether finished output and active deep-work pressure are rising together or starting to drift apart."})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"bg-white/[0.08] text-white/60",children:"Deterministic coaching"}),e.jsx(Ne,{content:"This is Forge's built-in coaching read. It looks at your overdue work, blocked work, current goal pressure, and recent evidence to produce one grounded recommendation from the actual operating record.",label:"Explain deterministic coaching"})]}),e.jsx("h2",{className:"mt-4 font-display text-4xl text-white",children:d.coaching.title}),e.jsx("p",{className:"mt-4 text-sm leading-7 text-white/60",children:"Forge turns the current state of your goals, projects, tasks, and recent evidence into one focused operating read instead of a vague motivational hint."}),e.jsxs("div",{className:"mt-4 rounded-[18px] border border-white/8 bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Current read"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/72",children:d.coaching.summary})]}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-[radial-gradient(circle_at_top_left,rgba(192,193,255,0.14),transparent_45%),rgba(255,255,255,0.03)] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Recommendation"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:d.coaching.recommendation}),k?e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"rounded-full bg-white/[0.06] px-3 py-2 text-sm text-white/64",children:["Connected goal: ",e.jsx("span",{className:"font-medium text-white",children:k.title})]}),e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>s(`/goals/${k.id}`),children:"Open goal"})]}):null]})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Store insight"}),e.jsxs("div",{className:"mt-4 rounded-[22px] bg-white/[0.04] p-5",children:[e.jsx("div",{className:"font-medium text-white",children:"Capture advice without forcing it into a task too early"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/60",children:"Insights are saved suggestions from you or your agent. Use them when something feels worth remembering, but it is not ready to become a goal, project, or task yet."}),e.jsx("div",{className:"mt-4",children:e.jsx(X,{onClick:()=>i(!0),children:"Store insight"})})]})]}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Stored insights"}),e.jsx("div",{className:"mt-4 grid gap-3",children:d.feed.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No stored insights yet."}):d.feed.map(m=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:m.title}),e.jsx("div",{className:"mt-1 text-sm text-white/56",children:m.summary})]}),e.jsx(B,{className:"text-white/70",children:m.status})]}),e.jsx("div",{className:"mt-3 text-sm text-white/58",children:m.recommendation}),e.jsxs("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:[m.originLabel??m.originType," · confidence ",Math.round(m.confidence*100),"%"]}),m.status==="applied"?e.jsx("div",{className:"mt-4 rounded-[16px] border border-emerald-400/18 bg-emerald-400/8 px-4 py-3 text-sm text-emerald-100/88",children:"This insight has already been turned into a real Forge record, so it stays here as a trace of what happened."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4 text-sm text-white/52",children:m.status==="accepted"?"Accepted means this feels useful and worth keeping in view. Apply turns it into a real goal, project, task, or note when you are ready.":"Accept keeps this advice on the board. Apply turns it into a real Forge record now. Dismiss deletes it from the list."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[m.status!=="accepted"?e.jsx(X,{variant:"secondary",pending:b===m.id,onClick:()=>void x.mutateAsync({insightId:m.id,feedbackType:"accepted"}),children:"Accept"}):null,e.jsx(X,{pending:j===m.id,onClick:()=>o(m),children:"Apply"}),e.jsx(X,{variant:"ghost",pending:c===m.id,onClick:()=>void g.mutateAsync({insightId:m.id}),children:"Dismiss"})]})]})]},m.id))})]})]})]}),e.jsx(Xn,{open:r,onOpenChange:i,entityCandidates:u,pending:l.isPending,onSubmit:async m=>{await l.mutateAsync(m)}}),n?e.jsx(jd,{open:!!n,onOpenChange:m=>{m||o(null)},insight:n,goals:a.goals,projects:a.projects,tasks:a.tasks,tags:a.tags,pending:f.isPending,onSubmit:async m=>{await f.mutateAsync({insight:n,submission:m})}}):null]})}const Ye=["backlog","focus","in_progress","blocked","done"];function Gn(t){return t.startsWith("lane:")||t.includes(":lane:")}function Nd(t){var s,a;return((a=(s=t.data)==null?void 0:s.current)==null?void 0:a.type)==="lane"||Gn(String(t.id))}function Td(t,s){const a=Math.max(0,Math.min(t.right,s.right)-Math.max(t.left,s.left)),r=Math.max(0,Math.min(t.bottom,s.bottom)-Math.max(t.top,s.top));return a*r}const Sd=t=>{const s=jo(t),a=s.find(n=>Gn(String(n.id)));if(a)return[a];const i=t.droppableContainers.filter(n=>Nd(n)).map(n=>{const o=t.droppableRects.get(n.id);if(!o)return null;const h=Td(t.collisionRect,o);return h<=0?null:{id:n.id,data:{droppableContainer:n,value:h}}}).filter(Boolean).sort((n,o)=>{var h,l;return(((h=o==null?void 0:o.data)==null?void 0:h.value)??0)-(((l=n==null?void 0:n.data)==null?void 0:l.value)??0)});return i.length>0?i:s.length>0?s:ko(t)};function Qn({task:t,goal:s,tags:a,isSelected:r,isDragging:i=!1,isOverlay:n=!1,style:o,setNodeRef:h,dragAttributes:l,dragListeners:x,isMobile:g=!1,onSelect:f,onStartTask:d,onQuickReopen:u,onStepTask:b,onOpenTask:c,onEditTask:j,notesSummaryByEntity:k}){const{t:$,formatDate:M}=Te(),I=Ye[Ye.indexOf(t.status)-1]??null,N=Ye[Ye.indexOf(t.status)+1]??null,m=Be(k,"task",t.id).count;return e.jsxs("article",{ref:h,style:o,className:Q("w-full max-w-full min-w-0 overflow-hidden rounded-[18px] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] transition cursor-grab active:cursor-grabbing",g&&"touch-none select-none",n&&"rotate-[0.5deg] bg-[linear-gradient(180deg,rgba(192,193,255,0.24),rgba(192,193,255,0.1))] shadow-[0_28px_80px_rgba(8,12,24,0.42),inset_0_0_0_1px_rgba(192,193,255,0.26)]",i&&!n&&"opacity-35 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.02)]",r?"bg-[linear-gradient(180deg,rgba(192,193,255,0.18),rgba(192,193,255,0.06))] shadow-[0_16px_40px_rgba(8,12,24,0.32),inset_0_0_0_1px_rgba(192,193,255,0.26)]":"bg-white/5"),"data-dragging":i?"true":"false","data-testid":`task-card-${t.id}`,onClick:()=>f(t.id),...l,...x,children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-2",children:[e.jsx(B,{className:"shrink-0 text-[11px] text-[var(--tertiary)]",children:t.priority}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j?e.jsx("button",{type:"button","aria-label":`Edit ${t.title}`,className:"inline-flex size-8 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white",onClick:w=>{w.preventDefault(),w.stopPropagation(),j(t.id)},children:e.jsx(us,{className:"size-3.5"})}):null,c?e.jsx("button",{type:"button","aria-label":`Open ${t.title} details`,className:"inline-flex size-8 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white",onClick:w=>{w.preventDefault(),w.stopPropagation(),c(t.id)},children:e.jsx(la,{className:"size-3.5"})}):null,g?e.jsxs("div",{className:"flex items-center gap-1",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{type:"button","aria-label":`Move ${t.title} to the previous lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!I,onClick:()=>{I&&(b==null||b(t.id,"previous"))},children:e.jsx(mn,{className:"size-3.5"})}),e.jsx("button",{type:"button","aria-label":`Move ${t.title} to the next lane`,className:"inline-flex size-7 items-center justify-center rounded-full bg-white/8 text-white/62 transition hover:bg-white/12 hover:text-white disabled:opacity-35",disabled:!N,onClick:()=>{N&&(b==null||b(t.id,"next"))},children:e.jsx(hn,{className:"size-3.5"})})]}):null,t.status!=="done"?e.jsx("button",{type:"button","aria-label":`Start work on ${t.title}`,className:"inline-flex size-8 items-center justify-center rounded-full bg-[var(--primary)]/16 text-[var(--primary)] transition hover:bg-[var(--primary)]/24",onClick:w=>{w.preventDefault(),w.stopPropagation(),d==null||d(t.id)},children:e.jsx(nt,{className:"size-4 fill-current"})}):null,e.jsxs("span",{className:"text-[11px] text-white/44",children:[t.points," xp"]})]})]}),e.jsx(ue,{kind:"task",label:t.title,className:"max-w-full",lines:3,labelClassName:"[overflow-wrap:anywhere]"}),e.jsx("p",{className:"mt-1.5 line-clamp-3 [overflow-wrap:anywhere] text-[12px] leading-5 text-white/62",children:t.description||$("common.executionBoard.noExecutionNote")}),e.jsxs("div",{className:"mt-2.5 flex min-w-0 flex-wrap gap-1.5",children:[s?e.jsx(re,{kind:"goal",label:s.title,compact:!0,wrap:!0,className:"min-w-0 max-w-full"}):null,e.jsx(Fe,{entityType:"task",entityId:t.id,count:m}),t.time.totalCreditedSeconds>0?e.jsxs(B,{className:"bg-white/8 text-white/72",children:[Math.floor(t.time.totalCreditedSeconds/60)," min"]}):null,t.time.activeRunCount>0?e.jsxs(B,{className:"bg-emerald-500/12 text-emerald-200",children:[t.time.activeRunCount," live"]}):null,a.slice(0,2).map(w=>e.jsx(B,{className:"bg-white/8",style:{color:w.color},children:w.name},w.id))]}),e.jsxs("div",{className:"mt-2.5 flex min-w-0 items-center justify-between gap-2 text-[11px] text-white/45",children:[e.jsxs("span",{className:"min-w-0 truncate",children:[t.effort," / ",t.energy]}),e.jsxs("div",{className:"flex min-w-0 shrink-0 items-center gap-2 text-right",children:[t.status==="done"&&u?e.jsx("button",{type:"button",className:"rounded-full bg-white/8 px-3 py-1 text-[10px] tracking-[0.16em] text-white transition hover:bg-white/12",onClick:w=>{w.preventDefault(),w.stopPropagation(),u(t.id)},children:$("common.executionBoard.reopen")}):null,e.jsx("span",{children:M(t.dueDate)})]})]})]})}function qi(t){const{task:s,sortableId:a}=t,{attributes:r,listeners:i,setNodeRef:n,transform:o,transition:h,isDragging:l}=So({id:a,data:{type:"task",taskId:s.id,status:s.status}});return e.jsx(Qn,{...t,setNodeRef:n,dragAttributes:r,dragListeners:i,isDragging:l,isMobile:t.isMobile,onStartTask:t.onStartTask,onStepTask:t.onStepTask,notesSummaryByEntity:t.notesSummaryByEntity,style:{transform:Co.Transform.toString(o),transition:h}})}function Bi({droppableId:t,status:s,title:a,detail:r,count:i,dragging:n,children:o}){const{setNodeRef:h,isOver:l}=To({id:t,data:{type:"lane",status:s}});return e.jsx("div",{ref:h,className:Q("w-full max-w-full min-w-0 overflow-hidden rounded-[24px] transition",l&&"scale-[1.005]"),"data-lane-id":s,"data-testid":`kanban-lane-${s}`,"data-lane-hover":l?"true":"false",children:e.jsxs(Y,{className:Q("h-full w-full max-w-full min-w-0 overflow-hidden p-3 transition-[background-color,box-shadow,border-color,transform]",n&&"border border-white/8",l?"border border-[rgba(125,211,252,0.38)] bg-[linear-gradient(180deg,rgba(125,211,252,0.12),rgba(125,211,252,0.05))] shadow-[0_18px_54px_rgba(14,165,233,0.12)]":"border border-transparent"),children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"type-label text-white/45",children:r}),e.jsx("h3",{className:"mt-1 break-words text-[1.45rem] leading-[1] text-white",children:a})]}),e.jsx("div",{className:"shrink-0 font-display text-[1.45rem] text-[var(--primary)]",children:i})]}),e.jsx("div",{className:Q("grid w-full max-w-full min-w-0 min-h-48 content-start gap-2 rounded-[18px] p-2 transition",l?"bg-[rgba(125,211,252,0.08)]":"bg-white/[0.02]"),children:o})]})})}function Wn({tasks:t,goals:s,tags:a,selectedTaskId:r,onMove:i,onSelectTask:n,onStartTask:o,onQuickReopenTask:h,onOpenTask:l,onEditTask:x,notesSummaryByEntity:g}){const{t:f}=Te(),d=y.useId(),[u,b]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(max-width: 1023px)").matches),c=fo(vo(No,{activationConstraint:{distance:6}})),[j,k]=y.useState(null),[$,M]=y.useState({}),I={backlog:{title:f("common.executionBoard.laneBacklogTitle"),detail:f("common.executionBoard.laneBacklogDetail")},focus:{title:f("common.executionBoard.laneFocusTitle"),detail:f("common.executionBoard.laneFocusDetail")},in_progress:{title:f("common.executionBoard.laneProgressTitle"),detail:f("common.executionBoard.laneProgressDetail")},blocked:{title:f("common.executionBoard.laneBlockedTitle"),detail:f("common.executionBoard.laneBlockedDetail")},done:{title:f("common.executionBoard.laneDoneTitle"),detail:f("common.executionBoard.laneDoneDetail")}},N=y.useMemo(()=>t.map(v=>{const C=$[v.id];return C?{...v,status:C}:v}),[$,t]),m=j?N.find(v=>v.id===j)??null:null,w=m?s.find(v=>v.id===m.goalId):void 0,L=m?m.tagIds.map(v=>a.find(C=>C.id===v)).filter(Boolean):[];y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const v=window.matchMedia("(max-width: 1023px)"),C=R=>{b(R?R.matches:v.matches)};return C(),typeof v.addEventListener=="function"?(v.addEventListener("change",C),()=>v.removeEventListener("change",C)):(v.addListener(C),()=>v.removeListener(C))},[]),y.useEffect(()=>{if(!j){document.body.style.cursor="";return}return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[j]),y.useEffect(()=>{M(v=>{const C=new Set(t.map(G=>G.id));let R=!1;const J={};for(const[G,se]of Object.entries(v)){const K=t.find(D=>D.id===G);if(!C.has(G)||!K||K.status===se){R=!0;continue}J[G]=se}return R?J:v})},[t]);function S(v){var R;const C=(R=v.active.data.current)==null?void 0:R.taskId;typeof C=="string"&&k(C)}async function O(v){var F,W,T,H;const{active:C,over:R}=v;if(k(null),!R||C.id===R.id)return;const J=typeof((F=C.data.current)==null?void 0:F.taskId)=="string"?C.data.current.taskId:String(C.id),G=N.find(U=>U.id===J);if(!G)return;const se=typeof((W=R.data.current)==null?void 0:W.status)=="string"?R.data.current.status:null,K=typeof((T=R.data.current)==null?void 0:T.taskId)=="string"?R.data.current.taskId:String(R.id),D=se??((H=N.find(U=>U.id===K))==null?void 0:H.status)??G.status;if(D!==G.status&&Ye.includes(D)){M(U=>({...U,[G.id]:D}));try{await i(G.id,D)}catch(U){throw M(Z=>{const ie={...Z};return delete ie[G.id],ie}),U}}}async function A(v,C){const R=N.find(K=>K.id===v);if(!R)return;const J=Ye.indexOf(R.status),G=C==="previous"?J-1:J+1,se=Ye[G]??null;if(!(!se||se===R.status)){M(K=>({...K,[R.id]:se}));try{await i(R.id,se)}catch(K){throw M(D=>{const F={...D};return delete F[R.id],F}),K}}}return e.jsxs(yo,{sensors:c,collisionDetection:Sd,onDragStart:S,onDragCancel:()=>k(null),onDragEnd:v=>void O(v),children:[e.jsx("div",{className:"w-full max-w-full min-w-0 pb-2",children:u?e.jsx("div",{className:"grid w-full max-w-full min-w-0 gap-2",children:Ye.map(v=>{const C=N.filter(R=>R.status===v);return e.jsx(fi,{items:C.map(R=>`${d}:task:${R.id}`),strategy:vi,children:e.jsxs(Bi,{droppableId:`${d}:lane:${v}`,status:v,title:I[v].title,detail:I[v].detail,count:C.length,dragging:j!==null,children:[C.map(R=>e.jsx(qi,{sortableId:`${d}:task:${R.id}`,task:R,goal:s.find(J=>J.id===R.goalId),tags:R.tagIds.map(J=>a.find(G=>G.id===J)).filter(Boolean),isSelected:r===R.id,isMobile:!0,onSelect:n,onStartTask:o,onQuickReopen:h,onStepTask:A,onOpenTask:l,onEditTask:x,notesSummaryByEntity:g},R.id)),C.length===0?e.jsx("div",{className:"w-full max-w-full rounded-[18px] border border-dashed border-white/8 px-4 py-8 text-center text-sm text-white/35",children:f("common.executionBoard.emptyLane")}):null]})},v)})}):e.jsx("div",{className:"grid w-full min-w-0 gap-0.5 xl:grid-cols-[repeat(5,minmax(0,1fr))]",children:Ye.map(v=>{const C=N.filter(R=>R.status===v);return e.jsx(fi,{items:C.map(R=>`${d}:task:${R.id}`),strategy:vi,children:e.jsxs(Bi,{droppableId:`${d}:lane:${v}`,status:v,title:I[v].title,detail:I[v].detail,count:C.length,dragging:j!==null,children:[C.map(R=>e.jsx(qi,{sortableId:`${d}:task:${R.id}`,task:R,goal:s.find(J=>J.id===R.goalId),tags:R.tagIds.map(J=>a.find(G=>G.id===J)).filter(Boolean),isSelected:r===R.id,onSelect:n,onStartTask:o,onQuickReopen:h,onStepTask:A,onOpenTask:l,onEditTask:x,notesSummaryByEntity:g},R.id)),C.length===0?e.jsx("div",{className:"w-full max-w-full rounded-[18px] border border-dashed border-white/8 px-4 py-8 text-center text-sm text-white/35",children:f("common.executionBoard.emptyLane")}):null]})},v)})})}),e.jsx(wo,{adjustScale:!1,dropAnimation:null,children:m?e.jsx("div",{className:"w-[20rem] max-w-[calc(100vw-2rem)]",children:e.jsx(Qn,{task:m,goal:w,tags:L,isSelected:r===m.id,isDragging:!0,isOverlay:!0,isMobile:u,onSelect:()=>{},onStartTask:o,notesSummaryByEntity:g})}):null})]})}const Cd=$r(t=>({selectedOwner:null,selectedGoalId:null,selectedTagIds:[],setOwner:s=>t({selectedOwner:s}),setGoal:s=>t({selectedGoalId:s}),toggleTag:s=>t(a=>({selectedTagIds:a.selectedTagIds.includes(s)?a.selectedTagIds.filter(r=>r!==s):[...a.selectedTagIds,s]})),reset:()=>t({selectedOwner:null,selectedGoalId:null,selectedTagIds:[]})}));function Id(){var L;const{t}=Te(),s=Le(),a=Ve(),r=Pe(),[i,n]=y.useState(((L=s.snapshot.tasks[0])==null?void 0:L.id)??null),[o,h]=y.useState(null),{selectedGoalId:l,selectedOwner:x,selectedTagIds:g,setGoal:f,setOwner:d,toggleTag:u,reset:b}=Cd(),c=s.snapshot.tasks.filter(S=>!(l&&S.goalId!==l||x&&S.owner!==x||g.length>0&&!g.every(O=>S.tagIds.includes(O)))),j=c.find(S=>S.id===i)??s.snapshot.tasks.find(S=>S.id===i)??null,k=o?s.snapshot.tasks.find(S=>S.id===o)??null:null,$=c.filter(S=>S.status==="blocked").length,M=c.filter(S=>S.status==="done").length,I=c.filter(S=>S.status==="focus"||S.status==="in_progress").length,N=s.snapshot.activeTaskRuns.length,m=async()=>{await Promise.all([r.invalidateQueries({queryKey:["forge-snapshot"]}),r.invalidateQueries({queryKey:["project-board"]}),r.invalidateQueries({queryKey:["task-context"]})])},w=de({mutationFn:({taskId:S,patch:O})=>Is(S,O),onSuccess:m});return s.snapshot.tasks.length===0?e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsx(ke,{title:"Kanban",description:"Move tasks across the board, start work quickly, and keep your next step visible.",badge:"0 visible tasks",actions:e.jsx(X,{size:"lg",onClick:()=>s.openStartWork(),children:"Start work"})}),e.jsx(Xe,{eyebrow:t("common.kanban.heroEyebrow"),title:t("common.kanban.emptyTitle"),description:t("common.kanban.emptyDescription"),action:e.jsx(xe,{to:"/goals",className:"inline-flex whitespace-nowrap rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium text-slate-950 transition hover:opacity-90",children:t("common.kanban.emptyAction")})})]}):e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsx(ke,{title:"Kanban",description:"Move tasks between states, start work directly from the board, or open a task when you need to edit it.",badge:`${c.length} visible tasks`,actions:e.jsx(X,{size:"lg",onClick:()=>s.openStartWork(j?{taskId:j.id}:void 0),children:"Start work"})}),e.jsx(Y,{className:"min-w-0 overflow-hidden",children:e.jsxs("div",{className:"flex 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.18em] text-white/45",children:"Board"}),e.jsx("div",{className:"mt-2 text-base text-white",children:"See what is not started, ready, active, blocked, or done, then move tasks where they belong."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[I," ready or active"]}),e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[$," blocked"]}),e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[M," done"]}),e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[N," live timer",N===1?"":"s"]})]})]})}),e.jsxs(Y,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"type-label text-white/40",children:"Filters"}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx(B,{tone:"meta",className:"bg-white/[0.08] text-white/60",children:"Goal"}),e.jsx("button",{className:`interactive-tap max-w-full rounded-full px-4 py-2 text-sm ${l===null?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/58"}`,onClick:()=>f(null),children:"All goals"}),s.snapshot.goals.map(S=>e.jsx("button",{className:`interactive-tap min-w-0 max-w-full rounded-full px-4 py-2 text-sm ${l===S.id?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/58"}`,onClick:()=>f(l===S.id?null:S.id),children:e.jsx(ue,{kind:"goal",label:S.title,className:"max-w-full min-w-0",lines:2,labelClassName:"whitespace-normal text-left"})},S.id))]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(B,{tone:"meta",className:"bg-white/[0.08] text-white/60",children:"Owner"}),e.jsx("button",{className:`interactive-tap max-w-full rounded-full px-4 py-2 text-sm ${x===null?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/58"}`,onClick:()=>d(null),children:"Everyone"}),s.snapshot.dashboard.owners.map(S=>e.jsx("button",{className:`interactive-tap max-w-full rounded-full px-4 py-2 text-sm ${x===S?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/58"}`,onClick:()=>d(x===S?null:S),children:S},S))]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[s.snapshot.tags.map(S=>e.jsx("button",{className:`interactive-tap max-w-full rounded-full px-4 py-2 text-sm ${g.includes(S.id)?"bg-white/[0.12] text-white":"bg-white/[0.04] text-white/58"}`,onClick:()=>u(S.id),children:S.name},S.id)),e.jsx("button",{className:"interactive-tap max-w-full rounded-full bg-white/[0.04] px-4 py-2 text-sm text-[var(--primary)]",onClick:b,children:"Reset"})]})]}),c.length===0?e.jsx(Xe,{eyebrow:t("common.kanban.heroEyebrow"),title:t("common.kanban.noTasksMatch"),description:"No tasks match the current filters. Reset the filters to bring the full board back.",action:e.jsx(X,{variant:"secondary",onClick:b,children:"Reset"})}):e.jsx(Wn,{tasks:c,goals:s.snapshot.goals,tags:s.snapshot.tags,notesSummaryByEntity:s.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:i,onMove:async(S,O)=>{await s.patchTaskStatus(S,O)},onQuickReopenTask:async S=>{await va(S),await m()},onStartTask:async S=>{await s.startTaskNow(S),n(S),await r.invalidateQueries({queryKey:["task-context",S]})},onSelectTask:S=>{n(S)},onOpenTask:S=>{a(`/tasks/${S}`)},onEditTask:S=>{h(S)}}),e.jsx(Ts,{open:k!==null,goals:s.snapshot.goals,projects:s.snapshot.dashboard.projects,tags:s.snapshot.tags,editingTask:k,onOpenChange:S=>{S||h(null)},onSubmit:async(S,O)=>{O&&(await w.mutateAsync({taskId:O,patch:S}),h(null))}})]})}const zi=[{value:"",label:"All linked entities"},{value:"goal",label:"Goals"},{value:"project",label:"Projects"},{value:"task",label:"Tasks"},{value:"trigger_report",label:"Trigger reports"},{value:"psyche_value",label:"Values"},{value:"behavior_pattern",label:"Patterns"},{value:"behavior",label:"Behaviors"},{value:"belief_entry",label:"Beliefs"},{value:"mode_profile",label:"Modes"}];function Pd(){var u;const t=Ve(),[s]=Ze(),a=s.get("entityType"),r=s.get("entityId"),i=zi.some(b=>b.value===a)?a:"",[n,o]=y.useState(s.get("query")??""),[h,l]=y.useState(s.get("author")??""),[x,g]=y.useState(i);y.useEffect(()=>{o(s.get("query")??""),l(s.get("author")??""),g(i)},[i,s]);const f=te({queryKey:["notes-index",n,h,x,r],queryFn:()=>Pn({linkedEntityType:i&&r?i:void 0,linkedEntityId:i&&r?r:void 0,query:n.trim()||void 0,author:h.trim()||void 0,limit:120})}),d=y.useMemo(()=>{var c;return(((c=f.data)==null?void 0:c.notes)??[]).filter(j=>j.links.some(k=>i&&r?k.entityType===i&&k.entityId===r:x?k.entityType===x:!0))},[x,r,i,(u=f.data)==null?void 0:u.notes]);return f.isError?e.jsx(je,{eyebrow:"Notes",error:f.error,onRetry:()=>void f.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{title:"Notes",titleText:"Notes",description:i&&r?"Review the Markdown notes linked to this exact entity, then jump back into the surrounding work.":"Search Markdown notes across Forge by content, author, and linked entity. Each result can jump you straight back to the underlying work.",badge:`${d.length} visible`}),e.jsx(Y,{className:"grid gap-4",children:e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.4fr)_minmax(12rem,0.7fr)_minmax(14rem,0.8fr)]",children:[e.jsx(ae,{value:n,onChange:b=>o(b.target.value),placeholder:"Search note content"}),e.jsx(ae,{value:h,onChange:b=>l(b.target.value),placeholder:"Filter by author"}),e.jsx("select",{value:x,onChange:b=>g(b.target.value),disabled:!!(i&&r),className:"rounded-[22px] border border-white/8 bg-white/[0.04] px-4 py-3 text-sm text-white",children:zi.map(b=>e.jsx("option",{value:b.value,children:b.label},b.label))})]})}),f.isLoading?e.jsx(Y,{className:"text-sm text-white/58",children:"Loading notes…"}):d.length===0?e.jsx(Xe,{eyebrow:"Notes",title:"No matching notes yet",description:"Try a broader search or remove one of the filters."}):e.jsx("div",{className:"grid gap-3",children:d.map(b=>{const c=sd(b),j=c?ya(c.entityType,c.entityId):null;return e.jsxs("button",{type:"button",className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.03))] p-5 text-left transition hover:bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.04))]",onClick:()=>{j&&t(j.includes("#")?j:`${j}#notes`)},children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"text-xs uppercase tracking-[0.16em] text-white/38",children:[(b.author??"Unknown author").toString()," • ",new Date(b.updatedAt).toLocaleString()]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.links.map(k=>e.jsxs(B,{className:"bg-white/[0.08] text-white/68",wrap:!0,children:[k.entityType.replaceAll("_"," "),k.anchorKey?` · ${Ot(k.anchorKey)}`:""]},`${b.id}-${k.entityType}-${k.entityId}-${k.anchorKey??""}`))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ms,{markdown:b.contentMarkdown,className:"line-clamp-none"})})]},b.id)})})]})}function Hn({eyebrow:t,title:s,description:a,items:r,tone:i="core",className:n}){return e.jsxs("section",{className:Q("min-w-0 overflow-hidden rounded-[28px] border border-white/6 shadow-[0_20px_54px_rgba(4,8,18,0.24)]",i==="core"?"bg-[linear-gradient(180deg,rgba(22,28,46,0.98),rgba(12,17,30,0.95))]":"bg-[linear-gradient(180deg,rgba(16,29,33,0.98),rgba(12,22,27,0.95))]",n),children:[e.jsxs("div",{className:Q("grid min-w-0 gap-3 px-4 py-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] lg:px-5",i==="core"?"bg-[radial-gradient(circle_at_top_right,rgba(192,193,255,0.12),transparent_36%),linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]":"bg-[radial-gradient(circle_at_top_right,rgba(110,231,183,0.1),transparent_36%),linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:Q("font-label text-[11px] uppercase tracking-[0.2em]",i==="core"?"text-[var(--secondary)]":"text-[rgba(110,231,183,0.82)]"),children:t}),e.jsx("h2",{className:"mt-2 max-w-3xl font-display text-[clamp(1.35rem,2vw,1.9rem)] leading-none text-white",children:s}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-white/60",children:a})]}),e.jsx("div",{className:"grid min-w-0 gap-2 sm:grid-cols-3",children:r.slice(0,3).map(o=>o.href?e.jsxs(xe,{to:o.href,className:Q("min-w-0 rounded-[20px] border border-white/6 px-3 py-3 backdrop-blur-sm transition hover:bg-white/[0.08]",i==="core"?"bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.025))]":"bg-[linear-gradient(180deg,rgba(110,231,183,0.08),rgba(255,255,255,0.02))]"),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:o.label}),e.jsx("div",{className:"mt-1.5 min-w-0 font-medium text-white",children:o.title})]},o.id):e.jsxs("div",{className:Q("min-w-0 rounded-[20px] border border-white/6 px-3 py-3 backdrop-blur-sm",i==="core"?"bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.025))]":"bg-[linear-gradient(180deg,rgba(110,231,183,0.08),rgba(255,255,255,0.02))]"),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:o.label}),e.jsx("div",{className:"mt-1.5 min-w-0 font-medium text-white",children:o.title})]},o.id))})]}),e.jsx("div",{className:"grid min-w-0 gap-3 px-4 py-4 lg:grid-cols-2 lg:px-5",children:r.map((o,h)=>{const l=Q("group flex min-h-[13.5rem] min-w-0 flex-col overflow-hidden rounded-[24px] border border-white/7 p-0 transition hover:-translate-y-0.5 hover:shadow-[0_22px_46px_rgba(3,8,18,0.28)] sm:min-h-[15.5rem]",i==="core"?"bg-[linear-gradient(180deg,rgba(19,26,42,0.98),rgba(11,16,28,0.96))] hover:border-white/12 hover:bg-[linear-gradient(180deg,rgba(24,31,50,0.98),rgba(13,19,33,0.97))]":"bg-[linear-gradient(180deg,rgba(17,29,32,0.98),rgba(9,18,22,0.97))] hover:border-white/12 hover:bg-[linear-gradient(180deg,rgba(21,36,40,0.98),rgba(11,22,27,0.97))]"),x=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Q("flex min-w-0 flex-1 flex-col p-4",i==="core"?"bg-[radial-gradient(circle_at_top_left,rgba(192,193,255,0.1),transparent_28%),linear-gradient(180deg,rgba(255,255,255,0.025),rgba(255,255,255,0))]":"bg-[radial-gradient(circle_at_top_left,rgba(110,231,183,0.08),transparent_28%),linear-gradient(180deg,rgba(255,255,255,0.025),rgba(255,255,255,0))]"),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:o.label}),e.jsx("div",{className:"mt-2.5 min-w-0 font-display text-[1.25rem] leading-tight text-white sm:text-[1.4rem]",children:o.title})]}),o.badge?e.jsx(B,{wrap:!0,className:"max-w-[10rem] shrink-0 self-start bg-white/[0.08] text-white/72",children:o.badge}):null]}),e.jsx("div",{className:"mt-2.5 text-sm leading-6 text-white/60",children:o.detail}),e.jsx("div",{className:"flex-1"})]}),o.href?e.jsx("div",{className:"border-t border-white/6 bg-[linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0.01))] px-4 py-3",children:e.jsxs("div",{className:"inline-flex min-h-10 min-w-0 max-w-full items-center gap-2 rounded-full border border-white/8 bg-white/[0.05] px-4 text-sm text-white/68 transition group-hover:border-white/14 group-hover:bg-white/[0.08] group-hover:text-white",children:[o.actionLabel??"Open",e.jsx(vt,{className:"size-3.5"})]})}):null]});return e.jsx(De.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.22,delay:.04*h,ease:"easeOut"},children:o.href?e.jsx(xe,{to:o.href,className:l,children:x}):e.jsx("div",{className:l,children:x})},o.id)})})]})}function Ld(t){switch(t){case"platinum":return"text-cyan-200";case"gold":return"text-amber-200";case"silver":return"text-slate-200";default:return"text-orange-200"}}function Md(t){switch(t){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 Un({profile:t,achievements:s,milestoneRewards:a,momentumPulse:r,recentLedger:i=[],className:n,tone:o="core"}){const h=s.filter(d=>d.unlocked),l=(h.length>0?h:s).slice(0,3),x=a.slice(0,3),g=i.slice(0,3),f=Math.min(100,Math.round(t.currentLevelXp/t.nextLevelXp*100));return e.jsxs("section",{className:Q("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)]",o==="psyche"&&"bg-[linear-gradient(180deg,rgba(18,27,35,0.96),rgba(12,20,26,0.94))]",n),children:[e.jsx("div",{className:Q("bg-gradient-to-r px-5 py-5",Md(r.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:r.headline}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-white/68",children:r.detail})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap gap-2",children:[e.jsxs(B,{wrap:!0,className:"bg-black/20 text-white/84",children:["Level ",t.level]}),e.jsxs(B,{wrap:!0,className:"bg-black/20 text-white/84",children:[t.streakDays," day streak"]}),e.jsxs(B,{wrap:!0,className:"bg-black/20 text-white/84",children:[t.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(De.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:r.nextMilestoneLabel})]}),e.jsx(B,{wrap:!0,className:"max-w-[12rem] shrink-0 self-start text-[var(--tertiary)]",children:r.celebrationLabel})]}),e.jsx("div",{className:"mt-5",children:e.jsx(ct,{value:f})}),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:[t.currentLevelXp,"/",t.nextLevelXp," XP"]}),e.jsxs("span",{children:[t.comboMultiplier.toFixed(2),"x combo"]})]})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:l.map((d,u)=>e.jsxs(De.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.24,delay:.04*u,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:d.title}),e.jsx(B,{wrap:!0,className:Q("max-w-[8rem] shrink-0 self-start",Ld(d.tier)),children:d.tier})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:d.summary}),e.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.16em] text-white/40",children:d.progressLabel})]},d.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(d=>{const u=Math.min(100,Math.round(d.current/d.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:d.title}),e.jsx(B,{wrap:!0,className:Q("max-w-[10.5rem] shrink-0 self-start",d.completed?"text-emerald-300":"text-white/68"),children:d.rewardLabel})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:d.summary}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:u})}),e.jsx("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:d.progressLabel})]},d.id)})})]}),g.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:g.map(d=>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:d.reasonTitle}),e.jsxs(B,{wrap:!0,className:Q("max-w-[8rem] shrink-0 self-start",d.deltaXp>=0?"text-emerald-300":"text-amber-300"),children:[d.deltaXp>0?"+":"",d.deltaXp," XP"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:d.reasonSummary}),e.jsx("div",{className:"mt-3 text-xs uppercase tracking-[0.16em] text-white/38",children:da(d.createdAt)})]},d.id))})]}):null]})]})]})}function at({to:t,children:s,className:a}){return e.jsx(xe,{to:t,className:"group block transition-transform duration-[var(--motion-medium)] ease-[var(--ease-standard)] hover:-translate-y-0.5 focus-visible:outline-none",children:e.jsx(Y,{className:Q("transition-[transform,box-shadow,background] duration-[var(--motion-medium)] ease-[var(--ease-standard)] group-hover:bg-white/[0.06] group-hover:shadow-[var(--card-shadow-hover)] group-focus-visible:shadow-[var(--card-shadow-hover)]",a),children:s})})}function it({label:t,value:s,tone:a="default",detail:r,className:i}){return e.jsxs(Y,{className:Q("rounded-[22px] p-4",a==="core"&&"bg-[linear-gradient(180deg,rgba(29,24,48,0.95),rgba(17,17,31,0.92))]",a==="psyche"&&"bg-[linear-gradient(180deg,rgba(18,31,34,0.96),rgba(13,24,27,0.94))]",i),children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:t}),e.jsx("div",{className:"mt-3 font-display text-3xl text-white",children:s}),r?e.jsx("div",{className:"mt-2 text-sm text-white/56",children:r}):null]})}function Ed(){const{t,formatDateTime:s}=Te(),{snapshot:a}=Le(),r=a.metrics.momentumScore>=80?"Strong":a.metrics.momentumScore>=60?"Steady":"Needs attention",i=new Map(a.projects.map(c=>[c.id,c])),n=a.dashboard.milestoneRewards.find(c=>!c.completed)??a.dashboard.milestoneRewards[0]??null,o=a.dashboard.achievements.filter(c=>c.unlocked).length,h=a.overview.topTasks[0]??null,l=a.overview.activeGoals[0]??null,x=a.overview.neglectedGoals[0]??null,g=a.overview.recentEvidence[0]??null,f={status:a.metrics.momentumScore>=80?"surging":a.metrics.momentumScore>=60?"steady":"recovering",headline:a.metrics.momentumScore>=80?`${a.metrics.streakDays}-day streak active. Your recent work is building on itself.`:a.metrics.momentumScore>=60?"Momentum is stable. One useful push will keep things moving.":"Momentum is soft right now. One real win will help restart it.",detail:n!==null?`${n.title} is the clean next unlock. ${n.progressLabel}.`:`Level ${a.metrics.level} is active with ${a.metrics.weeklyXp} weekly XP recorded.`,celebrationLabel:o>0?`${o} achievement${o===1?"":"s"} unlocked`:a.metrics.weeklyXp>=120?"A strong week is taking shape":"The next reward comes from a real completion or repair",nextMilestoneId:(n==null?void 0:n.id)??null,nextMilestoneLabel:(n==null?void 0:n.rewardLabel)??"Keep building visible momentum"},d=a.overview.activeGoals.length>0||a.overview.projects.length>0||a.overview.topTasks.length>0||a.overview.recentEvidence.length>0||a.overview.neglectedGoals.length>0,u=[{id:"top-task",label:h?"Top task":"Top goal",title:h?e.jsx(ue,{kind:"task",label:h.title,lines:3,labelClassName:"[overflow-wrap:anywhere]"}):l?e.jsx(ue,{kind:"goal",label:l.title,lines:3,labelClassName:"[overflow-wrap:anywhere]"}):"Choose the next task",detail:(h==null?void 0:h.description)||(l==null?void 0:l.description)||t("common.todayPage.noDirectiveDetail"),badge:h?`${h.points} xp`:`${a.overview.strategicHeader.focusTasks} focus tasks`,href:h?`/tasks/${h.id}`:l?`/goals/${l.id}`:"/goals",actionLabel:h?"Open task":"Open goal"},{id:"reward",label:"Next reward",title:(n==null?void 0:n.title)??"Keep the streak going",detail:(n==null?void 0:n.progressLabel)??`Level ${a.metrics.level} is live. ${a.metrics.currentLevelXp} XP is already banked toward the next unlock.`,badge:(n==null?void 0:n.rewardLabel)??`${a.metrics.comboMultiplier.toFixed(2)}x combo`,href:"/today",actionLabel:"Open today"},{id:"goal-needing-attention",label:"Goal needing attention",title:x?e.jsx(ue,{kind:"goal",label:x.title,lines:3,labelClassName:"[overflow-wrap:anywhere]"}):"No goal needs urgent attention",detail:(x==null?void 0:x.summary)??`Only ${a.overview.strategicHeader.overdueTasks} overdue task${a.overview.strategicHeader.overdueTasks===1?"":"s"} are currently slowing the engine.`,badge:(x==null?void 0:x.risk)??"stable",href:x?`/goals/${x.goalId}`:"/today",actionLabel:x?"Open goal":"Open today"},{id:"recent-activity",label:"Recent activity",title:g?Ls(g):`${o} achievement${o===1?"":"s"} unlocked`,detail:(g?Ms(g):null)??t("common.overview.noEvidence"),badge:(g==null?void 0:g.source)??`${a.metrics.weeklyXp} weekly XP`,href:g?b(g):"/activity",actionLabel:g?"Open item":"Open activity"}];function b(c){return c.entityType==="goal"?`/goals/${c.entityId}`:c.entityType==="project"?`/projects/${c.entityId}`:c.entityType==="task"?`/tasks/${c.entityId}`:c.entityType==="task_run"&&typeof c.metadata.taskId=="string"?`/tasks/${c.metadata.taskId}`:`/activity?eventId=${c.id}`}return d?e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsx(ke,{title:"Overview",titleText:"Overview",description:`${r}. See your main goals, active projects, top tasks, and recent activity in one place.`,badge:`${a.metrics.streakDays} day streak`}),e.jsx(Un,{profile:a.metrics,achievements:a.dashboard.achievements,milestoneRewards:a.dashboard.milestoneRewards,momentumPulse:f}),e.jsx(Hn,{eyebrow:"Actions",title:"What you can open or act on right now",description:"Each card below leads to a real task, goal, reward, or recent activity item.",items:u}),e.jsxs("section",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsxs(Y,{className:"bg-[linear-gradient(180deg,rgba(19,24,40,0.96),rgba(11,15,27,0.96))]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Overview summary"}),e.jsx(Ne,{content:"This summarizes your current level, weekly XP, and the goal that most needs attention."})]}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:"Level, weekly XP, and what needs attention"})]}),e.jsx("div",{className:"max-w-full min-w-0 rounded-full border border-white/8 bg-white/[0.04] px-4 py-2 text-sm text-white/62",children:f.status})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-3",children:[e.jsx(it,{label:t("common.overview.metricsLevel"),value:a.metrics.level,tone:"core"}),e.jsx(it,{label:t("common.overview.metricsWeeklyXp"),value:a.metrics.weeklyXp,tone:"core",detail:"XP earned so far this week."}),e.jsxs(at,{to:x?`/goals/${x.goalId}`:"/today",className:"rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/45",children:"Goal needing attention"}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(x==null?void 0:x.title)??"No goal needs urgent attention"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(x==null?void 0:x.summary)??`Only ${a.overview.strategicHeader.overdueTasks} overdue task${a.overview.strategicHeader.overdueTasks===1?"":"s"} are currently slowing the engine.`})]})]})]}),e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Goals"}),a.overview.activeGoals.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.overview.noGoals")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-3",children:a.overview.activeGoals.slice(0,3).map(c=>{var j;return e.jsxs(at,{to:`/goals/${c.id}`,className:"rounded-[22px] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsx(re,{kind:"goal",label:((j=c.tags[0])==null?void 0:j.name)??c.horizon,compact:!0,gradient:!1}),e.jsxs("div",{className:"shrink-0 text-[11px] uppercase tracking-[0.16em] text-white/42",children:[c.progress,"%"]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ue,{kind:"goal",label:c.title,variant:"heading",size:"lg",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:c.description}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:c.progress})}),e.jsx("div",{className:"mt-4",children:e.jsx(Fe,{entityType:"goal",entityId:c.id,count:Be(a.dashboard.notesSummaryByEntity,"goal",c.id).count})})]},c.id)})})]}),e.jsxs("div",{className:"grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]",children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Projects"}),e.jsx(Ne,{content:"These are the projects currently carrying active work."})]}),a.overview.projects.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.overview.noProjects")}):e.jsx("div",{className:"mt-4 grid gap-3",children:a.overview.projects.slice(0,4).map(c=>e.jsxs(at,{to:`/projects/${c.id}`,className:"rounded-[20px] px-4 py-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(re,{kind:"project",compact:!0,gradient:!1}),e.jsx(ue,{kind:"project",label:c.title,className:"min-w-0",showIcon:!1,lines:2,labelClassName:"[overflow-wrap:anywhere]"})]}),e.jsxs(B,{wrap:!0,className:"max-w-[8rem] shrink-0",children:[c.earnedPoints," xp"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:c.description}),e.jsx("div",{className:"mt-3",children:e.jsx(re,{kind:"goal",label:c.goalTitle,compact:!0})}),e.jsx("div",{className:"mt-4",children:e.jsx(Fe,{entityType:"project",entityId:c.id,count:Be(a.dashboard.notesSummaryByEntity,"project",c.id).count})})]},c.id))})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Tasks ready to start"}),e.jsx(Ne,{content:"These are the strongest task candidates to pick up next."})]}),a.overview.topTasks.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.overview.noFocus")}):e.jsx("div",{className:"mt-4 grid gap-3",children:a.overview.topTasks.slice(0,4).map(c=>{var j,k;return e.jsxs(at,{to:`/tasks/${c.id}`,className:"rounded-[20px] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(re,{kind:"task",compact:!0,gradient:!1}),e.jsx(ue,{kind:"task",label:c.title,className:"min-w-0",showIcon:!1,lines:2,labelClassName:"[overflow-wrap:anywhere]"})]}),e.jsxs(B,{wrap:!0,children:[c.points," xp"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:c.description}),e.jsx("div",{className:"mt-3",children:(j=i.get(c.projectId??""))!=null&&j.title?e.jsx(re,{kind:"project",label:((k=i.get(c.projectId??""))==null?void 0:k.title)??"",compact:!0}):e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:t("common.overview.noProjectYet")})}),e.jsx("div",{className:"mt-4",children:e.jsx(Fe,{entityType:"task",entityId:c.id,count:Be(a.dashboard.notesSummaryByEntity,"task",c.id).count})})]},c.id)})})]})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:[e.jsx("span",{children:"Recent activity"}),e.jsx(Ne,{content:"This shows the latest visible work, completions, and corrections linked to your goals, projects, and tasks."})]}),a.overview.recentEvidence.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.overview.noEvidence")}):e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:a.overview.recentEvidence.slice(0,6).map(c=>e.jsxs(at,{to:b(c),className:"rounded-[20px] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:c.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:c.description})]}),e.jsx(B,{wrap:!0,children:c.source})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:s(c.createdAt)})]},c.id))})]})]})]})]}):e.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-5",children:[e.jsx(ke,{title:"Overview",titleText:"Overview",description:"See your main goals, active projects, top tasks, recent activity, and current progress in one place.",badge:"0 live signals"}),e.jsx(Xe,{eyebrow:t("common.overview.heroEyebrow"),title:t("common.overview.emptyTitle"),description:t("common.overview.emptyDescription"),action:e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium whitespace-nowrap text-slate-950 transition hover:opacity-90",children:t("common.overview.emptyAction")})})]})}function Ke({className:t}){return e.jsx("div",{className:Q("surface-pulse rounded-2xl bg-white/[0.05]",t)})}function et({header:t=!0,sideRail:s=!0,className:a,eyebrow:r,title:i,description:n,columns:o=2,blocks:h=4}){const l=Array.from({length:Math.max(2,h)});return e.jsxs("div",{className:Q("grid gap-5",a),"aria-hidden":"true",children:[t?e.jsxs(Y,{className:"grid gap-4",children:[e.jsx(Ke,{className:Q("h-3",r?"w-40":"w-32")}),e.jsx(Ke,{className:Q("h-12",i?"max-w-2xl":"max-w-3xl")}),e.jsx(Ke,{className:Q("h-5",n?"max-w-3xl":"max-w-2xl")})]}):null,e.jsxs("section",{className:Q("grid gap-5",s?"xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]":""),children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{className:"grid gap-4",children:[e.jsx(Ke,{className:"h-3 w-28"}),e.jsx(Ke,{className:"h-28 w-full"})]}),e.jsxs(Y,{className:"grid gap-4",children:[e.jsx(Ke,{className:"h-3 w-40"}),e.jsx("div",{className:Q("grid gap-3",o>1?"md:grid-cols-2":""),children:l.map((x,g)=>e.jsx(Ke,{className:"h-28 w-full"},g))})]})]}),s?e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{className:"grid gap-4",children:[e.jsx(Ke,{className:"h-3 w-24"}),e.jsx(Ke,{className:"h-20 w-full"})]}),e.jsxs(Y,{className:"grid gap-4",children:[e.jsx(Ke,{className:"h-3 w-36"}),e.jsx(Ke,{className:"h-16 w-full"}),e.jsx(Ke,{className:"h-16 w-full"})]})]}):null]})]})}function Ad(t){return!!(t&&t.startsWith("campaign:"))}function Dd(){const{t}=Te(),s=Le(),a=js(),r=Ve(),i=Pe(),[n,o]=y.useState(!1),[h,l]=y.useState(!1),x=s.snapshot.dashboard.projects.find(m=>m.id===a.projectId)??null,g=x?s.snapshot.goals.find(m=>m.id===x.goalId)??null:null,f=x?s.snapshot.tasks.filter(m=>m.projectId===x.id||!m.projectId&&m.goalId===x.goalId):[],d=new Set(f.map(m=>m.id)),u=x?s.snapshot.activity.filter(m=>m.entityId===x.goalId||m.entityId===x.id||d.has(m.entityId)||m.entityType==="task_run"&&typeof m.metadata.taskId=="string"&&d.has(m.metadata.taskId)):[],b=Ad(a.projectId),c=te({queryKey:["project-board",a.projectId],queryFn:()=>vl(a.projectId),enabled:!!a.projectId&&!b}),j=de({mutationFn:m=>va(m),onSuccess:async()=>{await Promise.all([i.invalidateQueries({queryKey:["forge-snapshot"]}),i.invalidateQueries({queryKey:["project-board",a.projectId]})])}}),k=c.data??(x&&g?{project:x,goal:g,tasks:f,activity:u}:void 0),$=s.snapshot.dashboard.projects.find(m=>m.id===a.projectId)??null;if(c.isError&&!b)return e.jsx(je,{eyebrow:t("common.projectDetail.errorEyebrow"),error:c.error,onRetry:()=>void c.refetch()});if(!k)return e.jsx(et,{});const M=k.tasks.find(m=>m.status==="focus"||m.status==="in_progress")??k.tasks[0]??null,I=k.tasks.find(m=>m.status==="blocked")??k.tasks.find(m=>m.status==="backlog")??null;k.activity[0];const N="notesSummaryByEntity"in k?k.notesSummaryByEntity:s.snapshot.dashboard.notesSummaryByEntity;return e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ke,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:k.project.title,variant:"heading",size:"lg"}),titleText:k.project.title,description:k.project.description,badge:e.jsx(re,{kind:"goal",label:k.goal.title,compact:!0,gradient:!1})}),b?e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.projectDetail.compatibility")}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:t("common.projectDetail.compatibilityDescription")})]}):null,e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(X,{onClick:()=>l(!0),children:t("common.projectDetail.addTask")}),b?null:e.jsx(X,{variant:"secondary",onClick:()=>o(!0),children:t("common.projectDetail.editProject")}),e.jsx(xe,{to:`/goals/${k.goal.id}`,children:e.jsx(X,{variant:"ghost",children:t("common.projectDetail.openGoal")})})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex flex-wrap items-start 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:t("common.projectDetail.commandEyebrow")}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2vw,1.9rem)] text-white",children:t("common.projectDetail.commandTitle")}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:t("common.projectDetail.commandDescription")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{kind:"project",compact:!0,gradient:!1}),e.jsx(re,{kind:"goal",label:k.goal.title,compact:!0,gradient:!1})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:[e.jsxs(xe,{to:M?`/tasks/${M.id}`:`/projects/${k.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",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/42",children:t("common.projectDetail.signalNext")}),M?e.jsx(re,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(M==null?void 0:M.title)??t("common.projectDetail.noNextTask")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(M==null?void 0:M.description)||t("common.projectDetail.noNextTaskDetail")})]}),e.jsxs(xe,{to:I?`/tasks/${I.id}`:`/projects/${k.project.id}`,className:"rounded-[20px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",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/42",children:t("common.projectDetail.signalRisk")}),I?e.jsx(re,{kind:"task",compact:!0,gradient:!1}):null]}),e.jsx("div",{className:"mt-2 font-medium text-white",children:(I==null?void 0:I.title)??t("common.projectDetail.noRisk")}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:(I==null?void 0:I.description)||t("common.projectDetail.noRiskDetail")})]})]})]}),e.jsxs(Y,{className:"h-fit min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.projectDetail.sectionHealth")}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t(`common.enums.projectStatus.${k.project.status}`)}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:k.project.momentumLabel}),e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(k.project.time.totalCreditedSeconds/60)," min tracked"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.projectDetail.fieldProgress")}),e.jsxs("div",{className:"mt-2 font-display text-xl text-white",children:[k.project.progress,"%"]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.projectDetail.fieldMomentum")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:k.project.momentumLabel})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:t("common.projectDetail.fieldStatus")}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:t(`common.enums.projectStatus.${k.project.status}`)})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/42",children:"Live tasks"}),e.jsx("div",{className:"mt-2 font-display text-xl text-white",children:k.tasks.filter(m=>m.status==="focus"||m.status==="in_progress").length})]})]})]})]}),e.jsx(Wn,{tasks:k.tasks,goals:s.snapshot.goals,tags:s.snapshot.tags,notesSummaryByEntity:N,selectedTaskId:null,onMove:async(m,w)=>{await s.patchTaskStatus(m,w),await i.invalidateQueries({queryKey:["project-board",a.projectId]})},onSelectTask:m=>r(`/tasks/${m}`),onQuickReopenTask:async m=>{await j.mutateAsync(m)}}),b?null:e.jsx(Ps,{entityType:"project",entityId:k.project.id,title:"Project notes",description:"Keep rollout notes, checkpoints, and cross-task context attached to the project itself.",invalidateQueryKeys:[["project-board",a.projectId]]}),e.jsxs(Y,{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.projectDetail.sectionEvidence")}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:k.activity.slice(0,6).map(m=>e.jsxs(xe,{to:dt(m)??`/activity?eventId=${m.id}`,className:"rounded-[18px] bg-white/[0.04] p-4 transition hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:Ls(m)}),e.jsx(B,{children:m.source})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:Ms(m)})]},m.id))})]}),e.jsx(ua,{open:n,goals:s.snapshot.goals,editingProject:$,onOpenChange:o,onSubmit:async(m,w)=>{w&&(await s.patchProject(w,m),await i.invalidateQueries({queryKey:["project-board",a.projectId]}))}}),e.jsx(Ts,{open:h,goals:s.snapshot.goals,projects:s.snapshot.dashboard.projects,tags:s.snapshot.tags,editingTask:null,initialProjectId:b?null:k.project.id,onOpenChange:l,onSubmit:async(m,w)=>{w?await Is(w,m):await s.createTask(m),await i.invalidateQueries({queryKey:["project-board",a.projectId]})}})]})}function Rd(){const{snapshot:t}=Le();return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"project",title:e.jsx(ue,{kind:"project",label:"Projects",variant:"heading",size:"lg"}),titleText:"Projects",description:"Projects are the concrete paths that move a life goal forward. Each project owns its own tasks, its own board, and its own evidence of progress.",badge:`${t.dashboard.projects.length} projects`}),t.dashboard.projects.length===0?e.jsx(Xe,{eyebrow:"Projects",title:"No projects in flight",description:"Create the first practical path under a life goal so execution, kanban, and evidence all have a concrete home.",action:e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-white/[0.08] px-4 py-3 text-sm whitespace-nowrap text-white transition hover:bg-white/[0.12]",children:"Open goals"})}):e.jsx("div",{className:"grid gap-4 lg:grid-cols-2 2xl:grid-cols-3",children:t.dashboard.projects.map(s=>{const a=Be(t.dashboard.notesSummaryByEntity,"project",s.id);return e.jsxs(at,{to:`/projects/${s.id}`,className:"transition",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(re,{kind:"goal",label:s.goalTitle,compact:!0}),e.jsx(B,{className:s.status==="completed"?"text-emerald-300":s.status==="paused"?"text-amber-300":"text-[var(--primary)]",children:s.status})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ue,{kind:"project",label:s.title,variant:"heading",size:"xl"})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:s.description}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:s.progress,tone:s.status==="completed"?"secondary":"primary"})}),e.jsxs("div",{className:"mt-4 grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Active"}),e.jsx("div",{className:"mt-2 text-white",children:s.activeTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"Completed"}),e.jsx("div",{className:"mt-2 text-white",children:s.completedTaskCount})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.16em] text-white/40",children:"XP"}),e.jsx("div",{className:"mt-2 text-white",children:s.earnedPoints})]})]}),e.jsx("div",{className:"mt-5 text-[11px] uppercase tracking-[0.16em] text-white/40",children:s.nextTaskTitle?`Next move: ${s.nextTaskTitle}`:"Ready for the next task"}),e.jsx("div",{className:"mt-4",children:e.jsx(Fe,{entityType:"project",entityId:s.id,count:a.count})})]},s.id)})})]})}function ka(t,s,a){return Math.min(Math.max(t,s),a)}function Na(t,s,a){return Math.min(a,Math.max(1,Math.ceil(t.trim().length/s)))}function _d(t,{compact:s}){const a=Na(t,s?13:14,4),i=(s?114:156)+(a-1)*(s?12:18)+Math.min(24,Math.max(0,t.trim().length-18))*(s?.7:1);return ka(i,s?118:164,s?154:210)}function Od(t,{compact:s}){const a=Na(t,s?11:13,3),i=(s?40:48)+(a-1)*(s?6:8)+Math.min(s?18:26,Math.max(0,t.trim().length-(s?12:16)))*(s?.45:.55);return ka(i,s?42:50,s?56:68)}function es(t,{compact:s,emphasis:a=!1}){const i=Na(t,s?16:a?22:20,a?3:2);return{width:ka((s?a?184:152:a?224:176)+Math.min(t.length,48)*(s?1.8:2.15),s?a?188:156:a?228:184,s?a?248:208:a?300:244),height:i===1?s?64:70:i===2?s?82:92:s?98:110}}function Ki(t){if(t.kind==="goal"||t.kind==="value"||t.kind==="ghost"){const s=t.radius??(t.kind==="goal"?76:34);return{halfWidth:s,halfHeight:s}}return{halfWidth:(t.width??146)/2,halfHeight:(t.height??58)/2}}function $d(t,{compact:s}){const a=t.map(n=>({...n,homeX:n.x,homeY:n.y,locked:n.kind==="goal"||n.kind==="ghost"})),r=s?28:40,i=s?.08:.06;for(let n=0;n<180;n+=1){for(const o of a)o.locked||(o.x+=(o.homeX-o.x)*i,o.y+=(o.homeY-o.y)*i);for(let o=0;o<a.length;o+=1)for(let h=o+1;h<a.length;h+=1){const l=a[o],x=a[h],g=Ki(l),f=Ki(x),d=x.x-l.x,u=x.y-l.y,b=g.halfWidth+f.halfWidth+r-Math.abs(d),c=g.halfHeight+f.halfHeight+r-Math.abs(u);if(b<=0||c<=0)continue;const j=b<c?"x":"y",k=Math.sign(j==="x"?d||h-o||1:u||h-o||1),$=(j==="x"?b:c)/(l.locked||x.locked?1:2);l.locked||(j==="x"?l.x-=k*$:l.y-=k*$),x.locked||(j==="x"?x.x+=k*$:x.y+=k*$)}}return a.map(({homeX:n,homeY:o,locked:h,...l})=>l)}function Fd(){return{nodes:[{id:"ghost_goal_north",kind:"ghost",x:-250,y:-20,radius:68,label:"First goal",meta:"Goal",href:"/goals"},{id:"ghost_goal_center",kind:"ghost",x:0,y:34,radius:74,label:"Life goals",meta:"Goal",href:"/goals"},{id:"ghost_goal_south",kind:"ghost",x:250,y:-10,radius:68,label:"Direction",meta:"Goal",href:"/goals"}],edges:[],fields:[],inspectors:{ghost_goal_center:{id:"ghost_goal_center",eyebrow:"Goals",title:"Add the first life goal",summary:"The graph is already laid out. Once a goal exists, values, reports, beliefs, and behaviors will start orbiting it instead of staying fragmented.",href:"/goals",ctaLabel:"Open life goals",tone:"sky",entityKind:"goal",chips:["Goals","Values","Reports"],stats:["0 goals mapped yet"]}},defaultSelectedId:"ghost_goal_center"}}function Yn(t,{compact:s=!1}={}){var x;if(t.length===0)return Fd();const a=[],r=[],i=[],n={},o=s?560:840,h=-((t.length-1)*o)/2;t.forEach((g,f)=>{const d=h+f*o,u=f%2===0?92:146,b=g.linkedBehaviors.length+g.linkedBeliefs.length+g.linkedReports.length,c=`goal:${g.goal.id}`;a.push({id:c,kind:"goal",x:d,y:u,radius:_d(g.goal.title,{compact:s}),tone:"amber",label:g.goal.title,href:`/goals/${g.goal.id}`}),n[c]={id:c,eyebrow:"Goal",title:g.goal.title,summary:g.goal.description,href:`/goals/${g.goal.id}`,ctaLabel:"Open goal",tone:"amber",entityKind:"goal",chips:g.linkedValues.slice(0,4).map(A=>A.title),stats:[`${g.linkedValues.length} linked value${g.linkedValues.length===1?"":"s"}`,`${g.linkedProjects.length} live project${g.linkedProjects.length===1?"":"s"}`,`${b} friction signal${b===1?"":"s"}`]},b>0&&i.push({id:`field:${g.goal.id}`,x:d+18,y:u+20,radiusX:s?144:176,radiusY:s?104:132,tone:"rose",opacity:Math.min(.42,.14+b*.04)});const j=s?208:282;g.linkedValues.slice(0,s?4:5).forEach((A,v)=>{const C=(-95+v*(s?78:64))*(Math.PI/180),R=Od(A.title,{compact:s}),J=d+Math.cos(C)*j,G=u+Math.sin(C)*j,se=`value:${A.id}`;a.push({id:se,kind:"value",x:J,y:G,radius:R,tone:"mint",label:A.title,meta:`${A.linkedGoalIds.length} goal${A.linkedGoalIds.length===1?"":"s"}`,href:`/psyche/values?focus=${A.id}#values-atlas`}),r.push({id:`${c}->${se}`,from:c,to:se,tone:"mint",strength:"medium"}),n[se]={id:se,eyebrow:"Value",title:A.title,summary:A.valuedDirection||A.whyItMatters||A.description,href:`/psyche/values?focus=${A.id}#values-atlas`,ctaLabel:"Open values",tone:"mint",entityKind:"value",chips:A.committedActions.slice(0,3),stats:[`${A.linkedProjectIds.length} linked project${A.linkedProjectIds.length===1?"":"s"}`,`${A.linkedTaskIds.length} linked task${A.linkedTaskIds.length===1?"":"s"}`]}});const k=g.linkedProjects.slice(0,s?2:3).map(A=>({project:A,size:es(A.title,{compact:s,emphasis:!0})})),$=s?24:30;let I=-(k.reduce((A,v)=>A+v.size.width,0)+Math.max(0,k.length-1)*$)/2;k.forEach(({project:A,size:v},C)=>{const R=`project:${A.id}`,J=d+I+v.width/2,G=u-(s?330:434)-C*(s?16:20);I+=v.width+$,a.push({id:R,kind:"project",x:J,y:G,width:v.width,height:v.height,tone:"sky",label:A.title,meta:"Project",href:`/projects/${A.id}`}),r.push({id:`${c}->${R}`,from:c,to:R,tone:"sky",strength:"medium"}),n[R]={id:R,eyebrow:"Project",title:A.title,summary:A.description,href:`/projects/${A.id}`,ctaLabel:"Open project",tone:"sky",entityKind:"project",chips:[A.status,A.goalTitle],stats:[`${A.progress}% progress`,`${A.activeTaskCount} active task${A.activeTaskCount===1?"":"s"}`]}});let N=u+(s?132:156);g.linkedBehaviors.slice(0,s?2:3).forEach(A=>{const v=`behavior:${A.id}`,C=es(A.title,{compact:s}),R=d-(s?272:352);a.push({id:v,kind:"behavior",x:R,y:N,width:C.width,height:C.height,tone:"orange",label:A.title,meta:A.kind,href:`/psyche/behaviors?focus=${A.id}#behavior-columns`}),r.push({id:`${c}->${v}`,from:c,to:v,tone:"orange",dashed:A.kind!=="committed",strength:A.kind==="committed"?"medium":"low"}),n[v]={id:v,eyebrow:"Behavior",title:A.title,summary:A.replacementMove||A.description||A.urgeStory,href:`/psyche/behaviors?focus=${A.id}#behavior-columns`,ctaLabel:"Open behaviors",tone:"orange",entityKind:"behavior",chips:[A.kind,...A.commonCues.slice(0,2)],stats:[A.shortTermPayoff?"Short-term payoff mapped":"Payoff still to map",A.longTermCost?"Long-term cost mapped":"Cost still to map"]},N+=C.height+(s?18:22)});let m=u+(s?8:10);g.linkedBeliefs.slice(0,s?2:3).forEach(A=>{const v=`belief:${A.id}`,C=es(A.statement,{compact:s,emphasis:!0}),R=d+(s?278:362);a.push({id:v,kind:"belief",x:R,y:m,width:C.width,height:C.height,tone:"violet",label:A.statement,meta:"belief",href:`/psyche/schemas-beliefs?focus=${A.id}`}),r.push({id:`${c}->${v}`,from:c,to:v,tone:"violet",dashed:!0,strength:"low"}),n[v]={id:v,eyebrow:"Belief",title:A.statement,summary:A.flexibleAlternative||A.originNote||"Belief script attached to this part of the map.",href:`/psyche/schemas-beliefs?focus=${A.id}`,ctaLabel:"Open beliefs",tone:"violet",entityKind:"belief",chips:[A.beliefType,`${A.confidence}% grip`],stats:[`${A.linkedBehaviorIds.length} linked behavior${A.linkedBehaviorIds.length===1?"":"s"}`,`${A.linkedReportIds.length} linked report${A.linkedReportIds.length===1?"":"s"}`]},m+=C.height+(s?18:22)});const w=g.linkedReports.slice(0,s?2:3).map(A=>({report:A,size:es(A.title,{compact:s})})),L=s?20:26;let O=-(w.reduce((A,v)=>A+v.size.width,0)+Math.max(0,w.length-1)*L)/2;w.forEach(({report:A,size:v})=>{const C=`report:${A.id}`,R=d+O+v.width/2,J=u+(s?332:430);O+=v.width+L,a.push({id:C,kind:"report",x:R,y:J,width:v.width,height:v.height,tone:"blue",label:A.title,meta:A.status,href:`/psyche/reports/${A.id}`}),r.push({id:`${c}->${C}`,from:c,to:C,tone:"sky",strength:"medium"}),n[C]={id:C,eyebrow:"Report",title:A.title,summary:A.eventSituation||A.customEventType||"Reflective chain linked into this goal.",href:`/psyche/reports/${A.id}`,ctaLabel:"Open report",tone:"blue",entityKind:"report",chips:[A.status,...A.nextMoves.slice(0,2)],stats:[`${A.emotions.length} emotion${A.emotions.length===1?"":"s"}`,`${A.behaviors.length} move${A.behaviors.length===1?"":"s"}`]}})});const l=((x=a[0])==null?void 0:x.id)??"ghost_goal_center";return{nodes:$d(a,{compact:s}),edges:r,fields:i,inspectors:n,defaultSelectedId:l}}const ut={mint:"rgba(110,231,183,0.64)",sky:"rgba(125,211,252,0.66)",violet:"rgba(196,181,253,0.72)",rose:"rgba(251,113,133,0.68)",amber:"rgba(251,191,36,0.68)",orange:"rgba(251,146,60,0.72)",blue:"rgba(96,165,250,0.72)",slate:"rgba(148,163,184,0.52)"},zs={mint:"rgba(16,185,129,0.18)",sky:"rgba(56,189,248,0.18)",violet:"rgba(167,139,250,0.18)",rose:"rgba(251,113,133,0.18)",amber:"rgba(251,191,36,0.18)",orange:"rgba(251,146,60,0.18)",blue:"rgba(96,165,250,0.18)",slate:"rgba(148,163,184,0.12)"},pt={mint:"rgba(209,250,229,0.98)",sky:"rgba(224,242,254,0.98)",violet:"rgba(237,233,254,0.98)",rose:"rgba(255,228,230,0.98)",amber:"rgba(254,243,199,0.98)",orange:"rgba(255,237,213,0.98)",blue:"rgba(219,234,254,0.98)",slate:"rgba(241,245,249,0.9)"};function Jn(t){switch(t){case"goal":case"value":case"behavior":case"belief":case"report":case"project":return t;default:return null}}function qd(t){if(t.tone)return t.tone;switch(t.kind){case"goal":return"amber";case"value":return"mint";case"belief":return"violet";case"behavior":return"orange";case"project":return"sky";case"report":return"blue";default:return"slate"}}function Bd(t){if(t.kind==="ghost")return t.meta??null;const s=Jn(t.kind);return s?ot(s).label:t.meta??null}function Ks(t,s,a){return Math.min(Math.max(t,s),a)}function ts(t,s,a=3){const r=t.trim().split(/\s+/),i=[];let n="";for(let l=0;l<r.length;l+=1){const x=r[l],g=n?`${n} ${x}`:x;if(g.length>s&&n){if(i.push(n),i.length>=a-1){n=[x,...r.slice(l+1)].join(" ");break}n=x}else n=g}n&&i.push(n);const o=i.slice(0,a),h=o.length-1;return h>=0&&o[h].length>s&&(o[h]=`${o[h].slice(0,Math.max(1,s-1)).trimEnd()}…`),o}function zd(t,s){if(t.length===0&&s.length===0)return{minX:-360,maxX:360,minY:-240,maxY:240};let a=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const o of t){const h=o.kind==="goal"||o.kind==="value"||o.kind==="ghost"?o.radius??32:(o.width??124)/2,l=o.kind==="goal"||o.kind==="value"||o.kind==="ghost"?o.radius??32:(o.height??56)/2,x=o.meta&&(o.kind==="goal"||o.kind==="ghost")?48:0;a=Math.min(a,o.x-h),r=Math.max(r,o.x+h),i=Math.min(i,o.y-l-x),n=Math.max(n,o.y+l)}for(const o of s)a=Math.min(a,o.x-o.radiusX),r=Math.max(r,o.x+o.radiusX),i=Math.min(i,o.y-o.radiusY),n=Math.max(n,o.y+o.radiusY);return{minX:a,maxX:r,minY:i,maxY:n}}function Xi(t){return{x:t.x,y:t.y}}function Kd(t){if(t.kind==="goal"){const s=t.radius??112;return ts(t.label,Math.max(14,Math.floor(s/7.2)),4)}if(t.kind==="value"||t.kind==="ghost"){const s=t.radius??40;return ts(t.label,Math.max(12,Math.floor(s/3)),3)}return t.kind==="project"?ts(t.label,Math.max(18,Math.floor((t.width??220)/10)),3):ts(t.label,Math.max(16,Math.floor((t.width??180)/10.5)),2)}function Xd(t){switch(t){case"goal":return"amber";case"project":return"sky";case"value":return"mint";case"behavior":return"orange";case"belief":return"violet";case"report":return"blue";default:return"slate"}}function Vn({nodes:t,edges:s,fields:a=[],title:r,hint:i,action:n,legend:o,selectedNodeId:h,onSelectNode:l,minHeightClassName:x="min-h-[34rem] lg:min-h-[44rem]",compact:g=!1,testId:f}){const d=y.useRef(null),u=Ve(),[b,c]=y.useState({width:0,height:0}),[j,k]=y.useState({scale:1,x:0,y:0}),[$,M]=y.useState(null),I=y.useRef(null),N=y.useRef({scale:1,x:0,y:0}),m=y.useRef(new Map),w=y.useRef(null),L=y.useRef(0),S=y.useRef(!1),O=y.useMemo(()=>new Map(t.map(T=>[T.id,T])),[t]),A=y.useMemo(()=>zd(t,a),[a,t]),v=b.width>0&&b.width<640;y.useEffect(()=>{if(!d.current||typeof ResizeObserver>"u")return;const T=new ResizeObserver(H=>{const U=H[0];c({width:U.contentRect.width,height:U.contentRect.height})});return T.observe(d.current),()=>T.disconnect()},[]);const C=y.useCallback(()=>{if(!b.width||!b.height)return;const T=v?132:g?140:190,H=Math.max(A.maxX-A.minX,1),U=Math.max(A.maxY-A.minY,1),Z=Ks(Math.min(b.width/(H+T),b.height/(U+T)),v?.24:g?.4:.46,v?.76:g?1.04:1.18),ie=(A.minX+A.maxX)/2,ge=(A.minY+A.maxY)/2;k({scale:Z,x:b.width/2-ie*Z,y:b.height/2-ge*Z})},[A.maxX,A.maxY,A.minX,A.minY,g,b.height,b.width,v]);y.useEffect(()=>{N.current=j},[j]),y.useEffect(()=>{S.current||C()},[C]);const R=y.useCallback((T,H,U)=>{const Z=Ks(T,.28,1.9);k(ie=>{if(H==null||U==null)return{...ie,scale:Z};const ge=(H-ie.x)/ie.scale,z=(U-ie.y)/ie.scale;return{scale:Z,x:H-ge*Z,y:U-z*Z}})},[]),J=y.useCallback(()=>{const T=[...m.current.values()];if(T.length<2){w.current=null;return}const[H,U]=T,Z=Math.hypot(U.x-H.x,U.y-H.y);if(!Number.isFinite(Z)||Z<=0){w.current=null;return}const ie=N.current;w.current={startDistance:Z,startScale:ie.scale,startViewportX:ie.x,startViewportY:ie.y,startMidpointX:(H.x+U.x)/2,startMidpointY:(H.y+U.y)/2}},[]),G=T=>{var Z;T.preventDefault();const H=(Z=d.current)==null?void 0:Z.getBoundingClientRect();if(!H)return;S.current=!0;const U=T.deltaY<0?1.1:.9;R(j.scale*U,T.clientX-H.left,T.clientY-H.top)},se=T=>{var ie;const H=(ie=d.current)==null?void 0:ie.getBoundingClientRect(),U=T.clientX-((H==null?void 0:H.left)??0),Z=T.clientY-((H==null?void 0:H.top)??0);if(m.current.set(T.pointerId,{x:U,y:Z}),m.current.size===1){const ge=N.current;I.current={pointerId:T.pointerId,originX:ge.x,originY:ge.y,startX:U,startY:Z}}else I.current=null,J();T.currentTarget.setPointerCapture(T.pointerId)},K=T=>{var z;const H=(z=d.current)==null?void 0:z.getBoundingClientRect(),U=T.clientX-((H==null?void 0:H.left)??0),Z=T.clientY-((H==null?void 0:H.top)??0);if(m.current.has(T.pointerId)&&m.current.set(T.pointerId,{x:U,y:Z}),w.current&&m.current.size>=2){const[E,p]=[...m.current.values()],P=Math.hypot(p.x-E.x,p.y-E.y);if(Number.isFinite(P)&&P>0){S.current=!0,L.current=Date.now()+240;const _=(E.x+p.x)/2,ve=(E.y+p.y)/2,oe=w.current,Me=Ks(oe.startScale*P/oe.startDistance,.24,1.42),Oe=(oe.startMidpointX-oe.startViewportX)/oe.startScale,ze=(oe.startMidpointY-oe.startViewportY)/oe.startScale;k({scale:Me,x:_-Oe*Me,y:ve-ze*Me})}return}if(!I.current||I.current.pointerId!==T.pointerId||m.current.size!==1)return;S.current=!0;const ie=U-I.current.startX,ge=Z-I.current.startY;(Math.abs(ie)>3||Math.abs(ge)>3)&&(L.current=Date.now()+240),k(E=>{var p,P;return{...E,x:(((p=I.current)==null?void 0:p.originX)??E.x)+ie,y:(((P=I.current)==null?void 0:P.originY)??E.y)+ge}})},D=T=>{if(m.current.delete(T.pointerId),m.current.size<2&&(w.current=null),m.current.size===1){const[H,U]=[...m.current.entries()][0]??[];if(H!=null&&U){const Z=N.current;I.current={pointerId:H,originX:Z.x,originY:Z.y,startX:U.x,startY:U.y}}}else I.current=null;T.currentTarget.hasPointerCapture(T.pointerId)&&T.currentTarget.releasePointerCapture(T.pointerId)},F=$??h??null,W=y.useCallback(T=>{Date.now()<L.current||(l==null||l(T.id),T.href&&u(T.href))},[u,l]);return e.jsxs("section",{"data-testid":f,className:Q("overflow-hidden rounded-[32px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(125,211,252,0.12),transparent_32%),linear-gradient(180deg,rgba(11,18,31,0.985),rgba(7,12,23,0.98))] shadow-[0_26px_90px_rgba(2,6,16,0.38)]","px-3 py-3 sm:px-4 sm:py-4 lg:px-5 lg:py-5"),children:[e.jsxs("div",{className:"mb-3 flex min-w-0 flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[rgba(125,211,252,0.82)]",children:"Gravity well"}),e.jsx("h2",{className:Q("mt-2 font-display leading-none text-white",g?"text-[clamp(1.25rem,2vw,1.7rem)]":"text-[clamp(1.45rem,2.8vw,2.3rem)]"),children:r}),i?e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-6 text-white/54",children:v?"Select a node, pan the field, and open the full map when you need the wider structure.":i}):null]}),e.jsx("div",{className:"flex min-w-0 flex-wrap items-center justify-end gap-2",children:n})]}),e.jsxs("div",{ref:d,className:Q("group relative overflow-hidden rounded-[30px] border border-white/6 bg-[radial-gradient(circle_at_center,rgba(255,255,255,0.04),transparent_46%)] touch-none",x),style:{touchAction:"none"},onWheel:G,onPointerDown:se,onPointerMove:K,onPointerUp:D,onPointerCancel:D,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_center,rgba(110,231,183,0.06),transparent_28%),radial-gradient(circle_at_20%_20%,rgba(196,181,253,0.08),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.015),rgba(4,8,18,0.24))]"}),e.jsxs("div",{className:"absolute left-3 top-3 z-10 inline-flex max-w-[calc(100%-7rem)] items-center gap-2 rounded-full border border-white/8 bg-[rgba(8,14,25,0.78)] px-2.5 py-1.5 text-[11px] uppercase tracking-[0.18em] text-white/42 backdrop-blur-xl sm:left-4 sm:top-4 sm:max-w-none sm:px-3",onPointerDown:T=>T.stopPropagation(),children:[e.jsx(Fr,{className:"size-3.5"}),v?"Drag or pinch":"Drag to pan, scroll to zoom"]}),e.jsxs("div",{className:"absolute right-3 top-3 z-10 flex max-w-[calc(100%-1.5rem)] flex-wrap items-center justify-end gap-1.5 sm:right-4 sm:top-4 sm:max-w-none sm:gap-2",onPointerDown:T=>T.stopPropagation(),children:[e.jsx(X,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom in",onClick:()=>{S.current=!0,R(j.scale*1.12,b.width-96,72)},children:e.jsx(St,{className:"size-4"})}),e.jsx(X,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:px-3","aria-label":"Zoom out",onClick:()=>{S.current=!0,R(j.scale*.88,b.width-96,72)},children:e.jsx(qr,{className:"size-4"})}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[4.75rem] sm:px-3","aria-label":"Fit graph",onClick:()=>{S.current=!0,C()},children:[e.jsx(Br,{className:"size-4"}),v?null:"Fit"]}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",className:"px-2.5 sm:min-w-[5.5rem] sm:px-3","aria-label":"Reset graph",onClick:()=>{S.current=!1,C()},children:[e.jsx(zr,{className:"size-4"}),v?null:"Reset"]})]}),o&&o.length>0&&!v?e.jsx("div",{className:"absolute bottom-4 left-4 z-10 flex flex-wrap items-center gap-2 rounded-[24px] border border-white/8 bg-[rgba(8,14,25,0.76)] px-3 py-2 text-xs text-white/58 backdrop-blur-xl",children:o.map(T=>{const H=T.kind?Xd(T.kind):T.tone??"slate",U=T.kind?ot(T.kind).icon:null;return e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap rounded-full bg-white/[0.04] px-2.5 py-1.5",children:[U?e.jsx(U,{className:"size-3.5",color:pt[H],strokeWidth:2.1}):e.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:ut[H]}}),T.label]},T.label)})}):null,e.jsxs("svg",{className:"relative z-[1] h-full w-full",viewBox:`0 0 ${b.width||1200} ${b.height||760}`,role:"img","aria-label":r,children:[e.jsx("defs",{children:e.jsx("filter",{id:"forge-graph-blur",children:e.jsx("feGaussianBlur",{stdDeviation:"34"})})}),e.jsxs("g",{transform:`translate(${j.x} ${j.y}) scale(${j.scale})`,children:[a.map(T=>e.jsx("ellipse",{cx:T.x,cy:T.y,rx:T.radiusX,ry:T.radiusY,fill:zs[T.tone??"rose"],opacity:T.opacity??.42,filter:"url(#forge-graph-blur)"},T.id)),t.filter(T=>T.kind==="goal"||T.kind==="ghost").map(T=>{const H=T.radius??76;return e.jsx("g",{opacity:T.kind==="ghost"?.28:.55,children:[H+74,H+124].map((U,Z)=>e.jsx("circle",{cx:T.x,cy:T.y,r:U,fill:"none",stroke:Z===0?"rgba(255,255,255,0.08)":"rgba(255,255,255,0.045)",strokeDasharray:Z===0?"0":"10 10"},`${T.id}-ring-${U}`))},`${T.id}-orbital-lanes`)}),s.map(T=>{const H=O.get(T.from),U=O.get(T.to);if(!H||!U)return null;const Z=Xi(H),ie=Xi(U),ge=(Z.x+ie.x)/2,z=(Z.y+ie.y)/2,E=Math.max(24,Math.abs(Z.x-ie.x)*.08),p=ge,P=z-E;return e.jsx("path",{d:`M ${Z.x} ${Z.y} Q ${p} ${P} ${ie.x} ${ie.y}`,fill:"none",stroke:ut[T.tone??"slate"],strokeWidth:T.strength==="high"?3:T.strength==="medium"?2.2:1.6,strokeDasharray:T.dashed?"8 8":void 0,opacity:F&&T.from!==F&&T.to!==F?.18:.62},T.id)}),t.map(T=>{T.id;const H=$===T.id,U=F===T.id,Z=qd(T),ie=Bd(T),ge=Kd(T),z=Jn(T.kind),E=z?ot(z).icon:null;if(T.kind==="goal"||T.kind==="value"||T.kind==="ghost"){const Ie=T.radius??(T.kind==="goal"?76:34),ne=ie?T.y-Ie-(T.kind==="goal"?18:10):null,we=T.kind==="goal"?20:14.5,fe=T.kind==="goal"?28:16,be=T.kind==="goal"?T.y-Ie*.34:T.kind==="value"?T.y-Ie*.3:T.y-Ie*.2,Ge=T.kind==="goal"?T.y+Ie*.2:T.y+10;return e.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{M(T.id),l==null||l(T.id)},onPointerLeave:()=>M(he=>he===T.id?null:he),onFocus:()=>l==null?void 0:l(T.id),onClick:()=>W(T),onKeyDown:he=>{(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),W(T))},className:"cursor-pointer outline-none",children:[e.jsx("circle",{cx:T.x,cy:T.y,r:Ie+(U?14:0),fill:U?`${ut[Z]}22`:"transparent",stroke:U?ut[Z]:"transparent",opacity:H?.98:.9}),e.jsx("circle",{cx:T.x,cy:T.y,r:Ie+(H?2:0),fill:T.kind==="ghost"?"rgba(255,255,255,0.03)":zs[Z],stroke:T.kind==="ghost"?"rgba(255,255,255,0.18)":ut[Z],strokeDasharray:T.kind==="ghost"?"8 8":void 0,strokeWidth:U?2.8:1.6}),ie?e.jsx("text",{x:T.x,y:ne??T.y-12,textAnchor:"middle",fontSize:T.kind==="goal"?"11.5":"10.5",fill:T.kind==="ghost"?"rgba(255,255,255,0.62)":pt[Z],style:{letterSpacing:"0.18em",textTransform:"uppercase"},children:ie}):null,E?e.jsx(E,{x:T.x-fe/2,y:be-fe/2,width:fe,height:fe,color:pt[Z],strokeWidth:2.1}):null,ge.map((he,We)=>e.jsx("text",{x:T.x,y:Ge+We*we-(ge.length-1)*we/2,textAnchor:"middle",fontSize:T.kind==="goal"?21:12.8,fontWeight:T.kind==="goal"?600:500,fill:T.kind==="ghost"?"rgba(255,255,255,0.92)":pt[Z],children:he},`${T.id}-${he}-${We}`))]},T.id)}const p=T.width??146,P=T.height??58,_=T.x-p/2,ve=T.y-P/2,oe=T.kind==="project"?14:13,Me=_+14,Oe=ve+13,ze=ve+22,mt=ie?ve+P*.65:ve+P*.56,tt=T.kind==="project"?16:15,ht=T.kind==="project"?14.2:13.2;return e.jsxs("g",{tabIndex:0,role:"button",onPointerEnter:()=>{M(T.id),l==null||l(T.id)},onPointerLeave:()=>M(Ie=>Ie===T.id?null:Ie),onFocus:()=>l==null?void 0:l(T.id),onClick:()=>W(T),onKeyDown:Ie=>{(Ie.key==="Enter"||Ie.key===" ")&&(Ie.preventDefault(),W(T))},className:"cursor-pointer outline-none",children:[e.jsx("rect",{x:_-(U?6:0),y:ve-(U?6:0),rx:"28",ry:"28",width:p+(U?12:0),height:P+(U?12:0),fill:U?`${ut[Z]}22`:"transparent"}),e.jsx("rect",{x:_-(H?2:0),y:ve-(H?2:0),rx:"22",ry:"22",width:p+(H?4:0),height:P+(H?4:0),fill:zs[Z],stroke:ut[Z],strokeWidth:U?2.3:1.3}),E?e.jsx(E,{x:Me,y:Oe,width:oe,height:oe,color:pt[Z],strokeWidth:2.1}):null,ie?e.jsx("text",{x:Me+oe+8,y:ze,textAnchor:"start",fontSize:"9.5",fill:pt[Z],style:{letterSpacing:"0.16em",textTransform:"uppercase",opacity:.82},children:ie}):null,ge.map((Ie,ne)=>e.jsx("text",{x:T.x,y:mt+ne*tt-(ge.length-1)*tt/2,textAnchor:"middle",fontSize:ht,fontWeight:600,fill:pt[Z],children:Ie},`${T.id}-${Ie}-${ne}`))]},T.id)})]})]})]})]})}const Gi={intent:"trigger_report",linkedGoalId:"",linkedProjectId:"",linkedTaskId:""};function Gd({open:t,onOpenChange:s}){const a=Ve(),r=Le(),[i,n]=y.useState(Gi),o=[{id:"intent",eyebrow:"Reflect",title:"What do you want to reflect on?",description:"Choose the entrypoint first. Forge will route you into the right guided flow instead of dropping you into a generic form.",render:(l,x)=>e.jsx(Re,{columns:3,value:l.intent,onChange:g=>x({intent:g}),options:[{value:"trigger_report",label:"A situation",description:"Start a Spark-to-Pivot report about something that happened."},{value:"behavior",label:"A behavior",description:"Trace an away move, committed action, or recovery path."},{value:"belief",label:"A belief script",description:"Capture or refine the belief beneath the reaction."},{value:"pattern",label:"A recurring pattern",description:"Map the loop, payoff, cost, and better response."},{value:"value",label:"A blocked value",description:"Clarify which value is being challenged or needs support."},{value:"execution_tension",label:"A goal tension",description:"Reflect on a goal, project, or task that carries friction."}]})},{id:"placement",eyebrow:"Placement",title:"Attach the reflection to the wider system",description:"This keeps the reflection connected to values, behaviors, and live work instead of becoming an isolated note.",render:(l,x)=>e.jsx("div",{className:"grid gap-4",children:e.jsx(q,{label:"Goal / project / task tension",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(re,{kind:"goal",label:"Goal",compact:!0,gradient:!1}),e.jsx(re,{kind:"project",label:"Project",compact:!0,gradient:!1}),e.jsx(re,{kind:"task",label:"Task",compact:!0,gradient:!1})]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:l.linkedGoalId,onChange:g=>x({linkedGoalId:g.target.value}),children:[e.jsx("option",{value:"",children:"No goal selected"}),r.snapshot.goals.map(g=>e.jsxs("option",{value:g.id,children:["Goal · ",g.title]},g.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:l.linkedProjectId,onChange:g=>x({linkedProjectId:g.target.value}),children:[e.jsx("option",{value:"",children:"No project selected"}),r.snapshot.dashboard.projects.map(g=>e.jsxs("option",{value:g.id,children:["Project · ",g.title]},g.id))]}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:l.linkedTaskId,onChange:g=>x({linkedTaskId:g.target.value}),children:[e.jsx("option",{value:"",children:"No task selected"}),r.snapshot.tasks.slice(0,40).map(g=>e.jsxs("option",{value:g.id,children:["Task · ",g.title]},g.id))]})]})})})}],h=async()=>{const l=new URLSearchParams({create:"1",intent:i.intent});switch(i.linkedGoalId&&l.set("goalId",i.linkedGoalId),i.linkedProjectId&&l.set("projectId",i.linkedProjectId),i.linkedTaskId&&l.set("taskId",i.linkedTaskId),i.intent){case"behavior":a(`/psyche/behaviors?${l.toString()}`);break;case"belief":a(`/psyche/schemas-beliefs?${l.toString()}`);break;case"pattern":a(`/psyche/patterns?${l.toString()}`);break;case"value":a(`/psyche/values?${l.toString()}`);break;case"execution_tension":case"trigger_report":default:a(`/psyche/reports?${l.toString()}`);break}s(!1),n(Gi)};return e.jsx(qe,{open:t,onOpenChange:s,eyebrow:"Reflect",title:"Start from the right reflective doorway",description:"Choose what you want to reflect on first. Forge will take you into the right guided flow instead of leaving you in a generic form.",value:i,onChange:n,steps:o,submitLabel:"Open guided reflection",onSubmit:h})}const ss=[{to:"/psyche",label:"Overview",icon:aa},{to:"/psyche/values",label:"Values",icon:Kr},{to:"/psyche/patterns",label:"Patterns",icon:Xr},{to:"/psyche/behaviors",label:"Behaviors",icon:Gr},{to:"/psyche/reports",label:"Reports",icon:dn},{to:"/psyche/goal-map",label:"Goal Map",icon:Qr},{to:"/psyche/schemas-beliefs",label:"Schemas & Beliefs",icon:Wr},{to:"/psyche/modes",label:"Modes",icon:Hr}];function Xs(t,s){return t===s||t.startsWith(`${s}/`)}function Ue({className:t}){const s=oa(),[a,r]=y.useState(!1),i=y.useMemo(()=>[...ss].sort((n,o)=>o.to.length-n.to.length).find(n=>Xs(s.pathname,n.to))??ss[0],[s.pathname]);return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{className:Q("overflow-hidden bg-[linear-gradient(180deg,rgba(15,24,31,0.94),rgba(10,18,25,0.92))] p-2",t),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(n=>e.jsxs(gt,{to:n.to,className:({isActive:o})=>Q("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",o||Xs(s.pathname,n.to)?"bg-[rgba(110,231,183,0.18)] text-[var(--tertiary)]":"bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"),children:[e.jsx(n.icon,{className:"size-3.5"}),e.jsx("span",{children:n.label})]},n.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsxs("button",{type:"button",className:"inline-flex min-w-0 flex-1 items-center justify-between rounded-full bg-white/[0.06] px-4 py-3 text-left",onClick:()=>r(!0),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(i.icon,{className:"size-4 shrink-0 text-[var(--tertiary)]"}),e.jsx("span",{className:"truncate text-sm font-medium text-white",children:i.label})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.16em] text-white/42",children:"Switch"})]})})]}),a?e.jsx("div",{className:"fixed inset-0 z-50 bg-[rgba(5,10,18,0.86)] px-4 py-5 backdrop-blur-xl lg:hidden",children:e.jsxs("div",{className:"mx-auto flex h-full max-w-xl flex-col rounded-[32px] bg-[linear-gradient(180deg,rgba(16,25,33,0.98),rgba(11,18,25,0.98))] p-5 shadow-[0_30px_80px_rgba(0,0,0,0.35)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Psyche sections"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:"Move through the inner map"})]}),e.jsx(X,{variant:"secondary",onClick:()=>r(!1),children:"Close"})]}),e.jsx("div",{className:"mt-6 grid gap-3 overflow-y-auto",children:ss.map(n=>e.jsxs(gt,{to:n.to,onClick:()=>r(!1),className:Q("flex items-center justify-between rounded-[24px] px-4 py-4 transition",Xs(s.pathname,n.to)?"bg-[rgba(110,231,183,0.14)] text-white":"bg-white/[0.04] text-white/70"),children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(n.icon,{className:"size-4 text-[var(--tertiary)]"}),e.jsx("span",{className:"text-base font-medium",children:n.label})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.16em] text-white/36",children:"Open"})]},n.to))})]})}):null]})}function Qd(){var b;const t=Le(),[s,a]=Ze(),[r,i]=y.useState(s.get("reflect")==="1"),[n,o]=y.useState(null),h=te({queryKey:["forge-psyche-overview"],queryFn:Tn}),l=(b=h.data)==null?void 0:b.overview,x=y.useMemo(()=>l?t.snapshot.goals.slice(0,3).map(c=>{const j=l.values.filter(N=>N.linkedGoalIds.includes(c.id)),k=t.snapshot.dashboard.projects.filter(N=>N.goalId===c.id),$=l.reports.filter(N=>N.linkedGoalIds.includes(c.id)),M=l.behaviors.filter(N=>N.linkedValueIds.some(m=>j.some(w=>w.id===m))),I=l.beliefs.filter(N=>N.linkedValueIds.some(m=>j.some(w=>w.id===m)));return{goal:c,linkedValues:j,linkedProjects:k,linkedReports:$,linkedBehaviors:M,linkedBeliefs:I}}):[],[l,t.snapshot.dashboard.projects,t.snapshot.goals]),g=y.useMemo(()=>Yn(x,{compact:!0}),[x]);if(y.useEffect(()=>{o(g.defaultSelectedId)},[g.defaultSelectedId]),h.isLoading)return e.jsx(et,{});if(h.isError||!l)return e.jsx(je,{eyebrow:"Psyche",error:h.error,onRetry:()=>void h.refetch()});const f=g.inspectors[n??g.defaultSelectedId]??g.inspectors[g.defaultSelectedId],d=l.patterns[0]??null,u=l.reports[0]??null;return e.jsxs("div",{className:"grid min-w-0 gap-4 overflow-x-clip",children:[e.jsx(ke,{title:"Psyche",titleText:"Psyche",description:"See your goals, values, beliefs, behaviors, projects, and reports together, then open the goal map when you want the full structure.",badge:`${l.domain.title} active`,actions:e.jsx(e.Fragment,{children:e.jsx(xe,{to:"/psyche/goal-map",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-full bg-white/[0.08] px-4 py-2 text-sm whitespace-nowrap text-white transition hover:bg-white/[0.12]",children:"Open goal map"})})}),e.jsx(Ue,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_19rem]",children:[e.jsx(Vn,{testId:"psyche-hub-graph",compact:!0,title:"Reflective pulse and live entity field",hint:"This is the live field. Select any goal, value, belief, behavior, project, or report, then open the full goal map when you want the wider structure.",nodes:g.nodes,edges:g.edges,fields:g.fields,selectedNodeId:n,onSelectNode:o,minHeightClassName:"min-h-[20rem] sm:min-h-[24rem] lg:min-h-[34rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Behaviors",kind:"behavior"}],action:e.jsxs(e.Fragment,{children:[e.jsx(xe,{to:"/psyche/goal-map",className:"inline-flex min-h-10 min-w-0 max-w-full items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-4 py-2 text-sm font-medium whitespace-nowrap text-white transition hover:bg-white/12",children:"Open goal map"}),e.jsx(X,{size:"sm",className:"min-w-0 sm:min-w-[6.5rem]",onClick:()=>i(!0),children:"Reflect"})]})}),e.jsxs(Y,{className:"h-fit min-w-0 xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:f.entityKind?e.jsx(re,{kind:f.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:f.eyebrow})}),e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:f.entityKind?e.jsx(ue,{kind:f.entityKind,label:f.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"font-display text-[clamp(1.25rem,2.2vw,1.8rem)] leading-none text-white",children:f.title})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:f.summary}),f.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:f.chips.map(c=>e.jsx(B,{className:"bg-white/[0.08] text-white/74",children:c},c))}):null,f.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:f.stats.map(c=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/68",children:c},c))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(xe,{to:f.href,className:Q("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[0_12px_30px_rgba(192,193,255,0.08)]",f.entityKind?_t(f.entityKind,!0):"bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] text-white"),children:f.ctaLabel})})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(at,{to:"/psyche/behaviors",className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(17,29,32,0.96),rgba(11,21,23,0.94))] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-[rgba(110,231,183,0.82)]",children:"Best next reflective move"}),e.jsx("div",{className:"mt-3 font-display text-[clamp(1.45rem,2.2vw,2rem)] leading-none text-white",children:(d==null?void 0:d.preferredResponse)||"Map the active loop, then name the committed move that brings you back."}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/58",children:(d==null?void 0:d.targetBehavior)||"When the loop is explicit, the return path stops feeling abstract."})]}),e.jsxs(at,{to:u?`/psyche/reports/${u.id}`:"/psyche/reports",className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(24,19,37,0.96),rgba(13,12,22,0.94))] p-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-violet-100/72",children:"Open threads"}),e.jsxs("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Insights"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:l.openInsights})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] px-4 py-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Notes"}),e.jsx("div",{className:"mt-2 font-display text-4xl text-white",children:l.openNotes})]})]}),e.jsx("div",{className:"mt-4 text-sm text-white/60",children:(u==null?void 0:u.title)||"Open the next chain and keep the report field live without adding more dashboard noise."})]})]}),e.jsx(Gd,{open:r,onOpenChange:c=>{i(c);const j=new URLSearchParams(s);j.delete("reflect"),a(j,{replace:!0})}})]})}function Je({eyebrow:t,title:s,description:a,titleHelp:r,tone:i="default",children:n,className:o}){const h={default:"bg-[linear-gradient(180deg,rgba(17,24,35,0.96),rgba(11,16,24,0.94))]",mint:"bg-[radial-gradient(circle_at_top_left,rgba(110,231,183,0.14),transparent_42%),linear-gradient(180deg,rgba(14,28,31,0.96),rgba(10,20,24,0.94))]",sky:"bg-[radial-gradient(circle_at_top_left,rgba(125,211,252,0.14),transparent_42%),linear-gradient(180deg,rgba(16,25,34,0.96),rgba(10,17,24,0.94))]",violet:"bg-[radial-gradient(circle_at_top_left,rgba(196,181,253,0.14),transparent_42%),linear-gradient(180deg,rgba(20,19,35,0.96),rgba(12,13,24,0.94))]",rose:"bg-[radial-gradient(circle_at_top_left,rgba(251,113,133,0.14),transparent_42%),linear-gradient(180deg,rgba(31,18,24,0.96),rgba(18,11,16,0.94))]",amber:"bg-[radial-gradient(circle_at_top_left,rgba(251,191,36,0.14),transparent_42%),linear-gradient(180deg,rgba(32,24,16,0.96),rgba(20,15,10,0.94))]"};return e.jsxs("section",{className:Q("min-w-0 overflow-hidden rounded-[30px] border border-white/8 px-4 py-5 shadow-[0_24px_70px_rgba(4,8,18,0.28)] sm:px-5 lg:px-6",h[i],o),children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:t}),e.jsxs("div",{className:"mt-3 flex min-w-0 items-start gap-2",children:[e.jsx("h2",{className:"min-w-0 font-display text-[clamp(1.8rem,3.2vw,3rem)] leading-none text-white",children:s}),r?e.jsx(Ne,{content:r,label:`Explain ${s.toLowerCase()}`,className:"mt-1 shrink-0"}):null]}),a?e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-white/60",children:a}):null,e.jsx("div",{className:"mt-5 min-w-0",children:n})]})}function Gs(t){return t.trim().toLowerCase()}function Qi(t,s){return t.includes(s)?t:[...t,s]}function Ae({options:t,selectedValues:s,onChange:a,placeholder:r="Search or create…",emptyMessage:i="No matching entries yet.",createLabel:n="Create",onCreate:o,className:h}){const[l,x]=y.useState(""),[g,f]=y.useState(!1),[d,u]=y.useState(0),[b,c]=y.useState(!1),[j,k]=y.useState(null),[$,M]=y.useState([]),I=y.useMemo(()=>{const v=new Map;return[...$,...t].forEach(C=>{v.set(C.value,C)}),Array.from(v.values())},[$,t]),N=y.useMemo(()=>s.map(v=>I.find(C=>C.value===v)??{value:v,label:v}),[I,s]),m=Gs(l),w=y.useMemo(()=>{const v=I.filter(C=>!s.includes(C.value));return m?v.filter(C=>`${C.label} ${C.description??""} ${C.searchText??""}`.toLowerCase().includes(m)).slice(0,8):v.slice(0,8)},[I,m,s]),L=I.some(v=>Gs(v.label)===m),S=v=>{a(Qi(s,v)),x(""),k(null),u(0),f(!1)},O=v=>{a(s.filter(C=>C!==v))},A=async()=>{const v=l.trim();if(!(!o||!v)){c(!0);try{const C=await o(v);M(R=>R.some(J=>J.value===C.value)?R:[C,...R]),a(Qi(s,C.value)),x(""),k(null),u(0),f(!1)}catch(C){k(C instanceof Error?C.message:"Unable to create that link right now.")}finally{c(!1)}}};return e.jsxs("div",{className:Q("relative grid gap-2",h),children:[e.jsxs("div",{className:"rounded-[22px] border border-white/10 bg-white/[0.04] px-3 py-3",children:[N.length>0?e.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:N.map(v=>e.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[v.kind?e.jsx(re,{kind:v.kind,label:v.label,compact:!0,className:"max-w-[16rem]"}):v.badge?v.badge:e.jsx("span",{className:"inline-flex items-center gap-2 rounded-full bg-white/[0.08] px-3 py-1.5 text-sm text-white/78",children:e.jsx("span",{className:"max-w-[16rem] truncate",children:v.label})}),e.jsx("button",{type:"button",className:"rounded-full text-white/50 transition hover:text-white","aria-label":`Remove ${v.label}`,onClick:()=>O(v.value),children:e.jsx(Pt,{className:"size-3.5"})})]},v.value))}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"size-4 text-white/34"}),e.jsx("input",{value:l,onChange:v=>{x(v.target.value),k(null),f(!0),u(0)},onFocus:()=>f(!0),onBlur:()=>{window.setTimeout(()=>f(!1),120)},onKeyDown:v=>{if(v.key==="Backspace"&&!l&&s.length>0){O(s[s.length-1]);return}if(v.key==="ArrowDown"){v.preventDefault(),f(!0),u(J=>w.length===0?0:Math.min(w.length-1,J+1));return}if(v.key==="ArrowUp"){v.preventDefault(),u(J=>Math.max(0,J-1));return}if(v.key==="Escape"){f(!1);return}if(v.key!=="Enter")return;v.preventDefault();const C=w[d];if(C){S(C.value);return}const R=I.find(J=>Gs(J.label)===m);if(R&&!s.includes(R.value)){S(R.value);return}A()},placeholder:r,className:"min-w-0 flex-1 bg-transparent text-sm text-white placeholder:text-white/34 focus:outline-none"})]})]}),g?e.jsxs("div",{className:"absolute top-full z-20 mt-1.5 max-h-64 w-full overflow-y-auto rounded-[22px] border border-white/10 bg-[rgba(10,15,27,0.96)] p-2 shadow-[0_26px_60px_rgba(4,8,18,0.32)] backdrop-blur-xl",children:[w.map((v,C)=>e.jsx("button",{type:"button",className:Q("flex w-full items-start justify-between gap-3 rounded-[18px] px-3 py-2.5 text-left transition",C===d?"bg-white/[0.1] text-white":"text-white/70 hover:bg-white/[0.06] hover:text-white"),onMouseEnter:()=>u(C),onMouseDown:R=>R.preventDefault(),onClick:()=>S(v.value),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:v.kind?e.jsx(re,{kind:v.kind,label:v.label,compact:!0,gradient:!1}):v.menuBadge?v.menuBadge:v.badge?v.badge:v.label}),v.description?e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/46",children:v.description}):null]})},v.value)),!L&&m&&o?e.jsxs("button",{type:"button",disabled:b,className:"mt-1 flex w-full items-center gap-2 rounded-[18px] px-3 py-2.5 text-left text-sm text-[var(--secondary)] transition hover:bg-white/[0.06] disabled:opacity-50",onMouseDown:v=>v.preventDefault(),onClick:()=>void A(),children:[e.jsx(St,{className:"size-4"}),e.jsx("span",{className:"truncate",children:b?"Creating…":`${n} "${l.trim()}"`})]}):null,w.length===0&&(!m||L||!o)?e.jsx("div",{className:"px-3 py-2.5 text-sm text-white/42",children:i}):null]}):null,j?e.jsx("div",{className:"text-sm text-rose-300",children:j}):null]})}function Wd({entries:t}){const s={away:"border-rose-400/20 bg-[rgba(251,113,133,0.08)]",committed:"border-emerald-400/20 bg-[rgba(110,231,183,0.08)]",recovery:"border-amber-400/20 bg-[rgba(251,191,36,0.08)]"};return e.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:t.map(a=>e.jsxs(xe,{to:a.href,className:`rounded-[22px] border px-4 py-4 transition hover:-translate-y-0.5 ${s[a.tone]}`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:a.tone}),e.jsx("div",{className:"mt-2 font-medium text-white",children:a.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:a.summary}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 text-sm text-white/54",children:["Open",e.jsx(vt,{className:"size-3.5"})]})]},a.id))})}const Hd={maladaptive:"Maladaptive schema",adaptive:"Adaptive schema"},Ud={maladaptive:"A recurring pressure pattern that can distort how you interpret situations or respond.",adaptive:"A stable healthy belief pattern you want to strengthen and rely on."},Yd={disconnection_rejection:"Disconnection & rejection",impaired_autonomy:"Autonomy & competence",other_directedness:"Boundaries & mutuality",overvigilance_inhibition:"Standards & inhibition",healthy_selfhood:"Healthy selfhood"};function Es(t){return Hd[t]}function $t(t){return Ud[t]}function Ta(t){return Yd[t]??t.replaceAll("_"," ")}function Ct(t){return t==="adaptive"?{sectionTone:"border-emerald-400/14 bg-[linear-gradient(180deg,rgba(26,53,48,0.72),rgba(10,18,30,0.92))]",sectionEyebrow:"text-emerald-200/84",cardTone:"border-emerald-400/14 bg-[linear-gradient(180deg,rgba(28,63,56,0.44),rgba(14,24,36,0.92))]",badgeTone:"border-emerald-300/18 bg-[linear-gradient(135deg,rgba(16,185,129,0.18),rgba(56,189,248,0.12))] text-emerald-50",subtleBadgeTone:"border-emerald-300/12 bg-[rgba(16,185,129,0.1)] text-emerald-100/88",countLabel:"support links",linkSummary:"linked strengthening belief",emptyCopy:"No adaptive schema is linked yet. Add one when you want to capture the healthier pattern you are building from."}:{sectionTone:"border-fuchsia-400/14 bg-[linear-gradient(180deg,rgba(44,28,58,0.72),rgba(10,18,30,0.92))]",sectionEyebrow:"text-fuchsia-200/84",cardTone:"border-violet-400/14 bg-[linear-gradient(180deg,rgba(48,33,68,0.44),rgba(14,18,34,0.92))]",badgeTone:"border-rose-300/18 bg-[linear-gradient(135deg,rgba(244,63,94,0.16),rgba(168,85,247,0.12))] text-rose-50",subtleBadgeTone:"border-rose-300/12 bg-[rgba(244,63,94,0.1)] text-rose-100/88",countLabel:"linked records",linkSummary:"linked belief",emptyCopy:"No maladaptive schema is linked yet. Add one when you want to capture the recurring old pattern clearly."}}function Wi(t){return t.trim().toLowerCase()}function Zn(t,s){const a=Wi(s);return[t.id,t.slug,t.title].some(r=>Wi(r)===a)}function It(t,s){return s.find(a=>Zn(a,t))??null}function er(t,s){const a=t.filter(r=>!Zn(s,r));return a.length===t.length?[...a,s.id]:a}function rt({label:t,schemaType:s,compact:a=!1,showType:r=!1,className:i}){const n=Ct(s);return e.jsxs("span",{className:Q("inline-flex max-w-full min-w-0 items-center gap-2 rounded-full border px-3 py-1.5 text-sm leading-tight shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",a?"min-h-8":"min-h-9",n.badgeTone,i),children:[r?e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-white/58",children:Es(s)}):null,e.jsx("span",{className:"min-w-0 break-words whitespace-normal",children:t})]})}function Jd(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ut(t){y.useEffect(()=>{if(!t||typeof document>"u")return;const s=window.requestAnimationFrame(()=>{const a=document.querySelector(`[data-psyche-focus-id="${Jd(t)}"]`);a&&a.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})});return()=>window.cancelAnimationFrame(s)},[t])}function Yt(t){return t?"border-[rgba(125,211,252,0.28)] bg-[linear-gradient(180deg,rgba(125,211,252,0.14),rgba(255,255,255,0.06))] shadow-[0_24px_60px_rgba(56,189,248,0.14)]":""}function _e(t,s,a,r){t.setQueryData(s,i=>{const n=(i==null?void 0:i[a])??[];return n.some(o=>o.id===r.id)?i:{...i??{},[a]:[r,...n]}})}const me=ee().trim(),Ce=me.min(1),Vd=ce(Ce).transform(t=>Array.from(new Set(t))),Hi=Se({title:Ce,description:me,valuedDirection:Ce,whyItMatters:me,linkedGoalIds:ce(ee()).default([]),linkedProjectIds:ce(ee()).default([]),linkedTaskIds:ce(ee()).default([]),committedActions:ce(me).default([])}),Ui=Se({title:Ce,description:me,targetBehavior:Ce,cueContexts:ce(me).default([]),shortTermPayoff:me,longTermCost:me,preferredResponse:Ce,linkedValueIds:ce(ee()).default([]),linkedSchemaLabels:Vd.default([]),linkedModeIds:ce(ee()).default([]),linkedBeliefIds:ce(ee()).default([])}),Yi=Se({kind:Ee(["away","committed","recovery"]),title:Ce,description:me,commonCues:ce(me).default([]),urgeStory:me,shortTermPayoff:me,longTermCost:me,replacementMove:me,repairPlan:me,linkedPatternIds:ce(ee()).default([]),linkedValueIds:ce(ee()).default([]),linkedSchemaIds:ce(ee()).default([]),linkedModeIds:ce(ee()).default([])}),Ji=Se({schemaId:ee().nullable(),statement:Ce,beliefType:Ee(["absolute","conditional"]),originNote:me,confidence:un().int().min(0).max(100),evidenceFor:ce(me).default([]),evidenceAgainst:ce(me).default([]),flexibleAlternative:me,linkedValueIds:ce(ee()).default([]),linkedBehaviorIds:ce(ee()).default([]),linkedModeIds:ce(ee()).default([]),linkedReportIds:ce(ee()).default([])}),Vi=Se({family:Ee(["coping","child","critic_parent","healthy_adult","happy_child"]),archetype:me,title:Ce,persona:me,imagery:me,symbolicForm:me,facialExpression:me,fear:me,burden:me,protectiveJob:me,originContext:me,firstAppearanceAt:ee().trim().nullable(),linkedPatternIds:ce(ee()).default([]),linkedBehaviorIds:ce(ee()).default([]),linkedValueIds:ce(ee()).default([])}),Zd=Se({summary:Ce,answers:ce(Se({questionKey:Ce,value:Ce})).min(1)});Se({label:Ce,description:me});Se({label:Ce,description:me,category:me});const ec=Se({id:Ce,emotionDefinitionId:ee().nullable(),label:Ce,intensity:un().int().min(0).max(100),note:me}),tc=Se({id:Ce,text:Ce,parentMode:me,criticMode:me,beliefId:ee().nullable()}),sc=Se({id:Ce,text:Ce,mode:me,behaviorId:ee().nullable()}),ac=Se({id:Ce,stage:Ce,modeId:ee().nullable(),label:Ce,note:me}),ta=Se({title:Ce,status:Ee(["draft","reviewed","integrated"]).default("draft"),eventTypeId:ee().nullable(),customEventType:me,eventSituation:Ce,occurredAt:ee().trim().nullable(),emotions:ce(ec).default([]),thoughts:ce(tc).default([]),behaviors:ce(sc).default([]),consequences:Se({selfShortTerm:ce(me).default([]),selfLongTerm:ce(me).default([]),othersShortTerm:ce(me).default([]),othersLongTerm:ce(me).default([])}),linkedPatternIds:ce(ee()).default([]),linkedValueIds:ce(ee()).default([]),linkedGoalIds:ce(ee()).default([]),linkedProjectIds:ce(ee()).default([]),linkedTaskIds:ce(ee()).default([]),linkedBehaviorIds:ce(ee()).default([]),linkedBeliefIds:ce(ee()).default([]),linkedModeIds:ce(ee()).default([]),modeOverlays:ce(me).default([]),schemaLinks:ce(me).default([]),modeTimeline:ce(ac).default([]),nextMoves:ce(me).default([])}),as={kind:"away",title:"",description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[]};function ic(t){return{kind:t.kind,title:t.title,description:t.description,commonCues:t.commonCues,urgeStory:t.urgeStory,shortTermPayoff:t.shortTermPayoff,longTermCost:t.longTermCost,replacementMove:t.replacementMove,repairPlan:t.repairPlan,linkedPatternIds:t.linkedPatternIds,linkedValueIds:t.linkedValueIds,linkedSchemaIds:t.linkedSchemaIds,linkedModeIds:t.linkedModeIds}}const Zi={away:"Away moves",committed:"Committed actions",recovery:"Recovery moves"};function nc(){var D,F,W,T,H,U,Z,ie,ge,z,E;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(null),[l,x]=y.useState(as),[g,f]=y.useState(null),d=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),u=te({queryKey:["forge-psyche-patterns"],queryFn:Ss}),b=te({queryKey:["forge-psyche-values"],queryFn:yt}),c=te({queryKey:["forge-psyche-schema-catalog"],queryFn:Qt}),j=te({queryKey:["forge-psyche-modes"],queryFn:jt}),k=((D=d.data)==null?void 0:D.behaviors)??[],$=((F=u.data)==null?void 0:F.patterns)??[],M=((W=b.data)==null?void 0:W.values)??[],I=((T=c.data)==null?void 0:T.schemas)??[],N=((H=j.data)==null?void 0:H.modes)??[],m=a.get("focus"),w=t.snapshot.dashboard.notesSummaryByEntity;Ut(m),y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h(null),x(as);const p=new URLSearchParams(a);p.delete("create"),r(p,{replace:!0})}},[a,r]);const L=de({mutationFn:async p=>{const P=Yi.parse(p);return o?ll(o.id,P):Cs(P)},onSuccess:async()=>{n(!1),h(null),x(as),f(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-behaviors"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),S=$.map(p=>({value:p.id,label:p.title,description:p.preferredResponse||p.targetBehavior,kind:"pattern"})),O=M.map(p=>({value:p.id,label:p.title,description:p.valuedDirection,kind:"value"})),A=I.map(p=>({value:p.id,label:p.title,description:`${p.description} ${Ta(p.family)}`,searchText:`${p.slug} ${p.family} ${p.schemaType}`,badge:e.jsx(rt,{label:p.title,schemaType:p.schemaType,compact:!0}),menuBadge:e.jsx(rt,{label:p.title,schemaType:p.schemaType,compact:!0})})),v=N.map(p=>({value:p.id,label:p.title,description:p.archetype||p.family,kind:"mode"})),C=async p=>{const{pattern:P}=await xa({title:p,description:"",targetBehavior:p,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[]});return _e(s,["forge-psyche-patterns"],"patterns",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.preferredResponse||P.targetBehavior,kind:"pattern"}},R=async p=>{const{value:P}=await Lt({title:p,description:"",valuedDirection:p,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]});return _e(s,["forge-psyche-values"],"values",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.valuedDirection,kind:"value"}},J=async p=>{const{mode:P}=await Ht({family:"coping",archetype:"",title:p,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[]});return _e(s,["forge-psyche-modes"],"modes",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.archetype||P.family,kind:"mode"}},G=[{id:"behavior",eyebrow:"Behavior",title:"Describe the move or urge in plain language",description:"Start with the behavior itself so the map reads like something you can instantly recognize in real life.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Behavior title",children:e.jsx(ae,{value:p.title,onChange:_=>P({title:_.target.value}),placeholder:"Scroll to numb the impact"})}),e.jsx(q,{label:"What does the move look like?",children:e.jsx(le,{value:p.description,onChange:_=>P({description:_.target.value}),placeholder:"Describe the move the way you would recognize it in the moment, not in therapist shorthand."})})]})},{id:"context",eyebrow:"Context",title:"Capture the cue, the pull, and the immediate payoff",description:"Make the move readable as a real pattern instead of a label.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Common cues",children:e.jsx(le,{value:p.commonCues.join(`
|
|
11
|
+
`),onChange:_=>P({commonCues:_.target.value.split(`
|
|
12
|
+
`).map(ve=>ve.trim()).filter(Boolean)}),placeholder:`One line per cue
|
|
13
|
+
Late-night ambiguity
|
|
14
|
+
Feedback after a hard week`})}),e.jsx(q,{label:"What inner push or story shows up?",children:e.jsx(le,{value:p.urgeStory,onChange:_=>P({urgeStory:_.target.value}),placeholder:"What inner push or justification tends to appear?"})}),e.jsx(q,{label:"What do you get right away from this move?",children:e.jsx(le,{value:p.shortTermPayoff,onChange:_=>P({shortTermPayoff:_.target.value}),placeholder:"What relief, certainty, distance, or control does it give in the short term?"})})]})},{id:"classification",eyebrow:"Classification",title:"Now classify the move and define the return path",description:"Once the move is clear, decide whether it is an away move, a committed action, or a recovery path.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Move type",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["away","committed","recovery"].map(_=>e.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${p.kind===_?"border-white/20 bg-white/[0.12] text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07]"}`,onClick:()=>P({kind:_}),children:Zi[_]},_))})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"What does it cost over time?",children:e.jsx(le,{value:p.longTermCost,onChange:_=>P({longTermCost:_.target.value}),placeholder:"What does this move cost over time?"})}),e.jsx(q,{label:"What move should replace or steady it?",children:e.jsx(le,{value:p.replacementMove,onChange:_=>P({replacementMove:_.target.value}),placeholder:"What move should replace this one when possible?"})})]}),e.jsx(q,{label:"If the slip happens, how do you repair and return?",children:e.jsx(le,{value:p.repairPlan,onChange:_=>P({repairPlan:_.target.value}),placeholder:"Describe the repair path without shame or collapse."})})]})},{id:"links",eyebrow:"Links",title:"Attach the move to patterns, values, schemas, and modes",description:"This turns the move into part of the full graphical psyche system.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked patterns",children:e.jsx(Ae,{options:S,selectedValues:p.linkedPatternIds,onChange:_=>P({linkedPatternIds:_}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:C})}),e.jsx(q,{label:"Linked values",children:e.jsx(Ae,{options:O,selectedValues:p.linkedValueIds,onChange:_=>P({linkedValueIds:_}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:R})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Linked schemas",children:e.jsx(Ae,{options:A,selectedValues:p.linkedSchemaIds,onChange:_=>P({linkedSchemaIds:_}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),e.jsx(q,{label:"Linked modes",children:e.jsx(Ae,{options:v,selectedValues:p.linkedModeIds,onChange:_=>P({linkedModeIds:_}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:J})})]})]})}];if(d.isLoading||u.isLoading||b.isLoading||c.isLoading||j.isLoading)return e.jsx(Qe,{eyebrow:"Behaviors",title:"Loading behaviors",description:"Getting behaviors, patterns, values, schemas, and modes ready."});const se=d.error??u.error??b.error??c.error??j.error;if(se)return e.jsx(je,{eyebrow:"Psyche behaviors",error:se,onRetry:()=>void Promise.all([d.refetch(),u.refetch(),b.refetch(),c.refetch(),j.refetch()])});const K={away:k.filter(p=>p.kind==="away"),committed:k.filter(p=>p.kind==="committed"),recovery:k.filter(p=>p.kind==="recovery")};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"behavior",title:e.jsx(ue,{kind:"behavior",label:"Behaviors",variant:"heading",size:"lg"}),description:"Group behaviors by what pulls you away, what moves you toward your values, and what helps you recover after a slip.",badge:`${k.length} mapped`,actions:e.jsx(X,{onClick:()=>{h(null),x(as),n(!0)},children:"Add behavior"})}),e.jsx(Ue,{}),e.jsx(Je,{eyebrow:"Overview",title:"Behavior summary",description:"This summary keeps the three behavior types visible together: away, committed, and recovery.",tone:"amber",children:e.jsx(Wd,{entries:[{id:"away",title:((U=K.away[0])==null?void 0:U.title)??"No away move mapped yet",summary:((Z=K.away[0])==null?void 0:Z.replacementMove)||"Map the move that tends to pull you away first.",href:"#behavior-columns",tone:"away"},{id:"committed",title:((ie=K.committed[0])==null?void 0:ie.title)??"No committed action mapped yet",summary:((ge=K.committed[0])==null?void 0:ge.replacementMove)||"Map the move you want to practice instead.",href:"#behavior-columns",tone:"committed"},{id:"recovery",title:((z=K.recovery[0])==null?void 0:z.title)??"No recovery move mapped yet",summary:((E=K.recovery[0])==null?void 0:E.repairPlan)||"Map how you return after a slip without turning it into collapse.",href:"#behavior-columns",tone:"recovery"}]})}),e.jsx(Je,{eyebrow:"Behaviors",title:"Behaviors by type",description:"Use these columns to separate what pulls you off course, what helps you move toward your values, and what helps you recover.",tone:"default",children:e.jsx("div",{id:"behavior-columns",className:"grid gap-4 xl:grid-cols-3",children:["away","committed","recovery"].map(p=>e.jsxs("div",{className:"grid gap-3 rounded-[24px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:Zi[p]}),e.jsx(B,{children:K[p].length})]}),K[p].length===0?e.jsx("div",{className:"flex",children:e.jsxs(X,{variant:"secondary",onClick:()=>n(!0),children:["Add ",p==="away"?"away move":p==="committed"?"committed action":"recovery move"]})}):K[p].map(P=>e.jsxs("div",{"data-psyche-focus-id":P.id,className:`rounded-[22px] border border-white/8 bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.08] ${Yt(m===P.id)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:P.title}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{entityType:"behavior",entityId:P.id,count:Be(w,"behavior",P.id).count}),e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>{h(P),x(ic(P)),n(!0)},children:"Edit"})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:P.description}),e.jsx("div",{className:"mt-3 text-sm text-white/46",children:P.replacementMove||P.repairPlan||"No recovery step recorded yet."})]},P.id))]},p))})}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Behavior",title:o?"Refine behavior path":"Create behavior",description:"Use this guided flow to describe the behavior, when it shows up, what it gives you, and what kind of move it is.",value:l,onChange:x,steps:G,submitLabel:o?"Save behavior":"Create behavior",pending:L.isPending,error:g,onSubmit:async()=>{f(null);const p=Yi.safeParse(l);if(!p.success){f("This behavior still needs a kind and a title before it can be saved.");return}try{await L.mutateAsync(p.data)}catch(P){f(P instanceof Error?P.message:"Unable to save this behavior right now.")}}})]})}function rc(){var l;const t=Le(),[s,a]=y.useState(null),r=te({queryKey:["forge-psyche-overview"],queryFn:Tn}),i=(l=r.data)==null?void 0:l.overview,n=y.useMemo(()=>i?t.snapshot.goals.map(x=>{const g=i.values.filter(c=>c.linkedGoalIds.includes(x.id)),f=t.snapshot.dashboard.projects.filter(c=>c.goalId===x.id),d=i.reports.filter(c=>c.linkedGoalIds.includes(x.id)),u=i.behaviors.filter(c=>c.linkedValueIds.some(j=>g.some(k=>k.id===j))),b=i.beliefs.filter(c=>c.linkedValueIds.some(j=>g.some(k=>k.id===j)));return{goal:x,linkedValues:g,linkedProjects:f,linkedReports:d,linkedBehaviors:u,linkedBeliefs:b}}):[],[i,t.snapshot.dashboard.projects,t.snapshot.goals]),o=y.useMemo(()=>Yn(n),[n]);if(y.useEffect(()=>{a(o.defaultSelectedId)},[o.defaultSelectedId]),r.isLoading)return e.jsx(Qe,{eyebrow:"Goal map",title:"Loading the gravity well",description:"Linking goals, values, reports, beliefs, behaviors, and projects back into execution."});if(r.isError||!i)return e.jsx(je,{eyebrow:"Goal map",error:r.error??new Error("Forge returned an empty Psyche overview payload."),onRetry:()=>void r.refetch()});const h=o.inspectors[s??o.defaultSelectedId]??o.inspectors[o.defaultSelectedId];return e.jsxs("div",{className:"grid min-w-0 gap-4",children:[e.jsx(ke,{title:"Goal Map",titleText:"Goal Map",description:"Values orbit each goal. Reports, beliefs, behaviors, and projects reveal where the orbit gets disrupted and how execution reconnects.",badge:`${n.length} goal${n.length===1?"":"s"}`,actions:e.jsxs(e.Fragment,{children:[e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-white/[0.08] px-4 py-2 text-sm whitespace-nowrap text-white transition hover:bg-white/[0.12]",children:"Open goals"}),e.jsx(xe,{to:"/psyche/reports?create=1",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[rgba(125,211,252,0.16)] px-4 py-2 text-sm whitespace-nowrap text-white transition hover:bg-[rgba(125,211,252,0.22)]",children:"Reflect"})]})}),e.jsx(Ue,{}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsx(Vn,{testId:"goal-gravity-graph",title:"Life direction, value orbit, and execution field",hint:"Drag to inspect the whole field. Select any goal, value, belief, behavior, project, or report to see what it means and where to act next.",nodes:o.nodes,edges:o.edges,fields:o.fields,selectedNodeId:s,onSelectNode:a,minHeightClassName:"min-h-[25rem] sm:min-h-[34rem] lg:min-h-[56rem]",legend:[{label:"Goals",kind:"goal"},{label:"Values",kind:"value"},{label:"Beliefs",kind:"belief"},{label:"Behaviors",kind:"behavior"},{label:"Projects",kind:"project"},{label:"Reports",kind:"report"}],action:n.length===0?e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] px-4 py-2 text-sm font-medium whitespace-nowrap text-white",children:"Add first goal"}):e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-white/8 px-4 py-2 text-sm font-medium whitespace-nowrap text-white transition hover:bg-white/12",children:"Open goals"})}),e.jsxs(Y,{className:"min-w-0 h-fit xl:sticky xl:top-24",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:h.entityKind?e.jsx(re,{kind:h.entityKind,compact:!0,gradient:!1,iconOnly:!0}):e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:h.eyebrow})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[h.entityKind?e.jsx(ue,{kind:h.entityKind,label:h.title,variant:"heading",size:"lg",showKind:!1}):e.jsx("h2",{className:"font-display text-[clamp(1.35rem,2.2vw,2rem)] leading-none text-white",children:h.title}),h.entityKind?null:e.jsx(B,{className:"bg-white/[0.08]",style:{color:"white"},children:h.tone})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:h.summary}),h.stats.length>0?e.jsx("div",{className:"mt-4 grid gap-2",children:h.stats.map(x=>e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-3 py-3 text-sm text-white/68",children:x},x))}):null,h.chips.length>0?e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:h.chips.map(x=>e.jsx(B,{className:"bg-white/[0.08] text-white/74",children:x},x))}):null,e.jsx("div",{className:"mt-5",children:e.jsx(xe,{to:h.href,className:Q("inline-flex min-h-11 w-full items-center justify-center rounded-[var(--radius-control)] px-4 py-2.5 text-sm font-medium whitespace-nowrap shadow-[0_12px_30px_rgba(192,193,255,0.08)]",h.entityKind?_t(h.entityKind,!0):"bg-[linear-gradient(135deg,rgba(192,193,255,0.36),rgba(192,193,255,0.22))] text-white"),children:h.ctaLabel})})]})]})]})}function oc(t){return t instanceof Error?t:typeof t=="string"&&t.trim().length>0?new Error(t):new Error("Forge could not complete the requested query collection.")}function lc(t){const s=t.find(a=>a.isError);return{isLoading:t.some(a=>a.isPending||a.isLoading),error:s?oc(s.error):null}}async function dc(t){await Promise.all(t.map(s=>s.refetch()))}const is={copingResponse:[{value:"fight",label:"Fight"},{value:"flight",label:"Flight"},{value:"freeze",label:"Freeze"},{value:"detach",label:"Detach"},{value:"comply",label:"Comply"},{value:"overcompensate",label:"Overcompensate"},{value:"none",label:"Mixed / unsure"}],childState:[{value:"vulnerable",label:"Vulnerable"},{value:"angry",label:"Angry"},{value:"impulsive",label:"Impulsive"},{value:"lonely",label:"Lonely"},{value:"ashamed",label:"Ashamed"},{value:"none",label:"Mixed / unsure"}],criticStyle:[{value:"demanding",label:"Demanding"},{value:"punitive",label:"Punitive"},{value:"none",label:"Neither / unclear"}],healthyContact:[{value:"healthy_adult",label:"Healthy adult"},{value:"happy_child",label:"Happy child"},{value:"none",label:"Hard to access right now"}]};function cc(){var h,l,x,g,f,d;const t=Pe(),s=te({queryKey:["forge-psyche-mode-guide-sessions"],queryFn:ml}),a=xs({defaultValues:{summary:"What mode was most present in this moment?",copingResponse:"none",childState:"none",criticStyle:"none",healthyContact:"none"}}),r=de({mutationFn:async u=>{const b=Zd.parse({summary:u.summary,answers:[{questionKey:"coping_response",value:u.copingResponse},{questionKey:"child_state",value:u.childState},{questionKey:"critic_style",value:u.criticStyle},{questionKey:"healthy_contact",value:u.healthyContact}]});return hl(b)},onSuccess:async()=>{await t.invalidateQueries({queryKey:["forge-psyche-mode-guide-sessions"]})}}),i=[s],n=lc(i),o=((h=r.data)==null?void 0:h.session)??((x=(l=s.data)==null?void 0:l.sessions)==null?void 0:x[0]);return n.isLoading?e.jsx(Qe,{eyebrow:"Mode guide",title:"Loading guided sessions",description:"Hydrating previous mode-guide runs and the latest stored readings."}):n.error?e.jsx(je,{eyebrow:"Mode guide",error:n.error,onRetry:()=>void dc(i)}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{eyebrow:"Mode guide",title:"Guided Mode Identification",description:"A short guided pass can help separate coping responses, child states, critic pressure, and whatever healthy contact is still available.",badge:`${((g=s.data)==null?void 0:g.sessions.length)??0} sessions`,actions:e.jsx(xe,{to:"/psyche/modes",children:e.jsx(X,{variant:"secondary",children:"Back to mode map"})})}),e.jsx(Ue,{}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(Y,{className:"bg-[linear-gradient(180deg,rgba(16,20,30,0.96),rgba(11,15,24,0.94))]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Guided questionnaire"}),e.jsxs("form",{className:"mt-4 grid gap-5",onSubmit:a.handleSubmit(async u=>r.mutateAsync(u)),children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Prompt"}),e.jsx("input",{className:"w-full rounded-2xl border border-white/8 bg-white/6 px-4 py-3 text-sm text-white outline-none placeholder:text-white/35",...a.register("summary")})]}),e.jsxs(Y,{className:"rounded-[24px] bg-[rgba(248,113,113,0.08)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-rose-100/80",children:"When the pressure rose, what coping move dominated?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:is.copingResponse.map(u=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:u.value,...a.register("copingResponse")}),e.jsx("span",{className:"text-white/74",children:u.label})]},u.value))})]}),e.jsxs(Y,{className:"rounded-[24px] bg-[rgba(196,181,253,0.08)] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-violet-100/80",children:"Which child state felt closest?"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:is.childState.map(u=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:u.value,...a.register("childState")}),e.jsx("span",{className:"text-white/74",children:u.label})]},u.value))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Y,{className:"rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/48",children:"What was the critic like?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:is.criticStyle.map(u=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:u.value,...a.register("criticStyle")}),e.jsx("span",{className:"text-white/74",children:u.label})]},u.value))})]}),e.jsxs(Y,{className:"rounded-[24px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/48",children:"What healthy contact was still reachable?"}),e.jsx("div",{className:"mt-3 grid gap-2",children:is.healthyContact.map(u=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("input",{type:"radio",value:u.value,...a.register("healthyContact")}),e.jsx("span",{className:"text-white/74",children:u.label})]},u.value))})]})]}),e.jsx(X,{type:"submit",children:"Run guide"})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{className:"bg-[linear-gradient(180deg,rgba(15,21,34,0.96),rgba(10,15,23,0.94))]",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Latest reading"}),o?e.jsxs("div",{className:"mt-4 grid gap-3",children:[o.results.map(u=>e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:u.label}),e.jsxs(B,{className:"text-white/70",children:[Math.round(u.confidence*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:u.family.replaceAll("_"," ")}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/66",children:u.reasoning})]},`${u.family}:${u.label}`)),e.jsx(xe,{to:"/psyche/modes",children:e.jsx(X,{variant:"secondary",children:"Use this in the mode map"})})]}):e.jsx("div",{className:"mt-4",children:e.jsx(Xe,{eyebrow:"Guided reading",title:"No guided sessions yet",description:"Run the guide once to separate coping response, child state, critic pressure, and reachable healthy contact."})})]}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Session history"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((f=s.data)==null?void 0:f.sessions)??[]).length===0?e.jsx(Xe,{eyebrow:"Session history",title:"No stored guide history",description:"Completed guide sessions will accumulate here so later mode-map work can build from real prior readings."}):(((d=s.data)==null?void 0:d.sessions)??[]).map(u=>e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:u.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:u.results.map(b=>e.jsx(B,{className:"text-white/72",children:b.label},`${u.id}:${b.label}`))})]},u.id))})]})]})]})]})}const mc={coping:"bg-[rgba(251,113,133,0.16)] text-rose-100",child:"bg-[rgba(125,211,252,0.16)] text-sky-100",critic_parent:"bg-[rgba(196,181,253,0.16)] text-violet-100",healthy_adult:"bg-[rgba(110,231,183,0.16)] text-emerald-100",happy_child:"bg-[rgba(251,191,36,0.16)] text-amber-100"};function hc({family:t,label:s,className:a}){return e.jsx("span",{className:Q("inline-flex items-center rounded-full px-3 py-1.5 text-xs",mc[t],a),children:s})}const ns={family:"coping",archetype:"",title:"",persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[]};function uc(t){return{family:t.family,archetype:t.archetype,title:t.title,persona:t.persona,imagery:t.imagery,symbolicForm:t.symbolicForm,facialExpression:t.facialExpression,fear:t.fear,burden:t.burden,protectiveJob:t.protectiveJob,originContext:t.originContext,firstAppearanceAt:t.firstAppearanceAt,linkedPatternIds:t.linkedPatternIds,linkedBehaviorIds:t.linkedBehaviorIds,linkedValueIds:t.linkedValueIds}}const Qs={coping:"Coping",child:"Child",critic_parent:"Critic / parent",healthy_adult:"Healthy adult",happy_child:"Happy child"};function pc(){var G,se,K,D;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(null),[l,x]=y.useState(ns),[g,f]=y.useState(null),d=te({queryKey:["forge-psyche-modes"],queryFn:jt}),u=te({queryKey:["forge-psyche-patterns"],queryFn:Ss}),b=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),c=te({queryKey:["forge-psyche-values"],queryFn:yt}),j=((G=d.data)==null?void 0:G.modes)??[],k=((se=u.data)==null?void 0:se.patterns)??[],$=((K=b.data)==null?void 0:K.behaviors)??[],M=((D=c.data)==null?void 0:D.values)??[],I=a.get("focus"),N=t.snapshot.dashboard.notesSummaryByEntity;Ut(I),y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h(null),x(ns);const F=new URLSearchParams(a);F.delete("create"),r(F,{replace:!0})}},[a,r]);const m=de({mutationFn:async F=>{const W=Vi.parse(F);return o?cl(o.id,W):Ht(W)},onSuccess:async()=>{n(!1),h(null),x(ns),f(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-modes"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),w=k.map(F=>({value:F.id,label:F.title,description:F.preferredResponse||F.targetBehavior,kind:"pattern"})),L=$.map(F=>({value:F.id,label:F.title,description:F.kind,kind:"behavior"})),S=M.map(F=>({value:F.id,label:F.title,description:F.valuedDirection,kind:"value"})),O=async F=>{const{pattern:W}=await xa({title:F,description:"",targetBehavior:F,cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[]});return _e(s,["forge-psyche-patterns"],"patterns",W),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:W.id,label:W.title,description:W.preferredResponse||W.targetBehavior,kind:"pattern"}},A=async F=>{const{behavior:W}=await Cs({kind:"away",title:F,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[]});return _e(s,["forge-psyche-behaviors"],"behaviors",W),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:W.id,label:W.title,description:W.kind,kind:"behavior"}},v=async F=>{const{value:W}=await Lt({title:F,description:"",valuedDirection:F,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]});return _e(s,["forge-psyche-values"],"values",W),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:W.id,label:W.title,description:W.valuedDirection,kind:"value"}},C=[{id:"identity",eyebrow:"Identity",title:"Name the cast member and place it in the right family",description:"Start with the mode itself: who it feels like, what family it belongs to, and the recognizable role it plays.",render:(F,W)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Mode family",description:"Choose the broader inner family this mode belongs to.",labelHelp:"A mode family is the bigger cluster this state belongs to, like a coping part, a vulnerable child state, or a healthy adult response.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["coping","child","critic_parent","healthy_adult","happy_child"].map(T=>e.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${F.family===T?"border-white/20 bg-white/[0.12] text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07]"}`,onClick:()=>W({family:T}),children:Qs[T]},T))})}),e.jsx(q,{label:"Mode name",description:"Give it a memorable name you would instantly recognize later.",labelHelp:"This is the user-facing name of the mode. It should read like a cast member title, not a clinical record.",children:e.jsx(ae,{value:F.title,onChange:T=>W({title:T.target.value}),placeholder:"The Friday Vigil, The Scanner, The Good Son"})}),e.jsx(q,{label:"Archetype",description:"Name the recognizable inner role or pattern this mode most resembles.",labelHelp:"An archetype is the role this mode tends to play, like a protector, a critic, a frightened child, or a calm adult anchor.",children:e.jsx(ae,{value:F.archetype,onChange:T=>W({archetype:T.target.value}),placeholder:"Detached protector, vulnerable child, demanding critic"})})]})},{id:"texture",eyebrow:"Texture",title:"Give the mode a recognizable presence",description:"Imagery, facial expression, and persona should make the mode instantly memorable.",render:(F,W)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Persona",description:"Describe how this mode sounds, moves, and carries itself.",labelHelp:"Persona is the tone, posture, and voice of the mode. Imagine how it enters the room and how it speaks.",children:e.jsx(le,{value:F.persona,onChange:T=>W({persona:T.target.value}),placeholder:"Quiet, hyper-alert, always scanning for threat and trying to stay one step ahead."})}),e.jsx(q,{label:"Imagery",description:"Capture the mental image or scene that helps this mode feel vivid.",labelHelp:"Imagery is the picture that makes the mode easy to remember, like a scene, posture, weather pattern, or atmosphere.",children:e.jsx(le,{value:F.imagery,onChange:T=>W({imagery:T.target.value}),placeholder:"A night watchman under cold fluorescent light, pacing and checking every door twice."})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Symbolic form",description:"Pick the object, creature, or shape that best symbolizes this mode.",labelHelp:"Symbolic form is the metaphor for the mode, like armor, a fox, a storm front, or a glass wall.",children:e.jsx(ae,{value:F.symbolicForm,onChange:T=>W({symbolicForm:T.target.value}),placeholder:"A locked visor, a fox, a steel shield"})}),e.jsx(q,{label:"Facial expression",description:"Describe what you would see on the mode's face if it took over.",labelHelp:"This is the visible emotional expression of the mode: tight jaw, blank stare, pleading eyes, or calm grounded attention.",children:e.jsx(ae,{value:F.facialExpression,onChange:T=>W({facialExpression:T.target.value}),placeholder:"Tight jaw, narrowed eyes, forced calm"})})]})]})},{id:"burden",eyebrow:"Burden",title:"Map fear, burden, job, and origin",description:"This is what turns a named mode into a readable inner-state profile.",render:(F,W)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(q,{label:"Fear",description:"Name the threat this mode is trying hard to prevent.",labelHelp:"Fear is the danger the mode believes it must protect you from, such as rejection, shame, collapse, failure, or being trapped.",children:e.jsx(le,{value:F.fear,onChange:T=>W({fear:T.target.value}),placeholder:"If I relax, I will miss the threat and get hurt."})}),e.jsx(q,{label:"Burden",description:"Describe the emotional weight or exhausting role this mode keeps carrying.",labelHelp:"Burden is the heavy job or emotional load the mode feels stuck holding, even when it costs a lot.",children:e.jsx(le,{value:F.burden,onChange:T=>W({burden:T.target.value}),placeholder:"It believes it must never let the guard down, even when that means constant tension."})}),e.jsx(q,{label:"Protective job",description:"Describe the job this mode thinks it is performing for you.",labelHelp:"Protective job is the function the mode is trying to serve, like preventing rejection, keeping control, stopping humiliation, or preserving closeness.",children:e.jsx(le,{value:F.protectiveJob,onChange:T=>W({protectiveJob:T.target.value}),placeholder:"Keeps me prepared so I never get blindsided or look naive."})})]}),e.jsx(q,{label:"Origin context",description:"Describe when this mode first became useful or understandable.",labelHelp:"Origin context is the stretch of life where this mode likely learned its job or became especially necessary.",children:e.jsx(le,{value:F.originContext,onChange:T=>W({originContext:T.target.value}),placeholder:"Started getting stronger during adolescence when mistakes were met with criticism and unpredictability."})})]})},{id:"links",eyebrow:"Links",title:"Attach the mode to the rest of the psyche system",description:"Modes should connect to patterns, behaviors, and values, not sit in isolation.",render:(F,W)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked patterns",description:"Choose the loops this mode tends to activate or maintain.",children:e.jsx(Ae,{options:w,selectedValues:F.linkedPatternIds,onChange:T=>W({linkedPatternIds:T}),placeholder:"Search or create a pattern…",emptyMessage:"No patterns match yet.",createLabel:"Create pattern",onCreate:O})}),e.jsx(q,{label:"Linked behaviors",description:"Choose the moves this mode tends to trigger, justify, or amplify.",children:e.jsx(Ae,{options:L,selectedValues:F.linkedBehaviorIds,onChange:T=>W({linkedBehaviorIds:T}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:A})}),e.jsx(q,{label:"Colliding values",description:"Choose the valued directions this mode most often interrupts.",labelHelp:"These are the values that get obscured, sidelined, or distorted when this mode takes over.",children:e.jsx(Ae,{options:S,selectedValues:F.linkedValueIds,onChange:T=>W({linkedValueIds:T}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:v})})]})}];if(d.isLoading||u.isLoading||b.isLoading||c.isLoading)return e.jsx(Qe,{eyebrow:"Modes",title:"Loading modes",description:"Getting modes, linked patterns, behaviors, and values ready."});const R=d.error??u.error??b.error??c.error;if(R)return e.jsx(je,{eyebrow:"Modes",error:R,onRetry:()=>void Promise.all([d.refetch(),u.refetch(),b.refetch(),c.refetch()])});const J={coping:j.filter(F=>F.family==="coping"),child:j.filter(F=>F.family==="child"),critic_parent:j.filter(F=>F.family==="critic_parent"),healthy_adult:j.filter(F=>F.family==="healthy_adult"),happy_child:j.filter(F=>F.family==="happy_child")};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"mode",title:e.jsx(ue,{kind:"mode",label:"Modes",variant:"heading",size:"lg"}),description:"Modes should look and feel like a cast of inner states with identity, burden, and relational links, not a flat list of records.",badge:`${j.length} modes`,actions:e.jsx(X,{onClick:()=>{h(null),x(ns),n(!0)},children:"Add mode"})}),e.jsx(Ue,{}),e.jsx(Je,{eyebrow:"Mode families",title:"Modes by family",description:"Use these groups to see which modes show up most often, what role they play, and what they are connected to.",tone:"violet",children:j.length===0?e.jsx("div",{className:"flex justify-start",children:e.jsx(X,{onClick:()=>n(!0),children:"Add mode"})}):e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:Object.keys(J).map(F=>e.jsxs("div",{className:"grid gap-3 rounded-[26px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(hc,{family:F,label:Qs[F]}),e.jsx(B,{children:J[F].length})]}),J[F].length===0?e.jsx("div",{className:"flex",children:e.jsxs(X,{variant:"secondary",onClick:()=>n(!0),children:["Add ",Qs[F].toLowerCase()]})}):J[F].map(W=>e.jsxs("div",{"data-psyche-focus-id":W.id,className:`rounded-[22px] bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.08] ${Yt(I===W.id)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(re,{kind:"mode",compact:!0,gradient:!1}),e.jsx(ue,{kind:"mode",label:W.title,variant:"heading",size:"lg"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{entityType:"mode_profile",entityId:W.id,count:Be(N,"mode_profile",W.id).count}),e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>{h(W),x(uc(W)),n(!0)},children:"Edit"})]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/52",children:W.archetype}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/62",children:W.persona||W.protectiveJob||"Open the mode to add persona and protective details."})]},W.id))]},F))})}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Mode",title:o?"Refine cast member":"Create mode",description:"Use this guided flow to define the mode, how it shows up, what it is protecting, and where it comes from.",value:l,onChange:x,steps:C,submitLabel:o?"Save mode":"Create mode",pending:m.isPending,error:g,onSubmit:async()=>{f(null);const F=Vi.safeParse(l);if(!F.success){f("This mode still needs a family and a name before it can be saved.");return}try{await m.mutateAsync(F.data)}catch(W){f(W instanceof Error?W.message:"Unable to save this mode right now.")}}})]})}const xc={mint:"border-emerald-300/24 bg-[rgba(16,185,129,0.12)] text-emerald-100",sky:"border-sky-300/24 bg-[rgba(56,189,248,0.12)] text-sky-100",violet:"border-violet-300/24 bg-[rgba(167,139,250,0.12)] text-violet-100",rose:"border-rose-300/24 bg-[rgba(251,113,133,0.12)] text-rose-100"};function Ws(t,s,a){return Math.min(Math.max(t,s),a)}function gc(t){const s=t.detail.trim().length;return s>84?130:s>44?118:106}function bc(t,s,a){const r=s/2,i=a/2,n=Ws(Math.min(s/620,a/430),.64,1.06),o=t.map(d=>{const u=d.angle*Math.PI/180,b=d.radius*n,c=Math.min(184,Math.max(154,s-48)),j=gc(d),k=r+Math.cos(u)*b,$=i+Math.sin(u)*b;return{...d,x:k,y:$,width:c,height:j,homeX:k,homeY:$}}),h=s<720?16:22,l=20,x=s-20,g=18,f=a-18;for(let d=0;d<220;d+=1){for(const u of o)u.x+=(u.homeX-u.x)*.065,u.y+=(u.homeY-u.y)*.065;for(let u=0;u<o.length;u+=1)for(let b=u+1;b<o.length;b+=1){const c=o[u],j=o[b],k=j.x-c.x,$=j.y-c.y,M=c.width/2+j.width/2+h-Math.abs(k),I=c.height/2+j.height/2+h-Math.abs($);if(M<=0||I<=0)continue;const N=M<I?"x":"y",m=Math.sign(N==="x"?k||b-u||1:$||b-u||1),w=(N==="x"?M:I)/2;N==="x"?(c.x-=m*w,j.x+=m*w):(c.y-=m*w,j.y+=m*w)}for(const u of o)u.x=Ws(u.x,l+u.width/2,x-u.width/2),u.y=Ws(u.y,g+u.height/2,f-u.height/2)}return o}function tr({title:t,description:s,centerLabel:a,centerValue:r,nodes:i,action:n}){const o=y.useRef(null),[h,l]=y.useState({width:0,height:0});y.useEffect(()=>{if(!o.current||typeof ResizeObserver>"u")return;const f=new ResizeObserver(d=>{const u=d[0];l({width:u.contentRect.width,height:u.contentRect.height})});return f.observe(o.current),()=>f.disconnect()},[]);const x=i.length>0?i:[{id:"values",label:"Values",title:"Add value",detail:"Name what matters",href:"/psyche/values?create=1",angle:-86,radius:112,tone:"mint"},{id:"patterns",label:"Patterns",title:"Add pattern",detail:"Map a loop",href:"/psyche/patterns?create=1",angle:-14,radius:122,tone:"rose"},{id:"beliefs",label:"Beliefs",title:"Add belief",detail:"Capture a script",href:"/psyche/schemas-beliefs?create=1",angle:72,radius:118,tone:"violet"},{id:"reports",label:"Reports",title:"Reflect",detail:"Open the chain",href:"/psyche/reports?create=1",angle:160,radius:124,tone:"sky"}],g=y.useMemo(()=>bc(x,Math.max(h.width,320),Math.max(h.height,320)),[x,h.height,h.width]);return e.jsxs("section",{className:"overflow-hidden rounded-[32px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(110,231,183,0.14),transparent_42%),linear-gradient(180deg,rgba(15,30,34,0.98),rgba(10,21,25,0.98))] px-4 py-4 shadow-[0_24px_70px_rgba(4,8,18,0.28)] lg:px-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end 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-[rgba(110,231,183,0.8)]",children:"Reflective map"}),e.jsx("h2",{className:"mt-2 font-display text-[clamp(1.35rem,2.3vw,2rem)] leading-none text-white",children:t}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-white/60",children:s})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"inline-flex items-center gap-3 rounded-full border border-white/10 bg-white/[0.04] px-4 py-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-[0.18em] text-white/38",children:a}),e.jsx("span",{className:"text-sm font-medium text-white",children:r})]}),n?e.jsx("div",{className:"shrink-0",children:n}):null]})]}),e.jsxs("div",{ref:o,className:"relative min-h-[20rem] overflow-hidden rounded-[30px] border border-white/6 bg-[radial-gradient(circle_at_center,rgba(255,255,255,0.05),transparent_42%)] lg:min-h-[22rem]",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_center,rgba(110,231,183,0.08),transparent_32%),linear-gradient(180deg,transparent,rgba(8,13,24,0.24))]"}),[112,168,224].map(f=>e.jsx("div",{className:"absolute left-1/2 top-1/2 rounded-full border border-white/[0.05]",style:{width:`${f*2}px`,height:`${f*2}px`,transform:"translate(-50%, -50%)"}},f)),e.jsx("div",{className:"absolute inset-1/2 size-32 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/10 bg-[radial-gradient(circle,rgba(255,255,255,0.08),rgba(255,255,255,0.02))] shadow-[0_0_0_18px_rgba(255,255,255,0.02),0_0_0_56px_rgba(255,255,255,0.015)]",children:e.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-white/40",children:a}),e.jsx("div",{className:"mt-2 font-display text-2xl text-white",children:r})]})}),g.map((f,d)=>e.jsx(De.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},transition:{duration:.35,delay:d*.05,ease:"easeOut"},className:"absolute w-[min(11.5rem,calc(100vw-4rem))] max-w-[11.5rem] -translate-x-1/2 -translate-y-1/2",style:{left:`${f.x}px`,top:`${f.y}px`},whileHover:{y:-6,scale:1.03},children:e.jsxs(xe,{to:f.href,className:Q("block rounded-[22px] border px-3.5 py-3 shadow-[0_18px_38px_rgba(4,8,18,0.28)] backdrop-blur-sm transition hover:-translate-y-0.5 hover:bg-white/[0.1] hover:shadow-[0_24px_44px_rgba(4,8,18,0.34)]",xc[f.tone??"mint"]),children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/45",children:f.label}),e.jsx("div",{className:"mt-1.5 font-medium text-white",children:f.title}),e.jsx("div",{className:"mt-1.5 text-sm leading-5 text-white/62",children:f.detail})]})},f.id))]})]})}const rs={title:"",description:"",targetBehavior:"",cueContexts:[],shortTermPayoff:"",longTermCost:"",preferredResponse:"",linkedValueIds:[],linkedSchemaLabels:[],linkedModeIds:[],linkedBeliefIds:[]};function fc(t){return{title:t.title,description:t.description,targetBehavior:t.targetBehavior,cueContexts:t.cueContexts,shortTermPayoff:t.shortTermPayoff,longTermCost:t.longTermCost,preferredResponse:t.preferredResponse,linkedValueIds:t.linkedValueIds,linkedSchemaLabels:t.linkedSchemaLabels,linkedModeIds:t.linkedModeIds,linkedBeliefIds:t.linkedBeliefIds}}function vc(){var T,H,U,Z,ie,ge;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(null),[l,x]=y.useState(rs),[g,f]=y.useState(null),d=te({queryKey:["forge-psyche-patterns"],queryFn:Ss}),u=te({queryKey:["forge-psyche-values"],queryFn:yt}),b=te({queryKey:["forge-psyche-schema-catalog"],queryFn:Qt}),c=te({queryKey:["forge-psyche-modes"],queryFn:jt}),j=te({queryKey:["forge-psyche-beliefs"],queryFn:Wt}),k=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),$=((T=d.data)==null?void 0:T.patterns)??[],M=((H=u.data)==null?void 0:H.values)??[],I=((U=b.data)==null?void 0:U.schemas)??[],N=((Z=c.data)==null?void 0:Z.modes)??[],m=((ie=j.data)==null?void 0:ie.beliefs)??[],w=((ge=k.data)==null?void 0:ge.behaviors)??[],L=a.get("focus"),S=t.snapshot.dashboard.notesSummaryByEntity;Ut(L),y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h(null),x(rs);const z=new URLSearchParams(a);z.delete("create"),r(z,{replace:!0})}},[a,r]);const O=de({mutationFn:async z=>{const E=Ui.parse(z);return o?ol(o.id,E):xa(E)},onSuccess:async()=>{n(!1),h(null),x(rs),f(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-patterns"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),A=M.map(z=>({value:z.id,label:z.title,description:z.valuedDirection,kind:"value"})),v=I.map(z=>({value:z.title,label:z.title,description:`${z.description} ${Ta(z.family)}`,searchText:`${z.slug} ${z.family} ${z.schemaType}`,badge:e.jsx(rt,{label:z.title,schemaType:z.schemaType,compact:!0}),menuBadge:e.jsx(rt,{label:z.title,schemaType:z.schemaType,compact:!0})})),C=N.map(z=>({value:z.id,label:z.title,description:z.archetype||z.family,kind:"mode"})),R=m.map(z=>({value:z.id,label:z.statement,description:z.flexibleAlternative||z.originNote,kind:"belief"})),J=async z=>{const{mode:E}=await Ht({family:"coping",archetype:"",title:z,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[]});return _e(s,["forge-psyche-modes"],"modes",E),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:E.id,label:E.title,description:E.archetype||E.family,kind:"mode"}},G=async z=>{const{value:E}=await Lt({title:z,description:"",valuedDirection:z,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]});return _e(s,["forge-psyche-values"],"values",E),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:E.id,label:E.title,description:E.valuedDirection,kind:"value"}},se=async z=>{const{belief:E}=await ga({schemaId:null,statement:z,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[]});return _e(s,["forge-psyche-beliefs"],"beliefs",E),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:E.id,label:E.statement,description:E.flexibleAlternative||E.originNote,kind:"belief"}},K=y.useMemo(()=>$.filter(z=>!w.some(E=>E.kind==="away"&&E.linkedPatternIds.includes(z.id))),[$,w]),D=$.slice(0,5).map((z,E)=>({id:z.id,label:`${z.linkedValueIds.length} values`,title:z.title,detail:z.preferredResponse,href:`/psyche/patterns?focus=${z.id}#pattern-lanes`,angle:-92+E*70,radius:150+E%2*14,tone:["rose","sky","violet","mint"][E%4]})),F=[{id:"loop",eyebrow:"Loop",title:"Name the pattern and the behavior it keeps producing",description:"This should feel like a recognizable loop, not a diagnostic label.",render:(z,E)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Pattern name",description:"Give the loop a name you will recognize quickly later.",children:e.jsx(ae,{value:z.title,onChange:p=>E({title:p.target.value}),placeholder:"Anxious reassurance loop"})}),e.jsx(q,{label:"What happens in the loop",description:"Describe the actual sequence of behavior, not the diagnosis.",children:e.jsx(le,{value:z.targetBehavior,onChange:p=>E({targetBehavior:p.target.value}),placeholder:"What do you actually do when the trigger hits?"})}),e.jsx(q,{label:"Description",description:"Write the loop in plain language so it stays usable in the future.",children:e.jsx(le,{value:z.description,onChange:p=>E({description:p.target.value}),placeholder:"Describe the loop in plain human language so it stays recognizable later."})})]})},{id:"dynamics",eyebrow:"Dynamics",title:"Capture cues, payoff, cost, and the desired response",description:"The goal is to make the action map obvious at a glance.",render:(z,E)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Common cues",description:"Add one cue per line so the trigger pattern stays easy to scan.",children:e.jsx(le,{value:z.cueContexts.join(`
|
|
15
|
+
`),onChange:p=>E({cueContexts:p.target.value.split(`
|
|
16
|
+
`).map(P=>P.trim()).filter(Boolean)}),placeholder:`One line per cue
|
|
17
|
+
Silence after vulnerability
|
|
18
|
+
Late-night social comparison`})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Short-term payoff",description:"What relief, certainty, control, or distance do you get right away?",children:e.jsx(le,{value:z.shortTermPayoff,onChange:p=>E({shortTermPayoff:p.target.value}),placeholder:"What relief do you get right away?"})}),e.jsx(q,{label:"Long-term cost",description:"What does the loop cost you later in closeness, energy, values, or progress?",children:e.jsx(le,{value:z.longTermCost,onChange:p=>E({longTermCost:p.target.value}),placeholder:"What does this cost over time?"})})]}),e.jsx(q,{label:"Preferred response",description:"Name the return-path response you want to practice instead.",children:e.jsx(le,{value:z.preferredResponse,onChange:p=>E({preferredResponse:p.target.value}),placeholder:"What do you want to practice instead?"})})]})},{id:"links",eyebrow:"Links",title:"Attach the loop to values, schemas, modes, and beliefs",description:"This is what turns a private note into a navigable graphical system.",render:(z,E)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked values",description:"Choose the values this loop pulls against or tries to protect badly.",children:e.jsx(Ae,{options:A,selectedValues:z.linkedValueIds,onChange:p=>E({linkedValueIds:p}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:G})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Schema labels",description:"Attach the schema themes that define the pressure in this loop.",children:e.jsx(Ae,{options:v,selectedValues:z.linkedSchemaLabels,onChange:p=>E({linkedSchemaLabels:p}),placeholder:"Search schema themes…",emptyMessage:"No schema themes match."})}),e.jsx(q,{label:"Linked modes",description:"Search for an existing mode or press Enter to create and link one immediately.",children:e.jsx(Ae,{options:C,selectedValues:z.linkedModeIds,onChange:p=>E({linkedModeIds:p}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:J})})]}),e.jsx(q,{label:"Linked beliefs",description:"Search for a belief, or type a new one and press Enter to create it inline.",children:e.jsx(Ae,{options:R,selectedValues:z.linkedBeliefIds,onChange:p=>E({linkedBeliefIds:p}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:se})})]})}];if(d.isLoading||u.isLoading||b.isLoading||c.isLoading||j.isLoading||k.isLoading)return e.jsx(Qe,{eyebrow:"Patterns",title:"Loading patterns",description:"Getting patterns, values, schemas, beliefs, modes, and linked behaviors ready."});const W=d.error??u.error??b.error??c.error??j.error??k.error;return W?e.jsx(je,{eyebrow:"Psyche patterns",error:W,onRetry:()=>void Promise.all([d.refetch(),u.refetch(),b.refetch(),c.refetch(),j.refetch(),k.refetch()])}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"pattern",title:e.jsx(ue,{kind:"pattern",label:"Patterns",variant:"heading",size:"lg"}),description:"See each pattern as a loop: what starts it, what payoff it gives, what it costs, and what you want to do instead.",badge:`${$.length} patterns`,actions:e.jsx(X,{onClick:()=>{h(null),x(rs),n(!0)},children:"Add pattern"})}),e.jsx(Ue,{}),e.jsx(tr,{title:"See the loops that keep pulling against your values",description:"This map shows which patterns are hot, what they are connected to, and which response wants to replace them.",centerLabel:"Pattern field",centerValue:`${$.length} tracked`,nodes:D,action:e.jsx(X,{onClick:()=>n(!0),children:"Add pattern"})}),K.length>0?e.jsx(Je,{eyebrow:"Seed behavior drafts",title:"Some patterns still do not have an explicit away-move draft",description:"These are the best candidates to push into the Behaviors page next.",tone:"rose",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:K.slice(0,8).map(z=>e.jsx(re,{kind:"pattern",label:z.title,compact:!0},z.id))})}):null,e.jsx(Je,{eyebrow:"Pattern action map",title:"Read each loop from cue to return path",description:"Each lane turns a raw pattern into a visible behavior map: cues, short-term relief, long-term cost, and the move you actually want.",tone:"sky",className:"scroll-mt-24",children:e.jsx("div",{id:"pattern-lanes",className:"grid gap-4",children:$.length===0?e.jsx("div",{className:"flex justify-start",children:e.jsx(X,{onClick:()=>n(!0),children:"Add pattern"})}):$.map(z=>{const E=M.filter(oe=>z.linkedValueIds.includes(oe.id)),p=N.filter(oe=>z.linkedModeIds.includes(oe.id)),P=m.filter(oe=>z.linkedBeliefIds.includes(oe.id)),_=L===z.id,ve=Be(S,"behavior_pattern",z.id).count;return e.jsxs("div",{"data-psyche-focus-id":z.id,className:`rounded-[28px] border border-white/8 bg-white/[0.04] p-5 transition ${Yt(_)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(ue,{kind:"pattern",label:z.title,variant:"heading",size:"xl"}),e.jsx("div",{className:"mt-2 text-sm leading-7 text-white/58",children:z.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{entityType:"behavior_pattern",entityId:z.id,count:ve}),e.jsx(X,{variant:"secondary",onClick:()=>{h(z),x(fc(z)),n(!0)},children:"Edit"})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Cue"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/68",children:z.cueContexts[0]??"No cue captured yet."})]}),e.jsxs("div",{className:"rounded-[22px] bg-[rgba(251,113,133,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Loop"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/68",children:z.targetBehavior})]}),e.jsxs("div",{className:"rounded-[22px] bg-[rgba(251,191,36,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Short-term relief / long-term cost"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/68",children:z.shortTermPayoff||"No payoff note yet."}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/52",children:z.longTermCost||"No long-term cost note yet."})]}),e.jsxs("div",{className:"rounded-[22px] bg-[rgba(110,231,183,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Return path"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/68",children:z.preferredResponse})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[E.map(oe=>e.jsx(re,{kind:"value",label:oe.title,compact:!0},oe.id)),p.map(oe=>e.jsx(re,{kind:"mode",label:oe.title,compact:!0},oe.id)),z.linkedModeLabels.map(oe=>e.jsx(B,{className:"text-violet-100",children:oe},`legacy-${oe}`)),z.linkedSchemaLabels.map(oe=>{var Me,Oe;return e.jsx(rt,{label:((Me=It(oe,I))==null?void 0:Me.title)??oe,schemaType:((Oe=It(oe,I))==null?void 0:Oe.schemaType)??"maladaptive",compact:!0},oe)}),P.map(oe=>e.jsx(re,{kind:"belief",label:oe.statement,compact:!0},oe.id))]})]},z.id)})})}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Behavior pattern",title:o?"Refine pattern lane":"Create pattern",description:"Pattern capture should feel like mapping a loop, not filling an admin form.",value:l,onChange:x,steps:F,submitLabel:o?"Save pattern":"Create pattern",pending:O.isPending,error:g,onSubmit:async()=>{f(null);const z=Ui.safeParse(l);if(!z.success){f("This pattern still needs a title, a loop description, and a preferred response.");return}try{await O.mutateAsync(z.data)}catch(E){f(E instanceof Error?E.message:"Unable to save this pattern right now.")}}})]})}const en="(max-width: 1023px)";function yc(){const[t,s]=y.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(en).matches);return y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=window.matchMedia(en),r=i=>s(i.matches);return s(a.matches),typeof a.addEventListener=="function"?(a.addEventListener("change",r),()=>a.removeEventListener("change",r)):(a.addListener(r),()=>a.removeListener(r))},[]),t}function wc({stages:t,activeStageId:s,onStageChange:a,stageContent:r,inspector:i}){const n=yc(),[o,h]=y.useState(!1),l=t.find(x=>x.id===s);return y.useEffect(()=>{h(!n)},[n]),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"rounded-[30px] border border-white/8 bg-[radial-gradient(circle_at_top,rgba(196,181,253,0.12),transparent_38%),linear-gradient(180deg,rgba(21,20,38,0.98),rgba(10,12,22,0.96))] p-4",children:[e.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Tracing the chain"}),e.jsx("div",{className:"mt-1 text-sm text-white/58",children:l==null?void 0:l.summary})]}),i?e.jsxs(X,{variant:"secondary",size:"sm",onClick:()=>h(x=>!x),children:[o?e.jsx(Ur,{className:"size-4"}):e.jsx(Yr,{className:"size-4"}),"Inspector"]}):null]}),e.jsx("div",{className:"mb-4 overflow-x-auto pb-1",children:e.jsx("div",{className:"flex min-w-max items-center gap-3",children:t.map((x,g)=>e.jsxs("button",{type:"button",className:Q("rounded-[22px] px-4 py-3 text-left transition",x.id===s?"bg-[rgba(196,181,253,0.18)] text-white shadow-[0_18px_40px_rgba(15,12,28,0.28)]":"bg-white/[0.04] text-white/58 hover:bg-white/[0.07] hover:text-white"),onClick:()=>a(x.id),children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/34",children:[g+1,". ",x.label]}),n?null:e.jsx("div",{className:"mt-1.5 text-sm leading-5",children:x.summary})]},x.id))})}),e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-[linear-gradient(180deg,rgba(255,255,255,0.04),rgba(255,255,255,0.02))] p-4 md:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-white/[0.07] px-3 py-1.5 text-[11px] uppercase tracking-[0.18em] text-white/42",children:l==null?void 0:l.label}),e.jsx("span",{className:"text-sm text-white/54",children:l==null?void 0:l.summary})]}),e.jsx(bt,{mode:"wait",children:e.jsx(De.div,{initial:{opacity:0,y:14},animate:{opacity:1,y:0},exit:{opacity:0,y:-14},transition:{duration:.26,ease:"easeOut"},children:r},s)})]})]}),i?e.jsx(bt,{initial:!1,children:o?e.jsxs(De.div,{initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},transition:{duration:.22,ease:"easeOut"},className:"rounded-[26px] border border-white/8 bg-[linear-gradient(180deg,rgba(17,24,35,0.96),rgba(11,16,24,0.94))] p-3.5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Linked inspectors"}),e.jsx("div",{className:"mt-3 grid gap-3",children:i})]}):null}):null]})}function As(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function jc(){return{id:As("emotion"),emotionDefinitionId:null,label:"",intensity:55,note:""}}function kc(){return{id:As("thought"),text:"",parentMode:"",criticMode:"",beliefId:null}}function Nc(){return{id:As("behavior"),text:"",mode:"",behaviorId:null}}function Tc(){return{id:As("timeline"),stage:"",modeId:null,label:"",note:""}}function Jt({title:t,description:s,onAdd:a,addLabel:r}){return e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-medium text-white",children:t}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/56",children:s})]}),e.jsxs(X,{type:"button",variant:"secondary",size:"sm",onClick:a,children:[e.jsx(St,{className:"size-4"}),r]})]})}function Vt({onClick:t}){return e.jsx("button",{type:"button",className:"rounded-full bg-white/[0.06] p-2 text-white/55 transition hover:bg-white/[0.12] hover:text-white",onClick:t,"aria-label":"Remove row",children:e.jsx(Pt,{className:"size-4"})})}function He({title:t,description:s,addLabel:a,items:r,onChange:i,placeholder:n}){return e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Jt,{title:t,description:s,addLabel:a,onAdd:()=>i([...r,""])}),e.jsx("div",{className:"grid gap-3",children:r.map((o,h)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-[22px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsx(ae,{value:o,onChange:l=>i(r.map((x,g)=>g===h?l.target.value:x)),placeholder:n}),e.jsx(Vt,{onClick:()=>i(r.filter((l,x)=>x!==h))})]},`${t}-${h}`))})]})}function sr({items:t,onChange:s,definitions:a}){return e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Jt,{title:"What emotions were present?",description:"Add one emotion at a time, set the intensity, and note what stood out.",addLabel:"Add emotion",onAdd:()=>s([...t,jc()])}),e.jsx("div",{className:"grid gap-3",children:t.map(r=>e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"grid flex-1 gap-4 md:grid-cols-[minmax(0,1fr)_9rem]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Emotion"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:r.emotionDefinitionId??"",onChange:i=>{const n=a.find(o=>o.id===i.target.value);s(t.map(o=>o.id===r.id?{...o,emotionDefinitionId:i.target.value||null,label:(n==null?void 0:n.label)??o.label}:o))},children:[e.jsx("option",{value:"",children:"Choose or type your own"}),a.map(i=>e.jsx("option",{value:i.id,children:i.label},i.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Intensity"}),e.jsxs("div",{className:"rounded-[18px] border border-white/8 bg-white/[0.03] px-4 py-3",children:[e.jsx("input",{type:"range",min:0,max:100,value:r.intensity,onChange:i=>s(t.map(n=>n.id===r.id?{...n,intensity:Number(i.target.value)}:n))}),e.jsxs("div",{className:"mt-2 text-sm text-white/52",children:[r.intensity,"%"]})]})]})]}),e.jsx(Vt,{onClick:()=>s(t.filter(i=>i.id!==r.id))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"If the preset is not right, how would you name it?"}),e.jsx(ae,{value:r.label,onChange:i=>s(t.map(n=>n.id===r.id?{...n,label:i.target.value}:n)),placeholder:"Tight sadness, panic, shame, relief..."})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"What was notable about this emotion?"}),e.jsx(le,{value:r.note,onChange:i=>s(t.map(n=>n.id===r.id?{...n,note:i.target.value}:n)),placeholder:"Short note about what made this emotion stand out."})]})]},r.id))})]})}function ar({items:t,onChange:s,beliefs:a,modes:r}){return e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Jt,{title:"What did your mind start saying?",description:"Capture the thought itself first, then optionally link a belief or mode influence.",addLabel:"Add thought",onAdd:()=>s([...t,kc()])}),e.jsx("div",{className:"grid gap-3",children:t.map(i=>e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("label",{className:"grid flex-1 gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Thought"}),e.jsx(le,{value:i.text,onChange:n=>s(t.map(o=>o.id===i.id?{...o,text:n.target.value}:o)),placeholder:"What sentence, image, or conclusion showed up?"})]}),e.jsx(Vt,{onClick:()=>s(t.filter(n=>n.id!==i.id))})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Parent mode influence"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.parentMode,onChange:n=>s(t.map(o=>o.id===i.id?{...o,parentMode:n.target.value}:o)),children:[e.jsx("option",{value:"",children:"None"}),r.map(n=>e.jsx("option",{value:n.title,children:n.title},n.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Critic mode influence"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.criticMode,onChange:n=>s(t.map(o=>o.id===i.id?{...o,criticMode:n.target.value}:o)),children:[e.jsx("option",{value:"",children:"None"}),r.map(n=>e.jsx("option",{value:n.title,children:n.title},n.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Linked belief"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.beliefId??"",onChange:n=>s(t.map(o=>o.id===i.id?{...o,beliefId:n.target.value||null}:o)),children:[e.jsx("option",{value:"",children:"None"}),a.map(n=>e.jsx("option",{value:n.id,children:n.statement},n.id))]})]})]})]},i.id))})]})}function ir({items:t,onChange:s,behaviors:a,modes:r}){return e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Jt,{title:"What did you do, or want to do?",description:"Capture the move itself, then optionally link an existing behavior and the mode context around it.",addLabel:"Add behavior",onAdd:()=>s([...t,Nc()])}),e.jsx("div",{className:"grid gap-3",children:t.map(i=>e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("label",{className:"grid flex-1 gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Behavior or urge"}),e.jsx(le,{value:i.text,onChange:n=>s(t.map(o=>o.id===i.id?{...o,text:n.target.value}:o)),placeholder:"What did you do, or what move did you feel pulled toward?"})]}),e.jsx(Vt,{onClick:()=>s(t.filter(n=>n.id!==i.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/62",children:"Linked existing behavior"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.behaviorId??"",onChange:n=>{const o=a.find(h=>h.id===n.target.value);s(t.map(h=>h.id===i.id?{...h,behaviorId:n.target.value||null,text:o&&!h.text?o.title:h.text}:h))},children:[e.jsx("option",{value:"",children:"None"}),a.map(n=>e.jsx("option",{value:n.id,children:n.title},n.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Mode or urge context"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.mode,onChange:n=>s(t.map(o=>o.id===i.id?{...o,mode:n.target.value}:o)),children:[e.jsx("option",{value:"",children:"None"}),r.map(n=>e.jsx("option",{value:n.title,children:n.title},n.id))]})]})]})]},i.id))})]})}function nr({items:t,onChange:s,modes:a,stages:r}){return e.jsxs("div",{className:"grid gap-3",children:[e.jsx(Jt,{title:"How did your state shift through the chain?",description:"Build the mode timeline one moment at a time instead of typing parser syntax.",addLabel:"Add timeline moment",onAdd:()=>s([...t,Tc()])}),e.jsx("div",{className:"grid gap-3",children:t.map(i=>e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"grid flex-1 gap-4 md:grid-cols-3",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Stage"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.stage,onChange:n=>s(t.map(o=>o.id===i.id?{...o,stage:n.target.value}:o)),children:[e.jsx("option",{value:"",children:"Choose stage"}),r.map(n=>e.jsx("option",{value:n,children:n},n))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Mode"}),e.jsxs("select",{className:"rounded-[18px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.modeId??"",onChange:n=>{const o=a.find(h=>h.id===n.target.value);s(t.map(h=>h.id===i.id?{...h,modeId:n.target.value||null,label:o&&!h.label?o.title:h.label}:h))},children:[e.jsx("option",{value:"",children:"Choose mode"}),a.map(n=>e.jsx("option",{value:n.id,children:n.title},n.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"Moment label"}),e.jsx(ae,{value:i.label,onChange:n=>s(t.map(o=>o.id===i.id?{...o,label:n.target.value}:o)),placeholder:"What was happening in this moment?"})]})]}),e.jsx(Vt,{onClick:()=>s(t.filter(n=>n.id!==i.id))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/62",children:"What was important about this shift?"}),e.jsx(le,{value:i.note,onChange:n=>s(t.map(o=>o.id===i.id?{...o,note:n.target.value}:o)),placeholder:"Short note about how the mode showed up or what it was protecting."})]})]},i.id))})]})}function Sc(t){return t.join(`
|
|
19
|
+
`)}function Hs(t,s){return t.includes(s)?t.filter(a=>a!==s):[...t,s]}function Cc(t){return{title:t.title,status:t.status,eventTypeId:t.eventTypeId??"",customEventType:t.customEventType,eventSituation:t.eventSituation,occurredAt:t.occurredAt?t.occurredAt.slice(0,16):"",emotions:t.emotions,thoughts:t.thoughts,behaviors:t.behaviors,selfShortTerm:t.consequences.selfShortTerm,selfLongTerm:t.consequences.selfLongTerm,othersShortTerm:t.consequences.othersShortTerm,othersLongTerm:t.consequences.othersLongTerm,modeOverlaysText:Sc(t.modeOverlays),schemaLinks:t.schemaLinks,modeTimeline:t.modeTimeline,nextMoves:t.nextMoves,linkedBehaviorIds:t.linkedBehaviorIds,linkedBeliefIds:t.linkedBeliefIds,linkedModeIds:t.linkedModeIds}}function Ic(){var C,R,J,G,se,K;const{reportId:t}=js(),s=Pe(),[a,r]=y.useState("spark"),[i,n]=y.useState(null),[o,h]=y.useState(!1),l=te({queryKey:["forge-psyche-report",t],queryFn:()=>ul(t),enabled:!!t}),x=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),g=te({queryKey:["forge-psyche-beliefs"],queryFn:Wt}),f=te({queryKey:["forge-psyche-modes"],queryFn:jt}),d=te({queryKey:["forge-psyche-schema-catalog"],queryFn:Qt}),u=te({queryKey:["forge-psyche-event-types"],queryFn:Sn}),b=te({queryKey:["forge-psyche-emotions"],queryFn:Cn});y.useEffect(()=>{var D;(D=l.data)!=null&&D.report&&n(Cc(l.data.report))},[l.data]);const c=de({mutationFn:async D=>{var T;const F=(T=l.data)==null?void 0:T.report,W=ta.parse({title:D.title,status:D.status,eventTypeId:D.eventTypeId||null,customEventType:D.customEventType,eventSituation:D.eventSituation,occurredAt:D.occurredAt?new Date(D.occurredAt).toISOString():null,emotions:D.emotions.filter(H=>H.label.trim().length>0),thoughts:D.thoughts.filter(H=>H.text.trim().length>0),behaviors:D.behaviors.filter(H=>H.text.trim().length>0),consequences:{selfShortTerm:D.selfShortTerm,selfLongTerm:D.selfLongTerm,othersShortTerm:D.othersShortTerm,othersLongTerm:D.othersLongTerm},linkedPatternIds:(F==null?void 0:F.linkedPatternIds)??[],linkedValueIds:(F==null?void 0:F.linkedValueIds)??[],linkedGoalIds:(F==null?void 0:F.linkedGoalIds)??[],linkedProjectIds:(F==null?void 0:F.linkedProjectIds)??[],linkedTaskIds:(F==null?void 0:F.linkedTaskIds)??[],linkedBehaviorIds:D.linkedBehaviorIds,linkedBeliefIds:D.linkedBeliefIds,linkedModeIds:D.linkedModeIds,modeOverlays:D.modeOverlaysText.split(`
|
|
20
|
+
`).map(H=>H.trim()).filter(Boolean),schemaLinks:D.schemaLinks.filter(Boolean),modeTimeline:D.modeTimeline.filter(H=>H.stage.trim().length>0&&H.label.trim().length>0),nextMoves:D.nextMoves.filter(Boolean)});return pl(t,W)},onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-report",t]}),s.invalidateQueries({queryKey:["forge-psyche-reports"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]}),s.invalidateQueries({queryKey:["forge-reward-ledger"]})])}}),j=de({mutationFn:Mn,onSuccess:async()=>{await s.invalidateQueries({queryKey:["forge-psyche-report",t]}),await s.invalidateQueries({queryKey:["forge-insights"]})}}),k=l.error??x.error??g.error??f.error??d.error??u.error??b.error??null;if(l.isLoading||!i)return e.jsx(et,{});if(k)return e.jsx(je,{eyebrow:"Trigger report",error:k,onRetry:()=>void Promise.all([l.refetch(),x.refetch(),g.refetch(),f.refetch(),d.refetch(),u.refetch(),b.refetch()])});if(!l.data)return e.jsx(je,{eyebrow:"Trigger report",error:new Error("Forge returned an empty trigger report payload."),onRetry:()=>void l.refetch()});const $=l.data,M=$.report,I=((C=x.data)==null?void 0:C.behaviors)??[],N=((R=g.data)==null?void 0:R.beliefs)??[],m=((J=f.data)==null?void 0:J.modes)??[],w=((G=d.data)==null?void 0:G.schemas)??[],L=((se=u.data)==null?void 0:se.eventTypes)??[],S=((K=b.data)==null?void 0:K.emotions)??[],O=[{id:"spark",label:"Spark",summary:"What happened concretely?"},{id:"wave",label:"Wave",summary:"What emotional wave moved through you?"},{id:"script",label:"Script",summary:"What did the mind start saying?"},{id:"lens",label:"Lens",summary:"Which schemas and beliefs got activated?"},{id:"state",label:"State",summary:"Which modes took the wheel?"},{id:"move",label:"Move",summary:"What did you do or want to do?"},{id:"horizon",label:"Horizon",summary:"What were the consequences?"},{id:"pivot",label:"Pivot",summary:"What is the next move now?"}],A={spark:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_13rem]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Title"}),e.jsx(ae,{value:i.title,onChange:D=>n({...i,title:D.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Status"}),e.jsxs("select",{className:"rounded-[22px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.status,onChange:D=>n({...i,status:D.target.value}),children:[e.jsx("option",{value:"draft",children:"draft"}),e.jsx("option",{value:"reviewed",children:"reviewed"}),e.jsx("option",{value:"integrated",children:"integrated"})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Event type"}),e.jsxs("select",{className:"rounded-[22px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:i.eventTypeId,onChange:D=>n({...i,eventTypeId:D.target.value}),children:[e.jsx("option",{value:"",children:"Custom or uncategorized"}),L.map(D=>e.jsx("option",{value:D.id,children:D.label},D.id))]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Occurred at"}),e.jsx(ae,{type:"datetime-local",value:i.occurredAt,onChange:D=>n({...i,occurredAt:D.target.value})})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Custom event label"}),e.jsx(ae,{value:i.customEventType,onChange:D=>n({...i,customEventType:D.target.value})})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Situation"}),e.jsx(le,{value:i.eventSituation,onChange:D=>n({...i,eventSituation:D.target.value})})]})]}),wave:e.jsx(sr,{items:i.emotions,onChange:D=>n({...i,emotions:D}),definitions:S}),script:e.jsx(ar,{items:i.thoughts,onChange:D=>n({...i,thoughts:D}),beliefs:N,modes:m}),lens:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 rounded-[24px] border border-white/8 bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:"Schema links"}),e.jsx(Ne,{content:"Use maladaptive schemas for recurring old patterns that were active here. Use adaptive schemas for healthier patterns you want this response to build on.",label:"Explain schema links"})]}),e.jsx(lt,{children:"Choose the schemas that were active here or that you want the repair move to strengthen."}),[{title:"Maladaptive schemas",schemas:w.filter(D=>D.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:w.filter(D=>D.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this chain to strengthen."}].map(D=>{const F=Ct(D.schemaType);return e.jsxs("div",{className:`rounded-[22px] border p-4 ${F.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:D.title}),e.jsx(Ne,{content:$t(D.schemaType),label:`Explain ${Es(D.schemaType)}`})]}),e.jsx(lt,{className:"mt-2",children:D.description}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:D.schemas.map(W=>{const T=i.schemaLinks.some(H=>{var U;return((U=It(H,[W]))==null?void 0:U.id)===W.id});return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${T?`${F.badgeTone} ring-1 ring-white/18`:"border-white/8 bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>n({...i,schemaLinks:er(i.schemaLinks,W)}),children:W.title},W.id)})})]},D.schemaType)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Linked beliefs"}),e.jsx("div",{className:"mt-3 flex max-h-56 flex-wrap gap-2 overflow-y-auto",children:N.map(D=>{const F=i.linkedBeliefIds.includes(D.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${F?"bg-[rgba(196,181,253,0.18)] text-violet-100":"bg-white/[0.05] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>n({...i,linkedBeliefIds:Hs(i.linkedBeliefIds,D.id)}),children:D.statement},D.id)})})]})]}),state:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Mode overlays"}),e.jsx(le,{value:i.modeOverlaysText,onChange:D=>n({...i,modeOverlaysText:D.target.value})})]}),e.jsx(nr,{items:i.modeTimeline,onChange:D=>n({...i,modeTimeline:D}),modes:m,stages:O.map(D=>D.label)}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Linked modes"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:m.map(D=>{const F=i.linkedModeIds.includes(D.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${F?"bg-[rgba(251,191,36,0.18)] text-amber-100":"bg-white/[0.05] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>n({...i,linkedModeIds:Hs(i.linkedModeIds,D.id)}),children:D.title},D.id)})})]})]}),move:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(ir,{items:i.behaviors,onChange:D=>n({...i,behaviors:D}),behaviors:I,modes:m}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-white/58",children:"Linked behaviors"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:I.map(D=>{const F=i.linkedBehaviorIds.includes(D.id);return e.jsx("button",{type:"button",className:`rounded-full px-3 py-2 text-sm transition ${F?"bg-[rgba(251,113,133,0.16)] text-rose-100":"bg-white/[0.05] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>n({...i,linkedBehaviorIds:Hs(i.linkedBehaviorIds,D.id)}),children:D.title},D.id)})})]})]}),horizon:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(He,{title:"Short-term impact on you",description:"What happened to you right away?",addLabel:"Add self effect",items:i.selfShortTerm,onChange:D=>n({...i,selfShortTerm:D}),placeholder:"I shut down and lost the evening."}),e.jsx(He,{title:"Long-term impact on you",description:"What does this cost if it keeps repeating?",addLabel:"Add self cost",items:i.selfLongTerm,onChange:D=>n({...i,selfLongTerm:D}),placeholder:"It keeps training the same abandonment script."}),e.jsx(He,{title:"Short-term impact on others",description:"What happened to other people right away?",addLabel:"Add other effect",items:i.othersShortTerm,onChange:D=>n({...i,othersShortTerm:D}),placeholder:"They felt shut out."}),e.jsx(He,{title:"Long-term impact on others",description:"What pattern does this create over time?",addLabel:"Add other cost",items:i.othersLongTerm,onChange:D=>n({...i,othersLongTerm:D}),placeholder:"Trust gets thinner each time."})]}),pivot:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(He,{title:"What is the next move now?",description:"Finish with concrete repairs, boundaries, or committed actions.",addLabel:"Add next move",items:i.nextMoves,onChange:D=>n({...i,nextMoves:D}),placeholder:"Send one honest repair message tomorrow morning."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(X,{pending:c.isPending,onClick:()=>void c.mutateAsync(i),children:"Save chain"})})]})},v=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Linked modes"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[m.filter(D=>i.linkedModeIds.includes(D.id)).map(D=>e.jsx(re,{kind:"mode",label:D.title,compact:!0},D.id)),i.linkedModeIds.length===0?e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>r("state"),children:"Link mode"}):null]})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Linked beliefs"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[N.filter(D=>i.linkedBeliefIds.includes(D.id)).map(D=>e.jsx("div",{className:"rounded-[16px] bg-white/[0.04] px-3 py-3",children:e.jsx(re,{kind:"belief",label:D.statement,compact:!0})},D.id)),i.linkedBeliefIds.length===0?e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>r("lens"),children:"Link belief"}):null]})]}),e.jsx(Ps,{entityType:"trigger_report",entityId:M.id,anchorKey:a,includeAnchorlessWhenAnchored:!0,compact:!0,title:`Stage notes on ${a}`,description:"Use anchored Markdown notes to capture what became clear at this stage of the chain.",invalidateQueryKeys:[["forge-psyche-report",t],["forge-psyche-reports"],["forge-psyche-overview"]]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Insights"}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[$.insights.map(D=>e.jsxs("div",{className:"rounded-[16px] bg-white/[0.04] px-3 py-3 text-sm text-white/72",children:[e.jsx("div",{className:"font-medium text-white",children:D.title}),e.jsx("div",{className:"mt-2 text-white/62",children:D.summary})]},D.id)),e.jsx(X,{variant:"secondary",pending:j.isPending,onClick:()=>h(!0),children:"Store insight"})]})]})]});return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{eyebrow:"Trigger report",title:M.title,description:"Move through Spark to Pivot in one chain canvas.",badge:M.status}),e.jsx(Ue,{}),e.jsx(wc,{stages:O,activeStageId:a,onStageChange:r,stageContent:A[a],inspector:v}),e.jsx(Xn,{open:o,onOpenChange:h,eyebrow:"Report insight",title:"Store report insight",description:"Capture the insight from this report as a guided recommendation instead of a raw side-panel form.",submitLabel:"Store insight",pending:j.isPending,lockedEntity:{entityType:"trigger_report",entityId:M.id,kind:"report",label:M.title,description:`Anchored to the ${a} stage of this reflective chain.`},initialValue:{originType:"user",originLabel:"Forge Psyche",timeframeLabel:"Current trigger report",rationale:`Captured from the ${a} stage of the Psyche chain canvas.`},onSubmit:async D=>{await j.mutateAsync(D)}})]})}const os={title:"",status:"draft",eventTypeId:"",customEventType:"",eventSituation:"",occurredAt:"",emotions:[],thoughts:[],behaviors:[],selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[],linkedValueIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],schemaLinks:[],modeTimeline:[],nextMoves:[]};function Pc(){var T,H,U,Z,ie,ge,z,E;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(os),[l,x]=y.useState(null),g=te({queryKey:["forge-psyche-reports"],queryFn:ba}),f=te({queryKey:["forge-psyche-values"],queryFn:yt}),d=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),u=te({queryKey:["forge-psyche-beliefs"],queryFn:Wt}),b=te({queryKey:["forge-psyche-modes"],queryFn:jt}),c=te({queryKey:["forge-psyche-schema-catalog"],queryFn:Qt}),j=te({queryKey:["forge-psyche-event-types"],queryFn:Sn}),k=te({queryKey:["forge-psyche-emotions"],queryFn:Cn}),$=((T=g.data)==null?void 0:T.reports)??[],M=((H=f.data)==null?void 0:H.values)??[],I=((U=d.data)==null?void 0:U.behaviors)??[],N=((Z=u.data)==null?void 0:Z.beliefs)??[],m=((ie=b.data)==null?void 0:ie.modes)??[],w=((ge=c.data)==null?void 0:ge.schemas)??[],L=((z=j.data)==null?void 0:z.eventTypes)??[],S=((E=k.data)==null?void 0:E.emotions)??[],O=t.snapshot.dashboard.notesSummaryByEntity;y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h({...os,customEventType:a.get("intent")==="execution_tension"?"Execution tension":a.get("intent")==="belief"?"Belief script activation":a.get("intent")==="behavior"?"Behavior spike":a.get("intent")==="pattern"?"Recurring pattern":a.get("intent")==="value"?"Blocked value":"",linkedValueIds:a.get("valueId")?[a.get("valueId")]:[],linkedBehaviorIds:a.get("behaviorId")?[a.get("behaviorId")]:[],linkedBeliefIds:a.get("beliefId")?[a.get("beliefId")]:[],linkedGoalIds:a.get("goalId")?[a.get("goalId")]:[],linkedProjectIds:a.get("projectId")?[a.get("projectId")]:[],linkedTaskIds:a.get("taskId")?[a.get("taskId")]:[]});const p=new URLSearchParams(a);p.delete("create"),p.delete("intent"),p.delete("valueId"),p.delete("behaviorId"),p.delete("beliefId"),p.delete("goalId"),p.delete("projectId"),p.delete("taskId"),r(p,{replace:!0})}},[a,r]);const A=de({mutationFn:async p=>{const P=ta.parse({title:p.title,status:p.status,eventTypeId:p.eventTypeId||null,customEventType:p.customEventType,eventSituation:p.eventSituation,occurredAt:p.occurredAt?new Date(p.occurredAt).toISOString():null,emotions:p.emotions.filter(_=>_.label.trim().length>0),thoughts:p.thoughts.filter(_=>_.text.trim().length>0),behaviors:p.behaviors.filter(_=>_.text.trim().length>0),consequences:{selfShortTerm:p.selfShortTerm,selfLongTerm:p.selfLongTerm,othersShortTerm:p.othersShortTerm,othersLongTerm:p.othersLongTerm},linkedPatternIds:[],linkedValueIds:p.linkedValueIds,linkedGoalIds:p.linkedGoalIds,linkedProjectIds:p.linkedProjectIds,linkedTaskIds:p.linkedTaskIds,linkedBehaviorIds:p.linkedBehaviorIds,linkedBeliefIds:p.linkedBeliefIds,linkedModeIds:p.linkedModeIds,modeOverlays:[],schemaLinks:p.schemaLinks.filter(Boolean),modeTimeline:p.modeTimeline.filter(_=>_.stage.trim().length>0&&_.label.trim().length>0),nextMoves:p.nextMoves.filter(Boolean)});return In(P)},onSuccess:async()=>{n(!1),h(os),x(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-reports"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]}),s.invalidateQueries({queryKey:["forge-xp-metrics"]})])}}),v=M.map(p=>({value:p.id,label:p.title,description:p.valuedDirection,kind:"value"})),C=I.map(p=>({value:p.id,label:p.title,description:p.kind,kind:"behavior"})),R=N.map(p=>({value:p.id,label:p.statement,description:p.flexibleAlternative||p.originNote,kind:"belief"})),J=m.map(p=>({value:p.id,label:p.title,description:p.archetype||p.family,kind:"mode"})),G=async p=>{const{value:P}=await Lt({title:p,description:"",valuedDirection:p,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]});return _e(s,["forge-psyche-values"],"values",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.valuedDirection,kind:"value"}},se=async p=>{const{behavior:P}=await Cs({kind:"away",title:p,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[]});return _e(s,["forge-psyche-behaviors"],"behaviors",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.kind,kind:"behavior"}},K=async p=>{const{belief:P}=await ga({schemaId:null,statement:p,beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[]});return _e(s,["forge-psyche-beliefs"],"beliefs",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.statement,description:P.flexibleAlternative||P.originNote,kind:"belief"}},D=async p=>{const{mode:P}=await Ht({family:"coping",archetype:"",title:p,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[]});return _e(s,["forge-psyche-modes"],"modes",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.archetype||P.family,kind:"mode"}},F=[{id:"spark",eyebrow:"Spark",title:"Capture the trigger and the situation",description:"Start with what happened concretely before interpretation takes over.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Report title",children:e.jsx(ae,{value:p.title,onChange:_=>P({title:_.target.value}),placeholder:"Friday silence spiral"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Event type",children:e.jsxs("select",{className:"rounded-[22px] border border-white/8 bg-white/6 px-4 py-3 text-sm text-white",value:p.eventTypeId,onChange:_=>P({eventTypeId:_.target.value}),children:[e.jsx("option",{value:"",children:"Custom or uncategorized"}),L.map(_=>e.jsx("option",{value:_.id,children:_.label},_.id))]})}),e.jsx(q,{label:"Occurred at",children:e.jsx(ae,{type:"datetime-local",value:p.occurredAt,onChange:_=>P({occurredAt:_.target.value})})})]}),e.jsx(q,{label:"Custom event label",children:e.jsx(ae,{value:p.customEventType,onChange:_=>P({customEventType:_.target.value}),placeholder:"Unexpected distance after vulnerability"})}),e.jsx(q,{label:"Situation",children:e.jsx(le,{value:p.eventSituation,onChange:_=>P({eventSituation:_.target.value}),placeholder:"Describe what happened concretely, without explaining it away yet."})})]})},{id:"wave-script-move",eyebrow:"Wave, script, move",title:"Capture the emotional wave, thought script, and behavior",description:"These stay structured, but the flow keeps them staged instead of dumping everything into one giant form.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(sr,{items:p.emotions,onChange:_=>P({emotions:_}),definitions:S}),e.jsx(ar,{items:p.thoughts,onChange:_=>P({thoughts:_}),beliefs:N,modes:m}),e.jsx(ir,{items:p.behaviors,onChange:_=>P({behaviors:_}),behaviors:I,modes:m})]})},{id:"lens-state",eyebrow:"Lens and state",title:"Link the report to beliefs, modes, values, and behavior history",description:"This is where the report becomes part of the larger graphical psyche system.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked values",children:e.jsx(Ae,{options:v,selectedValues:p.linkedValueIds,onChange:_=>P({linkedValueIds:_}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:G})}),e.jsx(q,{label:"Linked behaviors",children:e.jsx(Ae,{options:C,selectedValues:p.linkedBehaviorIds,onChange:_=>P({linkedBehaviorIds:_}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:se})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Linked beliefs",children:e.jsx(Ae,{options:R,selectedValues:p.linkedBeliefIds,onChange:_=>P({linkedBeliefIds:_}),placeholder:"Search or create a belief…",emptyMessage:"No beliefs match yet.",createLabel:"Create belief",onCreate:K})}),e.jsx(q,{label:"Linked modes",children:e.jsx(Ae,{options:J,selectedValues:p.linkedModeIds,onChange:_=>P({linkedModeIds:_}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:D})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[p.linkedGoalIds.length>0?e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/62",children:["Linked to ",p.linkedGoalIds.length," goal tension"]}):null,p.linkedProjectIds.length>0?e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/62",children:["Linked to ",p.linkedProjectIds.length," project tension"]}):null,p.linkedTaskIds.length>0?e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/62",children:["Linked to ",p.linkedTaskIds.length," task tension"]}):null]})]})},{id:"horizon-pivot",eyebrow:"Horizon and pivot",title:"Record consequences, schema pressure, and the next move",description:"Use this step to record what happened next, which schemas were involved, and what you want to do after this moment.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(He,{title:"Short-term impact on you",description:"Add the immediate effects on your body, mood, or direction.",addLabel:"Add self effect",items:p.selfShortTerm,onChange:_=>P({selfShortTerm:_}),placeholder:"I shut down and lost the rest of the evening."}),e.jsx(He,{title:"Long-term impact on you",description:"Capture what this pattern costs when it keeps repeating.",addLabel:"Add self cost",items:p.selfLongTerm,onChange:_=>P({selfLongTerm:_}),placeholder:"It keeps reinforcing the same abandonment story."}),e.jsx(He,{title:"Short-term impact on others",description:"Note what happened to the people around you right away.",addLabel:"Add other effect",items:p.othersShortTerm,onChange:_=>P({othersShortTerm:_}),placeholder:"They felt pushed away and confused."}),e.jsx(He,{title:"Long-term impact on others",description:"Capture the longer pattern this creates in relationships.",addLabel:"Add other cost",items:p.othersLongTerm,onChange:_=>P({othersLongTerm:_}),placeholder:"Trust gets thinner every time this loop takes over."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsx(q,{label:"Schema links",description:"Choose the schemas that were active or that you want to strengthen in this moment.",labelHelp:"Use maladaptive schemas for recurring old patterns that felt active here. Use adaptive schemas for healthier patterns you want to rely on more.",children:e.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:w.filter(_=>_.schemaType==="maladaptive"),schemaType:"maladaptive",description:"Recurring old patterns that felt active in this moment."},{title:"Adaptive schemas",schemas:w.filter(_=>_.schemaType==="adaptive"),schemaType:"adaptive",description:"Healthier stable themes you want this repair move to strengthen."}].map(_=>{const ve=Ct(_.schemaType);return e.jsxs("div",{className:`rounded-[24px] border p-4 ${ve.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:_.title}),e.jsx(Ne,{content:$t(_.schemaType),label:`Explain ${Es(_.schemaType)}`})]}),e.jsx(lt,{className:"mt-2",children:_.description}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:_.schemas.map(oe=>{const Me=p.schemaLinks.some(Oe=>{var ze;return((ze=It(Oe,[oe]))==null?void 0:ze.id)===oe.id});return e.jsx("button",{type:"button",className:`rounded-full border px-3 py-2 text-sm transition ${Me?`${ve.badgeTone} ring-1 ring-white/18`:"border-white/8 bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>P({schemaLinks:er(p.schemaLinks,oe)}),children:oe.title},oe.id)})})]},_.schemaType)})})}),e.jsx(nr,{items:p.modeTimeline,onChange:_=>P({modeTimeline:_}),modes:m,stages:["Spark","Wave","Script","Lens","State","Move","Horizon","Pivot"]}),e.jsx(He,{title:"Next moves",description:"Finish with concrete next moves that protect the value or repair the situation.",addLabel:"Add next move",items:p.nextMoves,onChange:_=>P({nextMoves:_}),placeholder:"Send one honest repair message tomorrow morning."})]})]})}];if(g.isLoading||f.isLoading||d.isLoading||u.isLoading||b.isLoading||c.isLoading||j.isLoading||k.isLoading)return e.jsx(Qe,{eyebrow:"Reports",title:"Loading reports",description:"Getting reports, values, behaviors, beliefs, modes, event labels, and emotions ready."});const W=g.error??f.error??d.error??u.error??b.error??c.error??j.error??k.error;return W?e.jsx(je,{eyebrow:"Trigger reports",error:W,onRetry:()=>void Promise.all([g.refetch(),f.refetch(),d.refetch(),u.refetch(),b.refetch(),c.refetch(),j.refetch(),k.refetch()])}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"report",title:e.jsx(ue,{kind:"report",label:"Reports",variant:"heading",size:"lg"}),description:"Capture the trigger, emotional wave, script, state, and next pivot in one guided reflective chain instead of a single massive worksheet.",badge:`${$.length} reports`,actions:e.jsx(X,{onClick:()=>{h(os),n(!0)},children:"Reflect"})}),e.jsx(Ue,{}),e.jsx(Je,{eyebrow:"Reports",title:"Recent reports",description:"Open any report to review what happened, which beliefs and schemas were involved, and what you want to do next.",tone:"violet",children:e.jsx("div",{className:"grid gap-4",children:$.length===0?e.jsx(Xe,{eyebrow:"Trigger reports",title:"No reports yet",description:"Start a first Spark-to-Pivot chain so Forge can track the full reflective arc instead of isolated notes."}):$.map(p=>{var P;return e.jsxs("div",{className:"rounded-[28px] border border-white/8 bg-white/[0.04] p-5 transition hover:bg-white/[0.07]",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(ue,{kind:"report",label:p.title,variant:"heading",size:"xl"}),e.jsx("div",{className:"mt-2 text-sm text-white/54",children:p.customEventType||p.eventSituation})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{entityType:"trigger_report",entityId:p.id,count:Be(O,"trigger_report",p.id).count}),e.jsx(B,{children:p.status}),e.jsx(xe,{to:`/psyche/reports/${p.id}`,className:"inline-flex min-h-10 items-center rounded-full bg-white/[0.08] px-3 py-2 text-sm text-white transition hover:bg-white/[0.12]",children:"Open report"})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 xl:grid-cols-4",children:[e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Spark"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/66",children:p.eventSituation})]}),e.jsxs("div",{className:"rounded-[20px] bg-[rgba(110,231,183,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Wave"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/66",children:((P=p.emotions[0])==null?void 0:P.label)??"No emotion captured yet"})]}),e.jsxs("div",{className:"rounded-[20px] bg-[rgba(196,181,253,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Lens"}),e.jsx("div",{className:"mt-3",children:p.schemaLinks[0]?(()=>{const _=It(p.schemaLinks[0],w);return _?e.jsx(rt,{label:_.title,schemaType:_.schemaType,compact:!0}):e.jsx("div",{className:"text-sm leading-6 text-white/66",children:p.schemaLinks[0]})})():e.jsx("div",{className:"text-sm leading-6 text-white/66",children:"No schema link yet"})})]}),e.jsxs("div",{className:"rounded-[20px] bg-[rgba(251,191,36,0.08)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Pivot"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/66",children:p.nextMoves[0]??"No next move yet"})]})]})]},p.id)})})}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Trigger report",title:"Build a reflective chain",description:"This guided flow replaces the old open worksheet with a staged Spark-to-Pivot capture.",value:o,onChange:h,steps:F,submitLabel:"Create report",pending:A.isPending,error:l,onSubmit:async()=>{if(x(null),!ta.safeParse({title:o.title,status:o.status,eventTypeId:o.eventTypeId||null,customEventType:o.customEventType,eventSituation:o.eventSituation,occurredAt:o.occurredAt?new Date(o.occurredAt).toISOString():null,emotions:o.emotions.filter(P=>P.label.trim().length>0),thoughts:o.thoughts.filter(P=>P.text.trim().length>0),behaviors:o.behaviors.filter(P=>P.text.trim().length>0),consequences:{selfShortTerm:o.selfShortTerm,selfLongTerm:o.selfLongTerm,othersShortTerm:o.othersShortTerm,othersLongTerm:o.othersLongTerm},linkedPatternIds:[],linkedValueIds:o.linkedValueIds,linkedGoalIds:o.linkedGoalIds,linkedProjectIds:o.linkedProjectIds,linkedTaskIds:o.linkedTaskIds,linkedBehaviorIds:o.linkedBehaviorIds,linkedBeliefIds:o.linkedBeliefIds,linkedModeIds:o.linkedModeIds,modeOverlays:[],schemaLinks:o.schemaLinks.filter(Boolean),modeTimeline:o.modeTimeline.filter(P=>P.stage.trim().length>0&&P.label.trim().length>0),nextMoves:o.nextMoves.filter(Boolean)}).success){x("This report still needs a title and concrete triggering situation.");return}try{await A.mutateAsync(o)}catch(P){x(P instanceof Error?P.message:"Unable to create this report right now.")}}})]})}const At={schemaId:null,statement:"",beliefType:"absolute",originNote:"",confidence:60,evidenceFor:[],evidenceAgainst:[],flexibleAlternative:"",linkedValueIds:[],linkedBehaviorIds:[],linkedModeIds:[],linkedReportIds:[]};function Us(t){return{schemaId:t.schemaId,statement:t.statement,beliefType:t.beliefType,originNote:t.originNote,confidence:t.confidence,evidenceFor:t.evidenceFor,evidenceAgainst:t.evidenceAgainst,flexibleAlternative:t.flexibleAlternative,linkedValueIds:t.linkedValueIds,linkedBehaviorIds:t.linkedBehaviorIds,linkedModeIds:t.linkedModeIds,linkedReportIds:t.linkedReportIds}}function Lc({schema:t,beliefs:s,behaviors:a,reports:r}){const i=s.filter(h=>h.schemaId===t.id).length,n=a.filter(h=>h.linkedSchemaIds.includes(t.id)).length,o=r.filter(h=>h.schemaLinks.some(l=>{const x=It(l,[t]);return(x==null?void 0:x.id)===t.id})).length;return{beliefCount:i,behaviorCount:n,reportCount:o,total:i+n+o}}function tn({title:t,description:s,titleHelp:a,schemas:r,beliefs:i,behaviors:n,reports:o,onOpenBelief:h}){if(r.length===0)return null;const l=Ct(r[0].schemaType);return e.jsxs("section",{className:`min-w-0 grid gap-4 rounded-[30px] border p-4 md:p-5 ${l.sectionTone}`,children:[e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"grid min-w-0 gap-2",children:[e.jsxs("div",{className:`flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] ${l.sectionEyebrow}`,children:[e.jsx("span",{children:t}),a?e.jsx(Ne,{content:a,label:`Explain ${t.toLowerCase()}`}):null]}),e.jsx("div",{className:"max-w-3xl text-sm leading-6 text-white/60",children:s})]}),e.jsxs(B,{children:[r.length," schemas"]})]}),e.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:r.map(x=>{const g=Lc({schema:x,beliefs:i,behaviors:n,reports:o}),f=i.filter(u=>u.schemaId===x.id),d=Ct(x.schemaType);return e.jsxs("div",{className:`min-w-0 rounded-[26px] border p-5 ${d.cardTone}`,children:[e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-3 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(rt,{label:x.title,schemaType:x.schemaType}),e.jsx("div",{className:"mt-3 text-sm text-white/46",children:Ta(x.family)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/62",children:x.description})]}),e.jsxs(B,{children:[g.total," ",d.countLabel]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(B,{className:"bg-white/[0.06] text-white/68",children:[g.beliefCount," beliefs"]}),e.jsxs(B,{className:"bg-white/[0.06] text-white/68",children:[g.behaviorCount," behaviors"]}),e.jsxs(B,{className:"bg-white/[0.06] text-white/68",children:[g.reportCount," reports"]})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[f.length>0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/58",children:`${f.length} ${d.linkSummary}${f.length===1?"":"s"} live here.`}):e.jsx("div",{className:"rounded-[18px] bg-white/[0.03] p-4 text-sm leading-6 text-white/46",children:d.emptyCopy}),f.slice(0,2).map(u=>e.jsxs("button",{type:"button",className:"rounded-[20px] bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.08]",onClick:()=>h(u),children:[e.jsx("div",{className:"font-medium text-white",children:u.statement}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/60",children:u.flexibleAlternative||"No flexible alternative recorded yet."})]},u.id))]})]},x.id)})})]})}function Mc(){var U,Z,ie,ge,z,E;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(null),[l,x]=y.useState(At),[g,f]=y.useState(null),d=te({queryKey:["forge-psyche-schema-catalog"],queryFn:Qt}),u=te({queryKey:["forge-psyche-beliefs"],queryFn:Wt}),b=te({queryKey:["forge-psyche-behaviors"],queryFn:wt}),c=te({queryKey:["forge-psyche-modes"],queryFn:jt}),j=te({queryKey:["forge-psyche-values"],queryFn:yt}),k=te({queryKey:["forge-psyche-reports"],queryFn:ba}),$=((U=d.data)==null?void 0:U.schemas)??[],M=((Z=u.data)==null?void 0:Z.beliefs)??[],I=((ie=b.data)==null?void 0:ie.behaviors)??[],N=((ge=c.data)==null?void 0:ge.modes)??[],m=((z=j.data)==null?void 0:z.values)??[],w=((E=k.data)==null?void 0:E.reports)??[],L=a.get("focus"),S=t.snapshot.dashboard.notesSummaryByEntity;Ut(L),y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h(null),x(At);const p=new URLSearchParams(a);p.delete("create"),r(p,{replace:!0})}},[a,r]);const O=de({mutationFn:async p=>{const P=Ji.parse(p);return o?dl(o.id,P):ga(P)},onSuccess:async()=>{n(!1),h(null),x(At),f(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-beliefs"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),A=m.map(p=>({value:p.id,label:p.title,description:p.valuedDirection,kind:"value"})),v=I.map(p=>({value:p.id,label:p.title,description:p.kind,kind:"behavior"})),C=N.map(p=>({value:p.id,label:p.title,description:p.archetype||p.family,kind:"mode"})),R=w.map(p=>({value:p.id,label:p.title,description:p.customEventType||p.eventSituation,kind:"report"})),J=y.useMemo(()=>new Map($.map(p=>[p.id,p])),[$]),G=y.useMemo(()=>$.filter(p=>p.schemaType==="maladaptive"),[$]),se=y.useMemo(()=>$.filter(p=>p.schemaType==="adaptive"),[$]),K=async p=>{const{value:P}=await Lt({title:p,description:"",valuedDirection:p,whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]});return _e(s,["forge-psyche-values"],"values",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.valuedDirection,kind:"value"}},D=async p=>{const{behavior:P}=await Cs({kind:"away",title:p,description:"",commonCues:[],urgeStory:"",shortTermPayoff:"",longTermCost:"",replacementMove:"",repairPlan:"",linkedPatternIds:[],linkedValueIds:[],linkedSchemaIds:[],linkedModeIds:[]});return _e(s,["forge-psyche-behaviors"],"behaviors",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.kind,kind:"behavior"}},F=async p=>{const{mode:P}=await Ht({family:"coping",archetype:"",title:p,persona:"",imagery:"",symbolicForm:"",facialExpression:"",fear:"",burden:"",protectiveJob:"",originContext:"",firstAppearanceAt:null,linkedPatternIds:[],linkedBehaviorIds:[],linkedValueIds:[]});return _e(s,["forge-psyche-modes"],"modes",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.archetype||P.family,kind:"mode"}},W=async p=>{const{report:P}=await In({title:p,status:"draft",eventTypeId:null,customEventType:"",eventSituation:p,occurredAt:null,emotions:[],thoughts:[],behaviors:[],consequences:{selfShortTerm:[],selfLongTerm:[],othersShortTerm:[],othersLongTerm:[]},linkedPatternIds:[],linkedValueIds:[],linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],linkedBehaviorIds:[],linkedBeliefIds:[],linkedModeIds:[],modeOverlays:[],schemaLinks:[],modeTimeline:[],nextMoves:[]});return _e(s,["forge-psyche-reports"],"reports",P),await s.invalidateQueries({queryKey:["forge-psyche-overview"]}),{value:P.id,label:P.title,description:P.customEventType||P.eventSituation,kind:"report"}};y.useEffect(()=>{i&&f(null)},[i]);const T=[{id:"lens",eyebrow:"Lens",title:"Choose the schema and belief script",description:"Place the belief inside the right schema system, then write the actual inner line that tends to fire there.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Schema",description:"Choose the schema this belief belongs to, whether it is a recurring old pattern or a healthier pattern you want to strengthen.",labelHelp:"Schemas are the broader repeating themes. Beliefs are the personal scripts that fire inside those themes.",children:e.jsx("div",{className:"grid gap-4",children:[{title:"Maladaptive schemas",schemas:G,description:"Recurring old patterns that tend to get activated and distort how the situation feels.",schemaType:"maladaptive"},{title:"Adaptive schemas",schemas:se,description:"Healthier stable themes you want to strengthen, trust, and live from more often.",schemaType:"adaptive"}].map(_=>{const ve=Ct(_.schemaType);return e.jsxs("div",{className:`rounded-[24px] border p-4 ${ve.cardTone}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:_.title}),e.jsx(Ne,{content:$t(_.schemaType),label:`Explain ${Es(_.schemaType)}`})]}),e.jsx(lt,{className:"mt-2",children:_.description}),e.jsx("div",{className:"mt-4 grid gap-2 sm:flex sm:flex-wrap",children:_.schemas.map(oe=>{const Me=p.schemaId===oe.id;return e.jsx("button",{type:"button",className:`w-full rounded-[18px] border px-3 py-2 text-left text-sm leading-5 transition sm:w-auto sm:rounded-full ${Me?`${ve.badgeTone} ring-1 ring-white/18`:"border-white/8 bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"}`,onClick:()=>P({schemaId:oe.id}),children:oe.title},oe.id)})})]},_.schemaType)})})}),e.jsx(q,{label:"Belief statement",description:"Write the sentence the mind tends to say in the moment.",labelHelp:"A belief script should sound like the actual inner line that shows up under pressure, not a formal summary.",children:e.jsx(ae,{value:p.statement,onChange:_=>P({statement:_.target.value}),placeholder:"If they go quiet, I am already being left."})}),e.jsx(q,{label:"Belief type",description:"Choose whether the script sounds absolute or conditional.",labelHelp:"Absolute beliefs sound fixed and global. Conditional beliefs sound more like if-then rules about safety, worth, or closeness.",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:["absolute","conditional"].map(_=>e.jsx("button",{type:"button",className:`rounded-[22px] border px-4 py-4 text-left transition ${p.beliefType===_?"border-white/20 bg-white/[0.12] text-white":"border-white/8 bg-white/[0.04] text-white/62 hover:bg-white/[0.07]"}`,onClick:()=>P({beliefType:_}),children:_==="absolute"?"Absolute: this is simply true":"Conditional: if this happens, then..."},_))})})]})},{id:"origin",eyebrow:"Origin",title:"Capture the origin and confidence of the script",description:"This keeps the belief from turning into a generic note divorced from actual history.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Origin context",description:"Capture where this script learned its force or usefulness.",children:e.jsx(le,{value:p.originNote,onChange:_=>P({originNote:_.target.value}),placeholder:"It got stronger in periods where silence usually meant anger, distance, or punishment."})}),e.jsxs(q,{label:"Grip right now",description:"How strongly does this belief feel true when it gets activated?",labelHelp:"Grip is the felt strength of the script in the moment, not whether it is objectively true.",children:[e.jsx("input",{type:"range",min:0,max:100,value:p.confidence,onChange:_=>P({confidence:Number(_.target.value)})}),e.jsxs("div",{className:"text-sm text-white/48",children:[p.confidence,"% grip"]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(q,{label:"Evidence for",description:"Add one supporting memory, sign, or interpretation per line.",children:e.jsx(le,{value:p.evidenceFor.join(`
|
|
21
|
+
`),onChange:_=>P({evidenceFor:_.target.value.split(`
|
|
22
|
+
`).map(ve=>ve.trim()).filter(Boolean)}),placeholder:`One line per sign
|
|
23
|
+
They stopped replying for days
|
|
24
|
+
I was ignored when I asked directly`})}),e.jsx(q,{label:"Evidence against",description:"Add one counterexample, nuance, or disconfirming sign per line.",children:e.jsx(le,{value:p.evidenceAgainst.join(`
|
|
25
|
+
`),onChange:_=>P({evidenceAgainst:_.target.value.split(`
|
|
26
|
+
`).map(ve=>ve.trim()).filter(Boolean)}),placeholder:`One line per counterpoint
|
|
27
|
+
They later explained they were overwhelmed
|
|
28
|
+
Other people stay close without constant contact`})})]})]})},{id:"repair",eyebrow:"Repair",title:"Define the flexible alternative and attach the wider system",description:"The flexible alternative is the repair move; the links keep it attached to behaviors, values, modes, and reports.",render:(p,P)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Flexible alternative",description:"Write the steadier line you want available when the old script activates.",labelHelp:"A flexible alternative is not fake positivity. It is a truer, more workable belief that leaves room for uncertainty.",children:e.jsx(le,{value:p.flexibleAlternative,onChange:_=>P({flexibleAlternative:_.target.value}),placeholder:"Silence can mean many things. I can check the facts before deciding I am being left."})}),e.jsx(q,{label:"Linked values",description:"Choose the valued directions this belief interferes with most.",children:e.jsx(Ae,{options:A,selectedValues:p.linkedValueIds,onChange:_=>P({linkedValueIds:_}),placeholder:"Search or create a value…",emptyMessage:"No values match yet.",createLabel:"Create value",onCreate:K})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(q,{label:"Linked behaviors",description:"Choose the moves this belief tends to trigger or justify.",children:e.jsx(Ae,{options:v,selectedValues:p.linkedBehaviorIds,onChange:_=>P({linkedBehaviorIds:_}),placeholder:"Search or create a behavior…",emptyMessage:"No behaviors match yet.",createLabel:"Create behavior",onCreate:D})}),e.jsx(q,{label:"Linked modes",description:"Choose the inner states that most often carry this script.",children:e.jsx(Ae,{options:C,selectedValues:p.linkedModeIds,onChange:_=>P({linkedModeIds:_}),placeholder:"Search or create a mode…",emptyMessage:"No modes match yet.",createLabel:"Create mode",onCreate:F})}),e.jsx(q,{label:"Linked reports",description:"Choose the reflective chains where this script has already shown up.",children:e.jsx(Ae,{options:R,selectedValues:p.linkedReportIds,onChange:_=>P({linkedReportIds:_}),placeholder:"Search or create a report…",emptyMessage:"No reports match yet.",createLabel:"Create report",onCreate:W})})]})]})}];if(d.isLoading||u.isLoading||b.isLoading||c.isLoading||j.isLoading||k.isLoading)return e.jsx(Qe,{eyebrow:"Schemas & beliefs",title:"Loading schemas and beliefs",description:"Getting schemas, beliefs, behaviors, modes, values, and linked reports ready."});const H=d.error??u.error??b.error??c.error??j.error??k.error;return H?e.jsx(je,{eyebrow:"Schemas & beliefs",error:H,onRetry:()=>void Promise.all([d.refetch(),u.refetch(),b.refetch(),c.refetch(),j.refetch(),k.refetch()])}):e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ke,{title:"Schemas & Beliefs",description:"Review your schemas and beliefs together. See which beliefs are tied to each schema, then open any belief to edit it in context.",badge:`${M.length} beliefs`,actions:e.jsx(X,{onClick:()=>{h(null),x(At),n(!0)},children:"Add belief"})}),e.jsx(Ue,{}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsx(Je,{eyebrow:"Schemas",title:"Schemas",description:"Use these groups to notice recurring old patterns and to reinforce healthier patterns you want to rely on more often.",titleHelp:"Schemas are broad recurring patterns that shape how situations feel and how you respond. Use them to organize beliefs, behaviors, and reports around patterns that repeat.",tone:"violet",children:$.length===0?e.jsx("div",{className:"text-sm text-white/56",children:"Schema data is unavailable right now."}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(tn,{title:"Maladaptive schemas",titleHelp:$t("maladaptive"),description:"These schemas describe recurring old patterns that can change how you read situations and react.",schemas:G,beliefs:M,behaviors:I,reports:w,onOpenBelief:p=>{h(p),x(Us(p)),n(!0)}}),e.jsx(tn,{title:"Adaptive schemas",titleHelp:$t("adaptive"),description:"These schemas describe healthier patterns you want to trust, practice, and strengthen over time.",schemas:se,beliefs:M,behaviors:I,reports:w,onOpenBelief:p=>{h(p),x(Us(p)),n(!0)}})]})}),e.jsx(Je,{eyebrow:"Beliefs",title:"Beliefs",description:"Use this list to review and edit the stories you tell yourself. Open any belief to update the wording, evidence, or a more flexible alternative.",titleHelp:"Beliefs are the specific scripts or rules that show up in your mind, such as what you expect from yourself, from other people, or from a situation.",tone:"sky",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx(X,{onClick:()=>{h(null),x(At),n(!0)},children:"Add belief"}),M.length===0?e.jsx("div",{className:"text-sm text-white/56",children:"Your beliefs will appear here after you add the first one."}):M.map(p=>{const P=p.schemaId?J.get(p.schemaId)??null:null,_=L===p.id;return e.jsxs("div",{"data-psyche-focus-id":p.id,className:`rounded-[24px] border border-white/8 bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.08] ${Yt(_)}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:p.statement}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx(Fe,{entityType:"belief_entry",entityId:p.id,count:Be(S,"belief_entry",p.id).count}),e.jsxs(B,{children:[p.confidence,"% grip"]}),e.jsx(X,{variant:"secondary",size:"sm",onClick:()=>{h(p),x(Us(p)),n(!0)},children:"Edit"})]})]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:p.flexibleAlternative||"No flexible alternative recorded yet."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[P?e.jsx(rt,{label:P.title,schemaType:P.schemaType,compact:!0,showType:!0}):null,N.filter(ve=>p.linkedModeIds.includes(ve.id)).slice(0,2).map(ve=>e.jsx(re,{kind:"mode",label:ve.title,compact:!0},ve.id))]})]},p.id)})]})})]}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Belief",title:o?"Refine belief":"Create belief",description:"Use this guided flow to capture the belief, what seems to support it, and a more flexible alternative.",value:l,onChange:x,steps:T,submitLabel:o?"Save belief":"Create belief",pending:O.isPending,error:g,onSubmit:async()=>{f(null);const p=Ji.safeParse(l);if(!p.success){f("This belief still needs a statement before it can be saved.");return}try{await O.mutateAsync(p.data)}catch(P){f(P instanceof Error?P.message:"Unable to save this belief right now.")}}})]})}const ls={title:"",description:"",valuedDirection:"",whyItMatters:"",linkedGoalIds:[],linkedProjectIds:[],linkedTaskIds:[],committedActions:[]};function Ys(t,s){return t.includes(s)?t.filter(a=>a!==s):[...t,s]}function Ec(t){return{title:t.title,description:t.description,valuedDirection:t.valuedDirection,whyItMatters:t.whyItMatters,linkedGoalIds:t.linkedGoalIds,linkedProjectIds:t.linkedProjectIds,linkedTaskIds:t.linkedTaskIds,committedActions:t.committedActions}}function Ac(){var M;const t=Le(),s=Pe(),[a,r]=Ze(),[i,n]=y.useState(!1),[o,h]=y.useState(null),[l,x]=y.useState(ls),[g,f]=y.useState(null),d=te({queryKey:["forge-psyche-values"],queryFn:yt}),u=((M=d.data)==null?void 0:M.values)??[],b=a.get("focus"),c=t.snapshot.dashboard.notesSummaryByEntity;Ut(b),y.useEffect(()=>{if(a.get("create")==="1"){n(!0),h(null),x(ls);const I=new URLSearchParams(a);I.delete("create"),r(I,{replace:!0})}},[a,r]);const j=de({mutationFn:async I=>{const N=Hi.parse(I);return o?rl(o.id,N):Lt(N)},onSuccess:async()=>{n(!1),h(null),x(ls),f(null),await Promise.all([s.invalidateQueries({queryKey:["forge-psyche-values"]}),s.invalidateQueries({queryKey:["forge-psyche-overview"]})])}}),k=y.useMemo(()=>u.slice(0,5).map((I,N)=>({id:I.id,label:`${I.linkedGoalIds.length} goals`,title:I.title,detail:I.valuedDirection,href:`/psyche/values?focus=${I.id}#values-atlas`,angle:-90+N*68,radius:150+N%2*20,tone:["mint","sky","violet","rose"][N%4]})),[u]),$=[{id:"direction",eyebrow:"Compass",title:"Name the direction you want to protect",description:"Start with the value itself and the life-direction it points toward.",render:(I,N)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Value name",children:e.jsx(ae,{value:I.title,onChange:m=>N({title:m.target.value}),placeholder:"Repair with steadiness"})}),e.jsx(q,{label:"Valued direction",children:e.jsx(ae,{value:I.valuedDirection,onChange:m=>N({valuedDirection:m.target.value}),placeholder:"Warm, brave, and honest connection"})}),e.jsx(q,{label:"Why it matters",children:e.jsx(le,{value:I.whyItMatters,onChange:m=>N({whyItMatters:m.target.value}),placeholder:"Why is this direction important enough to protect when pressure rises?"})})]})},{id:"shape",eyebrow:"Texture",title:"Describe how the value should feel in lived form",description:"Keep this concrete enough that later reports and behaviors can map back to it.",render:(I,N)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Description",children:e.jsx(le,{value:I.description,onChange:m=>N({description:m.target.value}),placeholder:"Describe what this value looks like in daily behavior, not just in theory."})}),e.jsx(q,{label:"Committed action ideas",children:e.jsx(le,{value:I.committedActions.join(`
|
|
29
|
+
`),onChange:m=>N({committedActions:m.target.value.split(`
|
|
30
|
+
`).map(w=>w.trim()).filter(Boolean)}),placeholder:`One line per action
|
|
31
|
+
Text your sister before Friday
|
|
32
|
+
Take a ten-minute reset walk`})})]})},{id:"links",eyebrow:"Placement",title:"Place the value into the real system of work",description:"This is where values become graphical anchors across goals, projects, and tasks instead of standalone notes.",render:(I,N)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Linked goals",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.snapshot.goals.map(m=>{const w=I.linkedGoalIds.includes(m.id);return e.jsx("button",{type:"button",className:`rounded-full px-2.5 py-2 text-sm transition ${_t("goal",w)}`,onClick:()=>N({linkedGoalIds:Ys(I.linkedGoalIds,m.id)}),children:e.jsx(re,{kind:"goal",label:m.title,compact:!0,gradient:!1})},m.id)})})}),e.jsx(q,{label:"Linked projects",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.snapshot.dashboard.projects.map(m=>{const w=I.linkedProjectIds.includes(m.id);return e.jsx("button",{type:"button",className:`rounded-full px-2.5 py-2 text-sm transition ${_t("project",w)}`,onClick:()=>N({linkedProjectIds:Ys(I.linkedProjectIds,m.id)}),children:e.jsx(re,{kind:"project",label:m.title,compact:!0,gradient:!1})},m.id)})})}),e.jsx(q,{label:"Linked tasks",children:e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:t.snapshot.tasks.slice(0,24).map(m=>{const w=I.linkedTaskIds.includes(m.id);return e.jsx("button",{type:"button",className:`rounded-full px-2.5 py-2 text-sm transition ${_t("task",w)}`,onClick:()=>N({linkedTaskIds:Ys(I.linkedTaskIds,m.id)}),children:e.jsx(re,{kind:"task",label:m.title,compact:!0,gradient:!1})},m.id)})})})]})}];return d.isLoading?e.jsx(Qe,{eyebrow:"Psyche values",title:"Loading value constellation",description:"Hydrating values, linked goals, projects, and tasks."}):d.isError?e.jsx(je,{eyebrow:"Psyche values",error:d.error,onRetry:()=>void d.refetch()}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"value",title:e.jsx(ue,{kind:"value",label:"Values",variant:"heading",size:"lg"}),description:"Map values as living anchors. Each one should visibly relate to goals, projects, and tasks so reflection stops feeling separate from the rest of life.",badge:`${u.length} values`,actions:e.jsx(X,{onClick:()=>{h(null),x(ls),n(!0)},children:"Add value"})}),e.jsx(Ue,{}),e.jsx(tr,{title:"Place values inside the wider life system",description:"Values are not just notes. This constellation shows which directions are already attached to real goals, projects, and concrete tasks.",centerLabel:"Value field",centerValue:`${u.length} mapped`,nodes:k,action:e.jsx(X,{onClick:()=>n(!0),children:"Add value"})}),e.jsx(Je,{eyebrow:"Values in context",title:"See why each value matters and where it lives",description:"Each card combines the value narrative with its linked goals, projects, tasks, and committed actions so you can understand the shape immediately.",tone:"mint",className:"scroll-mt-24",children:e.jsx("div",{id:"values-atlas",className:"grid gap-4",children:u.length===0?e.jsx("div",{className:"flex justify-start",children:e.jsx(X,{onClick:()=>n(!0),children:"Add value"})}):u.map(I=>{const N=t.snapshot.goals.filter(O=>I.linkedGoalIds.includes(O.id)),m=t.snapshot.dashboard.projects.filter(O=>I.linkedProjectIds.includes(O.id)),w=t.snapshot.tasks.filter(O=>I.linkedTaskIds.includes(O.id)),L=b===I.id,S=Be(c,"psyche_value",I.id).count;return e.jsxs("div",{"data-psyche-focus-id":I.id,className:`rounded-[26px] border border-white/8 bg-white/[0.04] p-5 transition ${Yt(L)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(ue,{kind:"value",label:I.title,variant:"heading",size:"xl"}),e.jsx("div",{className:"mt-2 text-sm text-[var(--tertiary)]",children:I.valuedDirection})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{entityType:"psyche_value",entityId:I.id,count:S}),e.jsx(X,{variant:"secondary",onClick:()=>{h(I),x(Ec(I)),n(!0)},children:"Edit"})]})]}),e.jsx("p",{className:"mt-4 max-w-3xl text-sm leading-7 text-white/60",children:I.description}),e.jsxs("div",{className:"mt-5 grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Why it matters"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/64",children:I.whyItMatters})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Goals"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:N.length===0?e.jsx("span",{className:"text-sm text-white/44",children:"None linked"}):N.map(O=>e.jsx(re,{kind:"goal",label:O.title,compact:!0},O.id))})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Projects"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:m.length===0?e.jsx("span",{className:"text-sm text-white/44",children:"None linked"}):m.map(O=>e.jsx(re,{kind:"project",label:O.title,compact:!0},O.id))})]}),e.jsxs("div",{className:"rounded-[22px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/38",children:"Tasks"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:w.length===0?e.jsx("span",{className:"text-sm text-white/44",children:"None linked"}):w.slice(0,4).map(O=>e.jsx(re,{kind:"task",label:O.title,compact:!0},O.id))})]})]})]}),e.jsx("div",{className:"mt-4 grid gap-2 md:grid-cols-2",children:I.committedActions.map(O=>e.jsx("div",{className:"rounded-[18px] bg-[rgba(110,231,183,0.08)] px-4 py-3 text-sm text-white/72",children:O},O))})]},I.id)})})}),e.jsx(qe,{open:i,onOpenChange:n,eyebrow:"Value",title:o?"Refine value placement":"Create value",description:"Forge should capture values through guided placement, not a raw admin form.",value:l,onChange:x,steps:$,submitLabel:o?"Save value":"Create value",pending:j.isPending,error:g,onSubmit:async()=>{f(null);const I=Hi.safeParse(l);if(!I.success){f("This value still needs a title and valued direction before it can be saved.");return}try{await j.mutateAsync(I.data)}catch(N){f(N instanceof Error?N.message:"Unable to save this value right now.")}}})]})}const ds=[{to:"/settings",label:"General",icon:Jr},{to:"/settings/agents",label:"Agents",icon:Vr},{to:"/settings/rewards",label:"Rewards",icon:Zr},{to:"/settings/bin",label:"Bin",icon:Zs}];function Js(t,s){return s==="/settings"?t==="/settings":t===s||t.startsWith(`${s}/`)}function Ds({className:t}){const s=oa(),[a,r]=y.useState(!1),i=y.useMemo(()=>[...ds].sort((n,o)=>o.to.length-n.to.length).find(n=>Js(s.pathname,n.to))??ds[0],[s.pathname]);return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{className:Q("overflow-hidden bg-[linear-gradient(180deg,rgba(15,24,31,0.94),rgba(10,18,25,0.92))] p-2",t),children:[e.jsx("div",{className:"hidden items-center gap-3 lg:flex",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ds.map(n=>e.jsxs(gt,{to:n.to,end:n.to==="/settings",className:({isActive:o})=>Q("inline-flex items-center gap-2 whitespace-nowrap rounded-full px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",o||Js(s.pathname,n.to)?"bg-[var(--primary)]/[0.18] text-[var(--primary)]":"bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"),children:[e.jsx(n.icon,{className:"size-3.5"}),e.jsx("span",{children:n.label})]},n.to))})}),e.jsx("div",{className:"flex items-center justify-between gap-3 lg:hidden",children:e.jsxs("button",{type:"button",className:"inline-flex min-w-0 flex-1 items-center justify-between rounded-full bg-white/[0.06] px-4 py-3 text-left",onClick:()=>r(!0),children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(i.icon,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"truncate text-sm font-medium text-white",children:i.label})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.16em] text-white/42",children:"Switch"})]})})]}),a?e.jsx("div",{className:"fixed inset-0 z-50 bg-[rgba(5,10,18,0.86)] px-4 py-5 backdrop-blur-xl lg:hidden",children:e.jsxs("div",{className:"mx-auto flex h-full max-w-xl flex-col rounded-[32px] bg-[linear-gradient(180deg,rgba(16,25,33,0.98),rgba(11,18,25,0.98))] p-5 shadow-[0_30px_80px_rgba(0,0,0,0.35)]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/38",children:"Settings"}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:"Navigate to section"})]}),e.jsx(X,{variant:"secondary",onClick:()=>r(!1),children:"Close"})]}),e.jsx("div",{className:"mt-6 grid gap-3 overflow-y-auto",children:ds.map(n=>e.jsxs(gt,{to:n.to,end:n.to==="/settings",onClick:()=>r(!1),className:Q("flex items-center justify-between rounded-[24px] px-4 py-4 transition",Js(s.pathname,n.to)?"bg-[var(--primary)]/[0.14] text-white":"bg-white/[0.04] text-white/70"),children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(n.icon,{className:"size-4 text-[var(--primary)]"}),e.jsx("span",{className:"text-base font-medium",children:n.label})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.16em] text-white/36",children:"Open"})]},n.to))})]})}):null]})}function Dc(){var g,f;const{t}=Te(),s=Pe(),a=te({queryKey:["forge-operator-session"],queryFn:Gt}),r=a.isSuccess,i=te({queryKey:["forge-settings"],queryFn:fa,enabled:r}),n=xs({defaultValues:{profile:{operatorName:"",operatorEmail:"",operatorTitle:""},notifications:{goalDriftAlerts:!0,dailyQuestReminders:!0,achievementCelebrations:!0},execution:{maxActiveTasks:2,timeAccountingMode:"split"},themePreference:"obsidian",localePreference:"en"}}),o=async()=>{await Promise.all([s.invalidateQueries({queryKey:["forge-operator-session"]}),s.invalidateQueries({queryKey:["forge-settings"]})])},h=de({mutationFn:d=>Ml(d),onSuccess:o}),l=de({mutationFn:al,onSuccess:async()=>{await o(),await a.refetch()}});y.useEffect(()=>{var d;(d=i.data)!=null&&d.settings&&n.reset(qo.parse(i.data.settings))},[i.data,n]);const x=(g=i.data)==null?void 0:g.settings;return a.isLoading||i.isLoading?e.jsx(et,{eyebrow:"Settings",title:"Loading settings",description:"Establishing the operator session and fetching current configuration.",columns:2,blocks:6}):a.isError?e.jsx(je,{eyebrow:"Settings",error:a.error,onRetry:()=>void a.refetch()}):i.isError||!x?e.jsx(je,{eyebrow:"Settings",error:i.error??new Error("Forge returned an empty settings payload."),onRetry:()=>void i.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(ke,{title:"Settings",description:"Tune execution policy, timer behaviour, and personal preferences.",badge:`${x.security.integrityScore}% integrity`}),e.jsx(Ds,{}),(f=a.data)!=null&&f.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:a.data.session.actorLabel}),"."]}),e.jsx(X,{variant:"secondary",size:"sm",pending:l.isPending,pendingLabel:"Resetting session",onClick:()=>void l.mutateAsync(),children:"Reset operator session"})]}):null,e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Y,{children:e.jsxs("form",{className:"grid gap-4",onSubmit:n.handleSubmit(async d=>{await h.mutateAsync(d)}),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-4 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(ae,{...n.register("profile.operatorName")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Email"}),e.jsx(ae,{...n.register("profile.operatorEmail")})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Title"}),e.jsx(ae,{...n.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-4 lg:grid-cols-[minmax(0,0.75fr)_minmax(0,1.25fr)]",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Maximum active tasks"}),e.jsx(ae,{type:"number",min:1,max:8,...n.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-3 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(d=>e.jsxs("label",{className:"grid gap-2 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"radio",value:d.value,...n.register("execution.timeAccountingMode")}),e.jsx("span",{className:"text-white/82",children:d.label})]}),e.jsx("span",{className:"text-sm leading-6 text-white/56",children:d.description})]},d.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-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-white/72",children:"Goal drift alerts"}),e.jsx("input",{type:"checkbox",...n.register("notifications.goalDriftAlerts")})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-white/72",children:"Daily quest reminders"}),e.jsx("input",{type:"checkbox",...n.register("notifications.dailyQuestReminders")})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsx("span",{className:"text-white/72",children:"Achievement celebrations"}),e.jsx("input",{type:"checkbox",...n.register("notifications.achievementCelebrations")})]}),e.jsx("div",{className:"mt-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Theme calibration"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:["obsidian","solar","system"].map(d=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("input",{type:"radio",value:d,...n.register("themePreference")}),e.jsx("span",{className:"text-white/72 capitalize",children:d})]},d))}),e.jsx("div",{className:"mt-2 font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.settings.localeLabel")}),e.jsx("p",{className:"text-sm text-white/58",children:t("common.settings.localeDescription")}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:[{value:"en",label:t("common.settings.localeEnglish")},{value:"fr",label:t("common.settings.localeFrench")}].map(d=>e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] bg-white/[0.04] px-4 py-4",children:[e.jsx("input",{type:"radio",value:d.value,...n.register("localePreference")}),e.jsx("span",{className:"text-white/72",children:d.label})]},d.value))}),e.jsx(X,{type:"submit",pending:h.isPending,pendingLabel:"Saving settings",children:"Save settings"})]})}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Security posture"}),e.jsxs("div",{className:"mt-4 grid gap-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:"Storage mode"}),e.jsx("div",{className:"mt-2 font-display text-2xl text-white",children:x.security.storageMode})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm text-white/58",children:"Last audit"}),e.jsx("div",{className:"mt-2 text-white",children:new Date(x.security.lastAuditAt).toLocaleString()})]})]})]})]})]})}const vs=["read","write","insights","rewards.manage","psyche.read","psyche.write","psyche.note","psyche.insight","psyche.mode"],Rc=[{value:"read",label:"Read",description:"Inspect goals, projects, tasks, reviews, and metrics."},{value:"write",label:"Write",description:"Create and update work through the versioned API."},{value:"insights",label:"Insights",description:"Store structured findings, rationale, and feedback."},{value:"rewards.manage",label:"Rewards",description:"Tune reward rules and issue explainable bonus XP grants."},{value:"psyche.read",label:"Psyche read",description:"Read sensitive values, patterns, and trigger analyses."},{value:"psyche.write",label:"Psyche write",description:"Create and update sensitive therapeutic records."},{value:"psyche.note",label:"Psyche note",description:"Create and edit Markdown notes linked to reflective records."},{value:"psyche.insight",label:"Psyche insight",description:"Store therapeutic insights on Psyche entities."},{value:"psyche.mode",label:"Psyche mode",description:"Name, refine, and map mode profiles and guided mode results."}];function rr(t,s,a){return s==="review"?{...t,preset:s,trustLevel:"trusted",autonomyMode:"approval_required",approvalMode:"approval_by_default",scopes:[...a]}:s==="operator"?{...t,preset:s,trustLevel:"trusted",autonomyMode:"scoped_write",approvalMode:"high_impact_only",scopes:[...vs]}:s==="autonomous"?{...t,preset:s,trustLevel:"autonomous",autonomyMode:"autonomous",approvalMode:"none",scopes:[...vs]}:{...t,preset:s}}function sn(t,s,a){const r={preset:t,label:"Forge Pilot Token",agentLabel:s,agentType:"assistant",description:"Collaborative planning agent.",trustLevel:"trusted",autonomyMode:"scoped_write",approvalMode:"high_impact_only",scopes:[...vs]};return rr(r,t,a)}function _c({open:t,onOpenChange:s,pending:a=!1,initialPreset:r="operator",defaultAgentLabel:i="OpenClaw",recommendedScopes:n=[...vs],onSubmit:o}){const[h,l]=y.useState(()=>sn(r,i,n)),[x,g]=y.useState(null);y.useEffect(()=>{t&&(l(sn(r,i,n)),g(null))},[t,r,i,n]);const f=[{id:"preset",eyebrow:"Agent token",title:"Choose a starting point for this token",description:"Each preset locks in a sensible trust, autonomy, and approval policy. You can tune any setting in the next steps.",render:(d,u)=>e.jsx(Re,{columns:3,value:d.preset,onChange:b=>u(rr(d,b,n)),options:[{value:"review",label:"Review-first",description:"Every action waits for your approval. Safe starting point for a new agent you have not yet trusted."},{value:"operator",label:"Full operator",description:"Trusted collaborator with full scopes. High-impact actions still ask for approval."},{value:"autonomous",label:"Autonomous pilot",description:"No approval gates. Use only for agents you have fully verified in a controlled setup."},{value:"custom",label:"Custom",description:"Start from a blank slate and configure every dimension yourself."}]})},{id:"identity",eyebrow:"Agent identity",title:"Name the agent and this token",description:"The agent name appears in logs, approval requests, and audit trails. The token label is for your reference.",render:(d,u)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Agent name",labelHelp:"This label identifies the agent in every log entry, approval notification, and XP attribution. Pick something memorable.",children:e.jsx(ae,{value:d.agentLabel,placeholder:"OpenClaw",onChange:b=>u({agentLabel:b.target.value})})}),e.jsx(q,{label:"Token label",description:"A short name for this credential — mainly for your reference in the token list.",children:e.jsx(ae,{value:d.label,placeholder:"Forge Pilot Token",onChange:b=>u({label:b.target.value})})}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsx(q,{label:"Agent type",labelHelp:"Use 'assistant' for interactive agents. Use 'automation' for scripts or scheduled jobs with no conversational layer.",children:e.jsxs("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:d.agentType,onChange:b=>u({agentType:b.target.value}),children:[e.jsx("option",{value:"assistant",children:"assistant"}),e.jsx("option",{value:"automation",children:"automation"}),e.jsx("option",{value:"observer",children:"observer"})]})}),e.jsx(q,{label:"Description",description:"Optional note about what this agent does.",children:e.jsx(ae,{value:d.description,placeholder:"Collaborative planning agent.",onChange:b=>u({description:b.target.value})})})]})]})},{id:"policy",eyebrow:"Access policy",title:"Set trust level and approval behaviour",description:"These three settings control how much autonomy the agent has and when it needs your sign-off. The preset you chose filled sensible defaults — adjust only if needed.",render:(d,u)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Trust level",labelHelp:"Standard agents are sandboxed readers. Trusted agents can write with policy guardrails. Autonomous agents bypass all trust checks — use with care.",children:e.jsx(Re,{columns:3,value:d.trustLevel,onChange:b=>u({trustLevel:b}),options:[{value:"standard",label:"Standard",description:"Read-only by default, limited write surface."},{value:"trusted",label:"Trusted",description:"Full write surface with policy guardrails active."},{value:"autonomous",label:"Autonomous",description:"All checks bypassed — maximum capability."}]})}),e.jsx(q,{label:"Autonomy mode",labelHelp:"Approval-required means every mutation is held for review. Scoped write lets the agent act within its scopes. Autonomous skips all gates.",children:e.jsx(Re,{columns:3,value:d.autonomyMode,onChange:b=>u({autonomyMode:b}),options:[{value:"approval_required",label:"Approval required",description:"Every write action queues for your review."},{value:"scoped_write",label:"Scoped write",description:"Acts freely within its assigned scopes."},{value:"autonomous",label:"Autonomous",description:"No gates — full freedom to write."}]})}),e.jsx(q,{label:"Approval policy",labelHelp:"Controls which actions trigger the approval queue. High-impact-only is the balanced default: routine writes go through, large mutations get reviewed.",children:e.jsx(Re,{columns:3,value:d.approvalMode,onChange:b=>u({approvalMode:b}),options:[{value:"approval_by_default",label:"Approve by default",description:"Everything needs a sign-off unless explicitly exempt."},{value:"high_impact_only",label:"High impact only",description:"Routine writes pass through; high-stakes actions are held."},{value:"none",label:"None",description:"No approval gates — actions execute immediately."}]})})]})},{id:"scopes",eyebrow:"Scopes",title:"Select what this agent can access",description:"Scope selection follows the principle of least privilege — only grant what the agent actually needs. The full operator bundle covers every capability.",render:(d,u)=>e.jsxs(q,{label:"Capabilities",labelHelp:"Read lets the agent inspect the system. Write lets it create and update work. Rewards and Psyche scopes unlock more sensitive subsystems.",children:[e.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:Rc.map(b=>{const c=d.scopes.includes(b.value);return e.jsxs("button",{type:"button",className:`rounded-[18px] border px-4 py-4 text-left transition ${c?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/58 hover:bg-white/[0.08]"}`,onClick:()=>{if(c){if(d.scopes.length===1)return;u({scopes:d.scopes.filter(j=>j!==b.value)})}else u({scopes:[...d.scopes,b.value]})},children:[e.jsx("div",{className:"font-medium",children:b.label}),e.jsx("div",{className:"mt-1 text-xs leading-5 text-white/58",children:b.description})]},b.value)})}),e.jsxs("div",{className:"mt-2 text-xs text-white/40",children:[d.scopes.length," scope",d.scopes.length!==1?"s":""," selected"]})]})}];return e.jsx(qe,{open:t,onOpenChange:s,eyebrow:"Agent setup",title:"Issue an agent token",description:"Configure a new agent token step by step. The preset fills sensible defaults — adjust what you need.",value:h,onChange:l,steps:f,submitLabel:"Issue token",pending:a,pendingLabel:"Issuing token…",error:x,onSubmit:async()=>{g(null);const d=Bo.safeParse({label:h.label,agentLabel:h.agentLabel,agentType:h.agentType,description:h.description,trustLevel:h.trustLevel,autonomyMode:h.autonomyMode,approvalMode:h.approvalMode,scopes:h.scopes});if(!d.success){const u=d.error.issues[0];g((u==null?void 0:u.message)??"Check the agent name and at least one scope before issuing.");return}try{await o(d.data),s(!1)}catch(u){g(u instanceof Error?u.message:"Could not issue the token right now.")}}})}function an(t){return{source:"new",taskId:"",title:"",description:"",owner:t,projectId:"",status:"done",points:40}}function Oc({open:t,onOpenChange:s,pending:a=!1,defaultOwner:r="",availableTasks:i=[],availableProjects:n=[],onSubmit:o}){const[h,l]=y.useState(()=>an(r)),[x,g]=y.useState(null);y.useEffect(()=>{t&&(l(an(r)),g(null))},[t,r]);const f=[{id:"source",eyebrow:"Log work",title:"Is this work already tracked?",description:"If a task exists, link the work to it so Forge can update the record with the right status and XP. If not, a new task will be created from what you describe.",render:(d,u)=>e.jsxs(e.Fragment,{children:[e.jsx(Re,{columns:2,value:d.source,onChange:b=>u({source:b,taskId:""}),options:[{value:"new",label:"New task",description:"The work is not tracked yet — Forge will create a task and log the time against it."},{value:"existing",label:"Existing task",description:"Pick a task already in the board. The log will update its record and award XP."}]}),d.source==="existing"&&i.length>0?e.jsx(q,{label:"Pick the task",description:"Select the task this work belongs to.",children:e.jsxs("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:d.taskId,onChange:b=>u({taskId:b.target.value}),children:[e.jsx("option",{value:"",children:"— choose a task —"}),i.map(b=>e.jsxs("option",{value:b.id,children:[b.title," · ",b.status.replaceAll("_"," ")]},b.id))]})}):d.source==="existing"&&i.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-3 text-sm text-white/58",children:'No tasks are loaded yet. Switch to "New task" to create one from scratch.'}):null]})},{id:"details",eyebrow:"Work details",title:"Describe what was done",description:"Give the work a clear title and enough context to understand it later. These become the task record if you are creating a new one.",render:(d,u)=>e.jsxs(e.Fragment,{children:[e.jsx(q,{label:"Title",labelHelp:"Write the title like a short achievement: what was completed, not what was started.",children:e.jsx(ae,{value:d.title,placeholder:"Write postmortem draft",onChange:b=>u({title:b.target.value})})}),e.jsx(q,{label:"Owner",description:"Who did this work? Defaults to the operator name.",children:e.jsx(ae,{value:d.owner,placeholder:"Your name",onChange:b=>u({owner:b.target.value})})}),e.jsx(q,{label:"Description",description:"What moved forward? What should remain visible in the project history?",children:e.jsx(le,{className:"min-h-28",value:d.description,placeholder:"Wrote the full incident timeline and drafted the three key learnings for the team retrospective.",onChange:b=>u({description:b.target.value})})})]})},{id:"placement",eyebrow:"Placement",title:"Set the context and XP value",description:"Assign the work to a project and choose its final status. The XP value controls how much this work contributes to the operator's progress curve.",render:(d,u)=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsx(q,{label:"Project",description:"Link this work to an active project if it belongs to one.",children:e.jsxs("select",{className:"rounded-[14px] bg-white/[0.06] px-3 py-3 text-white",value:d.projectId,onChange:b=>u({projectId:b.target.value}),children:[e.jsx("option",{value:"",children:"No project link"}),n.map(b=>e.jsx("option",{value:b.id,children:b.title},b.id))]})}),e.jsx(q,{label:"Final status",labelHelp:"'Done' is the most common choice. Use 'In progress' if the work was real but the task is still open.",children:e.jsx(Re,{columns:2,value:d.status,onChange:b=>u({status:b}),options:[{value:"done",label:"Done",description:"Work is complete."},{value:"in_progress",label:"In progress",description:"Still active but already worth logging."},{value:"focus",label:"Focus",description:"Moved into focus."},{value:"blocked",label:"Blocked",description:"Work hit a wall."}]})})]}),e.jsx(q,{label:"XP value",labelHelp:"Typical task XP ranges from 20 to 100. Use 40 for routine tasks, 80+ for complex deliverables.",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ae,{type:"number",min:5,max:500,className:"w-36",value:d.points,onChange:b=>u({points:Number(b.target.value)})}),e.jsx("div",{className:"flex gap-2",children:[20,40,80,120].map(b=>e.jsxs("button",{type:"button",className:`rounded-full px-3 py-1.5 text-xs transition ${d.points===b?"bg-white/18 text-white":"bg-white/[0.06] text-white/55 hover:bg-white/[0.10]"}`,onClick:()=>u({points:b}),children:[b," xp"]},b))})]})})]})}];return e.jsx(qe,{open:t,onOpenChange:s,eyebrow:"Log work",title:"Log retroactive work",description:"Capture work that happened outside the timer so it counts toward progress and XP.",value:h,onChange:l,steps:f,submitLabel:"Log work",pending:a,pendingLabel:"Logging work…",error:x,onSubmit:async()=>{if(g(null),h.source==="new"&&h.title.trim().length===0){g("Add a title so Forge knows what work to create.");return}if(h.source==="existing"&&!h.taskId){g("Pick an existing task or switch to New task.");return}try{await o({taskId:h.source==="existing"&&h.taskId?h.taskId:void 0,title:h.source==="new"&&h.title.trim()?h.title.trim():void 0,description:h.description.trim()||void 0,owner:h.owner.trim()||void 0,projectId:h.projectId||null,status:h.status,points:h.points}),s(!1)}catch(d){g(d instanceof Error?d.message:"Could not log the work right now.")}}})}function or({text:t}){const[s,a]=y.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2200)}catch{}};return e.jsxs("button",{type:"button",onClick:()=>void r(),className:"flex items-center gap-1.5 rounded-full bg-white/[0.07] px-3 py-1.5 text-xs font-medium text-white/65 transition hover:bg-white/[0.12] hover:text-white",children:[s?e.jsx(na,{className:"size-3 text-emerald-400"}):e.jsx(to,{className:"size-3"}),s?"Copied":"Copy"]})}function Vs({label:t,children:s,copyText:a}){return e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:t}),e.jsx(or,{text:a??s})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[14px] bg-[rgba(8,13,28,0.78)] p-3 text-xs leading-6 text-white/78",children:e.jsx("code",{children:s})})]})}function $c({open:t,onOpenChange:s,state:a}){if(!a)return null;const{tokenString:r,agentLabel:i,onboarding:n}=a,o=JSON.stringify({baseUrl:n.forgeBaseUrl,apiToken:r,actorLabel:i,timeoutMs:n.defaultTimeoutMs},null,2),h=[`curl -s ${n.healthUrl} \\`,` -H "Authorization: Bearer ${r}" \\`,' -H "X-Forge-Source: agent" \\',` -H "X-Forge-Actor: ${i}"`].join(`
|
|
33
|
+
`),l=["openclaw gateway restart",'openclaw agent --message "forge_get_operator_overview"'].join(`
|
|
34
|
+
`);return e.jsx(Bt,{open:t,onOpenChange:s,children:e.jsxs(zt,{children:[e.jsx(Kt,{className:"fixed inset-0 z-40 bg-[rgba(4,8,18,0.82)] backdrop-blur-xl"}),e.jsxs(Xt,{className:"fixed left-1/2 top-1/2 z-50 flex h-[min(52rem,calc(100vh-1rem))] w-[min(52rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-[34px] border border-[rgba(192,193,255,0.14)] bg-[linear-gradient(180deg,rgba(21,28,44,0.99),rgba(12,17,30,0.99))] shadow-[0_30px_90px_rgba(3,8,18,0.55)]",children:[e.jsx(ks,{className:"sr-only",children:"Token issued — setup instructions"}),e.jsx(Ns,{className:"sr-only",children:"Your new agent token has been issued. Copy it now and follow the setup guide."}),e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-4 border-b border-white/8 px-6 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-[rgba(192,193,255,0.12)]",children:e.jsx(eo,{className:"size-5 text-[rgba(192,193,255,0.85)]"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/42",children:"Token issued"}),e.jsx("div",{className:"mt-0.5 font-display text-xl text-white",children:"Save your token now"})]})]}),e.jsx(gs,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"rounded-full bg-white/6 p-2 text-white/55 transition hover:bg-white/10 hover:text-white",children:e.jsx(Pt,{className:"size-4"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:e.jsxs(De.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.3,ease:"easeOut"},className:"grid gap-5",children:[e.jsxs("div",{className:"rounded-[20px] border border-amber-400/18 bg-amber-400/[0.07] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"text-amber-300",children:"One-time reveal"}),e.jsx("span",{className:"text-sm text-white/60",children:"This value will not be shown again."})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-[14px] bg-[rgba(8,13,28,0.78)] px-4 py-3",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs text-white/90",children:r}),e.jsx(or,{text:r})]}),e.jsx("div",{className:"mt-2 text-xs text-white/45",children:"Forge stores only a hash — the raw token is unrecoverable after you close this dialog. If lost, rotate the token from the Agents settings page."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("div",{className:"flex size-5 items-center justify-center rounded-full bg-white/12 text-xs font-semibold text-white",children:"1"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Add the token to your OpenClaw plugin config"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm leading-6 text-white/62",children:["Open your ",e.jsx("code",{className:"rounded-md bg-white/[0.08] px-1.5 py-0.5 text-xs text-white/82",children:"openclaw.json"})," file and find the"," ",e.jsx("code",{className:"rounded-md bg-white/[0.08] px-1.5 py-0.5 text-xs text-white/82",children:"forge"})," plugin entry under"," ",e.jsx("code",{className:"rounded-md bg-white/[0.08] px-1.5 py-0.5 text-xs text-white/82",children:"plugins"}),". Add or replace its"," ",e.jsx("code",{className:"rounded-md bg-white/[0.08] px-1.5 py-0.5 text-xs text-white/82",children:"params"})," with the config block below."]}),e.jsx("div",{className:"mt-3",children:e.jsx(Vs,{label:"Plugin params — paste into openclaw.json → plugins → forge → params",copyText:o,children:o})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("div",{className:"flex size-5 items-center justify-center rounded-full bg-white/12 text-xs font-semibold text-white",children:"2"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Restart the gateway and confirm the agent can connect"})]}),e.jsx(Vs,{label:"Run in terminal",copyText:l,children:l})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("div",{className:"flex size-5 items-center justify-center rounded-full bg-white/12 text-xs font-semibold text-white",children:"3"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Verify the token is accepted by the API"})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm leading-6 text-white/62",children:["Run the curl below. A"," ",e.jsx("code",{className:"rounded-md bg-white/[0.08] px-1.5 py-0.5 text-xs text-emerald-300",children:"200 OK"})," response means the token works and the agent"," ",e.jsx("strong",{className:"text-white/80",children:i})," is authenticated."]}),e.jsx("div",{className:"mt-3",children:e.jsx(Vs,{label:"Verify token — run in terminal",copyText:h,children:h})})]}),e.jsxs("div",{className:"rounded-[18px] border border-white/6 bg-white/[0.03] px-4 py-3 text-sm leading-6 text-white/50",children:[e.jsx("strong",{className:"text-white/68",children:"Tip:"})," If you ever lose this token, go to ",e.jsx("strong",{className:"text-white/68",children:"Settings → Agents → Agent tokens"}),", find the entry, and click"," ",e.jsx("strong",{className:"text-white/68",children:"Rotate & reveal"})," to get a fresh value without creating a new agent identity."]})]})}),e.jsx("div",{className:"shrink-0 border-t border-white/8 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"text-sm text-white/45",children:"Token saved? Close this dialog when you are ready."}),e.jsxs(X,{onClick:()=>s(!1),children:[e.jsx(na,{className:"size-4"}),"Done"]})]})})]})]})})}function cs(t,s){return s.every(a=>t.scopes.includes(a))}function Fc(){var U,Z,ie,ge,z;const t=Pe(),[s,a]=y.useState(!1),[r,i]=y.useState("operator"),[n,o]=y.useState(null),[h,l]=y.useState(!1),[x,g]=y.useState(!1),[f,d]=y.useState(!1),u=te({queryKey:["forge-operator-session"],queryFn:Gt}),b=u.isSuccess,c=te({queryKey:["forge-settings"],queryFn:fa,enabled:b}),j=te({queryKey:["forge-approval-requests"],queryFn:kl,enabled:b}),k=te({queryKey:["forge-agent-onboarding"],queryFn:jl}),$=te({queryKey:["forge-operator-context"],queryFn:yl,enabled:b}),M=async()=>{await Promise.all([t.invalidateQueries({queryKey:["forge-operator-session"]}),t.invalidateQueries({queryKey:["forge-settings"]}),t.invalidateQueries({queryKey:["forge-approval-requests"]}),t.invalidateQueries({queryKey:["forge-agent-onboarding"]}),t.invalidateQueries({queryKey:["forge-operator-context"]})])},I=de({mutationFn:E=>El(E),onSuccess:M}),N=de({mutationFn:E=>Al(E),onSuccess:async(E,p)=>{if(await M(),v){const P=E.token;o({tokenString:P.token,agentLabel:P.tokenSummary.agentLabel??"forge-agent",onboarding:v}),l(!0)}}}),m=de({mutationFn:E=>Dl(E),onSuccess:M}),w=de({mutationFn:E=>Nl(E),onSuccess:M}),L=de({mutationFn:E=>Tl(E),onSuccess:M}),S=de({mutationFn:Fl,onSuccess:M}),O=(U=c.data)==null?void 0:U.settings,A=((Z=j.data)==null?void 0:Z.approvalRequests)??[],v=(ie=k.data)==null?void 0:ie.onboarding,C=(ge=$.data)==null?void 0:ge.context,R=(O==null?void 0:O.agentTokens.filter(E=>E.status==="active"))??[],J=(v==null?void 0:v.recommendedScopes)??[],G=R.some(E=>cs(E,J)),se=R.some(E=>cs(E,["rewards.manage"])),K=R.some(E=>cs(E,["psyche.write"])),D=R.some(E=>E.autonomyMode!=="approval_required"&&cs(E,["write"])),F=R.length>0,W=y.useMemo(()=>{if(!C)return[];const E=[...C.focusTasks,...C.currentBoard.backlog,...C.currentBoard.focus,...C.currentBoard.inProgress,...C.currentBoard.blocked,...C.currentBoard.done],p=new Map;for(const P of E)p.set(P.id,P);return[...p.values()]},[C]),T=(O==null?void 0:O.profile.operatorName)??"",H=[{label:"Operator session",ok:!0,badge:"active",badgeTone:"emerald",detail:(z=u.data)!=null&&z.session?`Session open as ${u.data.session.actorLabel}. Works for localhost and Tailscale without a token.`:"Passwordless session is active for local and Tailscale access.",action:null},{label:"Agent token",ok:F,badge:F?`${R.length} active`:"none issued",badgeTone:F?"emerald":"amber",detail:F?`${R.length} active token${R.length===1?"":"s"} allow external agents and scripts to authenticate.`:"No token yet. Issue one to let external agents connect via the API.",action:F?null:{label:"Issue token",preset:"operator",onClick:()=>{i("operator"),a(!0)}}},{label:"Full operator bundle",ok:G,badge:G?"ready":"optional",badgeTone:G?"emerald":"neutral",detail:G?"A token covers all recommended scopes for full operator collaboration.":"No token covers the full recommended scope bundle. Issue one to unlock complete agent collaboration.",action:G?null:{label:"Set up",preset:"operator",onClick:()=>{i("operator"),a(!0)}}},{label:"Reward control",ok:se,badge:se?"ready":"optional",badgeTone:se?"emerald":"neutral",detail:se?"An agent can tune reward rules and issue bonus XP grants.":"No token has rewards.manage — agents cannot adjust XP rules or issue bonuses.",action:se?null:{label:"Add scope",preset:"operator",onClick:()=>{i("operator"),a(!0)}}},{label:"Psyche writes",ok:K,badge:K?"ready":"optional",badgeTone:K?"emerald":"neutral",detail:K?"Sensitive Psyche collaboration is enabled — agents can create and update therapeutic records.":"No token has psyche.write — agent collaboration on sensitive Psyche records is disabled.",action:K?null:{label:"Add scope",preset:"operator",onClick:()=>{i("operator"),a(!0)}}},{label:"Scoped writes",ok:D,badge:D?"ready":"optional",badgeTone:D?"emerald":"neutral",detail:D?"A trusted agent can write without constant approval prompts.":"All write tokens are approval-required. Agents must queue every mutation for your review.",action:D?null:{label:"Configure",preset:"operator",onClick:()=>{i("operator"),a(!0)}}}];return u.isLoading||c.isLoading?e.jsx(et,{eyebrow:"Settings · Agents",title:"Loading agent console",description:"Establishing the operator session and loading agent configuration.",columns:2,blocks:6}):u.isError?e.jsx(je,{eyebrow:"Settings · Agents",error:u.error,onRetry:()=>void u.refetch()}):c.isError||!O?e.jsx(je,{eyebrow:"Settings · Agents",error:c.error??new Error("Could not load settings."),onRetry:()=>void c.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(ke,{title:"Agents",description:"Connection status, capability access, tokens, approval queue, and work logging."}),e.jsx(Ds,{}),e.jsx(_c,{open:s,onOpenChange:a,pending:I.isPending,initialPreset:r,defaultAgentLabel:(v==null?void 0:v.defaultActorLabel)??"OpenClaw",recommendedScopes:J,onSubmit:async E=>{const p=await I.mutateAsync(E);a(!1),v&&(o({tokenString:p.token.token,agentLabel:E.agentLabel,onboarding:v}),l(!0))}}),e.jsx($c,{open:h,onOpenChange:l,state:n}),e.jsx(Oc,{open:x,onOpenChange:g,pending:S.isPending,defaultOwner:T,availableTasks:W,availableProjects:(C==null?void 0:C.activeProjects)??[],onSubmit:async E=>{await S.mutateAsync(E)}}),e.jsxs("div",{className:"grid gap-5",children:[C?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsx(it,{label:"Active projects",value:C.activeProjects.length,tone:"core"}),e.jsx(it,{label:"Focus tasks",value:C.focusTasks.length,tone:"core"}),e.jsx(it,{label:"Pending approvals",value:A.filter(E=>E.status==="pending").length,tone:"core"}),e.jsx(it,{label:"Operator level",value:C.xp.profile.level,tone:"core",detail:`${C.xp.profile.totalXp} total XP`})]}):null,e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Capability status"}),e.jsx("div",{className:"mt-4 grid gap-3",children:H.map(E=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-[18px] bg-white/[0.04] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"font-medium text-white",children:E.label}),e.jsx(B,{className:E.badgeTone==="emerald"?"text-emerald-300":E.badgeTone==="amber"?"text-amber-300":"text-white/45",children:E.badge})]}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-white/55",children:E.detail})]}),E.action?e.jsxs("button",{type:"button",onClick:E.action.onClick,className:"mt-0.5 flex shrink-0 items-center gap-1.5 rounded-full bg-white/[0.07] px-3 py-1.5 text-xs font-medium text-white/72 transition hover:bg-white/[0.12] hover:text-white",children:[E.action.label,e.jsx(vt,{className:"size-3"})]}):null]},E.label))})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Agent tokens"}),e.jsxs(X,{size:"sm",variant:"secondary",onClick:()=>{i("operator"),a(!0)},children:[e.jsx(St,{className:"size-3.5"}),"Issue token"]})]}),e.jsx("div",{className:"mt-4 grid gap-3",children:O.agentTokens.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/55",children:"No tokens yet. Issue one to let external agents or scripts authenticate with Forge."}):O.agentTokens.map(E=>e.jsxs("div",{className:"rounded-[18px] 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:"font-medium text-white",children:E.label}),e.jsxs("div",{className:"mt-0.5 text-sm text-white/50",children:[E.agentLabel??"Unassigned agent"," · ",e.jsx("span",{className:"font-mono text-xs",children:E.tokenPrefix})]})]}),e.jsx(B,{className:E.status==="active"?"text-emerald-300":"text-white/45",children:E.status})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-white/55",children:[e.jsx("span",{children:E.trustLevel}),e.jsx("span",{children:"·"}),e.jsx("span",{children:E.autonomyMode.replaceAll("_"," ")}),e.jsx("span",{children:"·"}),e.jsx("span",{children:E.approvalMode.replaceAll("_"," ")})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:["write","rewards.manage","psyche.write"].map(p=>e.jsx(B,{className:E.scopes.includes(p)?"text-emerald-300":"text-white/30",children:p},p))}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(X,{variant:"secondary",size:"sm",pending:N.isPending,pendingLabel:"Rotating",onClick:()=>void N.mutateAsync(E.id),children:"Rotate & reveal new token"}),e.jsx(X,{variant:"ghost",size:"sm",pending:m.isPending,pendingLabel:"Revoking",onClick:()=>void m.mutateAsync(E.id),children:"Revoke"})]})]},E.id))}),e.jsx("div",{className:"mt-3 px-1 text-xs text-white/35",children:"Raw token values are shown once and are never recoverable. If a token is lost, rotate or issue a new one."})]}),O.agents.length>0?e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Connected agents"}),e.jsx("div",{className:"mt-4 grid gap-3",children:O.agents.map(E=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-white",children:E.label}),E.description?e.jsx("div",{className:"mt-1 text-sm text-white/52",children:E.description}):null,e.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-white/55",children:[e.jsx("span",{children:E.agentType}),e.jsx("span",{children:E.autonomyMode.replaceAll("_"," ")}),e.jsxs("span",{children:[E.activeTokenCount," active token",E.activeTokenCount!==1?"s":""]})]})]}),e.jsx(B,{className:"text-white/60",children:E.trustLevel})]},E.id))})]}):null,C?e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1.05fr)_minmax(0,0.95fr)]",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Recommended next move"}),C.recommendedNextTask?e.jsxs("div",{className:"mt-4 grid gap-2",children:[e.jsx(ue,{kind:"task",label:C.recommendedNextTask.title,variant:"heading",size:"lg"}),e.jsx("div",{className:"text-sm leading-6 text-white/58",children:C.recommendedNextTask.description||"No extra notes yet."}),e.jsxs("div",{className:"mt-1 flex flex-wrap gap-2",children:[e.jsx(B,{children:C.recommendedNextTask.status.replaceAll("_"," ")}),e.jsxs(B,{children:[C.recommendedNextTask.points," xp"]}),e.jsx(B,{children:C.recommendedNextTask.owner})]})]}):e.jsx("div",{className:"mt-4 text-sm text-white/55",children:"Board is clear. No recommended task right now."})]}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Board pulse"}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-3",children:[{label:"Backlog",value:C.currentBoard.backlog.length},{label:"Focus",value:C.currentBoard.focus.length},{label:"In progress",value:C.currentBoard.inProgress.length},{label:"Blocked",value:C.currentBoard.blocked.length}].map(E=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/38",children:E.label}),e.jsx("div",{className:"mt-2 font-display text-3xl text-white",children:E.value})]},E.label))})]})]}):null,C&&C.activeProjects.length>0?e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Active projects"}),e.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:C.activeProjects.slice(0,6).map(E=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(ue,{kind:"project",label:E.title}),e.jsxs(B,{children:[E.progress,"%"]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(re,{kind:"goal",label:E.goalTitle,compact:!0,gradient:!1})}),e.jsxs("div",{className:"mt-2 text-xs text-white/38",children:[E.activeTaskCount," active · ",E.completedTaskCount," done"]})]},E.id))})]}):null,e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Approval queue"}),A.filter(E=>E.status==="pending").length>0?e.jsxs(B,{className:"text-amber-300",children:[A.filter(E=>E.status==="pending").length," pending"]}):null]}),e.jsx("div",{className:"mt-4 grid gap-3",children:A.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] px-4 py-4 text-sm text-white/55",children:"No pending approvals. Agent actions are flowing through."}):A.map(E=>e.jsxs("div",{className:"rounded-[18px] 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:"font-medium text-white",children:E.title}),e.jsx("div",{className:"mt-0.5 text-sm text-white/55",children:E.summary||E.actionType})]}),e.jsx(B,{className:E.status==="pending"?"text-amber-300":"text-white/45",children:E.status})]}),E.status==="pending"?e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(X,{variant:"secondary",size:"sm",pending:w.isPending,pendingLabel:"Approving",onClick:()=>void w.mutateAsync(E.id),children:"Approve"}),e.jsx(X,{variant:"ghost",size:"sm",pending:L.isPending,pendingLabel:"Rejecting",onClick:()=>void L.mutateAsync(E.id),children:"Reject"})]}):null]},E.id))})]}),e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Retroactive work log"}),e.jsx("div",{className:"mt-1 text-sm text-white/55",children:"Capture work done outside the timer so it counts toward progress and XP."})]}),e.jsxs(X,{variant:"secondary",size:"sm",onClick:()=>g(!0),children:[e.jsx(so,{className:"size-3.5"}),"Log work"]})]}),S.data?e.jsxs("div",{className:"mt-4 rounded-[18px] bg-[rgba(192,193,255,0.10)] px-4 py-3 text-sm text-white",children:["Logged"," ",e.jsx("span",{className:"inline-block align-middle",children:e.jsx(ue,{kind:"task",label:S.data.task.title,showKind:!1})}),". Operator XP updated to ",S.data.xp.profile.totalXp,"."]}):null]}),e.jsxs(Y,{children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 text-left",onClick:()=>d(E=>!E),children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Connection & onboarding"}),v?e.jsx("div",{className:"mt-1 text-sm text-white/55",children:v.forgeBaseUrl}):null]}),f?e.jsx(mn,{className:"size-4 shrink-0 text-white/38"}):e.jsx(hn,{className:"size-4 shrink-0 text-white/38"})]}),f&&v?e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"Forge API"}),e.jsx("div",{className:"mt-2 break-all text-sm text-white",children:v.forgeBaseUrl})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"Web app"}),e.jsx("div",{className:"mt-2 break-all text-sm text-white",children:v.webAppUrl})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"OpenAPI spec"}),e.jsx("div",{className:"mt-2 break-all text-sm text-white",children:v.openApiUrl})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"Default policy"}),e.jsxs("div",{className:"mt-2 text-sm text-white",children:[v.recommendedTrustLevel," · ",v.recommendedAutonomyMode.replaceAll("_"," ")," · ",v.recommendedApprovalMode.replaceAll("_"," ")]})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:v.authModes.operatorSession.label}),e.jsx(B,{className:"mt-1 text-emerald-300",children:v.defaultConnectionMode==="operator_session"?"default":"available"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/60",children:v.authModes.operatorSession.summary}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:v.authModes.operatorSession.trustedTargets.map(E=>e.jsx(B,{className:"text-white/65",children:E},E))})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-medium text-white",children:v.authModes.managedToken.label}),e.jsx(B,{className:"mt-1 text-white/55",children:"optional"}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-white/60",children:v.authModes.managedToken.summary}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/48",children:v.tokenRecovery.rotationSummary})]})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"Quick-connect verification"}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-[16px] bg-[rgba(8,13,28,0.78)] p-4 text-xs leading-6 text-white/72",children:e.jsx("code",{children:[`curl -s ${v.healthUrl}`,"openclaw plugins install ./projects/forge","openclaw gateway restart"].join(`
|
|
35
|
+
`)})})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.14em] text-white/40",children:"Required API headers"}),e.jsxs("div",{className:"mt-3 grid gap-1 text-sm text-white/60",children:[e.jsx("div",{children:v.requiredHeaders.authorization}),e.jsx("div",{children:v.requiredHeaders.source}),e.jsx("div",{children:v.requiredHeaders.actor})]})]})]}):f&&k.isError?e.jsx("div",{className:"mt-4 rounded-[18px] bg-[rgba(120,33,33,0.22)] px-4 py-3 text-sm text-rose-100/80",children:"Could not load the onboarding contract. Check the API bridge."}):f?e.jsx("div",{className:"mt-4 text-sm text-white/50",children:"Loading…"}):null]})]})]})}const xt={goal:"Goals",project:"Projects",task:"Tasks",tag:"Tags",note:"Notes",insight:"Insights",psyche_value:"Values",behavior_pattern:"Patterns",behavior:"Behaviors",belief_entry:"Beliefs",mode_profile:"Modes",mode_guide_session:"Mode guides",event_type:"Event types",emotion_definition:"Emotions",trigger_report:"Reports"},qc={goal:"goal",project:"project",task:"task",tag:null,note:null,insight:"report",psyche_value:"value",behavior_pattern:"pattern",behavior:"behavior",belief_entry:"belief",mode_profile:"mode",mode_guide_session:"mode",event_type:null,emotion_definition:null,trigger_report:"report"};function Bc(t){return new Date(t).toLocaleString()}function zc(){var I,N;const t=Pe(),[s,a]=y.useState(""),[r,i]=y.useState([]),n=te({queryKey:["forge-operator-session"],queryFn:Gt}),o=n.isSuccess,h=te({queryKey:["forge-settings-bin"],queryFn:wl,enabled:o}),l=async()=>{await t.invalidateQueries({predicate:m=>Array.isArray(m.queryKey)&&typeof m.queryKey[0]=="string"&&m.queryKey[0].startsWith("forge-")})},x=de({mutationFn:m=>Ri({operations:[{entityType:m.entityType,id:m.entityId}]}),onSuccess:l}),g=de({mutationFn:m=>Di({operations:[{entityType:m.entityType,id:m.entityId,mode:"hard"}]}),onSuccess:l}),f=de({mutationFn:m=>Ri({operations:m.map(w=>({entityType:w.entityType,id:w.entityId}))}),onSuccess:l}),d=de({mutationFn:m=>Di({operations:m.map(w=>({entityType:w.entityType,id:w.entityId,mode:"hard"}))}),onSuccess:l}),u=((I=h.data)==null?void 0:I.bin.records)??[],b=s.trim().toLowerCase(),c=y.useMemo(()=>u.filter(m=>r.length===0||r.includes(m.entityType)?b?[m.title,m.subtitle??"",m.entityType,m.entityId,m.deletedByActor??"",m.deletedSource??"",m.deleteReason??""].join(" ").toLowerCase().includes(b):!0:!1),[b,u,r]),j=y.useMemo(()=>{const m=new Map;for(const w of c){const L=m.get(w.entityType)??[];L.push(w),m.set(w.entityType,L)}return[...m.entries()].sort((w,L)=>xt[w[0]].localeCompare(xt[L[0]]))},[c]),k=y.useMemo(()=>[...new Set(u.map(m=>m.entityType))].sort((m,w)=>xt[m].localeCompare(xt[w])),[u]);function $(m){i(w=>w.includes(m)?w.filter(L=>L!==m):[...w,m])}async function M(){c.length===0||!window.confirm(`Permanently delete ${c.length} item${c.length===1?"":"s"} from the bin? This cannot be undone.`)||await d.mutateAsync(c)}return n.isLoading||h.isLoading?e.jsx(et,{eyebrow:"Settings",title:"Loading bin",description:"Loading deleted items and restore controls.",columns:2,blocks:6}):n.isError?e.jsx(je,{eyebrow:"Settings",error:n.error,onRetry:()=>void n.refetch()}):h.isError?e.jsx(je,{eyebrow:"Settings",error:h.error,onRetry:()=>void h.refetch()}):e.jsxs("div",{className:"mx-auto grid w-full max-w-[1220px] gap-5",children:[e.jsx(ke,{title:"Bin",description:"Restore soft-deleted items or permanently remove them when you really mean it.",badge:`${((N=h.data)==null?void 0:N.bin.totalCount)??0} deleted items`}),e.jsx(Ds,{}),e.jsxs(Y,{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-start",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Find deleted items"}),e.jsxs("div",{className:"relative",children:[e.jsx(ft,{className:"pointer-events-none absolute left-4 top-1/2 size-4 -translate-y-1/2 text-white/35"}),e.jsx(ae,{value:s,onChange:m=>a(m.target.value),placeholder:"Search title, id, reason, or source",className:"pl-11"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:k.map(m=>{const w=r.includes(m);return e.jsx("button",{type:"button",onClick:()=>$(m),className:Q("rounded-full border px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] transition",w?"border-[var(--primary)]/30 bg-[var(--primary)]/[0.16] text-[var(--primary)]":"border-white/10 bg-white/[0.04] text-white/58 hover:bg-white/[0.08] hover:text-white"),children:xt[m]},m)})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 lg:max-w-[22rem] lg:justify-end",children:[e.jsxs(X,{variant:"secondary",size:"sm",disabled:c.length===0,pending:f.isPending,pendingLabel:"Restoring",onClick:()=>void f.mutateAsync(c),children:[e.jsx(Zs,{className:"size-4"}),e.jsx("span",{children:"Restore visible"})]}),e.jsxs(X,{variant:"secondary",size:"sm",disabled:c.length===0,pending:d.isPending,pendingLabel:"Deleting",onClick:()=>void M(),children:[e.jsx(ps,{className:"size-4"}),e.jsx("span",{children:"Delete visible forever"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-sm text-white/55",children:[e.jsxs("span",{children:[c.length," visible"]}),r.length>0?e.jsxs("span",{children:[r.length," type filters active"]}):null,b?e.jsxs("span",{children:["Search: “",s.trim(),"”"]}):null]})]}),u.length===0?e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Deleted items"}),e.jsx("div",{className:"mt-4 text-white/72",children:"Nothing is in the bin right now."})]}):j.length===0?e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Deleted items"}),e.jsx("div",{className:"mt-4 text-white/72",children:"No deleted items match the current search or filters."})]}):e.jsx("div",{className:"grid gap-5",children:j.map(([m,w])=>{const L=qc[m];return e.jsxs(Y,{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[L?e.jsx(re,{kind:L,label:xt[m],compact:!0}):null,L?null:e.jsx("div",{className:"rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-white/55",children:xt[m]}),e.jsxs("div",{className:"text-sm text-white/55",children:[w.length," deleted"]})]})}),e.jsx("div",{className:"mt-4 grid gap-3",children:w.map(S=>e.jsxs("div",{className:"grid gap-3 rounded-[22px] border border-white/8 bg-white/[0.04] p-4 lg:grid-cols-[minmax(0,1fr)_auto]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-lg font-medium text-white",children:S.title}),S.subtitle?e.jsx("div",{className:"mt-1 text-sm text-white/62",children:S.subtitle}):null,e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 text-xs text-white/45",children:[e.jsxs("span",{children:["Deleted ",Bc(S.deletedAt)]}),S.deletedByActor?e.jsxs("span",{children:["By ",S.deletedByActor]}):null,S.deletedSource?e.jsxs("span",{children:["Source ",S.deletedSource]}):null,S.deleteReason?e.jsxs("span",{children:["Reason: ",S.deleteReason]}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-start justify-end gap-2",children:[e.jsxs(X,{variant:"secondary",size:"sm",pending:x.isPending,pendingLabel:"Restoring",onClick:()=>void x.mutateAsync(S),children:[e.jsx(Zs,{className:"size-4"}),e.jsx("span",{children:"Restore"})]}),e.jsxs(X,{variant:"secondary",size:"sm",pending:g.isPending,pendingLabel:"Deleting",onClick:()=>void g.mutateAsync(S),children:[e.jsx(ps,{className:"size-4"}),e.jsx("span",{children:"Delete forever"})]})]})]},`${S.entityType}:${S.entityId}`))})]},m)})})]})}function Kc(t){return JSON.stringify(t,null,2)}function nn(t){const s=t.trim();if(!s)return{};const a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Expected a JSON object.");return a}function Xc(){var m,w,L;const t=Pe(),[s,a]=y.useState(""),[r,i]=y.useState(null),[n,o]=y.useState(null),h=te({queryKey:["forge-operator-session"],queryFn:Gt}),l=h.isSuccess,x=te({queryKey:["forge-xp-metrics"],queryFn:Ll}),g=te({queryKey:["forge-reward-rules"],queryFn:Sl,enabled:l}),f=te({queryKey:["forge-reward-ledger"],queryFn:()=>Pl(30),enabled:l}),d=xs({defaultValues:{title:"",description:"",active:!0,configJson:"{}"}}),u=xs({defaultValues:{entityType:"task",entityId:"",deltaXp:15,reasonTitle:"Operator bonus",reasonSummary:"Manual boost for a meaningful action captured with good provenance.",metadataJson:"{}"}}),b=async()=>{await Promise.all([t.invalidateQueries({queryKey:["forge-xp-metrics"]}),t.invalidateQueries({queryKey:["forge-reward-rules"]}),t.invalidateQueries({queryKey:["forge-reward-ledger"]})])},c=de({mutationFn:S=>Cl(S.ruleId,{title:S.title,description:S.description,active:S.active,config:S.config}),onSuccess:b}),j=de({mutationFn:Il,onSuccess:b}),k=((m=g.data)==null?void 0:m.rules)??[];y.useEffect(()=>{k.length&&(!s||!k.some(S=>S.id===s))&&a(k[0].id)},[k,s]);const $=k.find(S=>S.id===s)??k[0]??null;y.useEffect(()=>{$&&(d.reset({title:$.title,description:$.description,active:$.active,configJson:Kc($.config)}),i(null))},[$,d]);const M=(w=x.data)==null?void 0:w.metrics,N=(((L=f.data)==null?void 0:L.ledger)??[]).filter(S=>S.metadata.manual===!0).slice(0,8);return h.isLoading?e.jsx(et,{eyebrow:"Settings · Rewards",title:"Loading reward controls",description:"Establishing the operator session and fetching reward configuration.",columns:2,blocks:6}):h.isError?e.jsx(je,{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(ke,{title:"Rewards",description:"XP command deck, reward rule editor, manual bonus grants, and ledger history."}),e.jsx(Ds,{}),e.jsx("div",{className:"grid gap-5",children:e.jsxs(Y,{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:[M?e.jsx(Un,{profile:M.profile,achievements:M.achievements,milestoneRewards:M.milestoneRewards,momentumPulse:M.momentumPulse,recentLedger:M.recentLedger}):null,M?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(it,{label:"Total XP",value:M.profile.totalXp,tone:"core"}),e.jsx(it,{label:"Daily ambient",value:`${M.dailyAmbientXp} / ${M.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"}),k.length>0?e.jsxs("form",{className:"mt-4 grid gap-4",onSubmit:d.handleSubmit(async S=>{try{i(null);const O=nn(S.configJson);if(!$)return;await c.mutateAsync({ruleId:$.id,title:S.title,description:S.description,active:S.active,config:O})}catch(O){i(O instanceof Error?O.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:s,onChange:S=>a(S.target.value),children:k.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(ae,{...d.register("title")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Description"}),e.jsx(le,{className:"min-h-24",...d.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",...d.register("active")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Config JSON"}),e.jsx(le,{className:"min-h-28 font-mono text-xs",...d.register("configJson")})]}),r?e.jsx("div",{className:"text-sm text-amber-300",children:r}):null,e.jsx(X,{type:"submit",pending:c.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:u.handleSubmit(async S=>{try{o(null);const O=nn(S.metadataJson);await j.mutateAsync({entityType:S.entityType,entityId:S.entityId,deltaXp:S.deltaXp,reasonTitle:S.reasonTitle,reasonSummary:S.reasonSummary,metadata:O}),u.reset({...S,entityId:"",reasonTitle:"Operator bonus",reasonSummary:"Manual boost for a meaningful action captured with good provenance.",metadataJson:"{}"})}catch(O){o(O instanceof Error?O.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(ae,{...u.register("entityType")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Entity id"}),e.jsx(ae,{placeholder:"task_123",...u.register("entityId")})]})]}),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(ae,{type:"number",...u.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(ae,{...u.register("reasonTitle")})]})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Reason summary"}),e.jsx(le,{className:"min-h-24",...u.register("reasonSummary")})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-white/58",children:"Metadata JSON"}),e.jsx(le,{className:"min-h-24 font-mono text-xs",...u.register("metadataJson")})]}),n?e.jsx("div",{className:"text-sm text-amber-300",children:n}):null,e.jsx(X,{type:"submit",pending:j.isPending,pendingLabel:"Issuing bonus",children:"Issue bonus XP"})]}),j.data?e.jsxs("div",{className:"mt-4 rounded-[18px] bg-[rgba(192,193,255,0.12)] p-4 text-sm text-white",children:["Granted ",j.data.reward.deltaXp>0?"+":"",j.data.reward.deltaXp," XP for ",e.jsx("strong",{children:j.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:N.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."}):N.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(B,{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))})]})]})]})})]})}function kt({label:t,help:s}){return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/58",children:[e.jsx("span",{children:t}),s?e.jsx(Ne,{content:s,label:`Explain ${t}`}):null]})}const Dt=[{status:"backlog",label:"Backlog",description:"Not started yet.",icon:ws},{status:"focus",label:"Focus",description:"Ready to start soon.",icon:ys},{status:"in_progress",label:"In progress",description:"Work is active now.",icon:nt},{status:"blocked",label:"Blocked",description:"Something is stopping progress.",icon:ao},{status:"done",label:"Done",description:"The task is completed.",icon:ra}];function Gc(){const{t,formatDate:s,formatDateTime:a}=Te(),r=Le(),i=js(),n=Pe(),[o,h]=y.useState(!1),[l,x]=y.useState(!1),[g,f]=y.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 1023px)").matches:!1);y.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const L=window.matchMedia("(max-width: 1023px)"),S=O=>f(O?O.matches:L.matches);return S(),typeof L.addEventListener=="function"?(L.addEventListener("change",S),()=>L.removeEventListener("change",S)):(L.addListener(S),()=>L.removeListener(S))},[]);const d=te({queryKey:["task-context",i.taskId],queryFn:()=>$l(i.taskId),enabled:!!i.taskId}),u=async()=>{await Promise.all([n.invalidateQueries({queryKey:["forge-snapshot"]}),n.invalidateQueries({queryKey:["task-context",i.taskId]}),n.invalidateQueries({queryKey:["activity-archive"]}),n.invalidateQueries({queryKey:["project-board"]})])},b=de({mutationFn:({taskId:L,patch:S})=>Is(L,S),onSuccess:u}),c=de({mutationFn:L=>va(L),onSuccess:u}),j=de({mutationFn:L=>Dn(L),onSuccess:u}),k=de({mutationFn:({runId:L,actor:S,note:O})=>_n(L,{actor:S,note:O??""}),onSuccess:u}),$=de({mutationFn:({runId:L,actor:S,note:O})=>Rn(L,{actor:S,note:O??""}),onSuccess:u}),M=d.data;if(d.isLoading)return e.jsx(et,{});if(d.isError)return e.jsx(je,{eyebrow:t("common.taskDetail.errorEyebrow"),error:d.error,onRetry:()=>void d.refetch()});if(!M)return e.jsx(je,{eyebrow:t("common.taskDetail.errorEyebrow"),error:new Error(t("common.taskDetail.emptyPayload")),onRetry:()=>void d.refetch()});const I=M.activeTaskRun??null,N=Dt.find(L=>L.status===M.task.status)??Dt[0];Dt.filter(L=>L.status!==M.task.status);const m=L=>{switch(L){case"active":return"Active";case"completed":return"Completed";case"released":return"Paused";case"timed_out":return"Timed out";default:return L}},w=async L=>{await b.mutateAsync({taskId:M.task.id,patch:{status:L}}),x(!1)};return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{entityKind:"task",title:e.jsx(ue,{kind:"task",label:M.task.title,variant:"heading",size:"lg",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"}),titleText:M.task.title,description:M.task.description||"Edit the task, change its status, start work, and review its history from one page.",badge:`${M.task.points} xp`}),e.jsxs(Y,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Task"}),e.jsx("div",{className:"mt-2",children:e.jsx(ue,{kind:"task",label:M.task.title,variant:"heading",size:"xl",lines:3,className:"max-w-full",labelClassName:"[overflow-wrap:anywhere]"})}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:M.task.description||"This page shows the task itself, where it belongs, what state it is in, and what has happened on it so far."})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[e.jsxs(X,{pending:d.isFetching,pendingLabel:I?"Opening":"Starting",onClick:async()=>{await r.startTaskNow(M.task.id),await u()},children:[e.jsx(nt,{className:"size-4 fill-current"}),I?"Focus work":"Start work"]}),I?e.jsxs(e.Fragment,{children:[e.jsx(X,{variant:"secondary",pending:k.isPending,pendingLabel:"Pausing",onClick:async()=>{await k.mutateAsync({runId:I.id,actor:I.actor,note:I.note})},children:"Pause"}),e.jsx(X,{variant:"secondary",pending:$.isPending,pendingLabel:"Completing",onClick:async()=>{await $.mutateAsync({runId:I.id,actor:I.actor,note:I.note})},children:"Complete"})]}):null,g?e.jsxs(e.Fragment,{children:[e.jsx(X,{variant:"secondary",size:"sm","aria-label":"Change task status",onClick:()=>x(!0),children:e.jsx(N.icon,{className:"size-4"})}),e.jsx(X,{variant:"secondary",size:"sm","aria-label":"Edit task",onClick:()=>h(!0),children:e.jsx(us,{className:"size-4"})})]}):e.jsxs(X,{variant:"secondary",onClick:()=>h(!0),children:[e.jsx(us,{className:"size-4"}),"Edit task"]}),M.task.status==="done"?e.jsx(X,{variant:"secondary",onClick:async()=>{await c.mutateAsync(M.task.id)},children:"Mark as not done"}):null]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap gap-2",children:[e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:N.label}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t(`common.enums.priority.${M.task.priority}`)}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t(`common.enums.effort.${M.task.effort}`)}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:t(`common.enums.energy.${M.task.energy}`)}),e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[M.task.points," xp"]}),M.task.time.totalCreditedSeconds>0?e.jsxs(B,{className:"bg-white/[0.08] text-white/72",children:[Math.floor(M.task.time.totalCreditedSeconds/60)," min tracked"]}):null,I?e.jsx(B,{className:"bg-emerald-500/12 text-emerald-200",children:"Timer active"}):null]}),g?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Status"}),e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-5",children:Dt.map(L=>{const S=L.icon,O=L.status===M.task.status;return e.jsxs("button",{type:"button",disabled:O||b.isPending,className:`rounded-[18px] border px-3.5 py-3 text-left transition ${O?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.08]"}`,onClick:()=>void w(L.status),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsx("span",{className:"font-medium",children:L.label})]}),e.jsx("div",{className:"mt-2 text-xs leading-5 text-white/54",children:L.description})]},L.status)})})]}),e.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Linked items"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsxs("div",{children:[e.jsx(kt,{label:"Project",help:"The project is the main work stream this task belongs to."}),e.jsx("div",{className:"mt-2",children:M.project?e.jsx(xe,{to:`/projects/${M.project.id}`,className:"inline-flex max-w-full",children:e.jsx(re,{kind:"project",label:M.project.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(B,{className:"bg-white/[0.08] text-white/65",children:"No project linked"})})]}),e.jsxs("div",{children:[e.jsx(kt,{label:"Goal",help:"The goal shows the longer-term result this task supports."}),e.jsx("div",{className:"mt-2",children:M.goal?e.jsx(xe,{to:`/goals/${M.goal.id}`,className:"inline-flex max-w-full",children:e.jsx(re,{kind:"goal",label:M.goal.title,compact:!0,gradient:!1,wrap:!0,className:"max-w-full"})}):e.jsx(B,{className:"bg-white/[0.08] text-white/65",children:"No goal linked"})})]})]})]}),e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Task details"}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(kt,{label:"Due date",help:"Use a due date only when timing actually matters for this task."}),e.jsx("div",{className:"mt-2 text-white",children:s(M.task.dueDate)})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(kt,{label:"Owner",help:"The owner is the person or role expected to carry this task."}),e.jsx("div",{className:"mt-2 text-white",children:M.task.owner})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(kt,{label:"Created"}),e.jsx("div",{className:"mt-2 text-white",children:a(M.task.createdAt)})]}),e.jsxs("div",{className:"rounded-[16px] bg-white/[0.03] px-3.5 py-3",children:[e.jsx(kt,{label:"Updated"}),e.jsx("div",{className:"mt-2 text-white",children:a(M.task.updatedAt)})]})]})]})]}),e.jsxs("div",{className:"mt-5 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-white/58",children:[e.jsx("span",{children:"Current timer"}),e.jsx(Ne,{content:"This shows whether work is running on the task right now and how much time has been credited.",label:"Explain current timer"})]}),e.jsx("div",{className:"mt-3 text-white",children:I?`${I.timerMode==="planned"?"Planned":"Unlimited"} timer active with ${Math.floor(I.creditedSeconds/60)} credited minutes.`:"No timer is running on this task right now."})]}),e.jsx("div",{className:"mt-5",children:e.jsx(Ps,{entityType:"task",entityId:M.task.id,title:"Task notes",description:"Capture real progress, blockers, and context in Markdown so the task keeps a durable work log.",invalidateQueryKeys:[["task-context",i.taskId],...M.task.projectId?[["project-board",M.task.projectId]]:[]]})}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Activity"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[M.activity.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No activity has been recorded for this task yet."}):null,M.activity.map(L=>e.jsxs("div",{className:"rounded-[18px] 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:"font-medium text-white",children:Ls(L)}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:Ms(L)}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:a(L.createdAt)})]}),e.jsx(X,{variant:"ghost",className:"shrink-0",onClick:async()=>{await j.mutateAsync(L.id)},children:"Remove"})]}),dt(L)&&fs(L)?e.jsx(xe,{to:dt(L),className:"mt-3 inline-flex text-[11px] uppercase tracking-[0.16em] text-[var(--primary)]",children:fs(L)}):null]},L.id))]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:"Timer sessions"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[M.taskRuns.length===0?e.jsx("div",{className:"rounded-[18px] bg-white/[0.04] p-4 text-sm text-white/55",children:"No timer sessions have been recorded for this task yet."}):null,M.taskRuns.map(L=>e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:L.actor}),e.jsx(B,{children:m(L.status)})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:L.note||t("common.labels.noRunNote")}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/35",children:a(L.updatedAt)})]},L.id))]})]})]}),e.jsx(Ts,{open:o,goals:r.snapshot.goals,projects:r.snapshot.dashboard.projects,tags:r.snapshot.tags,editingTask:M.task,onOpenChange:h,onSubmit:async(L,S)=>{S&&await b.mutateAsync({taskId:S,patch:L})}}),e.jsx(ma,{open:l,onOpenChange:x,eyebrow:"Task status",title:"Change status",description:"Pick the state that best matches where this task is right now.",children:e.jsx("div",{className:"grid gap-3",children:Dt.map(L=>{const S=L.icon,O=L.status===M.task.status;return e.jsx("button",{type:"button",disabled:O||b.isPending,className:`rounded-[22px] border px-4 py-4 text-left transition ${O?"border-[rgba(192,193,255,0.28)] bg-[rgba(192,193,255,0.14)] text-white":"border-white/8 bg-white/[0.04] text-white/72 hover:bg-white/[0.08]"}`,onClick:()=>void w(L.status),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{className:"size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:L.label}),e.jsx("div",{className:"mt-1 text-sm text-white/54",children:L.description})]})]})},L.status)})})})]})}function rn(t,s,a){var r;return((r=s.find(i=>i.id===t.goalId))==null?void 0:r.title)??a}function Qc(t,s){return t.tagIds.map(a=>s.find(r=>r.id===a)).filter(Boolean)}function Wc(t,s){(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s())}function Hc(t,s){switch(t.status){case"backlog":return{label:s.backlog,action:"start",icon:nt};case"focus":return{label:s.focus,action:"start",icon:nt};case"in_progress":return{label:s.in_progress,nextStatus:"done",action:"move",icon:ra};case"blocked":return{label:s.blocked,action:"start",icon:nt};default:return null}}function Uc({tasks:t,timeline:s,goals:a,tags:r,notesSummaryByEntity:i,selectedTaskId:n,onSelectTask:o,onMove:h,onStartTask:l}){const{t:x,formatDate:g}=Te(),f={backlog:x("common.dailyRunway.actionBacklog"),focus:x("common.dailyRunway.actionFocus"),in_progress:x("common.dailyRunway.actionProgress"),blocked:x("common.dailyRunway.actionBlocked")};return e.jsxs("div",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.3fr)_minmax(18rem,0.9fr)]",children:[e.jsxs("div",{className:"min-w-0 rounded-[24px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",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:x("common.dailyRunway.runwayEyebrow")}),e.jsx(Ne,{content:"These are the tasks that matter most for today. Click a card to open the task details. Use Start to begin work immediately."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-white",children:x("common.dailyRunway.runwayTitle")})]}),e.jsx(B,{className:"shrink-0 text-[var(--primary)]",children:x(t.length===1?"common.dailyRunway.prioritiesOne":"common.dailyRunway.prioritiesOther",{count:t.length})})]}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:t.map((d,u)=>{const b=Hc(d,f),c=Qc(d,r).slice(0,2),j=n===d.id,k=Be(i,"task",d.id).count;return e.jsxs("article",{role:"button",tabIndex:0,"aria-pressed":j,className:`grid w-full gap-3 rounded-[22px] px-4 py-4 text-left transition ${j?"bg-[linear-gradient(180deg,rgba(192,193,255,0.16),rgba(192,193,255,0.05))] shadow-[inset_0_0_0_1px_rgba(192,193,255,0.2)]":"bg-white/[0.03] hover:bg-white/[0.06]"}`,onClick:()=>o(d.id),onKeyDown:$=>Wc($,()=>o(d.id)),children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:x("common.dailyRunway.runwayItem",{index:u+1})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(re,{kind:"goal",label:rn(d,a,x("common.dailyRunway.unassigned")),compact:!0,gradient:!1}),d.time.activeRunCount>0?e.jsx(B,{className:"bg-emerald-500/12 text-emerald-200",children:"Live"}):null]}),e.jsx("div",{className:"mt-2",children:e.jsx(ue,{kind:"task",label:d.title,variant:"heading",size:"md"})}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-white/60",children:d.description||x("common.dailyRunway.noNote")})]}),e.jsx(B,{className:"shrink-0 self-start",children:d.status.replaceAll("_"," ")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[d.points," xp"]}),e.jsx(Fe,{entityType:"task",entityId:d.id,count:k}),d.time.totalCreditedSeconds>0?e.jsxs(B,{className:"bg-white/[0.08] text-white/70",children:[Math.floor(d.time.totalCreditedSeconds/60)," min tracked"]}):null,e.jsx(B,{className:"bg-white/[0.08] text-white/70",children:d.effort}),e.jsx(B,{className:"bg-white/[0.08] text-white/70",children:g(d.dueDate)}),c.map($=>e.jsx(B,{className:"bg-white/[0.08]",style:{color:$.color},children:$.name},$.id))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-white/40",children:d.owner}),b?e.jsxs(X,{variant:b.action==="start"?"primary":"secondary",className:"px-3 py-2 text-[11px] uppercase tracking-[0.16em]",onClick:async $=>{if($.stopPropagation(),b.action==="start"){await l(d.id);return}b.nextStatus&&await h(d.id,b.nextStatus)},children:[e.jsx(b.icon,{className:"mr-2 size-3.5"}),b.label]}):null]})]},d.id)})})]}),e.jsxs("div",{className:"min-w-0 rounded-[24px] bg-white/[0.04] p-4",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:x("common.dailyRunway.timelineEyebrow")}),e.jsx(Ne,{content:"This groups today's tasks by status, so you can see what is already moving, what is ready to start, what is blocked, and what is done."})]}),e.jsx("h4",{className:"mt-2 font-display text-2xl text-white",children:x("common.dailyRunway.timelineTitle")}),e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.map(d=>e.jsxs("div",{className:"rounded-[20px] bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-white",children:d.label}),e.jsx(B,{className:"bg-white/[0.08] text-white/65",children:d.tasks.length})]}),e.jsxs("div",{className:"mt-3 grid gap-2",children:[d.tasks.slice(0,3).map(u=>e.jsxs("button",{type:"button",className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.03] px-3 py-3 text-left transition hover:bg-white/[0.06]",onClick:()=>o(u.id),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(ue,{kind:"task",label:u.title,className:"max-w-full"}),e.jsx("div",{className:"mt-2",children:e.jsx(re,{kind:"goal",label:rn(u,a,x("common.dailyRunway.unassigned")),compact:!0,gradient:!1})})]}),e.jsx(vt,{className:"size-4 shrink-0 text-white/35"})]},u.id)),d.tasks.length===0?e.jsx("div",{className:"text-sm text-white/42",children:x("common.dailyRunway.emptyBucket")}):null]})]},d.id))})]})]})}function Yc(){var d;const{t}=Te(),s=Le(),a=Ve(),r=s.snapshot.today.directive.task,i=s.snapshot.today.milestoneRewards.find(u=>!u.completed)??s.snapshot.today.milestoneRewards[0]??null,n=s.snapshot.risk.blockedTasks[0]??s.snapshot.risk.overdueTasks[0]??null,o=Math.max(0,s.snapshot.metrics.nextLevelXp-s.snapshot.metrics.currentLevelXp),h=8,l=4,x=10,g=20;return r!==null||s.snapshot.overview.topTasks.length>0||s.snapshot.today.dailyQuests.length>0||s.snapshot.today.milestoneRewards.length>0?e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsx(ke,{title:"Today",titleText:"Today",description:(r==null?void 0:r.description)??"Start one real task, collect XP, and keep today's work moving.",badge:`${s.snapshot.metrics.weeklyXp} weekly xp`}),e.jsxs("section",{className:"grid gap-3 lg:grid-cols-4",children:[e.jsxs(Y,{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:"Weekly XP"}),e.jsx(Ne,{content:"Weekly XP is the XP earned since the start of the current week."})]}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--primary)]",children:s.snapshot.metrics.weeklyXp}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:["Total XP: ",s.snapshot.metrics.totalXp]})]}),e.jsxs(Y,{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:"Level"}),e.jsx(Ne,{content:"Levels come from total XP. The progress bar below shows how much XP is left before the next level."})]}),e.jsx("div",{className:"mt-3 font-display text-4xl text-white",children:s.snapshot.metrics.level}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[o," xp to next level"]}),e.jsx("div",{className:"mt-3",children:e.jsx(ct,{value:s.snapshot.metrics.currentLevelXp/s.snapshot.metrics.nextLevelXp*100,tone:"tertiary"})})]}),e.jsxs(Y,{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:"Momentum"}),e.jsx(Ne,{content:"Momentum is a simple signal that combines weekly XP, active work, and overdue drag."})]}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-white",children:[s.snapshot.metrics.momentumScore,"%"]}),e.jsxs("div",{className:"mt-2 text-sm text-white/58",children:[s.snapshot.metrics.streakDays," day streak"]})]}),e.jsxs(Y,{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:"Task rewards"}),e.jsx(Ne,{content:"Starting work, staying in work, and completing work all pay XP. Task completion also still awards the task's own XP value."})]}),e.jsxs("div",{className:"mt-3 grid gap-2 text-sm text-white/70",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-3 py-2",children:[e.jsx("span",{children:"Start work"}),e.jsxs(B,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:["+",h," xp"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-3 py-2",children:[e.jsxs("span",{children:["Every ",x," min"]}),e.jsxs(B,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:["+",l," xp"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-[16px] bg-white/[0.04] px-3 py-2",children:[e.jsx("span",{children:"Complete timer"}),e.jsxs(B,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:["+",g," xp"]})]})]})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-5 xl:grid-cols-[minmax(0,1.4fr)_24rem]",children:[e.jsx("div",{className:"min-w-0",children:e.jsx(Uc,{tasks:s.snapshot.overview.topTasks,timeline:s.snapshot.today.timeline,goals:s.snapshot.goals,tags:s.snapshot.tags,notesSummaryByEntity:s.snapshot.dashboard.notesSummaryByEntity,selectedTaskId:(r==null?void 0:r.id)??null,onSelectTask:u=>a(`/tasks/${u}`),onStartTask:async u=>{await s.startTaskNow(u)},onMove:async(u,b)=>{await s.patchTaskStatus(u,b)}})}),e.jsxs("div",{className:"grid min-w-0 gap-5",children:[e.jsxs(Y,{className:"min-w-0 overflow-hidden",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:"Current task"}),e.jsx(Ne,{content:"This is the task Forge currently considers the best anchor for today."})]}),r?e.jsxs("button",{type:"button",className:"mt-4 grid w-full gap-3 rounded-[20px] bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>a(`/tasks/${r.id}`),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:"font-medium text-white",children:r.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:r.description||"No description yet."})]}),e.jsxs(B,{className:"bg-[var(--primary)]/14 text-[var(--primary)]",children:[s.snapshot.today.directive.rewardXp," xp"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.snapshot.today.directive.goalTitle?e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:s.snapshot.today.directive.goalTitle}):null,e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:s.snapshot.today.directive.sessionLabel}),e.jsx(Fe,{entityType:"task",entityId:r.id,count:((d=s.snapshot.dashboard.notesSummaryByEntity[`task:${r.id}`])==null?void 0:d.count)??0})]})]}):e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:"No task is selected for today yet. Start one from the list on the left."})]}),e.jsxs(Y,{className:"min-w-0 overflow-hidden",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:t("common.todayPage.questsTitle")}),e.jsx(Ne,{content:"Daily rewards are small XP targets for today. They should support real work, not replace it."})]}),s.snapshot.today.dailyQuests.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.todayPage.questsEmpty")}):e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.snapshot.today.dailyQuests.map(u=>e.jsxs("div",{className:"rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium leading-tight text-white",children:u.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:u.summary})]}),e.jsxs(B,{className:`shrink-0 self-start ${u.completed?"text-emerald-300":"text-[var(--tertiary)]"}`,children:["+",u.rewardXp," xp"]})]}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/38",children:u.progressLabel})]},u.id))})]}),e.jsxs(Y,{className:"min-w-0 overflow-hidden",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:t("common.todayPage.rewardsTitle")}),e.jsx(Ne,{content:"Milestones are larger progress targets that stay active across multiple days."})]}),s.snapshot.today.milestoneRewards.length===0?e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:t("common.todayPage.rewardsEmpty")}):e.jsx("div",{className:"mt-4 grid min-w-0 gap-3",children:s.snapshot.today.milestoneRewards.map(u=>e.jsxs("div",{className:"overflow-hidden rounded-[20px] bg-white/[0.04] p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium leading-tight text-white",children:u.title}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:u.summary})]}),e.jsx(B,{className:"max-w-[10.5rem] shrink-0 self-start",children:u.rewardLabel})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ct,{value:u.current/u.target*100,tone:"tertiary"})}),e.jsx("div",{className:"mt-3 text-[11px] uppercase tracking-[0.16em] text-white/38",children:u.progressLabel})]},u.id))})]}),e.jsxs(Y,{className:"min-w-0 overflow-hidden",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:"Needs attention"}),e.jsx(Ne,{content:"This highlights the blocked or overdue task most likely to slow you down if ignored."})]}),n?e.jsx("button",{type:"button",className:"mt-4 grid w-full gap-3 rounded-[20px] bg-white/[0.04] p-4 text-left transition hover:bg-white/[0.06]",onClick:()=>a(`/tasks/${n.id}`),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:"font-medium text-white",children:n.title}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-white/58",children:n.description||s.snapshot.today.momentum.recoveryHint})]}),e.jsx(B,{className:"bg-white/[0.08] text-white/72",children:n.status.replaceAll("_"," ")})]})}):e.jsx("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4 text-sm text-white/58",children:s.snapshot.today.momentum.recoveryHint}),i?e.jsxs("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"text-sm font-medium text-white",children:i.title}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:i.progressLabel})]}):null]})]})]})]}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{title:"Today",titleText:"Today",description:"Start a task, earn XP, and keep today's work clear.",badge:`${s.snapshot.metrics.weeklyXp} weekly xp`}),e.jsx(Xe,{eyebrow:t("common.todayPage.heroEyebrow"),title:t("common.todayPage.emptyTitle"),description:t("common.todayPage.emptyDescription"),action:e.jsx(xe,{to:"/goals",className:"inline-flex min-h-10 min-w-max shrink-0 items-center justify-center rounded-full bg-[var(--primary)] px-4 py-2 text-sm font-medium whitespace-nowrap text-slate-950 transition hover:opacity-90",children:t("common.todayPage.emptyAction")})})]})}function Jc(){var h;const{t}=Te(),s=te({queryKey:["forge-weekly-review"],queryFn:fl}),a=(h=s.data)==null?void 0:h.review;if(s.isLoading)return e.jsx(et,{});if(s.isError)return e.jsx(je,{eyebrow:t("common.weeklyReview.heroEyebrow"),error:s.error,onRetry:()=>void s.refetch()});if(!a)return e.jsx(je,{eyebrow:t("common.weeklyReview.heroEyebrow"),error:new Error("Forge returned an empty weekly review payload."),onRetry:()=>void s.refetch()});const r=a.wins[0]??null,i=a.calibration.find(l=>l.mode==="recover")??a.calibration[0]??null,n=a.calibration.find(l=>l.mode==="accelerate")??a.calibration[0]??null,o=[{id:"week",label:"This week",title:`${a.momentumSummary.totalXp} XP with ${a.momentumSummary.focusHours} focus hours`,detail:`Peak window: ${a.momentumSummary.peakWindow}. Efficiency score is holding at ${a.momentumSummary.efficiencyScore}.`,badge:a.windowLabel},{id:"wins",label:"Wins",title:(r==null?void 0:r.title)??t("common.weeklyReview.noWin"),detail:(r==null?void 0:r.summary)??t("common.weeklyReview.noWinDetail"),badge:r?`+${r.rewardXp} xp`:`${a.wins.length} wins`},{id:"recovery",label:"Recovery",title:(i==null?void 0:i.title)??t("common.weeklyReview.noRecovery"),detail:(i==null?void 0:i.note)??t("common.weeklyReview.noRecoveryDetail"),badge:(i==null?void 0:i.mode)??"maintain"},{id:"next-intent",label:"Next intent",title:(n==null?void 0:n.title)??a.reward.title,detail:(n==null?void 0:n.note)??a.reward.summary,badge:`+${a.reward.rewardXp} xp`}];return e.jsxs("div",{className:"grid gap-5",children:[e.jsx(ke,{title:"Weekly Review",description:`${a.windowLabel}. ${t("common.weeklyReview.heroDescription")}`,badge:`${a.momentumSummary.totalXp} xp`}),e.jsxs("section",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionMomentum")}),e.jsx("div",{className:"mt-4 h-64",children:e.jsx(pn,{width:"100%",height:"100%",children:e.jsxs(go,{data:a.chart,children:[e.jsx(xn,{dataKey:"label",tick:{fill:"rgba(255,255,255,0.42)",fontSize:11}}),e.jsx(gn,{hide:!0}),e.jsx(bo,{dataKey:"xp",fill:"#c0c1ff",radius:[8,8,0,0]})]})})}),e.jsxs("div",{className:"mt-4 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:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"XP"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:a.momentumSummary.totalXp})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Focus hours"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:a.momentumSummary.focusHours})]}),e.jsxs("div",{className:"rounded-[18px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:"Peak window"}),e.jsx("div",{className:"mt-2 text-2xl text-white",children:a.momentumSummary.peakWindow})]})]})]}),e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionGoals")}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.calibration.map(l=>e.jsxs("div",{className:"overflow-hidden rounded-[20px] 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:l.title}),e.jsx(B,{className:"max-w-[9rem] shrink-0 self-start",children:l.mode})]}),e.jsx("div",{className:"mt-3 text-sm text-white/58",children:l.note})]},l.id))})]})]}),e.jsxs("div",{className:"grid gap-5",children:[e.jsxs(Y,{children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/45",children:t("common.weeklyReview.sectionWins")}),e.jsx("div",{className:"mt-4 grid gap-3",children:a.wins.map(l=>e.jsxs("div",{className:"overflow-hidden rounded-[20px] 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:l.title}),e.jsxs(B,{className:"max-w-[8rem] shrink-0 self-start text-emerald-300",children:["+",l.rewardXp," xp"]})]}),e.jsx("div",{className:"mt-2 text-sm text-white/58",children:l.summary})]},l.id))})]}),e.jsxs(Y,{children:[e.jsx("h2",{className:"font-display text-3xl text-white",children:a.reward.title}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-white/60",children:a.reward.summary}),e.jsxs("div",{className:"mt-4 rounded-[20px] bg-white/[0.04] p-4",children:[e.jsx("div",{className:"font-label text-[11px] uppercase tracking-[0.18em] text-white/40",children:t("common.weeklyReview.completionBonus")}),e.jsxs("div",{className:"mt-2 text-3xl text-[var(--primary)]",children:["+",a.reward.rewardXp," XP"]})]}),e.jsx(X,{className:"mt-4 w-full",children:t("common.weeklyReview.finalize")})]})]})]}),e.jsx(Hn,{eyebrow:t("common.weeklyReview.summaryEyebrow"),title:t("common.weeklyReview.summaryTitle"),description:t("common.weeklyReview.summaryDescription"),items:o})]})}function Vc(){return e.jsxs(io,{children:[e.jsxs(ye,{element:e.jsx(Ul,{}),children:[e.jsx(ye,{index:!0,element:e.jsx(_s,{to:"/overview",replace:!0})}),e.jsx(ye,{path:"overview",element:e.jsx(Ed,{})}),e.jsx(ye,{path:"goals",element:e.jsx(ld,{})}),e.jsx(ye,{path:"goals/:goalId",element:e.jsx(rd,{})}),e.jsx(ye,{path:"projects",element:e.jsx(Rd,{})}),e.jsx(ye,{path:"projects/:projectId",element:e.jsx(Dd,{})}),e.jsx(ye,{path:"campaigns",element:e.jsx(_s,{to:"/projects",replace:!0})}),e.jsx(ye,{path:"psyche",element:e.jsx(Qd,{})}),e.jsx(ye,{path:"psyche/values",element:e.jsx(Ac,{})}),e.jsx(ye,{path:"psyche/patterns",element:e.jsx(vc,{})}),e.jsx(ye,{path:"psyche/behaviors",element:e.jsx(nc,{})}),e.jsx(ye,{path:"psyche/reports",element:e.jsx(Pc,{})}),e.jsx(ye,{path:"psyche/reports/:reportId",element:e.jsx(Ic,{})}),e.jsx(ye,{path:"psyche/goal-map",element:e.jsx(rc,{})}),e.jsx(ye,{path:"psyche/schemas-beliefs",element:e.jsx(Mc,{})}),e.jsx(ye,{path:"psyche/modes",element:e.jsx(pc,{})}),e.jsx(ye,{path:"psyche/modes/guide",element:e.jsx(cc,{})}),e.jsx(ye,{path:"kanban",element:e.jsx(Id,{})}),e.jsx(ye,{path:"notes",element:e.jsx(Pd,{})}),e.jsx(ye,{path:"today",element:e.jsx(Yc,{})}),e.jsx(ye,{path:"activity",element:e.jsx(Vl,{})}),e.jsx(ye,{path:"insights",element:e.jsx(kd,{})}),e.jsx(ye,{path:"review/weekly",element:e.jsx(Jc,{})}),e.jsx(ye,{path:"settings",element:e.jsx(Dc,{})}),e.jsx(ye,{path:"settings/agents",element:e.jsx(Fc,{})}),e.jsx(ye,{path:"settings/rewards",element:e.jsx(Xc,{})}),e.jsx(ye,{path:"settings/bin",element:e.jsx(zc,{})}),e.jsx(ye,{path:"tasks/:taskId",element:e.jsx(Gc,{})})]}),e.jsx(ye,{path:"*",element:e.jsx(_s,{to:"/overview",replace:!0})})]})}const Zc=new no({defaultOptions:{queries:{staleTime:2e4,refetchOnWindowFocus:!1}}});ro.createRoot(document.getElementById("root")).render(e.jsx(oo.StrictMode,{children:e.jsx(lo,{client:Zc,children:e.jsx(co,{basename:Vo("/forge/"),children:e.jsx(Vc,{})})})}));
|
|
36
|
+
//# sourceMappingURL=index-BWtLtXwb.js.map
|