cogpit 3.2.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-runtime.js +5 -4
- package/dist/instance-worker.js +1 -1
- package/dist/web/assets/{CogpitBlock-L2yaEovX.js → CogpitBlock-DslWkKoF.js} +1 -1
- package/dist/web/assets/{CommandPaletteHost-CwInMsCp.js → CommandPaletteHost-DUZHK9Zh.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-9ySKSxnx.js → ConfigBrowser-CWys9Rgj.js} +1 -1
- package/dist/web/assets/{CrewPanel-9nMm5pVI.js → CrewPanel-CWubmgOn.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-CHdo4vxt.js → HighlightedEditor-BF3a6ok2.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-CRuTSHwt.js → KeyboardShortcutsDialog-DHxjcyzu.js} +1 -1
- package/dist/web/assets/{MissionHome-LPTXsRcd.js → MissionHome-Ckt9lu1H.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-Ie2O9iTa.js → MobileFileChanges-B0k6kNod.js} +1 -1
- package/dist/web/assets/{PluginsDialog-84zjmDAJ.js → PluginsDialog-CuaR5Cs1.js} +1 -1
- package/dist/web/assets/{PreviewPanel-US9z-vcE.js → PreviewPanel-CV3itR4d.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-BelqVoKU.js → ProjectFilesPanel-B7DRMwMm.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-BgzjVxf6.js → ProjectSwitcherModal-DhWTU3Op.js} +1 -1
- package/dist/web/assets/{TerminalOutput-D2nGNnds.js → TerminalOutput-CsysWxZc.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-DT9ZVWtN.js → ThemeSelectorModal-DbCAl7RY.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-C1fYtY5J.js → WorkflowsPanel-BkDClgyj.js} +1 -1
- package/dist/web/assets/{WorktreePanel-CVZp_AIL.js → WorktreePanel-DyQpVHNe.js} +1 -1
- package/dist/web/assets/{edition-ui-hI8w0jpR.js → edition-ui-xOZzffb-.js} +1 -1
- package/dist/web/assets/{index-D9cBiMbf.js → index-CFF4usU2.js} +1 -1
- package/dist/web/assets/{index-IUqOcQ_C.js → index-D2Gn2VwC.js} +1 -1
- package/dist/web/assets/{index-NgN68ZoJ.js → index-DUfVcKxj.js} +10 -10
- package/dist/web/assets/{index-BbEO6jPZ.js → index-y28pnuxv.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOutput-CsysWxZc.js","assets/vendor-react-gGw_S5I_.js","assets/vendor-ui-Dxtv9P3W.js","assets/vendor-shiki-DOn6sF-i.js","assets/vendor-markdown-BE1gYnO9.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/cpp-BRuaLJcg.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/ruby-B0Tyh1qT.js","assets/xml-D2mA2LmW.js","assets/java-CylS5w8V.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/php-aq0itWAE.js","assets/json-Cp-IABpG.js","assets/vue-DVfSmUF7.js","assets/svelte-DZMnMd3x.js","assets/scss-OYdSNvt2.js","assets/CogpitBlock-DslWkKoF.js","assets/ProjectSwitcherModal-DhWTU3Op.js","assets/CommandPaletteHost-DUZHK9Zh.js","assets/index-D2Gn2VwC.js","assets/password-BV9mqUzz.js","assets/KeyboardShortcutsDialog-DHxjcyzu.js","assets/ThemeSelectorModal-DbCAl7RY.js","assets/ProjectFilesPanel-B7DRMwMm.js","assets/HighlightedEditor-BF3a6ok2.js","assets/WorktreePanel-DyQpVHNe.js","assets/CrewPanel-CWubmgOn.js","assets/index-y28pnuxv.js","assets/MissionHome-Ckt9lu1H.js","assets/ConfigBrowser-CWys9Rgj.js","assets/PreviewPanel-CV3itR4d.js","assets/PluginsDialog-CuaR5Cs1.js","assets/MobileFileChanges-B0k6kNod.js","assets/edition-ui-xOZzffb-.js","assets/index-CFF4usU2.js","assets/WorkflowsPanel-BkDClgyj.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var YI=Object.defineProperty;var XI=(n,e,t)=>e in n?YI(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ze=(n,e,t)=>XI(n,typeof e!="symbol"?e+"":e,t);import{j as a,c as q,r as y,d as Ie,e as JI,a as QI,f as e7}from"./vendor-react-gGw_S5I_.js";import{aU as t7,aV as n7,aW as s7,aX as Qr,aY as gj,aZ as $1,a_ as R1,a$ as O1,b0 as L1,b1 as uc,X as At,b2 as M1,b3 as r7,b4 as o7,b5 as i7,b6 as a7,b7 as l7,b8 as c7,b9 as u7,ba as d7,aa as Wt,bb as f7,bc as m7,bd as p7,be as h7,bf as g7,I as Ht,bg as x7,bh as b7,bi as dc,bj as xj,bk as bj,W as z1,C as it,am as vt,bl as v7,J as _r,bm as uf,bn as eo,bo as y7,bp as w7,bq as S7,br as k7,bs as j7,bt as N7,bu as C7,bv as _7,a2 as vj,a as Fn,bw as E7,bx as yj,by as T7,bz as A7,bA as I7,bB as P7,bC as $7,bD as wj,y as _o,bE as md,g as Ll,bF as Sj,G as Wr,bG as D1,bH as R7,D as F1,an as Zs,bI as O7,bJ as qi,bK as Do,bL as L7,bM as M7,bN as z7,bO as D7,bP as Ml,S as ss,bQ as gr,bR as kj,bS as F7,bT as U7,bU as jj,bV as Nj,bW as Cj,bX as _j,bY as Ej,bZ as Tj,b_ as B7,b$ as W7,c0 as q7,ap as df,c1 as V7,a7 as ff,n as Ji,ai as ba,c2 as sg,c3 as H7,c4 as K7,c5 as G7,c6 as Z7,c7 as Y7,c8 as X7,c9 as J7,$ as U1,ca as Q7,V as Vs,z as Cs,cb as eP,cc as tP,cd as nP,ce as sP,cf as rP,cg as zl,ch as va,ci as oP,i as mf,a3 as B1,cj as iP,ck as aP,a4 as lP,c as W1,cl as cP,cm as uP,cn as dP,co as fP,cp as mP,cq as pP,cr as hP,cs as gP,ct as xP,cu as bP,P as xr,x as ya,cv as vP,cw as yP,cx as wP,cy as SP,l as qr,aq as Fo,cz as kP,cA as Aj,Y as q1,e as pf,cB as rg,ah as V1,cC as jP,cD as H1,cE as K1,cF as og,cG as NP,R as G1,cH as CP,cI as _P,a8 as Eo,b as Ij,cJ as EP,s as wa,cK as TP,a9 as xl,cL as pd,cM as Z1,k as To,cN as AP,cO as IP,cP as PP,cQ as Pj,cR as $j,cS as eu,cT as Go,as as Bv,F as fc,B as Y1,cU as $P,ad as hd,cV as RP,cW as OP,t as hf,N as Qi,a0 as X1,cX as LP,cY as MP,ac as ea,cZ as zP,c_ as DP,c$ as FP,d0 as UP,d1 as BP,d2 as Rj,d3 as WP,aH as qP,m as ig,d4 as VP,aP as HP,d5 as KP,d6 as Oj,h as Lj,A as mc,d7 as GP,aD as gf,aC as ks,ae as Mj,d8 as zj,r as ZP,d9 as YP,aL as Dj,p as XP,da as ag,v as JP,db as QP,dc as e$,dd as t$,de as n$,df as s$,o as r$,dg as o$,dh as i$,di as a$,dj as l$,ar as J1,O as Q1,H as c$,dk as Fj,dl as u$,dm as Wv,al as d$,L as Uj,w as Bj,ao as f$,ax as m$,aO as p$,dn as h$,dp as g$,dq as x$,ak as b$,dr as v$}from"./vendor-ui-Dxtv9P3W.js";import{c as y$,a as w$}from"./vendor-shiki-DOn6sF-i.js";import{r as S$,M as Er}from"./vendor-markdown-BE1gYnO9.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function t(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=t(r);fetch(r.href,o)}})();const k$="modulepreload",j$=function(n){return"/"+n},qv={},nt=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let i=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=i(t.map(u=>{if(u=j$(u),u in qv)return;qv[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const m=document.createElement("link");if(m.rel=d?"stylesheet":k$,d||(m.as="script"),m.crossOrigin="",m.href=u,c&&m.setAttribute("nonce",c),document.head.appendChild(m),d)return new Promise((p,h)=>{m.addEventListener("load",p),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return e().catch(o)})},Hs=["acp","codex","copilot","claude"];function gd(n,e){if(n==="default")return e;const t=new TextEncoder().encode(e),s=btoa(Array.from(t,r=>String.fromCharCode(r)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`i-${n}__${s}`}function lg(n){const e=/^i-([A-Za-z0-9-]+)__([A-Za-z0-9_-]+)$/.exec(n);if(!e)return{instanceId:"default",nativeId:n};try{const t=Uint8Array.from(atob(e[2].replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));return{instanceId:e[1],nativeId:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{throw new Error("Invalid instance session ID")}}function N$(n,e){return n==="default"?e:`instance__${n}__${e}`}function Vr(n){const e=/^instance__([A-Za-z0-9-]+)__(.+)$/.exec(n??"");return e?{instanceId:e[1],nativeDirName:e[2]}:{instanceId:"default",nativeDirName:n??""}}function ta(n,e){return e==="default"?n:{...n,instanceId:e,sessionId:gd(e,lg(n.sessionId).nativeId),...n.branchedFrom?{branchedFrom:{...n.branchedFrom,sessionId:gd(e,lg(n.branchedFrom.sessionId).nativeId)}}:{}}}const ex="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",C$=new RegExp(`^${ex}$`,"i");function Vv(n,e){const t=new TextEncoder().encode(e);let s="";for(const o of t)s+=String.fromCharCode(o);const r=btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${n}${r}`}function Hv(n,e){if(!e.startsWith(n))return null;try{const t=e.slice(n.length).replace(/-/g,"+").replace(/_/g,"/"),s=atob(t),r=Uint8Array.from(s,o=>o.charCodeAt(0));return new TextDecoder().decode(r)}catch{return null}}function tx(n){return{lossy:!1,owns:e=>typeof e=="string"&&e.startsWith(n),recognizes:e=>{const t=Hv(n,e);return t!==null&&t!==""&&Vv(n,t)===e},encode:e=>Vv(n,e),decode:e=>Hv(n,e)}}function Dl(n){const e=new RegExp(`(${ex})\\.jsonl$`,"i").exec(n);return e?e[1]:null}function xf(n){return n?{rootSessionId:n.toLowerCase(),isRootTranscript:!0}:null}function nx(n){const e=n.split("/");return e.every(s=>s!==""&&s!=="."&&s!==".."&&!s.includes("\\"))?e:null}const sx={urlId:n=>n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}.jsonl`};function Wj(n){return`'${n.replace(/'/g,"'\\''")}'`}function Fl(n,e){return e?[n,e]:[]}function xd(n,e){var t;return((t=e.exec(n))==null?void 0:t[1])??null}const bd="[0-9a-f-]{36}",qj="codex__",Vj="copilot__",_$=new Set(["default","plan","acceptEdits","dontAsk","auto"]),E$=new Set(["subagents","workflows"]);function T$(n){const e=nx(n);if(!e)return null;const[t,s]=e;if(e.length===1){const r=t.replace(/\.jsonl$/,"");return r!==t&&Gv(r)?xf(r):null}return e.length>2&&E$.has(s)&&Gv(t)?{rootSessionId:t.toLowerCase(),isRootTranscript:!1}:null}const Hj={kind:"claude",displayName:"Claude Code",binName:"claude",dirName:{lossy:!0,owns:n=>typeof n=="string"&&!n.startsWith(qj)&&!n.startsWith(Vj),recognizes:n=>/^(?:(?:-|[A-Za-z]--)[A-Za-z0-9-]*|[A-Za-z]-)$/.test(n),encode:n=>(n.replace(/[\\/]+$/,"")||n).replace(/[^a-zA-Z0-9]/g,"-"),decode:n=>{const e=/^([A-Za-z])--(.*)$/.exec(n);return e?`${e[1]}:\\${e[2].replace(/-/g,"\\")}`:"/"+n.replace(/^-/,"").replace(/-/g,"/")}},projectWorktreeDir:".claude/worktrees",sessionFile:{name:n=>`${n}.jsonl`,sessionId:Dl,...sx,transcriptRoot:T$},metadataFromHead:!0,resume:{command:n=>`claude --resume ${n}`,args:n=>["--resume",n]},launchArgs:{permissions:n=>n!=null&&n.mode?n.mode==="bypassPermissions"?["--dangerously-skip-permissions"]:[..._$.has(n.mode)?["--permission-mode",n.mode]:[],...(n.allowedTools??[]).flatMap(e=>["--allowedTools",e]),...(n.disallowedTools??[]).flatMap(e=>["--disallowedTools",e])]:["--permission-mode","default"],model:n=>Fl("--model",n),effort:n=>Fl("--effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@anthropic-ai/claude-code",homebrew:{name:"claude-code",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/claude")||n.endsWith("/.local/bin/claude.exe")||n.includes("/.local/share/claude/")},bundledBySdk:!0,homeDirName:".claude",homeEnvVar:null,sdkHomeEnvVar:"CLAUDE_CONFIG_DIR",installMarker:"projects",homeIsDiscoverable:!1,process:{by:"command",sessionIdFromCommand:n=>xd(n,new RegExp(`--resume(?:=|\\s+)(${bd})`))??xd(n,new RegExp(`--session-id(?:=|\\s+)(${bd})`))}},config:{rootDirName:".claude",instructions:[{in:"scope",path:"CLAUDE.md",scopes:["global","project"]},{in:"root",path:"CLAUDE.md",label:".claude/CLAUDE.md",scopes:["project"]},{in:"scope",path:"AGENTS.md",scopes:["project"],fallback:!0}],settings:[{in:"root",path:"settings.json",scopes:["global"]},{in:"root",path:"settings.local.json",scopes:["project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"commands",themesDir:"themes",pluginsDir:"plugins",pluginManifestDir:".claude-plugin"},contextWindow:{defaultLimit:1e6,limits:[{match:"claude-haiku-4-5",limit:2e5},{match:"claude-haiku-4-1",limit:2e5},{match:"claude-sonnet-4-5",limit:2e5},{match:"claude-opus-4-5",limit:2e5},{match:"claude-opus-4-1",limit:2e5}],compactBuffer:33e3,extendedContext:{marker:"[1m]",limit:1e6}},capabilities:{worktrees:!0,mcp:!0,slashCommands:!0,workflows:!0,agentTeams:!0,subagentTranscripts:!0,nestedSubagents:!1,sharing:!0,goals:"transcript",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!0,reasoningEffort:!0,configurableContextWindow:!1,fastTier:!0,lowPriorityInTerminal:!0,imageInput:!0,midTurnSteering:!1,stopSession:!0,ultracode:!0,contextWindow:!0,externalProcesses:!1,accountSwitching:!0,modelFallbackNotices:!0,autoPermissionMode:"per-model",toolPermissionRules:!0,settingsApply:"live",turnLiveness:"transcript",tokenStreaming:!0,nativeFork:!1,namedSessions:!0}},Kv={appServerValue:"priority",cliConfigValue:"fast"},A$={kind:"codex",displayName:"Codex",binName:"codex",dirName:tx(qj),projectWorktreeDir:null,sessionFile:{name:(n,e=new Date)=>{const t=String(e.getFullYear()),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`${t}/${s}/${r}/rollout-${t}-${s}-${r}T${o}-${i}-${l}-${n}.jsonl`},sessionId:Dl,...sx,transcriptRoot:n=>nx(n)?xf(Dl(n)):null},metadataFromHead:!1,resume:{command:(n,e)=>e?`codex -C ${Wj(e)} resume ${n}`:`codex resume ${n}`,args:n=>["resume",n]},launchArgs:{permissions:n=>{const e=(n==null?void 0:n.mode)||"default";return e==="bypassPermissions"?["--dangerously-bypass-approvals-and-sandbox"]:e==="auto"?["--approve-for-me"]:["--sandbox",e==="plan"?"read-only":"workspace-write","-c",'approval_policy="never"']},model:n=>Fl("-m",n),effort:n=>n?["-c",`model_reasoning_effort=${JSON.stringify(n)}`]:[],fastTier:n=>n?["-c",`service_tier=${JSON.stringify(Kv.cliConfigValue)}`,"--enable","fast_mode"]:[]},serviceTier:Kv,cli:{packageName:"@openai/codex",homebrew:{name:"codex",cask:!1},wingetId:null,versionArgs:["--version"],selfUpdate:null,bundledBySdk:!1,homeDirName:".codex",homeEnvVar:"CODEX_HOME",installMarker:"",homeIsDiscoverable:!0,process:{by:"command",sessionIdFromCommand:n=>xd(n,new RegExp(`codex(?:\\s+\\S+)*\\s+exec\\s+resume\\s+(${bd})`))}},config:{rootDirName:".codex",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.toml",scopes:["global","project"]}],skillsDir:"skills",agentsDir:"agents",commandsDir:"prompts",themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:272e3,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!0,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!0,nestedSubagents:!0,sharing:!1,goals:"thread-api",undo:!0,redo:!0,nativeRewind:!1,fileCheckpoints:!1,reasoningEffort:!0,configurableContextWindow:!0,fastTier:!0,lowPriorityInTerminal:!1,imageInput:!0,midTurnSteering:!0,stopSession:!1,ultracode:!1,contextWindow:!1,externalProcesses:!1,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!0,nativeFork:!1,namedSessions:!1}};function zm(n){const e=new RegExp(`^(${ex})/events\\.jsonl$`,"i").exec(n);return e?e[1]:null}const Qa={kind:"copilot",displayName:"GitHub Copilot CLI",binName:"copilot",dirName:tx(Vj),projectWorktreeDir:null,sessionFile:{name:n=>`${n}/events.jsonl`,sessionId:zm,urlId:n=>zm(n)??n.replace(/\.jsonl$/,""),fileNameFromUrlId:n=>n.endsWith(".jsonl")?n:`${n}/events.jsonl`,transcriptRoot:n=>xf(zm(n))},metadataFromHead:!0,resume:{command:(n,e)=>e?`copilot -C ${Wj(e)} --resume ${n}`:`copilot --resume ${n}`,args:n=>[`--resume=${n}`]},launchArgs:{permissions:n=>(n==null?void 0:n.mode)==="bypassPermissions"||(n==null?void 0:n.mode)==="auto"?["--allow-all"]:[],model:n=>Fl("--model",n),effort:n=>Fl("--reasoning-effort",n),fastTier:()=>[]},serviceTier:null,cli:{packageName:"@github/copilot",homebrew:{name:"copilot-cli",cask:!0},wingetId:"GitHub.Copilot",versionArgs:["--version"],selfUpdate:{args:["update"],matches:n=>n.endsWith("/.local/bin/copilot")||n==="/usr/local/bin/copilot"},bundledBySdk:!1,homeDirName:".copilot",homeEnvVar:"COPILOT_HOME",installMarker:"session-state",homeIsDiscoverable:!0,process:{by:"executable",sessionIdFromCommand:n=>xd(n,new RegExp(`--resume(?:=|\\s+)(${bd})`))}},config:{rootDirName:".copilot",instructions:[{in:"scope",path:"AGENTS.md",scopes:["global","project"]}],settings:[{in:"root",path:"config.json",scopes:["global"]}],skillsDir:"skills",agentsDir:null,commandsDir:null,themesDir:null,pluginsDir:null,pluginManifestDir:null},contextWindow:{defaultLimit:2e5,limits:[],compactBuffer:0,extendedContext:null},capabilities:{worktrees:!1,mcp:!1,slashCommands:!1,workflows:!1,agentTeams:!1,subagentTranscripts:!1,nestedSubagents:!1,sharing:!1,goals:!1,undo:!0,redo:!1,nativeRewind:!0,fileCheckpoints:!1,reasoningEffort:!1,configurableContextWindow:!1,fastTier:!1,lowPriorityInTerminal:!1,imageInput:!1,midTurnSteering:!0,stopSession:!0,ultracode:!1,contextWindow:!1,externalProcesses:!0,accountSwitching:!1,modelFallbackNotices:!1,autoPermissionMode:"always",toolPermissionRules:!0,settingsApply:"next-turn",turnLiveness:"runtime",tokenStreaming:!1,nativeFork:!0,namedSessions:!0}},I$={...Qa,kind:"acp",displayName:"ACP agent",binName:"acp",dirName:tx("acp__"),sessionFile:{name:n=>`${n}.jsonl`,sessionId:Dl,...sx,transcriptRoot:n=>{const e=nx(n);return(e==null?void 0:e.length)===1?xf(Dl(n)):null}},resume:{command:()=>"Resume this session in Cogpit",args:()=>[]},launchArgs:{permissions:()=>[],model:()=>[],effort:()=>[],fastTier:()=>[]},cli:{...Qa.cli,packageName:"",homebrew:null,wingetId:null,selfUpdate:null,requiresConfiguration:!0,homeDirName:".cogpit-acp",homeEnvVar:"COGPIT_ACP_HOME",homeIsDiscoverable:!0,installMarker:"projects"},config:{...Qa.config,rootDirName:".cogpit-acp",instructions:[],settings:[],skillsDir:null},capabilities:{...Qa.capabilities,undo:!1,redo:!1,nativeRewind:!1,nativeFork:!1,midTurnSteering:!1,externalProcesses:!1,autoPermissionMode:"never",toolPermissionRules:!1,namedSessions:!1}},Ul=Object.freeze({claude:Hj,codex:A$,copilot:Qa,acp:I$});function yn(n){return Ul[n]}function pc(){return Hs.map(n=>Ul[n])}function P$(n,e){const t=pc().filter(n);if(t.length!==1)throw new Error(`Expected exactly one agent with ${e}, found ${t.length}`);return t[0]}function hs(n){const e=Vr(n);if(e.instanceId!=="default"){const t=hs(e.nativeDirName);return{...t,dirName:{...t.dirName,encode:s=>N$(e.instanceId,t.dirName.encode(s)),decode:s=>t.dirName.decode(Vr(s).nativeDirName)},sessionFile:{...t.sessionFile,name:s=>t.sessionFile.name(lg(s).nativeId),sessionId:s=>{const r=t.sessionFile.sessionId(s);return r?gd(e.instanceId,r):null},transcriptRoot:s=>{const r=t.sessionFile.transcriptRoot(s);return r?{...r,rootSessionId:gd(e.instanceId,r.rootSessionId)}:null}}}}for(const t of Hs)if(t!=="claude"&&Ul[t].dirName.owns(n))return Ul[t];return Hj}function an(n){return hs(n).kind}function Dm(n,e,t){const s=Ul[n].dirName;return t&&s.lossy?t:s.encode(e)}function Gv(n){return C$.test(n)}const Uo=hs(null).kind;var pj;const tu=((pj=pc().find(n=>n.dirName.lossy))==null?void 0:pj.kind)??null;function na(n){return hs(n).capabilities}function fn(n){return yn(n).capabilities}function $$(n,e){return Hs.find(t=>t===n)??e}function vd(n){for(const e of pc()){const t=e.sessionFile.sessionId(n);if(t)return t}return n.replace(/\.jsonl$/,"")}function rx(n,e){var t;return((t=hs(n).sessionFile.transcriptRoot(e))==null?void 0:t.rootSessionId)??null}function R$(n,e){const t=hs(n).sessionFile.transcriptRoot(e);return t!=null&&t.isRootTranscript?t.rootSessionId:null}function Kj(n,e){return hs(n).sessionFile.urlId(e)}function O$(n,e){return hs(n).sessionFile.fileNameFromUrlId(e)}function ox(n,e,t){return yn(n).resume.command(e,t)}function L$(n,e){const t=yn(n);return{command:t.binName,args:[...t.resume.args(e)]}}function Zv(n){return n.replace(/\/+$/,"")||"/"}function M$(n,e,t){var r;const s=Zv(e);return((r=n.find(o=>hs(o.dirName).kind===t&&Zv(o.path)===s))==null?void 0:r.dirName)??null}const Tt="local",Gj="cogpit-last-path::",cg=new Map;function Dt(){var t;const n=typeof window<"u"?(t=window.location)==null?void 0:t.pathname:void 0;if(!n)return Tt;const e=/^\/d\/([^/]+)/.exec(n);return e?e[1]:Tt}function Bo(){return Dt()!==Tt}function bf(){const n=Dt();return n===Tt?"":`/d/${n}`}function Zj(){const n=Dt();return n===Tt?"":`/hub/${n}`}function ix(n){const e=Zj();return!e||n.startsWith("/api/hub/")||n.startsWith("/api/auth/")?n:n.startsWith("/api")||n.startsWith("/__pty")||n.startsWith("/__browser")?`${e}${n}`:n}let Bl=null;function z$(n){n!==Bl&&(Bl=n,window.dispatchEvent(new Event("cogpit-identity-changed")))}function Zn(){return Bl}function Bu(n){return n===Tt?0:cg.get(n)??0}function D$(n,e){if(n===Tt||!Number.isSafeInteger(e)||e<0)return!1;const t=cg.get(n);return t!==void 0&&e<=t?!1:(cg.set(n,e),window.dispatchEvent(new CustomEvent("cogpit-device-scope-changed",{detail:{deviceId:n,connectionRevision:e}})),!0)}function Jt(){const n=Dt(),e=Bu(n);return e===0?n:`${n}@${e}`}function en(n){const e=Dt(),t=Jt();return Bl!==null?`${n}::${t}::${Bl}`:e===Tt?n:`${n}::${t}`}function Ba(n,e){sessionStorage.setItem(`${Gj}${n}`,e)}function Ks(n){const t=sessionStorage.getItem(`${Gj}${n}`)??(n===Tt?"/":`/d/${n}/`);window.history.pushState(null,"",t),window.dispatchEvent(new Event("cogpit-device-changed"))}const F$=["personal","team"];function Yj(n){return F$.includes(n)}const U$="X-Cogpit-Gate",ax={terminal:!0,configWrite:!0,hostFiles:!0,manageDevices:!0,killAny:!0,viewUsage:!0,share:!0,browser:!0},Sa={terminal:!1,configWrite:!1,hostFiles:!1,manageDevices:!1,killAny:!1,viewUsage:!1,share:!1,browser:!1},ug="cogpit-gate";function B$(n){n.status===403&&n.headers.has(U$)&&window.dispatchEvent(new Event(ug))}function W$(n){return window.addEventListener(ug,n),()=>window.removeEventListener(ug,n)}const q$="/api/session-access/",lx="X-Cogpit-Session-Access",V$="X-Cogpit-Session-Id",Yv="access",Xv="session-config",Xj="cogpit-session-access-lost",Jj="cogpit-session-access-changed",Qj="cogpit-session-deleted",H$=6e4,Wu=new Map,K$=["none","view","interact","own"];function e4(n){return typeof n=="string"&&K$.includes(n)}function t4(n,e,t=!1){window.dispatchEvent(new CustomEvent(n,{detail:{sessionId:e,background:t}}))}function n4(n,e,t=!1){t4(e==="none"?Xj:Jj,n,t)}function G$(n){return n.headers.has(lx)}function s4(n){return n.headers.get(lx)==="none"}function Z$(n,e=!1){const t=n.headers.get(lx),s=n.headers.get(V$);e4(t)&&s&&n4(s,t,e)}function Y$(n){function e(t){let s;try{s=JSON.parse(t.data)}catch{return}e4(s.level)&&typeof s.sessionId=="string"&&n4(s.sessionId,s.level)}return n.addEventListener(Yv,e),()=>n.removeEventListener(Yv,e)}function cx(n,e,t){function s(r){const o=r.detail,i=o==null?void 0:o.sessionId;typeof i!="string"||t!==void 0&&i!==t||e(i,(o==null?void 0:o.background)===!0)}return window.addEventListener(n,s),()=>window.removeEventListener(n,s)}function X$(n){return cx(Xj,n)}function J$(n,e){const t=e.catch(()=>!1);Wu.set(n,t);const s=()=>{Wu.get(n)===t&&Wu.delete(n)};return t.then(r=>(r?(t4(Qj,n),setTimeout(s,H$)):s(),r))}function Q$(n){return Wu.get(n)??Promise.resolve(!1)}function e8(n){return cx(Qj,n)}function r4(n,e){return cx(Jj,n,e)}let o4=null;function yd(){return o4}function t8(n){o4=n}const n8=["DEVICE_AUTH_FAILED","DEVICE_UNREACHABLE","DEVICE_REFUSED"],Jv="cogpit-network-token",s8=new Set(["localhost","127.0.0.1","::1","0:0:0:0:0:0:0:1"]);function vf(){const n=window.location.hostname.toLowerCase(),e=n.startsWith("[")&&n.endsWith("]")?n.slice(1,-1):n;return!s8.has(e)}function yf(){try{localStorage.removeItem(Jv),sessionStorage.removeItem(Jv)}catch{}}typeof window<"u"&&yf();const r8={edition:"personal",signIn:"password",setupRequired:!1};let Wl=null;function i4(){return fetch("/api/hello",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}}).then(async n=>{if(!n.ok)throw new Error(`Hello handshake failed (${n.status})`);const e=await n.json(),t=e.signIn==="account"?"account":"password";return t8(t),{edition:Yj(e.edition)?e.edition:"personal",signIn:t,setupRequired:t==="account"&&e.setupRequired===!0}}).catch(()=>(Wl=null,r8))}function a4(){return Wl??(Wl=i4()),Wl}function Qv(){return Wl=i4(),Wl}function l4(){return a4().then(n=>n.signIn)}async function o8(){if(!vf()&&yd()!=="account")return!0;try{return(await fetch("/api/auth/session",{method:"GET",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})).ok}catch{return!1}}async function i8(){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}finally{yf()}}const a8=new Set(n8);function ey(){return yf(),window.dispatchEvent(new Event("cogpit-auth-required")),Promise.reject(new Error("Authentication required"))}function c4(n,e,t){t&&typeof n=="string"&&n.startsWith("/api")&&(n=ix(n));const{background:s=!1,...r}=e??{},o=new Headers(r.headers);return o.delete("Authorization"),o.set("X-Cogpit-Client","1"),fetch(n,{...r,headers:o,credentials:"same-origin"}).then(i=>{if(Z$(i,s),B$(i),i.status===401){if(vf()||yd()==="account")return ey();if(yd()===null)return l4().then(l=>l==="account"?ey():i)}if(i.status===502){const l=i.headers.get("X-Cogpit-Hub-Error"),c=i.headers.get("X-Cogpit-Device");c&&l&&a8.has(l)&&window.dispatchEvent(new CustomEvent("cogpit-device-unreachable",{detail:{deviceId:c,reason:l}}))}return i})}function Ee(n,e){return c4(n,e,!0)}function os(n,e,t={}){return Ee(n,{method:"POST",...t,headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(e)})}function po(n,e){return c4(n,e,!1)}function wf(n){return ix(n)}const bl={conversation:null,commands:[],cursor:0,freshness:"waiting"},ql=new Map;class l8{constructor(e,t){Ze(this,"state",bl);Ze(this,"listeners",new Set);Ze(this,"timer");Ze(this,"pending");Ze(this,"attempts",0);Ze(this,"stopped",!1);Ze(this,"identityChanged",()=>{var e;this.stopped=!0,clearTimeout(this.timer),(e=this.pending)==null||e.abort(),this.apply({...bl,freshness:"stale",error:"Account or device changed"}),ql.delete(this.key)});Ze(this,"refresh",()=>{document.visibilityState!=="hidden"&&this.fetch()});Ze(this,"subscribe",e=>(this.listeners.add(e),this.listeners.size===1&&(window.addEventListener("cogpit-command-accepted",this.refresh),window.addEventListener("online",this.refresh),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),document.addEventListener("visibilitychange",this.refresh),this.fetch()),()=>{var t;this.listeners.delete(e),this.listeners.size||(clearTimeout(this.timer),(t=this.pending)==null||t.abort(),window.removeEventListener("cogpit-command-accepted",this.refresh),window.removeEventListener("online",this.refresh),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),document.removeEventListener("visibilitychange",this.refresh),ql.delete(this.key))}));Ze(this,"snapshot",()=>this.state);this.key=e,this.url=t}get watched(){return this.listeners.size>0}admit(e){this.state.commands.some(t=>t.id===e.id)||this.apply({...this.state,commands:[...this.state.commands,e]})}apply(e){this.state=e;for(const t of this.listeners)t()}async fetch(){if(this.stopped||this.pending||!this.listeners.size)return;clearTimeout(this.timer);const e=new AbortController;this.pending=e;let t=!1;try{const s=await Ee(`${this.url}&after=${this.state.cursor}`,{signal:e.signal});if(!s.ok)throw t=[401,403,404].includes(s.status),new Error(`Queue unavailable (${s.status})`);const r=await s.json();if(e.signal.aborted)return;if(!r.conversation||!Array.isArray(r.commands)||!r.replay||!Number.isSafeInteger(r.replay.cursor))throw new Error("Invalid queue snapshot");this.apply({conversation:r.conversation,commands:r.commands,cursor:r.replay.cursor,freshness:"current",currentAddress:r.currentAddress,pendingTransition:r.pendingTransition}),this.attempts=0}catch(s){e.signal.aborted||this.apply({...t?bl:this.state,freshness:"stale",error:s instanceof Error?s.message:"Queue unavailable"}),this.attempts++}finally{this.pending=void 0,!this.stopped&&this.listeners.size&&!t&&(this.timer=setTimeout(()=>{this.fetch()},Math.min(3e4,2e3*2**Math.min(this.attempts,4))*(.8+Math.random()*.4)))}}async action(e){if(this.stopped)throw new Error("Account or device changed; reopen the conversation");const t=await Ee(this.url.split("?")[0],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const s=await t.json();throw new Error(s.error??"Queue update failed")}await this.fetch()}}function u4(n){const e=wf(`/api/session-commands?sessionId=${encodeURIComponent(n)}`);return{key:JSON.stringify([Jt(),Zn(),e]),url:e}}function Sf(n){const{key:e,url:t}=u4(n);let s=ql.get(e);return s||(s=new l8(e,t),ql.set(e,s)),s}function c8(n){const e=ql.get(u4(n.sessionId).key);return e!=null&&e.watched?(e.admit(n),!0):!1}function G(...n){return t7(n7(n))}const u8=Qr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/20 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-7 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-7 rounded-md [&_svg:not([class*='size-'])]:size-3.5","icon-sm":"size-7","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function J({className:n,variant:e,size:t,...s}){return a.jsx(s7,{"data-slot":"button",className:G(u8({variant:e,size:t,className:n})),...s})}const d8=[{value:"",label:"Default"},{value:"opus",label:"Opus"},{value:"fable",label:"Fable"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}],wd=[{value:"low",label:"Light",description:"Fast responses with lighter reasoning"},{value:"medium",label:"Medium",description:"Balanced for everyday tasks"},{value:"high",label:"High",description:"Deeper reasoning for complex work"},{value:"xhigh",label:"Extra High",description:"Extra depth for difficult problems"},{value:"max",label:"Max",description:"Maximum reasoning depth"}],f8=[...wd,{value:"ultra",label:"Ultra",description:"Maximum reasoning with automatic task delegation"}],m8=wd.slice(0,4);var hj;const d4=((hj=yn("codex").serviceTier)==null?void 0:hj.appServerValue)??"priority",p8=[{value:d4,label:"Fast",description:"1.5× speed with increased usage"}],ty=[{value:d4,label:"Fast",description:"2× speed with increased usage"}],io={defaultReasoningEffort:"medium",supportedReasoningEfforts:f8,inputModalities:["text","image"],supportsPersonality:!1,serviceTiers:p8},h8=[{value:"",label:"Default",description:"Use the model configured in Codex"},{value:"gpt-6.1-sol",label:"GPT-6.1 Sol",description:"Latest workhorse model for coding and everyday work",...io,defaultReasoningEffort:"low",serviceTiers:ty},{value:"gpt-6-astra",label:"GPT-6 Astra",description:"Frontier intelligence for the most demanding work",...io,serviceTiers:ty},{value:"gpt-6-sol",label:"GPT-6 Sol",description:"Previous generation workhorse model",...io},{value:"gpt-6-luna",label:"GPT-6 Luna",description:"Fast and affordable model for easier tasks",...io,supportedReasoningEfforts:wd},{value:"gpt-5.6-sol",label:"GPT-5.6 Sol",description:"Older generation workhorse model",...io,defaultReasoningEffort:"low"},{value:"gpt-5.6-terra",label:"GPT-5.6 Terra",description:"Older balanced model for straightforward work",...io},{value:"gpt-5.6-luna",label:"GPT-5.6 Luna",description:"Older fast and efficient model",...io,supportedReasoningEfforts:wd},{value:"gpt-5.5",label:"GPT-5.5",description:"Legacy coding model",...io,supportedReasoningEfforts:m8}],g8=[{value:"",label:"Default",supportsEffort:!1,inputModalities:["text"]},{value:"auto",label:"Auto",description:"Let Copilot choose the best available model",supportsEffort:!1,inputModalities:["text"]}],x8={acp:[{value:"",label:"Provider default"}],claude:d8,codex:h8,copilot:g8};function b8(n){return x8[n]}const ux=new Map,Sd=new Set;function v8(n,e){!Array.isArray(e)||e.length===0||(ux.set(n,e),Sd.forEach(t=>t()))}function y8(n){return Sd.add(n),()=>Sd.delete(n)}function w8(){ux.clear(),Sd.forEach(n=>n())}const ny="high",S8=[{value:"low",label:"Light"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"xhigh",label:"Extra High"},{value:"max",label:"Max"}];function k8(n){return ux.get(n)??b8(n)}function hc(n,e){return e?n.find(t=>t.value===e):n.find(t=>t.value!==""&&t.isDefault)??n.find(t=>t.value==="")??n.find(t=>t.value!=="")}function f4(n,e,t){const s=hc(e,t),r=s==null?void 0:s.supportedReasoningEfforts;return r&&r.length>0?r:(s==null?void 0:s.supportsEffort)===!1||!fn(n).reasoningEffort?[]:S8}function j8(n,e){var t,s;return(s=(t=hc(n,e))==null?void 0:t.serviceTiers)==null?void 0:s.find(r=>r.value==="fast"||r.value==="priority"||r.label.toLowerCase()==="fast")}function N8(n,e,t){var r;const s=(r=hc(e,t))==null?void 0:r.inputModalities;return s?s.includes("image"):fn(n).imageInput}function C8(n,e,t){var r;const s=fn(n).autoPermissionMode;return s==="always"?!0:s==="never"?!1:((r=hc(e,t))==null?void 0:r.supportsAutoMode)===!0}function _8(n,e){return fn(n).ultracode?!(e??"").toLowerCase().startsWith("haiku"):!1}function E8(n,e,t,s){var l;const r=f4(n,e,s);if(r.length===0)return"";const o=c=>!!c&&r.some(u=>u.value===c);if(o(t))return t;const i=(l=hc(e,s))==null?void 0:l.defaultReasoningEffort;return o(i)?i:o(ny)?ny:r[0].value}function T8(n){return n.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40).replace(/-$/,"")}async function kf(n){try{return await navigator.clipboard.writeText(n),!0}catch{const e=document.activeElement,t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const s=document.execCommand("copy");return document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),s}}function Ys(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(gj,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function A8(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(L1,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function V0e(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(uc,{"data-slot":"dialog-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function I8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(M1,{"data-slot":"dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Xs(n){const e=q.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,showCloseButton:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?!0:o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(I8,{}),e[5]=l):l=e[5];let c;e[6]!==s?(c=G("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-6 text-popover-foreground shadow-lg duration-150 ease-out sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",s),e[6]=s,e[7]=c):c=e[7];let u;e[8]!==i?(u=i&&a.jsxs(uc,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[a.jsx(At,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==t||e[11]!==r||e[12]!==c||e[13]!==u?(d=a.jsxs(A8,{children:[l,a.jsxs($1,{"data-slot":"dialog-content",className:c,...r,children:[t,u]})]}),e[10]=t,e[11]=r,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}function to(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function dx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Js(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-lg leading-none font-semibold",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(R1,{"data-slot":"dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Qs(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-muted-foreground text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(O1,{"data-slot":"dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function P8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("label",{"data-slot":"label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function $8(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("fieldset",{"data-slot":"field-set",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function R8(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,variant:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"legend":r;let i;e[4]!==t?(i=G("mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==i||e[8]!==o?(l=a.jsx("legend",{"data-slot":"field-legend","data-variant":o,className:i,...s}),e[6]=s,e[7]=i,e[8]=o,e[9]=l):l=e[9],l}function ka(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const O8=Qr("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function sn(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"vertical":r;let i;e[4]!==t||e[5]!==o?(i=G(O8({orientation:o}),t),e[4]=t,e[5]=o,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"field","data-orientation":o,className:i,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function H0e(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-content flex flex-1 flex-col gap-0.5 leading-snug",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"field-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function rn(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(P8,{"data-slot":"field-label",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function sa(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-left text-sm leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("p",{"data-slot":"field-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function jo(n){var d;const e=q.c(15);let t,s,r,o;e[0]!==n?({className:s,children:t,errors:r,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e:{if(t){i=t;break e}if(!(r!=null&&r.length)){i=null;break e}let f;e[5]!==r?(f=[...new Map(r.map(M8)).values()],e[5]=r,e[6]=f):f=e[6];const m=f;if((m==null?void 0:m.length)==1){i=(d=m[0])==null?void 0:d.message;break e}let p;e[7]!==m?(p=a.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:m.map(L8)}),e[7]=m,e[8]=p):p=e[8],i=p}const l=i;if(!l)return null;let c;e[9]!==s?(c=G("text-sm font-normal text-destructive",s),e[9]=s,e[10]=c):c=e[10];let u;return e[11]!==l||e[12]!==o||e[13]!==c?(u=a.jsx("div",{role:"alert","data-slot":"field-error",className:c,...o,children:l}),e[11]=l,e[12]=o,e[13]=c,e[14]=u):u=e[14],u}function L8(n,e){return(n==null?void 0:n.message)&&a.jsx("li",{children:n.message},e)}function M8(n){return[n==null?void 0:n.message,n]}function zn({className:n,...e}){return a.jsx(r7,{"data-slot":"input",className:G("h-8 w-full min-w-0 rounded-lg border border-input bg-background px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",n),...e})}const z8=Qr("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-150 motion-safe:ease-out motion-reduce:animate-none *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function wt({className:n,variant:e,...t}){return a.jsx("div",{"data-slot":"alert",role:"alert",className:G(z8({variant:e}),n),...t})}function Vt({className:n,...e}){return a.jsx("div",{"data-slot":"alert-title",className:G("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",n),...e})}function _t({className:n,...e}){return a.jsx("div",{"data-slot":"alert-description",className:G("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",n),...e})}function Ao({className:n,...e}){return a.jsx("div",{"data-slot":"alert-action",className:G("absolute top-2 right-2",n),...e})}const m4=l7;function p4(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("scroll-my-1 p-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(i7,{"data-slot":"select-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function h4(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-1 text-left",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(c7,{"data-slot":"select-value",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function g4(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({className:s,size:o,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==s?(l=G("group/select-trigger flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input py-2 pr-2 pl-2.5 text-sm whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out select-none data-pressed:scale-[0.98] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none motion-reduce:data-pressed:scale-100 bg-background hover:bg-accent dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",s),e[5]=s,e[6]=l):l=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(d7,{render:a.jsx(Wt,{className:"pointer-events-none size-4 text-muted-foreground transition-transform duration-150 ease-out group-data-popup-open/select-trigger:rotate-180 motion-reduce:transition-none"})}),e[7]=c):c=e[7];let u;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==l?(u=a.jsxs(u7,{"data-slot":"select-trigger","data-size":i,className:l,...r,children:[t,c]}),e[8]=t,e[9]=r,e[10]=i,e[11]=l,e[12]=u):u=e[12],u}function x4(n){const e=q.c(26);let t,s,r,o,i,l,c,u;e[0]!==n?({className:s,children:t,side:o,sideOffset:i,align:l,alignOffset:c,alignItemWithTrigger:u,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"bottom":o,f=i===void 0?4:i,m=l===void 0?"center":l,p=c===void 0?0:c,h=u===void 0?!0:u;let g;e[9]!==s?(g=G("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out data-[side=none]:animate-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[9]=s,e[10]=g):g=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(D8,{}),e[11]=x):x=e[11];let b;e[12]!==t?(b=a.jsx(f7,{children:t}),e[12]=t,e[13]=b):b=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(F8,{}),e[14]=w):w=e[14];let v;e[15]!==r||e[16]!==g||e[17]!==b?(v=a.jsxs(o7,{"data-slot":"select-content",className:g,...r,children:[x,b,w]}),e[15]=r,e[16]=g,e[17]=b,e[18]=v):v=e[18];let k;return e[19]!==m||e[20]!==h||e[21]!==p||e[22]!==d||e[23]!==f||e[24]!==v?(k=a.jsx(m7,{children:a.jsx(p7,{side:d,sideOffset:f,align:m,alignOffset:p,alignItemWithTrigger:h,className:"isolate z-50",children:v})}),e[19]=m,e[20]=h,e[21]=p,e[22]=d,e[23]=f,e[24]=v,e[25]=k):k=e[25],k}function dg(n){const e=q.c(13);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=a.jsx(h7,{className:"flex flex-1 shrink-0 gap-2 whitespace-nowrap",children:t}),e[6]=t,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(g7,{className:"transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",render:a.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:a.jsx(Ht,{className:"pointer-events-none"})}),e[8]=l):l=e[8];let c;return e[9]!==r||e[10]!==o||e[11]!==i?(c=a.jsxs(a7,{"data-slot":"select-item",className:o,...r,children:[i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=c):c=e[12],c}function D8(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(dc,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(x7,{"data-slot":"select-scroll-up-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function F8(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 transition-opacity duration-100 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&_svg:not([class*='size-'])]:size-4",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Wt,{}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(b7,{"data-slot":"select-scroll-down-button",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}function U8({sessionId:n,onOpen:e,open:t,onOpenChange:s}){var A,T,I;const r=y.useMemo(()=>Sf(n),[n]),o=y.useSyncExternalStore(r.subscribe,r.snapshot),[i,l]=y.useState([]),[c,u]=y.useState(Hs.at(-1)),[d,f]=y.useState(""),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=y.useRef(null),[v,k]=y.useState(null),[j,_]=y.useState(!t),N=y.useRef(0);y.useEffect(()=>{t&&_(!1)},[t]),y.useEffect(()=>{const E=++N.current,P=new AbortController;return Ee("/api/provider-instances",{signal:P.signal}).then(async R=>{if(R.ok){const L=await R.json();E===N.current&&l(L.instances.filter(O=>!O.retired))}}).catch(()=>{}),()=>{N.current=E+1,P.abort()}},[n]),y.useEffect(()=>{!j||!v||v.epoch!==N.current||(k(null),e(v.dirName,v.fileName))},[j,v,e]);async function S(E){if(!o.conversation)return;const P=N.current,R=i.find(M=>M.id===c),L=o.conversation.binding,O={sessionId:n,expectedRevision:o.conversation.revision,mode:E,agent:E==="resume"?L.agent:(R==null?void 0:R.agent)??c,instanceId:E==="resume"?L.instanceId:(R==null?void 0:R.id)??"default",message:d},$=JSON.stringify(O);(!w.current||w.current.payload!==$)&&(w.current={id:crypto.randomUUID(),payload:$}),p(!0),b(null);try{const M=await Ee("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...O,commandId:w.current.id})}),D=await M.json();if(P!==N.current)return;if(!M.ok)throw new Error(D.error||"Provider handoff failed");D.dirName&&D.fileName&&k({dirName:D.dirName,fileName:D.fileName,epoch:P}),s(!1),w.current=null}catch(M){P===N.current&&b(M instanceof Error?M.message:"Provider handoff failed")}finally{P===N.current&&p(!1)}}async function C(E=!1){if(!o.pendingTransition||E&&!window.confirm("Confirm you inspected the target provider’s history and no session was created for this handoff. This releases the conversation so you can start a new handoff."))return;const P=N.current;p(!0),b(null);try{const R=await Ee("/api/conversation-transition",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"resolve",sessionId:n,commandId:o.pendingTransition.id,confirmNotCreated:E,targetSessionId:E?void 0:h||o.pendingTransition.sessionId})}),L=await R.json();if(P!==N.current)return;if(!R.ok)throw new Error(L.error||"Handoff reconciliation failed");w.current=null,window.dispatchEvent(new Event("cogpit-command-accepted")),L.dirName&&L.fileName&&e(L.dirName,L.fileName)}catch(R){P===N.current&&b(R instanceof Error?R.message:"Handoff reconciliation failed")}finally{P===N.current&&p(!1)}}return a.jsxs("div",{className:"flex flex-col gap-2 px-3 empty:hidden",children:[o.conversation&&o.conversation.binding.sessionId!==n&&o.currentAddress&&a.jsx(J,{size:"xs",variant:"outline",onClick:()=>e(o.currentAddress.dirName,o.currentAddress.fileName),children:"Open current conversation session"}),o.pendingTransition&&a.jsx(wt,{children:a.jsxs(_t,{className:"flex flex-col gap-2",children:[a.jsx("p",{children:"A provider handoff needs reconciliation. Inspect the target provider’s history before choosing a recovery action."}),a.jsx(zn,{"aria-label":"Recovered session ID",placeholder:o.pendingTransition.sessionId||"Native session ID found in history",value:h,onChange:E=>g(E.target.value)}),a.jsx(J,{size:"xs",disabled:m||!(h||o.pendingTransition.sessionId),onClick:()=>void C(),children:"Attach recovered session"}),a.jsx(J,{size:"xs",variant:"outline",disabled:m,onClick:()=>void C(!0),children:"Confirm no session was created"})]})}),a.jsx(Ys,{open:t,onOpenChange:E=>{E&&_(!1),s(E)},onOpenChangeComplete:E=>{_(!E)},children:a.jsxs(Xs,{children:[a.jsxs(to,{children:[a.jsx(Js,{children:"Continue this conversation"}),a.jsx(Qs,{children:"Native resume keeps the current provider and account. Context handoff starts a new native session with up to 12 recent turns and 24,000 characters of text context. Files remain in the same project."})]}),a.jsxs(sa,{children:["Conversation: ",((A=o.conversation)==null?void 0:A.id)||"Loading…"]}),x&&a.jsx(wt,{variant:"destructive",children:a.jsx(_t,{children:x})}),a.jsxs(ka,{children:[a.jsxs(sn,{children:[a.jsx(rn,{children:"Target provider or account"}),a.jsxs(m4,{value:c,onValueChange:E=>E&&u(E),children:[a.jsx(g4,{"aria-label":"Handoff provider",children:a.jsx(h4,{children:((T=i.find(E=>E.id===c))==null?void 0:T.label)||((I=yn(c))==null?void 0:I.displayName)})}),a.jsx(x4,{children:a.jsxs(p4,{children:[Hs.map(E=>a.jsxs(dg,{value:E,children:[yn(E).displayName," · Default profile"]},E)),i.map(E=>a.jsx(dg,{value:E.id,children:E.label},E.id))]})})]})]}),a.jsxs(sn,{children:[a.jsx(rn,{htmlFor:"handoff-message",children:"Next request"}),a.jsx(zn,{id:"handoff-message",value:d,onChange:E=>f(E.target.value)}),a.jsx(sa,{children:"Tool state and permissions are established by the new provider."})]}),a.jsx(J,{disabled:m||!o.conversation,onClick:()=>void S("handoff"),children:"Start context handoff"}),a.jsx(J,{variant:"outline",disabled:m||!o.conversation,onClick:()=>void S("resume"),children:"Keep current native session"})]})]})}),!t&&x&&a.jsx(wt,{variant:"destructive",children:a.jsx(_t,{children:x})})]})}function sy(n){return n.split(/\r?\n/).filter(t=>!t.trimStart().startsWith("[ede_diagnostic]")).join(`
|
|
3
3
|
`).trim()||"The agent stopped before completing this turn. You can continue the conversation."}function br(n,e){const t=q.c(8);let s;t[0]!==e||t[1]!==n?(s=()=>{if(typeof window>"u")return e;try{const u=localStorage.getItem(n);return u===null?e:JSON.parse(u)}catch{return e}},t[0]=e,t[1]=n,t[2]=s):s=t[2];const[r,o]=y.useState(s);let i;t[3]!==n?(i=u=>{o(d=>{const f=typeof u=="function"?u(d):u;try{localStorage.setItem(n,JSON.stringify(f))}catch(m){const p=m;console.warn(`useLocalStorage: failed to serialize value for key "${n}"`,p)}return f})},t[3]=n,t[4]=i):i=t[4];const l=i;let c;return t[5]!==l||t[6]!==r?(c=[r,l],t[5]=l,t[6]=r,t[7]=c):c=t[7],c}const B8=Qr("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Ue(n){const e=q.c(13);let t,s,r,o,i;if(e[0]!==n){const{className:u,variant:d,render:f,...m}=n;t=f,i=d===void 0?"default":d,o=bj,s="span",r=xj({className:G(B8({variant:i}),u)},m),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i}else t=e[1],s=e[2],r=e[3],o=e[4],i=e[5];let l;e[6]!==i?(l={slot:"badge",variant:i},e[6]=i,e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==s||e[10]!==r||e[11]!==l?(c={defaultTagName:s,props:r,render:t,state:l},e[8]=t,e[9]=s,e[10]=r,e[11]=l,e[12]=c):c=e[12],o(c)}function kd(n){if(typeof n!="string"||n.length===0)return Number.NEGATIVE_INFINITY;const e=Date.parse(n);return Number.isFinite(e)?e:Number.NEGATIVE_INFINITY}function vr(n){const e=kd(n.lastActivityAt);return e!==Number.NEGATIVE_INFINITY?e:kd(n.lastModified)}function ry(n,e){return n===e?0:e-n}function oy(n){return[n.dirName??"",n.fileName??"",n.sessionId??""].join("/")}function W8(n,e){const t=ry(vr(n),vr(e));if(t!==0)return t;const s=ry(kd(n.lastModified),kd(e.lastModified));return s!==0?s:oy(n).localeCompare(oy(e))}function ja(n){return[...n].sort(W8)}function q8(n,e){var i;const{defaultLimit:t,limits:s,extendedContext:r}=yn(e).contextWindow,o=n.trim().toLowerCase();return r&&o.includes(r.marker)?r.limit:((i=s.find(l=>o.includes(l.match)))==null?void 0:i.limit)??t}function V8(n,e,t){const s=typeof n.input_tokens=="number"?n.input_tokens:0,r=typeof n.cache_creation_input_tokens=="number"?n.cache_creation_input_tokens:0,o=typeof n.cache_read_input_tokens=="number"?n.cache_read_input_tokens:0,i=s+r+o,l=q8(e,t),c=l-yn(t).contextWindow.compactBuffer;return{used:i,limit:l,compactAt:c,percent:Math.min(100,i/c*100),percentAbsolute:Math.min(100,i/l*100)}}const H8=["fable","mythos","opus","sonnet","haiku"];function iy(n){return n.charAt(0).toUpperCase()+n.slice(1)}function xi(n){if(!n)return"unknown";const e=n.toLowerCase(),t=/\[1m\]$/.test(e)?" 1M":"",s=e.replace(/\[[^\]]*\]$/,"");for(const r of H8){const o=s.match(new RegExp(`${r}(?:-(\\d+)(?:-(\\d{1,2}))?(?!\\d))?`));if(!o)continue;const i=o[1]?` ${o[1]}${o[2]?`.${o[2]}`:""}`:"";return`${iy(r)}${i}${t}`}if(s.startsWith("gpt-")){const[r,...o]=s.slice(4).split("-"),i=o.map(iy).join(" ");return`GPT-${r}${i?` ${i}`:""}${t}`}return n.length>20?n.slice(0,20)+"...":n}function K8(n){return n.split("/").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]")}const G8=new RegExp(`[\\\\/](?:${[...pc().map(n=>n.projectWorktreeDir),".worktrees"].filter(n=>n!==null).map(K8).join("|")})[\\\\/]([^\\\\/]+)`);function yr(n){const e=G8.exec(n);return e?{parentPath:n.slice(0,e.index),worktreeName:e[1]}:null}function K0e(n,e){return e===`worktree-${n}`}function ys(n){return Number.isFinite(n)?n<.01?`$${n.toFixed(4)}`:n<1?`$${n.toFixed(3)}`:`$${n.toFixed(2)}`:"—"}function Ct(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:String(n)}function wr(n){if(n<1e3)return`${n}ms`;const e=Math.round(n/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return t>=60?`${Math.floor(t/60)}h ${t%60}m`:`${t}m ${s}s`}function b4(n){return n>=1e6?`${(n/1e6).toFixed(1)}MB`:n>=1e3?`${(n/1e3).toFixed(0)}KB`:`${n}B`}function Sr(n){const e=Date.now()-new Date(n).getTime(),t=Math.floor(e/6e4);if(t<1)return"now";if(t<60)return`${t}m`;const s=Math.floor(t/60);if(s<24)return`${s}h`;const r=Math.floor(s/24);return r<7?`${r}d`:new Date(n).toLocaleDateString()}function fx(n){return n>=86400?`${Math.floor(n/86400)}d ${Math.floor(n%86400/3600)}h`:n>=3600?`${Math.floor(n/3600)}h ${Math.floor(n%3600/60)}m`:`${Math.max(1,Math.floor(n/60))}m`}function mx(n){if(n.durationMs!==null)return n.durationMs;if(!n.timestamp)return null;let e=0,t=n.timestamp,s="";const r=i=>{i&&i>s&&(s=i)},o=()=>{if(!s)return;const i=new Date(s).getTime()-new Date(t).getTime();i>0&&(e+=i),s=""};for(const i of n.contentBlocks){if(i.kind==="task_notification"){o(),i.timestamp&&(t=i.timestamp);continue}if(r(i.timestamp),i.kind==="tool_calls"||i.kind==="plan_mode")for(const l of i.toolCalls)r(l.timestamp)}return o(),e>0?e:null}function Ms(n,e){return n.length<=e?n:n.slice(0,e)+"..."}function ms(n){return hs(n).dirName.decode(n)??n}function gc(n,e=2){const t=n.replace(/\/+$/,"").split("/").filter(Boolean);return t.length<=e?n:t.slice(-e).join("/")}function kr(n){return n.replace(/\/+$/,"").split("/").at(-1)??n}function Io(n){const e=n.match(/^([^/]+)\/subagents\/agent-([^.]+)\.jsonl$/);return e?{parentSessionId:e[1],agentId:e[2],parentFileName:`${e[1]}.jsonl`}:null}function v4(n){for(let e=n.length-1;e>=0;e--){const t=n[e];if(t.type==="assistant")return V8(t.message.usage,t.message.model??"","claude")}return null}function li(n,e){return e||Ms(w4(n),50)}const Z8="Untitled session";function y4(n,e){const t=n.teamName&&n.agentName?n.agentName:"";return e||n.customTitle||n.aiTitle||t||n.lastUserMessage||n.firstUserMessage||n.slug||void 0}function w4(n,e){return y4(n,e)??Z8}function Y8(n,e){return y4(n,e)===void 0}function X8(n){const e=new Set(n.map(r=>r.sessionId)),t=new Map,s=[];for(const r of n){const o=r.teamLeadSessionId;if(o&&o!==r.sessionId&&e.has(o)){const i=t.get(o);i?i.push(r):t.set(o,[r])}else s.push(r)}return{topLevelSessions:s,teammatesByLead:t}}function J8(n){return n.find(e=>!yr(e.cwd??ms(e.dirName)))??n[0]}const Q8="Unknown project";function px(n){const e=yr(n);return gc(e?e.parentPath:n,2)||Q8}function vl(n){return px(n.cwd||ms(n.dirName))}function hx(n){return n==="inactive"?"Archived after two weeks without activity":"Archived"}function eR(n,e){return e?n:n.filter(t=>!t.archived)}function tR(n){const e=ja(n),t=new Map;for(const s of e){const r=vl(s),o=t.get(r);o?o.push(s):t.set(r,[s])}return t}function gx(n,e){return n.isActive?!0:e?n.agentStatus!=="completed":!1}const jf=new Set(["thinking","tool_use","processing","compacting","awaiting_agents"]),nR=12e4;function S4(n,e=Date.now()){const t=Date.parse(n.lastActivityAt||n.lastModified);return Number.isFinite(t)&&e-t<nR}function xx(n,e,t=Date.now()){return gx(n,e.get(n.sessionId))?!0:n.agentStatus==="completed"||!n.agentStatus?!1:S4(n,t)}function sR(n,e,t=Date.now()){return n.some(s=>xx(s,e,t))}const rR={awaitingPermission:new Set,awaitingQuestion:new Set,awaitingPrompt:new Set,awaitingPlan:new Set};function bx(n){var o,i;const e=new Map(n.map(l=>[l.sessionId,l])),t=l=>{const c=e.get(l);return c!==void 0&&!c.archived},s=[],r=new Map;for(const l of n){const c=l.crew;if(!c){s.push(l);continue}const u=[];let d=c.parentId;for(;d&&d!==l.sessionId&&e.has(d)&&!u.includes(d);)u.push(d),d=(i=(o=e.get(d))==null?void 0:o.crew)==null?void 0:i.parentId;c.rootId!==l.sessionId&&!u.includes(c.rootId)&&u.push(c.rootId);const f=[...u].reverse().find(t);if(!f){s.push(l);continue}const m=r.get(f);m?m.push(l):r.set(f,[l])}for(const l of r.values())l.sort((c,u)=>{var d,f;return(((d=c.crew)==null?void 0:d.startedAt)??0)-(((f=u.crew)==null?void 0:f.startedAt)??0)});return{topLevel:s,crewOf:r}}function k4(n,e,t){const s=n.sessionId;return t.awaitingPermission.has(s)?{state:"needs-you",need:"permission"}:t.awaitingQuestion.has(s)?{state:"needs-you",need:"question"}:t.awaitingPrompt.has(s)?{state:"needs-you",need:"input"}:t.awaitingPlan.has(s)?{state:"needs-you",need:"plan"}:n.agentStatus==="deferred"?{state:"needs-you",need:"deferred"}:{state:xx(n,e)&&(!n.agentStatus||jf.has(n.agentStatus))?"working":"done"}}function vx(n,e){const t={size:n.length,needsYou:0,working:0,done:0};let s;for(const r of n){const{state:o}=e(r);o==="needs-you"?(t.needsYou++,(!s||vr(r)<vr(s))&&(s=r)):o==="working"?t.working++:t.done++}return s&&(t.longestWaitSince=s.lastActivityAt||s.lastModified),t}function ay(n,e){const t=e.reduce((s,r)=>vr(r)>vr(s)?r:s,n);return t.lastActivityAt||t.lastModified}function ly(n){var e;return((e=n==null?void 0:n.cwd)==null?void 0:e.replace(/\/+$/,"").split("/").at(-1))||void 0}function jd(n,{customName:e,parent:t}){var r;if(e)return e;if((r=n.crew)!=null&&r.name)return n.crew.name;if(n.customTitle)return n.customTitle;const s=ly(n);return s&&s!==ly(t)?s:oR(n.firstUserMessage)??li(n)}const cy=60;function oR(n){const e=n==null?void 0:n.split(`
|
|
4
4
|
`).map(t=>t.replace(/^#+\s*/,"").trim()).find(Boolean);if(e)return e.length>cy?`${e.slice(0,cy-1)}…`:e}function iR(n,e){return e.filter(t=>{var s;return((s=t.crew)==null?void 0:s.parentId)===n}).length}function Nd(n,e,t){const s=e.get(n);if(!s)return;const r=t[n];return s.crew?jd(s,{customName:r,parent:e.get(s.crew.parentId)}):li(s,r)}const aR={capabilities:ax,user:{edition:"personal",user:null,hubUser:null,enforcesSessionAccess:!1},gate:null},j4={capabilities:Sa,user:{edition:null,user:null,hubUser:null,enforcesSessionAccess:null},gate:null};let N4=aR,fg=null;const mg=new Set;function yl(n,e=(n==null?void 0:n.user)??null){N4=n?{capabilities:n.capabilities,user:{edition:n.edition,user:n.user,hubUser:e,enforcesSessionAccess:n.enforcesSessionAccess===!0},gate:n.gate??null}:j4,fg=Jt();for(const t of mg)t()}function yx(){return fg===null||fg===Jt()?N4:j4}function ht(n){const{capabilities:e}=yx();return Object.hasOwn(e,n)&&e[n]===!0}function Cd(){return yx().user}function uy(){return yx().gate}function Nf(n){return mg.add(n),()=>mg.delete(n)}function C4(){return y.useSyncExternalStore(Nf,Cd,Cd)}function _4(){return y.useSyncExternalStore(Nf,uy,uy)}function wx(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function lR(n){return wx(n)?n:null}const cR="cogpit:session-list-cache",uR=10080*60*1e3,dR=24,Vl={projects:"projects",activeSessions:"active-sessions",runningProcesses:"running-processes"};function E4(n,e){return e===null?n:`${n}:${e}`}function qu(n){return E4(Vl.activeSessions,n)}const _d=new Map;function fR(){return{version:1,entries:{}}}function Cf(){return yd()==="account"&&Zn()===null?null:en(cR)}function Sx(n){const e=_d.get(n);if(e)return e;let t=fR();try{const s=localStorage.getItem(n);if(s){const r=JSON.parse(s);r.version===1&&r.entries&&typeof r.entries=="object"&&(t=r)}}catch{}return _d.set(n,t),t}function T4(n,e){_d.set(n,e);try{localStorage.setItem(n,JSON.stringify(e))}catch{}}function A4(n){const e=Cf(),t=e===null?void 0:Sx(e).entries[n];if(!(!t||Date.now()-t.savedAt>uR))return t.value}function I4(n,e){const t=Cf();if(t===null)return;const s={...Sx(t).entries,[n]:{savedAt:Date.now(),value:e}},r=Object.entries(s).sort(([,o],[,i])=>i.savedAt-o.savedAt);T4(t,{version:1,entries:Object.fromEntries(r.slice(0,dR))})}function P4(n){return wx(n)&&Array.isArray(n.sessions)&&typeof n.total=="number"}function dy(n,e){return n.filter(t=>!(wx(t)&&t.sessionId===e))}function mR(n,e){if(Array.isArray(n)){const r=dy(n,e);return r.length===n.length?n:r}if(!P4(n))return n;const t=dy(n.sessions,e),s=n.sessions.length-t.length;return s===0?n:{sessions:t,total:n.total-s}}function Vi(n){const e=A4(n);return Array.isArray(e)?e:void 0}function wl(n,e){I4(n,e)}function $4(n,e){return E4(`sessions:${n}`,e)}function pR(n,e){const t=A4($4(n,e));return P4(t)?t:void 0}function hR(n,e,t){I4($4(n,e),t)}function gR(n){const e=Cf();if(e===null)return;const t=Sx(e);let s=!1;const r={};for(const[o,i]of Object.entries(t.entries)){const l=mR(i.value,n);s||(s=l!==i.value),r[o]=l===i.value?i:{...i,value:l}}s&&T4(e,{version:1,entries:r})}function xR(){const n=Cf();if(n!==null){_d.delete(n);try{localStorage.removeItem(n)}catch{}}}const bR=Object.freeze({});let xc=bR,Na="idle";const pg=new Set;function _f(n,e){xc=n,Na=e;for(const t of pg)t()}function hg(){return xc}function Hl(){return Na}function kx(n){return pg.add(n),()=>pg.delete(n)}function vR(n){if(Na==="installed")throw new Error(`An edition UI is already installed; ${n.edition} cannot replace it`);_f(n.ui,"installed")}function yR(){Na!=="installed"&&_f(xc,"loading")}function wR(){Na!=="installed"&&_f(xc,"unavailable")}function SR(){Na!=="installed"&&_f(xc,"failed")}const kR=[],fy=new WeakMap;function my(){const n=Cd();let e=fy.get(n);return e||(e={...n,can:ht},fy.set(n,e)),e}function Tr(){return y.useSyncExternalStore(kx,hg,hg)}function py(){return Hl()==="unavailable"}function jR(){return y.useSyncExternalStore(kx,py,py)}function NR(){return y.useSyncExternalStore(Nf,my,my)}function jx(){const n=q.c(5),{mainViews:e}=Tr(),t=e===void 0?kR:e,s=NR();let r;if(n[0]!==s||n[1]!==t){let o;n[3]!==s?(o=i=>i.isAvailable(s),n[3]=s,n[4]=o):o=n[4],r=t.filter(o),n[0]=s,n[1]=t,n[2]=r}else r=n[2];return r}function R4(n){const e=q.c(3),t=jx();let s;return e[0]!==n||e[1]!==t?(s=n===null?null:t.find(r=>r.id===n)??null,e[0]=n,e[1]=t,e[2]=s):s=e[2],s}const CR=Object.freeze({key:null,query:Object.freeze({})});function _R(){return()=>{}}function ER(){return null}function Ef(){const n=q.c(7),{sessionListFilter:e}=Tr();let t;n[0]!==e?(t=c=>(e==null?void 0:e.subscribe(c))??_R(),n[0]=e,n[1]=t):t=n[1];const s=t;let r;n[2]!==e?(r=e?()=>e.getKey():ER,n[2]=e,n[3]=r):r=n[3];const o=r,i=y.useSyncExternalStore(s,o,o);let l;return n[4]!==i||n[5]!==e?(l=e&&i!==null?{key:i,query:e.getQuery()}:CR,n[4]=i,n[5]=e,n[6]=l):l=n[6],l}function Sl(n,e,t={}){const s=new URLSearchParams(t);for(const[o,i]of Object.entries(e.query))s.set(o,i);const r=s.toString();return r?`${n}?${r}`:n}function Tf(n,e){return Sl("/api/active-sessions",e,n)}async function cr(n){try{const e=await(n==null?void 0:n.json());return e&&typeof e=="object"?e:null}catch{return null}}async function kl(n,e){const t=await cr(n);return typeof(t==null?void 0:t.error)=="string"&&t.error?t.error:e}const TR=["view","interact","own"],AR=1e3,IR=3e4,Ed=new Map,O4=new Set,Vu=new Map,ci=new Set,gg=new Set;let hy=0;function Wo(n){return`${en("session-access")}::${n}`}function Ca(n){for(const e of n)e()}function bc(n,e,t){e!=="none"&&O4.add(n);const s=Ed.get(n);return s&&s.ticket>t?!1:(Ed.set(n,{level:e,ticket:t}),(s==null?void 0:s.level)!==e)}function PR(n){return TR.includes(n==null?void 0:n.level)}function $R(n){var e;return(e=Ed.get(Wo(n)))==null?void 0:e.level}function RR(n){return O4.has(Wo(n))}function OR(n){return ci.add(n),()=>ci.delete(n)}function Hr(){return hy+=1,hy}function ra(n,e){let t=!1;for(const{sessionId:s,access:r}of n)r&&(t=bc(Wo(s),r.level,e)||t);t&&Ca(ci)}async function LR(n){let e;try{e=await Ee(`${q$}${encodeURIComponent(n)}`)}catch{return null}if(e.status===404&&s4(e))return"none";if(!e.ok)return null;const t=await cr(e);return PR(t)?t.level:null}async function MR(n,e){var r;const t=Hr(),s=await LR(n);return s===null?null:(bc(e,s,t)&&Ca(ci),((r=Ed.get(e))==null?void 0:r.level)??null)}function L4(n){const e=Wo(n),t=MR(n,e).finally(()=>{Vu.get(e)===t&&Vu.delete(e)});return Vu.set(e,t),t}function gy(n){return Vu.get(Wo(n))??L4(n)}function G0e(n,e,t){bc(Wo(n),e,t)&&Ca(ci)}function zR(n){bc(Wo(n),"none",Hr())&&Ca(ci)}function M4(n){const{enforcesSessionAccess:e,user:t}=Cd();!e||!t||bc(Wo(n),"own",Hr())&&Ca(ci)}function z4(){Ca(gg)}function Af(n){return gg.add(n),()=>gg.delete(n)}function DR(n){let e=!1,t=0,s=0,r;async function o(l){const c=++s;clearTimeout(r);const u=await l();if(e||c!==s)return;if(u){t=0;return}const d=Math.min(AR*2**t,IR);t+=1,r=setTimeout(()=>void o(()=>gy(n)),d)}o(()=>gy(n));const i=r4(()=>{t=0,o(()=>L4(n))},n);return()=>{e=!0,clearTimeout(r),i()}}const FR=2e4;function UR(n){const e=new Map;for(const t of n){if(!t.sessionId)continue;const s=e.get(t.sessionId);(!s||t.memMB>s.memMB)&&e.set(t.sessionId,t)}return e}function xy(n,e){let t=null;for(const s of e){const r=!!s.archived;n.has(s.sessionId)!==r&&(t??(t=new Set(n)),r?t.add(s.sessionId):t.delete(s.sessionId))}return t??n}const D4=y.createContext(null);function BR({children:n}){const[e]=y.useState(Jt),t=Ef(),s=_4()!==null,r=qu(t.key),[o,i]=y.useState(()=>Vi(r)??[]),[l,c]=y.useState(()=>Vi(Vl.runningProcesses)??[]),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(new Set),[g,x]=br(en("live-sessions-show-archived"),!1),b=g===!0,[w,v]=y.useState(!1),k=b||w,[j,_]=y.useState(0),N=y.useRef(xy(new Set,o)),[S,C]=y.useState(N.current),A=y.useCallback(H=>{N.current=H,C(H)},[]),T=y.useRef(null),I=y.useRef(!1),E=y.useRef(o),P=y.useRef(r),R=y.useRef(null),L=y.useRef(!1);y.useEffect(()=>(L.current=!0,()=>{var H;L.current=!1,(H=R.current)==null||H.abort(),R.current=null}),[]);const O=y.useCallback(async()=>{var Y;if(s||!L.current||Jt()!==e)return;(Y=R.current)==null||Y.abort();const H=new AbortController;R.current=H;const K=()=>L.current&&!H.signal.aborted&&R.current===H&&Jt()===e;d(!0);const Z=Hr();try{const[X,ee]=await Promise.all([Ee(Tf(k?{archived:"include"}:{},t),{signal:H.signal}),Ee("/api/running-processes",{signal:H.signal})]);if(!K())return;if(!X.ok||!ee.ok)throw new Error("Failed to fetch live data");const[Q,ne]=await Promise.all([X.json(),ee.json()]);if(!K())return;const te=Array.isArray(Q)?Q:[],re=Array.isArray(ne)?ne:[];ra(te,Z),I.current&&(I.current=!1,T.current=null),E.current=te,i(te),c(re),A(xy(N.current,te)),_(Number(X.headers.get("X-Cogpit-Archived-Count"))||0),wl(r,te),wl(Vl.runningProcesses,re),m(null)}catch(X){if(!K())return;m(X instanceof Error?X.message:"Failed to load data")}finally{K()&&d(!1),R.current===H&&(R.current=null)}},[s,e,k,t,r,A]),$=y.useCallback(()=>{O()},[O]);y.useEffect(()=>{if(P.current===r)return;P.current=r,I.current=!0;const H=Vi(r)??[];E.current=H,i(H)},[r]),y.useEffect(()=>{$()},[$]),y.useEffect(()=>Af(()=>{I.current=!0,$()}),[$]);const M=y.useMemo(()=>UR(l),[l]),D=y.useMemo(()=>sR(o,M),[o,M]);y.useEffect(()=>(window.addEventListener("focus",$),()=>window.removeEventListener("focus",$)),[$]),y.useEffect(()=>{if(!D)return;const H=setInterval(()=>{document.visibilityState==="visible"&&$()},FR);return()=>clearInterval(H)},[D,$]),y.useEffect(()=>{if(o.length===0||I.current)return;const H=T.current,K=new Map;for(const Z of o)Z.agentStatus&&M.has(Z.sessionId)&&K.set(Z.sessionId,Z.agentStatus);H!==null&&h(Z=>{let Y=null;for(const[X,ee]of K)ee==="completed"&&H.has(X)&&H.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.add(X));for(const X of Z)K.get(X)!=="completed"&&(Y??(Y=new Set(Z)),Y.delete(X));return Y??Z}),T.current=K},[o,M]);const F=y.useCallback(H=>{h(K=>{if(!K.has(H))return K;const Z=new Set(K);return Z.delete(H),Z})},[]),z=y.useCallback(H=>{E.current=H,i(H),Jt()===e&&wl(r,H)},[e,r]),B=y.useCallback(H=>{z(E.current.filter(K=>K.sessionId!==H))},[z]),U=y.useCallback((H,K)=>{const Z=N.current,Y=new Set(H.filter(Q=>Z.has(Q)!==K));if(Y.size===0)return;const X=new Set(Z);for(const Q of Y)K?X.add(Q):X.delete(Q);A(X),z(E.current.map(Q=>{if(!Y.has(Q.sessionId))return Q;if(K)return{...Q,archived:!0,archivedReason:"manual"};const{archived:ne,archivedReason:te,...re}=Q;return re}));const ee=K?Y.size:-Y.size;_(Q=>Math.max(0,Q+ee))},[A,z]),W=y.useCallback(H=>S.has(H),[S]),V=y.useMemo(()=>({sessions:o,processes:l,procBySession:M,newlyCompleted:p,loading:u,error:f,refresh:$,removeSession:B,acknowledgeCompleted:F,showArchived:b,setShowArchived:x,setSearchActive:v,archivedCount:j,isArchived:W,setArchived:U}),[o,l,M,p,u,f,$,B,F,b,x,j,W,U]);return a.jsx(D4.Provider,{value:V,children:n})}function Nx(){const n=Ar();if(!n)throw new Error("useSessionInventory must be used within a SessionInventoryProvider");return n}function Ar(){return y.useContext(D4)}function F4(n){function e(){try{const i=localStorage.getItem(en(n));return i?JSON.parse(i):{}}catch{return{}}}let t=e();const s=new Set;function r(){for(const i of s)i()}function o(){t=e(),r()}return typeof window<"u"&&(window.addEventListener("cogpit-device-changed",o),window.addEventListener("cogpit-identity-changed",o)),{subscribe:i=>(s.add(i),()=>{s.delete(i)}),getSnapshot:()=>t,rename:(i,l)=>{const c={...t},u=l.trim();u?c[i]=u:delete c[i],localStorage.setItem(en(n),JSON.stringify(c)),t=c,r()}}}const xg=F4("session-custom-names"),U4=xg.rename;function If(){const n=q.c(2),e=y.useSyncExternalStore(xg.subscribe,xg.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:U4},n[0]=e,n[1]=t):t=n[1],t}function _a(){const n=q.c(5),e=Ar(),{names:t}=If();e==null||e.sessions;let s;n[0]!==(e==null?void 0:e.sessions)?(s=new Map(((e==null?void 0:e.sessions)??[]).map(WR)),n[0]=e==null?void 0:e.sessions,n[1]=s):s=n[1];const r=s;let o;return n[2]!==r||n[3]!==t?(o=i=>Nd(i,r,t),n[2]=r,n[3]=t,n[4]=o):o=n[4],o}function WR(n){return[n.sessionId,n]}const qR=/\x1b\].*?(?:\x07|\x1b\\)/g,VR=/\x1b\[[0-9;]*[A-Za-z]/g,HR=/\x1b[()][AB012]/g,KR=/\[2K\[1G/g;function B4(n){return n.replace(qR,"").replace(VR,"").replace(HR,"").replace(KR,`
|
|
@@ -6,7 +6,7 @@ var YI=Object.defineProperty;var XI=(n,e,t)=>e in n?YI(n,e,{enumerable:!0,config
|
|
|
6
6
|
|
|
7
7
|
`,t),r=s===-1?t:s+2;return{text:(n.slice(0,e)+n.slice(r)).trim(),isSystemNotification:!0}}function _x(n,e){if(!YR(n))return null;const t=W4(n),s=(t==null?void 0:t.state)==="error",r=t&&(e==null?void 0:e(t.childSessionId));if(!r)return s?"Delegated session failed":"Delegated session finished";const o=l9(t.result),i=o?` · ${o} ${o===1?"file":"files"} changed`:"";return`${r} ${s?"failed":"finished"}${i}`}function l9(n){const e=n==null?void 0:n.filesChanged;return Array.isArray(e)?e.length:0}const c9=()=>()=>{},u9=()=>bl;function d9(n){var p;const e=q.c(12),{sessionId:t,readOnly:s}=n,r=s===void 0?!1:s;let o;e[0]!==t?(o=t?Sf(t):null,e[0]=t,e[1]=o):o=e[1];const i=o,l=y.useSyncExternalStore((i==null?void 0:i.subscribe)??c9,(i==null?void 0:i.snapshot)??u9);if(!t||!i)return null;const c=`dismissed-command-failures:${((p=l.conversation)==null?void 0:p.id)??t}`;let u;e[2]!==c?(u=en(c),e[2]=c,e[3]=u):u=e[3];const d=u;let f;e[4]!==i||e[5]!==t?(f=h=>i.action({...h,sessionId:t}),e[4]=i,e[5]=t,e[6]=f):f=e[6];let m;return e[7]!==r||e[8]!==l.commands||e[9]!==d||e[10]!==f?(m=a.jsx(f9,{storageKey:d,commands:l.commands,readOnly:r,onAction:f},d),e[7]=r,e[8]=l.commands,e[9]=d,e[10]=f,e[11]=m):m=e[11],m}function f9({storageKey:n,commands:e,readOnly:t,onAction:s}){const[r,o]=br(n,[]),i=new Set(Array.isArray(r)?r:[]),[l,c]=y.useState(!1),[u,d]=y.useState(null),[f,m]=y.useState(null),p=_a(),h=e.filter(x=>x.state==="failed"&&!i.has(x.id)||x.state==="unknown");async function g(x){if(!t){c(!0),d(null);try{await s(x),m(null)}catch(b){d(b instanceof Error?b.message:"Queue update failed")}finally{c(!1)}}}return!h.length&&!u?null:a.jsxs("section",{className:"flex max-h-72 flex-col gap-2 overflow-y-auto p-3","aria-label":"Message delivery problems",children:[u&&a.jsxs(wt,{variant:"destructive",children:[a.jsxs(Vt,{className:"flex items-center justify-between gap-2",children:["Queue update failed",a.jsx(J,{size:"icon-xs",variant:"ghost","aria-label":"Dismiss queue error",onClick:()=>d(null),children:a.jsx(At,{})})]}),a.jsx(_t,{children:sy(u)})]}),h.map(x=>a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ue,{variant:"destructive",children:x.state}),a.jsx("span",{className:"min-w-0 flex-1 truncate",title:x.message,children:x.message&&_x(x.message,p)||x.message||"Image attachment"}),x.state==="failed"&&a.jsx(J,{size:"icon-xs",variant:"ghost","aria-label":"Dismiss failed message",title:"Dismiss failed message",onClick:()=>o(b=>[...Array.isArray(b)?b:[],x.id]),children:a.jsx(At,{})})]}),x.error&&a.jsx("p",{className:"text-sm text-muted-foreground",children:sy(x.error)}),x.state==="unknown"&&!t&&a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(J,{size:"xs",variant:"outline",disabled:l,onClick:()=>void g({action:"resolve",commandId:x.id,disposition:"completed"}),children:"History confirms completion"}),a.jsx(J,{size:"xs",variant:"outline",disabled:l,onClick:()=>void g({action:"resolve",commandId:x.id,disposition:"failed"}),children:"History confirms failure"}),a.jsx(J,{size:"xs",variant:"outline",disabled:l,onClick:()=>m(x.id),children:"Resend…"})]}),f===x.id&&a.jsxs(wt,{children:[a.jsx(Vt,{children:"This may send a duplicate"}),a.jsxs(_t,{children:["Review the conversation first. Cogpit could not confirm the original delivery.",a.jsx(J,{size:"xs",variant:"destructive",disabled:l,onClick:()=>void g({action:"resend",commandId:x.id,newCommandId:crypto.randomUUID(),confirmDuplicateRisk:!0}),children:"Confirm resend"}),a.jsx(J,{size:"xs",variant:"ghost",onClick:()=>m(null),children:"Keep waiting"})]})]})]},x.id))]})}const m9=3e3,bg=[],Hu=new Map;function Y4(n,e){const t=new AbortController;e.controller=t;const s=()=>{t.signal.aborted||(e.timer=setTimeout(()=>Y4(n,e),m9))};if(document.visibilityState!=="visible")return s();Ee(`/api/delegated-tasks?sessionId=${encodeURIComponent(n)}`,{signal:t.signal}).then(async r=>{if(!r.ok)return;const{tasks:o}=await r.json();if(!(t.signal.aborted||JSON.stringify(o)===JSON.stringify(e.tasks))){e.tasks=o;for(const i of e.listeners)i()}}).catch(()=>{}).finally(s)}function p9(n,e){let t=Hu.get(n);t||(t={tasks:bg,listeners:new Set},Hu.set(n,t),Y4(n,t)),t.listeners.add(e);const s=t;return()=>{var r;s.listeners.delete(e),!(s.listeners.size>0)&&((r=s.controller)==null||r.abort(),clearTimeout(s.timer),Hu.delete(n))}}function X4(n){const e=q.c(4);let t;e[0]!==n?(t=i=>n?p9(n,i):h9,e[0]=n,e[1]=t):t=e[1];const s=t;let r;e[2]!==n?(r=()=>{var i;return n?((i=Hu.get(n))==null?void 0:i.tasks)??bg:bg},e[2]=n,e[3]=r):r=e[3];const o=r;return y.useSyncExternalStore(s,o)}function h9(){}function g9(n){const e=n.filter(s=>s.state==="running").length,t=n.length-e;return[e&&`${e} running`,t&&`${t} finished`].filter(Boolean).join(" · ")}function x9(n){const e=q.c(29),{sessionId:t,crewOpen:s,onOpenCrew:r}=n,o=s===void 0?!1:s,i=X4(t);let l,c,u,d,f,m,p,h,g,x;if(e[0]!==o||e[1]!==i){c=Symbol.for("react.early_return_sentinel");e:{const k=i.filter(v9);if(o||!k.length){c=null;break e}const j=k.some(b9);p="status",h="Sessions this one started",g="mx-3 flex items-center gap-2 rounded-xl border border-border bg-card/60 py-1 pl-3 pr-1 text-sm",e[12]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx(z1,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[12]=x):x=e[12],l=j&&a.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-success ring-2 ring-success/30","aria-hidden":"true"}),u="min-w-0 flex-1 truncate text-muted-foreground",e[13]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx("span",{className:"text-foreground",children:"Crew"}),e[13]=d):d=e[13],f=" · ",m=g9(k)}e[0]=o,e[1]=i,e[2]=l,e[3]=c,e[4]=u,e[5]=d,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=g,e[11]=x}else l=e[2],c=e[3],u=e[4],d=e[5],f=e[6],m=e[7],p=e[8],h=e[9],g=e[10],x=e[11];if(c!==Symbol.for("react.early_return_sentinel"))return c;let b;e[14]!==u||e[15]!==d||e[16]!==f||e[17]!==m?(b=a.jsxs("span",{className:u,children:[d,f,m]}),e[14]=u,e[15]=d,e[16]=f,e[17]=m,e[18]=b):b=e[18];let w;e[19]!==r?(w=r&&a.jsxs(J,{variant:"ghost",size:"xs",onClick:r,children:["Open crew",a.jsx(it,{"data-icon":"inline-end"})]}),e[19]=r,e[20]=w):w=e[20];let v;return e[21]!==l||e[22]!==b||e[23]!==w||e[24]!==p||e[25]!==h||e[26]!==g||e[27]!==x?(v=a.jsxs("div",{role:p,"aria-label":h,className:g,children:[x,l,b,w]}),e[21]=l,e[22]=b,e[23]=w,e[24]=p,e[25]=h,e[26]=g,e[27]=x,e[28]=v):v=e[28],v}function b9(n){return n.state==="running"}function v9(n){return!n.acknowledgedAt&&n.state!=="cancelled"}function Ex(n,e){const t=q.c(4);let s,r;t[0]!==e||t[1]!==n?(s=()=>{if(!n)return;let o=!0;const i=()=>{document.visibilityState==="visible"&&n(()=>o)};i();const l=setInterval(i,e);return document.addEventListener("visibilitychange",i),()=>{o=!1,clearInterval(l),document.removeEventListener("visibilitychange",i)}},r=[n,e],t[0]=e,t[1]=n,t[2]=s,t[3]=r):(s=t[2],r=t[3]),y.useEffect(s,r)}const y9=5e3;function w9(n){const[e,t]=y.useState(null),s=y.useCallback(async r=>{if(n)try{const o=await Ee(`/api/session-board/${encodeURIComponent(n)}`);if(!r()||!o.ok)return;const{board:i}=await o.json();if(!r())return;t(l=>JSON.stringify(l)===JSON.stringify(i)?l:i)}catch{}},[n]);return Ex(n?s:null,y9),y.useEffect(()=>{t(r=>(r==null?void 0:r.sessionId)===n?r:null)},[n]),e}const J4={warning:"text-warning",success:"text-success"},S9={warning:"bg-warning",success:"bg-success"};function k9(n){const e=q.c(35),{boardSessionId:t}=n,s=w9(t),r=_a();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=br("board-line-open",o);if(!s)return null;let c;e[1]!==i?(c=Array.isArray(i)?i:[],e[1]=i,e[2]=c):c=e[2];const u=c;let d;e[3]!==s.sessionId||e[4]!==u?(d=u.includes(s.sessionId),e[3]=s.sessionId,e[4]=u,e[5]=d):d=e[5];const f=d;let m;e[6]!==s.sessionId||e[7]!==u||e[8]!==f||e[9]!==l?(m=()=>l(f?u.filter(b=>b!==s.sessionId):[...u,s.sessionId]),e[6]=s.sessionId,e[7]=u,e[8]=f,e[9]=l,e[10]=m):m=e[10];const p=m;let h;e[11]!==s.sessionId||e[12]!==r?(h=r(s.sessionId),e[11]=s.sessionId,e[12]=r,e[13]=h):h=e[13];const g=h;let x;if(e[14]!==s.progress||e[15]!==s.sections||e[16]!==s.title||e[17]!==s.updatedAt||e[18]!==g||e[19]!==f||e[20]!==p){const b=s.sections.filter(C9);let w;e[22]!==s.title?(w=s.title&&a.jsx("span",{className:"shrink-0 font-medium text-foreground",children:s.title}),e[22]=s.title,e[23]=w):w=e[23];let v;e[24]!==s.progress?(v=s.progress&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground",children:[a.jsx("span",{className:"h-1 w-12 overflow-hidden rounded-full bg-muted","aria-hidden":"true",children:a.jsx("span",{className:"block h-full rounded-full bg-foreground",style:{width:`${s.progress.done/s.progress.total*100}%`}})}),s.progress.done," of ",s.progress.total]}),e[24]=s.progress,e[25]=v):v=e[25];let k;e[26]!==s.updatedAt?(k=Sr(new Date(s.updatedAt).toISOString()),e[26]=s.updatedAt,e[27]=k):k=e[27];const j=g?` by ${g}`:"";let _;e[28]!==j||e[29]!==k?(_=a.jsxs("span",{className:"hidden shrink-0 text-[11px] text-muted-foreground/80 sm:inline",children:["updated ",k,j]}),e[28]=j,e[29]=k,e[30]=_):_=e[30];const N=!f&&"rotate-180";let S;e[31]!==N?(S=G("size-3.5 shrink-0 text-muted-foreground transition-transform",N),e[31]=N,e[32]=S):S=e[32];let C;e[33]!==S?(C=a.jsx(dc,{className:S,"aria-hidden":"true"}),e[33]=S,e[34]=C):C=e[34],x=a.jsxs("section",{"aria-label":"Board","data-board":!0,className:"mx-3 overflow-hidden rounded-xl border border-border bg-card/80 text-[12.5px]",children:[a.jsxs("button",{type:"button",onClick:p,"aria-expanded":f,className:"flex w-full min-w-0 items-center gap-2.5 px-3 py-2 text-left outline-none hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[w,v,a.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-2.5 truncate text-muted-foreground",children:b.map(N9)}),_,C]}),f&&b.length>0&&a.jsx("div",{className:"grid border-t border-border/70 sm:grid-cols-3",children:b.map(j9)})]}),e[14]=s.progress,e[15]=s.sections,e[16]=s.title,e[17]=s.updatedAt,e[18]=g,e[19]=f,e[20]=p,e[21]=x}else x=e[21];return x}function j9(n){return a.jsxs("div",{className:"min-w-0 border-border/70 px-3 py-2 sm:border-l sm:first:border-l-0",children:[a.jsx("h4",{className:G("mb-1 text-[11.5px] font-medium text-muted-foreground",n.tone&&J4[n.tone]),children:n.title}),a.jsx("ul",{className:"flex flex-col gap-0.5",children:n.items.map(e=>a.jsxs("li",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full bg-muted-foreground/50",n.tone&&S9[n.tone]),"aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:e})]},e))})]},n.title)}function N9(n){return a.jsxs("span",{className:G("shrink-0",n.tone&&J4[n.tone]),children:[n.title," ",a.jsx("span",{className:"font-medium tabular-nums",children:n.items.length})]},n.title)}function C9(n){return n.items.length>0}function _9(n){var w,v,k;const e=q.c(22),{sessionId:t,readOnly:s,onOpen:r,handoffOpen:o,onHandoffOpenChange:i,crewOpen:l,onOpenCrew:c,children:u}=n,f=((k=(v=(w=Ar())==null?void 0:w.sessions.find(j=>j.sessionId===t))==null?void 0:v.crew)==null?void 0:k.rootId)??t;let m;e[0]!==f?(m=a.jsx(k9,{boardSessionId:f}),e[0]=f,e[1]=m):m=e[1];let p;e[2]!==o||e[3]!==i||e[4]!==r||e[5]!==s||e[6]!==t?(p=t&&!s&&a.jsx(U8,{sessionId:t,onOpen:r,open:o,onOpenChange:i},`actions:${t}`),e[2]=o,e[3]=i,e[4]=r,e[5]=s,e[6]=t,e[7]=p):p=e[7];const h=`queue:${t??"pending"}`;let g;e[8]!==s||e[9]!==t||e[10]!==h?(g=a.jsx(d9,{sessionId:t,readOnly:s},h),e[8]=s,e[9]=t,e[10]=h,e[11]=g):g=e[11];let x;e[12]!==l||e[13]!==c||e[14]!==t?(x=t&&a.jsx(x9,{sessionId:t,crewOpen:l,onOpenCrew:c},`delegated:${t}`),e[12]=l,e[13]=c,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==u||e[17]!==m||e[18]!==p||e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"flex flex-col gap-2 rounded-t-xl bg-canvas/95 pt-2",children:[m,p,g,x,u]}),e[16]=u,e[17]=m,e[18]=p,e[19]=g,e[20]=x,e[21]=b):b=e[21],b}function Cn({className:n,...e}){return a.jsx("div",{"data-slot":"empty",className:G("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}function _n({className:n,...e}){return a.jsx("div",{"data-slot":"empty-header",className:G("flex max-w-sm flex-col items-center gap-2",n),...e})}const E9=Qr("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function Dn({className:n,variant:e="default",...t}){return a.jsx("div",{"data-slot":"empty-icon","data-variant":e,className:G(E9({variant:e,className:n})),...t})}function En({className:n,...e}){return a.jsx("div",{"data-slot":"empty-title",className:G("text-sm font-medium tracking-tight",n),...e})}function Tn({className:n,...e}){return a.jsx("div",{"data-slot":"empty-description",className:G("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",n),...e})}function vc({className:n,...e}){return a.jsx("div",{"data-slot":"empty-content",className:G("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",n),...e})}function T9(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const A9=n=>{switch(n){case"success":return $9;case"info":return O9;case"warning":return R9;case"error":return L9;default:return null}},I9=Array(12).fill(0),P9=({visible:n,className:e})=>Ie.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},Ie.createElement("div",{className:"sonner-spinner"},I9.map((t,s)=>Ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),$9=Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ie.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),R9=Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ie.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),O9=Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),L9=Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20","aria-hidden":"true"},Ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),M9=Ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},Ie.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ie.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),z9=()=>{const[n,e]=Ie.useState(document.hidden);return Ie.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),n};let D9=1;const F9=100,vy=n=>{var e;return typeof(n==null?void 0:n.id)=="number"||(n==null||(e=n.id)==null?void 0:e.length)>0?n.id:D9++};class U9{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-F9;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{const{message:t,...s}=e,r=vy(e),o=this.pendingDismissals.get(r);o!==void 0&&(cancelAnimationFrame(o),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));const i=this.dismissedToasts.has(r),l=e.dismissible===void 0?!0:e.dismissible;return i&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(u=>u.id!==r)),(i?void 0:this.toasts.find(u=>u.id===r))?this.toasts=this.toasts.map(u=>u.id===r?(this.publish({...u,...e,id:r,title:t}),{...u,...e,id:r,dismissible:l,title:t}):u):this.addToast({title:t,...s,dismissible:l,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(s=>{this.dismissedToasts.add(s.id),this.subscribers.forEach(r=>r({id:s.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);const t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(s=>s({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let o=s!==void 0,i;const l=r.then(async u=>{if(i=["resolve",u],Ie.isValidElement(u))o=!1,this.create({id:s,type:"default",message:u});else if(W9(u)&&!u.ok){o=!1;const f=typeof t.error=="function"?await t.error(`HTTP error! status: ${u.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${u.status}`):t.description,h=typeof f=="object"&&!Ie.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(u instanceof Error){o=!1;const f=typeof t.error=="function"?await t.error(u):t.error,m=typeof t.description=="function"?await t.description(u):t.description,h=typeof f=="object"&&!Ie.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:m,...h})}else if(t.success!==void 0){o=!1;const f=typeof t.success=="function"?await t.success(u):t.success,m=typeof t.description=="function"?await t.description(u):t.description,h=typeof f=="object"&&!Ie.isValidElement(f)?f:{message:f};this.create({id:s,type:"success",description:m,...h})}}).catch(async u=>{if(i=["reject",u],t.error!==void 0){o=!1;const d=typeof t.error=="function"?await t.error(u):t.error,f=typeof t.description=="function"?await t.description(u):t.description,p=typeof d=="object"&&!Ie.isValidElement(d)?d:{message:d};this.create({id:s,type:"error",description:f,...p})}}).finally(()=>{o&&(this.dismiss(s),s=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof s!="string"&&typeof s!="number"?{unwrap:c}:Object.assign(s,{unwrap:c})},this.custom=(e,t)=>{const s=vy(t);return this.create({...t,jsx:e(s),id:s,type:void 0}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}const es=new U9,B9=(n,e)=>es.message(n,e),W9=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",q9=B9,V9=()=>es.toasts,H9=()=>es.getActiveToasts(),Kn=Object.assign(q9,{success:es.success,info:es.info,warning:es.warning,error:es.error,custom:es.custom,message:es.message,promise:es.promise,dismiss:es.dismiss,loading:es.loading},{getHistory:V9,getToasts:H9});T9("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function nu(n){return n.label!==void 0}const K9=3,G9="24px",Z9="16px",yy=4e3,Y9=356,X9=14,J9=45,Q9=200;function ir(...n){return n.filter(Boolean).join(" ")}function eO(n){const[e,t]=n.split("-"),s=[];return e&&s.push(e),t&&s.push(t),s}const tO=n=>{var e,t,s,r,o,i,l,c,u;const{invert:d,toast:f,unstyled:m,interacting:p,setHeights:h,visibleToasts:g,heights:x,index:b,toasts:w,expanded:v,removeToast:k,defaultRichColors:j,closeButton:_,style:N,cancelButtonStyle:S,actionButtonStyle:C,className:A="",descriptionClassName:T="",duration:I,position:E,gap:P,expandByDefault:R,classNames:L,icons:O,closeButtonAriaLabel:$="Close toast"}=n,[M,D]=Ie.useState(null),[F,z]=Ie.useState(null),[B,U]=Ie.useState(!1),[W,V]=Ie.useState(!1),[H,K]=Ie.useState(!1),[Z,Y]=Ie.useState(!1),[X,ee]=Ie.useState(!1),[Q,ne]=Ie.useState(0),[te,re]=Ie.useState(0),oe=Ie.useRef(f.duration||I||yy),ie=Ie.useRef(null),ae=Ie.useRef(null),de=b===0,le=b+1<=g,se=f.type,me=se??"default",ue=f.dismissible!==!1,ce=f.className||"",xe=f.descriptionClassName||"",pe=Ie.useMemo(()=>x.findIndex(Ne=>Ne.toastId===f.id)||0,[x,f.id]),he=Ie.useMemo(()=>{var Ne;return(Ne=f.closeButton)!=null?Ne:_},[f.closeButton,_]),be=Ie.useMemo(()=>f.duration||I||yy,[f.duration,I]),we=Ie.useRef(0),ve=Ie.useRef(0),Se=Ie.useRef(0),Te=Ie.useRef(null),[Ae,ze]=E.split("-"),De=Ie.useMemo(()=>x.reduce((Ne,Ve,ye)=>ye>=pe?Ne:Ne+Ve.height,0),[x,pe]),Le=z9(),Ce=Ie.useMemo(()=>{var Ne;return(Ne=n.swipeDirections)!=null?Ne:eO(E)},[n.swipeDirections,E]),Be=f.invert||d,We=se==="loading";ve.current=Ie.useMemo(()=>pe*P+De,[pe,De]),Ie.useEffect(()=>{oe.current=be},[be]),Ie.useEffect(()=>{U(!0)},[]),Ie.useEffect(()=>{const Ne=ae.current;if(Ne){const Ve=Ne.getBoundingClientRect().height;return re(Ve),h(ye=>[{toastId:f.id,height:Ve,position:f.position},...ye]),()=>h(ye=>ye.filter($e=>$e.toastId!==f.id))}},[h,f.id]),Ie.useLayoutEffect(()=>{if(!B)return;const Ne=ae.current,Ve=Ne.style.height;Ne.style.height="auto";const ye=Ne.getBoundingClientRect().height;Ne.style.height=Ve,re(ye),h($e=>$e.find(Ke=>Ke.toastId===f.id)?$e.map(Ke=>Ke.toastId===f.id?{...Ke,height:ye}:Ke):[{toastId:f.id,height:ye,position:f.position},...$e])},[B,f.title,f.description,h,f.id,f.jsx,f.action,f.cancel]);const He=Ie.useCallback(()=>{V(!0),ne(ve.current),h(Ne=>Ne.filter(Ve=>Ve.toastId!==f.id)),setTimeout(()=>{k(f)},Q9)},[f,k,h,ve]);Ie.useEffect(()=>{if(f.promise&&se==="loading"||f.duration===1/0||f.type==="loading")return;let Ne;return v||p||Le?(()=>{if(Se.current<we.current){const $e=new Date().getTime()-we.current;oe.current=oe.current-$e}Se.current=new Date().getTime()})():(()=>{oe.current!==1/0&&(we.current=new Date().getTime(),Ne=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),He()},oe.current))})(),()=>clearTimeout(Ne)},[v,p,f,se,Le,He]),Ie.useEffect(()=>{f.delete&&(He(),f.onDismiss==null||f.onDismiss.call(f,f))},[He,f.delete]);function _e(){var Ne;if(O!=null&&O.loading){var Ve;return Ie.createElement("div",{className:ir(L==null?void 0:L.loader,f==null||(Ve=f.classNames)==null?void 0:Ve.loader,"sonner-loader"),"data-visible":se==="loading"},O.loading)}return Ie.createElement(P9,{className:ir(L==null?void 0:L.loader,f==null||(Ne=f.classNames)==null?void 0:Ne.loader),visible:se==="loading"})}const Re=f.icon||(O==null?void 0:O[se])||A9(se);var tt,Xe;return Ie.createElement("li",{tabIndex:0,ref:ae,className:ir(A,ce,L==null?void 0:L.toast,f==null||(e=f.classNames)==null?void 0:e.toast,L==null?void 0:L[me],f==null||(t=f.classNames)==null?void 0:t[me]),"data-sonner-toast":"","data-rich-colors":(tt=f.richColors)!=null?tt:j,"data-styled":!(f.jsx||f.unstyled||m),"data-mounted":B,"data-promise":!!f.promise,"data-swiped":X,"data-removed":W,"data-visible":le,"data-y-position":Ae,"data-x-position":ze,"data-index":b,"data-front":de,"data-swiping":H,"data-dismissible":ue,"data-type":se,"data-invert":Be,"data-swipe-out":Z,"data-swipe-direction":F,"data-expanded":!!(v||R&&B),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${W?Q:ve.current}px`,"--initial-height":R?"auto":`${te}px`,...N,...f.style},onDragEnd:()=>{K(!1),D(null),Te.current=null},onPointerDown:Ne=>{Ne.button!==2&&(We||!ue||(ie.current=new Date,ne(ve.current),Ne.target.setPointerCapture(Ne.pointerId),Ne.target.tagName!=="BUTTON"&&(K(!0),Te.current={x:Ne.clientX,y:Ne.clientY})))},onPointerUp:()=>{var Ne,Ve,ye;if(Z||!ue)return;Te.current=null;const $e=Number(((Ne=ae.current)==null?void 0:Ne.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),qe=Number(((Ve=ae.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ke=new Date().getTime()-((ye=ie.current)==null?void 0:ye.getTime()),fe=M==="x"?$e:qe,ke=Math.abs(fe)/Ke;if((M==="x"?Ce.includes($e>0?"right":"left"):Ce.includes(qe>0?"bottom":"top"))&&(Math.abs(fe)>=J9||ke>.11)){ne(ve.current),f.onDismiss==null||f.onDismiss.call(f,f),z(M==="x"?$e>0?"right":"left":qe>0?"down":"up"),He(),Y(!0);return}else{var Je,rt;(Je=ae.current)==null||Je.style.setProperty("--swipe-amount-x","0px"),(rt=ae.current)==null||rt.style.setProperty("--swipe-amount-y","0px")}ee(!1),K(!1),D(null)},onPointerMove:Ne=>{var Ve,ye,$e;if(!Te.current||!ue||((Ve=window.getSelection())==null?void 0:Ve.toString().length)>0)return;const Ke=Ne.clientY-Te.current.y,fe=Ne.clientX-Te.current.x;!M&&(Math.abs(fe)>1||Math.abs(Ke)>1)&&D(Math.abs(fe)>Math.abs(Ke)?"x":"y");let ke={x:0,y:0};const Ge=Je=>1/(1.5+Math.abs(Je)/20);if(M==="y"){if(Ce.includes("top")||Ce.includes("bottom"))if(Ce.includes("top")&&Ke<0||Ce.includes("bottom")&&Ke>0)ke.y=Ke;else{const Je=Ke*Ge(Ke);ke.y=Math.abs(Je)<Math.abs(Ke)?Je:Ke}}else if(M==="x"&&(Ce.includes("left")||Ce.includes("right")))if(Ce.includes("left")&&fe<0||Ce.includes("right")&&fe>0)ke.x=fe;else{const Je=fe*Ge(fe);ke.x=Math.abs(Je)<Math.abs(fe)?Je:fe}(Math.abs(ke.x)>0||Math.abs(ke.y)>0)&&ee(!0),(ye=ae.current)==null||ye.style.setProperty("--swipe-amount-x",`${ke.x}px`),($e=ae.current)==null||$e.style.setProperty("--swipe-amount-y",`${ke.y}px`)}},he&&!f.jsx&&se!=="loading"?Ie.createElement("button",{"aria-label":$,"data-disabled":We,"data-close-button":!0,onClick:We||!ue?()=>{}:()=>{He(),f.onDismiss==null||f.onDismiss.call(f,f)},className:ir(L==null?void 0:L.closeButton,f==null||(s=f.classNames)==null?void 0:s.closeButton)},(Xe=O==null?void 0:O.close)!=null?Xe:M9):null,(se||f.icon||f.promise)&&f.icon!==null&&((O==null?void 0:O[se])!==null||f.icon)?Ie.createElement("div",{"data-icon":"",className:ir(L==null?void 0:L.icon,f==null||(r=f.classNames)==null?void 0:r.icon)},se==="loading"?f.icon||_e():f.promise?_e():null,se!=="loading"?Re:null):null,Ie.createElement("div",{"data-content":"",className:ir(L==null?void 0:L.content,f==null||(o=f.classNames)==null?void 0:o.content)},Ie.createElement("div",{"data-title":"",className:ir(L==null?void 0:L.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?Ie.createElement("div",{"data-description":"",className:ir(T,xe,L==null?void 0:L.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),Ie.isValidElement(f.cancel)?f.cancel:f.cancel&&nu(f.cancel)?Ie.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||S,onClick:Ne=>{nu(f.cancel)&&ue&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,Ne),He())},className:ir(L==null?void 0:L.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,Ie.isValidElement(f.action)?f.action:f.action&&nu(f.action)?Ie.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||C,onClick:Ne=>{nu(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,Ne),!Ne.defaultPrevented&&He())},className:ir(L==null?void 0:L.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function wy(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function nO(n,e){const t={};return[n,e].forEach((s,r)=>{const o=r===1,i=o?"--mobile-offset":"--offset",l=o?Z9:G9;function c(u){["top","right","bottom","left"].forEach(d=>{t[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(u=>{s[u]===void 0?t[`${i}-${u}`]=l:t[`${i}-${u}`]=typeof s[u]=="number"?`${s[u]}px`:s[u]}):c(l)}),t}const sO=Ie.forwardRef(function(e,t){const{id:s,invert:r,position:o="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:g,visibleToasts:x=K9,toastOptions:b,dir:w=wy(),gap:v=X9,icons:k,customAriaLabel:j,containerAriaLabel:_="Notifications"}=e,[N,S]=Ie.useState([]),C=Ie.useMemo(()=>s?N.filter(U=>U.toasterId===s):N.filter(U=>!U.toasterId),[N,s]),A=Ie.useMemo(()=>Array.from(new Set([o].concat(C.filter(U=>U.position).map(U=>U.position)))),[C,o]),[T,I]=Ie.useState([]),[E,P]=Ie.useState(!1),[R,L]=Ie.useState(!1),[O,$]=Ie.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=Ie.useRef(null),D=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=Ie.useRef(null),z=Ie.useRef(!1),B=Ie.useCallback(U=>{S(W=>{var V;return(V=W.find(H=>H.id===U.id))!=null&&V.delete||es.dismiss(U.id),W.filter(({id:H})=>H!==U.id)})},[]);return Ie.useEffect(()=>es.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{S(W=>W.map(V=>V.id===U.id?{...V,delete:!0}:V))});return}setTimeout(()=>{JI.flushSync(()=>{S(W=>{const V=W.findIndex(H=>H.id===U.id);return V!==-1?[...W.slice(0,V),{...W[V],...U},...W.slice(V+1)]:[U,...W]})})})}),[]),Ie.useEffect(()=>{if(m!=="system"){$(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:W})=>{$(W?"dark":"light")})}catch{U.addListener(({matches:V})=>{try{$(V?"dark":"light")}catch(H){console.error(H)}})}},[m]),Ie.useEffect(()=>{N.length<=1&&P(!1)},[N]),Ie.useEffect(()=>{const U=W=>{var V;if(i.length>0&&i.every(Z=>W[Z]||W.code===Z)){var K;P(!0),(K=M.current)==null||K.focus()}W.code==="Escape"&&(document.activeElement===M.current||(V=M.current)!=null&&V.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),Ie.useEffect(()=>{if(M.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,z.current=!1)}},[M.current]),Ie.createElement("section",{ref:t,"aria-label":j??`${_} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},A.map((U,W)=>{var V;const[H,K]=U.split("-");return C.length?Ie.createElement("ol",{key:U,dir:w==="auto"?wy():w,tabIndex:-1,ref:M,className:u,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":H,"data-x-position":K,style:{"--front-toast-height":`${((V=T[0])==null?void 0:V.height)||0}px`,"--width":`${Y9}px`,"--gap":`${v}px`,...g,...nO(d,f)},onBlur:Z=>{z.current&&!Z.currentTarget.contains(Z.relatedTarget)&&(z.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||z.current||(z.current=!0,F.current=Z.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{R||P(!1)},onDragEnd:()=>P(!1),onPointerDown:Z=>{Z.target instanceof HTMLElement&&Z.target.dataset.dismissible==="false"||L(!0)},onPointerUp:()=>L(!1)},C.filter(Z=>!Z.position&&W===0||Z.position===U).map((Z,Y)=>{var X,ee;return Ie.createElement(tO,{key:Z.id,icons:k,index:Y,toast:Z,defaultRichColors:p,duration:(X=b==null?void 0:b.duration)!=null?X:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:r,visibleToasts:x,closeButton:(ee=b==null?void 0:b.closeButton)!=null?ee:c,interacting:R,position:U,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,closeButtonAriaLabel:b==null?void 0:b.closeButtonAriaLabel,removeToast:B,toasts:C.filter(Q=>Q.position==Z.position),heights:T.filter(Q=>Q.position==Z.position),setHeights:I,expandByDefault:l,gap:v,expanded:E,swipeDirections:e.swipeDirections})})):null}))}),rO=n=>{const e=q.c(6);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s,r;e[2]===Symbol.for("react.memo_cache_sentinel")?(s={success:a.jsx(eo,{className:"size-4"}),info:a.jsx(uf,{className:"size-4"}),warning:a.jsx(_r,{className:"size-4"}),error:a.jsx(v7,{className:"size-4"}),loading:a.jsx(vt,{className:"size-4 animate-spin"})},r={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},e[2]=s,e[3]=r):(s=e[2],r=e[3]);let o;return e[4]!==t?(o=a.jsx(sO,{className:"toaster group",icons:s,style:r,...t}),e[4]=t,e[5]=o):o=e[5],o},Pf=[{id:"layered",className:"dark theme-layered",name:"Layered Black",swatches:["#000000","#080808","#0f0f0f","#161616","#1d1d1d"]},{id:"layered-light",className:"theme-layered",name:"Layered Light",swatches:["#ffffff","#f7f7f7","#f0f0f0","#e9e9e9","#e2e2e2"]},{id:"dark",className:"dark",name:"Default Dark",swatches:["oklch(0.105 0 0)","oklch(0.13 0 0)","oklch(0.16 0 0)","oklch(0.2 0 0)","oklch(0.24 0 0)"]},{id:"oled",className:"dark theme-oled",name:"Deep OLED",swatches:["oklch(0 0 0)","oklch(0.08 0 0)","oklch(0.10 0 0)","oklch(0.10 0 0)","oklch(0.18 0 0)"]},{id:"light",className:"",name:"Light",swatches:["oklch(1 0 0)","oklch(1 0 0)","oklch(1 0 0)","oklch(0.96 0 0)","oklch(0.922 0 0)"]}],Q4="cogpit-theme",oO=[...new Set(Pf.flatMap(n=>n.className.split(" ").filter(Boolean)))];function iO(){var n;try{const e=localStorage.getItem(Q4);return((n=Pf.find(t=>t.id===e))==null?void 0:n.id)??"dark"}catch{return"dark"}}function aO(n){try{localStorage.setItem(Q4,n)}catch{}}function eN(n){return Pf.find(e=>e.id===n).className.split(" ").includes("dark")?"dark":"light"}function lO(n){var s;const e=Pf.find(r=>r.id===n),t=document.documentElement;t.classList.remove(...oO),t.classList.add(...e.className.split(" ").filter(Boolean)),t.style.colorScheme=eN(n),(s=document.querySelector('meta[name="theme-color"]'))==null||s.setAttribute("content",e.swatches[0])}function Sy(n){const e=q.c(18),{activeError:t,clearActiveError:s,modelFallbackNotice:r,dismissModelFallbackNotice:o,connectionLost:i,theme:l}=n;let c,u;e[0]!==t||e[1]!==s?(c=()=>{if(!t){Kn.dismiss("app-error");return}Kn.error(t,{id:"app-error",duration:8e3,onDismiss:s,onAutoClose:s})},u=[t,s],e[0]=t,e[1]=s,e[2]=c,e[3]=u):(c=e[2],u=e[3]),y.useEffect(c,u);let d,f;e[4]!==o||e[5]!==r?(d=()=>{if(!r){Kn.dismiss("model-fallback");return}Kn.warning(r,{id:"model-fallback",duration:1/0,onDismiss:o})},f=[o,r],e[4]=o,e[5]=r,e[6]=d,e[7]=f):(d=e[6],f=e[7]),y.useEffect(d,f);let m,p;e[8]!==i?(m=()=>{if(!i){Kn.dismiss("session-connection");return}Kn.warning("Connection lost",{id:"session-connection",description:"Reconnecting to the live session…",duration:1/0})},p=[i],e[8]=i,e[9]=m,e[10]=p):(m=e[9],p=e[10]),y.useEffect(m,p);const h=jR();let g,x;e[11]!==h?(g=()=>{h&&Kn.info("This server offers features this build of Cogpit doesn’t include.",{id:"edition-ui-unavailable"})},x=[h],e[11]=h,e[12]=g,e[13]=x):(g=e[12],x=e[13]),y.useEffect(g,x);let b;e[14]!==l?(b=eN(l),e[14]=l,e[15]=b):b=e[15];let w;return e[16]!==b?(w=a.jsx(rO,{theme:b,position:"bottom-center",closeButton:!0,visibleToasts:3}),e[16]=b,e[17]=w):w=e[17],w}const tN=300*1e3,nN=30*1e3;let Td=0,Qo=null,ky="",Ku=0;const Ur=()=>JSON.stringify([Jt(),Zn()]);function sN(n){return Array.isArray(n)&&n.length>0&&n.every(e=>e&&typeof e=="object"&&typeof e.value=="string"&&typeof e.label=="string")}async function cO(){const n=Ku,e=Ur();try{const t=await Ee("/api/models");if(!t.ok)throw new Error(`GET /api/models → ${t.status}`);const s=await t.json();if(n!==Ku||e!==Ur())return;for(const r of Hs){const o=s==null?void 0:s[r];sN(o)&&v8(r,o)}Td=Date.now()+tN}catch{n===Ku&&e===Ur()&&(Td=Date.now()+nN)}}function Tx(){if(ky!==Ur()&&(dO(),w8(),ky=Ur()),Qo)return Qo;if(Date.now()<Td)return Promise.resolve();const n=cO().finally(()=>{Qo===n&&(Qo=null)});return Qo=n,Qo}function uO(){const n=()=>{document.visibilityState==="visible"&&Tx()};return window.addEventListener("focus",n),window.addEventListener("cogpit-identity-changed",n),window.addEventListener("cogpit-device-scope-changed",n),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("focus",n),window.removeEventListener("cogpit-identity-changed",n),window.removeEventListener("cogpit-device-scope-changed",n),document.removeEventListener("visibilitychange",n)}}function dO(){Ku++,Td=0,Qo=null}function fO(n,e){const t=q.c(14),s=e===void 0?"default":e;let r;t[0]!==n||t[1]!==s?(r=JSON.stringify([Ur(),n,s]),t[0]=n,t[1]=s,t[2]=r):r=t[2];const o=r;let i;t[3]!==n||t[4]!==s||t[5]!==o?(i=pO(o,n,s),t[3]=n,t[4]=s,t[5]=o,t[6]=i):i=t[6];const l=i;let c;t[7]!==s?(c=()=>{if(s==="default")return Tx(),uO()},t[7]=s,t[8]=c):c=t[8];let u;t[9]!==n||t[10]!==s?(u=[n,s],t[9]=n,t[10]=s,t[11]=u):u=t[11],y.useEffect(c,u);let d;t[12]!==n?(d=()=>k8(n),t[12]=n,t[13]=d):d=t[13];const f=y.useSyncExternalStore(y8,d),m=y.useSyncExternalStore(l.subscribe,l.snapshot);return s==="default"?f:m}const jy=[{value:"",label:"Provider default"}],Ad=new Map;class mO{constructor(e,t,s,r){Ze(this,"options",jy);Ze(this,"listeners",new Set);Ze(this,"controller");Ze(this,"nextFetchAt",0);Ze(this,"snapshot",()=>this.options);Ze(this,"publish",()=>{for(const e of this.listeners)e()});Ze(this,"invalidate",()=>{var e;(e=this.controller)==null||e.abort(),this.options=jy,this.publish(),Ad.delete(this.key)});Ze(this,"refresh",()=>{if(this.instanceId==="default"||this.controller||Date.now()<this.nextFetchAt||this.scope!==Ur())return;const e=new AbortController;this.controller=e,Ee(`/api/models?instanceId=${encodeURIComponent(this.instanceId)}`,{signal:e.signal}).then(async t=>{if(!t.ok)throw new Error("Model catalog unavailable");const s=await t.json();e.signal.aborted||this.scope!==Ur()||(sN(s[this.agent])&&(this.options=s[this.agent],this.publish()),this.nextFetchAt=Date.now()+tN)}).catch(()=>{this.nextFetchAt=Date.now()+nN}).finally(()=>{this.controller===e&&(this.controller=void 0)})});Ze(this,"subscribe",e=>(this.listeners.add(e),this.listeners.size===1&&this.instanceId!=="default"&&(this.refresh(),window.addEventListener("focus",this.refresh),window.addEventListener("cogpit-identity-changed",this.invalidate),window.addEventListener("cogpit-device-scope-changed",this.invalidate)),()=>{var t;this.listeners.delete(e),this.listeners.size||((t=this.controller)==null||t.abort(),window.removeEventListener("focus",this.refresh),window.removeEventListener("cogpit-identity-changed",this.invalidate),window.removeEventListener("cogpit-device-scope-changed",this.invalidate),Ad.delete(this.key))}));this.key=e,this.agent=t,this.instanceId=s,this.scope=r}}function pO(n,e,t){let s=Ad.get(n);return s||(s=new mO(n,e,t,Ur()),Ad.set(n,s)),s}function rN(n,e,t){const s=q.c(26),o=fO(n,t===void 0?"default":t);let i;s[0]!==n||s[1]!==e||s[2]!==o?(i=f4(n,o,e),s[0]=n,s[1]=e,s[2]=o,s[3]=i):i=s[3];let l;s[4]!==e||s[5]!==o?(l=j8(o,e),s[4]=e,s[5]=o,s[6]=l):l=s[6];let c;s[7]!==n||s[8]!==e||s[9]!==o?(c=N8(n,o,e),s[7]=n,s[8]=e,s[9]=o,s[10]=c):c=s[10];let u;s[11]!==n||s[12]!==e||s[13]!==o?(u=C8(n,o,e),s[11]=n,s[12]=e,s[13]=o,s[14]=u):u=s[14];let d;s[15]!==n||s[16]!==e||s[17]!==o?(d=m=>E8(n,o,m,e),s[15]=n,s[16]=e,s[17]=o,s[18]=d):d=s[18];let f;return s[19]!==o||s[20]!==i||s[21]!==l||s[22]!==c||s[23]!==u||s[24]!==d?(f={options:o,effortOptions:i,fastTier:l,imageInput:c,autoPermissionMode:u,normalizeEffort:d},s[19]=o,s[20]=i,s[21]=l,s[22]=c,s[23]=u,s[24]=d,s[25]=f):f=s[25],f}function Ea(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(y7,{"data-slot":"popover",...t}),e[2]=t,e[3]=s):s=e[3],s}function Ta(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(w7,{"data-slot":"popover-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $f(n){const e=q.c(22);let t,s,r,o,i,l,c,u;e[0]!==n?({align:o,alignOffset:i,side:l,sideOffset:c,collisionPadding:u,collisionAvoidance:s,className:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c,e[8]=u):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7],u=e[8]);const d=o===void 0?"start":o,f=i===void 0?0:i,m=l===void 0?"bottom":l,p=c===void 0?6:c,h=u===void 0?8:u;let g;e[9]!==t?(g=G("z-50 max-h-(--available-height) origin-(--transform-origin) rounded-xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/10 outline-none duration-100 ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[9]=t,e[10]=g):g=e[10];let x;e[11]!==r||e[12]!==g?(x=a.jsx(S7,{"data-slot":"popover-content",className:g,...r}),e[11]=r,e[12]=g,e[13]=x):x=e[13];let b;return e[14]!==d||e[15]!==f||e[16]!==s||e[17]!==h||e[18]!==m||e[19]!==p||e[20]!==x?(b=a.jsx(k7,{children:a.jsx(j7,{className:"isolate z-50 outline-none",align:d,alignOffset:f,side:m,sideOffset:p,collisionPadding:h,collisionAvoidance:s,children:x})}),e[14]=d,e[15]=f,e[16]=s,e[17]=h,e[18]=m,e[19]=p,e[20]=x,e[21]=b):b=e[21],b}const hO=new Set(["mcp","server","servers","api","app","the","and"]),gO=/^([\w-]+\.[a-z]{2,})\s+(.+)$/i;function oN(n){const e=gO.exec(n.trim());return e?{short:e[2],namespace:e[1]}:{short:n.trim()}}function xO(n){const{short:e}=oN(n),t=e.split(/[^a-z0-9]+/i).filter(o=>o&&!hO.has(o.toLowerCase())),s=t.length>0?t:[e];return(s.length>=2?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Ax(n){return n?"bottom":"top"}function Ix(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("max-w-72 data-popup-open:bg-accent data-popup-open:text-accent-foreground",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Wt,{"data-icon":"inline-end",className:"opacity-60"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==r||e[9]!==o?(l=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:o,...r,children:[t,i]}),e[7]=t,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function Px(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({side:r,align:o,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"start":o;let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={side:"none",align:"shift",fallbackAxisSide:"none"},e[5]=l):l=e[5];let c;e[6]!==t?(c=G("flex flex-col overflow-hidden p-0",t),e[6]=t,e[7]=c):c=e[7];let u;return e[8]!==i||e[9]!==s||e[10]!==r||e[11]!==c?(u=a.jsx($f,{side:r,align:i,collisionAvoidance:l,className:c,...s}),e[8]=i,e[9]=s,e[10]=r,e[11]=c,e[12]=u):u=e[12],u}function Hi(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-2 pb-1 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function vg(n){const e=q.c(16);let t,s,r,o,i;e[0]!==n?({value:i,onValueChange:o,className:r,children:s,...t}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);let l;e[6]!==o?(l=d=>o(d),e[6]=o,e[7]=l):l=e[7];let c;e[8]!==r?(c=G("flex flex-col gap-px",r),e[8]=r,e[9]=c):c=e[9];let u;return e[10]!==t||e[11]!==s||e[12]!==l||e[13]!==c||e[14]!==i?(u=a.jsx(N7,{value:i,onValueChange:l,className:c,...t,children:s}),e[10]=t,e[11]=s,e[12]=l,e[13]=c,e[14]=i,e[15]=u):u=e[15],u}const bO="flex w-full cursor-pointer select-none items-center gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm outline-none transition-colors duration-100 hover:bg-accent/70 focus-visible:ring-2 focus-visible:ring-ring/40";function $x(n){const e=q.c(16),{value:t,title:s,description:r,icon:o,disabled:i}=n;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=G(bO,"group/option data-checked:bg-accent data-checked:text-accent-foreground data-disabled:cursor-not-allowed data-disabled:opacity-40 data-disabled:hover:bg-transparent"),e[0]=l):l=e[0];let c;e[1]!==o?(c=o&&a.jsx(o,{className:"size-4 shrink-0 text-muted-foreground group-data-checked/option:text-foreground"}),e[1]=o,e[2]=c):c=e[2];let u;e[3]!==s?(u=a.jsx("span",{className:"truncate leading-5 group-data-checked/option:font-medium",children:s}),e[3]=s,e[4]=u):u=e[4];let d;e[5]!==r?(d=r&&a.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",title:r,children:r}),e[5]=r,e[6]=d):d=e[6];let f;e[7]!==u||e[8]!==d?(f=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[u,d]}),e[7]=u,e[8]=d,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(C7,{keepMounted:!0,className:"shrink-0 text-foreground opacity-0 transition-opacity duration-100 data-checked:opacity-100",children:a.jsx(Ht,{className:"size-4"})}),e[10]=m):m=e[10];let p;return e[11]!==i||e[12]!==c||e[13]!==f||e[14]!==t?(p=a.jsxs(_7,{value:t,disabled:i,className:l,children:[c,f,m]}),e[11]=i,e[12]=c,e[13]=f,e[14]=t,e[15]=p):p=e[15],p}const vO=8;function yO(n){const e=q.c(89),{servers:t,selected:s,onToggle:r,onSetSelection:o,onRefresh:i,loading:l,onAuth:c,isNewSession:u}=n,[d,f]=y.useState(""),m=y.useId();let p,h,g,x,b,w,v,k,j,_,N,S,C,A,T,I,E;if(e[0]!==d||e[1]!==u||e[2]!==m||e[3]!==l||e[4]!==c||e[5]!==i||e[6]!==o||e[7]!==r||e[8]!==s||e[9]!==t){const O=t.filter(kO),$=t.filter(SO);let M;e[27]!==s?(M=new Set(s),e[27]=s,e[28]=M):M=e[28];const D=M;let F;e[29]!==D?(F=le=>D.has(le.name),e[29]=D,e[30]=F):F=e[30];const z=O.filter(F).length,B=l&&t.length===0,U=B?"MCPs":`MCPs ${z}/${O.length}`,W=d.trim().toLowerCase(),V=le=>!W||le.name.toLowerCase().includes(W),H=O.filter(V),K=$.filter(V);h=Ea,v=!1,e[31]===Symbol.for("react.memo_cache_sentinel")?(k=le=>{le||f("")},e[31]=k):k=e[31];let Z;e[32]!==U?(Z=a.jsx(Ix,{"aria-label":U}),e[32]=U,e[33]=Z):Z=e[33];let Y;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(vj,{"data-icon":"inline-start"}),e[34]=Y):Y=e[34];let X;e[35]!==U?(X=a.jsx("span",{className:"truncate",children:U}),e[35]=U,e[36]=X):X=e[36];let ee;e[37]!==B?(ee=B&&a.jsx(Fn,{className:"size-3 animate-spin","aria-hidden":!0}),e[37]=B,e[38]=ee):ee=e[38],e[39]!==Z||e[40]!==X||e[41]!==ee?(j=a.jsxs(Ta,{render:Z,children:[Y,X,ee]}),e[39]=Z,e[40]=X,e[41]=ee,e[42]=j):j=e[42],p=Px,e[43]!==u?(I=Ax(u),e[43]=u,e[44]=I):I=e[44],E="MCP servers",x="w-[23rem]";const Q=O.length>0&&a.jsxs("span",{"aria-hidden":!0,className:"ml-1.5 font-normal normal-case tracking-normal",children:[z," on"]});let ne;e[45]!==m||e[46]!==Q?(ne=a.jsxs(Hi,{id:m,className:"pt-1",children:["MCP servers",Q]}),e[45]=m,e[46]=Q,e[47]=ne):ne=e[47];const te=o&&O.length>1&&a.jsxs(a.Fragment,{children:[a.jsx(Ny,{label:"Turn every server on",disabled:z===O.length,onClick:()=>o(O.map(wO)),children:"All"}),a.jsx(Ny,{label:"Turn every server off",disabled:z===0,onClick:()=>o([]),children:"None"})]}),re=l&&"animate-spin";let oe;e[48]!==re?(oe=G(re),e[48]=re,e[49]=oe):oe=e[49];let ie;e[50]!==oe?(ie=a.jsx(Fn,{className:oe}),e[50]=oe,e[51]=ie):ie=e[51];let ae;e[52]!==i||e[53]!==ie?(ae=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:i,"aria-label":"Refresh status",title:"Refresh status",className:"text-muted-foreground",children:ie}),e[52]=i,e[53]=ie,e[54]=ae):ae=e[54];let de;e[55]!==te||e[56]!==ae?(de=a.jsxs("div",{className:"flex items-center gap-0.5",children:[te,ae]}),e[55]=te,e[56]=ae,e[57]=de):de=e[57],e[58]!==ne||e[59]!==de?(b=a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-1.5 pt-1.5",children:[ne,de]}),e[58]=ne,e[59]=de,e[60]=b):b=e[60],e[61]!==d||e[62]!==t.length?(w=t.length>vO&&a.jsx("div",{className:"shrink-0 px-1.5 pt-1",children:a.jsx("input",{type:"search",value:d,onChange:le=>f(le.target.value),placeholder:"Filter servers…","aria-label":"Filter servers",className:"h-7 w-full rounded-md bg-muted/60 px-2 text-xs text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring/40 [&::-webkit-search-cancel-button]:hidden"})}),e[61]=d,e[62]=t.length,e[63]=w):w=e[63],g="group",_=m,N="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1.5",e[64]!==l||e[65]!==t.length?(S=t.length===0&&a.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:l?"Loading…":"No MCP servers configured"}),e[64]=l,e[65]=t.length,e[66]=S):S=e[66],C=t.length>0&&H.length===0&&K.length===0&&a.jsx("p",{className:"px-0.5 py-1 text-xs text-muted-foreground",children:"No servers match."}),A=H.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-1",children:H.map(le=>a.jsx(Cy,{server:le,on:D.has(le.name),onClick:()=>r(le.name)},le.name))}),T=K.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(Hi,{className:"px-0.5 pt-2 text-warning/80",children:"Needs sign-in"}),a.jsx("div",{className:"grid grid-cols-2 gap-1",children:K.map(le=>a.jsx(Cy,{server:le,onClick:()=>c(le.name)},le.name))})]}),e[0]=d,e[1]=u,e[2]=m,e[3]=l,e[4]=c,e[5]=i,e[6]=o,e[7]=r,e[8]=s,e[9]=t,e[10]=p,e[11]=h,e[12]=g,e[13]=x,e[14]=b,e[15]=w,e[16]=v,e[17]=k,e[18]=j,e[19]=_,e[20]=N,e[21]=S,e[22]=C,e[23]=A,e[24]=T,e[25]=I,e[26]=E}else p=e[10],h=e[11],g=e[12],x=e[13],b=e[14],w=e[15],v=e[16],k=e[17],j=e[18],_=e[19],N=e[20],S=e[21],C=e[22],A=e[23],T=e[24],I=e[25],E=e[26];let P;e[67]!==g||e[68]!==_||e[69]!==N||e[70]!==S||e[71]!==C||e[72]!==A||e[73]!==T?(P=a.jsxs("div",{role:g,"aria-labelledby":_,className:N,children:[S,C,A,T]}),e[67]=g,e[68]=_,e[69]=N,e[70]=S,e[71]=C,e[72]=A,e[73]=T,e[74]=P):P=e[74];let R;e[75]!==p||e[76]!==x||e[77]!==b||e[78]!==w||e[79]!==P||e[80]!==I||e[81]!==E?(R=a.jsxs(p,{side:I,"aria-label":E,className:x,children:[b,w,P]}),e[75]=p,e[76]=x,e[77]=b,e[78]=w,e[79]=P,e[80]=I,e[81]=E,e[82]=R):R=e[82];let L;return e[83]!==h||e[84]!==v||e[85]!==k||e[86]!==j||e[87]!==R?(L=a.jsxs(h,{modal:v,onOpenChange:k,children:[j,R]}),e[83]=h,e[84]=v,e[85]=k,e[86]=j,e[87]=R,e[88]=L):L=e[88],L}function wO(n){return n.name}function SO(n){return n.status!=="connected"}function kO(n){return n.status==="connected"}function Ny(n){const e=q.c(5),{label:t,disabled:s,onClick:r,children:o}=n;let i;return e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r?(i=a.jsx(J,{type:"button",variant:"ghost",size:"xs","aria-label":t,title:t,disabled:s,onClick:r,className:"h-6 px-1.5 text-[11px] text-muted-foreground",children:o}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function Cy(n){const e=q.c(34),{server:t,on:s,onClick:r}=n;let o;e[0]!==t.name?(o=oN(t.name),e[0]=t.name,e[1]=o):o=e[1];const{short:i,namespace:l}=o,c=s===void 0,u=c?void 0:"checkbox",d=c?void 0:s,f=c?`${t.name}, needs sign-in`:t.name,m=c?`${t.name} · Sign in to connect`:t.name,p=c&&"bg-warning/5 ring-warning/25 hover:bg-warning/10",h=s===!0&&"bg-accent text-accent-foreground ring-foreground/10",g=s===!1&&"text-muted-foreground ring-transparent hover:bg-accent/60 hover:text-foreground";let x;e[2]!==p||e[3]!==h||e[4]!==g?(x=G("flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm outline-none ring-1 ring-inset transition-[background-color,box-shadow,color] duration-100 focus-visible:ring-2 focus-visible:ring-ring/40",p,h,g),e[2]=p,e[3]=h,e[4]=g,e[5]=x):x=e[5];const b=c&&"bg-warning/15 text-warning",w=s===!0&&"bg-primary text-primary-foreground",v=s===!1&&"bg-muted text-muted-foreground";let k;e[6]!==b||e[7]!==w||e[8]!==v?(k=G("flex size-6 shrink-0 items-center justify-center rounded-md text-[10px] font-semibold tracking-wide transition-colors duration-100",b,w,v),e[6]=b,e[7]=w,e[8]=v,e[9]=k):k=e[9];let j;e[10]!==t.name?(j=xO(t.name),e[10]=t.name,e[11]=j):j=e[11];let _;e[12]!==k||e[13]!==j?(_=a.jsx("span",{"aria-hidden":!0,className:k,children:j}),e[12]=k,e[13]=j,e[14]=_):_=e[14];let N;e[15]!==i?(N=a.jsx("span",{className:"truncate leading-4",children:i}),e[15]=i,e[16]=N):N=e[16];let S;e[17]!==l?(S=l&&a.jsx("span",{className:"truncate text-[10px] leading-3 text-muted-foreground",children:l}),e[17]=l,e[18]=S):S=e[18];let C;e[19]!==N||e[20]!==S?(C=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[N,S]}),e[19]=N,e[20]=S,e[21]=C):C=e[21];let A;e[22]!==c?(A=c&&a.jsx(E7,{className:"size-3.5 shrink-0 text-warning","aria-hidden":!0}),e[22]=c,e[23]=A):A=e[23];let T;return e[24]!==r||e[25]!==_||e[26]!==C||e[27]!==A||e[28]!==u||e[29]!==d||e[30]!==f||e[31]!==m||e[32]!==x?(T=a.jsxs("button",{type:"button",role:u,"aria-checked":d,"aria-label":f,title:m,onClick:r,className:x,children:[_,C,A]}),e[24]=r,e[25]=_,e[26]=C,e[27]=A,e[28]=u,e[29]=d,e[30]=f,e[31]=m,e[32]=x,e[33]=T):T=e[33],T}const Gu=[27e4,5e5,1e6];function _y(n){return Gu.includes(n)?Ct(n).replace(/\.0(?=[kM]$)/,""):n.toLocaleString("en-US")}function iN(n){const e=q.c(12),{value:t,onChange:s}=n;let r;e[0]!==t?(r=t===null?"Default":_y(t),e[0]=t,e[1]=r):r=e[1];const o=r,i=Gu[(Gu.indexOf(t??0)+1)%Gu.length],l=`Context window: ${o}`;let c;e[2]!==i?(c=_y(i),e[2]=i,e[3]=c):c=e[3];const u=`Context window: ${o}. Click to use ${c} next turn. Models with long-context pricing charge higher rates above 272k input tokens. This is not a hard billing cap.`;let d;e[4]!==i||e[5]!==s?(d=()=>s(i),e[4]=i,e[5]=s,e[6]=d):d=e[6];let f;return e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==d?(f=a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"h-6 shrink-0 tabular-nums","aria-label":l,title:u,onClick:d,children:o}),e[7]=o,e[8]=l,e[9]=u,e[10]=d,e[11]=f):f=e[11],f}const aN=Qr("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out hover:bg-muted hover:text-foreground active:scale-[0.96] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-pressed:bg-muted motion-reduce:transition-none motion-reduce:active:scale-100 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-muted"},size:{default:"h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",sm:"h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"}},defaultVariants:{variant:"default",size:"default"}});function jO(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"default":r,l=o===void 0?"default":o;let c;e[5]!==t||e[6]!==l||e[7]!==i?(c=G(aN({variant:i,size:l,className:t})),e[5]=t,e[6]=l,e[7]=i,e[8]=c):c=e[8];let u;return e[9]!==s||e[10]!==c?(u=a.jsx(yj,{"data-slot":"toggle",className:c,...s}),e[9]=s,e[10]=c,e[11]=u):u=e[11],u}function NO(n){const e=q.c(30),{options:t,value:s,onChange:r,labelId:o}=n,i=t.length-1;let l;if(e[0]!==t||e[1]!==s){let x;e[3]!==s?(x=b=>b.value===s,e[3]=s,e[4]=x):x=e[4],l=t.findIndex(x),e[0]=t,e[1]=s,e[2]=l}else l=e[2];const c=Math.max(0,l);let u;e[5]!==r||e[6]!==t||e[7]!==s?(u=x=>{const b=t[x];b&&b.value!==s&&r(b.value)},e[5]=r,e[6]=t,e[7]=s,e[8]=u):u=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(T7,{className:"rounded-full bg-primary"}),e[9]=d):d=e[9];let f;if(e[10]!==c||e[11]!==i||e[12]!==t){let x;e[14]!==c||e[15]!==i?(x=(b,w)=>a.jsx("span",{"aria-hidden":!0,className:G("pointer-events-none absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full transition-colors duration-150",w<=c?"bg-primary":"bg-muted-foreground/40"),style:{left:i===0?"50%":`${w/i*100}%`}},b.value),e[14]=c,e[15]=i,e[16]=x):x=e[16],f=t.map(x),e[10]=c,e[11]=i,e[12]=t,e[13]=f}else f=e[13];let m;e[17]!==t?(m=(x,b)=>{var w;return((w=t[b])==null?void 0:w.label)??""},e[17]=t,e[18]=m):m=e[18];let p;e[19]!==o||e[20]!==m?(p=a.jsx(A7,{"aria-labelledby":o,getAriaValueText:m,className:"size-3.5 rounded-full bg-primary shadow-[0_0_0_3px_var(--popover)] outline-none transition-transform duration-100 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/50 has-[:focus-visible]:ring-offset-2 has-[:focus-visible]:ring-offset-popover data-dragging:scale-125 motion-reduce:transition-none"}),e[19]=o,e[20]=m,e[21]=p):p=e[21];let h;e[22]!==f||e[23]!==p?(h=a.jsx(I7,{className:"flex h-6 w-full touch-none select-none items-center px-1.5",children:a.jsxs(P7,{className:"relative h-1 w-full rounded-full bg-muted-foreground/20",children:[d,f,p]})}),e[22]=f,e[23]=p,e[24]=h):h=e[24];let g;return e[25]!==c||e[26]!==i||e[27]!==u||e[28]!==h?(g=a.jsx($7,{value:c,min:0,max:i,step:1,onValueChange:u,className:"w-full",children:h}),e[25]=c,e[26]=i,e[27]=u,e[28]=h,e[29]=g):g=e[29],g}function lN(n,e){const t=y.forwardRef(function(r,o){const i=q.c(4);let l;i[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx("path",{d:e}),i[0]=l):l=i[0];let c;return i[1]!==r||i[2]!==o?(c=a.jsx("svg",{ref:o,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:24,height:24,fill:"currentColor","aria-hidden":!0,...r,children:l}),i[1]=r,i[2]=o,i[3]=c):c=i[3],c});return t.displayName=n,t}const CO=lN("AnthropicIcon","M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.1256 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"),_O=lN("OpenAIIcon","M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"),cN={acp:_o,claude:CO,codex:_O,copilot:wj},Rx={acp:"ACP",claude:"Claude",codex:"Codex",copilot:"Copilot"},EO={acp:"ACP agent",claude:"Claude",codex:"Codex",copilot:"GitHub Copilot"},TO={acp:"ACP",claude:null,codex:"Codex",copilot:"Copilot"},AO={acp:{letter:"A",label:"Loaded by ACP agent"},claude:{letter:"C",label:"Loaded by Claude Code"},codex:{letter:"X",label:"Loaded by Codex CLI"},copilot:{letter:"G",label:"Loaded by GitHub Copilot CLI"}},IO={acp:"var(--chart-4)",claude:"var(--chart-1)",codex:"var(--chart-2)",copilot:"var(--chart-3)"},PO={acp:"Cancel ACP turn",claude:"Interrupt agent",codex:"Stop active turn",copilot:"Stop Copilot turn"},$O={acp:[{value:"default",label:"Ask",description:"Use the provider’s permission requests"}],claude:[{value:"default",label:"Ask",description:"Ask before sensitive actions"},{value:"plan",label:"Plan",description:"Read and plan without changing files"},{value:"acceptEdits",label:"Accept Edits",description:"Allow file edits; ask for other actions"},{value:"auto",label:"Auto",description:"Run autonomously with classifier safeguards"},{value:"dontAsk",label:"Don't Ask",description:"Deny actions that need approval"},{value:"bypassPermissions",label:"Full access",description:"Skip permission checks"}],codex:[{value:"default",label:"Workspace",description:"Write inside the project sandbox"},{value:"plan",label:"Read only",description:"Inspect and plan without writing"},{value:"auto",label:"Auto review",description:"Review approval requests automatically, with the workspace sandbox"},{value:"bypassPermissions",label:"Full access",description:"No sandbox or approval checks"}],copilot:[{value:"default",label:"Ask",description:"Ask before running tools or changing files"},{value:"plan",label:"Plan",description:"Explore and plan without changing project files"},{value:"auto",label:"Autopilot",description:"Implement autonomously until the task is complete"},{value:"bypassPermissions",label:"Full access",description:"Allow tools, paths, and URLs without asking"}]};function uN(n){return $O[n]}function RO(n){return cN[n]}function Rf(n){return Rx[n]}function OO(n){return EO[n]}function LO(n){return TO[n]}function Z0e(n){return AO[n]}function MO(n){return PO[n]}function zO(n){return IO[n]}const Ey=hs(null).kind,dN=[Ey,...Hs.filter(n=>n!==Ey)];function DO(n){return`This ${Rx[n]} session is controlled by another process. Cogpit can only view it.`}const yg=dN.map(n=>({value:n,label:Rx[n],Icon:cN[n]}));function FO(n,e){const t=e==null?void 0:e.filter(s=>s.value!=="");return(t==null?void 0:t.find(s=>s.value===n))??(t==null?void 0:t.find(s=>s.resolvedModel===n))}function UO(n){var t;const e=(t=n.find(s=>s.value===""))==null?void 0:t.resolvedModel;return e?Ox(e,n):"Default"}function Ox(n,e){var t;return((t=FO(n,e))==null?void 0:t.label)??xi(n)}function BO(n){var _e;const e=q.c(111),{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,isNewSession:w}=n,v=h===void 0?!1:h,k=x===void 0?!1:x;let j;e[0]!==t?(j=fn(t),e[0]=t,e[1]=j):j=e[1];const _=j;let N;e[2]!==t?(N=yg.find(Re=>Re.value===t),e[2]=t,e[3]=N):N=e[3];const S=N,C=S==null?void 0:S.Icon,A=(S==null?void 0:S.label)??t;let T;e[4]!==i||e[5]!==o||e[6]!==r?(T=((_e=i.find(Re=>Re.value===r))==null?void 0:_e.label)??o,e[4]=i,e[5]=o,e[6]=r,e[7]=T):T=e[7];const I=T;let E;if(e[8]!==u||e[9]!==c){let Re;e[11]!==c?(Re=tt=>tt.value===c,e[11]=c,e[12]=Re):Re=e[12],E=u.find(Re),e[8]=u,e[9]=c,e[10]=E}else E=e[10];const P=E,R=!s,L=_.reasoningEffort,O=_.configurableContextWindow&&!!m,$=_.fastTier,M=_.ultracode,D=!!p&&!!g,F=!!b,z=v&&D,B=k&&F,U=P==null?void 0:P.description,W=P==null?void 0:P.label;let V;e[13]!==I||e[14]!==A||e[15]!==W?(V=[A,I,W].filter(Boolean),e[13]=I,e[14]=A,e[15]=W,e[16]=V):V=e[16];const H=V.join(" · "),K=z?"Fast mode on":null,Z=B?"Ultracode on":null;let Y;e[17]!==Z||e[18]!==K?(Y=[K,Z].filter(Boolean),e[17]=Z,e[18]=K,e[19]=Y):Y=e[19];const X=Y.join(", "),ee=y.useId(),Q=y.useId(),ne=y.useId(),te=X?`${H} (${X})`:H,re=X?`${H} · ${X}`:void 0;let oe;e[20]!==te||e[21]!==re?(oe=a.jsx(Ix,{"aria-label":te,title:re}),e[20]=te,e[21]=re,e[22]=oe):oe=e[22];let ie;e[23]!==C?(ie=C&&a.jsx(C,{"data-icon":"inline-start"}),e[23]=C,e[24]=ie):ie=e[24];let ae;e[25]!==I?(ae=a.jsx("span",{className:"truncate",children:I}),e[25]=I,e[26]=ae):ae=e[26];let de;e[27]!==P?(de=P&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-muted-foreground/60","aria-hidden":!0,children:"·"}),a.jsx("span",{className:"shrink-0 text-muted-foreground",children:P.label})]}),e[27]=P,e[28]=de):de=e[28];let le;e[29]!==ae||e[30]!==de?(le=a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[ae,de]}),e[29]=ae,e[30]=de,e[31]=le):le=e[31];let se;e[32]!==z?(se=z&&a.jsx(md,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[32]=z,e[33]=se):se=e[33];let me;e[34]!==B?(me=B&&a.jsx(Ll,{className:"size-3 shrink-0 fill-current","aria-hidden":!0}),e[34]=B,e[35]=me):me=e[35];let ue;e[36]!==oe||e[37]!==ie||e[38]!==le||e[39]!==se||e[40]!==me?(ue=a.jsxs(Ta,{render:oe,children:[ie,le,se,me]}),e[36]=oe,e[37]=ie,e[38]=le,e[39]=se,e[40]=me,e[41]=ue):ue=e[41];let ce;e[42]!==w?(ce=Ax(w),e[42]=w,e[43]=ce):ce=e[43];let xe;e[44]!==ee?(xe=a.jsx(Hi,{id:ee,children:"Provider"}),e[44]=ee,e[45]=xe):xe=e[45];let pe;e[46]!==s?(pe=Re=>s==null?void 0:s(Re),e[46]=s,e[47]=pe):pe=e[47];let he;e[48]!==t||e[49]!==R?(he=yg.map(Re=>a.jsx($x,{value:Re.value,title:Re.label,icon:Re.Icon,disabled:R&&Re.value!==t},Re.value)),e[48]=t,e[49]=R,e[50]=he):he=e[50];let be;e[51]!==t||e[52]!==ee||e[53]!==pe||e[54]!==he?(be=a.jsx(vg,{value:t,onValueChange:pe,"aria-labelledby":ee,children:he}),e[51]=t,e[52]=ee,e[53]=pe,e[54]=he,e[55]=be):be=e[55];let we;e[56]!==w||e[57]!==R?(we=R&&!w&&a.jsx("p",{className:"mt-auto px-2 pb-1 pt-3 text-[11px] leading-4 text-muted-foreground",children:"Fixed for this session. Start a new one to switch."}),e[56]=w,e[57]=R,e[58]=we):we=e[58];let ve;e[59]!==xe||e[60]!==be||e[61]!==we?(ve=a.jsxs("div",{className:"flex min-h-0 flex-col overflow-y-auto border-r bg-muted/30 p-1.5",children:[xe,be,we]}),e[59]=xe,e[60]=be,e[61]=we,e[62]=ve):ve=e[62];let Se;e[63]!==Q?(Se=a.jsx(Hi,{id:Q,children:"Model"}),e[63]=Q,e[64]=Se):Se=e[64];let Te;e[65]!==f||e[66]!==D||e[67]!==z||e[68]!==(p==null?void 0:p.description)||e[69]!==I||e[70]!==m||e[71]!==g||e[72]!==b||e[73]!==O||e[74]!==$||e[75]!==M||e[76]!==F||e[77]!==B?(Te=(O||$||M)&&a.jsxs("div",{className:"flex items-center gap-1",children:[O&&a.jsx(iN,{value:f??null,onChange:m}),$&&a.jsx(Ty,{label:"Fast mode",pressed:z,onPressedChange:Re=>g==null?void 0:g(Re),disabled:!D,title:D?`Fast mode · ${(p==null?void 0:p.description)??"Lower latency with increased usage"}`:`Fast mode isn't offered for ${I}`,children:a.jsx(md,{className:G(z&&"fill-current")})}),M&&a.jsxs(Ty,{label:"Ultracode",pressed:B,onPressedChange:Re=>b==null?void 0:b(Re),disabled:!F,title:F?"Ultracode · Standing multi-agent orchestration at any effort":`Ultracode isn't available for ${I}`,children:[a.jsx(Ll,{className:G(B&&"fill-current")}),"Ultracode"]})]}),e[65]=f,e[66]=D,e[67]=z,e[68]=p==null?void 0:p.description,e[69]=I,e[70]=m,e[71]=g,e[72]=b,e[73]=O,e[74]=$,e[75]=M,e[76]=F,e[77]=B,e[78]=Te):Te=e[78];let Ae;e[79]!==Se||e[80]!==Te?(Ae=a.jsxs("div",{className:"flex items-center justify-between gap-2 pr-0.5",children:[Se,Te]}),e[79]=Se,e[80]=Te,e[81]=Ae):Ae=e[81];let ze;e[82]!==i?(ze=i.map(WO),e[82]=i,e[83]=ze):ze=e[83];let De;e[84]!==Q||e[85]!==l||e[86]!==r||e[87]!==ze?(De=a.jsx(vg,{value:r,onValueChange:l,"aria-labelledby":Q,className:"max-h-56 min-h-0 flex-1 overflow-y-auto",children:ze}),e[84]=Q,e[85]=l,e[86]=r,e[87]=ze,e[88]=De):De=e[88];let Le;e[89]!==Ae||e[90]!==De?(Le=a.jsxs("div",{className:"flex min-h-0 flex-col p-1.5",children:[Ae,De]}),e[89]=Ae,e[90]=De,e[91]=Le):Le=e[91];let Ce;e[92]!==ve||e[93]!==Le?(Ce=a.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[10.5rem_minmax(0,1fr)] overflow-hidden",children:[ve,Le]}),e[92]=ve,e[93]=Le,e[94]=Ce):Ce=e[94];let Be;e[95]!==U||e[96]!==ne||e[97]!==u||e[98]!==I||e[99]!==d||e[100]!==c||e[101]!==P||e[102]!==L?(Be=L&&a.jsxs("div",{className:"shrink-0 border-t px-2 pb-1.5 pt-2",children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-1.5",children:[a.jsxs(Hi,{id:ne,className:"flex items-baseline gap-1.5 p-0",children:["Reasoning",P&&a.jsx("span",{className:"text-xs font-medium normal-case tracking-normal text-foreground motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200",children:P.label},P.value)]}),U&&a.jsx("span",{className:"truncate text-[11px] leading-4 text-muted-foreground",children:U})]}),u.length>0?a.jsx(NO,{options:u,value:c,onChange:d,labelId:ne}):a.jsxs("p",{className:"px-1.5 pb-1 text-xs leading-5 text-muted-foreground",children:["Not adjustable for ",I,"."]})]}),e[95]=U,e[96]=ne,e[97]=u,e[98]=I,e[99]=d,e[100]=c,e[101]=P,e[102]=L,e[103]=Be):Be=e[103];let We;e[104]!==ce||e[105]!==Ce||e[106]!==Be?(We=a.jsxs(Px,{side:ce,align:"end","aria-label":"Model settings",className:"w-[34rem] max-w-[calc(100vw-1.5rem)]",children:[Ce,Be]}),e[104]=ce,e[105]=Ce,e[106]=Be,e[107]=We):We=e[107];let He;return e[108]!==ue||e[109]!==We?(He=a.jsxs(Ea,{modal:!1,onOpenChange:qO,children:[ue,We]}),e[108]=ue,e[109]=We,e[110]=He):He=e[110],He}function WO(n){return a.jsx($x,{value:n.value,title:n.menuLabel??n.label,description:n.description},n.value)}function qO(n){n&&Tx()}function Ty(n){const e=q.c(7),{label:t,pressed:s,onPressedChange:r,disabled:o,title:i,children:l}=n;let c;return e[0]!==l||e[1]!==o||e[2]!==t||e[3]!==r||e[4]!==s||e[5]!==i?(c=a.jsx(jO,{variant:"outline",size:"sm",pressed:s,onPressedChange:r,disabled:o,"aria-label":t,title:i,className:"h-6 gap-1 px-1.5 text-xs text-muted-foreground data-pressed:bg-primary data-pressed:text-primary-foreground data-pressed:hover:bg-primary/90 [&_svg:not([class*='size-'])]:size-3.5",children:l}),e[0]=l,e[1]=o,e[2]=t,e[3]=r,e[4]=s,e[5]=i,e[6]=c):c=e[6],c}function fN(n,e){return uN(n).filter(t=>t.value!=="auto"||e)}function VO(n){const e=q.c(22),{agentKind:t,mode:s,onChange:r,autoAvailable:o,isNewSession:i}=n,l=o===void 0?!1:o,[c,u]=y.useState(!1),d=fN(t,l),f=d.find(I=>I.value===s)??d[0],m=y.useId(),p=`Permissions: ${f.label}`;let h;e[0]!==p?(h=a.jsx(Ix,{"aria-label":p}),e[0]=p,e[1]=h):h=e[1];let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Sj,{"data-icon":"inline-start"}),e[2]=g):g=e[2];const x=Px;let b;e[3]!==i?(b=Ax(i),e[3]=i,e[4]=b):b=e[4];const w="Permissions",v="w-80",k="p-1.5";let j;e[5]!==m?(j=a.jsx(Hi,{id:m,children:"Permissions"}),e[5]=m,e[6]=j):j=e[6];const _=vg;let N;e[7]!==r?(N=I=>{r(I),u(!1)},e[7]=r,e[8]=N):N=e[8];const S=d.map(HO);let C;e[9]!==_||e[10]!==m||e[11]!==s||e[12]!==N||e[13]!==S?(C=a.jsx(_,{value:s,onValueChange:N,"aria-labelledby":m,children:S}),e[9]=_,e[10]=m,e[11]=s,e[12]=N,e[13]=S,e[14]=C):C=e[14];let A;e[15]!==C||e[16]!==j?(A=a.jsxs("div",{className:k,children:[j,C]}),e[15]=C,e[16]=j,e[17]=A):A=e[17];let T;return e[18]!==x||e[19]!==A||e[20]!==b?(T=a.jsx(x,{side:b,"aria-label":w,className:v,children:A}),e[18]=x,e[19]=A,e[20]=b,e[21]=T):T=e[21],a.jsxs(Ea,{modal:!1,open:c,onOpenChange:u,children:[a.jsxs(Ta,{render:h,children:[g,a.jsx("span",{className:"truncate",children:f.label})]}),T]})}function HO(n){return a.jsx($x,{value:n.value,title:n.label,description:n.description},n.value)}function KO(n){const e=q.c(56),{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:g,isNewSession:x,worktreeEnabled:b,onWorktreeEnabledChange:w,ultracodeEnabled:v,onUltracodeEnabledChange:k,autoModeAvailable:j,permissionMode:_,onPermissionModeChange:N,mcpServers:S,selectedMcpServers:C,onToggleMcpServer:A,onSetMcpServers:T,onRefreshMcpServers:I,mcpLoading:E,onMcpAuth:P,changeAndApply:R,trailingExtra:L}=n;let O;e[0]!==t?(O=fn(t),e[0]=t,e[1]=O):O=e[1];const{worktrees:$}=O;let M;e[2]!==t||e[3]!==j||e[4]!==R||e[5]!==x||e[6]!==N||e[7]!==_?(M=N&&_&&a.jsx(VO,{agentKind:t,mode:_,onChange:H=>R(()=>N(H)),autoAvailable:j,isNewSession:x}),e[2]=t,e[3]=j,e[4]=R,e[5]=x,e[6]=N,e[7]=_,e[8]=M):M=e[8];let D;e[9]!==x||e[10]!==w||e[11]!==$||e[12]!==b?(D=$&&x&&w&&a.jsxs(J,{type:"button",variant:b?"secondary":"ghost",size:"xs","aria-pressed":!!b,onClick:()=>w(!b),children:[a.jsx(Wr,{"data-icon":"inline-start"}),"Worktree"]}),e[9]=x,e[10]=w,e[11]=$,e[12]=b,e[13]=D):D=e[13];let F;e[14]!==R||e[15]!==x||e[16]!==E||e[17]!==S||e[18]!==P||e[19]!==I||e[20]!==T||e[21]!==A||e[22]!==C?(F=A&&I&&P&&(E||S&&S.length>0)&&a.jsx(yO,{servers:S??[],selected:C??[],onToggle:H=>R(()=>A(H)),onSetSelection:T?H=>R(()=>T(H)):void 0,onRefresh:I,loading:E??!1,onAuth:P,isNewSession:x}),e[14]=R,e[15]=x,e[16]=E,e[17]=S,e[18]=P,e[19]=I,e[20]=T,e[21]=A,e[22]=C,e[23]=F):F=e[23];let z;e[24]!==M||e[25]!==D||e[26]!==F||e[27]!==L?(z=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[M,D,F,L]}),e[24]=M,e[25]=D,e[26]=F,e[27]=L,e[28]=z):z=e[28];let B;e[29]!==R||e[30]!==g?(B=g?H=>R(()=>g(H)):void 0,e[29]=R,e[30]=g,e[31]=B):B=e[31];let U;e[32]!==R||e[33]!==k?(U=k?H=>R(()=>k(H)):void 0,e[32]=R,e[33]=k,e[34]=U):U=e[34];let W;e[35]!==t||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==p||e[40]!==x||e[41]!==i||e[42]!==s||e[43]!==m||e[44]!==d||e[45]!==l||e[46]!==o||e[47]!==c||e[48]!==r||e[49]!==B||e[50]!==U||e[51]!==v?(W=a.jsx(BO,{agentKind:t,onAgentKindChange:s,selectedModel:r,resolvedDefaultName:o,modelOptions:i,onModelChange:l,selectedEffort:c,effortOptions:u,onEffortChange:d,contextWindowTokens:f,onContextWindowTokensChange:m,fastTier:p,fastModeEnabled:h,onFastModeEnabledChange:B,ultracodeEnabled:v,onUltracodeEnabledChange:U,isNewSession:x}),e[35]=t,e[36]=f,e[37]=u,e[38]=h,e[39]=p,e[40]=x,e[41]=i,e[42]=s,e[43]=m,e[44]=d,e[45]=l,e[46]=o,e[47]=c,e[48]=r,e[49]=B,e[50]=U,e[51]=v,e[52]=W):W=e[52];let V;return e[53]!==z||e[54]!==W?(V=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",role:"group","aria-label":"Session settings",children:[z,W]}),e[53]=z,e[54]=W,e[55]=V):V=e[55],V}function Qt(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,orientation:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"horizontal":r;let i;e[4]!==t?(i=G("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==s||e[8]!==i?(l=a.jsx(D1,{"data-slot":"separator",orientation:o,className:i,...s}),e[6]=o,e[7]=s,e[8]=i,e[9]=l):l=e[9],l}function GO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(gj,{"data-slot":"sheet",...t}),e[2]=t,e[3]=s):s=e[3],s}function ZO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(R7,{"data-slot":"sheet-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function YO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(uc,{"data-slot":"sheet-close",...t}),e[2]=t,e[3]=s):s=e[3],s}function XO(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(L1,{"data-slot":"sheet-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function JO(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 z-50 bg-black/55 duration-200 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(M1,{"data-slot":"sheet-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function QO(n){const e=q.c(17);let t,s,r,o,i;e[0]!==n?({className:s,children:t,side:o,showCloseButton:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"right":o,c=i===void 0?!0:i;let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(JO,{}),e[6]=u):u=e[6];let d;e[7]!==s?(d=G("fixed z-50 flex flex-col border-border bg-popover text-popover-foreground shadow-lg duration-200 ease-out data-closed:duration-150 data-closed:ease-in motion-reduce:animate-none","data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-full data-[side=right]:max-w-[560px] data-[side=right]:border-l","data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-full data-[side=left]:max-w-[560px] data-[side=left]:border-r","data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t","data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b","data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right data-[side=left]:data-open:slide-in-from-left data-[side=bottom]:data-open:slide-in-from-bottom data-[side=top]:data-open:slide-in-from-top","data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right data-[side=left]:data-closed:slide-out-to-left data-[side=bottom]:data-closed:slide-out-to-bottom data-[side=top]:data-closed:slide-out-to-top",s),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==c?(f=c&&a.jsxs(uc,{className:"absolute top-4 right-4 inline-flex size-7 items-center justify-center rounded-md text-muted-foreground outline-none transition-[color,background-color,transform,scale] duration-100 ease-out hover:bg-accent hover:text-foreground active:scale-90 focus-visible:ring-[3px] focus-visible:ring-ring/20 disabled:pointer-events-none motion-reduce:transition-none motion-reduce:active:scale-100",children:[a.jsx(At,{"data-icon":"inline-start",className:"size-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]}),e[9]=c,e[10]=f):f=e[10];let m;return e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==d||e[15]!==f?(m=a.jsxs(XO,{children:[u,a.jsxs($1,{"data-slot":"sheet-content","data-side":l,className:d,...r,children:[t,f]})]}),e[11]=t,e[12]=r,e[13]=l,e[14]=d,e[15]=f,e[16]=m):m=e[16],m}function eL(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-col gap-1.5 border-b p-4",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"sheet-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function tL(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(R1,{"data-slot":"sheet-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function nL(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(O1,{"data-slot":"sheet-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function jl(n){const e=q.c(10),{label:t,children:s,wide:r}=n,i=(r===void 0?!1:r)&&"col-span-2";let l;e[0]!==i?(l=G("min-w-0 gap-1 py-1",i),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==t?(c=a.jsx(rn,{className:"text-xs text-muted-foreground",children:t}),e[2]=t,e[3]=c):c=e[3];let u;e[4]!==s?(u=a.jsx("div",{className:"min-w-0 [&>button]:w-full [&>button]:justify-between",children:s}),e[4]=s,e[5]=u):u=e[5];let d;return e[6]!==l||e[7]!==c||e[8]!==u?(d=a.jsxs(sn,{className:l,children:[c,u]}),e[6]=l,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}function su(n){const e=q.c(18),{label:t,ariaLabel:s,value:r,options:o,onChange:i}=n;let l;e[0]!==i?(l=h=>{h!==null&&i(h)},e[0]=i,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(h4,{}),e[2]=c):c=e[2];let u;e[3]!==s?(u=a.jsx(g4,{"aria-label":s,className:"h-10 w-full",children:c}),e[3]=s,e[4]=u):u=e[4];let d;e[5]!==o?(d=o.map(sL),e[5]=o,e[6]=d):d=e[6];let f;e[7]!==d?(f=a.jsx(x4,{children:a.jsx(p4,{children:d})}),e[7]=d,e[8]=f):f=e[8];let m;e[9]!==o||e[10]!==l||e[11]!==u||e[12]!==f||e[13]!==r?(m=a.jsxs(m4,{items:o,value:r,onValueChange:l,children:[u,f]}),e[9]=o,e[10]=l,e[11]=u,e[12]=f,e[13]=r,e[14]=m):m=e[14];let p;return e[15]!==t||e[16]!==m?(p=a.jsx(jl,{label:t,children:m}),e[15]=t,e[16]=m,e[17]=p):p=e[17],p}function sL(n){return a.jsx(dg,{value:n.value,children:n.menuLabel??n.label},n.value||"default")}function rL(n){const e=q.c(36),{contextWindowTokens:t,onContextWindowTokensChange:s,agentKind:r,onAgentKindChange:o,selectedModel:i,onModelChange:l,modelOptions:c,selectedEffort:u,onEffortChange:d,effortOptions:f,fastTier:m,fastModeEnabled:p,onFastModeEnabledChange:h,permissionMode:g,permissionOptions:x,onPermissionModeChange:b,changeAndApply:w}=n;let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("h3",{id:"mobile-model-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Model and behavior"}),e[0]=v):v=e[0];let k;e[1]!==r||e[2]!==t||e[3]!==s?(k=fn(r).configurableContextWindow&&s&&a.jsx(iN,{value:t??null,onChange:s}),e[1]=r,e[2]=t,e[3]=s,e[4]=k):k=e[4];let j;e[5]!==k?(j=a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v,k]}),e[5]=k,e[6]=j):j=e[6];let _;e[7]!==r||e[8]!==o?(_=o&&a.jsx(su,{label:"Agent",ariaLabel:"Agent",value:r,options:yg,onChange:E=>o(E)}),e[7]=r,e[8]=o,e[9]=_):_=e[9];let N;e[10]!==c||e[11]!==l||e[12]!==i?(N=a.jsx(su,{label:"Model",ariaLabel:"Model",value:i,options:c,onChange:l}),e[10]=c,e[11]=l,e[12]=i,e[13]=N):N=e[13];let S;e[14]!==f||e[15]!==d||e[16]!==u?(S=f.length>0&&a.jsx(su,{label:"Reasoning",ariaLabel:"Reasoning effort",value:u,options:f,onChange:d}),e[14]=f,e[15]=d,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==w||e[19]!==p||e[20]!==m||e[21]!==h?(C=m&&h&&a.jsx(jl,{label:"Speed",children:a.jsxs(J,{type:"button",variant:p?"secondary":"ghost","aria-pressed":!!p,onClick:()=>w(()=>h(!p)),title:m.description,className:"h-10 justify-start",children:[a.jsx(md,{"data-icon":"inline-start",className:G(p&&"fill-current")}),p?"Fast":"Standard"]})}),e[18]=w,e[19]=p,e[20]=m,e[21]=h,e[22]=C):C=e[22];let A;e[23]!==b||e[24]!==g||e[25]!==x?(A=b&&g&&a.jsx(su,{label:"Access",ariaLabel:"Access policy",value:g,options:x,onChange:E=>b(E)}),e[23]=b,e[24]=g,e[25]=x,e[26]=A):A=e[26];let T;e[27]!==_||e[28]!==N||e[29]!==S||e[30]!==C||e[31]!==A?(T=a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[_,N,S,C,A]}),e[27]=_,e[28]=N,e[29]=S,e[30]=C,e[31]=A,e[32]=T):T=e[32];let I;return e[33]!==j||e[34]!==T?(I=a.jsxs("section",{"aria-labelledby":"mobile-model-controls",className:"flex flex-col gap-2",children:[j,T]}),e[33]=j,e[34]=T,e[35]=I):I=e[35],I}function oL(n){const e=q.c(30),{agentKind:t,isNewSession:s,worktreeEnabled:r,onWorktreeEnabledChange:o,ultracodeEnabled:i,onUltracodeEnabledChange:l,mcpServers:c,selectedMcpServers:u,onToggleMcpServer:d,onRefreshMcpServers:f,mcpLoading:m,onMcpAuth:p,changeAndApply:h}=n;let g;e[0]!==t?(g=fn(t),e[0]=t,e[1]=g):g=e[1];const{worktrees:x,ultracode:b}=g,w=!!(d&&f&&p&&(m||c&&c.length>0)),v=!!(x&&s&&o||b&&l||w);let k;e[2]!==u?(k=u??[],e[2]=u,e[3]=k):k=e[3];let j;e[4]!==k?(j=new Set(k),e[4]=k,e[5]=j):j=e[5];const _=j;if(!v)return null;let N;e[6]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("h3",{id:"mobile-advanced-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Advanced"}),e[6]=N):N=e[6];let S;e[7]!==s||e[8]!==o||e[9]!==x||e[10]!==r?(S=x&&s&&o&&a.jsx(jl,{label:"Isolation",children:a.jsxs(J,{type:"button",variant:r?"secondary":"ghost","aria-pressed":!!r,onClick:()=>o(!r),className:"h-10 justify-start",children:[a.jsx(Wr,{"data-icon":"inline-start"}),"Worktree"]})}),e[7]=s,e[8]=o,e[9]=x,e[10]=r,e[11]=S):S=e[11];let C;e[12]!==h||e[13]!==l||e[14]!==b||e[15]!==i?(C=b&&l&&a.jsx(jl,{label:"Workflow",children:a.jsxs(J,{type:"button",variant:i?"secondary":"ghost","aria-pressed":!!i,onClick:()=>h(()=>l(!i)),className:"h-10 justify-start",children:[a.jsx(md,{"data-icon":"inline-start",className:G(i&&"fill-current")}),"Ultracode"]})}),e[12]=h,e[13]=l,e[14]=b,e[15]=i,e[16]=C):C=e[16];let A;e[17]!==h||e[18]!==m||e[19]!==c||e[20]!==p||e[21]!==f||e[22]!==d||e[23]!==_||e[24]!==w?(A=w&&d&&f&&p&&a.jsx(jl,{label:"Connections",wide:!0,children:a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs(J,{type:"button",variant:"ghost",onClick:f,className:"min-h-10 justify-start",children:[a.jsx(Fn,{"data-icon":"inline-start",className:G(m&&"animate-spin")}),"Refresh MCP status"]}),(c??[]).map(I=>{const E=_.has(I.name),P=I.status==="connected";return a.jsxs(J,{type:"button",variant:"ghost","aria-pressed":P?E:void 0,onClick:()=>P?h(()=>d(I.name)):p(I.name),className:"min-h-10 justify-start text-left",children:[a.jsx("span",{className:G("size-2 shrink-0 rounded-full",P&&E?"bg-success":P?"bg-muted-foreground":"bg-warning")}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:I.name}),a.jsx("span",{className:"text-xs text-muted-foreground",children:P?E?"On":"Off":"Connect"})]},I.name)})]})}),e[17]=h,e[18]=m,e[19]=c,e[20]=p,e[21]=f,e[22]=d,e[23]=_,e[24]=w,e[25]=A):A=e[25];let T;return e[26]!==S||e[27]!==C||e[28]!==A?(T=a.jsxs("section",{"aria-labelledby":"mobile-advanced-controls",className:"flex flex-col gap-2",children:[N,a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[S,C,A]})]}),e[26]=S,e[27]=C,e[28]=A,e[29]=T):T=e[29],T}function iL(n){var de,le;const e=q.c(75),{open:t,onOpenChange:s,agentKind:r,onAgentKindChange:o,selectedModel:i,resolvedDefaultName:l,catalogOptions:c,modelOptions:u,onModelChange:d,selectedEffort:f,effortOptions:m,onEffortChange:p,contextWindowTokens:h,onContextWindowTokensChange:g,fastTier:x,fastModeEnabled:b,onFastModeEnabledChange:w,isNewSession:v,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:_,onUltracodeEnabledChange:N,autoModeAvailable:S,permissionMode:C,onPermissionModeChange:A,mcpServers:T,selectedMcpServers:I,onToggleMcpServer:E,onRefreshMcpServers:P,mcpLoading:R,onMcpAuth:L,mobileExtra:O,changeAndApply:$}=n;let M,D;e[0]!==r||e[1]!==S||e[2]!==C?(M=fN(r,S),D=(de=M.find(se=>se.value===C))==null?void 0:de.label,e[0]=r,e[1]=S,e[2]=C,e[3]=M,e[4]=D):(M=e[3],D=e[4]);const F=D;let z;e[5]!==c||e[6]!==l||e[7]!==i?(z=i?Ox(i,c):l,e[5]=c,e[6]=l,e[7]=i,e[8]=z):z=e[8];let B;e[9]!==m||e[10]!==f?(B=(le=m.find(se=>se.value===f))==null?void 0:le.label,e[9]=m,e[10]=f,e[11]=B):B=e[11];let U;e[12]!==F||e[13]!==z||e[14]!==B?(U=[z,B,F].filter(Boolean),e[12]=F,e[13]=z,e[14]=B,e[15]=U):U=e[15];const W=U.join(" · ");let V;e[16]!==$||e[17]!==A?(V=se=>{A&&$(()=>A(se))},e[16]=$,e[17]=A,e[18]=V):V=e[18];const H=V;let K;e[19]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(ZO,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"ml-0.5 shrink-0 rounded-full text-muted-foreground","aria-label":"Session controls",title:"Session controls"}),children:a.jsx(F1,{})}),e[19]=K):K=e[19];let Z;e[20]===Symbol.for("react.memo_cache_sentinel")?(Z=a.jsx(tL,{children:"Session controls"}),e[20]=Z):Z=e[20];let Y;e[21]!==W?(Y=a.jsx(nL,{className:"truncate text-xs",children:W}),e[21]=W,e[22]=Y):Y=e[22];let X;e[23]===Symbol.for("react.memo_cache_sentinel")?(X=a.jsx(YO,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-lg",className:"absolute right-2 top-2","aria-label":"Close session controls"}),children:a.jsx(At,{})}),e[23]=X):X=e[23];let ee;e[24]!==Y?(ee=a.jsxs(eL,{className:"gap-1 px-4 pb-3 pt-4",children:[Z,Y,X]}),e[24]=Y,e[25]=ee):ee=e[25];let Q;e[26]!==r||e[27]!==$||e[28]!==H||e[29]!==h||e[30]!==m||e[31]!==b||e[32]!==x||e[33]!==u||e[34]!==o||e[35]!==g||e[36]!==p||e[37]!==w||e[38]!==d||e[39]!==C||e[40]!==M||e[41]!==f||e[42]!==i?(Q=a.jsx(rL,{contextWindowTokens:h,onContextWindowTokensChange:g,agentKind:r,onAgentKindChange:o,selectedModel:i,onModelChange:d,modelOptions:u,selectedEffort:f,onEffortChange:p,effortOptions:m,fastTier:x,fastModeEnabled:b,onFastModeEnabledChange:w,permissionMode:C,permissionOptions:M,onPermissionModeChange:H,changeAndApply:$}),e[26]=r,e[27]=$,e[28]=H,e[29]=h,e[30]=m,e[31]=b,e[32]=x,e[33]=u,e[34]=o,e[35]=g,e[36]=p,e[37]=w,e[38]=d,e[39]=C,e[40]=M,e[41]=f,e[42]=i,e[43]=Q):Q=e[43];let ne;e[44]!==r||e[45]!==$||e[46]!==v||e[47]!==R||e[48]!==T||e[49]!==L||e[50]!==P||e[51]!==E||e[52]!==N||e[53]!==j||e[54]!==I||e[55]!==_||e[56]!==k?(ne=a.jsx(oL,{agentKind:r,isNewSession:v,worktreeEnabled:k,onWorktreeEnabledChange:j,ultracodeEnabled:_,onUltracodeEnabledChange:N,mcpServers:T,selectedMcpServers:I,onToggleMcpServer:E,onRefreshMcpServers:P,mcpLoading:R,onMcpAuth:L,changeAndApply:$}),e[44]=r,e[45]=$,e[46]=v,e[47]=R,e[48]=T,e[49]=L,e[50]=P,e[51]=E,e[52]=N,e[53]=j,e[54]=I,e[55]=_,e[56]=k,e[57]=ne):ne=e[57];let te;e[58]!==O?(te=O&&a.jsxs("section",{"aria-labelledby":"mobile-goal-controls",className:"flex flex-col gap-2 pt-1",children:[a.jsx(Qt,{className:"mb-3"}),a.jsx("h3",{id:"mobile-goal-controls",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Long-running goal"}),a.jsx("div",{className:"[&>*]:mx-0 [&>*]:mb-0 [&_button]:min-h-10",children:O})]}),e[58]=O,e[59]=te):te=e[59];let re;e[60]!==r||e[61]!==v?(re=!v&&a.jsx("p",{className:"text-xs text-muted-foreground",children:fn(r).settingsApply==="live"?"Changes apply live.":"Changes apply on the next turn."}),e[60]=r,e[61]=v,e[62]=re):re=e[62];let oe;e[63]!==Q||e[64]!==ne||e[65]!==te||e[66]!==re?(oe=a.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4",children:[Q,ne,te,re]}),e[63]=Q,e[64]=ne,e[65]=te,e[66]=re,e[67]=oe):oe=e[67];let ie;e[68]!==ee||e[69]!==oe?(ie=a.jsxs(QO,{side:"bottom",className:"max-h-[82dvh] overflow-hidden rounded-t-2xl pb-[env(safe-area-inset-bottom)]",showCloseButton:!1,children:[ee,oe]}),e[68]=ee,e[69]=oe,e[70]=ie):ie=e[70];let ae;return e[71]!==s||e[72]!==t||e[73]!==ie?(ae=a.jsx(a.Fragment,{children:a.jsxs(GO,{open:t,onOpenChange:s,children:[K,ie]})}),e[71]=s,e[72]=t,e[73]=ie,e[74]=ae):ae=e[74],ae}const aL=y.memo(function(e){const t=q.c(55),{agentKind:s,onAgentKindChange:r,selectedModel:o,onModelChange:i,selectedEffort:l,onEffortChange:c,contextWindowTokens:u,onContextWindowTokensChange:d,fastModeEnabled:f,onFastModeEnabledChange:m,isNewSession:p,worktreeEnabled:h,onWorktreeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,onApplySettings:w,activeModelId:v,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:_,onSetMcpServers:N,onRefreshMcpServers:S,mcpLoading:C,onMcpAuth:A,permissionMode:T,onPermissionModeChange:I,mobileExtra:E,trailingExtra:P,mobile:R}=e,L=s===void 0?Uo:s,O=R===void 0?!1:R,[$,M]=y.useState(!1);let D;t[0]!==p||t[1]!==w?(D=le=>{le(),!p&&w&&setTimeout(()=>w(),0)},t[0]=p,t[1]=w,t[2]=D):D=t[2];const F=D;let z;t[3]!==F||t[4]!==i?(z=le=>F(()=>i(le)),t[3]=F,t[4]=i,t[5]=z):z=t[5];const B=z;let U;t[6]!==F||t[7]!==c?(U=le=>F(()=>c(le)),t[6]=F,t[7]=c,t[8]=U):U=t[8];const W=U,{options:V,effortOptions:H,fastTier:K,autoPermissionMode:Z,normalizeEffort:Y}=rN(L,o),X=(v==null?void 0:v.toLowerCase().startsWith("gpt-"))??!1,Q=v&&(L==="copilot"||X===(L==="codex"))?v:void 0;let ne,te;t[9]!==V||t[10]!==Q?(ne=Q?Ox(Q,V):UO(V),te=V.map(le=>{const se=[le.description,le.availabilityMessage].filter(Boolean).join(" · ")||void 0;return le.value===""?{...le,description:se,label:ne,menuLabel:le.label}:{...le,description:se}}),t[9]=V,t[10]=Q,t[11]=ne,t[12]=te):(ne=t[11],te=t[12]);const re=te;let oe;t[13]!==Y||t[14]!==l?(oe=Y(l),t[13]=Y,t[14]=l,t[15]=oe):oe=t[15];let ie;t[16]!==L||t[17]!==Z||t[18]!==F||t[19]!==u||t[20]!==H||t[21]!==f||t[22]!==K||t[23]!==W||t[24]!==B||t[25]!==p||t[26]!==C||t[27]!==k||t[28]!==re||t[29]!==r||t[30]!==d||t[31]!==m||t[32]!==A||t[33]!==I||t[34]!==S||t[35]!==N||t[36]!==_||t[37]!==b||t[38]!==g||t[39]!==T||t[40]!==ne||t[41]!==j||t[42]!==o||t[43]!==oe||t[44]!==x||t[45]!==h?(ie={agentKind:L,onAgentKindChange:r,selectedModel:o,resolvedDefaultName:ne,modelOptions:re,onModelChange:B,selectedEffort:oe,effortOptions:H,onEffortChange:W,contextWindowTokens:u,onContextWindowTokensChange:d,fastTier:K,fastModeEnabled:f,onFastModeEnabledChange:m,isNewSession:p,worktreeEnabled:h,onWorktreeEnabledChange:g,ultracodeEnabled:x,onUltracodeEnabledChange:b,autoModeAvailable:Z,permissionMode:T,onPermissionModeChange:I,mcpServers:k,selectedMcpServers:j,onToggleMcpServer:_,onSetMcpServers:N,onRefreshMcpServers:S,mcpLoading:C,onMcpAuth:A,changeAndApply:F},t[16]=L,t[17]=Z,t[18]=F,t[19]=u,t[20]=H,t[21]=f,t[22]=K,t[23]=W,t[24]=B,t[25]=p,t[26]=C,t[27]=k,t[28]=re,t[29]=r,t[30]=d,t[31]=m,t[32]=A,t[33]=I,t[34]=S,t[35]=N,t[36]=_,t[37]=b,t[38]=g,t[39]=T,t[40]=ne,t[41]=j,t[42]=o,t[43]=oe,t[44]=x,t[45]=h,t[46]=ie):ie=t[46];const ae=ie;if(O){let le;return t[47]!==V||t[48]!==ae||t[49]!==E||t[50]!==$?(le=a.jsx(iL,{...ae,open:$,onOpenChange:M,catalogOptions:V,mobileExtra:E}),t[47]=V,t[48]=ae,t[49]=E,t[50]=$,t[51]=le):le=t[51],le}let de;return t[52]!==ae||t[53]!==P?(de=a.jsx(KO,{...ae,trailingExtra:P}),t[52]=ae,t[53]=P,t[54]=de):de=t[54],de});function mN(n){return n.agentType==="team-lead"}function lL(n){return mN(n)?void 0:n.color}const cL={blue:"bg-blue-500",green:"bg-green-500",yellow:"bg-yellow-500",purple:"bg-purple-500",orange:"bg-orange-500"};function uL(n){return n?cL[n]??"bg-zinc-400":"bg-zinc-400"}const dL=y.memo(function(e){const t=q.c(18),{teamName:s,members:r,currentMemberName:o,loadingMember:i,onMemberClick:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Zs,{className:"size-3"}),t[0]=c):c=t[0];let u;t[1]!==s?(u=a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[c,a.jsx("span",{className:"max-w-[120px] truncate",children:s})]}),t[1]=s,t[2]=u):u=t[2];let d;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(Qt,{orientation:"vertical",className:"h-3.5"}),t[3]=d):d=t[3];let f;if(t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==l){let h;t[9]!==o||t[10]!==i||t[11]!==l?(h=g=>{const x=g.name===o,b=g.name===i,w=uL(lL(g));return a.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>l(g),disabled:b,className:G("whitespace-nowrap",x?"bg-accent text-accent-foreground":"text-muted-foreground"),children:[b?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx("span",{className:G("inline-flex size-1.5 shrink-0 rounded-full",w)}),a.jsx("span",{children:g.name}),mN(g)&&a.jsx(O7,{"data-icon":"inline-end",className:"text-warning"})]},g.agentId)},t[9]=o,t[10]=i,t[11]=l,t[12]=h):h=t[12],f=r.map(h),t[4]=o,t[5]=i,t[6]=r,t[7]=l,t[8]=f}else f=t[8];let m;t[13]!==f?(m=a.jsx("div",{className:"flex items-center gap-1",children:f}),t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==u||t[16]!==m?(p=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 overflow-x-auto border-b bg-background px-3 py-2",children:[u,d,m]}),t[15]=u,t[16]=m,t[17]=p):p=t[17],p}),Lx=y.createContext(null),Mx=y.createContext(null);function Zu(n){const e=q.c(6),{value:t,chatValue:s,children:r}=n;let o;e[0]!==s||e[1]!==r?(o=a.jsx(Mx.Provider,{value:s,children:r}),e[0]=s,e[1]=r,e[2]=o):o=e[2];let i;return e[3]!==o||e[4]!==t?(i=a.jsx(Lx.Provider,{value:t,children:o}),e[3]=o,e[4]=t,e[5]=i):i=e[5],i}function Y0e(){return y.useContext(Lx)}function yt(){const n=y.useContext(Lx);if(!n)throw new Error("useSessionContext must be used within a SessionProvider");return n}function X0e(){return y.useContext(Mx)}function Of(){const n=y.useContext(Mx);if(!n)throw new Error("useSessionChatContext must be used within a SessionProvider");return n}var Ay=1,fL=.9,mL=.8,pL=.17,Fm=.1,Um=.999,hL=.9999,gL=.99,xL=/[\\\/_+.#"@\[\(\{&]/,bL=/[\\\/_+.#"@\[\(\{&]/g,vL=/[\s-]/,pN=/[\s-]/g;function wg(n,e,t,s,r,o,i){if(o===e.length)return r===n.length?Ay:gL;var l=`${r},${o}`;if(i[l]!==void 0)return i[l];for(var c=s.charAt(o),u=t.indexOf(c,r),d=0,f,m,p,h;u>=0;)f=wg(n,e,t,s,u+1,o+1,i),f>d&&(u===r?f*=Ay:xL.test(n.charAt(u-1))?(f*=mL,p=n.slice(r,u-1).match(bL),p&&r>0&&(f*=Math.pow(Um,p.length))):vL.test(n.charAt(u-1))?(f*=fL,h=n.slice(r,u-1).match(pN),h&&r>0&&(f*=Math.pow(Um,h.length))):(f*=pL,r>0&&(f*=Math.pow(Um,u-r))),n.charAt(u)!==e.charAt(o)&&(f*=hL)),(f<Fm&&t.charAt(u-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&t.charAt(u-1)!==s.charAt(o))&&(m=wg(n,e,t,s,u+1,o+2,i),m*Fm>f&&(f=m*Fm)),f>d&&(d=f),u=t.indexOf(c,u+1);return i[l]=d,d}function Iy(n){return n.toLowerCase().replace(pN," ")}function yL(n,e,t){return n=t&&t.length>0?`${n+" "+t.join(" ")}`:n,wg(n,e,Iy(n),Iy(e),0,0,{})}var Wa='[cmdk-group=""]',Bm='[cmdk-group-items=""]',wL='[cmdk-group-heading=""]',hN='[cmdk-item=""]',Py=`${hN}:not([aria-disabled="true"])`,Sg="cmdk-item-select",Ri="data-value",SL=(n,e,t)=>yL(n,e,t),gN=y.createContext(void 0),yc=()=>y.useContext(gN),xN=y.createContext(void 0),zx=()=>y.useContext(xN),bN=y.createContext(void 0),vN=y.forwardRef((n,e)=>{let t=Oi(()=>{var z,B;return{search:"",value:(B=(z=n.value)!=null?z:n.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=Oi(()=>new Set),r=Oi(()=>new Map),o=Oi(()=>new Map),i=Oi(()=>new Set),l=yN(n),{label:c,children:u,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:h,disablePointerSelection:g=!1,vimBindings:x=!0,...b}=n,w=qi(),v=qi(),k=qi(),j=y.useRef(null),_=$L();ui(()=>{if(d!==void 0){let z=d.trim();t.current.value=z,N.emit()}},[d]),ui(()=>{_(6,E)},[]);let N=y.useMemo(()=>({subscribe:z=>(i.current.add(z),()=>i.current.delete(z)),snapshot:()=>t.current,setState:(z,B,U)=>{var W,V,H,K;if(!Object.is(t.current[z],B)){if(t.current[z]=B,z==="search")I(),A(),_(1,T);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():(W=document.getElementById(w))==null||W.focus()}if(_(7,()=>{var Z;t.current.selectedItemId=(Z=P())==null?void 0:Z.id,N.emit()}),U||_(5,E),((V=l.current)==null?void 0:V.value)!==void 0){let Z=B??"";(K=(H=l.current).onValueChange)==null||K.call(H,Z);return}}N.emit()}},emit:()=>{i.current.forEach(z=>z())}}),[]),S=y.useMemo(()=>({value:(z,B,U)=>{var W;B!==((W=o.current.get(z))==null?void 0:W.value)&&(o.current.set(z,{value:B,keywords:U}),t.current.filtered.items.set(z,C(B,U)),_(2,()=>{A(),N.emit()}))},item:(z,B)=>(s.current.add(z),B&&(r.current.has(B)?r.current.get(B).add(z):r.current.set(B,new Set([z]))),_(3,()=>{I(),A(),t.current.value||T(),N.emit()}),()=>{o.current.delete(z),s.current.delete(z),t.current.filtered.items.delete(z);let U=P();_(4,()=>{I(),(U==null?void 0:U.getAttribute("id"))===z&&T(),N.emit()})}),group:z=>(r.current.has(z)||r.current.set(z,new Set),()=>{o.current.delete(z),r.current.delete(z)}),filter:()=>l.current.shouldFilter,label:c||n["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:w,inputId:k,labelId:v,listInnerRef:j}),[]);function C(z,B){var U,W;let V=(W=(U=l.current)==null?void 0:U.filter)!=null?W:SL;return z?V(z,t.current.search,B):0}function A(){if(!t.current.search||l.current.shouldFilter===!1)return;let z=t.current.filtered.items,B=[];t.current.filtered.groups.forEach(W=>{let V=r.current.get(W),H=0;V.forEach(K=>{let Z=z.get(K);H=Math.max(Z,H)}),B.push([W,H])});let U=j.current;R().sort((W,V)=>{var H,K;let Z=W.getAttribute("id"),Y=V.getAttribute("id");return((H=z.get(Y))!=null?H:0)-((K=z.get(Z))!=null?K:0)}).forEach(W=>{let V=W.closest(Bm);V?V.appendChild(W.parentElement===V?W:W.closest(`${Bm} > *`)):U.appendChild(W.parentElement===U?W:W.closest(`${Bm} > *`))}),B.sort((W,V)=>V[1]-W[1]).forEach(W=>{var V;let H=(V=j.current)==null?void 0:V.querySelector(`${Wa}[${Ri}="${encodeURIComponent(W[0])}"]`);H==null||H.parentElement.appendChild(H)})}function T(){let z=R().find(U=>U.getAttribute("aria-disabled")!=="true"),B=z==null?void 0:z.getAttribute(Ri);N.setState("value",B||void 0)}function I(){var z,B,U,W;if(!t.current.search||l.current.shouldFilter===!1){t.current.filtered.count=s.current.size;return}t.current.filtered.groups=new Set;let V=0;for(let H of s.current){let K=(B=(z=o.current.get(H))==null?void 0:z.value)!=null?B:"",Z=(W=(U=o.current.get(H))==null?void 0:U.keywords)!=null?W:[],Y=C(K,Z);t.current.filtered.items.set(H,Y),Y>0&&V++}for(let[H,K]of r.current)for(let Z of K)if(t.current.filtered.items.get(Z)>0){t.current.filtered.groups.add(H);break}t.current.filtered.count=V}function E(){var z,B,U;let W=P();W&&(((z=W.parentElement)==null?void 0:z.firstChild)===W&&((U=(B=W.closest(Wa))==null?void 0:B.querySelector(wL))==null||U.scrollIntoView({block:"nearest"})),W.scrollIntoView({block:"nearest"}))}function P(){var z;return(z=j.current)==null?void 0:z.querySelector(`${hN}[aria-selected="true"]`)}function R(){var z;return Array.from(((z=j.current)==null?void 0:z.querySelectorAll(Py))||[])}function L(z){let B=R()[z];B&&N.setState("value",B.getAttribute(Ri))}function O(z){var B;let U=P(),W=R(),V=W.findIndex(K=>K===U),H=W[V+z];(B=l.current)!=null&&B.loop&&(H=V+z<0?W[W.length-1]:V+z===W.length?W[0]:W[V+z]),H&&N.setState("value",H.getAttribute(Ri))}function $(z){let B=P(),U=B==null?void 0:B.closest(Wa),W;for(;U&&!W;)U=z>0?IL(U,Wa):PL(U,Wa),W=U==null?void 0:U.querySelector(Py);W?N.setState("value",W.getAttribute(Ri)):O(z)}let M=()=>L(R().length-1),D=z=>{z.preventDefault(),z.metaKey?M():z.altKey?$(1):O(1)},F=z=>{z.preventDefault(),z.metaKey?L(0):z.altKey?$(-1):O(-1)};return y.createElement(Do.div,{ref:e,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:z=>{var B;(B=b.onKeyDown)==null||B.call(b,z);let U=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||U))switch(z.key){case"n":case"j":{x&&z.ctrlKey&&D(z);break}case"ArrowDown":{D(z);break}case"p":case"k":{x&&z.ctrlKey&&F(z);break}case"ArrowUp":{F(z);break}case"Home":{z.preventDefault(),L(0);break}case"End":{z.preventDefault(),M();break}case"Enter":{z.preventDefault();let W=P();if(W){let V=new Event(Sg);W.dispatchEvent(V)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:OL},c),Lf(n,z=>y.createElement(xN.Provider,{value:N},y.createElement(gN.Provider,{value:S},z))))}),kL=y.forwardRef((n,e)=>{var t,s;let r=qi(),o=y.useRef(null),i=y.useContext(bN),l=yc(),c=yN(n),u=(s=(t=c.current)==null?void 0:t.forceMount)!=null?s:i==null?void 0:i.forceMount;ui(()=>{if(!u)return l.item(r,i==null?void 0:i.id)},[u]);let d=wN(r,o,[n.value,n.children,o],n.keywords),f=zx(),m=Po(_=>_.value&&_.value===d.current),p=Po(_=>u||l.filter()===!1?!0:_.search?_.filtered.items.get(r)>0:!0);y.useEffect(()=>{let _=o.current;if(!(!_||n.disabled))return _.addEventListener(Sg,h),()=>_.removeEventListener(Sg,h)},[p,n.onSelect,n.disabled]);function h(){var _,N;g(),(N=(_=c.current).onSelect)==null||N.call(_,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:b,onSelect:w,forceMount:v,keywords:k,...j}=n;return y.createElement(Do.div,{ref:Ml(o,e),...j,id:r,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||l.getDisablePointerSelection()?void 0:g,onClick:x?void 0:h},n.children)}),jL=y.forwardRef((n,e)=>{let{heading:t,children:s,forceMount:r,...o}=n,i=qi(),l=y.useRef(null),c=y.useRef(null),u=qi(),d=yc(),f=Po(p=>r||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ui(()=>d.group(i),[]),wN(i,l,[n.value,n.heading,c]);let m=y.useMemo(()=>({id:i,forceMount:r}),[r]);return y.createElement(Do.div,{ref:Ml(l,e),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},t&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},t),Lf(n,p=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?u:void 0},y.createElement(bN.Provider,{value:m},p))))}),NL=y.forwardRef((n,e)=>{let{alwaysRender:t,...s}=n,r=y.useRef(null),o=Po(i=>!i.search);return!t&&!o?null:y.createElement(Do.div,{ref:Ml(r,e),...s,"cmdk-separator":"",role:"separator"})}),CL=y.forwardRef((n,e)=>{let{onValueChange:t,...s}=n,r=n.value!=null,o=zx(),i=Po(u=>u.search),l=Po(u=>u.selectedItemId),c=yc();return y.useEffect(()=>{n.value!=null&&o.setState("search",n.value)},[n.value]),y.createElement(Do.input,{ref:e,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:r?n.value:i,onChange:u=>{r||o.setState("search",u.target.value),t==null||t(u.target.value)}})}),_L=y.forwardRef((n,e)=>{let{children:t,label:s="Suggestions",...r}=n,o=y.useRef(null),i=y.useRef(null),l=Po(u=>u.selectedItemId),c=yc();return y.useEffect(()=>{if(i.current&&o.current){let u=i.current,d=o.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(f),m.unobserve(u)}}},[]),y.createElement(Do.div,{ref:Ml(o,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:c.listId},Lf(n,u=>y.createElement("div",{ref:Ml(i,c.listInnerRef),"cmdk-list-sizer":""},u)))}),EL=y.forwardRef((n,e)=>{let{open:t,onOpenChange:s,overlayClassName:r,contentClassName:o,container:i,...l}=n;return y.createElement(L7,{open:t,onOpenChange:s},y.createElement(M7,{container:i},y.createElement(z7,{"cmdk-overlay":"",className:r}),y.createElement(D7,{"aria-label":n.label,"cmdk-dialog":"",className:o},y.createElement(vN,{ref:e,...l}))))}),TL=y.forwardRef((n,e)=>Po(t=>t.filtered.count===0)?y.createElement(Do.div,{ref:e,...n,"cmdk-empty":"",role:"presentation"}):null),AL=y.forwardRef((n,e)=>{let{progress:t,children:s,label:r="Loading...",...o}=n;return y.createElement(Do.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},Lf(n,i=>y.createElement("div",{"aria-hidden":!0},i)))}),Aa=Object.assign(vN,{List:_L,Item:kL,Input:CL,Group:jL,Separator:NL,Dialog:EL,Empty:TL,Loading:AL});function IL(n,e){let t=n.nextElementSibling;for(;t;){if(t.matches(e))return t;t=t.nextElementSibling}}function PL(n,e){let t=n.previousElementSibling;for(;t;){if(t.matches(e))return t;t=t.previousElementSibling}}function yN(n){let e=y.useRef(n);return ui(()=>{e.current=n}),e}var ui=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Oi(n){let e=y.useRef();return e.current===void 0&&(e.current=n()),e}function Po(n){let e=zx(),t=()=>n(e.snapshot());return y.useSyncExternalStore(e.subscribe,t,t)}function wN(n,e,t,s=[]){let r=y.useRef(),o=yc();return ui(()=>{var i;let l=(()=>{var u;for(let d of t){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():r.current}})(),c=s.map(u=>u.trim());o.value(n,l,c),(i=e.current)==null||i.setAttribute(Ri,l),r.current=l}),r}var $L=()=>{let[n,e]=y.useState(),t=Oi(()=>new Map);return ui(()=>{t.current.forEach(s=>s()),t.current=new Map},[n]),(s,r)=>{t.current.set(s,r),e({})}};function RL(n){let e=n.type;return typeof e=="function"?e(n.props):"render"in e?e.render(n.props):n}function Lf({asChild:n,children:e},t){return n&&y.isValidElement(e)?y.cloneElement(RL(e),{ref:e.ref},t(e.props.children)):t(e)}var OL={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function wc(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Aa,{"data-slot":"command",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function J0e(n){const e=q.c(24);let t,s,r,o,i,l;e[0]!==n?({title:o,description:i,children:t,className:s,showCloseButton:l,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=o===void 0?"Command Palette":o,u=i===void 0?"Search for a command to run...":i,d=l===void 0?!1:l;let f;e[7]!==s?(f=G("top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0",s),e[7]=s,e[8]=f):f=e[8];let m;e[9]!==c?(m=a.jsx(Js,{children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==u?(p=a.jsx(Qs,{children:u}),e[11]=u,e[12]=p):p=e[12];let h;e[13]!==m||e[14]!==p?(h=a.jsxs(to,{className:"sr-only",children:[m,p]}),e[13]=m,e[14]=p,e[15]=h):h=e[15];let g;e[16]!==t||e[17]!==d||e[18]!==f||e[19]!==h?(g=a.jsxs(Xs,{className:f,showCloseButton:d,children:[h,t]}),e[16]=t,e[17]=d,e[18]=f,e[19]=h,e[20]=g):g=e[20];let x;return e[21]!==r||e[22]!==g?(x=a.jsx(Ys,{...r,children:g}),e[21]=r,e[22]=g,e[23]=x):x=e[23],x}function Dx(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(ss,{className:"size-4 shrink-0 text-muted-foreground"}),e[3]=r):r=e[3];let o;e[4]!==t?(o=G("min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==o?(i=a.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-11 items-center gap-2 border-b px-3",children:[r,a.jsx(Aa.Input,{"data-slot":"command-input",className:o,...s})]}),e[6]=s,e[7]=o,e[8]=i):i=e[8],i}function Sc(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("no-scrollbar h-(--cmdk-list-height) max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none transition-[height] duration-100 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Aa.List,{"data-slot":"command-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function LL(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("py-6 text-center text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-100 motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Aa.Empty,{"data-slot":"command-empty",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function di(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(Aa.Group,{"data-slot":"command-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function No(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:s,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none transition-colors duration-75 in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-muted data-[selected=true]:text-foreground motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Ht,{className:"ml-auto scale-75 opacity-0 transition-[opacity,transform,scale] duration-100 ease-out group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:scale-100 group-data-[checked=true]/command-item:opacity-100 motion-reduce:transition-none"}),e[6]=i):i=e[6];let l;return e[7]!==t||e[8]!==r||e[9]!==o?(l=a.jsxs(Aa.Item,{"data-slot":"command-item",className:o,...r,children:[t,i]}),e[7]=t,e[8]=r,e[9]=o,e[10]=l):l=e[10],l}function ML(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-xs tracking-widest text-muted-foreground group-data-[selected=true]/command-item:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"command-shortcut",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function zL(n){return a.jsx(Ue,{variant:n.source==="built-in"?"secondary":"outline",children:n.source})}const DL=y.memo(function(e){const t=q.c(38),{suggestions:s,filter:r,loading:o,selectedIndex:i,onSelect:l,onHover:c,onEdit:u}=e;let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Map,t[0]=d):d=t[0];const f=y.useRef(d);let m,p;if(t[1]!==i?(m=()=>{var T;const A=f.current.get(i);A&&((T=A.scrollIntoView)==null||T.call(A,{block:"nearest"}))},p=[i],t[1]=i,t[2]=m,t[3]=p):(m=t[2],p=t[3]),y.useEffect(m,p),o){let A;return t[4]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:[a.jsx(vt,{className:"size-3.5 animate-spin text-muted-foreground"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading suggestions..."})]})}),t[4]=A):A=t[4],A}if(s.length===0){const A=r?`No commands or skills matching "${r}"`:"No commands or skills found";let T;return t[5]!==A?(T=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",children:a.jsx("div",{className:"rounded-lg border bg-popover p-3 text-popover-foreground shadow-sm",children:a.jsx("span",{className:"text-xs text-muted-foreground",children:A})})}),t[5]=A,t[6]=T):T=t[6],T}let h,g,x,b,w,v,k,j,_;if(t[7]!==u||t[8]!==c||t[9]!==l||t[10]!==i||t[11]!==s){const A=s.filter(UL),T=[{heading:"Commands",suggestions:A,offset:0},{heading:"Skills",suggestions:s.filter(BL),offset:A.length}];x="motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-2 max-w-[var(--chat-width)]",g=wc,w="slash-suggestions",v=s[i]?`${s[i].type}-${s[i].name}`:void 0,t[21]!==c||t[22]!==s?(k=I=>{const E=s.findIndex(P=>`${P.type}-${P.name}`===I);E>=0&&c(E)},t[21]=c,t[22]=s,t[23]=k):k=t[23],j=!1,_="border shadow-sm",h=Sc,b=T.map(I=>I.suggestions.length>0&&a.jsx(di,{heading:I.heading,children:I.suggestions.map((E,P)=>{const R=I.offset+P;return a.jsx(FL,{suggestion:E,index:R,isSelected:R===i,onSelect:l,onHover:c,onEdit:u,itemRefs:f},`${E.type}-${E.name}`)})},I.heading)),t[7]=u,t[8]=c,t[9]=l,t[10]=i,t[11]=s,t[12]=h,t[13]=g,t[14]=x,t[15]=b,t[16]=w,t[17]=v,t[18]=k,t[19]=j,t[20]=_}else h=t[12],g=t[13],x=t[14],b=t[15],w=t[16],v=t[17],k=t[18],j=t[19],_=t[20];let N;t[24]!==h||t[25]!==b?(N=a.jsx(h,{children:b}),t[24]=h,t[25]=b,t[26]=N):N=t[26];let S;t[27]!==g||t[28]!==N||t[29]!==w||t[30]!==v||t[31]!==k||t[32]!==j||t[33]!==_?(S=a.jsx(g,{id:w,value:v,onValueChange:k,shouldFilter:j,className:_,children:N}),t[27]=g,t[28]=N,t[29]=w,t[30]=v,t[31]=k,t[32]=j,t[33]=_,t[34]=S):S=t[34];let C;return t[35]!==x||t[36]!==S?(C=a.jsx("div",{className:x,children:S}),t[35]=x,t[36]=S,t[37]=C):C=t[37],C});function FL({suggestion:n,index:e,isSelected:t,onSelect:s,onHover:r,onEdit:o,itemRefs:i}){const l=y.useCallback(c=>{c?(c.id=`slash-suggestion-${e}`,i.current.set(e,c)):i.current.delete(e)},[e,i]);return a.jsxs("div",{className:"group/suggestion relative",children:[a.jsxs(No,{ref:l,value:`${n.type}-${n.name}`,className:"items-start gap-2.5 px-2 py-2 pr-10",onMouseEnter:()=>r(e),onSelect:()=>s(n),onMouseDown:c=>{c.preventDefault()},children:[a.jsx("div",{className:"mt-0.5 shrink-0",children:n.type==="command"?a.jsx(_o,{className:"size-4 text-muted-foreground"}):a.jsx(Ll,{className:"size-4 text-muted-foreground"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"font-mono text-sm font-medium text-foreground",children:["/",n.name]}),zL(n)]}),n.description&&a.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-muted-foreground",children:n.description})]}),t&&a.jsx(ML,{className:o&&n.filePath?"mr-6":void 0,children:"Enter"})]}),o&&n.filePath&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",className:"absolute right-1.5 top-1/2 -translate-y-1/2 opacity-0 transition-opacity group-hover/suggestion:opacity-100 focus-visible:opacity-100",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),o(n.filePath)},"aria-label":`Edit ${n.name}`,children:a.jsx(gr,{"data-icon":"inline-start"})})]})}function UL(n){return n.type==="command"}function BL(n){return n.type==="skill"}function WL(n){const e=q.c(25),{files:t,query:s,loading:r,selectedIndex:o,onSelect:i,onHover:l}=n;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Map,e[0]=c):c=e[0];const u=y.useRef(c);let d,f;e[1]!==o?(d=()=>{var v,k;(k=(v=u.current.get(o))==null?void 0:v.scrollIntoView)==null||k.call(v,{block:"nearest"})},f=[o],e[1]=o,e[2]=d,e[3]=f):(d=e[2],f=e[3]),y.useEffect(d,f);const m=t[o];let p;e[4]!==t||e[5]!==l?(p=v=>{const k=t.indexOf(v);k>=0&&l(k)},e[4]=t,e[5]=l,e[6]=p):p=e[6];let h;e[7]!==r?(h=r&&a.jsx(vt,{"data-icon":"inline-end","aria-label":"Loading project files",className:"size-3.5 animate-spin"}),e[7]=r,e[8]=h):h=e[8];let g;e[9]!==h?(g=a.jsxs("span",{className:"flex items-center justify-between",children:["Project files",h]}),e[9]=h,e[10]=g):g=e[10];let x;e[11]!==t||e[12]!==r||e[13]!==l||e[14]!==i||e[15]!==s||e[16]!==o?(x=!r&&t.length===0?a.jsx("p",{className:"px-2 py-3 text-xs text-muted-foreground",children:s?`No files matching “${s}”`:"No project files found"}):t.map((v,k)=>a.jsxs(No,{ref:j=>{j?(j.id=`file-suggestion-${k}`,u.current.set(k,j)):u.current.delete(k)},value:v,onMouseEnter:()=>l(k),onSelect:()=>i(v),onMouseDown:qL,children:[a.jsx(kj,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:v}),k===o&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"↵"})]},v)),e[11]=t,e[12]=r,e[13]=l,e[14]=i,e[15]=s,e[16]=o,e[17]=x):x=e[17];let b;e[18]!==g||e[19]!==x?(b=a.jsx(Sc,{className:"max-h-70",children:a.jsx(di,{heading:g,children:x})}),e[18]=g,e[19]=x,e[20]=b):b=e[20];let w;return e[21]!==m||e[22]!==p||e[23]!==b?(w=a.jsx("div",{className:"motion-popover-in absolute bottom-full left-0 right-0 z-50 mx-auto mb-1.5 max-w-[var(--chat-width)]",children:a.jsx(wc,{id:"file-suggestions",value:m,onValueChange:p,shouldFilter:!1,className:"border shadow-sm",children:b})}),e[21]=m,e[22]=p,e[23]=b,e[24]=w):w=e[24],w}function qL(n){return n.preventDefault()}function Ia(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(F7,{"data-slot":"dropdown-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function Pa(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(U7,{"data-slot":"dropdown-menu-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $a(n){const e=q.c(18);let t,s,r,o,i,l;e[0]!==n?({align:r,alignOffset:o,side:i,sideOffset:l,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?0:o,d=i===void 0?"bottom":i,f=l===void 0?4:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(jj,{"data-slot":"dropdown-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(_j,{children:a.jsx(Ej,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function pr(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Nj,{"data-slot":"dropdown-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function SN(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(Tj,{"data-slot":"dropdown-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function tn(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(Cj,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function Nl(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(D1,{"data-slot":"dropdown-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function An({...n}){return a.jsx(W7,{"data-slot":"collapsible",...n})}function Ns({...n}){return a.jsx(q7,{"data-slot":"collapsible-trigger",...n})}function In({className:n,...e}){return a.jsx(B7,{"data-slot":"collapsible-content",className:G("h-[var(--collapsible-panel-height)] overflow-hidden opacity-100 transition-[height,opacity] duration-150 ease-out [&[hidden]:not([hidden='until-found'])]:hidden motion-safe:data-starting-style:h-0 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:h-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none",n),...e})}const VL={exit_only:"Exit plan mode",interactive:"Implement interactively",autopilot:"Implement with Autopilot",autopilot_fleet:"Implement with Fleet"};function $y(n){return VL[n]??n.replaceAll("_"," ")}function kN(n){const e=q.c(34),{allowedPrompts:t,summary:s,planContent:r,actions:o,recommendedAction:i,responding:l,responseError:c,onApprove:u,onReject:d}=n;let f,m,p,h,g,x;if(e[0]!==u||e[1]!==d||e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==l){const j=o===void 0?[]:o,_=l===void 0?!1:l,N=i??j[0],S=j.filter(T=>T!==N);f=wt;const C=u&&"pr-44";e[12]!==C?(m=G("mb-3",C),e[12]=C,e[13]=m):m=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(df,{}),h=a.jsx(Vt,{children:"Plan ready for review"}),e[14]=p,e[15]=h):(p=e[14],h=e[15]);const A=s||(u?"Approve the plan or ask the agent to revise it.":"The agent is waiting for this plan to be reviewed.");e[16]!==A?(g=a.jsx(_t,{children:A}),e[16]=A,e[17]=g):g=e[17],x=u&&d&&a.jsxs(Ao,{className:"flex gap-2",children:[a.jsxs(J,{size:"sm",disabled:_,onClick:()=>u(N),children:[_&&a.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}),_?"Sending...":N?$y(N):"Approve"]}),S.length>0&&a.jsxs(Ia,{children:[a.jsx(Pa,{render:a.jsx(J,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Other plan actions",disabled:_}),children:a.jsx(Wt,{"data-icon":"icon"})}),a.jsx($a,{align:"end",children:a.jsx(pr,{children:S.map(T=>a.jsx(tn,{onClick:()=>u(T),children:$y(T)},T))})})]}),a.jsx(J,{variant:"ghost",size:"sm",disabled:_,onClick:d,children:"Reject"})]}),e[0]=u,e[1]=d,e[2]=i,e[3]=s,e[4]=o,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=h,e[10]=g,e[11]=x}else f=e[6],m=e[7],p=e[8],h=e[9],g=e[10],x=e[11];let b;e[18]!==c?(b=c&&a.jsx("div",{role:"alert",className:"col-span-full mt-2 text-xs text-destructive",children:c}),e[18]=c,e[19]=b):b=e[19];let w;e[20]!==r?(w=r&&a.jsxs(An,{className:"col-span-full mt-2",children:[a.jsx(Ns,{render:a.jsx(J,{type:"button",variant:"ghost",size:"xs"}),children:"Review full plan"}),a.jsx(In,{children:a.jsx("pre",{className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-muted p-3 text-xs text-foreground",children:r})})]}),e[20]=r,e[21]=w):w=e[21];let v;e[22]!==t?(v=t&&t.length>0&&a.jsxs("div",{className:"col-span-full mt-2 flex flex-wrap gap-1",children:[a.jsx("span",{className:"mr-1 self-center text-xs text-muted-foreground",children:"Permissions requested:"}),t.map(HL)]}),e[22]=t,e[23]=v):v=e[23];let k;return e[24]!==f||e[25]!==v||e[26]!==m||e[27]!==p||e[28]!==h||e[29]!==g||e[30]!==x||e[31]!==b||e[32]!==w?(k=a.jsxs(f,{className:m,children:[p,h,g,x,b,w,v]}),e[24]=f,e[25]=v,e[26]=m,e[27]=p,e[28]=h,e[29]=g,e[30]=x,e[31]=b,e[32]=w,e[33]=k):k=e[33],k}function HL(n,e){return a.jsx(Ue,{variant:"outline",children:n.prompt},e)}const KL=["allow","allow_always","deny"];function ru(n,e){return(n.availableDecisions??KL).includes(e)}function GL(n){switch(n){case"Bash":return{label:"Run command",icon:_o,tone:"cmd"};case"write_stdin":return{label:"Send terminal input",icon:_o,tone:"cmd"};case"Edit":return{label:"Edit file",icon:sg,tone:"write"};case"Write":return{label:"Write file",icon:sg,tone:"write"};case"Read":return{label:"Read file",icon:ba,tone:"read"};case"Glob":return{label:"File search",icon:ss,tone:"search"};case"Grep":return{label:"Content search",icon:ss,tone:"search"};case"WebFetch":return{label:"Fetch URL",icon:Ji,tone:"net"};case"WebSearch":return{label:"Web search",icon:Ji,tone:"net"};default:return{label:n,icon:ff,tone:"other"}}}function ZL(n,e){if(n==="Bash"&&typeof e.command=="string")return e.command;if(n==="write_stdin"&&typeof e.chars=="string")return e.chars;if((n==="Edit"||n==="Write"||n==="Read")&&typeof e.file_path=="string")return e.file_path;if((n==="Glob"||n==="Grep")&&typeof e.pattern=="string")return e.pattern;if(n==="WebFetch"&&typeof e.url=="string")return e.url;if(n==="WebSearch"&&typeof e.query=="string")return e.query;const t=Object.keys(e).slice(0,2);return t.length===0?null:t.flatMap(s=>{const r=e[s],o=typeof r=="string"?r:JSON.stringify(r);return o?[o.length>160?o.slice(0,157)+"…":o]:[]}).join(" · ")}function jN({requests:n,responding:e,onRespond:t,onRespondAll:s}){var k;const r=n[0],o=n.length,i=r!==void 0&&t!==void 0,l=i&&ru(r,"allow"),c=i&&ru(r,"allow_always"),u=i&&ru(r,"deny"),d=!!s&&o>1&&n.every(j=>!j.defaultToNo&&ru(j,"allow")),f=!(r!=null&&r.defaultToNo),m=y.useEffectEvent(j=>{if(!r)return;const _=j.target;if(_&&(_.tagName==="INPUT"||_.tagName==="TEXTAREA"||_.isContentEditable)||j.metaKey||j.ctrlKey||j.altKey)return;const N=j.key.toLowerCase();N==="a"&&j.shiftKey&&d?(j.preventDefault(),s==null||s("allow")):N==="a"&&l&&f?(j.preventDefault(),t==null||t(r.requestId,"allow")):N==="s"&&c&&f?(j.preventDefault(),t==null||t(r.requestId,"allow_always")):N==="d"&&u&&(j.preventDefault(),t==null||t(r.requestId,"deny"))});y.useEffect(()=>{const j=_=>m(_);return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[]);const p=r?GL(r.toolName):null,h=r?ZL(r.toolName,r.input):null,g=(r==null?void 0:r.decisionReason)||(r==null?void 0:r.description)||(r==null?void 0:r.blockedPath),x=(((k=r==null?void 0:r.suggestions)==null?void 0:k.length)??0)>0;if(!r||!p)return null;const b=p.icon,w=(e==null?void 0:e.has(r.requestId))??!1,v=o>1;return a.jsx("div",{className:"motion-slide-down-in border-b border-warning/20 bg-warning/5",children:a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx("div",{className:"flex size-7 items-center justify-center rounded-md bg-warning/10 text-warning",children:a.jsx(Sj,{className:"size-4"})}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(b,{className:"size-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:p.label})]})]}),h&&a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx("code",{className:"block truncate rounded-md border bg-muted/40 px-2 py-1 font-mono text-xs text-muted-foreground",children:h})}),g&&g!==h&&a.jsx("p",{className:"hidden max-w-64 truncate text-xs text-muted-foreground xl:block",title:g,children:g}),v&&a.jsxs(Ue,{variant:"outline",className:"shrink-0 tabular-nums",children:["+",o-1," more"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[u&&a.jsxs(J,{autoFocus:r.defaultToNo,variant:"ghost",size:"sm",className:"text-destructive",disabled:w,onClick:()=>t==null?void 0:t(r.requestId,"deny"),title:"Deny (D)",children:[a.jsx(At,{"data-icon":"inline-start"}),"Deny",a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"D"})]},r.requestId),c&&a.jsxs(J,{variant:"outline",size:"sm",disabled:w,onClick:()=>t==null?void 0:t(r.requestId,"allow_always"),title:x?`Apply the suggested scoped permission rule${f?" (S)":""}`:`Allow ${r.toolName} for this session${f?" (S)":""}`,children:[a.jsx(V7,{"data-icon":"inline-start"}),x?"Remember rule":"Session",f&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"S"})]}),d&&a.jsxs(J,{variant:"secondary",size:"sm",disabled:w,onClick:()=>s==null?void 0:s("allow"),title:"Allow all pending (⇧A)",children:["Allow all",a.jsx("kbd",{className:"ml-0.5 font-mono text-xs text-muted-foreground",children:"⇧A"})]}),l&&a.jsxs(J,{size:"sm",disabled:w,onClick:()=>t==null?void 0:t(r.requestId,"allow"),title:f?"Allow once (A)":"Allow once",children:[a.jsx(Ht,{"data-icon":"inline-start"}),"Allow",f&&a.jsx("kbd",{className:"ml-0.5 font-mono text-xs opacity-70",children:"A"})]}),i&&!l&&!c&&!u&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"Resolve this approval in Codex"})]})]})})}const YL=1568,XL=.85,Ry=35e5;function JL(n,e){let{width:t,height:s}=n;const r=Math.min(1,YL/Math.max(t,s));t=Math.round(t*r),s=Math.round(s*r);const o=document.createElement("canvas");o.width=t,o.height=s,o.getContext("2d").drawImage(n,0,0,t,s);const l=e==="image/jpeg"||e==="image/webp",c=l?"image/jpeg":"image/png";let u=o.toDataURL(c,l?XL:void 0),d=u.split(",")[1];if(d.length>Ry){let f=l?.7:.8;for(;d.length>Ry&&f>.3;)u=o.toDataURL("image/jpeg",f),d=u.split(",")[1],f-=.1;return{dataUrl:u,base64:d,mediaType:"image/jpeg"}}return{dataUrl:u,base64:d,mediaType:c}}function QL(n){const e=q.c(25),t=n===void 0?!0:n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[r,o]=y.useState(s),[i,l]=y.useState(!1),[c,u]=y.useState(!1),d=y.useRef(t);let f,m;e[1]!==t?(f=()=>{d.current=t},m=[t],e[1]=t,e[2]=f,e[3]=m):(f=e[2],m=e[3]),y.useEffect(f,m);let p;e[4]!==t?(p=$=>{const M=Array.from($).filter(nM);if(!t){M.length>0&&u(!0);return}u(!1);for(const D of M){const F=new FileReader;F.onload=()=>{if(!d.current){u(!0);return}const z=F.result,B=new Image;B.onload=()=>{if(!d.current){u(!0);return}const U=JL(B,D.type);o(W=>[...W,{id:crypto.randomUUID(),file:D,preview:U.dataUrl,data:U.base64,mediaType:U.mediaType}])},B.src=z},F.onerror=()=>{console.warn(`Failed to read image file: ${D.name}`)},F.readAsDataURL(D)}},e[4]=t,e[5]=p):p=e[5];const h=p;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=$=>{o(M=>M.filter((D,F)=>F!==$)),u(!1)},e[6]=g):g=e[6];const x=g;let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{o([]),u(!1)},e[7]=b):b=e[7];const w=b;let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=$=>{o(M=>M.length>0?M:$)},e[8]=v):v=e[8];const k=v;let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=()=>u(!1),e[9]=j):j=e[9];const _=j;let N;e[10]!==t?(N=$=>{$.preventDefault(),t&&l(!0)},e[10]=t,e[11]=N):N=e[11];const S=N;let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=$=>{$.preventDefault(),$.currentTarget.contains($.relatedTarget)||l(!1)},e[12]=C):C=e[12];const A=C;let T;e[13]!==h?(T=$=>{$.preventDefault(),l(!1),$.dataTransfer.files.length>0&&h($.dataTransfer.files)},e[13]=h,e[14]=T):T=e[14];const I=T;let E;e[15]!==h?(E=$=>{var z;const M=(z=$.clipboardData)==null?void 0:z.items;if(!M)return;const D=Array.from(M).filter(tM);if(D.length===0)return;$.preventDefault();const F=D.map(eM).filter(Boolean);h(F)},e[15]=h,e[16]=E):E=e[16];const P=E,R=!t&&r.length>0?"The selected model does not accept images. Switch models or remove the attachments.":!t&&c?"The selected model does not accept the image you tried to add.":null,L=!t&&r.length>0;let O;return e[17]!==S||e[18]!==I||e[19]!==P||e[20]!==r||e[21]!==i||e[22]!==R||e[23]!==L?(O={images:r,isDragOver:i,imageError:R,hasUnsupportedAttachments:L,dismissImageError:_,removeImage:x,clearImages:w,restoreImages:k,handleDragOver:S,handleDragLeave:A,handleDrop:I,handlePaste:P},e[17]=S,e[18]=I,e[19]=P,e[20]=r,e[21]=i,e[22]=R,e[23]=L,e[24]=O):O=e[24],O}function eM(n){return n.getAsFile()}function tM(n){return n.type.startsWith("image/")}function nM(n){return n.type.startsWith("image/")}const kg=new Map;function NN(n){return`${en("refused-draft")}::${n}`}function Oy(n,e){kg.set(NN(n),e)}function sM(n){const e=NN(n),t=kg.get(e);return kg.delete(e),t}function rM(n){const e=q.c(6);let t,s;e[0]!==n?({delay:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);const r=s===void 0?0:s;let o;return e[3]!==r||e[4]!==t?(o=a.jsx(Z7,{"data-slot":"tooltip-provider",delay:r,...t}),e[3]=r,e[4]=t,e[5]=o):o=e[5],o}function Ft(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(rM,{children:a.jsx(H7,{"data-slot":"tooltip",...t})}),e[2]=t,e[3]=s):s=e[3],s}function Ut(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(K7,{"data-slot":"tooltip-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function Bt(n){const e=q.c(20);let t,s,r,o,i,l,c;e[0]!==n?({className:s,side:o,sideOffset:i,align:l,alignOffset:c,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=o===void 0?"top":o,d=i===void 0?4:i,f=l===void 0?"center":l,m=c===void 0?0:c;let p;e[8]!==s?(p=G("z-50 w-fit origin-(--transform-origin) overflow-hidden rounded-md bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 text-balance duration-100 ease-out data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",s),e[8]=s,e[9]=p):p=e[9];let h;e[10]!==t||e[11]!==r||e[12]!==p?(h=a.jsx(G7,{"data-slot":"tooltip-content",className:p,...r,children:t}),e[10]=t,e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==f||e[15]!==m||e[16]!==u||e[17]!==d||e[18]!==h?(g=a.jsx(Y7,{children:a.jsx(X7,{align:f,alignOffset:m,side:u,sideOffset:d,className:"isolate z-50",children:h})}),e[14]=f,e[15]=m,e[16]=u,e[17]=d,e[18]=h,e[19]=g):g=e[19],g}function oM(n){const e=q.c(26),{hasContent:t,onSubmit:s,submitLabel:r}=n,o=r===void 0?"Send message":r,{isLive:i,sessionSource:l,actions:c}=yt(),{handleStopSession:u}=c,{chat:d}=Of(),{isConnected:f,interrupt:m}=d,p=f||i;let h;e[0]!==(l==null?void 0:l.agentKind)||e[1]!==(l==null?void 0:l.dirName)?(h=(l==null?void 0:l.agentKind)??an((l==null?void 0:l.dirName)??null),e[0]=l==null?void 0:l.agentKind,e[1]=l==null?void 0:l.dirName,e[2]=h):h=e[2];const g=h;let x;e[3]!==g?(x=MO(g),e[3]=g,e[4]=x):x=e[4];const b=x;let w;e[5]!==b||e[6]!==m||e[7]!==p?(w=p&&a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:"outline",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-warning",onClick:m,"aria-label":b,title:b}),children:a.jsx(U1,{"data-icon":"inline-start",className:"fill-current"})}),a.jsxs(Bt,{children:[b," (Esc)"]})]}),e[5]=b,e[6]=m,e[7]=p,e[8]=w):w=e[8];let v;e[9]!==g||e[10]!==u||e[11]!==p?(v=p&&fn(g).stopSession&&a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:"ghost",size:"icon-sm",className:"motion-enter shrink-0 rounded-full text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:u,"aria-label":"Stop session",title:"Stop session"}),children:a.jsx(J7,{"data-icon":"inline-start"})}),a.jsx(Bt,{children:"Stop session"})]}),e[9]=g,e[10]=u,e[11]=p,e[12]=v):v=e[12];const k=t?"default":"secondary",j=!t&&"text-muted-foreground";let _;e[13]!==j?(_=G("shrink-0 rounded-full",j),e[13]=j,e[14]=_):_=e[14];const N=!t;let S;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx(Q7,{"data-icon":"inline-start"}),e[15]=S):S=e[15];let C;e[16]!==s||e[17]!==o||e[18]!==_||e[19]!==N||e[20]!==k?(C=a.jsx(J,{variant:k,size:"icon-sm",className:_,disabled:N,onClick:s,"aria-label":o,title:o,children:S}),e[16]=s,e[17]=o,e[18]=_,e[19]=N,e[20]=k,e[21]=C):C=e[21];let A;return e[22]!==C||e[23]!==w||e[24]!==v?(A=a.jsxs("div",{className:"flex items-center gap-1",children:[w,v,C]}),e[22]=C,e[23]=w,e[24]=v,e[25]=A):A=e[25],A}function Ly(n){const e=q.c(34),{error:t}=n,[s,r]=y.useState(!1),[o,i]=y.useState(!1);let l;e[0]!==t?(l=t.split(`
|
|
8
8
|
`),e[0]=t,e[1]=l):l=e[1];const c=l[0];let u;e[2]!==t||e[3]!==c?(u=t.includes(`
|
|
9
|
-
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Vs,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(to,{children:[a.jsxs(Js,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(Vs,{className:"size-4"}),"Error details"]}),a.jsx(Qs,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let k;e[19]!==o?(k=o?a.jsx(Ht,{"data-icon":"inline-start"}):a.jsx(Cs,{"data-icon":"inline-start"}),e[19]=o,e[20]=k):k=e[20];const j=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==k||e[23]!==j?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:m,children:[k,j]})}),e[21]=m,e[22]=k,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(Xs,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(Ys,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function iM(n){const e=q.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Ll,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(At,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(J,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function aM(n){const e=/(?:^|\s)@([^\s]*)$/.exec(n);if(!e||e.index===void 0)return null;const t=e[0].lastIndexOf("@");return{start:e.index+t,query:e[1]??""}}function lM(n,e,t){return`${n.slice(0,e.start)}@${t} `}function xn(n){const e=q.c(3);let t,s;return e[0]!==n?(t=()=>ht(n),s=()=>ht(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Nf,t,s)}function cM(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function uM(n,e,t){const s=xn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ee(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(cM(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const jg="cogpit-share-revoked";function dM(){window.dispatchEvent(new Event(jg))}async function CN(n,e){const t=new Headers(e==null?void 0:e.headers);t.set("X-Cogpit-Client","1");const s=await fetch(n,{...e,headers:t,credentials:"same-origin",cache:"no-store"});return s.status===401&&dM(),s}function kc(n,e){return CN(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function fM(){let n;try{n=await fetch("/api/share/session",{credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}catch{return{status:"error",message:"Could not reach the server."}}if(n.status===401)return{status:"unauthenticated"};if(!n.ok)return{status:"error",message:`The server refused the request (${n.status}).`};try{return{status:"ok",info:await n.json()}}catch{return{status:"error",message:"The server sent an unreadable response."}}}function mM(n,e){return kc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function pM(){return kc("/api/share/interrupt")}function hM(){return kc("/api/share/stop")}async function gM(n,e){return(await kc("/api/share/permission",{requestId:n,behavior:e})).ok}async function xM(n,e){try{const t=await kc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function bM(){try{const n=await CN("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const vM=/^\/shared\/([^/]+)\/?$/;function _N(n){const e=vM.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Mf(n){return _N(n)!==null}function yM(n){return`/shared/${encodeURIComponent(n)}`}async function EN(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ee(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):os(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function wM(n){return[...n].join(", ")}async function TN(n,e){try{const t=await os(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function Fx(n,e,t){return Mf(window.location.pathname)?xM(e,t):EN("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function SM(n,e,t){try{return(await os(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function jc(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ou(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function kM(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function jM(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}function NM(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function CM(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const Ng=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var Ke;const c=xn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:k}=yt(),{chat:{status:j,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Of(),A=N||d,[T,I]=y.useState(""),[E,P]=y.useState(!1),[R,L]=y.useState(!1),[O,$]=y.useState(null),M=y.useRef(null),D=y.useRef(null),F=y.useRef(!1),z=y.useRef(""),B=y.useRef(null);y.useEffect(()=>{z.current=T},[T]);const U=y.useCallback(fe=>{F.current=fe,P(fe)},[]),{images:W,isDragOver:V,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:X,restoreImages:ee,handleDragOver:Q,handleDragLeave:ne,handleDrop:te,handlePaste:re}=QL(e),oe=y.useRef(W);y.useEffect(()=>{oe.current=W},[W]);const ie=(u==null?void 0:u.sessionId)??null,ae=y.useRef(null),de=y.useRef(null);y.useEffect(()=>{const fe=()=>z.current.trim()!==""||oe.current.length>0;ae.current={sessionId:ie};const ke=ie&&!fe()?sM(ie):void 0;return ke&&(de.current=ie,z.current=ke.text,oe.current=ke.images,I(ke.text),ee(ke.images)),()=>{ae.current=null,ie&&de.current===ie&&fe()&&(Oy(ie,{text:z.current,images:oe.current}),z.current="",oe.current=[],I(""),X()),de.current=null}},[ie,ee,X]);const[le,se]=y.useState(0),[me,ue]=y.useState(0),[ce,xe]=y.useState(!1),pe=T.startsWith("/")&&!T.includes(" "),he=pe?T.slice(1):"",be=y.useMemo(()=>{if(!pe)return[];const fe=he.toLowerCase(),ke=b.filter(rt=>fe?rt.name.toLowerCase().includes(fe)||rt.description.toLowerCase().includes(fe):!0),Ge=ke.filter(rt=>rt.type==="command"),Je=ke.filter(rt=>rt.type==="skill");return[...Ge,...Je]},[pe,he,b]),we=y.useMemo(()=>aM(T),[T]),ve=!!(c&&we&&s&&!ce),Se=uM(s,(we==null?void 0:we.query)??"",ve);y.useEffect(()=>{se(0)},[he]),y.useEffect(()=>{ue(0)},[we==null?void 0:we.query]);const Te=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{D.current=Te,M.current=null,L(!1),$(null)},[Te]);const Ae=y.useCallback(async fe=>{const ke=m;if(!(u!=null&&u.sessionId)||(ke==null?void 0:ke.type)!=="question")return;const Ge=ke.questions[0];if(!Ge||!fe.trim())return;(await Fx(u.sessionId,ke.toolUseId,{[Ge.question]:fe})).ok||S(fe)},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(async(fe,ke,Ge)=>{const Je=m;if((Je==null?void 0:Je.type)==="plan"&&Je.provider==="copilot"&&Je.requestId&&(u!=null&&u.sessionId)){const rt=Je.requestId;if(M.current)return!1;M.current=rt,L(!0),$(null);try{const Kt=await SM(u.sessionId,rt,{approved:fe,...ke?{selectedAction:ke}:{},...Ge?{feedback:Ge}:{}});return!Kt&&D.current===rt&&$("Couldn't send the plan response. Try again."),Kt}finally{M.current===rt&&(M.current=null,L(!1))}}return S(fe?"yes":Ge||"no"),!0},[m,u==null?void 0:u.sessionId,S]),De=y.useCallback(()=>{requestAnimationFrame(()=>{const fe=B.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,U(ou(fe,F.current)))})},[U]),Le=y.useCallback(fe=>{I(`/${fe.name} `),se(0),De()},[De]),Ce=y.useCallback(fe=>{I(fe),De()},[De]),Be=y.useCallback(fe=>{if(!we)return;const ke=lM(T,we,fe);I(ke),xe(!0),ue(0),requestAnimationFrame(()=>{const Ge=B.current;Ge&&(Ge.focus(),Ge.selectionStart=Ge.selectionEnd=Ge.value.length,U(ou(Ge,F.current)))})},[we,T,U]),We=y.useCallback(async()=>{const fe=T.trim();if(!fe&&W.length===0||!e&&W.length>0)return;if((m==null?void 0:m.type)==="question"){Ae(fe),I(""),U(!1),B.current&&(B.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!fe||!await ze(!1,void 0,fe))return;I(""),U(!1),B.current&&(B.current.style.height="auto");return}const ke=e&&W.length>0?W.map(Je=>({data:Je.data,mediaType:Je.mediaType})):void 0,Ge={text:T,images:W};de.current=null,S(fe,ke).then(Je=>{var rt;if(!Je){if(((rt=ae.current)==null?void 0:rt.sessionId)!==ie){ie&&Oy(ie,Ge);return}de.current=ie,I(Kt=>Kt||Ge.text),ee(Ge.images)}}),I(""),X(),U(!1),B.current&&(B.current.style.height="auto")},[T,W,e,S,X,ee,U,m,Ae,ze,ie]),He=y.useCallback(fe=>{if(ve&&fe.key==="Escape"){fe.preventDefault(),xe(!0);return}if(ve&&Se.files.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),ue(ke=>ke<Se.files.length-1?ke+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),ue(ke=>ke>0?ke-1:Se.files.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ke=Se.files[me];ke&&Be(ke);return}}if(pe&&be.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),se(ke=>ke<be.length-1?ke+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),se(ke=>ke>0?ke-1:be.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ke=be[le];ke&&Le(ke);return}if(fe.key==="Escape"){fe.preventDefault(),I("");return}}if(fe.key==="Escape"&&A&&C){fe.preventDefault(),C();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),We())},[We,A,C,ve,Se.files,me,Be,pe,be,le,Le]),_e=y.useCallback(fe=>{I(fe.target.value),xe(!1),U(ou(fe.target,F.current))},[U]);y.useImperativeHandle(l,()=>({focus:()=>{var fe;return(fe=B.current)==null?void 0:fe.focus()},getText:()=>z.current,setText:fe=>{I(fe),xe(!1),requestAnimationFrame(()=>U(ou(B.current,F.current)))}}),[U]);const Re=(m==null?void 0:m.type)==="plan",tt=(m==null?void 0:m.type)==="question",Xe=p.length>0,Ne=!!o,Ve=(T.trim().length>0||W.length>0)&&!K,ye=fn(t??Uo).midTurnSteering&&A,$e=ve?"file-suggestions":pe?"slash-suggestions":void 0,qe=ve&&Se.files[me]?`file-suggestion-${me}`:pe&&be[le]?`slash-suggestion-${le}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:ne,onDrop:te,children:[V&&a.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),pe&&a.jsx(DL,{suggestions:be,filter:he,loading:w,selectedIndex:le,onSelect:Le,onHover:se,onEdit:f}),ve&&a.jsx(WL,{files:Se.files,query:(we==null?void 0:we.query)??"",loading:Se.loading,selectedIndex:me,onSelect:Be,onHover:ue}),a.jsxs("div",{children:[Re&&a.jsx(kN,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:R,responseError:O,onApprove:fe=>{ze(!0,fe)},onReject:()=>{ze(!1)}}),a.jsx(iM,{suggestion:k,onAccept:Ce}),W.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:W.map((fe,ke)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:fe.preview,alt:`Upload ${ke+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(ke),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${ke+1}`,children:a.jsx(At,{className:"size-3","data-icon":"icon"})})]},fe.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(At,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",Ne?"rounded-3xl":"rounded-xl",jM(Re,tt,Xe),"focus-within:ring-3"),children:[Xe&&a.jsx(jN,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Ke=p[0])==null?void 0:Ke.requestId),a.jsxs("div",{className:G("min-w-0",Ne?"flex flex-col":"grid items-end",!Ne&&(E?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("flex shrink-0 items-center",E?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:r}),a.jsx(jc,{ref:B,value:T,onChange:_e,onKeyDown:He,onPaste:re,onFocus:()=>{setTimeout(()=>{var fe;return(fe=B.current)==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:kM(Re,tt,N,Xe,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!$e,"aria-controls":$e,"aria-activedescendant":qe,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0",NM(Ne,E,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",CM(Ne,E)),children:[o,a.jsx(oM,{hasContent:Ve,onSubmit:We,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),j==="error"&&_&&a.jsx(Ly,{error:_},_),v&&a.jsx(Ly,{error:v},v)]})]})}));function _M(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=lR(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function iu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Nc(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(EM,{children:a.jsx(TM,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(eP,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function EM(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tP,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function TM(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(nP,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function AN(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sP,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function IN(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(rP,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const AM={section:null,canCreate:!1,beginEditing:()=>{}},Ux=y.createContext(AM);function PN(){return y.useContext(Ux)}const $N="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",RN="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function IM(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function PM(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function $M({agentKind:n,threadId:e,children:t}){const s=Rf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async A=>{try{const T=await Ee(iu(e),{signal:A});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const I=await T.json();o(I.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const A=new AbortController;w(A.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{A.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var A;f((r==null?void 0:r.objective)??""),p(((A=r==null?void 0:r.tokenBudget)==null?void 0:A.toString())??""),b(null),u(!0)},[r]),k=async()=>{const A=d.trim();if(!A)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const I=await Ee(iu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:A,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),E=await I.json();if(!I.ok)throw new Error(E.error||"Could not save goal");o(E.goal),u(!1)}catch(I){b(I instanceof Error?I.message:"Could not save goal")}finally{g(!1)}},j=async A=>{if(r){g(!0);try{const T=await Ee(iu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ee(iu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:RN,onSubmit:A=>{A.preventDefault(),k()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(zl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(ka,{className:"gap-2",children:[a.jsxs(sn,{children:[a.jsx(rn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(jc,{id:"goal-objective",value:d,onChange:A=>f(A.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(sn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(rn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(zn,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:A=>p(A.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(jo,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(At,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(J,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(Ht,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const A=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:$N,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Ue,{variant:PM(r.status),children:IM(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[Ct(r.tokensUsed),r.tokenBudget?` / ${Ct(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[A&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(va,{"data-icon":"icon"})}),!A&&!T&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(oP,{"data-icon":"icon"})}),!T&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(Ht,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(gr,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(mf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(Nc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(Ux.Provider,{value:C,children:t})}function RM(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function OM(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function LM(n){const e=q.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Rf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=_M(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,k]=y.useState(w);v!==w&&(k(w),f(void 0));const j=d!==void 0?d:u;let _;e[4]!==(j==null?void 0:j.condition)?(_=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,D)=>{const F=d;f(D),p(!1);const z=await r(M);return z||f(F),z},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let A;e[9]!==h||e[10]!==C?(A=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=A):A=e[11];const T=A;let I;e[12]!==C?(I=()=>void C("/goal clear",null),e[12]=C,e[13]=I):I=e[13];const E=I;let P;if(e[14]!==l||e[15]!==N||e[16]!==E||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==j||e[21]!==T){if(P=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(zl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const D=j?"Replace goal":"Set a long-running goal";let F;e[24]!==D?(F=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,D]}),e[24]=D,e[25]=F):F=e[25];const z=!!x;let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(rn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=B):B=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=re=>g(re.target.value),e[27]=U):U=e[27];const W=`A measurable condition ${l} should keep working toward…`,V=!!x;let H;e[28]!==h||e[29]!==W||e[30]!==V?(H=a.jsx(jc,{id:"goal-condition",value:h,onChange:U,placeholder:W,rows:2,maxLength:4e3,"aria-invalid":V,autoFocus:!0}),e[28]=h,e[29]=W,e[30]=V,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(jo,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==z||e[35]!==H||e[36]!==K?(Z=a.jsxs(sn,{"data-invalid":z,children:[B,H,K]}),e[34]=z,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(At,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let X;e[39]!==T?(X=()=>void T(),e[39]=T,e[40]=X):X=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const Q=!ee;let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(Ht,{"data-icon":"inline-start"}),e[43]=ne):ne=e[43];let te;e[44]!==X||e[45]!==Q?(te=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(J,{type:"button",size:"xs",onClick:X,disabled:Q,children:[ne,"Start goal"]})]}),e[44]=X,e[45]=Q,e[46]=te):te=e[46],P=a.jsxs("section",{className:RN,"aria-label":`${l} goal editor`,children:[F,Z,te]})}else if(j){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(zl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let D;e[48]!==j.condition?(D=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[48]=j.condition,e[49]=D):D=e[49];let F;e[50]!==j.status?(F=OM(j.status),e[50]=j.status,e[51]=F):F=e[51];let z;e[52]!==j.status?(z=RM(j.status),e[52]=j.status,e[53]=z):z=e[53];let B;e[54]!==z||e[55]!==F?(B=a.jsx(Ue,{variant:F,children:z}),e[54]=z,e[55]=F,e[56]=B):B=e[56];const U=j.iterations,W=j.iterations===1?"":"s";let V;e[57]!==j.tokens?(V=Ct(j.tokens),e[57]=j.tokens,e[58]=V):V=e[58];let H;e[59]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[59]=j.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==j.iterations||e[62]!==W||e[63]!==V||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[U," turn",W," · ",V," · ",K,"m"]}),e[61]=j.iterations,e[62]=W,e[63]=V,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(gr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let X;e[67]!==N?(X=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=X):X=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(mf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let Q;e[70]!==E?(Q=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:E,"aria-label":"Clear goal",children:ee}),e[70]=E,e[71]=Q):Q=e[71];let ne;e[72]!==X||e[73]!==Q?(ne=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,Q]}),e[72]=X,e[73]=Q,e[74]=ne):ne=e[74];let te;e[75]!==B||e[76]!==Z||e[77]!==ne||e[78]!==D?(te=a.jsxs("div",{className:"flex items-center gap-2",children:[M,D,B,Z,ne]}),e[75]=B,e[76]=Z,e[77]=ne,e[78]=D,e[79]=te):te=e[79];let re;e[80]!==j.reason?(re=j.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[80]=j.reason,e[81]=re):re=e[81],P=a.jsxs("section",{className:$N,"aria-label":`${l} goal`,children:[te,re]})}e[14]=l,e[15]=N,e[16]=E,e[17]=h,e[18]=m,e[19]=x,e[20]=j,e[21]=T,e[22]=P}else P=e[22];const R=!j&&!m;let L;e[82]!==N||e[83]!==P||e[84]!==R?(L={section:P,canCreate:R,beginEditing:N},e[82]=N,e[83]=P,e[84]=R,e[85]=L):L=e[85];const O=L;let $;return e[86]!==o||e[87]!==O?($=a.jsx(Ux.Provider,{value:O,children:o}),e[86]=o,e[87]=O,e[88]=$):$=e[88],$}function MM(n){const e=q.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=fn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx($M,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(LM,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function zM(){return PN().section}function My(){const n=q.c(3),{canCreate:e,beginEditing:t}=PN();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(zl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=r):r=n[2],r}const DM=["allow","allow_always","deny"],FM=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function UM(n,e){return(n.availableDecisions??DM).includes(e)}function BM(n){const e=q.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>UM(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=FM.filter(l);t.defaultToNo&&c.sort(qM);const u=c.some(WM);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(B1,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(Vt,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(wt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:k,variant:j}=w;return a.jsx(J,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:j,disabled:r,onClick:()=>o(t.requestId,v),children:k},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function WM(n){return n.decision!=="allow_always"}function qM(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const ON=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function LN(n){const e=q.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(ON.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(iP,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function Cg(n){const e=q.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(ON),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",aN({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(yj,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function VM(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function HM(n){const e=q.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(VM(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let D;e[4]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(it,{"data-icon":"inline-end"}),e[4]=D):D=e[4];let F;e[5]!==i?(F=a.jsxs(J,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",D]}),e[5]=i,e[6]=F):F=e[6];let z;return e[7]!==M||e[8]!==F?(z=a.jsxs(zy,{children:[M,F]}),e[7]=M,e[8]=F,e[9]=z):z=e[9],z}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(D){const F={...f.current,[g.question]:D};if(c+1<l.length){f.current=F,h(new Set),u(c+1);return}o==null||o(t.toolUseId,F)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Ue,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let k;e[18]!==c||e[19]!==l.length?(k=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=k):k=e[20];let j;e[21]!==v||e[22]!==k?(j=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,k]}),e[21]=v,e[22]=k,e[23]=j):j=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,A=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=D=>a.jsx(KM,{option:D,disabled:x},D.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let I;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?(I=a.jsx(LN,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":A,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=I):I=e[41];let E;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(E=g.multiSelect&&o&&a.jsx(J,{size:"sm",disabled:s||p.size===0,onClick:()=>w(wM(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=E):E=e[49];let P;e[50]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{"data-icon":"inline-end"}),e[50]=P):P=e[50];let R;e[51]!==i?(R=a.jsxs(J,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",P]}),e[51]=i,e[52]=R):R=e[52];let L;e[53]!==E||e[54]!==R?(L=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[E,R]}),e[53]=E,e[54]=R,e[55]=L):L=e[55];let O;e[56]!==r?(O=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=O):O=e[57];let $;return e[58]!==I||e[59]!==L||e[60]!==O||e[61]!==j||e[62]!==_?($=a.jsxs(zy,{children:[j,_,I,L,O]}),e[58]=I,e[59]=L,e[60]=O,e[61]=j,e[62]=_,e[63]=$):$=e[63],$}function KM(n){const e=q.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(Cg,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(Cg,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Ut,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Bt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Ft,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function zy(n){const e=q.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(aP,{className:"text-info"}),r=a.jsx(Vt,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(wt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function GM(n){const e=q.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(BM,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(ZM),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(HM,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(lP,{className:"text-info"}),u=a.jsx(Vt,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(J,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(J,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(wt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function ZM(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(YM)}}function YM(n){return{label:n,hasPreview:!1}}const XM=3e3;function JM(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ee(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Ex(n?o:null,XM),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await os("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function Ra(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function zf(n,e,t){return`${t===void 0?bf():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(Kj(n,e))}`}async function Df(n){let e;try{e=await Ee(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await cr(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(Ra(zf(t.dirName,t.fileName)),!0)}function QM(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Dt();return`${s===Tt?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(Kj(e,t))}`}function ez(n){const e=q.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=JM(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(tz,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function tz(n){const e=q.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=QM(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&Ra(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(W1,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(J,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(GM,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let k;return e[23]!==v||e[24]!==h?(k=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=k):k=e[25],k}const _g="cogpit-session-config-changed";function nz(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function sz(n){function e(t){const s=nz(t.data);s&&window.dispatchEvent(new CustomEvent(_g,{detail:{sessionId:s}}))}return n.addEventListener(Xv,e),()=>n.removeEventListener(Xv,e)}function rz(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(_g,t),()=>window.removeEventListener(_g,t)}const Id=new Map;class oz extends EventTarget{constructor(t,s){super();Ze(this,"CONNECTING",0);Ze(this,"OPEN",1);Ze(this,"CLOSED",2);Ze(this,"withCredentials",!1);Ze(this,"onopen",null);Ze(this,"onmessage",null);Ze(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class iz{constructor(e,t){Ze(this,"source",null);Ze(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ze(this,"subscribers",new Set);Ze(this,"types",new Set(["open","error","message","access","session-config"]));Ze(this,"linked",new Set);Ze(this,"asking",null);Ze(this,"timer");Ze(this,"attempts",0);Ze(this,"generation",0);Ze(this,"retryingGeneration",null);Ze(this,"stopped",!1);Ze(this,"stopFrames",[]);Ze(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ze(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new oz(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[Y$(this.source),sz(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ee(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||s4(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),Id.get(this.key)===this&&Id.delete(this.key)}}function Bx(n,e={}){const t=wf(n),s=JSON.stringify([Jt(),Zn(),t]);let r=Id.get(s);r||(r=new iz(s,t),Id.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Cc({className:n,children:e,...t}){return a.jsxs(cP,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(uP,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:e}),a.jsx(az,{}),a.jsx(dP,{})]})}function az({className:n,orientation:e="vertical",...t}){return a.jsx(fP,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(mP,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function MN({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function lz({className:n,...e}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function cz({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function uz({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(MN,{className:G(t),...e})}function dz(n){const e=xn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ee(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const Dy=500,fz=5e3;function mz(n){const e=q.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(Dy),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(pz);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=D=>{var B;const F=D.type,z=D.id;if(F==="sessions"){l(D.sessions??[]);return}z&&((B=d.current.get(z))==null||B(F,D))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const D=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Zj()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const B=new WebSocket(D());c.current=B,B.onopen=()=>{if(p.current){B.close();return}f.current=Dy,r("connected"),B.send(JSON.stringify({type:"list"}))},B.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},B.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,fz),m.current=setTimeout(()=>h.current(),U)}};return h.current=F,F(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=D=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(D))},e[6]=t,e[7]=v):v=e[7];const k=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(D,F)=>{d.current.set(D,F)},e[8]=j):j=e[8];const _=j;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=D=>{d.current.delete(D)},e[9]=N):N=e[9];const S=N;let C;e[10]!==k?(C=D=>{const F=D===void 0?{}:D,z=`pty_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=k,e[11]=C):C=e[11];const A=C;let T;e[12]!==k?(T=D=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:F,name:D.name,cwd:D.cwd,args:["run",D.scriptName],command:"bun",metadata:{type:"script",source:D.source,scriptName:D.scriptName}}),F},e[12]=k,e[13]=T):T=e[13];const I=T;let E;e[14]!==k?(E=D=>{k({type:"kill",id:D})},e[14]=k,e[15]=E):E=e[15];const P=E;let R;e[16]!==k?(R=(D,F)=>{k({type:"input",id:D,data:F})},e[16]=k,e[17]=R):R=e[17];const L=R;let O;e[18]!==k?(O=(D,F,z)=>{k({type:"resize",id:D,cols:F,rows:z})},e[18]=k,e[19]=O):O=e[19];const $=O;let M;return e[20]!==P||e[21]!==$||e[22]!==k||e[23]!==i||e[24]!==I||e[25]!==A||e[26]!==s||e[27]!==L?(M={status:s,send:k,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:A,spawnScript:I,killSession:P,writeInput:L,resize:$},e[20]=P,e[21]=$,e[22]=k,e[23]=i,e[24]=I,e[25]=A,e[26]=s,e[27]=L,e[28]=M):M=e[28],M}function pz(){}const zN=y.createContext(null);function Wm(n){const e=q.c(3),{children:t,enabled:s}=n,o=mz(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(zN.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function Wx(){const n=y.useContext(zN);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function hz(n){var d;const e=q.c(11),t=Wx();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const r=s;let o;e[2]!==n||e[3]!==t?(o=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function gz(n){const e=q.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==i?(p=i?a.jsx(U1,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(va,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const xz=y.memo(function(e){const t=q.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=dz(s),{runningProcesses:h,runScript:g,stopScript:x}=hz(r);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(B=>B.name.toLowerCase().includes(F)||B.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const B of z){const U=b.get(B.dirLabel)??[];U.push(B),b.set(B.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[F,z]of h)v.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=v}else v=t[5];const k=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(z){f(B=>{const U=new Set(B);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=j):j=t[6];const _=j;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let A,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{i(bz),c("")},T=a.jsx(ss,{}),t[10]=A,t[11]=T):(A=t[10],T=t[11]);let I;t[12]!==o||t[13]!==C?(I=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:A,children:T}),t[12]=o,t[13]=C,t[14]=I):I=t[14];let E;t[15]!==S||t[16]!==I?(E=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,I]}),t[15]=S,t[16]=I,t[17]=E):E=t[17];let P;t[18]!==o||t[19]!==l?(P=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(zn,{type:"search",value:l,onChange:F=>c(F.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=P):P=t[20];let R;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==x?(R=[...w.entries()].map(F=>{const[z,B]=F,U=d.has(z)||!!l,W=B.filter(vz),V=B.filter(yz),H=U?B:W.length>0?W:B.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:z}),H.map(K=>{const Z=k.get(`${K.name}:${K.dir}`);return a.jsx(gz,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${z}:${K.name}`)}),!l&&V.length>0&&a.jsx(J,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(z),children:U?"Show less":`Show ${V.length} more`})]},z)}),t[21]=d,t[22]=w,t[23]=g,t[24]=k,t[25]=l,t[26]=x,t[27]=R):R=t[27];let L;t[28]!==w.size||t[29]!==p||t[30]!==l?(L=!p&&w.size===0&&l&&a.jsx(Cn,{className:"gap-1 p-3",children:a.jsxs(_n,{className:"gap-1",children:[a.jsx(En,{children:"No matching scripts"}),a.jsx(Tn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=L):L=t[31];let O;t[32]!==R||t[33]!==L?(O=a.jsxs(Cc,{className:"min-h-0 flex-1 px-1 pb-1",children:[R,L]}),t[32]=R,t[33]=L,t[34]=O):O=t[34];let $;t[35]!==P||t[36]!==O||t[37]!==E?($=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,P,O]}),t[35]=P,t[36]=O,t[37]=E,t[38]=$):$=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Qt,{orientation:"vertical"}),t[39]=M):M=t[39];let D;return t[40]!==$?(D=a.jsxs(a.Fragment,{children:[$,M]}),t[40]=$,t[41]=D):D=t[41],D});function bz(n){return!n}function vz(n){return n.isCommon}function yz(n){return!n.isCommon}function DN({className:n,orientation:e="horizontal",...t}){return a.jsx(xP,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const wz=Qr("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function FN({className:n,children:e,variant:t="default",...s}){return a.jsxs(hP,{"data-slot":"tabs-list","data-variant":t,className:G(wz({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(gP,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function el({className:n,...e}){return a.jsx(bP,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function tl({className:n,...e}){return a.jsx(pP,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Sz=y.lazy(()=>nt(()=>import("./TerminalOutput-D2nGNnds.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function kz({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=Bx(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=B4(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function jz(n){const e=q.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Ue,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(el,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const k=`Close ${t.name}`,j=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(At,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==k||e[28]!==j?(N=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs","aria-label":k,title:j,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=k,e[28]=j,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const UN=100,BN=600,Nz=200,WN="process-panel-height";function Cz(){try{const n=localStorage.getItem(WN);if(n)return Math.min(BN,Math.max(UN,Number(n)))}catch{}return Nz}const _z=y.memo(function(e){const t=q.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=Wx(),[b,w]=y.useState(Cz),v=y.useRef(null);let k,j;t[0]!==f||t[1]!==x.sessions?(k=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=k,t[3]=j):(k=t[2],j=t[3]),y.useEffect(k,j);let _;t[4]!==l||t[5]!==x?(_=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let A;t[9]===Symbol.for("react.memo_cache_sentinel")?(A=ce=>{if(!v.current)return;const xe=v.current.startY-ce.clientY,pe=Math.min(BN,Math.max(UN,v.current.startH+xe));w(pe)},t[9]=A):A=t[9];const T=A;let I;t[10]!==b?(I=()=>{if(v.current){v.current=null;try{localStorage.setItem(WN,String(b))}catch{}}},t[10]=b,t[11]=I):I=t[11];const E=I;let P;t[12]!==r||t[13]!==s?(P=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=P):P=t[14];const R=P;let L;t[15]!==s?(L=[...s.values()],t[15]=s,t[16]=L):L=t[16];const O=L;let $;t[17]!==i?($=ce=>{typeof ce=="string"&&i(ce)},t[17]=i,t[18]=$):$=t[18];let M;t[19]!==R||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==E?(M=!g&&!o&&R&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:E,onPointerCancel:E}),t[19]=R,t[20]=o,t[21]=g,t[22]=C,t[23]=E,t[24]=M):M=t[24];const D=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==D?(F=G("flex shrink-0 items-center border-b bg-card",D),t[25]=D,t[26]=F):F=t[26];const z=o?"Expand terminal panel":"Collapse terminal panel",B=!o;let U;t[27]!==o?(U=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(Wt,{"data-icon":"inline-start"}),t[27]=o,t[28]=U):U=t[28];const W=g&&"sr-only";let V;t[29]!==W?(V=G(W),t[29]=W,t[30]=V):V=t[30];let H;t[31]!==V?(H=a.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==z||t[35]!==B||t[36]!==U||t[37]!==H?(K=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":B,children:[U,H]}),t[33]=c,t[34]=z,t[35]=B,t[36]=U,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==O?(X=O.map(ce=>a.jsx(jz,{process:ce,isActive:ce.id===r,onSelectActive:()=>i(ce.id),onClose:()=>N(ce),mobile:g},ce.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=O,t[46]=X):X=t[46];let ee;t[47]!==Y||t[48]!==X?(ee=a.jsx(FN,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=ee):ee=t[49];let Q;t[50]!==u||t[51]!==m?(Q=u&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(xr,{})}),t[50]=u,t[51]=m,t[52]=Q):Q=t[52];let ne;t[53]!==F||t[54]!==K||t[55]!==ee||t[56]!==Q?(ne=a.jsxs("div",{className:F,children:[K,ee,Q]}),t[53]=F,t[54]=K,t[55]=ee,t[56]=Q,t[57]=ne):ne=t[57];const te=!o,re=g?"min(36dvh, 260px)":b;let oe;t[58]!==re?(oe={height:re},t[58]=re,t[59]=oe):oe=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&a.jsx(xz,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let ae;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==O?(ae=O.map(ce=>a.jsx(tl,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?a.jsx(kz,{process:ce}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Sz,{processId:ce.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(ce),onAddContext:d})})},ce.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=O,t[68]=ae):ae=t[68];let de;t[69]!==R||t[70]!==u||t[71]!==m?(de=!R&&a.jsxs(Cn,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(ya,{})}),a.jsx(En,{children:"No terminal open"}),a.jsx(Tn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(vc,{children:a.jsxs(J,{type:"button",size:"sm",onClick:u,children:[a.jsx(xr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=R,t[70]=u,t[71]=m,t[72]=de):de=t[72];let le;t[73]!==ae||t[74]!==de?(le=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[ae,de]}),t[73]=ae,t[74]=de,t[75]=le):le=t[75];let se;t[76]!==oe||t[77]!==ie||t[78]!==le?(se=a.jsx(In,{children:a.jsxs("div",{className:"flex min-h-0",style:oe,children:[ie,le]})}),t[76]=oe,t[77]=ie,t[78]=le,t[79]=se):se=t[79];let me;t[80]!==te||t[81]!==se?(me=a.jsx(An,{open:te,className:"min-h-0",children:se}),t[80]=te,t[81]=se,t[82]=me):me=t[82];let ue;return t[83]!==r||t[84]!==$||t[85]!==M||t[86]!==ne||t[87]!==me?(ue=a.jsxs(DN,{value:r,onValueChange:$,className:"shrink-0 gap-0 border-t bg-background",children:[M,ne,me]}),t[83]=r,t[84]=$,t[85]=M,t[86]=ne,t[87]=me,t[88]=ue):ue=t[88],ue});function _c(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const Ez=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function Tz(n){const e=new Set;for(const t of n.matchAll(Ez)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Az(n){var s;const e=q.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=Tz(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function Fy(n){var e;return((e=n.preview.split(`
|
|
9
|
+
`)||t.length>c.length,e[2]=t,e[3]=c,e[4]=u):u=e[4];const d=u;let f;e[5]!==t?(f=async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},e[5]=t,e[6]=f):f=e[6];const m=f;let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=()=>r(!0),e[7]=p):p=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(Vs,{"data-icon":"inline-start"}),e[8]=h):h=e[8];let g;e[9]!==c?(g=a.jsx("span",{className:"truncate",children:c}),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==d?(x=d&&a.jsx("span",{className:"shrink-0 opacity-60",children:"(details)"}),e[11]=d,e[12]=x):x=e[12];let b;e[13]!==g||e[14]!==x?(b=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:p,title:"Click to view the full error",className:"motion-enter mt-1 w-full justify-start text-destructive",children:[h,g,x]}),e[13]=g,e[14]=x,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(to,{children:[a.jsxs(Js,{className:"flex items-center gap-2 text-destructive",children:[a.jsx(Vs,{className:"size-4"}),"Error details"]}),a.jsx(Qs,{children:"The full output from the failed request, including the underlying process stderr."})]}),e[16]=w):w=e[16];let v;e[17]!==t?(v=a.jsx("pre",{className:"max-h-[50vh] select-text overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs text-destructive",children:t}),e[17]=t,e[18]=v):v=e[18];let k;e[19]!==o?(k=o?a.jsx(Ht,{"data-icon":"inline-start"}):a.jsx(Cs,{"data-icon":"inline-start"}),e[19]=o,e[20]=k):k=e[20];const j=o?"Copied":"Copy";let _;e[21]!==m||e[22]!==k||e[23]!==j?(_=a.jsx("div",{className:"flex justify-end",children:a.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:m,children:[k,j]})}),e[21]=m,e[22]=k,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==v||e[26]!==_?(N=a.jsxs(Xs,{className:"max-w-2xl",children:[w,v,_]}),e[25]=v,e[26]=_,e[27]=N):N=e[27];let S;e[28]!==s||e[29]!==N?(S=a.jsx(Ys,{open:s,onOpenChange:r,children:N}),e[28]=s,e[29]=N,e[30]=S):S=e[30];let C;return e[31]!==S||e[32]!==b?(C=a.jsxs(a.Fragment,{children:[b,S]}),e[31]=S,e[32]=b,e[33]=C):C=e[33],C}function iM(n){const e=q.c(17),{suggestion:t,onAccept:s}=n,[r,o]=y.useState(null);if(!t||t===r)return null;let i;e[0]!==s||e[1]!==t?(i=()=>{o(t),s(t)},e[0]=s,e[1]=t,e[2]=i):i=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Ll,{"data-icon":"inline-start"}),e[3]=l):l=e[3];let c;e[4]!==t?(c=a.jsx("span",{className:"truncate",children:t}),e[4]=t,e[5]=c):c=e[5];let u;e[6]!==i||e[7]!==c?(u=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",title:"Put this in the composer",onClick:i,className:"min-w-0 flex-1 justify-start text-muted-foreground",children:[l,c]}),e[6]=i,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==t?(d=()=>o(t),e[9]=t,e[10]=d):d=e[10];let f;e[11]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(At,{}),e[11]=f):f=e[11];let m;e[12]!==d?(m=a.jsx(J,{type:"button",variant:"ghost",size:"icon","aria-label":"Dismiss suggestion",onClick:d,className:"shrink-0 text-muted-foreground",children:f}),e[12]=d,e[13]=m):m=e[13];let p;return e[14]!==u||e[15]!==m?(p=a.jsxs("div",{className:"motion-enter mb-1 flex items-center gap-1",children:[u,m]}),e[14]=u,e[15]=m,e[16]=p):p=e[16],p}function aM(n){const e=/(?:^|\s)@([^\s]*)$/.exec(n);if(!e||e.index===void 0)return null;const t=e[0].lastIndexOf("@");return{start:e.index+t,query:e[1]??""}}function lM(n,e,t){return`${n.slice(0,e.start)}@${t} `}function xn(n){const e=q.c(3);let t,s;return e[0]!==n?(t=()=>ht(n),s=()=>ht(n),e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]),y.useSyncExternalStore(Nf,t,s)}function cM(n){const e=n.files;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function uM(n,e,t){const s=xn("hostFiles"),[r,o]=y.useState([]),[i,l]=y.useState(!1);return y.useEffect(()=>{if(!s||!t||!n){o([]),l(!1);return}const c=new AbortController,u=window.setTimeout(async()=>{l(!0);try{const d=await Ee(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(e)}&limit=30`,{signal:c.signal});if(!d.ok)throw new Error(`Request failed (${d.status})`);const f=await d.json();c.signal.aborted||o(cM(f))}catch{c.signal.aborted||o([])}finally{c.signal.aborted||l(!1)}},120);return()=>{window.clearTimeout(u),c.abort()}},[s,n,t,e]),{files:r,loading:i}}const jg="cogpit-share-revoked";function dM(){window.dispatchEvent(new Event(jg))}async function CN(n,e){const t=new Headers(e==null?void 0:e.headers);t.set("X-Cogpit-Client","1");const s=await fetch(n,{...e,headers:t,credentials:"same-origin",cache:"no-store"});return s.status===401&&dM(),s}function kc(n,e){return CN(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})}async function fM(){let n;try{n=await fetch("/api/share/session",{credentials:"same-origin",cache:"no-store",headers:{"X-Cogpit-Client":"1"}})}catch{return{status:"error",message:"Could not reach the server."}}if(n.status===401)return{status:"unauthenticated"};if(!n.ok)return{status:"error",message:`The server refused the request (${n.status}).`};try{return{status:"ok",info:await n.json()}}catch{return{status:"error",message:"The server sent an unreadable response."}}}function mM(n,e){return kc("/api/share/send-message",e!=null&&e.length?{message:n,images:e}:{message:n})}function pM(){return kc("/api/share/interrupt")}function hM(){return kc("/api/share/stop")}async function gM(n,e){return(await kc("/api/share/permission",{requestId:n,behavior:e})).ok}async function xM(n,e){try{const t=await kc("/api/share/answer",{toolUseId:n,answers:e});return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}async function bM(){try{const n=await CN("/api/share/pending");if(!n.ok)return null;const e=await n.json();return Array.isArray(e.permissions)?e.permissions:[]}catch{return null}}const vM=/^\/shared\/([^/]+)\/?$/;function _N(n){const e=vM.exec(n);if(!e)return null;try{return decodeURIComponent(e[1])||null}catch{return null}}function Mf(n){return _N(n)!==null}function yM(n){return`/shared/${encodeURIComponent(n)}`}async function EN(n,e,t){const s=typeof e.commandId=="string"?e.commandId:crypto.randomUUID(),r={...e,commandId:s};for(let o=0;;o++)try{const i=await(t?Ee(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),signal:t}):os(n,r));return i.ok&&window.dispatchEvent(new CustomEvent("cogpit-command-accepted",{detail:{commandId:s,sessionId:e.sessionId}})),i}catch(i){if(i instanceof Error&&i.name==="AbortError")throw i;if(t!=null&&t.aborted||o>=1)throw new Error(`Delivery could not be confirmed. Your draft is retained. Check receipt ${s} before sending again.`,{cause:i})}}function wM(n){return[...n].join(", ")}async function TN(n,e){try{const t=await os(n,e);return{ok:t.ok,gone:t.status===404}}catch{return{ok:!1,gone:!1}}}function Fx(n,e,t){return Mf(window.location.pathname)?xM(e,t):EN("/api/ask-user-answer",{sessionId:n,toolUseId:e,answers:t}).then(s=>({ok:s.ok,gone:s.status===404}),()=>({ok:!1,gone:!1}))}async function SM(n,e,t){try{return(await os(`/api/permissions/${encodeURIComponent(n)}/plan`,{requestId:e,...t})).ok}catch{return!1}}function jc(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-background px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("textarea",{"data-slot":"textarea",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function ou(n,e){if(!n)return!1;const t=n.offsetHeight;n.style.transition="none",n.style.height="auto";const s=Math.min(n.scrollHeight,200);let r;if(e){const i=n.style.width;n.style.width=`${Math.max(100,n.offsetWidth-140)}px`,r=n.scrollHeight>48,n.style.width=i}else r=s>44;return t!==s&&(n.style.height=t+"px",n.offsetHeight,n.style.transition="height 150ms ease"),n.style.height=s+"px",r}function kM(n,e,t,s,r,o){return s?"Resolve approval to continue...":n?"Provide feedback to request changes...":e?"Type a custom response...":o?r?"Steer…":"Message…":r?"Steer the active turn… (Enter to send)":t?"Message... (Enter to send)":"Send a message... (Enter to send)"}function jM(n,e,t){return t?"border-warning/40 focus-within:border-warning/60 focus-within:ring-warning/15":n||e?"border-info/40 focus-within:border-info/60 focus-within:ring-info/15":"border-input focus-within:border-ring focus-within:ring-ring/20"}function NM(n,e,t){return n?"px-4 pb-1.5 pt-3.5":e?G("col-span-2 row-start-1",t?"py-2.5 pr-3 pl-2":"py-3 pr-4 pl-4"):G("col-start-2 row-start-1",t?"py-2 pr-1 pl-2":"py-2.5 pr-2 pl-4")}function CM(n,e){return n?"gap-1 px-2 pb-2 pt-0.5":e?"col-start-2 row-start-2 px-1.5 pb-1.5":"col-start-3 row-start-1 pr-1.5 pb-1.5"}const Ng=y.memo(y.forwardRef(function({allowImages:e=!0,agentKind:t,projectCwd:s,leadingAccessory:r,footer:o,compact:i=!1},l){var Ke;const c=xn("hostFiles"),{session:u,isLive:d,actions:{handleEditConfig:f},pendingInteraction:m,permissionRequests:p,permissionResponding:h,respondPermission:g,respondAllPermissions:x,slashSuggestions:b,slashSuggestionsLoading:w,turnError:v,promptSuggestion:k}=yt(),{chat:{status:j,error:_,isConnected:N,sendMessage:S,interrupt:C}}=Of(),A=N||d,[T,I]=y.useState(""),[E,P]=y.useState(!1),[R,L]=y.useState(!1),[O,$]=y.useState(null),M=y.useRef(null),D=y.useRef(null),F=y.useRef(!1),z=y.useRef(""),B=y.useRef(null);y.useEffect(()=>{z.current=T},[T]);const U=y.useCallback(fe=>{F.current=fe,P(fe)},[]),{images:W,isDragOver:V,imageError:H,hasUnsupportedAttachments:K,dismissImageError:Z,removeImage:Y,clearImages:X,restoreImages:ee,handleDragOver:Q,handleDragLeave:ne,handleDrop:te,handlePaste:re}=QL(e),oe=y.useRef(W);y.useEffect(()=>{oe.current=W},[W]);const ie=(u==null?void 0:u.sessionId)??null,ae=y.useRef(null),de=y.useRef(null);y.useEffect(()=>{const fe=()=>z.current.trim()!==""||oe.current.length>0;ae.current={sessionId:ie};const ke=ie&&!fe()?sM(ie):void 0;return ke&&(de.current=ie,z.current=ke.text,oe.current=ke.images,I(ke.text),ee(ke.images)),()=>{ae.current=null,ie&&de.current===ie&&fe()&&(Oy(ie,{text:z.current,images:oe.current}),z.current="",oe.current=[],I(""),X()),de.current=null}},[ie,ee,X]);const[le,se]=y.useState(0),[me,ue]=y.useState(0),[ce,xe]=y.useState(!1),pe=T.startsWith("/")&&!T.includes(" "),he=pe?T.slice(1):"",be=y.useMemo(()=>{if(!pe)return[];const fe=he.toLowerCase(),ke=b.filter(rt=>fe?rt.name.toLowerCase().includes(fe)||rt.description.toLowerCase().includes(fe):!0),Ge=ke.filter(rt=>rt.type==="command"),Je=ke.filter(rt=>rt.type==="skill");return[...Ge,...Je]},[pe,he,b]),we=y.useMemo(()=>aM(T),[T]),ve=!!(c&&we&&s&&!ce),Se=uM(s,(we==null?void 0:we.query)??"",ve);y.useEffect(()=>{se(0)},[he]),y.useEffect(()=>{ue(0)},[we==null?void 0:we.query]);const Te=(m==null?void 0:m.type)==="plan"?m.requestId??null:null;y.useEffect(()=>{D.current=Te,M.current=null,L(!1),$(null)},[Te]);const Ae=y.useCallback(async fe=>{const ke=m;if(!(u!=null&&u.sessionId)||(ke==null?void 0:ke.type)!=="question")return;const Ge=ke.questions[0];if(!Ge||!fe.trim())return;(await Fx(u.sessionId,ke.toolUseId,{[Ge.question]:fe})).ok||S(fe)},[m,u==null?void 0:u.sessionId,S]),ze=y.useCallback(async(fe,ke,Ge)=>{const Je=m;if((Je==null?void 0:Je.type)==="plan"&&Je.provider==="copilot"&&Je.requestId&&(u!=null&&u.sessionId)){const rt=Je.requestId;if(M.current)return!1;M.current=rt,L(!0),$(null);try{const Kt=await SM(u.sessionId,rt,{approved:fe,...ke?{selectedAction:ke}:{},...Ge?{feedback:Ge}:{}});return!Kt&&D.current===rt&&$("Couldn't send the plan response. Try again."),Kt}finally{M.current===rt&&(M.current=null,L(!1))}}return S(fe?"yes":Ge||"no"),!0},[m,u==null?void 0:u.sessionId,S]),De=y.useCallback(()=>{requestAnimationFrame(()=>{const fe=B.current;fe&&(fe.focus(),fe.selectionStart=fe.selectionEnd=fe.value.length,U(ou(fe,F.current)))})},[U]),Le=y.useCallback(fe=>{I(`/${fe.name} `),se(0),De()},[De]),Ce=y.useCallback(fe=>{I(fe),De()},[De]),Be=y.useCallback(fe=>{if(!we)return;const ke=lM(T,we,fe);I(ke),xe(!0),ue(0),requestAnimationFrame(()=>{const Ge=B.current;Ge&&(Ge.focus(),Ge.selectionStart=Ge.selectionEnd=Ge.value.length,U(ou(Ge,F.current)))})},[we,T,U]),We=y.useCallback(async()=>{const fe=T.trim();if(!fe&&W.length===0||!e&&W.length>0)return;if((m==null?void 0:m.type)==="question"){Ae(fe),I(""),U(!1),B.current&&(B.current.style.height="auto");return}if((m==null?void 0:m.type)==="plan"&&m.provider==="copilot"){if(!fe||!await ze(!1,void 0,fe))return;I(""),U(!1),B.current&&(B.current.style.height="auto");return}const ke=e&&W.length>0?W.map(Je=>({data:Je.data,mediaType:Je.mediaType})):void 0,Ge={text:T,images:W};de.current=null,S(fe,ke).then(Je=>{var rt;if(!Je){if(((rt=ae.current)==null?void 0:rt.sessionId)!==ie){ie&&Oy(ie,Ge);return}de.current=ie,I(Kt=>Kt||Ge.text),ee(Ge.images)}}),I(""),X(),U(!1),B.current&&(B.current.style.height="auto")},[T,W,e,S,X,ee,U,m,Ae,ze,ie]),He=y.useCallback(fe=>{if(ve&&fe.key==="Escape"){fe.preventDefault(),xe(!0);return}if(ve&&Se.files.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),ue(ke=>ke<Se.files.length-1?ke+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),ue(ke=>ke>0?ke-1:Se.files.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ke=Se.files[me];ke&&Be(ke);return}}if(pe&&be.length>0){if(fe.key==="ArrowDown"){fe.preventDefault(),se(ke=>ke<be.length-1?ke+1:0);return}if(fe.key==="ArrowUp"){fe.preventDefault(),se(ke=>ke>0?ke-1:be.length-1);return}if(fe.key==="Tab"||fe.key==="Enter"&&!fe.shiftKey){fe.preventDefault();const ke=be[le];ke&&Le(ke);return}if(fe.key==="Escape"){fe.preventDefault(),I("");return}}if(fe.key==="Escape"&&A&&C){fe.preventDefault(),C();return}fe.key==="Enter"&&!fe.shiftKey&&(fe.preventDefault(),We())},[We,A,C,ve,Se.files,me,Be,pe,be,le,Le]),_e=y.useCallback(fe=>{I(fe.target.value),xe(!1),U(ou(fe.target,F.current))},[U]);y.useImperativeHandle(l,()=>({focus:()=>{var fe;return(fe=B.current)==null?void 0:fe.focus()},getText:()=>z.current,setText:fe=>{I(fe),xe(!1),requestAnimationFrame(()=>U(ou(B.current,F.current)))}}),[U]);const Re=(m==null?void 0:m.type)==="plan",tt=(m==null?void 0:m.type)==="question",Xe=p.length>0,Ne=!!o,Ve=(T.trim().length>0||W.length>0)&&!K,ye=fn(t??Uo).midTurnSteering&&A,$e=ve?"file-suggestions":pe?"slash-suggestions":void 0,qe=ve&&Se.files[me]?`file-suggestion-${me}`:pe&&be[le]?`slash-suggestion-${le}`:void 0;return a.jsxs("div",{className:G("relative pb-0",i?"px-2 pt-2":"px-3 pt-2",V&&"ring-2 ring-info/40 ring-inset"),onDragOver:Q,onDragLeave:ne,onDrop:te,children:[V&&a.jsx("div",{className:"motion-enter pointer-events-none absolute inset-0 flex items-center justify-center rounded-lg border-2 border-dashed border-info/40 bg-info/10",children:a.jsx("span",{className:"text-sm font-medium text-info",children:"Drop images here"})}),pe&&a.jsx(DL,{suggestions:be,filter:he,loading:w,selectedIndex:le,onSelect:Le,onHover:se,onEdit:f}),ve&&a.jsx(WL,{files:Se.files,query:(we==null?void 0:we.query)??"",loading:Se.loading,selectedIndex:me,onSelect:Be,onHover:ue}),a.jsxs("div",{children:[Re&&a.jsx(kN,{allowedPrompts:m.allowedPrompts,summary:m.summary,planContent:m.planContent,actions:m.actions,recommendedAction:m.recommendedAction,responding:R,responseError:O,onApprove:fe=>{ze(!0,fe)},onReject:()=>{ze(!1)}}),a.jsx(iM,{suggestion:k,onAccept:Ce}),W.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:W.map((fe,ke)=>a.jsxs("div",{className:"motion-list-item relative group/thumb",children:[a.jsx("img",{src:fe.preview,alt:`Upload ${ke+1}`,className:"h-16 w-auto rounded-md border bg-muted object-contain"}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Y(ke),className:"absolute -right-1.5 -top-1.5 size-5 rounded-full border bg-popover p-0 text-muted-foreground opacity-100 hover:bg-destructive hover:text-destructive-foreground sm:opacity-0 sm:group-hover/thumb:opacity-100 sm:focus-visible:opacity-100","aria-label":`Remove image ${ke+1}`,children:a.jsx(At,{className:"size-3","data-icon":"icon"})})]},fe.id))}),H&&a.jsxs("div",{role:"status","aria-live":"polite",className:"motion-enter mb-2 flex items-center gap-2 text-xs text-warning",children:[a.jsx("span",{className:"flex-1",children:H}),!K&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground","aria-label":"Dismiss image notice",children:a.jsx(At,{"data-icon":"icon"})})]}),a.jsxs("div",{className:G("relative overflow-hidden border bg-popover shadow-lg shadow-black/5 transition-[border-color,box-shadow] duration-150",Ne?"rounded-3xl":"rounded-xl",jM(Re,tt,Xe),"focus-within:ring-3"),children:[Xe&&a.jsx(jN,{requests:p,responding:h,onRespond:g,onRespondAll:x},(Ke=p[0])==null?void 0:Ke.requestId),a.jsxs("div",{className:G("min-w-0",Ne?"flex flex-col":"grid items-end",!Ne&&(E?"grid-cols-[1fr_auto]":"grid-cols-[auto_minmax(0,1fr)_auto]")),children:[r&&a.jsx("div",{className:G("flex shrink-0 items-center",E?"col-start-1 row-start-2 pl-0.5 pb-0.5":"col-start-1 row-start-1"),children:r}),a.jsx(jc,{ref:B,value:T,onChange:_e,onKeyDown:He,onPaste:re,onFocus:()=>{setTimeout(()=>{var fe;return(fe=B.current)==null?void 0:fe.scrollIntoView({behavior:"smooth",block:"center"})},300)},placeholder:kM(Re,tt,N,Xe,ye,i),"aria-label":"Message",role:"combobox","aria-autocomplete":"list","aria-expanded":!!$e,"aria-controls":$e,"aria-activedescendant":qe,rows:1,className:G("min-h-0 w-full resize-none rounded-none border-0 bg-transparent text-sm text-foreground shadow-none placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:ring-0",NM(Ne,E,i))}),a.jsxs("div",{className:G("flex shrink-0 items-center justify-end",CM(Ne,E)),children:[o,a.jsx(oM,{hasContent:Ve,onSubmit:We,submitLabel:ye?"Steer active turn":"Send message"})]})]})]}),j==="error"&&_&&a.jsx(Ly,{error:_},_),v&&a.jsx(Ly,{error:v},v)]})]})}));function _M(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t.type!=="attachment")continue;const s=lR(t.attachment);if((s==null?void 0:s.type)!=="goal_status")continue;const r=typeof s.condition=="string"?s.condition:"",o=s.met===!0,i=s.failed===!0;return s.sentinel===!0&&o||!r?null:{condition:r,status:i?"failed":o?"achieved":"active",reason:typeof s.reason=="string"?s.reason:void 0,iterations:typeof s.iterations=="number"?s.iterations:0,durationMs:typeof s.durationMs=="number"?s.durationMs:0,tokens:typeof s.tokens=="number"?s.tokens:0}}return null}function iu(n){return`/api/codex/goals/${encodeURIComponent(n)}`}function Nc(n){const e=q.c(13);let t,s,r,o;e[0]!==n?({className:s,children:t,value:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);let i;e[5]!==s?(i=G("flex flex-wrap gap-3",s),e[5]=s,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(EM,{children:a.jsx(TM,{})}),e[7]=l):l=e[7];let c;return e[8]!==t||e[9]!==r||e[10]!==i||e[11]!==o?(c=a.jsxs(eP,{value:o,"data-slot":"progress",className:i,...r,children:[t,l]}),e[8]=t,e[9]=r,e[10]=i,e[11]=o,e[12]=c):c=e[12],c}function EM(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(tP,{className:r,"data-slot":"progress-track",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function TM(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("h-full bg-primary transition-[width] duration-150 ease-out motion-reduce:transition-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(nP,{"data-slot":"progress-indicator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function AN(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm font-medium",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(sP,{className:r,"data-slot":"progress-label",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function IN(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("ml-auto text-sm text-muted-foreground tabular-nums",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(rP,{className:r,"data-slot":"progress-value",...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const AM={section:null,canCreate:!1,beginEditing:()=>{}},Ux=y.createContext(AM);function PN(){return y.useContext(Ux)}const $N="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-1",RN="mx-3 mb-1.5 rounded-lg border border-border bg-muted/30 px-2.5 py-2";function IM(n){return n==="usageLimited"?"Usage limited":n==="budgetLimited"?"Budget limited":n.charAt(0).toUpperCase()+n.slice(1)}function PM(n){return n==="complete"?"secondary":n==="blocked"||n.endsWith("Limited")?"destructive":n==="paused"?"outline":"default"}function $M({agentKind:n,threadId:e,children:t}){const s=Rf(n),[r,o]=y.useState(null),[i,l]=y.useState(!0),[c,u]=y.useState(!1),[d,f]=y.useState(""),[m,p]=y.useState(""),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(async A=>{try{const T=await Ee(iu(e),{signal:A});if(T.status===404||T.status===501){l(!1);return}if(!T.ok)return;const I=await T.json();o(I.goal),l(!0)}catch{}},[e]);y.useEffect(()=>{const A=new AbortController;w(A.signal);const T=i?setInterval(()=>void w(),1e4):void 0;return()=>{A.abort(),T!==void 0&&clearInterval(T)}},[w,i]);const v=y.useCallback(()=>{var A;f((r==null?void 0:r.objective)??""),p(((A=r==null?void 0:r.tokenBudget)==null?void 0:A.toString())??""),b(null),u(!0)},[r]),k=async()=>{const A=d.trim();if(!A)return;const T=m.trim()?Number(m):null;if(T!==null&&(!Number.isSafeInteger(T)||T<=0)){b("Token budget must be a positive whole number");return}g(!0),b(null);try{const I=await Ee(iu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objective:A,status:(r==null?void 0:r.status)==="complete"?"active":(r==null?void 0:r.status)??"active",tokenBudget:T})}),E=await I.json();if(!I.ok)throw new Error(E.error||"Could not save goal");o(E.goal),u(!1)}catch(I){b(I instanceof Error?I.message:"Could not save goal")}finally{g(!1)}},j=async A=>{if(r){g(!0);try{const T=await Ee(iu(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:A})});T.ok&&o((await T.json()).goal)}finally{g(!1)}}},_=async()=>{g(!0);try{(await Ee(iu(e),{method:"DELETE"})).ok&&(o(null),u(!1))}finally{g(!1)}},N=r!=null&&r.tokenBudget?Math.min(100,r.tokensUsed/r.tokenBudget*100):null;let S=null;if(i&&c)S=a.jsxs("form",{className:RN,onSubmit:A=>{A.preventDefault(),k()},children:[a.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a.jsx(zl,{className:"size-3.5","data-icon":"inline-start"}),r?"Edit long-running goal":"Set a long-running goal"]}),a.jsxs(ka,{className:"gap-2",children:[a.jsxs(sn,{children:[a.jsx(rn,{className:"sr-only",htmlFor:"goal-objective",children:"Goal objective"}),a.jsx(jc,{id:"goal-objective",value:d,onChange:A=>f(A.target.value),placeholder:`What should ${s} keep working toward?`,rows:2,autoFocus:!0})]}),a.jsxs(sn,{orientation:"horizontal","data-invalid":!!x,children:[a.jsx(rn,{className:"text-xs text-muted-foreground",htmlFor:"goal-budget",children:"Token budget"}),a.jsx(zn,{id:"goal-budget",type:"number",min:1,step:1,value:m,onChange:A=>p(A.target.value),placeholder:"Optional",className:"ml-auto h-8 w-28","aria-invalid":!!x})]})]}),a.jsx(jo,{className:"mt-1.5",children:x}),a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>u(!1),children:[a.jsx(At,{"data-icon":"inline-start"}),"Cancel"]}),a.jsxs(J,{type:"submit",size:"xs",disabled:h||!d.trim(),children:[a.jsx(Ht,{"data-icon":"inline-start"}),"Save goal"]})]})]});else if(i&&r){const A=r.status==="paused",T=r.status==="complete";S=a.jsxs("section",{className:$N,"aria-label":`${s} goal`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zl,{className:"size-3.5 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:r.objective,children:r.objective}),a.jsx(Ue,{variant:PM(r.status),children:IM(r.status)}),a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[Ct(r.tokensUsed),r.tokenBudget?` / ${Ct(r.tokenBudget)}`:""," · ",Math.max(0,Math.round(r.timeUsedSeconds/60)),"m"]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[A&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("active"),disabled:h,"aria-label":"Resume goal",children:a.jsx(va,{"data-icon":"icon"})}),!A&&!T&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("paused"),disabled:h,"aria-label":"Pause goal",children:a.jsx(oP,{"data-icon":"icon"})}),!T&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void j("complete"),disabled:h,"aria-label":"Mark goal complete",children:a.jsx(Ht,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:v,"aria-label":"Edit goal",children:a.jsx(gr,{"data-icon":"icon"})}),a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>void _(),disabled:h,className:"text-destructive","aria-label":"Clear goal",children:a.jsx(mf,{"data-icon":"icon"})})]})]}),N!==null&&a.jsx(Nc,{className:"mt-1 mb-0.5",value:N,"aria-label":`${N.toFixed(0)}% of goal token budget used`})]})}const C=y.useMemo(()=>({section:S,canCreate:i&&!r&&!c,beginEditing:v}),[S,i,r,c,v]);return a.jsx(Ux.Provider,{value:C,children:t})}function RM(n){switch(n){case"active":return"Goal active";case"achieved":return"Achieved";default:return"Needs attention"}}function OM(n){switch(n){case"failed":return"destructive";case"achieved":return"secondary";default:return"outline"}}function LM(n){const e=q.c(89),{agentKind:t,session:s,onSendCommand:r,children:o}=n;let i;e[0]!==t?(i=Rf(t),e[0]=t,e[1]=i):i=e[1];const l=i;let c;e[2]!==s.rawMessages?(c=_M(s.rawMessages),e[2]=s.rawMessages,e[3]=c):c=e[3];const u=c,[d,f]=y.useState(),[m,p]=y.useState(!1),[h,g]=y.useState(""),[x,b]=y.useState(null),w=u?`${u.status}\0${u.condition}`:"",[v,k]=y.useState(w);v!==w&&(k(w),f(void 0));const j=d!==void 0?d:u;let _;e[4]!==(j==null?void 0:j.condition)?(_=()=>{g((j==null?void 0:j.condition)??""),b(null),p(!0)},e[4]=j==null?void 0:j.condition,e[5]=_):_=e[5];const N=_;let S;e[6]!==r||e[7]!==d?(S=async(M,D)=>{const F=d;f(D),p(!1);const z=await r(M);return z||f(F),z},e[6]=r,e[7]=d,e[8]=S):S=e[8];const C=S;let A;e[9]!==h||e[10]!==C?(A=async()=>{const M=h.trim();if(!M)return;if(M.length>4e3){b("Goal conditions can be at most 4,000 characters");return}await C(`/goal ${M}`,{condition:M,status:"active",iterations:0,durationMs:0,tokens:0})||(g(M),p(!0))},e[9]=h,e[10]=C,e[11]=A):A=e[11];const T=A;let I;e[12]!==C?(I=()=>void C("/goal clear",null),e[12]=C,e[13]=I):I=e[13];const E=I;let P;if(e[14]!==l||e[15]!==N||e[16]!==E||e[17]!==h||e[18]!==m||e[19]!==x||e[20]!==j||e[21]!==T){if(P=null,m){let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(zl,{className:"size-3.5","data-icon":"inline-start"}),e[23]=M):M=e[23];const D=j?"Replace goal":"Set a long-running goal";let F;e[24]!==D?(F=a.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-foreground",children:[M,D]}),e[24]=D,e[25]=F):F=e[25];const z=!!x;let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=a.jsx(rn,{className:"sr-only",htmlFor:"goal-condition",children:"Goal condition"}),e[26]=B):B=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=re=>g(re.target.value),e[27]=U):U=e[27];const W=`A measurable condition ${l} should keep working toward…`,V=!!x;let H;e[28]!==h||e[29]!==W||e[30]!==V?(H=a.jsx(jc,{id:"goal-condition",value:h,onChange:U,placeholder:W,rows:2,maxLength:4e3,"aria-invalid":V,autoFocus:!0}),e[28]=h,e[29]=W,e[30]=V,e[31]=H):H=e[31];let K;e[32]!==x?(K=a.jsx(jo,{children:x}),e[32]=x,e[33]=K):K=e[33];let Z;e[34]!==z||e[35]!==H||e[36]!==K?(Z=a.jsxs(sn,{"data-invalid":z,children:[B,H,K]}),e[34]=z,e[35]=H,e[36]=K,e[37]=Z):Z=e[37];let Y;e[38]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>p(!1),children:[a.jsx(At,{"data-icon":"inline-start"}),"Cancel"]}),e[38]=Y):Y=e[38];let X;e[39]!==T?(X=()=>void T(),e[39]=T,e[40]=X):X=e[40];let ee;e[41]!==h?(ee=h.trim(),e[41]=h,e[42]=ee):ee=e[42];const Q=!ee;let ne;e[43]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsx(Ht,{"data-icon":"inline-start"}),e[43]=ne):ne=e[43];let te;e[44]!==X||e[45]!==Q?(te=a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-1",children:[Y,a.jsxs(J,{type:"button",size:"xs",onClick:X,disabled:Q,children:[ne,"Start goal"]})]}),e[44]=X,e[45]=Q,e[46]=te):te=e[46],P=a.jsxs("section",{className:RN,"aria-label":`${l} goal editor`,children:[F,Z,te]})}else if(j){let M;e[47]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(zl,{className:"size-3.5 shrink-0 text-primary","data-icon":"inline-start"}),e[47]=M):M=e[47];let D;e[48]!==j.condition?(D=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:j.condition,children:j.condition}),e[48]=j.condition,e[49]=D):D=e[49];let F;e[50]!==j.status?(F=OM(j.status),e[50]=j.status,e[51]=F):F=e[51];let z;e[52]!==j.status?(z=RM(j.status),e[52]=j.status,e[53]=z):z=e[53];let B;e[54]!==z||e[55]!==F?(B=a.jsx(Ue,{variant:F,children:z}),e[54]=z,e[55]=F,e[56]=B):B=e[56];const U=j.iterations,W=j.iterations===1?"":"s";let V;e[57]!==j.tokens?(V=Ct(j.tokens),e[57]=j.tokens,e[58]=V):V=e[58];let H;e[59]!==j.durationMs?(H=Math.round(j.durationMs/6e4),e[59]=j.durationMs,e[60]=H):H=e[60];const K=Math.max(0,H);let Z;e[61]!==j.iterations||e[62]!==W||e[63]!==V||e[64]!==K?(Z=a.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[U," turn",W," · ",V," · ",K,"m"]}),e[61]=j.iterations,e[62]=W,e[63]=V,e[64]=K,e[65]=Z):Z=e[65];let Y;e[66]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(gr,{"data-icon":"icon"}),e[66]=Y):Y=e[66];let X;e[67]!==N?(X=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:N,"aria-label":"Replace goal",children:Y}),e[67]=N,e[68]=X):X=e[68];let ee;e[69]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(mf,{"data-icon":"icon"}),e[69]=ee):ee=e[69];let Q;e[70]!==E?(Q=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:E,"aria-label":"Clear goal",children:ee}),e[70]=E,e[71]=Q):Q=e[71];let ne;e[72]!==X||e[73]!==Q?(ne=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[X,Q]}),e[72]=X,e[73]=Q,e[74]=ne):ne=e[74];let te;e[75]!==B||e[76]!==Z||e[77]!==ne||e[78]!==D?(te=a.jsxs("div",{className:"flex items-center gap-2",children:[M,D,B,Z,ne]}),e[75]=B,e[76]=Z,e[77]=ne,e[78]=D,e[79]=te):te=e[79];let re;e[80]!==j.reason?(re=j.reason&&a.jsx("p",{className:"line-clamp-2 pb-0.5 pl-5 text-xs text-muted-foreground",children:j.reason}),e[80]=j.reason,e[81]=re):re=e[81],P=a.jsxs("section",{className:$N,"aria-label":`${l} goal`,children:[te,re]})}e[14]=l,e[15]=N,e[16]=E,e[17]=h,e[18]=m,e[19]=x,e[20]=j,e[21]=T,e[22]=P}else P=e[22];const R=!j&&!m;let L;e[82]!==N||e[83]!==P||e[84]!==R?(L={section:P,canCreate:R,beginEditing:N},e[82]=N,e[83]=P,e[84]=R,e[85]=L):L=e[85];const O=L;let $;return e[86]!==o||e[87]!==O?($=a.jsx(Ux.Provider,{value:O,children:o}),e[86]=o,e[87]=O,e[88]=$):$=e[88],$}function MM(n){const e=q.c(9),{agentKind:t,session:s,onSendCommand:r,children:o}=n,i=fn(t).goals;if(i==="thread-api"){let l;return e[0]!==t||e[1]!==o||e[2]!==s.sessionId?(l=a.jsx($M,{agentKind:t,threadId:s.sessionId,children:o}),e[0]=t,e[1]=o,e[2]=s.sessionId,e[3]=l):l=e[3],l}if(i==="transcript"){let l;return e[4]!==t||e[5]!==o||e[6]!==r||e[7]!==s?(l=a.jsx(LM,{agentKind:t,session:s,onSendCommand:r,children:o}),e[4]=t,e[5]=o,e[6]=r,e[7]=s,e[8]=l):l=e[8],l}return o}function zM(){return PN().section}function My(){const n=q.c(3),{canCreate:e,beginEditing:t}=PN();if(!e)return null;let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(zl,{"data-icon":"inline-start"}),n[0]=s):s=n[0];let r;return n[1]!==t?(r=a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:t,title:"Set a long-running goal for this session",children:[s,"Set goal"]}),n[1]=t,n[2]=r):r=n[2],r}const DM=["allow","allow_always","deny"],FM=[{decision:"allow",label:"Allow",variant:"default"},{decision:"deny",label:"Deny",variant:"destructive"},{decision:"allow_always",label:"Always",variant:"outline"}];function UM(n,e){return(n.availableDecisions??DM).includes(e)}function BM(n){const e=q.c(22),{request:t,queued:s,responding:r,onRespond:o}=n;let i;if(e[0]!==o||e[1]!==s||e[2]!==t||e[3]!==r){let l;e[5]!==t?(l=w=>UM(t,w.decision),e[5]=t,e[6]=l):l=e[6];const c=FM.filter(l);t.defaultToNo&&c.sort(qM);const u=c.some(WM);let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(B1,{className:"text-warning"}),e[7]=d):d=e[7];const f=t.title||`Allow ${t.toolName}?`;let m;e[8]!==f?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==s?(p=s>0&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",children:["+",s]}),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==m||e[13]!==p?(h=a.jsxs(Vt,{className:"flex min-w-0 items-center gap-2",children:[m,p]}),e[12]=m,e[13]=p,e[14]=h):h=e[14];let g;e[15]!==t.toolName?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:t.toolName}),e[15]=t.toolName,e[16]=g):g=e[16];let x;e[17]!==t.summary?(x=t.summary&&a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-xs text-foreground",children:t.summary}),e[17]=t.summary,e[18]=x):x=e[18];let b;e[19]!==g||e[20]!==x?(b=a.jsxs("div",{className:"col-start-2 mt-2 flex min-w-0 items-center gap-2",children:[g,x]}),e[19]=g,e[20]=x,e[21]=b):b=e[21],i=a.jsxs(wt,{className:"border-warning/40 bg-warning/5",children:[d,h,b,o&&(u?a.jsx("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:c.map(w=>{const{decision:v,label:k,variant:j}=w;return a.jsx(J,{autoFocus:t.defaultToNo&&v==="deny",size:"xs",variant:j,disabled:r,onClick:()=>o(t.requestId,v),children:k},`${t.requestId}:${v}`)})}):a.jsx("p",{className:"col-start-2 mt-2 text-xs text-warning",children:"Resolve this approval in its own provider"}))]}),e[0]=o,e[1]=s,e[2]=t,e[3]=r,e[4]=i}else i=e[4];return i}function WM(n){return n.decision!=="allow_always"}function qM(n,e){return+(e.decision==="deny")-+(n.decision==="deny")}const ON=y.createContext({size:"default",variant:"default",spacing:2,orientation:"horizontal"});function LN(n){const e=q.c(29);let t,s,r,o,i,l,c;e[0]!==n?({className:s,variant:c,size:o,spacing:i,orientation:l,children:t,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l,e[7]=c):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6],c=e[7]);const u=i===void 0?2:i,d=l===void 0?"horizontal":l;let f;e[8]!==u?(f={"--gap":u},e[8]=u,e[9]=f):f=e[9];const m=f;let p;e[10]!==s?(p=G("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",s),e[10]=s,e[11]=p):p=e[11];let h;e[12]!==d||e[13]!==o||e[14]!==u||e[15]!==c?(h={variant:c,size:o,spacing:u,orientation:d},e[12]=d,e[13]=o,e[14]=u,e[15]=c,e[16]=h):h=e[16];let g;e[17]!==t||e[18]!==h?(g=a.jsx(ON.Provider,{value:h,children:t}),e[17]=t,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==d||e[21]!==r||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==p||e[26]!==g||e[27]!==c?(x=a.jsx(iP,{"data-slot":"toggle-group","data-variant":c,"data-size":o,"data-spacing":u,"data-orientation":d,orientation:d,style:m,className:p,...r,children:g}),e[20]=d,e[21]=r,e[22]=o,e[23]=u,e[24]=m,e[25]=p,e[26]=g,e[27]=c,e[28]=x):x=e[28],x}function Cg(n){const e=q.c(19);let t,s,r,o,i;e[0]!==n?({className:s,children:t,variant:o,size:i,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=o===void 0?"default":o,c=i===void 0?"default":i,u=y.useContext(ON),d=u.variant||l,f=u.size||c,m=u.spacing;let p;e[6]!==s||e[7]!==u.size||e[8]!==u.variant||e[9]!==c||e[10]!==l?(p=G("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",aN({variant:u.variant||l,size:u.size||c}),s),e[6]=s,e[7]=u.size,e[8]=u.variant,e[9]=c,e[10]=l,e[11]=p):p=e[11];let h;return e[12]!==t||e[13]!==u.spacing||e[14]!==r||e[15]!==d||e[16]!==f||e[17]!==p?(h=a.jsx(yj,{"data-slot":"toggle-group-item","data-variant":d,"data-size":f,"data-spacing":m,className:p,...r,children:t}),e[12]=t,e[13]=u.spacing,e[14]=r,e[15]=d,e[16]=f,e[17]=p,e[18]=h):h=e[18],h}function VM(n){return n.some(e=>e.options.length===0||e.options.some(t=>t.hasPreview))}function HM(n){const e=q.c(64),{request:t,responding:s,gone:r,onAnswer:o,onOpenSession:i}=n,l=t.questions,[c,u]=y.useState(0);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const f=y.useRef(d);let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[1]=m):m=e[1];const[p,h]=y.useState(m);if(l.length===0)return null;if(VM(l)){let M;e[2]!==l[0].question?(M=a.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:l[0].question}),e[2]=l[0].question,e[3]=M):M=e[3];let D;e[4]===Symbol.for("react.memo_cache_sentinel")?(D=a.jsx(it,{"data-icon":"inline-end"}),e[4]=D):D=e[4];let F;e[5]!==i?(F=a.jsxs(J,{variant:"outline",size:"sm",onClick:i,className:"mt-3",children:["Open full question",D]}),e[5]=i,e[6]=F):F=e[6];let z;return e[7]!==M||e[8]!==F?(z=a.jsxs(zy,{children:[M,F]}),e[7]=M,e[8]=F,e[9]=z):z=e[9],z}const g=l[c],x=s||!o;let b;e[10]!==g.question||e[11]!==c||e[12]!==o||e[13]!==l.length||e[14]!==t.toolUseId?(b=function(D){const F={...f.current,[g.question]:D};if(c+1<l.length){f.current=F,h(new Set),u(c+1);return}o==null||o(t.toolUseId,F)},e[10]=g.question,e[11]=c,e[12]=o,e[13]=l.length,e[14]=t.toolUseId,e[15]=b):b=e[15];const w=b;let v;e[16]!==g.header?(v=g.header&&a.jsx(Ue,{variant:"outline",className:"border-info/40 text-info",children:g.header}),e[16]=g.header,e[17]=v):v=e[17];let k;e[18]!==c||e[19]!==l.length?(k=l.length>1&&a.jsxs("span",{className:"ml-auto shrink-0 font-mono text-xs text-muted-foreground",children:[c+1," of ",l.length]}),e[18]=c,e[19]=l.length,e[20]=k):k=e[20];let j;e[21]!==v||e[22]!==k?(j=a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[v,k]}),e[21]=v,e[22]=k,e[23]=j):j=e[23];let _;e[24]!==g.question?(_=a.jsx("p",{className:"mt-2 line-clamp-3 text-sm leading-relaxed text-foreground",title:g.question,children:g.question}),e[24]=g.question,e[25]=_):_=e[25];let N;e[26]!==p?(N=[...p],e[26]=p,e[27]=N):N=e[27];let S;e[28]!==w||e[29]!==g.multiSelect?(S=M=>{g.multiSelect?h(new Set(M)):M[0]&&w(M[0])},e[28]=w,e[29]=g.multiSelect,e[30]=S):S=e[30];const C=g.multiSelect,A=g.question;let T;if(e[31]!==g.options||e[32]!==x){let M;e[34]!==x?(M=D=>a.jsx(KM,{option:D,disabled:x},D.label),e[34]=x,e[35]=M):M=e[35],T=g.options.map(M),e[31]=g.options,e[32]=x,e[33]=T}else T=e[33];let I;e[36]!==g.multiSelect||e[37]!==g.question||e[38]!==T||e[39]!==N||e[40]!==S?(I=a.jsx(LN,{value:N,onValueChange:S,multiple:C,orientation:"vertical",variant:"outline",size:"sm",className:"mt-3 w-full items-stretch","aria-label":A,children:T}),e[36]=g.multiSelect,e[37]=g.question,e[38]=T,e[39]=N,e[40]=S,e[41]=I):I=e[41];let E;e[42]!==w||e[43]!==g.multiSelect||e[44]!==c||e[45]!==o||e[46]!==l.length||e[47]!==s||e[48]!==p?(E=g.multiSelect&&o&&a.jsx(J,{size:"sm",disabled:s||p.size===0,onClick:()=>w(wM(p)),children:c+1<l.length?"Next":"Send"}),e[42]=w,e[43]=g.multiSelect,e[44]=c,e[45]=o,e[46]=l.length,e[47]=s,e[48]=p,e[49]=E):E=e[49];let P;e[50]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsx(it,{"data-icon":"inline-end"}),e[50]=P):P=e[50];let R;e[51]!==i?(R=a.jsxs(J,{variant:"ghost",size:"sm",onClick:i,className:"ml-auto text-muted-foreground",children:["Open session",P]}),e[51]=i,e[52]=R):R=e[52];let L;e[53]!==E||e[54]!==R?(L=a.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[E,R]}),e[53]=E,e[54]=R,e[55]=L):L=e[55];let O;e[56]!==r?(O=r&&a.jsx("p",{className:"mt-2 text-xs text-warning",children:"This question may already be answered. Open the session to check."}),e[56]=r,e[57]=O):O=e[57];let $;return e[58]!==I||e[59]!==L||e[60]!==O||e[61]!==j||e[62]!==_?($=a.jsxs(zy,{children:[j,_,I,L,O]}),e[58]=I,e[59]=L,e[60]=O,e[61]=j,e[62]=_,e[63]=$):$=e[63],$}function KM(n){const e=q.c(17),{option:t,disabled:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];const o=r;if(!t.description){let d;return e[2]!==s||e[3]!==o||e[4]!==t.label?(d=a.jsx(Cg,{value:t.label,disabled:s,className:"w-full justify-start px-3",children:o}),e[2]=s,e[3]=o,e[4]=t.label,e[5]=d):d=e[5],d}let i;e[6]!==s||e[7]!==t.label?(i=a.jsx(Cg,{value:t.label,disabled:s,className:"w-full justify-start px-3"}),e[6]=s,e[7]=t.label,e[8]=i):i=e[8];let l;e[9]!==o||e[10]!==i?(l=a.jsx(Ut,{render:i,children:o}),e[9]=o,e[10]=i,e[11]=l):l=e[11];let c;e[12]!==t.description?(c=a.jsx(Bt,{side:"right",className:"max-w-72 text-left",children:t.description}),e[12]=t.description,e[13]=c):c=e[13];let u;return e[14]!==l||e[15]!==c?(u=a.jsxs(Ft,{children:[l,c]}),e[14]=l,e[15]=c,e[16]=u):u=e[16],u}function zy(n){const e=q.c(4),{children:t}=n;let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(aP,{className:"text-info"}),r=a.jsx(Vt,{children:"Answer to continue"}),e[0]=s,e[1]=r):(s=e[0],r=e[1]);let o;return e[2]!==t?(o=a.jsxs(wt,{className:"border-info/40 bg-info/5",children:[s,r,a.jsx("div",{className:"col-start-2 mt-1 min-w-0",children:t})]}),e[2]=t,e[3]=o):o=e[3],o}function GM(n){const e=q.c(45),{sessionId:t,pending:s,queued:r,responding:o,onRespond:i,onOpen:l}=n;switch(s.kind){case"permission":{let c;e[0]!==s||e[1]!==t?(c={...s,sessionId:t,timestamp:0},e[0]=s,e[1]=t,e[2]=c):c=e[2];let u;e[3]!==i?(u=(f,m)=>i(f,{decision:m}),e[3]=i,e[4]=u):u=e[4];let d;return e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==u?(d=a.jsx(BM,{request:c,queued:r,responding:o,onRespond:u}),e[5]=r,e[6]=o,e[7]=c,e[8]=u,e[9]=d):d=e[9],d}case"question":{const c=s.requestId;let u;e[10]!==s.questions?(u=s.questions.map(ZM),e[10]=s.questions,e[11]=u):u=e[11];let d;e[12]!==s.requestId||e[13]!==t||e[14]!==u?(d={sessionId:t,toolUseId:c,askedAt:0,questions:u},e[12]=s.requestId,e[13]=t,e[14]=u,e[15]=d):d=e[15];let f;e[16]!==i?(f=(p,h)=>i(p,{answers:h}),e[16]=i,e[17]=f):f=e[17];let m;return e[18]!==l||e[19]!==o||e[20]!==d||e[21]!==f?(m=a.jsx(HM,{request:d,responding:o,gone:!1,onAnswer:f,onOpenSession:l}),e[18]=l,e[19]=o,e[20]=d,e[21]=f,e[22]=m):m=e[22],m}case"plan":{let c,u;e[23]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(lP,{className:"text-info"}),u=a.jsx(Vt,{children:"Approve the plan?"}),e[23]=c,e[24]=u):(c=e[23],u=e[24]);let d;e[25]!==s.summary?(d=s.summary&&a.jsx("p",{className:"col-start-2 mt-1 line-clamp-3 text-sm text-foreground",children:s.summary}),e[25]=s.summary,e[26]=d):d=e[26];let f;e[27]!==i||e[28]!==s.requestId?(f=()=>i(s.requestId,{approved:!0}),e[27]=i,e[28]=s.requestId,e[29]=f):f=e[29];let m;e[30]!==o||e[31]!==f?(m=a.jsx(J,{size:"xs",disabled:o,onClick:f,children:"Approve"}),e[30]=o,e[31]=f,e[32]=m):m=e[32];let p;e[33]!==i||e[34]!==s.requestId?(p=()=>i(s.requestId,{approved:!1}),e[33]=i,e[34]=s.requestId,e[35]=p):p=e[35];let h;e[36]!==o||e[37]!==p?(h=a.jsx(J,{size:"xs",variant:"destructive",disabled:o,onClick:p,children:"Reject"}),e[36]=o,e[37]=p,e[38]=h):h=e[38];let g;e[39]!==m||e[40]!==h?(g=a.jsxs("div",{className:"col-start-2 mt-3 flex items-center gap-2",children:[m,h]}),e[39]=m,e[40]=h,e[41]=g):g=e[41];let x;return e[42]!==d||e[43]!==g?(x=a.jsxs(wt,{className:"border-info/40 bg-info/5",children:[c,u,d,g]}),e[42]=d,e[43]=g,e[44]=x):x=e[44],x}}}function ZM(n){return{question:n.question,multiSelect:n.multiSelect,options:n.options.map(YM)}}function YM(n){return{label:n,hasPreview:!1}}const XM=3e3;function JM(n){const[e,t]=y.useState([]),[s,r]=y.useState(new Set),o=y.useCallback(async l=>{if(n)try{const c=await Ee(`/api/session-requests?parent=${encodeURIComponent(n)}`);if(!l()||!c.ok)return;const u=await c.json();if(!l())return;t(d=>JSON.stringify(d)===JSON.stringify(u.requests)?d:u.requests)}catch{}},[n]);Ex(n?o:null,XM),y.useEffect(()=>{t([])},[n]);const i=y.useCallback(async(l,c,u)=>{r(d=>new Set(d).add(c));try{const d=await os("/api/session-respond",{sessionId:l,requestId:c,...u});(d.ok||d.status===404)&&t(f=>f.map(m=>m.sessionId===l?{...m,waiting:m.waiting.filter(p=>p.requestId!==c)}:m).filter(m=>m.waiting.length>0))}finally{r(d=>{const f=new Set(d);return f.delete(c),f})}},[]);return{requests:e,responding:s,respond:i}}function Ra(n){window.history.pushState({},"",n),window.dispatchEvent(new PopStateEvent("popstate"))}function zf(n,e,t){return`${t===void 0?bf():`/d/${encodeURIComponent(t)}`}/${encodeURIComponent(n)}/${encodeURIComponent(Kj(n,e))}`}async function Df(n){let e;try{e=await Ee(`/api/find-session/${encodeURIComponent(n)}`)}catch{return!1}const t=e.ok?await cr(e):null;return typeof(t==null?void 0:t.dirName)!="string"||typeof t.fileName!="string"?!1:(Ra(zf(t.dirName,t.fileName)),!0)}function QM(n){var o;if(!n.address)return null;const{dirName:e,fileName:t}=n.address,s=((o=n.device)==null?void 0:o.id)??Dt();return`${s===Tt?"":`/d/${encodeURIComponent(s)}`}/${encodeURIComponent(e)}/${encodeURIComponent(Kj(e,t))}`}function ez(n){const e=q.c(9),{sessionId:t}=n,{requests:s,responding:r,respond:o}=JM(t);if(s.length===0)return null;let i;if(e[0]!==s||e[1]!==o||e[2]!==r){let c;e[4]!==o||e[5]!==r?(c=u=>a.jsx(tz,{request:u,responding:r,onRespond:(d,f)=>void o(u.sessionId,d,f)},u.sessionId),e[4]=o,e[5]=r,e[6]=c):c=e[6],i=s.map(c),e[0]=s,e[1]=o,e[2]=r,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=a.jsx("div",{className:"flex flex-col gap-2 px-3 pb-2",children:i}),e[7]=i,e[8]=l):l=e[8],l}function tz(n){const e=q.c(26),{request:t,responding:s,onRespond:r}=n;let o;e[0]!==t?(o=QM(t),e[0]=t,e[1]=o):o=e[1];const i=o;let l;e[2]!==i?(l=()=>{i&&Ra(i)},e[2]=i,e[3]=l):l=e[3];const c=l,[u]=t.waiting;if(!u)return null;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(W1,{className:"size-3.5"}),e[4]=d):d=e[4];const f=t.device?`Delegated session on ${t.device.name}`:"Delegated session";let m;e[5]!==f?(m=a.jsx("span",{className:"truncate",children:f}),e[5]=f,e[6]=m):m=e[6];let p;e[7]!==c||e[8]!==i?(p=i&&a.jsxs(J,{variant:"ghost",size:"xs",className:"ml-auto",onClick:c,children:["Open",a.jsx(it,{"data-icon":"inline-end"})]}),e[7]=c,e[8]=i,e[9]=p):p=e[9];let h;e[10]!==m||e[11]!==p?(h=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d,m,p]}),e[10]=m,e[11]=p,e[12]=h):h=e[12];const g=u.requestId,x=t.sessionId,b=t.waiting.length-1;let w;e[13]!==u.requestId||e[14]!==s?(w=s.has(u.requestId),e[13]=u.requestId,e[14]=s,e[15]=w):w=e[15];let v;e[16]!==r||e[17]!==c||e[18]!==u||e[19]!==t.sessionId||e[20]!==b||e[21]!==w?(v=a.jsx(GM,{sessionId:x,pending:u,queued:b,responding:w,onRespond:r,onOpen:c},g),e[16]=r,e[17]=c,e[18]=u,e[19]=t.sessionId,e[20]=b,e[21]=w,e[22]=v):v=e[22];let k;return e[23]!==v||e[24]!==h?(k=a.jsxs("div",{className:"flex flex-col gap-1",children:[h,v]}),e[23]=v,e[24]=h,e[25]=k):k=e[25],k}const _g="cogpit-session-config-changed";function nz(n){if(typeof n!="string")return null;let e;try{e=JSON.parse(n)}catch{e=n.trim()}if(typeof e=="string")return e||null;const t=e==null?void 0:e.sessionId;return typeof t=="string"?t:null}function sz(n){function e(t){const s=nz(t.data);s&&window.dispatchEvent(new CustomEvent(_g,{detail:{sessionId:s}}))}return n.addEventListener(Xv,e),()=>n.removeEventListener(Xv,e)}function rz(n,e){function t(s){var r;((r=s.detail)==null?void 0:r.sessionId)===n&&e()}return window.addEventListener(_g,t),()=>window.removeEventListener(_g,t)}const Id=new Map;class oz extends EventTarget{constructor(t,s){super();Ze(this,"CONNECTING",0);Ze(this,"OPEN",1);Ze(this,"CLOSED",2);Ze(this,"withCredentials",!1);Ze(this,"onopen",null);Ze(this,"onmessage",null);Ze(this,"onerror",null);this.owner=t,this.options=s;for(const r of["open","message","error"])super.addEventListener(r,o=>{const i=r==="open"?this.onopen:r==="message"?this.onmessage:this.onerror;i==null||i.call(this,o)})}get url(){return this.owner.url}get readyState(){var t;return((t=this.owner.source)==null?void 0:t.readyState)??(this.owner.health.transport==="denied"?2:0)}addEventListener(t,s,r){this.owner.listen(t),super.addEventListener(t,s,r)}close(){this.owner.remove(this)}emit(t){this.dispatchEvent(t instanceof MessageEvent?new MessageEvent(t.type,{data:t.data,origin:t.origin,lastEventId:t.lastEventId}):new Event(t.type))}}class iz{constructor(e,t){Ze(this,"source",null);Ze(this,"health",{transport:"connecting",freshness:"waiting",lastEventAt:null});Ze(this,"subscribers",new Set);Ze(this,"types",new Set(["open","error","message","access","session-config"]));Ze(this,"linked",new Set);Ze(this,"asking",null);Ze(this,"timer");Ze(this,"attempts",0);Ze(this,"generation",0);Ze(this,"retryingGeneration",null);Ze(this,"stopped",!1);Ze(this,"stopFrames",[]);Ze(this,"foreground",()=>{document.visibilityState==="hidden"||this.stopped||this.health.transport==="denied"||(!this.source||this.health.transport!=="open"||this.health.lastEventAt!==null&&Date.now()-this.health.lastEventAt>45e3)&&this.connect()});Ze(this,"identityChanged",()=>this.stop());this.key=e,this.url=t,window.addEventListener("online",this.foreground),document.addEventListener("visibilitychange",this.foreground),window.addEventListener("cogpit-identity-changed",this.identityChanged),window.addEventListener("cogpit-device-scope-changed",this.identityChanged),this.connect()}add(e){const t=new oz(this,e);return this.subscribers.add(t),queueMicrotask(()=>{var s,r;this.subscribers.has(t)&&((s=e.onState)==null||s.call(e,this.health),this.health.transport==="open"?t.emit(new Event("open")):this.health.transport==="denied"&&((r=e.onLost)==null||r.call(e)))}),t}remove(e){this.subscribers.delete(e),this.subscribers.size||this.stop()}listen(e){this.types.add(e),this.link(e)}link(e){const t=this.source,s=this.generation;!t||this.linked.has(e)||(this.linked.add(e),t.addEventListener(e,r=>{if(!(this.stopped||s!==this.generation)){if(e==="open")this.attempts=0,this.setHealth({...this.health,transport:"open"});else if(e==="error"){if(this.retryingGeneration===s)return;this.retryingGeneration=s,this.setHealth({...this.health,transport:"retrying",freshness:"stale"});const o=t.readyState===EventSource.CLOSED;t.close(),this.retry(s,o)}else this.setHealth({transport:"open",freshness:"current",lastEventAt:Date.now()});for(const o of this.subscribers)o.emit(r)}}))}setHealth(e){var t,s;this.health=e;for(const r of this.subscribers)(s=(t=r.options).onState)==null||s.call(t,e)}connect(){var e,t;if(!this.stopped){clearTimeout(this.timer),(e=this.asking)==null||e.abort();for(const s of this.stopFrames)s();(t=this.source)==null||t.close(),this.generation++,this.retryingGeneration=null,this.linked.clear(),this.setHealth({...this.health,transport:"connecting"}),this.source=new EventSource(this.url),this.stopFrames=[Y$(this.source),sz(this.source)];for(const s of this.types)this.link(s)}}async retry(e,t){var o,i,l;const s=new AbortController;if(this.asking=s,t)try{const c=await Ee(this.url,{signal:s.signal});if((o=c.body)==null||o.cancel(),this.stopped||e!==this.generation||s.signal.aborted)return;if(c.status===401||c.status===403||s4(c)){this.setHealth({...this.health,transport:"denied",freshness:"stale"});for(const u of this.subscribers)(l=(i=u.options).onLost)==null||l.call(i);return}}catch{if(this.stopped||s.signal.aborted)return}if(this.stopped||e!==this.generation)return;const r=Math.min(3e4,500*2**Math.min(this.attempts++,6))*(.75+Math.random()*.5);this.timer=setTimeout(()=>this.connect(),r)}stop(){var e,t;this.stopped=!0,this.generation++,clearTimeout(this.timer),(e=this.asking)==null||e.abort(),(t=this.source)==null||t.close();for(const s of this.stopFrames)s();window.removeEventListener("online",this.foreground),document.removeEventListener("visibilitychange",this.foreground),window.removeEventListener("cogpit-identity-changed",this.identityChanged),window.removeEventListener("cogpit-device-scope-changed",this.identityChanged),this.setHealth({...this.health,transport:"closed",freshness:"stale"}),Id.get(this.key)===this&&Id.delete(this.key)}}function Bx(n,e={}){const t=wf(n),s=JSON.stringify([Jt(),Zn(),t]);let r=Id.get(s);r||(r=new iz(s,t),Id.set(s,r));const o=r.add(e);return{source:o,close:()=>o.close(),state:()=>r.health}}function Cc({className:n,children:e,...t}){return a.jsxs(cP,{"data-slot":"scroll-area",className:G("relative overflow-hidden",n),...t,children:[a.jsx(uP,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:e}),a.jsx(az,{}),a.jsx(dP,{})]})}function az({className:n,orientation:e="vertical",...t}){return a.jsx(fP,{"data-slot":"scroll-area-scrollbar","data-orientation":e,orientation:e,className:G("flex touch-none p-px transition-colors select-none data-[orientation=horizontal]:h-2.5 data-[orientation=horizontal]:flex-col data-[orientation=horizontal]:border-t data-[orientation=horizontal]:border-t-transparent data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent",n),...t,children:a.jsx(mP,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function MN({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.2"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function lz({className:n,...e}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:a.jsx("path",{className:"status-icon-complete",d:"M20 6L9 17L4 12"})})}function cz({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:G("size-5",n),...e,children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function uz({className:n,...e}){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",className:G("status-icon-spin size-5",n),...e,children:[a.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.1"}),a.jsx("path",{d:"M12 2A10 10 0 0 1 22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),a.jsx("path",{d:"M12 22A10 10 0 0 1 2 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Pn({className:n,...e}){const t=n==null?void 0:n.replace(/\banimate-spin\b/g,"").trim();return a.jsx(MN,{className:G(t),...e})}function dz(n){const e=xn("hostFiles"),[t,s]=y.useState([]),[r,o]=y.useState(!1),i=y.useCallback(async()=>{if(!e||!n){s([]);return}o(!0);try{const l=await Ee(`/api/scripts?dir=${encodeURIComponent(n)}`);if(l.ok){const c=await l.json();s(c)}}catch{}finally{o(!1)}},[e,n]);return y.useEffect(()=>{i()},[i]),{scripts:t,loading:r,refresh:i}}const Dy=500,fz=5e3;function mz(n){const e=q.c(29),t=n===void 0?!0:n,[s,r]=y.useState("disconnected");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const[i,l]=y.useState(o),c=y.useRef(null);let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,e[1]=u):u=e[1];const d=y.useRef(u),f=y.useRef(Dy),m=y.useRef(null),p=y.useRef(!1),h=y.useRef(pz);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=D=>{var B;const F=D.type,z=D.id;if(F==="sessions"){l(D.sessions??[]);return}z&&((B=d.current.get(z))==null||B(F,D))},e[2]=g):g=e[2];const x=g;let b,w;e[3]!==t?(b=()=>{if(p.current=!1,!t)return()=>{p.current=!0};const D=function(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Zj()}/__pty`},F=function(){if(p.current||c.current&&c.current.readyState!==WebSocket.CLOSED)return;r("connecting");const B=new WebSocket(D());c.current=B,B.onopen=()=>{if(p.current){B.close();return}f.current=Dy,r("connected"),B.send(JSON.stringify({type:"list"}))},B.onmessage=U=>{try{const W=JSON.parse(U.data);x(W)}catch{}},B.onclose=()=>{if(p.current)return;r("disconnected"),c.current=null;const U=f.current;f.current=Math.min(U*2,fz),m.current=setTimeout(()=>h.current(),U)}};return h.current=F,F(),()=>{p.current=!0,m.current&&(clearTimeout(m.current),m.current=null),c.current&&(c.current.onclose=null,c.current.close(),c.current=null)}},w=[t,x],e[3]=t,e[4]=b,e[5]=w):(b=e[4],w=e[5]),y.useEffect(b,w);let v;e[6]!==t?(v=D=>{if(!t)return;const F=c.current;F&&F.readyState===WebSocket.OPEN&&F.send(JSON.stringify(D))},e[6]=t,e[7]=v):v=e[7];const k=v;let j;e[8]===Symbol.for("react.memo_cache_sentinel")?(j=(D,F)=>{d.current.set(D,F)},e[8]=j):j=e[8];const _=j;let N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=D=>{d.current.delete(D)},e[9]=N):N=e[9];const S=N;let C;e[10]!==k?(C=D=>{const F=D===void 0?{}:D,z=`pty_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:z,name:F.name??"Terminal",cwd:F.cwd,metadata:{type:"terminal"}}),z},e[10]=k,e[11]=C):C=e[11];const A=C;let T;e[12]!==k?(T=D=>{const F=`script_${crypto.randomUUID().slice(0,8)}`;return k({type:"spawn",id:F,name:D.name,cwd:D.cwd,args:["run",D.scriptName],command:"bun",metadata:{type:"script",source:D.source,scriptName:D.scriptName}}),F},e[12]=k,e[13]=T):T=e[13];const I=T;let E;e[14]!==k?(E=D=>{k({type:"kill",id:D})},e[14]=k,e[15]=E):E=e[15];const P=E;let R;e[16]!==k?(R=(D,F)=>{k({type:"input",id:D,data:F})},e[16]=k,e[17]=R):R=e[17];const L=R;let O;e[18]!==k?(O=(D,F,z)=>{k({type:"resize",id:D,cols:F,rows:z})},e[18]=k,e[19]=O):O=e[19];const $=O;let M;return e[20]!==P||e[21]!==$||e[22]!==k||e[23]!==i||e[24]!==I||e[25]!==A||e[26]!==s||e[27]!==L?(M={status:s,send:k,subscribe:_,unsubscribe:S,sessions:i,spawnTerminal:A,spawnScript:I,killSession:P,writeInput:L,resize:$},e[20]=P,e[21]=$,e[22]=k,e[23]=i,e[24]=I,e[25]=A,e[26]=s,e[27]=L,e[28]=M):M=e[28],M}function pz(){}const zN=y.createContext(null);function Wm(n){const e=q.c(3),{children:t,enabled:s}=n,o=mz(s===void 0?!0:s);let i;return e[0]!==t||e[1]!==o?(i=a.jsx(zN.Provider,{value:o,children:t}),e[0]=t,e[1]=o,e[2]=i):i=e[2],i}function Wx(){const n=y.useContext(zN);if(!n)throw new Error("usePty must be used within a PtyProvider");return n}function hz(n){var d;const e=q.c(11),t=Wx();let s;if(e[0]!==t.sessions){s=new Map;for(const f of t.sessions)((d=f.metadata)==null?void 0:d.type)==="script"&&s.set(f.id,{id:f.id,name:f.name,cwd:f.cwd,status:f.status==="running"?"running":"stopped",source:f.metadata.source??"root/"});e[0]=t.sessions,e[1]=s}else s=e[1];const r=s;let o;e[2]!==n||e[3]!==t?(o=(f,m,p)=>{const h=t.spawnScript({name:f,cwd:m,source:p,scriptName:f}),g=p==="root/"?f:`${p.replace(/\/$/,"")}:${f}`;n==null||n({id:h,name:g,type:"script",status:"running",source:p})},e[2]=n,e[3]=t,e[4]=o):o=e[4];const i=o;let l;e[5]!==t?(l=f=>{t.killSession(f)},e[5]=t,e[6]=l):l=e[6];const c=l;let u;return e[7]!==i||e[8]!==r||e[9]!==c?(u={runningProcesses:r,runScript:i,stopScript:c},e[7]=i,e[8]=r,e[9]=c,e[10]=u):u=e[10],u}function gz(n){const e=q.c(14),{script:t,status:s,onRun:r,onStop:o}=n,i=s==="running";let l="bg-transparent";i?l="bg-primary":s==="errored"&&(l="bg-destructive");const c=i?o:r,u=i?`Stop ${t.name}`:`Run: ${t.command}`;let d;e[0]!==l?(d=G("size-1.5 shrink-0 rounded-full",l),e[0]=l,e[1]=d):d=e[1];let f;e[2]!==d?(f=a.jsx("span",{className:d}),e[2]=d,e[3]=f):f=e[3];let m;e[4]!==t.name?(m=a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.name}),e[4]=t.name,e[5]=m):m=e[5];let p;e[6]!==i?(p=i?a.jsx(U1,{"data-icon":"inline-end",className:"fill-current text-destructive"}):a.jsx(va,{"data-icon":"inline-end",className:"opacity-0 text-muted-foreground transition-opacity group-hover:opacity-100"}),e[6]=i,e[7]=p):p=e[7];let h;return e[8]!==c||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==p?(h=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"motion-list-item group w-full justify-start px-2",onClick:c,title:u,children:[f,m,p]}),e[8]=c,e[9]=u,e[10]=f,e[11]=m,e[12]=p,e[13]=h):h=e[13],h}const xz=y.memo(function(e){const t=q.c(42),{projectDir:s,onProcessStarted:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,t[0]=u):u=t[0];const[d,f]=y.useState(u),{scripts:m,loading:p}=dz(s),{runningProcesses:h,runScript:g,stopScript:x}=hz(r);let b;if(t[1]!==m||t[2]!==l){const F=l.trim().toLowerCase(),z=F?m.filter(B=>B.name.toLowerCase().includes(F)||B.dirLabel.toLowerCase().includes(F)):m;b=new Map;for(const B of z){const U=b.get(B.dirLabel)??[];U.push(B),b.set(B.dirLabel,U)}t[1]=m,t[2]=l,t[3]=b}else b=t[3];const w=b;let v;if(t[4]!==h){v=new Map;for(const[F,z]of h)v.set(`${z.name}:${z.cwd}`,{id:F,status:z.status});t[4]=h,t[5]=v}else v=t[5];const k=v;if(!s||!p&&m.length===0)return null;let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=function(z){f(B=>{const U=new Set(B);return U.has(z)?U.delete(z):U.add(z),U})},t[6]=j):j=t[6];const _=j;let N;t[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:"Scripts"}),t[7]=N):N=t[7];let S;t[8]!==p?(S=p&&a.jsx(Pn,{className:"size-3 text-muted-foreground","aria-label":"Loading scripts"}),t[8]=p,t[9]=S):S=t[9];const C=o?"Close script search":"Search scripts";let A,T;t[10]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{i(bz),c("")},T=a.jsx(ss,{}),t[10]=A,t[11]=T):(A=t[10],T=t[11]);let I;t[12]!==o||t[13]!==C?(I=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":C,"aria-expanded":o,onClick:A,children:T}),t[12]=o,t[13]=C,t[14]=I):I=t[14];let E;t[15]!==S||t[16]!==I?(E=a.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-2",children:[N,S,I]}),t[15]=S,t[16]=I,t[17]=E):E=t[17];let P;t[18]!==o||t[19]!==l?(P=o&&a.jsx("div",{className:"motion-slide-down-in px-2 pb-2",children:a.jsx(zn,{type:"search",value:l,onChange:F=>c(F.target.value),placeholder:"Filter scripts...","aria-label":"Filter scripts",className:"h-7",autoFocus:!0})}),t[18]=o,t[19]=l,t[20]=P):P=t[20];let R;t[21]!==d||t[22]!==w||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==x?(R=[...w.entries()].map(F=>{const[z,B]=F,U=d.has(z)||!!l,W=B.filter(vz),V=B.filter(yz),H=U?B:W.length>0?W:B.slice(0,1);return a.jsxs("div",{className:"flex flex-col gap-0.5 pb-1",children:[w.size>1&&a.jsx("div",{className:"truncate px-2 pt-1 text-xs text-muted-foreground",children:z}),H.map(K=>{const Z=k.get(`${K.name}:${K.dir}`);return a.jsx(gz,{script:K,status:(Z==null?void 0:Z.status)??null,onRun:()=>g(K.name,K.dir,K.dirLabel),onStop:()=>{Z&&x(Z.id)}},`${z}:${K.name}`)}),!l&&V.length>0&&a.jsx(J,{type:"button",variant:"link",size:"sm",className:"h-auto justify-start px-2 py-1",onClick:()=>_(z),children:U?"Show less":`Show ${V.length} more`})]},z)}),t[21]=d,t[22]=w,t[23]=g,t[24]=k,t[25]=l,t[26]=x,t[27]=R):R=t[27];let L;t[28]!==w.size||t[29]!==p||t[30]!==l?(L=!p&&w.size===0&&l&&a.jsx(Cn,{className:"gap-1 p-3",children:a.jsxs(_n,{className:"gap-1",children:[a.jsx(En,{children:"No matching scripts"}),a.jsx(Tn,{children:"Try another name."})]})}),t[28]=w.size,t[29]=p,t[30]=l,t[31]=L):L=t[31];let O;t[32]!==R||t[33]!==L?(O=a.jsxs(Cc,{className:"min-h-0 flex-1 px-1 pb-1",children:[R,L]}),t[32]=R,t[33]=L,t[34]=O):O=t[34];let $;t[35]!==P||t[36]!==O||t[37]!==E?($=a.jsxs("section",{className:"flex w-56 shrink-0 flex-col","aria-label":"Scripts",children:[E,P,O]}),t[35]=P,t[36]=O,t[37]=E,t[38]=$):$=t[38];let M;t[39]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(Qt,{orientation:"vertical"}),t[39]=M):M=t[39];let D;return t[40]!==$?(D=a.jsxs(a.Fragment,{children:[$,M]}),t[40]=$,t[41]=D):D=t[41],D});function bz(n){return!n}function vz(n){return n.isCommon}function yz(n){return!n.isCommon}function DN({className:n,orientation:e="horizontal",...t}){return a.jsx(xP,{"data-slot":"tabs","data-orientation":e,className:G("group/tabs relative flex gap-2 data-[orientation=horizontal]:flex-col","has-[>[data-slot=tabs-content]]:grid has-[>[data-slot=tabs-content]]:grid-cols-1 [&>[data-slot=tabs-list]]:col-start-1 [&>[data-slot=tabs-list]]:row-start-1 [&>[data-slot=tabs-content]]:col-start-1 [&>[data-slot=tabs-content]]:row-start-2","data-[orientation=vertical]:has-[>[data-slot=tabs-content]]:grid-cols-[auto_minmax(0,1fr)] data-[orientation=vertical]:[&>[data-slot=tabs-content]]:col-start-2 data-[orientation=vertical]:[&>[data-slot=tabs-content]]:row-start-1",n),...t})}const wz=Qr("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function FN({className:n,children:e,variant:t="default",...s}){return a.jsxs(hP,{"data-slot":"tabs-list","data-variant":t,className:G(wz({variant:t}),"relative isolate",n),...s,children:[e,a.jsx(gP,{"data-slot":"tabs-indicator","data-variant":t,className:G("pointer-events-none absolute top-0 left-0 z-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) translate-y-(--active-tab-top) transition-[translate,width,height] duration-150 ease-out motion-reduce:transition-none after:absolute after:content-['']","data-[variant=default]:after:inset-0 data-[variant=default]:after:rounded-md data-[variant=default]:after:bg-background data-[variant=default]:after:shadow-sm","data-[variant=line]:after:bg-foreground data-[variant=line]:data-[orientation=horizontal]:after:inset-x-0 data-[variant=line]:data-[orientation=horizontal]:after:-bottom-[5px] data-[variant=line]:data-[orientation=horizontal]:after:h-0.5 data-[variant=line]:data-[orientation=vertical]:after:inset-y-0 data-[variant=line]:data-[orientation=vertical]:after:-right-1 data-[variant=line]:data-[orientation=vertical]:after:w-0.5")})]})}function el({className:n,...e}){return a.jsx(bP,{"data-slot":"tabs-trigger",className:G("relative z-10 inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 outline-none transition-[color,border-color,box-shadow,transform,scale] duration-100 ease-out group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground active:scale-[0.98] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-foreground dark:text-muted-foreground dark:hover:text-foreground dark:data-active:text-foreground motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n),...e})}function tl({className:n,...e}){return a.jsx(pP,{"data-slot":"tabs-content",className:G("flex-1 text-sm outline-none transition-[opacity,translate] duration-150 ease-out motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none","motion-safe:data-starting-style:data-[activation-direction=left]:translate-x-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=right]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=left]:translate-x-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=right]:translate-x-[-0.25rem]","motion-safe:data-starting-style:data-[activation-direction=up]:translate-y-[-0.25rem] motion-safe:data-starting-style:data-[activation-direction=down]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=up]:translate-y-[0.25rem] motion-safe:data-ending-style:data-[activation-direction=down]:translate-y-[-0.25rem]",n),...e})}const Sz=y.lazy(()=>nt(()=>import("./TerminalOutput-CsysWxZc.js"),__vite__mapDeps([0,1,2,3,4])).then(n=>({default:n.TerminalOutput})));function kz({process:n}){const[e,t]=y.useState(""),[s,r]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(n.type!=="task"||!n.outputPath)return;t(""),r(!1);const i=Bx(`/api/task-output?path=${encodeURIComponent(n.outputPath)}`),l=i.source;return l.onopen=()=>r(!0),l.onmessage=c=>{try{const u=JSON.parse(c.data);if(u.type==="output"&&u.text){const d=B4(u.text);d&&t(f=>{const m=f+d;return m.length>1e5?m.slice(-1e5):m})}}catch{}},i.close},[n.id,n.type,n.outputPath]),y.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[e]),a.jsx("pre",{ref:o,className:"flex-1 overflow-auto bg-background px-3 py-2 font-mono text-xs leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e||a.jsx("span",{className:"text-muted-foreground",children:s?"Waiting for output...":"Connecting..."})})}function jz(n){const e=q.c(34),{process:t,isActive:s,onSelectActive:r,onClose:o,mobile:i}=n,l=t.source??t.name,c=t.id,u=t.name;let d;e[0]!==s||e[1]!==r?(d=()=>{s&&r()},e[0]=s,e[1]=r,e[2]=d):d=e[2];const f=i?"gap-1 px-1.5":"gap-1.5 px-2";let m;e[3]!==f?(m=G("h-6 min-w-0 justify-start py-0 text-xs",f),e[3]=f,e[4]=m):m=e[4];let p;e[5]!==t.status?(p=t.status==="running"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-success"}),e[5]=t.status,e[6]=p):p=e[6];let h;e[7]!==t.status?(h=t.status==="errored"&&a.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-destructive"}),e[7]=t.status,e[8]=h):h=e[8];let g;e[9]!==t.name?(g=a.jsx("span",{className:"truncate max-w-[100px]",children:t.name}),e[9]=t.name,e[10]=g):g=e[10];const x=i&&"hidden";let b;e[11]!==x?(b=G("px-1 py-0 font-normal",x),e[11]=x,e[12]=b):b=e[12];let w;e[13]!==t.type||e[14]!==b?(w=a.jsx(Ue,{variant:"secondary",className:b,children:t.type}),e[13]=t.type,e[14]=b,e[15]=w):w=e[15];let v;e[16]!==t.id||e[17]!==t.name||e[18]!==w||e[19]!==d||e[20]!==m||e[21]!==p||e[22]!==h||e[23]!==g?(v=a.jsxs(el,{value:c,"aria-label":u,onClick:d,className:m,children:[p,h,g,w]}),e[16]=t.id,e[17]=t.name,e[18]=w,e[19]=d,e[20]=m,e[21]=p,e[22]=h,e[23]=g,e[24]=v):v=e[24];const k=`Close ${t.name}`,j=`Close ${t.name}`;let _;e[25]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx(At,{"data-icon":"inline-start"}),e[25]=_):_=e[25];let N;e[26]!==o||e[27]!==k||e[28]!==j?(N=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs","aria-label":k,title:j,onClick:o,className:"mr-0.5 text-muted-foreground",children:_}),e[26]=o,e[27]=k,e[28]=j,e[29]=N):N=e[29];let S;return e[30]!==l||e[31]!==v||e[32]!==N?(S=a.jsxs("div",{title:l,className:"inline-flex h-6 shrink-0 items-center",children:[v,N]}),e[30]=l,e[31]=v,e[32]=N,e[33]=S):S=e[33],S}const UN=100,BN=600,Nz=200,WN="process-panel-height";function Cz(){try{const n=localStorage.getItem(WN);if(n)return Math.min(BN,Math.max(UN,Number(n)))}catch{}return Nz}const _z=y.memo(function(e){const t=q.c(89),{processes:s,activeProcessId:r,collapsed:o,onSetActive:i,onRemove:l,onToggleCollapse:c,onRequestTerminal:u,onAddTerminalContext:d,onUpdateStatus:f,projectDir:m,onProcessStarted:p,mobile:h}=e,g=h===void 0?!1:h,x=Wx(),[b,w]=y.useState(Cz),v=y.useRef(null);let k,j;t[0]!==f||t[1]!==x.sessions?(k=()=>{for(const ce of x.sessions)ce.status==="exited"&&(f==null||f(ce.id,"stopped"))},j=[x.sessions,f],t[0]=f,t[1]=x.sessions,t[2]=k,t[3]=j):(k=t[2],j=t[3]),y.useEffect(k,j);let _;t[4]!==l||t[5]!==x?(_=ce=>{ce.type!=="task"&&x.killSession(ce.id),l(ce.id)},t[4]=l,t[5]=x,t[6]=_):_=t[6];const N=_;let S;t[7]!==b?(S=ce=>{ce.preventDefault(),v.current={startY:ce.clientY,startH:b},ce.target.setPointerCapture(ce.pointerId)},t[7]=b,t[8]=S):S=t[8];const C=S;let A;t[9]===Symbol.for("react.memo_cache_sentinel")?(A=ce=>{if(!v.current)return;const xe=v.current.startY-ce.clientY,pe=Math.min(BN,Math.max(UN,v.current.startH+xe));w(pe)},t[9]=A):A=t[9];const T=A;let I;t[10]!==b?(I=()=>{if(v.current){v.current=null;try{localStorage.setItem(WN,String(b))}catch{}}},t[10]=b,t[11]=I):I=t[11];const E=I;let P;t[12]!==r||t[13]!==s?(P=r?s.get(r):null,t[12]=r,t[13]=s,t[14]=P):P=t[14];const R=P;let L;t[15]!==s?(L=[...s.values()],t[15]=s,t[16]=L):L=t[16];const O=L;let $;t[17]!==i?($=ce=>{typeof ce=="string"&&i(ce)},t[17]=i,t[18]=$):$=t[18];let M;t[19]!==R||t[20]!==o||t[21]!==g||t[22]!==C||t[23]!==E?(M=!g&&!o&&R&&a.jsx("div",{className:"h-1 cursor-row-resize transition-colors hover:bg-accent active:bg-muted-foreground/30",onPointerDown:C,onPointerMove:T,onPointerUp:E,onPointerCancel:E}),t[19]=R,t[20]=o,t[21]=g,t[22]=C,t[23]=E,t[24]=M):M=t[24];const D=g?"h-7 gap-1 px-2":"h-8 gap-2 px-3";let F;t[25]!==D?(F=G("flex shrink-0 items-center border-b bg-card",D),t[25]=D,t[26]=F):F=t[26];const z=o?"Expand terminal panel":"Collapse terminal panel",B=!o;let U;t[27]!==o?(U=o?a.jsx(it,{"data-icon":"inline-start"}):a.jsx(Wt,{"data-icon":"inline-start"}),t[27]=o,t[28]=U):U=t[28];const W=g&&"sr-only";let V;t[29]!==W?(V=G(W),t[29]=W,t[30]=V):V=t[30];let H;t[31]!==V?(H=a.jsx("span",{className:V,children:"Terminal"}),t[31]=V,t[32]=H):H=t[32];let K;t[33]!==c||t[34]!==z||t[35]!==B||t[36]!==U||t[37]!==H?(K=a.jsxs(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:c,"aria-label":z,"aria-expanded":B,children:[U,H]}),t[33]=c,t[34]=z,t[35]=B,t[36]=U,t[37]=H,t[38]=K):K=t[38];const Z=!g&&"ml-2";let Y;t[39]!==Z?(Y=G("min-w-0 flex-1 justify-start overflow-x-auto no-scrollbar",Z),t[39]=Z,t[40]=Y):Y=t[40];let X;t[41]!==r||t[42]!==N||t[43]!==g||t[44]!==i||t[45]!==O?(X=O.map(ce=>a.jsx(jz,{process:ce,isActive:ce.id===r,onSelectActive:()=>i(ce.id),onClose:()=>N(ce),mobile:g},ce.id)),t[41]=r,t[42]=N,t[43]=g,t[44]=i,t[45]=O,t[46]=X):X=t[46];let ee;t[47]!==Y||t[48]!==X?(ee=a.jsx(FN,{variant:"default","aria-label":"Open processes",className:Y,children:X}),t[47]=Y,t[48]=X,t[49]=ee):ee=t[49];let Q;t[50]!==u||t[51]!==m?(Q=u&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",disabled:!m,onClick:u,"aria-label":"New terminal",title:m?"New terminal":"Open a project to start a terminal",children:a.jsx(xr,{})}),t[50]=u,t[51]=m,t[52]=Q):Q=t[52];let ne;t[53]!==F||t[54]!==K||t[55]!==ee||t[56]!==Q?(ne=a.jsxs("div",{className:F,children:[K,ee,Q]}),t[53]=F,t[54]=K,t[55]=ee,t[56]=Q,t[57]=ne):ne=t[57];const te=!o,re=g?"min(36dvh, 260px)":b;let oe;t[58]!==re?(oe={height:re},t[58]=re,t[59]=oe):oe=t[59];let ie;t[60]!==g||t[61]!==p||t[62]!==m?(ie=!g&&a.jsx(xz,{projectDir:m,onProcessStarted:p}),t[60]=g,t[61]=p,t[62]=m,t[63]=ie):ie=t[63];let ae;t[64]!==N||t[65]!==d||t[66]!==u||t[67]!==O?(ae=O.map(ce=>a.jsx(tl,{value:ce.id,className:"col-start-1 row-start-1 flex min-h-0 flex-col",children:ce.type==="task"?a.jsx(kz,{process:ce}):a.jsx(y.Suspense,{fallback:a.jsx("div",{className:"flex size-full items-center justify-center text-xs text-muted-foreground",children:"Loading terminal…"}),children:a.jsx(Sz,{processId:ce.id,autoFocus:!0,onRequestNew:u,onRequestClose:()=>N(ce),onAddContext:d})})},ce.id)),t[64]=N,t[65]=d,t[66]=u,t[67]=O,t[68]=ae):ae=t[68];let de;t[69]!==R||t[70]!==u||t[71]!==m?(de=!R&&a.jsxs(Cn,{className:"col-start-1 row-start-1 rounded-none",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(ya,{})}),a.jsx(En,{children:"No terminal open"}),a.jsx(Tn,{children:"Start a terminal here or run a project script from the left."})]}),u&&m&&a.jsx(vc,{children:a.jsxs(J,{type:"button",size:"sm",onClick:u,children:[a.jsx(xr,{"data-icon":"inline-start"}),"New terminal"]})})]}),t[69]=R,t[70]=u,t[71]=m,t[72]=de):de=t[72];let le;t[73]!==ae||t[74]!==de?(le=a.jsxs("div",{className:"grid min-h-0 min-w-0 flex-1 grid-cols-1",children:[ae,de]}),t[73]=ae,t[74]=de,t[75]=le):le=t[75];let se;t[76]!==oe||t[77]!==ie||t[78]!==le?(se=a.jsx(In,{children:a.jsxs("div",{className:"flex min-h-0",style:oe,children:[ie,le]})}),t[76]=oe,t[77]=ie,t[78]=le,t[79]=se):se=t[79];let me;t[80]!==te||t[81]!==se?(me=a.jsx(An,{open:te,className:"min-h-0",children:se}),t[80]=te,t[81]=se,t[82]=me):me=t[82];let ue;return t[83]!==r||t[84]!==$||t[85]!==M||t[86]!==ne||t[87]!==me?(ue=a.jsxs(DN,{value:r,onValueChange:$,className:"shrink-0 gap-0 border-t bg-background",children:[M,ne,me]}),t[83]=r,t[84]=$,t[85]=M,t[86]=ne,t[87]=me,t[88]=ue):ue=t[88],ue});function _c(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const Ez=/(?::(\d{4,5}))|(?:port\s+(\d{4,5}))|(?:localhost:(\d{4,5}))/gi;function Tz(n){const e=new Set;for(const t of n.matchAll(Ez)){const s=parseInt(t[1]||t[2]||t[3],10);s>0&&s<65536&&e.add(s)}return[...e]}function Az(n){var s;const e=q.c(2);let t;if(e[0]!==n){t=new Map;for(let r=0;r<n.length;r++)for(const o of n[r].toolCalls){if(o.name!=="Bash"||!o.input.run_in_background)continue;const i=o.input.command||"",l=o.input.description||"",c=((s=n[r].assistantText)==null?void 0:s.join(" "))||"",u=[i,l,o.result||"",c].join(" "),d=Tz(u);if(d.length===0){const p=i.toLowerCase();(p.includes("run dev")||p.includes("next dev")||p.includes("vite"))&&d.push(3e3)}const f=(o.result||"").match(/Output is being written to:\s*(\S+)/),m=f?f[1]:null;for(const p of d)t.set(p,{description:l||i.replace(/^cd\s+"[^"]*"\s*&&\s*/,"").slice(0,60),outputPath:m})}e[0]=n,e[1]=t}else t=e[1];return t}function Fy(n){var e;return((e=n.preview.split(`
|
|
10
10
|
`).find(t=>t.trim()))==null?void 0:e.trim())||`Task ${n.id}`}function Iz(n){const e=q.c(10),{port:t,isActive:s}=n,r=s?"bg-success":"bg-muted-foreground/40";let o;e[0]!==r?(o=G("inline-block size-1.5 rounded-full",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==o?(i=a.jsx("span",{className:o}),e[2]=o,e[3]=i):i=e[3];const l=s?"text-success":"text-muted-foreground";let c;e[4]!==t||e[5]!==l?(c=a.jsxs("span",{className:l,children:[":",t]}),e[4]=t,e[5]=l,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(Ue,{variant:"secondary",className:"font-mono",children:[i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function qN({cwd:n,turns:e,canStop:t=!1,onToggleServer:s,onServersChanged:r}){const[o,i]=y.useState([]),l=Az(e);y.useEffect(()=>{if(!n)return;let u=!1;async function d(){try{const m=await Ee(`/api/background-tasks?cwd=${encodeURIComponent(n)}`);if(u)return;if(m.ok){const g=await m.json();if(u)return;if(g.length>0){i(g);return}}if(l.size===0){i([]);return}const p=[...l.keys()],h=await Ee(`/api/check-ports?ports=${p.join(",")}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;const x=[],b=new Set;for(const[w,v]of l)!g[w]||b.has(w)||(b.add(w),x.push({id:`port-${w}`,outputPath:v.outputPath,ports:[w],portStatus:{[w]:!0},preview:v.description}));i(x)}}catch{}}d();const f=setInterval(d,1e4);return()=>{u=!0,clearInterval(f)}},[n,l]);const c=y.useCallback(async u=>{try{await Ee("/api/kill-port",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({port:u})}),setTimeout(()=>{i(d=>d.filter(f=>!f.ports.includes(u)))},1500)}catch{}},[]);return y.useEffect(()=>{if(!r)return;const u=o.filter(d=>d.outputPath).map(d=>({id:d.id,outputPath:d.outputPath,title:Fy(d)}));r(u)},[o,r]),o.length===0?null:a.jsxs("section",{children:[a.jsxs(_c,{children:["Active Servers (",o.length,")"]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:o.map(u=>{const d=u.ports.filter(m=>u.portStatus[m]),f=Fy(u);return a.jsxs("div",{className:"border-b border-border px-2 py-2 last:border-b-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(W1,{className:"size-3 shrink-0 text-success","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:f})]}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[u.ports.map(m=>a.jsx(Iz,{port:m,isActive:u.portStatus[m]},m)),a.jsx("div",{className:"flex-1"}),u.outputPath&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>s==null?void 0:s(u.id,u.outputPath,f),title:"View server output","aria-label":"View server output",children:a.jsx(ya,{"data-icon":"inline-start"})}),t&&d.length>0&&a.jsxs(J,{variant:"ghost",size:"xs",className:"text-destructive",onClick:()=>d.forEach(m=>c(m)),title:"Stop server","aria-label":"Stop server",children:[a.jsx(U1,{"data-icon":"inline-start",className:"fill-current"}),a.jsx("span",{children:"Stop"})]})]})]},u.id)})})]})}function qx(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(vP,{"data-slot":"alert-dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function Pz(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(yP,{"data-slot":"alert-dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $z(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(L1,{"data-slot":"alert-dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function Rz(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("fixed inset-0 isolate z-50 bg-black/55 duration-150 ease-out data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(M1,{"data-slot":"alert-dialog-overlay",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Vx(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Rz,{}),e[4]=i):i=e[4];let l;e[5]!==t?(l=G("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border bg-popover p-4 text-popover-foreground shadow-lg duration-150 ease-out outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-100 data-closed:ease-in motion-reduce:animate-none",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==o||e[9]!==l?(c=a.jsxs($z,{children:[i,a.jsx($1,{"data-slot":"alert-dialog-content","data-size":o,className:l,...s})]}),e[7]=s,e[8]=o,e[9]=l,e[10]=c):c=e[10],c}function Hx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Kx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Oz(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"alert-dialog-media",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Gx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(R1,{"data-slot":"alert-dialog-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Zx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(O1,{"data-slot":"alert-dialog-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Yx(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(J,{"data-slot":"alert-dialog-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Xx(n){const e=q.c(14);let t,s,r,o;e[0]!==n?({className:t,variant:r,size:o,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=r===void 0?"outline":r,l=o===void 0?"default":o;let c;e[5]!==t?(c=G(t),e[5]=t,e[6]=c):c=e[6];let u;e[7]!==l||e[8]!==i?(u=a.jsx(J,{variant:i,size:l}),e[7]=l,e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==s||e[11]!==c||e[12]!==u?(d=a.jsx(uc,{"data-slot":"alert-dialog-cancel",className:c,render:u,...s}),e[10]=s,e[11]=c,e[12]=u,e[13]=d):d=e[13],d}function VN(n){const e=q.c(9);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-[color,background-color,border-color,box-shadow,transform,scale] duration-100 ease-out active:scale-90 group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary bg-background dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary motion-reduce:transition-none motion-reduce:active:scale-100",t),e[3]=t,e[4]=r):r=e[4];let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(SP,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-[opacity,transform,scale] duration-100 ease-out motion-safe:data-starting-style:scale-75 motion-safe:data-starting-style:opacity-0 motion-safe:data-ending-style:scale-75 motion-safe:data-ending-style:opacity-0 motion-reduce:transition-none [&>svg]:size-3.5",children:a.jsx(Ht,{})}),e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r?(i=a.jsx(wP,{"data-slot":"checkbox",className:r,...s,children:o}),e[6]=s,e[7]=r,e[8]=i):i=e[8],i}const Lz={undo:"Undo turns?",redo:"Redo turns?","branch-switch":"Switch branch?"},Mz={undo:"This will revert file changes from the following turns.",redo:"This will re-apply file changes from the following turns.","branch-switch":"This will switch to a different branch, undoing current changes and applying the branch's changes."};function zz({state:n,isApplying:e,applyError:t,onConfirm:s,onCancel:r}){var f,m;const o=y.useRef(n),[i,l]=y.useState({key:"",selected:!1});y.useEffect(()=>{n&&(o.current=n)},[n]);const c=n??o.current;if(!c)return null;const u=((f=c.nativeRewind)==null?void 0:f.eventId)??`${c.type}:${c.targetTurnIndex}:${c.branchId??""}`,d=i.key===u&&i.selected;return a.jsx(qx,{open:n!==null,onOpenChange:p=>{p||r()},onOpenChangeComplete:p=>{p||(o.current=null,l({key:"",selected:!1}))},children:a.jsxs(Vx,{children:[a.jsxs(Hx,{children:[a.jsx(Oz,{children:a.jsx(_r,{className:"text-warning"})}),a.jsx(Gx,{children:Lz[c.type]}),a.jsx(Zx,{children:c.nativeRewind?d?"This removes the selected turn and everything after it, restoring captured files.":"This removes the selected turn and everything after it. Files stay unchanged.":Mz[c.type]})]}),a.jsxs("div",{className:"flex flex-col gap-2 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Turns affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.turnCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Files affected"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.fileCount})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Operations"}),a.jsx("span",{className:"text-foreground font-mono",children:c.summary.operationCount})]}),c.summary.filePaths.length>0&&a.jsx("div",{className:"mt-2 max-h-32 overflow-y-auto rounded-md border bg-muted/30 p-2",children:c.summary.filePaths.map(p=>a.jsx("div",{className:"truncate font-mono text-xs text-muted-foreground",children:p},p))}),((m=c.nativeRewind)==null?void 0:m.filesAvailable)&&a.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm text-foreground",children:[a.jsx(VN,{checked:d,disabled:e,onCheckedChange:p=>l({key:u,selected:p===!0})}),"Restore captured file changes"]})]}),t&&a.jsx(wt,{variant:"destructive",children:a.jsx(_t,{children:t})}),a.jsxs(Kx,{children:[a.jsx(Xx,{onClick:r,disabled:e,children:"Cancel"}),a.jsx(Yx,{onClick:()=>s(d),disabled:e,children:e?a.jsxs(a.Fragment,{children:[a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),"Applying..."]}):c.type==="undo"?"Undo":c.type==="redo"?"Redo":"Switch"})]})]})})}function Rs(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,size:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"default":r;let i;e[4]!==t?(i=G("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",t),e[4]=t,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==o||e[8]!==i?(l=a.jsx("div",{"data-slot":"card","data-size":o,className:i,...s}),e[6]=s,e[7]=o,e[8]=i,e[9]=l):l=e[9],l}function ur(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-header",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function dr(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-title",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function fr(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("text-sm text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-description",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Dz(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("col-start-2 row-span-2 row-start-1 self-start justify-self-end",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-action",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Os(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("px-4 group-data-[size=sm]/card:px-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-content",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Ff(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"card-footer",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function qo(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto bg-background dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("div",{"data-slot":"input-group",role:"group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}const Fz=Qr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function jr(n){const e=q.c(11);let t,s,r;e[0]!==n?({className:t,align:r,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=r===void 0?"inline-start":r;let i;e[4]!==o||e[5]!==t?(i=G(Fz({align:o}),t),e[4]=o,e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==s||e[9]!==i?(l=a.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":o,className:i,onClick:Uz,...s}),e[7]=o,e[8]=s,e[9]=i,e[10]=l):l=e[10],l}function Uz(n){var e,t;n.target.closest("button")||(t=(e=n.currentTarget.parentElement)==null?void 0:e.querySelector("input"))==null||t.focus()}const Bz=Qr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Uf(n){const e=q.c(15);let t,s,r,o,i;e[0]!==n?({className:t,type:r,variant:o,size:i,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5]);const l=r===void 0?"button":r,c=o===void 0?"ghost":o,u=i===void 0?"xs":i;let d;e[6]!==t||e[7]!==u?(d=G(Bz({size:u}),t),e[6]=t,e[7]=u,e[8]=d):d=e[8];let f;return e[9]!==s||e[10]!==u||e[11]!==d||e[12]!==l||e[13]!==c?(f=a.jsx(J,{type:l,"data-size":u,variant:c,className:d,...s}),e[9]=s,e[10]=u,e[11]=d,e[12]=l,e[13]=c,e[14]=f):f=e[14],f}function Vo(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(zn,{"data-slot":"input-group-control",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Wz(){const[n,e]=y.useState("idle"),[t,s]=y.useState(null),r=y.useRef(void 0),o=y.useCallback(async u=>{if(!u.trim()){e("idle"),s(null);return}e("validating"),s(null);try{const f=await(await Ee(`/api/config/validate?path=${encodeURIComponent(u)}`)).json();f.valid?(e("valid"),s(null)):(e("invalid"),s(f.error||"Invalid path"))}catch{e("invalid"),s("Failed to validate path")}},[]),i=y.useCallback(u=>{clearTimeout(r.current),r.current=setTimeout(()=>o(u),400)},[o]),l=y.useCallback(()=>{e("idle"),s(null),clearTimeout(r.current)},[]),c=y.useCallback(async(u,d)=>{try{const f=await Ee("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeDir:u,...d})}),m=await f.json();return f.ok&&m.success?{success:!0,claudeDir:m.claudeDir}:(s(m.error||"Failed to save"),e("invalid"),{success:!1,error:m.error})}catch{return s("Failed to save configuration"),{success:!1,error:"Network error"}}},[]);return y.useEffect(()=>()=>clearTimeout(r.current),[]),{status:n,error:t,debouncedValidate:i,validate:o,reset:l,save:c}}const Li=P$(n=>!n.cli.homeIsDiscoverable,"a home Cogpit has to be told about"),HN=pc().filter(n=>n.cli.homeIsDiscoverable&&!n.cli.requiresConfiguration);function KN(n){return n.flatMap((e,t)=>t===0?[e]:[t===n.length-1?" and ":", ",e])}function GN(n){const e=q.c(2),{children:t}=n;let s;return e[0]!==t?(s=a.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs text-foreground",children:t}),e[0]=t,e[1]=s):s=e[1],s}const qz=KN(HN.map(n=>n.displayName)),Vz=KN(HN.map(n=>a.jsx(GN,{children:["~",n.cli.homeDirName,n.cli.installMarker].filter(Boolean).join("/")},n.kind))),Hz=`~/${Li.cli.homeDirName}`;function Kz(n){const e=q.c(46),{onConfigured:t}=n,[s,r]=y.useState(""),[o,i]=y.useState(!1),{status:l,error:c,debouncedValidate:u,save:d}=Wz();let f;e[0]!==u?(f=M=>{const D=M.target.value;r(D),u(D)},e[0]=u,e[1]=f):f=e[1];const m=f;let p;e[2]!==t||e[3]!==s||e[4]!==d?(p=async()=>{i(!0);const M=await d(s);M.success&&M.claudeDir&&t(M.claudeDir),i(!1)},e[2]=t,e[3]=s,e[4]=d,e[5]=p):p=e[5];const h=p;let g;e[6]!==h||e[7]!==o||e[8]!==l?(g=M=>{M.preventDefault(),l==="valid"&&!o&&h()},e[6]=h,e[7]=o,e[8]=l,e[9]=g):g=e[9];let x,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(F1,{className:"size-4"})}),b=a.jsx(dr,{children:"Connect your coding agent"}),e[10]=x,e[11]=b):(x=e[10],b=e[11]);let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs(ur,{children:[x,b,a.jsxs(fr,{children:["Cogpit detects ",qz," automatically. Existing histories live in"," ",Vz,"."," ","For ",Li.displayName,", enter its data directory, usually"," ",a.jsx(GN,{children:Hz}),"."]})]}),e[12]=w):w=e[12];const v=l==="invalid";let k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsxs(rn,{htmlFor:"agent-data-directory",children:[Li.displayName," data directory"]}),e[13]=k):k=e[13];let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(jr,{children:a.jsx(qr,{"aria-hidden":"true"})}),e[14]=j):j=e[14];const _=l==="invalid";let N;e[15]!==m||e[16]!==s||e[17]!==_?(N=a.jsxs(qo,{children:[j,a.jsx(Vo,{id:"agent-data-directory",value:s,onChange:m,placeholder:`/Users/you/${Li.cli.homeDirName}`,autoFocus:!0,"aria-invalid":_,"aria-describedby":"agent-directory-status"})]}),e[15]=m,e[16]=s,e[17]=_,e[18]=N):N=e[18];let S;e[19]!==l?(S=l==="validating"&&a.jsxs(sa,{className:"flex items-center gap-2",children:[a.jsx(Pn,{className:"size-4"}),"Checking path..."]}),e[19]=l,e[20]=S):S=e[20];let C;e[21]!==l?(C=l==="valid"&&a.jsxs(sa,{className:"flex items-center gap-2 text-success",children:[a.jsx(df,{className:"size-4"}),Li.displayName," history found"]}),e[21]=l,e[22]=C):C=e[22];let A;e[23]!==c||e[24]!==l?(A=l==="invalid"&&c&&a.jsxs(jo,{className:"flex items-center gap-2",children:[a.jsx(Fo,{className:"size-4"}),c]}),e[23]=c,e[24]=l,e[25]=A):A=e[25];let T;e[26]!==S||e[27]!==C||e[28]!==A?(T=a.jsxs("div",{id:"agent-directory-status",className:"min-h-5",role:"status","aria-live":"polite",children:[S,C,A]}),e[26]=S,e[27]=C,e[28]=A,e[29]=T):T=e[29];let I;e[30]!==N||e[31]!==T||e[32]!==v?(I=a.jsx(Os,{children:a.jsx(ka,{children:a.jsxs(sn,{"data-invalid":v,children:[k,N,T]})})}),e[30]=N,e[31]=T,e[32]=v,e[33]=I):I=e[33];const E=l!=="valid"||o;let P;e[34]!==o?(P=o&&a.jsx(Pn,{"data-icon":"inline-start"}),e[34]=o,e[35]=P):P=e[35];const R=o?"Saving...":`Connect ${Li.displayName}`;let L;e[36]!==E||e[37]!==P||e[38]!==R?(L=a.jsx(Ff,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:E,children:[P,R]})}),e[36]=E,e[37]=P,e[38]=R,e[39]=L):L=e[39];let O;e[40]!==I||e[41]!==L?(O=a.jsxs(Rs,{children:[w,I,L]}),e[40]=I,e[41]=L,e[42]=O):O=e[42];let $;return e[43]!==O||e[44]!==g?($=a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8 text-foreground",children:a.jsx("form",{className:"w-full max-w-lg",onSubmit:g,children:O})}),e[43]=O,e[44]=g,e[45]=$):$=e[45],$}const Uy={0:"\0",b:"\b",f:"\f",n:`
|
|
11
11
|
`,r:"\r",t:" ",v:"\v"};function Gz(n){return!!(n&&/[A-Za-z_$]/.test(n))}function Pd(n){return!!(n&&/[\w$]/.test(n))}function Nr(n,e){const t=n[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let s="",r=e+1;for(;r<n.length;){const o=n[r];if(o===t)return{endIndex:r+1,value:s};if(o!=="\\"){s+=o,r++;continue}if(r++,r>=n.length)return null;const i=n[r];if(i in Uy){s+=Uy[i],r++;continue}if(i===`
|
|
12
12
|
`){r++;continue}if(i==="\r"){r+=n[r+1]===`
|
|
@@ -45,7 +45,7 @@ ${e}`:e)}function $F(n){return typeof n=="string"&&(n==="abort"||n==="binary_ass
|
|
|
45
45
|
`),{skipStats:!0}).turns;return s.length!==t.length?null:t.map((r,o)=>({line:r,id:s[o].id}))}function UF(n){return e0(n)?tC(n.input):[n]}function BF(n,e){if(n.length<2)return!1;const t=n[n.length-2],s=t.toolCalls[t.toolCalls.length-1];return(s==null?void 0:s.name)===e&&s.isError}function WF(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="text"||r.kind==="thinking"||r.kind==="tool_calls")}function qF(n,e){const t=n.contentBlocks,s=t.findIndex(r=>r.kind==="tool_calls"&&r.toolCalls.some(o=>o.id===e));return s===-1?!1:t.slice(s+1).some(r=>r.kind==="queued_prompt")}function VF(n){for(let e=n.toolCalls.length-1;e>=0;e--){const t=n.toolCalls[e];if(!t.asyncQuestion||t.isError)continue;if(qF(n,t.id))return null;const s=t.input.questions;if(s&&s.length>0)return{type:"question",toolUseId:t.id,questions:s}}return null}function HF(n,e){const t=e.toolCalls[e.toolCalls.length-1];if(!t||t.asyncQuestion)return null;const{name:s}=t;if(s!=="ExitPlanMode"&&s!=="AskUserQuestion"||t.result!==null&&!t.isError||BF(n,s)||t.isError&&WF(e,t.id))return null;const r=t.input;if(s==="ExitPlanMode")return{type:"plan",allowedPrompts:r.allowedPrompts};const o=r.questions;return o&&o.length>0?{type:"question",toolUseId:t.id,questions:o}:null}function MC(n){const{turns:e}=n;if(e.length===0)return null;const t=e[e.length-1];return!t||t.toolCalls.length===0?null:HF(e,t)??VF(t)}function KF(n){return typeof n=="string"?n:n.filter(e=>e.type==="text").map(e=>e.text).join(`
|
|
46
46
|
`)}function Kf(n,e){return RC(n).parse(n,e)}function GF(n,e){const t=OC(n.rawMessages),r=(t.kind===IC?RC(e):t).append(n,e);return n.instanceId?ta(r,n.instanceId):r}function Tc(n){return n===null?"":typeof n=="string"?n:KF(n)}function zC(n){return n===null||typeof n=="string"?[]:n.filter(e=>e.type==="image")}const DC=/^[a-z]:[\\/]/i;function i0(n){return(DC.test(n)?n.replace(/\\/g,"/"):n).replace(/\/+$/,"")||"/"}function c2(n){const e=i0(n);return DC.test(n)?e.toLowerCase():e}function ZF(n){const e=i0(n),t=e.lastIndexOf("/");return t<0?e:t===0?"/":e.slice(0,t)}function u2(n,e){const t=c2(n),s=c2(e);if(t===s)return"";const r=t==="/"?"/":`${t}/`;return s.startsWith(r)?i0(e).slice(r.length):null}let a0=!1;function YF(n){a0=n}function l0(){return a0}let Cl=null;function XF(n){return Cl=n,()=>{Cl===n&&(Cl=null)}}function JF(n,e){if(!n.path)return null;if(n.kind==="project")return{root:n.path,file:null,mode:"edit"};if(e){const r=u2(e,n.path);if(r)return{root:e,file:r,mode:d2(n),line:n.line}}const t=ZF(n.path),s=u2(t,n.path);return s?{root:t,file:s,mode:d2(n),line:n.line}:null}function d2(n){return n.mode==="diff"?"diff":"edit"}function FC(n){return a0&&Cl!==null&&Cl(n)}function UC(n,e){os(n,e).catch(()=>{})}function Gl(n,e={}){if(ht("hostFiles")&&!FC({kind:"file",path:n,...e})){if(Bo()){kf(n);return}UC("/api/open-in-editor",{path:n,mode:e.mode??"file",line:e.line,column:e.column})}}function BC(n){ht("hostFiles")&&(n.path&&FC({kind:"project",path:n.path})||qC("/api/open-in-editor",n))}function WC(n){ht("hostFiles")&&qC("/api/reveal-in-folder",n)}function qC(n,e){!e.path&&!e.dirName||UC(n,{path:e.path||void 0,dirName:e.dirName||void 0})}const QF=1500;function Kr(){const n=q.c(5),[e,t]=y.useState(!1),s=y.useRef(null),r=y.useRef(!0);let o,i;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(r.current=!0,()=>{r.current=!1,s.current&&clearTimeout(s.current)}),i=[],n[0]=o,n[1]=i):(o=n[0],i=n[1]),y.useEffect(o,i);let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=async d=>{!await kf(d)||!r.current||(t(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>t(!1),QF))},n[2]=l):l=n[2];const c=l;let u;return n[3]!==e?(u=[e,c],n[3]=e,n[4]=u):u=n[4],u}function Ac(){const n=q.c(2),[e,t]=y.useState(eU);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=document.documentElement,i=()=>t(o.classList.contains("dark")),l=new MutationObserver(i);return l.observe(o,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}function eU(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}let Km=null;const Pg=new Set,du=new Map,f2=["typescript","tsx","javascript","jsx","json","css","html","python","bash","yaml","markdown"],VC={typescript:()=>nt(()=>import("./typescript-BPQ3VLAy.js"),[]),tsx:()=>nt(()=>import("./tsx-COt5Ahok.js"),[]),javascript:()=>nt(()=>import("./javascript-wDzz0qaB.js"),[]),jsx:()=>nt(()=>import("./jsx-g9-lgVsj.js"),[]),json:()=>nt(()=>import("./json-Cp-IABpG.js"),[]),css:()=>nt(()=>import("./css-DPfMkruS.js"),[]),html:()=>nt(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([5,6,7])),python:()=>nt(()=>import("./python-B6aJPvgy.js"),[]),bash:()=>nt(()=>import("./bash-Yzrsuije.js"),[]),yaml:()=>nt(()=>import("./yaml-Buea-lGh.js"),[]),markdown:()=>nt(()=>import("./markdown-Cvjx9yec.js"),[]),rust:()=>nt(()=>import("./rust-B1yitclQ.js"),[]),go:()=>nt(()=>import("./go-CxLEBnE3.js"),[]),toml:()=>nt(()=>import("./toml-vGWfd6FD.js"),[]),sql:()=>nt(()=>import("./sql-BLtJtn59.js"),[]),c:()=>nt(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>nt(()=>import("./cpp-BRuaLJcg.js"),__vite__mapDeps([8,9,10])),java:()=>nt(()=>import("./java-CylS5w8V.js"),[]),ruby:()=>nt(()=>import("./ruby-B0Tyh1qT.js"),__vite__mapDeps([11,5,6,7,12,13,10,14,15,16,8,9,17,18])),swift:()=>nt(()=>import("./swift-D82vCrfD.js"),[]),kotlin:()=>nt(()=>import("./kotlin-BdnUsdx6.js"),[]),php:()=>nt(()=>import("./php-aq0itWAE.js"),__vite__mapDeps([19,5,6,7,12,13,10,20])),vue:()=>nt(()=>import("./vue-DVfSmUF7.js"),__vite__mapDeps([21,7,6,14,20,5])),svelte:()=>nt(()=>import("./svelte-DZMnMd3x.js"),__vite__mapDeps([22,6,14,7])),scss:()=>nt(()=>import("./scss-OYdSNvt2.js"),__vite__mapDeps([23,7]))};function HC(){return Km||(Km=(async()=>{const[n,e,...t]=await Promise.all([nt(()=>import("./github-dark-DHJKELXO.js"),[]).then(r=>r.default),nt(()=>import("./github-light-DAi9KRSo.js"),[]).then(r=>r.default),...f2.map(r=>VC[r]().then(o=>o.default))]),s=await y$({themes:[n,e],langs:t,engine:w$()});for(const r of f2)Pg.add(r);return s})()),Km}async function KC(n,e){if(Pg.has(e))return;if(du.has(e))return du.get(e);const t=VC[e];if(!t)return;const s=t().then(async r=>{await n.loadLanguage(r.default),Pg.add(e)}).finally(()=>du.delete(e));du.set(e,s),await s}const tU={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",mts:"typescript",cts:"typescript",py:"python",rs:"rust",go:"go",json:"json",css:"css",scss:"scss",html:"html",htm:"html",md:"markdown",mdx:"markdown",yml:"yaml",yaml:"yaml",toml:"toml",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",java:"java",rb:"ruby",swift:"swift",kt:"kotlin",kts:"kotlin",php:"php",vue:"vue",svelte:"svelte"};function GC(n){var t;const e=((t=n.split(".").pop())==null?void 0:t.toLowerCase())??"";return tU[e]??null}async function nU(n,e,t){try{const s=await HC();await KC(s,e);const r=t?"github-dark":"github-light";return s.codeToTokens(n,{lang:e,theme:r}).tokens}catch{return null}}const sU="min-w-0 max-h-96 overflow-y-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md border bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85",c0="min-w-0 max-h-96 overflow-auto whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-md bg-muted p-3 font-mono text-xs leading-relaxed text-foreground/85";function Gf(n,e,t){const s=q.c(5),[r,o]=y.useState(null);let i,l;return s[0]!==n||s[1]!==t||s[2]!==e?(i=()=>{if(!e)return;let c=!1;return nU(n,e,t).then(u=>{c||o({code:n,lang:e,isDark:t,tokens:u})}).catch(rU),()=>{c=!0}},l=[n,e,t],s[0]=n,s[1]=t,s[2]=e,s[3]=i,s[4]=l):(i=s[3],l=s[4]),y.useEffect(i,l),(r==null?void 0:r.code)===n&&r.lang===e&&r.isDark===t?r.tokens:null}function rU(){}function u0(n){const e=q.c(13),{lines:t,tokens:s,lineNums:r,variant:o,label:i}=n,l=o==="boxed"?sU:c0;let c;if(e[0]!==r||e[1]!==t||e[2]!==s){let f;e[4]!==r||e[5]!==s?(f=(m,p)=>{const h=s==null?void 0:s[p];return a.jsxs("span",{className:"block",children:[(r==null?void 0:r[p])&&a.jsx("span",{className:"inline-block w-10 text-right mr-2 text-muted-foreground select-none",children:r[p]}),h?h.map(oU):m||" "]},p)},e[4]=r,e[5]=s,e[6]=f):f=e[6],c=t.map(f),e[0]=r,e[1]=t,e[2]=s,e[3]=c}else c=e[3];let u;e[7]!==i||e[8]!==c?(u=a.jsx("code",{className:"block","aria-label":i,children:c}),e[7]=i,e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==u?(d=a.jsx("pre",{tabIndex:0,className:l,children:u}),e[10]=l,e[11]=u,e[12]=d):d=e[12],d}function oU(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}function ZC(n){const e=q.c(6),{code:t,language:s,label:r}=n,o=Ac(),i=Gf(t,s,o);let l;e[0]!==t?(l=Zl(t),e[0]=t,e[1]=l):l=e[1];const c=l;let u;return e[2]!==r||e[3]!==c||e[4]!==i?(u=a.jsx(u0,{lines:c,tokens:i,variant:"unboxed",label:r}),e[2]=r,e[3]=c,e[4]=i,e[5]=u):u=e[5],u}const iU=/^(\s*\d+)→(.*)$/;function Zl(n){return n.split(/\r\n|\r|\n/)}function aU(n){const e=[],t=[];for(const s of Zl(n)){const r=s.match(iU);r?(e.push(r[1]),t.push(r[2])):(e.push(""),t.push(s))}return{lineNums:e,codeLines:t}}function lU(n){const e=q.c(11),{result:t,filePath:s,variant:r}=n,o=r===void 0?"boxed":r,i=Ac();let l;e[0]!==s?(l=GC(s),e[0]=s,e[1]=l):l=e[1];const c=l;let u;e[2]!==t?(u=aU(t),e[2]=t,e[3]=u):u=e[3];const{lineNums:d,codeLines:f}=u;let m;e[4]!==f?(m=f.join(`
|
|
47
47
|
`),e[4]=f,e[5]=m):m=e[5];const h=Gf(m,c,i);let g;return e[6]!==f||e[7]!==d||e[8]!==h||e[9]!==o?(g=a.jsx(u0,{lines:f,tokens:h,lineNums:d,variant:o}),e[6]=f,e[7]=d,e[8]=h,e[9]=o,e[10]=g):g=e[10],g}function YC(n){const e=n.trim();if(e[0]!=="{"&&e[0]!=="[")return null;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return null}}function XC(n){const e=q.c(9),{result:t,alreadyPretty:s,variant:r}=n,o=r===void 0?"boxed":r,i=Ac();let l;e[0]!==s||e[1]!==t?(l=s?t:YC(t)??t,e[0]=s,e[1]=t,e[2]=l):l=e[2];const c=l;let u;e[3]!==c?(u=Zl(c),e[3]=c,e[4]=u):u=e[4];const d=u,f=Gf(c,"json",i);let m;return e[5]!==d||e[6]!==f||e[7]!==o?(m=a.jsx(u0,{lines:d,tokens:f,variant:o}),e[5]=d,e[6]=f,e[7]=o,e[8]=m):m=e[8],m}function cU(n){const e=Zl(n),t=e.slice(0,8).join(`
|
|
48
|
-
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-Zl(s).length),truncated:e.length>8||t.length>1e3}}function JC(n){const e=q.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=Kr(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?YC(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=cU(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const k=i?"Error":"Result";let j;e[8]!==v||e[9]!==k?(j=a.jsx("span",{className:v,children:k}),e[8]=v,e[9]=k,e[10]=j):j=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(Ht,{"data-icon":"icon"}):a.jsx(Cs,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(lU,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(XC,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(c0,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let A;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(A=x.truncated&&a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(uU),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=A):A=e[32];let T;return e[33]!==C||e[34]!==A||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,A]}),e[33]=C,e[34]=A,e[35]=N,e[36]=T):T=e[36],T}function uU(n){return!n}const dU={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function fU(n){return n&&dU[n.toLowerCase()]||null}const QC=y.createContext(null),mU=y.lazy(()=>nt(()=>import("./CogpitBlock-
|
|
48
|
+
`),s=t.slice(0,1e3);return{text:s,hiddenLines:Math.max(0,e.length-Zl(s).length),truncated:e.length>8||t.length>1e3}}function JC(n){const e=q.c(37),{result:t,isError:s,filePath:r,renderResult:o}=n,i=s===void 0?!1:s,[l,c]=y.useState(!1),[u,d]=Kr(),f=y.useId();let m;e[0]!==r||e[1]!==i||e[2]!==t?(m=!i&&!r?YC(t):null,e[0]=r,e[1]=i,e[2]=t,e[3]=m):m=e[3];const p=m,h=p??t;let g;e[4]!==h?(g=cU(h),e[4]=h,e[5]=g):g=e[5];const x=g,b=l?h:x.text,w=i&&"text-destructive";let v;e[6]!==w?(v=G("text-xs text-muted-foreground",w),e[6]=w,e[7]=v):v=e[7];const k=i?"Error":"Result";let j;e[8]!==v||e[9]!==k?(j=a.jsx("span",{className:v,children:k}),e[8]=v,e[9]=k,e[10]=j):j=e[10];let _;e[11]!==u||e[12]!==d||e[13]!==t?(_=t.trim()&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>d(t),"aria-label":u?"Result copied":"Copy result",children:u?a.jsx(Ht,{"data-icon":"icon"}):a.jsx(Cs,{"data-icon":"icon"})}),e[11]=u,e[12]=d,e[13]=t,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==r||e[19]!==i||e[20]!==p||e[21]!==o||e[22]!==t||e[23]!==b?(S=t.trim()?o?o(b):r&&!i?a.jsx(lU,{result:b,filePath:r,variant:"unboxed"}):p!==null?a.jsx(XC,{result:b,alreadyPretty:!0,variant:"unboxed"}):a.jsx("pre",{tabIndex:0,className:G(c0,i&&"border-destructive/30 text-destructive"),children:b}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No output"}),e[18]=r,e[19]=i,e[20]=p,e[21]=o,e[22]=t,e[23]=b,e[24]=S):S=e[24];let C;e[25]!==f||e[26]!==S?(C=a.jsx("div",{id:f,children:S}),e[25]=f,e[26]=S,e[27]=C):C=e[27];let A;e[28]!==l||e[29]!==x.hiddenLines||e[30]!==x.truncated||e[31]!==f?(A=x.truncated&&a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"mt-1",onClick:()=>c(uU),"aria-expanded":l,"aria-controls":f,children:l?"Show less":x.hiddenLines>0?`+${x.hiddenLines} ${x.hiddenLines===1?"line":"lines"}`:"Show more"}),e[28]=l,e[29]=x.hiddenLines,e[30]=x.truncated,e[31]=f,e[32]=A):A=e[32];let T;return e[33]!==C||e[34]!==A||e[35]!==N?(T=a.jsxs("section",{className:"mt-3 min-w-0","aria-label":"Result",children:[N,C,A]}),e[33]=C,e[34]=A,e[35]=N,e[36]=T):T=e[36],T}function uU(n){return!n}const dU={"cogpit-status":"status","cogpit-decisions":"decisions","cogpit-checklist":"checklist"};function fU(n){return n&&dU[n.toLowerCase()]||null}const QC=y.createContext(null),mU=y.lazy(()=>nt(()=>import("./CogpitBlock-DslWkKoF.js"),__vite__mapDeps([24,1,2,3,4]))),pU={js:"JavaScript",jsx:"JSX",ts:"TypeScript",tsx:"TSX",py:"Python",rb:"Ruby",rs:"Rust",go:"Go",java:"Java",kt:"Kotlin",swift:"Swift",cs:"C#",cpp:"C++",c:"C",sh:"Shell",bash:"Bash",zsh:"Zsh",fish:"Fish",ps1:"PowerShell",powershell:"PowerShell",sql:"SQL",graphql:"GraphQL",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Docker",makefile:"Makefile",cmake:"CMake",lua:"Lua",vim:"Vim",diff:"Diff",plaintext:"Text",text:"Text",txt:"Text",php:"PHP",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",clojure:"Clojure",haskell:"Haskell",ocaml:"OCaml",zig:"Zig",nim:"Nim",dart:"Dart",vue:"Vue",svelte:"Svelte",astro:"Astro",prisma:"Prisma",terraform:"Terraform",tf:"Terraform",proto:"Protobuf",protobuf:"Protobuf"};function hU(n){return pU[n.toLowerCase()]??n}function gU(n){if(!n)return null;const e=n.match(/language-(\S+)/);return(e==null?void 0:e[1])??null}function xU(n){const e=q.c(9),{text:t}=n,[s,r]=Kr();let o;e[0]!==r||e[1]!==t?(o=()=>r(t),e[0]=r,e[1]=t,e[2]=o):o=e[2];const i=s?"Copied":"Copy code";let l;e[3]!==s?(l=s?a.jsxs(a.Fragment,{children:[a.jsx(Ht,{className:"text-success","data-icon":"inline-start"}),a.jsx("span",{className:"text-success",children:"Copied"})]}):a.jsx(Cs,{"data-icon":"icon"}),e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==o||e[6]!==i||e[7]!==l?(c=a.jsx(J,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"text-muted-foreground",title:"Copy code","aria-label":i,children:l}),e[5]=o,e[6]=i,e[7]=l,e[8]=c):c=e[8],c}function bU(n){const e=q.c(2),{num:t}=n;let s;return e[0]!==t?(s=a.jsx("span",{className:"mr-3 inline-block w-8 select-none text-right text-xs text-muted-foreground/60",children:t}),e[0]=t,e[1]=s):s=e[1],s}function e5(n){var b,w;const e=q.c(28);let t,s,r,o;e[0]!==n?({children:s,className:r,node:t,...o}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=y.useContext(QC),l=!r&&typeof s=="string"&&!s.includes(`
|
|
49
49
|
`);let c;e[5]!==r?(c=gU(r),e[5]=r,e[6]=c):c=e[6];const u=c,d=String(s);let f;if(e[7]!==d){let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=/\n$/,e[9]=v):v=e[9],f=d.replace(v,""),e[7]=d,e[8]=f}else f=e[8];const m=f;if(l){let v;return e[10]!==s||e[11]!==o?(v=a.jsx("code",{className:"rounded-md border border-border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] text-foreground",...o,children:s}),e[10]=s,e[11]=o,e[12]=v):v=e[12],v}let p;e[13]!==m||e[14]!==u||e[15]!==o?(p=a.jsx(vU,{code:m,lang:u,...o}),e[13]=m,e[14]=u,e[15]=o,e[16]=p):p=e[16];const h=p;let g;e[17]!==i||e[18]!==u?(g=i?fU(u):null,e[17]=i,e[18]=u,e[19]=g):g=e[19];const x=g;if(x){const v=String(((b=t==null?void 0:t.position)==null?void 0:b.start.offset)??((w=t==null?void 0:t.position)==null?void 0:w.start.line)??0);let k;e[20]!==x||e[21]!==m||e[22]!==h||e[23]!==v?(k=a.jsx(mU,{kind:x,source:m,occurrence:v,fallback:h}),e[20]=x,e[21]=m,e[22]=h,e[23]=v,e[24]=k):k=e[24];let j;return e[25]!==h||e[26]!==k?(j=a.jsx(y.Suspense,{fallback:h,children:k}),e[25]=h,e[26]=k,e[27]=j):j=e[27],j}return h}function vU(n){const e=q.c(39);let t,s,r;e[0]!==n?({code:t,lang:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);const o=Ac(),i=Gf(t,s,o),[l,c]=y.useState(!1);let u,d,f,m;if(e[4]!==t||e[5]!==l||e[6]!==s||e[7]!==r||e[8]!==i){const g=t.split(`
|
|
50
50
|
`);u=g.length;const x=u>30,b=l?it:Wt;d="my-3 overflow-hidden rounded-lg border border-border bg-muted";let w;e[13]!==b||e[14]!==l||e[15]!==x?(w=x&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>c(!l),className:"text-muted-foreground","aria-label":l?"Expand code":"Collapse code",children:a.jsx(b,{"data-icon":"icon"})}),e[13]=b,e[14]=l,e[15]=x,e[16]=w):w=e[16];let v;e[17]!==s?(v=s&&a.jsx(Ue,{variant:"ghost",className:"px-0 uppercase tracking-wide text-muted-foreground",children:hU(s)}),e[17]=s,e[18]=v):v=e[18];let k;e[19]!==x||e[20]!==u?(k=x&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[u," lines"]}),e[19]=x,e[20]=u,e[21]=k):k=e[21];let j;e[22]!==w||e[23]!==v||e[24]!==k?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[w,v,k]}),e[22]=w,e[23]=v,e[24]=k,e[25]=j):j=e[25];let _;e[26]!==t?(_=a.jsx(xU,{text:t}),e[26]=t,e[27]=_):_=e[27],e[28]!==j||e[29]!==_?(f=a.jsxs("div",{className:"flex items-center justify-between border-b border-border bg-muted px-3 py-1.5",children:[j,_]}),e[28]=j,e[29]=_,e[30]=f):f=e[30],m=!l&&a.jsx("div",{className:"overflow-x-auto",children:a.jsx("pre",{className:"m-0 p-3 font-mono text-xs leading-relaxed",children:a.jsx("code",{className:G("block",!i&&"text-foreground/90"),...r,children:g.map((N,S)=>{const C=i==null?void 0:i[S];return a.jsxs("span",{className:"block",children:[a.jsx(bU,{num:S+1}),C?C.map(yU):N||" "]},S)})})})}),e[4]=t,e[5]=l,e[6]=s,e[7]=r,e[8]=i,e[9]=u,e[10]=d,e[11]=f,e[12]=m}else u=e[9],d=e[10],f=e[11],m=e[12];let p;e[31]!==l||e[32]!==u?(p=l&&a.jsxs(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-auto w-full justify-start rounded-none px-3 py-2 text-xs text-muted-foreground","aria-label":`Expand ${u} lines of code`,children:["Show ",u," lines..."]}),e[31]=l,e[32]=u,e[33]=p):p=e[33];let h;return e[34]!==d||e[35]!==f||e[36]!==m||e[37]!==p?(h=a.jsxs("div",{className:d,children:[f,m,p]}),e[34]=d,e[35]=f,e[36]=m,e[37]=p,e[38]=h):h=e[38],h}function yU(n,e){return a.jsx("span",{style:{color:n.color},children:n.content},e)}var ri=function(n,e){return Number(n.toFixed(e))},wU=function(n,e){return e},pt=function(n,e,t){t&&typeof t=="function"&&t(n,e)},SU=function(n){return-Math.cos(n*Math.PI)/2+.5},kU=function(n){return n},jU=function(n){return n*n},NU=function(n){return n*(2-n)},CU=function(n){return n<.5?2*n*n:-1+(4-2*n)*n},_U=function(n){return n*n*n},EU=function(n){return--n*n*n+1},TU=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1},AU=function(n){return n*n*n*n},IU=function(n){return 1- --n*n*n*n},PU=function(n){return n<.5?8*n*n*n*n:1-8*--n*n*n*n},$U=function(n){return n*n*n*n*n},RU=function(n){return 1+--n*n*n*n*n},OU=function(n){return n<.5?16*n*n*n*n*n:1+16*--n*n*n*n*n},t5={easeOut:SU,linear:kU,easeInQuad:jU,easeOutQuad:NU,easeInOutQuad:CU,easeInCubic:_U,easeOutCubic:EU,easeInOutCubic:TU,easeInQuart:AU,easeOutQuart:IU,easeInOutQuart:PU,easeInQuint:$U,easeOutQuint:RU,easeInOutQuint:OU},n5=function(n){typeof n=="number"&&cancelAnimationFrame(n)},Ls=function(n){n.mounted&&(n5(n.animation),n.isAnimating=!1,n.animation=null,n.velocity=null)};function s5(n,e,t,s){if(n.mounted){var r=new Date().getTime(),o=1;Ls(n),n.animation=function(){if(!n.mounted)return n5(n.animation);var i=new Date().getTime()-r,l=i/t,c=t5[e],u=c(l);i>=t?(s(o),n.animation=null):n.animation&&(s(u),requestAnimationFrame(n.animation))},requestAnimationFrame(n.animation)}}function LU(n){var e=n.scale,t=n.positionX,s=n.positionY;return!(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(s))}function Ho(n,e,t,s){var r=LU(e);if(!(!n.mounted||!r)){var o=n.setState,i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=e.scale-l,f=e.positionX-c,m=e.positionY-u;t===0?o(e.scale,e.positionX,e.positionY):s5(n,s,t,function(p){p!==1?n.isAnimating=!0:n.isAnimating=!1;var h=l+d*p,g=c+f*p,x=u+m*p;o(h,g,x)})}}function MU(n,e,t){var s=n.offsetWidth,r=n.offsetHeight,o=e.offsetWidth,i=e.offsetHeight,l=o*t,c=i*t,u=s-l,d=r-c;return{wrapperWidth:s,wrapperHeight:r,newContentWidth:l,newDiffWidth:u,newContentHeight:c,newDiffHeight:d}}var zU=function(n,e,t,s,r,o,i){var l=n>e?t*(i?.5:1):0,c=s>r?o*(i?.5:1):0,u=n-e-l,d=l,f=s-r-c,m=c;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m,scaleWidthFactor:l,scaleHeightFactor:c}},d0=function(n,e){var t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.centerZoomedOut,i=r.disablePadding;if(!t||!s)throw new Error("Components are not mounted");var l=MU(t,s,e),c=l.wrapperWidth,u=l.wrapperHeight,d=l.newContentWidth,f=l.newContentHeight,m=l.newDiffWidth,p=l.newDiffHeight,h=zU(c,d,m,u,f,p,!!o),g=c>=d&&u>=f;i&&g&&!o&&(h.minPositionX=0,h.maxPositionX=0,h.minPositionY=0,h.maxPositionY=0);var x=n.setup,b=x.minPositionX,w=x.maxPositionX,v=x.minPositionY,k=x.maxPositionY;return b!=null&&(h.minPositionX=c*(1-e)+b*e),w!=null&&(h.maxPositionX=w*e),v!=null&&(h.minPositionY=u*(1-e)+v*e),k!=null&&(h.maxPositionY=k*e),h},Yl=function(n,e,t,s){return s?n<e?ri(e,2):n>t?ri(t,2):ri(n,2):ri(n,2)},ia=function(n,e){var t=d0(n,e);return n.bounds=t,t};function Ic(n,e,t,s,r,o,i){var l=t.minPositionX,c=t.minPositionY,u=t.maxPositionX,d=t.maxPositionY,f=0,m=0;i&&(f=r,m=o);var p=Yl(n,l-f,u+f,s),h=Yl(e,c-m,d+m,s);return{x:p,y:h}}function Zf(n,e,t,s,r,o){var i=n.state,l=i.scale,c=i.positionX,u=i.positionY,d=s-l;if(!Number.isFinite(e)||!Number.isFinite(t))return console.error("Mouse X and Y position were not provided!"),{x:c,y:u};var f=c-e*d,m=u-t*d,p=Ic(f,m,r,o,0,0,null);return p}var m2=1e-7;function Pc(n,e,t,s,r){var o=r?s:0,i=Math.max(e-o,m2),l=t+o;return!Number.isNaN(t)&&n>=l?l:!Number.isNaN(e)&&n<=i?i:Math.max(n,m2)}var p2=function(n,e){var t=n.setup.panning.excluded,s=n.isInitialized,r=n.wrapperComponent,o=e.target,i="shadowRoot"in o&&"composedPath"in e,l=i?e.composedPath().some(function(d){return d instanceof Element?r==null?void 0:r.contains(d):!1}):r==null?void 0:r.contains(o),c=s&&o&&l;if(!c)return!1;var u=$c(o,t);return!(u||o.getAttribute("draggable")==="true"||o.getAttribute("contenteditable")==="true"||o.isContentEditable)},h2=function(n){var e=n.isInitialized,t=n.isPanning,s=n.setup,r=s.panning.disabled,o=e&&t&&!r;return!!o},DU=function(n,e){var t=n.state,s=t.positionX,r=t.positionY;n.isPanning=!0;var o=e.clientX,i=e.clientY;n.startCoords={x:o-s,y:i-r}},FU=function(n,e){var t=e.touches,s=n.state,r=s.positionX,o=s.positionY;n.isPanning=!0;var i=t.length===1;if(i){var l=t[0].clientX,c=t[0].clientY;n.startCoords={x:l-r,y:c-o}}};function UU(n){var e=n.state,t=e.positionX,s=e.positionY,r=e.scale,o=n.setup,i=o.disabled,l=o.limitToBounds,c=o.centerZoomedOut,u=n.wrapperComponent;if(!(i||!u||!n.bounds)){var d=n.bounds,f=d.maxPositionX,m=d.minPositionX,p=d.maxPositionY,h=d.minPositionY,g=t>f||t<m,x=s>p||s<h,b=t>f?u.offsetWidth:n.setup.minPositionX||0,w=s>p?u.offsetHeight:n.setup.minPositionY||0,v=Zf(n,b,w,r,n.bounds,l||c),k=v.x,j=v.y;return{scale:r,positionX:g?k:t,positionY:x?j:s}}}function r5(n,e,t,s,r){var o=n.setup.limitToBounds,i=n.wrapperComponent,l=n.bounds,c=n.state,u=c.scale,d=c.positionX,f=c.positionY;if(!(i===null||l===null||e===d&&t===f)){var m=Ic(e,t,l,o,s,r,i),p=m.x,h=m.y;n.setState(u,p,h)}}var BU=function(n,e,t){var s=n.startCoords,r=n.state,o=n.setup.panning,i=o.lockAxisX,l=o.lockAxisY,c=r.positionX,u=r.positionY;if(!s)return{x:c,y:u};var d=e-s.x,f=t-s.y,m=i?c:d,p=l?u:f;return{x:m,y:p}},$o=function(n,e,t){var s=n.setup,r=n.state,o=s.minScale,i=s.disablePadding,l=s.centerZoomedOut,c=t??r.scale;return e>0&&c>=o&&!i&&!l?e:0},vo;(function(n){n.TRACK_PAD="track_pad",n.MOUSE="mouse",n.TOUCH="touch"})(vo||(vo={}));var WU=function(n){var e=n.mounted,t=n.wrapperComponent,s=n.contentComponent,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=r.limitToBounds,c=n.state.scale,u=i.disabled;if(u||o||!e||!t||!s)return!1;if(!l)return!0;var d=t.offsetWidth<s.offsetWidth*c||t.offsetHeight<s.offsetHeight*c;return d},qU=function(n){var e=n.mounted,t=n.velocity,s=n.bounds,r=n.setup,o=r.disabled,i=r.velocityAnimation,l=i.disabled,c=!l&&!o&&e;return!(!c||!t||!s)};function VU(n,e){var t=n.setup.velocityAnimation,s=t.animationTime,r=t.maxAnimationTime,o=t.inertia;return Math.min(s*Math.max(1,Math.abs(e/o)),r)}function g2(n,e,t,s,r,o,i,l,c,u){if(r){if(e>i&&t>i){var d=i+(n-i)*u;return d>c?c:d<i?i:d}if(e<o&&t<o){var d=o+(n-o)*u;return d<l?l:d>o?o:d}}return s?e:Yl(n,o,i,r)}function HU(n){var e=1,t=n.offsetWidth/window.innerWidth;return Number.isNaN(t)?e:Math.min(e,t)}var Gm=function(n,e,t){var s=0,r=n*t;return Number.isNaN(r)?s:n<0?Math.max(r,-e):Math.min(r,e)};function KU(n,e,t){var s,r,o=WU(n);if(o){var i=n.lastMousePosition,l=n.velocityTime,c=n.setup,u=n.wrapperComponent,d=c.velocityAnimation,f=d.maxStrengthMouse,m=d.maxStrengthTouch,p=d.sensitivityTouch,h=d.sensitivityMouse,g=Date.now();if(i&&l&&u){var x=HU(u),b=(s={},s[vo.TOUCH]=p,s[vo.MOUSE]=h,s)[t],w=(r={},r[vo.TOUCH]=m,r[vo.MOUSE]=f,r)[t],v=e.x-i.x,k=e.y-i.y,j=Gm(v/x,w,b),_=Gm(k/x,w,b),N=g-l,S=v*v+k*k,C=Gm(Math.sqrt(S)/N,w,b);n.velocity={velocityX:j,velocityY:_,total:C}}n.lastMousePosition=e,n.velocityTime=g}}function GU(n){var e=n.velocity,t=n.bounds,s=n.setup,r=n.wrapperComponent,o=qU(n);if(!(!o||!e||!t||!r)){var i=e.velocityX,l=e.velocityY,c=e.total,u=t.maxPositionX,d=t.minPositionX,f=t.maxPositionY,m=t.minPositionY,p=s.limitToBounds,h=s.autoAlignment,g=s.zoomAnimation,x=s.panning,b=x.lockAxisY,w=x.lockAxisX,v=g.animationType,k=h.sizeX,j=h.sizeY,_=h.velocityAlignmentTime,N=_,S=VU(n,c),C=Math.max(S,N),A=$o(n,k),T=$o(n,j),I=A*r.offsetWidth/100,E=T*r.offsetHeight/100,P=u+I,R=d-I,L=f+E,O=m-E,$=n.state,M=new Date().getTime();s5(n,v,C,function(D){var F=n.state,z=F.scale,B=F.positionX,U=F.positionY,W=new Date().getTime()-M,V=W/N,H=t5[h.animationType],K=1-H(Math.min(1,V)),Z=1-D,Y=B+i*Z,X=U+l*Z,ee=g2(Y,$.positionX,B,w,p,d,u,R,P,K),Q=g2(X,$.positionY,U,b,p,m,f,O,L,K);if(B!==Y||U!==X){n.setState(z,ee,Q);var ne=n.props.onPanning;ne&&ne(dt(n),{})}})}}function x2(n,e){var t=n.state,s=t.scale,r=t.positionX,o=t.positionY;n.panStartPosition={x:r,y:o},Ls(n),ia(n,s),window.TouchEvent!==void 0&&e instanceof TouchEvent?FU(n,e):DU(n,e)}function o5(n,e){var t=n.state.scale,s=n.setup,r=s.minScale,o=s.autoAlignment,i=o.disabled,l=o.sizeX,c=o.sizeY,u=o.animationTime,d=o.animationType,f=i||t<r||!l&&!c;if(!f){var m=UU(n);m&&Ho(n,m,u,d)}}function b2(n,e,t,s){var r=n.startCoords,o=n.setup,i=o.autoAlignment,l=i.sizeX,c=i.sizeY;if(r){var u=BU(n,e,t),d=u.x,f=u.y,m=$o(n,l),p=$o(n,c);KU(n,{x:d,y:f},s),r5(n,d,f,m,p)}}function ZU(n,e){if(n.isPanning){var t=n.velocity,s=n.wrapperComponent,r=n.contentComponent;n.isPanning=!1;var o=n.state,i=o.positionX,l=o.positionY,c=o.scale,u=n.panStartPosition;if(n.panStartPosition=null,u){var d=i-u.x,f=l-u.y;if(d*d+f*f<=25)return}n.isAnimating=!1,n.animation=null;var m=(s==null?void 0:s.offsetWidth)||0,p=(s==null?void 0:s.offsetHeight)||0,h=((r==null?void 0:r.offsetWidth)||0)*c,g=((r==null?void 0:r.offsetHeight)||0)*c,x=!n.setup.limitToBounds||m<h||p<g,b=!e&&t&&t.total>.1&&x;b?GU(n):o5(n)}}function f0(n,e,t,s){var r=n.setup,o=r.minScale,i=r.maxScale,l=r.limitToBounds,c=Pc(ri(e,2),o,i,0,!1),u=ia(n,c),d=Zf(n,t,s,c,u,l),f=d.x,m=d.y;return{scale:c,positionX:f,positionY:m}}function m0(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.minScale,l=o.maxScale,c=o.limitToBounds,u=o.zoomAnimation,d=u.disabled,f=u.animationTime,m=u.animationType,p=s>=i&&s<=l,h=d||p;if((s>=1||c)&&o5(n),!(h||!r||!n.mounted)){var g=e||r.offsetWidth/2,x=t||r.offsetHeight/2,b=s<i?i:l,w=f0(n,b,g,x);w&&Ho(n,w,f,m)}}var ws=function(){return ws=Object.assign||function(e){for(var t,s=1,r=arguments.length;s<r;s++){t=arguments[s];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ws.apply(this,arguments)};function v2(n,e,t){for(var s=0,r=e.length,o;s<r;s++)(o||!(s in e))&&(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return n.concat(o||Array.prototype.slice.call(e))}var Zm={scale:1,positionX:0,positionY:0},si={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},$g={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},i5=function(n){var e,t,s,r,o,i,l,c,u,d=Math.max((e=n.minScale)!==null&&e!==void 0?e:si.minScale,1e-7),f=(t=n.maxScale)!==null&&t!==void 0?t:si.maxScale,m=(s=n.initialScale)!==null&&s!==void 0?s:Zm.scale,p=Math.min(Math.max(m,d),f),h=Yl((r=n.initialPositionX)!==null&&r!==void 0?r:Zm.positionX,(o=n.minPositionX)!==null&&o!==void 0?o:-1/0,(i=n.maxPositionX)!==null&&i!==void 0?i:1/0,n.minPositionX!=null||n.maxPositionX!=null),g=Yl((l=n.initialPositionY)!==null&&l!==void 0?l:Zm.positionY,(c=n.minPositionY)!==null&&c!==void 0?c:-1/0,(u=n.maxPositionY)!==null&&u!==void 0?u:1/0,n.minPositionY!=null||n.maxPositionY!=null);return{previousScale:p,scale:p,positionX:h,positionY:g}},y2=function(n){var e=ws({},si);return Object.keys(n).forEach(function(t){var s=t,r=typeof n[s]<"u",o=typeof si[s]<"u";if(o&&r){var i=Object.prototype.toString.call(si[s]),l=i==="[object Object]",c=i==="[object Array]";l?e[s]=ws(ws({},si[s]),n[s]):c?e[s]=v2(v2([],si[s],!0),n[s]):e[s]=n[s]}}),e.minScale<=0&&(e.minScale=1e-7),e},a5=function(n,e,t){var s=n.state.scale,r=n.wrapperComponent,o=n.setup,i=o.maxScale,l=o.minScale,c=o.zoomAnimation,u=o.smooth,d=c.size;if(!r)throw new Error("Wrapper is not mounted");var f=u?s*Math.exp(e*t):s+e*t,m=Pc(ri(f,3),l,i,d,!1);return m};function l5(n,e,t,s,r){var o,i,l=n.wrapperComponent,c=n.state,u=c.scale,d=c.positionX,f=c.positionY,m=n.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var p=m.disabled?0:s,h=l.offsetWidth,g=l.offsetHeight,x=(h/2-d)/u,b=(g/2-f)/u,w=a5(n,e,t),v=f0(n,w,x,b);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");var k=n.props,j=k.onZoomStart,_=k.onZoom,N=k.onZoomStop,S=new MouseEvent("mousemove",{bubbles:!0}),C=dt(n);pt(C,S,j),pt(C,S,_),Ho(n,v,p,r);var A=(i=(o=l.ownerDocument)===null||o===void 0?void 0:o.defaultView)!==null&&i!==void 0?i:typeof window<"u"?window:null;A&&A.setTimeout(function(){n.mounted&&pt(dt(n),S,N)},p)}function c5(n,e,t,s){var r,o,i=n.setup,l=n.wrapperComponent,c=n.contentComponent,u=i.limitToBounds,d=i.centerOnInit,f=i5(n.props),m=n.state,p=m.scale,h=m.positionX,g=m.positionY;if(l){var x=f.positionX,b=f.positionY;if(d&&c){var w=p0(f.scale,l,c);x=w.positionX,b=w.positionY}var v=d0(n,f.scale),k=Ic(x,b,v,u,0,0,l),j={scale:f.scale,positionX:k.x,positionY:k.y};if(!(p===f.scale&&h===f.positionX&&g===f.positionY)){s==null||s();var _=n.props,N=_.onZoomStart,S=_.onZoom,C=_.onZoomStop,A=new MouseEvent("mousemove",{bubbles:!0}),T=dt(n);pt(T,A,N),pt(T,A,S),Ho(n,j,e,t);var I=(o=(r=l.ownerDocument)===null||r===void 0?void 0:r.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;I&&I.setTimeout(function(){n.mounted&&pt(dt(n),A,C)},e)}}}function YU(n,e,t,s){var r=n.getBoundingClientRect(),o=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=o.x*s.scale,c=o.y*s.scale;return{x:(r.x-i.x+l)/s.scale,y:(r.y-i.y+c)/s.scale}}function XU(n,e,t,s,r){s===void 0&&(s=0),r===void 0&&(r=0);var o=n.wrapperComponent,i=n.contentComponent,l=n.state,c=n.setup,u=c.limitToBounds,d=c.minScale,f=c.maxScale;if(!o||!i)return l;var m=o.getBoundingClientRect(),p=e.getBoundingClientRect(),h=YU(e,o,i,l),g=h.x,x=h.y,b=p.width/l.scale,w=p.height/l.scale,v=o.offsetWidth/b,k=o.offsetHeight/w,j=Pc(t||Math.min(v,k),d,f,0,!1),_=(m.width-b*j)/2,N=(m.height-w*j)/2,S=(m.left-g)*j+_+s,C=(m.top-x)*j+N+r,A=d0(n,j),T=Ic(S,C,A,u,0,0,o),I=T.x,E=T.y;return{positionX:I,positionY:E,scale:j}}var JU=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),l5(n,1,e,t,s)}},QU=function(n){return function(e,t,s){e===void 0&&(e=.5),t===void 0&&(t=300),s===void 0&&(s="easeOut"),l5(n,-1,e,t,s)}},eB=function(n){return function(e,t,s,r,o){r===void 0&&(r=300),o===void 0&&(o="easeOut");var i=n.state,l=i.positionX,c=i.positionY,u=i.scale,d=n.wrapperComponent,f=n.contentComponent,m=n.setup.disabled;if(!(m||!d||!f)){var p={positionX:Number.isNaN(e)?l:e,positionY:Number.isNaN(t)?c:t,scale:Number.isNaN(s)?u:s};Ho(n,p,r,o)}}},tB=function(n){return function(e,t){e===void 0&&(e=200),t===void 0&&(t="easeOut"),c5(n,e,t)}},nB=function(n){return function(e,t,s){t===void 0&&(t=200),s===void 0&&(s="easeOut");var r=n.state,o=n.wrapperComponent,i=n.contentComponent;if(o&&i){var l=p0(e||r.scale,o,i);Ho(n,l,t,s)}}},sB=function(n){return function(e,t,s,r,o,i){s===void 0&&(s=600),r===void 0&&(r="easeOut"),o===void 0&&(o=0),i===void 0&&(i=0),Ls(n);var l=n.wrapperComponent,c=typeof e=="string"?document.getElementById(e):e;if(l&&c&&l.contains(c)){var u=XU(n,c,t,o,i);Ho(n,u,s,r)}}},Rg=function(n){return{instance:n,state:n.state,zoomIn:JU(n),zoomOut:QU(n),setTransform:eB(n),resetTransform:tB(n),centerView:nB(n),zoomToElement:sB(n)}},rB=function(n){return{instance:n,state:n.state}},dt=function(n){var e={};return Object.assign(e,rB(n)),Object.assign(e,Rg(n)),e},Ym=!1;function Xm(){try{var n={get passive(){return Ym=!0,!1}};return n}catch{return Ym=!1,Ym}}var fu=".".concat($g.wrapperClass),$c=function(n,e){return e.some(function(t){return n.matches("".concat(fu," ").concat(t,", ").concat(fu," .").concat(t,", ").concat(fu," ").concat(t," *, ").concat(fu," .").concat(t," *"))})},Xl=function(n){n&&clearTimeout(n)},oB=function(n){return Number.parseFloat(n.toFixed(8))},u5=function(n,e,t){var s=oB(t);return"translate(".concat(n,"px, ").concat(e,"px) scale(").concat(s,")")},p0=function(n,e,t){var s=t.offsetWidth*n,r=t.offsetHeight*n,o=(e.offsetWidth-s)/2,i=(e.offsetHeight-r)/2;return{scale:n,positionX:o,positionY:i}};function iB(n,e){n!=null&&(typeof n=="function"?n(e):n.current=e)}function aB(n){return function(e){n.forEach(function(t){typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var d5=function(n,e){var t=n.setup.wheel,s=t.disabled,r=t.wheelDisabled,o=t.touchPadDisabled,i=t.excluded,l=n.isInitialized,c=n.isPanning,u=e.target,d=l&&!c&&!s&&u;if(!d||r&&!e.ctrlKey||o&&e.ctrlKey)return!1;var f=$c(u,i);if(f)return!1;var m=n.isPressingKeys(n.setup.wheel.activationKeys);return!!m},lB=function(n,e){var t=n.setup,s=t.disabled,r=t.trackPadPanning,o=r.activationKeys,i=r.excluded;if(!n.wrapperComponent||!n.contentComponent||s||r.disabled||e.ctrlKey)return!1;var l=d5(n,e);if(l)return!1;var c=e.target,u=$c(c,i);if(u)return!1;var d=n.isPressingKeys(o);return!!d},cB=function(n){return n?n.deltaY<0?1:-1:0};function uB(n,e){var t=cB(n),s=wU(e,t);return s}function f5(n,e,t){var s=e.getBoundingClientRect(),r=0,o=0;if("clientX"in n)r=(n.clientX-s.left)/t,o=(n.clientY-s.top)/t;else{var i=n.touches[0];r=(i.clientX-s.left)/t,o=(i.clientY-s.top)/t}return Number.isNaN(r)||Number.isNaN(o)?(console.error("No mouse or touch offset found"),{x:0,y:0}):{x:r,y:o}}var dB=function(n,e,t,s,r){var o=n.state.scale,i=n.wrapperComponent,l=n.setup,c=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=l.disablePadding,m=d.size,p=d.disabled;if(!i)throw new Error("Wrapper is not mounted");var h=o+e*t,g=s?!1:!p,x=Pc(h,u,c,m,g&&!f);return x},m5=function(n,e){var t=n.previousWheelEvent,s=n.state.scale,r=n.setup,o=r.maxScale,i=r.minScale;return t?s<o||s>i||Math.sign(t.deltaY)!==Math.sign(e.deltaY)||t.deltaY>0&&t.deltaY<e.deltaY||t.deltaY<0&&t.deltaY>e.deltaY||Math.sign(t.deltaY)!==Math.sign(e.deltaY):!1},fB=function(n,e){var t=n.setup.pinch,s=t.disabled,r=t.excluded,o=n.isInitialized,i=e.target,l=o&&!s&&i;if(!l)return!1;var c=$c(i,r);return!c},mB=function(n){var e=n.setup.pinch.disabled,t=n.isInitialized,s=n.pinchStartDistance,r=t&&!e&&s!==null;return!!r},pB=function(n,e,t){var s=t.getBoundingClientRect(),r=n.touches,o=r[0].clientX-s.left,i=r[0].clientY-s.top,l=r[1].clientX-s.left,c=r[1].clientY-s.top;return{x:(o+l)/2/e,y:(i+c)/2/e}},p5=function(n){return Math.sqrt(Math.pow(n.touches[0].pageX-n.touches[1].pageX,2)+Math.pow(n.touches[0].pageY-n.touches[1].pageY,2))},hB=5,gB=function(n,e){var t=n.pinchStartScale,s=n.pinchStartDistance,r=n.setup,o=r.maxScale,i=r.minScale,l=r.zoomAnimation,c=r.disablePadding,u=r.pinch,d=l.size,f=l.disabled,m=u.step;if(!t||s===null)throw new Error("Pinch touches distance was not provided");if(e<0)return n.state.scale;var p=e/s,h=p*t,g=(h-t)*(m/hB),x=t+g,b=x===1/0?0:ri(x,10);return Pc(b,i,o,d,!f&&!c)},h5=160,g5=100,xB=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onZoomStart;n.wheelStopEventTimer||(Ls(n),pt(dt(n),e,s),pt(dt(n),e,r))},bB=function(n,e){var t=n.props,s=t.onWheel,r=t.onZoom,o=n.contentComponent,i=n.setup,l=n.state,c=l.scale,u=i.limitToBounds,d=i.centerZoomedOut,f=i.zoomAnimation,m=i.wheel,p=i.disablePadding,h=i.smooth,g=f.size,x=f.disabled,b=m.step;if(!o)throw new Error("Component not mounted");e.cancelable&&e.preventDefault(),e.stopPropagation();var w=uB(e,null),v=h?b*Math.abs(e.deltaY):b,k=dB(n,w,v,!e.ctrlKey);if(c!==k){var j=ia(n,k),_=f5(e,o,c),N=x||g===0||d||p,S=u&&N,C=Zf(n,_.x,_.y,k,j,S),A=C.x,T=C.y;n.previousWheelEvent=e,n.setState(k,A,T),pt(dt(n),e,s),pt(dt(n),e,r)}},vB=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onZoomStop;Xl(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(m0(n,e.x,e.y),n.wheelAnimationTimer=null)},g5);var o=m5(n,e);o&&(Xl(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,pt(dt(n),e,s),pt(dt(n),e,r))},h5))},yB=function(n,e){var t=n.props,s=t.onWheelStart,r=t.onPanningStart;n.wheelStopEventTimer||(Ls(n),pt(dt(n),e,s),pt(dt(n),e,r))},wB=function(n,e){var t=n.props,s=t.onWheelStop,r=t.onPanningStop;Xl(n.wheelAnimationTimer),n.wheelAnimationTimer=setTimeout(function(){n.mounted&&(m0(n,e.x,e.y),n.wheelAnimationTimer=null)},g5);var o=m5(n,e);o&&(Xl(n.wheelStopEventTimer),n.wheelStopEventTimer=setTimeout(function(){n.mounted&&(n.wheelStopEventTimer=null,pt(dt(n),e,s),pt(dt(n),e,r))},h5))},x5=function(n){for(var e=0,t=0,s=0;s<2;s+=1)e+=n.touches[s].clientX,t+=n.touches[s].clientY;var r=e/2,o=t/2;return{x:r,y:o}},SB=function(n,e){var t=p5(e);n.pinchStartDistance=t,n.lastDistance=t,n.pinchStartScale=n.state.scale,n.isPanning=!1,n.isPinching=!0,n.pinchPreviousCenter=x5(e),Ls(n)},kB=function(n,e){var t=n.contentComponent,s=n.pinchStartDistance,r=n.wrapperComponent,o=n.pinchPreviousCenter,i=n.state.scale,l=n.setup,c=l.limitToBounds,u=l.centerZoomedOut,d=l.zoomAnimation,f=l.autoAlignment,m=l.pinch,p=l.panning,h=d.disabled,g=d.size,x=m.allowPanning;if(!(s===null||!t)){var b=pB(e,i,t);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var w=p5(e),v=gB(n,w),k=x5(e),j=i/v,_=(k.x-((o==null?void 0:o.x)||0))*j,N=(k.y-((o==null?void 0:o.y)||0))*j;if(!(v===i&&_===0&&N===0)){n.pinchPreviousCenter=k;var S=ia(n,v),C=h||g===0||u,A=c&&C,T=Zf(n,b.x,b.y,v,S,A),I=T.x,E=T.y;if(n.pinchMidpoint=b,n.lastDistance=w,p.disabled||!x)n.setState(v,I,E);else{var P=f.sizeX,R=f.sizeY,L=$o(n,P,v),O=$o(n,R,v),$=I+_,M=E+N,D=Ic($,M,S,c,L,O,r),F=D.x,z=D.y;n.setState(v,F,z)}}}}},jB=function(n){var e=n.pinchMidpoint;n.velocity=null,n.lastDistance=null,n.pinchMidpoint=null,n.pinchStartScale=null,n.pinchStartDistance=null,n.isPinching=!1,m0(n,e==null?void 0:e.x,e==null?void 0:e.y)},b5=function(n,e){var t=n.props.onZoomStop,s=n.setup.doubleClick.animationTime;Xl(n.doubleClickStopEventTimer),n.doubleClickStopEventTimer=setTimeout(function(){n.doubleClickStopEventTimer=null,pt(dt(n),e,t)},s)},NB=function(n,e){var t=n.props,s=t.onZoomStart,r=t.onZoom,o=n.setup.doubleClick,i=o.animationTime,l=o.animationType;pt(dt(n),e,s),c5(n,i,l,function(){return pt(dt(n),e,r)}),b5(n,e)};function CB(n,e){return n==="toggle"?e===1?1:-1:n==="zoomOut"?-1:1}function _B(n,e){var t=n.setup,s=n.doubleClickStopEventTimer,r=n.state,o=n.contentComponent,i=r.scale,l=n.props,c=l.onZoomStart,u=l.onZoom,d=t.doubleClick,f=d.disabled,m=d.mode,p=d.step,h=d.animationTime,g=d.animationType;if(!f&&!s){if(m==="reset")return NB(n,e);if(!o)return console.error("No ContentComponent found");var x=CB(m,n.state.scale),b=a5(n,x,p);if(i!==b){pt(dt(n),e,c);var w=f5(e,o,i),v=f0(n,b,w.x,w.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");pt(dt(n),e,u),Ho(n,v,h,g),b5(n,e)}}}var EB=function(n,e){var t=n.isInitialized,s=n.setup,r=n.wrapperComponent,o=s.doubleClick,i=o.disabled,l=o.excluded,c=e.target,u=r==null?void 0:r.contains(c),d=t&&c&&u&&!i;if(!d)return!1;var f=$c(c,l);return!f},TB=(function(){function n(e){var t=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){t.initializeWindowEvents()},this.unmount=function(){t.cleanupWindowEvents()},this.update=function(s){t.props=s,t.wrapperComponent&&t.contentComponent&&ia(t,t.state.scale),t.setup=y2(s)},this.initializeWindowEvents=function(){var s,r,o,i,l=Xm(),c=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,u=c==null?void 0:c.defaultView;(r=t.wrapperComponent)===null||r===void 0||r.addEventListener("wheel",t.onWheelPanning,l),(o=t.wrapperComponent)===null||o===void 0||o.addEventListener("keyup",t.setKeyUnPressed,l),(i=t.wrapperComponent)===null||i===void 0||i.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("mousedown",t.onPanningStart,l),u==null||u.addEventListener("mousemove",t.onPanning,l),u==null||u.addEventListener("mouseup",t.onPanningStop,l),c==null||c.addEventListener("mouseleave",t.clearPanning,l),u==null||u.addEventListener("keyup",t.setKeyUnPressed,l),u==null||u.addEventListener("keydown",t.setKeyPressed,l),u==null||u.addEventListener("blur",t.handleWindowBlur)},this.cleanupWindowEvents=function(){var s,r,o,i,l,c=Xm(),u=(s=t.wrapperComponent)===null||s===void 0?void 0:s.ownerDocument,d=u==null?void 0:u.defaultView;d==null||d.removeEventListener("mousedown",t.onPanningStart,c),d==null||d.removeEventListener("mousemove",t.onPanning,c),d==null||d.removeEventListener("mouseup",t.onPanningStop,c),u==null||u.removeEventListener("mouseleave",t.clearPanning,c),d==null||d.removeEventListener("keyup",t.setKeyUnPressed,c),d==null||d.removeEventListener("keydown",t.setKeyPressed,c),d==null||d.removeEventListener("blur",t.handleWindowBlur),document.removeEventListener("mouseleave",t.clearPanning,c),(r=t.wrapperComponent)===null||r===void 0||r.removeEventListener("wheel",t.onWheelPanning,c),(o=t.wrapperComponent)===null||o===void 0||o.removeEventListener("keyup",t.setKeyUnPressed,c),(i=t.wrapperComponent)===null||i===void 0||i.removeEventListener("keydown",t.setKeyPressed,c),Ls(t),(l=t.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(s){var r=Xm();s.addEventListener("wheel",t.onWheelZoom,r),s.addEventListener("dblclick",t.onDoubleClick,r),s.addEventListener("touchstart",t.onTouchPanningStart,r),s.addEventListener("touchmove",t.onTouchPanning,r),s.addEventListener("touchend",t.onTouchPanningStop,r)},this.handleInitialize=function(s){var r=t.setup.centerOnInit;t.applyTransformation(),t.onInitCallbacks.forEach(function(o){return o(dt(t))}),r&&(t.setCenter(),t.observer=new ResizeObserver(function(){var o,i=s.offsetWidth,l=s.offsetHeight;(i>0||l>0)&&(t.onInitCallbacks.forEach(function(c){return c(dt(t))}),t.setCenter(),(o=t.observer)===null||o===void 0||o.disconnect())}),setTimeout(function(){var o;(o=t.observer)===null||o===void 0||o.disconnect()},5e3),t.observer.observe(s))},this.onWheelZoom=function(s){var r=t.setup.disabled;if(!r){t.syncModifierKeys(s);var o=d5(t,s);o&&(xB(t,s),bB(t,s),vB(t,s))}},this.onWheelPanning=function(s){var r=t.props.onPanning,o=t.setup.trackPadPanning,i=o.lockAxisX,l=o.lockAxisY;t.syncModifierKeys(s);var c=lB(t,s);if(c){s.cancelable&&s.preventDefault(),s.stopPropagation();var u=t.state,d=u.positionX,f=u.positionY,m=d-s.deltaX,p=f-s.deltaY,h=i?d:m,g=l?f:p,x=t.setup.autoAlignment,b=x.sizeX,w=x.sizeY,v=$o(t,b),k=$o(t,w);h===d&&g===f||(yB(t,s),r5(t,h,g,v,k),pt(dt(t),s,r),wB(t,s))}},this.onPanningStart=function(s){var r=t.setup.disabled,o=t.props.onPanningStart;if(!r){t.syncModifierKeys(s);var i=p2(t,s);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.button===0&&!t.setup.panning.allowLeftClickPan||s.button===1&&!t.setup.panning.allowMiddleClickPan||s.button===2&&!t.setup.panning.allowRightClickPan||(s.cancelable&&s.preventDefault(),s.stopPropagation(),Ls(t),x2(t,s),pt(dt(t),s,o)))}}},this.onPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(!r){if(t.syncModifierKeys(s),t.isPanning&&s.buttons===0){t.clearPanning(s);return}var i=h2(t);if(i){var l=t.isPressingKeys(t.setup.panning.activationKeys);l&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),b2(t,s.clientX,s.clientY,vo.MOUSE),pt(dt(t),s,o))}}},this.onPanningStop=function(s){var r=t.setup.panning.velocityDisabled,o=t.props.onPanningStop;t.isPanning&&(ZU(t,r),pt(dt(t),s,o))},this.onPinchStart=function(s){var r=t.setup.disabled,o=t.props.onPinchStart;if(!r){var i=fB(t,s);i&&(SB(t,s),Ls(t),pt(dt(t),s,o))}},this.onPinch=function(s){var r=t.setup.disabled,o=t.props.onPinch;if(!r){var i=mB(t);i&&(s.cancelable&&s.preventDefault(),s.stopPropagation(),kB(t,s),pt(dt(t),s,o))}},this.onPinchStop=function(s){var r=t.props.onPinchStop;t.pinchStartScale&&(jB(t),pt(dt(t),s,r))},this.onTouchPanningStart=function(s){var r=t.setup,o=r.disabled,i=r.doubleClick,l=t.props.onPanningStart;if(!o){var c=!(i!=null&&i.disabled),u=t.lastTouch&&+new Date-t.lastTouch<200;if(c&&u&&s.touches.length===1)t.onDoubleClick(s);else{t.lastTouch=+new Date,Ls(t);var d=s.touches,f=d.length===1,m=d.length===2,p=p2(t,s);if(f){if(!p)return;Ls(t),x2(t,s),pt(dt(t),s,l)}m&&t.onPinchStart(s)}}},this.onTouchPanning=function(s){var r=t.setup.disabled,o=t.props.onPanning;if(t.isPanning&&s.touches.length===1){if(r)return;var i=h2(t);if(!i)return;s.cancelable&&s.preventDefault(),s.stopPropagation();var l=s.touches[0];b2(t,l.clientX,l.clientY,vo.TOUCH),pt(dt(t),s,o)}else s.touches.length>1&&t.onPinch(s)},this.onTouchPanningStop=function(s){t.onPanningStop(s),t.onPinchStop(s)},this.onDoubleClick=function(s){var r=t.setup.disabled;if(!r){var o=EB(t,s);o&&_B(t,s)}},this.clearPanning=function(s){t.isPanning&&t.onPanningStop(s)},this.handleWindowBlur=function(){t.pressedKeys={},t.isPanning&&(t.isPanning=!1,t.startCoords=null)},this.syncModifierKeys=function(s){var r=s.ctrlKey,o=s.metaKey,i=s.shiftKey,l=s.altKey;typeof r=="boolean"&&(t.pressedKeys.Control=r),typeof o=="boolean"&&(t.pressedKeys.Meta=o),typeof i=="boolean"&&(t.pressedKeys.Shift=i),typeof l=="boolean"&&(t.pressedKeys.Alt=l)},this.setKeyPressed=function(s){t.pressedKeys[s.key]=!0},this.setKeyUnPressed=function(s){t.pressedKeys[s.key]=!1},this.isPressingKeys=function(s){return typeof s=="function"?s(Object.entries(t.pressedKeys).filter(function(r){var o=r[1];return o}).map(function(r){var o=r[0];return o})):s.length?!!s.every(function(r){return t.pressedKeys[r]}):!0},this.setCenter=function(){if(t.wrapperComponent&&t.contentComponent){var s=p0(t.state.scale,t.wrapperComponent,t.contentComponent);t.setState(s.scale,s.positionX,s.positionY)}},this.handleTransformStyles=function(s,r,o){return t.props.customTransform?t.props.customTransform(s,r,o):u5(s,r,o)},this.getContext=function(){return dt(t)},this.applyTransformation=function(){if(!(!t.mounted||!t.contentComponent)){var s=t.state,r=s.scale,o=s.positionX,i=s.positionY,l=t.handleTransformStyles(o,i,r);t.props.detached||(t.contentComponent.style.transform=l),t.onTransformCallbacks.forEach(function(c){return c({scale:r,positionX:o,positionY:i,previousScale:t.state.previousScale,ref:dt(t)})})}},this.setState=function(s,r,o){var i=t.props.onTransform;if(!Number.isNaN(s)&&!Number.isNaN(r)&&!Number.isNaN(o)){var l=Math.max(s,1e-7);l!==t.state.scale&&(t.state.previousScale=t.state.scale,t.state.scale=l),t.state.positionX=r,t.state.positionY=o,t.applyTransformation();var c=dt(t);t.onChangeCallbacks.forEach(function(u){return u(c)}),pt(c,{scale:t.state.scale,positionX:r,positionY:o},i)}else console.error("Detected NaN set state values")},this.onTransform=function(s){return t.onTransformCallbacks.has(s)||t.onTransformCallbacks.add(s),function(){t.onTransformCallbacks.delete(s)}},this.onChange=function(s){return t.onChangeCallbacks.has(s)||t.onChangeCallbacks.add(s),function(){t.onChangeCallbacks.delete(s)}},this.onInit=function(s){return t.onInitCallbacks.has(s)||t.onInitCallbacks.add(s),function(){t.onInitCallbacks.delete(s)}},this.init=function(s,r){t.cleanupWindowEvents(),t.wrapperComponent=s,t.contentComponent=r,ia(t,t.state.scale),t.handleInitializeWrapperEvents(s),t.handleInitialize(r),t.initializeWindowEvents(),t.isInitialized=!0;var o=dt(t);pt(o,void 0,t.props.onInit),iB(t.props.ref,o)},this.props=e,this.setup=y2(this.props),this.state=i5(this.props)}return n})(),Yf=Ie.createContext(null),AB=function(n,e){return typeof n=="function"?n(e):n},IB=Ie.forwardRef(function(n,e){var t=y.useRef(new TB(n)).current,s=AB(n.children,Rg(t));return y.useImperativeHandle(e,function(){return Rg(t)},[t]),y.useEffect(function(){t.update(n)},[t,n]),a.jsx(Yf.Provider,ws({value:t},{children:s}))});Ie.forwardRef(function(n,e){var t=y.useRef(null),s=y.useContext(Yf);return y.useEffect(function(){return s.onChange(function(r){if(t.current){var o=0,i=0;t.current.style.transform=s.handleTransformStyles(o,i,1/r.instance.state.scale)}})},[s]),a.jsx("div",ws({},n,{ref:aB([t,e])}))});function PB(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var s=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}}var $B=`.transform-component-module_wrapper__SPB86 {
|
|
51
51
|
position: relative;
|
|
@@ -125,7 +125,7 @@ ${P}`:P:null}).filter(Boolean).join(`
|
|
|
125
125
|
`)))}for(const i of uK(r))t.push({text:i.text,bodies:o,piped:i.piped})}return t}function fK(n,e){const t=n.match(/^cd\s+(?:"([^"]*)"|'([^']*)'|([^\s;&|]+))\s*$/);return t?Qf(t[1]??t[2]??t[3]??"",e):null}function mK(n){const e=n.match(/^tee\s+(?:(-a)\s+)?(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);if(e)return e[1]?null:e[2]??e[3]??e[4]??null;if(!/^cat\b/.test(n))return null;const t=n.match(/(>>?)\s*(?:"([^"]+)"|'([^']+)'|([^\s<>|;&]+))/);return!t||t[1]===">>"?null:t[2]??t[3]??t[4]??null}function pK(n,e){if(n.piped||n.bodies.size===0)return null;const t=n.text.match(h_);if(!t)return null;const s=n.bodies.get(t[2]??t[3]??"");if(s===void 0)return null;const r=mK(n.text);if(!r)return null;const o=Qf(r,e);return o?{name:"Write",input:{file_path:o,content:s}}:null}function X2(n,e){const t=e==="replacement";let s="";for(let r=0;r<n.length;r++){const o=n[r];if(o==="\\"){const i=n[r+1];if(i===void 0||i==="|"||!Z2.test(i)&&!"\\/&#".includes(i))return null;s+=i,r++;continue}if(o==="&"&&t||!t&&Z2.test(o))return null;s+=o}return s}const hK=/^sed\s+-i(?:\.\S+)?\s+(?:''\s+|""\s+)?(?<quote>['"])s(?<sep>.)(?<pattern>(?:(?!\k<sep>).)*)\k<sep>(?<replacement>(?:(?!\k<sep>).)*)\k<sep>(?<flags>[a-zA-Z]*)\k<quote>\s+(?:"(?<dquoted>[^"]+)"|'(?<squoted>[^']+)'|(?<bare>[^\s<>|;&]+))$/;function gK(n,e){var m;const t=(m=n.text.match(hK))==null?void 0:m.groups;if(!t)return null;const{pattern:s,replacement:r,flags:o,dquoted:i,squoted:l,bare:c}=t;if(/[^g]/.test(o))return null;const u=X2(s,"pattern"),d=X2(r,"replacement");if(!u||d===null)return null;const f=Qf(i??l??c??"",e);return f?{name:"Edit",input:{file_path:f,old_string:u,new_string:d,replace_all:o.includes("g")}}:null}function g_(n,e=null){if(n.fileDiffs)return dD(n.fileDiffs).map((o,i)=>({...Dd(n,`${n.id}:bash-${i}`,"Edit",{file_path:o.filePath,old_string:o.oldString,new_string:o.newString}),diffLineCounts:o.diffLineCounts}));const t=n.input.command;if(typeof t!="string"||!t)return[];const s=[];let r=e;for(const o of dK(t)){const i=fK(o.text,r);if(i){r=i;continue}const l=pK(o,r)??gK(o,r);l&&s.push(Dd(n,`${n.id}:bash-${s.length}`,l.name,l.input))}return s}function x_(n,e){const t=n.input.edits,s=n.input.file_path??n.input.path;if(!Array.isArray(t)||typeof s!="string")return[];const r=Qf(s,e)??s,o=[];for(const[i,l]of t.entries()){if(typeof l!="object"||l===null)continue;const{old_string:c,new_string:u,replace_all:d}=l;typeof c!="string"||typeof u!="string"||o.push(Dd(n,`${n.id}:edit-${i}`,"Edit",{file_path:r,old_string:c,new_string:u,replace_all:d===!0}))}return o}function b_(n,e){const t=[n.input.patch,n.input.value,n.input.input].find(s=>typeof s=="string");return t?hC("apply_patch",t,n.id,n.timestamp,e??"").map(s=>Dd(n,s.id,s.name,s.input)):[]}function El(n,e=null){const t=[];for(const s of n)s.isError||s.awaitingReview||(s.name==="Edit"||s.name==="Write"?t.push(s):s.name==="MultiEdit"?t.push(...x_(s,e)):s.name==="Bash"?t.push(...g_(s,e)):s.name==="apply_patch"&&t.push(...b_(s,e)));return t}function Fd(n,e=null){for(const t of n)if(!(t.isError||t.awaitingReview)&&(t.name==="Edit"||t.name==="Write"||t.name==="MultiEdit"&&x_(t,e).length>0||t.name==="Bash"&&g_(t,e).length>0||t.name==="apply_patch"&&b_(t,e).length>0))return!0;return!1}const xK=new Set(["tsx","jsx","ts","js","mjs","cjs","css","scss","sass","less","yaml","yml","toml","py","rs","go","html","htm","vue","svelte","sql","rb","java","kt","swift","php","c","h","cpp","cc","hpp","cs"]),bK={json:Bv,jsonc:Bv,md:xl,mdx:xl,txt:xl,png:Go,jpg:Go,jpeg:Go,gif:Go,webp:Go,svg:Go,ico:Go,sh:eu,bash:eu,zsh:eu,fish:eu};function v_(n){const e=n.split("/").at(-1)??n,t=e.lastIndexOf(".");return t===-1?"":e.slice(t+1).toLowerCase()}function vK(n){const e=v_(n);return bK[e]??(xK.has(e)?fc:kj)}function aa(n){const e=q.c(11),{add:t,del:s,dimmed:r,className:o}=n,i=r&&"opacity-40";let l;e[0]!==o||e[1]!==i?(l=G("flex shrink-0 items-center gap-1 font-mono text-xs tabular-nums",i,o),e[0]=o,e[1]=i,e[2]=l):l=e[2];let c;e[3]!==t?(c=t>0&&a.jsxs("span",{className:"text-success",children:["+",t]}),e[3]=t,e[4]=c):c=e[4];let u;e[5]!==s?(u=s>0&&a.jsxs("span",{className:"text-destructive",children:["-",s]}),e[5]=s,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==c||e[9]!==u?(d=a.jsxs("span",{className:l,children:[c,u]}),e[7]=l,e[8]=c,e[9]=u,e[10]=d):d=e[10],d}const J2=5;function T0(n){const e=q.c(11),{add:t,del:s}=n,r=t+s;if(r===0)return null;let o,i,l;if(e[0]!==t||e[1]!==r){const d=Math.round(t/r*J2);o=J2-d,i="flex items-center gap-[1px] shrink-0 ml-1",l=Array.from({length:d},wK),e[0]=t,e[1]=r,e[2]=o,e[3]=i,e[4]=l}else o=e[2],i=e[3],l=e[4];let c;e[5]!==o?(c=Array.from({length:o},yK),e[5]=o,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==l||e[9]!==c?(u=a.jsxs("span",{className:i,children:[l,c]}),e[7]=i,e[8]=l,e[9]=c,e[10]=u):u=e[10],u}function yK(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-destructive/70"},`d${e}`)}function wK(n,e){return a.jsx("span",{className:"inline-block size-1.5 rounded-xs bg-success/70"},`a${e}`)}const Ud="cogpit:open-subagent";function y_(n){const e=q.c(3),{hasEdit:t,hasWrite:s}=n;if(t&&s){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E+W"}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx("span",{className:"shrink-0 text-xs font-bold text-success",children:"W"}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx("span",{className:"shrink-0 text-xs font-bold text-warning",children:"E"}),e[2]=r):r=e[2],r}function A0(n){const e=q.c(2),{agentId:t}=n;let s;return e[0]!==t?(s=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",className:"size-5 shrink-0 font-mono text-xs font-bold text-muted-foreground","aria-label":"Open sub-agent view",title:"Open sub-agent view",onClick:r=>{r.stopPropagation(),window.dispatchEvent(new CustomEvent(Ud,{detail:{agentId:t}}))},children:"S"}),e[0]=t,e[1]=s):s=e[1],s}const w_=y.memo(function(e){const t=q.c(92),{file:s,defaultOpen:r,isHighlighted:o,diffMode:i}=e,{ref:l,isNear:c}=W5(),[u,d]=y.useState(r),[f,m]=y.useState(r),p=y.useRef(r);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=be=>{d(be),be?y.startTransition(()=>m(!0)):m(!1)},t[0]=h):h=t[0];const g=h;let x,b;t[1]!==r?(x=()=>{p.current!==r&&(p.current=r,g(r))},b=[r,g],t[1]=r,t[2]=x,t[3]=b):(x=t[2],b=t[3]),y.useEffect(x,b);let w,v;t[4]!==o?(w=()=>{o&&g(!0)},v=[o,g],t[4]=o,t[5]=w,t[6]=v):(w=t[5],v=t[6]),y.useEffect(w,v);let k;t[7]!==s.filePath?(k=v_(s.filePath),t[7]=s.filePath,t[8]=k):k=t[8];const j=k,_=s.netOriginal,N=s.netCurrent,S=!!(_||N);let C;t[9]!==s.edits?(C=s.edits.some(NK),t[9]=s.edits,t[10]=C):C=t[10];const T=i==="per-edit"?C:S,I=f&&c&&T,[E,P]=y.useState(0);let R;t[11]===Symbol.for("react.memo_cache_sentinel")?(R=be=>{if(!be)return;const we=be.offsetHeight;P(ve=>ve===we?ve:we)},t[11]=R):R=t[11];const L=R,O=s.turnRange[0]===s.turnRange[1]?`T${s.turnRange[0]+1}`:`T${s.turnRange[0]+1}–T${s.turnRange[1]+1}`,$=s.filePath,M=o?"border-ring ring-2 ring-ring/20":"border-border";let D;t[12]!==M?(D=G("rounded-lg border bg-card transition-colors",M),t[12]=M,t[13]=D):D=t[13];let F;t[14]!==u?(F=()=>g(!u),t[14]=u,t[15]=F):F=t[15];let z;t[16]!==u?(z=u?a.jsx(Wt,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}):a.jsx(it,{"data-icon":"inline-start",className:"size-3 shrink-0 text-muted-foreground"}),t[16]=u,t[17]=z):z=t[17];let B;t[18]!==j?(B=a.jsx("span",{className:"shrink-0 font-mono text-xs font-bold text-muted-foreground",children:j}),t[18]=j,t[19]=B):B=t[19];let U;t[20]!==s.opTypes?(U=s.opTypes.includes("Edit"),t[20]=s.opTypes,t[21]=U):U=t[21];let W;t[22]!==s.opTypes?(W=s.opTypes.includes("Write"),t[22]=s.opTypes,t[23]=W):W=t[23];let V;t[24]!==U||t[25]!==W?(V=a.jsx(y_,{hasEdit:U,hasWrite:W}),t[24]=U,t[25]=W,t[26]=V):V=t[26];let H;t[27]!==s.shortPath?(H=a.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s.shortPath}),t[27]=s.shortPath,t[28]=H):H=t[28];let K;t[29]!==O?(K=a.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:O}),t[29]=O,t[30]=K):K=t[30];let Z;t[31]!==s.editCount?(Z=s.editCount>1&&a.jsxs(Ue,{variant:"outline",className:"h-5 shrink-0 px-1 font-mono text-xs text-muted-foreground",children:[s.editCount,"x"]}),t[31]=s.editCount,t[32]=Z):Z=t[32];let Y;t[33]!==u||t[34]!==F||t[35]!==z||t[36]!==B||t[37]!==V||t[38]!==H||t[39]!==K||t[40]!==Z?(Y=a.jsxs(J,{type:"button",variant:"ghost",onClick:F,className:"h-auto min-w-0 flex-1 justify-start gap-1.5 rounded-r-none px-2 py-1 font-normal","aria-expanded":u,children:[z,B,V,H,K,Z]}),t[33]=u,t[34]=F,t[35]=z,t[36]=B,t[37]=V,t[38]=H,t[39]=K,t[40]=Z,t[41]=Y):Y=t[41];let X;t[42]!==s.subAgentId?(X=s.subAgentId&&a.jsx(A0,{agentId:s.subAgentId}),t[42]=s.subAgentId,t[43]=X):X=t[43];let ee;t[44]!==s.filePath?(ee=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Gl(s.filePath),"aria-label":"Open file in editor"}),t[44]=s.filePath,t[45]=ee):ee=t[45];let Q;t[46]===Symbol.for("react.memo_cache_sentinel")?(Q=a.jsx(Y1,{"data-icon":"inline-start"}),t[46]=Q):Q=t[46];let ne;t[47]!==ee?(ne=a.jsx(Ut,{render:ee,children:Q}),t[47]=ee,t[48]=ne):ne=t[48];let te;t[49]===Symbol.for("react.memo_cache_sentinel")?(te=a.jsx(Bt,{children:"Open in editor"}),t[49]=te):te=t[49];let re;t[50]!==ne?(re=a.jsxs(Ft,{children:[ne,te]}),t[50]=ne,t[51]=re):re=t[51];let oe;t[52]!==s.filePath?(oe=a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>Gl(s.filePath,{mode:"diff"}),"aria-label":"View git diff"}),t[52]=s.filePath,t[53]=oe):oe=t[53];let ie;t[54]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx($P,{"data-icon":"inline-start"}),t[54]=ie):ie=t[54];let ae;t[55]!==oe?(ae=a.jsx(Ut,{render:oe,children:ie}),t[55]=oe,t[56]=ae):ae=t[56];let de;t[57]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx(Bt,{children:"View git diff"}),t[57]=de):de=t[57];let le;t[58]!==ae?(le=a.jsxs(Ft,{children:[ae,de]}),t[58]=ae,t[59]=le):le=t[59];let se;t[60]!==re||t[61]!==le?(se=a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[re,le]}),t[60]=re,t[61]=le,t[62]=se):se=t[62];let me,ue;t[63]!==s.addCount||t[64]!==s.delCount?(me=a.jsx(aa,{add:s.addCount,del:s.delCount}),ue=a.jsx(T0,{add:s.addCount,del:s.delCount}),t[63]=s.addCount,t[64]=s.delCount,t[65]=me,t[66]=ue):(me=t[65],ue=t[66]);let ce;t[67]!==X||t[68]!==se||t[69]!==me||t[70]!==ue?(ce=a.jsxs("div",{className:"flex items-center gap-1.5 pr-2 shrink-0",children:[X,se,me,ue]}),t[67]=X,t[68]=se,t[69]=me,t[70]=ue,t[71]=ce):ce=t[71];let xe;t[72]!==Y||t[73]!==ce?(xe=a.jsxs("div",{className:"group sticky top-0 z-10 flex w-full items-center rounded-t-lg bg-popover",children:[Y,ce]}),t[72]=Y,t[73]=ce,t[74]=xe):xe=t[74];let pe;t[75]!==i||t[76]!==s.edits||t[77]!==s.filePath||t[78]!==s.netStartLine||t[79]!==T||t[80]!==E||t[81]!==N||t[82]!==_||t[83]!==u||t[84]!==I?(pe=a.jsx(SK,{showDiff:I,open:u,hasDiff:T,diffRef:L,lastDiffHeight:E,oldString:_,newString:N,filePath:s.filePath,diffMode:i,edits:s.edits,netStartLine:s.netStartLine}),t[75]=i,t[76]=s.edits,t[77]=s.filePath,t[78]=s.netStartLine,t[79]=T,t[80]=E,t[81]=N,t[82]=_,t[83]=u,t[84]=I,t[85]=pe):pe=t[85];let he;return t[86]!==s.filePath||t[87]!==l||t[88]!==D||t[89]!==xe||t[90]!==pe?(he=a.jsxs("div",{ref:l,"data-file-path":$,className:D,children:[xe,pe]}),t[86]=s.filePath,t[87]=l,t[88]=D,t[89]=xe,t[90]=pe,t[91]=he):he=t[91],he}),SK=y.memo(function(e){const t=q.c(15),{showDiff:s,open:r,hasDiff:o,diffRef:i,lastDiffHeight:l,oldString:c,newString:u,filePath:d,diffMode:f,edits:m,netStartLine:p}=e;if(s){let h;t[0]!==f||t[1]!==m||t[2]!==d||t[3]!==p||t[4]!==u||t[5]!==c?(h=f==="per-edit"?a.jsx(jK,{edits:m,filePath:d}):a.jsx(C0,{oldString:c,newString:u,filePath:d,compact:!1,startLine:p,hideHeader:!0}),t[0]=f,t[1]=m,t[2]=d,t[3]=p,t[4]=u,t[5]=c,t[6]=h):h=t[6];let g;return t[7]!==f||t[8]!==i||t[9]!==h?(g=a.jsx("div",{ref:i,className:"motion-enter overflow-hidden rounded-b",children:h},f),t[7]=f,t[8]=i,t[9]=h,t[10]=g):g=t[10],g}if(r&&l>0){let h;return t[11]!==l?(h=a.jsx("div",{style:{height:l}}),t[11]=l,t[12]=h):h=t[12],h}if(r&&!o){const h=f==="per-edit"?"No edits":"No net changes (all edits cancelled out)";let g;return t[13]!==h?(g=a.jsx("div",{className:"motion-enter px-3 py-2 text-xs italic text-muted-foreground",children:h}),t[13]=h,t[14]=g):g=t[14],g}return null}),Q2=3,kK=5,jK=y.memo(function(e){const t=q.c(9),{edits:s,filePath:r}=e,o=s.length,i=s.filter(CK),l=i.length>Q2,[c,u]=y.useState(l?Q2:i.length);y.useEffect(()=>{if(c>=i.length)return;const x=requestAnimationFrame(()=>{u(b=>Math.min(b+kK,i.length))});return()=>cancelAnimationFrame(x)},[c,i.length]);const d=l?i.slice(0,c):i,f="divide-y divide-border/30";let m;t[0]!==r||t[1]!==o?(m=(x,b)=>a.jsxs("div",{children:[o>1&&a.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 px-2.5 py-1",children:[a.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[x.toolName," ",b+1,"/",o]}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["T",x.turnIndex+1]}),x.agentId&&a.jsx(A0,{agentId:x.agentId})]}),a.jsx(C0,{oldString:x.oldString,newString:x.newString,filePath:r,compact:!1,startLine:x.startLine,hideHeader:!0})]},x.id),t[0]=r,t[1]=o,t[2]=m):m=t[2];const p=d.map(m);let h;t[3]!==i.length||t[4]!==c?(h=c<i.length&&a.jsxs("div",{className:"py-1.5 text-center text-xs text-muted-foreground",children:["Loading ",i.length-c," more edits…"]}),t[3]=i.length,t[4]=c,t[5]=h):h=t[5];let g;return t[6]!==p||t[7]!==h?(g=a.jsxs("div",{className:f,children:[p,h]}),t[6]=p,t[7]=h,t[8]=g):g=t[8],g});function NK(n){return!!(n.oldString||n.newString)}function CK(n){return!!(n.oldString||n.newString)}const ip=new Map;function _K(n){var w;const e=xn("hostFiles"),{sessionSource:t}=yt(),s=t==null?void 0:t.dirName,r=an(s)==="codex",o=n.turns.length,i=((w=n.turns.at(-1))==null?void 0:w.toolCalls.length)??0,l=y.useMemo(()=>{let v=0;for(const k of n.turns){v+=k.toolCalls.length;for(const j of k.subAgentActivity)v+=j.toolCalls.length}return v},[o,i]),c=y.useMemo(()=>{const v=[];for(let k=0;k<n.turns.length;k++)for(const j of n.turns[k].subAgentActivity){const _=r&&(j.status==="completed"||j.status==="failed"||j.status==="interrupted");(j.isBackground||_)&&j.toolCalls.length===0&&v.push({agentId:j.agentId,turnIndex:k})}return v},[n.turns,l,r]),[u,d]=y.useState(new Map),f=y.useRef(new Set);y.useEffect(()=>{if(!s||!n.sessionId||c.length===0)return;const v=[];for(const{agentId:_}of c){const N=en(`${s}/${n.sessionId}/${_}`);if(!f.current.has(N)){if(ip.has(N)){d(S=>{const C=new Map(S);return C.set(_,ip.get(N)),C}),f.current.add(N);continue}v.push({agentId:_,cacheKey:N})}}if(v.length===0)return;let k=!1;async function j(){const _=new Map;await Promise.all(v.map(async({agentId:N,cacheKey:S})=>{try{const C=`/api/sessions/${encodeURIComponent(s)}/${encodeURIComponent(n.sessionId)}/subagents/agent-${encodeURIComponent(N)}.jsonl`,A=await Ee(C);if(!A.ok)return;const T=await A.text(),E=Z5(T,N).flatMap(P=>El(P.toolCalls,n.cwd));ip.set(S,E),f.current.add(S),_.set(N,E)}catch{}})),!k&&_.size>0&&d(N=>{const S=new Map(N);for(const[C,A]of _)S.set(C,A);return S})}return j(),()=>{k=!0}},[s,n.sessionId,n.cwd,c]);const m=y.useMemo(()=>{const v=[],k=new Set;for(let j=0;j<n.turns.length;j++){const _=n.turns[j];for(const N of El(_.toolCalls,n.cwd))v.push({turnIndex:j,toolCall:N});for(const N of _.subAgentActivity){for(const S of El(N.toolCalls,n.cwd))v.push({turnIndex:j,toolCall:S,agentId:N.agentId});if((N.isBackground||r)&&N.toolCalls.length===0&&!k.has(N.agentId)){k.add(N.agentId);const S=u.get(N.agentId);if(S)for(const C of S)v.push({turnIndex:j,toolCall:C,agentId:N.agentId})}}}return v},[l,n.turns,u,r]),p=y.useMemo(()=>{const v=new Set;for(const k of m){const j=S_(k.toolCall);j&&v.add(j)}return[...v]},[m]),[h,g]=y.useState(new Map);y.useEffect(()=>{if(!e||p.length===0){g(new Map);return}let v=!1;return Promise.all(p.map(k=>Ee(`/api/file-content?path=${encodeURIComponent(k)}`).then(j=>j.ok?j.text():null).then(j=>j?[k,j]:null).catch(()=>null))).then(k=>{if(v)return;const j=new Map;for(const _ of k)_&&j.set(_[0],_[1]);g(j)}),()=>{v=!0}},[e,p]);const x=n.turns.length-1,b=y.useMemo(()=>{const v=new Map;for(const k of n.turns)for(const j of k.subAgentActivity)v.has(j.agentId)||v.set(j.agentId,{name:j.agentName,type:j.subagentType});return v},[n.turns]);return{fileChanges:m,fileContents:h,lastTurnIndex:x,agentMap:b}}function ew(n,e){if(!n||!e)return 1;const t=n.indexOf(e);if(t===-1)return 1;let s=1;for(let r=0;r<t;r++)n[r]===`
|
|
126
126
|
`&&s++;return s}function S_(n){return String(n.input.file_path??n.input.path??"")}function EK(n){const e=n.name==="Edit";return{oldString:e?String(n.input.old_string??""):"",newString:String(e?n.input.new_string??"":n.input.content??""),isWrite:!e,diffLineCounts:n.diffLineCounts}}function k_(n,e,t){const s=new Map;for(const o of n){if(e!=="all"&&o.turnIndex!==e)continue;const i=S_(o.toolCall);if(!i)continue;let l=s.get(i);l||(l=[],s.set(i,l)),l.push(o)}const r=[];for(const[o,i]of s){const l=[],c=[];let u=1/0,d=-1/0,f=!1,m=!1,p;const h=t==null?void 0:t.get(o);for(let b=0;b<i.length;b++){const w=i[b],v=EK(w.toolCall);l.push(v),w.turnIndex<u&&(u=w.turnIndex),w.turnIndex>d&&(d=w.turnIndex),w.toolCall.name==="Edit"?f=!0:m=!0,w.agentId&&(p=w.agentId),c.push({id:w.toolCall.id,oldString:v.oldString,newString:v.newString,toolName:w.toolCall.name,turnIndex:w.turnIndex,agentId:w.agentId,startLine:w.toolCall.name==="Write"?1:ew(h,v.newString||v.oldString)})}const g=Oq(l),x=[];f&&x.push("Edit"),m&&x.push("Write"),r.push({filePath:o,shortPath:o.split("/").slice(-3).join("/"),editCount:i.length,turnRange:[u,d],opTypes:x,netOriginal:g.originalStr,netCurrent:g.currentStr,addCount:g.addCount,delCount:g.delCount,subAgentId:p??null,edits:c,netStartLine:g.currentStr?ew(h,g.currentStr):c.length>0?c[0].startLine:1})}return r.sort((o,i)=>o.turnRange[1]-i.turnRange[1]||o.turnRange[0]-i.turnRange[0]||o.filePath.localeCompare(i.filePath)),r}function TK(n,e,t,s){const r=new Map;for(const i of n){if(!i.agentId||e!=="all"&&i.turnIndex!==e)continue;let l=r.get(i.agentId);l||(l=[],r.set(i.agentId,l)),l.push(i)}const o=[];for(const[i,l]of r){const c=k_(l,"all",s);if(c.length===0)continue;let u=0,d=0;for(const m of c)u+=m.addCount,d+=m.delCount;const f=t.get(i);o.push({agentId:i,agentName:(f==null?void 0:f.name)??null,subagentType:(f==null?void 0:f.type)??null,files:c,totalAdd:u,totalDel:d})}return o.sort((i,l)=>{var d,f;const c=((d=i.files[0])==null?void 0:d.turnRange[0])??0,u=((f=l.files[0])==null?void 0:f.turnRange[0])??0;return c-u}),o}const tc="cogpit:focus-file",AK="cogpit:file-changes-prefs",IK={expanded:!0,diffMode:"net",scope:"last",groupByAgent:!1};function PK(n){const e=q.c(34),{group:t,allExpanded:s,highlightPath:r,diffMode:o}=n;let i;e[0]!==t.agentId||e[1]!==t.agentName?(i=t.agentName||t.agentId.slice(0,8),e[0]=t.agentId,e[1]=t.agentName,e[2]=i):i=e[2];const l=i,c=t.subagentType,u=`Open subagent ${t.agentId}`;let d;e[3]!==t.agentId?(d=()=>{window.dispatchEvent(new CustomEvent(Ud,{detail:{agentId:t.agentId}}))},e[3]=t.agentId,e[4]=d):d=e[4];let f;e[5]!==l||e[6]!==u||e[7]!==d?(f=a.jsx(J,{type:"button",variant:"ghost",size:"xs",className:"h-auto min-w-0 truncate px-1 text-xs font-semibold",title:u,onClick:d,children:l}),e[5]=l,e[6]=u,e[7]=d,e[8]=f):f=e[8];let m;e[9]!==c?(m=c&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",children:c}),e[9]=c,e[10]=m):m=e[10];let p;e[11]!==t.files.length?(p=a.jsx(Ue,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:t.files.length}),e[11]=t.files.length,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx("div",{className:"flex-1"}),e[13]=h):h=e[13];let g;e[14]!==t.totalAdd||e[15]!==t.totalDel?(g=a.jsx(aa,{add:t.totalAdd,del:t.totalDel}),e[14]=t.totalAdd,e[15]=t.totalDel,e[16]=g):g=e[16];let x;e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==g?(x=a.jsxs("div",{className:"flex items-center gap-2 px-1.5 pt-1.5 pb-0.5",children:[f,m,p,h,g]}),e[17]=f,e[18]=m,e[19]=p,e[20]=g,e[21]=x):x=e[21];let b;if(e[22]!==s||e[23]!==o||e[24]!==t.files||e[25]!==r){let v;e[27]!==s||e[28]!==o||e[29]!==r?(v=k=>a.jsx(w_,{file:k,defaultOpen:s,isHighlighted:r===k.filePath,diffMode:o},k.filePath),e[27]=s,e[28]=o,e[29]=r,e[30]=v):v=e[30],b=t.files.map(v),e[22]=s,e[23]=o,e[24]=t.files,e[25]=r,e[26]=b}else b=e[26];let w;return e[31]!==b||e[32]!==x?(w=a.jsxs("div",{className:"flex flex-col gap-1",children:[x,b]}),e[31]=b,e[32]=x,e[33]=w):w=e[33],w}const $K=y.memo(function({session:e,sessionChangeKey:t}){const s=y.useRef(null),r=y.useRef(null),o=y.useRef(!0),i=y.useRef(!1),l=y.useRef(0),c=y.useRef(e.turns.length),[u,d]=y.useState(!1),[f,m]=y.useState(!1),[p,h]=br(AK,{}),g={...IK,...p},x=g.expanded,b=g.diffMode,w=g.groupByAgent,[v,k]=y.useState(g.scope),j=y.useCallback(W=>{h(V=>({...V,expanded:W}))},[h]),_=y.useCallback(W=>{h(V=>({...V,diffMode:W}))},[h]),N=y.useCallback(W=>{h(V=>({...V,groupByAgent:W}))},[h]);y.useEffect(()=>{typeof v!="number"&&h(W=>({...W,scope:v}))},[v,h]);const[S,C]=y.useState(null),A=y.useRef(null),{fileChanges:T,fileContents:I,lastTurnIndex:E,agentMap:P}=_K(e),R=y.useMemo(()=>k_(T,typeof v=="number"?v:v==="all"?"all":E,I),[T,v,E,I]),L=y.useMemo(()=>w?TK(T,typeof v=="number"?v:v==="all"?"all":E,P,I):[],[w,T,v,E,P,I]);y.useEffect(()=>{const W=V=>{const H=V.detail;H!=null&&H.filePath&&(k(H.turnIndex),C(H.filePath),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>C(null),3e3),requestAnimationFrame(()=>{var Z;const K=(Z=s.current)==null?void 0:Z.querySelector(`[data-file-path="${CSS.escape(H.filePath)}"]`);K==null||K.scrollIntoView({behavior:"smooth",block:"nearest"})}))};return window.addEventListener(tc,W),()=>{window.removeEventListener(tc,W),A.current&&clearTimeout(A.current)}},[]);const O=y.useCallback(()=>{const W=s.current;W&&(d(W.scrollTop>10),m(W.scrollHeight-W.scrollTop-W.clientHeight>10))},[]),$=y.useCallback(()=>{const W=s.current;W&&(o.current=W.scrollHeight-W.scrollTop-W.clientHeight<50,O())},[O]);if(y.useEffect(()=>{O()},[T.length,R.length,O]),y.useEffect(()=>{const W=s.current;W&&(W.scrollTop=W.scrollHeight),o.current=!0,i.current=!1,l.current=T.length,c.current=e.turns.length,k(g.scope),C(null),O()},[t]),y.useEffect(()=>{const W=e.turns.length;W>c.current&&(i.current=!0),c.current=W},[e.turns.length]),y.useEffect(()=>{if(T.length<=l.current){l.current=T.length;return}l.current=T.length,(i.current||o.current)&&(requestAnimationFrame(()=>{var W;(W=r.current)==null||W.scrollIntoView({behavior:"smooth"})}),i.current=!1)},[T.length]),T.length===0)return null;let M=0,D=0,F=0;if(w)for(const W of L)M+=W.totalAdd,D+=W.totalDel,F+=W.files.length;else{for(const W of R)M+=W.addCount,D+=W.delCount;F=R.length}function z(){k(v==="last"?"all":"last")}function B(){return typeof v=="number"?`Turn ${v+1}`:v==="all"?"All turns":`Last turn (T${E+1})`}const U=B();return a.jsxs("div",{className:"view-transition-file-panel panel-enter-bottom flex h-full min-w-0 flex-col overflow-hidden bg-canvas",children:[a.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 border-b px-3",children:[a.jsx(fc,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:"File Changes"}),a.jsxs(Ue,{variant:"outline",className:"h-5 px-1.5 text-xs text-muted-foreground",children:[F," file",F!==1?"s":""]}),a.jsx("div",{className:"flex-1"}),a.jsx(aa,{add:M,del:D}),a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:w?"secondary":"ghost",size:"icon-xs",onClick:()=>N(!w),"aria-label":w?"Show all changes":"Group by subagent"}),children:a.jsx(Zs,{"data-icon":"inline-start"})}),a.jsx(Bt,{children:w?"Show all changes":"Group by subagent"})]}),a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:v==="all"?"secondary":"ghost",size:"icon-xs",onClick:z,"aria-label":v==="last"?"Show all turns":"Show last turn only"}),children:v==="all"?a.jsx(hd,{"data-icon":"inline-start"}):a.jsx(Eo,{"data-icon":"inline-start"})}),a.jsx(Bt,{children:v==="last"?"Click for all turns":"Click for last turn only"})]}),a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:b==="per-edit"?"secondary":"ghost",size:"icon-xs",onClick:()=>_(b==="net"?"per-edit":"net"),"aria-label":b==="net"?"Show per-edit diffs":"Show net diff"}),children:b==="net"?a.jsx(RP,{"data-icon":"inline-start"}):a.jsx(OP,{"data-icon":"inline-start"})}),a.jsx(Bt,{children:b==="net"?"Switch to per-edit diffs":"Switch to net diff"})]}),a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>j(!x),"aria-label":x?"Collapse all":"Expand all"}),children:x?a.jsx(hf,{"data-icon":"inline-start"}):a.jsx(wa,{"data-icon":"inline-start"})}),a.jsx(Bt,{children:x?"Collapse all":"Expand all"})]})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b bg-muted/30 px-3 py-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:"Showing:"}),v!=="all"&&E>0&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>{const W=typeof v=="number"?v:E;W>0&&k(W-1)},disabled:(typeof v=="number"?v:E)<=0,"aria-label":"Previous turn",children:a.jsx(q1,{"data-icon":"inline-start"})}),a.jsx("span",{className:G("text-xs font-medium",typeof v=="number"?"text-foreground":"text-muted-foreground"),children:U}),v!=="all"&&E>0&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>{k(W=>typeof W!="number"?W:W+1>=E?"last":W+1)},disabled:v==="last","aria-label":"Next turn",children:a.jsx(it,{"data-icon":"inline-start"})}),typeof v=="number"&&a.jsx(J,{variant:"ghost",size:"icon-xs",onClick:()=>k("last"),"aria-label":"Back to last turn",children:a.jsx(At,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"relative flex-1 min-h-0",children:[a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 top-0 z-10 h-6 bg-gradient-to-b from-canvas to-transparent transition-opacity duration-200",u?"opacity-100":"opacity-0")}),a.jsxs("div",{ref:s,onScroll:$,className:"h-full overflow-y-auto",children:[a.jsx("div",{className:"flex flex-col gap-1 p-1.5",children:w?L.length>0?L.map(W=>a.jsx(PK,{group:W,allExpanded:x,highlightPath:S,diffMode:b},W.agentId)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No subagent changes in ",U.toLowerCase()]}):R.length>0?R.map(W=>a.jsx(w_,{file:W,defaultOpen:x,isHighlighted:S===W.filePath,diffMode:b},W.filePath)):a.jsxs("div",{className:"py-4 text-center text-xs text-muted-foreground",children:["No file changes in ",U.toLowerCase()]})}),a.jsx("div",{ref:r})]}),a.jsx("div",{className:G("pointer-events-none absolute inset-x-0 bottom-0 z-10 h-6 bg-gradient-to-t from-canvas to-transparent transition-opacity duration-200",f?"opacity-100":"opacity-0")})]})]})});function RK(n,e){const t=new Map;function s(r,o){const i=String(r.input.file_path??r.input.path??"");if(!i)return;const l=r.name==="Edit",c=l?String(r.input.old_string??""):"",u=String(l?r.input.new_string??"":r.input.content??""),d=r.diffLineCounts??zg(c,u),f=t.get(i)??{add:0,del:0,hasEdit:!1,hasWrite:!1,subAgentId:null};f.add+=d.add,f.del+=d.del,l?f.hasEdit=!0:f.hasWrite=!0,o&&(f.subAgentId=o),t.set(i,f)}return El(n.toolCalls,e).forEach(r=>s(r)),n.subAgentActivity.forEach(r=>El(r.toolCalls,e).forEach(o=>s(o,r.agentId))),[...t.entries()].map(([r,{add:o,del:i,hasEdit:l,hasWrite:c,subAgentId:u}])=>({filePath:r,additions:o,deletions:i,hasEdit:l,hasWrite:c,subAgentId:u}))}function tw(){return{children:new Map,isFile:!1,absPath:"",additions:0,deletions:0,hasEdit:!1,hasWrite:!1,subAgentId:null}}function OK(n,e){if(n.length===0)return[];const t=e.endsWith("/")?e.slice(0,-1):e,s=tw();for(const o of n){let i=o.filePath;t&&i.startsWith(t+"/")?i=i.slice(t.length+1):i.startsWith("/")&&(i=i.slice(1));const l=i.split("/");let c=s;for(let u=0;u<l.length;u++){let d=c.children.get(l[u]);d||(d=tw(),c.children.set(l[u],d)),u===l.length-1&&(d.isFile=!0,d.absPath=o.filePath,d.additions+=o.additions,d.deletions+=o.deletions,o.hasEdit&&(d.hasEdit=!0),o.hasWrite&&(d.hasWrite=!0),o.subAgentId&&(d.subAgentId=o.subAgentId)),c=d}}function r(o,i){return[...o.children.entries()].sort(([c,u],[d,f])=>{const m=u.isFile&&u.children.size===0,p=f.isFile&&f.children.size===0;return m!==p?m?1:-1:c.localeCompare(d)}).map(([c,u])=>{const d=i?`${i}/${c}`:c;if(u.isFile&&u.children.size===0)return{name:c,fullPath:d,absPath:u.absPath,isFile:!0,additions:u.additions,deletions:u.deletions,hasEdit:u.hasEdit,hasWrite:u.hasWrite,subAgentId:u.subAgentId,children:[]};let f=u,m=c,p=d;for(;!f.isFile&&f.children.size===1;){const[k,j]=[...f.children.entries()][0];if(j.isFile&&j.children.size===0)break;m+="/"+k,p+="/"+k,f=j}const h=r(f,p);let g=0,x=0,b=f.isFile?f.hasEdit:!1,w=f.isFile?f.hasWrite:!1,v=f.isFile?f.subAgentId:null;for(const k of h)g+=k.additions,x+=k.deletions,k.hasEdit&&(b=!0),k.hasWrite&&(w=!0),k.subAgentId&&(v=k.subAgentId);return f.isFile&&(g+=f.additions,x+=f.deletions),{name:m,fullPath:p,absPath:f.absPath,isFile:!1,additions:g,deletions:x,hasEdit:b,hasWrite:w,subAgentId:v,children:h}})}return r(s,"")}const LK=y.memo(function(e){const t=q.c(45),{turn:s,turnIndex:r,cwd:o}=e,i=xn("hostFiles");let l;t[0]!==o||t[1]!==s?(l=RK(s,o),t[0]=o,t[1]=s,t[2]=l):l=t[2];const c=l;let u;t[3]!==o||t[4]!==c?(u=OK(c,o),t[3]=o,t[4]=c,t[5]=u):u=t[5];const d=u,[f,m]=y.useState(!1);let p=0,h=0;if(t[6]!==p||t[7]!==h||t[8]!==c){for(const P of c)p=p+P.additions,h=h+P.deletions;t[6]=p,t[7]=h,t[8]=c,t[9]=p,t[10]=h}else p=t[9],h=t[10];let g;t[11]!==p||t[12]!==h?(g={add:p,del:h},t[11]=p,t[12]=h,t[13]=g):g=t[13];const x=g;if(c.length===0)return null;const b=f&&"rotate-90";let w;t[14]!==b?(w=G("size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",b),t[14]=b,t[15]=w):w=t[15];let v;t[16]!==w?(v=a.jsx(it,{"data-icon":"inline-start",className:w}),t[16]=w,t[17]=v):v=t[17];let k;t[18]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(fc,{className:"size-3.5 shrink-0","data-icon":"inline-start"}),t[18]=k):k=t[18];const j=c.length!==1?"s":"";let _;t[19]!==c.length||t[20]!==j?(_=a.jsxs("span",{className:"font-medium tabular-nums",children:[c.length," file",j]}),t[19]=c.length,t[20]=j,t[21]=_):_=t[21];let N,S;t[22]!==x.add||t[23]!==x.del?(N=a.jsx(aa,{add:x.add,del:x.del,className:"opacity-80"}),S=a.jsx(T0,{add:x.add,del:x.del}),t[22]=x.add,t[23]=x.del,t[24]=N,t[25]=S):(N=t[24],S=t[25]);let C;t[26]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx("span",{"aria-hidden":!0,className:"pointer-events-none ml-1 h-px flex-1 bg-border/40 transition-colors group-hover/files:bg-border/70"}),t[26]=C):C=t[26];let A;t[27]!==N||t[28]!==S||t[29]!==v||t[30]!==_?(A=a.jsxs(Ns,{className:"group/files flex min-h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[v,k,_,N,S,C]}),t[27]=N,t[28]=S,t[29]=v,t[30]=_,t[31]=A):A=t[31];let T;if(t[32]!==i||t[33]!==d||t[34]!==r){let P;t[36]!==i||t[37]!==r?(P=R=>a.jsx(MK,{node:R,depth:0,turnIndex:r,canFocusFiles:i},R.fullPath),t[36]=i,t[37]=r,t[38]=P):P=t[38],T=d.map(P),t[32]=i,t[33]=d,t[34]=r,t[35]=T}else T=t[35];let I;t[39]!==T?(I=a.jsx(In,{className:"ml-1 border-l border-border/40 pl-3",children:a.jsx("div",{className:"py-0.5",children:T})}),t[39]=T,t[40]=I):I=t[40];let E;return t[41]!==f||t[42]!==A||t[43]!==I?(E=a.jsxs(An,{open:f,onOpenChange:m,children:[A,I]}),t[41]=f,t[42]=A,t[43]=I,t[44]=E):E=t[44],E}),MK=y.memo(function n({node:e,depth:t,turnIndex:s,canFocusFiles:r}){const[o,i]=y.useState(!0),l=t*16+8;if(e.isFile){const c=vK(e.name),u=()=>{r&&e.absPath&&window.dispatchEvent(new CustomEvent(tc,{detail:{filePath:e.absPath,turnIndex:s}}))};return a.jsxs("div",{className:"flex h-7 w-full items-center gap-1.5 font-mono text-xs",style:{paddingLeft:l},children:[a.jsxs(J,{type:"button",variant:"ghost",size:"xs",disabled:!r,className:G("h-7 min-w-0 flex-1 justify-start gap-1.5 rounded-sm px-0 font-mono text-xs font-normal disabled:opacity-100",r&&"cursor-pointer"),onClick:u,title:r?"Click to focus in sidebar":void 0,children:[a.jsx(c,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(y_,{hasEdit:e.hasEdit,hasWrite:e.hasWrite}),a.jsx("span",{className:"truncate text-foreground/75",children:e.name})]}),e.subAgentId&&a.jsx(A0,{agentId:e.subAgentId}),a.jsx(aa,{add:e.additions,del:e.deletions}),a.jsx(T0,{add:e.additions,del:e.deletions})]})}return a.jsxs(a.Fragment,{children:[a.jsxs(J,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-full justify-start gap-1 rounded-sm font-mono text-xs font-normal",style:{paddingLeft:l},onClick:()=>i(!o),"aria-expanded":o,children:[o?a.jsx(Wt,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}):a.jsx(it,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx(Qi,{className:"size-3 shrink-0 text-muted-foreground","data-icon":"inline-start"}),a.jsx("span",{className:"truncate text-foreground/70",children:e.name}),a.jsx("div",{className:"flex-1 min-w-2"}),!o&&a.jsx(aa,{add:e.additions,del:e.deletions,dimmed:!0})]}),o&&e.children.map(c=>a.jsx(n,{node:c,depth:t+1,turnIndex:s,canFocusFiles:r},c.fullPath))]})});function zK(n){const e=q.c(14),{branchCount:t,onClick:s}=n;if(t===0)return null;let r;e[0]!==s?(r=a.jsx(J,{variant:"ghost",size:"xs",onClick:f=>{f.stopPropagation(),s()},className:"h-6 text-muted-foreground"}),e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(X1,{"data-icon":"inline-start"}),e[2]=o):o=e[2];let i;e[3]!==t?(i=a.jsx("span",{className:"font-mono text-xs",children:t}),e[3]=t,e[4]=i):i=e[4];let l;e[5]!==r||e[6]!==i?(l=a.jsxs(Ut,{render:r,children:[o,i]}),e[5]=r,e[6]=i,e[7]=l):l=e[7];const c=t!==1?"es":"";let u;e[8]!==t||e[9]!==c?(u=a.jsxs(Bt,{children:[t," branch",c," from this turn"]}),e[8]=t,e[9]=c,e[10]=u):u=e[10];let d;return e[11]!==l||e[12]!==u?(d=a.jsxs(Ft,{children:[l,u]}),e[11]=l,e[12]=u,e[13]=d):d=e[13],d}function em(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(MP,{"data-slot":"context-menu",...t}),e[2]=t,e[3]=s):s=e[3],s}function tm(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("select-none",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(LP,{"data-slot":"context-menu-trigger",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function nm(n){const e=q.c(18);let t,s,r,o,i,l;e[0]!==n?({className:t,align:r,alignOffset:o,side:i,sideOffset:l,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o,e[5]=i,e[6]=l):(t=e[1],s=e[2],r=e[3],o=e[4],i=e[5],l=e[6]);const c=r===void 0?"start":r,u=o===void 0?4:o,d=i===void 0?"right":i,f=l===void 0?0:l;let m;e[7]!==t?(m=G("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 ease-out outline-none data-[side=bottom]:slide-in-from-top-1 data-[side=inline-end]:slide-in-from-left-1 data-[side=inline-start]:slide-in-from-right-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-98 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-98 data-closed:duration-75 data-closed:ease-in motion-reduce:animate-none",t),e[7]=t,e[8]=m):m=e[8];let p;e[9]!==s||e[10]!==m?(p=a.jsx(jj,{"data-slot":"context-menu-content",className:m,...s}),e[9]=s,e[10]=m,e[11]=p):p=e[11];let h;return e[12]!==c||e[13]!==u||e[14]!==d||e[15]!==f||e[16]!==p?(h=a.jsx(_j,{children:a.jsx(Ej,{className:"isolate z-50 outline-none",align:c,alignOffset:u,side:d,sideOffset:f,children:p})}),e[12]=c,e[13]=u,e[14]=d,e[15]=f,e[16]=p,e[17]=h):h=e[17],h}function ii(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(Nj,{"data-slot":"context-menu-group",...t}),e[2]=t,e[3]=s):s=e[3],s}function Q0e(n){const e=q.c(10);let t,s,r;e[0]!==n?({className:t,inset:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",t),e[4]=t,e[5]=o):o=e[5];let i;return e[6]!==s||e[7]!==r||e[8]!==o?(i=a.jsx(Tj,{"data-slot":"context-menu-label","data-inset":s,className:o,...r}),e[6]=s,e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function Mn(n){const e=q.c(12);let t,s,r,o;e[0]!==n?({className:t,inset:s,variant:o,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o):(t=e[1],s=e[2],r=e[3],o=e[4]);const i=o===void 0?"default":o;let l;e[5]!==t?(l=G("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",t),e[5]=t,e[6]=l):l=e[6];let c;return e[7]!==s||e[8]!==r||e[9]!==l||e[10]!==i?(c=a.jsx(Cj,{"data-slot":"context-menu-item","data-inset":s,"data-variant":i,className:l,...r}),e[7]=s,e[8]=r,e[9]=l,e[10]=i,e[11]=c):c=e[11],c}function la(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("-mx-1 my-1 h-px bg-border",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(D1,{"data-slot":"context-menu-separator",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function DK(n){const e=q.c(22),{children:t,turnIndex:s,branches:r,onRestoreToHere:o,onOpenBranches:i,onBranchFromHere:l}=n;let c;e[0]!==t?(c=a.jsx(tm,{className:"select-text",children:t}),e[0]=t,e[1]=c):c=e[1];let u;e[2]!==o||e[3]!==s?(u=()=>o(s),e[2]=o,e[3]=s,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=a.jsx(G1,{"data-icon":"inline-start"}),e[5]=d):d=e[5];let f;e[6]!==u?(f=a.jsx(ii,{children:a.jsxs(Mn,{onClick:u,children:[d,"Restore to this point"]})}),e[6]=u,e[7]=f):f=e[7];let m;e[8]!==r.length||e[9]!==i||e[10]!==s?(m=r.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{onClick:()=>i(s),children:[a.jsx(X1,{"data-icon":"inline-start"}),"View branches (",r.length,")"]})})]}),e[8]=r.length,e[9]=i,e[10]=s,e[11]=m):m=e[11];let p;e[12]!==l||e[13]!==s?(p=l&&a.jsxs(a.Fragment,{children:[a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{onClick:()=>l(s),children:[a.jsx(Cs,{"data-icon":"inline-start"}),"Duplicate from here"]})})]}),e[12]=l,e[13]=s,e[14]=p):p=e[14];let h;e[15]!==f||e[16]!==m||e[17]!==p?(h=a.jsxs(nm,{className:"min-w-44",children:[f,m,p]}),e[15]=f,e[16]=m,e[17]=p,e[18]=h):h=e[18];let g;return e[19]!==c||e[20]!==h?(g=a.jsxs(em,{children:[c,h]}),e[19]=c,e[20]=h,e[21]=g):g=e[21],g}function FK(n){const e=q.c(6),{status:t}=n;switch(t){case"thinking":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(DP,{className:"size-5 text-warning"}),e[0]=s):s=e[0],s}case"tool_use":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(ya,{className:"size-5 text-info"}),e[1]=s):s=e[1],s}case"processing":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(zP,{className:"size-5 text-warning"}),e[2]=s):s=e[2],s}case"compacting":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(hf,{className:"size-5 text-warning"}),e[3]=s):s=e[3],s}case"awaiting_agents":{let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(ea,{className:"size-5 text-info"}),e[4]=s):s=e[4],s}case"completed":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(eo,{className:"size-5 text-success"}),e[5]=s):s=e[5],s}default:return null}}const nw=2e3,j_=600;function N_(n){const e=q.c(28),{status:t,label:s,fading:r,startTimestamp:o}=n,i=r===void 0?!1:r,l=t.status==="completed";let c;e[0]!==t.pendingAgentDescriptions?(c=t.pendingAgentDescriptions??[],e[0]=t.pendingAgentDescriptions,e[1]=c):c=e[1];const u=c,d=i?"opacity-0":"opacity-100";let f;e[2]!==d?(f=G("flex items-center gap-2.5 min-w-0 transition-opacity",d),e[2]=d,e[3]=f):f=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m={transitionDuration:`${j_}ms`},e[4]=m):m=e[4];let p;e[5]!==t.status?(p=a.jsx(FK,{status:t.status}),e[5]=t.status,e[6]=p):p=e[6];const h=!l&&"text-muted-foreground",g=l&&t.terminalReason&&"text-warning",x=l&&!t.terminalReason&&"text-success";let b;e[7]!==h||e[8]!==g||e[9]!==x?(b=G("text-xs font-medium shrink-0",h,g,x),e[7]=h,e[8]=g,e[9]=x,e[10]=b):b=e[10];let w;e[11]!==s||e[12]!==b?(w=a.jsx("span",{className:b,children:s}),e[11]=s,e[12]=b,e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==o?(v=!l&&o&&a.jsx(I0,{startTimestamp:o}),e[14]=l,e[15]=o,e[16]=v):v=e[16];let k;e[17]!==u?(k=u.length>0&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:u.join(`
|
|
127
127
|
`),children:u.join(" · ")}),e[17]=u,e[18]=k):k=e[18];let j;e[19]!==t.pendingQueue?(j=(t.pendingQueue??0)>0&&a.jsxs("span",{className:"ml-1 shrink-0 text-xs text-muted-foreground",children:["+",t.pendingQueue," queued"]}),e[19]=t.pendingQueue,e[20]=j):j=e[20];let _;return e[21]!==w||e[22]!==v||e[23]!==k||e[24]!==j||e[25]!==f||e[26]!==p?(_=a.jsxs("div",{className:f,style:m,children:[p,w,v,k,j]}),e[21]=w,e[22]=v,e[23]=k,e[24]=j,e[25]=f,e[26]=p,e[27]=_):_=e[27],_}function UK(n){const e=q.c(28),{status:t,durationLabel:s}=n,[r,o]=y.useState("visible");let i,l;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const h=setTimeout(()=>o("fading"),nw),g=setTimeout(()=>o("ready"),nw+j_);return()=>{clearTimeout(h),clearTimeout(g)}},l=[],e[0]=i,e[1]=l):(i=e[0],l=e[1]),y.useEffect(i,l),r==="ready"){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(eo,{className:"size-4 shrink-0 text-success"}),e[2]=h):h=e[2];const g=t.terminalReason?"text-warning":"text-muted-foreground";let x;e[3]!==g?(x=G("text-xs font-medium",g),e[3]=g,e[4]=x):x=e[4];let b;e[5]!==t.terminalReason?(b=t.terminalReason?b0(t.terminalReason):"Waiting for your input",e[5]=t.terminalReason,e[6]=b):b=e[6];let w;e[7]!==x||e[8]!==b?(w=a.jsx("span",{className:x,children:b}),e[7]=x,e[8]=b,e[9]=w):w=e[9];let v;e[10]!==s?(v=s&&a.jsx("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:s}),e[10]=s,e[11]=v):v=e[11];let k;return e[12]!==w||e[13]!==v?(k=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4","data-agent-ready":!0,children:[h,w,v]}),e[12]=w,e[13]=v,e[14]=k):k=e[14],k}let c;e[15]!==t.status||e[16]!==t.terminalReason||e[17]!==t.toolName?(c=Rc(t.status,t.toolName,t.terminalReason)??"Done",e[15]=t.status,e[16]=t.terminalReason,e[17]=t.toolName,e[18]=c):c=e[18];const u=c,d=r==="fading";let f;e[19]!==u||e[20]!==t||e[21]!==d?(f=a.jsx(N_,{status:t,label:u,fading:d}),e[19]=u,e[20]=t,e[21]=d,e[22]=f):f=e[22];let m;e[23]!==s?(m=s&&a.jsxs("span",{className:"font-mono text-xs tabular-nums text-muted-foreground",children:["in ",s]}),e[23]=s,e[24]=m):m=e[24];let p;return e[25]!==f||e[26]!==m?(p=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],p}const BK=y.memo(function(){const e=q.c(25),{session:t,isLive:s,sseState:r,isCompacting:o,pendingInteraction:i}=yt(),[l,c]=y.useState(!1),[u,d]=y.useState(!1),f=t==null?void 0:t.sessionId,[m,p]=y.useState(f);f!==m&&(p(f),c(!1),d(!1));let h;e:{if(!t||r!=="connected"){h=null;break e}if(o){let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P={status:"compacting"},e[0]=P):P=e[0],h=P;break e}const I=t.rawMessages;let E;e[1]!==I?(E=T5(I),e[1]=I,e[2]=E):E=e[2],h=E}const g=h;let x,b;e[3]!==g||e[4]!==s||e[5]!==u?(x=()=>{if(!(!g||g.status==="compacting"||g.status==="idle")){if(!s){g.status==="completed"&&!u&&c(!0);return}if(g.status==="completed"){d(!0);return}c(!1),d(!1)}},b=[g,s,u],e[3]=g,e[4]=s,e[5]=u,e[6]=x,e[7]=b):(x=e[6],b=e[7]),y.useEffect(x,b);let w;e:{if(!g){w=null;break e}if(g.status==="compacting"){w=g;break e}if(g.status==="completed"){if(l){w=null;break e}if(!s&&!u){w=null;break e}w=g;break e}if(!s||g.status==="idle"){w=null;break e}w=g}const v=w,k=(v==null?void 0:v.status)==="completed",j=(t==null?void 0:t.turns[t.turns.length-1])??null;let _;e:{if(!k||!j){_=null;break e}let I;if(e[8]!==j){const E=mx(j);I=E!==null?wr(E):null,e[8]=j,e[9]=I}else I=e[9];_=I}const N=_;if(i&&r==="connected"){let I;e[10]===Symbol.for("react.memo_cache_sentinel")?(I=a.jsx(Z1,{className:"size-5 shrink-0 text-info"}),e[10]=I):I=e[10];const E=i.type==="plan"?"Waiting for plan approval":"Waiting for your answer";let P;return e[11]!==E?(P=a.jsxs("div",{className:"flex items-center gap-2.5 py-3 px-4",children:[I,a.jsx("span",{className:"text-xs font-medium text-info",children:E})]}),e[11]=E,e[12]=P):P=e[12],P}if(!v)return null;if(k){let I;return e[13]!==v||e[14]!==N?(I=a.jsx(UK,{status:v,durationLabel:N}),e[13]=v,e[14]=N,e[15]=I):I=e[15],I}let S;e[16]!==v.pendingAgents||e[17]!==v.status||e[18]!==v.terminalReason||e[19]!==v.toolName?(S=Rc(v.status,v.toolName,v.terminalReason,v.pendingAgents),e[16]=v.pendingAgents,e[17]=v.status,e[18]=v.terminalReason,e[19]=v.toolName,e[20]=S):S=e[20];const C=S;if(!C)return null;const A=j==null?void 0:j.timestamp;let T;return e[21]!==v||e[22]!==C||e[23]!==A?(T=a.jsx("div",{className:"flex items-center gap-2.5 py-3 px-4",children:a.jsx(N_,{status:v,label:C,startTimestamp:A})}),e[21]=v,e[22]=C,e[23]=A,e[24]=T):T=e[24],T});function I0(n){const e=q.c(3),{startTimestamp:t,className:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(WK,{startTimestamp:t,className:s},t),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function WK(n){const e=q.c(12),{startTimestamp:t,className:s}=n;let r;e[0]!==t?(r=new Date(t).getTime(),e[0]=t,e[1]=r):r=e[1];const o=r,i=y.useRef(null);let l,c;e[2]!==o?(l=()=>{const h=setInterval(()=>{const g=i.current;g&&(g.textContent=wr(Math.max(0,Date.now()-o)))},1e3);return()=>clearInterval(h)},c=[o],e[2]=o,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c);let u;e[5]!==s?(u=G("font-mono text-xs tabular-nums text-muted-foreground",s),e[5]=s,e[6]=u):u=e[6];const d=Math.max(0,Date.now()-o);let f;e[7]!==d?(f=wr(d),e[7]=d,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=a.jsx("span",{ref:i,className:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function qK(n,e){var s;if(!e)return!0;const t=e.toLowerCase();if(n.userMessage&&(typeof n.userMessage=="string"?n.userMessage:JSON.stringify(n.userMessage)).toLowerCase().includes(t))return!0;for(const r of n.assistantText)if(r.toLowerCase().includes(t))return!0;for(const r of n.contentBlocks)if(r.kind==="queued_prompt"&&r.content.toLowerCase().includes(t)||r.kind==="agent_message"&&(r.sender.toLowerCase().includes(t)||r.body.toLowerCase().includes(t)))return!0;for(const r of n.thinking)if(r.thinking.toLowerCase().includes(t))return!0;for(const r of n.toolCalls)if(r.name.toLowerCase().includes(t)||JSON.stringify(r.input).toLowerCase().includes(t)||(s=r.result)!=null&&s.toLowerCase().includes(t))return!0;return!1}const VK=6e5;function HK(n,e){const t=n[e].timestamp,s=e>0?n[e-1].timestamp:void 0;if(!t||!s)return 0;const r=Date.parse(t)-Date.parse(s);return!Number.isFinite(r)||r<=0?0:Math.min(r,VK)}function sw(n,e){const t=[],s=[];let r=0,o=0,i=e;for(;i<n.length;){const l=n[i];if(l.kind==="thinking")t.push({kind:"thinking",blocks:l.blocks}),r+=l.blocks.length,o+=HK(n,i),i++;else if(l.kind==="tool_calls")t.push({kind:"tool_calls",toolCalls:l.toolCalls}),s.push(...l.toolCalls),i++;else break}return{items:t,toolCalls:s,thinkingCount:r,thoughtForMs:o,nextIndex:i}}const C_=y.createContext(null);function Ju(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(C_.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function ln(){const n=y.useContext(C_);if(!n)throw new Error("useAppContext must be used within an AppProvider");return n}const Fg=new Map,KK=300*1e3;function rw(n){const e=Fg.get(n);return e?Date.now()>e.expiresAt?(Fg.delete(n),null):e.data:null}function GK(n,e){Fg.set(n,{data:e,expiresAt:Date.now()+KK})}function ZK(n){const e=q.c(5);let t;e[0]!==n?(t=()=>n?rw(en(n))??new Map:new Map,e[0]=n,e[1]=t):t=e[1];const[s,r]=y.useState(t),o=y.useRef("");let i,l;return e[2]!==n?(i=()=>{if(!n||Mf(window.location.pathname))return;const c=en(n),u=rw(c);if(u){r(u);return}o.current=n;const d=new AbortController;return Ee(`/api/slash-suggestions?cwd=${encodeURIComponent(n)}`,{signal:d.signal}).then(async f=>{if(d.signal.aborted||o.current!==n||!f.ok)return;const m=await f.json();if(d.signal.aborted||o.current!==n)return;const p=new Map;for(const h of m.suggestions??[])h.type==="skill"&&p.set(h.name,{source:h.source,description:h.description,filePath:h.filePath});GK(c,p),r(p)}).catch(YK),()=>d.abort()},l=[n],e[2]=n,e[3]=i,e[4]=l):(i=e[3],l=e[4]),y.useEffect(i,l),s}function YK(){}const XK=new Set(["queued_prompt","agent_message","plan_mode","recap","task_notification","local_command"]),JK=new Set(["thinking","tool_calls","sub_agent","background_agent","hook_event"]),QK=new Set(["AskUserQuestion","ExitPlanMode"]),eG=new Set(["text","thinking","tool_calls"]);function tG(n){return n.kind==="tool_calls"&&n.toolCalls.some(e=>QK.has(e.name)&&e.result==null)}function nG(n,e){for(let t=n.length-1;t>=0;t--){if(tG(n[t]))return t;if(eG.has(n[t].kind))break}return e?n.findIndex(t=>t.kind==="tool_calls"&&t.toolCalls.some(s=>s.id===e&&s.asyncQuestion)):-1}const mu={foldedIndices:[],foldAnchorIndex:-1,foldable:!1,hiddenToolCalls:0};function sG(n,e="settled",t){if(n.length===0||!n.some(l=>JK.has(l.kind)))return mu;let s=-1;if(e==="settled"){for(let l=n.length-1;l>=0;l--)if(n[l].kind==="text"){s=l;break}if(s===-1)return mu}const r=nG(n,t),o=[];let i=0;for(let l=0;l<n.length;l++){if(l===s||l===r)continue;const c=n[l];XK.has(c.kind)||(o.push(l),c.kind==="tool_calls"&&(i+=c.toolCalls.length))}return o.length===0?mu:{foldedIndices:o,foldAnchorIndex:o[0],foldable:!0,hiddenToolCalls:i}}function rG(n,e){return n!==null&&n>0?`Worked for ${wr(n)}`:e>0?`Worked through ${e} step${e===1?"":"s"}`:"Show work"}const __="border border-border bg-prompt-surface",ow="border-l border-border/40",iw="border-l border-border";function E_(n){const e=q.c(21),{turn:t,index:s,branchCount:r}=n,o=r===void 0?0:r,{state:i,isMobile:l}=ln(),{activeTurnIndex:c,activeToolCallId:u,expandAll:d,expandToolPayloads:f}=i,{session:m,isLive:p,isSubAgentView:h,undoRedo:g,actions:x,pendingInteraction:b}=yt(),w=p&&m!==null,v=w&&s===((m==null?void 0:m.turns.length)??0)-1;let k=!v;if(v&&m){let T;if(e[0]!==m.rawMessages){const{status:I}=T5(m.rawMessages);T=jf.has(I),e[0]=m.rawMessages,e[1]=T}else T=e[1];k=!T}const j=(m==null?void 0:m.cwd)??"",_=ZK(j),N=(b==null?void 0:b.type)==="question"?b.toolUseId:void 0,S=c===s,C=!g.enabled||h?void 0:g.requestUndo;let A;return e[2]!==x.handleEditCommand||e[3]!==x.handleExpandCommand||e[4]!==x.handleOpenBranches||e[5]!==u||e[6]!==o||e[7]!==j||e[8]!==d||e[9]!==f||e[10]!==s||e[11]!==v||e[12]!==l||e[13]!==w||e[14]!==k||e[15]!==N||e[16]!==_||e[17]!==S||e[18]!==C||e[19]!==t?(A=a.jsx(aG,{turn:t,openQuestionId:N,index:s,branchCount:o,isActive:S,activeToolCallId:u,expandAll:d,expandToolPayloads:f,isAgentActive:v,isSessionLive:w,isTurnDone:k,isMobile:l,cwd:j,skillMetadata:_,onRestoreToHere:C,onOpenBranches:x.handleOpenBranches,onEditCommand:x.handleEditCommand,onExpandCommand:x.handleExpandCommand}),e[2]=x.handleEditCommand,e[3]=x.handleExpandCommand,e[4]=x.handleOpenBranches,e[5]=u,e[6]=o,e[7]=j,e[8]=d,e[9]=f,e[10]=s,e[11]=v,e[12]=l,e[13]=w,e[14]=k,e[15]=N,e[16]=_,e[17]=S,e[18]=C,e[19]=t,e[20]=A):A=e[20],A}function oG(n){const e=q.c(12),{index:t,children:s}=n,{session:r,isSubAgentView:o,undoRedo:i,actions:l}=yt(),{requestUndo:c,branchesAtTurn:u}=i,{handleOpenBranches:d,handleBranchFromHere:f}=l,m=t>=((r==null?void 0:r.turns.length)??0);if(!i.enabled||o||m||!c||!d){let g;return e[0]!==s?(g=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=g):g=e[1],g}let p;e[2]!==u||e[3]!==t?(p=u(t),e[2]=u,e[3]=t,e[4]=p):p=e[4];let h;return e[5]!==s||e[6]!==f||e[7]!==d||e[8]!==t||e[9]!==c||e[10]!==p?(h=a.jsx(DK,{turnIndex:t,branches:p,onRestoreToHere:c,onOpenBranches:d,onBranchFromHere:f,children:s}),e[5]=s,e[6]=f,e[7]=d,e[8]=t,e[9]=c,e[10]=p,e[11]=h):h=e[11],h}function iG(n){const e=q.c(5),{turn:t,isTurnDone:s,hiddenToolCalls:r}=n;if(s){let i;return e[0]!==r||e[1]!==t?(i=rG(mx(t),r),e[0]=r,e[1]=t,e[2]=i):i=e[2],i}if(!t.timestamp)return"Working";let o;return e[3]!==t.timestamp?(o=a.jsxs("span",{className:"inline-flex items-baseline gap-1",children:["Working for",a.jsx(I0,{startTimestamp:t.timestamp,className:"text-xs text-inherit"})]}),e[3]=t.timestamp,e[4]=o):o=e[4],o}const aG=y.memo(function({turn:e,index:t,branchCount:s,isActive:r,activeToolCallId:o,expandAll:i,expandToolPayloads:l,isAgentActive:c,isSessionLive:u,isTurnDone:d,isMobile:f,cwd:m,skillMetadata:p,onRestoreToHere:h,onOpenBranches:g,onEditCommand:x,onExpandCommand:b,openQuestionId:w}){const{ref:v,isNear:k}=W5(),j=y.useRef(null),_=y.useRef(0);y.useLayoutEffect(()=>{k&&j.current&&(_.current=j.current.offsetHeight)},[k]);const N=Fd(e.toolCalls,m)||e.subAgentActivity.some(L=>Fd(L.toolCalls,m)),S=d?"settled":"working",C=y.useMemo(()=>sG(e.contentBlocks,S,w),[S,w,e.contentBlocks]),[A,T]=y.useState(()=>d?void 0:!0),I=A??(i||!d),{leadingBlocks:E,trailingBlocks:P}=y.useMemo(()=>{if(!C.foldable)return{leadingBlocks:[],trailingBlocks:[]};const L=C.foldAnchorIndex,O=new Set(C.foldedIndices);return{leadingBlocks:e.contentBlocks.slice(0,L),trailingBlocks:e.contentBlocks.slice(L).filter(($,M)=>I||!O.has(L+M))}},[C,e.contentBlocks,I]),R={turnId:e.id,originalBlocks:e.contentBlocks,model:e.model,effort:e.effort,expandAll:i,expandToolPayloads:l,activeToolCallId:o,isAgentActive:c,isSessionLive:u,isMobile:f,skillMetadata:p};return a.jsxs("div",{ref:v,"data-turn-index":t,className:G("group relative",f?"px-0 py-5":"px-4 py-5",r&&"rounded-lg ring-1 ring-ring/40"),children:[a.jsx(cG,{index:t,turn:e,branchCount:s,isTurnDone:d,isMobile:f,onRestoreToHere:h,onOpenBranches:g}),k?a.jsxs("div",{ref:j,className:"flex flex-col gap-3",children:[e.userMessage&&a.jsx(oG,{index:t,children:a.jsx("div",{"data-turn-prompt":!0,className:G("rounded-lg p-3",__),children:a.jsx(w0,{content:e.userMessage,timestamp:e.timestamp,onEditCommand:x,onExpandCommand:b})})}),C.foldable?a.jsxs(a.Fragment,{children:[E.length>0&&a.jsx(ap,{blocks:E,...R}),a.jsx(oK,{label:a.jsx(iG,{turn:e,isTurnDone:d,hiddenToolCalls:C.hiddenToolCalls}),expanded:I,onToggle:()=>T(!I)}),P.length>0&&a.jsx(ap,{blocks:P,...R})]}):a.jsx(ap,{blocks:e.contentBlocks,...R}),d&&N&&a.jsx(LK,{turn:e,turnIndex:t,cwd:m})]}):a.jsx("div",{style:{minHeight:_.current||lG(e)}})]})});function lG(n){return Math.max(60,(n.userMessage?40:0)+n.contentBlocks.length*60)}function cG(n){const e=q.c(26),{index:t,turn:s,branchCount:r,isTurnDone:o,isMobile:i,onRestoreToHere:l,onOpenBranches:c}=n,u=!o&&!!s.timestamp;let d;e[0]!==o||e[1]!==s?(d=o?mx(s):null,e[0]=o,e[1]=s,e[2]=d):d=e[2];const f=d,m=i?"mb-2 gap-1.5":"mb-4 gap-2";let p;e[3]!==m?(p=G("flex items-center",m),e[3]=m,e[4]=p):p=e[4];const h=t+1;let g;e[5]!==h?(g=a.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h}),e[5]=h,e[6]=g):g=e[6];let x;e[7]!==f||e[8]!==u||e[9]!==s.timestamp?(x=a.jsx(uG,{durationMs:f,showLiveTimer:u,timestamp:s.timestamp}),e[7]=f,e[8]=u,e[9]=s.timestamp,e[10]=x):x=e[10];let b;e[11]!==t||e[12]!==i||e[13]!==l?(b=l&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>l(t),className:G("ml-auto text-muted-foreground transition-opacity hover:text-foreground",i?"opacity-70":"opacity-0 group-hover:opacity-100"),title:"Undo this turn and all after it",children:[a.jsx(G1,{"data-icon":"inline-start"}),a.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),e[11]=t,e[12]=i,e[13]=l,e[14]=b):b=e[14];let w;e[15]!==r||e[16]!==t||e[17]!==c||e[18]!==l?(w=r>0&&c&&a.jsx("div",{className:G(!l&&"ml-auto"),children:a.jsx(zK,{branchCount:r,onClick:()=>c(t)})}),e[15]=r,e[16]=t,e[17]=c,e[18]=l,e[19]=w):w=e[19];let v;return e[20]!==p||e[21]!==g||e[22]!==x||e[23]!==b||e[24]!==w?(v=a.jsxs("div",{className:p,children:[g,x,b,w]}),e[20]=p,e[21]=g,e[22]=x,e[23]=b,e[24]=w,e[25]=v):v=e[25],v}function uG(n){const e=q.c(8),{durationMs:t,showLiveTimer:s,timestamp:r}=n;if(t!==null){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Eo,{className:"size-3","data-icon":"inline-start"}),e[0]=o):o=e[0];let i;e[1]!==t?(i=wr(t),e[1]=t,e[2]=i):i=e[2];let l;return e[3]!==i?(l=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-muted-foreground",children:[o,i]}),e[3]=i,e[4]=l):l=e[4],l}if(s){let o;e[5]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Eo,{className:"size-3","data-icon":"inline-start"}),e[5]=o):o=e[5];let i;return e[6]!==r?(i=a.jsxs("span",{className:"flex items-center gap-1 font-mono text-xs tabular-nums text-info",children:[o,a.jsx(I0,{startTimestamp:r,className:"tabular-nums"})]}),e[6]=r,e[7]=i):i=e[7],i}return null}function dG(n){var e,t,s;switch(n.kind){case"tool_calls":return((e=n.toolCalls[0])==null?void 0:e.id)??null;case"sub_agent":case"background_agent":return((t=n.messages[0])==null?void 0:t.parentToolUseId)??((s=n.messages[0])==null?void 0:s.agentId)??null;default:return n.timestamp??null}}function ap(n){const e=q.c(13),{blocks:t,turnId:s,originalBlocks:r,model:o,effort:i,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,isSessionLive:f,isMobile:m,skillMetadata:p}=n;let h;if(e[0]!==u||e[1]!==t||e[2]!==i||e[3]!==l||e[4]!==c||e[5]!==d||e[6]!==m||e[7]!==f||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==s){const g=[],x=m?"ml-0 pl-2":"ml-1 pl-3",b=new Map,w=(k,j)=>{const _=dG(k)??`at-${j}`,N=b.get(_)??0;return b.set(_,N+1),N===0?_:`${_}#${N}`};let v=0;for(;v<t.length;){const k=t[v];if(k.kind==="thinking"||k.kind==="tool_calls"){const{items:j,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=sw(t,v),A=j.length===1&&j[0].kind==="tool_calls";g.push(a.jsx("div",{className:G(ow,x),children:a.jsx(G2,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:A?void 0:j,thinkingCount:N,thoughtForMs:S,skillMetadata:p})},w(k,v))),v=C;continue}if(k.kind==="text"){const{items:j,toolCalls:_,thinkingCount:N,thoughtForMs:S,nextIndex:C}=sw(t,v+1);g.push(a.jsxs("div",{children:[a.jsx("div",{className:G("flex flex-col","gap-3"),children:k.text.map((A,T)=>a.jsx(dq,{text:A,model:o,effort:i,timestamp:k.timestamp,messageKey:`${s}:${r.indexOf(k)}:${T}`},T))}),(_.length>0||N>0)&&a.jsx("div",{className:G("mt-1.5",ow,x),children:a.jsx(G2,{toolCalls:_,expandAll:l,expandToolPayloads:c,activeToolCallId:u,isAgentActive:d,activityItems:N>0?j:void 0,thinkingCount:N,thoughtForMs:S,skillMetadata:p})})]},w(k,v))),v=C;continue}if(k.kind==="queued_prompt"){g.push(a.jsxs("div",{className:G("rounded-lg p-3",__),children:[a.jsx(Ue,{variant:"outline",className:"mb-2",children:"Queued while working"}),a.jsx(w0,{content:k.content,timestamp:k.timestamp??""})]},w(k,v))),v++;continue}if(k.kind==="agent_message"){g.push(a.jsx(cq,{sender:k.sender,body:k.body,reply:k.reply,timestamp:k.timestamp,isLive:f},w(k,v))),v++;continue}if(k.kind==="sub_agent"){g.push(a.jsx("div",{className:G(iw,x),children:a.jsx($2,{messages:k.messages,expandAll:l,label:"Sub-agent activity",countLabel:"subagents active"})},w(k,v))),v++;continue}if(k.kind==="background_agent"){g.push(a.jsx("div",{className:G(iw,x),children:a.jsx($2,{messages:k.messages,expandAll:l,label:"Background agent activity",countLabel:"agents active"})},w(k,v))),v++;continue}if(k.kind==="hook_event"){g.push(a.jsx(Iq,{events:k.events},w(k,v))),v++;continue}if(k.kind==="plan_mode"){g.push(a.jsx(QH,{plan:k.plan,planFilePath:k.planFilePath,status:k.status,toolCalls:k.toolCalls,expandAll:l,expandToolPayloads:c,isAgentActive:d,skillMetadata:p},w(k,v))),v++;continue}if(k.kind==="recap"){g.push(a.jsx(eK,{content:k.content},w(k,v))),v++;continue}if(k.kind==="task_notification"){g.push(a.jsx(oW,{content:k.content},w(k,v))),v++;continue}if(k.kind==="local_command"){g.push(a.jsx(mW,{content:k.content},w(k,v))),v++;continue}v++}h=a.jsx(a.Fragment,{children:g}),e[0]=u,e[1]=t,e[2]=i,e[3]=l,e[4]=c,e[5]=d,e[6]=m,e[7]=f,e[8]=o,e[9]=r,e[10]=p,e[11]=s,e[12]=h}else h=e[12];return h}function fG(n){if(!n)return null;const e=n.trigger==="manual"?"manual":"auto";return n.postTokens!=null?`${e} · ${Ct(n.preTokens)} → ${Ct(n.postTokens)}`:`${e} · ${Ct(n.preTokens)}`}const mG=y.memo(function(e){const t=q.c(29),{summary:s,meta:r}=e,[o,i]=y.useState(!1);let l;t[0]!==r?(l=fG(r),t[0]=r,t[1]=l):l=t[1];const c=l;let u;t[2]!==s?(u=s==null?void 0:s.trim(),t[2]=s,t[3]=u):u=t[3];const d=u;let f;t[4]!==d||t[5]!==o?(f=d&&(o?a.jsx(Wt,{className:"size-3","data-icon":"inline-start"}):a.jsx(it,{className:"size-3","data-icon":"inline-start"})),t[4]=d,t[5]=o,t[6]=f):f=t[6];let m,p;t[7]===Symbol.for("react.memo_cache_sentinel")?(m=a.jsx(FP,{className:"size-3","data-icon":"inline-start"}),p=a.jsx("span",{className:"font-medium",children:"Compacted"}),t[7]=m,t[8]=p):(m=t[7],p=t[8]);let h;t[9]!==c?(h=c&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:c})]}),t[9]=c,t[10]=h):h=t[10];let g;t[11]!==f||t[12]!==h?(g=a.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground transition-colors group-hover:text-foreground",children:[f,m,p,h]}),t[11]=f,t[12]=h,t[13]=g):g=t[13];const x=g;if(!d){let N;t[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[14]=N):N=t[14];let S;t[15]===Symbol.for("react.memo_cache_sentinel")?(S=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[15]=S):S=t[15];let C;return t[16]!==x?(C=a.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[N,x,S]}),t[16]=x,t[17]=C):C=t[17],C}let b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx(J,{type:"button",variant:"ghost",className:"group h-auto w-full gap-3 px-0"}),w=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[18]=b,t[19]=w):(b=t[18],w=t[19]);let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:"h-px flex-1 bg-border"}),t[20]=v):v=t[20];let k;t[21]!==x?(k=a.jsxs(Ns,{render:b,children:[w,x,v]}),t[21]=x,t[22]=k):k=t[22];let j;t[23]!==d?(j=a.jsx(In,{children:a.jsx("div",{className:"prose prose-sm dark:prose-invert mx-8 mt-2 max-w-none rounded-md border bg-muted/30 px-3 py-2",children:a.jsx(Er,{remarkPlugins:Pr,components:Ir,children:d})})}),t[23]=d,t[24]=j):j=t[24];let _;return t[25]!==o||t[26]!==k||t[27]!==j?(_=a.jsxs(An,{open:o,onOpenChange:i,className:"px-4 py-2",children:[k,j]}),t[25]=o,t[26]=k,t[27]=j,t[28]=_):_=t[28],_}),pG=1.5;function hG(n,e){return e<=0?!1:n<e*pG}function gG(n,e){return n===0&&!e}function xG(n,e){return!n||!n.firstKey||e.length<=n.length||e[0]===n.firstKey?!1:e.includes(n.firstKey)}function bG(n,e){return e&&e!=="claude"?n.isFragment===!0:n.userMessage===null}const vG=1e3;function yG(n){const e=new Map;return n.map(t=>{if(!t.contentBlocks.some(r=>r.kind==="agent_message"))return t;const s=t.contentBlocks.filter(r=>{if(r.kind!=="agent_message")return!0;const o=Date.parse(r.timestamp??"");if(Number.isNaN(o))return!0;const i=`${r.sender}\0${r.body}`,l=e.get(i);return l!==void 0&&Math.abs(o-l)<=vG?!1:(e.set(i,o),!0)});return s.length===t.contentBlocks.length?t:{...t,contentBlocks:s}})}function T_(n,e,t){const s=new Set(n.map(c=>c.id)),r=e.filter(c=>!s.has(c.id));if(r.length===0)return n;const o=n[0],i=r[r.length-1],l=o&&i&&bG(o,t)?[...r.slice(0,-1),SG(i,o),...n.slice(1)]:[...r,...n];return n0(yG(l))}function wG(n,e){if(n.durationMs!==null&&e.durationMs!==null)return n.durationMs+e.durationMs;const t=Date.parse(n.timestamp),s=Date.parse(e.timestamp)+(e.durationMs??0);return!Number.isFinite(t)||!Number.isFinite(s)||s<t?e.durationMs??n.durationMs:s-t}function SG(n,e){return{...n,id:e.id,contentBlocks:[...n.contentBlocks,...e.contentBlocks],thinking:[...n.thinking,...e.thinking],assistantText:[...n.assistantText,...e.assistantText],toolCalls:[...n.toolCalls,...e.toolCalls],subAgentActivity:[...n.subAgentActivity,...e.subAgentActivity],durationMs:wG(n,e),tokenUsage:e.tokenUsage??n.tokenUsage,model:e.model??n.model,compactionSummary:n.compactionSummary??e.compactionSummary,compactionMeta:n.compactionMeta??e.compactionMeta}}function kG(){const n=q.c(10),{session:e,isSubAgentView:t,undoRedo:s}=yt(),{canRedo:r,redoTurnCount:o,redoGhostTurns:i,requestRedoAll:l,requestRedoUpTo:c}=s,u=(e==null?void 0:e.turns.length)??0;if(!s.enabled||t||!r||!l)return null;let d;n[0]!==o||n[1]!==l?(d=a.jsx(tq,{redoTurnCount:o,onRedoAll:l}),n[0]=o,n[1]=l,n[2]=d):d=n[2];let f;n[3]!==i||n[4]!==c||n[5]!==u?(f=i.length>0&&a.jsx("div",{className:"select-none",children:i.map((p,h)=>a.jsxs("div",{className:"group/ghost relative opacity-25 hover:opacity-40 transition-opacity",children:[a.jsx(E_,{turn:p,index:u+h}),c&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:()=>c(h),className:"absolute right-4 top-4 text-success opacity-0 transition-opacity group-hover/ghost:opacity-100",children:[a.jsx(UP,{"data-icon":"inline-start"}),"Redo to here"]})]},`ghost-${p.id}`))}),n[3]=i,n[4]=c,n[5]=u,n[6]=f):f=n[6];let m;return n[7]!==d||n[8]!==f?(m=a.jsxs(a.Fragment,{children:[d,f]}),n[7]=d,n[8]=f,n[9]=m):m=n[9],m}function jG(n){const e=q.c(5),{hasMore:t,isLoadingOlder:s}=n;let r;e[0]!==t||e[1]!==s?(r=s?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(vt,{className:"size-3 animate-spin","data-icon":"inline-start"}),"Loading older turns…"]}):t?null:a.jsx("span",{children:"Beginning of session"}),e[0]=t,e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=a.jsx("div",{className:"flex h-8 select-none items-center justify-center text-xs text-muted-foreground","data-testid":"history-status",children:r}),e[3]=r,e[4]=o):o=e[4],o}function NG(n){return(n.compactionSummary!=null||n.compactionMeta!=null)&&n.userMessage==null&&n.contentBlocks.length===0}function CG({filteredTurns:n,scrollContainerRef:e,hasMore:t=!1,isLoadingOlder:s=!1,pagingEnabled:r=!1,onLoadMore:o}){const{state:{activeTurnIndex:i}}=ln(),{undoRedo:l}=yt(),c=y.useRef(null),u=y.useRef(null),[d,f]=y.useState(0),m=y.useMemo(()=>{const v=new Map;return n.map(k=>{const j=v.get(k.turn.id)??0;return v.set(k.turn.id,j+1),{...k,key:j===0?k.turn.id:`${k.turn.id}#${j}`}})},[n]),p=y.useRef(null),h=y.useMemo(()=>xG(p.current,m.map(v=>v.key)),[m]);y.useLayoutEffect(()=>{var v;p.current={firstKey:(v=m[0])==null?void 0:v.key,length:m.length}},[m]);const g=y.useRef(t);y.useEffect(()=>{t&&(g.current=!0)},[t]);const x=t||g.current;y.useLayoutEffect(()=>{const v=e.current,k=u.current;if(!v||!k)return;const j=k.getBoundingClientRect().top-v.getBoundingClientRect().top+v.scrollTop;f(_=>Math.abs(_-j)<1?_:j)},[e,x]),y.useEffect(()=>{if(!t||!o||!r||s)return;const v=e.current;if(!v)return;const k=()=>{hG(v.scrollTop,v.clientHeight)&&o()};return k(),v.addEventListener("scroll",k,{passive:!0}),()=>v.removeEventListener("scroll",k)},[t,s,r,o,m.length,e]);const b=y.useMemo(()=>{const v=new Map;for(let k=0;k<m.length;k++)v.set(m[k].index,k);return v},[m]),w=y.useRef(null);return y.useEffect(()=>{var k;if(i===null){w.current=null;return}if(i===w.current)return;w.current=i;const v=b.get(i);v!==void 0&&((k=c.current)==null||k.scrollToIndex(v,{align:"start",smooth:!0}))},[i,b]),a.jsxs(a.Fragment,{children:[x&&a.jsx(jG,{hasMore:t,isLoadingOlder:s}),a.jsx("div",{ref:u,className:"motion-session-enter",children:a.jsx(eq,{ref:c,scrollRef:e,startMargin:d,shift:h,children:m.map(({turn:v,index:k,key:j})=>a.jsxs("div",{"data-turn-index":k,children:[(v.compactionSummary||v.compactionMeta)&&a.jsx(mG,{summary:v.compactionSummary,meta:v.compactionMeta}),!NG(v)&&a.jsx(E_,{turn:v,index:k,branchCount:l.branchesAtTurn?l.branchesAtTurn(k).length:0})]},j))})}),a.jsx(kG,{})]})}const _G=y.memo(function(e){const t=q.c(19),{chatScrollRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l}=e,{state:c}=ln(),{searchQuery:u,sessionChangeKey:d}=c,{session:f}=yt(),m=f==null?void 0:f.turns;let p;t[0]!==m?(p=m?m.map(EG):[],t[0]=m,t[1]=p):p=t[1];const h=p;let g;t[2]!==h||t[3]!==u?(g=u?h.filter(k=>{const{turn:j}=k;return qK(j,u)}):h,t[2]=h,t[3]=u,t[4]=g):g=t[4];const x=g;let b;t[5]!==x.length||t[6]!==r||t[7]!==u?(b=u?x.length===0:gG(x.length,r??!1),t[5]=x.length,t[6]=r,t[7]=u,t[8]=b):b=t[8];const w=b;let v;return t[9]!==s||t[10]!==x||t[11]!==r||t[12]!==o||t[13]!==l||t[14]!==i||t[15]!==u||t[16]!==d||t[17]!==w?(v=a.jsx(UB,{children:w?a.jsx(Cn,{className:"min-h-64 border-0",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:u?a.jsx(BP,{}):a.jsx(Rj,{})}),a.jsx(En,{children:u?"No matching turns":"No conversation yet"}),a.jsx(Tn,{children:u?"Try a different search term.":"Messages and tool activity will appear here."})]})}):a.jsx(CG,{filteredTurns:x,scrollContainerRef:s,hasMore:r,isLoadingOlder:o,pagingEnabled:i,onLoadMore:l},d)}),t[9]=s,t[10]=x,t[11]=r,t[12]=o,t[13]=l,t[14]=i,t[15]=u,t[16]=d,t[17]=w,t[18]=v):v=t[18],v});function EG(n,e){return{turn:n,index:e}}const TG="[data-turn-index]",A_="[data-turn-prompt]",aw=1,AG=120,lw=180;function IG(n,e){if(!n.userMessage)return null;const t=Tc(n.userMessage),{body:s}=Kl(t),{remainingText:r}=Cx(s),o=V4(r),i=_x(o,e);if(i)return i;if(!o){const c=H4(t);if(!c)return null;const u=K4(t);return u?`/${c} ${u}`:`/${c}`}const l=o.split(`
|
|
128
|
-
`)[0];return l.length>lw?`${l.slice(0,lw)}...`:l}function PG(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=IG(r,t);if(o)return{index:s,text:o}}return null}function $G(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(TG)){const c=l.getBoundingClientRect().top;if(c>e+aw)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(A_);return(o?o.getBoundingClientRect().bottom>e+aw:s+AG>e)?null:r}const RG=y.memo(function(e){const t=q.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const j=r.current;if(!j)return;let _=null;const N=()=>{_=null;const T=$G(j);i(I=>T===null?null:(I==null?void 0:I.sessionId)===s.sessionId&&I.index===T?I:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),j.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(j,{childList:!0,subtree:!0});const A=new ResizeObserver(S);return A.observe(j),j.firstElementChild&&A.observe(j.firstElementChild),S(),()=>{j.removeEventListener("scroll",S),C.disconnect(),A.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=_a();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(j=PG(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=j):j=t[7],d=j}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const j=r.current;if(!j)return;const _=j.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(A_))??_;if(!N)return;const S=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Rj,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(dc,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let k;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(k=a.jsxs(J,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=k):k=t[22],k});function Ug({path:n,dirName:e,command:t}){return Bo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ee("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const OG={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},LG=1440*60*1e3;function MG(n){return(n&&OG[n])??"usage"}function zG(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>LG;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function DG(n){const e=q.c(33),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=hs(s),c=ox(l.kind,vd(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=zG(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!Bo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Eo,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=MG(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(Vt,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let k;e[16]!==u||e[17]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[16]=u,e[17]=m,e[18]=k):k=e[18];let j;e[19]!==v||e[20]!==k?(j=a.jsxs("span",{children:[v,k]}),e[19]=v,e[20]=k,e[21]=j):j=e[21];let _;e[22]!==h||e[23]!==u||e[24]!==o||e[25]!==s?(_=h&&a.jsx(J,{size:"sm",variant:"outline",onClick:()=>Ug({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[22]=h,e[23]=u,e[24]=o,e[25]=s,e[26]=_):_=e[26];let N;e[27]!==j||e[28]!==_?(N=a.jsxs(_t,{className:"flex flex-col items-start gap-2",children:[j,_]}),e[27]=j,e[28]=_,e[29]=N):N=e[29];let S;return e[30]!==N||e[31]!==w?(S=a.jsxs(wt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,N]}),e[30]=N,e[31]=w,e[32]=S):S=e[32],S}function FG(n){const e=q.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&a.jsx(cw,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let r;e[7]!==t.text?(r=a.jsx(G5,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(cw,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function cw(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const UG=y.memo(function(){const e=q.c(9),t=k0();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=gq(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(BG,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(FG,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function BG(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class I_ extends y.Component{constructor(t){super(t);Ze(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(wt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(_r,{}),a.jsx(Vt,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Ao,{className:"static col-start-2 mt-2",children:a.jsxs(J,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const uw="find-in-session-highlight",lp="find-in-session-active";function WG(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let s;for(;s=t.nextNode();)s.nodeValue&&s.nodeValue.trim().length>0&&e.push(s);return e}const qG=y.forwardRef(function(e,t){const s=q.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const te=r.current;if(!te)return;te.querySelectorAll(`mark.${uw}`).forEach(VG)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=te=>{if(x(),!te||!r.current){f([]),p(-1);return}const re=r.current,oe=WG(re),ie=te.toLowerCase(),ae=[];for(const de of oe){const le=de.nodeValue||"",se=le.toLowerCase();let me=0;const ue=[];for(;;){const he=se.indexOf(ie,me);if(he===-1)break;ue.push(he),me=he+1}if(ue.length===0)continue;const ce=de.parentNode;if(!ce)continue;const xe=document.createDocumentFragment();let pe=0;for(const he of ue){he>pe&&xe.appendChild(document.createTextNode(le.slice(pe,he)));const be=document.createElement("mark");be.className=uw,be.textContent=le.slice(he,he+te.length),xe.appendChild(be),ae.push(be),pe=he+te.length}pe<le.length&&xe.appendChild(document.createTextNode(le.slice(pe))),ce.replaceChild(xe,de)}f(ae),ae.length>0?(p(0),ae[0].classList.add(lp),ae[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=te=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(lp);const re=(te%d.length+d.length)%d.length;d[re].classList.add(lp),d[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const k=v;let j;s[9]!==x?(j=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const _=j;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var te;return(te=h.current)==null?void 0:te.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,A;s[15]!==w||s[16]!==l?(C=()=>{const te=setTimeout(()=>w(l),150);return()=>clearTimeout(te)},A=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=A):(C=s[17],A=s[18]),y.useEffect(C,A);let T,I;s[19]!==x?(T=()=>()=>x(),I=[x],s[19]=x,s[20]=T,s[21]=I):(T=s[20],I=s[21]),y.useEffect(T,I);let E;s[22]!==m||s[23]!==k||s[24]!==_?(E=te=>{te.key==="Escape"?(te.preventDefault(),te.stopPropagation(),_()):te.key==="Enter"&&(te.preventDefault(),te.shiftKey?k(m-1):k(m+1))},s[22]=m,s[23]=k,s[24]=_,s[25]=E):E=s[25];const P=E;if(!o)return null;let R;s[26]===Symbol.for("react.memo_cache_sentinel")?(R=te=>c(te.target.value),s[26]=R):R=s[26];let L;s[27]!==P||s[28]!==l?(L=a.jsx(Vo,{ref:h,value:l,onChange:R,onKeyDown:P,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=P,s[28]=l,s[29]=L):L=s[29];const O=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let $;s[30]!==O?($=a.jsx(jr,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:O})}),s[30]=O,s[31]=$):$=s[31];let M;s[32]!==L||s[33]!==$?(M=a.jsxs(qo,{className:"w-64",children:[L,$]}),s[32]=L,s[33]=$,s[34]=M):M=s[34];let D;s[35]!==m||s[36]!==k?(D=()=>k(m-1),s[35]=m,s[36]=k,s[37]=D):D=s[37];const F=d.length===0,z=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let B;s[38]!==z?(B=G("text-muted-foreground",z),s[38]=z,s[39]=B):B=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(dc,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==D||s[42]!==F||s[43]!==B?(W=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,disabled:F,className:B,"aria-label":"Previous match",children:U}),s[41]=D,s[42]=F,s[43]=B,s[44]=W):W=s[44];let V;s[45]!==m||s[46]!==k?(V=()=>k(m+1),s[45]=m,s[46]=k,s[47]=V):V=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Wt,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==V||s[52]!==H||s[53]!==Z?(X=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=V,s[52]=H,s[53]=Z,s[54]=X):X=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(At,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let Q;s[56]!==_?(Q=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=Q):Q=s[57];let ne;return s[58]!==M||s[59]!==W||s[60]!==X||s[61]!==Q?(ne=a.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[M,W,X,Q]}),s[58]=M,s[59]=W,s[60]=X,s[61]=Q,s[62]=ne):ne=s[62],ne});function VG(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const P_=[1,2,3,4,5,6,7,8,9],ebe=["General","View","Tools"],sm=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},...P_.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],$_="cogpit-keybindings";let ei=null;function R_(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function nc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function HG(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function P0(){if(ei)return ei;try{const n=localStorage.getItem($_);if(!n)return ei={};const e=JSON.parse(n);if(!e||typeof e!="object")return ei={};const t={};for(const s of sm){const r=e[s.command];HG(r)&&(t[s.command]=r)}return ei=t}catch{return ei={}}}function $0(n){ei=n;try{localStorage.setItem($_,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Mc(n){const e=sm.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return P0()[n]??e.defaultShortcut}function tbe(){return Object.fromEntries(sm.map(n=>[n.command,Mc(n.command)]))}function nbe(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:nc(e.key)};$0({...P0(),[n]:t})}function sbe(n){const e={...P0()};delete e[n],$0(e)}function rbe(){$0({})}function obe(n){return{key:nc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function O_(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function Gt(n,e){const t=Mc(n);return"doubleTapModifier"in t||nc(e.key)!==nc(t.key)?!1:t.modKey?e.metaKey===e.ctrlKey?!1:e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey:t.platformChord?e.ctrlKey&&e.metaKey!==e.altKey&&e.shiftKey===!!t.shiftKey:e.metaKey===!!t.metaKey&&e.ctrlKey===!!t.ctrlKey&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}function Ci(n){return n===" "?"Space":n==="escape"?"Esc":n==="tab"?"Tab":n==="arrowup"?"↑":n==="arrowdown"?"↓":n==="arrowleft"?"←":n==="arrowright"?"→":n.length===1?n.toUpperCase():n}function KG(n){const e=R_();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ci(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ci(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ci(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ci(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ci(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ci(n.key)].filter(Boolean).join("+")}function Qu(n){return KG(Mc(n))}function dw(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${nc(n.key)}|${t}|${s}|${r}|${o}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function ibe(n,e){const t=new Set(dw(n));return sm.find(s=>s.command!==e&&dw(Mc(s.command)).some(r=>t.has(r)))??null}function fw(n){return"doubleTapModifier"in Mc(n)?R_()?"Meta":"Control":null}const GG=P_.map(n=>`device.switch.${n}`),ZG="device.cycle";function YG(n){const e=GG.findIndex(t=>Gt(t,n));return e===-1?null:e+1}function XG(n){return Gt(ZG,n)}const Bg="cogpit:find-in-conversation",rm=y.memo(function(e){const t=q.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=ln(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=yt(),v=xn("terminal"),{chat:k,scroll:j}=Of(),{searchQuery:_}=f,{pendingMessages:N}=k,{chatScrollRef:S,scrollEndRef:C,observeChatContent:A,handleScroll:T,canScrollDown:I,scrollToBottomInstant:E,initialScrollDone:P}=j,R=y.useRef(null);let L;t[0]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{var Se;return(Se=R.current)==null?void 0:Se.open()},t[0]=L):L=t[0];const O=L;let $,M;t[1]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Se=function(Ae){Gt("findInConversation",Ae)&&(Ae.preventDefault(),O())};return window.addEventListener("keydown",Se),window.addEventListener(Bg,O),()=>{window.removeEventListener("keydown",Se),window.removeEventListener(Bg,O)}},M=[O],t[1]=$,t[2]=M):($=t[1],M=t[2]),y.useEffect($,M);let D,F;t[3]!==p||t[4]!==d||t[5]!==s?(D=()=>{!p||!d||requestAnimationFrame(()=>{var Se;return(Se=s.current)==null?void 0:Se.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=D,t[7]=F):(D=t[6],F=t[7]),y.useEffect(D,F);let z;t[8]!==m||t[9]!==u?(z=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=z):z=t[10];const B=z,U=h;let W;t[11]!==x||t[12]!==g?(W=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=W):W=t[13];const V=W,H=U.turns.length>0||N.length===0;let K;t[14]!==B||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(K=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(qo,{className:"h-9 flex-1",children:[a.jsx(Vo,{ref:s,value:_,onChange:Se=>m({type:"SET_SEARCH_QUERY",value:Se.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(jr,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(J,{variant:"ghost",size:"icon-sm",onClick:B,"aria-label":"Close conversation search",children:a.jsx(At,{"data-icon":"inline-start"})})]}),t[14]=B,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=K):K=t[20];let Z;t[21]!==v||t[22]!==U.cwd||t[23]!==p||t[24]!==b.send||t[25]!==V?(Z=V&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(DG,{...V,cwd:U.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=U.cwd,t[23]=p,t[24]=b.send,t[25]=V,t[26]=Z):Z=t[26];let Y;t[27]!==S?(Y=a.jsx(qG,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Y):Y=t[28];let X;t[29]!==S||t[30]!==U?(X=a.jsx(RG,{session:U,scrollContainerRef:S}),t[29]=S,t[30]=U,t[31]=X):X=t[31];const ee=p&&"mobile-scroll";let Q;t[32]!==ee?(Q=G("h-full overflow-x-hidden overflow-y-auto",ee),t[32]=ee,t[33]=Q):Q=t[33];let ne;t[34]!==p||t[35]!==V?(ne=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",V?"pt-4":"pt-14"),t[34]=p,t[35]=V,t[36]=ne):ne=t[36];let te;t[37]!==r||t[38]!==p?(te=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=te):te=t[39];let re;t[40]!==S||t[41]!==o||t[42]!==P||t[43]!==i||t[44]!==l||t[45]!==H?(re=H&&a.jsx(_G,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:P,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=P,t[43]=i,t[44]=l,t[45]=H,t[46]=re):re=t[46];let oe,ie;t[47]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsx(UG,{}),ie=a.jsx(BK,{}),t[47]=oe,t[48]=ie):(oe=t[47],ie=t[48]);const ae=b.send&&!w;let de;t[49]!==U.sessionId||t[50]!==U.turns||t[51]!==p||t[52]!==N||t[53]!==ae?(de=a.jsx(I5,{sessionId:U.sessionId,turns:U.turns,pendingMessages:N,canManage:ae,isMobile:p}),t[49]=U.sessionId,t[50]=U.turns,t[51]=p,t[52]=N,t[53]=ae,t[54]=de):de=t[54];let le;t[55]!==C?(le=a.jsx("div",{ref:C}),t[55]=C,t[56]=le):le=t[56];let se;t[57]!==re||t[58]!==de||t[59]!==le?(se=a.jsxs(I_,{fallbackMessage:"Failed to render conversation timeline",children:[re,oe,ie,de,le]}),t[57]=re,t[58]=de,t[59]=le,t[60]=se):se=t[60];let me;t[61]!==A||t[62]!==ne||t[63]!==te||t[64]!==se?(me=a.jsx("div",{ref:A,className:ne,style:te,children:se}),t[61]=A,t[62]=ne,t[63]=te,t[64]=se,t[65]=me):me=t[65];let ue;t[66]!==S||t[67]!==T||t[68]!==Q||t[69]!==me?(ue=a.jsx("div",{ref:S,onScroll:T,className:Q,children:me}),t[66]=S,t[67]=T,t[68]=Q,t[69]=me,t[70]=ue):ue=t[70];const ce=I?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",xe=p?"right-3 bottom-3":"right-5 bottom-5";let pe;t[71]!==ce||t[72]!==xe?(pe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ce,xe),t[71]=ce,t[72]=xe,t[73]=pe):pe=t[73];let he;t[74]===Symbol.for("react.memo_cache_sentinel")?(he=a.jsx(WP,{"data-icon":"inline-start"}),t[74]=he):he=t[74];let be;t[75]!==E||t[76]!==pe?(be=a.jsx(J,{size:"icon",className:pe,onClick:E,"aria-label":"Scroll to bottom",children:he}),t[75]=E,t[76]=pe,t[77]=be):be=t[77];let we;t[78]!==Y||t[79]!==X||t[80]!==ue||t[81]!==be?(we=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Y,X,ue,be]}),t[78]=Y,t[79]=X,t[80]=ue,t[81]=be,t[82]=we):we=t[82];let ve;return t[83]!==Z||t[84]!==we||t[85]!==K?(ve=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[K,Z,we]}),t[83]=Z,t[84]=we,t[85]=K,t[86]=ve):ve=t[86],ve});function JG({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(qx,{open:n,onOpenChange:m,children:[t&&a.jsx(Pz,{render:t}),a.jsxs(Vx,{size:"sm",children:[a.jsxs(Hx,{children:[a.jsx(Gx,{children:s}),a.jsx(Zx,{children:r})]}),d&&a.jsx(jo,{className:"text-center",children:d}),a.jsxs(Kx,{children:[a.jsx(Xx,{disabled:c,children:"Cancel"}),a.jsxs(Yx,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function QG(n){const e=q.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(jo,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(J,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(J,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Wg="cogpit-devices-changed",L_="cogpit:devices-changed";function M_(n){typeof n.connectionRevision=="number"&&D$(n.id,n.connectionRevision)}function z_(n,e,t=!1){window.dispatchEvent(new CustomEvent(Wg,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(L_,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function mw(n){M_(n),z_(n.id,n.connectionRevision)}function pw(n){const e=Dt();e!==Tt&&!n.some(t=>t.id===e)&&Ks(Tt)}function cp(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function D_(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function eZ(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function La({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Dt()),l=y.useRef(0),c=y.useCallback(async()=>{const g=++l.current;if(!n){t([]),r(!1);return}try{const x=await po("/api/hub/devices");if(x.status===403&&g===l.current&&pw([]),!x.ok)return;const b=await cr(x);if(g!==l.current)return;const w=Array.isArray(b==null?void 0:b.devices)?b.devices:[];for(const v of w)M_(v);t(w),pw(w)}catch{}finally{g===l.current&&r(!1)}},[n]);y.useEffect(()=>{c()},[c]),y.useEffect(()=>{const g=()=>i(Dt()),x=()=>void c(),b=k=>{if(k.key===L_){try{const j=JSON.parse(k.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&Dt()===j.deviceId&&Ks(Tt)}catch{}c()}},w=()=>{l.current+=1,t([]),r(!0),c()},v=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",g),window.addEventListener("popstate",g),window.addEventListener(Wg,x),window.addEventListener("storage",b),window.addEventListener("cogpit-auth-changed",w),window.addEventListener("cogpit-identity-changed",w),window.addEventListener("cogpit-auth-required",v),()=>{window.removeEventListener("cogpit-device-changed",g),window.removeEventListener("popstate",g),window.removeEventListener(Wg,x),window.removeEventListener("storage",b),window.removeEventListener("cogpit-auth-changed",w),window.removeEventListener("cogpit-identity-changed",w),window.removeEventListener("cogpit-auth-required",v)}},[c]);const u=y.useMemo(()=>o===Tt?void 0:e.find(g=>g.id===o),[e,o]),d=y.useCallback(async(g,x,b,w)=>{try{const v=await po("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:g,port:x,allowLocalTunnel:b,tls:w})}),k=await cr(v);return(k==null?void 0:k.ok)===!0&&k.hello?{ok:!0,hello:k.hello}:{ok:!1,code:(k==null?void 0:k.code)??"UNREACHABLE",error:typeof(k==null?void 0:k.error)=="string"?k.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=y.useCallback(async g=>{try{const x=await po("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await cr(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return mw(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),m=y.useCallback(async(g,x)=>{try{const b=await po(cp(g),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(x)}),w=await cr(b);if(b.ok&&(w!=null&&w.device)){const v=w.device;return mw(v),{ok:!0,device:v}}return{ok:!1,code:(w==null?void 0:w.code)??"ERROR",error:typeof(w==null?void 0:w.error)=="string"?w.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),p=y.useCallback(async g=>{try{const x=await po(cp(g),{method:"DELETE"});if(x.ok)return Dt()===g&&Ks(Tt),z_(g,void 0,!0),{ok:!0};const b=await cr(x);return{ok:!1,error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),h=y.useCallback(async g=>{try{const x=await po(cp(g,"/test"),{method:"POST"});return await cr(x)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:u,loading:s,refresh:c,probe:d,addDevice:f,updateDevice:m,removeDevice:p,testDevice:h}}const F_="3.2.0",U_={version:F_},hw=U_.version,tZ=19384,nZ=443,sZ=450,rZ=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),oZ=`${rZ?"⌘⇧":"Ctrl+Shift+"}1–9`,iZ=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),aZ=new Set(["ACCOUNT_REFUSED"]);function pu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function lZ(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const B_={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function cZ(n){const e=q.c(10),{tone:t}=n,s=B_[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(eo,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(_r,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Fo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const uZ={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function dZ(n){const e=q.c(103),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i}=n,[l,c]=y.useState(!1),[u,d]=y.useState(t.name),[f,m]=y.useState(!1),[p,h]=y.useState(t.username??""),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,k]=y.useState(!1),[j,_]=y.useState(null);let N,S;e[0]!==t.name?(N=()=>{d(t.name)},S=[t.name],e[0]=t.name,e[1]=N,e[2]=S):(N=e[1],S=e[2]),y.useEffect(N,S);let C,A;e[3]!==t.username?(C=()=>{h(t.username??"")},A=[t.username],e[3]=t.username,e[4]=C,e[5]=A):(C=e[4],A=e[5]),y.useEffect(C,A);let T;e[6]!==t?(T=D_(t),e[6]=t,e[7]=T):T=e[7];const I=T,E=I!==void 0&&I!==hw;let P;e[8]!==t?(P=eZ(t),e[8]=t,e[9]=P):P=e[9];const R=P==="account";let L;e[10]!==t.id||e[11]!==t.name||e[12]!==u||e[13]!==s?(L=async function(){const ze=u.trim();if(!ze||ze===t.name){c(!1),d(t.name);return}_("rename"),await s(t.id,ze),_(null),c(!1)},e[10]=t.id,e[11]=t.name,e[12]=u,e[13]=s,e[14]=L):L=e[14];const O=L;let $;e[15]!==g||e[16]!==p||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?($=async function(){const ze=p.trim(),De=t.username??"",Le=ze!==De,Ce=g.length>0;if(!Le&&!Ce){m(!1),x(""),w(null);return}if(t.auth==="none"&&!Ce){w("Enter a password when adding an account to an unauthenticated device.");return}const Be={};Le&&(Be.username=ze||null),Ce&&(Be.password=g),_("credentials"),w(null);const We=await r(t.id,Be);if(_(null),!We.ok){w(We.error);return}m(!1),x("")},e[15]=g,e[16]=p,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=$):$=e[21];const M=$,D=`Status: ${t.runtime.authState}`,F=uZ[t.runtime.authState];let z;e[22]!==F?(z=G("size-2 shrink-0 rounded-full",F),e[22]=F,e[23]=z):z=e[23];let B;e[24]!==z||e[25]!==D?(B=a.jsx("span",{"aria-label":D,className:z}),e[24]=z,e[25]=D,e[26]=B):B=e[26];let U;e[27]!==t.auth||e[28]!==t.name||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==E||e[33]!==I?(U=l?a.jsx(zn,{value:u,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:Ae=>d(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&O(),Ae.key==="Escape"&&(c(!1),d(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),I&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",E?"text-warning":"text-muted-foreground"),title:E?`Device runs v${I}; hub runs v${hw}`:void 0,children:["v",I,E&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Ue,{variant:"secondary",children:"Unauthenticated"})]}),e[27]=t.auth,e[28]=t.name,e[29]=l,e[30]=u,e[31]=O,e[32]=E,e[33]=I,e[34]=U):U=e[34];const W=t.tls?"https://":"";let V;e[35]!==t.host||e[36]!==t.port||e[37]!==W?(V=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[W,t.host,":",t.port]}),e[35]=t.host,e[36]=t.port,e[37]=W,e[38]=V):V=e[38];let H;e[39]!==R||e[40]!==t.username?(H=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):R?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[39]=R,e[40]=t.username,e[41]=H):H=e[41];let K;e[42]!==U||e[43]!==V||e[44]!==H?(K=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[U,V,H]}),e[42]=U,e[43]=V,e[44]=H,e[45]=K):K=e[45];const Z=`Re-test ${t.name}`,Y=j==="test";let X;e[46]!==t.id||e[47]!==i?(X=async()=>{_("test"),await i(t.id),_(null)},e[46]=t.id,e[47]=i,e[48]=X):X=e[48];const ee=j==="test"&&"animate-spin";let Q;e[49]!==ee?(Q=G(ee),e[49]=ee,e[50]=Q):Q=e[50];let ne;e[51]!==Q?(ne=a.jsx(Fn,{"data-icon":"inline-start",className:Q}),e[51]=Q,e[52]=ne):ne=e[52];let te;e[53]!==Z||e[54]!==Y||e[55]!==X||e[56]!==ne?(te=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":Z,disabled:Y,onClick:X,children:ne}),e[53]=Z,e[54]=Y,e[55]=X,e[56]=ne,e[57]=te):te=e[57];const re=`Edit account for ${t.name}`;let oe;e[58]!==t.username?(oe=()=>{m(fZ),h(t.username??""),x(""),w(null)},e[58]=t.username,e[59]=oe):oe=e[59];let ie;e[60]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx(qP,{"data-icon":"inline-start"}),e[60]=ie):ie=e[60];let ae;e[61]!==re||e[62]!==oe?(ae=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":re,onClick:oe,children:ie}),e[61]=re,e[62]=oe,e[63]=ae):ae=e[63];const de=`Rename ${t.name}`;let le,se;e[64]===Symbol.for("react.memo_cache_sentinel")?(le=()=>c(!0),se=a.jsx(gr,{"data-icon":"inline-start"}),e[64]=le,e[65]=se):(le=e[64],se=e[65]);let me;e[66]!==de?(me=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":de,onClick:le,children:se}),e[66]=de,e[67]=me):me=e[67];const ue=`Remove ${t.name}`;let ce;e[68]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(mf,{"data-icon":"inline-start"}),e[68]=ce):ce=e[68];let xe;e[69]!==ue?(xe=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":ue,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:ce}),e[69]=ue,e[70]=xe):xe=e[70];let pe;e[71]!==t.name?(pe=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[71]=t.name,e[72]=pe):pe=e[72];let he;e[73]!==t.id||e[74]!==o?(he=async()=>(await o(t.id),null),e[73]=t.id,e[74]=o,e[75]=he):he=e[75];let be;e[76]!==v||e[77]!==xe||e[78]!==pe||e[79]!==he?(be=a.jsx(JG,{open:v,onOpenChange:k,trigger:xe,title:pe,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:he}),e[76]=v,e[77]=xe,e[78]=pe,e[79]=he,e[80]=be):be=e[80];let we;e[81]!==te||e[82]!==ae||e[83]!==me||e[84]!==be?(we=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[te,ae,me,be]}),e[81]=te,e[82]=ae,e[83]=me,e[84]=be,e[85]=we):we=e[85];let ve;e[86]!==B||e[87]!==K||e[88]!==we?(ve=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[B,K,we]}),e[86]=B,e[87]=K,e[88]=we,e[89]=ve):ve=e[89];let Se;e[90]!==j||e[91]!==b||e[92]!==g||e[93]!==p||e[94]!==t.id||e[95]!==t.name||e[96]!==t.username||e[97]!==f||e[98]!==M?(Se=f&&a.jsxs(QG,{error:b,busy:j==="credentials",saveLabel:"Save account",onCancel:()=>{m(!1),h(t.username??""),x(""),w(null)},onSave:()=>void M(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(sn,{children:[a.jsxs(rn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(zn,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:p,onChange:Ae=>h(Ae.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(sn,{children:[a.jsxs(rn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(zn,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:g,onChange:Ae=>x(Ae.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&p.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[90]=j,e[91]=b,e[92]=g,e[93]=p,e[94]=t.id,e[95]=t.name,e[96]=t.username,e[97]=f,e[98]=M,e[99]=Se):Se=e[99];let Te;return e[100]!==ve||e[101]!==Se?(Te=a.jsxs("div",{className:"rounded-lg border bg-card",children:[ve,Se]}),e[100]=ve,e[101]=Se,e[102]=Te):Te=e[102],Te}function fZ(n){return!n}function W_(n){var qe,Ke;const e=q.c(115),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,testDevice:f}=La(),[m,p]=y.useState(""),[h,g]=y.useState(""),[x,b]=y.useState(""),[w,v]=y.useState(""),[k,j]=y.useState(!1),[_,N]=y.useState(!1),[S,C]=y.useState(null),[A,T]=y.useState(!1),[I,E]=y.useState(null),P=y.useRef(null),R=y.useRef(0);let L,O;e[0]!==s||e[1]!==t?(L=()=>{t&&(p(""),g(""),b(""),v(""),j(!1),N(!1),C(null),E(null),s==="add"&&requestAnimationFrame(()=>{var fe;return(fe=P.current)==null?void 0:fe.focus()}))},O=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=O):(L=e[2],O=e[3]),y.useEffect(L,O);let $;e[4]!==k||e[5]!==h||e[6]!==l?($=async()=>{const{host:fe,port:ke,tls:Ge}=pu(h);if(!fe){C(null),N(!1);return}const Je=R.current=R.current+1;N(!0);const rt=await l(fe,ke,k,Ge);Je===R.current&&(C({...lZ(rt,fe,ke??(Ge?nZ:tZ)),hello:rt.ok?rt.hello:void 0}),N(!1))},e[4]=k,e[5]=h,e[6]=l,e[7]=$):$=e[7];const M=$;let D,F;e[8]!==h||e[9]!==t||e[10]!==M?(D=()=>{if(!t)return;if(!pu(h).host){C(null),N(!1);return}const fe=window.setTimeout(()=>void M(),sZ);return()=>window.clearTimeout(fe)},F=[t,h,M],e[8]=h,e[9]=t,e[10]=M,e[11]=D,e[12]=F):(D=e[11],F=e[12]),y.useEffect(D,F);const z=((qe=S==null?void 0:S.hello)==null?void 0:qe.signIn)==="account",B=z&&((Ke=S==null?void 0:S.hello)==null?void 0:Ke.setupRequired)===!0,U=z||!k;let W;e:{if(A){W=!1;break e}if(!pu(h).host){W=!1;break e}if(_||!S){W=!1;break e}if(B){W=!1;break e}if(U&&!w){W=!1;break e}if(z&&!x.trim()){W=!1;break e}if((S==null?void 0:S.tone)==="error"){W=!1;break e}W=!0}const V=W;let H;e[13]!==c||e[14]!==k||e[15]!==U||e[16]!==h||e[17]!==m||e[18]!==r||e[19]!==w||e[20]!==z||e[21]!==x?(H=async function(){const{host:ke,port:Ge,tls:Je}=pu(h);if(!ke)return;T(!0),E(null);const rt=await c({name:m.trim()||void 0,host:ke,port:Ge,tls:Je,username:z?x.trim():void 0,password:U&&w||void 0,allowLocalTunnel:k});if(T(!1),rt.ok){r(),Ks(rt.device.id);return}E({field:aZ.has(rt.code)?"username":iZ.has(rt.code)?"password":"host",message:rt.error})},e[13]=c,e[14]=k,e[15]=U,e[16]=h,e[17]=m,e[18]=r,e[19]=w,e[20]=z,e[21]=x,e[22]=H):H=e[22];const K=H;let Z;e[23]!==u?(Z=async(fe,ke)=>{await u(fe,{name:ke})},e[23]=u,e[24]=Z):Z=e[24];const Y=Z;let X;e[25]!==d?(X=async fe=>{await d(fe)},e[25]=d,e[26]=X):X=e[26];const ee=X;let Q;e[27]!==i||e[28]!==f?(Q=async fe=>{await f(fe),await i()},e[27]=i,e[28]=f,e[29]=Q):Q=e[29];const ne=Q;let te;e[30]!==r?(te=fe=>{fe||r()},e[30]=r,e[31]=te):te=e[31];let re;e[32]===Symbol.for("react.memo_cache_sentinel")?(re=a.jsxs(to,{children:[a.jsx(Js,{children:"Devices"}),a.jsxs(Qs,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",oZ," jumps between devices."]})]}),e[32]=re):re=e[32];let oe;e[33]!==o||e[34]!==ee||e[35]!==Y||e[36]!==ne||e[37]!==u?(oe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:o.map(fe=>a.jsx(dZ,{device:fe,onRename:Y,onCredentials:u,onRemove:ee,onTest:ne},fe.id))}),e[33]=o,e[34]=ee,e[35]=Y,e[36]=ne,e[37]=u,e[38]=oe):oe=e[38];let ie;e[39]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[39]=ie):ie=e[39];const ae=(I==null?void 0:I.field)==="host";let de,le;e[40]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx(rn,{htmlFor:"device-host",children:"Host"}),le=a.jsx(sa,{children:"Enter a local address or an HTTPS URL."}),e[40]=de,e[41]=le):(de=e[40],le=e[41]);let se;e[42]===Symbol.for("react.memo_cache_sentinel")?(se=fe=>{R.current=R.current+1,g(fe.target.value),b(""),C(null),E(null)},e[42]=se):se=e[42];let me;e[43]!==M?(me=()=>void M(),e[43]=M,e[44]=me):me=e[44];let ue;e[45]!==h||e[46]!==me?(ue=a.jsx(zn,{id:"device-host",ref:P,value:h,onChange:se,onBlur:me,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=me,e[47]=ue):ue=e[47];let ce;e[48]!==_?(ce=_&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=_,e[49]=ce):ce=e[49];let xe;e[50]!==S||e[51]!==_?(xe=!_&&S&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",B_[S.tone]),children:[a.jsx(cZ,{tone:S.tone}),S.text]}),e[50]=S,e[51]=_,e[52]=xe):xe=e[52];let pe;e[53]!==I?(pe=(I==null?void 0:I.field)==="host"&&a.jsx(jo,{children:I.message}),e[53]=I,e[54]=pe):pe=e[54];let he;e[55]!==ae||e[56]!==ue||e[57]!==ce||e[58]!==xe||e[59]!==pe?(he=a.jsxs(sn,{"data-invalid":ae,children:[de,le,ue,ce,xe,pe]}),e[55]=ae,e[56]=ue,e[57]=ce,e[58]=xe,e[59]=pe,e[60]=he):he=e[60];let be;e[61]===Symbol.for("react.memo_cache_sentinel")?(be=a.jsxs(rn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=be):be=e[61];let we;e[62]===Symbol.for("react.memo_cache_sentinel")?(we=fe=>p(fe.target.value),e[62]=we):we=e[62];let ve;e[63]!==m?(ve=a.jsxs(sn,{children:[be,a.jsx(zn,{id:"device-name",value:m,onChange:we,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=ve):ve=e[64];let Se;e[65]!==I||e[66]!==z||e[67]!==x?(Se=z&&a.jsxs(sn,{"data-invalid":(I==null?void 0:I.field)==="username",children:[a.jsx(rn,{htmlFor:"device-username",children:"Username"}),a.jsx(zn,{id:"device-username",value:x,onChange:fe=>b(fe.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(sa,{children:"Requests through this hub act as this account on that server."}),(I==null?void 0:I.field)==="username"&&a.jsx(jo,{children:I.message})]}),e[65]=I,e[66]=z,e[67]=x,e[68]=Se):Se=e[68];let Te;e[69]!==U||e[70]!==w||e[71]!==I||e[72]!==z?(Te=U&&a.jsxs(sn,{"data-invalid":(I==null?void 0:I.field)==="password",children:[a.jsx(rn,{htmlFor:"device-password",children:"Password"}),a.jsx(zn,{id:"device-password",type:"password",value:w,onChange:fe=>v(fe.target.value),placeholder:z?"Password for that account":"Network access password for that device",autoComplete:z?"current-password":"off"}),(I==null?void 0:I.field)==="password"&&a.jsx(jo,{children:I.message})]}),e[69]=U,e[70]=w,e[71]=I,e[72]=z,e[73]=Te):Te=e[73];let Ae;e[74]!==he||e[75]!==ve||e[76]!==Se||e[77]!==Te?(Ae=a.jsxs(ka,{children:[he,ve,Se,Te]}),e[74]=he,e[75]=ve,e[76]=Se,e[77]=Te,e[78]=Ae):Ae=e[78];let ze;e[79]===Symbol.for("react.memo_cache_sentinel")?(ze=fe=>{R.current=R.current+1,j(fe===!0),C(null),E(null)},e[79]=ze):ze=e[79];let De;e[80]!==k?(De=a.jsx(VN,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:ze}),e[80]=k,e[81]=De):De=e[81];const Le=z?"":" — no password";let Ce;e[82]!==Le?(Ce=a.jsxs(rn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Le]}),e[82]=Le,e[83]=Ce):Ce=e[83];let Be;e[84]!==De||e[85]!==Ce?(Be=a.jsxs(sn,{orientation:"horizontal",children:[De,Ce]}),e[84]=De,e[85]=Ce,e[86]=Be):Be=e[86];let We;e[87]!==k||e[88]!==z?(We=k&&a.jsxs(wt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(B1,{}),a.jsx(_t,{className:"text-warning",children:z?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[87]=k,e[88]=z,e[89]=We):We=e[89];let He;e[90]!==r?(He=a.jsx(J,{variant:"outline",onClick:r,children:"Close"}),e[90]=r,e[91]=He):He=e[91];const _e=!V;let Re;e[92]!==K?(Re=()=>void K(),e[92]=K,e[93]=Re):Re=e[93];let tt;e[94]!==A?(tt=A?a.jsxs(a.Fragment,{children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=A,e[95]=tt):tt=e[95];let Xe;e[96]!==_e||e[97]!==Re||e[98]!==tt?(Xe=a.jsx(J,{disabled:_e,onClick:Re,children:tt}),e[96]=_e,e[97]=Re,e[98]=tt,e[99]=Xe):Xe=e[99];let Ne;e[100]!==He||e[101]!==Xe?(Ne=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[He,Xe]}),e[100]=He,e[101]=Xe,e[102]=Ne):Ne=e[102];let Ve;e[103]!==Ae||e[104]!==Be||e[105]!==We||e[106]!==Ne?(Ve=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ie,Ae,Be,We,Ne]}),e[103]=Ae,e[104]=Be,e[105]=We,e[106]=Ne,e[107]=Ve):Ve=e[107];let ye;e[108]!==oe||e[109]!==Ve?(ye=a.jsxs(Xs,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[re,oe,Ve]}),e[108]=oe,e[109]=Ve,e[110]=ye):ye=e[110];let $e;return e[111]!==t||e[112]!==te||e[113]!==ye?($e=a.jsx(Ys,{open:t,onOpenChange:te,children:ye}),e[111]=t,e[112]=te,e[113]=ye,e[114]=$e):$e=e[114],$e}const mZ="Browsing folders needs a newer Cogpit on this machine.";async function q_(n){const e=await kl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?mZ:e)}async function pZ(n,e){const t=await Ee(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await q_(t);return await t.json()}async function hZ(n,e){const t=await os("/api/folders",{parent:n,name:e});if(!t.ok)throw await q_(t);return(await t.json()).path}function gZ(n,e=null){const t=xZ(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function xZ(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const qg="cogpit-browse-folders";function V_(){window.dispatchEvent(new Event(qg))}function bZ(n){return window.addEventListener(qg,n),()=>window.removeEventListener(qg,n)}const vZ=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-BgzjVxf6.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function H_(n){const e=q.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>bZ(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(vZ,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const yZ=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function gw(n,e){if(!yZ.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function ho(n,e){return`${n}.${e}`}function wZ(n){const e=new Set,t=new Set,s=[];for(const r of n){if(gw("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){gw("panel",o.id);const i=ho(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ti="cogpit",Et={worktrees:ho(ti,"worktrees"),projectFiles:ho(ti,"project-files"),browser:ho(ti,"browser"),fileChanges:ho(ti,"file-changes"),sessionInfo:ho(ti,"session-info"),crew:ho(ti,"crew")},SZ=y.lazy(()=>nt(()=>import("./CommandPaletteHost-CwInMsCp.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),kZ=y.lazy(()=>nt(()=>import("./index-IUqOcQ_C.js"),__vite__mapDeps([27,1,2,28,3,4])).then(n=>({default:n.ConfigDialog}))),jZ=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-CRuTSHwt.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),NZ=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-BgzjVxf6.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),CZ=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-DT9ZVWtN.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function _Z(n){const e=q.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=ln(),{session:c,sessionSource:u}=yt(),{devices:d,activeDeviceId:f}=La(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=ht("manageDevices"),e[0]=h):h=e[0];const g=h,x=jx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?ms(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,k=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,j=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==j?(_=()=>{const fe=function(Ge){Gt("keyboardShortcuts",Ge)&&(O_(document.activeElement)||(Ge.preventDefault(),j(!0)))};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},N=[j],e[4]=j,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Tt;let C;e[7]!==S?(C={id:Tt,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let A;if(e[9]!==f||e[10]!==d||e[11]!==C){let fe;e[13]!==f?(fe=ke=>({id:ke.id,name:ke.name,isLocal:!1,isActive:ke.id===f}),e[13]=f,e[14]=fe):fe=e[14],A=[C,...d.map(fe)],e[9]=f,e[10]=d,e[11]=C,e[12]=A}else A=e[12];const T=A,{openMainView:I,closeMainView:E}=t.panels;let P;if(e[15]!==E||e[16]!==x||e[17]!==I||e[18]!==b){let fe;e[20]!==E||e[21]!==I||e[22]!==b?(fe=ke=>{const Ge=ke.id===b;return{id:`main-view-${ke.id}`,label:`${Ge?"Close":"Open"} ${ke.label}`,keywords:ke.keywords,icon:ke.icon,onSelect:Ge?E:()=>I(ke.id)}},e[20]=E,e[21]=I,e[22]=b,e[23]=fe):fe=e[23],P=x.map(fe),e[15]=E,e[16]=x,e[17]=I,e[18]=b,e[19]=P}else P=e[19];const R=P;let L;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(L=()=>{if(!c)return;const fe=(u==null?void 0:u.agentKind)??an((u==null?void 0:u.dirName)??null);kf(ox(fe,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=L):L=e[27];const O=L,$=EZ,M=r.processPanel,D=r.workflowsPanel,F=r.undoDialog,z=r.branchModal,B=i.claudeDir??"";let U;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==B?(U=a.jsx(y.Suspense,{fallback:null,children:a.jsx(kZ,{open:i.showConfigDialog,currentPath:B,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=B,e[32]=U):U=e[32];const W=(u==null?void 0:u.dirName)??o.pendingDirName??null,V=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==W||e[39]!==V?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(NZ,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:W,currentProjectCwd:V})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=W,e[39]=V,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(H_,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(CZ,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,X=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,ne=t.onOpenPaletteProject,te=t.actions.handleDashboardSelect,re=t.panels.handleToggleSidebar;let oe,ie,ae;e[51]!==t.panels?(oe=()=>t.panels.toggleWorkspacePanel(Et.sessionInfo),ie=()=>t.panels.toggleWorkspacePanel(Et.fileChanges),ae=()=>t.panels.toggleWorkspacePanel(Et.worktrees),e[51]=t.panels,e[52]=oe,e[53]=ie,e[54]=ae):(oe=e[52],ie=e[53],ae=e[54]);const de=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,se=c?O:void 0,me=c?$:void 0,ue=ht("killAny")?r.onKillAll:void 0,ce=ht("configWrite")?t.panels.handleToggleConfig:void 0,xe=i.openConfigDialog;let pe;e[55]!==j?(pe=()=>j(!0),e[55]=j,e[56]=pe):pe=e[56];const he=s.currentCwd?s.onTogglePreview:void 0,be=ht("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let we;e[57]!==t.panels?(we=ht("browser")?()=>t.panels.toggleWorkspacePanel(Et.browser):void 0,e[57]=t.panels,e[58]=we):we=e[58];const ve=t.panels.handleToggleThemeSelector,Se=s.onOpenTerminal,Te=r.onFocusComposer,Ae=r.onExpandAll,ze=r.onExpandToolPayloads,De=r.onCollapseAll,Le=!!(c||o.pendingDirName);let Ce;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Ce=ht("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Ce):Ce=e[64];const Be=!!c;let We;e[65]!==s.hasFileChanges?(We=ht("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=We):We=e[66];const He=t.panels.activeWorkspacePanel===Et.sessionInfo,_e=t.panels.activeWorkspacePanel===Et.browser,Re=t.panels.activeWorkspacePanel===Et.fileChanges,tt=t.panels.activeWorkspacePanel===Et.worktrees,Xe=o.mainView==="config",Ne=o.mainView==="mission",Ve=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==k||e[75]!==R||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==oe||e[91]!==ie||e[92]!==ae||e[93]!==le||e[94]!==se||e[95]!==me||e[96]!==ue||e[97]!==ce||e[98]!==pe||e[99]!==he||e[100]!==be||e[101]!==we||e[102]!==Le||e[103]!==Ce||e[104]!==Be||e[105]!==We||e[106]!==He||e[107]!==_e||e[108]!==Re||e[109]!==tt||e[110]!==Xe||e[111]!==Ne||e[112]!==Ve?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(SZ,{open:Y,onOpenChange:X,onGoHome:ee,onNewSession:Q,onOpenProject:ne,onOpenSession:te,onToggleSidebar:re,onToggleStats:oe,onToggleFileChanges:ie,onToggleWorktrees:ae,onToggleMissionControl:de,extraActions:R,onDuplicateSession:le,onCopyResumeCommand:se,onFindInConversation:me,onKillAll:ue,onOpenConfig:ce,onOpenSettings:xe,onOpenKeyboardShortcuts:pe,onTogglePreview:he,onToggleProjectFiles:be,onToggleBrowser:we,onOpenTheme:ve,onOpenTerminal:Se,onOpenDevices:g?p:void 0,onSwitchDevice:Ks,devices:T,onFocusComposer:Te,onExpandAll:Ae,onExpandToolPayloads:ze,onCollapseAll:De,canFocusComposer:Le,canOpenTerminal:Ce,hasSession:Be,hasFileChanges:We,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:He,showProjectFiles:s.showProjectFiles,showBrowser:_e,showFileChanges:Re,showWorktrees:tt,showConfig:Xe,showMission:Ne,currentProjectDirName:k,projectCwd:Ve,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=k,e[75]=R,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=oe,e[91]=ie,e[92]=ae,e[93]=le,e[94]=se,e[95]=me,e[96]=ue,e[97]=ce,e[98]=pe,e[99]=he,e[100]=be,e[101]=we,e[102]=Le,e[103]=Ce,e[104]=Be,e[105]=We,e[106]=He,e[107]=_e,e[108]=Re,e[109]=tt,e[110]=Xe,e[111]=Ne,e[112]=Ve,e[113]=ye):ye=e[113];let $e;e[114]!==r.keyboardShortcutsOpen||e[115]!==j?($e=a.jsx(y.Suspense,{fallback:null,children:a.jsx(jZ,{open:r.keyboardShortcutsOpen,onOpenChange:j})}),e[114]=r.keyboardShortcutsOpen,e[115]=j,e[116]=$e):$e=e[116];let qe;e[117]!==m?(qe=g&&a.jsx(W_,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=qe):qe=e[118];let Ke;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==U||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==$e||e[129]!==qe?(Ke=a.jsxs(a.Fragment,{children:[M,D,F,z,U,H,K,Z,ye,$e,qe]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=U,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=$e,e[129]=qe,e[130]=Ke):Ke=e[130],Ke}function EZ(){window.dispatchEvent(new Event(Bg))}const K_={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function xw(n){return n===null?null:K_[n]??n}function G_(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===K_[n])??null:null}async function Z_(n,e,t){return(await os(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function TZ(n,e){return(await os(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function AZ(n,e,t){return TN("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function IZ(n,e,t){return TN("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const PZ=3e3,R0=y.createContext(null);async function up(n){try{const e=await Ee(n);return e.ok?await e.text():void 0}catch{return}}function dp(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function Ga(n){const e=new Map;for(const[t,s]of Object.entries(n??{}))Array.isArray(s)&&s.length>0&&e.set(t,s);return e}function hu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function $Z({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Ef(),b=_4()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[R,L,O]=await Promise.all([up(Sl("/api/permissions",x)),up(Sl("/api/user-questions",x)),up(Sl("/api/agent-prompts",x))]);if(w.current!==x.key)return;const $=dp(R,p),M=dp(L,h),D=dp(O,g);$&&(t(Ga($.bySession)),d(new Set(Ga($.plansBySession).keys()))),M&&r(Ga(M.bySession)),D&&(i(Ga(D.elicitationsBySession)),c(Ga(D.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const L=setInterval(R,PZ);return document.addEventListener("visibilitychange",R),()=>{clearInterval(L),document.removeEventListener("visibilitychange",R)}},[v,b]);const k=y.useCallback(async(R,L)=>{m(O=>new Set(O).add(R));try{return await L()}finally{m(O=>{const $=new Set(O);return $.delete(R),$}),v()}},[v]),j=y.useCallback((R,L,O)=>k(L,async()=>{await Z_(R,L,O).catch(()=>!1)&&(t(M=>hu(M,R,D=>D.requestId===L)),p.current="")}),[k]),_=y.useCallback((R,L,O)=>k(L,async()=>{const $=await Fx(R,L,O);return $.ok&&(r(M=>hu(M,R,D=>D.toolUseId===L)),h.current=""),$}),[k]),N=y.useCallback((R,L,O)=>k(L,async()=>{const $=await AZ(R,L,O);return $.ok&&(i(M=>hu(M,R,D=>D.requestId===L)),g.current=""),$}),[k]),S=y.useCallback((R,L,O)=>k(L,async()=>{const $=await IZ(R,L,O);return $.ok&&(c(M=>hu(M,R,D=>D.requestId===L)),g.current=""),$}),[k]),C=y.useMemo(()=>new Set(e.keys()),[e]),A=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),I=y.useMemo(()=>new Set(l.keys()),[l]),E=y.useCallback(()=>{v()},[v]),P=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:A,awaitingElicitation:T,awaitingDialog:I,awaitingPlan:u,responding:f,respond:j,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:E}),[e,s,o,l,C,A,T,I,u,f,j,_,N,S,E]);return a.jsx(R0.Provider,{value:P,children:n})}function RZ(){const n=y.useContext(R0);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function OZ(){return y.useContext(R0)}function Y_(n){var d;const e=q.c(29),t=Ar(),s=OZ(),r=X4(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:rR,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=k=>k.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var k;return((k=v.crew)==null?void 0:k.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let k;e[15]!==r?(k=r.filter(LZ),e[15]=r,e[16]=k):k=e[16];let j;e[17]!==p||e[18]!==k.length||e[19]!==r.length?(j={rootId:p,size:v,needsYou:0,working:k.length},e[17]=p,e[18]=k.length,e[19]=r.length,e[20]=j):j=e[20],u=j;break e}let x;e[21]!==c||e[22]!==i?(x=v=>k4(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=vx(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function LZ(n){return n.state==="running"}function ed(n){const e=q.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Ut,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Bt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Ft,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}const Qn="rounded-full border bg-popover shadow-sm",om=y.memo(function(e){const t=q.c(8);let s,r;t[0]!==e?({className:s,...r}=e,t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]);let o;t[3]!==s?(o=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=o):o=t[4];let i;return t[5]!==r||t[6]!==o?(i=a.jsx("span",{className:o,...r}),t[5]=r,t[6]=o,t[7]=i):i=t[7],i}),fp=y.memo(function(e){const t=q.c(17),{icon:s,label:r,onClick:o,disabled:i,className:l,iconClassName:c,size:u}=e,f=(u===void 0?"sm":u)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==f?(m=a.jsx(J,{variant:"ghost",size:f,className:l,onClick:o,disabled:i,"aria-label":r}),t[0]=l,t[1]=i,t[2]=r,t[3]=o,t[4]=f,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=a.jsx(s,{"data-icon":"inline-start",className:c}),t[6]=s,t[7]=c,t[8]=p):p=t[8];let h;t[9]!==m||t[10]!==p?(h=a.jsx(Ut,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==r?(g=a.jsx(Bt,{children:r}),t[12]=r,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=a.jsxs(Ft,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function MZ(n){return n<10?"critical":n<30?"warning":"healthy"}const zZ={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},X_=y.memo(function(e){const t=q.c(54),{rawMessages:s,showRemaining:r,showTooltip:o,warnOnly:i}=e,l=r===void 0?!1:r,c=o===void 0?!1:o,u=i===void 0?!1:i;let d,f,m,p,h,g,x,b,w,v,k,j,_;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==u){x=Symbol.for("react.early_return_sentinel");e:{const A=v4(s);if(!A){x=null;break e}const T=Math.max(0,100-A.percent),I=MZ(T);if(u&&I==="healthy"){x=null;break e}const E=Math.max(0,A.compactAt-A.used);let P;t[17]!==T||t[18]!==E||t[19]!==l?(P=l?`${T.toFixed(0)}% · ${Ct(E)}`:`${T.toFixed(0)}%`,t[17]=T,t[18]=E,t[19]=l,t[20]=P):P=t[20];const R=P,L=zZ[I],O=l&&"gap-1";let $;t[21]!==L||t[22]!==O?($=G("shrink-0 tabular-nums",L,O),t[21]=L,t[22]=O,t[23]=$):$=t[23];let M;t[24]!==R||t[25]!==$?(M=a.jsx(Ue,{variant:"outline",className:$,children:R}),t[24]=R,t[25]=$,t[26]=M):M=t[26];const D=M;if(!c){x=D;break e}f=Ft,t[27]!==D?(g=a.jsx(Ut,{render:D}),t[27]=D,t[28]=g):g=t[28],d=Bt,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let F;t[30]!==E?(F=Ct(E),t[30]=E,t[31]=F):F=t[31];let z;t[32]!==T?(z=T.toFixed(1),t[32]=T,t[33]=z):z=t[33],t[34]!==F||t[35]!==z?(h=a.jsxs("div",{children:[F," remaining (",z,"%)"]}),t[34]=F,t[35]=z,t[36]=h):h=t[36],b="text-muted-foreground",w=Ct(A.used),v=" / ",k=Ct(A.limit),j=" tokens used (",_=A.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=k,t[15]=j,t[16]=_}else d=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],w=t[12],v=t[13],k=t[14],j=t[15],_=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let N;t[37]!==b||t[38]!==w||t[39]!==v||t[40]!==k||t[41]!==j||t[42]!==_?(N=a.jsxs("div",{className:b,children:[w,v,k,j,_,"%)"]}),t[37]=b,t[38]=w,t[39]=v,t[40]=k,t[41]=j,t[42]=_,t[43]=N):N=t[43];let S;t[44]!==d||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==N?(S=a.jsxs(d,{className:m,children:[p,h,N]}),t[44]=d,t[45]=m,t[46]=p,t[47]=h,t[48]=N,t[49]=S):S=t[49];let C;return t[50]!==f||t[51]!==g||t[52]!==S?(C=a.jsxs(f,{children:[g,S]}),t[50]=f,t[51]=g,t[52]=S,t[53]=C):C=t[53],C});function DZ(n){var j;const e=q.c(22),{sessionId:t}=n,s=Ar(),{names:r}=If();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(FZ)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(j=i.get(t))==null?void 0:j.crew,!l){d=null;break e}c=i.get(l.parentId),u=Nd(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?Ra(zf(c.dirName,c.fileName)):Df(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(Qn,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(H1,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let k;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(k=a.jsxs(J,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=k):k=e[21],k}function FZ(n){return[n.sessionId,n]}const bw=U_.version,UZ={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},vw={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function BZ(n){const e=q.c(6),{state:t}=n,s=vw[t],r=vw[t],o=UZ[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function O0(n){const e=q.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=La(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Tt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ht("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=F=>{!F||r.length===0||Promise.all(r.map(z=>c(z.id).catch(qZ))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let k;e[7]!==b||e[8]!==v?(k=a.jsx(J,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=k):k=e[9];let j;e[10]!==m?(j=m?a.jsx(W1,{"data-icon":"inline-start"}):a.jsx(ig,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Wt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==k||e[16]!==j||e[17]!==_?(S=a.jsxs(Pa,{render:k,children:[j,_,N]}),e[15]=k,e[16]=j,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(SN,{children:"Devices"}),e[19]=C):C=e[19];let A,T;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(ig,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=A,e[21]=T):(A=e[20],T=e[21]);let I;e[22]!==m?(I=!m&&a.jsx(Ht,{className:"ml-auto text-success"}),e[22]=m,e[23]=I):I=e[23];let E;e[24]!==I?(E=a.jsxs(tn,{onClick:WZ,children:[A,T,I]}),e[24]=I,e[25]=E):E=e[25];let P;if(e[26]!==o||e[27]!==s||e[28]!==r){let F;e[30]!==o||e[31]!==s?(F=z=>{const B=D_(z),U=B!==void 0&&B!==bw,W=z.id===o;return a.jsxs(tn,{onClick:()=>Ks(z.id),className:G(s&&"min-h-10"),children:[a.jsx(BZ,{state:z.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:z.name}),U&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${B}; hub runs v${bw}`,children:["v",B]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),W&&a.jsx(Ht,{className:"ml-auto text-success"})]},z.id)},e[30]=o,e[31]=s,e[32]=F):F=e[32],P=r.map(F),e[26]=o,e[27]=s,e[28]=r,e[29]=P}else P=e[29];let R;e[33]!==E||e[34]!==P?(R=a.jsxs(pr,{children:[C,E,P]}),e[33]=E,e[34]=P,e[35]=R):R=e[35];let L;e[36]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Nl,{}),a.jsxs(pr,{children:[a.jsxs(tn,{onClick:()=>d("add"),children:[a.jsx(xr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(tn,{onClick:()=>d("manage"),children:[a.jsx(F1,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=r.length,e[37]=L):L=e[37];let O;e[38]!==R||e[39]!==L?(O=a.jsxs($a,{align:"end",sideOffset:6,className:"w-64",children:[R,L]}),e[38]=R,e[39]=L,e[40]=O):O=e[40];let $;e[41]!==x||e[42]!==S||e[43]!==O?($=a.jsxs(Ia,{onOpenChange:x,children:[S,O]}),e[41]=x,e[42]=S,e[43]=O,e[44]=$):$=e[44];let M;e[45]!==u?(M=h&&a.jsx(W_,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[45]=u,e[46]=M):M=e[46];let D;return e[47]!==$||e[48]!==M?(D=a.jsxs(a.Fragment,{children:[$,M]}),e[47]=$,e[48]=M,e[49]=D):D=e[49],D}function WZ(){return Ks(Tt)}function qZ(){return null}const VZ=6e4;function HZ(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),r=y.useRef(!1),o=y.useCallback(async()=>{if(!r.current){r.current=!0;try{const l=await Ee("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(u=>u.suspectedLeak))}}catch{}finally{r.current=!1}}},[]),i=y.useCallback(async l=>{if(l.length!==0){s(!0);try{await Ee("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await o()}catch{}finally{s(!1)}}},[o]);return y.useEffect(()=>{o();const l=window.setInterval(()=>{document.visibilityState==="visible"&&o()},VZ);return()=>window.clearInterval(l)},[o]),{leaks:n,killing:t,killLeaks:i,refresh:o}}const KZ=6e4;function GZ(){const n=q.c(29),{leaks:e,killing:t,killLeaks:s,refresh:r}=HZ(),[o,i]=y.useState(!1),l=e.length>0,c=e.reduce(XZ,0);let u,d;if(n[0]!==l?(u=()=>{if(l){i(!0);return}const I=window.setTimeout(()=>i(!1),KZ);return()=>window.clearTimeout(I)},d=[l],n[0]=l,n[1]=u,n[2]=d):(u=n[1],d=n[2]),y.useEffect(u,d),!l&&!o)return null;const f=Ft,m=l?"destructive":"ghost",p=l?`Kill ${e.length} leaked agent ${e.length===1?"process":"processes"}`:"Leak monitor. No leaked agent processes";let h;n[3]!==l||n[4]!==s||n[5]!==e||n[6]!==r?(h=()=>void(l?s(e.map(YZ)):r()),n[3]=l,n[4]=s,n[5]=e,n[6]=r,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=a.jsx(J,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(VP,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const v=t?"…":e.length;let k;n[17]!==v?(k=a.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=k):k=n[18];let j;n[19]!==k||n[20]!==b?(j=a.jsxs(Ut,{render:b,children:[w,k]}),n[19]=k,n[20]=b,n[21]=j):j=n[21];const _=Bt,N="bottom",S="p-3",C=l?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(ZZ),e.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),a.jsx(Qt,{}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let A;n[22]!==_||n[23]!==C?(A=a.jsx(_,{side:N,className:S,children:C}),n[22]=_,n[23]=C,n[24]=A):A=n[24];let T;return n[25]!==f||n[26]!==j||n[27]!==A?(T=a.jsxs(f,{children:[j,A]}),n[25]=f,n[26]=j,n[27]=A,n[28]=T):T=n[28],T}function ZZ(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",fx(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function YZ(n){return n.pid}function XZ(n,e){return n+e.cpuPercent}const JZ=15e3;function QZ(){const[n,e]=y.useState([]),t=y.useCallback(async()=>{var l,c;try{const u=await Ee("/api/notifications?limit=100");if(!u.ok)return;const d=await u.json();if(!Array.isArray(d.notifications))return;e(d.notifications),(c=(l=hg()).onInboxRead)==null||c.call(l,d.notifications)}catch{}},[]);y.useEffect(()=>{t();const l=()=>void t(),c=window.setInterval(l,JZ);return window.addEventListener("focus",l),()=>{window.clearInterval(c),window.removeEventListener("focus",l)}},[t]);const s=y.useCallback(async(l,c)=>{const u=new Date().toISOString();e(d=>d.map(f=>f.readAt===null&&c(f)?{...f,readAt:u}:f));try{await Ee("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch{}},[]),r=y.useCallback(async l=>s({ids:l},c=>l.includes(c.id)),[s]),o=y.useCallback(async()=>s({all:!0},()=>!0),[s]),i=n.filter(l=>l.readAt===null).length;return{notifications:n,unreadCount:i,refresh:t,markRead:r,markAllRead:o}}const eY={turnComplete:To,permission:Vs,system:To,access:HP};function tY(){const n=q.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:r,markAllRead:o}=QZ(),[i,l]=y.useState(!1);let c;n[0]!==r?(c=function(S){r([S.id]),!(!S.dirName||!S.sessionId)&&(Ra(`${bf()}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1))},n[0]=r,n[1]=c):c=n[1];const u=c;let d;n[2]!==s?(d=N=>{l(N),N&&s()},n[2]=s,n[3]=d):d=n[3];const f=i?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=a.jsx(J,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(rg,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&a.jsx(Ue,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let x;n[10]!==p||n[11]!==g?(x=a.jsxs(Pa,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==o||n[15]!==t?(w=t>0&&a.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>void o(),children:[a.jsx(KP,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=o,n[15]=t,n[16]=w):w=n[16];let v;n[17]!==w?(v=a.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,w]}),n[17]=w,n[18]=v):v=n[18];let k;n[19]!==e||n[20]!==u?(k=a.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?a.jsx(Cn,{className:"min-h-40 p-6",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(rg,{})}),a.jsx(En,{children:"No notifications"}),a.jsx(Tn,{children:"Session updates will appear here."})]})}):a.jsx(pr,{children:e.map(N=>a.jsx(nY,{notification:N,onOpen:u},N.id))})}),n[19]=e,n[20]=u,n[21]=k):k=n[21];let j;n[22]!==v||n[23]!==k?(j=a.jsxs($a,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,k]}),n[22]=v,n[23]=k,n[24]=j):j=n[24];let _;return n[25]!==i||n[26]!==d||n[27]!==j||n[28]!==x?(_=a.jsxs(Ia,{open:i,onOpenChange:d,children:[x,j]}),n[25]=i,n[26]=d,n[27]=j,n[28]=x,n[29]=_):_=n[29],_}function nY(n){const e=q.c(38),{notification:t,onOpen:s}=n,r=t.readAt===null,o=!!(t.dirName&&t.sessionId),i=Date.now();let l;e[0]!==t.at?(l=new Date(t.at).getTime(),e[0]=t.at,e[1]=l):l=e[1];const c=Math.max(0,(i-l)/1e3),u=eY[t.kind]??To;let d;e[2]!==t||e[3]!==s?(d=()=>s(t),e[2]=t,e[3]=s,e[4]=d):d=e[4];const f=!o&&"cursor-default",m=r&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==u||e[11]!==g?(x=a.jsx(u,{className:g}),e[10]=u,e[11]=g,e[12]=x):x=e[12];const b=r?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=G("truncate text-xs",b),e[13]=b,e[14]=w):w=e[14];let v;e[15]!==t.title||e[16]!==w?(v=a.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=v):v=e[17];let k;e[18]!==c?(k=fx(c),e[18]=c,e[19]=k):k=e[19];let j;e[20]!==k?(j=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:k}),e[20]=k,e[21]=j):j=e[21];let _;e[22]!==v||e[23]!==j?(_=a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==t.body?(N=a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=N):N=e[26];let S;e[27]!==_||e[28]!==N?(S=a.jsxs("span",{className:"min-w-0 flex-1",children:[_,N]}),e[27]=_,e[28]=N,e[29]=S):S=e[29];let C;e[30]!==r?(C=r&&a.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=r,e[31]=C):C=e[31];let A;return e[32]!==S||e[33]!==C||e[34]!==d||e[35]!==p||e[36]!==x?(A=a.jsxs(tn,{onClick:d,className:p,children:[x,S,C]}),e[32]=S,e[33]=C,e[34]=d,e[35]=p,e[36]=x,e[37]=A):A=e[37],A}const sY=2e3;function ca(n){return`${n.toFixed(n<10?1:0)}%`}function Bd(n){return`${n.toFixed(0)} MB`}function rY(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function oY(n){return n<=0?null:n>=1024*1024?`${(n/1024/1024).toFixed(1)} MB/s`:n>=1024?`${(n/1024).toFixed(1)} KB/s`:`${n.toFixed(0)} B/s`}function iY(n){const e=q.c(44),{metric:t,onKill:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];let o;e[2]!==t.pid?(o=a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==t.suspectedLeak?(i=t.suspectedLeak&&a.jsx(Ue,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=i):i=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&a.jsx(Ue,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==r||e[10]!==o||e[11]!==i||e[12]!==l?(c=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r,o,i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=l,e[13]=c):c=e[13];let u;e[14]!==t.command?(u=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=u):u=e[15];let d;e[16]!==c||e[17]!==u?(d=a.jsxs("div",{className:"min-w-0 flex-1",children:[c,u]}),e[16]=c,e[17]=u,e[18]=d):d=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&a.jsx(J,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=ca(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=a.jsx("div",{className:p,children:h}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let x;e[30]!==t.memoryMb?(x=Bd(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=fx(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let v;e[37]!==g||e[38]!==w?(v=a.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=v):v=e[39];let k;return e[40]!==v||e[41]!==d||e[42]!==f?(k=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[d,f,v]}),e[40]=v,e[41]=d,e[42]=f,e[43]=k):k=e[43],k}function aY(n){return n.name==="Server"?"API, file watching, session streams, and agent I/O":n.name==="Renderer"?"React rendering, markdown, layout, and animations":n.name==="GPU"?"Compositing, animation, and visual effects":n.name==="App"?"Electron window and application lifecycle":n.type}function lY(n,e,t=0){return t>0?t===1?'1 agent process outside Cogpit looks leaked. See "Agent processes" below.':`${t} agent processes outside Cogpit look leaked. See "Agent processes" below.`:n<5?"Cogpit is currently idle. Leave this open while the power spike happens.":e?e.name==="Server"?"The server is doing the most work. Compare the activity and API lists below to find the hot loop.":e.name==="Renderer"?"The renderer is doing the most work, which points to repeated UI rendering, layout, or animation.":e.name==="GPU"?"The GPU process is doing the most work, which points to continuous compositing or visual effects.":`${e.name} is currently the busiest Cogpit process.`:"The server is active. The lists below show its busiest recent work."}function J_(n){const e=q.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=aY(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=ca(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=Bd(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function yw(n){const e=q.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(cY)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function cY(n,e){const t=oY(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(Qt,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:rY(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Ue,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function uY(n){const e=q.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(dY).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:ca(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function dY(n){return ca(n)}function fY(n){var me,ue,ce,xe;const e=q.c(135),{open:t,onOpenChange:s}=n,[r,o]=y.useState(null),[i,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[u,d]=y.useState(c),[f,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,b]=Kr();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Te;if(g.current)return;g.current=!0,h(!0);const pe=Ee("/api/performance").then(bY),he=((Te=window.electronPerformance)==null?void 0:Te.getSnapshot())??Promise.resolve(null),[be,we]=await Promise.allSettled([pe,he]),ve=be.status==="fulfilled"?be.value:null,Se=we.status==="fulfilled"?we.value:null;if(ve&&l(ve),Se&&o(Se),!ve&&!Se)m("Performance data is unavailable.");else{m(null);const Ae=Se&&Se.processes.length>0?Se.processes.reduce(xY,0):(ve==null?void 0:ve.cpuPercent)??0;d(ze=>[...ze.slice(-29),Ae])}g.current=!1,h(!1)},e[1]=w):w=e[1];const v=w;let k,j;e[2]!==t?(k=()=>{if(!t)return;v();const pe=window.setInterval(()=>void v(),sY);return()=>window.clearInterval(pe)},j=[t,v],e[2]=t,e[3]=k,e[4]=j):(k=e[3],j=e[4]),y.useEffect(k,j);let _,N,S,C,A,T,I,E,P,R,L,O,$,M,D,F,z,B,U;if(e[5]!==x||e[6]!==b||e[7]!==r||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==i){const pe=[...(r==null?void 0:r.processes)??[]].sort(gY),he=pe.length>0?pe.reduce(hY,0):(i==null?void 0:i.cpuPercent)??0,be=pe[0];let we;e[33]!==((me=i==null?void 0:i.system)==null?void 0:me.processes)?(we=((ue=i==null?void 0:i.system)==null?void 0:ue.processes)??[],e[33]=(ce=i==null?void 0:i.system)==null?void 0:ce.processes,e[34]=we):we=e[34],I=we;const ve=((xe=i==null?void 0:i.system)==null?void 0:xe.suspectedLeakCount)??0,Se=ve>0||he>=80?"High":he>=15?"Active":"Idle";let Te;e[35]===Symbol.for("react.memo_cache_sentinel")?(Te=async rt=>{try{await Ee("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[rt]})}),await new Promise(pY)}catch{}v()},e[35]=Te):Te=e[35],T=Te;let Ae;e[36]!==b||e[37]!==r||e[38]!==u||e[39]!==i?(Ae=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:r,server:i,cpuHistory:u},null,2))},e[36]=b,e[37]=r,e[38]=u,e[39]=i,e[40]=Ae):Ae=e[40];const ze=Ae;A=Ys,$=t,M=s,C=Xs,R="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let De;e[41]===Symbol.for("react.memo_cache_sentinel")?(De=a.jsx(Js,{children:"Power & activity monitor"}),e[41]=De):De=e[41];const Le=Se==="High"?"destructive":"secondary";let Ce;e[42]!==Se||e[43]!==Le?(Ce=a.jsxs("div",{className:"flex items-center gap-2",children:[De,a.jsx(Ue,{variant:Le,children:Se})]}),e[42]=Se,e[43]=Le,e[44]=Ce):Ce=e[44];let Be;e[45]===Symbol.for("react.memo_cache_sentinel")?(Be=a.jsx(Qs,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=Be):Be=e[45];let We;e[46]!==Ce?(We=a.jsxs("div",{className:"min-w-0 flex-1",children:[Ce,Be]}),e[46]=Ce,e[47]=We):We=e[47];let He;e[48]===Symbol.for("react.memo_cache_sentinel")?(He=()=>void v(),e[48]=He):He=e[48];const _e=p&&"animate-spin";let Re;e[49]!==_e?(Re=G(_e),e[49]=_e,e[50]=Re):Re=e[50];let tt;e[51]!==Re?(tt=a.jsx(Fn,{"data-icon":"inline-start",className:Re}),e[51]=Re,e[52]=tt):tt=e[52];let Xe;e[53]!==p||e[54]!==tt?(Xe=a.jsxs(J,{variant:"outline",size:"sm",onClick:He,disabled:p,children:[tt,"Refresh"]}),e[53]=p,e[54]=tt,e[55]=Xe):Xe=e[55];const Ne=!i&&!r;let Ve;e[56]!==x?(Ve=x?a.jsx(Ht,{"data-icon":"inline-start"}):a.jsx(Cs,{"data-icon":"inline-start"}),e[56]=x,e[57]=Ve):Ve=e[57];const ye=x?"Copied":"Copy data";let $e;e[58]!==ze||e[59]!==Ne||e[60]!==Ve||e[61]!==ye?($e=a.jsxs(J,{variant:"outline",size:"sm",onClick:ze,disabled:Ne,children:[Ve,ye]}),e[58]=ze,e[59]=Ne,e[60]=Ve,e[61]=ye,e[62]=$e):$e=e[62];let qe;e[63]!==Xe||e[64]!==$e?(qe=a.jsxs("div",{className:"flex shrink-0 gap-1",children:[Xe,$e]}),e[63]=Xe,e[64]=$e,e[65]=qe):qe=e[65],e[66]!==We||e[67]!==qe?(L=a.jsx(to,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[We,qe]})}),e[66]=We,e[67]=qe,e[68]=L):L=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Qt,{}),e[69]=O):O=e[69],S=Cc,P="min-h-0 min-w-0 flex-1",B="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&a.jsx(wt,{variant:"destructive",children:a.jsx(_t,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Ke;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ke=a.jsx(dr,{children:"Current load"}),e[72]=Ke):Ke=e[72];const fe=he>=80&&"text-destructive";let ke;e[73]!==fe?(ke=G("font-mono text-lg font-semibold tabular-nums",fe),e[73]=fe,e[74]=ke):ke=e[74];const Ge=a.jsxs(ur,{children:[Ke,a.jsx(fr,{children:lY(he,be,ve)}),a.jsx(Dz,{children:a.jsxs("span",{className:ke,children:[ca(he)," CPU"]})})]});let Je;e[75]!==u?(Je=a.jsx(Os,{children:a.jsx(uY,{values:u})}),e[75]=u,e[76]=Je):Je=e[76],e[77]!==Ge||e[78]!==Je?(E=a.jsxs(Rs,{size:"sm",children:[Ge,Je]}),e[77]=Ge,e[78]=Je,e[79]=E):E=e[79],N=Rs,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsxs(ur,{children:[a.jsx(dr,{children:"Processes"}),a.jsx(fr,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],_=Os,D=pe.length>0?pe.map(mY):i?a.jsx(J_,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:i.cpuPercent,memoryMb:i.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=b,e[7]=r,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=p,e[13]=i,e[14]=_,e[15]=N,e[16]=S,e[17]=C,e[18]=A,e[19]=T,e[20]=I,e[21]=E,e[22]=P,e[23]=R,e[24]=L,e[25]=O,e[26]=$,e[27]=M,e[28]=D,e[29]=F,e[30]=z,e[31]=B,e[32]=U}else _=e[14],N=e[15],S=e[16],C=e[17],A=e[18],T=e[19],I=e[20],E=e[21],P=e[22],R=e[23],L=e[24],O=e[25],$=e[26],M=e[27],D=e[28],F=e[29],z=e[30],B=e[31],U=e[32];let W;e[81]!==_||e[82]!==D?(W=a.jsx(_,{children:D}),e[81]=_,e[82]=D,e[83]=W):W=e[83];let V;e[84]!==N||e[85]!==W||e[86]!==F||e[87]!==z?(V=a.jsxs(N,{size:F,children:[z,W]}),e[84]=N,e[85]=W,e[86]=F,e[87]=z,e[88]=V):V=e[88];let H;e[89]!==T||e[90]!==I?(H=I.length>0&&a.jsxs(Rs,{size:"sm",children:[a.jsxs(ur,{children:[a.jsx(dr,{children:"Agent processes"}),a.jsx(fr,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),a.jsx(Os,{children:I.map((pe,he)=>a.jsxs("div",{children:[he>0&&a.jsx(Qt,{}),a.jsx(iY,{metric:pe,onKill:be=>void T(be)})]},pe.pid))})]}),e[89]=T,e[90]=I,e[91]=H):H=e[91];let K;e[92]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(dr,{children:"Server activity"}),e[92]=K):K=e[92];const Z=(i==null?void 0:i.sampleWindowSeconds)??10;let Y;e[93]!==Z?(Y=a.jsxs(ur,{children:[K,a.jsxs(fr,{children:["File checks, streams, and agent work over the last ",Z," seconds."]})]}),e[93]=Z,e[94]=Y):Y=e[94];let X;e[95]!==(i==null?void 0:i.activities)?(X=(i==null?void 0:i.activities)??[],e[95]=i==null?void 0:i.activities,e[96]=X):X=e[96];let ee;e[97]!==X?(ee=a.jsx(Os,{children:a.jsx(yw,{metrics:X,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=X,e[98]=ee):ee=e[98];let Q;e[99]!==Y||e[100]!==ee?(Q=a.jsxs(Rs,{size:"sm",children:[Y,ee]}),e[99]=Y,e[100]=ee,e[101]=Q):Q=e[101];let ne;e[102]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsxs(ur,{children:[a.jsx(dr,{children:"API activity"}),a.jsx(fr,{children:"Requests ranked by recent frequency and time."})]}),e[102]=ne):ne=e[102];let te;e[103]!==(i==null?void 0:i.requests)?(te=(i==null?void 0:i.requests)??[],e[103]=i==null?void 0:i.requests,e[104]=te):te=e[104];let re;e[105]!==te?(re=a.jsxs(Rs,{size:"sm",children:[ne,a.jsx(Os,{children:a.jsx(yw,{metrics:te,emptyLabel:"No API requests in this sample."})})]}),e[105]=te,e[106]=re):re=e[106];let oe;e[107]!==Q||e[108]!==re?(oe=a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Q,re]}),e[107]=Q,e[108]=re,e[109]=oe):oe=e[109];let ie;e[110]!==i?(ie=i&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",ca(i.eventLoopPercent)," · heap ",Bd(i.memory.heapUsedMb)," · RSS ",Bd(i.memory.rssMb)]}),e[110]=i,e[111]=ie):ie=e[111];let ae;e[112]!==E||e[113]!==V||e[114]!==H||e[115]!==oe||e[116]!==ie||e[117]!==B||e[118]!==U?(ae=a.jsxs("div",{className:B,children:[U,E,V,H,oe,ie]}),e[112]=E,e[113]=V,e[114]=H,e[115]=oe,e[116]=ie,e[117]=B,e[118]=U,e[119]=ae):ae=e[119];let de;e[120]!==S||e[121]!==P||e[122]!==ae?(de=a.jsx(S,{className:P,children:ae}),e[120]=S,e[121]=P,e[122]=ae,e[123]=de):de=e[123];let le;e[124]!==C||e[125]!==R||e[126]!==L||e[127]!==O||e[128]!==de?(le=a.jsxs(C,{className:R,children:[L,O,de]}),e[124]=C,e[125]=R,e[126]=L,e[127]=O,e[128]=de,e[129]=le):le=e[129];let se;return e[130]!==A||e[131]!==$||e[132]!==M||e[133]!==le?(se=a.jsx(A,{open:$,onOpenChange:M,children:le}),e[130]=A,e[131]=$,e[132]=M,e[133]=le,e[134]=se):se=e[134],se}function mY(n,e){return a.jsxs("div",{children:[e>0&&a.jsx(Qt,{}),a.jsx(J_,{metric:n})]},n.pid)}function pY(n){return setTimeout(n,1e3)}function hY(n,e){return n+e.cpuPercent}function gY(n,e){return e.cpuPercent-n.cpuPercent}function xY(n,e){return n+e.cpuPercent}async function bY(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function vY(n){return`${n.title??`Pull request #${n.number}`}
|
|
128
|
+
`)[0];return l.length>lw?`${l.slice(0,lw)}...`:l}function PG(n,e,t){for(let s=e;s>=0;s--){const r=n[s];if(!r)continue;const o=IG(r,t);if(o)return{index:s,text:o}}return null}function $G(n){const e=n.getBoundingClientRect().top;let t=null,s=0;for(const l of n.querySelectorAll(TG)){const c=l.getBoundingClientRect().top;if(c>e+aw)break;t=l,s=c}if(!t)return null;const r=Number(t.dataset.turnIndex);if(!Number.isInteger(r))return null;const o=t.querySelector(A_);return(o?o.getBoundingClientRect().bottom>e+aw:s+AG>e)?null:r}const RG=y.memo(function(e){const t=q.c(23),{session:s,scrollContainerRef:r}=e,[o,i]=y.useState(null);let l,c;t[0]!==r||t[1]!==s.sessionId?(l=()=>{const j=r.current;if(!j)return;let _=null;const N=()=>{_=null;const T=$G(j);i(I=>T===null?null:(I==null?void 0:I.sessionId)===s.sessionId&&I.index===T?I:{sessionId:s.sessionId,index:T})},S=()=>{_===null&&(_=requestAnimationFrame(N))};i(null),j.addEventListener("scroll",S,{passive:!0});const C=new MutationObserver(S);C.observe(j,{childList:!0,subtree:!0});const A=new ResizeObserver(S);return A.observe(j),j.firstElementChild&&A.observe(j.firstElementChild),S(),()=>{j.removeEventListener("scroll",S),C.disconnect(),A.disconnect(),_!==null&&cancelAnimationFrame(_)}},c=[r,s.sessionId],t[0]=r,t[1]=s.sessionId,t[2]=l,t[3]=c):(l=t[2],c=t[3]),y.useEffect(l,c);const u=_a();let d;e:{if(!o||o.sessionId!==s.sessionId){d=null;break e}let j;t[4]!==u||t[5]!==s.turns||t[6]!==o.index?(j=PG(s.turns,o.index,u),t[4]=u,t[5]=s.turns,t[6]=o.index,t[7]=j):j=t[7],d=j}const f=d;if(!f)return null;let m;t[8]!==f.index||t[9]!==r?(m=()=>{const j=r.current;if(!j)return;const _=j.querySelector(`[data-turn-index="${f.index}"]`),N=(_==null?void 0:_.querySelector(A_))??_;if(!N)return;const S=j.scrollTop+N.getBoundingClientRect().top-j.getBoundingClientRect().top;j.scrollTo({top:Math.max(0,S),behavior:"smooth"})},t[8]=f.index,t[9]=r,t[10]=m):m=t[10];const p=m,h=`Scroll to turn ${f.index+1} prompt`;let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Rj,{"data-icon":"inline-start"}),t[11]=g):g=t[11];const x=f.index+1;let b;t[12]!==x?(b=a.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["Turn ",x]}),t[12]=x,t[13]=b):b=t[13];let w;t[14]!==f.text?(w=a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground/80",children:f.text}),t[14]=f.text,t[15]=w):w=t[15];let v;t[16]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx(dc,{"data-icon":"inline-end",className:"ml-auto"}),t[16]=v):v=t[16];let k;return t[17]!==f.text||t[18]!==p||t[19]!==h||t[20]!==b||t[21]!==w?(k=a.jsxs(J,{type:"button",variant:"outline",size:"sm","aria-label":h,title:f.text,className:"motion-slide-down-in absolute left-1/2 top-12 z-20 h-9 max-w-[calc(100%-5rem)] -translate-x-1/2 justify-start gap-2 rounded-full bg-popover px-3 text-left shadow-sm",onClick:p,children:[g,b,w,v]}),t[17]=f.text,t[18]=p,t[19]=h,t[20]=b,t[21]=w,t[22]=k):k=t[22],k});function Ug({path:n,dirName:e,command:t}){return Bo()?(console.warn("[open-terminal] unavailable for remote devices"),!1):!n&&!e?(console.warn("[open-terminal] no project path available"),!1):(Ee("/api/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,dirName:e,...t?{command:t}:{}})}).then(s=>{s.ok||s.json().then(r=>console.error("[open-terminal]",r.error)).catch(()=>{})}).catch(s=>console.error("[open-terminal] fetch failed:",s)),!0)}const OG={five_hour:"5-hour",seven_day:"weekly",seven_day_opus:"weekly Opus",seven_day_sonnet:"weekly Sonnet",seven_day_overage_included:"weekly",overage:"spend"},LG=1440*60*1e3;function MG(n){return(n&&OG[n])??"usage"}function zG(n){if(n===null)return null;const e=new Date(n*1e3);if(Number.isNaN(e.getTime()))return null;const t=e.getTime()-Date.now()>LG;return e.toLocaleString(void 0,{...t?{weekday:"short"}:{},hour:"numeric",minute:"2-digit"})}function DG(n){const e=q.c(33),{block:t,dirName:s,fileName:r,cwd:o,terminal:i}=n;let l,c;e[0]!==o||e[1]!==s||e[2]!==r?(l=hs(s),c=ox(l.kind,vd(r),o??void 0),e[0]=o,e[1]=s,e[2]=r,e[3]=l,e[4]=c):(l=e[3],c=e[4]);const u=c;let d;e[5]!==t.resetsAt?(d=zG(t.resetsAt),e[5]=t.resetsAt,e[6]=d):d=e[6];const f=d,m=t.lowPriority&&l.capabilities.lowPriorityInTerminal;let p;e[7]!==m||e[8]!==i?(p=m&&i&&!Bo(),e[7]=m,e[8]=i,e[9]=p):p=e[9];const h=p;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Eo,{}),e[10]=g):g=e[10];const x=l.displayName;let b;e[11]!==t.limit?(b=MG(t.limit),e[11]=t.limit,e[12]=b):b=e[12];let w;e[13]!==l.displayName||e[14]!==b?(w=a.jsxs(Vt,{children:[x," hit its ",b," limit"]}),e[13]=l.displayName,e[14]=b,e[15]=w):w=e[15];const v=f?`Resets at ${f}. `:"";let k;e[16]!==u||e[17]!==m?(k=m?a.jsxs(a.Fragment,{children:["It can keep this session going before then at lower priority, spending your weekly allowance to do it — a mode that exists only in its own terminal. Resume there with ",a.jsx("code",{className:"font-mono",children:u}),"."]}):a.jsx(a.Fragment,{children:"Nothing here can lift this one; the session continues once the allowance refills."}),e[16]=u,e[17]=m,e[18]=k):k=e[18];let j;e[19]!==v||e[20]!==k?(j=a.jsxs("span",{children:[v,k]}),e[19]=v,e[20]=k,e[21]=j):j=e[21];let _;e[22]!==h||e[23]!==u||e[24]!==o||e[25]!==s?(_=h&&a.jsx(J,{size:"sm",variant:"outline",onClick:()=>Ug({path:o??void 0,dirName:s,command:u}),children:"Open in terminal"}),e[22]=h,e[23]=u,e[24]=o,e[25]=s,e[26]=_):_=e[26];let N;e[27]!==j||e[28]!==_?(N=a.jsxs(_t,{className:"flex flex-col items-start gap-2",children:[j,_]}),e[27]=j,e[28]=_,e[29]=N):N=e[29];let S;return e[30]!==N||e[31]!==w?(S=a.jsxs(wt,{role:"status",className:"rounded-none border-x-0 border-t-0 px-4 py-2",children:[g,w,N]}),e[30]=N,e[31]=w,e[32]=S):S=e[32],S}function FG(n){const e=q.c(14),{block:t,showCursor:s}=n;if(t.blockType==="tool_use"){const l=t.toolName??"tool";let c;return e[0]!==l?(c=a.jsxs("div",{className:"text-xs text-muted-foreground italic py-1",children:["Preparing ",l,"…"]}),e[0]=l,e[1]=c):c=e[1],c}if(t.blockType==="thinking"){if(!t.text)return null;let l;e[2]!==s?(l=s&&a.jsx(cw,{}),e[2]=s,e[3]=l):l=e[3];let c;return e[4]!==t.text||e[5]!==l?(c=a.jsxs("div",{className:"my-2 whitespace-pre-wrap break-words border-l pl-3 text-sm italic leading-relaxed text-muted-foreground",children:[t.text,l]}),e[4]=t.text,e[5]=l,e[6]=c):c=e[6],c}if(!t.text)return null;let r;e[7]!==t.text?(r=a.jsx(G5,{text:t.text}),e[7]=t.text,e[8]=r):r=e[8];let o;e[9]!==s?(o=s&&a.jsx(cw,{}),e[9]=s,e[10]=o):o=e[10];let i;return e[11]!==r||e[12]!==o?(i=a.jsxs("div",{className:"text-sm leading-relaxed break-words my-2",children:[r,o]}),e[11]=r,e[12]=o,e[13]=i):i=e[13],i}function cw(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsx("span",{className:"ml-0.5 inline-block h-[15px] w-[7px] rounded-[1px] bg-foreground/70 align-text-bottom"}),n[0]=e):e=n[0],e}const UG=y.memo(function(){const e=q.c(9),t=k0();let s,r,o,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{const c=gq(t);if(c.length===0){i=null;break e}const u=new Map;s="px-4",r="streaming-turn-overlay",o=c.map(d=>{const f=u.get(d.messageId)??0;u.set(d.messageId,f+1);const m=d.blocks.reduce(BG,-1);return a.jsx("div",{children:d.blocks.map((p,h)=>a.jsx(FG,{block:p,showCursor:!d.stopped&&h===m},p.index))},`${d.messageId}:${f}`)})}e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i}else s=e[1],r=e[2],o=e[3],i=e[4];if(i!==Symbol.for("react.early_return_sentinel"))return i;let l;return e[5]!==s||e[6]!==r||e[7]!==o?(l=a.jsx("div",{className:s,"data-testid":r,children:o}),e[5]=s,e[6]=r,e[7]=o,e[8]=l):l=e[8],l});function BG(n,e,t){return e.blockType!=="tool_use"&&e.text?t:n}class I_ extends y.Component{constructor(t){super(t);Ze(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("ErrorBoundary caught:",t,s.componentStack)}render(){return this.state.hasError?a.jsx("div",{className:"flex justify-center p-8",children:a.jsxs(wt,{variant:"destructive",className:"max-w-md has-data-[slot=alert-action]:pr-2.5",children:[a.jsx(_r,{}),a.jsx(Vt,{children:a.jsx("h3",{children:this.props.fallbackMessage||"Something went wrong"})}),this.state.error&&a.jsx(_t,{className:"font-mono text-xs",children:this.state.error.message}),a.jsx(Ao,{className:"static col-start-2 mt-2",children:a.jsxs(J,{variant:"outline",size:"sm",onClick:this.handleRetry,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Try again"]})})]})}):this.props.children}}const uw="find-in-session-highlight",lp="find-in-session-active";function WG(n){const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let s;for(;s=t.nextNode();)s.nodeValue&&s.nodeValue.trim().length>0&&e.push(s);return e}const qG=y.forwardRef(function(e,t){const s=q.c(63),{scrollContainerRef:r}=e,[o,i]=y.useState(!1),[l,c]=y.useState("");let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],s[0]=u):u=s[0];const[d,f]=y.useState(u),[m,p]=y.useState(-1),h=y.useRef(null);let g;s[1]!==r?(g=()=>{const te=r.current;if(!te)return;te.querySelectorAll(`mark.${uw}`).forEach(VG)},s[1]=r,s[2]=g):g=s[2];const x=g;let b;s[3]!==x||s[4]!==r?(b=te=>{if(x(),!te||!r.current){f([]),p(-1);return}const re=r.current,oe=WG(re),ie=te.toLowerCase(),ae=[];for(const de of oe){const le=de.nodeValue||"",se=le.toLowerCase();let me=0;const ue=[];for(;;){const he=se.indexOf(ie,me);if(he===-1)break;ue.push(he),me=he+1}if(ue.length===0)continue;const ce=de.parentNode;if(!ce)continue;const xe=document.createDocumentFragment();let pe=0;for(const he of ue){he>pe&&xe.appendChild(document.createTextNode(le.slice(pe,he)));const be=document.createElement("mark");be.className=uw,be.textContent=le.slice(he,he+te.length),xe.appendChild(be),ae.push(be),pe=he+te.length}pe<le.length&&xe.appendChild(document.createTextNode(le.slice(pe))),ce.replaceChild(xe,de)}f(ae),ae.length>0?(p(0),ae[0].classList.add(lp),ae[0].scrollIntoView({block:"center",behavior:"smooth"})):p(-1)},s[3]=x,s[4]=r,s[5]=b):b=s[5];const w=b;let v;s[6]!==m||s[7]!==d?(v=te=>{if(d.length===0)return;m>=0&&m<d.length&&d[m].classList.remove(lp);const re=(te%d.length+d.length)%d.length;d[re].classList.add(lp),d[re].scrollIntoView({block:"center",behavior:"smooth"}),p(re)},s[6]=m,s[7]=d,s[8]=v):v=s[8];const k=v;let j;s[9]!==x?(j=()=>{i(!1),c(""),x(),f([]),p(-1)},s[9]=x,s[10]=j):j=s[10];const _=j;let N,S;s[11]!==_||s[12]!==o?(N=()=>({open:()=>{i(!0),requestAnimationFrame(()=>{var te;return(te=h.current)==null?void 0:te.focus()})},close:_,isOpen:o}),S=[_,o],s[11]=_,s[12]=o,s[13]=N,s[14]=S):(N=s[13],S=s[14]),y.useImperativeHandle(t,N,S);let C,A;s[15]!==w||s[16]!==l?(C=()=>{const te=setTimeout(()=>w(l),150);return()=>clearTimeout(te)},A=[l,w],s[15]=w,s[16]=l,s[17]=C,s[18]=A):(C=s[17],A=s[18]),y.useEffect(C,A);let T,I;s[19]!==x?(T=()=>()=>x(),I=[x],s[19]=x,s[20]=T,s[21]=I):(T=s[20],I=s[21]),y.useEffect(T,I);let E;s[22]!==m||s[23]!==k||s[24]!==_?(E=te=>{te.key==="Escape"?(te.preventDefault(),te.stopPropagation(),_()):te.key==="Enter"&&(te.preventDefault(),te.shiftKey?k(m-1):k(m+1))},s[22]=m,s[23]=k,s[24]=_,s[25]=E):E=s[25];const P=E;if(!o)return null;let R;s[26]===Symbol.for("react.memo_cache_sentinel")?(R=te=>c(te.target.value),s[26]=R):R=s[26];let L;s[27]!==P||s[28]!==l?(L=a.jsx(Vo,{ref:h,value:l,onChange:R,onKeyDown:P,placeholder:"Find in conversation","aria-label":"Find in conversation",autoFocus:!0}),s[27]=P,s[28]=l,s[29]=L):L=s[29];const O=l?d.length>0?`${m+1}/${d.length}`:"0/0":"";let $;s[30]!==O?($=a.jsx(jr,{align:"inline-end",children:a.jsx("span",{className:"min-w-12 text-center text-xs tabular-nums",children:O})}),s[30]=O,s[31]=$):$=s[31];let M;s[32]!==L||s[33]!==$?(M=a.jsxs(qo,{className:"w-64",children:[L,$]}),s[32]=L,s[33]=$,s[34]=M):M=s[34];let D;s[35]!==m||s[36]!==k?(D=()=>k(m-1),s[35]=m,s[36]=k,s[37]=D):D=s[37];const F=d.length===0,z=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let B;s[38]!==z?(B=G("text-muted-foreground",z),s[38]=z,s[39]=B):B=s[39];let U;s[40]===Symbol.for("react.memo_cache_sentinel")?(U=a.jsx(dc,{"data-icon":"inline-start"}),s[40]=U):U=s[40];let W;s[41]!==D||s[42]!==F||s[43]!==B?(W=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:D,disabled:F,className:B,"aria-label":"Previous match",children:U}),s[41]=D,s[42]=F,s[43]=B,s[44]=W):W=s[44];let V;s[45]!==m||s[46]!==k?(V=()=>k(m+1),s[45]=m,s[46]=k,s[47]=V):V=s[47];const H=d.length===0,K=d.length>0?"hover:text-foreground":"cursor-default opacity-40";let Z;s[48]!==K?(Z=G("text-muted-foreground",K),s[48]=K,s[49]=Z):Z=s[49];let Y;s[50]===Symbol.for("react.memo_cache_sentinel")?(Y=a.jsx(Wt,{"data-icon":"inline-start"}),s[50]=Y):Y=s[50];let X;s[51]!==V||s[52]!==H||s[53]!==Z?(X=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:V,disabled:H,className:Z,"aria-label":"Next match",children:Y}),s[51]=V,s[52]=H,s[53]=Z,s[54]=X):X=s[54];let ee;s[55]===Symbol.for("react.memo_cache_sentinel")?(ee=a.jsx(At,{"data-icon":"inline-start"}),s[55]=ee):ee=s[55];let Q;s[56]!==_?(Q=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:_,className:"text-muted-foreground hover:text-foreground","aria-label":"Close search",children:ee}),s[56]=_,s[57]=Q):Q=s[57];let ne;return s[58]!==M||s[59]!==W||s[60]!==X||s[61]!==Q?(ne=a.jsxs("div",{className:"motion-slide-down-in absolute right-4 top-12 z-30 flex items-center gap-1 rounded-lg border bg-popover p-2 text-popover-foreground shadow-sm",children:[M,W,X,Q]}),s[58]=M,s[59]=W,s[60]=X,s[61]=Q,s[62]=ne):ne=s[62],ne});function VG(n){const e=n.parentNode;e&&(e.replaceChild(document.createTextNode(n.textContent||""),n),e.normalize())}const P_=[1,2,3,4,5,6,7,8,9],ebe=["General","View","Tools"],sm=[{command:"commandPalette",label:"Open command palette",description:"Search actions, projects, and recent sessions",group:"General",defaultShortcut:{key:"k",modKey:!0}},{command:"keyboardShortcuts",label:"Show keyboard shortcuts",description:"Open this reference — only while no text field is focused",group:"General",defaultShortcut:{key:"?",shiftKey:!0}},{command:"newSession",label:"Start a new session",description:"Open the project picker for a new agent session",group:"General",defaultShortcut:{key:"n",platformChord:!0}},{command:"focusComposer",label:"Focus message composer",description:"Jump to the chat composer — only while no text field is focused",group:"General",defaultShortcut:{key:" "}},{command:"prevLiveSession",label:"Focus previous live session",description:"Move focus up the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowup",modKey:!0,shiftKey:!0}},{command:"nextLiveSession",label:"Focus next live session",description:"Move focus down the live session list; press Enter to open",group:"General",defaultShortcut:{key:"arrowdown",modKey:!0,shiftKey:!0}},{command:"recentSessionBack",label:"Previous recent session",description:"Step back through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0}},{command:"recentSessionForward",label:"Next recent session",description:"Step forward through recently opened sessions",group:"General",defaultShortcut:{key:"tab",ctrlKey:!0,shiftKey:!0}},{command:"toggleSidebar",label:"Toggle session sidebar",description:"Show or hide projects and sessions",group:"View",defaultShortcut:{key:"b",modKey:!0}},{command:"missionControl",label:"Toggle Mission Control",description:"Show every live session at once and answer whatever is blocked",group:"View",defaultShortcut:{doubleTapModifier:"mod"}},{command:"toggleStats",label:"Toggle session analytics",description:"Show or hide the right analytics panel",group:"View",defaultShortcut:{key:"b",modKey:!0,shiftKey:!0}},{command:"expandAll",label:"Expand all groups",description:"Expand conversation and tool groups without opening raw payloads",group:"View",defaultShortcut:{key:"e",modKey:!0}},{command:"expandToolPayloads",label:"Expand all tool payloads",description:"Expand tool inputs, results, and diffs with their containing groups",group:"View",defaultShortcut:{key:"e",modKey:!0,shiftKey:!0}},{command:"findInConversation",label:"Find in conversation",description:"Search the open conversation and step through matches",group:"View",defaultShortcut:{key:"f",modKey:!0}},{command:"integratedTerminal",label:"Toggle integrated terminal",description:"Open or collapse the in-app project terminal",group:"Tools",defaultShortcut:{key:"j",modKey:!0}},{command:"newIntegratedTerminal",label:"New integrated terminal",description:"Create another terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"n",modKey:!0}},{command:"closeIntegratedTerminal",label:"Close integrated terminal",description:"Close the active terminal while the integrated terminal is focused",group:"Tools",defaultShortcut:{key:"w",modKey:!0}},{command:"preview",label:"Toggle development preview",description:"Show or hide the in-app local server preview",group:"Tools",defaultShortcut:{key:"j",modKey:!0,shiftKey:!0}},{command:"previewRefresh",label:"Refresh development preview",description:"Reload the page while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"r",modKey:!0}},{command:"previewFocusUrl",label:"Focus preview URL",description:"Select the URL while the preview toolbar is focused",group:"Tools",defaultShortcut:{key:"l",modKey:!0}},{command:"previewZoomIn",label:"Zoom preview in",description:"Increase the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"=",modKey:!0}},{command:"previewZoomOut",label:"Zoom preview out",description:"Decrease the preview scale while its toolbar is focused",group:"Tools",defaultShortcut:{key:"-",modKey:!0}},{command:"previewResetZoom",label:"Reset preview zoom",description:"Return the preview to 100% while its toolbar is focused",group:"Tools",defaultShortcut:{key:"0",modKey:!0}},{command:"projectFiles",label:"Toggle project files",description:"Browse and edit files in the active project",group:"Tools",defaultShortcut:{key:"f",modKey:!0,shiftKey:!0}},{command:"projectFileSave",label:"Save project file",description:"Save the open file while the project file workspace is focused",group:"Tools",defaultShortcut:{key:"s",modKey:!0}},{command:"systemTerminal",label:"Open system terminal",description:"Open the project in your preferred terminal app",group:"Tools",defaultShortcut:{key:"t",platformChord:!0}},{command:"themeSelector",label:"Change theme",description:"Open the theme selector",group:"Tools",defaultShortcut:{key:"s",platformChord:!0}},...P_.map(n=>({command:`device.switch.${n}`,label:`Switch to device ${n}`,description:n===1?"Jump to this machine (the local device)":`Jump to the ${n}${n===2?"nd":n===3?"rd":"th"} device in the switcher`,group:"General",defaultShortcut:{key:String(n),platformChord:!0}})),{command:"device.cycle",label:"Cycle devices",description:"Switch to the next device in the switcher",group:"General",defaultShortcut:{key:"0",platformChord:!0}}],$_="cogpit-keybindings";let ei=null;function R_(n=typeof navigator>"u"?"":navigator.platform){return/Mac|iPhone|iPad/i.test(n)}function nc(n){const e=n.toLowerCase();return e==="esc"?"escape":e}function HG(n){if(!n||typeof n!="object")return!1;const e=n;return e.doubleTapModifier==="mod"||typeof e.key=="string"&&e.key.length>0}function P0(){if(ei)return ei;try{const n=localStorage.getItem($_);if(!n)return ei={};const e=JSON.parse(n);if(!e||typeof e!="object")return ei={};const t={};for(const s of sm){const r=e[s.command];HG(r)&&(t[s.command]=r)}return ei=t}catch{return ei={}}}function $0(n){ei=n;try{localStorage.setItem($_,JSON.stringify(n))}catch{}typeof window<"u"&&window.dispatchEvent(new Event("cogpit-keybindings-changed"))}function Mc(n){const e=sm.find(t=>t.command===n);if(!e)throw new Error(`Unknown keybinding command: ${n}`);return P0()[n]??e.defaultShortcut}function tbe(){return Object.fromEntries(sm.map(n=>[n.command,Mc(n.command)]))}function nbe(n,e){const t="doubleTapModifier"in e?{...e}:{...e,key:nc(e.key)};$0({...P0(),[n]:t})}function sbe(n){const e={...P0()};delete e[n],$0(e)}function rbe(){$0({})}function obe(n){return{key:nc(n.key),metaKey:n.metaKey||void 0,ctrlKey:n.ctrlKey||void 0,shiftKey:n.shiftKey||void 0,altKey:n.altKey||void 0}}function O_(n){const e=n;if(!e)return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||e.isContentEditable===!0}function Gt(n,e){const t=Mc(n);return"doubleTapModifier"in t||nc(e.key)!==nc(t.key)?!1:t.modKey?e.metaKey===e.ctrlKey?!1:e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey:t.platformChord?e.ctrlKey&&e.metaKey!==e.altKey&&e.shiftKey===!!t.shiftKey:e.metaKey===!!t.metaKey&&e.ctrlKey===!!t.ctrlKey&&e.shiftKey===!!t.shiftKey&&e.altKey===!!t.altKey}function Ci(n){return n===" "?"Space":n==="escape"?"Esc":n==="tab"?"Tab":n==="arrowup"?"↑":n==="arrowdown"?"↓":n==="arrowleft"?"←":n==="arrowright"?"→":n.length===1?n.toUpperCase():n}function KG(n){const e=R_();return"doubleTapModifier"in n?e?"Double ⌘":"Double Ctrl":n.modKey?e?`${n.shiftKey?"⇧":""}⌘${Ci(n.key)}`:`Ctrl+${n.shiftKey?"Shift+":""}${Ci(n.key)}`:n.platformChord?e?`⌃⌘${n.shiftKey?"⇧":""}${Ci(n.key)}`:`Ctrl+Alt+${n.shiftKey?"Shift+":""}${Ci(n.key)}`:e?`${n.ctrlKey?"⌃":""}${n.altKey?"⌥":""}${n.shiftKey?"⇧":""}${n.metaKey?"⌘":""}${Ci(n.key)}`:[n.ctrlKey?"Ctrl":null,n.altKey?"Alt":null,n.shiftKey?"Shift":null,n.metaKey?"Meta":null,Ci(n.key)].filter(Boolean).join("+")}function Qu(n){return KG(Mc(n))}function dw(n){if("doubleTapModifier"in n)return[`double-tap:${n.doubleTapModifier}`];const e=(t,s,r,o)=>`${nc(n.key)}|${t}|${s}|${r}|${o}`;return n.modKey?[e(!0,!1,!!n.shiftKey,!!n.altKey),e(!1,!0,!!n.shiftKey,!!n.altKey)]:n.platformChord?[e(!0,!0,!!n.shiftKey,!1),e(!1,!0,!!n.shiftKey,!0)]:[e(!!n.metaKey,!!n.ctrlKey,!!n.shiftKey,!!n.altKey)]}function ibe(n,e){const t=new Set(dw(n));return sm.find(s=>s.command!==e&&dw(Mc(s.command)).some(r=>t.has(r)))??null}function fw(n){return"doubleTapModifier"in Mc(n)?R_()?"Meta":"Control":null}const GG=P_.map(n=>`device.switch.${n}`),ZG="device.cycle";function YG(n){const e=GG.findIndex(t=>Gt(t,n));return e===-1?null:e+1}function XG(n){return Gt(ZG,n)}const Bg="cogpit:find-in-conversation",rm=y.memo(function(e){const t=q.c(87),{searchInputRef:s,hasTodos:r,hasMore:o,isLoadingOlder:i,onLoadMore:l,mobileSearchOpen:c,onMobileSearchClose:u}=e,d=c===void 0?!1:c,{state:f,dispatch:m,isMobile:p}=ln(),{session:h,sessionSource:g,rateLimit:x,permissions:b,isSubAgentView:w}=yt(),v=xn("terminal"),{chat:k,scroll:j}=Of(),{searchQuery:_}=f,{pendingMessages:N}=k,{chatScrollRef:S,scrollEndRef:C,observeChatContent:A,handleScroll:T,canScrollDown:I,scrollToBottomInstant:E,initialScrollDone:P}=j,R=y.useRef(null);let L;t[0]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{var Se;return(Se=R.current)==null?void 0:Se.open()},t[0]=L):L=t[0];const O=L;let $,M;t[1]===Symbol.for("react.memo_cache_sentinel")?($=()=>{const Se=function(Ae){Gt("findInConversation",Ae)&&(Ae.preventDefault(),O())};return window.addEventListener("keydown",Se),window.addEventListener(Bg,O),()=>{window.removeEventListener("keydown",Se),window.removeEventListener(Bg,O)}},M=[O],t[1]=$,t[2]=M):($=t[1],M=t[2]),y.useEffect($,M);let D,F;t[3]!==p||t[4]!==d||t[5]!==s?(D=()=>{!p||!d||requestAnimationFrame(()=>{var Se;return(Se=s.current)==null?void 0:Se.focus()})},F=[p,d,s],t[3]=p,t[4]=d,t[5]=s,t[6]=D,t[7]=F):(D=t[6],F=t[7]),y.useEffect(D,F);let z;t[8]!==m||t[9]!==u?(z=()=>{m({type:"SET_SEARCH_QUERY",value:""}),u==null||u()},t[8]=m,t[9]=u,t[10]=z):z=t[10];const B=z,U=h;let W;t[11]!==x||t[12]!==g?(W=x&&g?{block:x,dirName:g.dirName,fileName:g.fileName}:null,t[11]=x,t[12]=g,t[13]=W):W=t[13];const V=W,H=U.turns.length>0||N.length===0;let K;t[14]!==B||t[15]!==m||t[16]!==p||t[17]!==d||t[18]!==s||t[19]!==_?(K=p&&d&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b bg-background px-3 py-2",children:[a.jsxs(qo,{className:"h-9 flex-1",children:[a.jsx(Vo,{ref:s,value:_,onChange:Se=>m({type:"SET_SEARCH_QUERY",value:Se.target.value}),placeholder:"Search conversation...","aria-label":"Search conversation"}),a.jsx(jr,{align:"inline-start",children:a.jsx(ss,{})})]}),a.jsx(J,{variant:"ghost",size:"icon-sm",onClick:B,"aria-label":"Close conversation search",children:a.jsx(At,{"data-icon":"inline-start"})})]}),t[14]=B,t[15]=m,t[16]=p,t[17]=d,t[18]=s,t[19]=_,t[20]=K):K=t[20];let Z;t[21]!==v||t[22]!==U.cwd||t[23]!==p||t[24]!==b.send||t[25]!==V?(Z=V&&a.jsx("div",{className:G("shrink-0",!p&&"pt-10"),children:a.jsx(DG,{...V,cwd:U.cwd,terminal:v&&b.send})}),t[21]=v,t[22]=U.cwd,t[23]=p,t[24]=b.send,t[25]=V,t[26]=Z):Z=t[26];let Y;t[27]!==S?(Y=a.jsx(qG,{ref:R,scrollContainerRef:S}),t[27]=S,t[28]=Y):Y=t[28];let X;t[29]!==S||t[30]!==U?(X=a.jsx(RG,{session:U,scrollContainerRef:S}),t[29]=S,t[30]=U,t[31]=X):X=t[31];const ee=p&&"mobile-scroll";let Q;t[32]!==ee?(Q=G("h-full overflow-x-hidden overflow-y-auto",ee),t[32]=ee,t[33]=Q):Q=t[33];let ne;t[34]!==p||t[35]!==V?(ne=p?"px-3 py-3 pb-5":G("mx-auto w-full max-w-[var(--chat-width)] px-6",V?"pt-4":"pt-14"),t[34]=p,t[35]=V,t[36]=ne):ne=t[36];let te;t[37]!==r||t[38]!==p?(te=p?void 0:{paddingBottom:`max(var(--session-footer-height, 0px), ${r?12:8}rem)`},t[37]=r,t[38]=p,t[39]=te):te=t[39];let re;t[40]!==S||t[41]!==o||t[42]!==P||t[43]!==i||t[44]!==l||t[45]!==H?(re=H&&a.jsx(_G,{chatScrollRef:S,hasMore:o,isLoadingOlder:i,pagingEnabled:P,onLoadMore:l}),t[40]=S,t[41]=o,t[42]=P,t[43]=i,t[44]=l,t[45]=H,t[46]=re):re=t[46];let oe,ie;t[47]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsx(UG,{}),ie=a.jsx(BK,{}),t[47]=oe,t[48]=ie):(oe=t[47],ie=t[48]);const ae=b.send&&!w;let de;t[49]!==U.sessionId||t[50]!==U.turns||t[51]!==p||t[52]!==N||t[53]!==ae?(de=a.jsx(I5,{sessionId:U.sessionId,turns:U.turns,pendingMessages:N,canManage:ae,isMobile:p}),t[49]=U.sessionId,t[50]=U.turns,t[51]=p,t[52]=N,t[53]=ae,t[54]=de):de=t[54];let le;t[55]!==C?(le=a.jsx("div",{ref:C}),t[55]=C,t[56]=le):le=t[56];let se;t[57]!==re||t[58]!==de||t[59]!==le?(se=a.jsxs(I_,{fallbackMessage:"Failed to render conversation timeline",children:[re,oe,ie,de,le]}),t[57]=re,t[58]=de,t[59]=le,t[60]=se):se=t[60];let me;t[61]!==A||t[62]!==ne||t[63]!==te||t[64]!==se?(me=a.jsx("div",{ref:A,className:ne,style:te,children:se}),t[61]=A,t[62]=ne,t[63]=te,t[64]=se,t[65]=me):me=t[65];let ue;t[66]!==S||t[67]!==T||t[68]!==Q||t[69]!==me?(ue=a.jsx("div",{ref:S,onScroll:T,className:Q,children:me}),t[66]=S,t[67]=T,t[68]=Q,t[69]=me,t[70]=ue):ue=t[70];const ce=I?"opacity-100 scale-100":"opacity-0 scale-75 pointer-events-none",xe=p?"right-3 bottom-3":"right-5 bottom-5";let pe;t[71]!==ce||t[72]!==xe?(pe=G("absolute rounded-full shadow-sm transition-[opacity,transform] duration-200 ease-out active:scale-95",ce,xe),t[71]=ce,t[72]=xe,t[73]=pe):pe=t[73];let he;t[74]===Symbol.for("react.memo_cache_sentinel")?(he=a.jsx(WP,{"data-icon":"inline-start"}),t[74]=he):he=t[74];let be;t[75]!==E||t[76]!==pe?(be=a.jsx(J,{size:"icon",className:pe,onClick:E,"aria-label":"Scroll to bottom",children:he}),t[75]=E,t[76]=pe,t[77]=be):be=t[77];let we;t[78]!==Y||t[79]!==X||t[80]!==ue||t[81]!==be?(we=a.jsxs("div",{className:"relative min-h-0 flex-1",children:[Y,X,ue,be]}),t[78]=Y,t[79]=X,t[80]=ue,t[81]=be,t[82]=we):we=t[82];let ve;return t[83]!==Z||t[84]!==we||t[85]!==K?(ve=a.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[K,Z,we]}),t[83]=Z,t[84]=we,t[85]=K,t[86]=ve):ve=t[86],ve});function JG({open:n,onOpenChange:e,trigger:t,title:s,description:r,confirmLabel:o,destructive:i=!1,onConfirm:l}){const[c,u]=y.useState(!1),[d,f]=y.useState(null);function m(h){c||(f(null),e(h))}async function p(){u(!0),f(null);try{f(await l())}finally{u(!1)}}return a.jsxs(qx,{open:n,onOpenChange:m,children:[t&&a.jsx(Pz,{render:t}),a.jsxs(Vx,{size:"sm",children:[a.jsxs(Hx,{children:[a.jsx(Gx,{children:s}),a.jsx(Zx,{children:r})]}),d&&a.jsx(jo,{className:"text-center",children:d}),a.jsxs(Kx,{children:[a.jsx(Xx,{disabled:c,children:"Cancel"}),a.jsxs(Yx,{variant:i?"destructive":"default",disabled:c,onClick:()=>void p(),children:[c&&a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),o]})]})]})]})}function QG(n){const e=q.c(21),{children:t,error:s,busy:r,saveLabel:o,onCancel:i,onSave:l,className:c}=n;let u;e[0]!==c?(u=G("flex flex-col gap-3 border-t px-3 py-3",c),e[0]=c,e[1]=u):u=e[1];let d;e[2]!==s?(d=s&&a.jsx(jo,{children:s}),e[2]=s,e[3]=d):d=e[3];let f;e[4]!==i?(f=a.jsx(J,{variant:"outline",size:"sm",onClick:i,children:"Cancel"}),e[4]=i,e[5]=f):f=e[5];let m;e[6]!==r||e[7]!==o?(m=r?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):o,e[6]=r,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==r||e[10]!==l||e[11]!==m?(p=a.jsx(J,{size:"sm",disabled:r,onClick:l,children:m}),e[9]=r,e[10]=l,e[11]=m,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==p?(h=a.jsxs("div",{className:"flex justify-end gap-1.5",children:[f,p]}),e[13]=f,e[14]=p,e[15]=h):h=e[15];let g;return e[16]!==t||e[17]!==u||e[18]!==d||e[19]!==h?(g=a.jsxs("div",{className:u,children:[t,d,h]}),e[16]=t,e[17]=u,e[18]=d,e[19]=h,e[20]=g):g=e[20],g}const Wg="cogpit-devices-changed",L_="cogpit:devices-changed";function M_(n){typeof n.connectionRevision=="number"&&D$(n.id,n.connectionRevision)}function z_(n,e,t=!1){window.dispatchEvent(new CustomEvent(Wg,{detail:{deviceId:n,connectionRevision:e,removed:t}}));try{localStorage.setItem(L_,JSON.stringify({deviceId:n,connectionRevision:e,removed:t,nonce:`${Date.now()}:${Math.random()}`}))}catch{}}function mw(n){M_(n),z_(n.id,n.connectionRevision)}function pw(n){const e=Dt();e!==Tt&&!n.some(t=>t.id===e)&&Ks(Tt)}function cp(n,e=""){return`/api/hub/devices/${encodeURIComponent(n)}${e}`}function D_(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.version;if(typeof t=="string")return t}}function eZ(n){const e=n.runtime.lastHello;if(e&&typeof e=="object"){const t=e.signIn;if(t==="account"||t==="password")return t}}function La({enabled:n=!0}={}){const[e,t]=y.useState([]),[s,r]=y.useState(!0),[o,i]=y.useState(()=>Dt()),l=y.useRef(0),c=y.useCallback(async()=>{const g=++l.current;if(!n){t([]),r(!1);return}try{const x=await po("/api/hub/devices");if(x.status===403&&g===l.current&&pw([]),!x.ok)return;const b=await cr(x);if(g!==l.current)return;const w=Array.isArray(b==null?void 0:b.devices)?b.devices:[];for(const v of w)M_(v);t(w),pw(w)}catch{}finally{g===l.current&&r(!1)}},[n]);y.useEffect(()=>{c()},[c]),y.useEffect(()=>{const g=()=>i(Dt()),x=()=>void c(),b=k=>{if(k.key===L_){try{const j=JSON.parse(k.newValue??"null");(j==null?void 0:j.removed)===!0&&typeof j.deviceId=="string"&&Dt()===j.deviceId&&Ks(Tt)}catch{}c()}},w=()=>{l.current+=1,t([]),r(!0),c()},v=()=>{l.current+=1,t([]),r(!1)};return window.addEventListener("cogpit-device-changed",g),window.addEventListener("popstate",g),window.addEventListener(Wg,x),window.addEventListener("storage",b),window.addEventListener("cogpit-auth-changed",w),window.addEventListener("cogpit-identity-changed",w),window.addEventListener("cogpit-auth-required",v),()=>{window.removeEventListener("cogpit-device-changed",g),window.removeEventListener("popstate",g),window.removeEventListener(Wg,x),window.removeEventListener("storage",b),window.removeEventListener("cogpit-auth-changed",w),window.removeEventListener("cogpit-identity-changed",w),window.removeEventListener("cogpit-auth-required",v)}},[c]);const u=y.useMemo(()=>o===Tt?void 0:e.find(g=>g.id===o),[e,o]),d=y.useCallback(async(g,x,b,w)=>{try{const v=await po("/api/hub/devices/probe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:g,port:x,allowLocalTunnel:b,tls:w})}),k=await cr(v);return(k==null?void 0:k.ok)===!0&&k.hello?{ok:!0,hello:k.hello}:{ok:!1,code:(k==null?void 0:k.code)??"UNREACHABLE",error:typeof(k==null?void 0:k.error)=="string"?k.error:void 0}}catch{return{ok:!1,code:"UNREACHABLE",error:"Could not reach the device."}}},[]),f=y.useCallback(async g=>{try{const x=await po("/api/hub/devices",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(g)}),b=await cr(x);if(x.ok&&(b!=null&&b.device)){const w=b.device;return mw(w),{ok:!0,device:w}}return{ok:!1,code:(b==null?void 0:b.code)??"ERROR",error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not add the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not add the device."}}},[]),m=y.useCallback(async(g,x)=>{try{const b=await po(cp(g),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(x)}),w=await cr(b);if(b.ok&&(w!=null&&w.device)){const v=w.device;return mw(v),{ok:!0,device:v}}return{ok:!1,code:(w==null?void 0:w.code)??"ERROR",error:typeof(w==null?void 0:w.error)=="string"?w.error:"Could not update the device."}}catch{return{ok:!1,code:"ERROR",error:"Could not update the device."}}},[]),p=y.useCallback(async g=>{try{const x=await po(cp(g),{method:"DELETE"});if(x.ok)return Dt()===g&&Ks(Tt),z_(g,void 0,!0),{ok:!0};const b=await cr(x);return{ok:!1,error:typeof(b==null?void 0:b.error)=="string"?b.error:"Could not remove the device."}}catch{return{ok:!1,error:"Could not remove the device."}}},[]),h=y.useCallback(async g=>{try{const x=await po(cp(g,"/test"),{method:"POST"});return await cr(x)??{ok:!1,reachable:!1,code:"UNREACHABLE"}}catch{return{ok:!1,reachable:!1,code:"UNREACHABLE"}}},[]);return{devices:e,activeDeviceId:o,activeDevice:u,loading:s,refresh:c,probe:d,addDevice:f,updateDevice:m,removeDevice:p,testDevice:h}}const F_="3.3.2",U_={version:F_},hw=U_.version,tZ=19384,nZ=443,sZ=450,rZ=typeof navigator<"u"&&/Mac|iPhone|iPad/i.test(navigator.platform||""),oZ=`${rZ?"⌘⇧":"Ctrl+Shift+"}1–9`,iZ=new Set(["BAD_PASSWORD","PASSWORD_REQUIRED","USERNAME_REQUIRES_PASSWORD"]),aZ=new Set(["ACCOUNT_REFUSED"]);function pu(n){const e=n.trim(),t=/^https:\/\//i.test(e),s=e.replace(/^https?:\/\//i,"").replace(/\/.*$/,""),r=/^(.+):(\d+)$/.exec(s),o=r?r[1]:s,i=r?Number(r[2]):void 0;return t?{host:o,port:i,tls:!0}:{host:o,port:i}}function lZ(n,e,t){if(n.ok){if(n.hello.signIn==="account"&&n.hello.setupRequired===!0)return{tone:"info",text:"Reachable server — finish its setup before adding it here."};if(n.hello.signIn!=="account"&&n.hello.networkAccess===!1)return{tone:"warn",text:"Cogpit is running but network access is disabled — enable it in that device's settings."};if(n.hello.configured===!1)return{tone:"info",text:"Reachable — this device hasn't finished setup yet and will show its setup screen."};const s=n.hello.name?` "${n.hello.name}"`:"",r=n.hello.version?` (v${n.hello.version})`:"";return{tone:"ok",text:`Found Cogpit${s}${r}.`}}switch(n.code){case"UNREACHABLE":return{tone:"error",text:`Can't reach ${e}:${t}. Is Cogpit running with network access enabled?`};case"LEGACY_NO_HELLO":return{tone:"error",text:"That Cogpit is too old for multi-device — update it."};case"NOT_COGPIT":return{tone:"error",text:"Something responded, but it isn't Cogpit."};case"SELF_ADD":return{tone:"error",text:"That's this machine."};default:return{tone:"error",text:n.error??"Could not reach the device."}}}const B_={ok:"text-success",warn:"text-warning",info:"text-info",error:"text-destructive"};function cZ(n){const e=q.c(10),{tone:t}=n,s=B_[t];let r;e[0]!==s?(r=G("size-3.5 shrink-0",s),e[0]=s,e[1]=r):r=e[1];const o=r;if(t==="ok"){let l;return e[2]!==o?(l=a.jsx(eo,{"data-icon":"inline-start",className:o}),e[2]=o,e[3]=l):l=e[3],l}if(t==="warn"){let l;return e[4]!==o?(l=a.jsx(_r,{"data-icon":"inline-start",className:o}),e[4]=o,e[5]=l):l=e[5],l}if(t==="info"){let l;return e[6]!==o?(l=a.jsx(Fn,{"data-icon":"inline-start",className:o}),e[6]=o,e[7]=l):l=e[7],l}let i;return e[8]!==o?(i=a.jsx(Fo,{"data-icon":"inline-start",className:o}),e[8]=o,e[9]=i):i=e[9],i}const uZ={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"};function dZ(n){const e=q.c(103),{device:t,onRename:s,onCredentials:r,onRemove:o,onTest:i}=n,[l,c]=y.useState(!1),[u,d]=y.useState(t.name),[f,m]=y.useState(!1),[p,h]=y.useState(t.username??""),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,k]=y.useState(!1),[j,_]=y.useState(null);let N,S;e[0]!==t.name?(N=()=>{d(t.name)},S=[t.name],e[0]=t.name,e[1]=N,e[2]=S):(N=e[1],S=e[2]),y.useEffect(N,S);let C,A;e[3]!==t.username?(C=()=>{h(t.username??"")},A=[t.username],e[3]=t.username,e[4]=C,e[5]=A):(C=e[4],A=e[5]),y.useEffect(C,A);let T;e[6]!==t?(T=D_(t),e[6]=t,e[7]=T):T=e[7];const I=T,E=I!==void 0&&I!==hw;let P;e[8]!==t?(P=eZ(t),e[8]=t,e[9]=P):P=e[9];const R=P==="account";let L;e[10]!==t.id||e[11]!==t.name||e[12]!==u||e[13]!==s?(L=async function(){const ze=u.trim();if(!ze||ze===t.name){c(!1),d(t.name);return}_("rename"),await s(t.id,ze),_(null),c(!1)},e[10]=t.id,e[11]=t.name,e[12]=u,e[13]=s,e[14]=L):L=e[14];const O=L;let $;e[15]!==g||e[16]!==p||e[17]!==t.auth||e[18]!==t.id||e[19]!==t.username||e[20]!==r?($=async function(){const ze=p.trim(),De=t.username??"",Le=ze!==De,Ce=g.length>0;if(!Le&&!Ce){m(!1),x(""),w(null);return}if(t.auth==="none"&&!Ce){w("Enter a password when adding an account to an unauthenticated device.");return}const Be={};Le&&(Be.username=ze||null),Ce&&(Be.password=g),_("credentials"),w(null);const We=await r(t.id,Be);if(_(null),!We.ok){w(We.error);return}m(!1),x("")},e[15]=g,e[16]=p,e[17]=t.auth,e[18]=t.id,e[19]=t.username,e[20]=r,e[21]=$):$=e[21];const M=$,D=`Status: ${t.runtime.authState}`,F=uZ[t.runtime.authState];let z;e[22]!==F?(z=G("size-2 shrink-0 rounded-full",F),e[22]=F,e[23]=z):z=e[23];let B;e[24]!==z||e[25]!==D?(B=a.jsx("span",{"aria-label":D,className:z}),e[24]=z,e[25]=D,e[26]=B):B=e[26];let U;e[27]!==t.auth||e[28]!==t.name||e[29]!==l||e[30]!==u||e[31]!==O||e[32]!==E||e[33]!==I?(U=l?a.jsx(zn,{value:u,autoFocus:!0,"aria-label":`Rename ${t.name}`,onChange:Ae=>d(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&O(),Ae.key==="Escape"&&(c(!1),d(t.name))},onBlur:()=>void O(),className:"h-6 text-sm"}):a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"truncate text-sm text-foreground",children:t.name}),I&&a.jsxs("span",{className:G("shrink-0 font-mono text-xs",E?"text-warning":"text-muted-foreground"),title:E?`Device runs v${I}; hub runs v${hw}`:void 0,children:["v",I,E&&" ≠ hub"]}),t.auth==="none"&&a.jsx(Ue,{variant:"secondary",children:"Unauthenticated"})]}),e[27]=t.auth,e[28]=t.name,e[29]=l,e[30]=u,e[31]=O,e[32]=E,e[33]=I,e[34]=U):U=e[34];const W=t.tls?"https://":"";let V;e[35]!==t.host||e[36]!==t.port||e[37]!==W?(V=a.jsxs("span",{className:"truncate font-mono text-xs text-muted-foreground",children:[W,t.host,":",t.port]}),e[35]=t.host,e[36]=t.port,e[37]=W,e[38]=V):V=e[38];let H;e[39]!==R||e[40]!==t.username?(H=t.username?a.jsxs("span",{className:"truncate text-xs text-muted-foreground",title:t.username,children:["Account: ",t.username]}):R?a.jsx("span",{className:"text-xs text-warning",children:"Account not configured"}):null,e[39]=R,e[40]=t.username,e[41]=H):H=e[41];let K;e[42]!==U||e[43]!==V||e[44]!==H?(K=a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[U,V,H]}),e[42]=U,e[43]=V,e[44]=H,e[45]=K):K=e[45];const Z=`Re-test ${t.name}`,Y=j==="test";let X;e[46]!==t.id||e[47]!==i?(X=async()=>{_("test"),await i(t.id),_(null)},e[46]=t.id,e[47]=i,e[48]=X):X=e[48];const ee=j==="test"&&"animate-spin";let Q;e[49]!==ee?(Q=G(ee),e[49]=ee,e[50]=Q):Q=e[50];let ne;e[51]!==Q?(ne=a.jsx(Fn,{"data-icon":"inline-start",className:Q}),e[51]=Q,e[52]=ne):ne=e[52];let te;e[53]!==Z||e[54]!==Y||e[55]!==X||e[56]!==ne?(te=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":Z,disabled:Y,onClick:X,children:ne}),e[53]=Z,e[54]=Y,e[55]=X,e[56]=ne,e[57]=te):te=e[57];const re=`Edit account for ${t.name}`;let oe;e[58]!==t.username?(oe=()=>{m(fZ),h(t.username??""),x(""),w(null)},e[58]=t.username,e[59]=oe):oe=e[59];let ie;e[60]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsx(qP,{"data-icon":"inline-start"}),e[60]=ie):ie=e[60];let ae;e[61]!==re||e[62]!==oe?(ae=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":re,onClick:oe,children:ie}),e[61]=re,e[62]=oe,e[63]=ae):ae=e[63];const de=`Rename ${t.name}`;let le,se;e[64]===Symbol.for("react.memo_cache_sentinel")?(le=()=>c(!0),se=a.jsx(gr,{"data-icon":"inline-start"}),e[64]=le,e[65]=se):(le=e[64],se=e[65]);let me;e[66]!==de?(me=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":de,onClick:le,children:se}),e[66]=de,e[67]=me):me=e[67];const ue=`Remove ${t.name}`;let ce;e[68]===Symbol.for("react.memo_cache_sentinel")?(ce=a.jsx(mf,{"data-icon":"inline-start"}),e[68]=ce):ce=e[68];let xe;e[69]!==ue?(xe=a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":ue,className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:ce}),e[69]=ue,e[70]=xe):xe=e[70];let pe;e[71]!==t.name?(pe=a.jsxs(a.Fragment,{children:["Remove ",t.name,"?"]}),e[71]=t.name,e[72]=pe):pe=e[72];let he;e[73]!==t.id||e[74]!==o?(he=async()=>(await o(t.id),null),e[73]=t.id,e[74]=o,e[75]=he):he=e[75];let be;e[76]!==v||e[77]!==xe||e[78]!==pe||e[79]!==he?(be=a.jsx(JG,{open:v,onOpenChange:k,trigger:xe,title:pe,description:"This device will disappear from Cogpit. You can add it again later.",confirmLabel:"Remove device",destructive:!0,onConfirm:he}),e[76]=v,e[77]=xe,e[78]=pe,e[79]=he,e[80]=be):be=e[80];let we;e[81]!==te||e[82]!==ae||e[83]!==me||e[84]!==be?(we=a.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[te,ae,me,be]}),e[81]=te,e[82]=ae,e[83]=me,e[84]=be,e[85]=we):we=e[85];let ve;e[86]!==B||e[87]!==K||e[88]!==we?(ve=a.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[B,K,we]}),e[86]=B,e[87]=K,e[88]=we,e[89]=ve):ve=e[89];let Se;e[90]!==j||e[91]!==b||e[92]!==g||e[93]!==p||e[94]!==t.id||e[95]!==t.name||e[96]!==t.username||e[97]!==f||e[98]!==M?(Se=f&&a.jsxs(QG,{error:b,busy:j==="credentials",saveLabel:"Save account",onCancel:()=>{m(!1),h(t.username??""),x(""),w(null)},onSave:()=>void M(),children:[a.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[a.jsxs(sn,{children:[a.jsxs(rn,{htmlFor:`device-username-${t.id}`,children:["Username ",a.jsx("span",{className:"text-muted-foreground/60",children:"(account sign-in)"})]}),a.jsx(zn,{id:`device-username-${t.id}`,"aria-label":`Username for ${t.name}`,value:p,onChange:Ae=>h(Ae.target.value),placeholder:"Leave empty for password-only auth",autoComplete:"off",spellCheck:!1})]}),a.jsxs(sn,{children:[a.jsxs(rn,{htmlFor:`device-password-${t.id}`,children:["New password ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),a.jsx(zn,{id:`device-password-${t.id}`,"aria-label":`New password for ${t.name}`,type:"password",value:g,onChange:Ae=>x(Ae.target.value),placeholder:"Leave blank to keep the stored password",autoComplete:"new-password"})]})]}),t.username&&p.trim()===""&&a.jsx("p",{className:"text-xs text-warning",children:"Clearing the username switches this device back to password-only authentication."})]}),e[90]=j,e[91]=b,e[92]=g,e[93]=p,e[94]=t.id,e[95]=t.name,e[96]=t.username,e[97]=f,e[98]=M,e[99]=Se):Se=e[99];let Te;return e[100]!==ve||e[101]!==Se?(Te=a.jsxs("div",{className:"rounded-lg border bg-card",children:[ve,Se]}),e[100]=ve,e[101]=Se,e[102]=Te):Te=e[102],Te}function fZ(n){return!n}function W_(n){var qe,Ke;const e=q.c(115),{open:t,initialMode:s,onClose:r}=n,{devices:o,refresh:i,probe:l,addDevice:c,updateDevice:u,removeDevice:d,testDevice:f}=La(),[m,p]=y.useState(""),[h,g]=y.useState(""),[x,b]=y.useState(""),[w,v]=y.useState(""),[k,j]=y.useState(!1),[_,N]=y.useState(!1),[S,C]=y.useState(null),[A,T]=y.useState(!1),[I,E]=y.useState(null),P=y.useRef(null),R=y.useRef(0);let L,O;e[0]!==s||e[1]!==t?(L=()=>{t&&(p(""),g(""),b(""),v(""),j(!1),N(!1),C(null),E(null),s==="add"&&requestAnimationFrame(()=>{var fe;return(fe=P.current)==null?void 0:fe.focus()}))},O=[t,s],e[0]=s,e[1]=t,e[2]=L,e[3]=O):(L=e[2],O=e[3]),y.useEffect(L,O);let $;e[4]!==k||e[5]!==h||e[6]!==l?($=async()=>{const{host:fe,port:ke,tls:Ge}=pu(h);if(!fe){C(null),N(!1);return}const Je=R.current=R.current+1;N(!0);const rt=await l(fe,ke,k,Ge);Je===R.current&&(C({...lZ(rt,fe,ke??(Ge?nZ:tZ)),hello:rt.ok?rt.hello:void 0}),N(!1))},e[4]=k,e[5]=h,e[6]=l,e[7]=$):$=e[7];const M=$;let D,F;e[8]!==h||e[9]!==t||e[10]!==M?(D=()=>{if(!t)return;if(!pu(h).host){C(null),N(!1);return}const fe=window.setTimeout(()=>void M(),sZ);return()=>window.clearTimeout(fe)},F=[t,h,M],e[8]=h,e[9]=t,e[10]=M,e[11]=D,e[12]=F):(D=e[11],F=e[12]),y.useEffect(D,F);const z=((qe=S==null?void 0:S.hello)==null?void 0:qe.signIn)==="account",B=z&&((Ke=S==null?void 0:S.hello)==null?void 0:Ke.setupRequired)===!0,U=z||!k;let W;e:{if(A){W=!1;break e}if(!pu(h).host){W=!1;break e}if(_||!S){W=!1;break e}if(B){W=!1;break e}if(U&&!w){W=!1;break e}if(z&&!x.trim()){W=!1;break e}if((S==null?void 0:S.tone)==="error"){W=!1;break e}W=!0}const V=W;let H;e[13]!==c||e[14]!==k||e[15]!==U||e[16]!==h||e[17]!==m||e[18]!==r||e[19]!==w||e[20]!==z||e[21]!==x?(H=async function(){const{host:ke,port:Ge,tls:Je}=pu(h);if(!ke)return;T(!0),E(null);const rt=await c({name:m.trim()||void 0,host:ke,port:Ge,tls:Je,username:z?x.trim():void 0,password:U&&w||void 0,allowLocalTunnel:k});if(T(!1),rt.ok){r(),Ks(rt.device.id);return}E({field:aZ.has(rt.code)?"username":iZ.has(rt.code)?"password":"host",message:rt.error})},e[13]=c,e[14]=k,e[15]=U,e[16]=h,e[17]=m,e[18]=r,e[19]=w,e[20]=z,e[21]=x,e[22]=H):H=e[22];const K=H;let Z;e[23]!==u?(Z=async(fe,ke)=>{await u(fe,{name:ke})},e[23]=u,e[24]=Z):Z=e[24];const Y=Z;let X;e[25]!==d?(X=async fe=>{await d(fe)},e[25]=d,e[26]=X):X=e[26];const ee=X;let Q;e[27]!==i||e[28]!==f?(Q=async fe=>{await f(fe),await i()},e[27]=i,e[28]=f,e[29]=Q):Q=e[29];const ne=Q;let te;e[30]!==r?(te=fe=>{fe||r()},e[30]=r,e[31]=te):te=e[31];let re;e[32]===Symbol.for("react.memo_cache_sentinel")?(re=a.jsxs(to,{children:[a.jsx(Js,{children:"Devices"}),a.jsxs(Qs,{children:["Control another Cogpit device from here. The active device is chosen from the header switcher — ",oZ," jumps between devices."]})]}),e[32]=re):re=e[32];let oe;e[33]!==o||e[34]!==ee||e[35]!==Y||e[36]!==ne||e[37]!==u?(oe=o.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:o.map(fe=>a.jsx(dZ,{device:fe,onRename:Y,onCredentials:u,onRemove:ee,onTest:ne},fe.id))}),e[33]=o,e[34]=ee,e[35]=Y,e[36]=ne,e[37]=u,e[38]=oe):oe=e[38];let ie;e[39]===Symbol.for("react.memo_cache_sentinel")?(ie=a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(xr,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),a.jsx("p",{className:"text-sm font-medium text-foreground",children:"Add a device"})]}),e[39]=ie):ie=e[39];const ae=(I==null?void 0:I.field)==="host";let de,le;e[40]===Symbol.for("react.memo_cache_sentinel")?(de=a.jsx(rn,{htmlFor:"device-host",children:"Host"}),le=a.jsx(sa,{children:"Enter a local address or an HTTPS URL."}),e[40]=de,e[41]=le):(de=e[40],le=e[41]);let se;e[42]===Symbol.for("react.memo_cache_sentinel")?(se=fe=>{R.current=R.current+1,g(fe.target.value),b(""),C(null),E(null)},e[42]=se):se=e[42];let me;e[43]!==M?(me=()=>void M(),e[43]=M,e[44]=me):me=e[44];let ue;e[45]!==h||e[46]!==me?(ue=a.jsx(zn,{id:"device-host",ref:P,value:h,onChange:se,onBlur:me,placeholder:"192.168.1.42, my-mac.local:19384 or https://cogpit.example.com",spellCheck:!1,autoComplete:"off"}),e[45]=h,e[46]=me,e[47]=ue):ue=e[47];let ce;e[48]!==_?(ce=_&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-3.5 animate-spin"})," Checking device…"]}),e[48]=_,e[49]=ce):ce=e[49];let xe;e[50]!==S||e[51]!==_?(xe=!_&&S&&a.jsxs("p",{role:"status",className:G("flex items-center gap-1.5 text-xs",B_[S.tone]),children:[a.jsx(cZ,{tone:S.tone}),S.text]}),e[50]=S,e[51]=_,e[52]=xe):xe=e[52];let pe;e[53]!==I?(pe=(I==null?void 0:I.field)==="host"&&a.jsx(jo,{children:I.message}),e[53]=I,e[54]=pe):pe=e[54];let he;e[55]!==ae||e[56]!==ue||e[57]!==ce||e[58]!==xe||e[59]!==pe?(he=a.jsxs(sn,{"data-invalid":ae,children:[de,le,ue,ce,xe,pe]}),e[55]=ae,e[56]=ue,e[57]=ce,e[58]=xe,e[59]=pe,e[60]=he):he=e[60];let be;e[61]===Symbol.for("react.memo_cache_sentinel")?(be=a.jsxs(rn,{htmlFor:"device-name",children:["Name ",a.jsx("span",{className:"text-muted-foreground/60",children:"(optional)"})]}),e[61]=be):be=e[61];let we;e[62]===Symbol.for("react.memo_cache_sentinel")?(we=fe=>p(fe.target.value),e[62]=we):we=e[62];let ve;e[63]!==m?(ve=a.jsxs(sn,{children:[be,a.jsx(zn,{id:"device-name",value:m,onChange:we,placeholder:"Defaults to the device's own name"})]}),e[63]=m,e[64]=ve):ve=e[64];let Se;e[65]!==I||e[66]!==z||e[67]!==x?(Se=z&&a.jsxs(sn,{"data-invalid":(I==null?void 0:I.field)==="username",children:[a.jsx(rn,{htmlFor:"device-username",children:"Username"}),a.jsx(zn,{id:"device-username",value:x,onChange:fe=>b(fe.target.value),placeholder:"Account username",autoComplete:"username",spellCheck:!1}),a.jsx(sa,{children:"Requests through this hub act as this account on that server."}),(I==null?void 0:I.field)==="username"&&a.jsx(jo,{children:I.message})]}),e[65]=I,e[66]=z,e[67]=x,e[68]=Se):Se=e[68];let Te;e[69]!==U||e[70]!==w||e[71]!==I||e[72]!==z?(Te=U&&a.jsxs(sn,{"data-invalid":(I==null?void 0:I.field)==="password",children:[a.jsx(rn,{htmlFor:"device-password",children:"Password"}),a.jsx(zn,{id:"device-password",type:"password",value:w,onChange:fe=>v(fe.target.value),placeholder:z?"Password for that account":"Network access password for that device",autoComplete:z?"current-password":"off"}),(I==null?void 0:I.field)==="password"&&a.jsx(jo,{children:I.message})]}),e[69]=U,e[70]=w,e[71]=I,e[72]=z,e[73]=Te):Te=e[73];let Ae;e[74]!==he||e[75]!==ve||e[76]!==Se||e[77]!==Te?(Ae=a.jsxs(ka,{children:[he,ve,Se,Te]}),e[74]=he,e[75]=ve,e[76]=Se,e[77]=Te,e[78]=Ae):Ae=e[78];let ze;e[79]===Symbol.for("react.memo_cache_sentinel")?(ze=fe=>{R.current=R.current+1,j(fe===!0),C(null),E(null)},e[79]=ze):ze=e[79];let De;e[80]!==k?(De=a.jsx(VN,{id:"device-local-tunnel",name:"device-local-tunnel",checked:k,onCheckedChange:ze}),e[80]=k,e[81]=De):De=e[81];const Le=z?"":" — no password";let Ce;e[82]!==Le?(Ce=a.jsxs(rn,{htmlFor:"device-local-tunnel",children:["This is a local tunnel",Le]}),e[82]=Le,e[83]=Ce):Ce=e[83];let Be;e[84]!==De||e[85]!==Ce?(Be=a.jsxs(sn,{orientation:"horizontal",children:[De,Ce]}),e[84]=De,e[85]=Ce,e[86]=Be):Be=e[86];let We;e[87]!==k||e[88]!==z?(We=k&&a.jsxs(wt,{className:"border-warning/40 bg-warning/10 text-warning",children:[a.jsx(B1,{}),a.jsx(_t,{className:"text-warning",children:z?a.jsx(a.Fragment,{children:"The loopback address is allowed because the tunnel is local; account sign-in still applies."}):a.jsxs(a.Fragment,{children:["Traffic to this device is forwarded ",a.jsx("strong",{children:"unauthenticated"}),". Only use this for an SSH tunnel or another already-secured local channel."]})})]}),e[87]=k,e[88]=z,e[89]=We):We=e[89];let He;e[90]!==r?(He=a.jsx(J,{variant:"outline",onClick:r,children:"Close"}),e[90]=r,e[91]=He):He=e[91];const _e=!V;let Re;e[92]!==K?(Re=()=>void K(),e[92]=K,e[93]=Re):Re=e[93];let tt;e[94]!==A?(tt=A?a.jsxs(a.Fragment,{children:[a.jsx(vt,{"data-icon":"inline-start",className:"size-4 animate-spin"})," Adding…"]}):"Add device",e[94]=A,e[95]=tt):tt=e[95];let Xe;e[96]!==_e||e[97]!==Re||e[98]!==tt?(Xe=a.jsx(J,{disabled:_e,onClick:Re,children:tt}),e[96]=_e,e[97]=Re,e[98]=tt,e[99]=Xe):Xe=e[99];let Ne;e[100]!==He||e[101]!==Xe?(Ne=a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[He,Xe]}),e[100]=He,e[101]=Xe,e[102]=Ne):Ne=e[102];let Ve;e[103]!==Ae||e[104]!==Be||e[105]!==We||e[106]!==Ne?(Ve=a.jsxs("div",{className:"flex flex-col gap-4 border-t pt-4",children:[ie,Ae,Be,We,Ne]}),e[103]=Ae,e[104]=Be,e[105]=We,e[106]=Ne,e[107]=Ve):Ve=e[107];let ye;e[108]!==oe||e[109]!==Ve?(ye=a.jsxs(Xs,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl",children:[re,oe,Ve]}),e[108]=oe,e[109]=Ve,e[110]=ye):ye=e[110];let $e;return e[111]!==t||e[112]!==te||e[113]!==ye?($e=a.jsx(Ys,{open:t,onOpenChange:te,children:ye}),e[111]=t,e[112]=te,e[113]=ye,e[114]=$e):$e=e[114],$e}const mZ="Browsing folders needs a newer Cogpit on this machine.";async function q_(n){const e=await kl(n,`Request failed (${n.status})`);return new Error(n.status===404&&e==="Not found"?mZ:e)}async function pZ(n,e){const t=await Ee(n?`/api/folders?path=${encodeURIComponent(n)}`:"/api/folders",{signal:e});if(!t.ok)throw await q_(t);return await t.json()}async function hZ(n,e){const t=await os("/api/folders",{parent:n,name:e});if(!t.ok)throw await q_(t);return(await t.json()).path}function gZ(n,e=null){const t=xZ(n);if(e===null)return t;const s=o=>o.replace(/[\\/]+$/,""),r=t.findIndex(o=>s(o.path)===s(e));return r===-1?t:t.slice(r)}function xZ(n){const e=n.split(/[\\/]+/).filter(Boolean);let t,s,r;if(n.startsWith("\\\\")){const[o="",i="",...l]=e;t={label:`\\\\${o}\\${i}`,path:`\\\\${o}\\${i}\\`},s=l,r="\\"}else if(/^[a-z]:/i.test(n)){const[o="",...i]=e;t={label:o,path:`${o}\\`},s=i,r="\\"}else t={label:"/",path:"/"},s=e,r="/";return[t,...s.map((o,i)=>({label:o,path:t.path+s.slice(0,i+1).join(r)}))]}const qg="cogpit-browse-folders";function V_(){window.dispatchEvent(new Event(qg))}function bZ(n){return window.addEventListener(qg,n),()=>window.removeEventListener(qg,n)}const vZ=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-DhWTU3Op.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal})));function H_(n){const e=q.c(8),{onNewSession:t,onNewFolder:s,defaultAgentKind:r}=n,[o,i]=y.useState(null);let l,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>bZ(()=>i(!0)),c=[],e[0]=l,e[1]=c):(l=e[0],c=e[1]),y.useEffect(l,c),o===null)return null;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(!1),e[2]=u):u=e[2];let d;return e[3]!==r||e[4]!==s||e[5]!==t||e[6]!==o?(d=a.jsx(y.Suspense,{fallback:null,children:a.jsx(vZ,{open:o,onClose:u,onNewSession:t,onNewFolder:s,defaultAgentKind:r,currentProjectDirName:null,currentProjectCwd:null,initialView:"folders"})}),e[3]=r,e[4]=s,e[5]=t,e[6]=o,e[7]=d):d=e[7],d}const yZ=/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;function gw(n,e){if(!yZ.test(e))throw new Error(`Invalid Cogpit ${n} id "${e}"`)}function ho(n,e){return`${n}.${e}`}function wZ(n){const e=new Set,t=new Set,s=[];for(const r of n){if(gw("plugin",r.id),e.has(r.id))throw new Error(`Duplicate Cogpit plugin id "${r.id}"`);e.add(r.id);for(const o of r.workspacePanels??[]){gw("panel",o.id);const i=ho(r.id,o.id);if(t.has(i))throw new Error(`Duplicate Cogpit workspace panel id "${i}"`);t.add(i),s.push({...o,id:i,pluginId:r.id,localId:o.id})}}return s.sort((r,o)=>(r.order??100)-(o.order??100)||r.title.localeCompare(o.title))}function Gn({className:n,...e}){return a.jsx("div",{"data-slot":"skeleton",className:G("rounded-md bg-muted motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-200 motion-safe:ease-out motion-reduce:animate-none",n),...e})}const ti="cogpit",Et={worktrees:ho(ti,"worktrees"),projectFiles:ho(ti,"project-files"),browser:ho(ti,"browser"),fileChanges:ho(ti,"file-changes"),sessionInfo:ho(ti,"session-info"),crew:ho(ti,"crew")},SZ=y.lazy(()=>nt(()=>import("./CommandPaletteHost-DUZHK9Zh.js"),__vite__mapDeps([26,1,2,3,4])).then(n=>({default:n.CommandPaletteHost}))),kZ=y.lazy(()=>nt(()=>import("./index-D2Gn2VwC.js"),__vite__mapDeps([27,1,2,28,3,4])).then(n=>({default:n.ConfigDialog}))),jZ=y.lazy(()=>nt(()=>import("./KeyboardShortcutsDialog-DHxjcyzu.js"),__vite__mapDeps([29,1,2,3,4])).then(n=>({default:n.KeyboardShortcutsDialog}))),NZ=y.lazy(()=>nt(()=>import("./ProjectSwitcherModal-DhWTU3Op.js"),__vite__mapDeps([25,1,2,3,4])).then(n=>({default:n.ProjectSwitcherModal}))),CZ=y.lazy(()=>nt(()=>import("./ThemeSelectorModal-DbCAl7RY.js"),__vite__mapDeps([30,1,2,3,4])).then(n=>({default:n.ThemeSelectorModal})));function _Z(n){const e=q.c(131),{navigation:t,project:s,chrome:r}=n,{state:o,config:i,theme:l}=ln(),{session:c,sessionSource:u}=yt(),{devices:d,activeDeviceId:f}=La(),[m,p]=y.useState(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=ht("manageDevices"),e[0]=h):h=e[0];const g=h,x=jx(),b=o.mainView==="extension"?o.extensionViewId:null;let w;e[1]!==o.pendingCwd||e[2]!==o.pendingDirName?(w=o.pendingCwd??(o.pendingDirName?ms(o.pendingDirName):null),e[1]=o.pendingCwd,e[2]=o.pendingDirName,e[3]=w):w=e[3];const v=w,k=(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject??null,j=r.onKeyboardShortcutsOpenChange;let _,N;e[4]!==j?(_=()=>{const fe=function(Ge){Gt("keyboardShortcuts",Ge)&&(O_(document.activeElement)||(Ge.preventDefault(),j(!0)))};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)},N=[j],e[4]=j,e[5]=_,e[6]=N):(_=e[5],N=e[6]),y.useEffect(_,N);const S=f===Tt;let C;e[7]!==S?(C={id:Tt,name:"This machine",isLocal:!0,isActive:S},e[7]=S,e[8]=C):C=e[8];let A;if(e[9]!==f||e[10]!==d||e[11]!==C){let fe;e[13]!==f?(fe=ke=>({id:ke.id,name:ke.name,isLocal:!1,isActive:ke.id===f}),e[13]=f,e[14]=fe):fe=e[14],A=[C,...d.map(fe)],e[9]=f,e[10]=d,e[11]=C,e[12]=A}else A=e[12];const T=A,{openMainView:I,closeMainView:E}=t.panels;let P;if(e[15]!==E||e[16]!==x||e[17]!==I||e[18]!==b){let fe;e[20]!==E||e[21]!==I||e[22]!==b?(fe=ke=>{const Ge=ke.id===b;return{id:`main-view-${ke.id}`,label:`${Ge?"Close":"Open"} ${ke.label}`,keywords:ke.keywords,icon:ke.icon,onSelect:Ge?E:()=>I(ke.id)}},e[20]=E,e[21]=I,e[22]=b,e[23]=fe):fe=e[23],P=x.map(fe),e[15]=E,e[16]=x,e[17]=I,e[18]=b,e[19]=P}else P=e[19];const R=P;let L;e[24]!==c||e[25]!==(u==null?void 0:u.agentKind)||e[26]!==(u==null?void 0:u.dirName)?(L=()=>{if(!c)return;const fe=(u==null?void 0:u.agentKind)??an((u==null?void 0:u.dirName)??null);kf(ox(fe,c.sessionId,c.cwd))},e[24]=c,e[25]=u==null?void 0:u.agentKind,e[26]=u==null?void 0:u.dirName,e[27]=L):L=e[27];const O=L,$=EZ,M=r.processPanel,D=r.workflowsPanel,F=r.undoDialog,z=r.branchModal,B=i.claudeDir??"";let U;e[28]!==i.handleCloseConfigDialog||e[29]!==i.handleConfigSaved||e[30]!==i.showConfigDialog||e[31]!==B?(U=a.jsx(y.Suspense,{fallback:null,children:a.jsx(kZ,{open:i.showConfigDialog,currentPath:B,onClose:i.handleCloseConfigDialog,onSaved:i.handleConfigSaved})}),e[28]=i.handleCloseConfigDialog,e[29]=i.handleConfigSaved,e[30]=i.showConfigDialog,e[31]=B,e[32]=U):U=e[32];const W=(u==null?void 0:u.dirName)??o.pendingDirName??null,V=(c==null?void 0:c.cwd)??o.pendingCwd??null;let H;e[33]!==i.defaultAgentKind||e[34]!==t.onStartNewFolder||e[35]!==t.onStartNewSession||e[36]!==t.panels.handleCloseProjectSwitcher||e[37]!==t.panels.showProjectSwitcher||e[38]!==W||e[39]!==V?(H=a.jsx(y.Suspense,{fallback:null,children:a.jsx(NZ,{open:t.panels.showProjectSwitcher,onClose:t.panels.handleCloseProjectSwitcher,onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind,currentProjectDirName:W,currentProjectCwd:V})}),e[33]=i.defaultAgentKind,e[34]=t.onStartNewFolder,e[35]=t.onStartNewSession,e[36]=t.panels.handleCloseProjectSwitcher,e[37]=t.panels.showProjectSwitcher,e[38]=W,e[39]=V,e[40]=H):H=e[40];let K;e[41]!==i.defaultAgentKind||e[42]!==t.onStartNewFolder||e[43]!==t.onStartNewSession?(K=a.jsx(H_,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:i.defaultAgentKind}),e[41]=i.defaultAgentKind,e[42]=t.onStartNewFolder,e[43]=t.onStartNewSession,e[44]=K):K=e[44];let Z;e[45]!==t.panels.handleCloseThemeSelector||e[46]!==t.panels.showThemeSelector||e[47]!==l.setPreview||e[48]!==l.setTheme||e[49]!==l.theme?(Z=a.jsx(y.Suspense,{fallback:null,children:a.jsx(CZ,{open:t.panels.showThemeSelector,onClose:t.panels.handleCloseThemeSelector,currentTheme:l.theme,onSelectTheme:l.setTheme,onPreviewTheme:l.setPreview})}),e[45]=t.panels.handleCloseThemeSelector,e[46]=t.panels.showThemeSelector,e[47]=l.setPreview,e[48]=l.setTheme,e[49]=l.theme,e[50]=Z):Z=e[50];const Y=r.commandPaletteOpen,X=r.onCommandPaletteOpenChange,ee=t.actions.handleGoHome,Q=t.panels.handleOpenProjectSwitcher,ne=t.onOpenPaletteProject,te=t.actions.handleDashboardSelect,re=t.panels.handleToggleSidebar;let oe,ie,ae;e[51]!==t.panels?(oe=()=>t.panels.toggleWorkspacePanel(Et.sessionInfo),ie=()=>t.panels.toggleWorkspacePanel(Et.fileChanges),ae=()=>t.panels.toggleWorkspacePanel(Et.worktrees),e[51]=t.panels,e[52]=oe,e[53]=ie,e[54]=ae):(oe=e[52],ie=e[53],ae=e[54]);const de=t.panels.handleToggleMission,le=c?t.handlers.handleDuplicateSession:void 0,se=c?O:void 0,me=c?$:void 0,ue=ht("killAny")?r.onKillAll:void 0,ce=ht("configWrite")?t.panels.handleToggleConfig:void 0,xe=i.openConfigDialog;let pe;e[55]!==j?(pe=()=>j(!0),e[55]=j,e[56]=pe):pe=e[56];const he=s.currentCwd?s.onTogglePreview:void 0,be=ht("hostFiles")&&s.currentCwd?s.onToggleProjectFiles:void 0;let we;e[57]!==t.panels?(we=ht("browser")?()=>t.panels.toggleWorkspacePanel(Et.browser):void 0,e[57]=t.panels,e[58]=we):we=e[58];const ve=t.panels.handleToggleThemeSelector,Se=s.onOpenTerminal,Te=r.onFocusComposer,Ae=r.onExpandAll,ze=r.onExpandToolPayloads,De=r.onCollapseAll,Le=!!(c||o.pendingDirName);let Ce;e[59]!==v||e[60]!==(c==null?void 0:c.cwd)||e[61]!==(u==null?void 0:u.dirName)||e[62]!==o.dashboardProject||e[63]!==o.pendingDirName?(Ce=ht("terminal")&&!!((c==null?void 0:c.cwd)??v??(u==null?void 0:u.dirName)??o.pendingDirName??o.dashboardProject),e[59]=v,e[60]=c==null?void 0:c.cwd,e[61]=u==null?void 0:u.dirName,e[62]=o.dashboardProject,e[63]=o.pendingDirName,e[64]=Ce):Ce=e[64];const Be=!!c;let We;e[65]!==s.hasFileChanges?(We=ht("hostFiles")&&s.hasFileChanges,e[65]=s.hasFileChanges,e[66]=We):We=e[66];const He=t.panels.activeWorkspacePanel===Et.sessionInfo,_e=t.panels.activeWorkspacePanel===Et.browser,Re=t.panels.activeWorkspacePanel===Et.fileChanges,tt=t.panels.activeWorkspacePanel===Et.worktrees,Xe=o.mainView==="config",Ne=o.mainView==="mission",Ve=(c==null?void 0:c.cwd)??v??null;let ye;e[67]!==r.commandPaletteOpen||e[68]!==r.onCollapseAll||e[69]!==r.onCommandPaletteOpenChange||e[70]!==r.onExpandAll||e[71]!==r.onExpandToolPayloads||e[72]!==r.onFocusComposer||e[73]!==i.openConfigDialog||e[74]!==k||e[75]!==R||e[76]!==t.actions.handleDashboardSelect||e[77]!==t.actions.handleGoHome||e[78]!==t.onOpenPaletteProject||e[79]!==t.panels.handleOpenProjectSwitcher||e[80]!==t.panels.handleToggleMission||e[81]!==t.panels.handleToggleSidebar||e[82]!==t.panels.handleToggleThemeSelector||e[83]!==t.panels.showSidebar||e[84]!==T||e[85]!==s.launchTerminalRequest||e[86]!==s.onOpenTerminal||e[87]!==s.processPanel.addProcess||e[88]!==s.showProjectFiles||e[89]!==s.supportsWorktrees||e[90]!==oe||e[91]!==ie||e[92]!==ae||e[93]!==le||e[94]!==se||e[95]!==me||e[96]!==ue||e[97]!==ce||e[98]!==pe||e[99]!==he||e[100]!==be||e[101]!==we||e[102]!==Le||e[103]!==Ce||e[104]!==Be||e[105]!==We||e[106]!==He||e[107]!==_e||e[108]!==Re||e[109]!==tt||e[110]!==Xe||e[111]!==Ne||e[112]!==Ve?(ye=a.jsx(y.Suspense,{fallback:null,children:a.jsx(SZ,{open:Y,onOpenChange:X,onGoHome:ee,onNewSession:Q,onOpenProject:ne,onOpenSession:te,onToggleSidebar:re,onToggleStats:oe,onToggleFileChanges:ie,onToggleWorktrees:ae,onToggleMissionControl:de,extraActions:R,onDuplicateSession:le,onCopyResumeCommand:se,onFindInConversation:me,onKillAll:ue,onOpenConfig:ce,onOpenSettings:xe,onOpenKeyboardShortcuts:pe,onTogglePreview:he,onToggleProjectFiles:be,onToggleBrowser:we,onOpenTheme:ve,onOpenTerminal:Se,onOpenDevices:g?p:void 0,onSwitchDevice:Ks,devices:T,onFocusComposer:Te,onExpandAll:Ae,onExpandToolPayloads:ze,onCollapseAll:De,canFocusComposer:Le,canOpenTerminal:Ce,hasSession:Be,hasFileChanges:We,supportsWorktrees:s.supportsWorktrees,showSidebar:t.panels.showSidebar,showStats:He,showProjectFiles:s.showProjectFiles,showBrowser:_e,showFileChanges:Re,showWorktrees:tt,showConfig:Xe,showMission:Ne,currentProjectDirName:k,projectCwd:Ve,onProcessStarted:s.processPanel.addProcess,launchTerminalRequest:s.launchTerminalRequest})}),e[67]=r.commandPaletteOpen,e[68]=r.onCollapseAll,e[69]=r.onCommandPaletteOpenChange,e[70]=r.onExpandAll,e[71]=r.onExpandToolPayloads,e[72]=r.onFocusComposer,e[73]=i.openConfigDialog,e[74]=k,e[75]=R,e[76]=t.actions.handleDashboardSelect,e[77]=t.actions.handleGoHome,e[78]=t.onOpenPaletteProject,e[79]=t.panels.handleOpenProjectSwitcher,e[80]=t.panels.handleToggleMission,e[81]=t.panels.handleToggleSidebar,e[82]=t.panels.handleToggleThemeSelector,e[83]=t.panels.showSidebar,e[84]=T,e[85]=s.launchTerminalRequest,e[86]=s.onOpenTerminal,e[87]=s.processPanel.addProcess,e[88]=s.showProjectFiles,e[89]=s.supportsWorktrees,e[90]=oe,e[91]=ie,e[92]=ae,e[93]=le,e[94]=se,e[95]=me,e[96]=ue,e[97]=ce,e[98]=pe,e[99]=he,e[100]=be,e[101]=we,e[102]=Le,e[103]=Ce,e[104]=Be,e[105]=We,e[106]=He,e[107]=_e,e[108]=Re,e[109]=tt,e[110]=Xe,e[111]=Ne,e[112]=Ve,e[113]=ye):ye=e[113];let $e;e[114]!==r.keyboardShortcutsOpen||e[115]!==j?($e=a.jsx(y.Suspense,{fallback:null,children:a.jsx(jZ,{open:r.keyboardShortcutsOpen,onOpenChange:j})}),e[114]=r.keyboardShortcutsOpen,e[115]=j,e[116]=$e):$e=e[116];let qe;e[117]!==m?(qe=g&&a.jsx(W_,{open:m!==null,initialMode:m??"manage",onClose:()=>p(null)}),e[117]=m,e[118]=qe):qe=e[118];let Ke;return e[119]!==r.branchModal||e[120]!==r.processPanel||e[121]!==r.undoDialog||e[122]!==r.workflowsPanel||e[123]!==U||e[124]!==H||e[125]!==K||e[126]!==Z||e[127]!==ye||e[128]!==$e||e[129]!==qe?(Ke=a.jsxs(a.Fragment,{children:[M,D,F,z,U,H,K,Z,ye,$e,qe]}),e[119]=r.branchModal,e[120]=r.processPanel,e[121]=r.undoDialog,e[122]=r.workflowsPanel,e[123]=U,e[124]=H,e[125]=K,e[126]=Z,e[127]=ye,e[128]=$e,e[129]=qe,e[130]=Ke):Ke=e[130],Ke}function EZ(){window.dispatchEvent(new Event(Bg))}const K_={"github.repository":"cogpit.github.repository","clickup.tasks":"cogpit.clickup.tasks","vercel-deployments.deployments":"cogpit.vercel.deployments"};function xw(n){return n===null?null:K_[n]??n}function G_(n,e){return n?e.find(t=>t.id===n)??e.find(t=>t.id===K_[n])??null:null}async function Z_(n,e,t){return(await os(`/api/permissions/${encodeURIComponent(n)}/respond`,{requestId:e,behavior:t})).ok}async function TZ(n,e){return(await os(`/api/permissions/${encodeURIComponent(n)}/respond-all`,{behavior:e})).ok}function AZ(n,e,t){return TN("/api/elicitation-answer",{sessionId:n,requestId:e,...t})}function IZ(n,e,t){return TN("/api/user-dialog-answer",{sessionId:n,requestId:e,choice:t})}const PZ=3e3,R0=y.createContext(null);async function up(n){try{const e=await Ee(n);return e.ok?await e.text():void 0}catch{return}}function dp(n,e){if(!(n===void 0||n===e.current))try{const t=JSON.parse(n);return e.current=n,t}catch{return}}function Ga(n){const e=new Map;for(const[t,s]of Object.entries(n??{}))Array.isArray(s)&&s.length>0&&e.set(t,s);return e}function hu(n,e,t){const s=new Map(n),r=(s.get(e)??[]).filter(o=>!t(o));return r.length>0?s.set(e,r):s.delete(e),s}function $Z({children:n}){const[e,t]=y.useState(new Map),[s,r]=y.useState(new Map),[o,i]=y.useState(new Map),[l,c]=y.useState(new Map),[u,d]=y.useState(new Set),[f,m]=y.useState(new Set),p=y.useRef(""),h=y.useRef(""),g=y.useRef(""),x=Ef(),b=_4()!==null,w=y.useRef(x.key);y.useLayoutEffect(()=>{w.current=x.key},[x.key]);const v=y.useCallback(async()=>{const[R,L,O]=await Promise.all([up(Sl("/api/permissions",x)),up(Sl("/api/user-questions",x)),up(Sl("/api/agent-prompts",x))]);if(w.current!==x.key)return;const $=dp(R,p),M=dp(L,h),D=dp(O,g);$&&(t(Ga($.bySession)),d(new Set(Ga($.plansBySession).keys()))),M&&r(Ga(M.bySession)),D&&(i(Ga(D.elicitationsBySession)),c(Ga(D.dialogsBySession)))},[x]);y.useEffect(()=>{if(b)return;const R=()=>{document.visibilityState==="visible"&&v()};R();const L=setInterval(R,PZ);return document.addEventListener("visibilitychange",R),()=>{clearInterval(L),document.removeEventListener("visibilitychange",R)}},[v,b]);const k=y.useCallback(async(R,L)=>{m(O=>new Set(O).add(R));try{return await L()}finally{m(O=>{const $=new Set(O);return $.delete(R),$}),v()}},[v]),j=y.useCallback((R,L,O)=>k(L,async()=>{await Z_(R,L,O).catch(()=>!1)&&(t(M=>hu(M,R,D=>D.requestId===L)),p.current="")}),[k]),_=y.useCallback((R,L,O)=>k(L,async()=>{const $=await Fx(R,L,O);return $.ok&&(r(M=>hu(M,R,D=>D.toolUseId===L)),h.current=""),$}),[k]),N=y.useCallback((R,L,O)=>k(L,async()=>{const $=await AZ(R,L,O);return $.ok&&(i(M=>hu(M,R,D=>D.requestId===L)),g.current=""),$}),[k]),S=y.useCallback((R,L,O)=>k(L,async()=>{const $=await IZ(R,L,O);return $.ok&&(c(M=>hu(M,R,D=>D.requestId===L)),g.current=""),$}),[k]),C=y.useMemo(()=>new Set(e.keys()),[e]),A=y.useMemo(()=>new Set(s.keys()),[s]),T=y.useMemo(()=>new Set(o.keys()),[o]),I=y.useMemo(()=>new Set(l.keys()),[l]),E=y.useCallback(()=>{v()},[v]),P=y.useMemo(()=>({permissionsBySession:e,questionsBySession:s,elicitationsBySession:o,dialogsBySession:l,awaitingPermission:C,awaitingQuestion:A,awaitingElicitation:T,awaitingDialog:I,awaitingPlan:u,responding:f,respond:j,answerQuestion:_,answerElicitation:N,answerDialog:S,refresh:E}),[e,s,o,l,C,A,T,I,u,f,j,_,N,S,E]);return a.jsx(R0.Provider,{value:P,children:n})}function RZ(){const n=y.useContext(R0);if(!n)throw new Error("usePendingHumanInput must be used within a PendingHumanInputProvider");return n}function OZ(){return y.useContext(R0)}function Y_(n){var d;const e=q.c(29),t=Ar(),s=OZ(),r=X4(n),o=t==null?void 0:t.sessions,i=t==null?void 0:t.procBySession;let l;e[0]!==s?(l=s?{awaitingPermission:s.awaitingPermission,awaitingQuestion:s.awaitingQuestion,awaitingPrompt:new Set([...s.awaitingElicitation,...s.awaitingDialog]),awaitingPlan:s.awaitingPlan}:rR,e[0]=s,e[1]=l):l=e[1];const c=l;let u;if(e[2]!==c||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==r){e:{if(!n||!o||!i){u=null;break e}let f;if(e[8]!==n||e[9]!==o){let v;e[11]!==n?(v=k=>k.sessionId===n,e[11]=n,e[12]=v):v=e[12],f=o.find(v),e[8]=n,e[9]=o,e[10]=f}else f=e[10];const m=f,p=((d=m==null?void 0:m.crew)==null?void 0:d.rootId)??n;let h;e[13]!==p?(h=v=>{var k;return((k=v.crew)==null?void 0:k.rootId)===p},e[13]=p,e[14]=h):h=e[14];const g=o.filter(h);if(g.length===0){if(r.length===0){u=null;break e}const v=r.length;let k;e[15]!==r?(k=r.filter(LZ),e[15]=r,e[16]=k):k=e[16];let j;e[17]!==p||e[18]!==k.length||e[19]!==r.length?(j={rootId:p,size:v,needsYou:0,working:k.length},e[17]=p,e[18]=k.length,e[19]=r.length,e[20]=j):j=e[20],u=j;break e}let x;e[21]!==c||e[22]!==i?(x=v=>k4(v,i,c),e[21]=c,e[22]=i,e[23]=x):x=e[23];const b=vx(g,x);let w;e[24]!==b.needsYou||e[25]!==b.size||e[26]!==b.working||e[27]!==p?(w={rootId:p,size:b.size,needsYou:b.needsYou,working:b.working},e[24]=b.needsYou,e[25]=b.size,e[26]=b.working,e[27]=p,e[28]=w):w=e[28],u=w}e[2]=c,e[3]=i,e[4]=n,e[5]=o,e[6]=r,e[7]=u}else u=e[7];return u}function LZ(n){return n.state==="running"}function ed(n){const e=q.c(10),{reason:t,children:s}=n;if(!t)return s;let r;e[0]!==t?(r=a.jsx("span",{className:"inline-flex",tabIndex:0,"aria-label":t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s||e[3]!==r?(o=a.jsx(Ut,{render:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4];let i;e[5]!==t?(i=a.jsx(Bt,{children:t}),e[5]=t,e[6]=i):i=e[6];let l;return e[7]!==o||e[8]!==i?(l=a.jsxs(Ft,{children:[o,i]}),e[7]=o,e[8]=i,e[9]=l):l=e[9],l}const Qn="rounded-full border bg-popover shadow-sm",om=y.memo(function(e){const t=q.c(8);let s,r;t[0]!==e?({className:s,...r}=e,t[0]=e,t[1]=s,t[2]=r):(s=t[1],r=t[2]);let o;t[3]!==s?(o=G("inline-block size-2 shrink-0 rounded-full bg-success",s),t[3]=s,t[4]=o):o=t[4];let i;return t[5]!==r||t[6]!==o?(i=a.jsx("span",{className:o,...r}),t[5]=r,t[6]=o,t[7]=i):i=t[7],i}),fp=y.memo(function(e){const t=q.c(17),{icon:s,label:r,onClick:o,disabled:i,className:l,iconClassName:c,size:u}=e,f=(u===void 0?"sm":u)==="sm"?"icon-xs":"icon-sm";let m;t[0]!==l||t[1]!==i||t[2]!==r||t[3]!==o||t[4]!==f?(m=a.jsx(J,{variant:"ghost",size:f,className:l,onClick:o,disabled:i,"aria-label":r}),t[0]=l,t[1]=i,t[2]=r,t[3]=o,t[4]=f,t[5]=m):m=t[5];let p;t[6]!==s||t[7]!==c?(p=a.jsx(s,{"data-icon":"inline-start",className:c}),t[6]=s,t[7]=c,t[8]=p):p=t[8];let h;t[9]!==m||t[10]!==p?(h=a.jsx(Ut,{render:m,children:p}),t[9]=m,t[10]=p,t[11]=h):h=t[11];let g;t[12]!==r?(g=a.jsx(Bt,{children:r}),t[12]=r,t[13]=g):g=t[13];let x;return t[14]!==h||t[15]!==g?(x=a.jsxs(Ft,{children:[h,g]}),t[14]=h,t[15]=g,t[16]=x):x=t[16],x});function MZ(n){return n<10?"critical":n<30?"warning":"healthy"}const zZ={critical:"border-destructive/30 bg-destructive/10 text-destructive",warning:"border-warning/30 bg-warning/10 text-warning",healthy:"text-muted-foreground"},X_=y.memo(function(e){const t=q.c(54),{rawMessages:s,showRemaining:r,showTooltip:o,warnOnly:i}=e,l=r===void 0?!1:r,c=o===void 0?!1:o,u=i===void 0?!1:i;let d,f,m,p,h,g,x,b,w,v,k,j,_;if(t[0]!==s||t[1]!==l||t[2]!==c||t[3]!==u){x=Symbol.for("react.early_return_sentinel");e:{const A=v4(s);if(!A){x=null;break e}const T=Math.max(0,100-A.percent),I=MZ(T);if(u&&I==="healthy"){x=null;break e}const E=Math.max(0,A.compactAt-A.used);let P;t[17]!==T||t[18]!==E||t[19]!==l?(P=l?`${T.toFixed(0)}% · ${Ct(E)}`:`${T.toFixed(0)}%`,t[17]=T,t[18]=E,t[19]=l,t[20]=P):P=t[20];const R=P,L=zZ[I],O=l&&"gap-1";let $;t[21]!==L||t[22]!==O?($=G("shrink-0 tabular-nums",L,O),t[21]=L,t[22]=O,t[23]=$):$=t[23];let M;t[24]!==R||t[25]!==$?(M=a.jsx(Ue,{variant:"outline",className:$,children:R}),t[24]=R,t[25]=$,t[26]=M):M=t[26];const D=M;if(!c){x=D;break e}f=Ft,t[27]!==D?(g=a.jsx(Ut,{render:D}),t[27]=D,t[28]=g):g=t[28],d=Bt,m="flex flex-col gap-1 text-xs",t[29]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx("div",{className:"font-medium",children:"Context before auto-compact"}),t[29]=p):p=t[29];let F;t[30]!==E?(F=Ct(E),t[30]=E,t[31]=F):F=t[31];let z;t[32]!==T?(z=T.toFixed(1),t[32]=T,t[33]=z):z=t[33],t[34]!==F||t[35]!==z?(h=a.jsxs("div",{children:[F," remaining (",z,"%)"]}),t[34]=F,t[35]=z,t[36]=h):h=t[36],b="text-muted-foreground",w=Ct(A.used),v=" / ",k=Ct(A.limit),j=" tokens used (",_=A.percentAbsolute.toFixed(1)}t[0]=s,t[1]=l,t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=m,t[7]=p,t[8]=h,t[9]=g,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=k,t[15]=j,t[16]=_}else d=t[4],f=t[5],m=t[6],p=t[7],h=t[8],g=t[9],x=t[10],b=t[11],w=t[12],v=t[13],k=t[14],j=t[15],_=t[16];if(x!==Symbol.for("react.early_return_sentinel"))return x;let N;t[37]!==b||t[38]!==w||t[39]!==v||t[40]!==k||t[41]!==j||t[42]!==_?(N=a.jsxs("div",{className:b,children:[w,v,k,j,_,"%)"]}),t[37]=b,t[38]=w,t[39]=v,t[40]=k,t[41]=j,t[42]=_,t[43]=N):N=t[43];let S;t[44]!==d||t[45]!==m||t[46]!==p||t[47]!==h||t[48]!==N?(S=a.jsxs(d,{className:m,children:[p,h,N]}),t[44]=d,t[45]=m,t[46]=p,t[47]=h,t[48]=N,t[49]=S):S=t[49];let C;return t[50]!==f||t[51]!==g||t[52]!==S?(C=a.jsxs(f,{children:[g,S]}),t[50]=f,t[51]=g,t[52]=S,t[53]=C):C=t[53],C});function DZ(n){var j;const e=q.c(22),{sessionId:t}=n,s=Ar(),{names:r}=If();s==null||s.sessions;let o;e[0]!==(s==null?void 0:s.sessions)?(o=new Map(((s==null?void 0:s.sessions)??[]).map(FZ)),e[0]=s==null?void 0:s.sessions,e[1]=o):o=e[1];const i=o;let l,c,u,d;if(e[2]!==i||e[3]!==r||e[4]!==t){d=Symbol.for("react.early_return_sentinel");e:{if(l=(j=i.get(t))==null?void 0:j.crew,!l){d=null;break e}c=i.get(l.parentId),u=Nd(l.parentId,i,r)??l.parentTitle??"the session that started it"}e[2]=i,e[3]=r,e[4]=t,e[5]=l,e[6]=c,e[7]=u,e[8]=d}else l=e[5],c=e[6],u=e[7],d=e[8];if(d!==Symbol.for("react.early_return_sentinel"))return d;const f=u;let m;e[9]!==l||e[10]!==c?(m=()=>{c?Ra(zf(c.dirName,c.fileName)):Df(l.parentId)},e[9]=l,e[10]=c,e[11]=m):m=e[11];const p=m,h=`Reports to ${f}`,g=`Open ${f}, which started this session`;let x,b,w;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=G(Qn,"h-8 min-w-12 max-w-56 shrink-[4] gap-1.5 px-2.5 text-xs text-muted-foreground hover:text-foreground"),b=a.jsx(H1,{className:"size-3 shrink-0","aria-hidden":"true"}),w=a.jsx("span",{className:"shrink-0 max-[1200px]:hidden",children:"Reports to"}),e[12]=x,e[13]=b,e[14]=w):(x=e[12],b=e[13],w=e[14]);let v;e[15]!==f?(v=a.jsx("span",{className:"truncate font-medium text-foreground",children:f}),e[15]=f,e[16]=v):v=e[16];let k;return e[17]!==p||e[18]!==v||e[19]!==h||e[20]!==g?(k=a.jsxs(J,{type:"button",variant:"ghost",size:"xs","data-crew-parent":!0,onClick:p,"aria-label":h,title:g,className:x,children:[b,w,v]}),e[17]=p,e[18]=v,e[19]=h,e[20]=g,e[21]=k):k=e[21],k}function FZ(n){return[n.sessionId,n]}const bw=U_.version,UZ={ok:"bg-success",unknown:"bg-warning","bad-password":"bg-destructive"},vw={ok:"Reachable",unknown:"Not reachable","bad-password":"Password rejected"};function BZ(n){const e=q.c(6),{state:t}=n,s=vw[t],r=vw[t],o=UZ[t];let i;e[0]!==o?(i=G("size-2 shrink-0 rounded-full",o),e[0]=o,e[1]=i):i=e[1];let l;return e[2]!==s||e[3]!==r||e[4]!==i?(l=a.jsx("span",{"aria-label":s,title:r,className:i}),e[2]=s,e[3]=r,e[4]=i,e[5]=l):l=e[5],l}function O0(n){const e=q.c(50),{compact:t}=n,s=t===void 0?!1:t,{devices:r,activeDeviceId:o,activeDevice:i,refresh:l,testDevice:c}=La(),[u,d]=y.useState(null),f=(i==null?void 0:i.name)??"This machine",m=o!==Tt;let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=ht("manageDevices"),e[0]=p):p=e[0];const h=p;let g;e[1]!==r||e[2]!==l||e[3]!==c?(g=F=>{!F||r.length===0||Promise.all(r.map(z=>c(z.id).catch(qZ))).then(()=>l())},e[1]=r,e[2]=l,e[3]=c,e[4]=g):g=e[4];const x=g;if(!s&&r.length===0&&!m)return null;const b=s?"sm":"xs",w=s&&"h-10";let v;e[5]!==w?(v=G("max-w-40 justify-start",w),e[5]=w,e[6]=v):v=e[6];let k;e[7]!==b||e[8]!==v?(k=a.jsx(J,{variant:"ghost",size:b,"aria-label":"Switch device",className:v}),e[7]=b,e[8]=v,e[9]=k):k=e[9];let j;e[10]!==m?(j=m?a.jsx(W1,{"data-icon":"inline-start"}):a.jsx(ig,{"data-icon":"inline-start"}),e[10]=m,e[11]=j):j=e[11];let _;e[12]!==f?(_=a.jsx("span",{className:"truncate",children:f}),e[12]=f,e[13]=_):_=e[13];let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx(Wt,{"data-icon":"inline-end",className:"opacity-60"}),e[14]=N):N=e[14];let S;e[15]!==k||e[16]!==j||e[17]!==_?(S=a.jsxs(Pa,{render:k,children:[j,_,N]}),e[15]=k,e[16]=j,e[17]=_,e[18]=S):S=e[18];let C;e[19]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(SN,{children:"Devices"}),e[19]=C):C=e[19];let A,T;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(ig,{}),T=a.jsx("span",{className:"flex-1 truncate",children:"This machine"}),e[20]=A,e[21]=T):(A=e[20],T=e[21]);let I;e[22]!==m?(I=!m&&a.jsx(Ht,{className:"ml-auto text-success"}),e[22]=m,e[23]=I):I=e[23];let E;e[24]!==I?(E=a.jsxs(tn,{onClick:WZ,children:[A,T,I]}),e[24]=I,e[25]=E):E=e[25];let P;if(e[26]!==o||e[27]!==s||e[28]!==r){let F;e[30]!==o||e[31]!==s?(F=z=>{const B=D_(z),U=B!==void 0&&B!==bw,W=z.id===o;return a.jsxs(tn,{onClick:()=>Ks(z.id),className:G(s&&"min-h-10"),children:[a.jsx(BZ,{state:z.runtime.authState}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"truncate",children:z.name}),U&&a.jsxs("span",{className:"shrink-0 font-mono text-xs text-warning",title:`Device runs v${B}; hub runs v${bw}`,children:["v",B]})]}),a.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:[z.host,":",z.port,z.auth==="none"&&" · unauthenticated"]})]}),W&&a.jsx(Ht,{className:"ml-auto text-success"})]},z.id)},e[30]=o,e[31]=s,e[32]=F):F=e[32],P=r.map(F),e[26]=o,e[27]=s,e[28]=r,e[29]=P}else P=e[29];let R;e[33]!==E||e[34]!==P?(R=a.jsxs(pr,{children:[C,E,P]}),e[33]=E,e[34]=P,e[35]=R):R=e[35];let L;e[36]!==r.length?(L=h&&a.jsxs(a.Fragment,{children:[a.jsx(Nl,{}),a.jsxs(pr,{children:[a.jsxs(tn,{onClick:()=>d("add"),children:[a.jsx(xr,{}),a.jsx("span",{children:"Add device…"})]}),r.length>0&&a.jsxs(tn,{onClick:()=>d("manage"),children:[a.jsx(F1,{}),a.jsx("span",{children:"Manage devices…"})]})]})]}),e[36]=r.length,e[37]=L):L=e[37];let O;e[38]!==R||e[39]!==L?(O=a.jsxs($a,{align:"end",sideOffset:6,className:"w-64",children:[R,L]}),e[38]=R,e[39]=L,e[40]=O):O=e[40];let $;e[41]!==x||e[42]!==S||e[43]!==O?($=a.jsxs(Ia,{onOpenChange:x,children:[S,O]}),e[41]=x,e[42]=S,e[43]=O,e[44]=$):$=e[44];let M;e[45]!==u?(M=h&&a.jsx(W_,{open:u!==null,initialMode:u??"manage",onClose:()=>d(null)}),e[45]=u,e[46]=M):M=e[46];let D;return e[47]!==$||e[48]!==M?(D=a.jsxs(a.Fragment,{children:[$,M]}),e[47]=$,e[48]=M,e[49]=D):D=e[49],D}function WZ(){return Ks(Tt)}function qZ(){return null}const VZ=6e4;function HZ(){const[n,e]=y.useState([]),[t,s]=y.useState(!1),r=y.useRef(!1),o=y.useCallback(async()=>{if(!r.current){r.current=!0;try{const l=await Ee("/api/system-processes");if(l.ok){const c=await l.json();e((c.processes??[]).filter(u=>u.suspectedLeak))}}catch{}finally{r.current=!1}}},[]),i=y.useCallback(async l=>{if(l.length!==0){s(!0);try{await Ee("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:l})}),await new Promise(c=>setTimeout(c,1e3)),await o()}catch{}finally{s(!1)}}},[o]);return y.useEffect(()=>{o();const l=window.setInterval(()=>{document.visibilityState==="visible"&&o()},VZ);return()=>window.clearInterval(l)},[o]),{leaks:n,killing:t,killLeaks:i,refresh:o}}const KZ=6e4;function GZ(){const n=q.c(29),{leaks:e,killing:t,killLeaks:s,refresh:r}=HZ(),[o,i]=y.useState(!1),l=e.length>0,c=e.reduce(XZ,0);let u,d;if(n[0]!==l?(u=()=>{if(l){i(!0);return}const I=window.setTimeout(()=>i(!1),KZ);return()=>window.clearTimeout(I)},d=[l],n[0]=l,n[1]=u,n[2]=d):(u=n[1],d=n[2]),y.useEffect(u,d),!l&&!o)return null;const f=Ft,m=l?"destructive":"ghost",p=l?`Kill ${e.length} leaked agent ${e.length===1?"process":"processes"}`:"Leak monitor. No leaked agent processes";let h;n[3]!==l||n[4]!==s||n[5]!==e||n[6]!==r?(h=()=>void(l?s(e.map(YZ)):r()),n[3]=l,n[4]=s,n[5]=e,n[6]=r,n[7]=h):h=n[7];const g=!l&&"text-muted-foreground";let x;n[8]!==g?(x=G("mr-1 font-mono",g),n[8]=g,n[9]=x):x=n[9];let b;n[10]!==t||n[11]!==m||n[12]!==p||n[13]!==h||n[14]!==x?(b=a.jsx(J,{variant:m,size:"xs","aria-label":p,onClick:h,disabled:t,className:x}),n[10]=t,n[11]=m,n[12]=p,n[13]=h,n[14]=x,n[15]=b):b=n[15];let w;n[16]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsx(VP,{"data-icon":"inline-start"}),n[16]=w):w=n[16];const v=t?"…":e.length;let k;n[17]!==v?(k=a.jsx("span",{className:"tabular-nums",children:v}),n[17]=v,n[18]=k):k=n[18];let j;n[19]!==k||n[20]!==b?(j=a.jsxs(Ut,{render:b,children:[w,k]}),n[19]=k,n[20]=b,n[21]=j):j=n[21];const _=Bt,N="bottom",S="p-3",C=l?a.jsxs("div",{className:"flex min-w-56 flex-col gap-2",children:[a.jsxs("div",{className:"text-xs font-medium",children:["Leaked agent processes · ",c.toFixed(0),"% CPU"]}),e.slice(0,6).map(ZZ),e.length>6&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",e.length-6," more"]}),a.jsx(Qt,{}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Click to kill ",e.length===1?"it":"all of them"]})]}):a.jsxs("div",{className:"flex min-w-48 flex-col gap-1",children:[a.jsx("div",{className:"text-xs font-medium",children:"Leak monitor"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"No leaked agent processes. Click to scan again."})]});let A;n[22]!==_||n[23]!==C?(A=a.jsx(_,{side:N,className:S,children:C}),n[22]=_,n[23]=C,n[24]=A):A=n[24];let T;return n[25]!==f||n[26]!==j||n[27]!==A?(T=a.jsxs(f,{children:[j,A]}),n[25]=f,n[26]=j,n[27]=A,n[28]=T):T=n[28],T}function ZZ(n){return a.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[a.jsxs("span",{className:"truncate text-muted-foreground",children:[n.label," · ",fx(n.ageSeconds)]}),a.jsxs("span",{className:"shrink-0 font-semibold text-destructive",children:[n.cpuPercent.toFixed(0),"%"]})]},n.pid)}function YZ(n){return n.pid}function XZ(n,e){return n+e.cpuPercent}const JZ=15e3;function QZ(){const[n,e]=y.useState([]),t=y.useCallback(async()=>{var l,c;try{const u=await Ee("/api/notifications?limit=100");if(!u.ok)return;const d=await u.json();if(!Array.isArray(d.notifications))return;e(d.notifications),(c=(l=hg()).onInboxRead)==null||c.call(l,d.notifications)}catch{}},[]);y.useEffect(()=>{t();const l=()=>void t(),c=window.setInterval(l,JZ);return window.addEventListener("focus",l),()=>{window.clearInterval(c),window.removeEventListener("focus",l)}},[t]);const s=y.useCallback(async(l,c)=>{const u=new Date().toISOString();e(d=>d.map(f=>f.readAt===null&&c(f)?{...f,readAt:u}:f));try{await Ee("/api/notifications/read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch{}},[]),r=y.useCallback(async l=>s({ids:l},c=>l.includes(c.id)),[s]),o=y.useCallback(async()=>s({all:!0},()=>!0),[s]),i=n.filter(l=>l.readAt===null).length;return{notifications:n,unreadCount:i,refresh:t,markRead:r,markAllRead:o}}const eY={turnComplete:To,permission:Vs,system:To,access:HP};function tY(){const n=q.c(30),{notifications:e,unreadCount:t,refresh:s,markRead:r,markAllRead:o}=QZ(),[i,l]=y.useState(!1);let c;n[0]!==r?(c=function(S){r([S.id]),!(!S.dirName||!S.sessionId)&&(Ra(`${bf()}/${encodeURIComponent(S.dirName)}/${encodeURIComponent(S.sessionId)}`),l(!1))},n[0]=r,n[1]=c):c=n[1];const u=c;let d;n[2]!==s?(d=N=>{l(N),N&&s()},n[2]=s,n[3]=d):d=n[3];const f=i?"secondary":"ghost",m=t>0?`Notifications, ${t} unread`:"Notifications";let p;n[4]!==f||n[5]!==m?(p=a.jsx(J,{type:"button",variant:f,size:"icon-sm",className:"relative","aria-label":m}),n[4]=f,n[5]=m,n[6]=p):p=n[6];let h;n[7]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(rg,{"data-icon":"inline-start"}),n[7]=h):h=n[7];let g;n[8]!==t?(g=t>0&&a.jsx(Ue,{className:"absolute -right-1 -top-1 h-4 min-w-4 px-1 tabular-nums",children:t>99?"99+":t}),n[8]=t,n[9]=g):g=n[9];let x;n[10]!==p||n[11]!==g?(x=a.jsxs(Pa,{render:p,children:[h,g]}),n[10]=p,n[11]=g,n[12]=x):x=n[12];let b;n[13]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{className:"text-sm font-medium",children:"Notifications"}),n[13]=b):b=n[13];let w;n[14]!==o||n[15]!==t?(w=t>0&&a.jsxs(J,{variant:"ghost",size:"xs",onClick:()=>void o(),children:[a.jsx(KP,{"data-icon":"inline-start"}),"Mark all read"]}),n[14]=o,n[15]=t,n[16]=w):w=n[16];let v;n[17]!==w?(v=a.jsxs("div",{className:"flex h-11 items-center justify-between border-b px-3",children:[b,w]}),n[17]=w,n[18]=v):v=n[18];let k;n[19]!==e||n[20]!==u?(k=a.jsx("div",{className:"max-h-96 overflow-y-auto",children:e.length===0?a.jsx(Cn,{className:"min-h-40 p-6",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(rg,{})}),a.jsx(En,{children:"No notifications"}),a.jsx(Tn,{children:"Session updates will appear here."})]})}):a.jsx(pr,{children:e.map(N=>a.jsx(nY,{notification:N,onOpen:u},N.id))})}),n[19]=e,n[20]=u,n[21]=k):k=n[21];let j;n[22]!==v||n[23]!==k?(j=a.jsxs($a,{align:"end",sideOffset:6,className:"w-80 overflow-hidden p-0",children:[v,k]}),n[22]=v,n[23]=k,n[24]=j):j=n[24];let _;return n[25]!==i||n[26]!==d||n[27]!==j||n[28]!==x?(_=a.jsxs(Ia,{open:i,onOpenChange:d,children:[x,j]}),n[25]=i,n[26]=d,n[27]=j,n[28]=x,n[29]=_):_=n[29],_}function nY(n){const e=q.c(38),{notification:t,onOpen:s}=n,r=t.readAt===null,o=!!(t.dirName&&t.sessionId),i=Date.now();let l;e[0]!==t.at?(l=new Date(t.at).getTime(),e[0]=t.at,e[1]=l):l=e[1];const c=Math.max(0,(i-l)/1e3),u=eY[t.kind]??To;let d;e[2]!==t||e[3]!==s?(d=()=>s(t),e[2]=t,e[3]=s,e[4]=d):d=e[4];const f=!o&&"cursor-default",m=r&&"bg-accent/50";let p;e[5]!==f||e[6]!==m?(p=G("rounded-none border-b px-3 py-2.5 last:border-b-0",f,m),e[5]=f,e[6]=m,e[7]=p):p=e[7];const h=t.kind==="permission"?"text-warning":"text-info";let g;e[8]!==h?(g=G("mt-0.5",h),e[8]=h,e[9]=g):g=e[9];let x;e[10]!==u||e[11]!==g?(x=a.jsx(u,{className:g}),e[10]=u,e[11]=g,e[12]=x):x=e[12];const b=r?"font-medium text-foreground":"text-muted-foreground";let w;e[13]!==b?(w=G("truncate text-xs",b),e[13]=b,e[14]=w):w=e[14];let v;e[15]!==t.title||e[16]!==w?(v=a.jsx("span",{className:w,children:t.title}),e[15]=t.title,e[16]=w,e[17]=v):v=e[17];let k;e[18]!==c?(k=fx(c),e[18]=c,e[19]=k):k=e[19];let j;e[20]!==k?(j=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:k}),e[20]=k,e[21]=j):j=e[21];let _;e[22]!==v||e[23]!==j?(_=a.jsxs("span",{className:"flex items-baseline justify-between gap-2",children:[v,j]}),e[22]=v,e[23]=j,e[24]=_):_=e[24];let N;e[25]!==t.body?(N=a.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.body}),e[25]=t.body,e[26]=N):N=e[26];let S;e[27]!==_||e[28]!==N?(S=a.jsxs("span",{className:"min-w-0 flex-1",children:[_,N]}),e[27]=_,e[28]=N,e[29]=S):S=e[29];let C;e[30]!==r?(C=r&&a.jsx("span",{className:"mt-1.5 size-1.5 shrink-0 rounded-full bg-primary"}),e[30]=r,e[31]=C):C=e[31];let A;return e[32]!==S||e[33]!==C||e[34]!==d||e[35]!==p||e[36]!==x?(A=a.jsxs(tn,{onClick:d,className:p,children:[x,S,C]}),e[32]=S,e[33]=C,e[34]=d,e[35]=p,e[36]=x,e[37]=A):A=e[37],A}const sY=2e3;function ca(n){return`${n.toFixed(n<10?1:0)}%`}function Bd(n){return`${n.toFixed(0)} MB`}function rY(n){return n>=10?`${n.toFixed(0)}/s`:n>=1?`${n.toFixed(1)}/s`:`${n.toFixed(2)}/s`}function oY(n){return n<=0?null:n>=1024*1024?`${(n/1024/1024).toFixed(1)} MB/s`:n>=1024?`${(n/1024).toFixed(1)} KB/s`:`${n.toFixed(0)} B/s`}function iY(n){const e=q.c(44),{metric:t,onKill:s}=n;let r;e[0]!==t.label?(r=a.jsx("span",{className:"truncate text-sm font-medium",children:t.label}),e[0]=t.label,e[1]=r):r=e[1];let o;e[2]!==t.pid?(o=a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=o):o=e[3];let i;e[4]!==t.suspectedLeak?(i=t.suspectedLeak&&a.jsx(Ue,{variant:"destructive",children:"possible leak"}),e[4]=t.suspectedLeak,e[5]=i):i=e[5];let l;e[6]!==t.orphaned||e[7]!==t.suspectedLeak?(l=t.orphaned&&!t.suspectedLeak&&a.jsx(Ue,{variant:"secondary",children:"orphaned"}),e[6]=t.orphaned,e[7]=t.suspectedLeak,e[8]=l):l=e[8];let c;e[9]!==r||e[10]!==o||e[11]!==i||e[12]!==l?(c=a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r,o,i,l]}),e[9]=r,e[10]=o,e[11]=i,e[12]=l,e[13]=c):c=e[13];let u;e[14]!==t.command?(u=a.jsx("p",{className:"mt-1 truncate font-mono text-xs text-muted-foreground",title:t.command,children:t.command}),e[14]=t.command,e[15]=u):u=e[15];let d;e[16]!==c||e[17]!==u?(d=a.jsxs("div",{className:"min-w-0 flex-1",children:[c,u]}),e[16]=c,e[17]=u,e[18]=d):d=e[18];let f;e[19]!==t.pid||e[20]!==t.suspectedLeak||e[21]!==s?(f=t.suspectedLeak&&s&&a.jsx(J,{variant:"destructive",size:"xs",className:"shrink-0",onClick:()=>s(t.pid),children:"Kill"}),e[19]=t.pid,e[20]=t.suspectedLeak,e[21]=s,e[22]=f):f=e[22];const m=t.cpuPercent>=20&&"text-destructive";let p;e[23]!==m?(p=G("font-mono text-sm font-semibold tabular-nums",m),e[23]=m,e[24]=p):p=e[24];let h;e[25]!==t.cpuPercent?(h=ca(t.cpuPercent),e[25]=t.cpuPercent,e[26]=h):h=e[26];let g;e[27]!==p||e[28]!==h?(g=a.jsx("div",{className:p,children:h}),e[27]=p,e[28]=h,e[29]=g):g=e[29];let x;e[30]!==t.memoryMb?(x=Bd(t.memoryMb),e[30]=t.memoryMb,e[31]=x):x=e[31];let b;e[32]!==t.ageSeconds?(b=fx(t.ageSeconds),e[32]=t.ageSeconds,e[33]=b):b=e[33];let w;e[34]!==x||e[35]!==b?(w=a.jsxs("div",{className:"text-xs text-muted-foreground",children:[x," · ",b]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let v;e[37]!==g||e[38]!==w?(v=a.jsxs("div",{className:"shrink-0 text-right",children:[g,w]}),e[37]=g,e[38]=w,e[39]=v):v=e[39];let k;return e[40]!==v||e[41]!==d||e[42]!==f?(k=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[d,f,v]}),e[40]=v,e[41]=d,e[42]=f,e[43]=k):k=e[43],k}function aY(n){return n.name==="Server"?"API, file watching, session streams, and agent I/O":n.name==="Renderer"?"React rendering, markdown, layout, and animations":n.name==="GPU"?"Compositing, animation, and visual effects":n.name==="App"?"Electron window and application lifecycle":n.type}function lY(n,e,t=0){return t>0?t===1?'1 agent process outside Cogpit looks leaked. See "Agent processes" below.':`${t} agent processes outside Cogpit look leaked. See "Agent processes" below.`:n<5?"Cogpit is currently idle. Leave this open while the power spike happens.":e?e.name==="Server"?"The server is doing the most work. Compare the activity and API lists below to find the hot loop.":e.name==="Renderer"?"The renderer is doing the most work, which points to repeated UI rendering, layout, or animation.":e.name==="GPU"?"The GPU process is doing the most work, which points to continuous compositing or visual effects.":`${e.name} is currently the busiest Cogpit process.`:"The server is active. The lists below show its busiest recent work."}function J_(n){const e=q.c(34),{metric:t}=n;let s;e[0]!==t.name?(s=a.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e[0]=t.name,e[1]=s):s=e[1];let r;e[2]!==t.pid?(r=t.pid>0&&a.jsxs(Ue,{variant:"outline",children:["PID ",t.pid]}),e[2]=t.pid,e[3]=r):r=e[3];let o;e[4]!==s||e[5]!==r?(o=a.jsxs("div",{className:"flex items-center gap-2",children:[s,r]}),e[4]=s,e[5]=r,e[6]=o):o=e[6];let i;e[7]!==t?(i=aY(t),e[7]=t,e[8]=i):i=e[8];let l;e[9]!==i?(l=a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i}),e[9]=i,e[10]=l):l=e[10];let c;e[11]!==o||e[12]!==l?(c=a.jsxs("div",{className:"min-w-0 flex-1",children:[o,l]}),e[11]=o,e[12]=l,e[13]=c):c=e[13];const u=t.cpuPercent>=50&&"text-destructive";let d;e[14]!==u?(d=G("font-mono text-sm font-semibold tabular-nums",u),e[14]=u,e[15]=d):d=e[15];let f;e[16]!==t.cpuPercent?(f=ca(t.cpuPercent),e[16]=t.cpuPercent,e[17]=f):f=e[17];let m;e[18]!==d||e[19]!==f?(m=a.jsx("div",{className:d,children:f}),e[18]=d,e[19]=f,e[20]=m):m=e[20];let p;e[21]!==t.memoryMb?(p=Bd(t.memoryMb),e[21]=t.memoryMb,e[22]=p):p=e[22];let h;e[23]!==p?(h=a.jsx("div",{className:"text-xs text-muted-foreground",children:p}),e[23]=p,e[24]=h):h=e[24];let g;e[25]!==t.idleWakeupsPerSecond?(g=t.idleWakeupsPerSecond!==void 0&&t.idleWakeupsPerSecond>0&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.idleWakeupsPerSecond.toFixed(0)," wakeups/s"]}),e[25]=t.idleWakeupsPerSecond,e[26]=g):g=e[26];let x;e[27]!==m||e[28]!==h||e[29]!==g?(x=a.jsxs("div",{className:"shrink-0 text-right",children:[m,h,g]}),e[27]=m,e[28]=h,e[29]=g,e[30]=x):x=e[30];let b;return e[31]!==x||e[32]!==c?(b=a.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[c,x]}),e[31]=x,e[32]=c,e[33]=b):b=e[33],b}function yw(n){const e=q.c(6),{metrics:t,emptyLabel:s}=n;let r,o;if(e[0]!==s||e[1]!==t){o=Symbol.for("react.early_return_sentinel");e:{const i=t.slice(0,8);if(i.length===0){let l;e[4]!==s?(l=a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:s}),e[4]=s,e[5]=l):l=e[5],o=l;break e}r=i.map(cY)}e[0]=s,e[1]=t,e[2]=r,e[3]=o}else r=e[2],o=e[3];return o!==Symbol.for("react.early_return_sentinel")?o:r}function cY(n,e){const t=oY(n.bytesPerSecond);return a.jsxs("div",{children:[e>0&&a.jsx(Qt,{}),a.jsxs("div",{className:"flex items-center gap-3 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm",children:n.name}),a.jsxs("div",{className:"mt-0.5 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:rY(n.ratePerSecond)}),t&&a.jsx("span",{children:t}),n.averageDurationMs!==void 0&&a.jsxs("span",{children:[n.averageDurationMs.toFixed(0)," ms avg"]})]})]}),n.active!==void 0&&n.active>0&&a.jsxs(Ue,{variant:"secondary",children:[n.active," open"]})]})]},n.name)}function uY(n){const e=q.c(8),{values:t}=n,s=Math.max(100,...t);let r;e[0]!==t?(r=t.map(dY).join(", "),e[0]=t,e[1]=r):r=e[1];const o=`Recent Cogpit CPU: ${r}`;let i;e[2]!==s||e[3]!==t?(i=t.length===0?a.jsx("span",{className:"self-center text-xs text-muted-foreground",children:"Collecting samples…"}):t.map((c,u)=>a.jsx("div",{className:G("min-w-1 flex-1 rounded-sm bg-primary/70",c>=80&&"bg-destructive/80"),style:{height:`${Math.max(4,Math.min(100,c/s*100))}%`},title:ca(c)},u)),e[2]=s,e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==o||e[6]!==i?(l=a.jsx("div",{className:"flex h-14 items-end gap-1 rounded-md bg-muted/50 p-2",role:"img","aria-label":o,children:i}),e[5]=o,e[6]=i,e[7]=l):l=e[7],l}function dY(n){return ca(n)}function fY(n){var me,ue,ce,xe;const e=q.c(135),{open:t,onOpenChange:s}=n,[r,o]=y.useState(null),[i,l]=y.useState(null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[u,d]=y.useState(c),[f,m]=y.useState(null),[p,h]=y.useState(!1),g=y.useRef(!1),[x,b]=Kr();let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=async()=>{var Te;if(g.current)return;g.current=!0,h(!0);const pe=Ee("/api/performance").then(bY),he=((Te=window.electronPerformance)==null?void 0:Te.getSnapshot())??Promise.resolve(null),[be,we]=await Promise.allSettled([pe,he]),ve=be.status==="fulfilled"?be.value:null,Se=we.status==="fulfilled"?we.value:null;if(ve&&l(ve),Se&&o(Se),!ve&&!Se)m("Performance data is unavailable.");else{m(null);const Ae=Se&&Se.processes.length>0?Se.processes.reduce(xY,0):(ve==null?void 0:ve.cpuPercent)??0;d(ze=>[...ze.slice(-29),Ae])}g.current=!1,h(!1)},e[1]=w):w=e[1];const v=w;let k,j;e[2]!==t?(k=()=>{if(!t)return;v();const pe=window.setInterval(()=>void v(),sY);return()=>window.clearInterval(pe)},j=[t,v],e[2]=t,e[3]=k,e[4]=j):(k=e[3],j=e[4]),y.useEffect(k,j);let _,N,S,C,A,T,I,E,P,R,L,O,$,M,D,F,z,B,U;if(e[5]!==x||e[6]!==b||e[7]!==r||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t||e[12]!==p||e[13]!==i){const pe=[...(r==null?void 0:r.processes)??[]].sort(gY),he=pe.length>0?pe.reduce(hY,0):(i==null?void 0:i.cpuPercent)??0,be=pe[0];let we;e[33]!==((me=i==null?void 0:i.system)==null?void 0:me.processes)?(we=((ue=i==null?void 0:i.system)==null?void 0:ue.processes)??[],e[33]=(ce=i==null?void 0:i.system)==null?void 0:ce.processes,e[34]=we):we=e[34],I=we;const ve=((xe=i==null?void 0:i.system)==null?void 0:xe.suspectedLeakCount)??0,Se=ve>0||he>=80?"High":he>=15?"Active":"Idle";let Te;e[35]===Symbol.for("react.memo_cache_sentinel")?(Te=async rt=>{try{await Ee("/api/system-processes/kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pids:[rt]})}),await new Promise(pY)}catch{}v()},e[35]=Te):Te=e[35],T=Te;let Ae;e[36]!==b||e[37]!==r||e[38]!==u||e[39]!==i?(Ae=()=>{b(JSON.stringify({capturedAt:new Date().toISOString(),electron:r,server:i,cpuHistory:u},null,2))},e[36]=b,e[37]=r,e[38]=u,e[39]=i,e[40]=Ae):Ae=e[40];const ze=Ae;A=Ys,$=t,M=s,C=Xs,R="h-[min(780px,calc(100vh-2rem))] gap-0 p-0 sm:max-w-3xl";let De;e[41]===Symbol.for("react.memo_cache_sentinel")?(De=a.jsx(Js,{children:"Power & activity monitor"}),e[41]=De):De=e[41];const Le=Se==="High"?"destructive":"secondary";let Ce;e[42]!==Se||e[43]!==Le?(Ce=a.jsxs("div",{className:"flex items-center gap-2",children:[De,a.jsx(Ue,{variant:Le,children:Se})]}),e[42]=Se,e[43]=Le,e[44]=Ce):Ce=e[44];let Be;e[45]===Symbol.for("react.memo_cache_sentinel")?(Be=a.jsx(Qs,{className:"mt-1",children:"Live CPU, memory, and wakeups. Sampling runs only while this window is open."}),e[45]=Be):Be=e[45];let We;e[46]!==Ce?(We=a.jsxs("div",{className:"min-w-0 flex-1",children:[Ce,Be]}),e[46]=Ce,e[47]=We):We=e[47];let He;e[48]===Symbol.for("react.memo_cache_sentinel")?(He=()=>void v(),e[48]=He):He=e[48];const _e=p&&"animate-spin";let Re;e[49]!==_e?(Re=G(_e),e[49]=_e,e[50]=Re):Re=e[50];let tt;e[51]!==Re?(tt=a.jsx(Fn,{"data-icon":"inline-start",className:Re}),e[51]=Re,e[52]=tt):tt=e[52];let Xe;e[53]!==p||e[54]!==tt?(Xe=a.jsxs(J,{variant:"outline",size:"sm",onClick:He,disabled:p,children:[tt,"Refresh"]}),e[53]=p,e[54]=tt,e[55]=Xe):Xe=e[55];const Ne=!i&&!r;let Ve;e[56]!==x?(Ve=x?a.jsx(Ht,{"data-icon":"inline-start"}):a.jsx(Cs,{"data-icon":"inline-start"}),e[56]=x,e[57]=Ve):Ve=e[57];const ye=x?"Copied":"Copy data";let $e;e[58]!==ze||e[59]!==Ne||e[60]!==Ve||e[61]!==ye?($e=a.jsxs(J,{variant:"outline",size:"sm",onClick:ze,disabled:Ne,children:[Ve,ye]}),e[58]=ze,e[59]=Ne,e[60]=Ve,e[61]=ye,e[62]=$e):$e=e[62];let qe;e[63]!==Xe||e[64]!==$e?(qe=a.jsxs("div",{className:"flex shrink-0 gap-1",children:[Xe,$e]}),e[63]=Xe,e[64]=$e,e[65]=qe):qe=e[65],e[66]!==We||e[67]!==qe?(L=a.jsx(to,{className:"p-5 pb-4",children:a.jsxs("div",{className:"flex items-start gap-3 pr-8",children:[We,qe]})}),e[66]=We,e[67]=qe,e[68]=L):L=e[68],e[69]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Qt,{}),e[69]=O):O=e[69],S=Cc,P="min-h-0 min-w-0 flex-1",B="flex flex-col gap-4 p-5",e[70]!==f?(U=f&&a.jsx(wt,{variant:"destructive",children:a.jsx(_t,{children:f})}),e[70]=f,e[71]=U):U=e[71];let Ke;e[72]===Symbol.for("react.memo_cache_sentinel")?(Ke=a.jsx(dr,{children:"Current load"}),e[72]=Ke):Ke=e[72];const fe=he>=80&&"text-destructive";let ke;e[73]!==fe?(ke=G("font-mono text-lg font-semibold tabular-nums",fe),e[73]=fe,e[74]=ke):ke=e[74];const Ge=a.jsxs(ur,{children:[Ke,a.jsx(fr,{children:lY(he,be,ve)}),a.jsx(Dz,{children:a.jsxs("span",{className:ke,children:[ca(he)," CPU"]})})]});let Je;e[75]!==u?(Je=a.jsx(Os,{children:a.jsx(uY,{values:u})}),e[75]=u,e[76]=Je):Je=e[76],e[77]!==Ge||e[78]!==Je?(E=a.jsxs(Rs,{size:"sm",children:[Ge,Je]}),e[77]=Ge,e[78]=Je,e[79]=E):E=e[79],N=Rs,F="sm",e[80]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsxs(ur,{children:[a.jsx(dr,{children:"Processes"}),a.jsx(fr,{children:"Which part of Cogpit is consuming CPU and memory."})]}),e[80]=z):z=e[80],_=Os,D=pe.length>0?pe.map(mY):i?a.jsx(J_,{metric:{pid:0,name:"Server",type:"Node",cpuPercent:i.cpuPercent,memoryMb:i.memory.rssMb}}):a.jsx("p",{className:"py-3 text-sm text-muted-foreground",children:"Collecting process data…"}),e[5]=x,e[6]=b,e[7]=r,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=p,e[13]=i,e[14]=_,e[15]=N,e[16]=S,e[17]=C,e[18]=A,e[19]=T,e[20]=I,e[21]=E,e[22]=P,e[23]=R,e[24]=L,e[25]=O,e[26]=$,e[27]=M,e[28]=D,e[29]=F,e[30]=z,e[31]=B,e[32]=U}else _=e[14],N=e[15],S=e[16],C=e[17],A=e[18],T=e[19],I=e[20],E=e[21],P=e[22],R=e[23],L=e[24],O=e[25],$=e[26],M=e[27],D=e[28],F=e[29],z=e[30],B=e[31],U=e[32];let W;e[81]!==_||e[82]!==D?(W=a.jsx(_,{children:D}),e[81]=_,e[82]=D,e[83]=W):W=e[83];let V;e[84]!==N||e[85]!==W||e[86]!==F||e[87]!==z?(V=a.jsxs(N,{size:F,children:[z,W]}),e[84]=N,e[85]=W,e[86]=F,e[87]=z,e[88]=V):V=e[88];let H;e[89]!==T||e[90]!==I?(H=I.length>0&&a.jsxs(Rs,{size:"sm",children:[a.jsxs(ur,{children:[a.jsx(dr,{children:"Agent processes"}),a.jsx(fr,{children:"Claude sessions, browsers, and scripts running outside Cogpit."})]}),a.jsx(Os,{children:I.map((pe,he)=>a.jsxs("div",{children:[he>0&&a.jsx(Qt,{}),a.jsx(iY,{metric:pe,onKill:be=>void T(be)})]},pe.pid))})]}),e[89]=T,e[90]=I,e[91]=H):H=e[91];let K;e[92]===Symbol.for("react.memo_cache_sentinel")?(K=a.jsx(dr,{children:"Server activity"}),e[92]=K):K=e[92];const Z=(i==null?void 0:i.sampleWindowSeconds)??10;let Y;e[93]!==Z?(Y=a.jsxs(ur,{children:[K,a.jsxs(fr,{children:["File checks, streams, and agent work over the last ",Z," seconds."]})]}),e[93]=Z,e[94]=Y):Y=e[94];let X;e[95]!==(i==null?void 0:i.activities)?(X=(i==null?void 0:i.activities)??[],e[95]=i==null?void 0:i.activities,e[96]=X):X=e[96];let ee;e[97]!==X?(ee=a.jsx(Os,{children:a.jsx(yw,{metrics:X,emptyLabel:"No watched-file or stream activity in this sample."})}),e[97]=X,e[98]=ee):ee=e[98];let Q;e[99]!==Y||e[100]!==ee?(Q=a.jsxs(Rs,{size:"sm",children:[Y,ee]}),e[99]=Y,e[100]=ee,e[101]=Q):Q=e[101];let ne;e[102]===Symbol.for("react.memo_cache_sentinel")?(ne=a.jsxs(ur,{children:[a.jsx(dr,{children:"API activity"}),a.jsx(fr,{children:"Requests ranked by recent frequency and time."})]}),e[102]=ne):ne=e[102];let te;e[103]!==(i==null?void 0:i.requests)?(te=(i==null?void 0:i.requests)??[],e[103]=i==null?void 0:i.requests,e[104]=te):te=e[104];let re;e[105]!==te?(re=a.jsxs(Rs,{size:"sm",children:[ne,a.jsx(Os,{children:a.jsx(yw,{metrics:te,emptyLabel:"No API requests in this sample."})})]}),e[105]=te,e[106]=re):re=e[106];let oe;e[107]!==Q||e[108]!==re?(oe=a.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[Q,re]}),e[107]=Q,e[108]=re,e[109]=oe):oe=e[109];let ie;e[110]!==i?(ie=i&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Server event loop ",ca(i.eventLoopPercent)," · heap ",Bd(i.memory.heapUsedMb)," · RSS ",Bd(i.memory.rssMb)]}),e[110]=i,e[111]=ie):ie=e[111];let ae;e[112]!==E||e[113]!==V||e[114]!==H||e[115]!==oe||e[116]!==ie||e[117]!==B||e[118]!==U?(ae=a.jsxs("div",{className:B,children:[U,E,V,H,oe,ie]}),e[112]=E,e[113]=V,e[114]=H,e[115]=oe,e[116]=ie,e[117]=B,e[118]=U,e[119]=ae):ae=e[119];let de;e[120]!==S||e[121]!==P||e[122]!==ae?(de=a.jsx(S,{className:P,children:ae}),e[120]=S,e[121]=P,e[122]=ae,e[123]=de):de=e[123];let le;e[124]!==C||e[125]!==R||e[126]!==L||e[127]!==O||e[128]!==de?(le=a.jsxs(C,{className:R,children:[L,O,de]}),e[124]=C,e[125]=R,e[126]=L,e[127]=O,e[128]=de,e[129]=le):le=e[129];let se;return e[130]!==A||e[131]!==$||e[132]!==M||e[133]!==le?(se=a.jsx(A,{open:$,onOpenChange:M,children:le}),e[130]=A,e[131]=$,e[132]=M,e[133]=le,e[134]=se):se=e[134],se}function mY(n,e){return a.jsxs("div",{children:[e>0&&a.jsx(Qt,{}),a.jsx(J_,{metric:n})]},n.pid)}function pY(n){return setTimeout(n,1e3)}function hY(n,e){return n+e.cpuPercent}function gY(n,e){return e.cpuPercent-n.cpuPercent}function xY(n,e){return n+e.cpuPercent}async function bY(n){if(!n.ok)throw new Error(`Server monitor returned ${n.status}`);return n.json()}function vY(n){return`${n.title??`Pull request #${n.number}`}
|
|
129
129
|
${n.repo}${n.isDraft?" · draft":""}`}function Q_(n){return{href:n.url,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),"aria-label":`Pull request #${n.number}`,title:vY(n)}}function zc(n){const e=q.c(17),{pullRequests:t,max:s,compact:r,layout:o}=n,i=s===void 0?3:s,l=o===void 0?"chips":o;if(!(t!=null&&t.length))return null;if(l==="list"){let f;e[0]!==t?(f=t.map(wY),e[0]=t,e[1]=f):f=e[1];let m;return e[2]!==f?(m=a.jsx("div",{className:"flex flex-col gap-0.5",children:f}),e[2]=f,e[3]=m):m=e[3],m}let c,u;if(e[4]!==r||e[5]!==i||e[6]!==t){const f=t.slice(-i);if(e[9]!==i||e[10]!==t){const p=t.slice(0,-i);c=p.length>0&&a.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",title:p.map(yY).join(`
|
|
130
130
|
`),children:["+",p.length]}),e[9]=i,e[10]=t,e[11]=c}else c=e[11];let m;e[12]!==r?(m=p=>{const h=p.isDraft?Oj:Lj;return a.jsxs(Ue,{variant:p.isDraft?"outline":"secondary",render:a.jsx("a",{...Q_(p)}),className:G("shrink-0",r&&"px-1"),children:[a.jsx(h,{"data-icon":"inline-start"}),"#",p.number]},p.url)},e[12]=r,e[13]=m):m=e[13],u=f.map(m),e[4]=r,e[5]=i,e[6]=t,e[7]=c,e[8]=u}else c=e[7],u=e[8];let d;return e[14]!==c||e[15]!==u?(d=a.jsxs(a.Fragment,{children:[c,u]}),e[14]=c,e[15]=u,e[16]=d):d=e[16],d}function yY(n){return`#${n.number} ${n.title??n.repo}`}function wY(n){const e=n.isDraft?Oj:Lj;return a.jsxs("a",{...Q_(n),className:"flex items-center gap-1 text-foreground hover:underline",children:[a.jsx(e,{className:"size-2.5 shrink-0"}),a.jsxs("span",{className:"shrink-0",children:["#",n.number]}),n.title&&a.jsx("span",{className:"truncate text-muted-foreground",children:n.title})]},n.url)}const SY=y.memo(function(e){const t=q.c(34),{session:s,sessionSource:r,isLive:o,pullRequests:i,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}=e;let p;if(t[0]!==r){const A=r?Io(r.fileName):null;p=A?N0(A.agentId):null,t[0]=r,t[1]=p}else p=t[1];const h=p;let g;t[2]!==s.turns?(g=s.turns.some(NY),t[2]=s.turns,t[3]=g):g=t[3];const x=g;let b;t[4]!==s.rawMessages||t[5]!==(r==null?void 0:r.dirName)?(b=na(r==null?void 0:r.dirName).contextWindow?s.rawMessages:[],t[4]=s.rawMessages,t[5]=r==null?void 0:r.dirName,t[6]=b):b=t[6];const w=b;let v;t[7]===Symbol.for("react.memo_cache_sentinel")?(v=a.jsx("div",{className:G(Qn,"flex h-8 min-w-0 items-center gap-2 pl-1 pr-3")}),t[7]=v):v=t[7];let k;t[8]!==l||t[9]!==c||t[10]!==u||t[11]!==f||t[12]!==d||t[13]!==m||t[14]!==s||t[15]!==r?(k=r?a.jsx(jY,{session:s,sessionSource:r,copied:l,creatingSession:c,onCopyResume:u,onNewSession:d,onDuplicateSession:f,onOpenTerminal:m}):a.jsx("button",{type:"button",onClick:u,className:"truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground",children:l?"Copied":s.slug||s.sessionId.slice(0,8)}),t[8]=l,t[9]=c,t[10]=u,t[11]=f,t[12]=d,t[13]=m,t[14]=s,t[15]=r,t[16]=k):k=t[16];let j;t[17]!==o?(j=o&&a.jsx(om,{"aria-label":"Session is live"}),t[17]=o,t[18]=j):j=t[18];let _;t[19]!==w?(_=a.jsx(X_,{rawMessages:w}),t[19]=w,t[20]=_):_=t[20];let N;t[21]!==k||t[22]!==j||t[23]!==_?(N=a.jsxs(Ut,{delay:200,render:v,children:[k,j,_]}),t[21]=k,t[22]=j,t[23]=_,t[24]=N):N=t[24];let S;t[25]!==i||t[26]!==w||t[27]!==s||t[28]!==h||t[29]!==x?(S=a.jsx(Bt,{role:"tooltip",side:"bottom",align:"start",sideOffset:6,className:"p-3",children:a.jsx(kY,{session:s,thinkingEnabled:x,subAgentLabel:h,pullRequests:i,rawMessages:w})}),t[25]=i,t[26]=w,t[27]=s,t[28]=h,t[29]=x,t[30]=S):S=t[30];let C;return t[31]!==N||t[32]!==S?(C=a.jsxs(Ft,{children:[N,S]}),t[31]=N,t[32]=S,t[33]=C):C=t[33],C});function _i(n){const e=q.c(7),{label:t,children:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"w-24 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex gap-3",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function kY(n){const e=q.c(33),{session:t,thinkingEnabled:s,subAgentLabel:r,pullRequests:o,rawMessages:i}=n;let l,c,u,d,f,m,p;if(e[0]!==o||e[1]!==i||e[2]!==t.branchedFrom||e[3]!==t.gitBranch||e[4]!==t.model||e[5]!==r||e[6]!==s){const g=v4(i),x=t.branchedFrom;l="flex min-w-64 max-w-96 flex-col gap-1.5 text-xs",e[14]!==t.model||e[15]!==s?(c=t.model&&a.jsxs(_i,{label:"Model",children:[a.jsx("span",{children:xi(t.model)}),s&&a.jsx("span",{className:"text-muted-foreground",children:"· thinking"})]}),e[14]=t.model,e[15]=s,e[16]=c):c=e[16],e[17]!==t.gitBranch?(u=t.gitBranch&&a.jsx(_i,{label:"Branch",children:a.jsx("span",{className:"truncate font-mono",children:t.gitBranch})}),e[17]=t.gitBranch,e[18]=u):u=e[18],e[19]!==o?(d=o.length>0&&a.jsx(_i,{label:"Pull requests",children:a.jsx(zc,{pullRequests:o})}),e[19]=o,e[20]=d):d=e[20],e[21]!==r?(f=r&&a.jsx(_i,{label:"Agent",children:r}),e[21]=r,e[22]=f):f=e[22],e[23]!==x?(m=x&&a.jsxs(_i,{label:"Duplicated from",children:[x.sessionId.slice(0,8),x.turnIndex!=null?` at turn ${x.turnIndex+1}`:""]}),e[23]=x,e[24]=m):m=e[24],p=g&&a.jsxs(_i,{label:"Context",children:[Ct(Math.max(0,g.compactAt-g.used))," left before compact ·"," ",Ct(g.used)," / ",Ct(g.limit)]}),e[0]=o,e[1]=i,e[2]=t.branchedFrom,e[3]=t.gitBranch,e[4]=t.model,e[5]=r,e[6]=s,e[7]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=m,e[13]=p}else l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],m=e[12],p=e[13];let h;return e[25]!==l||e[26]!==c||e[27]!==u||e[28]!==d||e[29]!==f||e[30]!==m||e[31]!==p?(h=a.jsxs("div",{className:l,children:[c,u,d,f,m,p]}),e[25]=l,e[26]=c,e[27]=u,e[28]=d,e[29]=f,e[30]=m,e[31]=p,e[32]=h):h=e[32],h}function jY(n){const e=q.c(55),{session:t,sessionSource:s,copied:r,creatingSession:o,onCopyResume:i,onNewSession:l,onDuplicateSession:c,onOpenTerminal:u}=n,{dispatch:d}=ln(),f=!!(t.cwd||s.dirName);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=Bo(),e[0]=m):m=e[0];const p=m;let h;e[1]!==t.sessionId||e[2]!==t.slug?(h=t.slug||t.sessionId.slice(0,8),e[1]=t.sessionId,e[2]=t.slug,e[3]=h):h=e[3];const g=h;let x;e[4]!==t.cwd||e[5]!==g?(x=t.cwd?`${kr(t.cwd)} / ${g}`:g,e[4]=t.cwd,e[5]=g,e[6]=x):x=e[6];const b=x;let w;e[7]!==t.cwd||e[8]!==s.dirName?(w={path:t.cwd,dirName:s.dirName},e[7]=t.cwd,e[8]=s.dirName,e[9]=w):w=e[9];const v=w;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=ht("hostFiles"),e[10]=k):k=e[10];const j=k;let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=j&&(!p||l0()),e[11]=_):_=e[11];const N=_,S=j&&!p;let C;e[12]!==d||e[13]!==s.dirName?(C=function(){y.startTransition(()=>{d({type:"GO_HOME",isMobile:!1}),d({type:"SET_DASHBOARD_PROJECT",dirName:s.dirName})})},e[12]=d,e[13]=s.dirName,e[14]=C):C=e[14];const A=C,T=`Copy resume command for ${b}; open session actions with the context menu`;let I;e[15]!==i||e[16]!==T?(I=a.jsx("button",{type:"button",onClick:i,className:"flex min-w-0 max-w-80 items-center gap-1.5 truncate rounded-full px-1.5 py-1 text-sm font-medium text-foreground transition-colors hover:bg-accent","aria-label":T,"aria-haspopup":"menu",title:"Click to copy resume command. Right-click for session actions."}),e[15]=i,e[16]=T,e[17]=I):I=e[17];let E;e[18]!==r||e[19]!==t.cwd||e[20]!==g?(E=r?a.jsxs("span",{className:"flex items-center gap-1.5 text-success",children:[a.jsx(Ht,{className:"size-3"})," Copied"]}):a.jsxs(a.Fragment,{children:[t.cwd&&a.jsx("span",{className:"truncate text-muted-foreground",children:kr(t.cwd)}),t.cwd&&a.jsx("span",{className:"text-muted-foreground/50",children:"/"}),a.jsx("span",{className:"truncate",children:g})]}),e[18]=r,e[19]=t.cwd,e[20]=g,e[21]=E):E=e[21];let P;e[22]!==E||e[23]!==I?(P=a.jsx(tm,{render:I,children:E}),e[22]=E,e[23]=I,e[24]=P):P=e[24];let R;e[25]!==l||e[26]!==t.cwd||e[27]!==s.dirName?(R=()=>l(s.dirName,t.cwd),e[25]=l,e[26]=t.cwd,e[27]=s.dirName,e[28]=R):R=e[28];let L;e[29]!==o?(L=o?a.jsx(Pn,{className:"size-3.5"}):a.jsx(xr,{className:"size-3.5"}),e[29]=o,e[30]=L):L=e[30];let O;e[31]!==o||e[32]!==R||e[33]!==L?(O=a.jsxs(Mn,{disabled:o,onClick:R,children:[L,"New session in this project"]}),e[31]=o,e[32]=R,e[33]=L,e[34]=O):O=e[34];let $;e[35]!==c?($=c&&a.jsxs(Mn,{onClick:c,children:[a.jsx(Cs,{className:"size-3.5"}),"Duplicate this session"]}),e[35]=c,e[36]=$):$=e[36];let M;e[37]!==f||e[38]!==v?(M=f&&(N||S)&&a.jsxs(a.Fragment,{children:[a.jsx(la,{}),N&&a.jsxs(Mn,{onClick:()=>BC(v),children:[a.jsx(Y1,{className:"size-3.5"}),"Open project in editor"]}),S&&a.jsxs(Mn,{onClick:()=>WC(v),children:[a.jsx(mc,{className:"size-3.5"}),"Reveal in file manager"]})]}),e[37]=f,e[38]=v,e[39]=M):M=e[39];let D;e[40]!==u?(D=u&&!p&&ht("terminal")&&a.jsxs(Mn,{onClick:u,children:[a.jsx(ya,{className:"size-3.5"}),"Open terminal in project"]}),e[40]=u,e[41]=D):D=e[41];let F;e[42]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(la,{}),e[42]=F):F=e[42];let z;e[43]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsx(qr,{className:"size-3.5"}),e[43]=z):z=e[43];let B;e[44]!==A?(B=a.jsxs(Mn,{onClick:A,children:[z,"View all sessions in this project"]}),e[44]=A,e[45]=B):B=e[45];let U;e[46]!==O||e[47]!==$||e[48]!==M||e[49]!==D||e[50]!==B?(U=a.jsxs(nm,{className:"min-w-56",children:[O,$,M,D,F,B]}),e[46]=O,e[47]=$,e[48]=M,e[49]=D,e[50]=B,e[51]=U):U=e[51];let W;return e[52]!==P||e[53]!==U?(W=a.jsxs(em,{children:[P,U]}),e[52]=P,e[53]=U,e[54]=W):W=e[54],W}function NY(n){return n.thinking.length>0}const Za="Could not reach the server";async function gu(n,e){try{return await Ee(n,e)}catch{return null}}function CY(){const n=q.c(15);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0];const[t,s]=y.useState(e),[r,o]=y.useState(null),i=y.useRef(!0);let l,c;n[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>(i.current=!0,()=>{i.current=!1}),c=[],n[1]=l,n[2]=c):(l=n[1],c=n[2]),y.useEffect(l,c);let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=async()=>{const _=await gu("/api/shares");if(!(_!=null&&_.ok))return;const N=await _.json().catch(AY);i.current&&Array.isArray(N)&&s(N)},n[3]=u):u=n[3];const d=u;let f,m;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{d()},m=[d],n[4]=f,n[5]=m):(f=n[4],m=n[5]),y.useEffect(f,m);let p;n[6]===Symbol.for("react.memo_cache_sentinel")?(p=async _=>{o(null);const N=await gu("/api/shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:_})});if(!(N!=null&&N.ok))return i.current&&o(await kl(N,Za)),null;const S=await N.json().catch(TY);if(!(S!=null&&S.passphrase)||!S.share)return i.current&&o(Za),null;const C=S.share;return i.current&&s(A=>[...A.filter(T=>T.sessionId!==C.sessionId),C]),S.passphrase},n[6]=p):p=n[6];const h=p;let g;n[7]===Symbol.for("react.memo_cache_sentinel")?(g=async _=>{o(null);const N=await gu(`/api/shares/${encodeURIComponent(_)}/regenerate`,{method:"POST"});if(!(N!=null&&N.ok))return i.current&&o(await kl(N,Za)),null;const S=await N.json().catch(EY);return S!=null&&S.passphrase?(d(),S.passphrase):(i.current&&o(Za),null)},n[7]=g):g=n[7];const x=g;let b;n[8]===Symbol.for("react.memo_cache_sentinel")?(b=async _=>{o(null);const N=await gu(`/api/shares/${encodeURIComponent(_)}`,{method:"DELETE"});if(!(N!=null&&N.ok)){i.current&&o(await kl(N,Za));return}i.current&&s(S=>S.filter(C=>C.sessionId!==_))},n[8]=b):b=n[8];const w=b;let v;n[9]!==t?(v=async()=>{const _=t.map(_Y);for(const N of _)await w(N)},n[9]=t,n[10]=v):v=n[10];const k=v;let j;return n[11]!==r||n[12]!==k||n[13]!==t?(j={shares:t,error:r,refresh:d,create:h,regenerate:x,revoke:w,revokeAll:k},n[11]=r,n[12]=k,n[13]=t,n[14]=j):j=n[14],j}function _Y(n){return n.sessionId}function EY(){return null}function TY(){return null}function AY(){return null}const IY=5e3,PY="••••";function $Y(n){return n===0?"No guests connected":n===1?"1 guest connected":`${n} guests connected`}function RY({sessionId:n}){const{config:{networkAccessDisabled:e}}=ln(),{shares:t,error:s,refresh:r,create:o,regenerate:i,revoke:l}=CY(),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),[h,g]=Kr(),[x,b]=Kr(),w=t.find(_=>_.sessionId===n)??null,v=`${window.location.origin}${yM(n)}`;y.useEffect(()=>f(null),[n]),y.useEffect(()=>{if(!c)return;r();const _=setInterval(()=>void r(),IY);return()=>clearInterval(_)},[c,r]);async function k(_){p(!0);try{await _()}finally{p(!1)}}const j=e&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Network access is off, so this link only works on this machine."});return a.jsxs(Ia,{open:c,onOpenChange:_=>{u(_),_||f(null)},children:[a.jsx(Pa,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":w?"Session is shared":"Share session",className:G(w&&"bg-primary/15 text-primary hover:bg-primary/25")}),children:a.jsx(GP,{"data-icon":"inline-start"})}),a.jsx($a,{align:"end",sideOffset:6,className:"w-80 p-3",children:w?a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:v}),a.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Copy link",onClick:()=>g(v),children:h?a.jsx(Ht,{"data-icon":"inline-start"}):a.jsx(Cs,{"data-icon":"inline-start"})})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono text-[11px]",children:d??PY}),a.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Regenerate passphrase",disabled:m,onClick:()=>k(async()=>{f(await i(n))}),children:a.jsx(Fn,{"data-icon":"inline-start"})})]}),d?a.jsx(J,{variant:"secondary",size:"xs",onClick:()=>b(`${v}
|
|
131
131
|
Passphrase: ${d}`),children:x?"Copied":"Copy link & passphrase"}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"The passphrase is only shown once. Regenerate to get a new one."}),j,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsxs("div",{className:"flex items-center justify-between gap-2 border-t pt-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:$Y(w.guests)}),a.jsx(J,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",disabled:m,onClick:()=>k(async()=>{await l(n),f(null)}),children:"Stop sharing"})]})]}):a.jsxs("div",{className:"flex flex-col gap-2.5",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone with the link and passphrase can read and join this session."}),j,s&&a.jsx("p",{className:"text-xs text-destructive",children:s}),a.jsx(J,{size:"xs",disabled:m,onClick:()=>k(async()=>{f(await o(n))}),children:"Enable sharing"})]})})]})}function L0(n,e,t){if(!(n===void 0||!Number.isFinite(n)))return{utilization:Math.min(100,Math.max(0,n)),...e===void 0?{}:{resetsAt:e},...t===void 0?{}:{label:t}}}function jt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function Ws(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Co(n){return typeof n=="string"?n:void 0}function wo(n){return n?L0(Ws(n.utilization),Co(n.resets_at)):void 0}function eE(n){if(n)return{isEnabled:!!n.is_enabled,monthlyLimit:Ws(n.monthly_limit),usedCredits:Ws(n.used_credits),utilization:Ws(n.utilization)}}function OY(n){return{fiveHour:wo(jt(n.five_hour)),sevenDay:wo(jt(n.seven_day)),sevenDayOpus:wo(jt(n.seven_day_opus)),sevenDaySonnet:wo(jt(n.seven_day_sonnet)),extraUsage:eE(jt(n.extra_usage)),subscriptionType:Co(n.subscriptionType)}}function LY(n){if(n.available!==!0)return null;const e=jt(n.usage),t=jt(e==null?void 0:e.rate_limits),s=jt(n.account),r={fiveHour:wo(jt(t==null?void 0:t.five_hour)),sevenDay:wo(jt(t==null?void 0:t.seven_day)),sevenDayOpus:wo(jt(t==null?void 0:t.seven_day_opus)),sevenDaySonnet:wo(jt(t==null?void 0:t.seven_day_sonnet)),extraUsage:eE(jt(t==null?void 0:t.extra_usage)),subscriptionType:Co(e==null?void 0:e.subscription_type)??Co(s==null?void 0:s.subscriptionType)};return r.fiveHour||r.sevenDay||r.extraUsage||r.subscriptionType?r:null}function MY(n){const e=Ws(n);if(e!==void 0)return new Date(e<1e10?e*1e3:e).toISOString()}function zY(n,e){const t=Ws(n);return t===void 0||t<=0?e:t%1440===0?`${t/1440}-day`:t%60===0?`${t/60}-hour`:`${t}-minute`}function ww(n,e){if(n)return L0(Ws(n.usedPercent),MY(n.resetsAt),zY(n.windowDurationMins,e))}const DY={free:"Free",go:"Go",plus:"Plus",pro:"Pro (More)",prolite:"Pro",promax:"Pro (Max)",team:"Team",business:"Business",ent26:"Enterprise",enterprise:"Enterprise",edu:"Edu",edu_plus:"Edu Plus",edu_pro:"Edu Pro"};function FY(n){var d,f,m;if(n.available!==!0)return null;const e=jt((d=jt(n.rateLimits))==null?void 0:d.rateLimits),t=jt((f=jt(n.account))==null?void 0:f.account),s=jt((m=jt(n.usage))==null?void 0:m.summary),r=jt(e==null?void 0:e.credits),o=ww(jt(e==null?void 0:e.primary),"Primary"),i=ww(jt(e==null?void 0:e.secondary),"Secondary"),l=s==null?void 0:s.lifetimeTokens,c=Ws(l)??(typeof l=="string"&&Number.isSafeInteger(Number(l))?Number(l):void 0),u=Co(e==null?void 0:e.planType)??Co(t==null?void 0:t.planType);return!o&&!i&&c===void 0?null:{fiveHour:o,sevenDay:i,subscriptionType:u?DY[u]??u:void 0,lifetimeTokens:c,creditBalance:Co(r==null?void 0:r.balance),creditsUnlimited:(r==null?void 0:r.unlimited)===!0}}function Sw(n,e){if(!n)return;const t=Ws(n.remainingPercentage),s=Ws(n.usedRequests),r=Ws(n.entitlementRequests);let o;return t!==void 0?o=100-t:n.isUnlimitedEntitlement===!0||r===-1?o=0:s!==void 0&&r!==void 0&&r>0&&(o=s/r*100),L0(o,Co(n.resetDate),e)}function UY(n){var s;if(n.available!==!0)return null;const e=jt((s=jt(n.quota))==null?void 0:s.quotaSnapshots),t=Sw(jt(e==null?void 0:e.chat),"Chat")??Sw(jt(e==null?void 0:e.premium_interactions),"Premium interactions");return t?{fiveHour:t}:null}const BY={acp:{endpoint:"/api/acp/runtime",read:()=>({})},claude:{endpoint:"/api/claude/runtime",read:LY,legacy:{endpoint:"/api/usage",read:OY}},codex:{endpoint:"/api/codex/runtime",read:FY},copilot:{endpoint:"/api/copilot/runtime",read:UY}};function WY(n){return BY[n]}const qY=300*1e3;function VY(n=Uo){const e=xn("viewUsage"),[t,s]=y.useState(null),[r,o]=y.useState(!1),[i,l]=y.useState(!1),c=y.useRef(0),u=y.useRef(null),d=y.useCallback(async()=>{var h;if(!e)return;const f=++c.current;(h=u.current)==null||h.abort();const m=new AbortController;u.current=m;const p=()=>c.current===f&&!m.signal.aborted;o(!0);try{const g=WY(n);let x=await Ee(g.endpoint,{signal:m.signal}),b=g.read;if(g.legacy&&!x.ok&&!m.signal.aborted&&(x=await Ee(g.legacy.endpoint,{signal:m.signal}),b=g.legacy.read),!p())return;if(x.status===501||x.status===404){l(!1);return}if(!x.ok){l(!0);return}const w=await x.json();if(!p())return;const v=b(w);l(v!==null),s(v?{...v,agentKind:n,fetchedAt:Date.now()}:null)}catch{}finally{p()&&(u.current=null,o(!1))}},[n,e]);return y.useEffect(()=>{var m;if(s(null),l(!1),!e){o(!1),c.current+=1,(m=u.current)==null||m.abort(),u.current=null;return}d();const f=setInterval(d,qY);return()=>{var p;clearInterval(f),c.current+=1,(p=u.current)==null||p.abort(),u.current=null}},[n,e,d]),{usage:e?t:null,loading:e&&r,available:e&&i,refresh:d}}function tE(n){return n>=90?"danger":n>=80?"warning":n>=60?"caution":"nominal"}const nE={nominal:"text-muted-foreground",caution:"text-warning",warning:"text-warning",danger:"text-destructive"};function HY(n){var u;const e=q.c(31),{usage:t}=n;let s,r,o;if(e[0]!==t.agentKind||e[1]!==t.fetchedAt||e[2]!==t.fiveHour||e[3]!==t.sevenDay||e[4]!==t.sevenDayOpus||e[5]!==t.sevenDaySonnet||e[6]!==t.subscriptionType){const d=[];t.fiveHour&&d.push({label:t.fiveHour.label??"5-hour",pct:t.fiveHour.utilization,resetsAt:t.fiveHour.resetsAt}),t.sevenDay&&d.push({label:t.sevenDay.label??"7-day",pct:t.sevenDay.utilization,resetsAt:t.sevenDay.resetsAt}),t.sevenDayOpus&&d.push({label:"Opus",pct:t.sevenDayOpus.utilization,resetsAt:t.sevenDayOpus.resetsAt}),t.sevenDaySonnet&&d.push({label:"Sonnet",pct:t.sevenDaySonnet.utilization,resetsAt:t.sevenDaySonnet.resetsAt}),s="flex min-w-[200px] flex-col gap-2";let f;e[10]!==t.agentKind?(f=t.agentKind?Rf(t.agentKind):"Agent",e[10]=t.agentKind,e[11]=f):f=e[11];let m;e[12]!==f?(m=a.jsxs("span",{className:"text-xs font-medium uppercase tracking-wide",children:[f," usage"]}),e[12]=f,e[13]=m):m=e[13];let p;e[14]!==t.subscriptionType?(p=t.subscriptionType&&a.jsx(Ue,{variant:"secondary",children:t.subscriptionType}),e[14]=t.subscriptionType,e[15]=p):p=e[15],e[16]!==m||e[17]!==p?(r=a.jsxs("div",{className:"flex items-center justify-between",children:[m,p]}),e[16]=m,e[17]=p,e[18]=r):r=e[18],o=d.map(h=>{const g=h.resetsAt&&t.fetchedAt!=null?new Date(h.resetsAt).getTime()-t.fetchedAt:null,x=g!=null?Math.max(0,Math.round(g/36e5)):null,b=tE(h.pct);return a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:h.label}),a.jsxs("span",{className:G("font-semibold",nE[b]),children:[h.pct.toFixed(1),"%"]})]}),a.jsx(Nc,{value:Math.min(h.pct,100)}),x!=null&&a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Resets in ",x,"h"]})]},h.label)}),e[0]=t.agentKind,e[1]=t.fetchedAt,e[2]=t.fiveHour,e[3]=t.sevenDay,e[4]=t.sevenDayOpus,e[5]=t.sevenDaySonnet,e[6]=t.subscriptionType,e[7]=s,e[8]=r,e[9]=o}else s=e[7],r=e[8],o=e[9];let i;e[19]!==t.extraUsage?(i=((u=t.extraUsage)==null?void 0:u.isEnabled)&&t.extraUsage.usedCredits!=null&&t.extraUsage.monthlyLimit!=null&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(Qt,{}),"Extra: $",t.extraUsage.usedCredits.toFixed(2)," / $",t.extraUsage.monthlyLimit.toFixed(2)]}),e[19]=t.extraUsage,e[20]=i):i=e[20];let l;e[21]!==t.creditBalance||e[22]!==t.creditsUnlimited||e[23]!==t.lifetimeTokens?(l=(t.lifetimeTokens!=null||t.creditBalance||t.creditsUnlimited)&&a.jsxs("div",{className:"flex flex-col gap-1 pt-1 text-xs text-muted-foreground",children:[a.jsx(Qt,{}),t.lifetimeTokens!=null&&a.jsxs("div",{children:["Lifetime: ",Ct(t.lifetimeTokens)," tokens"]}),t.creditsUnlimited?a.jsx("div",{children:"Credits: Unlimited"}):t.creditBalance?a.jsxs("div",{children:["Credits: ",t.creditBalance]}):null]}),e[21]=t.creditBalance,e[22]=t.creditsUnlimited,e[23]=t.lifetimeTokens,e[24]=l):l=e[24];let c;return e[25]!==s||e[26]!==r||e[27]!==o||e[28]!==i||e[29]!==l?(c=a.jsxs("div",{className:s,children:[r,o,i,l]}),e[25]=s,e[26]=r,e[27]=o,e[28]=i,e[29]=l,e[30]=c):c=e[30],c}function KY(n){var k,j;const e=q.c(22),{agentKind:t}=n,s=t===void 0?Uo:t,{usage:r,loading:o,available:i,refresh:l}=VY(s);if(!i||!r)return null;const c=((k=r.fiveHour)==null?void 0:k.utilization)??((j=r.sevenDay)==null?void 0:j.utilization);if(c==null)return null;let u;e[0]!==r.agentKind?(u=r.agentKind?Rf(r.agentKind):"agent",e[0]=r.agentKind,e[1]=u):u=e[1];const d=`Refresh ${u} usage`;let f;e[2]!==o||e[3]!==l||e[4]!==d?(f=a.jsx(J,{type:"button",variant:"ghost",size:"xs","aria-label":d,onClick:l,disabled:o,className:"mr-1 font-mono"}),e[2]=o,e[3]=l,e[4]=d,e[5]=f):f=e[5];const m=nE[tE(c)],p=o&&"opacity-50";let h;e[6]!==m||e[7]!==p?(h=G("tabular-nums",m,p),e[6]=m,e[7]=p,e[8]=h):h=e[8];let g;e[9]!==c?(g=c.toFixed(0),e[9]=c,e[10]=g):g=e[10];let x;e[11]!==h||e[12]!==g?(x=a.jsxs("span",{className:h,children:[g,"%"]}),e[11]=h,e[12]=g,e[13]=x):x=e[13];let b;e[14]!==f||e[15]!==x?(b=a.jsx(Ut,{render:f,children:x}),e[14]=f,e[15]=x,e[16]=b):b=e[16];let w;e[17]!==r?(w=a.jsx(Bt,{side:"bottom",className:"p-3",children:a.jsx(HY,{usage:r})}),e[17]=r,e[18]=w):w=e[18];let v;return e[19]!==b||e[20]!==w?(v=a.jsxs(Ft,{children:[b,w]}),e[19]=b,e[20]=w,e[21]=v):v=e[21],v}function GY(n){const e=q.c(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={summary:null,loading:!1,error:null},e[0]=t):t=e[0];const[s,r]=y.useState(t),[o,i]=y.useState(0);let l;e[1]!==n?(l=()=>{const m=new AbortController;r(YY);const p=Intl.DateTimeFormat().resolvedOptions().timeZone;return Ee(`/api/usage-cost?days=${n}&tz=${encodeURIComponent(p)}`,{signal:m.signal}).then(async h=>{if(!h.ok)throw new Error(`Usage scan failed (${h.status})`);const g=await h.json();r({summary:g,loading:!1,error:null})}).catch(h=>{m.signal.aborted||r(g=>({...g,loading:!1,error:h instanceof Error?h.message:"Usage scan failed"}))}),()=>m.abort()},e[1]=n,e[2]=l):l=e[2];let c;e[3]!==n||e[4]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],y.useEffect(l,c);let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i(ZY),e[6]=u):u=e[6];const d=u;let f;return e[7]!==s?(f={...s,refresh:d},e[7]=s,e[8]=f):f=e[8],f}function ZY(n){return n+1}function YY(n){return{...n,loading:!0,error:null}}function XY(n){const e=n.trim().toLowerCase().replace(/\[[^\]]*\]$/,""),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}const JY=new Set(["<synthetic>","synthetic","opus","sonnet","haiku","fable"]);function QY(n,e){const t=XY(e);return t.length===0||JY.has(t)?null:n.get(t)??null}function eX(n,e){const t=n.longContextThresholdTokens,s=e.uncachedInputTokens+e.cachedInputTokens+e.cacheCreationTokens,r=t!==null&&s>t;return function(i,l,c){return i<=0?0:c===null||t===null?i*l:n.longContextPricing==="wholeRequest"?i*(r?c:l):i<=t?i*l:t*l+(i-t)*c}}function tX(n){return n.uncachedInputUsd+n.cachedInputUsd+n.cacheCreationUsd+n.outputUsd}function nX(n,e,t,s=null){const r=QY(n,e);if(r===null)return null;const o=Math.min(t.cacheCreation1hTokens,t.cacheCreationTokens),i=t.cacheCreationTokens-o,l=eX(r,t),c=s==="fast"?r.fastCostMultiplier:1;return{uncachedInputUsd:c*l(t.uncachedInputTokens,r.inputCostPerToken,r.inputCostPerTokenAboveThreshold),cachedInputUsd:c*l(t.cachedInputTokens,r.cacheReadCostPerToken,r.cacheReadCostPerTokenAboveThreshold),cacheCreationUsd:c*(l(i,r.cacheCreationCostPerToken,r.cacheCreationCostPerTokenAboveThreshold)+o*r.cacheCreation1hCostPerToken),outputUsd:c*l(t.outputTokens,r.outputCostPerToken,r.outputCostPerTokenAboveThreshold)}}function sX(n,e,t,s,r=null){const o=nX(n,e,t,r);return o===null?{costUsd:0,costSource:"unpriced"}:{costUsd:tX(o),costSource:"modelPriced"}}function M0(n){return n.uncachedInputTokens+n.cachedInputTokens+n.cacheCreationTokens+n.outputTokens}function rX(n,e,t){if(!e)return 0;const{costUsd:s,costSource:r}=sX(n,e,{uncachedInputTokens:t.input_tokens,cachedInputTokens:t.cache_read_input_tokens??0,cacheCreationTokens:t.cache_creation_input_tokens??0,cacheCreation1hTokens:0,outputTokens:t.output_tokens});return r==="unpriced"?0:s}const oX=[{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}],Gi=dN.map(n=>({key:n,label:yn(n).displayName,color:zO(n)}));function iX(n,e){const t=[],r=Date.parse(`${e}T00:00:00Z`);for(let o=Date.parse(`${n}T00:00:00Z`);o<=r;o+=864e5)t.push(new Date(o).toISOString().slice(0,10));return t}function kw(){return Object.fromEntries(Gi.map(({key:n})=>[n,{costUsd:0,tokens:0}]))}function aX(n){const e=new Map;for(const r of iX(n.sinceDay,n.untilDay))e.set(r,{day:r,byProvider:kw(),costUsd:0,tokens:0});const t=new Map,s={costUsd:0,tokens:0,cacheSavingsUsd:0,byProvider:kw(),days:[],models:[]};for(const r of n.buckets){const o=M0(r.totals);s.costUsd+=r.costUsd,s.tokens+=o,s.cacheSavingsUsd+=r.cacheSavingsUsd,s.byProvider[r.provider].costUsd+=r.costUsd,s.byProvider[r.provider].tokens+=o;const i=e.get(r.day);i&&(i.byProvider[r.provider].costUsd+=r.costUsd,i.byProvider[r.provider].tokens+=o,i.costUsd+=r.costUsd,i.tokens+=o);const l=`${r.provider}:${r.model}`;let c=t.get(l);c||(c={provider:r.provider,model:r.model,costUsd:0,tokens:0,unpriced:!0},t.set(l,c)),c.costUsd+=r.costUsd,c.tokens+=o,r.costSource!=="unpriced"&&(c.unpriced=!1)}return s.days=[...e.values()],s.models=[...t.values()].sort((r,o)=>o.costUsd-r.costUsd||o.tokens-r.tokens),s}function jw(n){const e=Date.parse(`${n}T00:00:00Z`);return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}).format(e)}const mp=720,pp=180,lX=18;function cX(n){const e=q.c(41),{days:t,metric:s}=n,[r,o]=y.useState(null);let i;e[0]!==s?(i=N=>s==="cost"?N.costUsd:N.tokens,e[0]=s,e[1]=i):i=e[1];const l=i;let c;if(e[2]!==t||e[3]!==l){let N;e[5]!==l?(N=S=>l(S),e[5]=l,e[6]=N):N=e[6],c=Math.max(...t.map(N)),e[2]=t,e[3]=l,e[4]=c}else c=e[4];const u=c;if(u<=0){let N;return e[7]===Symbol.for("react.memo_cache_sentinel")?(N=a.jsx("div",{className:"flex h-32 items-center justify-center text-xs text-muted-foreground",children:"No activity in this window."}),e[7]=N):N=e[7],N}const d=pp-lX,f=mp/t.length,m=Math.max(2,Math.min(28,f-2)),p=r!==null?t[r]:null;let h;e[8]!==p||e[9]!==s||e[10]!==l?(h=p&&a.jsx("div",{className:"pointer-events-none absolute left-0 right-0 top-0 z-10 flex justify-center",children:a.jsxs("div",{className:"rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-xs",children:[a.jsx("span",{className:"font-medium",children:jw(p.day)}),Gi.map(N=>{const{key:S,label:C,color:A}=N,T=p.byProvider[S];return l(T)<=0?null:a.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-1.5 rounded-full",style:{backgroundColor:A}}),C,": ",s==="cost"?ys(T.costUsd):Ct(T.tokens)]},S)}),a.jsx("span",{className:"ml-2 font-medium",children:s==="cost"?ys(p.costUsd):Ct(p.tokens)})]})}),e[8]=p,e[9]=s,e[10]=l,e[11]=h):h=e[11];const g=`Daily ${s==="cost"?"raw API cost":"processed tokens"} by provider`;let x,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),b=a.jsx("line",{x1:0,y1:d,x2:mp,y2:d,stroke:"var(--border)",strokeWidth:1}),e[12]=x,e[13]=b):(x=e[12],b=e[13]);let w;if(e[14]!==m||e[15]!==t||e[16]!==r||e[17]!==u||e[18]!==f||e[19]!==l){let N;e[21]!==m||e[22]!==r||e[23]!==u||e[24]!==f||e[25]!==l?(N=(S,C)=>{const A=C*f+(f-m)/2;let T=d;const I=r===C;return a.jsxs("g",{onMouseEnter:()=>o(C),children:[a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"transparent"}),I&&a.jsx("rect",{x:C*f,y:0,width:f,height:d,fill:"var(--foreground)",opacity:.05,rx:2}),Gi.map(E=>{const{key:P,color:R}=E,L=l(S.byProvider[P]);if(L<=0)return null;const O=L/u*(d-6);return T=T-O,a.jsx("rect",{x:A,y:T,width:m,height:Math.max(1,O-1.5),rx:1.5,fill:R,opacity:I?1:.85},P)})]},S.day)},e[21]=m,e[22]=r,e[23]=u,e[24]=f,e[25]=l,e[26]=N):N=e[26],w=t.map(N),e[14]=m,e[15]=t,e[16]=r,e[17]=u,e[18]=f,e[19]=l,e[20]=w}else w=e[20];let v;if(e[27]!==t||e[28]!==f){let N;e[30]!==t.length||e[31]!==f?(N=(S,C)=>C===0||C===t.length-1||t.length>10&&C%7===0&&C<t.length-3?a.jsx("text",{x:C*f+f/2,y:pp-4,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:jw(S.day)},S.day):null,e[30]=t.length,e[31]=f,e[32]=N):N=e[32],v=t.map(N),e[27]=t,e[28]=f,e[29]=v}else v=e[29];let k;e[33]!==g||e[34]!==w||e[35]!==v?(k=a.jsxs("svg",{viewBox:`0 0 ${mp} ${pp}`,className:"w-full",role:"img","aria-label":g,onMouseLeave:x,children:[b,w,v]}),e[33]=g,e[34]=w,e[35]=v,e[36]=k):k=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"mt-1 flex items-center gap-4",children:Gi.map(uX)}),e[37]=j):j=e[37];let _;return e[38]!==h||e[39]!==k?(_=a.jsxs("div",{className:"relative",children:[h,k,j]}),e[38]=h,e[39]=k,e[40]=_):_=e[40],_}function uX(n){const{key:e,label:t,color:s}=n;return a.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 rounded-full",style:{backgroundColor:s}}),t]},e)}function hp(n){const e=q.c(7),{label:t,value:s}=n;let r;e[0]!==t?(r=a.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==s?(o=a.jsx("span",{className:"text-sm font-medium text-foreground tabular-nums",children:s}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=a.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i}function dX(n){const e=q.c(68),{days:t}=n,{summary:s,loading:r,error:o,refresh:i}=GY(t),[l,c]=y.useState("cost");let u;e[0]!==s?(u=s?aX(s):null,e[0]=s,e[1]=u):u=e[1];const d=u;if(o){let F;e[2]!==i?(F=a.jsx(J,{variant:"outline",size:"sm",onClick:i,children:"Retry"}),e[2]=i,e[3]=F):F=e[3];let z;return e[4]!==o||e[5]!==F?(z=a.jsxs("div",{className:"flex flex-col items-center gap-2 py-10 text-sm text-muted-foreground",children:[o,F]}),e[4]=o,e[5]=F,e[6]=z):z=e[6],z}if(!d||!s){let F;return e[7]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"})," Scanning transcripts…"]}),e[7]=F):F=e[7],F}const f=r&&"opacity-60";let m;e[8]!==f?(m=G("flex flex-col gap-5",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==d.costUsd||e[11]!==d.tokens||e[12]!==l?(p=l==="cost"?ys(d.costUsd):Ct(d.tokens),e[10]=d.costUsd,e[11]=d.tokens,e[12]=l,e[13]=p):p=e[13];let h;e[14]!==p?(h=a.jsx("span",{className:"text-3xl font-semibold text-foreground tabular-nums",children:p}),e[14]=p,e[15]=h):h=e[15];const g=l==="cost"?"raw API price":"processed tokens";let x;e[16]!==s.distinctSessions||e[17]!==g?(x=a.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.distinctSessions," sessions · ",g]}),e[16]=s.distinctSessions,e[17]=g,e[18]=x):x=e[18];let b;e[19]!==h||e[20]!==x?(b=a.jsxs("div",{className:"flex flex-col gap-0.5",children:[h,x]}),e[19]=h,e[20]=x,e[21]=b):b=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=["cost","tokens"],e[22]=w):w=e[22];let v;e[23]!==l?(v=a.jsx("div",{className:"flex rounded-md border p-0.5",children:w.map(F=>a.jsx(J,{variant:l===F?"secondary":"ghost",size:"xs",onClick:()=>c(F),children:F==="cost"?"Cost":"Tokens"},F))}),e[23]=l,e[24]=v):v=e[24];let k;e[25]!==d.byProvider||e[26]!==l?(k=Gi.map(F=>{const{key:z,label:B}=F,U=d.byProvider[z];return U.costUsd===0&&U.tokens===0?null:a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[B,": ",l==="cost"?ys(U.costUsd):Ct(U.tokens)]},z)}),e[25]=d.byProvider,e[26]=l,e[27]=k):k=e[27];let j;e[28]!==v||e[29]!==k?(j=a.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[v,k]}),e[28]=v,e[29]=k,e[30]=j):j=e[30];let _;e[31]!==j||e[32]!==b?(_=a.jsxs("div",{className:"flex items-end justify-between gap-4",children:[b,j]}),e[31]=j,e[32]=b,e[33]=_):_=e[33];let N;e[34]!==d.days||e[35]!==l?(N=a.jsx(cX,{days:d.days,metric:l}),e[34]=d.days,e[35]=l,e[36]=N):N=e[36];let S;e[37]!==d.tokens?(S=Ct(d.tokens),e[37]=d.tokens,e[38]=S):S=e[38];let C;e[39]!==S?(C=a.jsx(hp,{label:"Processed tokens",value:S}),e[39]=S,e[40]=C):C=e[40];let A;e[41]!==d.cacheSavingsUsd?(A=ys(d.cacheSavingsUsd),e[41]=d.cacheSavingsUsd,e[42]=A):A=e[42];let T;e[43]!==A?(T=a.jsx(hp,{label:"Cache savings",value:A}),e[43]=A,e[44]=T):T=e[44];const I=String(s.scannedFiles);let E;e[45]!==I?(E=a.jsx(hp,{label:"Files scanned",value:I}),e[45]=I,e[46]=E):E=e[46];let P;e[47]!==C||e[48]!==T||e[49]!==E?(P=a.jsxs("div",{className:"grid grid-cols-3 gap-x-6 gap-y-3 border-t pt-3",children:[C,T,E]}),e[47]=C,e[48]=T,e[49]=E,e[50]=P):P=e[50];let R;e[51]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx("thead",{children:a.jsxs("tr",{className:"border-b text-left text-xs text-muted-foreground",children:[a.jsx("th",{className:"py-1.5 font-normal",children:"Model"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Cost"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Share"}),a.jsx("th",{className:"py-1.5 text-right font-normal",children:"Tokens"})]})}),e[51]=R):R=e[51];let L;if(e[52]!==d.costUsd||e[53]!==d.models){let F;e[55]!==d.costUsd?(F=z=>{var B;return a.jsxs("tr",{className:"border-b border-border/50",children:[a.jsx("td",{className:"max-w-56 truncate py-1.5 text-foreground",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{"aria-hidden":!0,className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(B=Gi.find(U=>U.key===z.provider))==null?void 0:B.color}}),z.model]})}),a.jsx("td",{className:"py-1.5 text-right text-foreground tabular-nums",children:z.unpriced?"—":ys(z.costUsd)}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:d.costUsd>0&&!z.unpriced?`${(z.costUsd/d.costUsd*100).toFixed(1)}%`:"—"}),a.jsx("td",{className:"py-1.5 text-right text-muted-foreground tabular-nums",children:Ct(z.tokens)})]},`${z.provider}:${z.model}`)},e[55]=d.costUsd,e[56]=F):F=e[56],L=d.models.map(F),e[52]=d.costUsd,e[53]=d.models,e[54]=L}else L=e[54];let O;e[57]!==L?(O=a.jsxs("table",{className:"w-full text-sm",children:[R,a.jsx("tbody",{children:L})]}),e[57]=L,e[58]=O):O=e[58];const $=s.pricing.status==="unavailable"?" (rate table unavailable — costs incomplete)":"";let M;e[59]!==$?(M=a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Raw API-equivalent prices from LiteLLM rates",$," ","— not what a subscription bills."]}),e[59]=$,e[60]=M):M=e[60];let D;return e[61]!==_||e[62]!==N||e[63]!==P||e[64]!==O||e[65]!==M||e[66]!==m?(D=a.jsxs("div",{className:m,children:[_,N,P,O,M]}),e[61]=_,e[62]=N,e[63]=P,e[64]=O,e[65]=M,e[66]=m,e[67]=D):D=e[67],D}function fX(n){const e=q.c(15),{open:t,onOpenChange:s}=n,[r,o]=y.useState(30);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsxs("div",{children:[a.jsx(Js,{children:"API usage"}),a.jsx(Qs,{children:"What this machine's agent usage would cost at raw API prices."})]}),e[0]=i):i=e[0];let l;e[1]!==r?(l=oX.map(m=>a.jsx(J,{variant:r===m.days?"secondary":"ghost",size:"xs",onClick:()=>o(m.days),children:m.label},m.days)),e[1]=r,e[2]=l):l=e[2];let c;e[3]!==l?(c=a.jsx(to,{children:a.jsxs("div",{className:"flex items-center justify-between gap-4 pr-6",children:[i,a.jsx("div",{className:"flex rounded-md border p-0.5",children:l})]})}),e[3]=l,e[4]=c):c=e[4];let u;e[5]!==r||e[6]!==t?(u=t&&a.jsx(dX,{days:r}),e[5]=r,e[6]=t,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs(Xs,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==s||e[12]!==t||e[13]!==d?(f=a.jsx(Ys,{open:t,onOpenChange:s,children:d}),e[11]=s,e[12]=t,e[13]=d,e[14]=f):f=e[14],f}async function mX(n,e){try{return(await os("/api/archive-sessions",{sessionIds:n,archived:e})).ok}catch{return!1}}function sE(){const n=Ar(),e=n==null?void 0:n.setArchived,t=n==null?void 0:n.refresh,s=y.useCallback(async(r,o,i)=>{if(e==null||e(r,o),!await mX([...r],o)){e==null||e(r,!o),Kn.error(o?"Could not archive session":"Could not restore session");return}t==null||t(),i&&Kn(i,{action:{label:"Undo",onClick:()=>{s(r,!o,null)}}})},[e,t]);return s}function rE(n,e,t){const s=q.c(13),r=Ar(),o=sE();if(!r||!t)return null;let i;s[0]!==r||s[1]!==n?(i=r.isArchived(n),s[0]=r,s[1]=n,s[2]=i):i=s[2];const l=i,c=l?"Restore from archive":"Archive session",u=l?gf:ks,d=e&&!l?"Stop the session before archiving it":void 0;let f;s[3]!==o||s[4]!==l||s[5]!==n?(f=()=>{o([n],!l,l?"Session restored":"Session archived")},s[3]=o,s[4]=l,s[5]=n,s[6]=f):f=s[6];let m;return s[7]!==l||s[8]!==c||s[9]!==u||s[10]!==d||s[11]!==f?(m={archived:l,label:c,icon:u,disabledReason:d,toggle:f},s[7]=l,s[8]=c,s[9]=u,s[10]=d,s[11]=f,s[12]=m):m=s[12],m}const pX=/https:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/,hX=/(?:^|[\n;&|(`])[ \t]*(?:[A-Za-z_]\w*=\S*[ \t]+)*gh[ \t]+pr[ \t]+create\b/,gp=String.raw`(?:--title|(?:^|\s)-t)(?:=|\s+)`,gX=[new RegExp(`${gp}"((?:[^"\\\\]|\\\\.)*)"`),new RegExp(`${gp}'([^']*)'`),new RegExp(`${gp}(\\S+)`)];function xX(n){const e=n.command??n.cmd;if(typeof e=="string")return[e];if(Array.isArray(e)){const i=e.filter(l=>typeof l=="string");return[i.join(" "),...i]}const t=n.source;if(typeof t!="string")return[];const s=[],r=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*"((?:\\.|[^"\\])*)"/g;for(const i of t.matchAll(r))try{s.push(JSON.parse(`"${i[1]}"`))}catch{}const o=/(?:["'](?:cmd|command)["']|\b(?:cmd|command))\s*:\s*`([^`]*)`/g;for(const i of t.matchAll(o))s.push(i[1]);return s}function bX(n){return xX(n).find(e=>hX.test(e))??null}function vX(n){for(const e of gX){const t=e.exec(n);if(t)return t[1].replace(/\\(.)/g,"$1")}return null}function yX(){const n=[],e=new Set;function t(s){e.has(s.url)||(e.add(s.url),n.push(s))}return{pullRequests:n,add:t,record(s,r,o,i){const l=pX.exec(s);l&&t({url:l[0],number:Number(l[3]),repo:`${l[1]}/${l[2]}`,title:vX(r),isDraft:/(?:^|\s)--draft(?:\s|$)/.test(r),toolCallId:o,timestamp:i})}}}function wX(n){const e=yX();for(const t of n)for(const s of t.toolCalls){if(s.isError||!s.result)continue;const r=bX(s.input);r&&e.record(s.result,r,s.id,s.timestamp)}return e.pullRequests}function SX(...n){const e=new Map;for(const t of n)for(const s of t??[])e.has(s.url)||e.set(s.url,s);return[...e.values()].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}const ao="flex h-8 items-center px-0.5",kX=y.memo(function(e){var fe;const t=q.c(123),{showSidebar:s,sidebarRendered:r,sidebarShortcut:o,killing:i,creatingSession:l,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d,onBackToMain:f,onShowWorkflows:m,workflowCount:p,onToggleSidebar:h,onKillAll:g,onOpenSettings:x,onLogout:b,onOpenMainView:w}=e,v=r===void 0?s:r,{config:k}=ln(),{networkUrl:j,defaultAgentKind:_}=k,{session:N,sessionSource:S,isLive:C,permissions:A,actions:T}=yt(),I=Ar(),{AccountControl:E,SessionHeaderActions:P}=Tr(),R=xn("viewUsage"),[L,O]=y.useState(!1),[$,M]=y.useState(!1),[D,F]=Kr(),z=N==null?void 0:N.turns;let B;t[0]!==(I==null?void 0:I.sessions)||t[1]!==(N==null?void 0:N.sessionId)?(B=(fe=I==null?void 0:I.sessions.find(ke=>ke.sessionId===(N==null?void 0:N.sessionId)))==null?void 0:fe.pullRequests,t[0]=I==null?void 0:I.sessions,t[1]=N==null?void 0:N.sessionId,t[2]=B):B=t[2];const U=B;let W;t[3]!==U||t[4]!==z?(W=SX(wX(z??[]),U),t[3]=U,t[4]=z,t[5]=W):W=t[5];const V=W,H=rE((N==null?void 0:N.sessionId)??"",C,A.archive);let K;t[6]!==_||t[7]!==S?(K=S?S.agentKind??an(S.dirName):_,t[6]=_,t[7]=S,t[8]=K):K=t[8];const Z=K;let Y;t[9]!==S?(Y=S?Io(S.fileName)!==null:!1,t[9]=S,t[10]=Y):Y=t[10];const X=Y;let ee;t[11]!==F||t[12]!==N||t[13]!==(S==null?void 0:S.agentKind)||t[14]!==(S==null?void 0:S.dirName)?(ee=function(){if(!N)return;const Ge=(S==null?void 0:S.agentKind)??an((S==null?void 0:S.dirName)??null);F(ox(Ge,N.sessionId,N.cwd))},t[11]=F,t[12]=N,t[13]=S==null?void 0:S.agentKind,t[14]=S==null?void 0:S.dirName,t[15]=ee):ee=t[15];const Q=ee;let ne;t[16]!==j?(ne=function(){j&&kf(j).then(jX)},t[16]=j,t[17]=ne):ne=t[17];const te=ne;let re,oe;t[18]===Symbol.for("react.memo_cache_sentinel")?(oe=a.jsx("div",{"aria-hidden":!0,className:"drag-strip absolute inset-x-0 top-0 z-10 h-10"}),re=a.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-background from-50% to-transparent"}),t[18]=re,t[19]=oe):(re=t[18],oe=t[19]);const ie=!v&&"window-inset-start";let ae;t[20]!==ie?(ae=G("electron-no-drag pointer-events-auto flex min-w-0 items-center gap-1.5",ie),t[20]=ie,t[21]=ae):ae=t[21];let de;t[22]!==h||t[23]!==s||t[24]!==o?(de=!s&&a.jsx(Nw,{icon:YP,label:`Show sidebar (${o})`,onClick:h}),t[22]=h,t[23]=s,t[24]=o,t[25]=de):de=t[25];let le;t[26]!==X||t[27]!==f||t[28]!==N?(le=N&&X&&f&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:f,className:G(Qn,"h-8 shrink-0 px-2.5 text-xs text-muted-foreground"),children:[a.jsx(it,{className:"size-3 rotate-180"}),"Main"]}),t[26]=X,t[27]=f,t[28]=N,t[29]=le):le=t[29];let se;t[30]!==D||t[31]!==l||t[32]!==Q||t[33]!==C||t[34]!==u||t[35]!==c||t[36]!==d||t[37]!==V||t[38]!==N||t[39]!==S?(se=N&&a.jsx(SY,{session:N,sessionSource:S,isLive:C,pullRequests:V,copied:D,creatingSession:l,onCopyResume:Q,onNewSession:c,onDuplicateSession:u,onOpenTerminal:d}),t[30]=D,t[31]=l,t[32]=Q,t[33]=C,t[34]=u,t[35]=c,t[36]=d,t[37]=V,t[38]=N,t[39]=S,t[40]=se):se=t[40];let me;t[41]!==X||t[42]!==N?(me=N&&!X&&a.jsx(DZ,{sessionId:N.sessionId}),t[41]=X,t[42]=N,t[43]=me):me=t[43];let ue;t[44]!==m||t[45]!==N||t[46]!==p?(ue=N&&m&&(p??0)>0&&a.jsxs(J,{variant:"ghost",size:"xs",className:G(Qn,"h-8 shrink-0 gap-1 px-2.5 text-[11px] text-muted-foreground hover:text-foreground"),onClick:m,children:[a.jsx(Mj,{className:"size-3"}),"Workflows",a.jsx(Ue,{variant:"outline",className:"h-4 min-w-4 justify-center px-1 text-[9px] font-semibold",children:p})]}),t[44]=m,t[45]=N,t[46]=p,t[47]=ue):ue=t[47];let ce;t[48]!==ae||t[49]!==de||t[50]!==le||t[51]!==se||t[52]!==me||t[53]!==ue?(ce=a.jsxs("div",{className:ae,children:[de,le,se,me,ue]}),t[48]=ae,t[49]=de,t[50]=le,t[51]=se,t[52]=me,t[53]=ue,t[54]=ce):ce=t[54];let xe,pe,he;t[55]===Symbol.for("react.memo_cache_sentinel")?(xe=a.jsx("div",{className:G(Qn,ao,"empty:hidden"),children:a.jsx(GZ,{})}),pe=a.jsx("div",{className:G(Qn,ao,"empty:hidden"),children:a.jsx(tY,{})}),he=G(Qn,ao,"empty:hidden"),t[55]=xe,t[56]=pe,t[57]=he):(xe=t[55],pe=t[56],he=t[57]);let be;t[58]!==Z?(be=a.jsx("div",{className:he,children:a.jsx(KY,{agentKind:Z})}),t[58]=Z,t[59]=be):be=t[59];let we;t[60]===Symbol.for("react.memo_cache_sentinel")?(we=a.jsx("div",{className:G(Qn,ao,"empty:hidden"),children:a.jsx(O0,{})}),t[60]=we):we=t[60];let ve;t[61]!==Z||t[62]!==N?(ve=N&&fn(Z).sharing&&ht("share")&&a.jsx("div",{className:G(Qn,ao),children:a.jsx(RY,{sessionId:N.sessionId})}),t[61]=Z,t[62]=N,t[63]=ve):ve=t[63];let Se;t[64]!==P||t[65]!==X||t[66]!==N?(Se=N&&!X&&P&&a.jsx("div",{className:G(Qn,ao,"empty:hidden"),children:a.jsx(P,{sessionId:N.sessionId})}),t[64]=P,t[65]=X,t[66]=N,t[67]=Se):Se=t[67];let Te;t[68]!==H||t[69]!==X||t[70]!==N?(Te=N&&!X&&H&&a.jsx(Nw,{icon:H.icon,label:H.label,disabledReason:H.disabledReason,onClick:H.toggle}),t[68]=H,t[69]=X,t[70]=N,t[71]=Te):Te=t[71];let Ae;t[72]===Symbol.for("react.memo_cache_sentinel")?(Ae=G(Qn,ao),t[72]=Ae):Ae=t[72];let ze;t[73]===Symbol.for("react.memo_cache_sentinel")?(ze=a.jsx(Pa,{render:a.jsx(J,{variant:"ghost",size:"icon-sm","aria-label":"More actions"}),children:a.jsx(Dj,{"data-icon":"inline-start"})}),t[73]=ze):ze=t[73];let De;t[74]!==T||t[75]!==X||t[76]!==A.send||t[77]!==N?(De=N&&!X&&A.send&&T.handleProviderHandoff&&a.jsxs(a.Fragment,{children:[a.jsx(pr,{children:a.jsxs(tn,{onClick:T.handleProviderHandoff,children:[a.jsx(zj,{}),"Continue with another provider…"]})}),a.jsx(Nl,{})]}),t[74]=T,t[75]=X,t[76]=A.send,t[77]=N,t[78]=De):De=t[78];let Le;t[79]!==R?(Le=R&&a.jsxs(tn,{onClick:()=>O(!0),children:[a.jsx(XP,{}),"Usage & cost…"]}),t[79]=R,t[80]=Le):Le=t[80];let Ce;t[81]===Symbol.for("react.memo_cache_sentinel")?(Ce=a.jsxs(tn,{onClick:()=>M(!0),children:[a.jsx(ag,{}),"Server monitor…"]}),t[81]=Ce):Ce=t[81];let Be;t[82]!==te||t[83]!==j?(Be=j&&a.jsxs(tn,{onClick:te,children:[a.jsx(Ji,{className:"text-success"}),"Copy network URL",a.jsx("span",{className:"ml-auto truncate pl-2 font-mono text-[11px] text-muted-foreground",children:j})]}),t[82]=te,t[83]=j,t[84]=Be):Be=t[84];let We;t[85]!==Le||t[86]!==Be?(We=a.jsxs(pr,{children:[Le,Ce,Be]}),t[85]=Le,t[86]=Be,t[87]=We):We=t[87];let He;t[88]===Symbol.for("react.memo_cache_sentinel")?(He=a.jsx(Nl,{}),t[88]=He):He=t[88];let _e;t[89]===Symbol.for("react.memo_cache_sentinel")?(_e=a.jsx(JP,{}),t[89]=_e):_e=t[89];let Re;t[90]!==x?(Re=a.jsx(pr,{children:a.jsxs(tn,{onClick:x,children:[_e,"Settings"]})}),t[90]=x,t[91]=Re):Re=t[91];let tt;t[92]!==i||t[93]!==g?(tt=ht("killAny")&&a.jsxs(a.Fragment,{children:[a.jsx(Nl,{}),a.jsx(pr,{children:a.jsxs(tn,{variant:"destructive",onClick:g,disabled:i,children:[a.jsx(ZP,{}),i?"Stopping processes…":"Stop all agent processes"]})})]}),t[92]=i,t[93]=g,t[94]=tt):tt=t[94];let Xe;t[95]!==De||t[96]!==We||t[97]!==Re||t[98]!==tt?(Xe=a.jsx("div",{className:Ae,children:a.jsxs(Ia,{children:[ze,a.jsxs($a,{align:"end",sideOffset:6,className:"w-64",children:[De,We,He,Re,tt]})]})}),t[95]=De,t[96]=We,t[97]=Re,t[98]=tt,t[99]=Xe):Xe=t[99];let Ne;t[100]!==E||t[101]!==b||t[102]!==w?(Ne=E&&a.jsx("div",{className:G(Qn,ao,"empty:hidden"),children:a.jsx(E,{onLogout:b,onOpenMainView:w})}),t[100]=E,t[101]=b,t[102]=w,t[103]=Ne):Ne=t[103];let Ve;t[104]!==be||t[105]!==ve||t[106]!==Se||t[107]!==Te||t[108]!==Xe||t[109]!==Ne?(Ve=a.jsxs("div",{className:"electron-no-drag window-inset-end pointer-events-auto flex shrink-0 items-center gap-1.5",children:[xe,pe,be,we,ve,Se,Te,Xe,Ne]}),t[104]=be,t[105]=ve,t[106]=Se,t[107]=Te,t[108]=Xe,t[109]=Ne,t[110]=Ve):Ve=t[110];let ye;t[111]!==ce||t[112]!==Ve?(ye=a.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-30 flex items-start justify-between gap-3 px-3 pt-2",children:[ce,Ve]}),t[111]=ce,t[112]=Ve,t[113]=ye):ye=t[113];let $e;t[114]!==R||t[115]!==L?($e=R&&a.jsx(fX,{open:L,onOpenChange:O}),t[114]=R,t[115]=L,t[116]=$e):$e=t[116];let qe;t[117]!==$?(qe=a.jsx(fY,{open:$,onOpenChange:M}),t[117]=$,t[118]=qe):qe=t[118];let Ke;return t[119]!==ye||t[120]!==$e||t[121]!==qe?(Ke=a.jsxs(a.Fragment,{children:[oe,re,ye,$e,qe]}),t[119]=ye,t[120]=$e,t[121]=qe,t[122]=Ke):Ke=t[122],Ke});function Nw(n){const e=q.c(23),{icon:t,label:s,onClick:r,disabledReason:o}=n;if(o){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=G(Qn,"size-8 shrink-0"),e[0]=m):m=e[0];let p;e[1]!==t?(p=a.jsx(t,{"data-icon":"inline-start"}),e[1]=t,e[2]=p):p=e[2];let h;e[3]!==s||e[4]!==p?(h=a.jsx(J,{variant:"ghost",size:"icon-sm",disabled:!0,"aria-label":s,className:m,children:p}),e[3]=s,e[4]=p,e[5]=h):h=e[5];let g;return e[6]!==o||e[7]!==h?(g=a.jsx(ed,{reason:o,children:h}),e[6]=o,e[7]=h,e[8]=g):g=e[8],g}let i;e[9]===Symbol.for("react.memo_cache_sentinel")?(i=G(Qn,"size-8 shrink-0"),e[9]=i):i=e[9];let l;e[10]!==s||e[11]!==r?(l=a.jsx(J,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":s,className:i}),e[10]=s,e[11]=r,e[12]=l):l=e[12];let c;e[13]!==t?(c=a.jsx(t,{"data-icon":"inline-start"}),e[13]=t,e[14]=c):c=e[14];let u;e[15]!==l||e[16]!==c?(u=a.jsx(Ut,{render:l,children:c}),e[15]=l,e[16]=c,e[17]=u):u=e[17];let d;e[18]!==s?(d=a.jsx(Bt,{side:"bottom",children:s}),e[18]=s,e[19]=d):d=e[19];let f;return e[20]!==u||e[21]!==d?(f=a.jsxs(Ft,{children:[u,d]}),e[20]=u,e[21]=d,e[22]=f):f=e[22],f}function jX(n){n&&Kn.success("Copied network URL")}const NX=y.memo(function(e){const t=q.c(13),{onToggleSidebar:s,onGoHome:r,onOpenCommandPalette:o,sidebarShortcut:i,commandPaletteShortcut:l}=e;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("div",{className:"flex-1"}),t[0]=c):c=t[0];let u;t[1]!==r?(u=a.jsx(fp,{icon:ba,label:"Home",onClick:r,size:"default"}),t[1]=r,t[2]=u):u=t[2];const d=`Search (${l})`;let f;t[3]!==o||t[4]!==d?(f=a.jsx(fp,{icon:ss,label:d,onClick:o,size:"default"}),t[3]=o,t[4]=d,t[5]=f):f=t[5];const m=`Hide sidebar (${i})`;let p;t[6]!==s||t[7]!==m?(p=a.jsx(fp,{icon:QP,label:m,onClick:s,size:"default"}),t[6]=s,t[7]=m,t[8]=p):p=t[8];let h;return t[9]!==u||t[10]!==f||t[11]!==p?(h=a.jsxs("div",{className:"electron-drag window-inset-start flex h-12 shrink-0 items-center gap-1 px-2",children:[c,u,f,p]}),t[9]=u,t[10]=f,t[11]=p,t[12]=h):h=t[12],h});function CX(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex h-full w-full aria-[orientation=vertical]:flex-col",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx(n$,{"data-slot":"resizable-panel-group",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function Cw(n){const e=q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=a.jsx(t$,{"data-slot":"resizable-panel",...t}),e[2]=t,e[3]=s):s=e[3],s}function _X(n){const e=q.c(12);let t,s,r;e[0]!==n?({withHandle:r,className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==t?(o=G("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),e[4]=t,e[5]=o):o=e[5];let i;e[6]!==r?(i=r&&a.jsx("div",{className:"z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border"}),e[6]=r,e[7]=i):i=e[7];let l;return e[8]!==s||e[9]!==o||e[10]!==i?(l=a.jsx(e$,{"data-slot":"resizable-handle",className:o,...s,children:i}),e[8]=s,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const oE=y.createContext(null);function iE(n){const e=q.c(3),{value:t,children:s}=n;let r;return e[0]!==s||e[1]!==t?(r=a.jsx(oE.Provider,{value:t,children:s}),e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function z0(){const n=y.useContext(oE);if(!n)throw new Error("Built-in workspace panel services are unavailable");return n}function aE(n){const e=q.c(18),{title:t,icon:s,active:r,onClick:o,children:i}=n,l=r&&"bg-sidebar-primary text-sidebar-primary-foreground hover:bg-sidebar-primary/90 hover:text-sidebar-primary-foreground";let c;e[0]!==l?(c=G("relative rounded-md",l),e[0]=l,e[1]=c):c=e[1];let u;e[2]!==r||e[3]!==o||e[4]!==c||e[5]!==t?(u=a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":t,"aria-pressed":r,onClick:o,className:c}),e[2]=r,e[3]=o,e[4]=c,e[5]=t,e[6]=u):u=e[6];let d;e[7]!==s?(d=a.jsx(s,{"data-icon":"inline-start"}),e[7]=s,e[8]=d):d=e[8];let f;e[9]!==i||e[10]!==u||e[11]!==d?(f=a.jsxs(Ut,{render:u,children:[d,i]}),e[9]=i,e[10]=u,e[11]=d,e[12]=f):f=e[12];let m;e[13]!==t?(m=a.jsx(Bt,{side:"left",children:t}),e[13]=t,e[14]=m):m=e[14];let p;return e[15]!==f||e[16]!==m?(p=a.jsxs(Ft,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function D0(n,e){return n.filter(t=>{var s;return((s=t.when)==null?void 0:s.call(t,e))??!0})}function EX(n){const e=q.c(25),{panels:t,context:s,activePanelId:r,onTogglePanel:o,actions:i}=n;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const c=l;let u,d,f,m,p,h;if(e[2]!==c||e[3]!==r||e[4]!==s||e[5]!==o||e[6]!==t){h=Symbol.for("react.early_return_sentinel");e:{const x=D0(t,s);if(x.length===0&&c.length===0){h=null;break e}u="Workspace panels",d="electron-no-drag flex w-11 shrink-0 flex-col items-center gap-1 border-l bg-sidebar py-2 text-sidebar-foreground",e[13]!==c?(f=c.map(TX),e[13]=c,e[14]=f):f=e[14],m=c.length>0&&x.length>0&&a.jsx("div",{"aria-hidden":!0,className:"my-1 h-px w-6 bg-sidebar-border"});let b;e[15]!==r||e[16]!==s||e[17]!==o?(b=w=>{var _;const v=w.id===r,k=(_=w.badge)==null?void 0:_.call(w,s),j=w.indicator;return a.jsx(aE,{title:w.title,icon:w.icon,active:v,onClick:()=>o(w.id),children:j?a.jsx(j,{...w.indicatorProps,context:s,active:v}):k!=null&&a.jsx(Ue,{className:"absolute -right-1 -top-1 min-w-4 px-1 text-[9px]",variant:"secondary",children:k})},w.id)},e[15]=r,e[16]=s,e[17]=o,e[18]=b):b=e[18],p=x.map(b)}e[2]=c,e[3]=r,e[4]=s,e[5]=o,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=m,e[11]=p,e[12]=h}else u=e[7],d=e[8],f=e[9],m=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;return e[19]!==u||e[20]!==d||e[21]!==f||e[22]!==m||e[23]!==p?(g=a.jsxs("aside",{"aria-label":u,className:d,children:[f,m,p]}),e[19]=u,e[20]=d,e[21]=f,e[22]=m,e[23]=p,e[24]=g):g=e[24],g}function TX(n){return a.jsx(aE,{title:n.title,icon:n.icon,active:n.active,onClick:n.onSelect},n.id)}function lE(n){const e=q.c(20),{panels:t,context:s,activePanelId:r,onClosePanel:o,active:i}=n,l=i===void 0?!0:i;let c;e[0]!==r?(c=()=>new Set([r]),e[0]=r,e[1]=c):c=e[1];const[u,d]=y.useState(c);let f,m;e[2]!==r?(f=()=>{d(g=>{if(g.has(r))return g;const x=new Set(g);return x.add(r),x})},m=[r],e[2]=r,e[3]=f,e[4]=m):(f=e[3],m=e[4]),y.useEffect(f,m);let p;if(e[5]!==r||e[6]!==s||e[7]!==l||e[8]!==o||e[9]!==t||e[10]!==u){let g;e[12]!==r||e[13]!==s||e[14]!==l||e[15]!==o||e[16]!==u?(g=x=>{const b=x.id===r,w=b&&l;if(!b&&(!x.keepAlive||!u.has(x.id)))return null;const v=x.component;return a.jsx("div",{className:G("absolute inset-0 min-h-0",!w&&"hidden"),"aria-hidden":!w,children:a.jsx(v,{...x.componentProps,context:s,active:w,closePanel:o})},x.id)},e[12]=r,e[13]=s,e[14]=l,e[15]=o,e[16]=u,e[17]=g):g=e[17],p=t.map(g),e[5]=r,e[6]=s,e[7]=l,e[8]=o,e[9]=t,e[10]=u,e[11]=p}else p=e[11];let h;return e[18]!==p?(h=a.jsx("div",{className:"relative h-full min-h-0 overflow-hidden bg-canvas",children:p}),e[18]=p,e[19]=h):h=e[19],h}function AX(n){const e=n==null?void 0:n.match(/^(\d+(?:\.\d+)?)%$/);if(!e)return"64%";const t=Number(e[1]);return t>0&&t<100?`${100-t}%`:"64%"}function IX(n){const e=q.c(23),{children:t,panels:s,context:r,activePanel:o,services:i,onClosePanel:l,onTogglePanel:c,actions:u}=n;let d;e[0]!==o?(d=o?AX(o.defaultSize):"100%",e[0]=o,e[1]=d):d=e[1];let f;e[2]!==t||e[3]!==d?(f=a.jsx(Cw,{defaultSize:d,minSize:"320px",children:t}),e[2]=t,e[3]=d,e[4]=f):f=e[4];let m;e[5]!==o||e[6]!==r||e[7]!==l||e[8]!==s||e[9]!==i?(m=o&&a.jsxs(a.Fragment,{children:[a.jsx(_X,{withHandle:!0}),a.jsx(Cw,{defaultSize:o.defaultSize??"36%",minSize:o.minSize??"300px",maxSize:o.maxSize??"70%",children:a.jsx(iE,{value:i,children:a.jsx(lE,{panels:s,context:r,activePanelId:o.id,onClosePanel:l})})})]}),e[5]=o,e[6]=r,e[7]=l,e[8]=s,e[9]=i,e[10]=m):m=e[10];let p;e[11]!==f||e[12]!==m?(p=a.jsxs(CX,{orientation:"horizontal",className:"min-h-0 min-w-0 w-auto flex-1",children:[f,m]}),e[11]=f,e[12]=m,e[13]=p):p=e[13];const h=(o==null?void 0:o.id)??null;let g;e[14]!==u||e[15]!==r||e[16]!==c||e[17]!==s||e[18]!==h?(g=a.jsx(EX,{panels:s,context:r,activePanelId:h,onTogglePanel:c,actions:u}),e[14]=u,e[15]=r,e[16]=c,e[17]=s,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function Vg(n){const e=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,r])=>e.indexOf(+s)===-1).map(([s,r])=>r)}function _w(n,e="|"){return n.map(t=>mE(t)).join(e)}function Hg(n,e){return typeof e=="bigint"?e.toString():e}class PX{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}}function im(n){return new PX(n)}function $X(n){return n==null}function F0(n){const e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function RX(n,e){const t=n/e,s=Math.round(t),r=4*Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-s)<r?0:t-s}function no(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function U0(n){const e=Object.getOwnPropertyDescriptor(n,"shape");return e!=null&&e.get?e.get.raw:e==null?void 0:e.value}function Yr(n){return U0(n._zod.def)??n._zod.def.shape}function cE(n,e,t){Object.defineProperty(n,e,{get(){const s=t();return no(this,e,s),s},enumerable:!0,configurable:!0})}function uE(n,e,t){e in n?no(n,e,t):n[e]=t}function fi(n,e,t,s){const r=Yr(e);for(const o of t){const i=Object.getOwnPropertyDescriptor(r,o);i.enumerable&&(i.get?cE(n,o,()=>{const l=e._zod.def.shape[o];return s?s(l,o):l}):uE(n,o,s?s(i.value,o):i.value))}}function OX(n,e){for(const t of Reflect.ownKeys(e)){const s=Object.getOwnPropertyDescriptor(e,t);s.enumerable&&(s.get?cE(n,t,()=>e[t]):uE(n,t,s.value))}}function fs(...n){const e={};for(const t of n){const s=Object.getOwnPropertyDescriptors(t);Object.assign(e,s)}return Object.defineProperties({},e)}function LX(n){return JSON.stringify(n)}function MX(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const dE="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function sc(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const zX=im(()=>{var n;if(Gs.jitless||typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)!=null&&n.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ua(n){if(sc(n)===!1)return!1;const e=n.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(sc(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function fE(n){return ua(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}const DX=new Set(["string","number","symbol"]);function da(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ko(n,e,t){const s=new n._zod.constr(e??n._zod.def);return(!e||t!=null&&t.parent)&&(s._zod.parent=n),s}function Ye(n){const e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function mE(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function FX(n){return Object.keys(n).filter(e=>n[e]._zod.optin!==void 0&&n[e]._zod.optout==="optional")}const pE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},UX={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function BX(n,e){const t=n._zod.def,s=t.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return fi(o,n,am(n,e)),Ko(n,fs(t,{shape:o,checks:[]}))}function am(n,e){var r;const t=Yr(n),s=[];for(const o of Reflect.ownKeys(e)){if(!((r=Object.getOwnPropertyDescriptor(t,o))!=null&&r.enumerable))throw new Error(`Unrecognized key: "${String(o)}"`);e[o]&&s.push(o)}return s}function WX(n,e){const t=n._zod.def,s=t.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(am(n,e)),i={};return fi(i,n,Reflect.ownKeys(Yr(n)).filter(l=>!o.has(l))),Ko(n,fs(t,{shape:i,checks:[]}))}function qX(n,e){if(!ua(e))throw new Error("Invalid input to extend: expected a plain object");const t=n._zod.def.checks;if(t&&t.length>0){const r=Yr(n);for(const o of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ko(n,fs(n._zod.def,{shape:hE(n,e)}))}function hE(n,e){const t={};return fi(t,n,Reflect.ownKeys(Yr(n))),OX(t,e),t}function VX(n,e){if(!ua(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Ko(n,fs(n._zod.def,{shape:hE(n,e)}))}function HX(n,e){var r,o;if(!((r=e==null?void 0:e._zod)!=null&&r.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=n._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const t={};fi(t,n,Reflect.ownKeys(Yr(n))),fi(t,e,Reflect.ownKeys(Yr(e)));const s=fs(n._zod.def,{shape:t,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ko(n,s)}function Ew(n,e,t,s="partial"){const o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${s}() cannot be used on object schemas containing refinements`);const l=t?new Set(am(e,t)):void 0,c={};return fi(c,e,Reflect.ownKeys(Yr(e)),n&&((u,d)=>l&&!l.has(d)?u:new n({type:"optional",innerType:u}))),Ko(e,fs(e._zod.def,{shape:c,checks:[]}))}function KX(n,e,t){const s=t?new Set(am(e,t)):void 0,r={};return fi(r,e,Reflect.ownKeys(Yr(e)),(o,i)=>s&&!s.has(i)?o:new n({type:"nonoptional",innerType:o})),Ko(e,fs(e._zod.def,{shape:r}))}function Fr(n,e=0){var t;if(n.aborted===!0)return!0;for(let s=e;s<n.issues.length;s++)if(((t=n.issues[s])==null?void 0:t.continue)!==!0)return!0;return!1}function GX(n,e=0){var t;if(n.aborted===!0)return!0;for(let s=e;s<n.issues.length;s++)if(((t=n.issues[s])==null?void 0:t.continue)===!1)return!0;return!1}function Fi(n,e){return e.map(t=>{var s;return(s=t).path??(s.path=[]),t.path.unshift(n),t})}function Ya(n){return typeof n=="string"?n:n==null?void 0:n.message}function Tw(n,e,t){var s;for(let r=e;r<n.length;r++)(s=n[r]).schema??(s.schema=t)}function Ro(n,e,t){var c,u,d,f,m,p,h,g,x,b;var s;const r=(u=(c=n.inst)==null?void 0:c._zod)==null?void 0:u.traits;r!=null&&r.has("$ZodType")&&(r.has("$ZodCheck")?(s=n).schema??(s.schema=n.inst):n.schema=n.inst);const o=n.schema!==n.inst?(f=(d=n.schema)==null?void 0:d._zod.def)==null?void 0:f.error:void 0,i=n.message?n.message:Ya((h=(p=(m=n.inst)==null?void 0:m._zod.def)==null?void 0:p.error)==null?void 0:h.call(p,n))??Ya(o==null?void 0:o(n))??Ya((g=e==null?void 0:e.error)==null?void 0:g.call(e,n))??Ya((x=t.customError)==null?void 0:x.call(t,n))??Ya((b=t.localeError)==null?void 0:b.call(t,n))??"Invalid input",l={};for(const w of Object.keys(n))w==="inst"||w==="schema"||w==="continue"||w==="input"||w==="__proto__"||(l[w]=n[w]);return l.path??(l.path=[]),l.message=i,e!=null&&e.reportInput&&(l.input=n.input),l}const ZX=/[\uD800-\uDBFF]/;function B0(n){const e=n.length;if(!ZX.test(n))return e;let t=e;for(let s=0;s<e-1;s++)(n.charCodeAt(s)&64512)===55296&&(n.charCodeAt(s+1)&64512)===56320&&(t--,s++);return t}function W0(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function YX(n){const e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";const t=n;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return e}function rc(...n){const[e,t,s]=n;return typeof e=="string"?{message:e,code:"custom",input:t,inst:s}:{...e}}function XX(n,e){for(const t in e){const s=Object.getOwnPropertyDescriptor(e,t);s.get?Object.defineProperty(n,t,{...s,enumerable:!1}):JX(n,t,s.value)}}function Oo(n,e,t,s=!0){return Object.defineProperty(n,e,{configurable:!0,writable:!0,enumerable:s,value:t}),t}function gE(n,e,t){return Oo(n,e,t,!1)}function xE(n,e){for(const t in n){const s=n[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){return Oo(this,t,s(this))},set(r){Oo(this,t,r)}})}return e}function JX(n,e,t){Object.defineProperty(n,e,{configurable:!0,get(){return this==null?t:Oo(this,e,t.bind(this))},set(s){Oo(this,e,s)}})}function QX(n,e){const t=Object.getPrototypeOf(n);return e in t?void 0:t}let xp,fo=!1;const eJ={configurable:!0,get(){fo=!0}};function xt(n,e,t){const s=Object.getPrototypeOf(n._zod);if(e in s&&xp!==n._zod){xp=void 0;return}xp=n._zod,Object.defineProperty(s,e,{configurable:!0,get(){Object.defineProperty(this,e,eJ);const r=fo;fo=!1;try{const o=t(this);return fo?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),fo=fo||r,o}catch(o){throw delete this[e],fo=fo||r,o}},set(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})}function tJ(n,e,t,s){const r=QX(n,e);r&&Object.defineProperty(r,e,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:s,value:void 0};return Object.defineProperty(this,e,o),o.value=t(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:s,value:o})}})}const nJ="~constantCatch";function sJ(n){const e=()=>n;return e[nJ]=!0,e}var Aw;const bp={value:void 0,enumerable:!1};let Iw="captureStackTrace"in Error?Error:null;function rJ(n){const e=Iw;if(e){const t=e.stackTraceLimit;if(typeof t=="number"){try{e.stackTraceLimit=0}catch{return Iw=null,new n}try{return new n}finally{e.stackTraceLimit=t}}}return new n}function ge(n,e,t,s){const r={};function o(m){this.def=m,this.constr=f,this.traits=new Set}o.prototype=r;const i=t,l=i&&new WeakSet;function c(m,p){if(m._zod){if(m._zod.traits.has(n))return}else{bp.value=new o(p);try{Object.defineProperty(m,"_zod",bp)}finally{bp.value=void 0}}if(m._zod.traits.add(n),e(m,p),l){const g=Object.getPrototypeOf(m),x=m._zod.constr.prototype;let b=g;for(;b&&b!==x;)b=Object.getPrototypeOf(b);const w=b??g;l.has(w)||(l.add(w),XX(w,i))}const h=f.prototype;for(const g in h)Object.prototype.hasOwnProperty.call(h,g)&&(g in m||(m[g]=h[g].bind(m)))}const u=(s==null?void 0:s.Parent)??Object;class d extends u{}Object.defineProperty(d,"name",{value:n});function f(m){var x;const p=s!=null&&s.Parent?rJ(d):this;c(p,m);const h=p._zod.deferred;if(h){for(const b of h)b();p._zod.deferred=void 0}const g=(x=globalThis.__zod_globalConfig)==null?void 0:x.postProcessor;return g&&g(p),p}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:m=>{var p,h;return s!=null&&s.Parent&&m instanceof s.Parent?!0:(h=(p=m==null?void 0:m._zod)==null?void 0:p.traits)==null?void 0:h.has(n)}}),Object.defineProperty(f,"name",{value:n}),f}class ai extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class bE extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Aw=globalThis).__zod_globalConfig??(Aw.__zod_globalConfig={});const Gs=globalThis.__zod_globalConfig;function Cr(n){return n&&Object.assign(Gs,n),Gs}function oJ(){const n=this._zod;return n.message??(n.message=JSON.stringify(n.def,Hg,2)),n.message}function iJ(n){this._zod.message=n}const aJ={get:oJ,set:iJ,enumerable:!0,configurable:!0},vp={value:void 0,enumerable:!1},Pw=new WeakSet([Object.prototype,Error.prototype]),lJ=(n,e)=>{n.name="$ZodError",vp.value=e,Object.defineProperty(n,"issues",vp),vp.value=void 0,Object.defineProperty(n,"message",aJ);const t=Object.getPrototypeOf(n);Pw.has(t)||(Pw.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){const s=()=>this.message;return Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0})}}))},cJ=ge("$ZodError",lJ);function uJ(n,e,t){return Object.prototype.hasOwnProperty.call(n,e)||(e==="__proto__"?Object.defineProperty(n,e,{value:t(),writable:!0,enumerable:!0,configurable:!0}):n[e]=t()),n[e]}function dJ(n,e=t=>t.message){const t={},s=[];for(const r of n.issues)r.path.length>0?uJ(t,r.path[0],()=>[]).push(e(r)):s.push(e(r));return{formErrors:s,fieldErrors:t}}function fJ(n,e=t=>t.message){const t={_errors:[]},s=(r,o=[])=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>s({issues:l},[...o,...i.path]));else if(i.code==="invalid_key")s({issues:i.issues},[...o,...i.path]);else if(i.code==="invalid_element")s({issues:i.issues},[...o,...i.path]);else{const l=[...o,...i.path];if(l.length===0)t._errors.push(e(i));else{let c=t,u=0;for(;u<l.length;){const d=l[u],f=u===l.length-1;if(d==="_errors"){f&&c._errors.push(e(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const m=c[d];f&&m._errors.push(e(i)),c=m,u++}}}};return s(n),t}function lm(n,e){return{callee:(e==null?void 0:e.callee)??n,Err:e==null?void 0:e.Err}}const q0=n=>{const e=(t,s,r,o)=>{const i=r?{...r,async:!1}:{async:!1},l=t._zod.run({value:s,issues:[]},i);if(l instanceof Promise)throw new ai;if(l.issues.length){const c=new((o==null?void 0:o.Err)??n)(l.issues.map(u=>Ro(u,i,Cr())));throw dE(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},V0=n=>{const e=async(t,s,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let l=t._zod.run({value:s,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const c=new((o==null?void 0:o.Err)??n)(l.issues.map(u=>Ro(u,i,Cr())));throw dE(c,(o==null?void 0:o.callee)??e),c}return l.value};return e},H0=n=>(e,t,s)=>{const r=s?{...s,async:!1}:{async:!1},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new ai;return o.issues.length?vE(n,o.issues,r):{success:!0,data:o.value}};function vE(n,e,t){let s;return{success:!1,get error(){return s||(s=new n(e.map(r=>Ro(r,t,Cr()))),e=void 0,t=void 0),s},set error(r){s=r,e=void 0,t=void 0}}}const K0=n=>async(e,t,s)=>{const r=s?{...s,async:!0}:{async:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?vE(n,o.issues,r):{success:!0,data:o.value}},mJ=Symbol.for("zod.compile.invalid"),pJ=Symbol.for("zod.compile.fallback"),hJ=((n,e,t)=>{const s=n._zod.bag.validator;if(s!==void 0){if(s(e)!==mJ)return!0;if(s.definite===!0&&t===void 0)return!1}return gJ(n,e,t)});function gJ(n,e,t){const s=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=n._zod.bag.fallbackRun;let o;if(r?(s[pJ]=!0,o=r({value:e,issues:[]},s)):o=n._zod.run({value:e,issues:[]},s),o instanceof Promise)throw new ai;return o.issues.length===0}const xJ=async(n,e,t)=>{const s=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let r=n._zod.run({value:e,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length===0},bJ=n=>{const e=q0(n),t=(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return e(s,r,l,lm(t,i))};return t},vJ=n=>{const e=q0(n),t=(s,r,o,i)=>e(s,r,o,lm(t,i));return t},yJ=n=>{const e=V0(n),t=async(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return await e(s,r,l,lm(t,i))};return t},wJ=n=>{const e=V0(n),t=async(s,r,o,i)=>await e(s,r,o,lm(t,i));return t},SJ=n=>(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return H0(n)(e,t,r)},kJ=n=>(e,t,s)=>H0(n)(e,t,s),jJ=n=>async(e,t,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return K0(n)(e,t,r)},NJ=n=>async(e,t,s)=>K0(n)(e,t,s),CJ=/^[cC][0-9a-z]{6,}$/,_J=/^[0-9a-z]+$/,EJ=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,TJ=/^[0-9a-vA-V]{20}$/,AJ=/^[A-Za-z0-9]{27}$/,IJ=/^[a-zA-Z0-9_-]{21}$/;function PJ(n){return new RegExp(`^[a-zA-Z0-9_-]{${n}}$`)}const $J=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,RJ=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$w=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,OJ=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,LJ="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function MJ(){return new RegExp(LJ,"u")}const zJ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,DJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,FJ=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,UJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,BJ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,WJ=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,qJ=/^https?$/,VJ=/^\+[1-9]\d{6,14}$/,yE="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function HJ(n){return new RegExp(`^${n}$`)}const KJ=HJ(yE);function Kg(n){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:n.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function GJ(n){return new RegExp(`^${Kg(n)}$`)}function ZJ(n){const e=["Z"];n.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const t=`${Kg({precision:n.precision,seconds:!0})}(?:${e.join("|")})`,s=n.local?`${t}|${Kg({precision:n.precision})}`:t;return new RegExp(`^${yE}T(?:${s})$`)}const YJ=/^[\s\S]{0,}$/,XJ=/^-?\d+$/,G0=/^-?\d+(?:\.\d+)?$/,JJ=/^(?:true|false)$/i,QJ=/^null$/i,eQ=/^[^A-Z]*$/,tQ=/^[^a-z]*$/,is=ge("$ZodCheck",(n,e)=>{var t;n._zod??(n._zod={}),n._zod.def=e,(t=n._zod).onattach??(t.onattach=[])}),Z0=n=>{const e=n.value;return!$X(e)&&e.length!==void 0},Wd={number:"number",bigint:"bigint",object:"date"},wE=ge("$ZodCheckLessThan",(n,e)=>{is.init(n,e);const t=Wd[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value<=e.value:s.value<e.value)||s.issues.push({origin:Wd[typeof s.value]??t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),SE=ge("$ZodCheckGreaterThan",(n,e)=>{is.init(n,e);const t=Wd[typeof e.value];n._zod.check=s=>{(e.inclusive?s.value>=e.value:s.value>e.value)||s.issues.push({origin:Wd[typeof s.value]??t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:s.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),nQ=ge("$ZodCheckMultipleOf",(n,e)=>{is.init(n,e),n._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?e.value!==BigInt(0)&&t.value%e.value===BigInt(0):RX(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),sQ=ge("$ZodCheckNumberFormat",(n,e)=>{var i;is.init(n,e),e.format=e.format||"float64";const t=(i=e.format)==null?void 0:i.includes("int"),s=t?"int":"number",[r,o]=pE[e.format];n._zod.check=l=>{const c=l.value;if(t){if(!Number.isInteger(c)){l.issues.push({expected:s,format:e.format,code:"invalid_type",continue:!1,input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?l.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!e.abort}):l.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!e.abort});return}}c<r&&l.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:n,continue:!e.abort}),c>o&&l.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:n,continue:!e.abort})}}),rQ=ge("$ZodCheckMaxLength",(n,e)=>{var t;is.init(n,e),(t=n._zod.def).when??(t.when=Z0),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>e.maximum?B0(r):o)<=e.maximum)return;const l=W0(r);s.issues.push({origin:l,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),oQ=ge("$ZodCheckMinLength",(n,e)=>{var t;is.init(n,e),(t=n._zod.def).when??(t.when=Z0),n._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>=e.minimum&&o<e.minimum*2?B0(r):o)>=e.minimum)return;const l=W0(r);s.issues.push({origin:l,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}),iQ=ge("$ZodCheckLengthEquals",(n,e)=>{var t;is.init(n,e),(t=n._zod.def).when??(t.when=Z0),n._zod.check=s=>{const r=s.value,o=r.length,i=typeof r=="string"&&o>=e.length&&o<=e.length*2?B0(r):o;if(i===e.length)return;const l=W0(r),c=i>e.length;s.issues.push({origin:l,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!e.abort})}}),cm=ge("$ZodCheckStringFormat",(n,e)=>{var t,s;is.init(n,e),e.pattern?(t=n._zod).check??(t.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(s=n._zod).check??(s.check=()=>{})}),aQ=ge("$ZodCheckRegex",(n,e)=>{cm.init(n,e),n._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),lQ=ge("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=eQ),cm.init(n,e)}),cQ=ge("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=tQ),cm.init(n,e)}),uQ=ge("$ZodCheckIncludes",(n,e)=>{is.init(n,e);const t=da(e.includes),s=new RegExp(typeof e.position=="number"?`^.{${e.position},}${t}`:t);e.pattern=s,n._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:n,continue:!e.abort})}}),dQ=ge("$ZodCheckStartsWith",(n,e)=>{is.init(n,e);const t=new RegExp(`^${da(e.prefix)}.*`);e.pattern??(e.pattern=t),n._zod.check=s=>{s.value.startsWith(e.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:s.value,inst:n,continue:!e.abort})}}),fQ=ge("$ZodCheckEndsWith",(n,e)=>{is.init(n,e);const t=new RegExp(`.*${da(e.suffix)}$`);e.pattern??(e.pattern=t),n._zod.check=s=>{s.value.endsWith(e.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:s.value,inst:n,continue:!e.abort})}}),mQ=ge("$ZodCheckOverwrite",(n,e)=>{is.init(n,e),n._zod.check=t=>{t.value=e.tx(t.value)}});class pQ{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const s=e.split(`
|
|
@@ -451,20 +451,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
451
451
|
`&&(t+=l),o++;continue}}if(i===s){s="";continue}if(!s&&(i==="'"||i==='"')){s=i;continue}if(s!=="'"){if(i==="`"||i==="$"&&/[('"{]/.test(l??""))return null;(i==="$"||!s&&/[*?[{}~]/.test(i))&&(r=!1)}t+=i}return s?null:{value:t,start:e,end:o,literal:r}}function Vme(n){const e=[];let t=[],s=0,r=0;const o=()=>({commands:[...e,{words:t,end:n.length,pipeline:s}],complete:!1});for(let i=0;i<n.length;){const l=n[i];if(l==="\\"&&n[i+1]===`
|
|
452
452
|
`){i+=2;continue}if(l==="#"){const d=n.indexOf(`
|
|
453
453
|
`,i);e.push({words:t,end:i,pipeline:s}),t.length>0&&r===0&&s++,t=[],i=d<0?n.length:d;continue}if(/[^\S\n]/.test(l)){i++;continue}if(/[;&|()\n]/.test(l)){const d=n[i+1],f=l==="|"&&d!=="|";if(l==="("&&r++,l===")"&&r--,r<0)return o();e.push({words:t,end:i,pipeline:s}),r===0&&!f&&l!=="("&&l!==")"&&(l!==`
|
|
454
|
-
`||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=_3(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=_3(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const pl="agent-browser",Hme=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),Kme=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),Gme=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),Zme=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,Yme=/^[A-Za-z_][A-Za-z_\d]*=/;function mA(n){return n.slice(n.lastIndexOf("/")+1)}function Xme(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(Yme.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||Zme.test(o.value))return null;const i=mA(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=Hme.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function Jme(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=Fme,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!Wme(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:pl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function Qme(n){var l;const{commands:e,complete:t}=Vme(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(pl)));if(!t)return{invocations:s,ambiguous:r||n.includes(pl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(pl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=Xme(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=mA(c[f].value);if(m!==pl){!(Kme.has(m)||m==="git"&&Gme.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=Jme(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function epe(n){return Qme(n).invocations}const E3=120,tpe=/(?:^|[._])exec_command$/;function npe(n){return n==="Bash"||tpe.test(n)}function spe(n){return UF(n).filter(e=>npe(e.name)).map(e=>Gr(e.input))}function rpe(n){for(const e of spe(n)){const[t]=epe(e);if(t===void 0||qme(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>E3?`${s.slice(0,E3-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function ope(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let r=s.length-1;r>=0;r--){const o=rpe(s[r]);if(o)return o}}return null}const T3=1e4,ipe=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-BelqVoKU.js"),__vite__mapDeps([31,1,32,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),ape=y.lazy(()=>nt(()=>import("./WorktreePanel-CVZp_AIL.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),lpe=y.lazy(()=>nt(()=>import("./CrewPanel-9nMm5pVI.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.CrewPanel}))),cpe=y.lazy(()=>nt(()=>import("./index-BbEO6jPZ.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Sm(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function upe(n){const e=q.c(6),{context:t,closePanel:s}=n,r=z0(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Sm,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(ipe,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function dpe(n){const e=q.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx($K,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function fpe(){const n=q.c(7),e=z0();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=a.jsx(Dme,{onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}function mpe(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Sm,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(cpe,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function ppe(n){var u;const e=q.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=ope(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+T3-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(hpe),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=T3)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function hpe(n){return n+1}function gpe(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Sm,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(lpe,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function xpe(n){const e=q.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function bpe(n){const e=q.c(8),{closePanel:t}=n,s=z0();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Sm,{}),e[0]=r):r=e[0];let o;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(ape,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=o):o=e[7],o}const vpe={id:ti,workspacePanels:[{id:"crew",title:"Crew",icon:z1,component:gpe,indicator:xpe,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Wr,component:bpe,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:r$,component:upe,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:Ji,component:mpe,indicator:ppe,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:fc,component:dpe,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:o$,component:fpe,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},ype=wZ([vpe]);function wpe(n,e,t){if(!e)return null;const s=l=>{const c=(t==="win32"?l.replaceAll("\\","/").toLowerCase():l).replace(/\/+$/,"")||"/";return c.split("/").some(u=>u==="."||u==="..")?null:c},r=s(e);if(!r)return null;let o=null,i=-1;for(const l of n)for(const c of l.paths){const u=s(c);u&&u.length>i&&(r===u||r.startsWith(u.endsWith("/")?u:`${u}/`))&&(o=l,i=u.length)}return o}function Spe(n){const e=q.c(22),{client:t,status:s,activation:r,projectPath:o}=n,i=!!(s!=null&&s.store.available)&&!!r;let l;e[0]!==i||e[1]!==o||e[2]!==s?(l=i?wpe(s.projects,o,s.runtime.platform):null,e[0]=i,e[1]=o,e[2]=s,e[3]=l):l=e[3];const c=l,u=i&&!c?o:null;let d;e[4]!==r||e[5]!==o||e[6]!==(s==null?void 0:s.connectionRevision)||e[7]!==(s==null?void 0:s.host.instanceId)||e[8]!==(s==null?void 0:s.projects)||e[9]!==(s==null?void 0:s.store)?(d=JSON.stringify([r,o,s==null?void 0:s.host.instanceId,s==null?void 0:s.store.revision,s==null?void 0:s.connectionRevision,s==null?void 0:s.projects]),e[4]=r,e[5]=o,e[6]=s==null?void 0:s.connectionRevision,e[7]=s==null?void 0:s.host.instanceId,e[8]=s==null?void 0:s.projects,e[9]=s==null?void 0:s.store,e[10]=d):d=e[10];const f=d,[m,p]=y.useState(null);let h,g;if(e[11]!==t||e[12]!==f||e[13]!==u?(h=()=>{if(!u)return;const b=new AbortController;return Promise.resolve().then(()=>(b.signal.throwIfAborted(),t.resolveWorkspace(u,b.signal))).then(w=>{b.signal.aborted||p({key:f,project:w})}).catch(()=>{b.signal.aborted||p({key:f,project:null})}),()=>b.abort()},g=[t,f,u],e[11]=t,e[12]=f,e[13]=u,e[14]=h,e[15]=g):(h=e[14],g=e[15]),y.useEffect(h,g),!i||!o){let b;return e[16]===Symbol.for("react.memo_cache_sentinel")?(b={project:null,resolving:!1},e[16]=b):b=e[16],b}if(c){let b;return e[17]!==c?(b={project:c,resolving:!1},e[17]=c,e[18]=b):b=e[18],b}let x;return e[19]!==f||e[20]!==m?(x=(m==null?void 0:m.key)===f?{project:m.project,resolving:!1}:{project:null,resolving:!0},e[19]=f,e[20]=m,e[21]=x):x=e[21],x}const A3={"cogpit.github":wj,"cogpit.clickup":l$,"cogpit.vercel":a$,"cogpit.cloudflare":i$};function kpe(n){const e=q.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx(rme,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function jpe(n){var o;const e=q.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Kre,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Npe({client:n,status:e,activation:t,project:s,legacyPanels:r=ype,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||dA())return i;const l=new Set(i.map(u=>u.id)),c=zi();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&sre(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=ho(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:A3[u.id]??J1,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...A3[u.id]?{indicator:jpe,indicatorProps:{runtime:m}}:{},component:kpe,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function pA(n){const e=q.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=fA();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=Spe(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=Npe({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function km(n){const e=q.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function ha(n){const e=q.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=wf(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function hA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function gA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function k1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function xA(n){const e=q.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=bj,s="a",r=xj({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function bA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function vA(n){const e=q.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const Cpe=1e3,_pe=255;function Epe(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function Tpe(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":Epe(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>_pe?"That folder name is too long":null}function I3(n,e){return n instanceof Error&&n.message?n.message:e}function Ape({hostName:n,projectPaths:e,onStart:t,onBack:s}){var B;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,k]=y.useState(!1),j=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const U=new AbortController;return pZ(r.path,U.signal).then(W=>c({request:i,listing:W})).catch(W=>{U.signal.aborted||c({request:i,error:I3(W,"This folder could not be read")})}),()=>U.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,A=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,I=C?null:(A==null?void 0:A.path)??null,E=u.trim().toLowerCase(),P=(A==null?void 0:A.folders.filter(U=>U.name.toLowerCase().includes(E)))??[],R=P.some(U=>U.path===f)?f:((B=P[0])==null?void 0:B.path)??"",L=A==null?void 0:A.path;y.useEffect(()=>{var W,V;const U=N.current;U&&(U.scrollLeft=U.scrollWidth),S.current&&!((W=j.current)!=null&&W.contains(document.activeElement))&&((V=_.current)==null||V.focus()),S.current=!1},[L]);function O(U){var W;S.current=((W=j.current)==null?void 0:W.contains(document.activeElement))??!1,o(V=>({path:U,request:V.request+1})),d(""),h(!1),x(""),w(null)}function $(){I&&t(I)}function M(U){U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!p?(U.preventDefault(),$()):U.key==="Backspace"&&U.target===_.current&&u===""&&(A!=null&&A.parent)&&!C&&(U.preventDefault(),O(A.parent))}function D(){var U;h(!1),x(""),w(null),(U=_.current)==null||U.focus()}async function F(U){var H;U.preventDefault();const W=g.trim(),V=Tpe(W);if(V){w(V);return}if(!(!I||v)){k(!0);try{const K=await hZ(I,W);O(K),(H=_.current)==null||H.focus()}catch(K){w(I3(K,"The folder could not be made"))}finally{k(!1)}}}const z=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:j,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(Q1,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:z}),A&&A.path!==A.root&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>O(null),"aria-label":"Go to the projects root",title:A.root,children:a.jsx(c$,{})})]}),A&&a.jsx(Ipe,{path:A.path,top:A.confined?A.root:null,listRef:N,onOpen:O}),a.jsxs(wc,{shouldFilter:!1,label:"Filter folders",value:R,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(Dx,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Sc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(Ppe,{message:T,onRetry:()=>O(r.path),onRoot:r.path===null?void 0:()=>O(null)}):A===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):P.length===0?a.jsx(Cn,{className:"border-0 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:E?"No folder matches":"No folders here"}),a.jsx(Tn,{children:E?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(di,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[P.map(U=>a.jsxs(No,{value:U.path,onSelect:()=>O(U.path),onMouseDown:W=>W.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(Qi,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.name}),e.has(U.path)&&a.jsx(Ue,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},U.path)),A.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Cpe.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:U=>void F(U),className:"flex items-center gap-2",children:[a.jsx(zn,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:U=>{x(U.target.value),w(null)},onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),D())}}),a.jsxs(J,{type:"submit",size:"sm",disabled:v||!I||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:D,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:!I,onClick:()=>h(!0),children:[a.jsx(Fj,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(J,{type:"button",size:"sm",className:"ml-auto",disabled:!I,onClick:$,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function Ipe(n){const e=q.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=gZ(t,s);l=hA,f="border-b px-3 py-1.5",i=gA,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(vA,{}),a.jsx(k1,{className:"shrink-0",children:x===h.length-1?a.jsx(bA,{children:g.label}):a.jsx(xA,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function Ppe(n){const e=q.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Dn,{variant:"icon",children:a.jsx(Vs,{})}),i=a.jsx(En,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(_n,{children:[o,i,a.jsx(Tn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Cn,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function $pe(){const n=q.c(7),e=xn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=La(t);let r;n[2]!==s?(r=!s&&vf(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ee("/api/hello",{signal:d.signal}).then(cr).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(Rpe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function Rpe(){}function P3(n){return n.replace(/[\\/]+$/,"")||n}function yA(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=P3(s.path);!yr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=yr(s.path),i=o&&t.get(P3(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const j1=F4("project-custom-names"),Ope=j1.rename;function Eb(){const n=q.c(2),e=y.useSyncExternalStore(j1.subscribe,j1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:Ope},n[0]=e,n[1]=t):t=n[1],t}const $3="browse-folders";function hl(n){return n.replace(/[\\/]+$/,"")||n}function wA(n){const e=q.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ee("/api/projects",{signal:l.signal}).then(Lpe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function Lpe(n){return n.ok?await n.json():[]}function SA(n){var U;const e=q.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=Eb(),b=$pe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const W=yA(t);if(!m){w=W;break e}const V=m.toLowerCase();w=W.filter(H=>{var K;return H.path.toLowerCase().includes(V)||H.shortName.toLowerCase().includes(V)||H.dirName.toLowerCase().includes(V)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(V))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let k,j;e[4]!==m||e[5]!==t?(k=m.trim(),j=(k.startsWith("/")||/^[a-z]:[\\/]/i.test(k)||k.startsWith("\\\\"))&&!t.some(V=>hl(V.path)===hl(k)),e[4]=m,e[5]=t,e[6]=k,e[7]=j):(k=e[6],j=e[7]);const _=j;let N;e[8]!==i?(N=i?hl(((U=yr(i))==null?void 0:U.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==k?(C=_?[`folder:${k}`]:[],e[10]=_,e[11]=k,e[12]=C):C=e[12];let A;e[13]!==v||e[14]!==C?(A=[...C,...v.map(zpe),$3],e[13]=v,e[14]=C,e[15]=A):A=e[15];const T=A,I=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let W;e[16]!==t?(W=new Set(t.map(Mpe)),e[16]=t,e[17]=W):W=e[17];let V;e[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>f("projects"),e[18]=V):V=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==W?(H=a.jsx(Ape,{hostName:b,projectPaths:W,onStart:r,onBack:V}),e[19]=b,e[20]=r,e[21]=W,e[22]=H):H=e[22],H}let E;e[23]!==m?(E=a.jsx(Dx,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=E):E=e[24];let P;e[25]!==_||e[26]!==v.length?(P=v.length===0&&!_&&a.jsx(Cn,{className:"border-0 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:"No projects found"}),a.jsx(Tn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=P):P=e[27];let R;e[28]!==_||e[29]!==o||e[30]!==k||e[31]!==r?(R=_&&a.jsxs(No,{value:`folder:${k}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(k),children:[a.jsx(Fj,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[k," · ",OO(o)]})]})]}),e[28]=_,e[29]=o,e[30]=k,e[31]=r,e[32]=R):R=e[32];let L;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let W;e[38]!==S||e[39]!==s||e[40]!==x?(W=V=>{const H=x[V.dirName],K=gc(V.path);return a.jsxs(No,{value:`project:${V.dirName}`,"data-checked":S!==null&&hl(V.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(V.dirName,V.path),children:[a.jsx(ha,{projectPath:V.path,fallback:a.jsx(qr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),V.sessionCount," session",V.sessionCount!==1?"s":"",V.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(V.lastModified).toLocaleDateString()]})]})]})]},V.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=W):W=e[41],L=v.map(W),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=L}else L=e[37];let O;e[42]!==L||e[43]!==R?(O=a.jsxs(di,{className:"p-0",children:[R,L]}),e[42]=L,e[43]=R,e[44]=O):O=e[44];let $,M;e[45]===Symbol.for("react.memo_cache_sentinel")?($=()=>f("folders"),M=a.jsx(mc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=$,e[46]=M):($=e[45],M=e[46]);const D=b?`Browse folders on ${b}…`:"Browse folders…";let F;e[47]!==D?(F=a.jsx(di,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(No,{value:$3,className:"h-auto gap-3 px-3 py-2.5",onSelect:$,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:D})]})}),e[47]=D,e[48]=F):F=e[48];let z;e[49]!==O||e[50]!==F||e[51]!==P?(z=a.jsxs(Sc,{className:"box-content max-h-80 p-1",children:[P,O,F]}),e[49]=O,e[50]=F,e[51]=P,e[52]=z):z=e[52];let B;return e[53]!==c||e[54]!==I||e[55]!==z||e[56]!==E?(B=a.jsxs(wc,{shouldFilter:!1,value:I,onValueChange:g,className:"rounded-none p-0",children:[E,z,c]}),e[53]=c,e[54]=I,e[55]=z,e[56]=E,e[57]=B):B=e[57],B}function Mpe(n){return hl(n.path)}function zpe(n){return`project:${n.dirName}`}function kA(n){const e=q.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?kr(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(Dpe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:gc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Dpe(n){const e=q.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=wA(c);let f;e[0]!==s?(f=a.jsx(ha,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(wa,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Ta,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(j,_)=>{u(!1),o(j,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=j=>{u(!1),i(j)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:Qu("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx($f,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(SA,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let k;return e[20]!==c||e[21]!==v||e[22]!==h?(k=a.jsxs(Ea,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=k):k=e[23],k}function Tb(n){const e=q.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const k=v;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"w-full"}),e[2]=j):j=e[2];let _;e[3]!==t?(_=a.jsx(tm,{render:j,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==k?(N=(l||o||c||u)&&a.jsxs(ii,{children:[l&&a.jsxs(Mn,{onClick:k,children:[a.jsx(gr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Mn,{onClick:o,children:[a.jsx(Cs,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Mn,{onClick:u,children:[a.jsx(gf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Mn,{onClick:c,disabled:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=k,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(mf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(nm,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let A;e[21]!==_||e[22]!==C?(A=a.jsxs(em,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=A):A=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(Gx,{children:"Delete session?"}),e[24]=T):T=e[24];let I;e[25]!==s?(I=a.jsxs(Hx,{children:[T,a.jsxs(Zx,{children:["This will permanently delete"," ",a.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=I):I=e[26];let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(Xx,{size:"sm",children:"Cancel"}),e[27]=E):E=e[27];let P;e[28]!==i?(P=a.jsxs(Kx,{children:[E,a.jsx(Yx,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=P):P=e[29];let R;e[30]!==I||e[31]!==P?(R=a.jsxs(Vx,{children:[I,P]}),e[30]=I,e[31]=P,e[32]=R):R=e[32];let L;e[33]!==m||e[34]!==R?(L=a.jsx(qx,{open:m,onOpenChange:p,children:R}),e[33]=m,e[34]=R,e[35]=L):L=e[35];let O;e[36]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(to,{children:[a.jsx(Js,{className:"text-foreground",children:"Rename session"}),a.jsx(Qs,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=O):O=e[36];let $;e[37]!==l||e[38]!==x?($=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=$):$=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(rn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=V=>b(V.target.value),e[41]=D):D=e[41];let F;e[42]!==x||e[43]!==s?(F=a.jsxs(sn,{children:[M,a.jsx(zn,{id:"session-rename",ref:w,value:x,onChange:D,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=F):F=e[44];let z;e[45]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsxs(dx,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[45]=z):z=e[45];let B;e[46]!==$||e[47]!==F?(B=a.jsxs(Xs,{className:"sm:max-w-md",children:[O,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:$,children:[F,z]})]}),e[46]=$,e[47]=F,e[48]=B):B=e[48];let U;e[49]!==h||e[50]!==B?(U=a.jsx(Ys,{open:h,onOpenChange:g,children:B}),e[49]=h,e[50]=B,e[51]=U):U=e[51];let W;return e[52]!==L||e[53]!==U||e[54]!==A?(W=a.jsxs(a.Fragment,{children:[A,L,U]}),e[52]=L,e[53]=U,e[54]=A,e[55]=W):W=e[55],W}function N1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const Gh=N1(!1,!1),Fpe={unknown:Gh,none:Gh,view:Gh,interact:N1(!0,!1),own:N1(!0,!0)};function ga(n){return Fpe[n]}function jm(){const n=q.c(3),{enforcesSessionAccess:e}=C4(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>ga(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function jA(n){const e=q.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(jr,{children:i?a.jsx(vt,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Vo,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(At,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(qo,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function NA(n){const e=q.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(_r,{"aria-hidden":"true"}),o=a.jsx(Vt,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(_t,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Ao,{children:a.jsxs(J,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(wt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function CA(n){const e=q.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(Qt,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function _A(n){const e=q.c(3),{access:t}=n,{SessionBadges:s}=Tr();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Us={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},Upe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,Bpe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,Wpe=/(?:^|\s)#(\d+)(?=\s|$)/,qpe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Mu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function Vpe(n){const e=n.trim().replace(/^(?:pr|pull\s+request)\b/i,"").trim().replace(/^(?:in|on)\s+/i,"");return!e||/^(?:pr|pull\s+request)$/i.test(e)?null:e.toLowerCase()}function EA(n){const e=n.trim();if(!e)return null;const t=Upe.exec(e);if(t){const l=Mu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=Bpe.exec(e);if(s){const l=Mu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=Wpe.exec(e);if(r){const l=Mu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:Vpe(c)}}const o=qpe.exec(e);if(!o)return null;const i=Mu(o[1]);return i===null?null:{number:i,repoHint:null}}function R3(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function Hpe(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(r=>r.replace(/[^a-z0-9]/g,"")===s)}function Kpe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?R3(n.repo,s):R3(n.repo,s)?!0:t.some(r=>Hpe(r,s)):!0}function TA(n,e,t=[]){var o;const s=EA(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Kpe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const Gpe=120*1e3;function AA(n){return n?Date.now()-new Date(n).getTime()<Gpe:!1}function IA(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Ms(s,70):Ms(n.sessionId,16)}function O3(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function Zpe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||O3(t)===O3(e)?null:Ms(t,220)}function Ype(n,e){return TA(n,e)}function Xpe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?wr(t):null}function Jpe(n){const e=[n.sessionId];return n.cwd&&e.push(n.cwd),n.version&&e.push(`CLI ${n.version}`),n.timestamp&&e.push(`Started ${new Date(n.timestamp).toLocaleString()}`),e.join(`
|
|
455
|
-
`)}function Qpe(n){var t;const e=n.cwd?(t=yr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:u$,label:e,title:n.cwd}:n.gitBranch?{icon:Wr,label:n.gitBranch}:null}function ehe(n,e){return n.agentStatus==="deferred"?"attention":e?Oc(n.agentStatus)?"idle":"working":null}function the(n){const e=q.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Oc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Rc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=Xf(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Ue,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=b0(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Ue,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function Zh(n){const e=q.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function nhe(n){const e=q.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=AA(o),l=ehe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,k,j,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const $=Qpe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=Xpe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const D=M,F=t.turnCount??0;let z,B;e[29]!==s||e[30]!==t?(B=IA(t,s),z=Zpe(t,B),e[29]=s,e[30]=t,e[31]=z,e[32]=B):(z=e[31],B=e[32]);const U=z;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=Jpe(t),e[33]=t,e[34]=p):p=e[34],h="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let W;e[35]===Symbol.for("react.memo_cache_sentinel")?(W=a.jsx(Wv,{className:"size-4"}),e[35]=W):W=e[35];let V;e[36]!==c?(V=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Us[c])}),e[36]=c,e[37]=V):V=e[37],e[38]!==V?(g=a.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[W,V]}),e[38]=V,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==B?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:B}),e[40]=B,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",children:[a.jsx(ea,{"data-icon":"inline-start"}),Ms(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(X1,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(the,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let X;e[49]!==o?(X=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Sr(o)}),e[49]=o,e[50]=X):X=e[50];let ee;e[51]!==Y||e[52]!==X?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,X]}),e[51]=Y,e[52]=X,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==U?(d=U&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:U}),e[59]=U,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(_A,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Ue,{variant:"outline",children:xi(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==F?(k=F>0&&a.jsxs(Zh,{icon:Wv,children:[F," ",F===1?"turn":"turns"]}),e[65]=F,e[66]=k):k=e[66],e[67]!==D?(j=D&&a.jsx(Zh,{icon:Eo,title:"First prompt to last activity",children:D}),e[67]=D,e[68]=j):j=e[68],_=$&&a.jsx(Zh,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:Ms($.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=k,e[22]=j,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],k=e[21],j=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=b4(t.size),e[69]=t.size,e[70]=C):C=e[70];let A;e[71]!==C?(A=a.jsx("span",{children:C}),e[71]=C,e[72]=A):A=e[72];let T;e[73]!==A||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==k||e[78]!==j||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,k,j,_,A]}),e[73]=A,e[74]=b,e[75]=w,e[76]=v,e[77]=k,e[78]=j,e[79]=_,e[80]=T):T=e[80];let I;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?(I=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=I):I=e[85];let E;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==I?(E=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,I]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=I,e[92]=E):E=e[92];let P;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(P=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=P):P=e[95];let R;e[96]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=R):R=e[96];let L;e[97]!==P?(L=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[P,R]}),e[97]=P,e[98]=L):L=e[98];let O;return e[99]!==x||e[100]!==E||e[101]!==L?(O=a.jsxs("div",{className:x,children:[E,L]}),e[99]=x,e[100]=E,e[101]=L,e[102]=O):O=e[102],O}function she(n){const e=q.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:k,rename:j}=If(),_=jm();let N;e[0]!==t.path?(N=kr(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(k1,{children:a.jsx(xA,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let A;e[4]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(vA,{}),e[4]=A):A=e[4];let T;e[5]!==S?(T=a.jsx(k1,{className:"min-w-0",children:a.jsx(bA,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let I;e[7]!==C||e[8]!==T?(I=a.jsx(hA,{children:a.jsxs(gA,{children:[C,A,T]})}),e[7]=C,e[8]=T,e[9]=I):I=e[9];let E;e[10]!==S?(E=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=E):E=e[11];let P;e[12]!==o?(P=a.jsx(Ue,{variant:"secondary",children:o}),e[12]=o,e[13]=P):P=e[13];let R;e[14]!==E||e[15]!==P?(R=a.jsxs("div",{className:"flex items-center gap-2",children:[E,P]}),e[14]=E,e[15]=P,e[16]=R):R=e[16];let L;e[17]!==t.path?(L=gc(t.path),e[17]=t.path,e[18]=L):L=e[18];let O;e[19]!==L?(O=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:L}),e[19]=L,e[20]=O):O=e[20];let $;e[21]!==O||e[22]!==R?($=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[R,O]}),e[21]=O,e[22]=R,e[23]=$):$=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(jA,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let D;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(D=p&&a.jsxs(J,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(xr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let F;e[33]!==M||e[34]!==D?(F=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,D]}),e[33]=M,e[34]=D,e[35]=F):F=e[35];let z;e[36]!==f||e[37]!==w?(z=f&&a.jsx(NA,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=z):z=e[38];let B;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==j||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==k||e[51]!==r||e[52]!==i||e[53]!==o?(B=(i||l)&&d.length===0?a.jsx(CA,{includeMessagePlaceholder:!0}):d.length===0?a.jsx(rhe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((V,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(Qt,{}),a.jsx(Tb,{sessionLabel:IA(V),customName:k[V.sessionId],onRename:K=>j(V.sessionId,K),onDuplicate:g?()=>g(t.dirName,V.fileName):void 0,onDelete:x&&_(V.access).delete?()=>x(t.dirName,V.fileName):void 0,children:a.jsx(nhe,{session:V,customName:k[V.sessionId],onSelect:()=>m(t.dirName,V.fileName)})})]},V.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(J,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=j,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=k,e[51]=r,e[52]=i,e[53]=o,e[54]=B):B=e[54];let U;e[55]!==F||e[56]!==z||e[57]!==B?(U=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[F,z,B]}),e[55]=F,e[56]=z,e[57]=B,e[58]=U):U=e[58];let W;return e[59]!==$||e[60]!==U||e[61]!==I?(W=a.jsx(Cc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[I,$,U]})}),e[59]=$,e[60]=U,e[61]=I,e[62]=W):W=e[62],W}function rhe(n){const e=q.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Dn,{variant:"icon",children:a.jsx(To,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(En,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Tn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Cn,{className:"min-h-72 border",children:a.jsxs(_n,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function PA(n){const e=q.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(tm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(gr,{"data-icon":"inline-start"}),e[9]=k):k=e[9];let j;e[10]!==x?(j=a.jsx(ii,{children:a.jsxs(Mn,{onClick:x,children:[k,"Rename project"]})}),e[10]=x,e[11]=j):j=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{onClick:c,disabled:u===0,children:[a.jsx(ks,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs(nm,{className:"min-w-44",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(em,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(to,{children:[a.jsx(Js,{className:"text-foreground",children:"Rename project"}),a.jsx(Qs,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let A;e[22]!==i||e[23]!==m?(A=$=>{$.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=A):A=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(rn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let I;e[26]===Symbol.for("react.memo_cache_sentinel")?(I=$=>p($.target.value),e[26]=I):I=e[26];let E;e[27]!==s||e[28]!==m?(E=a.jsxs(sn,{children:[T,a.jsx(zn,{id:"project-rename",ref:h,value:m,onChange:I,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=E):E=e[29];let P;e[30]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsxs(dx,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[30]=P):P=e[30];let R;e[31]!==A||e[32]!==E?(R=a.jsxs(Xs,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:A,children:[E,P]})]}),e[31]=A,e[32]=E,e[33]=R):R=e[33];let L;e[34]!==d||e[35]!==R?(L=a.jsx(Ys,{open:d,onOpenChange:f,children:R}),e[34]=d,e[35]=R,e[36]=L):L=e[36];let O;return e[37]!==S||e[38]!==L?(O=a.jsxs(a.Fragment,{children:[S,L]}),e[37]=S,e[38]=L,e[39]=O):O=e[39],O}function ohe(n){const e=q.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const $ of s)AA($.lastModified)&&(m[$.dirName]=(m[$.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=Eb();let x;e[2]!==t?(x=yA(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let $;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),D=F=>{var z;return F.path.toLowerCase().includes(M)||F.shortName.toLowerCase().includes(M)||((z=h[F.dirName])==null?void 0:z.toLowerCase().includes(M))};$=b.filter(F=>D(F)||F.worktrees.some(D)),e[4]=h,e[5]=b,e[6]=i,e[7]=$}else $=e[7];w=$}const v=w;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=k):k=e[8];let j;e[9]!==b.length?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[k,a.jsx(Ue,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=j):j=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==j?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[j,_]}),e[12]=j,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(jA,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let A;e[17]!==C?(A=G(C),e[17]=C,e[18]=A):A=e[18];let T;e[19]!==A?(T=a.jsx(Fn,{"data-icon":"inline-start",className:A}),e[19]=A,e[20]=T):T=e[20];let I;e[21]!==f||e[22]!==o||e[23]!==T?(I=a.jsxs(J,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=I):I=e[24];let E;e[25]!==I||e[26]!==S?(E=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,I]}),e[25]=I,e[26]=S,e[27]=E):E=e[27];let P;e[28]!==c||e[29]!==f||e[30]!==u?(P=c&&!u&&a.jsx(NA,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=P):P=e[31];let R;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(R=r?a.jsx(CA,{}):v.length===0?a.jsxs(Cn,{className:"min-h-72 border",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Tn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(vc,{children:a.jsxs(J,{variant:"outline",size:"sm",onClick:ihe,children:[a.jsx(mc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map(($,M)=>{const D=p[$.dirName]||0,F=h[$.dirName],z=LO(an($.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(Qt,{}),a.jsx(PA,{projectLabel:kr($.path),customName:F,onRename:B=>g($.dirName,B),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d($.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(ha,{projectPath:$.path,className:"size-4",fallback:a.jsx(qr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:F||kr($.path)}),z&&a.jsx(Ue,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:z})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[gc($.path),$.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",$.worktrees.length," ",$.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[$.sessionCount," ",$.sessionCount===1?"session":"sessions"]}),$.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Sr($.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),$.worktrees.map(B=>a.jsx(ahe,{worktree:B,customName:h[B.dirName],activeCount:p[B.dirName]||0,onSelect:()=>d==null?void 0:d(B.dirName)},B.dirName))]},$.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=R):R=e[39];let L;e[40]!==E||e[41]!==P||e[42]!==R?(L=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[E,P,R]}),e[40]=E,e[41]=P,e[42]=R,e[43]=L):L=e[43];let O;return e[44]!==L||e[45]!==N?(O=a.jsx(Cc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,L]})}),e[44]=L,e[45]=N,e[46]=O):O=e[46],O}function ihe(){return V_()}function ahe(n){var b;const e=q.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=yr(t.path))==null?void 0:b.worktreeName)||kr(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Wr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Sr(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const lhe=250,che=400,L3={results:null,loading:!1,error:null};function $A(n,e,t){const s=y.useMemo(()=>EA(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState(L3);y.useEffect(()=>{if(!s){l(L3);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Hr();try{const x=await Ee(Tf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},che);return}const v=Array.isArray(b)?b:[];ra(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},lhe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Af(c)},[u,c]),{...i,active:u,refresh:c}}const uhe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var ne;const c=Ef(),u=(ne=Tr().sessionListFilter)==null?void 0:ne.Empty,[d]=y.useState(()=>({projects:Vi(Vl.projects),activeSessions:Vi(qu(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,k]=y.useState(null),[j,_]=y.useState(null),[N,S]=y.useState([]),[C,A]=y.useState(0),[T,I]=y.useState(1),[E,P]=y.useState(!1),[R,L]=y.useState(""),[O,$]=y.useState(null),M=y.useRef(0),D=y.useRef(null),F=y.useRef(null),z=y.useRef(c.key),B=y.useCallback(async()=>{try{const te=await Ee("/api/projects");if(!te.ok)throw new Error("Failed to fetch dashboard data");const re=await te.json(),oe=Array.isArray(re)?re:[];m(oe),wl(Vl.projects,oe),k(null)}catch(te){k(te instanceof Error?te.message:"Failed to load data")}finally{x(!1)}},[]),U=y.useCallback(async()=>{var oe;(oe=F.current)==null||oe.abort();const te=new AbortController;F.current=te;const re=Hr();try{const ie=await Ee(Tf({},c),{signal:te.signal});if(!ie.ok)throw new Error("Failed to fetch dashboard data");const ae=await ie.json();if(te.signal.aborted)return;const de=Array.isArray(ae)?ae:[];ra(de,re),h(de),wl(qu(c.key),de),_(null)}catch(ie){if(te.signal.aborted)return;_(ie instanceof Error?ie.message:"Failed to load data")}},[c]);y.useEffect(()=>{B()},[B]),y.useEffect(()=>{z.current!==c.key&&(z.current=c.key,h(Vi(qu(c.key))??[])),U()},[c,U]);async function W(){w(!0),await Promise.all([B(),U()]),w(!1)}const V=y.useCallback(async(te,re=1,oe=!1)=>{var se;const ie=++M.current;(se=D.current)==null||se.abort();const ae=new AbortController;D.current=ae;const de=()=>ie===M.current;P(!0),$(null);const le=Hr();if(!oe){const me=pR(te,c.key);me?(S(me.sessions),A(me.total),I(1)):S([])}try{const me=await Ee(Sl(`/api/sessions/${encodeURIComponent(te)}`,c,{page:String(re),limit:"20"}),{signal:ae.signal});if(!me.ok)throw new Error(`Failed to load sessions (${me.status})`);const ue=await me.json();if(!de())return;const ce=Array.isArray(ue.sessions)?ue.sessions:[],xe=typeof ue.total=="number"?ue.total:ce.length;ra(ce,le),S(pe=>oe?[...pe,...ce]:ce),A(xe),I(re),oe||hR(te,c.key,{sessions:ce,total:xe})}catch(me){if(!de()||ae.signal.aborted)return;$(me instanceof Error?me.message:"Failed to load sessions")}finally{de()&&(D.current=null,P(!1))}},[c]);y.useEffect(()=>{var te;if(!r){M.current+=1,(te=D.current)==null||te.abort(),D.current=null,S([]),A(0),I(1),P(!1);return}V(r)},[r,V]),y.useEffect(()=>{L("")},[r]),y.useEffect(()=>()=>{var te,re;M.current+=1,(te=D.current)==null||te.abort(),(re=F.current)==null||re.abort()},[]),y.useEffect(()=>Af(()=>{U(),r&&V(r)}),[U,V,r]);const H=y.useMemo(()=>{if(!r)return null;const te=f.find(oe=>oe.dirName===r);if(te)return te;const re=ms(r);return{dirName:r,path:re,shortName:kr(re),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&V(r,T+1,!0)},[r,T,V]),Y=$A(r?R:"",c,r??void 0),X=y.useMemo(()=>R?N.filter(te=>Ype(te,R)):N,[N,R]),ee=Y.results??X;async function Q(te,re){await(l==null?void 0:l(te,re))&&(S(oe=>oe.filter(ie=>ie.fileName!==re)),A(oe=>oe-1))}return H?a.jsx(she,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:E,searchLoading:Y.loading,searchFilter:R,setSearchFilter:L,filteredSessions:ee,fetchError:Y.error??O,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:Q,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}$(null),r&&V(r)},loadMoreSessions:Z}):a.jsx(ohe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:R,setSearchFilter:L,fetchError:v??j,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void W()})}),M3=768;function Ab(){const n=q.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<M3:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${M3-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const RA=typeof navigator<"u"&&"vibrate"in navigator;function C1(){RA&&navigator.vibrate(10)}function dhe(){RA&&navigator.vibrate(20)}function fhe(n){return!!(n.teamName&&n.agentName)}function mhe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of ja(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(fhe(d))continue;const m=xx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||jf.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function phe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=vx(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):vr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:ja(i),workingCrews:l}}function OA(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}const LA="aw:turnCounts",hhe=200,Nm=new Map;try{const n=localStorage.getItem(LA);if(n){const e=JSON.parse(n);for(const[t,s]of e)Nm.set(t,s)}}catch{}function ghe(){try{const n=[...Nm.entries()].slice(-hhe);localStorage.setItem(LA,JSON.stringify(n))}catch{}}function xhe(n,e){Nm.set(en(n),e),ghe()}function MA(n,e){const t=Nm.get(en(n));return Math.max(t??0,e??0)}function Ib(n){const e=q.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=MA(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Qi,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",Xf(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Zs,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(ks,{className:"size-3"}),hx(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(zc,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let k;e[20]!==t.gitBranch||e[21]!==i?(k=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Wr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=k):k=e[22];let j;e[23]!==f?(j=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(To,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=j):j=e[24];let _;e[25]!==t.size?(_=b4(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(d$,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let A;e[31]!==C?(A=Sr(C),e[31]=C,e[32]=A):A=e[32];let T;e[33]!==A?(T=a.jsx("span",{children:A}),e[33]=A,e[34]=T):T=e[34];let I;e[35]!==j||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==k?(I=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[k,j,N,S,T]}),e[35]=j,e[36]=N,e[37]=S,e[38]=T,e[39]=k,e[40]=I):I=e[40];let E;return e[41]!==m||e[42]!==I||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(E=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,I]}),e[41]=m,e[42]=I,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=E):E=e[50],E}const bhe=120;function Pb(n){const e=q.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,bhe))},e[2]=n,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const vhe=6;function yhe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:OA(n)}function whe(n){const e=q.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(She),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=Sr(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function She(n){return n+1}const khe={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},plan:{label:"Review plan",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function jhe({reason:n,crew:e}){const t=khe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const Nhe={permission:Us.attention,deferred:Us.attention,waiting:Us.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Us.attention};function z3(n){const e=q.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=v0(an(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let k;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(k=v?"Read-only":Rc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=k):k=e[9];const j=k,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=Pb(x),C=b?"px-2.5 py-2":"border px-2 py-2",A=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==A?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,A),e[10]=o,e[11]=C,e[12]=A,e[13]=T):T=e[13];let I;e[14]!==b||e[15]!==l?(I=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=I):I=e[16];const E=_&&"pr-20";let P;e[17]!==E?(P=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[17]=E,e[18]=P):P=e[18];let R;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==P?(R=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:P}),e[19]=S,e[20]=N,e[21]=p,e[22]=P,e[23]=R):R=e[23];const L=b&&"ring-0";let O;e[24]!==r||e[25]!==L?(O=G("size-1.5 shrink-0 rounded-full",r,L),e[24]=r,e[25]=L,e[26]=O):O=e[26];let $;e[27]!==O?($=a.jsx("span",{className:O,"aria-hidden":"true"}),e[27]=O,e[28]=$):$=e[28];let M;e[29]!==d||e[30]!==t?(M=li(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let D;e[32]!==M?(D=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=D):D=e[33];const F=b?"text-muted-foreground":s.className;let z;e[34]!==F?(z=G("shrink-0",F),e[34]=F,e[35]=z):z=e[35];const B=v?"Read-only":s.label;let U;e[36]!==z||e[37]!==B?(U=a.jsx(Ue,{variant:"outline",className:z,children:B}),e[36]=z,e[37]=B,e[38]=U):U=e[38];let W;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(W=!b&&a.jsx(whe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=W):W=e[43];let V;e[44]!==$||e[45]!==D||e[46]!==U||e[47]!==W?(V=a.jsxs("span",{className:"flex items-center gap-1.5",children:[$,D,U,W]}),e[44]=$,e[45]=D,e[46]=U,e[47]=W,e[48]=V):V=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==R||e[52]!==V||e[53]!==H?(K=a.jsxs(Ut,{render:R,children:[V,H]}),e[51]=R,e[52]=V,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==j?(Z=a.jsx(Bt,{side:"right",className:"max-w-[280px]",children:a.jsx(Ib,{session:t,proc:c,statusLabel:j,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=j,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Ft,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let X;e[63]!==_||e[64]!==g?(X=_&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=X):X=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ne=>h(c.pid,ne),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let Q;return e[71]!==Y||e[72]!==X||e[73]!==ee||e[74]!==T||e[75]!==I?(Q=a.jsxs("div",{className:T,children:[I,Y,X,ee]}),e[71]=Y,e[72]=X,e[73]=ee,e[74]=T,e[75]=I,e[76]=Q):Q=e[76],Q}function Che(n){const e=q.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function _he(n){const e=q.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=jm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,vhe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||px(C.cwd||ms(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let k;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(k=C=>{const A=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:A,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!A?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=k):k=e[14];const j=k;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==j?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Che,{dotClassName:Us.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var I;const{session:A,reason:T}=C;return a.jsx(z3,{...j(A),chip:jhe(C),since:T==="crew"?(I=C.crew)==null?void 0:I.longestWaitSince:void 0,dotClassName:Nhe[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(A.access).send?()=>d(A.sessionId,A.cwd,A.dirName):void 0},`${A.dirName}/${A.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=j,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==j||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx(z3,{...j(C),chip:{label:yhe(C,t),className:""},dotClassName:Us.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(Wt,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=j,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function Ehe(n){const e=q.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=D=>d(D.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Vo,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(jr,{align:"inline-start",children:o?a.jsx(vt,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(At,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(qo,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx($j,{"data-icon":"inline-start"})}),a.jsx(Bt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const k=s?"icon-sm":"icon-xs",j=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==k||e[25]!==j?(S=a.jsx(J,{variant:"ghost",size:k,onClick:f,"aria-pressed":i,"aria-label":j,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=k,e[25]=j,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(ks,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let A;e[28]!==S?(A=a.jsx(Ut,{render:S,children:C}),e[28]=S,e[29]=A):A=e[29];const T=i?"Hide archived":"Show archived";let I;e[30]!==p||e[31]!==T?(I=a.jsxs(Bt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=I):I=e[32];let E;e[33]!==A||e[34]!==I?(E=a.jsxs(Ft,{children:[A,I]}),e[33]=A,e[34]=I,e[35]=E):E=e[35];const P=s?"icon-sm":"icon-xs",R=t&&"animate-spin";let L;e[36]!==R?(L=G(R),e[36]=R,e[37]=L):L=e[37];let O;e[38]!==L?(O=a.jsx(Fn,{"data-icon":"inline-start",className:L}),e[38]=L,e[39]=O):O=e[39];let $;e[40]!==m||e[41]!==P||e[42]!==O?($=a.jsx(J,{variant:"ghost",size:P,onClick:m,"aria-label":"Refresh sessions",children:O}),e[40]=m,e[41]=P,e[42]=O,e[43]=$):$=e[43];let M;return e[44]!==E||e[45]!==$||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,E,$]}),e[44]=E,e[45]=$,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const The=["first","second","third","fourth","fifth"];function Ahe(n){const e=q.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=Phe({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(wt,{variant:"destructive",children:[a.jsx(_r,{}),a.jsx(Vt,{children:"Could not load sessions"}),a.jsx(_t,{className:"truncate",children:t}),a.jsx(Ao,{children:a.jsx(J,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Cn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(ks,{})}),a.jsx(En,{children:"Everything is archived"}),a.jsx(Tn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(J,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let k;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(k=b==="focused"&&a.jsxs(Cn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(ag,{})}),a.jsx(En,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Tn,{children:$he(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(J,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(hd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(J,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=k):k=e[19];const j=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Cn,{className:"min-h-56 px-4 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(ag,{})}),a.jsx(En,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Tn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:The.map(Ihe)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==k||e[30]!==j||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,k,j,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=k,e[30]=j,e[31]=_,e[32]=S):S=e[32],S}function Ihe(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function Phe({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function $he(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const Yh=864e5;function Rhe(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Ohe(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=Rhe(e);return t>=s?"Today":t>=s-Yh?"Yesterday":t>=s-6*Yh?"Last 7 days":t>=s-29*Yh?"Last 30 days":"Older"}const Lhe=6,Mhe={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},D3={"needs-you":0,working:1,done:2};function zhe(n){const e=q.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(Dhe)),g=$=>!$.crew||$.crew.parentId===t.sessionId||!h.has($.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=$=>g($)||o($).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=($,M)=>D3[o($).state]-D3[o(M).state]||(o($).state==="done"?vr(M)-vr($):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let k;e[18]!==o?(k=$=>o($).state==="done",e[18]=o,e[19]=k):k=e[19];const j=v.filter(k),_=f?[]:j.slice(Lhe),N=v.filter($=>!_.includes($)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,A=i&&"rotate-90";let T;e[20]!==A?(T=G("size-3 shrink-0 transition-transform duration-150",A),e[20]=A,e[21]=T):T=e[21];let I;e[22]!==T?(I=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=I):I=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=E):E=e[24];let P;e[25]!==r.size?(P=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=P):P=e[26];let R;e[27]!==r.needsYou?(R=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=R):R=e[28];let L;e[29]!==r.working?(L=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=L):L=e[30];let O;e[31]!==l||e[32]!==i||e[33]!==P||e[34]!==R||e[35]!==L||e[36]!==C||e[37]!==I?(O=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[I,E,P,R,L]}),e[31]=l,e[32]=i,e[33]=P,e[34]=R,e[35]=L,e[36]=C,e[37]=I,e[38]=O):O=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[O,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map($=>{var H;const M=o($),D=iR($.sessionId,s),F=$.crew?h.get($.crew.parentId):void 0,z=u===`${$.dirName}/${$.fileName}`,B=jd($,{customName:c[$.sessionId],parent:F??t}),U=Uhe($,M),V=(!g($)&&F?` · via ${jd(F,{customName:c[F.sessionId],parent:h.get(((H=F.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(D>0?` · ${D} ${D===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":$.sessionId,"aria-current":z?"true":void 0,"aria-label":`${B}${V}, ${U}`,onClick:()=>d($.dirName,$.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",z&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",Fhe(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[B,V&&a.jsx("span",{className:"text-muted-foreground/70",children:V})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:U})]})},$.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function Dhe(n){return[n.sessionId,n]}function Fhe({state:n}){return n==="needs-you"?Us.attention:n==="working"?Us.working:"bg-muted-foreground/50"}function Uhe(n,{state:e,need:t}){var o;const s=Sr(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${Mhe[t??"input"]} · ${s}`;if(e==="working")return OA(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const Bhe={};function Whe(n){var $r,wn;const e=q.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:A,activeSessionKey:T}=n,I=A===void 0?Bhe:A,E=T===void 0?null:T,{isLive:P,isRunning:R,isNativeIdle:L,isDeferred:O,isReadOnly:$,isTeammate:M,isArchived:D,statusLabel:F,dotState:z,justFinished:B}=y0(t,l,u),[U,W]=y.useState(!1);let V;e[0]!==d||e[1]!==t?(V=w4(t,d),e[0]=d,e[1]=t,e[2]=V):V=e[2];const H=V,K=Y8(t,d),Z=o&&!C?s:void 0,Y=qhe(S==null?void 0:S.counts,z),X=S!==void 0&&Date.parse(S.activityAt)>vr(t),ee=t.lastUserMessage||t.firstUserMessage,Q=!!ee&&ee!==H,ne=MA(t.sessionId,t.turnCount);let te;e[3]!==t.archivedReason?(te=hx(t.archivedReason),e[3]=t.archivedReason,e[4]=te):te=e[4];const re=te,oe=D?k&&{label:"Restore from archive",icon:gf,run:()=>k(t)}:v&&!R&&{label:"Archive session",icon:ks,run:()=>v(t)},ie=O&&!!N&&!$,ae=!!m&&!!h,de=!!t.matchedPullRequestNumber||!!(($r=t.pullRequests)!=null&&$r.length),le=ie||ae||de;let se;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(se=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=se):se=e[9];const{onHoverStart:me,onHoverEnd:ue}=Pb(se);let ce;e[10]!==N||e[11]!==U||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(ce=()=>{!N||U||(W(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>W(!1),3e3))},e[10]=N,e[11]=U,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=ce):ce=e[15];const xe=ce,pe=!0,he=D||void 0,be=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",Vhe(i,B),D&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let we;e[16]!==C?(we=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(H1,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=we):we=e[17];let ve;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(ve=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=ve):ve=e[21];const Se=i?"true":void 0,Te=C?"pt-1":"pt-2.5",Ae=le||S?"pb-1.5":"pb-2.5";let ze;e[22]!==Te||e[23]!==Ae?(ze=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",Te,Ae),e[22]=Te,e[23]=Ae,e[24]=ze):ze=e[24];let De;e[25]!==ue||e[26]!==me||e[27]!==ve||e[28]!==Se||e[29]!==ze?(De=a.jsx("button",{type:"button","data-live-session":!0,onClick:ve,onMouseEnter:me,onMouseLeave:ue,onFocus:me,onBlur:ue,"aria-current":Se,className:ze}),e[25]=ue,e[26]=me,e[27]=ve,e[28]=Se,e[29]=ze,e[30]=De):De=e[30];let Le;e[31]!==Z||e[32]!==r?(Le=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(ha,{projectPath:r,fallback:a.jsx(Qi,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Le):Le=e[33];let Ce;e[34]!==Y?(Ce=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Us[Y])}),e[34]=Y,e[35]=Ce):Ce=e[35];let Be;e[36]!==Ce?(Be=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Ce}),e[36]=Ce,e[37]=Be):Be=e[37];const We=K?"text-muted-foreground":"font-medium text-foreground";let He;e[38]!==We?(He=G("line-clamp-2 flex-1 text-sm leading-snug",We),e[38]=We,e[39]=He):He=e[39];let _e;e[40]!==H||e[41]!==He?(_e=a.jsx("span",{className:He,children:H}),e[40]=H,e[41]=He,e[42]=_e):_e=e[42];let Re;e[43]!==Be||e[44]!==_e?(Re=a.jsxs("span",{className:"flex items-start gap-2",children:[Be,_e]}),e[43]=Be,e[44]=_e,e[45]=Re):Re=e[45];let tt;e[46]!==ee||e[47]!==Q?(tt=Q&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=Q,e[48]=tt):tt=e[48];let Xe;e[49]!==O||e[50]!==P||e[51]!==L||e[52]!==t.agentStatus||e[53]!==F?(Xe=P&&!O&&F&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G(L?"text-success":Xf(t.agentStatus)),children:F}),e[49]=O,e[50]=P,e[51]=L,e[52]=t.agentStatus,e[53]=F,e[54]=Xe):Xe=e[54];let Ne;e[55]!==O?(Ne=O&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=O,e[56]=Ne):Ne=e[56];let Ve;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(Ve=M&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(ea,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=Ve):Ve=e[60];let ye;e[61]!==t.access?(ye=a.jsx(_A,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let $e;e[63]!==f?($e=f&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(Wr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=$e):$e=e[64];let qe;e[65]!==t.gitBranch||e[66]!==f?(qe=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Wr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=qe):qe=e[67];let Ke;e[68]!==ne?(Ke=ne>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(To,{className:"size-3 shrink-0","aria-hidden":"true"}),ne," ",ne===1?"turn":"turns"]}),e[68]=ne,e[69]=Ke):Ke=e[69];let fe;e[70]!==re||e[71]!==D?(fe=D&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ks,{className:"size-3 shrink-0","aria-label":re,role:"img"}),"Archived"]}),e[70]=re,e[71]=D,e[72]=fe):fe=e[72];let ke;e[73]!==S||e[74]!==X||e[75]!==t?(ke=X?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",S4({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",Sr(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:Sr(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=X,e[75]=t,e[76]=ke):ke=e[76];let Ge;e[77]!==Xe||e[78]!==Ne||e[79]!==Ve||e[80]!==ye||e[81]!==$e||e[82]!==qe||e[83]!==Ke||e[84]!==fe||e[85]!==ke?(Ge=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Xe,Ne,Ve,ye,$e,qe,Ke,fe,ke]}),e[77]=Xe,e[78]=Ne,e[79]=Ve,e[80]=ye,e[81]=$e,e[82]=qe,e[83]=Ke,e[84]=fe,e[85]=ke,e[86]=Ge):Ge=e[86];let Je;e[87]!==De||e[88]!==Le||e[89]!==Re||e[90]!==tt||e[91]!==Ge?(Je=a.jsxs(Ut,{render:De,children:[Le,Re,tt,Ge]}),e[87]=De,e[88]=Le,e[89]=Re,e[90]=tt,e[91]=Ge,e[92]=Je):Je=e[92];const rt=Z?void 0:s;let Kt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==F||e[97]!==rt||e[98]!==f?(Kt=a.jsx(Bt,{side:"right",className:"max-w-[320px]",children:a.jsx(Ib,{session:t,proc:l,statusLabel:F,customName:d,worktreeName:f,projectLabel:rt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=F,e[97]=rt,e[98]=f,e[99]=Kt):Kt=e[99];let pn;e[100]!==Je||e[101]!==Kt?(pn=a.jsxs(Ft,{children:[Je,Kt]}),e[100]=Je,e[101]=Kt,e[102]=pn):pn=e[102];let $n;e[103]!==ie||e[104]!==xe||e[105]!==le||e[106]!==ae||e[107]!==h||e[108]!==U||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?($n=le&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:2,compact:!0}),ae&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(Zs,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ie&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:xe,disabled:U,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ie,e[104]=xe,e[105]=le,e[106]=ae,e[107]=h,e[108]=U,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=$n):$n=e[113];let Xn;e[114]!==E||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==I?(Xn=S&&a.jsx(zhe,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:I,activeSessionKey:E,onSelectSession:g}),e[114]=E,e[115]=S,e[116]=g,e[117]=t,e[118]=I,e[119]=Xn):Xn=e[119];let Rn;e[120]!==oe||e[121]!==S?(Rn=oe&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:oe.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:oe.label,"aria-label":oe.label,children:a.jsx(oe.icon,{"data-icon":"inline-start"})}),e[120]=oe,e[121]=S,e[122]=Rn):Rn=e[122];let On;e[123]!==S||e[124]!==D||e[125]!==$||e[126]!==R||e[127]!==c||e[128]!==x||e[129]!==l?(On=l&&x&&R&&!D&&!$&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Es=>x(l.pid,Es),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[123]=S,e[124]=D,e[125]=$,e[126]=R,e[127]=c,e[128]=x,e[129]=l,e[130]=On):On=e[130];let Jn;e[131]!==we||e[132]!==pn||e[133]!==$n||e[134]!==Xn||e[135]!==Rn||e[136]!==On||e[137]!==he||e[138]!==be?(Jn=a.jsxs("div",{"data-session-card":pe,"data-archived":he,className:be,children:[we,pn,$n,Xn,Rn,On]}),e[131]=we,e[132]=pn,e[133]=$n,e[134]=Xn,e[135]=Rn,e[136]=On,e[137]=he,e[138]=be,e[139]=Jn):Jn=e[139];const hn=Jn;if(b||w||j||v||k){let Es;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Es=t.slug||((wn=t.firstUserMessage)==null?void 0:wn.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Es):Es=e[143];let Ts;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ts=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ts):Ts=e[147];let nr;e[148]!==w||e[149]!==t?(nr=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=nr):nr=e[150];let sr;e[151]!==j||e[152]!==t.sessionId?(sr=j?za=>j(t.sessionId,za):void 0,e[151]=j,e[152]=t.sessionId,e[153]=sr):sr=e[153];let gs;e[154]!==D||e[155]!==v||e[156]!==t?(gs=v&&!D?()=>v(t):void 0,e[154]=D,e[155]=v,e[156]=t,e[157]=gs):gs=e[157];let rr;e[158]!==D||e[159]!==k||e[160]!==t?(rr=k&&D?()=>k(t):void 0,e[158]=D,e[159]=k,e[160]=t,e[161]=rr):rr=e[161];let vi;return e[162]!==hn||e[163]!==d||e[164]!==R||e[165]!==Es||e[166]!==Ts||e[167]!==nr||e[168]!==sr||e[169]!==gs||e[170]!==rr?(vi=a.jsx(Tb,{sessionLabel:Es,customName:d,onDuplicate:Ts,onDelete:nr,onRename:sr,onArchive:gs,onUnarchive:rr,archiveDisabled:R,children:hn}),e[162]=hn,e[163]=d,e[164]=R,e[165]=Es,e[166]=Ts,e[167]=nr,e[168]=sr,e[169]=gs,e[170]=rr,e[171]=vi):vi=e[171],vi}return hn}function qhe(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function Vhe(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function Hhe(n){var ue;const e=q.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:k}=n,{isLive:j,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:A,isArchived:T,statusLabel:I,dotState:E,justFinished:P}=y0(t,r,i),[R,L]=y.useState(!1);let O;e[0]!==t.archivedReason?(O=hx(t.archivedReason),e[0]=t.archivedReason,e[1]=O):O=e[1];const $=O;let M;e[2]!==l||e[3]!==t?(M=li(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const D=M,F=T?b&&{label:"Restore from archive",icon:gf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:ks,run:()=>x(t)};let z;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(z=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=z):z=e[9];const{onHoverStart:B,onHoverEnd:U}=Pb(z);let W;e[10]!==k||e[11]!==R||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(W=ce=>{ce.stopPropagation(),!(!k||R)&&(L(!0),k(t.sessionId,t.cwd,t.dirName),setTimeout(()=>L(!1),3e3))},e[10]=k,e[11]=R,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=W):W=e[15];const V=W,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",Khe(s,P),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==U||e[21]!==B||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:B,onMouseLeave:U,onFocus:B,onBlur:U,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=U,e[21]=B,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==D?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:D}),e[24]=D,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(Wr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let Q;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==I||e[34]!==c?(Q=a.jsx(Bt,{side:"right",className:"max-w-[280px]",children:a.jsx(Ib,{session:t,proc:r,statusLabel:I,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=I,e[34]=c,e[35]=Q):Q=e[35];let ne;e[36]!==f||e[37]!==u||e[38]!==d?(ne=!!u&&f&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(Zs,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=ne):ne=e[39];let te;e[40]!==V||e[41]!==S||e[42]!==C||e[43]!==k||e[44]!==R?(te=S&&k&&!C&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:V,disabled:R,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]}),e[40]=V,e[41]=S,e[42]=C,e[43]=k,e[44]=R,e[45]=te):te=e[45];let re;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(re=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=re):re=e[48];let oe;e[49]!==$||e[50]!==T?(oe=T&&a.jsx(ks,{className:"size-3 shrink-0 text-muted-foreground","aria-label":$,role:"img"}),e[49]=$,e[50]=T,e[51]=oe):oe=e[51];const ie=t.lastActivityAt||t.lastModified;let ae;e[52]!==ie?(ae=Sr(ie),e[52]=ie,e[53]=ae):ae=e[53];let de;e[54]!==ae?(de=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:ae}),e[54]=ae,e[55]=de):de=e[55];let le;e[56]!==F?(le=F&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>{ce.stopPropagation(),F.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:F.label,"aria-label":F.label,children:a.jsx(F.icon,{"data-icon":"inline-start"})}),e[56]=F,e[57]=le):le=e[57];let se;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(se=r&&p&&_&&!T&&!C&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>p(r.pid,ce),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=se):se=e[64];const me=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Ft,{children:[a.jsxs(Ut,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:E&&a.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Us[E])})}),Y,A&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(ea,{"data-icon":"inline-start"}),D!==t.agentName?t.agentName:"Agent"]}),j&&!S&&I&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&Xf(t.agentStatus)),children:I}),X,ee]}),Q]}),ne,te,re,oe,de,le,se]});if(h||g||w||x||b){let ce;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ce=t.slug||((ue=t.firstUserMessage)==null?void 0:ue.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ce):ce=e[68];let xe;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(xe=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=xe):xe=e[72];let pe;e[73]!==g||e[74]!==t?(pe=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=pe):pe=e[75];let he;e[76]!==w||e[77]!==t.sessionId?(he=w?ve=>w(t.sessionId,ve):void 0,e[76]=w,e[77]=t.sessionId,e[78]=he):he=e[78];let be;e[79]!==T||e[80]!==x||e[81]!==t?(be=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=be):be=e[82];let we;return e[83]!==T||e[84]!==b||e[85]!==t?(we=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=we):we=e[86],a.jsx(Tb,{sessionLabel:ce,customName:l,onDuplicate:xe,onDelete:pe,onRename:he,onArchive:be,onUnarchive:we,archiveDisabled:_,children:me})}return me}function Khe(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const Ghe={state:"done"};function Zhe(n){const e=q.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?Xhe:c,A=jm();let T,I,E,P;if(e[0]!==S||e[1]!==t){T=S?bx(t):{topLevel:t,crewOf:new Map},I=X8(T.topLevel);const ue=he=>{const be=T.crewOf.get(he.sessionId);return be?ay(he,be):he.lastActivityAt||he.lastModified},ce=new Map(I.topLevelSessions.map(he=>[{...he,lastActivityAt:ue(he)},he]));P=ja([...ce.keys()]).map(he=>ce.get(he));const xe=Date.now(),pe=P.map(he=>Ohe(ue(he),xe));E=pe.map((he,be)=>he===pe[be-1]?null:he),e[0]=S,e[1]=t,e[2]=T,e[3]=I,e[4]=E,e[5]=P}else T=e[2],I=e[3],E=e[4],P=e[5];const R=E;let L;e[6]!==T.crewOf||e[7]!==R||e[8]!==I.teammatesByLead||e[9]!==P?(L={topLevelSessions:P,teammatesByLead:I.teammatesByLead,crewOf:T.crewOf,shelves:R},e[6]=T.crewOf,e[7]=R,e[8]=I.teammatesByLead,e[9]=P,e[10]=L):L=e[10];const{topLevelSessions:O,teammatesByLead:$,crewOf:M,shelves:D}=L;let F,z;e[11]===Symbol.for("react.memo_cache_sentinel")?(F=en("live-sessions-open-crews"),z=[],e[11]=F,e[12]=z):(F=e[11],z=e[12]);const[B,U]=br(F,z);let W;e[13]!==B?(W=Array.isArray(B)?B:[],e[13]=B,e[14]=W):W=e[14];let V;e[15]!==W?(V=new Set(W),e[15]=W,e[16]=V):V=e[16];const H=V;let K;e[17]!==B||e[18]!==U?(K=ue=>{const ce=Array.isArray(B)?B:[];U(ce.includes(ue)?ce.filter(xe=>xe!==ue):[...ce,ue])},e[17]=B,e[18]=U,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let X;e[22]!==t||e[23]!==Y?(X=new Map([...Y,...t].map(Yhe)),e[22]=t,e[23]=Y,e[24]=X):X=e[24];const ee=X;let Q;e[25]===Symbol.for("react.memo_cache_sentinel")?(Q=new Set,e[25]=Q):Q=e[25];const[ne,te]=y.useState(Q);let re;e[26]===Symbol.for("react.memo_cache_sentinel")?(re=ue=>{te(ce=>{const xe=new Set(ce);return xe.has(ue)?xe.delete(ue):xe.add(ue),xe})},e[26]=re):re=e[26];const oe=re;let ie;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==j||e[36]!==N||e[37]!==g||e[38]!==k||e[39]!==A||e[40]!==d||e[41]!==p?(ie=ue=>{const ce=A(ue.access);return{session:ue,isActiveSession:u===Xh(ue),proc:d.get(ue.sessionId),killingPids:f,isNewlyCompleted:m.has(ue.sessionId),customName:p[ue.sessionId],onSelectSession:g,onKill:ce.stop?x:void 0,onDuplicateSession:b,onDeleteSession:ce.delete?w:void 0,onArchiveSession:ce.archive?v:void 0,onUnarchiveSession:ce.archive?k:void 0,onRenameSession:j,onPrefetchSession:_,onResumeSession:ce.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=j,e[36]=N,e[37]=g,e[38]=k,e[39]=A,e[40]=d,e[41]=p,e[42]=ie):ie=e[42];const ae=ie;let de;e[43]!==s?(de=s&&a.jsx(ege,{firstMessage:s.firstMessage}),e[43]=s,e[44]=de):de=e[44];let le;if(e[45]!==u||e[46]!==ne||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==ae||e[54]!==p||e[55]!==D||e[56]!==o||e[57]!==$||e[58]!==Z||e[59]!==O){let ue;e[61]!==u||e[62]!==ne||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==ae||e[70]!==p||e[71]!==D||e[72]!==o||e[73]!==$||e[74]!==Z?(ue=(ce,xe)=>{const pe=Xh(ce),he=ce.cwd??ms(ce.dirName),be=yr(he),we=h[ce.dirName]??vl(ce),ve=$.get(ce.sessionId),Se=ne.has(ce.sessionId),Te=D[xe],Ae=M.get(ce.sessionId),ze=Ae&&{members:Ae,counts:vx(Ae,C),statusOf:C,activityAt:ay(ce,Ae),open:H.has(ce.sessionId),onToggle:()=>Z(ce.sessionId)},De=a.jsx(Whe,{...ae(ce),worktreeName:be==null?void 0:be.worktreeName,projectLabel:we,projectPath:(be==null?void 0:be.parentPath)??he,showProject:o,teammateCount:ve==null?void 0:ve.length,teammatesCollapsed:ve?Se:void 0,onToggleTeammates:ve?()=>oe(ce.sessionId):void 0,crew:ze,lineage:Jhe(ce,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[Te&&a.jsx(Qhe,{label:Te}),ve&&!Se?a.jsxs("div",{className:"flex flex-col gap-px",children:[De,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:ve.map(Le=>a.jsx(Hhe,{...ae(Le)},Xh(Le)))})]}):De]},pe)},e[61]=u,e[62]=ne,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=ae,e[70]=p,e[71]=D,e[72]=o,e[73]=$,e[74]=Z,e[75]=ue):ue=e[75],le=O.map(ue),e[45]=u,e[46]=ne,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=ae,e[54]=p,e[55]=D,e[56]=o,e[57]=$,e[58]=Z,e[59]=O,e[60]=le}else le=e[60];let se;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(se=r.canLoad&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(Pj,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=se):se=e[79];let me;return e[80]!==de||e[81]!==le||e[82]!==se?(me=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[de,le,se]}),e[80]=de,e[81]=le,e[82]=se,e[83]=me):me=e[83],me}function Yhe(n){return[n.sessionId,n]}function Xhe(){return Ghe}function Jhe(n,e,t,s){const r=n.crew;if(!r)return;const o=Nd(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:Nd(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void Df(r.parentId)}}function Qhe(n){const e=q.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function ege(n){const e=q.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(vt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function Xh(n){return`${n.dirName}/${n.fileName}`}function xo(n,e){return`${n} ${n===1?e:`${e}s`}`}function tge(n){if(!n)return"No sessions listed";const e=xo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&xo(n.crews,"crew"),n.worktrees>0&&xo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function F3(n){const e=q.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function nge(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function sge(n){const e=q.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${xo(t.length,"project")}, ${xo(o,"session")}${p>0?` · ${xo(p,"crew")}`:""}`:tge(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=nge(t,s);let k;e[6]!==l?(k=ee=>{l(ee),g(!1)},e[6]=l,e[7]=k):k=e[7];const j=k,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(hd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(ha,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(Qi,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let A;e[13]!==w?(A=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=A):A=e[14];let T;e[15]!==C||e[16]!==A?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,A]}),e[15]=C,e[16]=A,e[17]=T):T=e[17];let I;e[18]!==v?(I=v>0&&a.jsx(F3,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=I):I=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(wa,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=E):E=e[20];let P;e[21]!==I||e[22]!==_||e[23]!==N||e[24]!==T?(P=a.jsxs(Ta,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,I,E]}),e[21]=I,e[22]=_,e[23]=N,e[24]=T,e[25]=P):P=e[25];const R=P;let L;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==R?(L=r&&d?a.jsx(PA,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:R}):R,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=R,e[31]=L):L=e[31];let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Dx,{placeholder:"Find a project",autoFocus:!0}),e[32]=O):O=e[32];let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(LL,{children:"No project matches."}),e[33]=$):$=e[33];const M=s===null;let D;e[34]!==j?(D=()=>j(null),e[34]=j,e[35]=D):D=e[35];let F,z;e[36]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(hd,{className:"text-muted-foreground","aria-hidden":"true"}),z=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=F,e[37]=z):(F=e[36],z=e[37]);let B;e[38]!==o?(B=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=B):B=e[39];let U;e[40]!==M||e[41]!==D||e[42]!==B?(U=a.jsx(di,{children:a.jsxs(No,{value:"all-projects","data-checked":M,onSelect:D,className:"gap-2.5",children:[F,z,B]})}),e[40]=M,e[41]=D,e[42]=B,e[43]=U):U=e[43];let W;if(e[44]!==t||e[45]!==j||e[46]!==s){let ee;e[48]!==j||e[49]!==s?(ee=Q=>a.jsxs(No,{value:Q.key,keywords:Q.customName?[Q.customName]:void 0,"data-checked":s===Q.key,onSelect:()=>j(Q.key),className:"gap-2.5",children:[a.jsx(ha,{projectPath:Q.cwd??null,fallback:a.jsx(Qi,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:Q.customName??Q.key}),Q.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:Q.key})]}),Q.needsYou>0&&a.jsx(F3,{count:Q.needsYou,label:`${xo(Q.needsYou,"session")} waiting for you`,className:"text-xs"}),Q.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":xo(Q.live,"live session"),children:[a.jsx(om,{className:"size-1.5","aria-hidden":"true"}),Q.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:Q.total})]},Q.key),e[48]=j,e[49]=s,e[50]=ee):ee=e[50],W=t.map(ee),e[44]=t,e[45]=j,e[46]=s,e[47]=W}else W=e[47];let V;e[51]!==W?(V=a.jsx(di,{heading:"Projects",children:W}),e[51]=W,e[52]=V):V=e[52];let H;e[53]!==U||e[54]!==V?(H=a.jsx($f,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(wc,{children:[O,a.jsxs(Sc,{children:[$,U,V]})]})}),e[53]=U,e[54]=V,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==L||e[58]!==H?(K=a.jsxs(Ea,{open:h,onOpenChange:g,children:[L,H]}),e[56]=h,e[57]=L,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(J,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(xr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:rge,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(mc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let X;return e[68]!==K||e[69]!==Z||e[70]!==Y?(X=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=X):X=e[71],X}function rge(){return V_()}function oge(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function ige(n){const e=yr(n.cwd??ms(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:hs(n.dirName).dirName.encode(t),cwd:t}}function age(n){const e=n.map(t=>{var s;return(s=yr(t.cwd??ms(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function lge(n,e,t,s,r=new Map){return[...tR(n).entries()].map(([o,i])=>{const l=J8(i),c=ige(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:oge(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:age(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function U3(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>vl(i)===e);const{topLevel:s,crewOf:r}=bx(n),o=new Set;for(const i of s)if(vl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)vl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function cge(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:ja([...n,...s])}const B3={key:null,sessions:[],loading:!1,loaded:!1};function uge(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function dge(n,e,t){const s=q.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(B3),l=o.key===r?o:B3;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Hr();try{const x=(await Promise.all(uge(n,e).map(async b=>{const w=await Ee(Tf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();ra(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Af(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const fge={key:"all"},mge=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=If(),{names:m,rename:p}=Eb(),h=Wx(),g=xn("terminal"),x=xn("killAny"),b=jm(),w=Ef(),{Control:v,Empty:k}=Tr().sessionListFilter??{},{sessions:j,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:A,removeSession:T,acknowledgeCompleted:I,showArchived:E,setShowArchived:P,setSearchActive:R,archivedCount:L}=Nx(),{awaitingPermission:O,awaitingQuestion:$,awaitingElicitation:M,awaitingDialog:D,awaitingPlan:F}=RZ(),z=y.useMemo(()=>new Set([...M,...D]),[M,D]),[B,U]=y.useState(new Set),[W,V]=y.useState(""),[H,K]=br(en("live-sessions-project-scope"),null),[Z,Y]=br(en("live-sessions-group-crews"),!0),X=Z!==!1,ee=!!W.trim(),Q=X&&!ee,ne=E||ee;y.useEffect(()=>(R(ee),()=>R(!1)),[ee,R]);const te=y.useRef(new Set),re=y.useRef(!1),oe=y.useCallback((ye,$e)=>{if(!re.current)return;const qe=setTimeout(()=>{te.current.delete(qe),re.current&&ye()},$e);te.current.add(qe)},[]);y.useEffect(()=>{const ye=te.current;return re.current=!0,()=>{re.current=!1;for(const $e of ye)clearTimeout($e);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=A,()=>{c.current===A&&(c.current=null)}},[A,c]);const ie=Ab(),ae=$A(W,w),de=y.useMemo(()=>eR(j,ne),[j,ne]),le=ne?0:L,se=y.useMemo(()=>({awaitingPermission:O,awaitingQuestion:$,awaitingPrompt:z,awaitingPlan:F}),[O,$,z,F]),me=y.useCallback(ye=>k4(ye,_,se),[_,se]),ue=y.useMemo(()=>bx(de),[de]),ce=y.useMemo(()=>{const ye=qe=>b(qe.access).canInteract,$e=mhe(ue.topLevel,_,N,O,$,z,F,ye);return phe($e,ue.topLevel,ue.crewOf,me,ye)},[ue,_,N,O,$,z,F,b,me]),xe=y.useMemo(()=>new Set(ce.needsYou.map(ye=>ye.session.sessionId)),[ce]),pe=X?ue.topLevel:de,he=y.useMemo(()=>lge(pe,_,m,xe,ue.crewOf),[pe,_,m,xe,ue.crewOf]),be=H===null?null:he.find(ye=>ye.key===H)??null,we=(be==null?void 0:be.customName)??H,ve=dge(H===null?fge:be,ne,w),Se=y.useMemo(()=>cge(U3(de,H,Q),ve.sessions),[de,H,Q,ve.sessions]),Te=y.useMemo(()=>ee?Se.filter(ye=>{const $e=d[ye.sessionId],qe=m[ye.dirName];return TA(ye,W,[$e,qe])}):Se,[Se,ee,W,d,m]),Ae=y.useMemo(()=>ae.results?U3(ae.results,H,Q):Te,[ae.results,H,Q,Te]),ze=ce.needsYou.length>0||ce.working.length>0,De=!ee&&ze&&H===null,Le=y.useMemo(()=>H===null?[]:Se.filter(ye=>!ye.archived&&b(ye.access).archive&&!gx(ye,_.get(ye.sessionId))),[H,Se,_,b]),Ce=H===null||l!=null&&px(l.cwd||ms(l.dirName))===H,Be=y.useRef(!1);y.useEffect(()=>{if(Be.current||!u||j.length===0)return;Be.current=!0;const ye=ja(j).slice(0,3),$e=globalThis,qe=()=>{for(const ke of ye)u(ke.dirName,ke.fileName)};let Ke=null,fe=null;return typeof $e.requestIdleCallback=="function"?Ke=$e.requestIdleCallback(qe,{timeout:1500}):fe=setTimeout(qe,300),()=>{Ke!=null&&typeof $e.cancelIdleCallback=="function"&&$e.cancelIdleCallback(Ke),fe!=null&&clearTimeout(fe)}},[j,u]);const We=y.useCallback(async(ye,$e)=>{$e.stopPropagation(),U(qe=>new Set(qe).add(ye));try{if(!(await Ee("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");oe(A,1500)}catch{Kn.error("Could not stop session")}oe(()=>{U(qe=>{const Ke=new Set(qe);return Ke.delete(ye),Ke})},2e3)},[A,oe]);y.useEffect(()=>{const ye=j.find($e=>`${$e.dirName}/${$e.fileName}`===e);ye&&N.has(ye.sessionId)&&I(ye.sessionId)},[e,j,N,I]);const He=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),_e=sE(),Re=y.useCallback(ye=>{_e([ye.sessionId],!0,`Archived “${li(ye,d[ye.sessionId])}”`)},[_e,d]),tt=y.useCallback(ye=>{_e([ye.sessionId],!1,`Restored “${li(ye,d[ye.sessionId])}”`)},[_e,d]),Xe=y.useCallback(ye=>{if(ye.length===0)return;const $e=ye.map(qe=>qe.sessionId);_e($e,!0,`Archived ${$e.length} ${$e.length===1?"session":"sessions"}`)},[_e]),Ne=y.useCallback((ye,$e,qe)=>{const{command:Ke,args:fe}=L$(an(qe),ye),ke=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:ke,name:`Resume ${ye.slice(0,8)}`,command:Ke,args:fe,cwd:$e??void 0,metadata:{type:"terminal"}}),oe(A,3e3)},[h,A,oe]),Ve={activeSessionKey:e,procBySession:_,killingPids:B,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?We:void 0,onDuplicateSession:s,onDeleteSession:r?He:void 0,onArchiveSession:Re,onUnarchiveSession:tt,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?Ne:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Ehe,{loading:S,isMobile:ie,searchQuery:W,searchLoading:ae.loading,showArchived:E,archivedCount:L,groupCrews:X,onToggleGroupCrews:()=>Y(!X),onSearchQueryChange:V,onToggleShowArchived:()=>P(!E),onRefresh:()=>{dhe(),A()}}),v&&a.jsx(v,{}),a.jsx(sge,{options:he,value:H,focused:be,totalSessions:pe.length,crewCount:X?ue.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Le.length,onArchiveIdle:()=>Xe(Le)}),a.jsx(Cc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(Ahe,{fetchError:ae.error??C,showEmpty:Ae.length===0&&!(l&&Ce)&&!S&&!ae.loading&&!C&&!ae.error,searching:ee,loading:S||ae.loading,sessionCount:ae.active?Ae.length:de.length,hiddenArchivedCount:le,focusedProject:we,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&k?a.jsx(k,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>P(!0),onRetry:ae.error?ae.refresh:A}),De&&a.jsx(_he,{groups:ce,activeSessionKey:e,procBySession:_,killingPids:B,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?We:void 0,onResumeSession:g?Ne:void 0,onPrefetchSession:u}),a.jsx(Zhe,{...Ve,sessions:Ae,pendingSession:Ce?l:null,showProject:H===null,groupCrews:Q,lineageSessions:de,memberStatusOf:me,older:{canLoad:(H===null||!!be)&&!ve.loaded&&!ee,loading:ve.loading,load:ve.load}})]})})]})}),pge=y.memo(function(e){const t=q.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(mge,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),hge=y.lazy(()=>nt(()=>import("./MissionHome-LPTXsRcd.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MissionHome})));function Cm(n){const e=q.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=r):r=e[2],r}function zA(n){const e=q.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=yt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=a.jsx(pge,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:o,header:r}),e[0]=l,e[1]=r,e[2]=o,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function gge(n){const e=q.c(8),{navigation:t}=n,{state:s}=ln();let r;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(r=a.jsx(uhe,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=r):r=e[7],r}function lf(n){const e=q.c(6),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o}=ln(),[i,l]=y.useState(!1);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Cm,{label:"Loading Mission Control…"}),e[0]=c):c=e[0];let u;return e[1]!==i||e[2]!==t||e[3]!==r||e[4]!==o?(u=a.jsx(y.Suspense,{fallback:c,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:i||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),l(!1)},children:[a.jsx(Q1,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(gge,{navigation:t})]}):a.jsx(hge,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>l(!0),newSessionControl:a.jsx(xge,{navigation:t})})})}),e[1]=i,e[2]=t,e[3]=r,e[4]=o,e[5]=u):u=e[5],u}function xge(n){const e=q.c(13),{navigation:t}=n,{config:s}=ln(),[r,o]=y.useState(!1),i=wA(r);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(J,{variant:"outline",className:"h-auto w-full justify-between px-4 py-4"}),e[0]=l):l=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsxs(Ta,{render:l,children:["What should we build?",a.jsx("span",{className:"text-muted-foreground",children:"Choose a project"})]}),e[1]=c):c=e[1];let u,d;e[2]!==t?(u=(p,h)=>{o(!1),t.onStartNewSession(p,h)},d=p=>{o(!1),t.onStartNewFolder(p)},e[2]=t,e[3]=u,e[4]=d):(u=e[3],d=e[4]);let f;e[5]!==s.defaultAgentKind||e[6]!==i||e[7]!==u||e[8]!==d?(f=a.jsx($f,{className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(SA,{projects:i,defaultAgentKind:s.defaultAgentKind,onNewSession:u,onNewFolder:d})}),e[5]=s.defaultAgentKind,e[6]=i,e[7]=u,e[8]=d,e[9]=f):f=e[9];let m;return e[10]!==r||e[11]!==f?(m=a.jsxs(Ea,{open:r,onOpenChange:o,children:[c,f]}),e[10]=r,e[11]=f,e[12]=m):m=e[12],m}function DA(n){const e=q.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Cm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function bge({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function vge({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function FA({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
|
|
454
|
+
`||t.length>0)&&s++,t=[],i+=(l==="&"||l==="|")&&(d===l||f&&d==="&")?2:1;continue}if(/^(?:\d+)?<</.test(n.slice(i)))return o();const c=/^(?:\d+)?(?:>>|>\||>&|<&|<>|[<>])/.exec(n.slice(i));if(c){for(i+=c[0].length;/[^\S\n]/.test(n[i]??"");)i++;const d=_3(n,i);if(!d||d.end===i)return o();i=d.end;continue}const u=_3(n,i);if(!u||u.end===i)return o();t.push(u),i=u.end}return e.push({words:t,end:n.length,pipeline:s}),{commands:e,complete:r===0}}const pl="agent-browser",Hme=new Map([["env",new Set(["-i","--ignore-environment","--"])],["command",new Set(["--"])],["exec",new Set(["--"])],["npx",new Set(["-y","--yes","--"])],["bunx",new Set(["--bun","--"])]]),Kme=new Set(["echo","printf","rg","grep","cat","head","tail","wc","ls","stat","file","basename","dirname","cp","mv","rm","mkdir","rmdir","touch"]),Gme=new Set(["commit","log","show","diff","status","add","grep","ls-files","rev-parse"]),Zme=/^(?:if|then|else|elif|fi|while|until|for|select|case|esac|do|done|function|\{|\}|!)$/,Yme=/^[A-Za-z_][A-Za-z_\d]*=/;function mA(n){return n.slice(n.lastIndexOf("/")+1)}function Xme(n,e){var s,r;let t=0;for(;t<n.length;){const o=n[t];if(Yme.test(e.slice(o.start,o.end))){t++;continue}if(!o.literal||Zme.test(o.value))return null;const i=mA(o.value);if(i==="command"&&["-v","-V"].includes((s=n[t+1])==null?void 0:s.value))return-1;const l=Hme.get(i);if(!l)return t;for(t++;(r=n[t])!=null&&r.value.startsWith("-");){if(!n[t].literal||!l.has(n[t].value))return null;if(n[t++].value==="--")break}}return-1}function Jme(n,e,t){const[s,...r]=n;if(r.some(l=>!l.literal))return null;let o=Fme,i=null;for(let l=0;l<r.length;l++){const c=r[l];if(c.value!=="--session"&&!c.value.startsWith("--session="))continue;if(i!==null)return null;const u=c.value==="--session"?r[++l]:c;if(o=c.value==="--session"?u==null?void 0:u.value:c.value.slice(10),!o||!Wme(o)||u!==c&&!/^(?:\s|\\\n)*$/.test(t.slice(c.end,u.start)))return null;i={start:c.start,end:u.end}}return{text:pl+t.slice(s.end,e).trimEnd(),binaryEnd:s.end,browser:o,sessionFlag:i}}function Qme(n){var l;const{commands:e,complete:t}=Vme(n),s=[],r=e.some(({words:c})=>c.some(({value:u})=>u.includes(pl)));if(!t)return{invocations:s,ambiguous:r||n.includes(pl)};const o=new Set(e.filter(({words:c})=>c.some(({value:u})=>u.includes(pl))).map(({pipeline:c})=>c));let i=!1;for(const{words:c,end:u,pipeline:d}of e){const f=Xme(c,n);if(f===null){i||(i=r);continue}if(f<0)continue;const m=mA(c[f].value);if(m!==pl){!(Kme.has(m)||m==="git"&&Gme.has((l=c[f+1])==null?void 0:l.value))&&o.has(d)&&(i=!0);continue}const p=Jme(c.slice(f),u,n);p===null?i=!0:s.push(p)}return{invocations:s,ambiguous:i}}function epe(n){return Qme(n).invocations}const E3=120,tpe=/(?:^|[._])exec_command$/;function npe(n){return n==="Bash"||tpe.test(n)}function spe(n){return UF(n).filter(e=>npe(e.name)).map(e=>Gr(e.input))}function rpe(n){for(const e of spe(n)){const[t]=epe(e);if(t===void 0||qme(t.browser))continue;const{text:s}=t;return{session:t.browser,command:s.length>E3?`${s.slice(0,E3-1)}…`:s,timestamp:n.timestamp,toolCallId:n.id,done:n.result!==null}}return null}function ope(n){const e=(n==null?void 0:n.turns)??[];for(let t=e.length-1;t>=0;t--){const s=e[t].toolCalls;for(let r=s.length-1;r>=0;r--){const o=rpe(s[r]);if(o)return o}}return null}const T3=1e4,ipe=y.lazy(()=>nt(()=>import("./ProjectFilesPanel-B7DRMwMm.js"),__vite__mapDeps([31,1,32,2,4,3])).then(n=>({default:n.ProjectFilesPanel}))),ape=y.lazy(()=>nt(()=>import("./WorktreePanel-DyQpVHNe.js"),__vite__mapDeps([33,1,2,3,4])).then(n=>({default:n.WorktreePanel}))),lpe=y.lazy(()=>nt(()=>import("./CrewPanel-CWubmgOn.js"),__vite__mapDeps([34,1,2,3,4])).then(n=>({default:n.CrewPanel}))),cpe=y.lazy(()=>nt(()=>import("./index-y28pnuxv.js"),__vite__mapDeps([35,1,2,3,4])).then(n=>({default:n.BrowserPanel})));function Sm(){const n=q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=a.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[a.jsx(Pn,{}),"Loading panel…"]}),n[0]=e):e=n[0],e}function upe(n){const e=q.c(6),{context:t,closePanel:s}=n,r=z0(),o=r.projectFilesRoot??t.projectPath;if(!o)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(Sm,{}),e[0]=i):i=e[0];let l;return e[1]!==s||e[2]!==o||e[3]!==r.addProjectContext||e[4]!==r.projectFilesRequest?(l=a.jsx(y.Suspense,{fallback:i,children:a.jsx(ipe,{cwd:o,onClose:s,onAddToPrompt:r.addProjectContext,openRequest:r.projectFilesRequest},o)}),e[1]=s,e[2]=o,e[3]=r.addProjectContext,e[4]=r.projectFilesRequest,e[5]=l):l=e[5],l}function dpe(n){const e=q.c(3),{context:t}=n;if(!t.session)return null;let s;return e[0]!==t.session||e[1]!==t.sessionChangeKey?(s=a.jsx($K,{session:t.session,sessionChangeKey:t.sessionChangeKey}),e[0]=t.session,e[1]=t.sessionChangeKey,e[2]=s):s=e[2],s}function fpe(){const n=q.c(7),e=z0();let t;return n[0]!==e.backgroundAgents||n[1]!==e.jumpToTurn||n[2]!==e.loadSession||n[3]!==e.searchInputRef||n[4]!==e.serversChanged||n[5]!==e.toggleServer?(t=a.jsx(Dme,{onJumpToTurn:e.jumpToTurn,onToggleServer:e.toggleServer,onServersChanged:e.serversChanged,searchInputRef:e.searchInputRef,onLoadSession:e.loadSession,backgroundAgents:e.backgroundAgents}),n[0]=e.backgroundAgents,n[1]=e.jumpToTurn,n[2]=e.loadSession,n[3]=e.searchInputRef,n[4]=e.serversChanged,n[5]=e.toggleServer,n[6]=t):t=n[6],t}function mpe(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Sm,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(cpe,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function ppe(n){var u;const e=q.c(8),{context:t}=n,[,s]=y.useState(0);let r;e[0]!==t.session?(r=Date.parse(((u=ope(t.session))==null?void 0:u.timestamp)??""),e[0]=t.session,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==s?(i=()=>{const d=o+T3-Date.now();if(Number.isNaN(d)||d<=0)return;const f=setTimeout(()=>s(hpe),d);return()=>clearTimeout(f)},e[2]=o,e[3]=s,e[4]=i):i=e[4];let l;if(e[5]!==o?(l=[o],e[5]=o,e[6]=l):l=e[6],y.useEffect(i,l),Number.isNaN(o)||Date.now()-o>=T3)return null;let c;return e[7]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx("span",{role:"status","aria-label":"The agent is using the browser",className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-emerald-500 motion-safe:animate-pulse"}),e[7]=c):c=e[7],c}function hpe(n){return n+1}function gpe(n){const e=q.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=a.jsx(Sm,{}),e[0]=t):t=e[0];let s;return e[1]!==n?(s=a.jsx(y.Suspense,{fallback:t,children:a.jsx(lpe,{...n})}),e[1]=n,e[2]=s):s=e[2],s}function xpe(n){const e=q.c(5),{context:t}=n,s=t.crew;if(!s)return null;if(s.needsYou>0){const i=`${s.needsYou} ${s.needsYou===1?"session needs":"sessions need"} you`;let l;return e[0]!==s.needsYou||e[1]!==i?(l=a.jsx("span",{role:"status","aria-label":i,className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-warning px-1 text-[9px] font-semibold text-warning-foreground",children:s.needsYou}),e[0]=s.needsYou,e[1]=i,e[2]=l):l=e[2],l}if(s.working===0)return null;const r=`${s.working} ${s.working===1?"session":"sessions"} working`;let o;return e[3]!==r?(o=a.jsx("span",{role:"status","aria-label":r,className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-success ring-2 ring-success/30"}),e[3]=r,e[4]=o):o=e[4],o}function bpe(n){const e=q.c(8),{closePanel:t}=n,s=z0();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Sm,{}),e[0]=r):r=e[0];let o;return e[1]!==t||e[2]!==s.openWorktreeSession||e[3]!==s.worktreeDirName||e[4]!==s.worktrees.loading||e[5]!==s.worktrees.refetch||e[6]!==s.worktrees.worktrees?(o=a.jsx(y.Suspense,{fallback:r,children:a.jsx(ape,{worktrees:s.worktrees.worktrees,loading:s.worktrees.loading,dirName:s.worktreeDirName,onRefetch:s.worktrees.refetch,onOpenSession:s.openWorktreeSession,onClose:t})}),e[1]=t,e[2]=s.openWorktreeSession,e[3]=s.worktreeDirName,e[4]=s.worktrees.loading,e[5]=s.worktrees.refetch,e[6]=s.worktrees.worktrees,e[7]=o):o=e[7],o}const vpe={id:ti,workspacePanels:[{id:"crew",title:"Crew",icon:z1,component:gpe,indicator:xpe,order:1,defaultSize:"30%",minSize:"340px",maxSize:"60%",when:n=>!!n.crew},{id:"worktrees",title:"Worktrees",icon:Wr,component:bpe,order:5,defaultSize:"36%",minSize:"320px",when:n=>n.supportsWorktrees===!0},{id:"project-files",title:"Project files",icon:r$,component:upe,order:10,defaultSize:"55%",minSize:"340px",maxSize:"75%",keepAlive:!0,when:n=>n.canAccessHostFiles&&n.projectPath!==null},{id:"browser",title:"Browser",icon:Ji,component:mpe,indicator:ppe,order:15,defaultSize:"46%",minSize:"360px",maxSize:"75%",keepAlive:!0,when:n=>n.canUseBrowser},{id:"file-changes",title:"File changes",icon:fc,component:dpe,order:20,defaultSize:"36%",minSize:"320px",when:n=>n.canAccessHostFiles&&n.hasFileChanges&&n.session!==null},{id:"session-info",title:"Session details",icon:o$,component:fpe,order:30,defaultSize:"36%",minSize:"320px",when:n=>n.session!==null}]},ype=wZ([vpe]);function wpe(n,e,t){if(!e)return null;const s=l=>{const c=(t==="win32"?l.replaceAll("\\","/").toLowerCase():l).replace(/\/+$/,"")||"/";return c.split("/").some(u=>u==="."||u==="..")?null:c},r=s(e);if(!r)return null;let o=null,i=-1;for(const l of n)for(const c of l.paths){const u=s(c);u&&u.length>i&&(r===u||r.startsWith(u.endsWith("/")?u:`${u}/`))&&(o=l,i=u.length)}return o}function Spe(n){const e=q.c(22),{client:t,status:s,activation:r,projectPath:o}=n,i=!!(s!=null&&s.store.available)&&!!r;let l;e[0]!==i||e[1]!==o||e[2]!==s?(l=i?wpe(s.projects,o,s.runtime.platform):null,e[0]=i,e[1]=o,e[2]=s,e[3]=l):l=e[3];const c=l,u=i&&!c?o:null;let d;e[4]!==r||e[5]!==o||e[6]!==(s==null?void 0:s.connectionRevision)||e[7]!==(s==null?void 0:s.host.instanceId)||e[8]!==(s==null?void 0:s.projects)||e[9]!==(s==null?void 0:s.store)?(d=JSON.stringify([r,o,s==null?void 0:s.host.instanceId,s==null?void 0:s.store.revision,s==null?void 0:s.connectionRevision,s==null?void 0:s.projects]),e[4]=r,e[5]=o,e[6]=s==null?void 0:s.connectionRevision,e[7]=s==null?void 0:s.host.instanceId,e[8]=s==null?void 0:s.projects,e[9]=s==null?void 0:s.store,e[10]=d):d=e[10];const f=d,[m,p]=y.useState(null);let h,g;if(e[11]!==t||e[12]!==f||e[13]!==u?(h=()=>{if(!u)return;const b=new AbortController;return Promise.resolve().then(()=>(b.signal.throwIfAborted(),t.resolveWorkspace(u,b.signal))).then(w=>{b.signal.aborted||p({key:f,project:w})}).catch(()=>{b.signal.aborted||p({key:f,project:null})}),()=>b.abort()},g=[t,f,u],e[11]=t,e[12]=f,e[13]=u,e[14]=h,e[15]=g):(h=e[14],g=e[15]),y.useEffect(h,g),!i||!o){let b;return e[16]===Symbol.for("react.memo_cache_sentinel")?(b={project:null,resolving:!1},e[16]=b):b=e[16],b}if(c){let b;return e[17]!==c?(b={project:c,resolving:!1},e[17]=c,e[18]=b):b=e[18],b}let x;return e[19]!==f||e[20]!==m?(x=(m==null?void 0:m.key)===f?{project:m.project,resolving:!1}:{project:null,resolving:!0},e[19]=f,e[20]=m,e[21]=x):x=e[21],x}const A3={"cogpit.github":wj,"cogpit.clickup":l$,"cogpit.vercel":a$,"cogpit.cloudflare":i$};function kpe(n){const e=q.c(6);let t,s;e[0]!==n?({runtime:s,...t}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;return e[3]!==t||e[4]!==s?(r=s?a.jsx(rme,{...t,...s}):null,e[3]=t,e[4]=s,e[5]=r):r=e[5],r}function jpe(n){var o;const e=q.c(3),{runtime:t,context:s}=n;let r;return e[0]!==s||e[1]!==t?(r=t?a.jsx(Kre,{client:t.client,pluginId:t.plugin.id,projectId:((o=t.project)==null?void 0:o.id)??null,workspacePath:t.project?s.projectPath:null,activation:t.activation,registryRevision:t.registryRevision}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}function Npe({client:n,status:e,activation:t,project:s,legacyPanels:r=ype,openSettings:o}){const i=[...r];if(!(e!=null&&e.store.available)||e.safeMode||!t||dA())return i;const l=new Set(i.map(u=>u.id)),c=zi();for(const u of e.store.plugins)if(!(!u.enabled||u.scope.type==="projects"&&(!s||!u.scope.projectIds.includes(s.id)))&&sre(u.manifest,c,e.runtime,{allowPrerelease:u.manifest.publisher.startsWith("dev-")}).compatible)for(const d of u.manifest.contributes.panels){const f=ho(u.id,d.id);if(l.has(f)||d.when==="project-selected"&&!s)continue;l.add(f);const m={client:n,plugin:u,activation:t,registryRevision:e.store.revision,project:s,title:d.title,openSettings:o};i.push({id:f,pluginId:u.id,localId:d.id,title:d.title,icon:A3[u.id]??J1,order:d.order,defaultSize:d.defaultSize,minSize:d.minSize,maxSize:d.maxSize,keepAlive:!0,...A3[u.id]?{indicator:jpe,indicatorProps:{runtime:m}}:{},component:kpe,componentProps:{runtime:m}})}return i.sort((u,d)=>(u.order??100)-(d.order??100)||u.title.localeCompare(d.title))}function pA(n){const e=q.c(11),{client:t,status:s,activation:r,projectPath:o,openSettings:i}=n,l=fA();let c;e[0]!==r||e[1]!==t||e[2]!==o||e[3]!==s?(c={client:t,status:s,activation:r,projectPath:o},e[0]=r,e[1]=t,e[2]=o,e[3]=s,e[4]=c):c=e[4];const{project:u,resolving:d}=Spe(c),f=l||d?"":r;let m;return e[5]!==t||e[6]!==i||e[7]!==u||e[8]!==s||e[9]!==f?(m=Npe({client:t,status:s,activation:f,project:u,openSettings:i}),e[5]=t,e[6]=i,e[7]=u,e[8]=s,e[9]=f,e[10]=m):m=e[10],m}function km(n){const e=q.c(7),{floating:t,children:s}=n,r=y.useRef(null);let o,i;if(e[0]!==t?(o=()=>{const c=r.current,u=c==null?void 0:c.parentElement;if(!t||!c||!u)return;const d=u.style.getPropertyValue("--session-footer-height"),f=()=>u.style.setProperty("--session-footer-height",`${c.getBoundingClientRect().height}px`);f();const m=new ResizeObserver(f);return m.observe(c),()=>{m.disconnect(),d?u.style.setProperty("--session-footer-height",d):u.style.removeProperty("--session-footer-height")}},i=[t],e[0]=t,e[1]=o,e[2]=i):(o=e[1],i=e[2]),y.useLayoutEffect(o,i),t){let c;return e[3]!==s?(c=a.jsx("div",{ref:r,className:"pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-canvas via-canvas/70 to-transparent pt-4",children:a.jsx("div",{className:"pointer-events-auto w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[3]=s,e[4]=c):c=e[4],c}let l;return e[5]!==s?(l=a.jsx("div",{className:"flex w-full shrink-0 justify-center",children:a.jsx("div",{className:"w-full max-w-[var(--chat-width)] px-3 pb-3",children:s})}),e[5]=s,e[6]=l):l=e[6],l}function ha(n){const e=q.c(13),{projectPath:t,fallback:s,className:r}=n,[o,i]=y.useState(null);if(!t||o===t){let m;return e[0]!==s?(m=a.jsx(a.Fragment,{children:s}),e[0]=s,e[1]=m):m=e[1],m}const l=`/api/project-icon?cwd=${encodeURIComponent(t)}`;let c;e[2]!==l?(c=wf(l),e[2]=l,e[3]=c):c=e[3];let u;e[4]!==t?(u=()=>i(t),e[4]=t,e[5]=u):u=e[5];let d;e[6]!==r?(d=G("size-3.5 shrink-0 rounded-[3px] object-contain",r),e[6]=r,e[7]=d):d=e[7];let f;return e[8]!==t||e[9]!==c||e[10]!==u||e[11]!==d?(f=a.jsx("img",{src:c,alt:"","aria-hidden":!0,loading:"lazy",decoding:"async",onError:u,className:d},t),e[8]=t,e[9]=c,e[10]=u,e[11]=d,e[12]=f):f=e[12],f}function hA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G(t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function gA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("ol",{"data-slot":"breadcrumb-list",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function k1(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("inline-flex items-center gap-1",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("li",{"data-slot":"breadcrumb-item",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function xA(n){const e=q.c(10);let t,s,r,o;if(e[0]!==n){const{className:c,render:u,...d}=n;t=u,o=bj,s="a",r=xj({className:G("transition-colors hover:text-foreground",c)},d),e[0]=n,e[1]=t,e[2]=s,e[3]=r,e[4]=o}else t=e[1],s=e[2],r=e[3],o=e[4];let i;e[5]===Symbol.for("react.memo_cache_sentinel")?(i={slot:"breadcrumb-link"},e[5]=i):i=e[5];let l;return e[6]!==t||e[7]!==s||e[8]!==r?(l={defaultTagName:s,props:r,render:t,state:i},e[6]=t,e[7]=s,e[8]=r,e[9]=l):l=e[9],o(l)}function bA(n){const e=q.c(8);let t,s;e[0]!==n?({className:t,...s}=n,e[0]=n,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=G("font-normal text-foreground",t),e[3]=t,e[4]=r):r=e[4];let o;return e[5]!==s||e[6]!==r?(o=a.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:r,...s}),e[5]=s,e[6]=r,e[7]=o):o=e[7],o}function vA(n){const e=q.c(12);let t,s,r;e[0]!==n?({children:t,className:s,...r}=n,e[0]=n,e[1]=t,e[2]=s,e[3]=r):(t=e[1],s=e[2],r=e[3]);let o;e[4]!==s?(o=G("[&>svg]:size-3.5",s),e[4]=s,e[5]=o):o=e[5];let i;e[6]!==t?(i=t??a.jsx(it,{}),e[6]=t,e[7]=i):i=e[7];let l;return e[8]!==r||e[9]!==o||e[10]!==i?(l=a.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:o,...r,children:i}),e[8]=r,e[9]=o,e[10]=i,e[11]=l):l=e[11],l}const Cpe=1e3,_pe=255;function Epe(n){for(const e of n){const t=e.codePointAt(0)??0;if(t<32||t===127)return!0}return!1}function Tpe(n){return n.trim()===""?"Enter a folder name":n!==n.trim()?"A folder name cannot start or end with a space":n==="."||n===".."?`"${n}" is not a folder name`:n.includes("/")||n.includes("\\")?"A folder name cannot contain / or \\":Epe(n)?"A folder name cannot contain control characters":new TextEncoder().encode(n).length>_pe?"That folder name is too long":null}function I3(n,e){return n instanceof Error&&n.message?n.message:e}function Ape({hostName:n,projectPaths:e,onStart:t,onBack:s}){var B;const[r,o]=y.useState({path:null,request:0}),i=`${r.request}:${r.path??""}`,[l,c]=y.useState(null),[u,d]=y.useState(""),[f,m]=y.useState(""),[p,h]=y.useState(!1),[g,x]=y.useState(""),[b,w]=y.useState(null),[v,k]=y.useState(!1),j=y.useRef(null),_=y.useRef(null),N=y.useRef(null),S=y.useRef(!1);y.useEffect(()=>{const U=new AbortController;return pZ(r.path,U.signal).then(W=>c({request:i,listing:W})).catch(W=>{U.signal.aborted||c({request:i,error:I3(W,"This folder could not be read")})}),()=>U.abort()},[i,r.path]);const C=(l==null?void 0:l.request)!==i,A=l&&"listing"in l?l.listing:null,T=!C&&l&&"error"in l?l.error:null,I=C?null:(A==null?void 0:A.path)??null,E=u.trim().toLowerCase(),P=(A==null?void 0:A.folders.filter(U=>U.name.toLowerCase().includes(E)))??[],R=P.some(U=>U.path===f)?f:((B=P[0])==null?void 0:B.path)??"",L=A==null?void 0:A.path;y.useEffect(()=>{var W,V;const U=N.current;U&&(U.scrollLeft=U.scrollWidth),S.current&&!((W=j.current)!=null&&W.contains(document.activeElement))&&((V=_.current)==null||V.focus()),S.current=!1},[L]);function O(U){var W;S.current=((W=j.current)==null?void 0:W.contains(document.activeElement))??!1,o(V=>({path:U,request:V.request+1})),d(""),h(!1),x(""),w(null)}function $(){I&&t(I)}function M(U){U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!p?(U.preventDefault(),$()):U.key==="Backspace"&&U.target===_.current&&u===""&&(A!=null&&A.parent)&&!C&&(U.preventDefault(),O(A.parent))}function D(){var U;h(!1),x(""),w(null),(U=_.current)==null||U.focus()}async function F(U){var H;U.preventDefault();const W=g.trim(),V=Tpe(W);if(V){w(V);return}if(!(!I||v)){k(!0);try{const K=await hZ(I,W);O(K),(H=_.current)==null||H.focus()}catch(K){w(I3(K,"The folder could not be made"))}finally{k(!1)}}}const z=n?`Folders on ${n}`:"Folders";return a.jsxs("div",{ref:j,onKeyDownCapture:M,className:"flex min-h-0 flex-col bg-popover text-popover-foreground",children:[a.jsxs("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 in-data-[slot=dialog-content]:pr-12",children:[a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Back to projects",children:a.jsx(Q1,{})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:z}),A&&A.path!==A.root&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>O(null),"aria-label":"Go to the projects root",title:A.root,children:a.jsx(c$,{})})]}),A&&a.jsx(Ipe,{path:A.path,top:A.confined?A.root:null,listRef:N,onOpen:O}),a.jsxs(wc,{shouldFilter:!1,label:"Filter folders",value:R,onValueChange:m,className:"rounded-none p-0",children:[a.jsx(Dx,{ref:_,autoFocus:!0,placeholder:"Filter folders...",value:u,onValueChange:d}),a.jsx(Sc,{className:"box-content max-h-72 p-1","aria-busy":C,children:T!==null?a.jsx(Ppe,{message:T,onRetry:()=>O(r.path),onRoot:r.path===null?void 0:()=>O(null)}):A===null?a.jsxs("div",{role:"status",className:"flex items-center justify-center gap-2 py-8 text-sm text-muted-foreground",children:[a.jsx(Pn,{className:"size-4"}),"Loading folders…"]}):P.length===0?a.jsx(Cn,{className:"border-0 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:E?"No folder matches":"No folders here"}),a.jsx(Tn,{children:E?"Try another name.":"Start a session right here, or make a new folder."})]})}):a.jsxs(di,{className:G("p-0 transition-opacity",C&&"opacity-50"),children:[P.map(U=>a.jsxs(No,{value:U.path,onSelect:()=>O(U.path),onMouseDown:W=>W.preventDefault(),className:"motion-list-item h-auto gap-3 px-3 py-2",children:[a.jsx(Qi,{className:"size-4 shrink-0 text-muted-foreground"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:U.name}),e.has(U.path)&&a.jsx(Ue,{variant:"secondary",children:"Project"}),a.jsx(it,{className:"size-4 shrink-0 text-muted-foreground"})]},U.path)),A.truncated&&a.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Cpe.toLocaleString()," folders."]})]})})]}),a.jsxs("div",{className:"flex flex-col gap-1.5 border-t p-2",children:[p?a.jsxs("form",{onSubmit:U=>void F(U),className:"flex items-center gap-2",children:[a.jsx(zn,{autoFocus:!0,"aria-label":"New folder name",placeholder:"New folder name",value:g,disabled:v,"aria-invalid":b?!0:void 0,onChange:U=>{x(U.target.value),w(null)},onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),D())}}),a.jsxs(J,{type:"submit",size:"sm",disabled:v||!I||g.trim()==="",children:[v&&a.jsx(Pn,{"data-icon":"inline-start",className:"size-4"}),"Create"]}),a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:D,children:"Cancel"})]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(J,{type:"button",variant:"ghost",size:"sm",disabled:!I,onClick:()=>h(!0),children:[a.jsx(Fj,{"data-icon":"inline-start"}),"New folder"]}),a.jsx(J,{type:"button",size:"sm",className:"ml-auto",disabled:!I,onClick:$,"aria-keyshortcuts":"Meta+Enter Control+Enter",children:"Start session here"})]}),b&&a.jsx("p",{role:"alert",className:"px-1 text-xs text-destructive",children:b})]})]})}function Ipe(n){const e=q.c(19),{path:t,top:s,listRef:r,onOpen:o}=n;let i,l,c,u,d,f;if(e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==s){const h=gZ(t,s);l=hA,f="border-b px-3 py-1.5",i=gA,c=r,u="no-scrollbar flex-nowrap gap-1 overflow-x-auto text-xs",d=h.map((g,x)=>a.jsxs(y.Fragment,{children:[x>0&&a.jsx(vA,{}),a.jsx(k1,{className:"shrink-0",children:x===h.length-1?a.jsx(bA,{children:g.label}):a.jsx(xA,{render:a.jsx("button",{type:"button",onClick:()=>o(g.path)}),children:g.label})})]},g.path)),e[0]=r,e[1]=o,e[2]=t,e[3]=s,e[4]=i,e[5]=l,e[6]=c,e[7]=u,e[8]=d,e[9]=f}else i=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9];let m;e[10]!==i||e[11]!==c||e[12]!==u||e[13]!==d?(m=a.jsx(i,{ref:c,className:u,children:d}),e[10]=i,e[11]=c,e[12]=u,e[13]=d,e[14]=m):m=e[14];let p;return e[15]!==l||e[16]!==f||e[17]!==m?(p=a.jsx(l,{className:f,children:m}),e[15]=l,e[16]=f,e[17]=m,e[18]=p):p=e[18],p}function Ppe(n){const e=q.c(14),{message:t,onRetry:s,onRoot:r}=n;let o,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=a.jsx(Dn,{variant:"icon",children:a.jsx(Vs,{})}),i=a.jsx(En,{children:"This folder could not be opened"}),e[0]=o,e[1]=i):(o=e[0],i=e[1]);let l;e[2]!==t?(l=a.jsxs(_n,{children:[o,i,a.jsx(Tn,{children:t})]}),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==s?(c=a.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Try again"}),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r?(u=r&&a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Go to the projects root"}),e[6]=r,e[7]=u):u=e[7];let d;e[8]!==c||e[9]!==u?(d=a.jsxs("div",{className:"flex gap-2",children:[c,u]}),e[8]=c,e[9]=u,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==d?(f=a.jsxs(Cn,{className:"border-0 py-8",children:[l,d]}),e[11]=l,e[12]=d,e[13]=f):f=e[13],f}function $pe(){const n=q.c(7),e=xn("manageDevices");let t;n[0]!==e?(t={enabled:e},n[0]=e,n[1]=t):t=n[1];const{activeDevice:s}=La(t);let r;n[2]!==s?(r=!s&&vf(),n[2]=s,n[3]=r):r=n[3];const o=r,[i,l]=y.useState(null);let c,u;return n[4]!==o?(c=()=>{if(!o)return;const d=new AbortController;return Ee("/api/hello",{signal:d.signal}).then(cr).then(f=>{typeof(f==null?void 0:f.name)=="string"&&f.name&&l(f.name)}).catch(Rpe),()=>d.abort()},u=[o],n[4]=o,n[5]=c,n[6]=u):(c=n[5],u=n[6]),y.useEffect(c,u),(s==null?void 0:s.name)??(o?i:null)}function Rpe(){}function P3(n){return n.replace(/[\\/]+$/,"")||n}function yA(n){const e=n.map(s=>({...s,worktrees:[]})),t=new Map;for(const s of e){const r=P3(s.path);!yr(s.path)&&!t.has(r)&&t.set(r,s)}return e.filter((s,r)=>{const o=yr(s.path),i=o&&t.get(P3(o.parentPath));return i?(i.worktrees.push(n[r]),!1):!0})}const j1=F4("project-custom-names"),Ope=j1.rename;function Eb(){const n=q.c(2),e=y.useSyncExternalStore(j1.subscribe,j1.getSnapshot);let t;return n[0]!==e?(t={names:e,rename:Ope},n[0]=e,n[1]=t):t=n[1],t}const $3="browse-folders";function hl(n){return n.replace(/[\\/]+$/,"")||n}function wA(n){const e=q.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n)return;const l=new AbortController;return Ee("/api/projects",{signal:l.signal}).then(Lpe).then(r).catch(()=>{l.signal.aborted||r([])}),()=>l.abort()},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}async function Lpe(n){return n.ok?await n.json():[]}function SA(n){var U;const e=q.c(58),{projects:t,onNewSession:s,onNewFolder:r,defaultAgentKind:o,currentPath:i,initialView:l,children:c}=n,u=l===void 0?"projects":l,[d,f]=y.useState(u),[m,p]=y.useState(""),[h,g]=y.useState(null),{names:x}=Eb(),b=$pe();let w;if(e[0]!==m||e[1]!==x||e[2]!==t){e:{const W=yA(t);if(!m){w=W;break e}const V=m.toLowerCase();w=W.filter(H=>{var K;return H.path.toLowerCase().includes(V)||H.shortName.toLowerCase().includes(V)||H.dirName.toLowerCase().includes(V)||((K=x[H.dirName])==null?void 0:K.toLowerCase().includes(V))})}e[0]=m,e[1]=x,e[2]=t,e[3]=w}else w=e[3];const v=w;let k,j;e[4]!==m||e[5]!==t?(k=m.trim(),j=(k.startsWith("/")||/^[a-z]:[\\/]/i.test(k)||k.startsWith("\\\\"))&&!t.some(V=>hl(V.path)===hl(k)),e[4]=m,e[5]=t,e[6]=k,e[7]=j):(k=e[6],j=e[7]);const _=j;let N;e[8]!==i?(N=i?hl(((U=yr(i))==null?void 0:U.parentPath)??i):null,e[8]=i,e[9]=N):N=e[9];const S=N;let C;e[10]!==_||e[11]!==k?(C=_?[`folder:${k}`]:[],e[10]=_,e[11]=k,e[12]=C):C=e[12];let A;e[13]!==v||e[14]!==C?(A=[...C,...v.map(zpe),$3],e[13]=v,e[14]=C,e[15]=A):A=e[15];const T=A,I=h!==null&&T.includes(h)?h:T[0];if(d==="folders"){let W;e[16]!==t?(W=new Set(t.map(Mpe)),e[16]=t,e[17]=W):W=e[17];let V;e[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>f("projects"),e[18]=V):V=e[18];let H;return e[19]!==b||e[20]!==r||e[21]!==W?(H=a.jsx(Ape,{hostName:b,projectPaths:W,onStart:r,onBack:V}),e[19]=b,e[20]=r,e[21]=W,e[22]=H):H=e[22],H}let E;e[23]!==m?(E=a.jsx(Dx,{autoFocus:!0,placeholder:"Search projects, paste a folder path, or browse",value:m,onValueChange:p}),e[23]=m,e[24]=E):E=e[24];let P;e[25]!==_||e[26]!==v.length?(P=v.length===0&&!_&&a.jsx(Cn,{className:"border-0 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:"No projects found"}),a.jsx(Tn,{children:"Try another name, paste an absolute path, or browse the folders."})]})}),e[25]=_,e[26]=v.length,e[27]=P):P=e[27];let R;e[28]!==_||e[29]!==o||e[30]!==k||e[31]!==r?(R=_&&a.jsxs(No,{value:`folder:${k}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>r(k),children:[a.jsx(Fj,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),a.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[k," · ",OO(o)]})]})]}),e[28]=_,e[29]=o,e[30]=k,e[31]=r,e[32]=R):R=e[32];let L;if(e[33]!==S||e[34]!==v||e[35]!==s||e[36]!==x){let W;e[38]!==S||e[39]!==s||e[40]!==x?(W=V=>{const H=x[V.dirName],K=gc(V.path);return a.jsxs(No,{value:`project:${V.dirName}`,"data-checked":S!==null&&hl(V.path)===S,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>s(V.dirName,V.path),children:[a.jsx(ha,{projectPath:V.path,fallback:a.jsx(qr,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),className:"size-4"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-sm font-medium",children:H||K}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[H&&a.jsx("span",{className:"mr-1.5",children:K}),V.sessionCount," session",V.sessionCount!==1?"s":"",V.lastModified&&a.jsxs(a.Fragment,{children:[" · ",new Date(V.lastModified).toLocaleDateString()]})]})]})]},V.dirName)},e[38]=S,e[39]=s,e[40]=x,e[41]=W):W=e[41],L=v.map(W),e[33]=S,e[34]=v,e[35]=s,e[36]=x,e[37]=L}else L=e[37];let O;e[42]!==L||e[43]!==R?(O=a.jsxs(di,{className:"p-0",children:[R,L]}),e[42]=L,e[43]=R,e[44]=O):O=e[44];let $,M;e[45]===Symbol.for("react.memo_cache_sentinel")?($=()=>f("folders"),M=a.jsx(mc,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),e[45]=$,e[46]=M):($=e[45],M=e[46]);const D=b?`Browse folders on ${b}…`:"Browse folders…";let F;e[47]!==D?(F=a.jsx(di,{className:"sticky -bottom-1 border-t bg-popover p-0 py-1",children:a.jsxs(No,{value:$3,className:"h-auto gap-3 px-3 py-2.5",onSelect:$,children:[M,a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:D})]})}),e[47]=D,e[48]=F):F=e[48];let z;e[49]!==O||e[50]!==F||e[51]!==P?(z=a.jsxs(Sc,{className:"box-content max-h-80 p-1",children:[P,O,F]}),e[49]=O,e[50]=F,e[51]=P,e[52]=z):z=e[52];let B;return e[53]!==c||e[54]!==I||e[55]!==z||e[56]!==E?(B=a.jsxs(wc,{shouldFilter:!1,value:I,onValueChange:g,className:"rounded-none p-0",children:[E,z,c]}),e[53]=c,e[54]=I,e[55]=z,e[56]=E,e[57]=B):B=e[57],B}function Mpe(n){return hl(n.path)}function zpe(n){return`project:${n.dirName}`}function kA(n){const e=q.c(13),{projectPath:t,switcher:s}=n;let r;e[0]!==t?(r=t?kr(t):null,e[0]=t,e[1]=r):r=e[1];const o=r;let i;e[2]!==o||e[3]!==t||e[4]!==s?(i=o?a.jsxs(a.Fragment,{children:["What should we build in"," ",a.jsx(Dpe,{name:o,projectPath:t,switcher:s}),"?"]}):"What should we build?",e[2]=o,e[3]=t,e[4]=s,e[5]=i):i=e[5];let l;e[6]!==i?(l=a.jsx("h1",{className:"text-balance text-2xl font-semibold tracking-tight text-foreground",children:i}),e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t?(c=t&&a.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:gc(t)}),e[8]=t,e[9]=c):c=e[9];let u;return e[10]!==l||e[11]!==c?(u=a.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 text-center",children:[l,c]}),e[10]=l,e[11]=c,e[12]=u):u=e[12],u}function Dpe(n){const e=q.c(24),{name:t,projectPath:s,switcher:r}=n,{onNewSession:o,onNewFolder:i,defaultAgentKind:l}=r,[c,u]=y.useState(!1),d=wA(c);let f;e[0]!==s?(f=a.jsx(ha,{projectPath:s,fallback:null,className:"size-5"}),e[0]=s,e[1]=f):f=e[1];let m;e[2]!==t?(m=a.jsx("span",{className:"truncate underline decoration-dotted decoration-muted-foreground/50 underline-offset-[6px] transition-colors group-hover/project:decoration-foreground/70 group-data-popup-open/project:decoration-foreground/70",children:t}),e[2]=t,e[3]=m):m=e[3];let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(wa,{className:"size-4 shrink-0 text-muted-foreground transition-colors group-hover/project:text-foreground group-data-popup-open/project:text-foreground","aria-hidden":"true"}),e[4]=p):p=e[4];let h;e[5]!==f||e[6]!==m?(h=a.jsxs(Ta,{title:"Switch project",className:"group/project -mx-1 inline-flex max-w-full items-center gap-1.5 rounded-lg px-1.5 align-baseline outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[f,m,p]}),e[5]=f,e[6]=m,e[7]=h):h=e[7];let g;e[8]!==o?(g=(j,_)=>{u(!1),o(j,_)},e[8]=o,e[9]=g):g=e[9];let x;e[10]!==i?(x=j=>{u(!1),i(j)},e[10]=i,e[11]=x):x=e[11];let b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=a.jsx("span",{children:"Switch where this session starts"}),e[12]=b):b=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=a.jsxs("div",{className:"flex items-center justify-between border-t px-3 py-2 text-[11px] text-muted-foreground",children:[b,a.jsx("kbd",{className:"font-mono",children:Qu("newSession")})]}),e[13]=w):w=e[13];let v;e[14]!==l||e[15]!==s||e[16]!==d||e[17]!==g||e[18]!==x?(v=a.jsx($f,{align:"center",className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(SA,{projects:d,currentPath:s,defaultAgentKind:l,onNewSession:g,onNewFolder:x,children:w})}),e[14]=l,e[15]=s,e[16]=d,e[17]=g,e[18]=x,e[19]=v):v=e[19];let k;return e[20]!==c||e[21]!==v||e[22]!==h?(k=a.jsxs(Ea,{open:c,onOpenChange:u,children:[h,v]}),e[20]=c,e[21]=v,e[22]=h,e[23]=k):k=e[23],k}function Tb(n){const e=q.c(56),{children:t,sessionLabel:s,customName:r,onDuplicate:o,onDelete:i,onRename:l,onArchive:c,onUnarchive:u,archiveDisabled:d}=n,f=d===void 0?!1:d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),[x,b]=y.useState(""),w=y.useRef(null);let v;e[0]!==r?(v=function(){b(r||""),g(!0),requestAnimationFrame(()=>{var H;return(H=w.current)==null?void 0:H.select()})},e[0]=r,e[1]=v):v=e[1];const k=v;let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{className:"w-full"}),e[2]=j):j=e[2];let _;e[3]!==t?(_=a.jsx(tm,{render:j,children:t}),e[3]=t,e[4]=_):_=e[4];let N;e[5]!==f||e[6]!==c||e[7]!==o||e[8]!==l||e[9]!==u||e[10]!==k?(N=(l||o||c||u)&&a.jsxs(ii,{children:[l&&a.jsxs(Mn,{onClick:k,children:[a.jsx(gr,{"data-icon":"inline-start"}),"Rename session"]}),o&&a.jsxs(Mn,{onClick:o,children:[a.jsx(Cs,{"data-icon":"inline-start"}),"Duplicate session"]}),u?a.jsxs(Mn,{onClick:u,children:[a.jsx(gf,{"data-icon":"inline-start"}),"Restore from archive"]}):c&&a.jsxs(Mn,{onClick:c,disabled:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),f?"Archive (stop the session first)":"Archive session"]})]}),e[5]=f,e[6]=c,e[7]=o,e[8]=l,e[9]=u,e[10]=k,e[11]=N):N=e[11];let S;e[12]!==c||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==u?(S=i&&a.jsxs(a.Fragment,{children:[(o||l||c||u)&&a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{variant:"destructive",onClick:()=>p(!0),children:[a.jsx(mf,{"data-icon":"inline-start"}),"Delete session"]})})]}),e[12]=c,e[13]=i,e[14]=o,e[15]=l,e[16]=u,e[17]=S):S=e[17];let C;e[18]!==N||e[19]!==S?(C=a.jsxs(nm,{className:"min-w-44",children:[N,S]}),e[18]=N,e[19]=S,e[20]=C):C=e[20];let A;e[21]!==_||e[22]!==C?(A=a.jsxs(em,{children:[_,C]}),e[21]=_,e[22]=C,e[23]=A):A=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(Gx,{children:"Delete session?"}),e[24]=T):T=e[24];let I;e[25]!==s?(I=a.jsxs(Hx,{children:[T,a.jsxs(Zx,{children:["This will permanently delete"," ",a.jsx("span",{className:"font-medium text-foreground",children:s}),". This action cannot be undone."]})]}),e[25]=s,e[26]=I):I=e[26];let E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(Xx,{size:"sm",children:"Cancel"}),e[27]=E):E=e[27];let P;e[28]!==i?(P=a.jsxs(Kx,{children:[E,a.jsx(Yx,{variant:"destructive",size:"sm",onClick:()=>{i==null||i(),p(!1)},children:"Delete"})]}),e[28]=i,e[29]=P):P=e[29];let R;e[30]!==I||e[31]!==P?(R=a.jsxs(Vx,{children:[I,P]}),e[30]=I,e[31]=P,e[32]=R):R=e[32];let L;e[33]!==m||e[34]!==R?(L=a.jsx(qx,{open:m,onOpenChange:p,children:R}),e[33]=m,e[34]=R,e[35]=L):L=e[35];let O;e[36]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsxs(to,{children:[a.jsx(Js,{className:"text-foreground",children:"Rename session"}),a.jsx(Qs,{className:"text-muted-foreground",children:"Give this session a custom name. Clear to reset to default."})]}),e[36]=O):O=e[36];let $;e[37]!==l||e[38]!==x?($=V=>{V.preventDefault(),l==null||l(x),g(!1)},e[37]=l,e[38]=x,e[39]=$):$=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=a.jsx(rn,{htmlFor:"session-rename",children:"Session name"}),e[40]=M):M=e[40];let D;e[41]===Symbol.for("react.memo_cache_sentinel")?(D=V=>b(V.target.value),e[41]=D):D=e[41];let F;e[42]!==x||e[43]!==s?(F=a.jsxs(sn,{children:[M,a.jsx(zn,{id:"session-rename",ref:w,value:x,onChange:D,placeholder:s})]}),e[42]=x,e[43]=s,e[44]=F):F=e[44];let z;e[45]===Symbol.for("react.memo_cache_sentinel")?(z=a.jsxs(dx,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[45]=z):z=e[45];let B;e[46]!==$||e[47]!==F?(B=a.jsxs(Xs,{className:"sm:max-w-md",children:[O,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:$,children:[F,z]})]}),e[46]=$,e[47]=F,e[48]=B):B=e[48];let U;e[49]!==h||e[50]!==B?(U=a.jsx(Ys,{open:h,onOpenChange:g,children:B}),e[49]=h,e[50]=B,e[51]=U):U=e[51];let W;return e[52]!==L||e[53]!==U||e[54]!==A?(W=a.jsxs(a.Fragment,{children:[A,L,U]}),e[52]=L,e[53]=U,e[54]=A,e[55]=W):W=e[55],W}function N1(n,e){return Object.freeze({canInteract:n,canOwn:e,send:n,stop:n,answer:n,configure:n,mcp:n,undo:n,archive:e,delete:e})}const Gh=N1(!1,!1),Fpe={unknown:Gh,none:Gh,view:Gh,interact:N1(!0,!1),own:N1(!0,!0)};function ga(n){return Fpe[n]}function jm(){const n=q.c(3),{enforcesSessionAccess:e}=C4(),t=e===!1?"own":"unknown";let s;return n[0]!==e||n[1]!==t?(s=r=>ga(e!==null&&r?r.level:t),n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function jA(n){const e=q.c(16),{value:t,onChange:s,placeholder:r,loading:o}=n,i=o===void 0?!1:o;let l;e[0]!==i?(l=a.jsx(jr,{children:i?a.jsx(vt,{className:"animate-spin","aria-label":"Searching session history"}):a.jsx(ss,{"aria-hidden":"true"})}),e[0]=i,e[1]=l):l=e[1];let c;e[2]!==s?(c=m=>s(m.target.value),e[2]=s,e[3]=c):c=e[3];let u;e[4]!==i||e[5]!==r||e[6]!==c||e[7]!==t?(u=a.jsx(Vo,{type:"search","aria-busy":i,"aria-label":r,value:t,onChange:c,placeholder:r}),e[4]=i,e[5]=r,e[6]=c,e[7]=t,e[8]=u):u=e[8];let d;e[9]!==s||e[10]!==t?(d=t&&a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{"aria-label":"Clear search",onClick:()=>s(""),size:"icon-xs",children:a.jsx(At,{})})}),e[9]=s,e[10]=t,e[11]=d):d=e[11];let f;return e[12]!==l||e[13]!==u||e[14]!==d?(f=a.jsxs(qo,{className:"w-full sm:max-w-sm",children:[l,u,d]}),e[12]=l,e[13]=u,e[14]=d,e[15]=f):f=e[15],f}function NA(n){const e=q.c(10),{message:t,onRetry:s}=n;let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(_r,{"aria-hidden":"true"}),o=a.jsx(Vt,{children:"Could not load this data"}),e[0]=r,e[1]=o):(r=e[0],o=e[1]);let i;e[2]!==t?(i=a.jsx(_t,{children:t}),e[2]=t,e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(Fn,{"data-icon":"inline-start"}),e[4]=l):l=e[4];let c;e[5]!==s?(c=a.jsx(Ao,{children:a.jsxs(J,{variant:"ghost",size:"xs",onClick:s,children:[l,"Retry"]})}),e[5]=s,e[6]=c):c=e[6];let u;return e[7]!==i||e[8]!==c?(u=a.jsxs(wt,{variant:"destructive",children:[r,o,i,c]}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u}function CA(n){const e=q.c(5),{count:t,includeMessagePlaceholder:s}=n,r=t===void 0?4:t,o=s===void 0?!1:s;let i;if(e[0]!==r||e[1]!==o){let l;e[3]!==o?(l=(c,u)=>a.jsxs("div",{children:[u>0&&a.jsx(Qt,{}),a.jsxs("div",{className:"flex items-center gap-3 px-4 py-3.5",children:[a.jsx(Gn,{className:"size-8 shrink-0 rounded-md"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[a.jsx(Gn,{className:"h-4 w-40 max-w-full"}),o&&a.jsx(Gn,{className:"h-3 w-72 max-w-full"}),a.jsx(Gn,{className:"h-3 w-52 max-w-full"})]}),a.jsx(Gn,{className:"hidden h-5 w-20 sm:block"})]})]},u),e[3]=o,e[4]=l):l=e[4],i=a.jsx("div",{className:"overflow-hidden rounded-lg border","aria-hidden":"true",children:Array.from({length:r},l)}),e[0]=r,e[1]=o,e[2]=i}else i=e[2];return i}function _A(n){const e=q.c(3),{access:t}=n,{SessionBadges:s}=Tr();let r;return e[0]!==s||e[1]!==t?(r=s?a.jsx(s,{access:t}):null,e[0]=s,e[1]=t,e[2]=r):r=e[2],r}const Us={attention:"bg-warning",working:"bg-success ring-2 ring-success/30",idle:"bg-success/40"},Upe=/(?:https?:\/\/)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)/i,Bpe=/^([\w.-]+(?:\/[\w.-]+)?)#(\d+)$/,Wpe=/(?:^|\s)#(\d+)(?=\s|$)/,qpe=/^(?:pr|pull\s+request)\s*#?(\d+)$/i;function Mu(n){const e=Number(n);return Number.isSafeInteger(e)&&e>0?e:null}function Vpe(n){const e=n.trim().replace(/^(?:pr|pull\s+request)\b/i,"").trim().replace(/^(?:in|on)\s+/i,"");return!e||/^(?:pr|pull\s+request)$/i.test(e)?null:e.toLowerCase()}function EA(n){const e=n.trim();if(!e)return null;const t=Upe.exec(e);if(t){const l=Mu(t[3]);return l===null?null:{number:l,repoHint:`${t[1]}/${t[2]}`.toLowerCase()}}const s=Bpe.exec(e);if(s){const l=Mu(s[2]);return l===null?null:{number:l,repoHint:s[1].toLowerCase()}}const r=Wpe.exec(e);if(r){const l=Mu(r[1]);if(l===null)return null;const c=`${e.slice(0,r.index)} ${e.slice(r.index+r[0].length)}`;return{number:l,repoHint:Vpe(c)}}const o=qpe.exec(e);if(!o)return null;const i=Mu(o[1]);return i===null?null:{number:i,repoHint:null}}function R3(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"");return t===e||t.endsWith(`/${e}`)||e.endsWith(`/${t}`)}function Hpe(n,e){if(!n)return!1;const t=n.toLowerCase().replace(/\.git$/,"").split(/[\\/]/).filter(Boolean).at(-1);if(!t)return!1;const s=t.replace(/[^a-z0-9]/g,"");return e.split("/").some(r=>r.replace(/[^a-z0-9]/g,"")===s)}function Kpe(n,e,t=[]){if(n.number!==e.number)return!1;const s=e.repoHint;return s?n.repo&&s.includes("/")?R3(n.repo,s):R3(n.repo,s)?!0:t.some(r=>Hpe(r,s)):!0}function TA(n,e,t=[]){var o;const s=EA(e);if(s){const i=[n.cwd,n.projectShortName,...t];return((o=n.pullRequests)==null?void 0:o.some(l=>Kpe(l,s,i)))??!1}const r=e.trim().toLowerCase();return r?[...t,n.aiTitle,n.name,n.slug,n.customTitle,n.firstUserMessage,n.lastUserMessage,n.model,n.gitBranch,n.agentName,n.teamName,n.sessionId,n.cwd,n.projectShortName].some(i=>i==null?void 0:i.toLowerCase().includes(r)):!0}const Gpe=120*1e3;function AA(n){return n?Date.now()-new Date(n).getTime()<Gpe:!1}function IA(n,e){const t=n.teamName?n.agentName:"",s=e||n.aiTitle||n.name||t||n.slug||n.firstUserMessage||n.customTitle;return s?Ms(s,70):Ms(n.sessionId,16)}function O3(n){return n.trim().replace(/\s+/g," ").slice(0,40).toLowerCase()}function Zpe(n,e){const t=(n.lastUserMessage||n.firstUserMessage||"").trim();return!t||O3(t)===O3(e)?null:Ms(t,220)}function Ype(n,e){return TA(n,e)}function Xpe(n,e){if(!n||!e)return null;const t=new Date(e).getTime()-new Date(n).getTime();return t>=6e4?wr(t):null}function Jpe(n){const e=[n.sessionId];return n.cwd&&e.push(n.cwd),n.version&&e.push(`CLI ${n.version}`),n.timestamp&&e.push(`Started ${new Date(n.timestamp).toLocaleString()}`),e.join(`
|
|
455
|
+
`)}function Qpe(n){var t;const e=n.cwd?(t=yr(n.cwd))==null?void 0:t.worktreeName:void 0;return e?{icon:u$,label:e,title:n.cwd}:n.gitBranch?{icon:Wr,label:n.gitBranch}:null}function ehe(n,e){return n.agentStatus==="deferred"?"attention":e?Oc(n.agentStatus)?"idle":"working":null}function the(n){const e=q.c(20),{session:t,live:s}=n;if(t.agentStatus==="deferred"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Needs review"}),e[0]=r):r=e[0],r}if(s){const r=Oc(t.agentStatus);let o;e[1]!==t.agentPendingAgents||e[2]!==t.agentStatus||e[3]!==t.agentTerminalReason||e[4]!==t.agentToolName?(o=Rc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??"Active",e[1]=t.agentPendingAgents,e[2]=t.agentStatus,e[3]=t.agentTerminalReason,e[4]=t.agentToolName,e[5]=o):o=e[5];const i=o;let l;e[6]!==t.agentStatus?(l=Xf(t.agentStatus),e[6]=t.agentStatus,e[7]=l):l=e[7];const c=r?"bg-success/60":"bg-current";let u;e[8]!==c?(u=G("size-1.5 rounded-full",c),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==u?(d=a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:u}),e[10]=u,e[11]=d):d=e[11];let f;return e[12]!==i||e[13]!==l||e[14]!==d?(f=a.jsxs(Ue,{variant:"secondary",className:l,children:[d,i]}),e[12]=i,e[13]=l,e[14]=d,e[15]=f):f=e[15],f}if(t.agentTerminalReason){let r;e[16]!==t.agentTerminalReason?(r=b0(t.agentTerminalReason),e[16]=t.agentTerminalReason,e[17]=r):r=e[17];let o;return e[18]!==r?(o=a.jsx(Ue,{variant:"outline",className:"max-w-44 truncate text-warning",children:r}),e[18]=r,e[19]=o):o=e[19],o}return null}function Zh(n){const e=q.c(9),{icon:t,title:s,className:r,children:o}=n;let i;e[0]!==r?(i=G("flex items-center gap-1",r),e[0]=r,e[1]=i):i=e[1];let l;e[2]!==t?(l=a.jsx(t,{className:"size-3 shrink-0"}),e[2]=t,e[3]=l):l=e[3];let c;return e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==s?(c=a.jsxs("span",{className:i,title:s,children:[l,o]}),e[4]=o,e[5]=i,e[6]=l,e[7]=s,e[8]=c):c=e[8],c}function nhe(n){const e=q.c(103),{session:t,customName:s,onSelect:r}=n,o=t.lastActivityAt||t.lastModified;let i,l;e[0]!==o||e[1]!==t?(i=AA(o),l=ehe(t,i),e[0]=o,e[1]=t,e[2]=i,e[3]=l):(i=e[2],l=e[3]);const c=l,u=t.teamName?t.agentName:void 0;let d,f,m,p,h,g,x,b,w,v,k,j,_,N,S;if(e[4]!==s||e[5]!==c||e[6]!==o||e[7]!==i||e[8]!==r||e[9]!==t||e[10]!==u){const $=Qpe(t);let M;e[26]!==o||e[27]!==t.timestamp?(M=Xpe(t.timestamp,o),e[26]=o,e[27]=t.timestamp,e[28]=M):M=e[28];const D=M,F=t.turnCount??0;let z,B;e[29]!==s||e[30]!==t?(B=IA(t,s),z=Zpe(t,B),e[29]=s,e[30]=t,e[31]=z,e[32]=B):(z=e[31],B=e[32]);const U=z;x="motion-list-item group flex w-full items-start gap-3 px-4 py-3 transition-colors hover:bg-muted/50 focus-within:bg-muted",f="button",m=r,e[33]!==t?(p=Jpe(t),e[33]=t,e[34]=p):p=e[34],h="flex min-w-0 flex-1 items-start gap-3 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring";let W;e[35]===Symbol.for("react.memo_cache_sentinel")?(W=a.jsx(Wv,{className:"size-4"}),e[35]=W):W=e[35];let V;e[36]!==c?(V=c&&a.jsx("span",{"aria-hidden":"true","data-status-dot":c,className:G("absolute -top-1 -right-1 size-2 rounded-full ring-2 ring-card",Us[c])}),e[36]=c,e[37]=V):V=e[37],e[38]!==V?(g=a.jsxs("span",{className:"relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40 text-muted-foreground",children:[W,V]}),e[38]=V,e[39]=g):g=e[39],N="flex min-w-0 flex-1 flex-col gap-1";let H;e[40]!==B?(H=a.jsx("span",{className:"truncate text-sm font-medium",children:B}),e[40]=B,e[41]=H):H=e[41];let K;e[42]!==u?(K=u&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",children:[a.jsx(ea,{"data-icon":"inline-start"}),Ms(u,18)]}),e[42]=u,e[43]=K):K=e[43];let Z;e[44]!==t.branchedFrom?(Z=t.branchedFrom&&a.jsxs(Ue,{variant:"outline",className:"shrink-0",title:"Branched from another session",children:[a.jsx(X1,{"data-icon":"inline-start"}),"branch"]}),e[44]=t.branchedFrom,e[45]=Z):Z=e[45];let Y;e[46]!==i||e[47]!==t?(Y=a.jsx(the,{session:t,live:i}),e[46]=i,e[47]=t,e[48]=Y):Y=e[48];let X;e[49]!==o?(X=o&&a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:Sr(o)}),e[49]=o,e[50]=X):X=e[50];let ee;e[51]!==Y||e[52]!==X?(ee=a.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2",children:[Y,X]}),e[51]=Y,e[52]=X,e[53]=ee):ee=e[53],e[54]!==H||e[55]!==K||e[56]!==Z||e[57]!==ee?(S=a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[H,K,Z,ee]}),e[54]=H,e[55]=K,e[56]=Z,e[57]=ee,e[58]=S):S=e[58],e[59]!==U?(d=U&&a.jsx("span",{className:"line-clamp-1 text-sm text-muted-foreground",children:U}),e[59]=U,e[60]=d):d=e[60],b="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",e[61]!==t.access?(w=a.jsx(_A,{access:t.access}),e[61]=t.access,e[62]=w):w=e[62],e[63]!==t.model?(v=t.model&&a.jsx(Ue,{variant:"outline",children:xi(t.model)}),e[63]=t.model,e[64]=v):v=e[64],e[65]!==F?(k=F>0&&a.jsxs(Zh,{icon:Wv,children:[F," ",F===1?"turn":"turns"]}),e[65]=F,e[66]=k):k=e[66],e[67]!==D?(j=D&&a.jsx(Zh,{icon:Eo,title:"First prompt to last activity",children:D}),e[67]=D,e[68]=j):j=e[68],_=$&&a.jsx(Zh,{icon:$.icon,className:"max-w-40 truncate",title:$.title,children:Ms($.label,22)}),e[4]=s,e[5]=c,e[6]=o,e[7]=i,e[8]=r,e[9]=t,e[10]=u,e[11]=d,e[12]=f,e[13]=m,e[14]=p,e[15]=h,e[16]=g,e[17]=x,e[18]=b,e[19]=w,e[20]=v,e[21]=k,e[22]=j,e[23]=_,e[24]=N,e[25]=S}else d=e[11],f=e[12],m=e[13],p=e[14],h=e[15],g=e[16],x=e[17],b=e[18],w=e[19],v=e[20],k=e[21],j=e[22],_=e[23],N=e[24],S=e[25];let C;e[69]!==t.size?(C=b4(t.size),e[69]=t.size,e[70]=C):C=e[70];let A;e[71]!==C?(A=a.jsx("span",{children:C}),e[71]=C,e[72]=A):A=e[72];let T;e[73]!==A||e[74]!==b||e[75]!==w||e[76]!==v||e[77]!==k||e[78]!==j||e[79]!==_?(T=a.jsxs("span",{className:b,children:[w,v,k,j,_,A]}),e[73]=A,e[74]=b,e[75]=w,e[76]=v,e[77]=k,e[78]=j,e[79]=_,e[80]=T):T=e[80];let I;e[81]!==d||e[82]!==T||e[83]!==N||e[84]!==S?(I=a.jsxs("span",{className:N,children:[S,d,T]}),e[81]=d,e[82]=T,e[83]=N,e[84]=S,e[85]=I):I=e[85];let E;e[86]!==f||e[87]!==m||e[88]!==p||e[89]!==h||e[90]!==g||e[91]!==I?(E=a.jsxs("button",{type:f,onClick:m,title:p,className:h,children:[g,I]}),e[86]=f,e[87]=m,e[88]=p,e[89]=h,e[90]=g,e[91]=I,e[92]=E):E=e[92];let P;e[93]!==t.matchedPullRequestNumber||e[94]!==t.pullRequests?(P=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:2,compact:!0}),e[93]=t.matchedPullRequestNumber,e[94]=t.pullRequests,e[95]=P):P=e[95];let R;e[96]===Symbol.for("react.memo_cache_sentinel")?(R=a.jsx(it,{className:"size-4 text-muted-foreground transition-transform group-hover:translate-x-0.5"}),e[96]=R):R=e[96];let L;e[97]!==P?(L=a.jsxs("span",{className:"flex shrink-0 items-center gap-2 pt-1.5",children:[P,R]}),e[97]=P,e[98]=L):L=e[98];let O;return e[99]!==x||e[100]!==E||e[101]!==L?(O=a.jsxs("div",{className:x,children:[E,L]}),e[99]=x,e[100]=E,e[101]=L,e[102]=O):O=e[102],O}function she(n){const e=q.c(63),{selectedProject:t,filterEmpty:s,sessions:r,sessionsTotal:o,sessionsLoading:i,searchLoading:l,searchFilter:c,setSearchFilter:u,filteredSessions:d,fetchError:f,onSelectSession:m,onNewSession:p,creatingSession:h,onDuplicateSession:g,onDeleteSession:x,onBack:b,onRetryFetch:w,loadMoreSessions:v}=n,{names:k,rename:j}=If(),_=jm();let N;e[0]!==t.path?(N=kr(t.path),e[0]=t.path,e[1]=N):N=e[1];const S=N;let C;e[2]!==b?(C=a.jsx(k1,{children:a.jsx(xA,{render:a.jsx("button",{type:"button",onClick:b}),children:"Projects"})}),e[2]=b,e[3]=C):C=e[3];let A;e[4]===Symbol.for("react.memo_cache_sentinel")?(A=a.jsx(vA,{}),e[4]=A):A=e[4];let T;e[5]!==S?(T=a.jsx(k1,{className:"min-w-0",children:a.jsx(bA,{className:"truncate",children:S})}),e[5]=S,e[6]=T):T=e[6];let I;e[7]!==C||e[8]!==T?(I=a.jsx(hA,{children:a.jsxs(gA,{children:[C,A,T]})}),e[7]=C,e[8]=T,e[9]=I):I=e[9];let E;e[10]!==S?(E=a.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight",children:S}),e[10]=S,e[11]=E):E=e[11];let P;e[12]!==o?(P=a.jsx(Ue,{variant:"secondary",children:o}),e[12]=o,e[13]=P):P=e[13];let R;e[14]!==E||e[15]!==P?(R=a.jsxs("div",{className:"flex items-center gap-2",children:[E,P]}),e[14]=E,e[15]=P,e[16]=R):R=e[16];let L;e[17]!==t.path?(L=gc(t.path),e[17]=t.path,e[18]=L):L=e[18];let O;e[19]!==L?(O=a.jsx("p",{className:"truncate text-sm text-muted-foreground",children:L}),e[19]=L,e[20]=O):O=e[20];let $;e[21]!==O||e[22]!==R?($=a.jsxs("header",{className:"flex min-w-0 flex-col gap-1",children:[R,O]}),e[21]=O,e[22]=R,e[23]=$):$=e[23];let M;e[24]!==c||e[25]!==l||e[26]!==u?(M=a.jsx(jA,{value:c,onChange:u,placeholder:"Search sessions or PRs...",loading:l}),e[24]=c,e[25]=l,e[26]=u,e[27]=M):M=e[27];let D;e[28]!==h||e[29]!==p||e[30]!==t.dirName||e[31]!==t.path?(D=p&&a.jsxs(J,{size:"sm",disabled:h,onClick:()=>p(t.dirName,t.path),children:[h?a.jsx(Pn,{"data-icon":"inline-start"}):a.jsx(xr,{"data-icon":"inline-start"}),"New Session"]}),e[28]=h,e[29]=p,e[30]=t.dirName,e[31]=t.path,e[32]=D):D=e[32];let F;e[33]!==M||e[34]!==D?(F=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[M,D]}),e[33]=M,e[34]=D,e[35]=F):F=e[35];let z;e[36]!==f||e[37]!==w?(z=f&&a.jsx(NA,{message:f,onRetry:w}),e[36]=f,e[37]=w,e[38]=z):z=e[38];let B;e[39]!==s||e[40]!==d||e[41]!==v||e[42]!==x||e[43]!==g||e[44]!==m||e[45]!==_||e[46]!==j||e[47]!==c||e[48]!==l||e[49]!==t.dirName||e[50]!==k||e[51]!==r||e[52]!==i||e[53]!==o?(B=(i||l)&&d.length===0?a.jsx(CA,{includeMessagePlaceholder:!0}):d.length===0?a.jsx(rhe,{searchFilter:c,filterEmpty:s}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:d.map((V,H)=>a.jsxs(y.Fragment,{children:[H>0&&a.jsx(Qt,{}),a.jsx(Tb,{sessionLabel:IA(V),customName:k[V.sessionId],onRename:K=>j(V.sessionId,K),onDuplicate:g?()=>g(t.dirName,V.fileName):void 0,onDelete:x&&_(V.access).delete?()=>x(t.dirName,V.fileName):void 0,children:a.jsx(nhe,{session:V,customName:k[V.sessionId],onSelect:()=>m(t.dirName,V.fileName)})})]},V.fileName))}),r.length<o&&!c&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(J,{variant:"outline",size:"sm",disabled:i,onClick:v,children:[i&&a.jsx(Pn,{"data-icon":"inline-start"}),i?"Loading...":"Load more sessions"]})})]}),e[39]=s,e[40]=d,e[41]=v,e[42]=x,e[43]=g,e[44]=m,e[45]=_,e[46]=j,e[47]=c,e[48]=l,e[49]=t.dirName,e[50]=k,e[51]=r,e[52]=i,e[53]=o,e[54]=B):B=e[54];let U;e[55]!==F||e[56]!==z||e[57]!==B?(U=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Sessions",children:[F,z,B]}),e[55]=F,e[56]=z,e[57]=B,e[58]=U):U=e[58];let W;return e[59]!==$||e[60]!==U||e[61]!==I?(W=a.jsx(Cc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[I,$,U]})}),e[59]=$,e[60]=U,e[61]=I,e[62]=W):W=e[62],W}function rhe(n){const e=q.c(8),{searchFilter:t,filterEmpty:s}=n;if(!t&&s)return s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Dn,{variant:"icon",children:a.jsx(To,{})}),e[0]=r):r=e[0];const o=t?"No sessions match your search":"No sessions yet";let i;e[1]!==o?(i=a.jsx(En,{children:o}),e[1]=o,e[2]=i):i=e[2];const l=t?"Try #157, honest-cms #157, or paste a PR URL.":"Start a session in this project and it will appear here.";let c;e[3]!==l?(c=a.jsx(Tn,{children:l}),e[3]=l,e[4]=c):c=e[4];let u;return e[5]!==i||e[6]!==c?(u=a.jsx(Cn,{className:"min-h-72 border",children:a.jsxs(_n,{children:[r,i,c]})}),e[5]=i,e[6]=c,e[7]=u):u=e[7],u}function PA(n){const e=q.c(40),{children:t,projectLabel:s,customName:r,className:o,onRename:i,archivableCount:l,onArchiveIdle:c}=n,u=l===void 0?0:l,[d,f]=y.useState(!1),[m,p]=y.useState(""),h=y.useRef(null);let g;e[0]!==r?(g=function(){p(r||""),f(!0),requestAnimationFrame(()=>{var M;return(M=h.current)==null?void 0:M.select()})},e[0]=r,e[1]=g):g=e[1];const x=g;let b;e[2]!==o?(b=G("w-full",o),e[2]=o,e[3]=b):b=e[3];let w;e[4]!==b?(w=a.jsx("div",{className:b}),e[4]=b,e[5]=w):w=e[5];let v;e[6]!==t||e[7]!==w?(v=a.jsx(tm,{render:w,children:t}),e[6]=t,e[7]=w,e[8]=v):v=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx(gr,{"data-icon":"inline-start"}),e[9]=k):k=e[9];let j;e[10]!==x?(j=a.jsx(ii,{children:a.jsxs(Mn,{onClick:x,children:[k,"Rename project"]})}),e[10]=x,e[11]=j):j=e[11];let _;e[12]!==u||e[13]!==c?(_=c&&a.jsxs(a.Fragment,{children:[a.jsx(la,{}),a.jsx(ii,{children:a.jsxs(Mn,{onClick:c,disabled:u===0,children:[a.jsx(ks,{"data-icon":"inline-start"}),u>0?`Archive ${u} idle ${u===1?"session":"sessions"}`:"Archive idle sessions"]})})]}),e[12]=u,e[13]=c,e[14]=_):_=e[14];let N;e[15]!==j||e[16]!==_?(N=a.jsxs(nm,{className:"min-w-44",children:[j,_]}),e[15]=j,e[16]=_,e[17]=N):N=e[17];let S;e[18]!==v||e[19]!==N?(S=a.jsxs(em,{children:[v,N]}),e[18]=v,e[19]=N,e[20]=S):S=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsxs(to,{children:[a.jsx(Js,{className:"text-foreground",children:"Rename project"}),a.jsx(Qs,{className:"text-muted-foreground",children:"Give this project a custom name. Clear to reset to default."})]}),e[21]=C):C=e[21];let A;e[22]!==i||e[23]!==m?(A=$=>{$.preventDefault(),i(m),f(!1)},e[22]=i,e[23]=m,e[24]=A):A=e[24];let T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=a.jsx(rn,{htmlFor:"project-rename",children:"Project name"}),e[25]=T):T=e[25];let I;e[26]===Symbol.for("react.memo_cache_sentinel")?(I=$=>p($.target.value),e[26]=I):I=e[26];let E;e[27]!==s||e[28]!==m?(E=a.jsxs(sn,{children:[T,a.jsx(zn,{id:"project-rename",ref:h,value:m,onChange:I,placeholder:s})]}),e[27]=s,e[28]=m,e[29]=E):E=e[29];let P;e[30]===Symbol.for("react.memo_cache_sentinel")?(P=a.jsxs(dx,{children:[a.jsx(J,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(!1),children:"Cancel"}),a.jsx(J,{type:"submit",size:"sm",children:"Save"})]}),e[30]=P):P=e[30];let R;e[31]!==A||e[32]!==E?(R=a.jsxs(Xs,{className:"sm:max-w-md",children:[C,a.jsxs("form",{className:"flex flex-col gap-4",onSubmit:A,children:[E,P]})]}),e[31]=A,e[32]=E,e[33]=R):R=e[33];let L;e[34]!==d||e[35]!==R?(L=a.jsx(Ys,{open:d,onOpenChange:f,children:R}),e[34]=d,e[35]=R,e[36]=L):L=e[36];let O;return e[37]!==S||e[38]!==L?(O=a.jsxs(a.Fragment,{children:[S,L]}),e[37]=S,e[38]=L,e[39]=O):O=e[39],O}function ohe(n){const e=q.c(47),{projects:t,activeSessions:s,loading:r,refreshing:o,searchFilter:i,setSearchFilter:l,fetchError:c,selectedProjectDirName:u,onSelectProject:d,onRefresh:f}=n;let m;if(e[0]!==s){m={};for(const $ of s)AA($.lastModified)&&(m[$.dirName]=(m[$.dirName]||0)+1);e[0]=s,e[1]=m}else m=e[1];const p=m,{names:h,rename:g}=Eb();let x;e[2]!==t?(x=yA(t),e[2]=t,e[3]=x):x=e[3];const b=x;let w;e:{if(!i){w=b;break e}let $;if(e[4]!==h||e[5]!==b||e[6]!==i){const M=i.toLowerCase(),D=F=>{var z;return F.path.toLowerCase().includes(M)||F.shortName.toLowerCase().includes(M)||((z=h[F.dirName])==null?void 0:z.toLowerCase().includes(M))};$=b.filter(F=>D(F)||F.worktrees.some(D)),e[4]=h,e[5]=b,e[6]=i,e[7]=$}else $=e[7];w=$}const v=w;let k;e[8]===Symbol.for("react.memo_cache_sentinel")?(k=a.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Projects"}),e[8]=k):k=e[8];let j;e[9]!==b.length?(j=a.jsxs("div",{className:"flex items-center gap-2",children:[k,a.jsx(Ue,{variant:"secondary",children:b.length})]}),e[9]=b.length,e[10]=j):j=e[10];let _;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=a.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a project to browse and resume its sessions."}),e[11]=_):_=e[11];let N;e[12]!==j?(N=a.jsxs("header",{className:"flex flex-col gap-1",children:[j,_]}),e[12]=j,e[13]=N):N=e[13];let S;e[14]!==i||e[15]!==l?(S=a.jsx(jA,{value:i,onChange:l,placeholder:"Filter projects..."}),e[14]=i,e[15]=l,e[16]=S):S=e[16];const C=o&&"animate-spin";let A;e[17]!==C?(A=G(C),e[17]=C,e[18]=A):A=e[18];let T;e[19]!==A?(T=a.jsx(Fn,{"data-icon":"inline-start",className:A}),e[19]=A,e[20]=T):T=e[20];let I;e[21]!==f||e[22]!==o||e[23]!==T?(I=a.jsxs(J,{variant:"outline",size:"sm",onClick:f,disabled:o,"aria-label":"Refresh projects",children:[T,"Refresh"]}),e[21]=f,e[22]=o,e[23]=T,e[24]=I):I=e[24];let E;e[25]!==I||e[26]!==S?(E=a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[S,I]}),e[25]=I,e[26]=S,e[27]=E):E=e[27];let P;e[28]!==c||e[29]!==f||e[30]!==u?(P=c&&!u&&a.jsx(NA,{message:c,onRetry:f}),e[28]=c,e[29]=f,e[30]=u,e[31]=P):P=e[31];let R;e[32]!==p||e[33]!==v||e[34]!==r||e[35]!==d||e[36]!==h||e[37]!==g||e[38]!==i?(R=r?a.jsx(CA,{}):v.length===0?a.jsxs(Cn,{className:"min-h-72 border",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(qr,{})}),a.jsx(En,{children:i?"No projects match your search":"No projects yet"}),a.jsx(Tn,{children:i?"Try a project name or path.":"Start Claude Code, Codex, or Copilot and its project will appear here."})]}),!i&&a.jsx(vc,{children:a.jsxs(J,{variant:"outline",size:"sm",onClick:ihe,children:[a.jsx(mc,{"data-icon":"inline-start"}),"Start in a folder"]})})]}):a.jsx("div",{className:"overflow-hidden rounded-lg border bg-card",children:v.map(($,M)=>{const D=p[$.dirName]||0,F=h[$.dirName],z=LO(an($.dirName));return a.jsxs(y.Fragment,{children:[M>0&&a.jsx(Qt,{}),a.jsx(PA,{projectLabel:kr($.path),customName:F,onRename:B=>g($.dirName,B),children:a.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d($.dirName),className:"motion-list-item group flex w-full flex-col gap-3 px-4 py-3.5 text-left outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset sm:flex-row sm:items-center",children:[a.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-md border bg-muted/40",children:a.jsx(ha,{projectPath:$.path,className:"size-4",fallback:a.jsx(qr,{className:"size-4 text-muted-foreground"})})}),a.jsxs("span",{className:"min-w-0",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:F||kr($.path)}),z&&a.jsx(Ue,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-[10px]",children:z})]}),a.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[gc($.path),$.worktrees.length>0&&a.jsxs(a.Fragment,{children:[" · ",$.worktrees.length," ",$.worktrees.length===1?"worktree":"worktrees"]})]})]})]}),a.jsxs("span",{className:"flex items-center gap-4 pl-11 text-sm text-muted-foreground sm:pl-0",children:[D>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),D," active"]}),a.jsxs("span",{className:"whitespace-nowrap",children:[$.sessionCount," ",$.sessionCount===1?"session":"sessions"]}),$.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Sr($.lastModified)}),a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"})]})]})}),$.worktrees.map(B=>a.jsx(ahe,{worktree:B,customName:h[B.dirName],activeCount:p[B.dirName]||0,onSelect:()=>d==null?void 0:d(B.dirName)},B.dirName))]},$.dirName)})}),e[32]=p,e[33]=v,e[34]=r,e[35]=d,e[36]=h,e[37]=g,e[38]=i,e[39]=R):R=e[39];let L;e[40]!==E||e[41]!==P||e[42]!==R?(L=a.jsxs("section",{className:"flex flex-col gap-4","aria-label":"Projects",children:[E,P,R]}),e[40]=E,e[41]=P,e[42]=R,e[43]=L):L=e[43];let O;return e[44]!==L||e[45]!==N?(O=a.jsx(Cc,{className:"h-full",children:a.jsxs("main",{className:"mx-auto flex max-w-6xl flex-col gap-6 px-4 py-6 sm:px-6 sm:pb-10 sm:pt-14",children:[N,L]})}),e[44]=L,e[45]=N,e[46]=O):O=e[46],O}function ihe(){return V_()}function ahe(n){var b;const e=q.c(23),{worktree:t,customName:s,activeCount:r,onSelect:o}=n;let i;e[0]!==s||e[1]!==t.path?(i=s||((b=yr(t.path))==null?void 0:b.worktreeName)||kr(t.path),e[0]=s,e[1]=t.path,e[2]=i):i=e[2];const l=i;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Wr,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[3]=c):c=e[3];let u;e[4]!==l?(u=a.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground group-hover:text-foreground",children:l}),e[4]=l,e[5]=u):u=e[5];let d;e[6]!==r?(d=r>0&&a.jsxs(Ue,{variant:"secondary",children:[a.jsx("span",{"aria-hidden":"true","data-icon":"inline-start",className:"size-1.5 rounded-full bg-success"}),r," active"]}),e[6]=r,e[7]=d):d=e[7];const f=t.sessionCount===1?"session":"sessions";let m;e[8]!==f||e[9]!==t.sessionCount?(m=a.jsxs("span",{className:"whitespace-nowrap",children:[t.sessionCount," ",f]}),e[8]=f,e[9]=t.sessionCount,e[10]=m):m=e[10];let p;e[11]!==t.lastModified?(p=t.lastModified&&a.jsx("span",{className:"hidden w-24 whitespace-nowrap text-right md:inline",children:Sr(t.lastModified)}),e[11]=t.lastModified,e[12]=p):p=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=a.jsx(it,{className:"size-4 shrink-0 transition-transform group-hover:translate-x-0.5"}),e[13]=h):h=e[13];let g;e[14]!==d||e[15]!==m||e[16]!==p?(g=a.jsxs("span",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[d,m,p,h]}),e[14]=d,e[15]=m,e[16]=p,e[17]=g):g=e[17];let x;return e[18]!==o||e[19]!==u||e[20]!==g||e[21]!==t.path?(x=a.jsxs("button",{type:"button",onClick:o,title:t.path,className:"motion-list-item group flex w-full items-center gap-3 py-2 pl-15 pr-4 text-left text-sm outline-none transition-colors hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",children:[c,u,g]}),e[18]=o,e[19]=u,e[20]=g,e[21]=t.path,e[22]=x):x=e[22],x}const lhe=250,che=400,L3={results:null,loading:!1,error:null};function $A(n,e,t){const s=y.useMemo(()=>EA(n),[n]),[r,o]=y.useState(0),[i,l]=y.useState(L3);y.useEffect(()=>{if(!s){l(L3);return}const d=new AbortController;l({results:null,loading:!0,error:null});let f=null;const m=async()=>{const h=new URLSearchParams({search:n.trim(),limit:"200"});t&&h.set("project",t);const g=Hr();try{const x=await Ee(Tf(h,e),{signal:d.signal});if(!x.ok)throw new Error(`Search failed (${x.status})`);const b=await x.json();if(d.signal.aborted)return;const w=Number(x.headers.get("X-Cogpit-PR-Index-Pending")??"0");if(Number.isFinite(w)&&w>0){f=setTimeout(()=>{m()},che);return}const v=Array.isArray(b)?b:[];ra(v,g),l({results:v,loading:!1,error:null})}catch(x){if(d.signal.aborted)return;l({results:[],loading:!1,error:x instanceof Error?x.message:"Search failed"})}},p=setTimeout(()=>{m()},lhe);return()=>{clearTimeout(p),f&&clearTimeout(f),d.abort()}},[e,t,s,n,r]);const c=y.useCallback(()=>o(d=>d+1),[]),u=s!==null;return y.useEffect(()=>{if(u)return Af(c)},[u,c]),{...i,active:u,refresh:c}}const uhe=y.memo(function({onSelectSession:e,onNewSession:t,creatingSession:s,selectedProjectDirName:r,onSelectProject:o,onDuplicateSession:i,onDeleteSession:l}){var ne;const c=Ef(),u=(ne=Tr().sessionListFilter)==null?void 0:ne.Empty,[d]=y.useState(()=>({projects:Vi(Vl.projects),activeSessions:Vi(qu(c.key))})),[f,m]=y.useState(d.projects??[]),[p,h]=y.useState(d.activeSessions??[]),[g,x]=y.useState(d.projects===void 0),[b,w]=y.useState(!1),[v,k]=y.useState(null),[j,_]=y.useState(null),[N,S]=y.useState([]),[C,A]=y.useState(0),[T,I]=y.useState(1),[E,P]=y.useState(!1),[R,L]=y.useState(""),[O,$]=y.useState(null),M=y.useRef(0),D=y.useRef(null),F=y.useRef(null),z=y.useRef(c.key),B=y.useCallback(async()=>{try{const te=await Ee("/api/projects");if(!te.ok)throw new Error("Failed to fetch dashboard data");const re=await te.json(),oe=Array.isArray(re)?re:[];m(oe),wl(Vl.projects,oe),k(null)}catch(te){k(te instanceof Error?te.message:"Failed to load data")}finally{x(!1)}},[]),U=y.useCallback(async()=>{var oe;(oe=F.current)==null||oe.abort();const te=new AbortController;F.current=te;const re=Hr();try{const ie=await Ee(Tf({},c),{signal:te.signal});if(!ie.ok)throw new Error("Failed to fetch dashboard data");const ae=await ie.json();if(te.signal.aborted)return;const de=Array.isArray(ae)?ae:[];ra(de,re),h(de),wl(qu(c.key),de),_(null)}catch(ie){if(te.signal.aborted)return;_(ie instanceof Error?ie.message:"Failed to load data")}},[c]);y.useEffect(()=>{B()},[B]),y.useEffect(()=>{z.current!==c.key&&(z.current=c.key,h(Vi(qu(c.key))??[])),U()},[c,U]);async function W(){w(!0),await Promise.all([B(),U()]),w(!1)}const V=y.useCallback(async(te,re=1,oe=!1)=>{var se;const ie=++M.current;(se=D.current)==null||se.abort();const ae=new AbortController;D.current=ae;const de=()=>ie===M.current;P(!0),$(null);const le=Hr();if(!oe){const me=pR(te,c.key);me?(S(me.sessions),A(me.total),I(1)):S([])}try{const me=await Ee(Sl(`/api/sessions/${encodeURIComponent(te)}`,c,{page:String(re),limit:"20"}),{signal:ae.signal});if(!me.ok)throw new Error(`Failed to load sessions (${me.status})`);const ue=await me.json();if(!de())return;const ce=Array.isArray(ue.sessions)?ue.sessions:[],xe=typeof ue.total=="number"?ue.total:ce.length;ra(ce,le),S(pe=>oe?[...pe,...ce]:ce),A(xe),I(re),oe||hR(te,c.key,{sessions:ce,total:xe})}catch(me){if(!de()||ae.signal.aborted)return;$(me instanceof Error?me.message:"Failed to load sessions")}finally{de()&&(D.current=null,P(!1))}},[c]);y.useEffect(()=>{var te;if(!r){M.current+=1,(te=D.current)==null||te.abort(),D.current=null,S([]),A(0),I(1),P(!1);return}V(r)},[r,V]),y.useEffect(()=>{L("")},[r]),y.useEffect(()=>()=>{var te,re;M.current+=1,(te=D.current)==null||te.abort(),(re=F.current)==null||re.abort()},[]),y.useEffect(()=>Af(()=>{U(),r&&V(r)}),[U,V,r]);const H=y.useMemo(()=>{if(!r)return null;const te=f.find(oe=>oe.dirName===r);if(te)return te;const re=ms(r);return{dirName:r,path:re,shortName:kr(re),sessionCount:C,lastModified:null}},[r,f,C]),K=y.useCallback(()=>{o==null||o(null)},[o]),Z=y.useCallback(()=>{r&&V(r,T+1,!0)},[r,T,V]),Y=$A(r?R:"",c,r??void 0),X=y.useMemo(()=>R?N.filter(te=>Ype(te,R)):N,[N,R]),ee=Y.results??X;async function Q(te,re){await(l==null?void 0:l(te,re))&&(S(oe=>oe.filter(ie=>ie.fileName!==re)),A(oe=>oe-1))}return H?a.jsx(she,{selectedProject:H,filterEmpty:c.key!==null&&u?a.jsx(u,{className:"min-h-72 border"}):null,sessions:N,sessionsTotal:C,sessionsLoading:E,searchLoading:Y.loading,searchFilter:R,setSearchFilter:L,filteredSessions:ee,fetchError:Y.error??O,onSelectSession:e,onNewSession:t,creatingSession:s,onDuplicateSession:i,onDeleteSession:Q,onBack:K,onRetryFetch:()=>{if(Y.error){Y.refresh();return}$(null),r&&V(r)},loadMoreSessions:Z}):a.jsx(ohe,{projects:f,activeSessions:p,loading:g,refreshing:b,searchFilter:R,setSearchFilter:L,fetchError:v??j,selectedProjectDirName:r??null,onSelectProject:o,onRefresh:()=>void W()})}),M3=768;function Ab(){const n=q.c(2),[e,t]=y.useState(typeof window<"u"?window.innerWidth<M3:!1);let s,r;return n[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>{const o=window.matchMedia(`(max-width: ${M3-1}px)`),i=l=>t(l.matches);return o.addEventListener("change",i),t(o.matches),()=>o.removeEventListener("change",i)},r=[],n[0]=s,n[1]=r):(s=n[0],r=n[1]),y.useEffect(s,r),e}const RA=typeof navigator<"u"&&"vibrate"in navigator;function C1(){RA&&navigator.vibrate(10)}function dhe(){RA&&navigator.vibrate(20)}function fhe(n){return!!(n.teamName&&n.agentName)}function mhe(n,e,t,s,r,o,i,l=()=>!0){const c=[],u=[];for(const d of ja(n)){const f=p=>{l(d)&&c.push({session:d,reason:p})};if(s!=null&&s.has(d.sessionId)){f("permission");continue}if(r!=null&&r.has(d.sessionId)){f("question");continue}if(o!=null&&o.has(d.sessionId)){f("prompt");continue}if(i!=null&&i.has(d.sessionId)){f("plan");continue}if(d.agentStatus==="deferred"){f("deferred");continue}if(fhe(d))continue;const m=xx(d,e);if(d.agentStatus==="completed"||!m){t.has(d.sessionId)&&f("done");continue}if(d.agentStatus==="idle"){f("waiting");continue}(!d.agentStatus||jf.has(d.agentStatus))&&u.push(d)}return{needsYou:c,working:u}}function phe(n,e,t,s,r=()=>!0){const o=[...n.needsYou],i=[...n.working],l=new Map;for(const u of e){const d=t.get(u.sessionId);if(!(d!=null&&d.length))continue;const f=vx(d,p=>{const h=s(p);return h.state==="needs-you"&&!r(p)?{state:"done"}:h}),m=o.findIndex(p=>p.session.sessionId===u.sessionId);if(f.needsYou>0)if(m>=0)o[m]={...o[m],crew:f};else{o.push({session:u,reason:"crew",crew:f});const p=i.indexOf(u);p>=0&&i.splice(p,1)}else f.working>0&&m<0&&!i.includes(u)&&(i.push(u),l.set(u.sessionId,f))}const c=u=>{var d;return u.reason==="crew"&&((d=u.crew)!=null&&d.longestWaitSince)?Date.parse(u.crew.longestWaitSince):vr(u.session)};return o.sort((u,d)=>c(d)-c(u)),{needsYou:o,working:ja(i),workingCrews:l}}function OA(n){switch(n.agentStatus){case"tool_use":return n.agentToolName||"Tool";case"thinking":return"Thinking";case"processing":return"Processing";case"compacting":return"Compacting";case"awaiting_agents":return"Agents running";default:return"Running"}}const LA="aw:turnCounts",hhe=200,Nm=new Map;try{const n=localStorage.getItem(LA);if(n){const e=JSON.parse(n);for(const[t,s]of e)Nm.set(t,s)}}catch{}function ghe(){try{const n=[...Nm.entries()].slice(-hhe);localStorage.setItem(LA,JSON.stringify(n))}catch{}}function xhe(n,e){Nm.set(en(n),e),ghe()}function MA(n,e){const t=Nm.get(en(n));return Math.max(t??0,e??0)}function Ib(n){const e=q.c(51),{session:t,proc:s,statusLabel:r,customName:o,worktreeName:i,projectLabel:l}=n,c=o||t.aiTitle,u=t.firstUserMessage,d=t.lastUserMessage&&t.lastUserMessage!==u?t.lastUserMessage:void 0,f=MA(t.sessionId,t.turnCount);let m;e[0]!==c?(m=c&&a.jsx("span",{className:"font-medium leading-snug text-foreground",children:c}),e[0]=c,e[1]=m):m=e[1];let p;e[2]!==l?(p=l&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Qi,{className:"size-3 shrink-0"}),a.jsx("span",{className:"truncate",children:l})]}),e[2]=l,e[3]=p):p=e[3];let h;e[4]!==t.agentStatus||e[5]!==r?(h=r&&a.jsx("span",{className:G("font-medium",Xf(t.agentStatus)),children:r}),e[4]=t.agentStatus,e[5]=r,e[6]=h):h=e[6];let g;e[7]!==t.agentName||e[8]!==t.teamName?(g=t.teamName&&t.agentName&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(Zs,{className:"size-3"}),t.agentName," · ",t.teamName]}),e[7]=t.agentName,e[8]=t.teamName,e[9]=g):g=e[9];let x;e[10]!==t.archived||e[11]!==t.archivedReason?(x=t.archived&&a.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[a.jsx(ks,{className:"size-3"}),hx(t.archivedReason)]}),e[10]=t.archived,e[11]=t.archivedReason,e[12]=x):x=e[12];let b;e[13]!==u||e[14]!==d?(b=u&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Started with"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-first-prompt":!0,className:"line-clamp-8 leading-relaxed",children:u})})]}),e[13]=u,e[14]=d,e[15]=b):b=e[15];let w;e[16]!==d?(w=d&&a.jsxs("div",{className:"flex flex-col gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:"Latest"}),a.jsx("div",{className:"border-l-2 pl-2 text-muted-foreground",children:a.jsx("span",{"data-last-prompt":!0,className:"line-clamp-4 leading-relaxed",children:d})})]}),e[16]=d,e[17]=w):w=e[17];let v;e[18]!==t.pullRequests?(v=a.jsx(zc,{pullRequests:t.pullRequests,layout:"list"}),e[18]=t.pullRequests,e[19]=v):v=e[19];let k;e[20]!==t.gitBranch||e[21]!==i?(k=t.gitBranch&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(Wr,{className:"size-2.5"}),i?`${t.gitBranch} · ${i}`:t.gitBranch]}),e[20]=t.gitBranch,e[21]=i,e[22]=k):k=e[22];let j;e[23]!==f?(j=f>0&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(To,{className:"size-2.5"}),f," ",f===1?"turn":"turns"]}),e[23]=f,e[24]=j):j=e[24];let _;e[25]!==t.size?(_=b4(t.size),e[25]=t.size,e[26]=_):_=e[26];let N;e[27]!==_?(N=a.jsx("span",{children:_}),e[27]=_,e[28]=N):N=e[28];let S;e[29]!==s?(S=s&&a.jsxs("span",{className:"flex items-center gap-0.5 text-success",children:[a.jsx(d$,{className:"size-2.5"}),s.memMB," MB"]}),e[29]=s,e[30]=S):S=e[30];const C=t.lastActivityAt||t.lastModified;let A;e[31]!==C?(A=Sr(C),e[31]=C,e[32]=A):A=e[32];let T;e[33]!==A?(T=a.jsx("span",{children:A}),e[33]=A,e[34]=T):T=e[34];let I;e[35]!==j||e[36]!==N||e[37]!==S||e[38]!==T||e[39]!==k?(I=a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-muted-foreground",children:[k,j,N,S,T]}),e[35]=j,e[36]=N,e[37]=S,e[38]=T,e[39]=k,e[40]=I):I=e[40];let E;return e[41]!==m||e[42]!==I||e[43]!==p||e[44]!==h||e[45]!==g||e[46]!==x||e[47]!==b||e[48]!==w||e[49]!==v?(E=a.jsxs("div",{className:"flex w-72 flex-col gap-2 text-xs",children:[m,p,h,g,x,b,w,v,I]}),e[41]=m,e[42]=I,e[43]=p,e[44]=h,e[45]=g,e[46]=x,e[47]=b,e[48]=w,e[49]=v,e[50]=E):E=e[50],E}const bhe=120;function Pb(n){const e=q.c(7),t=y.useRef(null);let s,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{t.current&&clearTimeout(t.current)},r=[],e[0]=s,e[1]=r):(s=e[0],r=e[1]),y.useEffect(s,r);let o;e[2]!==n?(o=()=>{n&&(t.current&&clearTimeout(t.current),t.current=setTimeout(n,bhe))},e[2]=n,e[3]=o):o=e[3];const i=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{t.current&&(clearTimeout(t.current),t.current=null)},e[4]=l):l=e[4];const c=l;let u;return e[5]!==i?(u={onHoverStart:i,onHoverEnd:c},e[5]=i,e[6]=u):u=e[6],u}const vhe=6;function yhe(n,e){var s;const t=(s=e.workingCrews)==null?void 0:s.get(n.sessionId);return t?`${t.working} in crew`:OA(n)}function whe(n){const e=q.c(7),{iso:t}=n,[,s]=y.useState(0);let r;e[0]!==s?(r=()=>{const c=setInterval(()=>s(She),15e3);return()=>clearInterval(c)},e[0]=s,e[1]=r):r=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2],y.useEffect(r,o);let i;e[3]!==t?(i=Sr(t),e[3]=t,e[4]=i):i=e[4];let l;return e[5]!==i?(l=a.jsx("span",{"data-relative-time":!0,className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:i}),e[5]=i,e[6]=l):l=e[6],l}function She(n){return n+1}const khe={permission:{label:"Permission",className:"border-warning/30 bg-warning/10 text-warning"},deferred:{label:"Deferred",className:"border-warning/30 bg-warning/10 text-warning"},question:{label:"Question",className:"border-warning/30 bg-warning/10 text-warning"},prompt:{label:"Input needed",className:"border-warning/30 bg-warning/10 text-warning"},plan:{label:"Review plan",className:"border-warning/30 bg-warning/10 text-warning"},waiting:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"},done:{label:"Done",className:"border-success/30 bg-success/10 text-success"},crew:{label:"Waiting",className:"border-warning/30 bg-warning/10 text-warning"}};function jhe({reason:n,crew:e}){const t=khe[n];return n==="crew"&&e?{...t,label:`${e.needsYou} waiting`}:t}const Nhe={permission:Us.attention,deferred:Us.attention,waiting:Us.attention,question:"bg-warning",prompt:"bg-warning",plan:"bg-warning",done:"bg-success",crew:Us.attention};function z3(n){const e=q.c(77),{session:t,chip:s,dotClassName:r,cardClassName:o,since:i,isActiveSession:l,proc:c,killingPids:u,customName:d,projectLabel:f,compact:m,onSelect:p,onKill:h,onResume:g,onPrefetch:x}=n,b=m===void 0?!1:m;let w;e[0]!==c||e[1]!==t.dirName?(w=v0(an(t.dirName),c),e[0]=c,e[1]=t.dirName,e[2]=w):w=e[2];const v=w;let k;e[3]!==s||e[4]!==v||e[5]!==t.agentPendingAgents||e[6]!==t.agentStatus||e[7]!==t.agentTerminalReason||e[8]!==t.agentToolName?(k=v?"Read-only":Rc(t.agentStatus,t.agentToolName,t.agentTerminalReason,t.agentPendingAgents)??s.label,e[3]=s,e[4]=v,e[5]=t.agentPendingAgents,e[6]=t.agentStatus,e[7]=t.agentTerminalReason,e[8]=t.agentToolName,e[9]=k):k=e[9];const j=k,_=!!g&&!v,{onHoverStart:N,onHoverEnd:S}=Pb(x),C=b?"px-2.5 py-2":"border px-2 py-2",A=l&&!b&&"ring-1 ring-ring";let T;e[10]!==o||e[11]!==C||e[12]!==A?(T=G("group relative w-full rounded-md text-left transition-colors",C,o,A),e[10]=o,e[11]=C,e[12]=A,e[13]=T):T=e[13];let I;e[14]!==b||e[15]!==l?(I=b&&l&&a.jsx("span",{className:"absolute inset-y-2 left-0 w-0.5 rounded-full bg-primary","aria-hidden":"true"}),e[14]=b,e[15]=l,e[16]=I):I=e[16];const E=_&&"pr-20";let P;e[17]!==E?(P=G("w-full rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",E),e[17]=E,e[18]=P):P=e[18];let R;e[19]!==S||e[20]!==N||e[21]!==p||e[22]!==P?(R=a.jsx("button",{type:"button","data-attention-session":!0,onClick:p,onMouseEnter:N,onMouseLeave:S,onFocus:N,onBlur:S,className:P}),e[19]=S,e[20]=N,e[21]=p,e[22]=P,e[23]=R):R=e[23];const L=b&&"ring-0";let O;e[24]!==r||e[25]!==L?(O=G("size-1.5 shrink-0 rounded-full",r,L),e[24]=r,e[25]=L,e[26]=O):O=e[26];let $;e[27]!==O?($=a.jsx("span",{className:O,"aria-hidden":"true"}),e[27]=O,e[28]=$):$=e[28];let M;e[29]!==d||e[30]!==t?(M=li(t,d),e[29]=d,e[30]=t,e[31]=M):M=e[31];let D;e[32]!==M?(D=a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-tight text-foreground",children:M}),e[32]=M,e[33]=D):D=e[33];const F=b?"text-muted-foreground":s.className;let z;e[34]!==F?(z=G("shrink-0",F),e[34]=F,e[35]=z):z=e[35];const B=v?"Read-only":s.label;let U;e[36]!==z||e[37]!==B?(U=a.jsx(Ue,{variant:"outline",className:z,children:B}),e[36]=z,e[37]=B,e[38]=U):U=e[38];let W;e[39]!==b||e[40]!==t.lastActivityAt||e[41]!==t.lastModified||e[42]!==i?(W=!b&&a.jsx(whe,{iso:i??(t.lastActivityAt||t.lastModified)}),e[39]=b,e[40]=t.lastActivityAt,e[41]=t.lastModified,e[42]=i,e[43]=W):W=e[43];let V;e[44]!==$||e[45]!==D||e[46]!==U||e[47]!==W?(V=a.jsxs("span",{className:"flex items-center gap-1.5",children:[$,D,U,W]}),e[44]=$,e[45]=D,e[46]=U,e[47]=W,e[48]=V):V=e[48];let H;e[49]!==f?(H=a.jsx("span",{className:"mt-1 block truncate pl-3 text-xs text-muted-foreground",children:f}),e[49]=f,e[50]=H):H=e[50];let K;e[51]!==R||e[52]!==V||e[53]!==H?(K=a.jsxs(Ut,{render:R,children:[V,H]}),e[51]=R,e[52]=V,e[53]=H,e[54]=K):K=e[54];let Z;e[55]!==d||e[56]!==c||e[57]!==t||e[58]!==j?(Z=a.jsx(Bt,{side:"right",className:"max-w-[280px]",children:a.jsx(Ib,{session:t,proc:c,statusLabel:j,customName:d})}),e[55]=d,e[56]=c,e[57]=t,e[58]=j,e[59]=Z):Z=e[59];let Y;e[60]!==K||e[61]!==Z?(Y=a.jsxs(Ft,{children:[K,Z]}),e[60]=K,e[61]=Z,e[62]=Y):Y=e[62];let X;e[63]!==_||e[64]!==g?(X=_&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:g,className:"absolute bottom-1 right-1 text-warning","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]}),e[63]=_,e[64]=g,e[65]=X):X=e[65];let ee;e[66]!==v||e[67]!==u||e[68]!==h||e[69]!==c?(ee=c&&h&&!v&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ne=>h(c.pid,ne),disabled:u.has(c.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${c.pid}`,"aria-label":`Kill process ${c.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[66]=v,e[67]=u,e[68]=h,e[69]=c,e[70]=ee):ee=e[70];let Q;return e[71]!==Y||e[72]!==X||e[73]!==ee||e[74]!==T||e[75]!==I?(Q=a.jsxs("div",{className:T,children:[I,Y,X,ee]}),e[71]=Y,e[72]=X,e[73]=ee,e[74]=T,e[75]=I,e[76]=Q):Q=e[76],Q}function Che(n){const e=q.c(15),{dotClassName:t,labelClassName:s,label:r,count:o}=n;let i;e[0]!==t?(i=G("size-1.5 rounded-full",t),e[0]=t,e[1]=i):i=e[1];let l;e[2]!==i?(l=a.jsx("span",{className:i,"aria-hidden":"true"}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=G("text-xs font-medium",s),e[4]=s,e[5]=c):c=e[5];let u;e[6]!==r||e[7]!==c?(u=a.jsx("span",{className:c,children:r}),e[6]=r,e[7]=c,e[8]=u):u=e[8];let d;e[9]!==o?(d=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[9]=o,e[10]=d):d=e[10];let f;return e[11]!==l||e[12]!==u||e[13]!==d?(f=a.jsxs("div",{className:"flex items-center gap-1.5 px-0.5",children:[l,u,d]}),e[11]=l,e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function _he(n){const e=q.c(28),{groups:t,activeSessionKey:s,procBySession:r,killingPids:o,sessionNames:i,projectNames:l,onSelectSession:c,onKill:u,onResumeSession:d,onPrefetchSession:f}=n,m=jm(),[p,h]=y.useState(!1);let g;e[0]!==t.working||e[1]!==p?(g=p?t.working:t.working.slice(0,vhe),e[0]=t.working,e[1]=p,e[2]=g):g=e[2];const x=g,b=t.working.length-x.length;let w;e[3]!==l?(w=C=>l[C.dirName]||px(C.cwd||ms(C.dirName)),e[3]=l,e[4]=w):w=e[4];const v=w;let k;e[5]!==s||e[6]!==o||e[7]!==u||e[8]!==f||e[9]!==c||e[10]!==m||e[11]!==r||e[12]!==v||e[13]!==i?(k=C=>{const A=s===`${C.dirName}/${C.fileName}`;return{session:C,isActiveSession:A,proc:r.get(C.sessionId),killingPids:o,customName:i[C.sessionId],projectLabel:v(C),onSelect:()=>c(C.dirName,C.fileName),onKill:m(C.access).stop?u:void 0,onPrefetch:f&&!A?()=>f(C.dirName,C.fileName):void 0}},e[5]=s,e[6]=o,e[7]=u,e[8]=f,e[9]=c,e[10]=m,e[11]=r,e[12]=v,e[13]=i,e[14]=k):k=e[14];const j=k;let _;e[15]!==t.needsYou||e[16]!==d||e[17]!==m||e[18]!==j?(_=t.needsYou.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(Che,{dotClassName:Us.attention,labelClassName:"text-warning",label:"Needs you",count:t.needsYou.length}),t.needsYou.map(C=>{var I;const{session:A,reason:T}=C;return a.jsx(z3,{...j(A),chip:jhe(C),since:T==="crew"?(I=C.crew)==null?void 0:I.longestWaitSince:void 0,dotClassName:Nhe[T],cardClassName:"border-warning/20 bg-warning/5 hover:bg-warning/10",onResume:T==="deferred"&&d&&m(A.access).send?()=>d(A.sessionId,A.cwd,A.dirName):void 0},`${A.dirName}/${A.fileName}`)})]}),e[15]=t.needsYou,e[16]=d,e[17]=m,e[18]=j,e[19]=_):_=e[19];let N;e[20]!==t||e[21]!==b||e[22]!==j||e[23]!==x?(N=t.working.length>0&&a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsxs("div",{className:"flex items-center justify-between px-1",children:[a.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Working"}),a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:t.working.length})]}),a.jsx("div",{"data-working-list":!0,className:"flex flex-col gap-0.5 overflow-hidden rounded-lg border bg-background p-0.5",children:x.map(C=>a.jsx(z3,{...j(C),chip:{label:yhe(C,t),className:""},dotClassName:Us.working,cardClassName:"hover:bg-accent/50",compact:!0},`${C.dirName}/${C.fileName}`))}),b>0&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:()=>h(!0),className:"justify-start",children:[a.jsx(Wt,{"data-icon":"inline-start"}),"Show ",b," more"]})]}),e[20]=t,e[21]=b,e[22]=j,e[23]=x,e[24]=N):N=e[24];let S;return e[25]!==_||e[26]!==N?(S=a.jsxs("div",{className:"flex flex-col gap-2","data-attention-strip":!0,children:[_,N]}),e[25]=_,e[26]=N,e[27]=S):S=e[27],S}function Ehe(n){const e=q.c(49),{loading:t,isMobile:s,searchQuery:r,searchLoading:o,showArchived:i,archivedCount:l,groupCrews:c,onToggleGroupCrews:u,onSearchQueryChange:d,onToggleShowArchived:f,onRefresh:m}=n,p=l===0?"No archived sessions":`${l} archived ${l===1?"session":"sessions"}`;let h;e[0]!==d?(h=D=>d(D.target.value),e[0]=d,e[1]=h):h=e[1];let g;e[2]!==o||e[3]!==r||e[4]!==h?(g=a.jsx(Vo,{type:"search",value:r,onChange:h,placeholder:"Search sessions or PRs","aria-label":"Search sessions by project, branch, title, prompt, PR number, or PR URL","aria-busy":o}),e[2]=o,e[3]=r,e[4]=h,e[5]=g):g=e[5];let x;e[6]!==o?(x=a.jsx(jr,{align:"inline-start",children:o?a.jsx(vt,{className:"animate-spin"}):a.jsx(ss,{})}),e[6]=o,e[7]=x):x=e[7];let b;e[8]!==d||e[9]!==r?(b=r&&a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{size:"icon-xs",onClick:()=>d(""),"aria-label":"Clear session search",children:a.jsx(At,{"data-icon":"inline-start"})})}),e[8]=d,e[9]=r,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==x||e[13]!==b?(w=a.jsxs(qo,{children:[g,x,b]}),e[11]=g,e[12]=x,e[13]=b,e[14]=w):w=e[14];let v;e[15]!==c||e[16]!==s||e[17]!==u?(v=u&&a.jsxs(Ft,{children:[a.jsx(Ut,{render:a.jsx(J,{variant:"ghost",size:s?"icon-sm":"icon-xs",onClick:u,"aria-pressed":c,"aria-label":c?"List spawned sessions on their own":"Group spawned sessions",className:G(c&&"bg-accent text-accent-foreground")}),children:a.jsx($j,{"data-icon":"inline-start"})}),a.jsx(Bt,{side:"bottom",children:c?"Sessions another session started are listed under it":"Group spawned sessions under the session that started them"})]}),e[15]=c,e[16]=s,e[17]=u,e[18]=v):v=e[18];const k=s?"icon-sm":"icon-xs",j=i?"Hide archived sessions":"Show archived sessions",_=i&&"bg-accent text-accent-foreground";let N;e[19]!==_?(N=G(_),e[19]=_,e[20]=N):N=e[20];let S;e[21]!==f||e[22]!==i||e[23]!==N||e[24]!==k||e[25]!==j?(S=a.jsx(J,{variant:"ghost",size:k,onClick:f,"aria-pressed":i,"aria-label":j,className:N}),e[21]=f,e[22]=i,e[23]=N,e[24]=k,e[25]=j,e[26]=S):S=e[26];let C;e[27]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(ks,{"data-icon":"inline-start"}),e[27]=C):C=e[27];let A;e[28]!==S?(A=a.jsx(Ut,{render:S,children:C}),e[28]=S,e[29]=A):A=e[29];const T=i?"Hide archived":"Show archived";let I;e[30]!==p||e[31]!==T?(I=a.jsxs(Bt,{side:"bottom",children:[T," · ",p]}),e[30]=p,e[31]=T,e[32]=I):I=e[32];let E;e[33]!==A||e[34]!==I?(E=a.jsxs(Ft,{children:[A,I]}),e[33]=A,e[34]=I,e[35]=E):E=e[35];const P=s?"icon-sm":"icon-xs",R=t&&"animate-spin";let L;e[36]!==R?(L=G(R),e[36]=R,e[37]=L):L=e[37];let O;e[38]!==L?(O=a.jsx(Fn,{"data-icon":"inline-start",className:L}),e[38]=L,e[39]=O):O=e[39];let $;e[40]!==m||e[41]!==P||e[42]!==O?($=a.jsx(J,{variant:"ghost",size:P,onClick:m,"aria-label":"Refresh sessions",children:O}),e[40]=m,e[41]=P,e[42]=O,e[43]=$):$=e[43];let M;return e[44]!==E||e[45]!==$||e[46]!==w||e[47]!==v?(M=a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-2.5 py-2",children:[w,v,E,$]}),e[44]=E,e[45]=$,e[46]=w,e[47]=v,e[48]=M):M=e[48],M}const The=["first","second","third","fourth","fifth"];function Ahe(n){const e=q.c(33),{fetchError:t,showEmpty:s,searching:r,loading:o,sessionCount:i,hiddenArchivedCount:l,focusedProject:c,onShowAllProjects:u,filterEmpty:d,onShowArchived:f,onRetry:m}=n,p=c===void 0?null:c,h=d===void 0?null:d,g=!!h;let x;e[0]!==p||e[1]!==l||e[2]!==r||e[3]!==s||e[4]!==g?(x=Phe({showEmpty:s,searching:r,focusedProject:p,hiddenArchivedCount:l,filtered:g}),e[0]=p,e[1]=l,e[2]=r,e[3]=s,e[4]=g,e[5]=x):x=e[5];const b=x;let w;e[6]!==t||e[7]!==m?(w=t&&a.jsxs(wt,{variant:"destructive",children:[a.jsx(_r,{}),a.jsx(Vt,{children:"Could not load sessions"}),a.jsx(_t,{className:"truncate",children:t}),a.jsx(Ao,{children:a.jsx(J,{variant:"outline",size:"xs",onClick:m,children:"Retry"})})]}),e[6]=t,e[7]=m,e[8]=w):w=e[8];let v;e[9]!==b||e[10]!==l||e[11]!==f?(v=b==="archived"&&a.jsxs(Cn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(ks,{})}),a.jsx(En,{children:"Everything is archived"}),a.jsx(Tn,{children:l===1?"1 archived session is hidden.":`${l} archived sessions are hidden.`})]}),a.jsxs(J,{variant:"outline",size:"sm",onClick:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),"Show archived"]})]}),e[9]=b,e[10]=l,e[11]=f,e[12]=v):v=e[12];let k;e[13]!==b||e[14]!==p||e[15]!==l||e[16]!==u||e[17]!==f||e[18]!==r?(k=b==="focused"&&a.jsxs(Cn,{className:"min-h-56 px-4 py-8",children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(ag,{})}),a.jsx(En,{children:r?`No matching sessions in ${p}`:`No sessions in ${p}`}),a.jsx(Tn,{children:$he(r,l)})]}),a.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[a.jsxs(J,{variant:"outline",size:"sm",onClick:u,children:[a.jsx(hd,{"data-icon":"inline-start"}),"All projects"]}),!r&&l>0&&a.jsxs(J,{variant:"ghost",size:"sm",onClick:f,children:[a.jsx(ks,{"data-icon":"inline-start"}),"Show archived"]})]})]}),e[13]=b,e[14]=p,e[15]=l,e[16]=u,e[17]=f,e[18]=r,e[19]=k):k=e[19];const j=b==="filtered"&&h;let _;e[20]!==b||e[21]!==r?(_=b==="plain"&&a.jsx(Cn,{className:"min-h-56 px-4 py-8",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:r?a.jsx(ss,{}):a.jsx(ag,{})}),a.jsx(En,{children:r?"No matching sessions":"No sessions yet"}),a.jsx(Tn,{children:r?"Try #157, honest-cms #157, or paste a PR URL.":"Start Claude Code, Codex, or Copilot to see recent work here."})]})}),e[20]=b,e[21]=r,e[22]=_):_=e[22];let N;e[23]!==o||e[24]!==i?(N=o&&i===0&&a.jsx("div",{className:"flex flex-col gap-2 px-2 py-4","aria-label":"Loading sessions",children:The.map(Ihe)}),e[23]=o,e[24]=i,e[25]=N):N=e[25];let S;return e[26]!==N||e[27]!==w||e[28]!==v||e[29]!==k||e[30]!==j||e[31]!==_?(S=a.jsxs(a.Fragment,{children:[w,v,k,j,_,N]}),e[26]=N,e[27]=w,e[28]=v,e[29]=k,e[30]=j,e[31]=_,e[32]=S):S=e[32],S}function Ihe(n){return a.jsxs("div",{className:"flex items-center gap-2 py-1",children:[a.jsx(Gn,{className:"size-2 shrink-0 rounded-full"}),a.jsx(Gn,{className:"h-4 flex-1"}),a.jsx(Gn,{className:"h-4 w-10"})]},n)}function Phe({showEmpty:n,searching:e,focusedProject:t,hiddenArchivedCount:s,filtered:r}){return n?t!==null?"focused":!e&&s>0?"archived":!e&&r?"filtered":"plain":null}function $he(n,e){return n?"Try another search, or look across every project.":e>0?"Its sessions may be archived. Start a new one, or look across every project.":"Start a new session here, or look across every project."}const Yh=864e5;function Rhe(n){const e=new Date(n);return e.setHours(0,0,0,0),e.getTime()}function Ohe(n,e=Date.now()){const t=Date.parse(n);if(!Number.isFinite(t))return"Older";const s=Rhe(e);return t>=s?"Today":t>=s-Yh?"Yesterday":t>=s-6*Yh?"Last 7 days":t>=s-29*Yh?"Last 30 days":"Older"}const Lhe=6,Mhe={permission:"permission",question:"question",input:"input",plan:"plan",deferred:"deferred"},D3={"needs-you":0,working:1,done:2};function zhe(n){const e=q.c(39),{host:t,members:s,counts:r,statusOf:o,open:i,onToggle:l,sessionNames:c,activeSessionKey:u,onSelectSession:d}=n,[f,m]=y.useState(!1);let p;if(e[0]!==u||e[1]!==r.needsYou||e[2]!==r.size||e[3]!==r.working||e[4]!==t||e[5]!==s||e[6]!==d||e[7]!==l||e[8]!==i||e[9]!==c||e[10]!==f||e[11]!==o){const h=new Map([t,...s].map(Dhe)),g=$=>!$.crew||$.crew.parentId===t.sessionId||!h.has($.crew.parentId);let x;e[13]!==g||e[14]!==o?(x=$=>g($)||o($).state==="needs-you",e[13]=g,e[14]=o,e[15]=x):x=e[15];const b=s.filter(x);let w;e[16]!==o?(w=($,M)=>D3[o($).state]-D3[o(M).state]||(o($).state==="done"?vr(M)-vr($):0),e[16]=o,e[17]=w):w=e[17];const v=[...b].sort(w);let k;e[18]!==o?(k=$=>o($).state==="done",e[18]=o,e[19]=k):k=e[19];const j=v.filter(k),_=f?[]:j.slice(Lhe),N=v.filter($=>!_.includes($)),S=`Crew of ${r.size}${r.needsYou?`, ${r.needsYou} need you`:""}${r.working?`, ${r.working} working`:""}`,C=i?`Hide crew: ${S}`:`Show crew: ${S}`,A=i&&"rotate-90";let T;e[20]!==A?(T=G("size-3 shrink-0 transition-transform duration-150",A),e[20]=A,e[21]=T):T=e[21];let I;e[22]!==T?(I=a.jsx(it,{className:T,"aria-hidden":"true"}),e[22]=T,e[23]=I):I=e[23];let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx("span",{className:"font-medium text-foreground",children:"Crew"}),e[24]=E):E=e[24];let P;e[25]!==r.size?(P=a.jsxs("span",{className:"tabular-nums",children:["· ",r.size]}),e[25]=r.size,e[26]=P):P=e[26];let R;e[27]!==r.needsYou?(R=r.needsYou>0&&a.jsxs("span",{className:"tabular-nums text-warning",children:["· ",r.needsYou," need you"]}),e[27]=r.needsYou,e[28]=R):R=e[28];let L;e[29]!==r.working?(L=r.working>0&&a.jsxs("span",{className:"tabular-nums",children:["· ",r.working," working"]}),e[29]=r.working,e[30]=L):L=e[30];let O;e[31]!==l||e[32]!==i||e[33]!==P||e[34]!==R||e[35]!==L||e[36]!==C||e[37]!==I?(O=a.jsxs("button",{type:"button",onClick:l,"aria-expanded":i,"aria-label":C,className:"flex w-full items-center gap-1.5 rounded-sm py-0.5 text-left text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[I,E,P,R,L]}),e[31]=l,e[32]=i,e[33]=P,e[34]=R,e[35]=L,e[36]=C,e[37]=I,e[38]=O):O=e[38],p=a.jsxs("div",{"data-crew-fold":!0,className:"mx-3 mb-2 ml-[26px] border-t border-border/60 pt-1.5",children:[O,i&&a.jsxs("ul",{className:"mt-1 ml-1.5 flex flex-col gap-px border-l border-border/70 pl-1.5",children:[N.map($=>{var H;const M=o($),D=iR($.sessionId,s),F=$.crew?h.get($.crew.parentId):void 0,z=u===`${$.dirName}/${$.fileName}`,B=jd($,{customName:c[$.sessionId],parent:F??t}),U=Uhe($,M),V=(!g($)&&F?` · via ${jd(F,{customName:c[F.sessionId],parent:h.get(((H=F.crew)==null?void 0:H.parentId)??"")??t})}`:"")||(D>0?` · ${D} ${D===1?"session":"sessions"}`:"");return a.jsx("li",{children:a.jsxs("button",{type:"button","data-crew-member":$.sessionId,"aria-current":z?"true":void 0,"aria-label":`${B}${V}, ${U}`,onClick:()=>d($.dirName,$.fileName),className:G("flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",z&&"bg-accent"),children:[a.jsx("span",{className:G("size-1.5 shrink-0 rounded-full",Fhe(M)),"aria-hidden":"true"}),a.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[B,V&&a.jsx("span",{className:"text-muted-foreground/70",children:V})]}),a.jsx("span",{className:G("shrink-0 text-[11px] tabular-nums",M.state==="needs-you"?"text-warning":"text-muted-foreground/80"),children:U})]})},$.sessionId)}),_.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>m(!0),className:"rounded-sm px-1.5 py-1 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:["Show ",_.length," more done"]})})]})]}),e[0]=u,e[1]=r.needsYou,e[2]=r.size,e[3]=r.working,e[4]=t,e[5]=s,e[6]=d,e[7]=l,e[8]=i,e[9]=c,e[10]=f,e[11]=o,e[12]=p}else p=e[12];return p}function Dhe(n){return[n.sessionId,n]}function Fhe({state:n}){return n==="needs-you"?Us.attention:n==="working"?Us.working:"bg-muted-foreground/50"}function Uhe(n,{state:e,need:t}){var o;const s=Sr(n.lastActivityAt||n.lastModified);if(e==="needs-you")return`${Mhe[t??"input"]} · ${s}`;if(e==="working")return OA(n);const r=(o=n.pullRequests)==null?void 0:o.at(-1);return r?`#${r.number} · ${s}`:s}const Bhe={};function Whe(n){var $r,wn;const e=q.c(172),{session:t,projectLabel:s,projectPath:r,showProject:o,isActiveSession:i,proc:l,killingPids:c,isNewlyCompleted:u,customName:d,worktreeName:f,teammateCount:m,teammatesCollapsed:p,onToggleTeammates:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:_,onResumeSession:N,crew:S,lineage:C,sessionNames:A,activeSessionKey:T}=n,I=A===void 0?Bhe:A,E=T===void 0?null:T,{isLive:P,isRunning:R,isNativeIdle:L,isDeferred:O,isReadOnly:$,isTeammate:M,isArchived:D,statusLabel:F,dotState:z,justFinished:B}=y0(t,l,u),[U,W]=y.useState(!1);let V;e[0]!==d||e[1]!==t?(V=w4(t,d),e[0]=d,e[1]=t,e[2]=V):V=e[2];const H=V,K=Y8(t,d),Z=o&&!C?s:void 0,Y=qhe(S==null?void 0:S.counts,z),X=S!==void 0&&Date.parse(S.activityAt)>vr(t),ee=t.lastUserMessage||t.firstUserMessage,Q=!!ee&&ee!==H,ne=MA(t.sessionId,t.turnCount);let te;e[3]!==t.archivedReason?(te=hx(t.archivedReason),e[3]=t.archivedReason,e[4]=te):te=e[4];const re=te,oe=D?k&&{label:"Restore from archive",icon:gf,run:()=>k(t)}:v&&!R&&{label:"Archive session",icon:ks,run:()=>v(t)},ie=O&&!!N&&!$,ae=!!m&&!!h,de=!!t.matchedPullRequestNumber||!!(($r=t.pullRequests)!=null&&$r.length),le=ie||ae||de;let se;e[5]!==i||e[6]!==_||e[7]!==t.dirName||e[8]!==t.fileName?(se=_&&!i?()=>_(t.dirName,t.fileName):void 0,e[5]=i,e[6]=_,e[7]=t.dirName,e[8]=t.fileName,e[9]=se):se=e[9];const{onHoverStart:me,onHoverEnd:ue}=Pb(se);let ce;e[10]!==N||e[11]!==U||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(ce=()=>{!N||U||(W(!0),N(t.sessionId,t.cwd,t.dirName),setTimeout(()=>W(!1),3e3))},e[10]=N,e[11]=U,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=ce):ce=e[15];const xe=ce,pe=!0,he=D||void 0,be=G("motion-list-item group relative flex flex-col rounded-lg border transition-colors",Vhe(i,B),D&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let we;e[16]!==C?(we=C&&a.jsxs("button",{type:"button","data-crew-lineage":!0,onClick:C.onOpenParent,"aria-label":`Open ${C.parentTitle}, which started this session`,className:"flex min-w-0 items-center gap-1.5 rounded-t-lg px-3 pl-[26px] pt-2.5 text-left text-[11px] leading-tight outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[a.jsx(H1,{className:"size-3 shrink-0 text-muted-foreground","aria-hidden":"true"}),a.jsx("span",{className:"truncate text-foreground/90",children:C.parentTitle}),C.rootTitle&&a.jsxs("span",{className:"truncate text-muted-foreground",children:["· ",C.rootTitle]})]}),e[16]=C,e[17]=we):we=e[17];let ve;e[18]!==g||e[19]!==t.dirName||e[20]!==t.fileName?(ve=()=>g(t.dirName,t.fileName),e[18]=g,e[19]=t.dirName,e[20]=t.fileName,e[21]=ve):ve=e[21];const Se=i?"true":void 0,Te=C?"pt-1":"pt-2.5",Ae=le||S?"pb-1.5":"pb-2.5";let ze;e[22]!==Te||e[23]!==Ae?(ze=G("flex w-full flex-col gap-1.5 rounded-lg px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",Te,Ae),e[22]=Te,e[23]=Ae,e[24]=ze):ze=e[24];let De;e[25]!==ue||e[26]!==me||e[27]!==ve||e[28]!==Se||e[29]!==ze?(De=a.jsx("button",{type:"button","data-live-session":!0,onClick:ve,onMouseEnter:me,onMouseLeave:ue,onFocus:me,onBlur:ue,"aria-current":Se,className:ze}),e[25]=ue,e[26]=me,e[27]=ve,e[28]=Se,e[29]=ze,e[30]=De):De=e[30];let Le;e[31]!==Z||e[32]!==r?(Le=Z&&a.jsxs("span",{"data-session-project":!0,className:"flex items-center gap-1.5 pl-3.5 text-[11px] leading-tight text-muted-foreground",children:[a.jsx(ha,{projectPath:r,fallback:a.jsx(Qi,{className:"size-3 shrink-0","aria-hidden":"true"}),className:"size-3"}),a.jsx("span",{className:"truncate",children:Z})]}),e[31]=Z,e[32]=r,e[33]=Le):Le=e[33];let Ce;e[34]!==Y?(Ce=Y&&a.jsx("span",{"data-status-dot":Y,className:G("size-1.5 rounded-full",Us[Y])}),e[34]=Y,e[35]=Ce):Ce=e[35];let Be;e[36]!==Ce?(Be=a.jsx("span",{className:"mt-[7px] flex w-1.5 shrink-0 justify-center","aria-hidden":"true",children:Ce}),e[36]=Ce,e[37]=Be):Be=e[37];const We=K?"text-muted-foreground":"font-medium text-foreground";let He;e[38]!==We?(He=G("line-clamp-2 flex-1 text-sm leading-snug",We),e[38]=We,e[39]=He):He=e[39];let _e;e[40]!==H||e[41]!==He?(_e=a.jsx("span",{className:He,children:H}),e[40]=H,e[41]=He,e[42]=_e):_e=e[42];let Re;e[43]!==Be||e[44]!==_e?(Re=a.jsxs("span",{className:"flex items-start gap-2",children:[Be,_e]}),e[43]=Be,e[44]=_e,e[45]=Re):Re=e[45];let tt;e[46]!==ee||e[47]!==Q?(tt=Q&&a.jsx("span",{className:"line-clamp-2 pl-3.5 text-xs leading-relaxed text-muted-foreground",children:ee}),e[46]=ee,e[47]=Q,e[48]=tt):tt=e[48];let Xe;e[49]!==O||e[50]!==P||e[51]!==L||e[52]!==t.agentStatus||e[53]!==F?(Xe=P&&!O&&F&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G(L?"text-success":Xf(t.agentStatus)),children:F}),e[49]=O,e[50]=P,e[51]=L,e[52]=t.agentStatus,e[53]=F,e[54]=Xe):Xe=e[54];let Ne;e[55]!==O?(Ne=O&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[55]=O,e[56]=Ne):Ne=e[56];let Ve;e[57]!==H||e[58]!==M||e[59]!==t.agentName?(Ve=M&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(ea,{"data-icon":"inline-start"}),H!==t.agentName?t.agentName:"Agent"]}),e[57]=H,e[58]=M,e[59]=t.agentName,e[60]=Ve):Ve=e[60];let ye;e[61]!==t.access?(ye=a.jsx(_A,{access:t.access}),e[61]=t.access,e[62]=ye):ye=e[62];let $e;e[63]!==f?($e=f&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(Wr,{"data-icon":"inline-start"}),f]}),e[63]=f,e[64]=$e):$e=e[64];let qe;e[65]!==t.gitBranch||e[66]!==f?(qe=t.gitBranch&&!f&&a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx(Wr,{className:"size-3 shrink-0","aria-hidden":"true"}),a.jsx("span",{className:"truncate",children:t.gitBranch})]}),e[65]=t.gitBranch,e[66]=f,e[67]=qe):qe=e[67];let Ke;e[68]!==ne?(Ke=ne>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(To,{className:"size-3 shrink-0","aria-hidden":"true"}),ne," ",ne===1?"turn":"turns"]}),e[68]=ne,e[69]=Ke):Ke=e[69];let fe;e[70]!==re||e[71]!==D?(fe=D&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(ks,{className:"size-3 shrink-0","aria-label":re,role:"img"}),"Archived"]}),e[70]=re,e[71]=D,e[72]=fe):fe=e[72];let ke;e[73]!==S||e[74]!==X||e[75]!==t?(ke=X?a.jsxs("span",{"data-crew-activity":!0,className:G("ml-auto tabular-nums",S4({...t,lastActivityAt:S.activityAt})&&"text-success"),children:["crew active ",Sr(S.activityAt)]}):a.jsx("span",{className:"ml-auto tabular-nums",children:Sr(t.lastActivityAt||t.lastModified)}),e[73]=S,e[74]=X,e[75]=t,e[76]=ke):ke=e[76];let Ge;e[77]!==Xe||e[78]!==Ne||e[79]!==Ve||e[80]!==ye||e[81]!==$e||e[82]!==qe||e[83]!==Ke||e[84]!==fe||e[85]!==ke?(Ge=a.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 pl-3.5 text-[11px] text-muted-foreground",children:[Xe,Ne,Ve,ye,$e,qe,Ke,fe,ke]}),e[77]=Xe,e[78]=Ne,e[79]=Ve,e[80]=ye,e[81]=$e,e[82]=qe,e[83]=Ke,e[84]=fe,e[85]=ke,e[86]=Ge):Ge=e[86];let Je;e[87]!==De||e[88]!==Le||e[89]!==Re||e[90]!==tt||e[91]!==Ge?(Je=a.jsxs(Ut,{render:De,children:[Le,Re,tt,Ge]}),e[87]=De,e[88]=Le,e[89]=Re,e[90]=tt,e[91]=Ge,e[92]=Je):Je=e[92];const rt=Z?void 0:s;let Kt;e[93]!==d||e[94]!==l||e[95]!==t||e[96]!==F||e[97]!==rt||e[98]!==f?(Kt=a.jsx(Bt,{side:"right",className:"max-w-[320px]",children:a.jsx(Ib,{session:t,proc:l,statusLabel:F,customName:d,worktreeName:f,projectLabel:rt})}),e[93]=d,e[94]=l,e[95]=t,e[96]=F,e[97]=rt,e[98]=f,e[99]=Kt):Kt=e[99];let pn;e[100]!==Je||e[101]!==Kt?(pn=a.jsxs(Ft,{children:[Je,Kt]}),e[100]=Je,e[101]=Kt,e[102]=pn):pn=e[102];let $n;e[103]!==ie||e[104]!==xe||e[105]!==le||e[106]!==ae||e[107]!==h||e[108]!==U||e[109]!==t.matchedPullRequestNumber||e[110]!==t.pullRequests||e[111]!==m||e[112]!==p?($n=le&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pl-[26px]",children:[t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:2,compact:!0}),ae&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:h,"aria-expanded":!p,"aria-label":p?`Show ${m} team agents`:`Hide ${m} team agents`,children:[a.jsx(Zs,{"data-icon":"inline-start"}),m,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!p&&"rotate-90")})]}),ie&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:xe,disabled:U,className:"text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]})]}),e[103]=ie,e[104]=xe,e[105]=le,e[106]=ae,e[107]=h,e[108]=U,e[109]=t.matchedPullRequestNumber,e[110]=t.pullRequests,e[111]=m,e[112]=p,e[113]=$n):$n=e[113];let Xn;e[114]!==E||e[115]!==S||e[116]!==g||e[117]!==t||e[118]!==I?(Xn=S&&a.jsx(zhe,{host:t,members:S.members,counts:S.counts,statusOf:S.statusOf,open:S.open,onToggle:S.onToggle,sessionNames:I,activeSessionKey:E,onSelectSession:g}),e[114]=E,e[115]=S,e[116]=g,e[117]=t,e[118]=I,e[119]=Xn):Xn=e[119];let Rn;e[120]!==oe||e[121]!==S?(Rn=oe&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:oe.run,className:G("absolute right-1.5 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",S?"top-1.5":"bottom-1.5"),title:oe.label,"aria-label":oe.label,children:a.jsx(oe.icon,{"data-icon":"inline-start"})}),e[120]=oe,e[121]=S,e[122]=Rn):Rn=e[122];let On;e[123]!==S||e[124]!==D||e[125]!==$||e[126]!==R||e[127]!==c||e[128]!==x||e[129]!==l?(On=l&&x&&R&&!D&&!$&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:Es=>x(l.pid,Es),disabled:c.has(l.pid),className:G("absolute right-1.5 bg-popover text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",S?"top-1.5":"bottom-1.5"),title:`Kill PID ${l.pid}`,"aria-label":`Kill process ${l.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[123]=S,e[124]=D,e[125]=$,e[126]=R,e[127]=c,e[128]=x,e[129]=l,e[130]=On):On=e[130];let Jn;e[131]!==we||e[132]!==pn||e[133]!==$n||e[134]!==Xn||e[135]!==Rn||e[136]!==On||e[137]!==he||e[138]!==be?(Jn=a.jsxs("div",{"data-session-card":pe,"data-archived":he,className:be,children:[we,pn,$n,Xn,Rn,On]}),e[131]=we,e[132]=pn,e[133]=$n,e[134]=Xn,e[135]=Rn,e[136]=On,e[137]=he,e[138]=be,e[139]=Jn):Jn=e[139];const hn=Jn;if(b||w||j||v||k){let Es;e[140]!==t.firstUserMessage||e[141]!==t.sessionId||e[142]!==t.slug?(Es=t.slug||((wn=t.firstUserMessage)==null?void 0:wn.slice(0,30))||t.sessionId.slice(0,12),e[140]=t.firstUserMessage,e[141]=t.sessionId,e[142]=t.slug,e[143]=Es):Es=e[143];let Ts;e[144]!==b||e[145]!==t.dirName||e[146]!==t.fileName?(Ts=b?()=>b(t.dirName,t.fileName):void 0,e[144]=b,e[145]=t.dirName,e[146]=t.fileName,e[147]=Ts):Ts=e[147];let nr;e[148]!==w||e[149]!==t?(nr=w?()=>w(t):void 0,e[148]=w,e[149]=t,e[150]=nr):nr=e[150];let sr;e[151]!==j||e[152]!==t.sessionId?(sr=j?za=>j(t.sessionId,za):void 0,e[151]=j,e[152]=t.sessionId,e[153]=sr):sr=e[153];let gs;e[154]!==D||e[155]!==v||e[156]!==t?(gs=v&&!D?()=>v(t):void 0,e[154]=D,e[155]=v,e[156]=t,e[157]=gs):gs=e[157];let rr;e[158]!==D||e[159]!==k||e[160]!==t?(rr=k&&D?()=>k(t):void 0,e[158]=D,e[159]=k,e[160]=t,e[161]=rr):rr=e[161];let vi;return e[162]!==hn||e[163]!==d||e[164]!==R||e[165]!==Es||e[166]!==Ts||e[167]!==nr||e[168]!==sr||e[169]!==gs||e[170]!==rr?(vi=a.jsx(Tb,{sessionLabel:Es,customName:d,onDuplicate:Ts,onDelete:nr,onRename:sr,onArchive:gs,onUnarchive:rr,archiveDisabled:R,children:hn}),e[162]=hn,e[163]=d,e[164]=R,e[165]=Es,e[166]=Ts,e[167]=nr,e[168]=sr,e[169]=gs,e[170]=rr,e[171]=vi):vi=e[171],vi}return hn}function qhe(n,e){return n?n.needsYou>0||e==="attention"?"attention":n.working>0?"working":e:e}function Vhe(n,e){return n?"border-foreground/15 bg-accent":e?"border-success/30 bg-success/10":"border-border/70 bg-card hover:border-border hover:bg-accent"}function Hhe(n){var ue;const e=q.c(87),{session:t,isActiveSession:s,proc:r,killingPids:o,isNewlyCompleted:i,customName:l,worktreeName:c,teammateCount:u,teammatesCollapsed:d,onToggleTeammates:f,onSelectSession:m,onKill:p,onDuplicateSession:h,onDeleteSession:g,onArchiveSession:x,onUnarchiveSession:b,onRenameSession:w,onPrefetchSession:v,onResumeSession:k}=n,{isLive:j,isRunning:_,isNativeIdle:N,isDeferred:S,isReadOnly:C,isTeammate:A,isArchived:T,statusLabel:I,dotState:E,justFinished:P}=y0(t,r,i),[R,L]=y.useState(!1);let O;e[0]!==t.archivedReason?(O=hx(t.archivedReason),e[0]=t.archivedReason,e[1]=O):O=e[1];const $=O;let M;e[2]!==l||e[3]!==t?(M=li(t,l),e[2]=l,e[3]=t,e[4]=M):M=e[4];const D=M,F=T?b&&{label:"Restore from archive",icon:gf,run:()=>b(t)}:x&&!_&&{label:"Archive session",icon:ks,run:()=>x(t)};let z;e[5]!==s||e[6]!==v||e[7]!==t.dirName||e[8]!==t.fileName?(z=v&&!s?()=>v(t.dirName,t.fileName):void 0,e[5]=s,e[6]=v,e[7]=t.dirName,e[8]=t.fileName,e[9]=z):z=e[9];const{onHoverStart:B,onHoverEnd:U}=Pb(z);let W;e[10]!==k||e[11]!==R||e[12]!==t.cwd||e[13]!==t.dirName||e[14]!==t.sessionId?(W=ce=>{ce.stopPropagation(),!(!k||R)&&(L(!0),k(t.sessionId,t.cwd,t.dirName),setTimeout(()=>L(!1),3e3))},e[10]=k,e[11]=R,e[12]=t.cwd,e[13]=t.dirName,e[14]=t.sessionId,e[15]=W):W=e[15];const V=W,H=G("motion-list-item group relative flex min-h-9 w-full items-center gap-1.5 rounded-md px-2.5 py-2 transition-colors",Khe(s,P),T&&"opacity-60 hover:opacity-100 focus-within:opacity-100");let K;e[16]!==m||e[17]!==t.dirName||e[18]!==t.fileName?(K=()=>m(t.dirName,t.fileName),e[16]=m,e[17]=t.dirName,e[18]=t.fileName,e[19]=K):K=e[19];let Z;e[20]!==U||e[21]!==B||e[22]!==K?(Z=a.jsx("button",{type:"button","data-live-session":!0,onClick:K,onMouseEnter:B,onMouseLeave:U,onFocus:B,onBlur:U,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e[20]=U,e[21]=B,e[22]=K,e[23]=Z):Z=e[23];let Y;e[24]!==D?(Y=a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:D}),e[24]=D,e[25]=Y):Y=e[25];let X;e[26]!==S?(X=S&&a.jsx(Ue,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"deferred"}),e[26]=S,e[27]=X):X=e[27];let ee;e[28]!==c?(ee=c&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(Wr,{"data-icon":"inline-start"}),c]}),e[28]=c,e[29]=ee):ee=e[29];let Q;e[30]!==l||e[31]!==r||e[32]!==t||e[33]!==I||e[34]!==c?(Q=a.jsx(Bt,{side:"right",className:"max-w-[280px]",children:a.jsx(Ib,{session:t,proc:r,statusLabel:I,customName:l,worktreeName:c})}),e[30]=l,e[31]=r,e[32]=t,e[33]=I,e[34]=c,e[35]=Q):Q=e[35];let ne;e[36]!==f||e[37]!==u||e[38]!==d?(ne=!!u&&f&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:f,className:"shrink-0",title:d?"Show team agents":"Hide team agents","aria-label":d?`Show ${u} team agents`:`Hide ${u} team agents`,"aria-expanded":!d,children:[a.jsx(Zs,{"data-icon":"inline-start"}),u,a.jsx(it,{"data-icon":"inline-end",className:G("transition-transform duration-150",!d&&"rotate-90")})]}),e[36]=f,e[37]=u,e[38]=d,e[39]=ne):ne=e[39];let te;e[40]!==V||e[41]!==S||e[42]!==C||e[43]!==k||e[44]!==R?(te=S&&k&&!C&&a.jsxs(J,{type:"button",variant:"outline",size:"xs",onClick:V,disabled:R,className:"shrink-0 text-warning",title:"Resume to evaluate deferred permission","aria-label":"Resume to evaluate",children:[a.jsx(va,{"data-icon":"inline-start"}),"Resume"]}),e[40]=V,e[41]=S,e[42]=C,e[43]=k,e[44]=R,e[45]=te):te=e[45];let re;e[46]!==t.matchedPullRequestNumber||e[47]!==t.pullRequests?(re=t.matchedPullRequestNumber?a.jsxs(Ue,{variant:"outline",className:"shrink-0 px-1",children:["Matched #",t.matchedPullRequestNumber]}):a.jsx(zc,{pullRequests:t.pullRequests,max:1,compact:!0}),e[46]=t.matchedPullRequestNumber,e[47]=t.pullRequests,e[48]=re):re=e[48];let oe;e[49]!==$||e[50]!==T?(oe=T&&a.jsx(ks,{className:"size-3 shrink-0 text-muted-foreground","aria-label":$,role:"img"}),e[49]=$,e[50]=T,e[51]=oe):oe=e[51];const ie=t.lastActivityAt||t.lastModified;let ae;e[52]!==ie?(ae=Sr(ie),e[52]=ie,e[53]=ae):ae=e[53];let de;e[54]!==ae?(de=a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:ae}),e[54]=ae,e[55]=de):de=e[55];let le;e[56]!==F?(le=F&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>{ce.stopPropagation(),F.run()},className:"absolute right-0 top-0 bg-popover text-muted-foreground opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 hover:text-foreground",title:F.label,"aria-label":F.label,children:a.jsx(F.icon,{"data-icon":"inline-start"})}),e[56]=F,e[57]=le):le=e[57];let se;e[58]!==T||e[59]!==C||e[60]!==_||e[61]!==o||e[62]!==p||e[63]!==r?(se=r&&p&&_&&!T&&!C&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-xs",onClick:ce=>p(r.pid,ce),disabled:o.has(r.pid),className:"absolute right-0 top-0 text-destructive opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",title:`Kill PID ${r.pid}`,"aria-label":`Kill process ${r.pid}`,children:a.jsx(At,{"data-icon":"inline-start"})}),e[58]=T,e[59]=C,e[60]=_,e[61]=o,e[62]=p,e[63]=r,e[64]=se):se=e[64];const me=a.jsxs("div",{className:H,"data-archived":T||void 0,children:[a.jsxs(Ft,{children:[a.jsxs(Ut,{render:Z,children:[a.jsx("span",{className:"flex w-1.5 shrink-0 items-center justify-center","aria-hidden":"true",children:E&&a.jsx("span",{"data-status-dot":E,className:G("size-1.5 rounded-full",Us[E])})}),Y,A&&a.jsxs(Ue,{variant:"outline",children:[a.jsx(ea,{"data-icon":"inline-start"}),D!==t.agentName?t.agentName:"Agent"]}),j&&!S&&I&&a.jsx(Ue,{variant:"secondary","data-session-live-state":!0,className:G("shrink-0",N&&"text-success",!N&&Xf(t.agentStatus)),children:I}),X,ee]}),Q]}),ne,te,re,oe,de,le,se]});if(h||g||w||x||b){let ce;e[65]!==t.firstUserMessage||e[66]!==t.sessionId||e[67]!==t.slug?(ce=t.slug||((ue=t.firstUserMessage)==null?void 0:ue.slice(0,30))||t.sessionId.slice(0,12),e[65]=t.firstUserMessage,e[66]=t.sessionId,e[67]=t.slug,e[68]=ce):ce=e[68];let xe;e[69]!==h||e[70]!==t.dirName||e[71]!==t.fileName?(xe=h?()=>h(t.dirName,t.fileName):void 0,e[69]=h,e[70]=t.dirName,e[71]=t.fileName,e[72]=xe):xe=e[72];let pe;e[73]!==g||e[74]!==t?(pe=g?()=>g(t):void 0,e[73]=g,e[74]=t,e[75]=pe):pe=e[75];let he;e[76]!==w||e[77]!==t.sessionId?(he=w?ve=>w(t.sessionId,ve):void 0,e[76]=w,e[77]=t.sessionId,e[78]=he):he=e[78];let be;e[79]!==T||e[80]!==x||e[81]!==t?(be=x&&!T?()=>x(t):void 0,e[79]=T,e[80]=x,e[81]=t,e[82]=be):be=e[82];let we;return e[83]!==T||e[84]!==b||e[85]!==t?(we=b&&T?()=>b(t):void 0,e[83]=T,e[84]=b,e[85]=t,e[86]=we):we=e[86],a.jsx(Tb,{sessionLabel:ce,customName:l,onDuplicate:xe,onDelete:pe,onRename:he,onArchive:be,onUnarchive:we,archiveDisabled:_,children:me})}return me}function Khe(n,e){return n?"bg-accent":e?"bg-success/10":"hover:bg-accent/60"}const Ghe={state:"done"};function Zhe(n){const e=q.c(84),{sessions:t,pendingSession:s,older:r,showProject:o,groupCrews:i,lineageSessions:l,memberStatusOf:c,activeSessionKey:u,procBySession:d,killingPids:f,newlyCompleted:m,sessionNames:p,projectNames:h,onSelectSession:g,onKill:x,onDuplicateSession:b,onDeleteSession:w,onArchiveSession:v,onUnarchiveSession:k,onRenameSession:j,onPrefetchSession:_,onResumeSession:N}=n,S=i===void 0?!0:i,C=c===void 0?Xhe:c,A=jm();let T,I,E,P;if(e[0]!==S||e[1]!==t){T=S?bx(t):{topLevel:t,crewOf:new Map},I=X8(T.topLevel);const ue=he=>{const be=T.crewOf.get(he.sessionId);return be?ay(he,be):he.lastActivityAt||he.lastModified},ce=new Map(I.topLevelSessions.map(he=>[{...he,lastActivityAt:ue(he)},he]));P=ja([...ce.keys()]).map(he=>ce.get(he));const xe=Date.now(),pe=P.map(he=>Ohe(ue(he),xe));E=pe.map((he,be)=>he===pe[be-1]?null:he),e[0]=S,e[1]=t,e[2]=T,e[3]=I,e[4]=E,e[5]=P}else T=e[2],I=e[3],E=e[4],P=e[5];const R=E;let L;e[6]!==T.crewOf||e[7]!==R||e[8]!==I.teammatesByLead||e[9]!==P?(L={topLevelSessions:P,teammatesByLead:I.teammatesByLead,crewOf:T.crewOf,shelves:R},e[6]=T.crewOf,e[7]=R,e[8]=I.teammatesByLead,e[9]=P,e[10]=L):L=e[10];const{topLevelSessions:O,teammatesByLead:$,crewOf:M,shelves:D}=L;let F,z;e[11]===Symbol.for("react.memo_cache_sentinel")?(F=en("live-sessions-open-crews"),z=[],e[11]=F,e[12]=z):(F=e[11],z=e[12]);const[B,U]=br(F,z);let W;e[13]!==B?(W=Array.isArray(B)?B:[],e[13]=B,e[14]=W):W=e[14];let V;e[15]!==W?(V=new Set(W),e[15]=W,e[16]=V):V=e[16];const H=V;let K;e[17]!==B||e[18]!==U?(K=ue=>{const ce=Array.isArray(B)?B:[];U(ce.includes(ue)?ce.filter(xe=>xe!==ue):[...ce,ue])},e[17]=B,e[18]=U,e[19]=K):K=e[19];const Z=K;let Y;e[20]!==l?(Y=l??[],e[20]=l,e[21]=Y):Y=e[21];let X;e[22]!==t||e[23]!==Y?(X=new Map([...Y,...t].map(Yhe)),e[22]=t,e[23]=Y,e[24]=X):X=e[24];const ee=X;let Q;e[25]===Symbol.for("react.memo_cache_sentinel")?(Q=new Set,e[25]=Q):Q=e[25];const[ne,te]=y.useState(Q);let re;e[26]===Symbol.for("react.memo_cache_sentinel")?(re=ue=>{te(ce=>{const xe=new Set(ce);return xe.has(ue)?xe.delete(ue):xe.add(ue),xe})},e[26]=re):re=e[26];const oe=re;let ie;e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==v||e[31]!==w||e[32]!==b||e[33]!==x||e[34]!==_||e[35]!==j||e[36]!==N||e[37]!==g||e[38]!==k||e[39]!==A||e[40]!==d||e[41]!==p?(ie=ue=>{const ce=A(ue.access);return{session:ue,isActiveSession:u===Xh(ue),proc:d.get(ue.sessionId),killingPids:f,isNewlyCompleted:m.has(ue.sessionId),customName:p[ue.sessionId],onSelectSession:g,onKill:ce.stop?x:void 0,onDuplicateSession:b,onDeleteSession:ce.delete?w:void 0,onArchiveSession:ce.archive?v:void 0,onUnarchiveSession:ce.archive?k:void 0,onRenameSession:j,onPrefetchSession:_,onResumeSession:ce.send?N:void 0}},e[27]=u,e[28]=f,e[29]=m,e[30]=v,e[31]=w,e[32]=b,e[33]=x,e[34]=_,e[35]=j,e[36]=N,e[37]=g,e[38]=k,e[39]=A,e[40]=d,e[41]=p,e[42]=ie):ie=e[42];const ae=ie;let de;e[43]!==s?(de=s&&a.jsx(ege,{firstMessage:s.firstMessage}),e[43]=s,e[44]=de):de=e[44];let le;if(e[45]!==u||e[46]!==ne||e[47]!==M||e[48]!==ee||e[49]!==C||e[50]!==g||e[51]!==H||e[52]!==h||e[53]!==ae||e[54]!==p||e[55]!==D||e[56]!==o||e[57]!==$||e[58]!==Z||e[59]!==O){let ue;e[61]!==u||e[62]!==ne||e[63]!==M||e[64]!==ee||e[65]!==C||e[66]!==g||e[67]!==H||e[68]!==h||e[69]!==ae||e[70]!==p||e[71]!==D||e[72]!==o||e[73]!==$||e[74]!==Z?(ue=(ce,xe)=>{const pe=Xh(ce),he=ce.cwd??ms(ce.dirName),be=yr(he),we=h[ce.dirName]??vl(ce),ve=$.get(ce.sessionId),Se=ne.has(ce.sessionId),Te=D[xe],Ae=M.get(ce.sessionId),ze=Ae&&{members:Ae,counts:vx(Ae,C),statusOf:C,activityAt:ay(ce,Ae),open:H.has(ce.sessionId),onToggle:()=>Z(ce.sessionId)},De=a.jsx(Whe,{...ae(ce),worktreeName:be==null?void 0:be.worktreeName,projectLabel:we,projectPath:(be==null?void 0:be.parentPath)??he,showProject:o,teammateCount:ve==null?void 0:ve.length,teammatesCollapsed:ve?Se:void 0,onToggleTeammates:ve?()=>oe(ce.sessionId):void 0,crew:ze,lineage:Jhe(ce,ee,p,g),sessionNames:p,activeSessionKey:u});return a.jsxs(y.Fragment,{children:[Te&&a.jsx(Qhe,{label:Te}),ve&&!Se?a.jsxs("div",{className:"flex flex-col gap-px",children:[De,a.jsx("div",{className:"ml-3 flex flex-col gap-px border-l pl-1",children:ve.map(Le=>a.jsx(Hhe,{...ae(Le)},Xh(Le)))})]}):De]},pe)},e[61]=u,e[62]=ne,e[63]=M,e[64]=ee,e[65]=C,e[66]=g,e[67]=H,e[68]=h,e[69]=ae,e[70]=p,e[71]=D,e[72]=o,e[73]=$,e[74]=Z,e[75]=ue):ue=e[75],le=O.map(ue),e[45]=u,e[46]=ne,e[47]=M,e[48]=ee,e[49]=C,e[50]=g,e[51]=H,e[52]=h,e[53]=ae,e[54]=p,e[55]=D,e[56]=o,e[57]=$,e[58]=Z,e[59]=O,e[60]=le}else le=e[60];let se;e[76]!==r.canLoad||e[77]!==r.load||e[78]!==r.loading?(se=r.canLoad&&a.jsxs(J,{type:"button",variant:"ghost",size:"xs",onClick:r.load,disabled:r.loading,className:"justify-start text-muted-foreground",children:[r.loading?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(Pj,{"data-icon":"inline-start"}),"Load older sessions"]}),e[76]=r.canLoad,e[77]=r.load,e[78]=r.loading,e[79]=se):se=e[79];let me;return e[80]!==de||e[81]!==le||e[82]!==se?(me=a.jsxs("div",{className:"flex flex-col gap-1.5","data-session-card-list":!0,children:[de,le,se]}),e[80]=de,e[81]=le,e[82]=se,e[83]=me):me=e[83],me}function Yhe(n){return[n.sessionId,n]}function Xhe(){return Ghe}function Jhe(n,e,t,s){const r=n.crew;if(!r)return;const o=Nd(r.parentId,e,t)??r.parentTitle??"Another session",i=r.rootId===r.parentId?void 0:Nd(r.rootId,e,t)??r.rootTitle,l=e.get(r.parentId);return{parentTitle:o,...i&&i!==o&&{rootTitle:i},onOpenParent:l?()=>s(l.dirName,l.fileName):()=>void Df(r.parentId)}}function Qhe(n){const e=q.c(2),{label:t}=n;let s;return e[0]!==t?(s=a.jsx("div",{"data-recency-divider":!0,className:"px-1 pb-0.5 pt-2 text-[11px] font-medium text-muted-foreground/80 first:pt-0",children:t}),e[0]=t,e[1]=s):s=e[1],s}function ege(n){const e=q.c(3),{firstMessage:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(vt,{className:"size-3 shrink-0 animate-spin text-info"}),e[0]=s):s=e[0];const r=t||"New session";let o;return e[1]!==r?(o=a.jsxs("div",{className:"motion-enter relative flex w-full items-center gap-1.5 rounded-lg border border-border/70 bg-accent px-3 py-2.5 text-left",children:[s,a.jsx("span",{className:"flex-1 truncate text-sm leading-tight text-foreground",children:r})]}),e[1]=r,e[2]=o):o=e[2],o}function Xh(n){return`${n.dirName}/${n.fileName}`}function xo(n,e){return`${n} ${n===1?e:`${e}s`}`}function tge(n){if(!n)return"No sessions listed";const e=xo(n.total,"session"),t=n.live>0?`${e}, ${n.live} live`:e,s=[n.crews>0&&xo(n.crews,"crew"),n.worktrees>0&&xo(n.worktrees,"worktree")].filter(Boolean);return[t,...s].join(" · ")}function F3(n){const e=q.c(7),{count:t,label:s,className:r}=n;let o;e[0]!==r?(o=G("flex shrink-0 items-center gap-1 font-medium text-warning",r),e[0]=r,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx("span",{className:"size-1.5 rounded-full bg-warning","aria-hidden":"true"}),e[2]=i):i=e[2];let l;return e[3]!==t||e[4]!==s||e[5]!==o?(l=a.jsxs("span",{className:o,"aria-label":s,children:[i,t]}),e[3]=t,e[4]=s,e[5]=o,e[6]=l):l=e[6],l}function nge(n,e){return e===null?0:n.reduce((t,s)=>s.key===e?t:t+s.needsYou,0)}function sge(n){const e=q.c(72),{options:t,value:s,focused:r,totalSessions:o,crewCount:i,onChange:l,onNewSession:c,creatingSession:u,onRenameProject:d,archivableCount:f,onArchiveIdle:m}=n,p=i===void 0?0:i,[h,g]=y.useState(!1),x=(r==null?void 0:r.customName)??s;let b;e[0]!==p||e[1]!==r||e[2]!==t.length||e[3]!==o||e[4]!==s?(b=s===null?`${xo(t.length,"project")}, ${xo(o,"session")}${p>0?` · ${xo(p,"crew")}`:""}`:tge(r),e[0]=p,e[1]=r,e[2]=t.length,e[3]=o,e[4]=s,e[5]=b):b=e[5];const w=b,v=nge(t,s);let k;e[6]!==l?(k=ee=>{l(ee),g(!1)},e[6]=l,e[7]=k):k=e[7];const j=k,_=s===null?"Choose a project to focus on":`Focused on ${x}. Change project`;let N;e[8]!==(r==null?void 0:r.cwd)||e[9]!==s?(N=s===null?a.jsx(hd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):a.jsx(ha,{projectPath:(r==null?void 0:r.cwd)??null,fallback:a.jsx(Qi,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),className:"size-5"}),e[8]=r==null?void 0:r.cwd,e[9]=s,e[10]=N):N=e[10];const S=s===null?"All projects":x;let C;e[11]!==S?(C=a.jsx("span",{className:"truncate text-sm font-medium leading-tight text-foreground",children:S}),e[11]=S,e[12]=C):C=e[12];let A;e[13]!==w?(A=a.jsx("span",{className:"truncate text-[11px] leading-tight text-muted-foreground",children:w}),e[13]=w,e[14]=A):A=e[14];let T;e[15]!==C||e[16]!==A?(T=a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[C,A]}),e[15]=C,e[16]=A,e[17]=T):T=e[17];let I;e[18]!==v?(I=v>0&&a.jsx(F3,{count:v,label:v===1?"1 session in another project is waiting for you":`${v} sessions in other projects are waiting for you`,className:"rounded-full border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[11px]"}),e[18]=v,e[19]=I):I=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=a.jsx(wa,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[20]=E):E=e[20];let P;e[21]!==I||e[22]!==_||e[23]!==N||e[24]!==T?(P=a.jsxs(Ta,{"aria-label":_,className:"flex h-11 min-w-0 flex-1 items-center gap-2.5 rounded-lg px-2 text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring data-popup-open:bg-accent",children:[N,T,I,E]}),e[21]=I,e[22]=_,e[23]=N,e[24]=T,e[25]=P):P=e[25];const R=P;let L;e[26]!==f||e[27]!==r||e[28]!==m||e[29]!==d||e[30]!==R?(L=r&&d?a.jsx(PA,{projectLabel:r.key,customName:r.customName,className:"flex min-w-0 flex-1",archivableCount:f,onArchiveIdle:m,onRename:ee=>d(r.dirName,ee),children:R}):R,e[26]=f,e[27]=r,e[28]=m,e[29]=d,e[30]=R,e[31]=L):L=e[31];let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=a.jsx(Dx,{placeholder:"Find a project",autoFocus:!0}),e[32]=O):O=e[32];let $;e[33]===Symbol.for("react.memo_cache_sentinel")?($=a.jsx(LL,{children:"No project matches."}),e[33]=$):$=e[33];const M=s===null;let D;e[34]!==j?(D=()=>j(null),e[34]=j,e[35]=D):D=e[35];let F,z;e[36]===Symbol.for("react.memo_cache_sentinel")?(F=a.jsx(hd,{className:"text-muted-foreground","aria-hidden":"true"}),z=a.jsx("span",{className:"flex-1 truncate",children:"All projects"}),e[36]=F,e[37]=z):(F=e[36],z=e[37]);let B;e[38]!==o?(B=a.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:o}),e[38]=o,e[39]=B):B=e[39];let U;e[40]!==M||e[41]!==D||e[42]!==B?(U=a.jsx(di,{children:a.jsxs(No,{value:"all-projects","data-checked":M,onSelect:D,className:"gap-2.5",children:[F,z,B]})}),e[40]=M,e[41]=D,e[42]=B,e[43]=U):U=e[43];let W;if(e[44]!==t||e[45]!==j||e[46]!==s){let ee;e[48]!==j||e[49]!==s?(ee=Q=>a.jsxs(No,{value:Q.key,keywords:Q.customName?[Q.customName]:void 0,"data-checked":s===Q.key,onSelect:()=>j(Q.key),className:"gap-2.5",children:[a.jsx(ha,{projectPath:Q.cwd??null,fallback:a.jsx(Qi,{className:"text-muted-foreground","aria-hidden":"true"}),className:"size-4"}),a.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsx("span",{className:"truncate",children:Q.customName??Q.key}),Q.customName&&a.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:Q.key})]}),Q.needsYou>0&&a.jsx(F3,{count:Q.needsYou,label:`${xo(Q.needsYou,"session")} waiting for you`,className:"text-xs"}),Q.live>0&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs font-medium text-success","aria-label":xo(Q.live,"live session"),children:[a.jsx(om,{className:"size-1.5","aria-hidden":"true"}),Q.live]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:Q.total})]},Q.key),e[48]=j,e[49]=s,e[50]=ee):ee=e[50],W=t.map(ee),e[44]=t,e[45]=j,e[46]=s,e[47]=W}else W=e[47];let V;e[51]!==W?(V=a.jsx(di,{heading:"Projects",children:W}),e[51]=W,e[52]=V):V=e[52];let H;e[53]!==U||e[54]!==V?(H=a.jsx($f,{className:"w-(--anchor-width) min-w-72 p-0",children:a.jsxs(wc,{children:[O,a.jsxs(Sc,{children:[$,U,V]})]})}),e[53]=U,e[54]=V,e[55]=H):H=e[55];let K;e[56]!==h||e[57]!==L||e[58]!==H?(K=a.jsxs(Ea,{open:h,onOpenChange:g,children:[L,H]}),e[56]=h,e[57]=L,e[58]=H,e[59]=K):K=e[59];let Z;e[60]!==u||e[61]!==r||e[62]!==x||e[63]!==c?(Z=r&&c&&a.jsx(J,{type:"button",variant:"outline",size:"icon-sm",className:"shrink-0",disabled:u,onClick:()=>c(r.dirName,r.cwd),"aria-label":`New session in ${x}`,children:u?a.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}):a.jsx(xr,{"data-icon":"inline-start"})}),e[60]=u,e[61]=r,e[62]=x,e[63]=c,e[64]=Z):Z=e[64];let Y;e[65]!==u||e[66]!==c?(Y=c&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",className:"shrink-0",disabled:u,onClick:rge,"aria-label":"Start a session in a folder",title:"Start a session in a folder",children:a.jsx(mc,{"data-icon":"inline-start"})}),e[65]=u,e[66]=c,e[67]=Y):Y=e[67];let X;return e[68]!==K||e[69]!==Z||e[70]!==Y?(X=a.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1.5",children:[K,Z,Y]}),e[68]=K,e[69]=Z,e[70]=Y,e[71]=X):X=e[71],X}function rge(){return V_()}function oge(n,e){return n.reduce((t,s)=>s.isActive?t+1:e.has(s.sessionId)?s.agentStatus==="completed"?t:t+1:t,0)}function ige(n){const e=yr(n.cwd??ms(n.dirName));if(!e)return{dirName:n.dirName,cwd:n.cwd};const{parentPath:t}=e;return{dirName:hs(n.dirName).dirName.encode(t),cwd:t}}function age(n){const e=n.map(t=>{var s;return(s=yr(t.cwd??ms(t.dirName)))==null?void 0:s.worktreeName});return new Set(e.filter(Boolean)).size}function lge(n,e,t,s,r=new Map){return[...tR(n).entries()].map(([o,i])=>{const l=J8(i),c=ige(l);return{key:o,customName:t[c.dirName],...c,dirNames:[...new Set(i.map(u=>u.dirName))],total:i.length,live:oge(i,e),needsYou:i.filter(u=>s.has(u.sessionId)).length,worktrees:age(i),crews:i.filter(u=>r.has(u.sessionId)).length}})}function U3(n,e,t=!1){if(e===null)return n;if(!t)return n.filter(i=>vl(i)===e);const{topLevel:s,crewOf:r}=bx(n),o=new Set;for(const i of s)if(vl(i)===e){o.add(i);for(const l of r.get(i.sessionId)??[])o.add(l)}for(const i of r.values())for(const l of i)vl(l)===e&&o.add(l);return n.filter(i=>o.has(i))}function cge(n,e){if(e.length===0)return n;const t=new Set(n.map(r=>r.sessionId)),s=e.filter(r=>!t.has(r.sessionId));return s.length===0?n:ja([...n,...s])}const B3={key:null,sessions:[],loading:!1,loaded:!1};function uge(n,e){const t=n.dirNames?n.dirNames.map(s=>new URLSearchParams({project:s,limit:"200"})):[new URLSearchParams({limit:"200",perProject:"100"})];if(e)for(const s of t)s.set("archived","include");return t}function dge(n,e,t){const s=q.c(14),r=n?`${e?"a":"l"}:${t.key??""}:${n.key}`:null,[o,i]=y.useState(B3),l=o.key===r?o:B3;let c;s[0]!==t||s[1]!==e||s[2]!==r||s[3]!==n?(c=async()=>{if(r===null||!n)return;i(g=>g.key===r?{...g,loading:!0}:{key:r,sessions:[],loading:!0,loaded:!1});const h=Hr();try{const x=(await Promise.all(uge(n,e).map(async b=>{const w=await Ee(Tf(b,t));if(!w.ok)throw new Error(`Could not load older sessions (${w.status})`);const v=await w.json();return Array.isArray(v)?v:[]}))).flat();ra(x,h),i(b=>b.key===r?{key:r,sessions:x,loading:!1,loaded:!0}:b)}catch(g){const x=g;i(b=>b.key===r?{...b,loading:!1}:b),Kn.error(x instanceof Error?x.message:"Could not load older sessions")}},s[0]=t,s[1]=e,s[2]=r,s[3]=n,s[4]=c):c=s[4];const u=c,{loaded:d}=l;let f,m;s[5]!==u||s[6]!==d?(f=()=>{if(d)return Af(()=>void u())},m=[d,u],s[5]=u,s[6]=d,s[7]=f,s[8]=m):(f=s[7],m=s[8]),y.useEffect(f,m);let p;return s[9]!==l.loading||s[10]!==l.sessions||s[11]!==u||s[12]!==d?(p={sessions:l.sessions,loading:l.loading,loaded:d,load:u},s[9]=l.loading,s[10]=l.sessions,s[11]=u,s[12]=d,s[13]=p):p=s[13],p}const fge={key:"all"},mge=y.memo(function({activeSessionKey:e,onSelectSession:t,onDuplicateSession:s,onDeleteSession:r,onNewSession:o,creatingSession:i,pendingSession:l,refreshRef:c,onPrefetchSession:u}){const{names:d,rename:f}=If(),{names:m,rename:p}=Eb(),h=Wx(),g=xn("terminal"),x=xn("killAny"),b=jm(),w=Ef(),{Control:v,Empty:k}=Tr().sessionListFilter??{},{sessions:j,procBySession:_,newlyCompleted:N,loading:S,error:C,refresh:A,removeSession:T,acknowledgeCompleted:I,showArchived:E,setShowArchived:P,setSearchActive:R,archivedCount:L}=Nx(),{awaitingPermission:O,awaitingQuestion:$,awaitingElicitation:M,awaitingDialog:D,awaitingPlan:F}=RZ(),z=y.useMemo(()=>new Set([...M,...D]),[M,D]),[B,U]=y.useState(new Set),[W,V]=y.useState(""),[H,K]=br(en("live-sessions-project-scope"),null),[Z,Y]=br(en("live-sessions-group-crews"),!0),X=Z!==!1,ee=!!W.trim(),Q=X&&!ee,ne=E||ee;y.useEffect(()=>(R(ee),()=>R(!1)),[ee,R]);const te=y.useRef(new Set),re=y.useRef(!1),oe=y.useCallback((ye,$e)=>{if(!re.current)return;const qe=setTimeout(()=>{te.current.delete(qe),re.current&&ye()},$e);te.current.add(qe)},[]);y.useEffect(()=>{const ye=te.current;return re.current=!0,()=>{re.current=!1;for(const $e of ye)clearTimeout($e);ye.clear()}},[]),y.useEffect(()=>{if(c)return c.current=A,()=>{c.current===A&&(c.current=null)}},[A,c]);const ie=Ab(),ae=$A(W,w),de=y.useMemo(()=>eR(j,ne),[j,ne]),le=ne?0:L,se=y.useMemo(()=>({awaitingPermission:O,awaitingQuestion:$,awaitingPrompt:z,awaitingPlan:F}),[O,$,z,F]),me=y.useCallback(ye=>k4(ye,_,se),[_,se]),ue=y.useMemo(()=>bx(de),[de]),ce=y.useMemo(()=>{const ye=qe=>b(qe.access).canInteract,$e=mhe(ue.topLevel,_,N,O,$,z,F,ye);return phe($e,ue.topLevel,ue.crewOf,me,ye)},[ue,_,N,O,$,z,F,b,me]),xe=y.useMemo(()=>new Set(ce.needsYou.map(ye=>ye.session.sessionId)),[ce]),pe=X?ue.topLevel:de,he=y.useMemo(()=>lge(pe,_,m,xe,ue.crewOf),[pe,_,m,xe,ue.crewOf]),be=H===null?null:he.find(ye=>ye.key===H)??null,we=(be==null?void 0:be.customName)??H,ve=dge(H===null?fge:be,ne,w),Se=y.useMemo(()=>cge(U3(de,H,Q),ve.sessions),[de,H,Q,ve.sessions]),Te=y.useMemo(()=>ee?Se.filter(ye=>{const $e=d[ye.sessionId],qe=m[ye.dirName];return TA(ye,W,[$e,qe])}):Se,[Se,ee,W,d,m]),Ae=y.useMemo(()=>ae.results?U3(ae.results,H,Q):Te,[ae.results,H,Q,Te]),ze=ce.needsYou.length>0||ce.working.length>0,De=!ee&&ze&&H===null,Le=y.useMemo(()=>H===null?[]:Se.filter(ye=>!ye.archived&&b(ye.access).archive&&!gx(ye,_.get(ye.sessionId))),[H,Se,_,b]),Ce=H===null||l!=null&&px(l.cwd||ms(l.dirName))===H,Be=y.useRef(!1);y.useEffect(()=>{if(Be.current||!u||j.length===0)return;Be.current=!0;const ye=ja(j).slice(0,3),$e=globalThis,qe=()=>{for(const ke of ye)u(ke.dirName,ke.fileName)};let Ke=null,fe=null;return typeof $e.requestIdleCallback=="function"?Ke=$e.requestIdleCallback(qe,{timeout:1500}):fe=setTimeout(qe,300),()=>{Ke!=null&&typeof $e.cancelIdleCallback=="function"&&$e.cancelIdleCallback(Ke),fe!=null&&clearTimeout(fe)}},[j,u]);const We=y.useCallback(async(ye,$e)=>{$e.stopPropagation(),U(qe=>new Set(qe).add(ye));try{if(!(await Ee("/api/kill-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pid:ye})})).ok)throw new Error("Could not stop session");oe(A,1500)}catch{Kn.error("Could not stop session")}oe(()=>{U(qe=>{const Ke=new Set(qe);return Ke.delete(ye),Ke})},2e3)},[A,oe]);y.useEffect(()=>{const ye=j.find($e=>`${$e.dirName}/${$e.fileName}`===e);ye&&N.has(ye.sessionId)&&I(ye.sessionId)},[e,j,N,I]);const He=y.useCallback(async ye=>{await(r==null?void 0:r(ye.dirName,ye.fileName))&&T(ye.sessionId)},[r,T]),_e=sE(),Re=y.useCallback(ye=>{_e([ye.sessionId],!0,`Archived “${li(ye,d[ye.sessionId])}”`)},[_e,d]),tt=y.useCallback(ye=>{_e([ye.sessionId],!1,`Restored “${li(ye,d[ye.sessionId])}”`)},[_e,d]),Xe=y.useCallback(ye=>{if(ye.length===0)return;const $e=ye.map(qe=>qe.sessionId);_e($e,!0,`Archived ${$e.length} ${$e.length===1?"session":"sessions"}`)},[_e]),Ne=y.useCallback((ye,$e,qe)=>{const{command:Ke,args:fe}=L$(an(qe),ye),ke=`resume_${crypto.randomUUID().slice(0,8)}`;h.send({type:"spawn",id:ke,name:`Resume ${ye.slice(0,8)}`,command:Ke,args:fe,cwd:$e??void 0,metadata:{type:"terminal"}}),oe(A,3e3)},[h,A,oe]),Ve={activeSessionKey:e,procBySession:_,killingPids:B,newlyCompleted:N,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?We:void 0,onDuplicateSession:s,onDeleteSession:r?He:void 0,onArchiveSession:Re,onUnarchiveSession:tt,onRenameSession:f,onPrefetchSession:u,onResumeSession:g?Ne:void 0};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsx(Ehe,{loading:S,isMobile:ie,searchQuery:W,searchLoading:ae.loading,showArchived:E,archivedCount:L,groupCrews:X,onToggleGroupCrews:()=>Y(!X),onSearchQueryChange:V,onToggleShowArchived:()=>P(!E),onRefresh:()=>{dhe(),A()}}),v&&a.jsx(v,{}),a.jsx(sge,{options:he,value:H,focused:be,totalSessions:pe.length,crewCount:X?ue.crewOf.size:0,onChange:K,onNewSession:o,creatingSession:i,onRenameProject:p,archivableCount:Le.length,onArchiveIdle:()=>Xe(Le)}),a.jsx(Cc,{className:"flex-1",children:a.jsxs("div",{className:"flex flex-col gap-4 p-2",children:[a.jsx(Ahe,{fetchError:ae.error??C,showEmpty:Ae.length===0&&!(l&&Ce)&&!S&&!ae.loading&&!C&&!ae.error,searching:ee,loading:S||ae.loading,sessionCount:ae.active?Ae.length:de.length,hiddenArchivedCount:le,focusedProject:we,onShowAllProjects:()=>K(null),filterEmpty:w.key!==null&&k?a.jsx(k,{className:"min-h-56 px-4 py-8"}):null,onShowArchived:()=>P(!0),onRetry:ae.error?ae.refresh:A}),De&&a.jsx(_he,{groups:ce,activeSessionKey:e,procBySession:_,killingPids:B,sessionNames:d,projectNames:m,onSelectSession:t,onKill:x?We:void 0,onResumeSession:g?Ne:void 0,onPrefetchSession:u}),a.jsx(Zhe,{...Ve,sessions:Ae,pendingSession:Ce?l:null,showProject:H===null,groupCrews:Q,lineageSessions:de,memberStatusOf:me,older:{canLoad:(H===null||!!be)&&!ve.loaded&&!ee,loading:ve.loading,load:ve.load}})]})})]})}),pge=y.memo(function(e){const t=q.c(16),{activeSessionKey:s,onSelectSession:r,onNewSession:o,creatingSession:i,isMobile:l,onDuplicateSession:c,onDeleteSession:u,pendingSession:d,liveSessionsRefreshRef:f,onPrefetchSession:m,header:p}=e,h=l?"w-full":"w-80";let g;t[0]!==h?(g=G("flex h-full shrink-0 flex-col bg-sidebar",h),t[0]=h,t[1]=g):g=t[1];let x;t[2]!==s||t[3]!==i||t[4]!==f||t[5]!==u||t[6]!==c||t[7]!==o||t[8]!==m||t[9]!==r||t[10]!==d?(x=a.jsx(mge,{activeSessionKey:s,onSelectSession:r,onDuplicateSession:c,onDeleteSession:u,onNewSession:o,creatingSession:i,pendingSession:d,refreshRef:f,onPrefetchSession:m}),t[2]=s,t[3]=i,t[4]=f,t[5]=u,t[6]=c,t[7]=o,t[8]=m,t[9]=r,t[10]=d,t[11]=x):x=t[11];let b;return t[12]!==p||t[13]!==g||t[14]!==x?(b=a.jsxs("aside",{className:g,"aria-label":"Session browser",children:[p,x]}),t[12]=p,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}),hge=y.lazy(()=>nt(()=>import("./MissionHome-Ckt9lu1H.js"),__vite__mapDeps([36,1,2,3,4])).then(n=>({default:n.MissionHome})));function Cm(n){const e=q.c(3),{label:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(Pn,{className:"size-4"}),e[0]=s):s=e[0];let r;return e[1]!==t?(r=a.jsxs("div",{className:"motion-enter flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",role:"status",children:[s,t]}),e[1]=t,e[2]=r):r=e[2],r}function zA(n){const e=q.c(12),{navigation:t,mobile:s,header:r}=n,o=s===void 0?!1:s,{sessionSource:i}=yt(),l=i?`${i.dirName}/${i.fileName}`:null;let c;return e[0]!==l||e[1]!==r||e[2]!==o||e[3]!==t.actions.handleDashboardSelect||e[4]!==t.creatingSession||e[5]!==t.handlers.handleDeleteSession||e[6]!==t.handlers.handleDuplicateSessionByPath||e[7]!==t.liveSessionsRefreshRef||e[8]!==t.onPrefetchSession||e[9]!==t.onStartNewSession||e[10]!==t.pendingSession?(c=a.jsx(pge,{activeSessionKey:l,onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,pendingSession:t.pendingSession,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession,liveSessionsRefreshRef:t.liveSessionsRefreshRef,onPrefetchSession:t.onPrefetchSession,isMobile:o,header:r}),e[0]=l,e[1]=r,e[2]=o,e[3]=t.actions.handleDashboardSelect,e[4]=t.creatingSession,e[5]=t.handlers.handleDeleteSession,e[6]=t.handlers.handleDuplicateSessionByPath,e[7]=t.liveSessionsRefreshRef,e[8]=t.onPrefetchSession,e[9]=t.onStartNewSession,e[10]=t.pendingSession,e[11]=c):c=e[11],c}function gge(n){const e=q.c(8),{navigation:t}=n,{state:s}=ln();let r;return e[0]!==t.actions.handleDashboardSelect||e[1]!==t.creatingSession||e[2]!==t.handlers.handleDeleteSession||e[3]!==t.handlers.handleDuplicateSessionByPath||e[4]!==t.onSelectProject||e[5]!==t.onStartNewSession||e[6]!==s.dashboardProject?(r=a.jsx(uhe,{onSelectSession:t.actions.handleDashboardSelect,onNewSession:t.onStartNewSession,creatingSession:t.creatingSession,selectedProjectDirName:s.dashboardProject,onSelectProject:t.onSelectProject,onDuplicateSession:t.handlers.handleDuplicateSessionByPath,onDeleteSession:t.handlers.handleDeleteSession}),e[0]=t.actions.handleDashboardSelect,e[1]=t.creatingSession,e[2]=t.handlers.handleDeleteSession,e[3]=t.handlers.handleDuplicateSessionByPath,e[4]=t.onSelectProject,e[5]=t.onStartNewSession,e[6]=s.dashboardProject,e[7]=r):r=e[7],r}function lf(n){const e=q.c(6),{navigation:t,showProjectHistory:s}=n,r=s===void 0?!1:s,{state:o}=ln(),[i,l]=y.useState(!1);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsx(Cm,{label:"Loading Mission Control…"}),e[0]=c):c=e[0];let u;return e[1]!==i||e[2]!==t||e[3]!==r||e[4]!==o?(u=a.jsx(y.Suspense,{fallback:c,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:i||r&&o.dashboardProject?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-4 pt-12",children:a.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>{t.onSelectProject(null),l(!1)},children:[a.jsx(Q1,{"data-icon":"inline-start"})," Mission Control"]})}),a.jsx(gge,{navigation:t})]}):a.jsx(hge,{onOpenSession:t.actions.handleDashboardSelect,onBrowseProjects:()=>l(!0),newSessionControl:a.jsx(xge,{navigation:t})})})}),e[1]=i,e[2]=t,e[3]=r,e[4]=o,e[5]=u):u=e[5],u}function xge(n){const e=q.c(13),{navigation:t}=n,{config:s}=ln(),[r,o]=y.useState(!1),i=wA(r);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=a.jsx(J,{variant:"outline",className:"h-auto w-full justify-between px-4 py-4"}),e[0]=l):l=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=a.jsxs(Ta,{render:l,children:["What should we build?",a.jsx("span",{className:"text-muted-foreground",children:"Choose a project"})]}),e[1]=c):c=e[1];let u,d;e[2]!==t?(u=(p,h)=>{o(!1),t.onStartNewSession(p,h)},d=p=>{o(!1),t.onStartNewFolder(p)},e[2]=t,e[3]=u,e[4]=d):(u=e[3],d=e[4]);let f;e[5]!==s.defaultAgentKind||e[6]!==i||e[7]!==u||e[8]!==d?(f=a.jsx($f,{className:"w-96 max-w-[calc(100vw-2rem)] p-0",children:a.jsx(SA,{projects:i,defaultAgentKind:s.defaultAgentKind,onNewSession:u,onNewFolder:d})}),e[5]=s.defaultAgentKind,e[6]=i,e[7]=u,e[8]=d,e[9]=f):f=e[9];let m;return e[10]!==r||e[11]!==f?(m=a.jsxs(Ea,{open:r,onOpenChange:o,children:[c,f]}),e[10]=r,e[11]=f,e[12]=m):m=e[12],m}function DA(n){const e=q.c(8),{view:t,onClose:s}=n,{Component:r}=t,o=`Loading ${t.label}…`;let i;e[0]!==o?(i=a.jsx(Cm,{label:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==r||e[3]!==s?(l=a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 flex-col",children:a.jsx(r,{onClose:s})}),e[2]=r,e[3]=s,e[4]=l):l=e[4];let c;return e[5]!==i||e[6]!==l?(c=a.jsx(y.Suspense,{fallback:i,children:l}),e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function bge({mainView:n,hasSession:e,pendingDirName:t,extensionViewAvailable:s}){return n==="config"?"config":n==="mission"?"mission":n==="extension"&&s?"extension":e?"session":t?"pending":"dashboard"}function vge({sessionCwd:n,pendingPath:e,sessionDirPath:t,dashboardProjectPath:s}){return n??e??t??s??null}function FA({path:n,text:e,startLine:t,endLine:s,comment:r}){if(!e)return`@${n}`;const o=e.includes("```")?"````":"```",i=t===s?`line ${t}`:`lines ${t}-${s}`;return`${r?`Review request: ${r}
|
|
456
456
|
`:""}${n} (${i})
|
|
457
457
|
${o}
|
|
458
458
|
${e}
|
|
459
|
-
${o}`}const yge=y.lazy(()=>nt(()=>import("./ConfigBrowser-
|
|
459
|
+
${o}`}const yge=y.lazy(()=>nt(()=>import("./ConfigBrowser-CWys9Rgj.js"),__vite__mapDeps([37,1,2,32,3,4])).then(n=>({default:n.ConfigBrowser}))),wge=y.lazy(()=>nt(()=>import("./PreviewPanel-CV3itR4d.js"),__vite__mapDeps([38,1,2,3,4])).then(n=>({default:n.PreviewPanel}))),Sge=y.lazy(()=>nt(()=>import("./PluginsDialog-CuaR5Cs1.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PluginsDialog})));function kge(n){const e=q.c(20),{sessionView:t,floatingChrome:s}=n,{session:r}=yt();if(!r)return null;let o;e[0]!==t.teamMembersBar?(o=t.teamMembersBar&&a.jsx("div",{className:"pt-10",children:t.teamMembersBar}),e[0]=t.teamMembersBar,e[1]=o):o=e[1];const i=!!t.todoProgress&&t.todosExpanded;let l;e[2]!==t.hasMoreTurns||e[3]!==t.isLoadingOlderTurns||e[4]!==t.onLoadMoreTurns||e[5]!==t.searchInputRef||e[6]!==i?(l=a.jsx(rm,{searchInputRef:t.searchInputRef,hasTodos:i,hasMore:t.hasMoreTurns,isLoadingOlder:t.isLoadingOlderTurns,onLoadMore:t.onLoadMoreTurns}),e[2]=t.hasMoreTurns,e[3]=t.isLoadingOlderTurns,e[4]=t.onLoadMoreTurns,e[5]=t.searchInputRef,e[6]=i,e[7]=l):l=e[7];let c;e[8]!==t.onTodosExpandedChange||e[9]!==t.todoProgress||e[10]!==t.todosExpanded?(c=t.todoProgress&&a.jsx(P5,{progress:t.todoProgress,expanded:t.todosExpanded,onExpandedChange:t.onTodosExpandedChange}),e[8]=t.onTodosExpandedChange,e[9]=t.todoProgress,e[10]=t.todosExpanded,e[11]=c):c=e[11];let u;e[12]!==t.activeComposer||e[13]!==c?(u=a.jsxs(km,{floating:!0,children:[c,t.activeComposer]}),e[12]=t.activeComposer,e[13]=c,e[14]=u):u=e[14];let d;return e[15]!==s||e[16]!==o||e[17]!==l||e[18]!==u?(d=a.jsx("div",{className:"flex min-h-0 flex-1",children:a.jsxs("div",{className:"relative flex h-full min-h-0 flex-1 flex-col",children:[s,o,l,u]})}),e[15]=s,e[16]=o,e[17]=l,e[18]=u,e[19]=d):d=e[19],d}function jge(n){const e=q.c(41),{navigation:t,sessionView:s,project:r,view:o,extensionView:i,floatingChrome:l}=n,{state:c,config:u}=ln(),{session:d,sessionSource:f}=yt();let m,p;if(e[0]!==(d==null?void 0:d.cwd)||e[1]!==f||e[2]!==c.configFilePath||e[3]!==c.dashboardProject||e[4]!==c.pendingCwd||e[5]!==c.pendingDirName||e[6]!==o){p=Symbol.for("react.early_return_sentinel");e:if(m=c.pendingCwd??(c.pendingDirName?ms(c.pendingDirName):null),o==="config"){let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=a.jsx(Cm,{label:"Loading configuration…"}),e[9]=g):g=e[9];const x=a.jsx(yge,{projectPath:vge({sessionCwd:d==null?void 0:d.cwd,pendingPath:m,sessionDirPath:f!=null&&f.dirName?ms(f.dirName):null,dashboardProjectPath:c.dashboardProject?ms(c.dashboardProject):null}),initialFilePath:c.configFilePath});let b;e[10]!==x?(b=a.jsx(y.Suspense,{fallback:g,children:a.jsx("div",{className:"motion-session-enter flex min-h-0 flex-1 pt-10",children:x})}),e[10]=x,e[11]=b):b=e[11],p=b;break e}e[0]=d==null?void 0:d.cwd,e[1]=f,e[2]=c.configFilePath,e[3]=c.dashboardProject,e[4]=c.pendingCwd,e[5]=c.pendingDirName,e[6]=o,e[7]=m,e[8]=p}else m=e[7],p=e[8];if(p!==Symbol.for("react.early_return_sentinel"))return p;if(o==="mission"){let g;return e[12]!==t?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(lf,{navigation:t})}),e[12]=t,e[13]=g):g=e[13],g}if(o==="extension"&&i){let g;return e[14]!==i||e[15]!==t.panels.closeMainView?(g=a.jsx("div",{className:"flex min-h-0 flex-1 flex-col pt-10",children:a.jsx(DA,{view:i,onClose:t.panels.closeMainView})}),e[14]=i,e[15]=t.panels.closeMainView,e[16]=g):g=e[16],g}if(o==="session"){let g;return e[17]!==l||e[18]!==s?(g=a.jsx(kge,{sessionView:s,floatingChrome:l}),e[17]=l,e[18]=s,e[19]=g):g=e[19],g}if(o==="pending"){const g=s.pendingTurns.length>0,x=Bo()?"Only on the machine running this session":void 0;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=l0()?void 0:x,e[20]=b):b=e[20];const w=b,v=!g&&"justify-center gap-4";let k;e[21]!==v?(k=G("flex min-h-0 min-w-0 flex-1 flex-col",v),e[21]=v,e[22]=k):k=e[22];let j;e[23]!==u||e[24]!==g||e[25]!==t||e[26]!==m||e[27]!==s.pendingTurns?(j=g?a.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-14",children:a.jsx("div",{className:"mx-auto w-full max-w-[var(--chat-width)]",children:s.pendingTurns})}):a.jsx(kA,{projectPath:m,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:u.defaultAgentKind}}),e[23]=u,e[24]=g,e[25]=t,e[26]=m,e[27]=s.pendingTurns,e[28]=j):j=e[28];let _;e[29]!==s.pendingComposer?(_=a.jsx(km,{children:s.pendingComposer}),e[29]=s.pendingComposer,e[30]=_):_=e[30];let N;e[31]!==g||e[32]!==r?(N=!g&&a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[ht("terminal")&&a.jsx(ed,{reason:x,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!x,onClick:r.onOpenTerminal,children:[a.jsx(ya,{"data-icon":"inline-start"}),"Terminal"]})}),ht("hostFiles")&&a.jsxs(a.Fragment,{children:[a.jsx(ed,{reason:w,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!w,onClick:()=>BC(r.pendingProject),children:[a.jsx(Y1,{"data-icon":"inline-start"}),"Open in editor"]})}),a.jsx(ed,{reason:x,children:a.jsxs(J,{variant:"outline",size:"xs",disabled:!!x,onClick:()=>WC(r.pendingProject),children:[a.jsx(mc,{"data-icon":"inline-start"}),"Reveal in files"]})})]})]}),e[31]=g,e[32]=r,e[33]=N):N=e[33];let S;return e[34]!==k||e[35]!==j||e[36]!==_||e[37]!==N?(S=a.jsxs("div",{className:k,children:[j,_,N]}),e[34]=k,e[35]=j,e[36]=_,e[37]=N,e[38]=S):S=e[38],S}let h;return e[39]!==t?(h=a.jsx(lf,{navigation:t,showProjectHistory:!0}),e[39]=t,e[40]=h):h=e[40],h}function Nge(n){const e=q.c(125),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=ln(),{session:c,sessionSource:u}=yt(),d=Y_((c==null?void 0:c.sessionId)??null),[f,m]=y.useState(Cge),[p,h]=y.useState();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=Le=>{h(Le),m(!0)},e[0]=g):g=e[0];const x=g;let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=ht("configWrite"),e[1]=b):b=e[1];const w=AT(b),v=r.currentCwd??null;let k;e[2]!==w||e[3]!==v?(k={...w,projectPath:v,openSettings:x},e[2]=w,e[3]=v,e[4]=k):k=e[4];const j=pA(k),_=R4(i.mainView==="extension"?i.extensionViewId:null);let N;e[5]!==s.chatInputRef?(N=function(Ce){var We,He,_e;const Be=((We=s.chatInputRef.current)==null?void 0:We.getText().trimEnd())??"";(He=s.chatInputRef.current)==null||He.setText(Be?`${Be}
|
|
460
460
|
|
|
461
461
|
${Ce}
|
|
462
462
|
`:`${Ce}
|
|
463
|
-
`),(_e=s.chatInputRef.current)==null||_e.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(Ce){const{path:Be,text:We,startLine:He,endLine:_e,comment:Re}=Ce;S(FA({path:Be,text:We,startLine:He,endLine:_e,comment:Re}))},e[7]=S,e[8]=C):C=e[8];const A=C,T=i.mainView,I=!!c,E=_!==null;let P;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==I||e[12]!==E?(P=bge({mainView:T,hasSession:I,pendingDirName:i.pendingDirName,extensionViewAvailable:E}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=I,e[12]=E,e[13]=P):P=e[13];const R=P,L=t.panels.handleToggleSidebar,O=t.actions.handleGoHome,$=o.onOpenCommandPalette;let M,D;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Qu("toggleSidebar"),D=Qu("commandPalette"),e[14]=M,e[15]=D):(M=e[14],D=e[15]);let F;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(F=a.jsx(NX,{onToggleSidebar:L,onGoHome:O,onOpenCommandPalette:$,sidebarShortcut:M,commandPaletteShortcut:D}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=F):F=e[19];const z=F,B=R==="mission"||R==="dashboard"&&!i.dashboardProject;let U;e[20]===Symbol.for("react.memo_cache_sentinel")?(U=new Set,e[20]=U):U=e[20];const W=y.useRef(U),V=t.panels.openWorkspacePanel;let H,K;e[21]!==B||e[22]!==d||e[23]!==V?(H=()=>{B||!d||W.current.has(d.rootId)||(W.current.add(d.rootId),V(Et.crew))},K=[B,d,V],e[21]=B,e[22]=d,e[23]=V,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!B;let Y,X,ee;e[26]!==S||e[27]!==B||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==j?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:ht("hostFiles"),canUseBrowser:ht("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=D0(j,Y),X=i.mainView==="sessions"&&!B?G_(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=B,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=j,e[39]=Y,e[40]=X,e[41]=ee):(Y=e[39],X=e[40],ee=e[41]);const Q=X,ne=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let te;e[42]!==t.panels||e[43]!==r?(te=function(Ce){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(Ce)},e[42]=t.panels,e[43]=r,e[44]=te):te=e[44];const re=te;let oe;e[45]!==t.actions||e[46]!==t.panels?(oe=function(Ce){t.actions.handleDashboardSelect(Ce.dirName,`${Ce.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=oe):oe=e[47];const ie=oe,ae=t.panels.showSidebar;let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=Qu("toggleSidebar"),e[48]=de):de=e[48];let le;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(le=a.jsx(kX,{showSidebar:ae,sidebarRendered:Z,sidebarShortcut:de,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=le):le=e[64];const se=le;let me;e[65]!==t||e[66]!==z||e[67]!==Z?(me=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(zA,{navigation:t,header:z})}),e[65]=t,e[66]=z,e[67]=Z,e[68]=me):me=e[68];const ue=Q??null,ce=r.projectFilesRoot??r.currentCwd??null;let xe;e[69]!==A||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ie||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==ce||e[80]!==ne?(xe={projectFilesRoot:ce,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:A,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:ne,openWorktreeSession:ie},e[69]=A,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ie,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=ce,e[80]=ne,e[81]=xe):xe=e[81];let pe;e[82]!==B||e[83]!==t.panels.handleToggleMission?(pe={id:"mission-control",title:"Mission Control",icon:Uj,active:B,onSelect:t.panels.handleToggleMission},e[82]=B,e[83]=t.panels.handleToggleMission,e[84]=pe):pe=e[84];let he;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(he=ht("configWrite")?[{id:"plugins",title:"Plugins",icon:J1,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:Bj,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=he):he=e[88];let be;e[89]!==pe||e[90]!==he?(be=[pe,...he],e[89]=pe,e[90]=he,e[91]=be):be=e[91];const we=R!=="session"&&se;let ve;e[92]!==_||e[93]!==se||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==R?(ve=a.jsx(jge,{navigation:t,sessionView:s,project:r,view:R,extensionView:_,floatingChrome:se}),e[92]=_,e[93]=se,e[94]=t,e[95]=r,e[96]=s,e[97]=R,e[98]=ve):ve=e[98];let Se;e[99]!==we||e[100]!==ve?(Se=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,ve]}),e[99]=we,e[100]=ve,e[101]=Se):Se=e[101];let Te;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==ue||e[105]!==xe||e[106]!==be||e[107]!==Se||e[108]!==re||e[109]!==ee?(Te=a.jsx(IX,{panels:ee,context:Y,activePanel:ue,services:xe,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:re,actions:be,children:Se}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=ue,e[105]=xe,e[106]=be,e[107]=Se,e[108]=re,e[109]=ee,e[110]=Te):Te=e[110];let Ae;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(Ae=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(wge,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=Ae):Ae=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&ht("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Sge,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let De;return e[120]!==me||e[121]!==Te||e[122]!==Ae||e[123]!==ze?(De=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[me,Te,Ae,ze]}),e[120]=me,e[121]=Te,e[122]=Ae,e[123]=ze,e[124]=De):De=e[124],De}function Cge(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function _ge(n){const e=q.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(O5,{}),l=a.jsx(R5,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(Nge,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(_Z,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const Ege=[{id:"sessions",label:"Sessions",icon:qr},{id:"chat",label:"Chat",icon:To},{id:"workspace",label:"Workspace",icon:f$}],Tge=y.memo(function(e){const t=q.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=yt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=Ege.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{C1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(om,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function Age(n){const e=q.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:k}=n,j=rE(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(q1,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,A;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(O0,{compact:!0}),A=a.jsx(Qt,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=A):(C=e[7],A=e[8]);let T;e[9]!==c?(T=a.jsx(X_,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let I;e[11]!==t.cwd?(I=t.cwd?kr(t.cwd):"Session",e[11]=t.cwd,e[12]=I):I=e[12];let E;e[13]!==I?(E=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:I}),e[13]=I,e[14]=E):E=e[14];let P;e[15]!==o?(P=o&&a.jsx(om,{"aria-label":"Session is live"}),e[15]=o,e[16]=P):P=e[16];let R;e[17]!==E||e[18]!==P?(R=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[E,P]}),e[17]=E,e[18]=P,e[19]=R):R=e[19];let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(Pa,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(Dj,{"data-icon":"inline-start"})}),e[20]=L):L=e[20];let O;e[21]!==t.cwd?(O=t.cwd?kr(t.cwd):"Current session",e[21]=t.cwd,e[22]=O):O=e[22];let $;e[23]!==O?($=a.jsx("span",{className:"truncate text-foreground",children:O}),e[23]=O,e[24]=$):$=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let D;e[28]!==M?(D=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=D):D=e[29];let F;e[30]!==$||e[31]!==D?(F=a.jsxs(SN,{className:"flex flex-col gap-0.5",children:[$,D]}),e[30]=$,e[31]=D,e[32]=F):F=e[32];let z;e[33]!==d||e[34]!==N||e[35]!==s?(z=s&&a.jsxs(tn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(xr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=z):z=e[36];let B;e[37]!==m?(B=m&&a.jsxs(tn,{onClick:m,children:[a.jsx(Cs,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=B):B=e[38];let U;e[39]!==r||e[40]!==l?(U=l&&!r&&a.jsxs(tn,{onClick:l,children:[a.jsx(zj,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=U):U=e[41];let W;e[42]!==j||e[43]!==r?(W=j&&!r&&a.jsxs(tn,{onClick:j.toggle,disabled:!!j.disabledReason,children:[a.jsx(j.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[j.label,j.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:j.disabledReason})]})]}),e[42]=j,e[43]=r,e[44]=W):W=e[44];let V;e[45]!==F||e[46]!==z||e[47]!==B||e[48]!==U||e[49]!==W?(V=a.jsxs(pr,{children:[F,z,B,U,W]}),e[45]=F,e[46]=z,e[47]=B,e[48]=U,e[49]=W,e[50]=V):V=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Nl,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(tn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==k?(Z=k&&a.jsxs(tn,{onClick:k,children:[v?a.jsx(hf,{}):a.jsx(wa,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=k,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(tn,{onClick:h,children:[a.jsx(fc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let X;e[60]!==x||e[61]!==b?(X=x&&(b??0)>0&&a.jsxs(tn,{onClick:x,children:[a.jsx(Mj,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Ue,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=X):X=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==X?(ee=a.jsxs(pr,{children:[K,Z,Y,X]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=X,e[67]=ee):ee=e[67];let Q;e[68]!==V||e[69]!==ee?(Q=a.jsxs(Ia,{children:[L,a.jsxs($a,{align:"end",sideOffset:6,className:"w-72",children:[V,H,ee]})]}),e[68]=V,e[69]=ee,e[70]=Q):Q=e[70];let ne;return e[71]!==u||e[72]!==S||e[73]!==Q||e[74]!==T||e[75]!==R?(ne=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,A,T,R,u,Q]}),e[71]=u,e[72]=S,e[73]=Q,e[74]=T,e[75]=R,e[76]=ne):ne=e[76],ne}const Ige=y.memo(function(e){const t=q.c(14),{isMobile:s}=ln(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=yt();if(!s||!r)return null;let u;t[0]!==o?(u=o?Io(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=na(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(Age,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),Pge=50;function $ge({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<Pge||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const W3=["sessions","chat","workspace"];function q3(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function Rge(n){var R;const e=q.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=D0(t,s);let L;e[16]!==r?(L=F=>F.id===r,e[16]=r,e[17]=L):L=e[17],h=p.find(L);let O;e[18]!==f?(O=f.find(Lge),e[18]=f,e[19]=O):O=e[19],m=O,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let $;e[20]!==s.projectPath?($=(R=s.projectPath)==null?void 0:R.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=$):$=e[21];const M=$;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const D=v?a.jsxs(a.Fragment,{children:[a.jsx(J,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(Q1,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(J,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==D?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:D}),e[22]=D,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(F=>{var W;const z=F.icon,B=F.indicator,U=(W=F.badge)==null?void 0:W.call(F,s);return a.jsxs(J,{variant:"outline","aria-label":F.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(F.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(z,{"data-icon":"inline-start"}),B&&a.jsx(B,{context:s,active:!1})]}),U!=null&&a.jsx(Ue,{variant:"secondary",children:U})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:F.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},F.id)}),f.map(Oge)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const k=v?"relative min-h-0 flex-1":"hidden",j=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==j||e[25]!==_?(N=a.jsx(I_,{fallbackMessage:"Couldn't open this workspace tool",children:_},j),e[24]=j,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",A=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==A?(T=a.jsx(lE,{panels:p,context:s,activePanelId:C,active:A,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=A,e[32]=T):T=e[32];let I;e[33]!==S||e[34]!==T?(I=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=I):I=e[35];let E;e[36]!==N||e[37]!==I||e[38]!==k?(E=a.jsxs("div",{className:k,children:[N,I]}),e[36]=N,e[37]=I,e[38]=k,e[39]=E):E=e[39];let P;return e[40]!==E||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(P=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,E]}),e[40]=E,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=P):P=e[45],P}function Oge(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(J,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function Lge(n){return n.active}const Mge=y.lazy(()=>nt(()=>import("./PluginsDialog-84zjmDAJ.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),zge=y.lazy(()=>nt(()=>import("./ConfigBrowser-9ySKSxnx.js"),__vite__mapDeps([37,1,2,32,3,4])).then(n=>({default:n.ConfigBrowser})));function Dge(n){var ae;const e=q.c(90),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=ln(),{session:l,sessionSource:c}=yt(),u=Y_((l==null?void 0:l.sessionId)??null),d=xn("hostFiles"),f=xn("browser"),m=xn("configWrite"),[p,h]=y.useState(Fge),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=de=>{x(de),h(!0)},e[0]=b):b=e[0];const w=b,v=AT(m),k=r.currentCwd??null;let j;e[1]!==v||e[2]!==k?(j={...v,projectPath:k,openSettings:w},e[1]=v,e[2]=k,e[3]=j):j=e[3];const _=pA(j),[N,S]=y.useState(null),{panels:C}=t,A=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let I;e[4]!==C?(I=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=I):I=e[5];const E=I;let P;e[6]!==C?(P=function(le){C.closeWorkspacePanel(),S(le)},e[6]=C,e[7]=P):P=e[7];const R=P;let L;e[8]!==t.actions||e[9]!==s.chatInputRef?(L=function(le){const se=s.chatInputRef.current,me=(se==null?void 0:se.getText().trimEnd())??"";se==null||se.setText(me?`${me}
|
|
463
|
+
`),(_e=s.chatInputRef.current)==null||_e.focus()},e[5]=s.chatInputRef,e[6]=N):N=e[6];const S=N;let C;e[7]!==S?(C=function(Ce){const{path:Be,text:We,startLine:He,endLine:_e,comment:Re}=Ce;S(FA({path:Be,text:We,startLine:He,endLine:_e,comment:Re}))},e[7]=S,e[8]=C):C=e[8];const A=C,T=i.mainView,I=!!c,E=_!==null;let P;e[9]!==i.mainView||e[10]!==i.pendingDirName||e[11]!==I||e[12]!==E?(P=bge({mainView:T,hasSession:I,pendingDirName:i.pendingDirName,extensionViewAvailable:E}),e[9]=i.mainView,e[10]=i.pendingDirName,e[11]=I,e[12]=E,e[13]=P):P=e[13];const R=P,L=t.panels.handleToggleSidebar,O=t.actions.handleGoHome,$=o.onOpenCommandPalette;let M,D;e[14]===Symbol.for("react.memo_cache_sentinel")?(M=Qu("toggleSidebar"),D=Qu("commandPalette"),e[14]=M,e[15]=D):(M=e[14],D=e[15]);let F;e[16]!==o.onOpenCommandPalette||e[17]!==t.actions.handleGoHome||e[18]!==t.panels.handleToggleSidebar?(F=a.jsx(NX,{onToggleSidebar:L,onGoHome:O,onOpenCommandPalette:$,sidebarShortcut:M,commandPaletteShortcut:D}),e[16]=o.onOpenCommandPalette,e[17]=t.actions.handleGoHome,e[18]=t.panels.handleToggleSidebar,e[19]=F):F=e[19];const z=F,B=R==="mission"||R==="dashboard"&&!i.dashboardProject;let U;e[20]===Symbol.for("react.memo_cache_sentinel")?(U=new Set,e[20]=U):U=e[20];const W=y.useRef(U),V=t.panels.openWorkspacePanel;let H,K;e[21]!==B||e[22]!==d||e[23]!==V?(H=()=>{B||!d||W.current.has(d.rootId)||(W.current.add(d.rootId),V(Et.crew))},K=[B,d,V],e[21]=B,e[22]=d,e[23]=V,e[24]=H,e[25]=K):(H=e[24],K=e[25]),y.useEffect(H,K);const Z=t.panels.showSidebar&&i.mainView!=="config"&&!B;let Y,X,ee;e[26]!==S||e[27]!==B||e[28]!==t.handlers.handleLoadSessionScrollAware||e[29]!==t.panels.activeWorkspacePanel||e[30]!==d||e[31]!==r.currentCwd||e[32]!==r.hasFileChanges||e[33]!==r.supportsWorktrees||e[34]!==c||e[35]!==u||e[36]!==i.mainView||e[37]!==i.sessionChangeKey||e[38]!==j?(Y={session:c,sessionAddress:u?{dirName:u.dirName,fileName:u.fileName}:null,sessionChangeKey:i.sessionChangeKey,projectPath:r.currentCwd??null,hasFileChanges:r.hasFileChanges,canAccessHostFiles:ht("hostFiles"),canUseBrowser:ht("browser"),supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:S,crew:d},ee=D0(j,Y),X=i.mainView==="sessions"&&!B?G_(t.panels.activeWorkspacePanel,ee):null,e[26]=S,e[27]=B,e[28]=t.handlers.handleLoadSessionScrollAware,e[29]=t.panels.activeWorkspacePanel,e[30]=d,e[31]=r.currentCwd,e[32]=r.hasFileChanges,e[33]=r.supportsWorktrees,e[34]=c,e[35]=u,e[36]=i.mainView,e[37]=i.sessionChangeKey,e[38]=j,e[39]=Y,e[40]=X,e[41]=ee):(Y=e[39],X=e[40],ee=e[41]);const Q=X,ne=(u==null?void 0:u.dirName)??i.pendingDirName??i.dashboardProject??null;let te;e[42]!==t.panels||e[43]!==r?(te=function(Ce){r.showPreview&&r.onCloseRightWorkspace(),t.panels.toggleWorkspacePanel(Ce)},e[42]=t.panels,e[43]=r,e[44]=te):te=e[44];const re=te;let oe;e[45]!==t.actions||e[46]!==t.panels?(oe=function(Ce){t.actions.handleDashboardSelect(Ce.dirName,`${Ce.sessionId}.jsonl`),t.panels.closeWorkspacePanel()},e[45]=t.actions,e[46]=t.panels,e[47]=oe):oe=e[47];const ie=oe,ae=t.panels.showSidebar;let de;e[48]===Symbol.for("react.memo_cache_sentinel")?(de=Qu("toggleSidebar"),e[48]=de):de=e[48];let le;e[49]!==o.killing||e[50]!==o.onKillAll||e[51]!==o.onLogout||e[52]!==l.openConfigDialog||e[53]!==t.creatingSession||e[54]!==t.handlers.handleDuplicateSession||e[55]!==t.onStartNewSession||e[56]!==t.panels.handleToggleSidebar||e[57]!==t.panels.openMainView||e[58]!==t.panels.showSidebar||e[59]!==r.onOpenTerminal||e[60]!==s.onBackToMain||e[61]!==s.onShowWorkflows||e[62]!==s.workflowCount||e[63]!==Z?(le=a.jsx(kX,{showSidebar:ae,sidebarRendered:Z,sidebarShortcut:de,killing:o.killing,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onOpenTerminal:r.onOpenTerminal,onBackToMain:s.onBackToMain,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onToggleSidebar:t.panels.handleToggleSidebar,onKillAll:o.onKillAll,onOpenSettings:l.openConfigDialog,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView}),e[49]=o.killing,e[50]=o.onKillAll,e[51]=o.onLogout,e[52]=l.openConfigDialog,e[53]=t.creatingSession,e[54]=t.handlers.handleDuplicateSession,e[55]=t.onStartNewSession,e[56]=t.panels.handleToggleSidebar,e[57]=t.panels.openMainView,e[58]=t.panels.showSidebar,e[59]=r.onOpenTerminal,e[60]=s.onBackToMain,e[61]=s.onShowWorkflows,e[62]=s.workflowCount,e[63]=Z,e[64]=le):le=e[64];const se=le;let me;e[65]!==t||e[66]!==z||e[67]!==Z?(me=Z&&a.jsx("div",{className:"view-transition-sidebar panel-enter w-80 shrink-0 border-r bg-sidebar text-sidebar-foreground",children:a.jsx(zA,{navigation:t,header:z})}),e[65]=t,e[66]=z,e[67]=Z,e[68]=me):me=e[68];const ue=Q??null,ce=r.projectFilesRoot??r.currentCwd??null;let xe;e[69]!==A||e[70]!==t.actions.handleJumpToTurn||e[71]!==t.handlers.handleLoadSessionScrollAware||e[72]!==ie||e[73]!==r.backgroundAgents||e[74]!==r.processPanel.handleServersChanged||e[75]!==r.processPanel.handleToggleServer||e[76]!==r.projectFilesRequest||e[77]!==r.worktrees||e[78]!==s.searchInputRef||e[79]!==ce||e[80]!==ne?(xe={projectFilesRoot:ce,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:A,jumpToTurn:t.actions.handleJumpToTurn,toggleServer:r.processPanel.handleToggleServer,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:ne,openWorktreeSession:ie},e[69]=A,e[70]=t.actions.handleJumpToTurn,e[71]=t.handlers.handleLoadSessionScrollAware,e[72]=ie,e[73]=r.backgroundAgents,e[74]=r.processPanel.handleServersChanged,e[75]=r.processPanel.handleToggleServer,e[76]=r.projectFilesRequest,e[77]=r.worktrees,e[78]=s.searchInputRef,e[79]=ce,e[80]=ne,e[81]=xe):xe=e[81];let pe;e[82]!==B||e[83]!==t.panels.handleToggleMission?(pe={id:"mission-control",title:"Mission Control",icon:Uj,active:B,onSelect:t.panels.handleToggleMission},e[82]=B,e[83]=t.panels.handleToggleMission,e[84]=pe):pe=e[84];let he;e[85]!==t.panels.handleToggleConfig||e[86]!==f||e[87]!==i.mainView?(he=ht("configWrite")?[{id:"plugins",title:"Plugins",icon:J1,active:f,onSelect:()=>m(!0)},{id:"config",title:"Config",icon:Bj,active:i.mainView==="config",onSelect:t.panels.handleToggleConfig}]:[],e[85]=t.panels.handleToggleConfig,e[86]=f,e[87]=i.mainView,e[88]=he):he=e[88];let be;e[89]!==pe||e[90]!==he?(be=[pe,...he],e[89]=pe,e[90]=he,e[91]=be):be=e[91];const we=R!=="session"&&se;let ve;e[92]!==_||e[93]!==se||e[94]!==t||e[95]!==r||e[96]!==s||e[97]!==R?(ve=a.jsx(jge,{navigation:t,sessionView:s,project:r,view:R,extensionView:_,floatingChrome:se}),e[92]=_,e[93]=se,e[94]=t,e[95]=r,e[96]=s,e[97]=R,e[98]=ve):ve=e[98];let Se;e[99]!==we||e[100]!==ve?(Se=a.jsxs("main",{className:"app-view-transition relative flex size-full min-w-0 flex-col overflow-hidden",children:[we,ve]}),e[99]=we,e[100]=ve,e[101]=Se):Se=e[101];let Te;e[102]!==t.panels.closeWorkspacePanel||e[103]!==Y||e[104]!==ue||e[105]!==xe||e[106]!==be||e[107]!==Se||e[108]!==re||e[109]!==ee?(Te=a.jsx(IX,{panels:ee,context:Y,activePanel:ue,services:xe,onClosePanel:t.panels.closeWorkspacePanel,onTogglePanel:re,actions:be,children:Se}),e[102]=t.panels.closeWorkspacePanel,e[103]=Y,e[104]=ue,e[105]=xe,e[106]=be,e[107]=Se,e[108]=re,e[109]=ee,e[110]=Te):Te=e[110];let Ae;e[111]!==r.currentCwd||e[112]!==r.onCloseRightWorkspace||e[113]!==r.showPreview?(Ae=r.showPreview&&r.currentCwd&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(wge,{cwd:r.currentCwd,onClose:r.onCloseRightWorkspace})}),e[111]=r.currentCwd,e[112]=r.onCloseRightWorkspace,e[113]=r.showPreview,e[114]=Ae):Ae=e[114];let ze;e[115]!==p||e[116]!==f||e[117]!==r.currentCwd||e[118]!==w?(ze=f&&ht("configWrite")&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Sge,{client:w.client,state:w,currentPath:r.currentCwd??null,initialPluginId:p,onClose:()=>{m(!1),h(void 0)}})}),e[115]=p,e[116]=f,e[117]=r.currentCwd,e[118]=w,e[119]=ze):ze=e[119];let De;return e[120]!==me||e[121]!==Te||e[122]!==Ae||e[123]!==ze?(De=a.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[me,Te,Ae,ze]}),e[120]=me,e[121]=Te,e[122]=Ae,e[123]=ze,e[124]=De):De=e[124],De}function Cge(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}function _ge(n){const e=q.c(15),{navigation:t,sessionView:s,project:r,chrome:o}=n;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=a.jsx(O5,{}),l=a.jsx(R5,{}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let c;e[2]!==o||e[3]!==t||e[4]!==r||e[5]!==s?(c=a.jsx(Nge,{navigation:t,sessionView:s,project:r,chrome:o}),e[2]=o,e[3]=t,e[4]=r,e[5]=s,e[6]=c):c=e[6];let u;e[7]!==o||e[8]!==t||e[9]!==r?(u=a.jsx(_Z,{navigation:t,project:r,chrome:o}),e[7]=o,e[8]=t,e[9]=r,e[10]=u):u=e[10];let d;return e[11]!==o.backgroundServers||e[12]!==c||e[13]!==u?(d=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[o.backgroundServers,i,l,c,u]}),e[11]=o.backgroundServers,e[12]=c,e[13]=u,e[14]=d):d=e[14],d}const Ege=[{id:"sessions",label:"Sessions",icon:qr},{id:"chat",label:"Chat",icon:To},{id:"workspace",label:"Workspace",icon:f$}],Tge=y.memo(function(e){const t=q.c(6),{activeTab:s,onTabChange:r}=e,{isLive:o}=yt();let i;t[0]!==s||t[1]!==o||t[2]!==r?(i=Ege.map(c=>{const u=c.icon,d=s===c.id;return a.jsx("button",{type:"button","aria-current":d?"page":void 0,"aria-label":c.label,title:c.label,onClick:()=>{C1(),r(c.id)},className:G("flex min-h-14 flex-1 items-center justify-center outline-none transition-[color,transform] duration-150 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset motion-reduce:transition-none",d?"text-foreground":"text-muted-foreground hover:text-foreground"),children:a.jsxs("div",{className:G("relative flex size-9 items-center justify-center rounded-md transition-[background-color,transform,scale] duration-150 ease-out motion-reduce:transition-none",d?"scale-100 bg-accent":"scale-95"),children:[a.jsx(u,{className:G("size-[18px] transition-transform duration-150 ease-out motion-reduce:transition-none",d&&"scale-110"),"aria-hidden":"true"}),c.id==="chat"&&o&&!d&&a.jsx(om,{"aria-label":"Session is live",className:"absolute right-0.5 top-0.5 size-1.5 ring-2 ring-background"})]})},c.id)}),t[0]=s,t[1]=o,t[2]=r,t[3]=i):i=t[3];let l;return t[4]!==i?(l=a.jsx("nav",{className:"flex shrink-0 items-stretch border-t bg-background pb-[env(safe-area-inset-bottom)]","aria-label":"Navigation",children:i}),t[4]=i,t[5]=l):l=t[5],l});function Age(n){const e=q.c(77),{session:t,sessionSource:s,isSubAgentView:r,isLive:o,canArchive:i,onProviderHandoff:l,claudeRawMessages:c,headerAccessory:u,creatingSession:d,onNewSession:f,onDuplicateSession:m,onBackToMain:p,onShowFileChanges:h,hasFileChanges:g,onShowWorkflows:x,workflowCount:b,onSearch:w,expandAll:v,onToggleExpandAll:k}=n,j=rE(t.sessionId,o,i);let _;e[0]!==f||e[1]!==t.cwd||e[2]!==s?(_=()=>{s&&f(s.dirName,t.cwd)},e[0]=f,e[1]=t.cwd,e[2]=s,e[3]=_):_=e[3];const N=_;let S;e[4]!==r||e[5]!==p?(S=r&&p&&a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm",onClick:p,"aria-label":"Back to main agent",children:a.jsx(q1,{"data-icon":"inline-start"})}),e[4]=r,e[5]=p,e[6]=S):S=e[6];let C,A;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=a.jsx(O0,{compact:!0}),A=a.jsx(Qt,{orientation:"vertical",className:"h-4"}),e[7]=C,e[8]=A):(C=e[7],A=e[8]);let T;e[9]!==c?(T=a.jsx(X_,{rawMessages:c,warnOnly:!0}),e[9]=c,e[10]=T):T=e[10];let I;e[11]!==t.cwd?(I=t.cwd?kr(t.cwd):"Session",e[11]=t.cwd,e[12]=I):I=e[12];let E;e[13]!==I?(E=a.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:I}),e[13]=I,e[14]=E):E=e[14];let P;e[15]!==o?(P=o&&a.jsx(om,{"aria-label":"Session is live"}),e[15]=o,e[16]=P):P=e[16];let R;e[17]!==E||e[18]!==P?(R=a.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1.5",children:[E,P]}),e[17]=E,e[18]=P,e[19]=R):R=e[19];let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=a.jsx(Pa,{render:a.jsx(J,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Session actions"}),children:a.jsx(Dj,{"data-icon":"inline-start"})}),e[20]=L):L=e[20];let O;e[21]!==t.cwd?(O=t.cwd?kr(t.cwd):"Current session",e[21]=t.cwd,e[22]=O):O=e[22];let $;e[23]!==O?($=a.jsx("span",{className:"truncate text-foreground",children:O}),e[23]=O,e[24]=$):$=e[24];let M;e[25]!==t.gitBranch||e[26]!==t.model?(M=[t.model,t.gitBranch].filter(Boolean).join(" · ")||"Session actions",e[25]=t.gitBranch,e[26]=t.model,e[27]=M):M=e[27];let D;e[28]!==M?(D=a.jsx("span",{className:"truncate font-normal",children:M}),e[28]=M,e[29]=D):D=e[29];let F;e[30]!==$||e[31]!==D?(F=a.jsxs(SN,{className:"flex flex-col gap-0.5",children:[$,D]}),e[30]=$,e[31]=D,e[32]=F):F=e[32];let z;e[33]!==d||e[34]!==N||e[35]!==s?(z=s&&a.jsxs(tn,{onClick:N,disabled:d,children:[d?a.jsx(Pn,{}):a.jsx(xr,{}),a.jsx("span",{children:"New session"})]}),e[33]=d,e[34]=N,e[35]=s,e[36]=z):z=e[36];let B;e[37]!==m?(B=m&&a.jsxs(tn,{onClick:m,children:[a.jsx(Cs,{}),a.jsx("span",{children:"Duplicate session"})]}),e[37]=m,e[38]=B):B=e[38];let U;e[39]!==r||e[40]!==l?(U=l&&!r&&a.jsxs(tn,{onClick:l,children:[a.jsx(zj,{}),a.jsx("span",{children:"Continue with another provider…"})]}),e[39]=r,e[40]=l,e[41]=U):U=e[41];let W;e[42]!==j||e[43]!==r?(W=j&&!r&&a.jsxs(tn,{onClick:j.toggle,disabled:!!j.disabledReason,children:[a.jsx(j.icon,{}),a.jsxs("span",{className:"flex flex-col",children:[j.label,j.disabledReason&&a.jsx("span",{className:"text-xs text-muted-foreground",children:j.disabledReason})]})]}),e[42]=j,e[43]=r,e[44]=W):W=e[44];let V;e[45]!==F||e[46]!==z||e[47]!==B||e[48]!==U||e[49]!==W?(V=a.jsxs(pr,{children:[F,z,B,U,W]}),e[45]=F,e[46]=z,e[47]=B,e[48]=U,e[49]=W,e[50]=V):V=e[50];let H;e[51]===Symbol.for("react.memo_cache_sentinel")?(H=a.jsx(Nl,{}),e[51]=H):H=e[51];let K;e[52]!==w?(K=w&&a.jsxs(tn,{onClick:w,children:[a.jsx(ss,{}),a.jsx("span",{children:"Search conversation"})]}),e[52]=w,e[53]=K):K=e[53];let Z;e[54]!==v||e[55]!==k?(Z=k&&a.jsxs(tn,{onClick:k,children:[v?a.jsx(hf,{}):a.jsx(wa,{}),a.jsx("span",{children:v?"Collapse tool calls":"Expand tool calls"})]}),e[54]=v,e[55]=k,e[56]=Z):Z=e[56];let Y;e[57]!==g||e[58]!==h?(Y=g&&h&&a.jsxs(tn,{onClick:h,children:[a.jsx(fc,{}),a.jsx("span",{children:"File changes"})]}),e[57]=g,e[58]=h,e[59]=Y):Y=e[59];let X;e[60]!==x||e[61]!==b?(X=x&&(b??0)>0&&a.jsxs(tn,{onClick:x,children:[a.jsx(Mj,{}),a.jsx("span",{className:"flex-1",children:"Workflows"}),a.jsx(Ue,{variant:"secondary",children:b})]}),e[60]=x,e[61]=b,e[62]=X):X=e[62];let ee;e[63]!==K||e[64]!==Z||e[65]!==Y||e[66]!==X?(ee=a.jsxs(pr,{children:[K,Z,Y,X]}),e[63]=K,e[64]=Z,e[65]=Y,e[66]=X,e[67]=ee):ee=e[67];let Q;e[68]!==V||e[69]!==ee?(Q=a.jsxs(Ia,{children:[L,a.jsxs($a,{align:"end",sideOffset:6,className:"w-72",children:[V,H,ee]})]}),e[68]=V,e[69]=ee,e[70]=Q):Q=e[70];let ne;return e[71]!==u||e[72]!==S||e[73]!==Q||e[74]!==T||e[75]!==R?(ne=a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1.5 border-b bg-background px-2",children:[S,C,A,T,R,u,Q]}),e[71]=u,e[72]=S,e[73]=Q,e[74]=T,e[75]=R,e[76]=ne):ne=e[76],ne}const Ige=y.memo(function(e){const t=q.c(14),{isMobile:s}=ln(),{session:r,sessionSource:o,isLive:i,permissions:l,actions:c}=yt();if(!s||!r)return null;let u;t[0]!==o?(u=o?Io(o.fileName):null,t[0]=o,t[1]=u):u=t[1];const d=u;let f;t[2]!==r||t[3]!==(o==null?void 0:o.dirName)?(f=na(o==null?void 0:o.dirName).contextWindow?r.rawMessages:[],t[2]=r,t[3]=o==null?void 0:o.dirName,t[4]=f):f=t[4];const m=f,p=d!==null,h=l.send&&d===null?c.handleProviderHandoff:void 0;let g;return t[5]!==m||t[6]!==i||t[7]!==l.archive||t[8]!==e||t[9]!==r||t[10]!==o||t[11]!==p||t[12]!==h?(g=a.jsx(Age,{...e,session:r,sessionSource:o,isSubAgentView:p,isLive:i,canArchive:l.archive,onProviderHandoff:h,claudeRawMessages:m}),t[5]=m,t[6]=i,t[7]=l.archive,t[8]=e,t[9]=r,t[10]=o,t[11]=p,t[12]=h,t[13]=g):g=t[13],g}),Pge=50;function $ge({onSwipeLeft:n,onSwipeRight:e}){const t=y.useRef(null),s=y.useRef(null),r=y.useRef(n),o=y.useRef(e);return r.current=n,o.current=e,y.useEffect(()=>{const i=t.current;if(!i)return;function l(u){const d=u.touches[0];s.current={x:d.clientX,y:d.clientY}}function c(u){var p,h;if(!s.current)return;const d=u.changedTouches[0],f=d.clientX-s.current.x,m=d.clientY-s.current.y;s.current=null,!(Math.abs(f)<Pge||Math.abs(f)<Math.abs(m))&&(f>0?(p=o.current)==null||p.call(o):(h=r.current)==null||h.call(r))}return i.addEventListener("touchstart",l,{passive:!0}),i.addEventListener("touchend",c,{passive:!0}),()=>{i.removeEventListener("touchstart",l),i.removeEventListener("touchend",c)}},[]),t}const W3=["sessions","chat","workspace"];function q3(n,e,t){const s=n.indexOf(e);return s===-1?null:n[s+t]??null}function Rge(n){var R;const e=q.c(46),{panels:t,context:s,activePanelId:r,active:o,onSelectPanel:i,onClosePanel:l,actions:c,actionContent:u}=n;let d;e[0]!==c?(d=c===void 0?[]:c,e[0]=c,e[1]=d):d=e[1];const f=d;let m,p,h,g,x,b,w,v;if(e[2]!==f||e[3]!==r||e[4]!==s||e[5]!==l||e[6]!==i||e[7]!==t){p=D0(t,s);let L;e[16]!==r?(L=F=>F.id===r,e[16]=r,e[17]=L):L=e[17],h=p.find(L);let O;e[18]!==f?(O=f.find(Lge),e[18]=f,e[19]=O):O=e[19],m=O,v=(m==null?void 0:m.title)??(h==null?void 0:h.title);let $;e[20]!==s.projectPath?($=(R=s.projectPath)==null?void 0:R.split(/[/\\]/).filter(Boolean).at(-1),e[20]=s.projectPath,e[21]=$):$=e[21];const M=$;g="Workspace",x="flex min-h-0 min-w-0 flex-1 flex-col";const D=v?a.jsxs(a.Fragment,{children:[a.jsx(J,{variant:"ghost",size:"icon-lg",onClick:l,"aria-label":"All workspace tools",children:a.jsx(Q1,{"data-icon":"inline-start"})}),a.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:v}),a.jsx(J,{variant:"outline",onClick:l,children:"Switch"})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[a.jsx("h1",{className:"text-base font-medium",children:"Workspace"}),M&&a.jsx("span",{className:"truncate text-xs text-muted-foreground",title:s.projectPath??void 0,children:M})]});e[22]!==D?(b=a.jsx("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3",children:D}),e[22]=D,e[23]=b):b=e[23],w=!v&&a.jsx("div",{className:"mobile-scroll min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("nav",{"aria-label":"Workspace tools",className:"grid grid-cols-2 gap-2",children:[p.map(F=>{var W;const z=F.icon,B=F.indicator,U=(W=F.badge)==null?void 0:W.call(F,s);return a.jsxs(J,{variant:"outline","aria-label":F.title,className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:()=>i(F.id),children:[a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsxs("span",{className:"relative",children:[a.jsx(z,{"data-icon":"inline-start"}),B&&a.jsx(B,{context:s,active:!1})]}),U!=null&&a.jsx(Ue,{variant:"secondary",children:U})]}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:F.title}),a.jsx(it,{"data-icon":"inline-end"})]})]},F.id)}),f.map(Oge)]})}),e[2]=f,e[3]=r,e[4]=s,e[5]=l,e[6]=i,e[7]=t,e[8]=m,e[9]=p,e[10]=h,e[11]=g,e[12]=x,e[13]=b,e[14]=w,e[15]=v}else m=e[8],p=e[9],h=e[10],g=e[11],x=e[12],b=e[13],w=e[14],v=e[15];const k=v?"relative min-h-0 flex-1":"hidden",j=(m==null?void 0:m.id)??(h==null?void 0:h.id)??"workspace",_=m&&u;let N;e[24]!==j||e[25]!==_?(N=a.jsx(I_,{fallbackMessage:"Couldn't open this workspace tool",children:_},j),e[24]=j,e[25]=_,e[26]=N):N=e[26];const S=m?"hidden":"h-full min-h-0",C=(h==null?void 0:h.id)??"",A=o&&!m;let T;e[27]!==p||e[28]!==s||e[29]!==l||e[30]!==C||e[31]!==A?(T=a.jsx(lE,{panels:p,context:s,activePanelId:C,active:A,onClosePanel:l}),e[27]=p,e[28]=s,e[29]=l,e[30]=C,e[31]=A,e[32]=T):T=e[32];let I;e[33]!==S||e[34]!==T?(I=a.jsx("div",{className:S,children:T}),e[33]=S,e[34]=T,e[35]=I):I=e[35];let E;e[36]!==N||e[37]!==I||e[38]!==k?(E=a.jsxs("div",{className:k,children:[N,I]}),e[36]=N,e[37]=I,e[38]=k,e[39]=E):E=e[39];let P;return e[40]!==E||e[41]!==g||e[42]!==x||e[43]!==b||e[44]!==w?(P=a.jsxs("section",{"aria-label":g,className:x,children:[b,w,E]}),e[40]=E,e[41]=g,e[42]=x,e[43]=b,e[44]=w,e[45]=P):P=e[45],P}function Oge(n){const{id:e,title:t,icon:s,onSelect:r}=n;return a.jsxs(J,{variant:"outline",className:"h-auto min-h-24 min-w-0 flex-col items-start justify-between gap-3 whitespace-normal p-3 text-left",onClick:r,children:[a.jsx(s,{"data-icon":"inline-start"}),a.jsxs("span",{className:"flex w-full items-center justify-between gap-2",children:[a.jsx("span",{children:t}),a.jsx(it,{"data-icon":"inline-end"})]})]},e)}function Lge(n){return n.active}const Mge=y.lazy(()=>nt(()=>import("./PluginsDialog-CuaR5Cs1.js"),__vite__mapDeps([39,1,2,3,4])).then(n=>({default:n.PluginsDialog}))),zge=y.lazy(()=>nt(()=>import("./ConfigBrowser-CWys9Rgj.js"),__vite__mapDeps([37,1,2,32,3,4])).then(n=>({default:n.ConfigBrowser})));function Dge(n){var ae;const e=q.c(90),{navigation:t,sessionView:s,project:r,active:o}=n,{state:i}=ln(),{session:l,sessionSource:c}=yt(),u=Y_((l==null?void 0:l.sessionId)??null),d=xn("hostFiles"),f=xn("browser"),m=xn("configWrite"),[p,h]=y.useState(Fge),[g,x]=y.useState();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=de=>{x(de),h(!0)},e[0]=b):b=e[0];const w=b,v=AT(m),k=r.currentCwd??null;let j;e[1]!==v||e[2]!==k?(j={...v,projectPath:k,openSettings:w},e[1]=v,e[2]=k,e[3]=j):j=e[3];const _=pA(j),[N,S]=y.useState(null),{panels:C}=t,A=C.activeWorkspacePanel===null?N:null,T=(c==null?void 0:c.dirName)??i.pendingDirName??i.dashboardProject;let I;e[4]!==C?(I=function(){S(null),C.closeWorkspacePanel()},e[4]=C,e[5]=I):I=e[5];const E=I;let P;e[6]!==C?(P=function(le){C.closeWorkspacePanel(),S(le)},e[6]=C,e[7]=P):P=e[7];const R=P;let L;e[8]!==t.actions||e[9]!==s.chatInputRef?(L=function(le){const se=s.chatInputRef.current,me=(se==null?void 0:se.getText().trimEnd())??"";se==null||se.setText(me?`${me}
|
|
464
464
|
|
|
465
465
|
${le}
|
|
466
466
|
`:`${le}
|
|
467
|
-
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>se==null?void 0:se.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=L):L=e[10];const O=L;let $;e[11]!==c?($=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=$):$=e[12];const M=r.currentCwd??null;let D;e[13]!==d||e[14]!==f||e[15]!==O||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==$||e[23]!==M?(D={session:l,sessionAddress:$,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:O,crew:u},e[13]=d,e[14]=f,e[15]=O,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=$,e[23]=M,e[24]=D):D=e[24];const F=D,z=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==O?(B=de=>O(FA(de)),e[25]=O,e[26]=B):B=e[26];let U;e[27]!==t.actions||e[28]!==r.processPanel?(U=(...de)=>{const le=de;r.processPanel.handleToggleServer(...le),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=U):U=e[29];let W;e[30]!==t.actions?(W=de=>{t.actions.handleDashboardSelect(de.dirName,`${de.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let V;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==z||e[40]!==B||e[41]!==U||e[42]!==W||e[43]!==T?(V={projectFilesRoot:z,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:U,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=z,e[40]=B,e[41]=U,e[42]=W,e[43]=T,e[44]=V):V=e[44];let H;e[45]!==C.activeWorkspacePanel||e[46]!==_?(H=((ae=G_(C.activeWorkspacePanel,_))==null?void 0:ae.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=H):H=e[47];let K;e[48]!==C?(K=de=>{S(null),C.openWorkspacePanel(de)},e[48]=C,e[49]=K):K=e[49];let Z;e[50]!==m?(Z=m?[{id:"plugins",title:"Plugins",icon:J1,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Z):Z=e[51];const Y=A==="mission";let X;e[52]!==R?(X=()=>R("mission"),e[52]=R,e[53]=X):X=e[53];let ee;e[54]!==Y||e[55]!==X?(ee={id:"mission",title:"Mission Control",icon:Uj,active:Y,onSelect:X},e[54]=Y,e[55]=X,e[56]=ee):ee=e[56];let Q;e[57]!==m||e[58]!==R||e[59]!==A?(Q=m?[{id:"config",title:"Config",icon:Bj,active:A==="config",onSelect:()=>R("config")}]:[],e[57]=m,e[58]=R,e[59]=A,e[60]=Q):Q=e[60];let ne;e[61]!==Z||e[62]!==ee||e[63]!==Q?(ne=[...Z,ee,...Q],e[61]=Z,e[62]=ee,e[63]=Q,e[64]=ne):ne=e[64];let te;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==A||e[69]!==i.configFilePath?(te=A==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(lf,{navigation:t})}):A==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Cm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(zge,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=A,e[69]=i.configFilePath,e[70]=te):te=e[70];let re;e[71]!==o||e[72]!==E||e[73]!==F||e[74]!==H||e[75]!==K||e[76]!==ne||e[77]!==te||e[78]!==_?(re=a.jsx(Rge,{panels:_,context:F,activePanelId:H,active:o,onSelectPanel:K,onClosePanel:E,actions:ne,actionContent:te}),e[71]=o,e[72]=E,e[73]=F,e[74]=H,e[75]=K,e[76]=ne,e[77]=te,e[78]=_,e[79]=re):re=e[79];let oe;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(oe=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Mge,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=oe):oe=e[85];let ie;return e[86]!==V||e[87]!==re||e[88]!==oe?(ie=a.jsxs(iE,{value:V,children:[re,oe]}),e[86]=V,e[87]=re,e[88]=oe,e[89]=ie):ie=e[89],ie}function Fge(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const Uge=y.lazy(()=>nt(()=>import("./MobileFileChanges-Ie2O9iTa.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function Bge(n){const e=q.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=ln(),{session:c}=yt(),[u,d]=y.useState(!1),{AccountControl:f}=Tr(),m=R4(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=q3(W3,i.mobileTab,1);K&&(C1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=q3(W3,i.mobileTab,-1);K&&(C1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=$ge(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,k=o.backgroundServers;let j,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(O5,{}),_=a.jsx(R5,{}),e[12]=j,e[13]=_):(j=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(O0,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(zA,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",A=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let I;e[21]!==T?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=I):I=e[22];let E;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(E=a.jsx(Wge,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=E):E=e[29];let P;e[30]!==A||e[31]!==I||e[32]!==E||e[33]!==C?(P=a.jsx("div",{"aria-hidden":C,inert:A,className:I,children:E}),e[30]=A,e[31]=I,e[32]=E,e[33]=C,e[34]=P):P=e[34];const R=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace",O=i.mobileTab!=="workspace"&&"hidden";let $;e[35]!==O?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",O),e[35]=O,e[36]=$):$=e[36];const M=i.mobileTab==="workspace";let D;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(D=a.jsx(Dge,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=D):D=e[42];let F;e[43]!==R||e[44]!==L||e[45]!==$||e[46]!==D?(F=a.jsx("div",{"aria-hidden":R,inert:L,className:$,children:D}),e[43]=R,e[44]=L,e[45]=$,e[46]=D,e[47]=F):F=e[47];let z;e[48]!==m||e[49]!==t.panels?(z=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(DA,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=z):z=e[50];let B;e[51]!==g||e[52]!==P||e[53]!==F||e[54]!==z||e[55]!==S?(B=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,P,F,z]}),e[51]=g,e[52]=P,e[53]=F,e[54]=z,e[55]=S,e[56]=B):B=e[56];let U;e[57]!==v||e[58]!==i.mobileTab?(U=a.jsx(Tge,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=U):U=e[59];let W;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(W=a.jsx(H_,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=W):W=e[63];let V;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(V=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Uge,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=V):V=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==B||e[74]!==U||e[75]!==W||e[76]!==V||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[k,j,_,N,B,o.workflowsPanel,U,o.undoDialog,o.branchModal,W,V]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=B,e[74]=U,e[75]=W,e[76]=V,e[77]=N,e[78]=H):H=e[78],H}function Wge(n){const e=q.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=ln(),{session:f,isSubAgentView:m}=yt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(Ige,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(rm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(kA,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),ht("terminal")&&a.jsxs(J,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(ya,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(lf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function qge(n){const e=q.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=ln(),{session:d}=yt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(rm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(km,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Cn,{className:"max-w-md",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:s?a.jsx(Vs,{}):a.jsx(vt,{className:"animate-spin"})}),a.jsx(En,{children:s?"Unable to open session":"Opening session"}),a.jsx(Tn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}const Vge=5;function UA(){const n=Jt(),e=Zn();return e===null?n:`${n}:${e}`}function zu(n,e){return`${UA()}:${n}/${e}`}class Hge{constructor(){Ze(this,"cache",new Map)}get(e,t){const s=zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=zu(e,t);!this.cache.has(u)&&this.cache.size>=Vge&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(zu(e,t)):this.evictLRU()}evictSession(e){const t=`${UA()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&rx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const Ss=new Hge,V3={};function BA(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(V3),[x,b]=y.useState(null),[w,v]=y.useState(null),[k,j]=y.useState(Mi),_=y.useRef(""),N=y.useRef(null),S=y.useRef(Mi),C=y.useRef("disconnected"),A=y.useRef(e);A.current=e;const T=y.useRef(r);T.current=r;const I=y.useRef(t);I.current=t;const E=y.useRef(s);E.current=s;const P=y.useRef(o??null);P.current=o??null;const R=y.useRef(!1),L=(n==null?void 0:n.dirName)??null,O=(n==null?void 0:n.fileName)??null,$=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode($).byteLength;return y.useEffect(()=>{if(_.current=$,!$){N.current=null,l(!1);return}const D=P.current;if(D){N.current=D;return}I.current($).then(F=>{N.current=ta(F,Vr(n==null?void 0:n.dirName).instanceId)})},[$,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!L||!O){l(!1),u("disconnected");return}u("connecting");const D=`/api/watch/${encodeURIComponent(L)}/${encodeURIComponent(O)}?offset=${M}`,F=Bx(D),z=F.source;let B=null;const U=(le=3e4)=>{B&&clearTimeout(B),B=setTimeout(()=>{l(!1),f(!1)},le)};let W="",V=M,H=!1,K=!1,Z=!1,Y=null;const X=()=>{Z=!1,Y=null,N.current&&A.current(N.current)},ee=()=>{Z||(Z=!0,Y=requestAnimationFrame(X))};let Q=!1,ne=null,te=null;const re=()=>{Q=!1,ne=null,j(S.current)},oe=()=>{Q||(Q=!0,ne=requestAnimationFrame(re))},ie=le=>{le!==S.current&&(S.current=le,oe(),le.length>0&&!te&&(te=setInterval(()=>{const se=hq(S.current);se!==S.current&&(S.current=se,oe()),S.current.length===0&&te&&(clearInterval(te),te=null)},5e3)))},ae=()=>{ie(Mi),g(V3)},de=()=>{if(K||H||!W)return;const le=W;W="",H=!0;const se=N.current;(se?E.current(se,le):I.current(_.current)).then(ue=>{const ce=ta(ue,Vr(L).instanceId);K||(N.current=ce,L&&O&&Ss.update(L,O,{parsed:ce,source:{rawText:_.current,watchOffset:V}}),ee())}).catch(ue=>{console.error("[useLiveSession] worker parse failed:",ue)}).finally(()=>{H=!1,!K&&W&&de()})};return z.onopen=()=>{var le;if(C.current!=="connected"){const se=R.current;R.current=!1,C.current="connected",u("connected"),se&&((le=T.current)==null||le.call(T))}},z.onmessage=le=>{try{C.current!=="connected"&&(C.current="connected",u("connected"));const se=JSON.parse(le.data);if(se.type==="init")se.recentlyActive?(l(!0),U(5e3)):U();else if(se.type==="compacting")se.active&&(l(!0),ae(),U()),f(se.active===!0);else if(se.type==="subagent_activity")l(!0),U();else if(se.type==="runtime_activity")l(!0),U();else if(se.type==="stream_snapshot")l(!0),U(),ie(fq(se.messages??[]));else if(se.type==="stream_delta")l(!0),U(),p(null),b(null),v(null),ie(mq(S.current,se.events??[]));else if(se.type==="rate_limit")v(se.block??null);else if(se.type==="agent_progress")l(!0),U(),g(me=>({...me,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")b(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")ae(),f(!1);else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),U(),ie(pq(S.current,se.lines));const me=se.lines.join(`
|
|
467
|
+
`),t.actions.handleMobileTabChange("chat"),requestAnimationFrame(()=>se==null?void 0:se.focus())},e[8]=t.actions,e[9]=s.chatInputRef,e[10]=L):L=e[10];const O=L;let $;e[11]!==c?($=c?{dirName:c.dirName,fileName:c.fileName}:null,e[11]=c,e[12]=$):$=e[12];const M=r.currentCwd??null;let D;e[13]!==d||e[14]!==f||e[15]!==O||e[16]!==t.handlers.handleLoadSessionScrollAware||e[17]!==u||e[18]!==r.hasFileChanges||e[19]!==r.supportsWorktrees||e[20]!==l||e[21]!==i.sessionChangeKey||e[22]!==$||e[23]!==M?(D={session:l,sessionAddress:$,sessionChangeKey:i.sessionChangeKey,projectPath:M,hasFileChanges:r.hasFileChanges,canAccessHostFiles:d,canUseBrowser:f,supportsWorktrees:r.supportsWorktrees,openSession:t.handlers.handleLoadSessionScrollAware,composePrompt:O,crew:u},e[13]=d,e[14]=f,e[15]=O,e[16]=t.handlers.handleLoadSessionScrollAware,e[17]=u,e[18]=r.hasFileChanges,e[19]=r.supportsWorktrees,e[20]=l,e[21]=i.sessionChangeKey,e[22]=$,e[23]=M,e[24]=D):D=e[24];const F=D,z=r.projectFilesRoot??r.currentCwd??null;let B;e[25]!==O?(B=de=>O(FA(de)),e[25]=O,e[26]=B):B=e[26];let U;e[27]!==t.actions||e[28]!==r.processPanel?(U=(...de)=>{const le=de;r.processPanel.handleToggleServer(...le),t.actions.handleMobileTabChange("chat")},e[27]=t.actions,e[28]=r.processPanel,e[29]=U):U=e[29];let W;e[30]!==t.actions?(W=de=>{t.actions.handleDashboardSelect(de.dirName,`${de.sessionId}.jsonl`)},e[30]=t.actions,e[31]=W):W=e[31];let V;e[32]!==t.handlers.handleLoadSessionScrollAware||e[33]!==t.handlers.handleMobileJumpToTurn||e[34]!==r.backgroundAgents||e[35]!==r.processPanel.handleServersChanged||e[36]!==r.projectFilesRequest||e[37]!==r.worktrees||e[38]!==s.searchInputRef||e[39]!==z||e[40]!==B||e[41]!==U||e[42]!==W||e[43]!==T?(V={projectFilesRoot:z,projectFilesRequest:r.projectFilesRequest,backgroundAgents:r.backgroundAgents,searchInputRef:s.searchInputRef,addProjectContext:B,jumpToTurn:t.handlers.handleMobileJumpToTurn,toggleServer:U,serversChanged:r.processPanel.handleServersChanged,loadSession:t.handlers.handleLoadSessionScrollAware,worktrees:r.worktrees,worktreeDirName:T,openWorktreeSession:W},e[32]=t.handlers.handleLoadSessionScrollAware,e[33]=t.handlers.handleMobileJumpToTurn,e[34]=r.backgroundAgents,e[35]=r.processPanel.handleServersChanged,e[36]=r.projectFilesRequest,e[37]=r.worktrees,e[38]=s.searchInputRef,e[39]=z,e[40]=B,e[41]=U,e[42]=W,e[43]=T,e[44]=V):V=e[44];let H;e[45]!==C.activeWorkspacePanel||e[46]!==_?(H=((ae=G_(C.activeWorkspacePanel,_))==null?void 0:ae.id)??C.activeWorkspacePanel,e[45]=C.activeWorkspacePanel,e[46]=_,e[47]=H):H=e[47];let K;e[48]!==C?(K=de=>{S(null),C.openWorkspacePanel(de)},e[48]=C,e[49]=K):K=e[49];let Z;e[50]!==m?(Z=m?[{id:"plugins",title:"Plugins",icon:J1,active:!1,onSelect:()=>h(!0)}]:[],e[50]=m,e[51]=Z):Z=e[51];const Y=A==="mission";let X;e[52]!==R?(X=()=>R("mission"),e[52]=R,e[53]=X):X=e[53];let ee;e[54]!==Y||e[55]!==X?(ee={id:"mission",title:"Mission Control",icon:Uj,active:Y,onSelect:X},e[54]=Y,e[55]=X,e[56]=ee):ee=e[56];let Q;e[57]!==m||e[58]!==R||e[59]!==A?(Q=m?[{id:"config",title:"Config",icon:Bj,active:A==="config",onSelect:()=>R("config")}]:[],e[57]=m,e[58]=R,e[59]=A,e[60]=Q):Q=e[60];let ne;e[61]!==Z||e[62]!==ee||e[63]!==Q?(ne=[...Z,ee,...Q],e[61]=Z,e[62]=ee,e[63]=Q,e[64]=ne):ne=e[64];let te;e[65]!==m||e[66]!==t||e[67]!==r.currentCwd||e[68]!==A||e[69]!==i.configFilePath?(te=A==="mission"?a.jsx("div",{className:"flex h-full min-h-0 flex-col",children:a.jsx(lf,{navigation:t})}):A==="config"&&m?a.jsx(y.Suspense,{fallback:a.jsx(Cm,{label:"Loading configuration…"}),children:a.jsx("div",{className:"flex h-full min-h-0",children:a.jsx(zge,{projectPath:r.currentCwd??null,initialFilePath:i.configFilePath})})}):null,e[65]=m,e[66]=t,e[67]=r.currentCwd,e[68]=A,e[69]=i.configFilePath,e[70]=te):te=e[70];let re;e[71]!==o||e[72]!==E||e[73]!==F||e[74]!==H||e[75]!==K||e[76]!==ne||e[77]!==te||e[78]!==_?(re=a.jsx(Rge,{panels:_,context:F,activePanelId:H,active:o,onSelectPanel:K,onClosePanel:E,actions:ne,actionContent:te}),e[71]=o,e[72]=E,e[73]=F,e[74]=H,e[75]=K,e[76]=ne,e[77]=te,e[78]=_,e[79]=re):re=e[79];let oe;e[80]!==m||e[81]!==g||e[82]!==p||e[83]!==r.currentCwd||e[84]!==v?(oe=p&&m&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Mge,{client:v.client,state:v,currentPath:r.currentCwd??null,initialPluginId:g,onClose:()=>{h(!1),x(void 0)}})}),e[80]=m,e[81]=g,e[82]=p,e[83]=r.currentCwd,e[84]=v,e[85]=oe):oe=e[85];let ie;return e[86]!==V||e[87]!==re||e[88]!==oe?(ie=a.jsxs(iE,{value:V,children:[re,oe]}),e[86]=V,e[87]=re,e[88]=oe,e[89]=ie):ie=e[89],ie}function Fge(){return new URLSearchParams(window.location.search).get("pluginSafeMode")==="1"}const Uge=y.lazy(()=>nt(()=>import("./MobileFileChanges-B0k6kNod.js"),__vite__mapDeps([40,1,2,3,4])).then(n=>({default:n.MobileFileChanges})));function Bge(n){const e=q.c(79),{navigation:t,sessionView:s,project:r,chrome:o}=n,{state:i,config:l}=ln(),{session:c}=yt(),[u,d]=y.useState(!1),{AccountControl:f}=Tr(),m=R4(i.mainView==="extension"?i.extensionViewId:null),p=i.mobileTab==="workspace"||(m==null?void 0:m.locksSwipe)===!0;let h;e[0]!==t.actions||e[1]!==i.mobileTab||e[2]!==p?(h={onSwipeLeft:()=>{if(p)return;const K=q3(W3,i.mobileTab,1);K&&(C1(),t.actions.handleMobileTabChange(K))},onSwipeRight:()=>{if(p)return;const K=q3(W3,i.mobileTab,-1);K&&(C1(),t.actions.handleMobileTabChange(K))}},e[0]=t.actions,e[1]=i.mobileTab,e[2]=p,e[3]=h):h=e[3];const g=$ge(h);let x;e[4]!==f||e[5]!==o.onLogout||e[6]!==t.panels?(x=f&&a.jsx(f,{mobile:!0,onLogout:o.onLogout,onOpenMainView:t.panels.openMainView,className:"ml-auto"}),e[4]=f,e[5]=o.onLogout,e[6]=t.panels,e[7]=x):x=e[7];const b=x;let w;e[8]!==m||e[9]!==t.actions||e[10]!==t.panels?(w=K=>{d(!1),m&&t.panels.closeMainView(),t.actions.handleMobileTabChange(K)},e[8]=m,e[9]=t.actions,e[10]=t.panels,e[11]=w):w=e[11];const v=w,k=o.backgroundServers;let j,_;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx(O5,{}),_=a.jsx(R5,{}),e[12]=j,e[13]=_):(j=e[12],_=e[13]);let N;e[14]!==b||e[15]!==c||e[16]!==i.mobileTab?(N=!(i.mobileTab==="chat"&&c)&&a.jsxs("div",{className:"motion-slide-down-in flex h-12 shrink-0 items-center border-b bg-background px-2",children:[a.jsx(O0,{compact:!0}),b]}),e[14]=b,e[15]=c,e[16]=i.mobileTab,e[17]=N):N=e[17];let S;e[18]!==t||e[19]!==i.mobileTab?(S=i.mobileTab==="sessions"&&a.jsx(zA,{navigation:t,mobile:!0}),e[18]=t,e[19]=i.mobileTab,e[20]=S):S=e[20];const C=i.mobileTab!=="chat",A=i.mobileTab!=="chat",T=i.mobileTab!=="chat"&&"invisible pointer-events-none";let I;e[21]!==T?(I=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",T),e[21]=T,e[22]=I):I=e[22];let E;e[23]!==o||e[24]!==b||e[25]!==t||e[26]!==r||e[27]!==u||e[28]!==s?(E=a.jsx(Wge,{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:b,searchOpen:u,onSearchOpenChange:d}),e[23]=o,e[24]=b,e[25]=t,e[26]=r,e[27]=u,e[28]=s,e[29]=E):E=e[29];let P;e[30]!==A||e[31]!==I||e[32]!==E||e[33]!==C?(P=a.jsx("div",{"aria-hidden":C,inert:A,className:I,children:E}),e[30]=A,e[31]=I,e[32]=E,e[33]=C,e[34]=P):P=e[34];const R=i.mobileTab!=="workspace",L=i.mobileTab!=="workspace",O=i.mobileTab!=="workspace"&&"hidden";let $;e[35]!==O?($=G("absolute inset-0 flex min-h-0 min-w-0 flex-col",O),e[35]=O,e[36]=$):$=e[36];const M=i.mobileTab==="workspace";let D;e[37]!==o||e[38]!==t||e[39]!==r||e[40]!==s||e[41]!==M?(D=a.jsx(Dge,{navigation:t,sessionView:s,project:r,chrome:o,active:M}),e[37]=o,e[38]=t,e[39]=r,e[40]=s,e[41]=M,e[42]=D):D=e[42];let F;e[43]!==R||e[44]!==L||e[45]!==$||e[46]!==D?(F=a.jsx("div",{"aria-hidden":R,inert:L,className:$,children:D}),e[43]=R,e[44]=L,e[45]=$,e[46]=D,e[47]=F):F=e[47];let z;e[48]!==m||e[49]!==t.panels?(z=m&&a.jsx("div",{className:"absolute inset-0 z-10 flex min-h-0 min-w-0 flex-col bg-canvas",children:a.jsx(DA,{view:m,onClose:t.panels.closeMainView})}),e[48]=m,e[49]=t.panels,e[50]=z):z=e[50];let B;e[51]!==g||e[52]!==P||e[53]!==F||e[54]!==z||e[55]!==S?(B=a.jsxs("main",{ref:g,className:"app-view-transition relative flex flex-1 min-h-0 overflow-hidden",children:[S,P,F,z]}),e[51]=g,e[52]=P,e[53]=F,e[54]=z,e[55]=S,e[56]=B):B=e[56];let U;e[57]!==v||e[58]!==i.mobileTab?(U=a.jsx(Tge,{activeTab:i.mobileTab,onTabChange:v}),e[57]=v,e[58]=i.mobileTab,e[59]=U):U=e[59];let W;e[60]!==l.defaultAgentKind||e[61]!==t.onStartNewFolder||e[62]!==t.onStartNewSession?(W=a.jsx(H_,{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:l.defaultAgentKind}),e[60]=l.defaultAgentKind,e[61]=t.onStartNewFolder,e[62]=t.onStartNewSession,e[63]=W):W=e[63];let V;e[64]!==o||e[65]!==r||e[66]!==c||e[67]!==i.sessionChangeKey?(V=c&&r.hasFileChanges&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Uge,{open:o.fileChangesOpen,onClose:()=>o.onFileChangesOpenChange(!1),session:c,sessionChangeKey:i.sessionChangeKey})}),e[64]=o,e[65]=r,e[66]=c,e[67]=i.sessionChangeKey,e[68]=V):V=e[68];let H;return e[69]!==o.backgroundServers||e[70]!==o.branchModal||e[71]!==o.undoDialog||e[72]!==o.workflowsPanel||e[73]!==B||e[74]!==U||e[75]!==W||e[76]!==V||e[77]!==N?(H=a.jsxs("div",{className:"flex h-dvh flex-col bg-canvas text-foreground",children:[k,j,_,N,B,o.workflowsPanel,U,o.undoDialog,o.branchModal,W,V]}),e[69]=o.backgroundServers,e[70]=o.branchModal,e[71]=o.undoDialog,e[72]=o.workflowsPanel,e[73]=B,e[74]=U,e[75]=W,e[76]=V,e[77]=N,e[78]=H):H=e[78],H}function Wge(n){const e=q.c(23),{navigation:t,sessionView:s,project:r,chrome:o,headerAccessory:i,searchOpen:l,onSearchOpenChange:c}=n,{state:u,config:d}=ln(),{session:f,isSubAgentView:m}=yt();let p;e[0]!==o||e[1]!==d||e[2]!==i||e[3]!==m||e[4]!==t||e[5]!==c||e[6]!==r||e[7]!==l||e[8]!==f||e[9]!==s||e[10]!==u.expandAll||e[11]!==u.pendingDirName?(p=f?a.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[s.teamMembersBar,a.jsx(Ige,{headerAccessory:i,creatingSession:t.creatingSession,onNewSession:t.onStartNewSession,onDuplicateSession:t.handlers.handleDuplicateSession,onBackToMain:m?s.onBackToMain:void 0,onShowFileChanges:()=>o.onFileChangesOpenChange(!0),hasFileChanges:r.hasFileChanges,onShowWorkflows:s.onShowWorkflows,workflowCount:s.workflowCount,onSearch:()=>c(!0),expandAll:u.expandAll,onToggleExpandAll:s.onToggleExpandAll}),a.jsx(rm,{searchInputRef:s.searchInputRef,hasMore:s.hasMoreTurns,isLoadingOlder:s.isLoadingOlderTurns,onLoadMore:s.onLoadMoreTurns,mobileSearchOpen:l,onMobileSearchClose:()=>c(!1)})]}):u.pendingDirName?a.jsx("div",{className:"flex flex-1 min-h-0 flex-col",children:s.pendingTurns.length>0?a.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-3",children:s.pendingTurns}):a.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 px-4",children:[a.jsx(kA,{projectPath:s.pendingPath??null,switcher:{onNewSession:t.onStartNewSession,onNewFolder:t.onStartNewFolder,defaultAgentKind:d.defaultAgentKind}}),ht("terminal")&&a.jsxs(J,{variant:"outline",size:"xs",onClick:r.onOpenTerminal,children:[a.jsx(ya,{"data-icon":"inline-start"}),"Terminal"]})]})}):a.jsx(lf,{navigation:t}),e[0]=o,e[1]=d,e[2]=i,e[3]=m,e[4]=t,e[5]=c,e[6]=r,e[7]=l,e[8]=f,e[9]=s,e[10]=u.expandAll,e[11]=u.pendingDirName,e[12]=p):p=e[12];let h;e[13]!==f||e[14]!==s||e[15]!==u.pendingDirName?(h=(f||u.pendingDirName)&&a.jsxs(a.Fragment,{children:[s.todoProgress,f?s.activeComposer:s.pendingComposer]}),e[13]=f,e[14]=s,e[15]=u.pendingDirName,e[16]=h):h=e[16];let g;e[17]!==o.processPanel||e[18]!==h?(g=a.jsxs("div",{className:"shrink-0",children:[o.processPanel,h]}),e[17]=o.processPanel,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==p||e[21]!==g?(x=a.jsxs(a.Fragment,{children:[p,g]}),e[20]=p,e[21]=g,e[22]=x):x=e[22],x}function qge(n){const e=q.c(10),{sessionId:t,loadError:s,searchInputRef:r,activeComposer:o,hasMoreTurns:i,isLoadingOlderTurns:l,onLoadMoreTurns:c}=n,{isMobile:u}=ln(),{session:d}=yt();let f;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==u||e[4]!==s||e[5]!==c||e[6]!==r||e[7]!==d||e[8]!==t?(f=a.jsx("div",{className:"flex h-dvh flex-col overflow-hidden bg-canvas text-foreground",children:d?a.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[a.jsx(rm,{searchInputRef:r,hasMore:i,isLoadingOlder:l,onLoadMore:c}),u?o:a.jsx(km,{floating:!0,children:o})]}):a.jsx("main",{className:"flex min-h-0 flex-1 items-center justify-center p-6",children:a.jsx(Cn,{className:"max-w-md",children:a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:s?a.jsx(Vs,{}):a.jsx(vt,{className:"animate-spin"})}),a.jsx(En,{children:s?"Unable to open session":"Opening session"}),a.jsx(Tn,{children:s??`Looking for ${t} in your local Claude, Codex, and Copilot history.`})]})})})}),e[0]=o,e[1]=i,e[2]=l,e[3]=u,e[4]=s,e[5]=c,e[6]=r,e[7]=d,e[8]=t,e[9]=f):f=e[9],f}const Vge=5;function UA(){const n=Jt(),e=Zn();return e===null?n:`${n}:${e}`}function zu(n,e){return`${UA()}:${n}/${e}`}class Hge{constructor(){Ze(this,"cache",new Map)}get(e,t){const s=zu(e,t),r=this.cache.get(s);return r&&(r.lastAccessed=Date.now()),r}set(e,t,s,r,o,i,l,c){const u=zu(e,t);!this.cache.has(u)&&this.cache.size>=Vge&&this.evictLRU(),this.cache.set(u,{parsed:s,olderTurns:[],source:{dirName:e,fileName:t,rawText:r,agentKind:l,...c!==void 0?{watchOffset:c}:{}},nextByteOffset:o,hasMore:i,lastAccessed:Date.now()})}update(e,t,s){const r=zu(e,t),o=this.cache.get(r);o&&(s.parsed!==void 0&&(o.parsed=s.parsed),s.olderTurns!==void 0&&(o.olderTurns=s.olderTurns),s.nextByteOffset!==void 0&&(o.nextByteOffset=s.nextByteOffset),s.hasMore!==void 0&&(o.hasMore=s.hasMore),s.lastAccessed!==void 0&&(o.lastAccessed=s.lastAccessed),s.source&&(o.source={...o.source,...s.source}))}evict(e,t){e!==void 0&&t!==void 0?this.cache.delete(zu(e,t)):this.evictLRU()}evictSession(e){const t=`${UA()}:`;for(const[s,{source:r}]of this.cache)s.startsWith(t)&&rx(r.dirName,r.fileName)===e&&this.cache.delete(s)}clear(){this.cache.clear()}evictLRU(){let e,t=1/0;for(const[s,r]of this.cache)r.lastAccessed<t&&(t=r.lastAccessed,e=s);e!==void 0&&this.cache.delete(e)}}const Ss=new Hge,V3={};function BA(n,e,t,s,r,o){const[i,l]=y.useState(!1),[c,u]=y.useState("disconnected"),[d,f]=y.useState(!1),[m,p]=y.useState(null),[h,g]=y.useState(V3),[x,b]=y.useState(null),[w,v]=y.useState(null),[k,j]=y.useState(Mi),_=y.useRef(""),N=y.useRef(null),S=y.useRef(Mi),C=y.useRef("disconnected"),A=y.useRef(e);A.current=e;const T=y.useRef(r);T.current=r;const I=y.useRef(t);I.current=t;const E=y.useRef(s);E.current=s;const P=y.useRef(o??null);P.current=o??null;const R=y.useRef(!1),L=(n==null?void 0:n.dirName)??null,O=(n==null?void 0:n.fileName)??null,$=(n==null?void 0:n.rawText)??"",M=(n==null?void 0:n.watchOffset)??new TextEncoder().encode($).byteLength;return y.useEffect(()=>{if(_.current=$,!$){N.current=null,l(!1);return}const D=P.current;if(D){N.current=D;return}I.current($).then(F=>{N.current=ta(F,Vr(n==null?void 0:n.dirName).instanceId)})},[$,n==null?void 0:n.dirName]),y.useEffect(()=>{if(b(null),v(null),!L||!O){l(!1),u("disconnected");return}u("connecting");const D=`/api/watch/${encodeURIComponent(L)}/${encodeURIComponent(O)}?offset=${M}`,F=Bx(D),z=F.source;let B=null;const U=(le=3e4)=>{B&&clearTimeout(B),B=setTimeout(()=>{l(!1),f(!1)},le)};let W="",V=M,H=!1,K=!1,Z=!1,Y=null;const X=()=>{Z=!1,Y=null,N.current&&A.current(N.current)},ee=()=>{Z||(Z=!0,Y=requestAnimationFrame(X))};let Q=!1,ne=null,te=null;const re=()=>{Q=!1,ne=null,j(S.current)},oe=()=>{Q||(Q=!0,ne=requestAnimationFrame(re))},ie=le=>{le!==S.current&&(S.current=le,oe(),le.length>0&&!te&&(te=setInterval(()=>{const se=hq(S.current);se!==S.current&&(S.current=se,oe()),S.current.length===0&&te&&(clearInterval(te),te=null)},5e3)))},ae=()=>{ie(Mi),g(V3)},de=()=>{if(K||H||!W)return;const le=W;W="",H=!0;const se=N.current;(se?E.current(se,le):I.current(_.current)).then(ue=>{const ce=ta(ue,Vr(L).instanceId);K||(N.current=ce,L&&O&&Ss.update(L,O,{parsed:ce,source:{rawText:_.current,watchOffset:V}}),ee())}).catch(ue=>{console.error("[useLiveSession] worker parse failed:",ue)}).finally(()=>{H=!1,!K&&W&&de()})};return z.onopen=()=>{var le;if(C.current!=="connected"){const se=R.current;R.current=!1,C.current="connected",u("connected"),se&&((le=T.current)==null||le.call(T))}},z.onmessage=le=>{try{C.current!=="connected"&&(C.current="connected",u("connected"));const se=JSON.parse(le.data);if(se.type==="init")se.recentlyActive?(l(!0),U(5e3)):U();else if(se.type==="compacting")se.active&&(l(!0),ae(),U()),f(se.active===!0);else if(se.type==="subagent_activity")l(!0),U();else if(se.type==="runtime_activity")l(!0),U();else if(se.type==="stream_snapshot")l(!0),U(),ie(fq(se.messages??[]));else if(se.type==="stream_delta")l(!0),U(),p(null),b(null),v(null),ie(mq(S.current,se.events??[]));else if(se.type==="rate_limit")v(se.block??null);else if(se.type==="agent_progress")l(!0),U(),g(me=>({...me,[se.toolUseId]:se.summary}));else if(se.type==="prompt_suggestion")b(typeof se.suggestion=="string"?se.suggestion:null);else if(se.type==="turn_error")p(typeof se.message=="string"?se.message:"The turn failed");else if(se.type==="stream_clear")ae(),f(!1);else if(se.type==="lines"&&se.lines.length>0){l(!0),f(!1),U(),ie(pq(S.current,se.lines));const me=se.lines.join(`
|
|
468
468
|
`)+`
|
|
469
469
|
`;V+=new TextEncoder().encode(me).byteLength,_.current+=me,W+=me,de()}}catch(se){console.error("[useLiveSession] Error processing SSE message:",se)}},z.onerror=()=>{l(!1),f(!1),R.current=C.current==="connected",C.current="disconnected",u("disconnected"),ae()},()=>{K=!0,F.close(),l(!1),C.current="disconnected",u("disconnected"),B&&clearTimeout(B),Y!==null&&cancelAnimationFrame(Y),ne!==null&&cancelAnimationFrame(ne),te&&clearInterval(te),S.current=Mi,j(Mi)}},[L,O,$,M]),{isLive:i,sseState:c,isCompacting:d,streamingOverlay:k,turnError:m,agentProgress:h,promptSuggestion:x,rateLimit:w}}const Kge=3e4;function WA(n,e,t){const s=q.c(12);let r;s[0]!==t?(r=t===void 0?{}:t,s[0]=t,s[1]=r):r=s[1];const{onLost:o,staleAfterMs:i}=r,l=i===void 0?Kge:i,[c,u]=y.useState(!1),d=y.useRef(e),f=y.useRef(o);let m,p;s[2]!==o||s[3]!==e?(m=()=>{d.current=e,f.current=o},p=[e,o],s[2]=o,s[3]=e,s[4]=m,s[5]=p):(m=s[4],p=s[5]),y.useEffect(m,p);let h,g;s[6]!==l||s[7]!==n?(h=()=>{if(!n){u(!1);return}let b=!0,w=null;const v=Bx(n,{onLost:()=>{var _;return(_=f.current)==null?void 0:_.call(f)}}),k=v.source;u(!1);const j=()=>{w&&clearTimeout(w),w=setTimeout(()=>{b&&u(!1)},l)};return k.onmessage=_=>{if(b)try{const N=JSON.parse(_.data);N.type==="init"?j():N.type==="update"&&(u(!0),j(),d.current())}catch{}},k.onerror=()=>{b&&u(!1)},()=>{b=!1,v.close(),w&&clearTimeout(w)}},g=[n,l],s[6]=l,s[7]=n,s[8]=h,s[9]=g):(h=s[8],g=s[9]),y.useEffect(h,g);let x;return s[10]!==c?(x={isLive:c},s[10]=c,s[11]=x):x=s[11],x}function Gge(n,e,t){const s=q.c(2),r=n?`/api/team-watch/${encodeURIComponent(n)}`:null;let o;return s[0]!==t?(o={onLost:t},s[0]=t,s[1]=o):o=s[1],WA(r,e,o)}function Zge(n,e){const[t,s]=y.useState(null),r=y.useRef(null),o=(()=>{if(!n)return null;let c,u=null;const d=n.match(/^([^/]+)\/subagents\/(.+)$/);d?(c=d[1],u=d[2]):c=n.replace(".jsonl","");const f=new URLSearchParams({leadSessionId:c});return u&&f.set("subagentFile",u),e&&f.set("dirName",e),f.toString()})();r.current=o;const i=y.useCallback(async()=>{const c=r.current;if(c)try{const u=await Ee(`/api/session-team?${c}`);if(!u.ok){s(null);return}const d=await u.json();s(d?{teamName:d.teamName,config:d.config,currentMemberName:d.currentMemberName||null}:null)}catch{s(null)}},[]);y.useEffect(()=>{if(!n){s(null);return}i()},[n,i]);const l=y.useCallback(()=>s(null),[]);return Gge((t==null?void 0:t.teamName)??null,i,l),t}function Yge(n,e,t,s){let r=null;return n&&e&&(r=`/api/workflow-watch/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,t&&(r=r+`/${encodeURIComponent(t)}`)),WA(r,s)}function Xge(n,e,t=!0){const[s,r]=y.useState([]),[o,i]=y.useState(!1),l=y.useRef(0),c=!!n&&!!e,u=y.useCallback(async()=>{const m=++l.current;if(!c){r([]);return}try{const p=await Ee(`/api/workflows/${encodeURIComponent(n)}/${encodeURIComponent(e)}`);if(!p.ok){m===l.current&&r([]);return}const h=await p.json();m===l.current&&r(Array.isArray(h)?h:[])}catch{m===l.current&&r([])}finally{m===l.current&&i(!1)}},[c,n,e]);y.useEffect(()=>{if(!c){r([]),i(!1);return}i(!0),u()},[c,u]);const d=c&&(t||s.length>0),{isLive:f}=Yge(d?n:null,d?e:null,null,u);return{workflows:s,loading:o,isLive:f,refetch:u}}function Jge(n){if(!n)return!1;const e=n.toLowerCase();return e.includes("issue with the selected model")||e.includes("selected model")&&e.includes("may not exist or you may not have access")||e.includes("run --model to pick a different model")}async function _1(n,e){const t=await n.json().catch(()=>({}));return{message:typeof t.error=="string"&&t.error?t.error:e,code:typeof t.code=="string"?t.code:null}}async function H3(n){if(n.status!==202)return null;const e=await n.clone().json().catch(()=>null);return(e==null?void 0:e.receipt)??null}async function qA(n,e){const{model:t,agentKind:s,errorFallback:r,onModelRejected:o}=e,i=m=>typeof r=="function"?r(m):r;let c=await n(s==="copilot"?t||"auto":t||void 0),u=c.ok?null:await _1(c,i(c)),d=!1,f=await H3(c);return f&&s==="codex"&&t&&(d=!0,Qge(f,n,e)),!c.ok&&s==="codex"&&t&&Jge(u==null?void 0:u.message)&&(o==null||o(t),c=await n(void 0),u=c.ok?null:await _1(c,i(c)),f=await H3(c)),{res:c,errorMessage:(u==null?void 0:u.message)??null,errorCode:(u==null?void 0:u.code)??null,observingReceipt:d,receipt:f}}function Qge(n,e,t){var u;const s=Sf(n.sessionId);let r=!1,o=()=>{};const i=()=>{var d,f;r||(r=!0,clearTimeout(l),o(),(d=t.signal)==null||d.removeEventListener("abort",i),(f=t.onReceiptSettled)==null||f.call(t))},l=setTimeout(i,1440*60*1e3),c=()=>{var m,p,h;if(r)return;const d=s.snapshot();if((m=t.signal)!=null&&m.aborted||d.error==="Account or device changed"||/Queue unavailable \((401|403|404)\)/.test(d.error??"")){i();return}if(d.freshness!=="current")return;const f=d.commands.find(g=>g.id===n.id);!f||!["failed","completed","cancelled","unknown"].includes(f.state)||(i(),!(f.state!=="failed"||f.errorCode!=="MODEL_REJECTED"||f.delivery||f.turnId||((p=d.conversation)==null?void 0:p.revision)!==n.bindingRevision||d.conversation.binding.sessionId!==n.sessionId)&&((h=t.onModelRejected)==null||h.call(t,t.model),e(void 0).then(async g=>{var x;g.ok||(x=t.onDeliveryError)==null||x.call(t,(await _1(g,"The default model could not accept the message")).message)}).catch(g=>{var x;(x=t.onDeliveryError)==null||x.call(t,g instanceof Error?g.message:"Fallback delivery could not be confirmed")})))};o=s.subscribe(c),(u=t.signal)==null||u.addEventListener("abort",i,{once:!0}),c()}const e1e=[];function t1e({sessionSource:n,parsedSessionId:e,cwd:t,permissions:s,onPermissionsApplied:r,model:o,effort:i,contextWindowTokens:l,fastMode:c,ultracode:u,settingsChange:d=e1e,onSettingsChangeSent:f,mcpConfig:m,onModelRejected:p,readOnly:h=!1,onCreateSession:g}){const[x,b]=y.useState("idle"),[w,v]=y.useState(),[k,j]=y.useState([]),_=y.useRef(null),N=y.useRef(new Set),S=y.useRef(null),C=y.useRef(!1),A=n!=null&&n.fileName?vd(n.fileName):null,T=e||A,I=n?an(n.dirName):null,E=y.useCallback(()=>{var D;for(const F of N.current)F.abort();N.current.clear(),(D=_.current)==null||D.abort(),_.current=null,C.current=!1,b("idle"),v(void 0),j([])},[]);y.useEffect(()=>{var D;S.current!==T&&(C.current?(C.current=!1,(D=_.current)==null||D.abort(),_.current=null,b("idle"),v(void 0)):E(),S.current=T)},[T,E]),y.useEffect(()=>{const D=N.current;return()=>{var F;for(const z of D)z.abort();(F=_.current)==null||F.abort()}},[]),y.useEffect(()=>{h&&E()},[h,E]);const P=y.useCallback(async(D,F)=>{if(h)return!1;if(!T&&g){j(B=>[...B,D]),b("connected"),v(void 0),C.current=!0,r==null||r();try{if(!await g(D,F))return C.current=!1,b("idle"),j([]),!0;b("idle")}catch(B){C.current=!1,v(B instanceof Error?B.message:"Failed to create session"),b("error"),j([])}return!0}if(!T)return!0;j(B=>[...B,D]),b("connected"),v(void 0),r==null||r();const z=new AbortController;N.current.add(z),_.current=z;try{const B={sessionId:T,message:D,images:F||void 0,cwd:t||void 0,permissions:s,effort:i||void 0,contextWindowTokens:l,fastMode:c||d.includes("fastMode")?c:void 0,ultracode:u||d.includes("ultracode")?u:void 0,mcpConfig:m||void 0,settingsChange:d.length>0?d:void 0},{res:U,errorMessage:W,observingReceipt:V,receipt:H}=await qA(K=>EN("/api/send-message",{...B,model:K},z.signal),{model:o,agentKind:I,errorFallback:K=>`Request failed (${K.status})`,onModelRejected:p,signal:z.signal,onReceiptSettled:()=>N.current.delete(z),onDeliveryError:K=>{_.current===z&&(v(K),b("error"))}});return V||N.current.delete(z),H&&c8(H)&&j(K=>{const Z=K.lastIndexOf(D);return Z<0?K:K.filter((Y,X)=>X!==Z)}),_.current===z&&(U.ok?b("idle"):(v(W||`Request failed (${U.status})`),b("error"),j(K=>K.slice(0,-1)))),U.ok&&d.length>0&&(f==null||f()),U.ok&&!G$(U)}catch(B){return N.current.delete(z),B instanceof Error&&B.name==="AbortError"?!0:(_.current===z&&(v(B instanceof Error?B.message:"Unknown error"),b("error"),j(U=>U.slice(0,-1))),!1)}},[T,I,t,s,r,o,i,l,c,u,d,f,m,p,h,g]),R=y.useCallback(()=>{E()},[E]),L=y.useCallback(()=>{!T||h||Ee("/api/interrupt-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:T})}).catch(()=>{})},[T,h]),O=y.useCallback(()=>{var D;(D=_.current)==null||D.abort(),_.current=null,L(),b("idle"),j([])},[L]),$=O,M=y.useCallback((D=1)=>{j(F=>F.slice(D))},[]);return{status:x,error:w,pendingMessages:k,sendMessage:P,disconnect:R,interrupt:O,stopAgent:$,consumePending:M,isConnected:x==="connected"}}const Di={expandAll:!1,expandToolPayloads:!1},n1e={session:null,windowTurns:[],olderTurns:[],sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Di,sessionChangeKey:0,currentMemberName:null,loadingMember:null,mainView:"sessions",extensionViewId:null,configFilePath:null,mobileTab:"sessions",dashboardProject:null};function K3(n,e,t,s){const r=T_(e,t,s);return r===n.turns?n:{...n,turns:r}}function Du(n){return{session:n,windowTurns:(n==null?void 0:n.turns)??[],olderTurns:[]}}function s1e(n,e){var t,s;switch(e.type){case"LOAD_SESSION":case"FINALIZE_SESSION":case"INIT_PENDING_SESSION":{const r=e.type==="INIT_PENDING_SESSION";return{...n,...Du(r?null:e.session),sessionSource:r?null:e.source,pendingDirName:r?e.dirName:null,pendingCwd:r?e.cwd??null:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Di,mainView:"sessions",currentMemberName:null,dashboardProject:null,sessionChangeKey:n.sessionChangeKey+1,mobileTab:e.isMobile?"chat":n.mobileTab}}case"GO_HOME":case"CLOSE_SESSION":{const r=e.type==="GO_HOME";return{...n,...Du(null),sessionSource:null,pendingDirName:null,pendingCwd:null,activeTurnIndex:null,activeToolCallId:null,searchQuery:"",...Di,mainView:r?"sessions":n.mainView,currentMemberName:null,dashboardProject:null,mobileTab:e.isMobile&&(r||n.mobileTab==="chat")?"sessions":n.mobileTab}}case"SWITCH_TEAM_MEMBER":return{...n,...Du(e.session),sessionSource:e.source,activeTurnIndex:null,searchQuery:"",...Di,currentMemberName:e.memberName,sessionChangeKey:n.sessionChangeKey+1};case"JUMP_TO_TURN":return{...n,activeTurnIndex:e.index,activeToolCallId:e.toolCallId??null};case"SET_SEARCH_QUERY":return n.searchQuery===e.value?n:{...n,searchQuery:e.value};case"SET_EXPAND_ALL":return e.value?n.expandAll&&!n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!1}:!n.expandAll&&!n.expandToolPayloads?n:{...n,...Di};case"SET_EXPAND_TOOL_PAYLOADS":return e.value?n.expandAll&&n.expandToolPayloads?n:{...n,expandAll:!0,expandToolPayloads:!0}:n.expandToolPayloads?{...n,expandToolPayloads:!1}:n;case"TOGGLE_EXPAND_ALL":return n.expandAll?{...n,...Di}:{...n,expandAll:!0};case"SET_MOBILE_TAB":return n.mobileTab===e.tab?n:{...n,mobileTab:e.tab};case"UPDATE_SESSION":return{...n,windowTurns:e.session.turns,session:K3(e.session,e.session.turns,n.olderTurns,(t=n.sessionSource)==null?void 0:t.agentKind)};case"SET_OLDER_TURNS":return!n.session||e.turns===n.olderTurns?n:{...n,olderTurns:e.turns,session:K3(n.session,n.windowTurns,e.turns,(s=n.sessionSource)==null?void 0:s.agentKind)};case"RELOAD_SESSION_CONTENT":return{...n,...Du(e.session),sessionSource:e.source,sessionChangeKey:n.sessionChangeKey+1};case"SET_CURRENT_MEMBER_NAME":return n.currentMemberName===e.name?n:{...n,currentMemberName:e.name};case"GUARD_MOBILE_TAB":{let r=n.mobileTab;return!e.hasSession&&r==="chat"&&(r="sessions"),r!==n.mobileTab?{...n,mobileTab:r}:n}case"SET_LOADING_MEMBER":return n.loadingMember===e.name?n:{...n,loadingMember:e.name};case"SET_DASHBOARD_PROJECT":return n.dashboardProject===e.dirName?n:{...n,dashboardProject:e.dirName};case"OPEN_CONFIG":return{...n,mainView:"config",configFilePath:e.filePath??null};case"CLOSE_CONFIG":return{...n,mainView:"sessions",configFilePath:null};case"OPEN_MISSION":return{...n,mainView:"mission"};case"CLOSE_MISSION":return{...n,mainView:"sessions"};case"OPEN_EXTENSION_VIEW":return{...n,mainView:"extension",extensionViewId:e.id};case"CLOSE_EXTENSION_VIEW":return{...n,mainView:"sessions",extensionViewId:null};default:return n}}function VA(){return y.useReducer(s1e,n1e)}function G3(n){n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})}function HA({session:n,isLive:e,pendingMessages:t,consumePending:s,sessionChangeKey:r,partialSignal:o}){const i=y.useRef(null),l=y.useRef(null),c=y.useRef(!0),u=y.useRef(!1),d=y.useRef(0),f=y.useMemo(()=>(n==null?void 0:n.turns.flatMap($=>$.contentBlocks.flatMap(M=>M.kind==="queued_prompt"?[{id:JSON.stringify([M.timestamp??"",M.content]),content:M.content}]:[])))??[],[n==null?void 0:n.turns]),m=y.useRef(null),p=y.useRef(!1),[h,g]=y.useState(!1),[x,b]=y.useState(null),w=y.useCallback(()=>{requestAnimationFrame(()=>{var $;($=l.current)==null||$.scrollIntoView({behavior:"smooth"})})},[]),v=y.useCallback(()=>{G3(()=>{const $=i.current;$&&($.scrollTop=$.scrollHeight),c.current=!0,u.current=!1})},[]),k=y.useCallback(()=>{p.current=!0},[]),j=y.useRef(!1),_=y.useCallback(()=>{const $=i.current;if(!$)return;const M=$.scrollHeight-$.scrollTop-$.clientHeight>10;M!==j.current&&(j.current=M,g(M))},[]),[N,S]=y.useState(null);y.useEffect(()=>{if(!N)return;let $=0;const M=new ResizeObserver(()=>{cancelAnimationFrame($),$=requestAnimationFrame(()=>{const D=i.current;D&&c.current&&(D.scrollTop=D.scrollHeight),_()})});return M.observe(N,{box:"border-box"}),()=>{M.disconnect(),cancelAnimationFrame($)}},[N,_]);const C=y.useCallback(()=>{const $=i.current;$&&(c.current=$.scrollHeight-$.scrollTop-$.clientHeight<150,_())},[_]),A=y.useCallback($=>{d.current=$},[]),T=y.useRef(r);y.useEffect(()=>{if(r===T.current)return;T.current=r;const $=p.current;p.current=!1;const M=()=>{const F=i.current;F&&($?(F.scrollTop=0,c.current=!1):(F.scrollTop=F.scrollHeight,c.current=!0),u.current=!1)};G3(M);const D=setTimeout(()=>{M(),b(r)},150);return()=>clearTimeout(D)},[r]);const I=t.length;y.useEffect(()=>{I>0&&(u.current=!0,w())},[I,w]),y.useEffect(()=>{const $=(n==null?void 0:n.sessionId)??null,M=m.current,D=new Set(f.map(B=>B.id));if(!M||M.sessionId!==$){m.current={sessionId:$,ids:D};return}const F=f.filter(B=>!M.ids.has(B.id));if(m.current={sessionId:$,ids:D},F.length===0||I===0)return;let z=0;for(const B of F){const U=t[z];(U===B.content||(U==null?void 0:U.trim())===""&&B.content.length>0)&&z++}z>0&&s(z)},[n==null?void 0:n.sessionId,f,t,I,s]);const E=(n==null?void 0:n.turns.length)??0;y.useEffect(()=>{if(E===0)return;const $=E-d.current;$>0&&(I>0&&s(Math.min($,I)),(u.current||c.current)&&(w(),u.current=!1)),d.current=E},[E,I,s,w]);const P=n==null?void 0:n.turns.at(-1),R=(P==null?void 0:P.toolCalls.length)??0,L=(P==null?void 0:P.assistantText.length)??0;y.useEffect(()=>{if(!(!n||!e)){if(c.current){const $=i.current;$&&($.scrollTop=$.scrollHeight)}requestAnimationFrame(_)}},[E,R,L,o,e,_]);const O=x===r;return y.useMemo(()=>({chatScrollRef:i,scrollEndRef:l,observeChatContent:S,canScrollDown:h,initialScrollDone:O,handleScroll:C,scrollToBottomInstant:v,requestScrollToTop:k,resetTurnCount:A}),[S,h,O,C,v,k,A])}async function KA(n,e,t,s,{background:r=!1}={}){const o=await Ee(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?tail=30`,{background:r});if(!o.ok)throw new Error(`Failed to load ${s} (${o.status})`);const i=await o.json(),l=new Set(i.headerLines),c=i.tailLines.filter(f=>!l.has(f)),u=[...i.headerLines,...c].join(`
|
|
470
470
|
`);return{parsed:ta(await t(u),Vr(n).instanceId),source:{dirName:n,fileName:e,rawText:u,agentKind:an(n),watchOffset:i.totalSize},byteOffset:i.byteOffset,hasMore:i.hasMore}}async function xa(n,e,t,s,r={}){const o=Ss.get(n,e);if(o)return{parsed:o.parsed,source:o.source};const i=Jt(),l=Zn(),{parsed:c,source:u,byteOffset:d,hasMore:f}=await KA(n,e,t,s,r);if(Jt()!==i||Zn()!==l)return{parsed:c,source:u};const m=Ss.get(n,e);return m?{parsed:m.parsed,source:m.source}:(Ss.set(n,e,c,u.rawText,d,f,u.agentKind,u.watchOffset),{parsed:c,source:u})}async function GA(n,e,t,s){Ss.evict(n,e);const r=Jt(),o=Zn(),{parsed:i,source:l,byteOffset:c,hasMore:u}=await KA(n,e,t,s);return Jt()===r&&Zn()===o&&Ss.set(n,e,i,l.rawText,c,u,l.agentKind,l.watchOffset),{parsed:i,source:l}}function r1e({dispatch:n,isMobile:e,mobileTab:t="sessions",teamContext:s,scrollToBottomInstant:r,resetTurnCount:o,workerParse:i,onBeforeSwitch:l}){const[c,u]=y.useState(null),d=y.useCallback((w,v)=>{u(null),y.startTransition(()=>{n({type:"LOAD_SESSION",session:w,source:v,isMobile:e})}),o(w.turns.length),xhe(w.sessionId,w.turns.length),r()},[n,e,o,r]),f=y.useCallback(async(w,v)=>{l==null||l(),u(null);try{const{parsed:k,source:j}=await xa(w,v,i,"session");d(k,j)}catch(k){u(k instanceof Error?k.message:"Failed to load session")}},[d,i,l]),m=y.useCallback(async w=>{if(s){l==null||l(),u(null),n({type:"SET_LOADING_MEMBER",name:w.name});try{const v=await Ee(`/api/team-member-session/${encodeURIComponent(s.teamName)}/${encodeURIComponent(w.name)}`);if(!v.ok)throw new Error(`Failed to find session for ${w.name}`);const{dirName:k,fileName:j}=await v.json(),{parsed:_,source:N}=await xa(k,j,i,`session for ${w.name}`);y.startTransition(()=>{n({type:"SWITCH_TEAM_MEMBER",session:_,source:N,memberName:w.name})}),o(_.turns.length),r()}catch(v){u(v instanceof Error?v.message:"Failed to switch team member")}finally{n({type:"SET_LOADING_MEMBER",name:null})}}},[n,s,o,r,i,l]),p=y.useCallback(()=>u(null),[]),h=y.useCallback(()=>{y.startTransition(()=>{n({type:"GO_HOME",isMobile:e})})},[n,e]),g=y.useCallback(()=>{y.startTransition(()=>{n({type:"CLOSE_SESSION",isMobile:e})})},[n,e]),x=y.useCallback((w,v)=>{n({type:"JUMP_TO_TURN",index:w,toolCallId:v})},[n]),b=y.useCallback(w=>{w!==t&&n({type:"SET_MOBILE_TAB",tab:w})},[n,t]);return{loadError:c,clearLoadError:p,handleLoadSession:d,handleDashboardSelect:f,handleTeamMemberSwitch:m,handleGoHome:h,handleCloseSession:g,handleJumpToTurn:x,handleMobileTabChange:b}}const o1e=/^\/preview\/([^/]+)\/?$/;function $b(n){const e=o1e.exec(n);if(!e)return null;try{const t=decodeURIComponent(e[1]);return t.length>0?t:null}catch{return null}}function E1(){const n=bf();return n?`${n}/`:"/"}function ZA(n){const e=/^\/d\/[^/]+(\/.*)?$/.exec(n);return e?e[1]||"/":n}function i1e(n,e){return O$(n,e)}function a1e(n){const e=bf();return n.sessionSource?zf(n.sessionSource.dirName,n.sessionSource.fileName):n.pendingDirName?`${e}/${encodeURIComponent(n.pendingDirName)}`:n.dashboardProject?`${e}/${encodeURIComponent(n.dashboardProject)}`:E1()}function Z3(n){const e=ZA(n),t=$b(e);if(t)return{type:"preview",sessionId:t};if(e.startsWith("/team/"))return{type:"home",normalizeHome:!0};const s=e.split("/").filter(Boolean);return s.length>=2?{type:"session",dirName:decodeURIComponent(s[0]),sessionId:decodeURIComponent(s[1])}:s.length===1?{type:"project",dirName:decodeURIComponent(s[0])}:{type:"home"}}function l1e({state:n,dispatch:e,isMobile:t,resetTurnCount:s,scrollToBottomInstant:r,workerParse:o}){const[i,l]=y.useState(null),c=y.useRef(0),u=y.useRef(window.location.pathname),d=y.useRef(!1),f=y.useCallback(async m=>{c.current++;try{if(m.type==="preview"&&m.sessionId){l(null);try{const p=await Ee(`/api/find-session/${encodeURIComponent(m.sessionId)}`);if(!p.ok)throw new Error(p.status===404?`Session ${m.sessionId} was not found.`:`Failed to resolve session (${p.status}).`);const h=await p.json();if(!h.dirName||!h.fileName)throw new Error("Cogpit returned an invalid session location.");const g=await xa(h.dirName,h.fileName,o,"session preview");e({type:"LOAD_SESSION",session:g.parsed,source:g.source,isMobile:t}),s(g.parsed.turns.length),r()}catch(p){e({type:"GO_HOME",isMobile:t}),l(p instanceof Error?p.message:"Failed to load session preview.")}}else if(m.type==="session"&&m.dirName&&m.sessionId){l(null);const p=i1e(m.dirName,m.sessionId);let h;try{h=await xa(m.dirName,p,o,"session")}catch{e({type:"GO_HOME",isMobile:t});const g=E1();window.history.replaceState(null,"",g),u.current=g,Ba(Dt(),g);return}e({type:"LOAD_SESSION",session:h.parsed,source:h.source,isMobile:t}),s(h.parsed.turns.length),r()}else if(m.type==="project"&&m.dirName)l(null),e({type:"SET_DASHBOARD_PROJECT",dirName:m.dirName});else if(l(null),e({type:"GO_HOME",isMobile:t}),m.normalizeHome){const p=E1();window.history.replaceState(null,"",p),u.current=p,Ba(Dt(),p)}}finally{c.current--}},[e,t,s,r,o]);return y.useEffect(()=>{if(d.current)return;d.current=!0,Ba(Dt(),window.location.pathname);const m=Z3(window.location.pathname);(m.type!=="home"||m.normalizeHome)&&f(m)},[f]),y.useEffect(()=>{if(c.current>0||$b(ZA(window.location.pathname)))return;const m=a1e(n);m!==u.current&&(window.history.pushState(null,"",m),u.current=m,Ba(Dt(),m))},[n.sessionSource,n.pendingDirName,n.mainView,n.dashboardProject]),y.useEffect(()=>{const m=()=>{const p=Z3(window.location.pathname);u.current=window.location.pathname,Ba(Dt(),window.location.pathname),f(p)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[f]),{previewLoadError:i}}const c1e=400;function Y3(){return Array.from(document.querySelectorAll("[data-live-session]"))}function u1e(n){let e=n.parentElement;for(;e;){const{overflowY:t}=getComputedStyle(e);if(t==="auto"||t==="scroll")return e;e=e.parentElement}return null}function X3(n){n.focus({preventScroll:!0});const e=u1e(n);if(e){const t=e.getBoundingClientRect(),s=n.getBoundingClientRect();s.top<t.top?e.scrollTop-=t.top-s.top+8:s.bottom>t.bottom&&(e.scrollTop+=s.bottom-t.bottom+8)}}function d1e(n){const e=q.c(20),{isMobile:t,searchInputRef:s,chatInputRef:r,dispatch:o,onToggleSidebar:i,onToggleRightSidebar:l,onToggleMissionControl:c,onOpenCommandPalette:u,onOpenProjectSwitcher:d,onOpenThemeSelector:f,onOpenTerminal:m,onToggleIntegratedTerminal:p,onTogglePreview:h,onToggleProjectFiles:g,onHistoryBack:x,onHistoryForward:b,onNavigateToSession:w,onCommitNavigation:v}=n;let k,j;e[0]!==r||e[1]!==o||e[2]!==t||e[3]!==v||e[4]!==x||e[5]!==b||e[6]!==w||e[7]!==u||e[8]!==d||e[9]!==m||e[10]!==f||e[11]!==p||e[12]!==c||e[13]!==h||e[14]!==g||e[15]!==l||e[16]!==i||e[17]!==s?(k=()=>{if(t)return;let _=!1,N=!1,S=null;const C=function(E){var O,$;const P=fw("missionControl");if(P){if(E.key===P){E.repeat||(_=!0,N=E.shiftKey||E.altKey||(P==="Meta"?E.ctrlKey:E.metaKey));return}_&&(N=!0),S=null}if(Gt("commandPalette",E)){E.preventDefault(),u==null||u();return}if(Gt("integratedTerminal",E)){if(!ht("terminal"))return;E.preventDefault(),p();return}if(Gt("preview",E)){E.preventDefault(),h();return}if(Gt("projectFiles",E)){if(!ht("hostFiles"))return;E.preventDefault(),g();return}if(Gt("expandAll",E)){E.preventDefault(),o({type:"SET_EXPAND_ALL",value:!0});return}if(Gt("expandToolPayloads",E)){E.preventDefault(),o({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0});return}if(Gt("toggleSidebar",E)){E.preventDefault(),i();return}if(Gt("toggleStats",E)){E.preventDefault(),l();return}if(Gt("missionControl",E)){E.preventDefault(),c();return}if(Gt("newSession",E)&&(E.preventDefault(),d()),Gt("themeSelector",E)&&(E.preventDefault(),f()),Gt("systemTerminal",E)){if(!ht("terminal"))return;E.preventDefault(),m()}if(E.key==="Escape"&&(o({type:"SET_SEARCH_QUERY",value:""}),(O=s.current)==null||O.blur()),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.code.startsWith("Digit")){const M=parseInt(E.code.charAt(5),10);if(M>=1&&M<=9){E.preventDefault();const F=Y3()[M-1];F&&(X3(F),F.click())}}const R=Gt("recentSessionForward",E);if(R||Gt("recentSessionBack",E)){E.preventDefault();const M=R?b():x();M&&w(M.dirName,M.fileName)}Gt("focusComposer",E)&&!O_(document.activeElement)&&(E.preventDefault(),($=r.current)==null||$.focus());const L=Gt("nextLiveSession",E);if(L||Gt("prevLiveSession",E)){E.preventDefault();const M=Y3();if(M.length===0)return;const D=M.findIndex(f1e);let F;D===-1?F=L?0:M.length-1:F=Math.max(0,Math.min(M.length-1,D+(L?1:-1))),X3(M[F])}},A=function(E){const P=fw("missionControl");if(P&&E.key===P&&_){const R=!N;if(_=!1,N=!1,R){const L=Date.now();S!==null&&L-S<=c1e?(S=null,E.preventDefault(),c()):S=L}else S=null}E.key==="Control"&&(v==null||v())},T=function(){_=!1,N=!1,S=null};return window.addEventListener("keydown",C),window.addEventListener("keyup",A),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",C),window.removeEventListener("keyup",A),window.removeEventListener("blur",T)}},j=[t,s,r,o,i,l,c,u,d,f,m,p,h,g,x,b,w,v],e[0]=r,e[1]=o,e[2]=t,e[3]=v,e[4]=x,e[5]=b,e[6]=w,e[7]=u,e[8]=d,e[9]=m,e[10]=f,e[11]=p,e[12]=c,e[13]=h,e[14]=g,e[15]=l,e[16]=i,e[17]=s,e[18]=k,e[19]=j):(k=e[18],j=e[19]),y.useEffect(k,j)}function f1e(n){return n===document.activeElement}function YA(){const n=q.c(7),[e,t]=y.useState(iO),[s,r]=y.useState(null);let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=f=>{aO(f),t(f),r(null)},n[0]=o):o=n[0];const i=o,l=s??e;let c,u;n[1]!==l?(c=()=>lO(l),u=[l],n[1]=l,n[2]=c,n[3]=u):(c=n[2],u=n[3]),y.useEffect(c,u);let d;return n[4]!==l||n[5]!==e?(d={theme:e,activeTheme:l,setTheme:i,setPreview:r},n[4]=l,n[5]=e,n[6]=d):d=n[6],d}const m1e="cogpit-session-history",T1=50;function XA(){return en(m1e)}function p1e(){try{const n=localStorage.getItem(XA());if(!n)return[];const e=JSON.parse(n);if(Array.isArray(e))return e.slice(0,T1)}catch{}return[]}function Jh(n){try{localStorage.setItem(XA(),JSON.stringify(n))}catch{}}function h1e(){const n=q.c(7);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=p1e(),n[0]=e):e=n[0];const t=y.useRef(e),s=y.useRef(0),r=y.useRef(!1);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=(x,b)=>{if(r.current){r.current=!1;return}const w=`${x}/${b}`;t.current=t.current.filter(v=>`${v.dirName}/${v.fileName}`!==w),t.current.unshift({dirName:x,fileName:b}),t.current.length>T1&&(t.current.length=T1),s.current=0,Jh(t.current)},n[1]=o):o=n[1];const i=o;let l;n[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{if(t.current.length<=1)return null;const x=(s.current+1)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[2]=l):l=n[2];const c=l;let u;n[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(t.current.length<=1)return null;const x=(s.current-1+t.current.length)%t.current.length;return s.current=x,r.current=!0,t.current[x]},n[3]=u):u=n[3];const d=u;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(s.current===0){r.current=!1;return}const x=t.current[s.current];x&&(t.current.splice(s.current,1),t.current.unshift(x),Jh(t.current)),s.current=0,r.current=!1},n[4]=f):f=n[4];const m=f;let p;n[5]===Symbol.for("react.memo_cache_sentinel")?(p=x=>{const b=t.current.filter(w=>rx(w.dirName,w.fileName)!==x);b.length!==t.current.length&&(t.current=b,s.current=0,Jh(b))},n[5]=p):p=n[5];const h=p;let g;return n[6]===Symbol.for("react.memo_cache_sentinel")?(g={push:i,goBack:c,goForward:d,commitNavigation:m,forget:h},n[6]=g):g=n[6],g}const g1e="You no longer have access to this session",x1e="You don't have access to this session";function b1e(n){const e=q.c(7),{openSessionId:t,leave:s,forgetVisits:r}=n,{removeSession:o}=Nx();let i,l;e[0]!==r||e[1]!==s||e[2]!==t||e[3]!==o?(i=()=>{const u=function(p){Ss.evictSession(p),gR(p),zR(p),o(p),r(p),z4(),p===t&&s()},d=X$((m,p)=>{const h=RR(m)?g1e:x1e;u(m),!(p&&m!==t)&&Q$(m).then(g=>{g||Kn.error(h,{id:`session-access-lost:${m}`})})}),f=e8(u);return()=>{d(),f()}},l=[t,s,r,o],e[0]=r,e[1]=s,e[2]=t,e[3]=o,e[4]=i,e[5]=l):(i=e[4],l=e[5]),y.useEffect(i,l);let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[6]=c):c=e[6],y.useEffect(v1e,c)}function v1e(){return r4(y1e)}function y1e(){return z4()}const J3={mode:"bypassPermissions",allowedTools:[],disallowedTools:[]},w1e="cogpit:permissions";function JA(){return en(w1e)}function Q3(){try{const n=localStorage.getItem(JA());if(n){const e=JSON.parse(n);return{mode:e.mode||J3.mode,allowedTools:Array.isArray(e.allowedTools)?e.allowedTools:[],disallowedTools:Array.isArray(e.disallowedTools)?e.disallowedTools:[]}}}catch{}return J3}function S1e(n){localStorage.setItem(JA(),JSON.stringify(n))}function QA(n,e){const t=uN(n);return(t.find(s=>s.value===e)??t[0]).value}function ej(n,e){return{...e,mode:QA(n,e.mode),...!fn(n).toolPermissionRules&&{allowedTools:[],disallowedTools:[]}}}function k1e(n){const e=q.c(25),t=n===void 0?Uo:n,[s,r]=y.useState(Q3),[o,i]=y.useState(Q3);let l;e[0]!==t||e[1]!==s?(l=ej(t,s),e[0]=t,e[1]=s,e[2]=l):l=e[2];const c=l;let u;e[3]!==t||e[4]!==o?(u=ej(t,o),e[3]=t,e[4]=o,e[5]=u):u=e[5];const d=u,f=y.useRef(!0);let m,p;e[6]!==s?(m=()=>{if(f.current){f.current=!1;return}S1e(s)},p=[s],e[6]=s,e[7]=m,e[8]=p):(m=e[7],p=e[8]),y.useEffect(m,p);let h;e[9]!==d.allowedTools||e[10]!==d.disallowedTools||e[11]!==d.mode||e[12]!==c.allowedTools||e[13]!==c.disallowedTools||e[14]!==c.mode?(h=c.mode!==d.mode||JSON.stringify(c.allowedTools)!==JSON.stringify(d.allowedTools)||JSON.stringify(c.disallowedTools)!==JSON.stringify(d.disallowedTools),e[9]=d.allowedTools,e[10]=d.disallowedTools,e[11]=d.mode,e[12]=c.allowedTools,e[13]=c.disallowedTools,e[14]=c.mode,e[15]=h):h=e[15];const g=h;let x;e[16]!==t?(x=j=>{r(_=>({..._,mode:QA(t,j)}))},e[16]=t,e[17]=x):x=e[17];const b=x;let w;e[18]!==c?(w=()=>{i(c)},e[18]=c,e[19]=w):w=e[19];const v=w;let k;return e[20]!==c||e[21]!==g||e[22]!==v||e[23]!==b?(k={config:c,hasPendingChanges:g,setMode:b,markApplied:v},e[20]=c,e[21]=g,e[22]=v,e[23]=b,e[24]=k):k=e[24],k}const j1e=2e3;function N1e(n,e){return n.length!==e.length?!1:JSON.stringify(n)===JSON.stringify(e)}function C1e(n){const[e,t]=y.useState([]),[s,r]=y.useState(null),[o,i]=y.useState(new Set);y.useEffect(()=>{if(!n){t([]),r(null);return}let u=!1;const d=async()=>{if(!u)try{const h=await Ee(`/api/permissions/${encodeURIComponent(n)}`);if(u)return;if(h.ok){const g=await h.json();if(u)return;t(b=>N1e(b,g.permissions)?b:g.permissions);const x=g.plan?{type:"plan",provider:"copilot",...g.plan}:null;r(b=>JSON.stringify(b)===JSON.stringify(x)?b:x)}}catch{}},f=()=>{(typeof document>"u"||document.visibilityState==="visible")&&d()},m=()=>{document.visibilityState==="visible"&&d()};f();const p=setInterval(f,j1e);return document.addEventListener("visibilitychange",m),()=>{u=!0,clearInterval(p),document.removeEventListener("visibilitychange",m)}},[n]);const l=y.useCallback(async(u,d)=>{if(n){i(f=>new Set(f).add(u));try{await Z_(n,u,d)&&t(f=>f.filter(m=>m.requestId!==u))}finally{i(f=>{const m=new Set(f);return m.delete(u),m})}}},[n]),c=y.useCallback(async u=>{if(n)try{await TZ(n,u)&&t([])}catch{}},[n]);return{requests:e,plan:s,responding:o,respond:l,respondAll:c}}async function _1e(n,e){const t=await os(`/api/copilot-history/${encodeURIComponent(n)}/preview`,{eventId:e});return t.ok?await t.json():null}async function E1e(n,e,t){const s=await os(`/api/copilot-history/${encodeURIComponent(n)}/rewind`,{eventId:e,mode:t}),r=await s.json().catch(()=>null);return!s.ok||(r==null?void 0:r.outcome)!=="success"?{ok:!1,error:(r==null?void 0:r.error)||`Copilot rewind failed${r!=null&&r.outcome?`: ${r.outcome}`:""}`}:{ok:!0}}function T1e(n){return n.file_path??n.path??""}function eI(n){const e=[];for(const t of n.toolCalls){if(t.isError||t.awaitingReview||lK(t))continue;const s=T1e(t.input);if(s){if(t.name==="Edit"){const r=t.input.old_string,o=t.input.new_string;r!==void 0&&o!==void 0&&e.push({type:"Edit",filePath:s,oldString:r,newString:o,replaceAll:t.input.replace_all??!1})}else if(t.name==="Write"){const r=t.input.content;r!==void 0&&e.push({type:"Write",filePath:s,content:r})}}}return e}function A1e(n,e){return{index:e,id:n.id,userMessage:Tc(n.userMessage),toolCalls:eI(n),thinkingBlocks:n.thinking.map(t=>t.thinking),assistantText:[...n.assistantText],timestamp:n.timestamp,model:n.model}}function cf(n,e,t){const s=[];for(let r=e;r>t;r--){const o=n[r];if(!o)continue;const i=eI(o);for(let l=i.length-1;l>=0;l--){const c=i[l];c&&(c.type==="Edit"?s.push({type:"reverse-edit",filePath:c.filePath,oldString:c.newString,newString:c.oldString,replaceAll:c.replaceAll,turnIndex:r}):c.type==="Write"&&s.push({type:"delete-write",filePath:c.filePath,content:c.content,turnIndex:r}))}}return s}function I1e(n,e){const t=[];for(const s of n)s.type==="Edit"?t.push({type:"apply-edit",filePath:s.filePath,oldString:s.oldString,newString:s.newString,replaceAll:s.replaceAll,turnIndex:e}):s.type==="Write"&&t.push({type:"create-write",filePath:s.filePath,content:s.content,turnIndex:e});return t}function Rl(n,e){const t=[],s=e!==void 0?e+1:n.length;for(let r=0;r<s;r++){const o=n[r];o&&t.push(...I1e(o.toolCalls,o.index))}return t}function tI(n,e,t,s,r){var c;const o=[];for(let u=e+1;u<n.length;u++){const d=n[u];d&&o.push(A1e(d,u))}const i=((c=o[0])==null?void 0:c.userMessage)||"Untitled branch",l=i.length>60?i.slice(0,57)+"...":i;return{id:crypto.randomUUID(),createdAt:new Date().toISOString(),branchPointTurnIndex:e,...r!==void 0?{branchPointTurnId:r}:{},label:l,turns:o,jsonlLines:t,...s&&s.length>0?{childBranches:s}:{}}}const P1e=-2;function $1e(n,e){const t=new Map(e.map((o,i)=>[o.id,i]));let s=!1;const r=n.map(o=>{const{branchPointTurnId:i}=o;if(i===void 0)return o;const l=i===null?-1:t.get(i)??P1e;return l===o.branchPointTurnIndex?o:(s=!0,{...o,branchPointTurnIndex:l})});return s?r:n}function R1e(n){return(n.childBranches??[]).map(e=>{if(typeof e.branchPointTurnId!="string")return e;const t=n.turns.findIndex(s=>s.id===e.branchPointTurnId);return t<0?e:{...e,branchPointTurnIndex:n.branchPointTurnIndex+1+t}})}function nI(n,e){const t=[],s=[];for(const r of n)r.branchPointTurnIndex>e?s.push(r):t.push(r);return{retained:t,scooped:s}}function O1e(n,e,t){const s=e+t,r=[],o=[];for(const i of n)i.branchPointTurnIndex<=s?r.push(i):o.push(i);return{restored:r,remaining:o}}function L1e(n){const e=new Set(n.map(t=>t.filePath));return{fileCount:e.size,filePaths:[...e],operationCount:n.length}}function M1e(n){return{sessionId:n,branches:[],activeBranchId:null}}function Fu(n,e){return{...L1e(n),turnCount:e}}function z1e(n,e,t){return LC($C(an(t)),n,e)}function D1e(n,e,t,s,r,o){var c,u;const i=$C(an(o)),l=FF(i,n);if(l){const d=e?l.findLastIndex(m=>m.id===e.id):-1;if(d>=0)return{cutoffLine:((c=l[d+1])==null?void 0:c.line)??n.length,branchPointTurnId:l[d].id};const f=t?l.findIndex(m=>m.id===t.id):-1;if(f>=0)return{cutoffLine:l[f].line,branchPointTurnId:((u=l[f-1])==null?void 0:u.id)??null}}return o0(i,n).length>r?null:{cutoffLine:LC(i,n,s),branchPointTurnId:void 0}}class Wi extends Error{constructor(){super("abort")}}const sI="Unable to locate the selected turn in the current session file";function rI(n,e,t,s,r){const o=D1e(t,n.turns[s-1],n.turns[s],s,n.turns.length,e.dirName);if(!o)throw r(sI),new Wi;return o}async function F1e(n,e,t,s,r,o,i){var v;const l=n.targetTurnIndex,c=cf(e.turns,e.turns.length-1,l),u=l+1,d=r.split(`
|
|
@@ -474,7 +474,7 @@ ${le}
|
|
|
474
474
|
`).filter(Boolean).length},state:h})}const W1e=[];function iI(n,e,t,s=!0){const[r,o]=y.useState(null),[i,l]=y.useState(null),[c,u]=y.useState(!1),[d,f]=y.useState(null),m=y.useRef(null),p=y.useRef(0);y.useEffect(()=>{if(p.current+=1,!s||!n){o(null),l(null),f(null),m.current=null;return}if(n.sessionId===m.current)return;if(m.current=n.sessionId,!na(e==null?void 0:e.dirName).redo){o(null);return}const E=n.sessionId,P=new AbortController;return Ee(`/api/undo-state/${encodeURIComponent(E)}`,{signal:P.signal}).then(R=>R.ok?R.json():null).then(R=>{m.current===E&&o(R??null)}).catch(R=>{R instanceof Error&&R.name==="AbortError"||m.current===E&&o(null)}),()=>P.abort()},[s,n==null?void 0:n.sessionId]);const h=y.useCallback(async E=>{try{const P=await Ee("/api/undo/transaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operations:E.operations,session:{dirName:E.sessionSource.dirName,fileName:E.sessionSource.fileName,mutation:E.sessionMutation},state:E.state,checkpoint:E.checkpoint})}),R=await P.json().catch(()=>null);if(!P.ok)throw f((R==null?void 0:R.error)||"Undo transaction failed"),new Wi;o(E.state)}catch(P){throw P instanceof Wi?P:(f(String(P)),new Wi)}},[]),g=(r==null?void 0:r.branches)??W1e,x=n==null?void 0:n.turns,b=y.useMemo(()=>x?$1e(g,x):g,[g,x]),{canRedo:w,redoTurnCount:v,redoBranch:k}=y.useMemo(()=>{if(!n||b.length===0)return{canRedo:!1,redoTurnCount:0,redoBranch:null};for(let E=b.length-1;E>=0;E--){const P=b[E];if(P.branchPointTurnIndex+1===n.turns.length)return{canRedo:!0,redoTurnCount:P.turns.length,redoBranch:P}}return{canRedo:!1,redoTurnCount:0,redoBranch:null}},[n,b]),j=y.useMemo(()=>{if(!k||k.jsonlLines.length===0)return[];try{return Kf(k.jsonlLines.join(`
|
|
475
475
|
`)).turns}catch{return[]}},[k]),_=y.useCallback(E=>b.filter(P=>P.branchPointTurnIndex===E),[b]),N=y.useCallback(E=>{if(!s||!n)return;const P=E-1;if(P>=n.turns.length-1||P<-1)return;if(na(e==null?void 0:e.dirName).nativeRewind){const L=n.turns[E];if(!L)return;const O=n.sessionId,$=++p.current,M=()=>p.current===$&&m.current===O,D=L.id.includes("@")?L.id.slice(L.id.lastIndexOf("@")+1):L.id,F=n.turns.length-E;_1e(n.sessionId,D).then(z=>{var W;if(!M())return;const B=((W=z==null?void 0:z.files)==null?void 0:W.map(({path:V})=>V).filter(V=>typeof V=="string"))??[],U=z!=null&&z.available?z.fileCount??B.length:0;l({type:"undo",summary:{turnCount:F,fileCount:U,filePaths:B,operationCount:U},targetTurnIndex:P,nativeRewind:{eventId:D,mode:"conversation",filesAvailable:!!(z!=null&&z.available&&U>0)}})}).catch(()=>{M()&&l({type:"undo",summary:{turnCount:F,fileCount:0,filePaths:[],operationCount:0},targetTurnIndex:P,nativeRewind:{eventId:D,mode:"conversation"}})});return}const R=cf(n.turns,n.turns.length-1,P);l({type:"undo",summary:Fu(R,n.turns.length-1-P),targetTurnIndex:P})},[s,n,e==null?void 0:e.dirName]),S=y.useCallback(()=>{if(!s||!w||!k||!n)return;const E=Rl(k.turns);l({type:"redo",summary:Fu(E,k.turns.length),targetTurnIndex:k.branchPointTurnIndex+k.turns.length,branchId:k.id})},[s,w,k,n]),C=y.useCallback(E=>{if(!s||!w||!k||!n)return;const P=E+1,R=Rl(k.turns,E);l({type:"redo",summary:Fu(R,P),targetTurnIndex:k.branchPointTurnIndex+P,branchId:k.id,redoUpToArchiveIndex:E})},[s,w,k,n]),A=y.useCallback((E,P)=>{if(!s||!n)return;const R=b.find(M=>M.id===E);if(!R)return;const L=P??R.turns.length-1,O=n.turns.length>R.branchPointTurnIndex+1?cf(n.turns,n.turns.length-1,R.branchPointTurnIndex):[],$=Rl(R.turns,L);l({type:"branch-switch",summary:Fu([...O,...$],L+1),targetTurnIndex:R.branchPointTurnIndex,branchId:E,branchTurnIndex:L})},[s,n,b]),T=y.useCallback(async(E=!1)=>{if(!s||!i||!n||!e){l(null);return}u(!0),f(null);try{if(i.nativeRewind){const O=E&&i.nativeRewind.filesAvailable?"conversation-and-files":"conversation",$=await E1e(n.sessionId,i.nativeRewind.eventId,O);if(!$.ok){f($.error);return}await t(),l(null);return}const P={...r??M1e(n.sessionId),branches:b},R=await Ee(`/api/sessions/${encodeURIComponent(e.dirName)}/${encodeURIComponent(e.fileName)}`);if(!R.ok){f("Failed to read session file");return}const L=await R.text();if(i.type==="undo")await F1e(i,n,e,P,L,h,f);else if(i.type==="redo"){const O=b.find($=>$.id===i.branchId);if(!O){l(null);return}await U1e(i,e,P,O,L,h)}else if(i.type==="branch-switch"){const O=b.find($=>$.id===i.branchId);if(!O){l(null);return}await B1e(n,e,P,O,L,i,h,f)}try{await Ee("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n.sessionId})})}catch{}await t(),l(null)}catch(P){if(!(P instanceof Wi))throw P}finally{u(!1)}},[s,i,n,e,r,b,h,t]),I=y.useCallback(()=>{p.current+=1,l(null),f(null)},[]);return{enabled:s,undoState:r,canRedo:w,redoTurnCount:v,redoGhostTurns:j,branches:b,branchesAtTurn:_,requestUndo:N,requestRedoAll:S,requestRedoUpTo:C,requestBranchSwitch:A,confirmState:i,confirmApply:T,confirmCancel:I,isApplying:c,applyError:d}}async function q1e(n){try{const t=await(await po("/api/network-info",{signal:n})).json();return{url:t.enabled&&t.url?t.url:null,disabled:!t.enabled}}catch{return{url:null,disabled:!1}}}async function V1e(n){const e=await Ee("/api/config",{signal:n});if(!e.ok)throw new Error(`Config request failed (${e.status})`);const t=await e.json();return{claudeDir:(t==null?void 0:t.claudeDir)??null,defaultAgentKind:$$(t==null?void 0:t.mode,Uo),useBuiltInEditor:(t==null?void 0:t.useBuiltInEditor)===!0}}function H1e(){const n=q.c(26),[e,t]=y.useState(!0),[s,r]=y.useState(null),[o,i]=y.useState(null),[l,c]=y.useState(Uo),[u,d]=y.useState(!1),[f,m]=y.useState(null),[p,h]=y.useState(!1),[g,x]=y.useState(0),b=y.useRef(null);let w;n[0]===Symbol.for("react.memo_cache_sentinel")?(w=B=>{i(B.claudeDir),c(B.defaultAgentKind),YF(B.useBuiltInEditor)},n[0]=w):w=n[0];const v=w;let k;n[1]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{var W;(W=b.current)==null||W.abort();const B=new AbortController;b.current=B;const U=await q1e(B.signal);B.signal.aborted||b.current!==B||(m(U.url),h(U.disabled))},n[1]=k):k=n[1];const j=k;let _,N;n[2]===Symbol.for("react.memo_cache_sentinel")?(_=()=>()=>{var B;(B=b.current)==null||B.abort()},N=[],n[2]=_,n[3]=N):(_=n[2],N=n[3]),y.useEffect(_,N);let S;n[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const B=new AbortController;return t(!0),r(null),V1e(B.signal).then(v).catch(U=>{U instanceof Error&&U.name==="AbortError"||(i(null),r(U instanceof Error?U.message:"Failed to load configuration"))}).finally(()=>{B.signal.aborted||t(!1)}),()=>B.abort()},n[4]=S):S=n[4];let C;n[5]!==g?(C=[v,g],n[5]=g,n[6]=C):C=n[6],y.useEffect(S,C);let A,T;n[7]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{const B=()=>x(Z1e);return window.addEventListener("cogpit-auth-changed",B),()=>window.removeEventListener("cogpit-auth-changed",B)},T=[],n[7]=A,n[8]=T):(A=n[7],T=n[8]),y.useEffect(A,T);let I;n[9]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{j()},n[9]=I):I=n[9];let E;n[10]!==o?(E=[o,j],n[10]=o,n[11]=E):E=n[11],y.useEffect(I,E);let P;n[12]===Symbol.for("react.memo_cache_sentinel")?(P=()=>d(!1),n[12]=P):P=n[12];const R=P;let L;n[13]!==o?(L=B=>{if(d(!1),B!==o){i(B),window.location.reload();return}x(G1e),j()},n[13]=o,n[14]=L):L=n[14];const O=L;let $;n[15]===Symbol.for("react.memo_cache_sentinel")?($=()=>d(!0),n[15]=$):$=n[15];const M=$;let D;n[16]===Symbol.for("react.memo_cache_sentinel")?(D=()=>x(K1e),n[16]=D):D=n[16];const F=D;let z;return n[17]!==o||n[18]!==s||n[19]!==e||n[20]!==l||n[21]!==O||n[22]!==p||n[23]!==f||n[24]!==u?(z={configLoading:e,configError:s,claudeDir:o,defaultAgentKind:l,setClaudeDir:i,showConfigDialog:u,openConfigDialog:M,handleCloseConfigDialog:R,handleConfigSaved:O,retryConfig:F,networkUrl:f,networkAccessDisabled:p},n[17]=o,n[18]=s,n[19]=e,n[20]=l,n[21]=O,n[22]=p,n[23]=f,n[24]=u,n[25]=z):z=n[25],z}function K1e(n){return n+1}function G1e(n){return n+1}function Z1e(n){return n+1}const tj={authenticated:!0,edition:"personal",user:null,capabilities:ax},dd={authenticated:!1,edition:null,user:null,capabilities:Sa,checked:!1},Y1e=Object.keys(ax);function nj(n,e){return n!==null&&n.edition===e&&n.authenticated&&(e==="personal"?n.user===null:n.user!==null)&&Y1e.every(t=>{var s;return typeof((s=n.capabilities)==null?void 0:s[t])=="boolean"})}function X1e(n,e){const t={};for(const[s,r]of Object.entries(e))t[s]=r===!0&&n[s]!==!1;return{...Sa,...t}}function J1e(n){const e=n==null?void 0:n.capabilities;return!n||!e||typeof e.browser=="boolean"?n:{...n,capabilities:{...e,browser:e.hostFiles===!0}}}async function sj(n,e){try{const t=await n("/api/me",{signal:e});return t.ok?J1e(await t.json()):null}catch{return null}}async function Q1e(n){try{const e=await Ee("/api/hello",{signal:n});if(!e.ok)return null;const t=await e.json();return Yj(t.edition)?t.edition:"personal"}catch{return null}}function $i(n,e){return yl(n,e),z$((e==null?void 0:e.id)??null),n?{...n,checked:!0}:dd}function exe(n){const e=q.c(11),[t,s]=y.useState(dd),[r,o]=y.useState(0),i=y.useRef(null),l=y.useRef(!1);let c;e[0]!==n?(c=()=>{var N;if((N=i.current)==null||N.abort(),n===null){l.current=!1,yl(null),s(dd);return}const b=l.current;l.current=!1,yl(null),s(S=>b?{...S,capabilities:Sa,checked:!1}:dd);const w=new AbortController;i.current=w;const v=Bo(),k=sj(po,w.signal),j=v?Q1e(w.signal):Promise.resolve(n),_=v?sj(Ee,w.signal):Promise.resolve(null);return Promise.all([k,j,_]).then(S=>{const[C,A,T]=S;if(w.signal.aborted)return;const I=nj(C,n)?C:n==="personal"?tj:null;if(v&&(I!=null&&I.gate)){Ks(Tt);return}if(!I||A===null){s($i(null,null));return}if(!v){s($i(I,I.user));return}const E=nj(T,A)?T:A==="personal"?tj:null;if(!E){s($i(null,null));return}s($i({authenticated:E.authenticated,edition:E.edition,user:E.user,capabilities:X1e(I.capabilities,E.capabilities),...E.enforcesSessionAccess&&{enforcesSessionAccess:!0},...E.gate&&{gate:E.gate}},I.user))}).catch(()=>{w.signal.aborted||s($i(null,null))}),()=>{w.abort(),i.current===w&&(i.current=null)}},e[0]=n,e[1]=c):c=e[1];let u;e[2]!==n||e[3]!==r?(u=[n,r],e[2]=n,e[3]=r,e[4]=u):u=e[4],y.useEffect(c,u);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{var b;(b=i.current)==null||b.abort(),l.current=!0,yl(null),s(sxe),o(nxe)},e[5]=d):d=e[5];const f=d;let m,p;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{const b=()=>{var v;(v=i.current)==null||v.abort(),l.current=!1,s($i(null,null)),o(txe)},w=v=>{var _;const k=Dt();if(k===Tt)return;const j=(_=v.detail)==null?void 0:_.deviceId;j&&j!==k||f()};return window.addEventListener("cogpit-auth-changed",b),window.addEventListener("cogpit-devices-changed",w),()=>{window.removeEventListener("cogpit-auth-changed",b),window.removeEventListener("cogpit-devices-changed",w)}},p=[f],e[6]=m,e[7]=p):(m=e[6],p=e[7]),y.useEffect(m,p);const h=t.checked&&!t.gate;let g,x;return e[8]!==h?(g=()=>{if(h)return W$(f)},x=[h,f],e[8]=h,e[9]=g,e[10]=x):(g=e[9],x=e[10]),y.useEffect(g,x),t}function txe(n){return n+1}function nxe(n){return n+1}function sxe(n){return{...n,capabilities:Sa,checked:!1}}const rxe=3e4;function oxe(n){const[e,t]=y.useState(()=>({dirName:n,worktrees:[],loading:n!==null,error:null})),s=y.useRef(0),r=y.useCallback(async()=>{if(!n)return;const i=++s.current;t(l=>l.dirName===n&&l.loading?l:{dirName:n,worktrees:l.dirName===n?l.worktrees:[],loading:!0,error:l.dirName===n?l.error:null});try{const l=await Ee(`/api/worktrees/${encodeURIComponent(n)}`);if(i!==s.current)return;if(l.ok){const c=await l.json();if(i!==s.current)return;t({dirName:n,worktrees:c,loading:!1,error:null});return}t(c=>c.dirName===n?{...c,loading:!1,error:"Failed to fetch worktrees"}:c)}catch(l){if(i!==s.current)return;t(c=>c.dirName===n?{...c,loading:!1,error:l instanceof Error?l.message:"Unknown error"}:c)}},[n]);y.useEffect(()=>{if(!n){s.current+=1;return}r();const i=setInterval(()=>void r(),rxe);return()=>{clearInterval(i),s.current+=1}},[n,r]);const o=e.dirName===n?e:{worktrees:[],loading:n!==null,error:null};return{worktrees:o.worktrees,loading:o.loading,error:o.error,refetch:r}}function ixe(){const n=q.c(3),[e,t]=y.useState(!1);let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=async()=>{t(!0);try{await Ee("/api/kill-all",{method:"POST"})}catch{}setTimeout(()=>t(!1),1500)},n[0]=s):s=n[0];const r=s;let o;return n[1]!==e?(o={killing:e,handleKillAll:r},n[1]=e,n[2]=o):o=n[2],o}function axe(n,e){return n?`${n}.jsonl`:e??null}async function aI(n){await cI(n);try{const e=await Ee(`/api/session-config/${encodeURIComponent(n)}`);if(!e.ok)return null;const t=await e.json();return t&&typeof t=="object"?t:null}catch{return null}}const lxe=300,Ol=new Map,gl=new Map;function cxe(n,e,t){const s=(gl.get(n)??Promise.resolve(!0)).then(async()=>{try{return(await os(`/api/session-config/${encodeURIComponent(e)}`,t,{method:"PUT"})).ok}catch{return!1}});return gl.set(n,s),s.then(()=>{gl.get(n)===s&&gl.delete(n)}),s}function uxe(){let n;return{stored:new Promise(t=>{n=t}),answer:n}}function lI(n,e,t){clearTimeout(t.timer),Ol.delete(n);const s=cxe(n,e,t.patch);return s.then(t.answer),s}async function cI(n){const e=en(n),t=Ol.get(e);await(t?lI(e,n,t):gl.get(e))}function A1(n,e){const t=en(n),s=Ol.get(t);s&&clearTimeout(s.timer);const{stored:r,answer:o}=s??uxe(),i={patch:s?{...s.patch,...e}:e,stored:r,answer:o,timer:setTimeout(()=>{en(n)===t?lI(t,n,i):(Ol.delete(t),i.answer(!1))},lxe)};return Ol.set(t,i),r}function I1(n){return new Set(n.filter(e=>e.status==="connected").map(e=>e.name))}async function rj(n){const e=await aI(n);return Array.isArray(e==null?void 0:e.mcpServers)?e.mcpServers:null}function Qh(n,e){A1(n,{mcpServers:e})}async function dxe(n){if(!n.ok)return null;const e=await n.json();return{servers:e.servers??[],configs:e.configs??{}}}async function oj(n,e){try{const t=await Ee(n,{signal:e});if(e.aborted)return null;const s=await dxe(t);return e.aborted?null:s}catch{return null}}async function ij(n,e,t){const s=I1(t);if(s.size===0)return[];if(n){const r=await rj(n);if(r)return r.filter(o=>s.has(o))}if(e&&n!==e){const r=await rj(e);if(r)return r.filter(o=>s.has(o))}return[...s]}function fxe(n,e,t,s=!0){const[r,o]=y.useState([]),[i,l]=y.useState({}),[c,u]=y.useState([]),[d,f]=y.useState(!1),[m,p]=y.useState(!1),h=y.useRef(null),g=y.useRef(e);g.current=e;const x=t??e??null,b=y.useRef(x);b.current=x;const w=y.useRef(void 0);y.useEffect(()=>{var S,C;if(!s||!n){(S=h.current)==null||S.abort(),w.current=void 0,o([]),l({}),u([]),f(!1),p(!1);return}const N=new AbortController;return(C=h.current)==null||C.abort(),o([]),l({}),u([]),f(!0),p(!1),w.current=n,oj(`/api/mcp-servers?cwd=${encodeURIComponent(n)}`,N.signal).then(async A=>{if(N.signal.aborted||w.current!==n||!A)return;o(A.servers),l(A.configs);const T=await ij(b.current,g.current,A.servers);N.signal.aborted||w.current!==n||u(T)}).finally(()=>{N.signal.aborted||w.current!==n||(f(!1),p(!0))}),()=>N.abort()},[n,s]),y.useEffect(()=>()=>{var N;return(N=h.current)==null?void 0:N.abort()},[]),y.useEffect(()=>{if(r.length===0||!x)return;let N=!1;return ij(x,e,r).then(S=>{N||b.current!==x||u(S)}),()=>{N=!0}},[x]);const v=y.useCallback(N=>{u(S=>{const C=S.includes(N)?S.filter(A=>A!==N):[...S,N];return b.current&&Qh(b.current,C),C})},[]),k=y.useCallback(N=>{u(()=>(b.current&&Qh(b.current,N),N))},[]),j=y.useCallback(()=>{var S;if(!s||!n)return;(S=h.current)==null||S.abort();const N=new AbortController;h.current=N,f(!0),oj(`/api/mcp-servers?cwd=${encodeURIComponent(n)}&refresh=1`,N.signal).then(C=>{if(N.signal.aborted||w.current!==n||!C)return;o(C.servers),l(C.configs);const A=I1(C.servers);u(T=>{const I=T.filter(E=>A.has(E));return b.current&&Qh(b.current,I),I})}).finally(()=>{N.signal.aborted||h.current!==N||f(!1)})},[n,s]),_=y.useMemo(()=>{if(r.length===0)return null;const N=I1(r);if(c.length===N.size&&N.size>0&&c.every(A=>N.has(A))||!c.every(A=>i[A]))return null;const C=Object.fromEntries(c.map(A=>[A,i[A]]));return JSON.stringify({mcpServers:C})},[c,i,r]);return{servers:r,selectedServers:c,mcpConfigJson:_,loading:d,loaded:m,toggleServer:v,setSelection:k,refresh:j}}function mxe(n){var s,r;const e=q.c(12);let t;e:{if(!n){t=null;break e}let o=null,i;if(e[0]!==o||e[1]!==n.turns){const p=new Map;let h=0;for(const g of n.turns)for(const x of g.toolCalls){if(x.name==="TodoWrite"){const b=x.input;Array.isArray(b.todos)&&(o=b.todos);continue}if(x.name==="TaskCreate"){const b=x.input;h=h+1;const v=((r=(s=x.result)==null?void 0:s.match(/(?:Task\s*#?|task[_ ]?id["': ]+)(\d+)/i))==null?void 0:r[1])??String(h);p.set(v,{id:v,content:b.subject||b.description||`Task ${v}`,activeForm:b.activeForm||b.subject||`Working on task ${v}`,status:"pending",owner:b.owner});continue}if(x.name==="TaskUpdate"){const b=x.input,w=String(b.taskId??"");if(!w)continue;if(b.status==="deleted"){p.delete(w);continue}const v=p.get(w)??{id:w,content:b.subject||b.description||`Task ${w}`,activeForm:b.activeForm||b.subject||`Working on task ${w}`,status:"pending"};p.set(w,{...v,content:b.subject||b.description||v.content,activeForm:b.activeForm||v.activeForm,status:b.status||v.status,owner:b.owner??v.owner,blockedBy:b.addBlockedBy?[...new Set([...v.blockedBy??[],...b.addBlockedBy])]:v.blockedBy})}}i=p.size>0?[...p.values()]:o,e[0]=o,e[1]=n.turns,e[2]=i,e[3]=o}else i=e[2],o=e[3];const l=i;if(!l||l.length===0){t=null;break e}let c;e[4]!==l?(c=l.filter(hxe),e[4]=l,e[5]=c):c=e[5];const u=c.length;let d;e[6]!==l?(d=l.find(pxe)??null,e[6]=l,e[7]=d):d=e[7];const f=d;let m;e[8]!==u||e[9]!==f||e[10]!==l?(m={todos:l,completed:u,total:l.length,inProgress:f},e[8]=u,e[9]=f,e[10]=l,e[11]=m):m=e[11],t=m}return t}function pxe(n){return n.status==="in_progress"}function hxe(n){return n.status==="completed"}function gxe(n){const e=q.c(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[s,r]=y.useState(t);let o,i;return e[1]!==n?(o=()=>{if(!n){r([]);return}let l=!1;const c=async function(){try{const f=await Ee(`/api/background-agents?cwd=${encodeURIComponent(n)}`);if(l)return;if(f.ok){const m=await f.json();r(m)}}catch{}};c();const u=setInterval(c,5e3);return()=>{l=!0,clearInterval(u)}},i=[n],e[1]=n,e[2]=o,e[3]=i):(o=e[2],i=e[3]),y.useEffect(o,i),s}function xxe(n,e){const t=q.c(8),s=e===void 0?!0:e;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];const[o,i]=y.useState(r),[l,c]=y.useState(!1),u=y.useRef(void 0);let d,f;t[1]!==n||t[2]!==s?(d=()=>{if(!s){u.current=void 0,i([]),c(!1);return}if(u.current===n)return;u.current=n,c(!0);const p=n?`?cwd=${encodeURIComponent(n)}`:"";Ee(`/api/slash-suggestions${p}`).then(bxe).then(h=>i(h.suggestions||[])).catch(()=>i([])).finally(()=>c(!1))},f=[n,s],t[1]=n,t[2]=s,t[3]=d,t[4]=f):(d=t[3],f=t[4]),y.useEffect(d,f);let m;return t[5]!==l||t[6]!==o?(m={suggestions:o,loading:l},t[5]=l,t[6]=o,t[7]=m):m=t[7],m}function bxe(n){return n.json()}function aj(n,e){const t=q.c(6),[s,r]=br(n,e),o=typeof s=="boolean"?s:e;let i;t[0]!==e||t[1]!==r?(i=u=>{r(d=>typeof u=="function"?u(typeof d=="boolean"?d:e):u)},t[0]=e,t[1]=r,t[2]=i):i=t[2];const l=i;let c;return t[3]!==l||t[4]!==o?(c=[o,l],t[3]=l,t[4]=o,t[5]=c):c=t[5],c}const lj={config:{type:"CLOSE_CONFIG"},mission:{type:"CLOSE_MISSION"},extension:{type:"CLOSE_EXTENSION_VIEW"}};function cj(){if(typeof window>"u")return Et.fileChanges;try{if(JSON.parse(localStorage.getItem("panel-worktrees-visible")??"false")===!0)return Et.worktrees;if(JSON.parse(localStorage.getItem("panel-stats-visible")??"false")===!0)return Et.sessionInfo;if(JSON.parse(localStorage.getItem("panel-file-changes-visible")??"true")===!1)return null}catch{}return Et.fileChanges}function vxe(n,e){const t=q.c(53),[s,r]=aj("panel-sidebar-visible",!0),[o,i]=aj("panel-workflows-visible",!1);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=cj(),t[0]=l):l=t[0];const[c,u]=br("workspace-panel-active",l);let d;t[1]!==c?(d=typeof c=="string"||c===null?c:cj(),t[1]=c,t[2]=d):d=t[2];const f=d,[m,p]=y.useState(!1),[h,g]=y.useState(!1),{mainView:x}=n;let b;t[3]!==r||t[4]!==s?(b=()=>{y.startTransition(()=>r(!s))},t[3]=r,t[4]=s,t[5]=b):b=t[5];const w=b;let v;t[6]!==e||t[7]!==x||t[8]!==u?(v=ne=>{y.startTransition(()=>{const te=x!=="sessions";te&&e(lj[x]),u(re=>te||xw(re)!==xw(ne)?ne:null)})},t[6]=e,t[7]=x,t[8]=u,t[9]=v):v=t[9];const k=v;let j;t[10]!==e||t[11]!==x||t[12]!==u?(j=ne=>{y.startTransition(()=>{x!=="sessions"&&e(lj[x]),u(ne)})},t[10]=e,t[11]=x,t[12]=u,t[13]=j):j=t[13];const _=j;let N;t[14]!==u?(N=()=>{y.startTransition(()=>u(null))},t[14]=u,t[15]=N):N=t[15];const S=N;let C;t[16]!==e||t[17]!==x?(C=()=>{const ne=x==="config";y.startTransition(()=>{e({type:ne?"CLOSE_CONFIG":"OPEN_CONFIG"})})},t[16]=e,t[17]=x,t[18]=C):C=t[18];const A=C;let T;t[19]!==e||t[20]!==x?(T=()=>{const ne=x==="mission";y.startTransition(()=>{e({type:ne?"CLOSE_MISSION":"OPEN_MISSION"})})},t[19]=e,t[20]=x,t[21]=T):T=t[21];const I=T;let E;t[22]!==e?(E=ne=>{y.startTransition(()=>e({type:"OPEN_EXTENSION_VIEW",id:ne}))},t[22]=e,t[23]=E):E=t[23];const P=E;let R;t[24]!==e?(R=()=>{y.startTransition(()=>e({type:"CLOSE_EXTENSION_VIEW"}))},t[24]=e,t[25]=R):R=t[25];const L=R,O=jx();let $;t[26]===Symbol.for("react.memo_cache_sentinel")?($=new Set,t[26]=$):$=t[26];const M=y.useRef($),D=y.useRef(!1);let F,z;t[27]!==O||t[28]!==P?(F=()=>{var te;if(D.current)return;const ne=M.current;for(const re of O)if(!ne.has(re.id)&&(ne.add(re.id),(te=re.openOnStart)!=null&&te.call(re))){D.current=!0,P(re.id);return}},z=[O,P],t[27]=O,t[28]=P,t[29]=F,t[30]=z):(F=t[29],z=t[30]),y.useEffect(F,z);let B;t[31]!==e?(B=ne=>{y.startTransition(()=>{e({type:"OPEN_CONFIG",filePath:ne})})},t[31]=e,t[32]=B):B=t[32];const U=B;let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W=()=>p(!0),t[33]=W):W=t[33];const V=W;let H;t[34]===Symbol.for("react.memo_cache_sentinel")?(H=()=>p(!1),t[34]=H):H=t[34];const K=H;let Z;t[35]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>g(yxe),t[35]=Z):Z=t[35];const Y=Z;let X;t[36]===Symbol.for("react.memo_cache_sentinel")?(X=()=>g(!1),t[36]=X):X=t[36];const ee=X;let Q;return t[37]!==f||t[38]!==L||t[39]!==S||t[40]!==U||t[41]!==A||t[42]!==I||t[43]!==w||t[44]!==P||t[45]!==_||t[46]!==i||t[47]!==m||t[48]!==s||t[49]!==h||t[50]!==o||t[51]!==k?(Q={showSidebar:s,showWorkflows:o,activeWorkspacePanel:f,showProjectSwitcher:m,showThemeSelector:h,handleToggleSidebar:w,toggleWorkspacePanel:k,openWorkspacePanel:_,closeWorkspacePanel:S,handleToggleConfig:A,handleToggleMission:I,openMainView:P,closeMainView:L,handleEditConfig:U,handleOpenProjectSwitcher:V,handleCloseProjectSwitcher:K,handleToggleThemeSelector:Y,handleCloseThemeSelector:ee,setShowWorkflows:i},t[37]=f,t[38]=L,t[39]=S,t[40]=U,t[41]=A,t[42]=I,t[43]=w,t[44]=P,t[45]=_,t[46]=i,t[47]=m,t[48]=s,t[49]=h,t[50]=o,t[51]=k,t[52]=Q):Q=t[52],Q}function yxe(n){return!n}async function wxe(n,e){let t;try{t=await os("/api/delete-session",{dirName:n,fileName:e})}catch{return Kn.error("Could not delete session"),!1}return t.ok||t.status===404?!0:(Kn.error(await kl(t,"Could not delete session")),!1)}function Sxe(n){var ee;const{state:e,dispatch:t,isMobile:s,handleJumpToTurn:r,markPermissionsApplied:o,hasPermsPendingChanges:i,permissionsConfig:l,settingsChange:c,onSettingsChangeSent:u,selectedModel:d,selectedEffort:f,fastMode:m,ultracode:p,mcpConfig:h,scrollRequestScrollToTop:g,handleDashboardSelect:x,workerParse:b,canInteract:w}=n,v=y.useCallback(async()=>{if(!e.sessionSource)return;const{dirName:Q,fileName:ne}=e.sessionSource;try{const{parsed:te,source:re}=await GA(Q,ne,b,"session");t({type:"RELOAD_SESSION_CONTENT",session:te,source:re})}catch{}},[e.sessionSource,t,b]),[k,j]=y.useState(null),_=y.useCallback(Q=>j(Q),[]),N=y.useCallback(()=>j(null),[]),S=y.useCallback(async Q=>{try{const ne=await Ee("/api/branch-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)});if(!ne.ok)return;const te=await ne.json();M4(te.sessionId);const{parsed:re,source:oe}=await xa(te.dirName,te.fileName,b,"session");t({type:"LOAD_SESSION",session:re,source:oe,isMobile:s})}catch{}},[t,s,b]),C=y.useCallback((Q,ne)=>S({dirName:Q,fileName:ne}),[S]),A=y.useCallback(()=>{e.sessionSource&&C(e.sessionSource.dirName,e.sessionSource.fileName)},[e.sessionSource,C]),T=y.useCallback((Q,ne)=>{const te=wxe(Q,ne),re=R$(Q,ne);return re?J$(re,te):te},[]),I=y.useCallback(async Q=>{var oe,ie;if(!e.sessionSource)return;const{dirName:ne,fileName:te}=e.sessionSource,re=(ie=(oe=e.session)==null?void 0:oe.turns[Q])==null?void 0:ie.id;await S({dirName:ne,fileName:te,turnIndex:Q,turnUuid:re})},[e.sessionSource,e.session,S]),E=y.useCallback((Q,ne)=>{r(Q,ne),t({type:"SET_MOBILE_TAB",tab:"chat"})},[r,t]),[P,R]=y.useState({}),L=y.useRef(d);L.current=d;const O=y.useRef(f);O.current=f;const $=y.useRef(h);$.current=h;const M=y.useRef(m);M.current=m;const D=y.useRef(p);D.current=p;const F=y.useRef(l);F.current=l;const z=y.useRef(c);z.current=c;const B=y.useRef(u);B.current=u;const U=((ee=e.session)==null?void 0:ee.sessionId)??null,W=y.useRef(null);y.useEffect(()=>{U!==W.current&&(W.current=U,U&&R(Q=>U in Q?Q:{...Q,[U]:{model:L.current,effort:O.current,fastMode:M.current,ultracode:D.current,mcpConfig:$.current}}))},[U]);const V=U?P[U]:void 0,H=h!==((V==null?void 0:V.mcpConfig)??null),K=V!=null&&(d!==V.model||f!==V.effort||m!==V.fastMode||p!==V.ultracode||i||H),Z=y.useCallback(async()=>{var se,me;if(!U||!w)return;const Q=L.current,ne=O.current,te=M.current,re=D.current,oe=$.current,ie=F.current,ae=z.current,de=B.current,le=((se=e.sessionSource)==null?void 0:se.agentKind)??an(((me=e.sessionSource)==null?void 0:me.dirName)??null);fn(le).settingsApply==="live"&&(await Ee(`/api/claude/settings/${encodeURIComponent(U)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:Q,effort:ne,fastMode:te,ultracode:re,mcpConfig:oe,...ie&&{permissionMode:ie.mode,allowedTools:ie.allowedTools,disallowedTools:ie.disallowedTools},...ae.length>0&&{settingsChange:ae}})})).ok&&ae.length>0&&de(),R(ue=>({...ue,[U]:{model:Q,effort:ne,fastMode:te,ultracode:re,mcpConfig:oe}})),o()},[U,w,e.sessionSource,o]),Y=y.useCallback(async()=>{if(!(!U||!w))try{await Ee("/api/stop-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:U})})}catch{}},[U,w]),X=y.useCallback((Q,ne)=>{Io(ne)&&g(),x(Q,ne)},[g,x]);return{reloadSession:v,branchModalTurn:k,setBranchModalTurn:j,handleOpenBranches:_,handleCloseBranchModal:N,handleDuplicateSessionByPath:C,handleDuplicateSession:A,handleDeleteSession:T,handleBranchFromHere:I,handleMobileJumpToTurn:E,hasSettingsChanges:K,handleApplySettings:Z,handleStopSession:Y,handleLoadSessionScrollAware:X}}function uI(){const n=q.c(6),e=y.useRef(null);let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Map,n[0]=t):t=n[0];const s=y.useRef(t),r=y.useRef(0);let o,i;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const m=s.current,p=new Worker(new URL("/assets/session-parser.worker-D3SBmcaP.js",import.meta.url),{type:"module"});return p.onmessage=h=>{const g=h.data,x=m.get(g.id);x&&(m.delete(g.id),g.type==="result"?x.resolve(g.session):x.reject(new Error(g.error)))},p.onerror=h=>{for(const[,g]of m)g.reject(new Error(`Worker error: ${h.message}`));m.clear()},e.current=p,()=>{p.terminate(),e.current=null;for(const[,h]of m)h.reject(new Error("Worker terminated"));m.clear()}},i=[],n[1]=o,n[2]=i):(o=n[1],i=n[2]),y.useEffect(o,i);let l;n[3]===Symbol.for("react.memo_cache_sentinel")?(l=m=>{const p=e.current;return p?new Promise((h,g)=>{r.current=r.current+1;const x=r.current;s.current.set(x,{resolve:h,reject:g}),p.postMessage({type:"parse",id:x,text:m})}):Promise.resolve().then(()=>Kf(m))},n[3]=l):l=n[3];const c=l;let u;n[4]===Symbol.for("react.memo_cache_sentinel")?(u=(m,p)=>{const h=e.current;return h?new Promise((g,x)=>{r.current=r.current+1;const b=r.current;s.current.set(b,{resolve:g,reject:x}),h.postMessage({type:"append",id:b,existing:m,newText:p})}):Promise.resolve().then(()=>GF(m,p))},n[4]=u):u=n[4];const d=u;let f;return n[5]===Symbol.for("react.memo_cache_sentinel")?(f={parse:c,append:d},n[5]=f):f=n[5],f}const kxe=30;function dI({dirName:n,fileName:e,sessionChangeKey:t,workerParse:s,onOlderTurns:r}){const[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(""),d=y.useRef(null),f=`${n??""}::${e??""}::${t}`;return y.useEffect(()=>{u.current=f,d.current=null,c(!1);const p=n&&e?Ss.get(n,e):void 0;i((p==null?void 0:p.hasMore)??!1),p&&p.olderTurns.length>0&&r(p.olderTurns)},[f,n,e,t,r]),{loadMore:y.useCallback(async()=>{if(!n||!e||d.current)return 0;const p=`${n}::${e}::${t}`,h=Ss.get(n,e);if(!(h!=null&&h.hasMore))return u.current===p&&i(!1),0;const g=Symbol("paging-flight");d.current=g,c(!0);try{const x=await Ee(`/api/sessions/${encodeURIComponent(n)}/${encodeURIComponent(e)}?before=${h.nextByteOffset}&count=${kxe}`);if(!x.ok)return 0;const b=await x.json(),w=b.lines.length>0&&b.hasMore;if(u.current===p&&i(w),b.lines.length===0)return Ss.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset}),0;const v=new Set(b.headerLines),k=b.lines.filter(N=>!v.has(N)),j=await s([...b.headerLines,...k].join(`
|
|
476
476
|
`)),_=T_(h.olderTurns,j.turns,h.source.agentKind);return Ss.update(n,e,{hasMore:w,nextByteOffset:b.byteOffset,olderTurns:_}),u.current!==p?0:(r(_),j.turns.length)}finally{d.current===g&&(d.current=null,u.current===p&&c(!1))}},[n,e,t,s,r]),hasMore:o,isLoadingOlder:l}}function jxe(n){const e=q.c(48),{agentKind:t,session:s,sessionSource:r,pendingDirName:o,isLive:i}=n,l=t??Uo,[c,u]=y.useState(""),[d,f]=y.useState(""),[m,p]=y.useState(null),[h,g]=y.useState(!1),[x,b]=y.useState(!1),w=(r==null?void 0:r.dirName)??o;let v;e[0]!==w?(v=Vr(w),e[0]=w,e[1]=v):v=e[1];const{options:k,fastTier:j,imageInput:_,normalizeEffort:N}=rN(l,c,v.instanceId),S=c||(s==null?void 0:s.model);let C;e[2]!==l||e[3]!==S?(C=_8(l,S),e[2]=l,e[3]=S,e[4]=C):C=e[4];const A=C,T=x&&A;let I;e[5]!==N||e[6]!==d?(I=N(d),e[5]=N,e[6]=d,e[7]=I):I=e[7];const E=I,P=!!j,R=P&&h,[L,O]=y.useState(null),$=y.useRef(null),M=(r==null?void 0:r.fileName)??null,D=y.useRef(M);let F,z;e[8]!==M?(F=()=>{const ie=D.current;D.current=M,!(ie===null||ie===M)&&(b(!1),p(null))},z=[M],e[8]=M,e[9]=F,e[10]=z):(F=e[9],z=e[10]),y.useEffect(F,z);let B,U;e[11]!==o?(B=()=>{o&&(b(!1),p(null))},U=[o],e[11]=o,e[12]=B,e[13]=U):(B=e[12],U=e[13]),y.useEffect(B,U);let W;e[14]!==l?(W=ie=>{u(ae=>ae===ie?"":ae),O(`${ie} is unavailable for this account. Cogpit retried the turn with ${yn(l).displayName}'s default model.`)},e[14]=l,e[15]=W):W=e[15];const V=W;let H;e[16]===Symbol.for("react.memo_cache_sentinel")?(H=()=>{O(null)},e[16]=H):H=e[16];const K=H;let Z,Y;e[17]!==k||e[18]!==o||e[19]!==c||e[20]!==r?(Z=()=>{c&&(!r&&!o||k.some(ie=>ie.value===c)||u(""))},Y=[k,c,r,o],e[17]=k,e[18]=o,e[19]=c,e[20]=r,e[21]=Z,e[22]=Y):(Z=e[21],Y=e[22]),y.useEffect(Z,Y);let X,ee;e[23]!==L?(X=()=>{if(!L)return;const ie=setTimeout(()=>O(null),12e3);return()=>clearTimeout(ie)},ee=[L],e[23]=L,e[24]=X,e[25]=ee):(X=e[24],ee=e[25]),y.useEffect(X,ee);const Q=s==null?void 0:s.rawMessages;let ne,te;e[26]!==l||e[27]!==i||e[28]!==Q?(ne=()=>{if(!i||!Q||!fn(l).modelFallbackNotices)return;let ie;for(let me=Q.length-1;me>=0;me=me-1,me){const ue=Q[me];if(ue.type==="system"&&ue.subtype==="model_refusal_fallback"){ie=ue;break}}if(!ie)return;const ae=typeof ie.uuid=="string"?ie.uuid:`${String(ie.original_model)}:${String(ie.fallback_model)}:${String(ie.request_id)}`;if($.current===ae)return;$.current=ae;const de=typeof ie.original_model=="string"?ie.original_model:"Fable",le=typeof ie.fallback_model=="string"?ie.fallback_model:"Opus",se=typeof ie.api_refusal_explanation=="string"?` ${ie.api_refusal_explanation}`:"";O(`${de} could not handle this request, so Claude continued with ${le}.${se}`)},te=[i,Q,l],e[26]=l,e[27]=i,e[28]=Q,e[29]=ne,e[30]=te):(ne=e[29],te=e[30]),y.useEffect(ne,te);let re;e[31]!==l?(re=fn(l),e[31]=l,e[32]=re):re=e[32];let oe;return e[33]!==m||e[34]!==E||e[35]!==R||e[36]!==P||e[37]!==h||e[38]!==V||e[39]!==_||e[40]!==L||e[41]!==d||e[42]!==c||e[43]!==re.configurableContextWindow||e[44]!==T||e[45]!==A||e[46]!==x?(oe={contextWindowTokens:m,setContextWindowTokens:p,contextWindowAvailable:re.configurableContextWindow,selectedModel:c,setSelectedModel:u,selectedEffort:d,setSelectedEffort:f,fastModeEnabled:h,ultracodeEnabled:x,effectiveEffort:E,fastModeAvailable:P,fastModeActive:R,setFastModeEnabled:g,ultracodeAvailable:A,ultracodeActive:T,setUltracodeEnabled:b,imageInputAvailable:_,modelFallbackNotice:L,dismissModelFallbackNotice:K,handleModelRejected:V},e[33]=m,e[34]=E,e[35]=R,e[36]=P,e[37]=h,e[38]=V,e[39]=_,e[40]=L,e[41]=d,e[42]=c,e[43]=re.configurableContextWindow,e[44]=T,e[45]=A,e[46]=x,e[47]=oe):oe=e[47],oe}const Xi=["permissionMode","model","effort","contextWindowTokens","fastMode","ultracode"];function Nxe(n){return Xi.some(e=>e===n)}function Cxe(n){return JSON.stringify(n,[...Xi])}function Ja(n,e){return Xi.filter(t=>n[t]!==e[t])}function Uu(n,e){const t={};for(const s of e)Object.assign(t,{[s]:n[s]});return t}function _xe(n,e){return{model:n.model??e.model,effort:n.effort??e.effort,contextWindowTokens:n.contextWindowTokens??null,fastMode:n.fastMode??e.fastMode,ultracode:n.ultracode??e.ultracode,permissionMode:n.permissionMode??e.permissionMode}}function Exe({sessionKey:n,sessionId:e,values:t,access:s,onHydrate:r}){const[o,i]=y.useState(null),l=y.useRef(null),c=y.useRef(0),u=y.useRef(r);u.current=r;const d=y.useRef(t);d.current=t;const f=y.useRef(s);f.current=s;const m=y.useCallback((w,v)=>{const k=l.current;if((k==null?void 0:k.key)!==w||!ga(f.current).configure)return;const j=Ja(k.values,v);if(j.length===0)return;const _=Uu(v,j);l.current={key:w,values:v},A1(w,_).then(N=>{N&&i(S=>(S==null?void 0:S.key)===w?{key:w,values:{...S.values,..._}}:S)})},[]),p=y.useCallback(w=>{var _;const v=++c.current,k=d.current,j=((_=l.current)==null?void 0:_.key)===w?l.current.values:null;aI(w).then(N=>{if(v!==c.current||N===null)return;const S=d.current,C=ga(f.current).configure;if(!Xi.some(E=>N[E]!==void 0)){if(l.current={key:w,values:S},i({key:w,values:S}),!C)return;const E=f.current==="own"?Xi:Xi.filter(P=>P!=="permissionMode");A1(w,Uu(S,E));return}const A=_xe(N,j??S),T=j?[...new Set([...Ja(j,k),...Ja(k,S)])]:[],I={...A,...Uu(S,T)};(!j||Ja(S,I).length>0)&&u.current({...N,...Uu(S,T)}),l.current={key:w,values:A},i({key:w,values:A}),m(w,I)})},[m]);y.useEffect(()=>{var w;if(((w=l.current)==null?void 0:w.key)!==n&&(l.current=null),!!n)return p(n),()=>{c.current+=1}},[n,s,p]),y.useEffect(()=>{if(!n)return;const w=()=>p(n),v=e?rz(e,w):void 0;let k=document.visibilityState==="hidden";function j(){k&&(k=!1,w())}function _(){document.visibilityState==="hidden"?k=!0:j()}return document.addEventListener("visibilitychange",_),window.addEventListener("focus",j),()=>{v==null||v(),document.removeEventListener("visibilitychange",_),window.removeEventListener("focus",j)}},[n,e,p]);const h=Cxe(t);y.useEffect(()=>{n&&m(n,d.current)},[h,n,m]);const g=(o==null?void 0:o.key)===n?Ja(o.values,t).join():"",x=y.useMemo(()=>g.split(",").filter(Nxe),[g]),b=y.useCallback(()=>{n&&cI(n)},[n]);return{picked:x,settlePicked:b}}function Txe(n){const[e,t]=y.useState(new Map),[s,r]=y.useState(null),[o,i]=y.useState(!0),l=y.useRef(new Map),c=y.useRef(null);y.useEffect(()=>{const x=n??null,b=c.current;if(b&&b!==x&&l.current.set(b,{activeId:s,collapsed:o}),x!==b){const w=x?l.current.get(x):null;w?(r(w.activeId),i(w.collapsed)):(r(null),i(!0))}c.current=x},[n]);const u=y.useCallback(()=>i(x=>!x),[]),d=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.set(x.id,x),w}),r(x.id),i(!1)},[]),f=y.useCallback(x=>{t(b=>{const w=new Map(b);return w.delete(x),r(v=>{if(v!==x)return v;const k=[...w.keys()];return k.length>0?k[k.length-1]:null}),w})},[]),m=y.useCallback(x=>{r(x),i(!1)},[]),p=y.useCallback((x,b)=>{t(w=>{const v=w.get(x);if(!v||v.status===b)return w;const k=new Map(w);return k.set(x,{...v,status:b}),k})},[]),h=y.useCallback(x=>{t(b=>{let w=!1;const v=new Map(b),k=new Set(x.map(j=>j.id));for(const[j,_]of v)_.type==="task"&&!k.has(j)&&(v.delete(j),w=!0);for(const j of x){const _=v.get(j.id);_?(_.name!==j.title||_.outputPath!==j.outputPath)&&(v.set(j.id,{..._,name:j.title,outputPath:j.outputPath}),w=!0):(v.set(j.id,{id:j.id,name:j.title,type:"task",status:"running",outputPath:j.outputPath}),w=!0)}return w?v:b})},[]),g=y.useCallback((x,b,w)=>{b&&w&&t(v=>{if(v.has(x))return v;const k=new Map(v);return k.set(x,{id:x,name:w,type:"task",status:"running",outputPath:b}),k}),r(v=>v===x?(i(!0),v):(i(!1),x))},[]);return{processes:e,activeProcessId:s,collapsed:o,toggleCollapse:u,addProcess:d,removeProcess:f,setActive:m,updateProcessStatus:p,handleServersChanged:h,handleToggleServer:g}}function Axe(n){const e=q.c(52),{sessionId:t,sessionCwd:s,pendingPath:r,sessionDirName:o,pendingDirName:i,dashboardProject:l,supportsFileWorkspace:c,activeWorkspacePanel:u,openWorkspacePanel:d,closeWorkspacePanel:f}=n,m=Txe(t),[p,h]=y.useState(null),[g,x]=y.useState(0),b=y.useRef(0),w=s??r??void 0,v=!!(w&&(p==null?void 0:p.kind)==="preview"&&p.cwd===w),k=(p==null?void 0:p.kind)==="project-files"&&p.anchorCwd===(w??null)?p:null;let j;e[0]!==i||e[1]!==r?(j={path:r,dirName:i},e[0]=i,e[1]=r,e[2]=j):j=e[2];const _=j;let N;e[3]!==l||e[4]!==i||e[5]!==r||e[6]!==s||e[7]!==o?(N=()=>({path:s??r??void 0,dirName:o??i??l??void 0}),e[3]=l,e[4]=i,e[5]=r,e[6]=s,e[7]=o,e[8]=N):N=e[8];const S=N;let C;e[9]!==S?(C=()=>{Ug(S())},e[9]=S,e[10]=C):C=e[10];const A=C;let T;e[11]!==S?(T=X=>{Ug({...S(),command:"claude /mcp"})},e[11]=S,e[12]=T):T=e[12];const I=T;let E;e[13]!==r||e[14]!==m||e[15]!==s?(E=()=>{const ee=[...m.processes.values()].filter($xe).at(-1);if(!ee){(s??r)&&x(Pxe);return}m.activeProcessId===ee.id&&!m.collapsed?m.toggleCollapse():m.setActive(ee.id)},e[13]=r,e[14]=m,e[15]=s,e[16]=E):E=e[16];const P=E;let R;e[17]!==r||e[18]!==s?(R=()=>{(s??r)&&x(Ixe)},e[17]=r,e[18]=s,e[19]=R):R=e[19];const L=R;let O;e[20]!==f||e[21]!==w||e[22]!==v?(O=()=>{w&&y.startTransition(()=>{f(),h(v?null:{kind:"preview",cwd:w})})},e[20]=f,e[21]=w,e[22]=v,e[23]=O):O=e[23];const $=O;let M;e[24]!==u||e[25]!==f||e[26]!==w||e[27]!==d?(M=()=>{if(w){if(u===Et.projectFiles){f();return}y.startTransition(()=>{h({kind:"project-files",root:w,anchorCwd:w,request:null}),d(Et.projectFiles)})}},e[24]=u,e[25]=f,e[26]=w,e[27]=d,e[28]=M):M=e[28];const D=M;let F;e[29]!==w||e[30]!==d||e[31]!==c?(F=X=>{if(!c)return!1;const ee=JF(X,w);if(!ee)return!1;b.current=b.current+1;const Q=b.current;return y.startTransition(()=>h({kind:"project-files",root:ee.root,anchorCwd:w??null,request:ee.file?{file:ee.file,mode:ee.mode,line:ee.line,token:Q}:null})),d(Et.projectFiles),!0},e[29]=w,e[30]=d,e[31]=c,e[32]=F):F=e[32];const z=F;let B,U;e[33]!==z?(B=()=>XF(z),U=[z],e[33]=z,e[34]=B,e[35]=U):(B=e[34],U=e[35]),y.useEffect(B,U);let W;e[36]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{y.startTransition(()=>h(null))},e[36]=W):W=e[36];const V=W,H=!!(w&&u===Et.projectFiles),K=k==null?void 0:k.root,Z=(k==null?void 0:k.request)??null;let Y;return e[37]!==w||e[38]!==I||e[39]!==L||e[40]!==A||e[41]!==P||e[42]!==$||e[43]!==D||e[44]!==g||e[45]!==_||e[46]!==m||e[47]!==v||e[48]!==H||e[49]!==K||e[50]!==Z?(Y={processPanel:m,currentCwd:w,showPreview:v,showProjectFiles:H,projectFilesRoot:K,projectFilesRequest:Z,launchTerminalRequest:g,pendingProject:_,handleOpenTerminal:A,handleMcpAuth:I,handleToggleIntegratedTerminal:P,handleNewIntegratedTerminal:L,handleTogglePreview:$,handleToggleProjectFiles:D,closeRightWorkspace:V},e[37]=w,e[38]=I,e[39]=L,e[40]=A,e[41]=P,e[42]=$,e[43]=D,e[44]=g,e[45]=_,e[46]=m,e[47]=v,e[48]=H,e[49]=K,e[50]=Z,e[51]=Y):Y=e[51],Y}function Ixe(n){return n+1}function Pxe(n){return n+1}function $xe(n){return n.type==="terminal"}function Rxe(n){const e=n.replace(/<[^>]+>[\s\S]*?<\/[^>]+>/g,"").trim();if(!e)return"";const t=e.split(`
|
|
477
|
-
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const Oxe={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function fI(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:an(n.dirName)}}function Lxe(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...Oxe},rawMessages:[],agentKind:an(n.dirName)}}function mI(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ta(Kf(n),Vr(e).instanceId)}}catch{return null}}async function Mxe(n,e,t=3,s=100,r=!0){if(r){const o=mI(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ee(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:ta(Kf(l),Vr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function zxe(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await Mxe(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:fI(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function Dxe(n,e,t,s,r){const o=mI(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??Lxe(n),c=fI(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),zxe(n,e,t,i),n.sessionId}function Fxe(n){return n.access?n.access.mine:!0}async function Uxe(n,e,t,s){const r=Hr(),o=await Ee(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();ra(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&Fxe(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function Bxe({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),k=y.useRef(null),j=y.useCallback((C,A)=>{v.current=C,k.current=A??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:A,isMobile:t})},[e,t]),_=y.useCallback(async(C,A)=>{var $;const T=v.current;if(!T)return null;const I=an(T),E=k.current;($=w.current)==null||$.abort();const P=new AbortController;w.current=P,p(!0),g(null),r==null||r(C);const R=Date.now(),L=Rxe(C);async function O(M){v.current=null,k.current=null,M4(M.sessionId);const D=await Dxe(M,P,e,t,s);return L&&D&&U4(D,L),D}try{const M=yn(I),{capabilities:D}=M,F={dirName:T,cwd:M.dirName.lossy?E??void 0:void 0,message:C,images:A,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:D.ultracode&&d?!0:void 0,name:D.namedSessions&&L||void 0,worktreeName:D.worktrees&&x?T8(C):void 0,mcpConfig:D.mcp&&f||void 0},{res:z,errorMessage:B,errorCode:U}=await qA(W=>Ee("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:W}),signal:P.signal}),{model:i,agentKind:I,errorFallback:"Unknown error",onModelRejected:o});if(!z.ok){if(I==="codex"&&U!=="SESSION_UNCONFIRMED"){const W=await Uxe(T,C,R,P);if(W)return await O(W)}return g(B||`Failed to create session (${z.status})`),null}return await O(await z.json())}catch(M){return P.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{P.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,k.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:j,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function Wxe(n){const e=q.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{var H;(H=g.current)==null||H.call(g,V),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let k;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(k={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=k):k=e[11];const j=Bxe(k),_=j.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const A=y.useRef(C),T=qxe;let I;e[13]===Symbol.for("react.memo_cache_sentinel")?(I=async V=>{if(tu===null)return null;const H=A.current;if(H.has(V))return H.get(V)??null;const K=M$(await T(),V,tu);return H.set(V,K),K},e[13]=I):I=e[13];const E=I;let P;e[14]!==_?(P=async(V,H)=>{var X;const K=H??((X=(await T()).find(ee=>ee.dirName===V))==null?void 0:X.path)??null;if(!K){S(null),_(V);return}if(Vr(V).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(V,K);return}const Z=an(V)===tu?tu:null,Y=Z?Dm(Z,K):await E(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:V,K)},e[14]=_,e[15]=P):P=e[15];const R=P;let L;e[16]!==o||e[17]!==R?(L=V=>{const H=Dm(o,V);R(H,V)},e[16]=o,e[17]=R,e[18]=L):L=e[18];const O=L;let $;e[19]!==_||e[20]!==N?($=V=>{if(!N)return;const H=Dm(V,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=$):$=e[21];const M=$;let D;e:{if(!j.creatingSession||!i){D=null;break e}const V=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==V?(H={dirName:i,cwd:l,firstMessage:V},e[22]=l,e[23]=i,e[24]=V,e[25]=H):H=e[25],D=H}const F=D;let z,B;e[26]!==i?(B=()=>{i||(w(null),S(null))},z=[i],e[26]=i,e[27]=z,e[28]=B):(z=e[27],B=e[28]),y.useEffect(B,z);const U=N?M:void 0;let W;return e[29]!==O||e[30]!==R||e[31]!==j.cancelCreation||e[32]!==j.clearCreateError||e[33]!==j.createAndSend||e[34]!==j.createError||e[35]!==j.creatingSession||e[36]!==j.setWorktreeEnabled||e[37]!==j.worktreeEnabled||e[38]!==F||e[39]!==U?(W={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:F,pendingAgentKindChange:U,handleStartNewSession:R,handleStartNewFolder:O},e[29]=O,e[30]=R,e[31]=j.cancelCreation,e[32]=j.clearCreateError,e[33]=j.createAndSend,e[34]=j.createError,e[35]=j.creatingSession,e[36]=j.setWorktreeEnabled,e[37]=j.worktreeEnabled,e[38]=F,e[39]=U,e[40]=W):W=e[40],W}async function qxe(){try{const n=await Ee("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const eg=new Set;function Vxe(n,e){const t=Jt(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function Hxe(n,e,t){const s=Vxe(n,e);if(!eg.has(s)&&!Ss.get(n,e)){eg.add(s);try{await xa(n,e,t,"session prefetch",{background:!0})}catch{}finally{eg.delete(s)}}}function Kxe({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=Tr();y.useEffect(()=>{let w=!1;return l4().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),k=await v.json();v.ok&&k.valid?(yf(),l(""),o(""),n()):f(k.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Rs,{children:[a.jsxs(ur,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(m$,{className:"size-4"})}),a.jsx(dr,{children:"Sign in to Cogpit"}),a.jsx(fr,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Os,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Os,{className:"flex flex-col gap-4",children:[e&&a.jsxs(wt,{children:[a.jsx(uf,{"aria-hidden":"true"}),a.jsx(_t,{children:"This server has no accounts yet."})]}),a.jsxs(ka,{children:[h&&a.jsxs(sn,{children:[a.jsx(rn,{htmlFor:"login-username",children:"Username"}),a.jsx(zn,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(sn,{children:[a.jsx(rn,{htmlFor:"login-password",children:"Password"}),a.jsxs(qo,{children:[a.jsx(Vo,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(V1,{}):a.jsx(ba,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(wt,{variant:"destructive",children:[a.jsx(Vs,{"aria-hidden":"true"}),a.jsx(Vt,{children:"Sign in failed"}),a.jsx(_t,{children:d})]})]}),a.jsx(Ff,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function Gxe(){const n=q.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=vf(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let I=!1;return a4().then(E=>{I||r(E)}),()=>{I=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let I=!1;const E=u.current;return o8().then(P=>{!I&&u.current===E&&(i(P),c(!0))}),()=>{I=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.signIn)?(g=()=>{let I=!1;const E=()=>{const P=u.current=u.current+1,R=()=>{I||u.current!==P||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){R();return}Qv().then(L=>{I||u.current!==P||(r(L),L.signIn==="account"&&R())})};return window.addEventListener("cogpit-auth-required",E),()=>{I=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let k;n[11]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{r(await Qv())},n[11]=k):k=n[11];const j=k;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{xR(),u.current=u.current+1,i(!1),c(!0),i8().finally(Zxe)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,A=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==A?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:A,handleAuthenticated:v,refreshServerState:j,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=A,n[17]=T):T=n[17],T}function Zxe(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function Yxe(n){const e=q.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=La();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Bo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Dn,{variant:"icon",children:a.jsx(B1,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(En,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Tn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(_n,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(J,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(J,{variant:"outline",size:"sm",onClick:Xxe,children:[a.jsx(ig,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(J,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(p$,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(vc,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Xxe(){return Ks(Tt)}function Jxe(n){const e=q.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(h$,{className:"text-destructive"})}),a.jsx(En,{children:"Cogpit couldn’t finish loading"}),a.jsx(Tn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[s,a.jsx(vc,{className:"flex-row justify-center",children:a.jsxs(J,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const P1="cogpit:edition-ui-reloaded";let tg=null;function Qxe(){return tg??(tg=nt(()=>import("./edition-ui-hI8w0jpR.js"),__vite__mapDeps([41,1,2,28,3,4])).then(n=>n.default,n=>{throw tg=null,n})),tg}function e0e(){try{if(sessionStorage.getItem(P1)!==null)return!1;sessionStorage.setItem(P1,"1")}catch{return!1}return window.location.reload(),!0}function pI(){try{sessionStorage.removeItem(P1)}catch{}}async function t0e(n,e){let t;try{t=await Qxe()}catch{return e&&e0e()?"reloading":"failed"}return pI(),(t==null?void 0:t.edition)===n?t:null}async function hI(n,e,t){yR();const s=await t0e(n,t);s!=="reloading"&&(s==="failed"&&e?(pI(),SR()):s===null||s==="failed"?wR():vR(s))}async function n0e(n,{required:e=!1}={}){if(n==="personal")return;const t=Hl();t==="installed"||t==="loading"||t==="failed"||await hI(n,e,!0)}async function s0e(n){Hl()==="failed"&&await hI(n,!0,!1)}function uj(n){return n==="personal"?null:n}function r0e(n,e){const t=q.c(16),s=y.useSyncExternalStore(kx,Hl,Hl);let r;t[0]!==n?(r=uj(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??uj(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&n0e(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&s0e(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const gI={level:"own"},dj={level:"unknown"},o0e={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:gI};function i0e(n){const e=q.c(5),{enforcesSessionAccess:t}=C4(),s=t?n:null;let r;e[0]!==s?(r=()=>s?$R(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(OR,o,o);let l,c;return e[2]!==s?(l=()=>s?DR(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?dj:s?i?o0e[i]:dj:gI}function a0e({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:ga(n).canInteract?null:{kind:"view-only"}}function l0e(n){const e=q.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fd,{icon:ea,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=DO(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(fd,{icon:ea,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fd,{icon:x$,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fj,{icon:g$,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fj,{icon:ba,children:a.jsx(c0e,{})}),e[7]=s):s=e[7],s}}}function c0e(){const n=q.c(3),{ReadOnlyNote:e}=Tr(),{session:t}=yt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function fj(n){const e=q.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(u0e,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(fd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function u0e(){const n=q.c(7),{pendingInteraction:e,permissionRequests:t}=yt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx(kN,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(jN,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function fd(n){const e=q.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const d0e=y.lazy(()=>nt(()=>import("./index-D9cBiMbf.js"),__vite__mapDeps([42,1,2,3,4])).then(n=>({default:n.BranchModal}))),f0e=y.lazy(()=>nt(()=>import("./WorkflowsPanel-C1fYtY5J.js"),__vite__mapDeps([43,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function m0e(){window.location.reload()}function p0e(){var mv,pv,hv,gv,xv,bv,vv,yv,wv,Sv,kv,jv,Nv,Cv,_v,Ev,Tv,Av,Iv,Pv,$v,Rv,Ov,Lv,Mv,zv;const n=$b(window.location.pathname),e=H1e(),t=Gxe(),s=exe(t.edition),r=r0e(t.edition,s.edition),o=Tr(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=Ab(),f=YA(),[m,p]=VA(),{procBySession:h}=Nx(),{parse:g,append:x}=uI(),b=y.useCallback(Me=>{p({type:"SET_OLDER_TURNS",turns:Me})},[p]),w=y.useCallback((Me,at)=>{Hxe(Me,at,g)},[g]),v=dI({dirName:((mv=m.sessionSource)==null?void 0:mv.dirName)??null,fileName:((pv=m.sessionSource)==null?void 0:pv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:k}=v,j=!!m.searchQuery&&v.hasMore,_=((hv=m.session)==null?void 0:hv.turns.length)??0;y.useEffect(()=>{j&&k()},[j,k,_]);const N=vxe(m,p),S=y.useRef(null),C=y.useRef(null),[A,T]=y.useState(!1),[I,E]=y.useState(!1),P=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),R=y.useCallback(()=>T(!0),[]),L=y.useCallback(()=>{var Me;return(Me=C.current)==null?void 0:Me.focus()},[]),O=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),$=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),D=N.toggleWorkspacePanel,F=y.useCallback(()=>D(Et.sessionInfo),[D]),z=y.useCallback(Me=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[p]),B=m.pendingCwd??(m.pendingDirName?ms(m.pendingDirName):null),U=((gv=m.sessionSource)==null?void 0:gv.agentKind)??an(((xv=m.sessionSource)==null?void 0:xv.dirName)??m.pendingDirName??null),W=(bv=m.session)!=null&&bv.sessionId?h.get(m.session.sessionId):void 0,V=fn(U),H=v0(U,W),K=i0e(((vv=m.session)==null?void 0:vv.sessionId)??null),Z=ga(K.level),Y=V.worktrees,X=V.mcp&&l&&Z.mcp,ee=xxe(l?((yv=m.session)==null?void 0:yv.cwd)??B??void 0:void 0,l&&V.slashCommands),Q=y.useCallback(Me=>{if(!l)return;const at=ee.suggestions.find(cn=>cn.name===Me);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:at==null?void 0:at.filePath})})},[l,p,ee.suggestions]),ne=y.useCallback(async(Me,at)=>{if(!l)return null;const cn=ee.suggestions.find(Or=>Or.name===Me);if(!(cn!=null&&cn.filePath))return null;try{const Or=await Ee("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:cn.filePath,args:at||""})});return Or.ok?(await Or.json()).content??null:null}catch{return null}},[l,ee.suggestions]),te=N.openWorkspacePanel,re=y.useCallback(Me=>{te(Me),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[te,d,p]),oe=y.useCallback(()=>re(Et.crew),[re]),ie=N.activeWorkspacePanel===Et.crew&&(!d||m.mobileTab==="workspace"),{processPanel:ae,currentCwd:de,showPreview:le,showProjectFiles:se,projectFilesRoot:me,projectFilesRequest:ue,launchTerminalRequest:ce,pendingProject:xe,handleOpenTerminal:pe,handleMcpAuth:he,handleToggleIntegratedTerminal:be,handleNewIntegratedTerminal:we,handleTogglePreview:ve,handleToggleProjectFiles:Se,closeRightWorkspace:Te}=Axe({sessionId:(wv=m.session)==null?void 0:wv.sessionId,sessionCwd:(Sv=m.session)==null?void 0:Sv.cwd,pendingPath:B,sessionDirName:(kv=m.sessionSource)==null?void 0:kv.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:re,closeWorkspacePanel:N.closeWorkspacePanel}),Ae=mxe(m.session??null),[ze,De]=y.useState(!1),Le=((jv=m.sessionSource)==null?void 0:jv.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Ce,closeWorkspacePanel:Be,showWorkflows:We}=N,He=oxe(i&&Y&&m.mainView==="sessions"&&Ce===Et.worktrees?Le:null),_e=y.useMemo(()=>{const Me=m.session;return Me?Me.turns.some(at=>Fd(at.toolCalls,Me.cwd)||at.subAgentActivity.some(cn=>Fd(cn.toolCalls,Me.cwd))):!1},[m.session]),Re=y.useMemo(()=>{if(!m.session||!V.workflows)return 0;let Me=0;for(const at of m.session.turns)for(const cn of at.toolCalls)cn.name==="Workflow"&&Me++;return Me},[m.session,V.workflows]),tt=Re>0,Xe=y.useMemo(()=>{const Me=m.sessionSource;return!Me||!V.workflows||Io(Me.fileName)?{dirName:null,sessionId:null}:{dirName:Me.dirName,sessionId:vd(Me.fileName)}},[m.sessionSource,V.workflows]),Ne=Xge(Xe.dirName,Xe.sessionId,tt),Ve=tt||Ne.workflows.length>0,ye=Ne.workflows.length||Re,$e=N.setShowWorkflows,qe=y.useCallback(()=>$e(!0),[$e]),[Ke,fe]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Me=()=>{d?fe(!0):te(Et.fileChanges)};return window.addEventListener(tc,Me),()=>window.removeEventListener(tc,Me)},[c,te,d]);const ke=y.useMemo(()=>m.session?MC(m.session):null,[m.session]),Ge=y.useRef(null),{isLive:Je,sseState:rt,isCompacting:Kt,streamingOverlay:pn,turnError:$n,agentProgress:Xn,promptSuggestion:Rn,rateLimit:On}=BA(m.sessionSource,Me=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Me})})},g,x,()=>{var Me;return(Me=Ge.current)==null?void 0:Me.call(Ge)},m.session),Jn=gxe(((Nv=m.session)==null?void 0:Nv.cwd)??null),hn=k1e(U),$r=hn.setMode,wn=C1e(H?null:((Cv=m.session)==null?void 0:Cv.sessionId)??null),Es=H?null:wn.plan??ke,{contextWindowTokens:Ts,setContextWindowTokens:nr,contextWindowAvailable:sr,selectedModel:gs,setSelectedModel:rr,selectedEffort:vi,setSelectedEffort:za,fastModeEnabled:vI,ultracodeEnabled:yI,effectiveEffort:Vc,fastModeAvailable:wI,fastModeActive:Hc,setFastModeEnabled:_m,ultracodeAvailable:SI,ultracodeActive:Kc,setUltracodeEnabled:Em,imageInputAvailable:Rb,modelFallbackNotice:kI,dismissModelFallbackNotice:Ob,handleModelRejected:Lb}=jxe({agentKind:U,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:Je}),Mb=axe((_v=m.session)==null?void 0:_v.sessionId,(Ev=m.sessionSource)==null?void 0:Ev.fileName),Da=Exe({sessionKey:Mb,sessionId:((Tv=m.session)==null?void 0:Tv.sessionId)??null,access:K.level,values:{model:gs,effort:vi,contextWindowTokens:Ts,fastMode:vI,ultracode:yI,permissionMode:hn.config.mode},onHydrate:y.useCallback(Me=>{nr(Me.contextWindowTokens??null),Me.model!==void 0&&rr(Me.model),Me.effort!==void 0&&za(Me.effort),Me.fastMode!==void 0&&_m(Me.fastMode),Me.ultracode!==void 0&&Em(Me.ultracode),Me.permissionMode&&$r(Me.permissionMode)},[nr,rr,za,_m,Em,$r])}),zb=Da.picked.includes("permissionMode")?hn.config:void 0,cs=fxe(X?de:void 0,X?Le??void 0:void 0,X?Mb??void 0:void 0,X);y.useEffect(()=>{!Y&&Ce===Et.worktrees&&Be()},[Y,Ce,Be]),y.useEffect(()=>{We&&!Ve&&$e(!1)},[We,Ve,$e]);const{creatingSession:Db,createError:Fb,clearCreateError:jI,createAndSend:NI,cancelCreation:Ub,worktreeEnabled:CI,setWorktreeEnabled:_I,sessionFinalizedRef:Gc,liveSessionsRefreshRef:Bb,pendingSessionInfo:Wb,pendingAgentKindChange:EI,handleStartNewSession:qb,handleStartNewFolder:Vb}=Wxe({permissionsConfig:hn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:Lb,model:gs,effort:Vc,contextWindowTokens:sr?Ts:void 0,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null}),Lt=t1e({sessionSource:m.sessionSource,parsedSessionId:((Av=m.session)==null?void 0:Av.sessionId)??null,cwd:(Iv=m.session)==null?void 0:Iv.cwd,permissions:zb,onPermissionsApplied:hn.markApplied,settingsChange:Da.picked,onSettingsChangeSent:Da.settlePicked,model:gs,effort:Vc,contextWindowTokens:sr?Ts:void 0,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null,onModelRejected:Lb,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?NI:void 0}),Sn=Zge(V.agentTeams?((Pv=m.sessionSource)==null?void 0:Pv.fileName)??null:null,(($v=m.sessionSource)==null?void 0:$v.dirName)??null);y.useEffect(()=>{Sn!=null&&Sn.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:Sn.currentMemberName}):Sn||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Sn==null?void 0:Sn.currentMemberName,Sn,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const or=HA({session:m.session,isLive:Je,pendingMessages:Lt.pendingMessages,consumePending:Lt.consumePending,sessionChangeKey:m.sessionChangeKey,partialSignal:pn}),Hb=or.chatScrollRef,Kb=or.resetTurnCount,Gb=or.scrollToBottomInstant,TI=y.useCallback(Me=>{De(Me),requestAnimationFrame(()=>{const at=Hb.current;at&&at.scrollTo({top:at.scrollTop+(Me?64:-64),behavior:"smooth"})})},[Hb]);y.useLayoutEffect(()=>{const Me=at=>{Kb(0),Gb()};return Gc.current=Me,()=>{Gc.current===Me&&(Gc.current=null)}},[Kb,Gb,Gc]);const AI=y.useCallback(()=>{Lt.disconnect(),Ub()},[Lt.disconnect,Ub]),xs=r1e({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:Sn,scrollToBottomInstant:or.scrollToBottomInstant,resetTurnCount:or.resetTurnCount,workerParse:g,onBeforeSwitch:AI}),II=y.useCallback(Me=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[p,d]),{previewLoadError:PI}=l1e({state:m,dispatch:p,isMobile:d,resetTurnCount:or.resetTurnCount,scrollToBottomInstant:or.scrollToBottomInstant,workerParse:g}),Fa=h1e();b1e({openSessionId:(m.sessionSource&&rx(m.sessionSource.dirName,m.sessionSource.fileName))??((Rv=m.session)==null?void 0:Rv.sessionId)??null,leave:xs.handleCloseSession,forgetVisits:Fa.forget});const Zb=Fa.push;y.useEffect(()=>{m.sessionSource&&Zb(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,Zb]);const Mt=Sxe({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:xs.handleJumpToTurn,markPermissionsApplied:hn.markApplied,hasPermsPendingChanges:hn.hasPendingChanges,permissionsConfig:zb,settingsChange:Da.picked,onSettingsChangeSent:Da.settlePicked,selectedModel:gs,selectedEffort:Vc,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null,scrollRequestScrollToTop:or.requestScrollToTop,handleDashboardSelect:xs.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:Yb,handleApplySettings:Xb}=Mt,Jb=X&&cs.mcpConfigJson!==null,Qb=y.useRef(!1);y.useEffect(()=>{var cn;const Me=cs.loaded&&!Qb.current;Qb.current=cs.loaded;const at=(cn=m.session)==null?void 0:cn.sessionId;Me&&at&&Jb&&Yb&&Xb()},[cs.loaded,Jb,Yb,Xb,(Ov=m.session)==null?void 0:Ov.sessionId]),y.useLayoutEffect(()=>(Ge.current=Mt.reloadSession,()=>{Ge.current===Mt.reloadSession&&(Ge.current=null)}),[Mt.reloadSession]);const Rr=iI(m.session,m.sessionSource,Mt.reloadSession,c&&Z.undo),Zc=Rr.requestBranchSwitch,Yc=Mt.setBranchModalTurn,$I=y.useCallback((Me,at)=>{Zc(Me,at),Yc(null)},[Zc,Yc]),RI=y.useCallback(Me=>{Zc(Me),Yc(null)},[Zc,Yc]);d1e({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:F,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:R,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:pe,onToggleIntegratedTerminal:be,onTogglePreview:ve,onToggleProjectFiles:Se,onHistoryBack:Fa.goBack,onHistoryForward:Fa.goForward,onNavigateToSession:xs.handleDashboardSelect,onCommitNavigation:Fa.commitNavigation});const{killing:OI,handleKillAll:LI}=ixe(),ro=m.sessionSource?Io(m.sessionSource.fileName):null,MI=ro!==null&&!!(Sn!=null&&Sn.currentMemberName),Tm=ro!==null&&!MI,Xc=xs.handleDashboardSelect,ev=y.useCallback(()=>{!m.sessionSource||!ro||Xc(m.sessionSource.dirName,ro.parentFileName)},[m.sessionSource,ro,Xc]);y.useEffect(()=>{const Me=at=>{const{agentId:cn}=at.detail??{};if(!cn||!m.sessionSource||!V.subagentTranscripts)return;const Or=ro?ro.parentSessionId:vd(m.sessionSource.fileName);Xc(m.sessionSource.dirName,`${Or}/subagents/agent-${cn}.jsonl`)};return window.addEventListener(Ud,Me),()=>window.removeEventListener(Ud,Me)},[m.sessionSource,ro,Xc,V.subagentTranscripts]);const[zI,tv]=y.useState(null),DI=Mt.branchModalTurn!==null,yi=Mt.branchModalTurn??zI;y.useEffect(()=>{Mt.branchModalTurn!==null&&tv(Mt.branchModalTurn)},[Mt.branchModalTurn]);const nv=yi!==null?Rr.branchesAtTurn(yi):[];let wi=null;Tm?wi={kind:"subagent"}:H?wi={kind:"external",agentKind:U}:wi=a0e(K);const Am=wi&&a.jsx(l0e,{reason:wi}),oo=((Lv=m.session)==null?void 0:Lv.sessionId)??null,Si=oo!==null&&wi===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[FI,Im]=y.useState(null);y.useEffect(()=>{Im(null)},[oo,Si]);const sv=y.useCallback(()=>{Si&&Im(oo)},[oo,Si]),UI=y.useCallback(Me=>{Im(at=>Me?oo:at===oo?null:at)},[oo]),BI=xs.loadError||Fb||null;let Pm;xs.loadError?Pm=xs.clearLoadError:Fb&&(Pm=jI);const WI=!!(m.session&&m.sessionSource&&rt==="disconnected"),$m=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Rm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:Je,sseState:rt,isCompacting:Kt,turnError:$n,promptSuggestion:Rn,rateLimit:On,undoRedo:Rr,pendingInteraction:Es,permissionRequests:wn.requests,permissionResponding:wn.responding,respondPermission:wn.respond,respondAllPermissions:wn.respondAll,isSubAgentView:Tm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Mt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?Q:void 0,handleExpandCommand:l?ne:void 0,handleOpenBranches:Mt.handleOpenBranches,handleBranchFromHere:Mt.handleBranchFromHere,handleToggleExpandAll:P,handleLoadSession:Mt.handleLoadSessionScrollAware,handleProviderHandoff:Si?sv:void 0}}),[m.session,m.sessionSource,Je,rt,Kt,$n,Rn,On,Rr,Es,Tm,Z,wn.requests,wn.responding,wn.respond,wn.respondAll,ee.suggestions,ee.loading,Mt.handleStopSession,l,N.handleEditConfig,Q,ne,Mt.handleOpenBranches,Mt.handleBranchFromHere,P,Mt.handleLoadSessionScrollAware,Si,sv]),Om=y.useMemo(()=>({chat:{status:Lt.status,error:Lt.error,pendingMessages:Lt.pendingMessages,isConnected:Lt.isConnected,sendMessage:Lt.sendMessage,interrupt:Lt.interrupt,stopAgent:Lt.stopAgent,consumePending:Lt.consumePending},scroll:or}),[Lt.status,Lt.error,Lt.pendingMessages,Lt.isConnected,Lt.sendMessage,Lt.interrupt,Lt.stopAgent,Lt.consumePending,or]),Ua=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!Ua||d)return;const Me=requestAnimationFrame(()=>{var at;return(at=C.current)==null?void 0:at.focus()});return()=>cancelAnimationFrame(Me)},[Ua,d,m.pendingDirName]),r.failed)return a.jsx(Jxe,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Me=o.SetupScreen;return t.setupRequired&&Me?a.jsx(Me,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(Kxe,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Me=o.GateScreen??Yxe;return a.jsxs(a.Fragment,{children:[a.jsx(Me,{gate:s.gate,onRestored:m0e,onLogout:t.logout}),a.jsx(Sy,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:Ob,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(_r,{className:"text-destructive"})}),a.jsx(En,{children:"Failed to connect"}),a.jsx(Tn,{children:e.configError})]}),a.jsx(vc,{children:a.jsxs(J,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Kz,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Lm=a.jsx(Sy,{activeError:BI,clearActiveError:Pm,modelFallbackNotice:kI,dismissModelFallbackNotice:Ob,connectionLost:WI,theme:f.activeTheme}),rv=c?a.jsx(zz,{state:Rr.confirmState,isApplying:Rr.isApplying,applyError:Rr.applyError,onConfirm:Rr.confirmApply,onCancel:Rr.confirmCancel}):null,qI=yi!==null&&m.session?m.session.turns.slice(yi):[],ov=c&&yi!==null&&nv.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(d0e,{open:DI,branches:nv,branchPointTurnIndex:yi,currentTurns:qI,onClose:Mt.handleCloseBranchModal,onCloseComplete:()=>tv(null),onRedoToTurn:$I,onRedoEntireBranch:RI})}),iv=u&&a.jsx(_z,{processes:ae.processes,activeProcessId:ae.activeProcessId,collapsed:ae.collapsed,onSetActive:ae.setActive,onRemove:ae.removeProcess,onToggleCollapse:ae.toggleCollapse,onRequestTerminal:ht("terminal")?we:void 0,onAddTerminalContext:Me=>{var Dv,Fv,Uv;const at=Me.trim();if(!at)return;const cn=at.includes("```")?"````":"```",Or=`${cn}terminal
|
|
477
|
+
`)[0].trim();return t.length<=60?t:t.slice(0,57)+"..."}const Oxe={totalInputTokens:0,totalOutputTokens:0,totalCacheCreationTokens:0,totalCacheReadTokens:0,toolCallCounts:{},errorCount:0,totalDurationMs:0,turnCount:0};function fI(n,e){return{dirName:n.dirName,fileName:n.fileName,rawText:e,agentKind:an(n.dirName)}}function Lxe(n){return{sessionId:n.sessionId,version:"",gitBranch:"",cwd:"",slug:"",name:"",model:"",turns:[],stats:{...Oxe},rawMessages:[],agentKind:an(n.dirName)}}function mI(n,e){if(!(n!=null&&n.trim()))return null;try{return{rawText:n,parsed:ta(Kf(n),Vr(e).instanceId)}}catch{return null}}async function Mxe(n,e,t=3,s=100,r=!0){if(r){const o=mI(n.initialContent,n.dirName);if(o)return o}for(let o=0;o<t;o++){if(e.signal.aborted)throw new DOMException("Aborted","AbortError");const i=await Ee(`/api/sessions/${encodeURIComponent(n.dirName)}/${encodeURIComponent(n.fileName)}`,{signal:e.signal});if(i.ok){const l=await i.text();if(l.trim())try{return{rawText:l,parsed:ta(Kf(l),Vr(n.dirName).instanceId)}}catch{}}o<t-1&&await new Promise(l=>setTimeout(l,s))}return null}async function zxe(n,e,t,s){let r=s;for(let o=0;o<30;o++){if(e.signal.aborted)return;const i=await Mxe(n,e,1,0,!1);if(i&&i.rawText!==r){t({type:"RELOAD_SESSION_CONTENT",session:i.parsed,source:fI(n,i.rawText)});return}r=(i==null?void 0:i.rawText)??r,await new Promise(l=>setTimeout(l,200))}}async function Dxe(n,e,t,s,r){const o=mI(n.initialContent,n.dirName),i=(o==null?void 0:o.rawText)??"",l=(o==null?void 0:o.parsed)??Lxe(n),c=fI(n,i);return t({type:"FINALIZE_SESSION",session:l,source:c,isMobile:s}),r(l,c),zxe(n,e,t,i),n.sessionId}function Fxe(n){return n.access?n.access.mine:!0}async function Uxe(n,e,t,s){const r=Hr(),o=await Ee(`/api/sessions/${encodeURIComponent(n)}?page=1&limit=10`,{signal:s.signal});if(!o.ok)return null;const i=await o.json();ra(i.sessions??[],r);const l=t-3e4,c=e.trim(),u=(i.sessions??[]).filter(f=>{const m=f.lastModified?new Date(f.lastModified).getTime():0;return Number.isFinite(m)&&m>=l&&Fxe(f)}),d=u.find(f=>{var m,p;return((m=f.firstUserMessage)==null?void 0:m.trim())===c||((p=f.lastUserMessage)==null?void 0:p.trim())===c})??u[0];return d?{dirName:n,fileName:d.fileName,sessionId:d.sessionId}:null}function Bxe({permissionsConfig:n,dispatch:e,isMobile:t,onSessionFinalized:s,onCreateStarted:r,onModelRejected:o,model:i,effort:l,contextWindowTokens:c,fastMode:u,ultracode:d,mcpConfig:f}){const[m,p]=y.useState(!1),[h,g]=y.useState(null),[x,b]=y.useState(!1),w=y.useRef(null),v=y.useRef(null),k=y.useRef(null),j=y.useCallback((C,A)=>{v.current=C,k.current=A??null,g(null),p(!1),e({type:"INIT_PENDING_SESSION",dirName:C,cwd:A,isMobile:t})},[e,t]),_=y.useCallback(async(C,A)=>{var $;const T=v.current;if(!T)return null;const I=an(T),E=k.current;($=w.current)==null||$.abort();const P=new AbortController;w.current=P,p(!0),g(null),r==null||r(C);const R=Date.now(),L=Rxe(C);async function O(M){v.current=null,k.current=null,M4(M.sessionId);const D=await Dxe(M,P,e,t,s);return L&&D&&U4(D,L),D}try{const M=yn(I),{capabilities:D}=M,F={dirName:T,cwd:M.dirName.lossy?E??void 0:void 0,message:C,images:A,permissions:n,effort:l||void 0,contextWindowTokens:c,fastMode:u?!0:void 0,ultracode:D.ultracode&&d?!0:void 0,name:D.namedSessions&&L||void 0,worktreeName:D.worktrees&&x?T8(C):void 0,mcpConfig:D.mcp&&f||void 0},{res:z,errorMessage:B,errorCode:U}=await qA(W=>Ee("/api/create-and-send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...F,model:W}),signal:P.signal}),{model:i,agentKind:I,errorFallback:"Unknown error",onModelRejected:o});if(!z.ok){if(I==="codex"&&U!=="SESSION_UNCONFIRMED"){const W=await Uxe(T,C,R,P);if(W)return await O(W)}return g(B||`Failed to create session (${z.status})`),null}return await O(await z.json())}catch(M){return P.signal.aborted||g(M instanceof Error?M.message:"Failed to create session"),null}finally{P.signal.aborted||p(!1)}},[n,i,l,c,u,d,f,x,e,t,s,r,o]),N=y.useCallback(()=>g(null),[]),S=y.useCallback(()=>{var C;(C=w.current)==null||C.abort(),w.current=null,v.current=null,k.current=null,p(!1),g(null)},[]);return{creatingSession:m,createError:h,clearCreateError:N,handleNewSession:j,createAndSend:_,cancelCreation:S,worktreeEnabled:x,setWorktreeEnabled:b}}function Wxe(n){const e=q.c(41),{permissionsConfig:t,dispatch:s,isMobile:r,defaultAgentKind:o,pendingDirName:i,pendingCwd:l,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p,onModelRejected:h}=n,g=y.useRef(null),x=y.useRef(null),[b,w]=y.useState(null);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{var H;(H=g.current)==null||H.call(g,V),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},300),setTimeout(()=>{var K;return(K=x.current)==null?void 0:K.call(x)},2e3)},e[0]=v):v=e[0];let k;e[1]!==d||e[2]!==s||e[3]!==u||e[4]!==f||e[5]!==r||e[6]!==p||e[7]!==c||e[8]!==h||e[9]!==t||e[10]!==m?(k={permissionsConfig:t,dispatch:s,isMobile:r,onSessionFinalized:v,onCreateStarted:w,onModelRejected:h,model:c,effort:u,contextWindowTokens:d,fastMode:f,ultracode:m,mcpConfig:p},e[1]=d,e[2]=s,e[3]=u,e[4]=f,e[5]=r,e[6]=p,e[7]=c,e[8]=h,e[9]=t,e[10]=m,e[11]=k):k=e[11];const j=Bxe(k),_=j.handleNewSession,[N,S]=y.useState(null);let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=new Map,e[12]=C):C=e[12];const A=y.useRef(C),T=qxe;let I;e[13]===Symbol.for("react.memo_cache_sentinel")?(I=async V=>{if(tu===null)return null;const H=A.current;if(H.has(V))return H.get(V)??null;const K=M$(await T(),V,tu);return H.set(V,K),K},e[13]=I):I=e[13];const E=I;let P;e[14]!==_?(P=async(V,H)=>{var X;const K=H??((X=(await T()).find(ee=>ee.dirName===V))==null?void 0:X.path)??null;if(!K){S(null),_(V);return}if(Vr(V).instanceId!=="default"){S({discoveredDirName:null,cwd:K}),_(V,K);return}const Z=an(V)===tu?tu:null,Y=Z?Dm(Z,K):await E(K);S({discoveredDirName:Y,cwd:K}),_(Z&&Y?Y:V,K)},e[14]=_,e[15]=P):P=e[15];const R=P;let L;e[16]!==o||e[17]!==R?(L=V=>{const H=Dm(o,V);R(H,V)},e[16]=o,e[17]=R,e[18]=L):L=e[18];const O=L;let $;e[19]!==_||e[20]!==N?($=V=>{if(!N)return;const H=Dm(V,N.cwd,N.discoveredDirName??void 0);_(H,N.cwd)},e[19]=_,e[20]=N,e[21]=$):$=e[21];const M=$;let D;e:{if(!j.creatingSession||!i){D=null;break e}const V=b??void 0;let H;e[22]!==l||e[23]!==i||e[24]!==V?(H={dirName:i,cwd:l,firstMessage:V},e[22]=l,e[23]=i,e[24]=V,e[25]=H):H=e[25],D=H}const F=D;let z,B;e[26]!==i?(B=()=>{i||(w(null),S(null))},z=[i],e[26]=i,e[27]=z,e[28]=B):(z=e[27],B=e[28]),y.useEffect(B,z);const U=N?M:void 0;let W;return e[29]!==O||e[30]!==R||e[31]!==j.cancelCreation||e[32]!==j.clearCreateError||e[33]!==j.createAndSend||e[34]!==j.createError||e[35]!==j.creatingSession||e[36]!==j.setWorktreeEnabled||e[37]!==j.worktreeEnabled||e[38]!==F||e[39]!==U?(W={creatingSession:j.creatingSession,createError:j.createError,clearCreateError:j.clearCreateError,createAndSend:j.createAndSend,cancelCreation:j.cancelCreation,worktreeEnabled:j.worktreeEnabled,setWorktreeEnabled:j.setWorktreeEnabled,sessionFinalizedRef:g,liveSessionsRefreshRef:x,pendingSessionInfo:F,pendingAgentKindChange:U,handleStartNewSession:R,handleStartNewFolder:O},e[29]=O,e[30]=R,e[31]=j.cancelCreation,e[32]=j.clearCreateError,e[33]=j.createAndSend,e[34]=j.createError,e[35]=j.creatingSession,e[36]=j.setWorktreeEnabled,e[37]=j.worktreeEnabled,e[38]=F,e[39]=U,e[40]=W):W=e[40],W}async function qxe(){try{const n=await Ee("/api/projects");return n.ok?await n.json():[]}catch{return[]}}const eg=new Set;function Vxe(n,e){const t=Jt(),s=Zn();return`${s===null?t:`${t}:${s}`}:${n}/${e}`}async function Hxe(n,e,t){const s=Vxe(n,e);if(!eg.has(s)&&!Ss.get(n,e)){eg.add(s);try{await xa(n,e,t,"session prefetch",{background:!0})}catch{}finally{eg.delete(s)}}}function Kxe({onAuthenticated:n,setupRequired:e=!1}){const[t,s]=y.useState(null),[r,o]=y.useState(""),[i,l]=y.useState(""),[c,u]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(!1),h=t==="account",{LoginNotice:g}=Tr();y.useEffect(()=>{let w=!1;return l4().then(v=>{w||s(v)}),()=>{w=!0}},[]);const x=y.useCallback(async w=>{if(w.preventDefault(),!(!i.trim()||h&&!r.trim())){p(!0),f(null);try{const v=await fetch("/api/auth/verify",h?{method:"POST",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json","X-Cogpit-Client":"1"},body:JSON.stringify({username:r.trim(),password:i})}:{method:"POST",credentials:"same-origin",cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-Cogpit-Client":"1"}}),k=await v.json();v.ok&&k.valid?(yf(),l(""),o(""),n()):f(k.error||(h?"Invalid credentials":"Invalid password"))}catch{f("Failed to connect to server")}finally{p(!1)}}},[h,n,i,r]),b=m||!i.trim()||h&&!r.trim();return a.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-canvas px-4 py-8",children:a.jsx("form",{onSubmit:x,className:"w-full max-w-sm",children:a.jsxs(Rs,{children:[a.jsxs(ur,{children:[a.jsx("div",{className:"mb-2 flex size-9 items-center justify-center rounded-lg border bg-muted text-muted-foreground",children:a.jsx(m$,{className:"size-4"})}),a.jsx(dr,{children:"Sign in to Cogpit"}),a.jsx(fr,{children:h?"Sign in with your account to continue.":"Enter the server password to continue."})]}),t===null?a.jsx(Os,{children:a.jsx("div",{className:"flex min-h-24 items-center justify-center",role:"status","aria-label":"Checking server",children:a.jsx(Pn,{className:"size-5 text-muted-foreground"})})}):a.jsxs(a.Fragment,{children:[a.jsxs(Os,{className:"flex flex-col gap-4",children:[e&&a.jsxs(wt,{children:[a.jsx(uf,{"aria-hidden":"true"}),a.jsx(_t,{children:"This server has no accounts yet."})]}),a.jsxs(ka,{children:[h&&a.jsxs(sn,{children:[a.jsx(rn,{htmlFor:"login-username",children:"Username"}),a.jsx(zn,{id:"login-username",type:"text",value:r,onChange:w=>o(w.target.value),placeholder:"Username",autoComplete:"username",autoFocus:!0})]}),a.jsxs(sn,{children:[a.jsx(rn,{htmlFor:"login-password",children:"Password"}),a.jsxs(qo,{children:[a.jsx(Vo,{id:"login-password",type:c?"text":"password",value:i,onChange:w=>l(w.target.value),placeholder:"Password",autoComplete:"current-password",autoFocus:!h}),a.jsx(jr,{align:"inline-end",children:a.jsx(Uf,{size:"icon-xs",onClick:()=>u(w=>!w),"aria-label":c?"Hide password":"Show password",children:c?a.jsx(V1,{}):a.jsx(ba,{})})})]})]})]}),h&&g&&a.jsx(g,{}),d&&a.jsxs(wt,{variant:"destructive",children:[a.jsx(Vs,{"aria-hidden":"true"}),a.jsx(Vt,{children:"Sign in failed"}),a.jsx(_t,{children:d})]})]}),a.jsx(Ff,{children:a.jsxs(J,{type:"submit",className:"w-full",disabled:b,children:[m&&a.jsx(Pn,{"data-icon":"inline-start"}),"Connect"]})})]})]})})})}function Gxe(){const n=q.c(18);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=vf(),n[0]=e):e=n[0];const t=e,[s,r]=y.useState(null),[o,i]=y.useState(!1),[l,c]=y.useState(!1),u=y.useRef(0);let d,f;n[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{let I=!1;return a4().then(E=>{I||r(E)}),()=>{I=!0}},f=[],n[1]=d,n[2]=f):(d=n[1],f=n[2]),y.useEffect(d,f);const m=t?!0:s===null?null:s.signIn==="account";let p,h;n[3]!==m?(p=()=>{if(m===null)return;if(!m){i(!0),c(!0);return}let I=!1;const E=u.current;return o8().then(P=>{!I&&u.current===E&&(i(P),c(!0))}),()=>{I=!0}},h=[m],n[3]=m,n[4]=p,n[5]=h):(p=n[4],h=n[5]),y.useEffect(p,h);let g;n[6]!==(s==null?void 0:s.signIn)?(g=()=>{let I=!1;const E=()=>{const P=u.current=u.current+1,R=()=>{I||u.current!==P||(i(!1),c(!0))};if(t||(s==null?void 0:s.signIn)==="account"){R();return}Qv().then(L=>{I||u.current!==P||(r(L),L.signIn==="account"&&R())})};return window.addEventListener("cogpit-auth-required",E),()=>{I=!0,window.removeEventListener("cogpit-auth-required",E)}},n[6]=s==null?void 0:s.signIn,n[7]=g):g=n[7];const x=s==null?void 0:s.signIn;let b;n[8]!==x?(b=[x,t],n[8]=x,n[9]=b):b=n[9],y.useEffect(g,b);let w;n[10]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{u.current=u.current+1,i(!0),c(!0),window.dispatchEvent(new Event("cogpit-auth-changed"))},n[10]=w):w=n[10];const v=w;let k;n[11]===Symbol.for("react.memo_cache_sentinel")?(k=async()=>{r(await Qv())},n[11]=k):k=n[11];const j=k;let _;n[12]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{xR(),u.current=u.current+1,i(!1),c(!0),i8().finally(Zxe)},n[12]=_):_=n[12];const N=_,S=(s==null?void 0:s.edition)??null,C=l&&s!==null,A=(s==null?void 0:s.setupRequired)===!0;let T;return n[13]!==o||n[14]!==S||n[15]!==C||n[16]!==A?(T={isRemote:t,edition:S,authChecked:C,authenticated:o,setupRequired:A,handleAuthenticated:v,refreshServerState:j,logout:N},n[13]=o,n[14]=S,n[15]=C,n[16]=A,n[17]=T):T=n[17],T}function Zxe(){window.dispatchEvent(new Event("cogpit-auth-changed"))}function Yxe(n){const e=q.c(18),{onRestored:t,onLogout:s}=n,{activeDevice:r,activeDeviceId:o}=La();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Bo(),e[0]=i):i=e[0];const l=i,c=l?(r==null?void 0:r.name)??o:"This server";let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=a.jsx(Dn,{variant:"icon",children:a.jsx(B1,{className:"text-destructive"})}),e[1]=u):u=e[1];let d;e[2]!==c?(d=a.jsxs(En,{children:[c," isn’t available to your account right now"]}),e[2]=c,e[3]=d):d=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=a.jsx(Tn,{children:"Its administrator can let you back in. Check again once they have."}),e[4]=f):f=e[4];let m;e[5]!==d?(m=a.jsxs(_n,{children:[u,d,f]}),e[5]=d,e[6]=m):m=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=a.jsx(Fn,{"data-icon":"inline-start"}),e[7]=p):p=e[7];let h;e[8]!==t?(h=a.jsxs(J,{size:"sm",onClick:t,children:[p,"Check again"]}),e[8]=t,e[9]=h):h=e[9];let g;e[10]!==s?(g=l?a.jsxs(J,{variant:"outline",size:"sm",onClick:Xxe,children:[a.jsx(ig,{"data-icon":"inline-start"}),"Switch to this machine"]}):a.jsxs(J,{variant:"outline",size:"sm",onClick:s,children:[a.jsx(p$,{"data-icon":"inline-start"}),"Sign out"]}),e[10]=s,e[11]=g):g=e[11];let x;e[12]!==h||e[13]!==g?(x=a.jsxs(vc,{className:"flex-row justify-center",children:[h,g]}),e[12]=h,e[13]=g,e[14]=x):x=e[14];let b;return e[15]!==m||e[16]!==x?(b=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[m,x]})}),e[15]=m,e[16]=x,e[17]=b):b=e[17],b}function Xxe(){return Ks(Tt)}function Jxe(n){const e=q.c(4),{onRetry:t}=n;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(h$,{className:"text-destructive"})}),a.jsx(En,{children:"Cogpit couldn’t finish loading"}),a.jsx(Tn,{children:"Part of this server’s interface didn’t download. Check your connection and try again."})]}),e[0]=s):s=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(Fn,{"data-icon":"inline-start"}),e[1]=r):r=e[1];let o;return e[2]!==t?(o=a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[s,a.jsx(vc,{className:"flex-row justify-center",children:a.jsxs(J,{size:"sm",onClick:t,children:[r,"Retry"]})})]})}),e[2]=t,e[3]=o):o=e[3],o}const P1="cogpit:edition-ui-reloaded";let tg=null;function Qxe(){return tg??(tg=nt(()=>import("./edition-ui-xOZzffb-.js"),__vite__mapDeps([41,1,2,28,3,4])).then(n=>n.default,n=>{throw tg=null,n})),tg}function e0e(){try{if(sessionStorage.getItem(P1)!==null)return!1;sessionStorage.setItem(P1,"1")}catch{return!1}return window.location.reload(),!0}function pI(){try{sessionStorage.removeItem(P1)}catch{}}async function t0e(n,e){let t;try{t=await Qxe()}catch{return e&&e0e()?"reloading":"failed"}return pI(),(t==null?void 0:t.edition)===n?t:null}async function hI(n,e,t){yR();const s=await t0e(n,t);s!=="reloading"&&(s==="failed"&&e?(pI(),SR()):s===null||s==="failed"?wR():vR(s))}async function n0e(n,{required:e=!1}={}){if(n==="personal")return;const t=Hl();t==="installed"||t==="loading"||t==="failed"||await hI(n,e,!0)}async function s0e(n){Hl()==="failed"&&await hI(n,!0,!1)}function uj(n){return n==="personal"?null:n}function r0e(n,e){const t=q.c(16),s=y.useSyncExternalStore(kx,Hl,Hl);let r;t[0]!==n?(r=uj(n),t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==e||t[3]!==o?(i=o??uj(e),t[2]=e,t[3]=o,t[4]=i):i=t[4];const l=i,c=o!==null;let u,d;t[5]!==c||t[6]!==l?(u=()=>{l!==null&&n0e(l,{required:c})},d=[l,c],t[5]=c,t[6]=l,t[7]=u,t[8]=d):(u=t[7],d=t[8]),y.useEffect(u,d);let f;t[9]!==l?(f=()=>{l!==null&&s0e(l)},t[9]=l,t[10]=f):f=t[10];const m=f,p=s==="installed"||s==="unavailable",h=o===null||p,g=l===null||p,x=c&&s==="failed";let b;return t[11]!==m||t[12]!==h||t[13]!==g||t[14]!==x?(b={serverReady:h,ready:g,failed:x,retry:m},t[11]=m,t[12]=h,t[13]=g,t[14]=x,t[15]=b):b=t[15],b}const gI={level:"own"},dj={level:"unknown"},o0e={none:{level:"none"},view:{level:"view"},interact:{level:"interact"},own:gI};function i0e(n){const e=q.c(5),{enforcesSessionAccess:t}=C4(),s=t?n:null;let r;e[0]!==s?(r=()=>s?$R(s):void 0,e[0]=s,e[1]=r):r=e[1];const o=r,i=y.useSyncExternalStore(OR,o,o);let l,c;return e[2]!==s?(l=()=>s?DR(s):void 0,c=[s],e[2]=s,e[3]=l,e[4]=c):(l=e[3],c=e[4]),y.useEffect(l,c),t===null?dj:s?i?o0e[i]:dj:gI}function a0e({level:n}){return n==="unknown"?{kind:"checking"}:n==="none"?{kind:"no-access"}:ga(n).canInteract?null:{kind:"view-only"}}function l0e(n){const e=q.c(8),{reason:t}=n;switch(t.kind){case"subagent":{let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fd,{icon:ea,children:"Viewing sub-agent session (read-only)"}),e[0]=s):s=e[0],s}case"external":{let s;e[1]!==t.agentKind?(s=DO(t.agentKind),e[1]=t.agentKind,e[2]=s):s=e[2];let r;return e[3]!==s?(r=a.jsx(fd,{icon:ea,status:!0,children:s}),e[3]=s,e[4]=r):r=e[4],r}case"no-access":{let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fd,{icon:x$,status:!0,children:"You don't have access to this session"}),e[5]=s):s=e[5],s}case"checking":{let s;return e[6]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fj,{icon:g$,children:"Checking access…"}),e[6]=s):s=e[6],s}case"view-only":{let s;return e[7]===Symbol.for("react.memo_cache_sentinel")?(s=a.jsx(fj,{icon:ba,children:a.jsx(c0e,{})}),e[7]=s):s=e[7],s}}}function c0e(){const n=q.c(3),{ReadOnlyNote:e}=Tr(),{session:t}=yt();let s;return n[0]!==e||n[1]!==t?(s=e&&t?a.jsx(e,{sessionId:t.sessionId}):"View only",n[0]=e,n[1]=t,n[2]=s):s=n[2],s}function fj(n){const e=q.c(4),{icon:t,children:s}=n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=a.jsx(u0e,{}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==t?(o=a.jsxs("div",{className:"shrink-0",children:[r,a.jsx(fd,{icon:t,status:!0,children:s})]}),e[1]=s,e[2]=t,e[3]=o):o=e[3],o}function u0e(){const n=q.c(7),{pendingInteraction:e,permissionRequests:t}=yt(),s=(e==null?void 0:e.type)==="plan"?e:null;if(!s&&t.length===0)return null;let r;n[0]!==s?(r=s&&a.jsx(kN,{allowedPrompts:s.allowedPrompts,summary:s.summary,planContent:s.planContent}),n[0]=s,n[1]=r):r=n[1];let o;n[2]!==t?(o=t.length>0&&a.jsx("div",{className:"mb-2 overflow-hidden rounded-xl border border-warning/40 bg-popover",children:a.jsx(jN,{requests:t})}),n[2]=t,n[3]=o):o=n[3];let i;return n[4]!==r||n[5]!==o?(i=a.jsxs("div",{className:"px-3 pt-2",children:[r,o]}),n[4]=r,n[5]=o,n[6]=i):i=n[6],i}function fd(n){const e=q.c(8),{icon:t,status:s,children:r}=n,i=(s===void 0?!1:s)?"status":void 0;let l;e[0]!==t?(l=a.jsx(t,{"data-icon":"inline-start",className:"size-3.5 text-muted-foreground"}),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==r?(c=a.jsx("span",{className:"text-xs text-muted-foreground",children:r}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==l||e[6]!==c?(u=a.jsxs("div",{role:i,className:"flex shrink-0 items-center justify-center gap-2 border-t bg-card px-4 py-2.5",children:[l,c]}),e[4]=i,e[5]=l,e[6]=c,e[7]=u):u=e[7],u}const d0e=y.lazy(()=>nt(()=>import("./index-CFF4usU2.js"),__vite__mapDeps([42,1,2,3,4])).then(n=>({default:n.BranchModal}))),f0e=y.lazy(()=>nt(()=>import("./WorkflowsPanel-BkDClgyj.js"),__vite__mapDeps([43,1,4,2,3])).then(n=>({default:n.WorkflowsPanel})));function m0e(){window.location.reload()}function p0e(){var mv,pv,hv,gv,xv,bv,vv,yv,wv,Sv,kv,jv,Nv,Cv,_v,Ev,Tv,Av,Iv,Pv,$v,Rv,Ov,Lv,Mv,zv;const n=$b(window.location.pathname),e=H1e(),t=Gxe(),s=exe(t.edition),r=r0e(t.edition,s.edition),o=Tr(),i=s.checked&&(s.edition==="personal"||s.user!==null),l=i&&s.capabilities.configWrite,c=i&&s.capabilities.hostFiles,u=i&&s.capabilities.terminal,d=Ab(),f=YA(),[m,p]=VA(),{procBySession:h}=Nx(),{parse:g,append:x}=uI(),b=y.useCallback(Me=>{p({type:"SET_OLDER_TURNS",turns:Me})},[p]),w=y.useCallback((Me,at)=>{Hxe(Me,at,g)},[g]),v=dI({dirName:((mv=m.sessionSource)==null?void 0:mv.dirName)??null,fileName:((pv=m.sessionSource)==null?void 0:pv.fileName)??null,sessionChangeKey:m.sessionChangeKey,workerParse:g,onOlderTurns:b}),{loadMore:k}=v,j=!!m.searchQuery&&v.hasMore,_=((hv=m.session)==null?void 0:hv.turns.length)??0;y.useEffect(()=>{j&&k()},[j,k,_]);const N=vxe(m,p),S=y.useRef(null),C=y.useRef(null),[A,T]=y.useState(!1),[I,E]=y.useState(!1),P=y.useCallback(()=>p({type:"TOGGLE_EXPAND_ALL"}),[p]),R=y.useCallback(()=>T(!0),[]),L=y.useCallback(()=>{var Me;return(Me=C.current)==null?void 0:Me.focus()},[]),O=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!0}),[p]),$=y.useCallback(()=>p({type:"SET_EXPAND_TOOL_PAYLOADS",value:!0}),[p]),M=y.useCallback(()=>p({type:"SET_EXPAND_ALL",value:!1}),[p]),D=N.toggleWorkspacePanel,F=y.useCallback(()=>D(Et.sessionInfo),[D]),z=y.useCallback(Me=>{y.startTransition(()=>{p({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[p]),B=m.pendingCwd??(m.pendingDirName?ms(m.pendingDirName):null),U=((gv=m.sessionSource)==null?void 0:gv.agentKind)??an(((xv=m.sessionSource)==null?void 0:xv.dirName)??m.pendingDirName??null),W=(bv=m.session)!=null&&bv.sessionId?h.get(m.session.sessionId):void 0,V=fn(U),H=v0(U,W),K=i0e(((vv=m.session)==null?void 0:vv.sessionId)??null),Z=ga(K.level),Y=V.worktrees,X=V.mcp&&l&&Z.mcp,ee=xxe(l?((yv=m.session)==null?void 0:yv.cwd)??B??void 0:void 0,l&&V.slashCommands),Q=y.useCallback(Me=>{if(!l)return;const at=ee.suggestions.find(cn=>cn.name===Me);y.startTransition(()=>{p({type:"OPEN_CONFIG",filePath:at==null?void 0:at.filePath})})},[l,p,ee.suggestions]),ne=y.useCallback(async(Me,at)=>{if(!l)return null;const cn=ee.suggestions.find(Or=>Or.name===Me);if(!(cn!=null&&cn.filePath))return null;try{const Or=await Ee("/api/expand-command",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:cn.filePath,args:at||""})});return Or.ok?(await Or.json()).content??null:null}catch{return null}},[l,ee.suggestions]),te=N.openWorkspacePanel,re=y.useCallback(Me=>{te(Me),d&&p({type:"SET_MOBILE_TAB",tab:"workspace"})},[te,d,p]),oe=y.useCallback(()=>re(Et.crew),[re]),ie=N.activeWorkspacePanel===Et.crew&&(!d||m.mobileTab==="workspace"),{processPanel:ae,currentCwd:de,showPreview:le,showProjectFiles:se,projectFilesRoot:me,projectFilesRequest:ue,launchTerminalRequest:ce,pendingProject:xe,handleOpenTerminal:pe,handleMcpAuth:he,handleToggleIntegratedTerminal:be,handleNewIntegratedTerminal:we,handleTogglePreview:ve,handleToggleProjectFiles:Se,closeRightWorkspace:Te}=Axe({sessionId:(wv=m.session)==null?void 0:wv.sessionId,sessionCwd:(Sv=m.session)==null?void 0:Sv.cwd,pendingPath:B,sessionDirName:(kv=m.sessionSource)==null?void 0:kv.dirName,pendingDirName:m.pendingDirName,dashboardProject:m.dashboardProject,supportsFileWorkspace:c,activeWorkspacePanel:N.activeWorkspacePanel,openWorkspacePanel:re,closeWorkspacePanel:N.closeWorkspacePanel}),Ae=mxe(m.session??null),[ze,De]=y.useState(!1),Le=((jv=m.sessionSource)==null?void 0:jv.dirName)??m.pendingDirName??m.dashboardProject??null,{activeWorkspacePanel:Ce,closeWorkspacePanel:Be,showWorkflows:We}=N,He=oxe(i&&Y&&m.mainView==="sessions"&&Ce===Et.worktrees?Le:null),_e=y.useMemo(()=>{const Me=m.session;return Me?Me.turns.some(at=>Fd(at.toolCalls,Me.cwd)||at.subAgentActivity.some(cn=>Fd(cn.toolCalls,Me.cwd))):!1},[m.session]),Re=y.useMemo(()=>{if(!m.session||!V.workflows)return 0;let Me=0;for(const at of m.session.turns)for(const cn of at.toolCalls)cn.name==="Workflow"&&Me++;return Me},[m.session,V.workflows]),tt=Re>0,Xe=y.useMemo(()=>{const Me=m.sessionSource;return!Me||!V.workflows||Io(Me.fileName)?{dirName:null,sessionId:null}:{dirName:Me.dirName,sessionId:vd(Me.fileName)}},[m.sessionSource,V.workflows]),Ne=Xge(Xe.dirName,Xe.sessionId,tt),Ve=tt||Ne.workflows.length>0,ye=Ne.workflows.length||Re,$e=N.setShowWorkflows,qe=y.useCallback(()=>$e(!0),[$e]),[Ke,fe]=y.useState(!1);y.useEffect(()=>{if(!c)return;const Me=()=>{d?fe(!0):te(Et.fileChanges)};return window.addEventListener(tc,Me),()=>window.removeEventListener(tc,Me)},[c,te,d]);const ke=y.useMemo(()=>m.session?MC(m.session):null,[m.session]),Ge=y.useRef(null),{isLive:Je,sseState:rt,isCompacting:Kt,streamingOverlay:pn,turnError:$n,agentProgress:Xn,promptSuggestion:Rn,rateLimit:On}=BA(m.sessionSource,Me=>{y.startTransition(()=>{p({type:"UPDATE_SESSION",session:Me})})},g,x,()=>{var Me;return(Me=Ge.current)==null?void 0:Me.call(Ge)},m.session),Jn=gxe(((Nv=m.session)==null?void 0:Nv.cwd)??null),hn=k1e(U),$r=hn.setMode,wn=C1e(H?null:((Cv=m.session)==null?void 0:Cv.sessionId)??null),Es=H?null:wn.plan??ke,{contextWindowTokens:Ts,setContextWindowTokens:nr,contextWindowAvailable:sr,selectedModel:gs,setSelectedModel:rr,selectedEffort:vi,setSelectedEffort:za,fastModeEnabled:vI,ultracodeEnabled:yI,effectiveEffort:Vc,fastModeAvailable:wI,fastModeActive:Hc,setFastModeEnabled:_m,ultracodeAvailable:SI,ultracodeActive:Kc,setUltracodeEnabled:Em,imageInputAvailable:Rb,modelFallbackNotice:kI,dismissModelFallbackNotice:Ob,handleModelRejected:Lb}=jxe({agentKind:U,session:m.session,sessionSource:m.sessionSource,pendingDirName:m.pendingDirName,isLive:Je}),Mb=axe((_v=m.session)==null?void 0:_v.sessionId,(Ev=m.sessionSource)==null?void 0:Ev.fileName),Da=Exe({sessionKey:Mb,sessionId:((Tv=m.session)==null?void 0:Tv.sessionId)??null,access:K.level,values:{model:gs,effort:vi,contextWindowTokens:Ts,fastMode:vI,ultracode:yI,permissionMode:hn.config.mode},onHydrate:y.useCallback(Me=>{nr(Me.contextWindowTokens??null),Me.model!==void 0&&rr(Me.model),Me.effort!==void 0&&za(Me.effort),Me.fastMode!==void 0&&_m(Me.fastMode),Me.ultracode!==void 0&&Em(Me.ultracode),Me.permissionMode&&$r(Me.permissionMode)},[nr,rr,za,_m,Em,$r])}),zb=Da.picked.includes("permissionMode")?hn.config:void 0,cs=fxe(X?de:void 0,X?Le??void 0:void 0,X?Mb??void 0:void 0,X);y.useEffect(()=>{!Y&&Ce===Et.worktrees&&Be()},[Y,Ce,Be]),y.useEffect(()=>{We&&!Ve&&$e(!1)},[We,Ve,$e]);const{creatingSession:Db,createError:Fb,clearCreateError:jI,createAndSend:NI,cancelCreation:Ub,worktreeEnabled:CI,setWorktreeEnabled:_I,sessionFinalizedRef:Gc,liveSessionsRefreshRef:Bb,pendingSessionInfo:Wb,pendingAgentKindChange:EI,handleStartNewSession:qb,handleStartNewFolder:Vb}=Wxe({permissionsConfig:hn.config,dispatch:p,isMobile:d,defaultAgentKind:e.defaultAgentKind,pendingDirName:m.pendingDirName,pendingCwd:m.pendingCwd,onModelRejected:Lb,model:gs,effort:Vc,contextWindowTokens:sr?Ts:void 0,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null}),Lt=t1e({sessionSource:m.sessionSource,parsedSessionId:((Av=m.session)==null?void 0:Av.sessionId)??null,cwd:(Iv=m.session)==null?void 0:Iv.cwd,permissions:zb,onPermissionsApplied:hn.markApplied,settingsChange:Da.picked,onSettingsChangeSent:Da.settlePicked,model:gs,effort:Vc,contextWindowTokens:sr?Ts:void 0,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null,onModelRejected:Lb,readOnly:H||!Z.send,onCreateSession:m.pendingDirName?NI:void 0}),Sn=Zge(V.agentTeams?((Pv=m.sessionSource)==null?void 0:Pv.fileName)??null:null,(($v=m.sessionSource)==null?void 0:$v.dirName)??null);y.useEffect(()=>{Sn!=null&&Sn.currentMemberName?p({type:"SET_CURRENT_MEMBER_NAME",name:Sn.currentMemberName}):Sn||p({type:"SET_CURRENT_MEMBER_NAME",name:null})},[Sn==null?void 0:Sn.currentMemberName,Sn,p]),y.useEffect(()=>{d&&p({type:"GUARD_MOBILE_TAB",hasSession:!!m.session||!!m.pendingDirName})},[m.session,m.pendingDirName,m.mobileTab,d,p]);const or=HA({session:m.session,isLive:Je,pendingMessages:Lt.pendingMessages,consumePending:Lt.consumePending,sessionChangeKey:m.sessionChangeKey,partialSignal:pn}),Hb=or.chatScrollRef,Kb=or.resetTurnCount,Gb=or.scrollToBottomInstant,TI=y.useCallback(Me=>{De(Me),requestAnimationFrame(()=>{const at=Hb.current;at&&at.scrollTo({top:at.scrollTop+(Me?64:-64),behavior:"smooth"})})},[Hb]);y.useLayoutEffect(()=>{const Me=at=>{Kb(0),Gb()};return Gc.current=Me,()=>{Gc.current===Me&&(Gc.current=null)}},[Kb,Gb,Gc]);const AI=y.useCallback(()=>{Lt.disconnect(),Ub()},[Lt.disconnect,Ub]),xs=r1e({dispatch:p,isMobile:d,mobileTab:m.mobileTab,teamContext:Sn,scrollToBottomInstant:or.scrollToBottomInstant,resetTurnCount:or.resetTurnCount,workerParse:g,onBeforeSwitch:AI}),II=y.useCallback(Me=>{y.startTransition(()=>{p({type:"GO_HOME",isMobile:d}),p({type:"SET_DASHBOARD_PROJECT",dirName:Me})})},[p,d]),{previewLoadError:PI}=l1e({state:m,dispatch:p,isMobile:d,resetTurnCount:or.resetTurnCount,scrollToBottomInstant:or.scrollToBottomInstant,workerParse:g}),Fa=h1e();b1e({openSessionId:(m.sessionSource&&rx(m.sessionSource.dirName,m.sessionSource.fileName))??((Rv=m.session)==null?void 0:Rv.sessionId)??null,leave:xs.handleCloseSession,forgetVisits:Fa.forget});const Zb=Fa.push;y.useEffect(()=>{m.sessionSource&&Zb(m.sessionSource.dirName,m.sessionSource.fileName)},[m.sessionSource,Zb]);const Mt=Sxe({state:{session:m.session,sessionSource:m.sessionSource},dispatch:p,isMobile:d,handleJumpToTurn:xs.handleJumpToTurn,markPermissionsApplied:hn.markApplied,hasPermsPendingChanges:hn.hasPendingChanges,permissionsConfig:zb,settingsChange:Da.picked,onSettingsChangeSent:Da.settlePicked,selectedModel:gs,selectedEffort:Vc,fastMode:Hc,ultracode:Kc,mcpConfig:X?cs.mcpConfigJson:null,scrollRequestScrollToTop:or.requestScrollToTop,handleDashboardSelect:xs.handleDashboardSelect,workerParse:g,canInteract:Z.canInteract}),{hasSettingsChanges:Yb,handleApplySettings:Xb}=Mt,Jb=X&&cs.mcpConfigJson!==null,Qb=y.useRef(!1);y.useEffect(()=>{var cn;const Me=cs.loaded&&!Qb.current;Qb.current=cs.loaded;const at=(cn=m.session)==null?void 0:cn.sessionId;Me&&at&&Jb&&Yb&&Xb()},[cs.loaded,Jb,Yb,Xb,(Ov=m.session)==null?void 0:Ov.sessionId]),y.useLayoutEffect(()=>(Ge.current=Mt.reloadSession,()=>{Ge.current===Mt.reloadSession&&(Ge.current=null)}),[Mt.reloadSession]);const Rr=iI(m.session,m.sessionSource,Mt.reloadSession,c&&Z.undo),Zc=Rr.requestBranchSwitch,Yc=Mt.setBranchModalTurn,$I=y.useCallback((Me,at)=>{Zc(Me,at),Yc(null)},[Zc,Yc]),RI=y.useCallback(Me=>{Zc(Me),Yc(null)},[Zc,Yc]);d1e({isMobile:d,searchInputRef:S,chatInputRef:C,dispatch:p,onToggleSidebar:N.handleToggleSidebar,onToggleRightSidebar:F,onToggleMissionControl:N.handleToggleMission,onOpenCommandPalette:R,onOpenProjectSwitcher:N.handleOpenProjectSwitcher,onOpenThemeSelector:N.handleToggleThemeSelector,onOpenTerminal:pe,onToggleIntegratedTerminal:be,onTogglePreview:ve,onToggleProjectFiles:Se,onHistoryBack:Fa.goBack,onHistoryForward:Fa.goForward,onNavigateToSession:xs.handleDashboardSelect,onCommitNavigation:Fa.commitNavigation});const{killing:OI,handleKillAll:LI}=ixe(),ro=m.sessionSource?Io(m.sessionSource.fileName):null,MI=ro!==null&&!!(Sn!=null&&Sn.currentMemberName),Tm=ro!==null&&!MI,Xc=xs.handleDashboardSelect,ev=y.useCallback(()=>{!m.sessionSource||!ro||Xc(m.sessionSource.dirName,ro.parentFileName)},[m.sessionSource,ro,Xc]);y.useEffect(()=>{const Me=at=>{const{agentId:cn}=at.detail??{};if(!cn||!m.sessionSource||!V.subagentTranscripts)return;const Or=ro?ro.parentSessionId:vd(m.sessionSource.fileName);Xc(m.sessionSource.dirName,`${Or}/subagents/agent-${cn}.jsonl`)};return window.addEventListener(Ud,Me),()=>window.removeEventListener(Ud,Me)},[m.sessionSource,ro,Xc,V.subagentTranscripts]);const[zI,tv]=y.useState(null),DI=Mt.branchModalTurn!==null,yi=Mt.branchModalTurn??zI;y.useEffect(()=>{Mt.branchModalTurn!==null&&tv(Mt.branchModalTurn)},[Mt.branchModalTurn]);const nv=yi!==null?Rr.branchesAtTurn(yi):[];let wi=null;Tm?wi={kind:"subagent"}:H?wi={kind:"external",agentKind:U}:wi=a0e(K);const Am=wi&&a.jsx(l0e,{reason:wi}),oo=((Lv=m.session)==null?void 0:Lv.sessionId)??null,Si=oo!==null&&wi===null&&m.mainView==="sessions"&&(!d||m.mobileTab==="chat"),[FI,Im]=y.useState(null);y.useEffect(()=>{Im(null)},[oo,Si]);const sv=y.useCallback(()=>{Si&&Im(oo)},[oo,Si]),UI=y.useCallback(Me=>{Im(at=>Me?oo:at===oo?null:at)},[oo]),BI=xs.loadError||Fb||null;let Pm;xs.loadError?Pm=xs.clearLoadError:Fb&&(Pm=jI);const WI=!!(m.session&&m.sessionSource&&rt==="disconnected"),$m=y.useMemo(()=>({state:m,dispatch:p,config:e,theme:f,isMobile:d}),[m.activeTurnIndex,m.activeToolCallId,m.searchQuery,m.expandAll,m.expandToolPayloads,m.mainView,m.extensionViewId,m.mobileTab,m.dashboardProject,m.pendingDirName,m.pendingCwd,m.currentMemberName,m.loadingMember,m.configFilePath,m.sessionChangeKey,p,e,f,d]),Rm=y.useMemo(()=>({session:m.session,sessionSource:m.sessionSource,isLive:Je,sseState:rt,isCompacting:Kt,turnError:$n,promptSuggestion:Rn,rateLimit:On,undoRedo:Rr,pendingInteraction:Es,permissionRequests:wn.requests,permissionResponding:wn.responding,respondPermission:wn.respond,respondAllPermissions:wn.respondAll,isSubAgentView:Tm,permissions:Z,slashSuggestions:ee.suggestions,slashSuggestionsLoading:ee.loading,actions:{handleStopSession:Mt.handleStopSession,handleEditConfig:l?N.handleEditConfig:void 0,handleEditCommand:l?Q:void 0,handleExpandCommand:l?ne:void 0,handleOpenBranches:Mt.handleOpenBranches,handleBranchFromHere:Mt.handleBranchFromHere,handleToggleExpandAll:P,handleLoadSession:Mt.handleLoadSessionScrollAware,handleProviderHandoff:Si?sv:void 0}}),[m.session,m.sessionSource,Je,rt,Kt,$n,Rn,On,Rr,Es,Tm,Z,wn.requests,wn.responding,wn.respond,wn.respondAll,ee.suggestions,ee.loading,Mt.handleStopSession,l,N.handleEditConfig,Q,ne,Mt.handleOpenBranches,Mt.handleBranchFromHere,P,Mt.handleLoadSessionScrollAware,Si,sv]),Om=y.useMemo(()=>({chat:{status:Lt.status,error:Lt.error,pendingMessages:Lt.pendingMessages,isConnected:Lt.isConnected,sendMessage:Lt.sendMessage,interrupt:Lt.interrupt,stopAgent:Lt.stopAgent,consumePending:Lt.consumePending},scroll:or}),[Lt.status,Lt.error,Lt.pendingMessages,Lt.isConnected,Lt.sendMessage,Lt.interrupt,Lt.stopAgent,Lt.consumePending,or]),Ua=!!m.pendingDirName&&!m.session;if(y.useEffect(()=>{if(!Ua||d)return;const Me=requestAnimationFrame(()=>{var at;return(at=C.current)==null?void 0:at.focus()});return()=>cancelAnimationFrame(Me)},[Ua,d,m.pendingDirName]),r.failed)return a.jsx(Jxe,{onRetry:r.retry});if(!t.authChecked||!r.serverReady)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Checking authentication",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(!t.authenticated){const Me=o.SetupScreen;return t.setupRequired&&Me?a.jsx(Me,{onAuthenticated:t.handleAuthenticated,onSetupClosed:t.refreshServerState}):a.jsx(Kxe,{onAuthenticated:t.handleAuthenticated,setupRequired:t.setupRequired})}if(!i||!r.ready)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading identity",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(s.gate){const Me=o.GateScreen??Yxe;return a.jsxs(a.Fragment,{children:[a.jsx(Me,{gate:s.gate,onRestored:m0e,onLogout:t.logout}),a.jsx(Sy,{activeError:null,modelFallbackNotice:null,dismissModelFallbackNotice:Ob,connectionLost:!1,theme:f.activeTheme})]})}if(e.configLoading)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas",role:"status","aria-label":"Loading",children:a.jsx(vt,{"data-icon":"inline-start",className:"size-6 animate-spin text-muted-foreground"})});if(e.configError)return a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-foreground",children:a.jsxs(Cn,{children:[a.jsxs(_n,{children:[a.jsx(Dn,{variant:"icon",children:a.jsx(_r,{className:"text-destructive"})}),a.jsx(En,{children:"Failed to connect"}),a.jsx(Tn,{children:e.configError})]}),a.jsx(vc,{children:a.jsxs(J,{variant:"outline",size:"sm",onClick:e.retryConfig,children:[a.jsx(Fn,{"data-icon":"inline-start"}),"Retry"]})})]})});if(!e.claudeDir)return l?a.jsx(Kz,{onConfigured:e.setClaudeDir}):a.jsx("div",{className:"dark flex h-dvh items-center justify-center bg-canvas text-sm text-muted-foreground",children:"Cogpit is waiting for an administrator to finish server setup."});const Lm=a.jsx(Sy,{activeError:BI,clearActiveError:Pm,modelFallbackNotice:kI,dismissModelFallbackNotice:Ob,connectionLost:WI,theme:f.activeTheme}),rv=c?a.jsx(zz,{state:Rr.confirmState,isApplying:Rr.isApplying,applyError:Rr.applyError,onConfirm:Rr.confirmApply,onCancel:Rr.confirmCancel}):null,qI=yi!==null&&m.session?m.session.turns.slice(yi):[],ov=c&&yi!==null&&nv.length>0&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(d0e,{open:DI,branches:nv,branchPointTurnIndex:yi,currentTurns:qI,onClose:Mt.handleCloseBranchModal,onCloseComplete:()=>tv(null),onRedoToTurn:$I,onRedoEntireBranch:RI})}),iv=u&&a.jsx(_z,{processes:ae.processes,activeProcessId:ae.activeProcessId,collapsed:ae.collapsed,onSetActive:ae.setActive,onRemove:ae.removeProcess,onToggleCollapse:ae.toggleCollapse,onRequestTerminal:ht("terminal")?we:void 0,onAddTerminalContext:Me=>{var Dv,Fv,Uv;const at=Me.trim();if(!at)return;const cn=at.includes("```")?"````":"```",Or=`${cn}terminal
|
|
478
478
|
${at}
|
|
479
479
|
${cn}`,Mm=((Dv=C.current)==null?void 0:Dv.getText().trimEnd())??"";(Fv=C.current)==null||Fv.setText(Mm?`${Mm}
|
|
480
480
|
|